resess / ardiff Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi, sir
I noticed that the dataset does not contain code for two-dimensional arrays.
Does ARDiff support code equivalence determination for codes that contain 2-dimensional arrays?
Thanks.
Hello! I've utilized ARDiff to test a program I've written myself. Below is the old version of the program:
public class oldV{ public static int snippet(int num, int den) { int ratio; if (num < 0 || den < 0) { ratio = -1; } else if (den == 0 || num == 0) { ratio = 0; } else if (den > 200 || num > 200) { ratio = 200; } else if (den < 2) { ratio = 2 * num; } else if (den < 4) { ratio = num - den; } else if (den < 8) { if (num < den) { ratio = num; } else { ratio = den; } } else if (den < 16) { if (num > den) { ratio = num; } else { ratio = den; } } else if (den < 32) { ratio = 32; for (int i = 2; i < 32; i++) { if (num % i == 0) { ratio = i; break; } } } else if (den < 64) { ratio = 64; for (int i = 2; i < 64; i++) { if (den % i == 0) { ratio = i; break; } } } else if (den < 128) { int x = den; int y = num; int z = x + y; for (int i = 1; i < 30; i++) { z = x + y; x = y; y = z; } ratio = z; } else { ratio = den + num + 10; } return ratio; } }
The new version of the code is as follows:
public class newV{ public static int snippet(int num, int den) { int ratio; if (num < 0 || den < 0) { ratio = -1; } else if (den == 0 || num == 0) { ratio = 0; } else if (den > 200 || num > 200) { ratio = 200; } else if (den < 2) { ratio = 2 * num; } else if (den < 4) { ratio = num - den; } else if (den < 8) { if (num < den) { ratio = num; } else { ratio = den; } } else if (den < 16) { if (num > den) { ratio = num; } else { ratio = den; } } else if (den < 32) { ratio = 32; for (int i = 2; i < 32; i++) { if (num % i == 0) { ratio = i; break; } } } else if (den < 64) { ratio = 64; for (int i = 2; i < 64; i++) { if (den % i == 0) { ratio = i; break; } } } else if (den < 128) { int x = den; int y = num; int z = x + y; for (int i = 1; i < 30; i++) { z = x + y; x = y; y = z; } ratio = y; } else { ratio = den + num + 10; } return ratio; } }
When I use IMP-S to test the code, IMP-S can provide correct results. However, when I use DSE and ARDiff to test the program, the tools report errors as follows:
`*****************************************************************************
------------------------------------ARDIFF-----------------------------------
An error/exception occurred when instrumenting the files or running the equivalence checking. Please report this issue to us.
java.io.IOException: Compilation error: Compilation error: cannot find symbol
symbol: variable ratio
location: class demo.benchmarks.Airy.Sign.Eq.instrumented.IoldVARDiffcannot find symbol
symbol: variable ratio
location: class demo.benchmarks.Airy.Sign.Eq.instrumented.IoldVARDiff
at equiv.checking.Utils.compile(Utils.java:69)
at equiv.checking.Instrumentation.saveNewProcedure(Instrumentation.java:312)
at DSE.DSE.runEquivalenceChecking(DSE.java:272)
at GradDiff.GradDiff.runTool(GradDiff.java:90)
at Runner.Runner.runTool(Runner.java:163)
at Runner.Runner.main(Runner.java:472)`
The detection instructions I used are:java -Djava.library.path=jpf-git/jpf-symbc/lib -jar target/artifacts/Implementation_jar/Implementation.jar --path1 /project/ARDiff/benchmarks/Airy/Sign/Eq/oldV.java --path2 /project/ARDiff/benchmarks/Airy/Sign/Eq/newV.java --tool A --s coral --b 3
I replaced the files in the /benchmarks/Airy/Sign/Eq directory of the test suite with my own code. Therefore, the error message indicates that the error occurred in the demo.benchmarks.Airy.Sign.Eq directory.
The error message indicates that the symbol "ratio" was not found. I attempted to redefine "ratio" within the function snippet instead of as a standalone entity. Here is an example of how it is done:
'public class oldV{
public static int snippet(int num, int den,int ratio) {
if (num < 0 || den < 0) {
ratio = -1;
} else if (den == 0 || num == 0) {
ratio = 0;
} else if (den > 200 || num > 200) {
ratio = 200;
} else if (den < 2) {
ratio = 2 * num;
} else if (den < 4) {
ratio = num - den;
} else if (den < 8) {
if (num < den) {
ratio = num;
} else {
ratio = den;
}
} else if (den < 16) {
if (num > den) {
ratio = num;
} else {
ratio = den;
}
} else if (den < 32) {
ratio = 32;
for (int i = 2; i < 32; i++) {
if (num % i == 0) {
ratio = i;
break;
}
}
} else if (den < 64) {
ratio = 64;
for (int i = 2; i < 64; i++) {
if (den % i == 0) {
ratio = i;
break;
}
}
} else if (den < 128) {
int x = den;
int y = num;
int z = x + y;
for (int i = 1; i < 30; i++) {
z = x + y;
x = y;
y = z;
}
ratio = z;
} else {
ratio = den + num + 10;
}
return ratio;
}
}'
After making this modification, ARDiff no longer reports this error. Do you happen to know the reason behind this problem?
Hello, I used ARDiff to test the following non-equivalence pairs and the results showed equivalence, can you confirm that this is a false positive? And explain why? Thank you.
package demo.benchmarks.Fib.NEq;
public class oldV {
public static double snippet(int x) {
if(x<5){
return lib(x);
}else{
return 0;
}
}
public static double lib(int n) {
int a = 0;
int b = 1;
int i = 0;
if(1 < n){
i += 1;
a = b;
b = a + b;
return lib(n-1) + lib(n-2);
}
return n < 1 ? 0 : 1;
}
}
package demo.benchmarks.Fib.NEq;
public class newV {
public static double snippet(int x) {
if(x<5){
return lib(x);
}else{
return 0;
}
}
public static double lib(int n) {
int a = 0;
int b = 1;
int i = 0;
while(i < n){
i += 1;
a = b;
b = a + b;
}
return a;
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.