Code Monkey home page Code Monkey logo

Comments (2)

nguyenthanhvuh avatar nguyenthanhvuh commented on June 9, 2024

x1 and x2 are unbounds and so generate too many large traces with terms like 16*x1*x1*x2*x2. Here's a fix (add bounds to x1 and x2) and also an improved version (use more terms)

#include <stdio.h>
#include <stdlib.h>

void vassume(int b) {}
void vtrace(int g, int h, int x, int y) {}
void vtrace1(int f_x_f_x, int f_y_f_x, int f_y_f_y, int f_x1_f_x2) {}

// f(x) = x(x + 1)
int F(int x) { return x * x; }

void mainQ(int x1, int x2) {
  vassume(-20 < x1); vassume(x1 < 20);
  vassume(-20 < x2); vassume(x2 < 20);
  
  int x = x1 + x2;
  int y = x1 - x2;
  int f_x = F(x);
  int f_y = F(y);
  int f_x1 = F(x1);
  int f_x2 = F(x2);

  int myg = f_x*f_x - 2*f_y*f_x + f_y*f_y;
  int myh = f_x1*f_x2;
  vtrace(myg, myh, x, y); // <--------------------------HERE


  int f_x_f_x = f_x*f_x;
  int f_y_f_x = f_y*f_x;
  int f_y_f_y = f_y*f_y;
  int f_x1_f_x2 = f_x1*f_x2;

  vtrace1(f_x_f_x,f_y_f_x,f_y_f_y,f_x1_f_x2);
}

void main(int argc, char *argv[]) {
  mainQ(atoi(argv[1]), atoi(argv[2]));
}
tnguyen@DynaROARS ~/g/d/src (dev)> time ~/miniconda3/bin/python3 -O dig.py  ../tests/t2.c --maxdeg 1 --noss --noieq --nocong --nominmax                                               (base) 
settings:INFO:2023-05-22 13:54:58.882998: dig.py ../tests/t2.c --maxdeg 1 --noss --noieq --nocong --nominmax
alg:INFO:analyzing '../tests/t2.c'
alg:INFO:analyzing '../tests/t2.c'
alg:INFO:got 152 traces over 2 locs
alg:INFO:check 2 invs using 152 traces (0.03s)
alg:INFO:simplify 2 invs (0.01s)
tmpdir: /var/tmp/dig_2029142113675619442_wwoafspq
vtrace (1 invs):
1. -g + 16*h == 0
vtrace1 (1 invs):
1. 16*f_x1_f_x2 - f_x_f_x + 2*f_y_f_x - f_y_f_y == 0

from dig.

nguyenthanhvuh avatar nguyenthanhvuh commented on June 9, 2024

also fix a bug with abs here c31dc37. The bug is forgetting to filter out very large negative traces and therefore screw things up.

Still cannot get g=16*h sometimes because linsolve cannot get the correct coefs in the first place

from dig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.