├── README.md
├── boolector_solving
├── boolector_check_after_simplify.py
├── boolector_check_after_simplify_peertools.py
├── boolector_check_before_simplify.py
├── makefile
└── total.py
├── dataset
├── pldi_dataset_linear_MBA.txt
├── pldi_dataset_linear_MBA.txt.simplify.txt
├── pldi_dataset_linear_MBA.txt.simplify.txt.z3.verify.64bit.after.simplify.txt
├── pldi_dataset_linear_MBA.txt.z3.verify.64bit.before.simplify.txt
├── pldi_dataset_nonpoly_MBA.txt
├── pldi_dataset_nonpoly_MBA.txt.simplify.txt
├── pldi_dataset_nonpoly_MBA.txt.simplify.txt.z3.verify.64bit.after.simplify.txt
├── pldi_dataset_nonpoly_MBA.txt.z3.verify.64bit.before.simplify.txt
├── pldi_dataset_poly_MBA.txt
├── pldi_dataset_poly_MBA.txt.simplify.txt
├── pldi_dataset_poly_MBA.txt.simplify.txt.z3.verify.64bit.after.simplify.txt
├── pldi_dataset_poly_MBA.txt.z3.verify.64bit.before.simplify.txt
└── sub-dataset-generator.py
├── full-dataset
├── pldi_dataset_linear_MBA.txt
├── pldi_dataset_linear_MBA.txt.boolector.verify.64bit.before.simplify.txt
├── pldi_dataset_linear_MBA.txt.simplify.txt
├── pldi_dataset_linear_MBA.txt.simplify.txt.boolector.verify.64bit.before.simplify.txt
├── pldi_dataset_linear_MBA.txt.simplify.txt.stp.verify.64bit.after.simplify.txt
├── pldi_dataset_linear_MBA.txt.simplify.txt.z3.verify.64bit.after.simplify.txt
├── pldi_dataset_linear_MBA.txt.stp.verify.64bit.before.simplify.txt
├── pldi_dataset_linear_MBA.txt.z3.verify.64bit.before.simplify.txt
├── pldi_dataset_nonpoly_MBA.txt
├── pldi_dataset_nonpoly_MBA.txt.simplify.txt
├── pldi_dataset_poly_MBA.txt
├── pldi_dataset_poly_MBA.txt.boolector.verify.64bit.before.simplify.txt
├── pldi_dataset_poly_MBA.txt.simplify.txt
├── pldi_dataset_poly_MBA.txt.simplify.txt.boolector.verify.64bit.before.simplify.txt
├── pldi_dataset_poly_MBA.txt.simplify.txt.stp.verify.64bit.after.simplify.txt
├── pldi_dataset_poly_MBA.txt.simplify.txt.z3.verify.64bit.after.simplify.txt
├── pldi_dataset_poly_MBA.txt.stp.verify.64bit.before.simplify.txt
└── pldi_dataset_poly_MBA.txt.z3.verify.64bit.before.simplify.txt
├── license
├── makefile
├── mba-simplifier
├── makefile
├── pldi_dataset_simplify_linear.py
├── pldi_dataset_simplify_nonpoly.py
└── pldi_dataset_simplify_poly.py
├── sspam
├── linear.MBA.SSPAM.result.txt
├── makefile
├── nonpoly.MBA.SSPAM.result.txt
├── poly.MBA.SSPAM.result.txt
└── sspam-evaluation.py
├── stp_solving
├── makefile
├── stp_check_after_simplify.py
├── stp_check_after_simplify_peertools.py
├── stp_check_before_simplify.py
└── total.py
├── syntia
├── linear.64bit.result.txt
├── makefile
├── mcts_synthesis
│ ├── game.py
│ ├── grammar.py
│ ├── graph.py
│ ├── mcts.py
│ ├── mcts_synthesis_multi_core.py
│ ├── mctsutils.py
│ ├── metrics.py
│ ├── paralleliser.py
│ ├── sample_synthesis.py
│ ├── sampling_synthesis_helpers.py
│ ├── transform_manual_sampling_io_pairs.py
│ └── utils.py
├── nonpoly.64bit.result.txt
├── poly.64bit.result.txt
├── syntia-evaluation.py
├── testmcts.py
└── transformation.py
├── tools
├── 1variable_truthtable.txt
├── 2variable_truthtable.txt
├── 3variable_truthtable.txt
├── 4variable_truthtable.txt
├── __init__.py
├── commons.py
├── mba_ast_operation.py
├── mba_string_operation.py
├── mba_string_operation.pyc
├── svector_simplify.py
└── truthtable_search_simplify.py
└── z3_solving
├── makefile
├── total.py
├── z3_check_after_simplify.py
├── z3_check_after_simplify_peertools.py
└── z3_check_before_simplify.py
/README.md:
--------------------------------------------------------------------------------
1 | # MBA-Solver Code and Dataset
2 |
3 | MBA-Solver is a tool to make MBA expressions easier for SMT solving.
4 |
5 | ## How to Build
6 |
7 | ### MBA-Solver
8 |
9 | MBA-Solver is written in Python 3.6. It relies on ast, numpy, sympy, astparse
10 | libraries, which can be easily installed by `pip3 install ast numpy astparse
11 | sympy`.
12 |
13 | ### Solvers and their Python interface
14 | The following solvers are supported. MBA-Solver uses python interface
15 | to communicate with the solvers.
16 |
17 | 1. Z3: [GitHub Link](https://github.com/Z3Prover/z3)
18 | Python interface: `pip3 install z3-solver`
19 | 2. Boolector: [GitHub Link](https://github.com/boolector/boolector)
20 | Python interface: [Link](https://boolector.github.io/docs/index.html)
21 | 3. STP: [Github Link](https://github.com/stp/stp)
22 | Python interface: [Link](https://stp.readthedocs.io/en/latest/#python-usage)
23 |
24 | ## Source Files
25 | 1. tools/svector_simplify.py: simplify linear MBA sub-expression
26 | 2. tools/truthtable_search_simplify.py: simplify poly MBA sub-expression
27 | 3. mba-simplifier/pldi_dataset_simplify_*.py: split MBA expression and apply the corresponding simplification (linear, poly, nonpoly) to them.
28 |
29 | ## Step-by-Step Instructions
30 | ### Dataset
31 | The folder "full-dataset" contains the compete dataset: 1000 linear MBA expression, 1000 poly MBA expression, and 1000 nonpoly MBA expression.
32 |
33 | To facilitate the artifact evaluation, the folder "dataset" include a sub-dataset: 21 linear MBA expression, 21 poly MBA expression, and 20 nonpoly MBA expression.
34 |
35 | If you would like to run on the full-dataset, please rename "full-dataset" to "dataset".
36 |
37 | ### Quick Demo
38 |
39 | Run `make quick-demo` will first use Z3 to solve the original MBA, then use MBA-Solver to simplify them, and then use Z3 to solve the simplified MBA.
40 |
41 | ### Simplify MBA
42 |
43 | Run MBA-Solver: `make mba-solver-simplify-mba`.
44 |
45 | Functions for analyzing and manipulating MBA expressions are in the "tools" folder. The simplification results are stored in the "dataset" folder.
46 |
47 | ## SMT Solving
48 |
49 | Each script will print out the number of correctly simplified cases (True), incorrectly simplified cases (False), Timeout cases and total number.
50 |
51 | ### Timeout
52 |
53 | The timeout can be configured at the beginning of the makefiles under boolector_solving, stp_solving, and z3_solving. The default timeout is set to 5 seconds for quick evaluation. The evaluation in our paper is set to one hour. Please note that, running with shorter timeout may reduce the ratio of solved cases in peer tools.
54 |
55 | ### Z3
56 | 1. Solve original MBA: `make z3-solving-original`.
57 | 2. Solve MBA after simplification by MBA-Solver: `make z3-solving-mba-solver-simplify`.
58 | 3. Solve MBA after simplification by SSPAM: `make z3-solving-sspam-simplify`.
59 | 4. Solve MBA after simplification by Syntia: `make z3-solving-syntia-simplify`.
60 |
61 | Run `make z3` will run these four experiments in a batch.
62 |
63 | ### Boolector
64 | 1. Solve original MBA: `make boolector-solving-original`.
65 | 2. Solve MBA after simplification by MBA-Solver: `make boolector-solving-mba-solver-simplify`.
66 | 3. Solve MBA after simplification by SSPAM: `make boolector-solving-sspam-simplify`.
67 | 4. Solve MBA after simplification by Syntia: `make boolector-solving-syntia-simplify`.
68 |
69 | Run `make boolector` will run these four experiments in a batch.
70 |
71 | ### STP
72 | 1. Solve original MBA: `make stp-solving-original`.
73 | 2. Solve MBA after simplification by MBA-Solver: `make stp-solving-mba-solver-simplify`.
74 | 3. Solve MBA after simplification by SSPAM: `make stp-solving-sspam-simplify`.
75 | 4. Solve MBA after simplification by Syntia: `make stp-solving-syntia-simplify`.
76 |
77 | Run `make stp` will run these four experiments in a batch.
78 |
79 | ## Peer tools
80 |
81 | 1. SSPAM: [GitHub Link](https://github.com/quarkslab/sspam/blob/master/README.md).
82 | 2. Syntia: [GitHub link](https://github.com/RUB-SysSec/syntia/blob/master/README.md).
83 |
84 | Running peer tools may take around 18 hours on the subset. To save time, we have already include the simplified result from these tools. So you do not have to run the commands in this section.
85 |
86 | Run SSPAM on MBA dataset: `make sspam-simplify-mba`.
87 |
88 | Run Syntia on MBA dataset: `make syntia-simplify-mba`.
89 |
--------------------------------------------------------------------------------
/boolector_solving/boolector_check_after_simplify.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 |
3 | import pyboolector
4 | import re
5 | import sys
6 | sys.path.append("../tools")
7 | import time
8 | from pyboolector import Boolector, BoolectorException
9 | from mba_string_operation import variable_list
10 | from multiprocessing import Process, Value
11 |
12 | def verify_mba_unsat(leftExpre, rightExpre, bitnumber, res):
13 | """check the relaion whether the left expression is euqal to the right expression.
14 | Args:
15 | leftExpre: left expression.
16 | rightExpre: right expression.
17 | bitnumber: the number of the bits of the variable.
18 | Returns:
19 | True: equation.
20 | False: unequal.
21 | Raises:
22 | None.
23 | """
24 | btor = Boolector()
25 | btor.Set_opt(pyboolector.BTOR_OPT_INCREMENTAL, True)
26 | btor.Set_opt(pyboolector.BTOR_OPT_MODEL_GEN, 1)
27 | _bv = btor.BitVecSort(bitnumber)
28 |
29 | x = btor.Var(_bv, "x")
30 | y = btor.Var(_bv, "y")
31 | z = btor.Var(_bv, "z")
32 | t = btor.Var(_bv, "t")
33 | a = btor.Var(_bv, "a")
34 | b = btor.Var(_bv, "b")
35 | c = btor.Var(_bv, "c")
36 | d = btor.Var(_bv, "d")
37 | e = btor.Var(_bv, "e")
38 | f = btor.Var(_bv, "f")
39 |
40 | try:
41 | leftEval = eval(leftExpre)
42 | rightEval = eval(rightExpre)
43 | except:
44 | res.value = 2
45 | return None
46 |
47 | if not re.search("[xyztabcdef]", leftExpre) and not re.search("[xyztabcdef]", rightExpre):
48 | #whether is a constant
49 | if leftEval - rightEval == 0:
50 | res.value = 1
51 | else:
52 | res.value = 2
53 | else:
54 | btor.Assert(leftEval != rightEval)
55 | btor.Sat()
56 |
57 | variableList = variable_list(leftExpre)
58 | try:
59 | for variable in variableList:
60 | eval(variable).assignment
61 | except:
62 | res.value = 1
63 | else:
64 | res.value = 2
65 |
66 | return None
67 |
68 | def variable_count(expreStr):
69 | """get the set of variable of expression.
70 | Args:
71 | expreStr: the mba expression string.
72 | Return:
73 | variableList: the list of variables.
74 | Raise:
75 | None.
76 | """
77 | varSet = set(expreStr)
78 | variableList = []
79 | for i in varSet:
80 | #the variable name
81 | if i in ["x", "y", "z", "t", "a", "b", "c", "d", "e", "f"]:
82 | variableList.append(i)
83 |
84 | return variableList
85 |
86 |
87 |
88 | def boolector_check_time(sourcefilename, timeout, bv=64):
89 | """input the expression from the source file, then check the equation and output the time of process to desination file.
90 | Args:
91 | sourcefilename: source file.
92 | Returns:
93 | None.
94 | Raises:
95 | None.
96 | """
97 | desfilename = "{source}.boolector.verify.{bv}bit.after.simplify.txt".format(source=sourcefilename, bv=bv)
98 | fwrite = open(desfilename, "w")
99 | comment = "#complex,groundtruth,simcomplex,simground,boolectorres,verificationtime\n"
100 | fwrite.write(comment)
101 |
102 | solvingList = [0, 0, 0]
103 | with open(sourcefilename, "r") as data:
104 | linenum = 0
105 | for line in data:
106 | line = line.strip().replace(" ", "")
107 | if "#" not in line:
108 | expreStrList = re.split(",", line)
109 | sourceExpreStr = expreStrList[0]
110 | groundExpreStr = expreStrList[1]
111 | sourceSimStr = expreStrList[2]
112 | groundSimStr = expreStrList[3]
113 |
114 | start = time.time()
115 | #res = verify_mba_unsat(sourceSimStr, groundSimStr, bv)
116 | res = Value('i', 0)
117 | p = Process(target=verify_mba_unsat, args=(sourceSimStr, groundSimStr, bv, res,))
118 | p.start()
119 | p.join(timeout) # wait timeout seconds or it finishes
120 |
121 | if p.is_alive():
122 | print("Still solving, but kill it as timeout set to", timeout, "seconds ...")
123 | p.terminate()
124 | p.join()
125 |
126 | result = {
127 | 0: "Timeout",
128 | 1: "True",
129 | 2: "False",
130 | }
131 | end = time.time()
132 | elapsed = end - start
133 | resultStr = "{source},{ground},{ssim}, {gsim},{res},{vtime}\n".format(source=sourceExpreStr, ground=groundExpreStr, ssim=sourceSimStr, gsim=groundSimStr, res=result[res.value], vtime=elapsed)
134 | fwrite.write(resultStr)
135 | fwrite.flush()
136 |
137 | # print linenum, sourceExpreStr, groundExpreStr, sourceSimStr, groundSimStr, result[res.value], elapsed
138 | print linenum, result[res.value], "Time =", elapsed
139 | linenum += 1
140 | solvingList[res.value] += 1
141 |
142 | fwrite.close()
143 | print("Timeout: ", solvingList[0])
144 | print("True: ", solvingList[1])
145 | print("False: ", solvingList[2])
146 | return None
147 |
148 |
149 | def main(sourcefilename, timeout):
150 | boolector_check_time(sourcefilename, timeout)
151 |
152 | return None
153 |
154 |
155 |
156 | if __name__ =="__main__":
157 | sourcefilename = sys.argv[1]
158 | timeout = int(sys.argv[2])
159 | main(sourcefilename, timeout)
160 |
161 |
--------------------------------------------------------------------------------
/boolector_solving/boolector_check_after_simplify_peertools.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 |
3 | import pyboolector
4 | import re
5 | import sys
6 | sys.path.append("../tools")
7 | import time
8 | from pyboolector import Boolector, BoolectorException
9 | from mba_string_operation import variable_list
10 | from multiprocessing import Process, Value
11 |
12 | def verify_mba_unsat(leftExpre, rightExpre, bitnumber, res):
13 | """check the relaion whether the left expression is euqal to the right expression.
14 | Args:
15 | leftExpre: left expression.
16 | rightExpre: right expression.
17 | bitnumber: the number of the bits of the variable.
18 | Returns:
19 | True: equation.
20 | False: unequal.
21 | Raises:
22 | None.
23 | """
24 | btor = Boolector()
25 | btor.Set_opt(pyboolector.BTOR_OPT_INCREMENTAL, True)
26 | btor.Set_opt(pyboolector.BTOR_OPT_MODEL_GEN, 1)
27 | _bv = btor.BitVecSort(bitnumber)
28 |
29 | x = btor.Var(_bv, "x")
30 | y = btor.Var(_bv, "y")
31 | z = btor.Var(_bv, "z")
32 | t = btor.Var(_bv, "t")
33 | a = btor.Var(_bv, "a")
34 | b = btor.Var(_bv, "b")
35 | c = btor.Var(_bv, "c")
36 | d = btor.Var(_bv, "d")
37 | e = btor.Var(_bv, "e")
38 | f = btor.Var(_bv, "f")
39 |
40 | try:
41 | leftEval = eval(leftExpre)
42 | rightEval = eval(rightExpre)
43 | except:
44 | res.value = 2
45 | return None
46 |
47 | if not re.search("[xyztabcdef]", leftExpre) and not re.search("[xyztabcdef]", rightExpre):
48 | #whether is a constant
49 | if leftEval - rightEval == 0:
50 | res.value = 1
51 | else:
52 | res.value = 2
53 | else:
54 | btor.Assert(leftEval != rightEval)
55 | btor.Sat()
56 |
57 | variableList = variable_list(leftExpre)
58 | try:
59 | for variable in variableList:
60 | eval(variable).assignment
61 | except:
62 | res.value = 1
63 | else:
64 | res.value = 2
65 |
66 | return None
67 |
68 | def variable_count(expreStr):
69 | """get the set of variable of expression.
70 | Args:
71 | expreStr: the mba expression string.
72 | Return:
73 | variableList: the list of variables.
74 | Raise:
75 | None.
76 | """
77 | varSet = set(expreStr)
78 | variableList = []
79 | for i in varSet:
80 | #the variable name
81 | if i in ["x", "y", "z", "t", "a", "b", "c", "d", "e", "f"]:
82 | variableList.append(i)
83 |
84 | return variableList
85 |
86 |
87 |
88 | def boolector_check_time(sourcefilename, timeout, bv=64):
89 | """input the expression from the source file, then check the equation and output the time of process to desination file.
90 | Args:
91 | sourcefilename: source file.
92 | Returns:
93 | None.
94 | Raises:
95 | None.
96 | """
97 | desfilename = "{source}.boolector.verify.{bv}bit.after.simplify.txt".format(source=sourcefilename, bv=bv)
98 | fwrite = open(desfilename, "w")
99 | comment = "#complex,groundtruth,simcomplex,boolectorres,verificationtime\n"
100 | fwrite.write(comment)
101 |
102 | with open(sourcefilename, "r") as data:
103 | linenum = 0
104 | for line in data:
105 | line = line.strip().replace(" ", "")
106 | if "#" not in line:
107 | expreStrList = re.split(",", line)
108 | sourceExpreStr = expreStrList[0]
109 | groundExpreStr = expreStrList[1]
110 | sourceSimStr = expreStrList[2]
111 |
112 | start = time.time()
113 | res = Value('i', 0)
114 | p = Process(target=verify_mba_unsat, args=(sourceSimStr, groundExpreStr, bv, res,))
115 | p.start()
116 | p.join(timeout) # wait timeout seconds or it finishes
117 |
118 | if p.is_alive():
119 | print("Still solving, but kill it as timeout set to", timeout, "seconds ...")
120 | p.terminate()
121 | p.join()
122 |
123 | result = {
124 | 0: "Timeout",
125 | 1: "True",
126 | 2: "False",
127 | }
128 | #res = verify_mba_unsat(sourceSimStr, groundExpreStr, bv)
129 | end = time.time()
130 | elapsed = end - start
131 | resultStr = "{source},{ground},{ssim},{res},{vtime}\n".format(source=sourceExpreStr, ground=groundExpreStr, ssim=sourceSimStr, res=result[res.value], vtime=elapsed)
132 | fwrite.write(resultStr)
133 | fwrite.flush()
134 |
135 | # print linenum, sourceExpreStr, groundExpreStr, sourceSimStr, result[res.value], elapsed
136 | print linenum, result[res.value], "Time =", elapsed
137 | linenum += 1
138 |
139 | fwrite.close()
140 | return None
141 |
142 |
143 | def main(sourcefilename, timeout):
144 | boolector_check_time(sourcefilename, timeout)
145 |
146 | return None
147 |
148 |
149 |
150 | if __name__ =="__main__":
151 | sourcefilename = sys.argv[1]
152 | timeout = int(sys.argv[2])
153 | main(sourcefilename, timeout)
154 |
155 |
--------------------------------------------------------------------------------
/boolector_solving/boolector_check_before_simplify.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 |
3 | import pyboolector
4 | import re
5 | import sys
6 | sys.path.append("../tools")
7 | import time
8 | from pyboolector import Boolector, BoolectorException
9 | #from mba_string_operation import variable_list
10 | from multiprocessing import Process, Value
11 |
12 | def verify_mba_unsat(leftExpre, rightExpre, bitnumber, res):
13 | """check the relaion whether the left expression is euqal to the right expression.
14 | Args:
15 | leftExpre: left expression.
16 | rightExpre: right expression.
17 | bitnumber: the number of the bits of the variable.
18 | Returns:
19 | True: equation.
20 | False: unequal.
21 | Raises:
22 | None.
23 | """
24 | btor = Boolector()
25 | btor.Set_opt(pyboolector.BTOR_OPT_INCREMENTAL, True)
26 | btor.Set_opt(pyboolector.BTOR_OPT_MODEL_GEN, 1)
27 | _bv = btor.BitVecSort(bitnumber)
28 |
29 | x = btor.Var(_bv, "x")
30 | y = btor.Var(_bv, "y")
31 | z = btor.Var(_bv, "z")
32 | t = btor.Var(_bv, "t")
33 | a = btor.Var(_bv, "a")
34 | b = btor.Var(_bv, "b")
35 | c = btor.Var(_bv, "c")
36 | d = btor.Var(_bv, "d")
37 | e = btor.Var(_bv, "e")
38 | f = btor.Var(_bv, "f")
39 |
40 | leftEval = eval(leftExpre)
41 | rightEval = eval(rightExpre)
42 | btor.Assert(leftEval != rightEval)
43 | btor.Sat()
44 |
45 | variableList = variable_list(leftExpre)
46 | try:
47 | for variable in variableList:
48 | eval(variable).assignment
49 | except:
50 | res.value = 1
51 | else:
52 | res.value = 2
53 |
54 | return None
55 |
56 | def variable_list(expreStr):
57 | """get the set of variable of expression.
58 | Args:
59 | expreStr: the mba expression string.
60 | Return:
61 | variableList: the list of variables.
62 | Raise:
63 | None.
64 | """
65 | varSet = set(expreStr)
66 | variableList = []
67 | for i in varSet:
68 | #the variable name
69 | if i in ["x", "y", "z", "t", "a", "b", "c", "d", "e", "f"]:
70 | variableList.append(i)
71 |
72 | return variableList
73 |
74 |
75 |
76 | def boolector_check_time(sourcefilename, timeout, bv=64):
77 | """input the expression from the source file, then check the equation and output the time of process to desination file.
78 | Args:
79 | sourcefilename: source file.
80 | Returns:
81 | None.
82 | Raises:
83 | None.
84 | """
85 | desfilename = "{source}.boolector.verify.{bv}bit.before.simplify.txt".format(source=sourcefilename, bv=bv)
86 | fwrite = open(desfilename, "w")
87 | comment = "#complex,groundtruth,boolectorres,verificationtime\n"
88 | fwrite.write(comment)
89 |
90 | with open(sourcefilename, "r") as data:
91 | linenum = 0
92 | for line in data:
93 | line = line.strip().replace(" ", "")
94 | if "#" not in line:
95 | expreStrList = re.split(",", line)
96 | sourceExpreStr = expreStrList[0]
97 | groundExpreStr = expreStrList[1]
98 | start = time.time()
99 | #res = verify_mba_unsat(sourceExpreStr, groundExpreStr, bv)
100 | res = Value('i', 0)
101 | p = Process(target=verify_mba_unsat, args=(sourceExpreStr, groundExpreStr, bv, res,))
102 | p.start()
103 | p.join(timeout) # wait timeout seconds or it finishes
104 |
105 | if p.is_alive():
106 | print("Still solving, but kill it as timeout set to", timeout, "seconds ...")
107 | p.terminate()
108 | p.join()
109 |
110 | result = {
111 | 0: "Timeout",
112 | 1: "True",
113 | 2: "False",
114 | }
115 | end = time.time()
116 | elapsed = end - start
117 | resultStr = "{source},{ground},{res},{vtime}\n".format(source=sourceExpreStr, ground=groundExpreStr, res=result[res.value], vtime=elapsed)
118 | fwrite.write(resultStr)
119 | fwrite.flush()
120 |
121 | # print linenum, sourceExpreStr, groundExpreStr, result[res.value], elapsed
122 | print linenum, result[res.value], "Time =", elapsed
123 | linenum += 1
124 |
125 | fwrite.close()
126 | return None
127 |
128 |
129 | def main(sourcefilename, timeout):
130 | boolector_check_time(sourcefilename, timeout)
131 |
132 | return None
133 |
134 |
135 | if __name__ =="__main__":
136 | sourcefilename = sys.argv[1]
137 | timeout = int(sys.argv[2])
138 | main(sourcefilename, timeout)
139 |
140 |
--------------------------------------------------------------------------------
/boolector_solving/makefile:
--------------------------------------------------------------------------------
1 | timeout = 5
2 |
3 | boolector-linear-before-simplify:
4 | python2 boolector_check_before_simplify.py ../dataset/pldi_dataset_linear_MBA.txt $(timeout)
5 |
6 | boolector-poly-before-simplify:
7 | python2 boolector_check_before_simplify.py ../dataset/pldi_dataset_poly_MBA.txt $(timeout)
8 |
9 | boolector-nonpoly-before-simplify:
10 | python2 boolector_check_before_simplify.py ../dataset/pldi_dataset_nonpoly_MBA.txt $(timeout)
11 |
12 | boolector-linear-after-simplify:
13 | python2 boolector_check_after_simplify.py ../dataset/pldi_dataset_linear_MBA.txt.simplify.txt $(timeout)
14 |
15 | boolector-poly-after-simplify:
16 | python2 boolector_check_after_simplify.py ../dataset/pldi_dataset_poly_MBA.txt.simplify.txt $(timeout)
17 |
18 | boolector-nonpoly-after-simplify:
19 | python2 boolector_check_after_simplify.py ../dataset/pldi_dataset_nonpoly_MBA.txt.simplify.txt $(timeout)
20 |
21 | boolector-linear-after-simplify-sspam:
22 | python2 boolector_check_after_simplify_peertools.py ../sspam/linear.MBA.SSPAM.result.txt $(timeout)
23 |
24 | boolector-poly-after-simplify-sspam:
25 | python2 boolector_check_after_simplify_peertools.py ../sspam/poly.MBA.SSPAM.result.txt $(timeout)
26 |
27 | boolector-nonpoly-after-simplify-sspam:
28 | python2 boolector_check_after_simplify_peertools.py ../sspam/nonpoly.MBA.SSPAM.result.txt $(timeout)
29 |
30 | boolector-linear-after-simplify-syntia:
31 | python2 boolector_check_after_simplify_peertools.py ../syntia/linear.64bit.result.txt $(timeout)
32 |
33 | boolector-poly-after-simplify-syntia:
34 | python2 boolector_check_after_simplify_peertools.py ../syntia/poly.64bit.result.txt $(timeout)
35 |
36 | boolector-nonpoly-after-simplify-syntia:
37 | python2 boolector_check_after_simplify_peertools.py ../syntia/nonpoly.64bit.result.txt $(timeout)
38 |
39 | boolector-solving-before-simplify-total:
40 | python3 total.py boolector 0
41 | boolector-solving-before-simplify:
42 | @echo "--------------------boolector solving linear MBA samples-------------------------"
43 | @make boolector-linear-before-simplify
44 | @echo "--------------------boolector solving linear MBA samples completion--------------"
45 | @echo "--------------------boolector solving poly MBA samples---------------------------"
46 | @make boolector-poly-before-simplify
47 | @echo "--------------------boolector solving poly MBA samples completion----------------"
48 | @echo "--------------------boolector solving nonpoly MBA samples------------------------"
49 | @make boolector-nonpoly-before-simplify
50 | @echo "--------------------boolector solving nonpoly MBA samples completion-------------"
51 | @echo "--------------------boolector solving MBA samples before simplification-------------"
52 | @make boolector-solving-before-simplify-total
53 |
54 | boolector-solving-mba-solver-total:
55 | python3 total.py boolector 1 mba
56 | boolector-solving-mba-solver:
57 | @echo "--------------------boolector solving linear MBA samples after MBA-Solver simplification--------------------------"
58 | @make boolector-linear-after-simplify
59 | @echo "--------------------boolector solving linear MBA samples after MBA-Solver simplification completion---------------"
60 | @echo "--------------------boolector solving poly MBA samples after MBA-Solver simplification----------------------------"
61 | @make boolector-poly-after-simplify
62 | @echo "--------------------boolector solving poly MBA samples after MBA-Solver simplification completion-----------------"
63 | @echo "--------------------boolector solving nonpoly MBA samples after MBA-Solver simplification-------------------------"
64 | @make boolector-nonpoly-after-simplify
65 | @echo "--------------------boolector solving nonpoly MBA samples after MBA-Solver simplification completion--------------"
66 | @echo "--------------------boolector solving MBA samples after MBA-Solver simplification --------------"
67 | @make boolector-solving-mba-solver-total
68 |
69 | boolector-solving-sspam-total:
70 | python3 total.py boolector 1 sspam
71 | boolector-solving-sspam:
72 | @echo "--------------------boolector solving linear MBA samples after SSPAM simplification--------------------------"
73 | @make boolector-linear-after-simplify-sspam
74 | @echo "--------------------boolector solving linear MBA samples after SSPAM simplification completion---------------"
75 | @echo "--------------------boolector solving poly MBA samples after SSPAM simplification----------------------------"
76 | @make boolector-poly-after-simplify-sspam
77 | @echo "--------------------boolector solving poly MBA samples after SSPAM simplification completion-----------------"
78 | @echo "--------------------boolector solving nonpoly MBA samples after SSPAM simplification-------------------------"
79 | @make boolector-nonpoly-after-simplify-sspam
80 | @echo "--------------------boolector solving nonpoly MBA samples after SSPAM simplification completion--------------"
81 | @echo "--------------------boolector solving MBA samples after SSPAM simplification --------------"
82 | @make boolector-solving-sspam-total
83 |
84 | boolector-solving-syntia-total:
85 | python3 total.py boolector 1 syntia
86 | boolector-solving-syntia:
87 | @echo "--------------------boolector solving linear MBA samples after Syntia simplification--------------------------"
88 | @make boolector-linear-after-simplify-syntia
89 | @echo "--------------------boolector solving linear MBA samples after Syntia simplification completion---------------"
90 | @echo "--------------------boolector solving poly MBA samples after Syntia simplification----------------------------"
91 | @make boolector-poly-after-simplify-syntia
92 | @echo "--------------------boolector solving poly MBA samples after Syntia simplification completion-----------------"
93 | @echo "--------------------boolector solving nonpoly MBA samples after Syntia simplification-------------------------"
94 | @make boolector-nonpoly-after-simplify-syntia
95 | @echo "--------------------boolector solving nonpoly MBA samples after Syntia simplification completion--------------"
96 | @echo "--------------------boolector solving MBA samples after Syntia simplification --------------"
97 | @make boolector-solving-syntia-total
98 |
--------------------------------------------------------------------------------
/boolector_solving/total.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | import re
4 | import sys
5 | import time
6 |
7 |
8 |
9 | def total_simplify(smtsolver, solver):
10 | """count the solving number after solving by smt solver.
11 | """
12 | true = 0
13 | false = 0
14 | timeout = 0
15 |
16 | if "mba" in solver:
17 | path = "../dataset"
18 | dataFile = ["linear", "poly", "nonpoly"]
19 | for data in dataFile:
20 | fileread = "{path}/pldi_dataset_{data}_MBA.txt.simplify.txt.{smtsolver}.verify.64bit.after.simplify.txt".format(path=path, data=data, smtsolver=smtsolver)
21 | with open(fileread, "r") as fr:
22 | for line in fr:
23 | line = line.strip().replace(" ", "")
24 | if "#" not in line:
25 | expreStrList = re.split(",", line)
26 | flag = expreStrList[4]
27 | if "ue" in flag:
28 | true += 1
29 | elif "out" in flag:
30 | timeout += 1
31 | else:
32 | false += 1
33 | elif "sspam" in solver:
34 | path = "../sspam"
35 | dataFile = ["linear", "poly", "nonpoly"]
36 | for data in dataFile:
37 | fileread = "{path}/{data}.MBA.SSPAM.result.txt.{smtsolver}.verify.64bit.after.simplify.txt".format(path=path, data=data, smtsolver=smtsolver)
38 | with open(fileread, "r") as fr:
39 | for line in fr:
40 | line = line.strip().replace(" ", "")
41 | if "#" not in line:
42 | expreStrList = re.split(",", line)
43 | flag = expreStrList[3]
44 | if "ue" in flag:
45 | true += 1
46 | elif "out" in flag:
47 | timeout += 1
48 | else:
49 | false += 1
50 | elif "syntia" in solver:
51 | path = "../syntia"
52 | dataFile = ["linear", "poly", "nonpoly"]
53 | for data in dataFile:
54 | fileread = "{path}/{data}.64bit.result.txt.{smtsolver}.verify.64bit.after.simplify.txt".format(path=path, data=data, smtsolver=smtsolver)
55 | with open(fileread, "r") as fr:
56 | for line in fr:
57 | line = line.strip().replace(" ", "")
58 | if "#" not in line:
59 | expreStrList = re.split(",", line)
60 | flag = expreStrList[3]
61 | if "ue" in flag:
62 | true += 1
63 | elif "out" in flag:
64 | timeout += 1
65 | else:
66 | false += 1
67 | total = true+false+timeout
68 | print("Total: ", total)
69 | print("True: ", true)
70 | print("False: ", false)
71 | print("Timeout: ", timeout)
72 |
73 | return None
74 |
75 |
76 |
77 | def total_original(smtsolver):
78 | """count the solving number before solving by smt solver.
79 | """
80 | true = 0
81 | false = 0
82 | timeout = 0
83 |
84 |
85 | path = "../dataset"
86 | dataFile = ["linear", "poly", "nonpoly"]
87 | for data in dataFile:
88 | fileread = "{path}/pldi_dataset_{data}_MBA.txt.{smtsolver}.verify.64bit.before.simplify.txt".format(path=path, data=data, smtsolver=smtsolver)
89 | with open(fileread, "r") as fr:
90 | for line in fr:
91 | line = line.strip().replace(" ", "")
92 | if "#" not in line:
93 | expreStrList = re.split(",", line)
94 | flag = expreStrList[2]
95 | if "ue" in flag:
96 | true += 1
97 | elif "out" in flag:
98 | timeout += 1
99 | else:
100 | false += 1
101 | total = true+false+timeout
102 | print("Total: ", total)
103 | print("True: ", true)
104 | print("False: ", false)
105 | print("Timeout: ", timeout)
106 |
107 | return None
108 |
109 |
110 |
111 |
112 |
113 | def main(smtsolver, flag, solver=None):
114 | if flag:
115 | #after simplification
116 | total_simplify(smtsolver, solver)
117 | else:
118 | #before simplification
119 | total_original(smtsolver)
120 |
121 |
122 |
123 | if __name__ =="__main__":
124 | #smt solver
125 | smtsolver = sys.argv[1]
126 | #before/after simplification
127 | flag = int(sys.argv[2])
128 | #if simplificationn, tools
129 | if len(sys.argv) > 3:
130 | solver = sys.argv[3]
131 | main(smtsolver, flag, solver)
132 | else:
133 | main(smtsolver, flag)
134 |
135 |
136 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_linear_MBA.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth
2 | (x|y)+y-(~x&y),x+y
3 | 3*(x&~y)-(x^y)+~x-~(x&y),x-y
4 | -1*(~(x&y))+(x|y)-1*(x^y)-1*x+2*~x-1*(~(x&~y))-1*(~(x^y))-1*(x|~y)+3*(~(x|y))+1*(~(x|~y))+4*(x&~y)+4*(x&y),1*y+1*~y
5 | -2*(~(x&y))-2*~y-2*~x+(~(x^y))-2*x-1*y-1*(x|y)+(x|~y)+6*(~(x|y))+8*(~(x|~y))+7*(x&~y)+4*(x&y),1*(~(x&~x))+1*(~(x&~y))
6 | -1*(x|y)+(~(x&~y))+2*y-2*~y-1*~x-1*(~(x&~x))+(~(x^y))+x+2*(~(x|y))-1*(~(x|~y))+3*(x&~y)-2*(x&y),-(~(x&y))+1*(x|~y)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(x|y))&~t)|((y^~(x&(y&z)))&t))+7*(((~y&~(x^z))&~t)|(~(x&~y)&t))+1*(((y^~(~x|(y&z)))&~t)|((x&~x)&t))-1*((~(x|(y|z))&~t)|((z^~(x|(~y&z)))&t))+2*((((x&z)^(x^(~y&z)))&~t)|(((x&y)^~(x^(y&z)))&t))-9*(((x^(y|z))&~t)|(((y&z)|(~x&(y|z)))&t))+1*(((y|(x&~z))&~t)|((~(x|y)|~(x^(y^z)))&t))-5*(((~(x^y)|~(x^z))&~t)|(((x|y)&(x^(y^z)))&t))-4*((((x|~y)&~(x^(y^z)))&~t)|((y|(x^z))&t))+9*(((y^~(x|(~y&z)))&~t)|((x&z)&t))-1*((((x&y)^(x^(~y|z)))&~t)|((z^~(x&~y))&t))-3*(((y^~(x&(y^z)))&~t)|((z^~(~x&(~y|z)))&t))+1*((~(~x&(y&z))&~t)|(~(x^(~y&z))&t))-4*(((x&~z)&~t)|((z&~(x^y))&t))+11*~(x|(~y|(z|t)))+11*~(~x|(y|(z|t)))+3*~(~x|(~y|(z|t)))+15*~(x|(y|(~z|t)))+5*~(x|(~y|(~z|t)))-9*~(~x|(~y|(~z|t)))-12*(~x&(~y&(~z&t)))+13*(~x&(y&(~z&t)))+15*(x&(~y&(~z&t)))+4*(x&(y&(~z&t)))+14*(~x&(~y&(z&t)))+13*(~x&(y&(z&t)))-12*(x&(~y&(z&t)))+10*(x&(y&(z&t))),-1*~(~x|(y|(~z|t)))+6*(((~y&~(x^z))&~t)|((z^~(~x|(y&z)))&t))
23 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_linear_MBA.txt.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,simplifiedcomplex,simplifiedgroundtruth,z3flag,simtime
2 | (x|y)+y-(~x&y),x+y,1*~(x|~y)+1*(x&~y)+2*(x&y),1*~(x|~y)+1*(x&~y)+2*(x&y),True,0.019237756729125977
3 | 3*(x&~y)-(x^y)+~x-~(x&y),x-y,-1*~(x|~y)+1*(x&~y),-1*~(x|~y)+1*(x&~y),True,0.0010426044464111328
4 | -1*(~(x&y))+(x|y)-1*(x^y)-1*x+2*~x-1*(~(x&~y))-1*(~(x^y))-1*(x|~y)+3*(~(x|y))+1*(~(x|~y))+4*(x&~y)+4*(x&y),1*y+1*~y,-1,-1,True,0.0012309551239013672
5 | -2*(~(x&y))-2*~y-2*~x+(~(x^y))-2*x-1*y-1*(x|y)+(x|~y)+6*(~(x|y))+8*(~(x|~y))+7*(x&~y)+4*(x&y),1*(~(x&~x))+1*(~(x&~y)),2*~(x|y)+2*~(x|~y)+1*(x&~y)+2*(x&y),2*~(x|y)+2*~(x|~y)+1*(x&~y)+2*(x&y),True,0.0015075206756591797
6 | -1*(x|y)+(~(x&~y))+2*y-2*~y-1*~x-1*(~(x&~x))+(~(x^y))+x+2*(~(x|y))-1*(~(x|~y))+3*(x&~y)-2*(x&y),-(~(x&y))+1*(x|~y),-1*~(x|~y)+1*(x&y),-1*~(x|~y)+1*(x&y),True,0.0012502670288085938
7 | -1*x-1*~y+4*(~(x&~x))-1*(~(x^y))+y-4*(~(x&y))-1*(~(x&~y))+2*(~(x|y))-1*(~(x|~y))+2*(x&~y)-2*(x&y),-~x,-1*~x,-1*~x,True,0.0011723041534423828
8 | (~(x&~x))+y-2*(x^y)-1*~y+x-1*(~(x&~y))-2*~x-3*(~(x|y))-2*(~(x|~y))-4*(x&~y)-3*(x&y),-5*(~(x&y))-(~(x^y)),-6*~(x|y)-5*~(x|~y)-5*(x&~y)-1*(x&y),-6*~(x|y)-5*~(x|~y)-5*(x&~y)-1*(x&y),True,0.0018951892852783203
9 | (~(x&y))+(x^y)-1*y+x-2*(x|~y)+2*(~(x&~y))+~y-1*(~(x^y))-1*(~(x|y))-4*(~(x|~y))-3*(x&~y),-(x|y),-1*(x|y),-1*(x|y),True,0.00356292724609375
10 | -1*x-1*~x+4*(x|~y)-1*(~(x&~y))-1*~y-4*(x&~y)-1*(x&y),1*(~(x^y))-2*(x^y),1*~(x|y)-2*~(x|~y)-2*(x&~y)+1*(x&y),1*~(x|y)-2*~(x|~y)-2*(x&~y)+1*(x&y),True,0.0014660358428955078
11 | 2*~x+5*(~(x^y))-1*(~(x&y))+(x^y)+x-1*(~(x&~y))+(x|~y)-7*(~(x|y))-3*(~(x|~y))-3*(x&~y)-8*(x&y),-y-(~(x&~x)),-1*~(x|y)-2*~(x|~y)-1*(x&~y)-2*(x&y),-1*~(x|y)-2*~(x|~y)-1*(x&~y)-2*(x&y),True,0.001287221908569336
12 | -3*~(x^y)-6*~y-2*(x^y)-7*~(x&y)+1*~(x&~x)+2*~(x&~y)-11*(x|~y)-6*x-2*y+24*~(x|y)+8*~(x|~y)+31*(x&~y),-19*(x&y),-19*(x&y),-19*(x&y),True,0.002896547317504883
13 | 1*((x|y)&~(y^z))+1*~(x|(y|z))-2*~(~x|(y|z))-2*(x&(y&z)),1*(~x&(~y|z))-1*((x|~y)&(x^(y^z))),1*~(x|(y|z))-1*~(~x|(y|z))+1*(~x&(y&z))-1*(x&(y&z)),1*~(x|(y|z))-1*~(~x|(y|z))+1*(~x&(y&z))-1*(x&(y&z)),True,0.0026865005493164062
14 | -3*(z^~(~x|(~y&z)))-1*(x&(~y|z))-4*~(x|(~y|z))-1*~(~x|(~y|z))+3*(~x&(~y&z))-1*(~x&(y&z))-3*(x&(y&z)),-4*(x|y),-4*(x|y),-4*(x|y),True,0.0037043094635009766
15 | 2*(y|~(x^z))-1*(~x&(~y|z))+2*~(x^(y|z))-3*~(x|(y|z))-2*~(x|(~y|z))+1*(~x&(~y&z))-4*(x&(~y&z))-4*(x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),True,0.0028769969940185547
16 | 5*(~x&(y^z))+1*(x&(y^z))+1*((x&~y)|(x^(y^z)))-6*~(x|(~y|z))-1*~(~x|(y|z))-1*~(~x|(~y|z))-2*(x&(~y&z))-1*(x&(y&z)),6*(~x&(~y&z)),6*(~x&(~y&z)),6*(~x&(~y&z)),True,0.00534510612487793
17 | -7*((x^y)&~(x^z))+5*(~z|~(x^y))-3*~(x|(y|z))+4*~(x|(~y|z))-3*~(~x|(y|z))-3*~(~x|(~y|z))-3*(~x&(~y&z))+9*(x&(~y&z))-5*(x&(y&z)),2*~(y&z),2*~(y&z),2*~(y&z),True,0.0033311843872070312
18 | -3*~(y^z)+5*(z^(~x|(y|z)))-12*~(x|(y|z))-15*~(x|(~y|z))-8*~(~x|(y|z))-16*~(~x|(~y|z))-8*(~x&(y&z))+1*(x&(~y&z))+3*(x&(y&z)),1*(z^(~x|(y&z)))-11*(z^~(~x&(y&z))),-10*~(x|(y|z))-10*~(x|(~y|z))-11*~(~x|(y|z))-11*~(~x|(~y|z))-11*(~x&(y&z))+1*(x&(~y&z)),-10*~(x|(y|z))-10*~(x|(~y|z))-11*~(~x|(y|z))-11*~(~x|(~y|z))-11*(~x&(y&z))+1*(x&(~y&z)),True,0.005104780197143555
19 | -2*(y|~z)+1*(x^y)+2*~(x|(y|z))+3*~(~x|(y|z))+4*~(~x|(~y|z))+2*(~x&(~y&z))+3*(~x&(y&z))-1*(x&(~y&z))+4*(x&(y&z)),2*(z^~(~x|(y&z)))-1*~(x|(~y|z)),-1*~(x|(~y|z))+2*~(~x|(y|z))+2*~(~x|(~y|z))+2*(~x&(~y&z))+2*(~x&(y&z))+2*(x&(y&z)),-1*~(x|(~y|z))+2*~(~x|(y|z))+2*~(~x|(~y|z))+2*(~x&(~y&z))+2*(~x&(y&z))+2*(x&(y&z)),True,0.004362344741821289
20 | -1*((~(x^(~y&z))&~t)|((z^(~x|(y&z)))&t))+1*((((x&y)^(x^(y&z)))&~t)|(((x&~y)|~(y^z))&t))+1*(((z^~(x&y))&~t)|(((x|y)&~(x^(y^z)))&t))-2*~(~x|(y|(z|t)))-2*~(~x|(~y|(~z|t)))+1*(~x&(y&(~z&t)))-1*(x&(~y&(~z&t)))-2*(~x&(y&(z&t)))-1*(x&(y&(z&t))),1*(x&(y&(~z&t)))+1*(x&(~y&(z&t))),1*(((x&~x)&~t)|((x&(y^z))&t)),1*(((x&~x)&~t)|((x&(y^z))&t)),True,0.48560190200805664
21 | 2*((((y&z)|(~x&(y|z)))&~t)|((y^~(x&(~y&z)))&t))-2*(((z^~(~x&(y|z)))&~t)|(((x|y)&~(y^z))&t))-2*(((z^~(x|(~y&z)))&~t)|(((x&y)^(x^(~y|z)))&t))-2*((((x^y)&(x^z))&~t)|((~(x|y)|~(y^z))&t))+4*~(x|(y|(z|t)))+4*~(~x|(y|(z|t)))+2*~(~x|(~y|(z|t)))+2*~(x|(y|(~z|t)))+2*~(x|(~y|(~z|t)))+2*~(~x|(y|(~z|t)))+2*(~x&(~y&(~z&t)))+2*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),-2*(x&(~y&(~z&t))),-2*(x&(~y&(~z&t))),-2*(x&(~y&(~z&t))),True,0.453047513961792
22 | 3*(((z^~(x|y))&~t)|((y^~(x&(y&z)))&t))+7*(((~y&~(x^z))&~t)|(~(x&~y)&t))+1*(((y^~(~x|(y&z)))&~t)|((x&~x)&t))-1*((~(x|(y|z))&~t)|((z^~(x|(~y&z)))&t))+2*((((x&z)^(x^(~y&z)))&~t)|(((x&y)^~(x^(y&z)))&t))-9*(((x^(y|z))&~t)|(((y&z)|(~x&(y|z)))&t))+1*(((y|(x&~z))&~t)|((~(x|y)|~(x^(y^z)))&t))-5*(((~(x^y)|~(x^z))&~t)|(((x|y)&(x^(y^z)))&t))-4*((((x|~y)&~(x^(y^z)))&~t)|((y|(x^z))&t))+9*(((y^~(x|(~y&z)))&~t)|((x&z)&t))-1*((((x&y)^(x^(~y|z)))&~t)|((z^~(x&~y))&t))-3*(((y^~(x&(y^z)))&~t)|((z^~(~x&(~y|z)))&t))+1*((~(~x&(y&z))&~t)|(~(x^(~y&z))&t))-4*(((x&~z)&~t)|((z&~(x^y))&t))+11*~(x|(~y|(z|t)))+11*~(~x|(y|(z|t)))+3*~(~x|(~y|(z|t)))+15*~(x|(y|(~z|t)))+5*~(x|(~y|(~z|t)))-9*~(~x|(~y|(~z|t)))-12*(~x&(~y&(~z&t)))+13*(~x&(y&(~z&t)))+15*(x&(~y&(~z&t)))+4*(x&(y&(~z&t)))+14*(~x&(~y&(z&t)))+13*(~x&(y&(z&t)))-12*(x&(~y&(z&t)))+10*(x&(y&(z&t))),-1*~(~x|(y|(~z|t)))+6*(((~y&~(x^z))&~t)|((z^~(~x|(y&z)))&t)),6*~(x|(y|(z|t)))+5*~(~x|(y|(~z|t)))+6*(x&(~y&(~z&t)))+6*(x&(y&(~z&t)))+6*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),6*~(x|(y|(z|t)))+5*~(~x|(y|(~z|t)))+6*(x&(~y&(~z&t)))+6*(x&(y&(~z&t)))+6*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),True,0.4736015796661377
23 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_linear_MBA.txt.simplify.txt.z3.verify.64bit.after.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,simcomplex,simground,z3res,verificationtime
2 | (x|y)+y-(~x&y),x+y,1*~(x|~y)+1*(x&~y)+2*(x&y),1*~(x|~y)+1*(x&~y)+2*(x&y),True,0.02516460418701172
3 | 3*(x&~y)-(x^y)+~x-~(x&y),x-y,-1*~(x|~y)+1*(x&~y),-1*~(x|~y)+1*(x&~y),True,0.021987438201904297
4 | -1*(~(x&y))+(x|y)-1*(x^y)-1*x+2*~x-1*(~(x&~y))-1*(~(x^y))-1*(x|~y)+3*(~(x|y))+1*(~(x|~y))+4*(x&~y)+4*(x&y),1*y+1*~y,-1,-1,True,0.024457931518554688
5 | -2*(~(x&y))-2*~y-2*~x+(~(x^y))-2*x-1*y-1*(x|y)+(x|~y)+6*(~(x|y))+8*(~(x|~y))+7*(x&~y)+4*(x&y),1*(~(x&~x))+1*(~(x&~y)),2*~(x|y)+2*~(x|~y)+1*(x&~y)+2*(x&y),2*~(x|y)+2*~(x|~y)+1*(x&~y)+2*(x&y),True,0.02544236183166504
6 | -1*(x|y)+(~(x&~y))+2*y-2*~y-1*~x-1*(~(x&~x))+(~(x^y))+x+2*(~(x|y))-1*(~(x|~y))+3*(x&~y)-2*(x&y),-(~(x&y))+1*(x|~y),-1*~(x|~y)+1*(x&y),-1*~(x|~y)+1*(x&y),True,0.02810811996459961
7 | -1*x-1*~y+4*(~(x&~x))-1*(~(x^y))+y-4*(~(x&y))-1*(~(x&~y))+2*(~(x|y))-1*(~(x|~y))+2*(x&~y)-2*(x&y),-~x,-1*~x,-1*~x,True,0.036657094955444336
8 | (~(x&~x))+y-2*(x^y)-1*~y+x-1*(~(x&~y))-2*~x-3*(~(x|y))-2*(~(x|~y))-4*(x&~y)-3*(x&y),-5*(~(x&y))-(~(x^y)),-6*~(x|y)-5*~(x|~y)-5*(x&~y)-1*(x&y),-6*~(x|y)-5*~(x|~y)-5*(x&~y)-1*(x&y),True,0.028145551681518555
9 | (~(x&y))+(x^y)-1*y+x-2*(x|~y)+2*(~(x&~y))+~y-1*(~(x^y))-1*(~(x|y))-4*(~(x|~y))-3*(x&~y),-(x|y),-1*(x|y),-1*(x|y),True,0.02967524528503418
10 | -1*x-1*~x+4*(x|~y)-1*(~(x&~y))-1*~y-4*(x&~y)-1*(x&y),1*(~(x^y))-2*(x^y),1*~(x|y)-2*~(x|~y)-2*(x&~y)+1*(x&y),1*~(x|y)-2*~(x|~y)-2*(x&~y)+1*(x&y),True,0.030411243438720703
11 | 2*~x+5*(~(x^y))-1*(~(x&y))+(x^y)+x-1*(~(x&~y))+(x|~y)-7*(~(x|y))-3*(~(x|~y))-3*(x&~y)-8*(x&y),-y-(~(x&~x)),-1*~(x|y)-2*~(x|~y)-1*(x&~y)-2*(x&y),-1*~(x|y)-2*~(x|~y)-1*(x&~y)-2*(x&y),True,0.035628318786621094
12 | -3*~(x^y)-6*~y-2*(x^y)-7*~(x&y)+1*~(x&~x)+2*~(x&~y)-11*(x|~y)-6*x-2*y+24*~(x|y)+8*~(x|~y)+31*(x&~y),-19*(x&y),-19*(x&y),-19*(x&y),True,0.036316633224487305
13 | 1*((x|y)&~(y^z))+1*~(x|(y|z))-2*~(~x|(y|z))-2*(x&(y&z)),1*(~x&(~y|z))-1*((x|~y)&(x^(y^z))),1*~(x|(y|z))-1*~(~x|(y|z))+1*(~x&(y&z))-1*(x&(y&z)),1*~(x|(y|z))-1*~(~x|(y|z))+1*(~x&(y&z))-1*(x&(y&z)),True,0.03185009956359863
14 | -3*(z^~(~x|(~y&z)))-1*(x&(~y|z))-4*~(x|(~y|z))-1*~(~x|(~y|z))+3*(~x&(~y&z))-1*(~x&(y&z))-3*(x&(y&z)),-4*(x|y),-4*(x|y),-4*(x|y),True,0.02678203582763672
15 | 2*(y|~(x^z))-1*(~x&(~y|z))+2*~(x^(y|z))-3*~(x|(y|z))-2*~(x|(~y|z))+1*(~x&(~y&z))-4*(x&(~y&z))-4*(x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),True,0.024659156799316406
16 | 5*(~x&(y^z))+1*(x&(y^z))+1*((x&~y)|(x^(y^z)))-6*~(x|(~y|z))-1*~(~x|(y|z))-1*~(~x|(~y|z))-2*(x&(~y&z))-1*(x&(y&z)),6*(~x&(~y&z)),6*(~x&(~y&z)),6*(~x&(~y&z)),True,0.02594757080078125
17 | -7*((x^y)&~(x^z))+5*(~z|~(x^y))-3*~(x|(y|z))+4*~(x|(~y|z))-3*~(~x|(y|z))-3*~(~x|(~y|z))-3*(~x&(~y&z))+9*(x&(~y&z))-5*(x&(y&z)),2*~(y&z),2*~(y&z),2*~(y&z),True,0.024266719818115234
18 | -3*~(y^z)+5*(z^(~x|(y|z)))-12*~(x|(y|z))-15*~(x|(~y|z))-8*~(~x|(y|z))-16*~(~x|(~y|z))-8*(~x&(y&z))+1*(x&(~y&z))+3*(x&(y&z)),1*(z^(~x|(y&z)))-11*(z^~(~x&(y&z))),-10*~(x|(y|z))-10*~(x|(~y|z))-11*~(~x|(y|z))-11*~(~x|(~y|z))-11*(~x&(y&z))+1*(x&(~y&z)),-10*~(x|(y|z))-10*~(x|(~y|z))-11*~(~x|(y|z))-11*~(~x|(~y|z))-11*(~x&(y&z))+1*(x&(~y&z)),True,0.028255462646484375
19 | -2*(y|~z)+1*(x^y)+2*~(x|(y|z))+3*~(~x|(y|z))+4*~(~x|(~y|z))+2*(~x&(~y&z))+3*(~x&(y&z))-1*(x&(~y&z))+4*(x&(y&z)),2*(z^~(~x|(y&z)))-1*~(x|(~y|z)),-1*~(x|(~y|z))+2*~(~x|(y|z))+2*~(~x|(~y|z))+2*(~x&(~y&z))+2*(~x&(y&z))+2*(x&(y&z)),-1*~(x|(~y|z))+2*~(~x|(y|z))+2*~(~x|(~y|z))+2*(~x&(~y&z))+2*(~x&(y&z))+2*(x&(y&z)),True,0.027940988540649414
20 | -1*((~(x^(~y&z))&~t)|((z^(~x|(y&z)))&t))+1*((((x&y)^(x^(y&z)))&~t)|(((x&~y)|~(y^z))&t))+1*(((z^~(x&y))&~t)|(((x|y)&~(x^(y^z)))&t))-2*~(~x|(y|(z|t)))-2*~(~x|(~y|(~z|t)))+1*(~x&(y&(~z&t)))-1*(x&(~y&(~z&t)))-2*(~x&(y&(z&t)))-1*(x&(y&(z&t))),1*(x&(y&(~z&t)))+1*(x&(~y&(z&t))),1*(((x&~x)&~t)|((x&(y^z))&t)),1*(((x&~x)&~t)|((x&(y^z))&t)),True,0.022180795669555664
21 | 2*((((y&z)|(~x&(y|z)))&~t)|((y^~(x&(~y&z)))&t))-2*(((z^~(~x&(y|z)))&~t)|(((x|y)&~(y^z))&t))-2*(((z^~(x|(~y&z)))&~t)|(((x&y)^(x^(~y|z)))&t))-2*((((x^y)&(x^z))&~t)|((~(x|y)|~(y^z))&t))+4*~(x|(y|(z|t)))+4*~(~x|(y|(z|t)))+2*~(~x|(~y|(z|t)))+2*~(x|(y|(~z|t)))+2*~(x|(~y|(~z|t)))+2*~(~x|(y|(~z|t)))+2*(~x&(~y&(~z&t)))+2*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),-2*(x&(~y&(~z&t))),-2*(x&(~y&(~z&t))),-2*(x&(~y&(~z&t))),True,0.028020858764648438
22 | 3*(((z^~(x|y))&~t)|((y^~(x&(y&z)))&t))+7*(((~y&~(x^z))&~t)|(~(x&~y)&t))+1*(((y^~(~x|(y&z)))&~t)|((x&~x)&t))-1*((~(x|(y|z))&~t)|((z^~(x|(~y&z)))&t))+2*((((x&z)^(x^(~y&z)))&~t)|(((x&y)^~(x^(y&z)))&t))-9*(((x^(y|z))&~t)|(((y&z)|(~x&(y|z)))&t))+1*(((y|(x&~z))&~t)|((~(x|y)|~(x^(y^z)))&t))-5*(((~(x^y)|~(x^z))&~t)|(((x|y)&(x^(y^z)))&t))-4*((((x|~y)&~(x^(y^z)))&~t)|((y|(x^z))&t))+9*(((y^~(x|(~y&z)))&~t)|((x&z)&t))-1*((((x&y)^(x^(~y|z)))&~t)|((z^~(x&~y))&t))-3*(((y^~(x&(y^z)))&~t)|((z^~(~x&(~y|z)))&t))+1*((~(~x&(y&z))&~t)|(~(x^(~y&z))&t))-4*(((x&~z)&~t)|((z&~(x^y))&t))+11*~(x|(~y|(z|t)))+11*~(~x|(y|(z|t)))+3*~(~x|(~y|(z|t)))+15*~(x|(y|(~z|t)))+5*~(x|(~y|(~z|t)))-9*~(~x|(~y|(~z|t)))-12*(~x&(~y&(~z&t)))+13*(~x&(y&(~z&t)))+15*(x&(~y&(~z&t)))+4*(x&(y&(~z&t)))+14*(~x&(~y&(z&t)))+13*(~x&(y&(z&t)))-12*(x&(~y&(z&t)))+10*(x&(y&(z&t))),-1*~(~x|(y|(~z|t)))+6*(((~y&~(x^z))&~t)|((z^~(~x|(y&z)))&t)),6*~(x|(y|(z|t)))+5*~(~x|(y|(~z|t)))+6*(x&(~y&(~z&t)))+6*(x&(y&(~z&t)))+6*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),6*~(x|(y|(z|t)))+5*~(~x|(y|(~z|t)))+6*(x&(~y&(~z&t)))+6*(x&(y&(~z&t)))+6*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),True,0.03368663787841797
23 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_linear_MBA.txt.z3.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,z3res,verificationtime
2 | (x|y)+y-(~x&y),x+y,True,0.056780099868774414
3 | 3*(x&~y)-(x^y)+~x-~(x&y),x-y,True,1.4941563606262207
4 | -1*(~(x&y))+(x|y)-1*(x^y)-1*x+2*~x-1*(~(x&~y))-1*(~(x^y))-1*(x|~y)+3*(~(x|y))+1*(~(x|~y))+4*(x&~y)+4*(x&y),1*y+1*~y,Timeout,5.011584043502808
5 | -2*(~(x&y))-2*~y-2*~x+(~(x^y))-2*x-1*y-1*(x|y)+(x|~y)+6*(~(x|y))+8*(~(x|~y))+7*(x&~y)+4*(x&y),1*(~(x&~x))+1*(~(x&~y)),Timeout,5.010826349258423
6 | -1*(x|y)+(~(x&~y))+2*y-2*~y-1*~x-1*(~(x&~x))+(~(x^y))+x+2*(~(x|y))-1*(~(x|~y))+3*(x&~y)-2*(x&y),-(~(x&y))+1*(x|~y),Timeout,5.009274244308472
7 | -1*x-1*~y+4*(~(x&~x))-1*(~(x^y))+y-4*(~(x&y))-1*(~(x&~y))+2*(~(x|y))-1*(~(x|~y))+2*(x&~y)-2*(x&y),-~x,Timeout,5.010176420211792
8 | (~(x&~x))+y-2*(x^y)-1*~y+x-1*(~(x&~y))-2*~x-3*(~(x|y))-2*(~(x|~y))-4*(x&~y)-3*(x&y),-5*(~(x&y))-(~(x^y)),Timeout,5.008573532104492
9 | (~(x&y))+(x^y)-1*y+x-2*(x|~y)+2*(~(x&~y))+~y-1*(~(x^y))-1*(~(x|y))-4*(~(x|~y))-3*(x&~y),-(x|y),Timeout,5.010337829589844
10 | -1*x-1*~x+4*(x|~y)-1*(~(x&~y))-1*~y-4*(x&~y)-1*(x&y),1*(~(x^y))-2*(x^y),Timeout,5.008653163909912
11 | 2*~x+5*(~(x^y))-1*(~(x&y))+(x^y)+x-1*(~(x&~y))+(x|~y)-7*(~(x|y))-3*(~(x|~y))-3*(x&~y)-8*(x&y),-y-(~(x&~x)),Timeout,5.010957956314087
12 | -3*~(x^y)-6*~y-2*(x^y)-7*~(x&y)+1*~(x&~x)+2*~(x&~y)-11*(x|~y)-6*x-2*y+24*~(x|y)+8*~(x|~y)+31*(x&~y),-19*(x&y),Timeout,5.010417222976685
13 | 1*((x|y)&~(y^z))+1*~(x|(y|z))-2*~(~x|(y|z))-2*(x&(y&z)),1*(~x&(~y|z))-1*((x|~y)&(x^(y^z))),True,1.62892746925354
14 | -3*(z^~(~x|(~y&z)))-1*(x&(~y|z))-4*~(x|(~y|z))-1*~(~x|(~y|z))+3*(~x&(~y&z))-1*(~x&(y&z))-3*(x&(y&z)),-4*(x|y),Timeout,5.00928521156311
15 | 2*(y|~(x^z))-1*(~x&(~y|z))+2*~(x^(y|z))-3*~(x|(y|z))-2*~(x|(~y|z))+1*(~x&(~y&z))-4*(x&(~y&z))-4*(x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),Timeout,5.057357549667358
16 | 5*(~x&(y^z))+1*(x&(y^z))+1*((x&~y)|(x^(y^z)))-6*~(x|(~y|z))-1*~(~x|(y|z))-1*~(~x|(~y|z))-2*(x&(~y&z))-1*(x&(y&z)),6*(~x&(~y&z)),Timeout,5.011525869369507
17 | -7*((x^y)&~(x^z))+5*(~z|~(x^y))-3*~(x|(y|z))+4*~(x|(~y|z))-3*~(~x|(y|z))-3*~(~x|(~y|z))-3*(~x&(~y&z))+9*(x&(~y&z))-5*(x&(y&z)),2*~(y&z),Timeout,5.009667873382568
18 | -3*~(y^z)+5*(z^(~x|(y|z)))-12*~(x|(y|z))-15*~(x|(~y|z))-8*~(~x|(y|z))-16*~(~x|(~y|z))-8*(~x&(y&z))+1*(x&(~y&z))+3*(x&(y&z)),1*(z^(~x|(y&z)))-11*(z^~(~x&(y&z))),Timeout,5.009520530700684
19 | -2*(y|~z)+1*(x^y)+2*~(x|(y|z))+3*~(~x|(y|z))+4*~(~x|(~y|z))+2*(~x&(~y&z))+3*(~x&(y&z))-1*(x&(~y&z))+4*(x&(y&z)),2*(z^~(~x|(y&z)))-1*~(x|(~y|z)),Timeout,5.010574817657471
20 | -1*((~(x^(~y&z))&~t)|((z^(~x|(y&z)))&t))+1*((((x&y)^(x^(y&z)))&~t)|(((x&~y)|~(y^z))&t))+1*(((z^~(x&y))&~t)|(((x|y)&~(x^(y^z)))&t))-2*~(~x|(y|(z|t)))-2*~(~x|(~y|(~z|t)))+1*(~x&(y&(~z&t)))-1*(x&(~y&(~z&t)))-2*(~x&(y&(z&t)))-1*(x&(y&(z&t))),1*(x&(y&(~z&t)))+1*(x&(~y&(z&t))),Timeout,5.009374380111694
21 | 2*((((y&z)|(~x&(y|z)))&~t)|((y^~(x&(~y&z)))&t))-2*(((z^~(~x&(y|z)))&~t)|(((x|y)&~(y^z))&t))-2*(((z^~(x|(~y&z)))&~t)|(((x&y)^(x^(~y|z)))&t))-2*((((x^y)&(x^z))&~t)|((~(x|y)|~(y^z))&t))+4*~(x|(y|(z|t)))+4*~(~x|(y|(z|t)))+2*~(~x|(~y|(z|t)))+2*~(x|(y|(~z|t)))+2*~(x|(~y|(~z|t)))+2*~(~x|(y|(~z|t)))+2*(~x&(~y&(~z&t)))+2*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),-2*(x&(~y&(~z&t))),Timeout,5.010774850845337
22 | 3*(((z^~(x|y))&~t)|((y^~(x&(y&z)))&t))+7*(((~y&~(x^z))&~t)|(~(x&~y)&t))+1*(((y^~(~x|(y&z)))&~t)|((x&~x)&t))-1*((~(x|(y|z))&~t)|((z^~(x|(~y&z)))&t))+2*((((x&z)^(x^(~y&z)))&~t)|(((x&y)^~(x^(y&z)))&t))-9*(((x^(y|z))&~t)|(((y&z)|(~x&(y|z)))&t))+1*(((y|(x&~z))&~t)|((~(x|y)|~(x^(y^z)))&t))-5*(((~(x^y)|~(x^z))&~t)|(((x|y)&(x^(y^z)))&t))-4*((((x|~y)&~(x^(y^z)))&~t)|((y|(x^z))&t))+9*(((y^~(x|(~y&z)))&~t)|((x&z)&t))-1*((((x&y)^(x^(~y|z)))&~t)|((z^~(x&~y))&t))-3*(((y^~(x&(y^z)))&~t)|((z^~(~x&(~y|z)))&t))+1*((~(~x&(y&z))&~t)|(~(x^(~y&z))&t))-4*(((x&~z)&~t)|((z&~(x^y))&t))+11*~(x|(~y|(z|t)))+11*~(~x|(y|(z|t)))+3*~(~x|(~y|(z|t)))+15*~(x|(y|(~z|t)))+5*~(x|(~y|(~z|t)))-9*~(~x|(~y|(~z|t)))-12*(~x&(~y&(~z&t)))+13*(~x&(y&(~z&t)))+15*(x&(~y&(~z&t)))+4*(x&(y&(~z&t)))+14*(~x&(~y&(z&t)))+13*(~x&(y&(z&t)))-12*(x&(~y&(z&t)))+10*(x&(y&(z&t))),-1*~(~x|(y|(~z|t)))+6*(((~y&~(x^z))&~t)|((z^~(~x|(y&z)))&t)),Timeout,5.011717081069946
23 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_nonpoly_MBA.txt.z3.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,z3res,verificationtime
2 | ((3*(a&b)+2*(a&~b)-2*~(a&~a)+1*~(a|b)+2*~(a|~b)+1*~b)&y)*((3*(a&b)+2*(a&~b)-2*~(a&~a)+1*~(a|b)+2*~(a|~b)+1*~b)|y)+((3*(a&b)+2*(a&~b)-2*~(a&~a)+1*~(a|b)+2*~(a|~b)+1*~b)&~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11*~(a|b)-11*~a)&~(-10*(a&b)+1*(a&~b)+11*b+11*~(a|b)-11*~a))+4*~((-10*(a&b)+1*(a&~b)+11*b+11*~(a|b)-11*~a)|y)+20*((-10*(a&b)+1*(a&~b)+11*b+11*~(a|b)-11*~a)&~y)-1*((-10*(a&b)+1*(a&~b)+11*b+11*~(a|b)-11*~a)&y),5*(a|~y)-12*~(a|~y),Timeout,5.010175704956055
13 | 1*((7*(a&b)+4*(a&~b)-3*a-3*~(a^b)+3*~(a|b))^(y&z))+1*~((7*(a&b)+4*(a&~b)-3*a-3*~(a^b)+3*~(a|b))|(y|z))+1*~(~(7*(a&b)+4*(a&~b)-3*a-3*~(a^b)+3*~(a|b))|(y|z))+1*((7*(a&b)+4*(a&~b)-3*a-3*~(a^b)+3*~(a|b))&(~y&z))+2*((7*(a&b)+4*(a&~b)-3*a-3*~(a^b)+3*~(a|b))&(y&z)),1*((a&z)|~(y|z))+1*(a|(y&z)),Timeout,5.010781526565552
14 | 1*(z^((-10*(a&b)+1*(a^b)+11*~(a&~b)-11*~(a|b)-12*~(a|~b))&(y|z)))+1*(((-10*(a&b)+1*(a^b)+11*~(a&~b)-11*~(a|b)-12*~(a|~b))&y)^(y|z))+1*(y^(~(-10*(a&b)+1*(a^b)+11*~(a&~b)-11*~(a|b)-12*~(a|~b))|(y&z)))-2*~(~(-10*(a&b)+1*(a^b)+11*~(a&~b)-11*~(a|b)-12*~(a|~b))|(~y|z))-3*(~(-10*(a&b)+1*(a^b)+11*~(a&~b)-11*~(a|b)-12*~(a|~b))&(~y&z))-2*(~(-10*(a&b)+1*(a^b)+11*~(a&~b)-11*~(a|b)-12*~(a|~b))&(y&z))-1*((-10*(a&b)+1*(a^b)+11*~(a&~b)-11*~(a|b)-12*~(a|~b))&(~y&z)),1*~(a|(y|z))+1*~(a|(~y|z)),Timeout,5.0105791091918945
15 | 1*(~(4*(a&b)-2*(a&~b)-3*~(a^b)+3*~b)&(~y|z))-5*(y^~(~(4*(a&b)-2*(a&~b)-3*~(a^b)+3*~b)&(y^z)))-2*(z|((4*(a&b)-2*(a&~b)-3*~(a^b)+3*~b)^y))+7*~((4*(a&b)-2*(a&~b)-3*~(a^b)+3*~b)|(~y|z))+7*~(~(4*(a&b)-2*(a&~b)-3*~(a^b)+3*~b)|(y|z))+1*(~(4*(a&b)-2*(a&~b)-3*~(a^b)+3*~b)&(y&z))+7*((4*(a&b)-2*(a&~b)-3*~(a^b)+3*~b)&(~y&z))+2*((4*(a&b)-2*(a&~b)-3*~(a^b)+3*~b)&(y&z)),-4*~(a|(y|z))-1*(~a&(~y&z)),Timeout,5.0103161334991455
16 | -1*(((-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))&z)^((-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))^(y&z)))+2*(~((-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))&~y)&~(y^z))+1*((y&~z)^((-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))|(y^z)))+1*~(~(-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))|(~y|z))-1*(~(-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))&(~y&z))-1*(~(-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))&(y&z))-1*((-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))&(~y&z))-2*((-10*(a&b)-17*(a&~b)+7*(a^b)+11*(a|~b)-11*~(a|b)-7*~(a|~b))&(y&z)),2*~(a|(y|z)),Timeout,5.011632442474365
17 | -7*~((1*(a&b)+1*(a&~b)+5*b-5*~(a&~b)+5*~(a|b))&~z)-7*(~z&~((1*(a&b)+1*(a&~b)+5*b-5*~(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z)),5*(a&(y&z))-2*~(~a|(y|z)),Timeout,5.009333848953247
19 | 7*~(~(-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))|(~y&z))-7*(y^~((-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))|z))-11*(~(-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))|(~y|z))-6*((-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))&(~y|z))+11*~((-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))|(~y|z))+10*~(~(-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))|(y|z))+18*(~(-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))&(y&z))+17*((-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))&(~y&z))+17*((-1*(a&~b)+1*(a|~b)+1*~(a&b)-2*~(a|b)-1*~(a|~b))&(y&z)),-18*~(a|(y|z))-11*(~a&(~y&z)),Timeout,5.010852098464966
20 | (x&~(y-1))*(x|~(y-1))+(x&~(~(y-1)))*(~x&~(y-1))+(x|~y)+2*y+4*x+(~(x&~y))+(~(x^y))+2*(~(x&~x))-5*(~(x|y))-6*(~(x|~y))-8*(x&~y)-12*(x&y),x*(-y)-(x|y),Timeout,5.013050079345703
21 | (x&~(y-1))*(x|~(y-1))+(x&~(~(y-1)))*(~x&~(y-1))-3*(~(x^y))-5*(x|y)-1*(~(x&y))-3*(~(x&~y))-1*(x^y)+(x|~y)-1*x+(~(x&~x))+4*(~(x|y))+8*(~(x|~y))+6*(x&~y)+10*(x&y),x*(-y)-~x,Timeout,5.010507106781006
22 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_poly_MBA.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth
2 | (x&y)*(x|y)+(x&~y)*(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~x&(y|z)))-1*(~x|(y|z))-2*(~(x&~y)&(x^(y^z)))+1*(~z|~(x^y))+1*(y^~(x&(y^z)))+3*~(x&(y|z))-2*(~(x&y)&~(x^(y^z)))-5*~(~x&(~y|z))+1*((x&z)^~(x^(y&z)))+7*(x|~y)+5*(y^~(x&~z))-3*(~(x|y)|(y^z))+11*(~z|(x^y))-1*((x&~y)|(y^z))-11*~(x&(y&z))+14*~(x|(~y|z))-5*~(~x|(~y|z))-12*(~x&(~y&z))+6*(~x&(y&z))-5*(x&(~y&z))-11*(x&(y&z)),x*y+24*~(x|(y|z))
23 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_poly_MBA.txt.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,simplifiedcomplex,simplifiedgroundtruth,z3flag,simtime
2 | (x&y)*(x|y)+(x&~y)*(~x&y)-41,x*y-41,x*y+41*~(x&~x),x*y+41*~(x&~x),True,0.5204839706420898
3 | (x&y)*(x|y)+(x&~y)*(~x&y)-253,x*y-253,x*y+253*~(x&~x),x*y+253*~(x&~x),True,0.03568553924560547
4 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*~x+1*(x|~y)-1*~(x|~y)-3*(x&~y),x*y+1*(x&y)-2*(x^y),x*y+3*x+3*y-5*(x|y),x*y+3*x+3*y-5*(x|y),True,0.05966973304748535
5 | (x&y)*(x|y)+(x&~y)*(~x&y)+5*~y-11*(x|~y)+6*~(x|y)+8*(x&~y),x*y-13*(x&y)+2*x,x*y-11*x-13*y+13*(x|y),x*y-11*x-13*y+13*(x|y),True,0.05811810493469238
6 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*y+2*~(x&y)-2*(x^y)+1*(x&y),x*y-3*~(x|~y)+2*~x,x*y+x-3*(x|y)+2*~(x&~x),x*y+x-3*(x|y)+2*~(x&~x),True,0.04904937744140625
7 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*~(x&y)-11*~(x^y)+12*~(x|y)+1*~(x|~y)+11*(x&y),x*y+2*~x+1*(x&~y),x*y-2*x-y+(x|y)+2*~(x&~x),x*y-2*x-y+(x|y)+2*~(x&~x),True,0.071502685546875
8 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*~x+5*x-2*~(x^y)+13*~(x|y)+11*~(x|~y),x*y+5*(x&~y)+3*(x&y),x*y+3*x-2*y+2*(x|y),x*y+3*x-2*y+2*(x|y),True,0.05661463737487793
9 | (x&y)*(x|y)+(x&~y)*(~x&y)-2*~(x&~x)+2*y+3*~(x|y)+1*~(x|~y)+2*(x&~y),x*y+1*~x,x*y-x+~(x&~x),x*y-x+~(x&~x),True,0.045102834701538086
10 | (x&y)*(x|y)+(x&~y)*(~x&y)+11*(x|~y)+3*~(x&~x)+5*~(x&y)-19*(x&~y)-14*(x&y),x*y+19*~(x|y)+8*~(x|~y),x*y-8*x-11*(x|y)+19*~(x&~x),x*y-8*x-11*(x|y)+19*~(x&~x),True,0.0661630630493164
11 | (x&y)*(x|y)+(x&~y)*(~x&y)+7*~y+4*~(x&y)+11*~(x&~x)-22*~(x|y)-11*(x&y),x*y+15*~(x|~y)+22*(x&~y),x*y-15*x-22*y+37*(x|y),x*y-15*x-22*y+37*(x|y),True,0.058561086654663086
12 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*(x|~y)-3*~y+2*x+14*~(x|y)+12*(x&~y),x*y-9*(x&y),x*y-9*x-9*y+9*(x|y),x*y-9*x-9*y+9*(x|y),True,0.05002331733703613
13 | (x&y)*(x|y)+(x&~y)*(~x&y)+2*(x|y)-4*~(x|y)-2*~(x|~y)-1*(x&~y)-7*(x&y),x*y-5*~(x^y)+1*~y,x*y-5*x-6*y+10*(x|y)-4*~(x&~x),x*y-5*x-6*y+10*(x|y)-4*~(x&~x),True,0.07141613960266113
14 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*~y+1*y+3*~(x|y)+3*(x&~y)+1*(x&y),x*y-1*~(x|~y)+2*~(x&~x),x*y+x-(x|y)+2*~(x&~x),x*y+x-(x|y)+2*~(x&~x),True,0.044994354248046875
15 | (x&y)*(x|y)+(x&~y)*(~x&y)+2*~(x&~y)-5*~(x&y)-1*x+5*~(x|y)+3*~(x|~y)+1*(x&y),x*y-6*(x&~y)+2*~(x^y),x*y+2*x+8*y-10*(x|y)+2*~(x&~x),x*y+2*x+8*y-10*(x|y)+2*~(x&~x),True,0.06714129447937012
16 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(y^~(~x|(~y&z)))-1*(y^~(x|~z))+1*~(x|(~y|z))+1*~(~x|(~y|z))+1*(x&(~y&z))+1*(x&(y&z)),x*y+1*(x^y)-1*(~x&(~y&z)),x*y+x+y-z-2*(x&y)+(y&z)+(x&z)-(x&y&z),x*y+x+y-z-2*(x&y)+(y&z)+(x&z)-(x&y&z),True,0.0675041675567627
17 | (x&y)*(x|y)+(x&~y)*(~x&y)+4*(y&z)-1*~(x^y)+2*(~x|(y&z))-1*~(x|(y|z))-2*~(x|(~y|z))+1*~(~x|(~y|z))-1*(~x&(~y&z)),x*y+6*(~x&(y&z))+5*(x&(y&z)),x*y+6*(y&z)-(x&y&z),x*y+6*(y&z)-(x&y&z),True,0.04415774345397949
18 | (x&y)*(x|y)+(x&~y)*(~x&y)+3*(z^(~x|(y&z)))-11*(y&~(x&z))+4*(z^(~x|(y|z)))-7*~(x|(y|z))+4*~(x|(~y|z))+7*~(~x|(~y|z))+11*(~x&(y&z)),x*y+3*(x&(~y&z)),x*y+3*(x&z)-3*(x&y&z),x*y+3*(x&z)-3*(x&y&z),True,0.045854806900024414
19 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(z^~(x&(y&z)))-2*((x|~y)&~(y^z))+1*~(x|(y|z))-1*~(x|(~y|z))-10*~(~x|(y|z))-12*~(~x|(~y|z))-11*(~x&(y&z))-10*(x&(y&z)),x*y-11*((x&z)^(x^(y&z))),x*y-11*x-11*(y&z)+11*(x&z),x*y-11*x-11*(y&z)+11*(x&z),True,0.052782297134399414
20 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*((y&~z)|~(~x|(~y&z)))+4*(z^~(~x|(y&z)))+11*~(x|(~y|z))+7*~(~x|(y|z))+6*~(~x|(~y|z))-4*(~x&(y&z))-1*(x&(~y&z))+7*(x&(y&z)),x*y-1*(x&(y^z))+4*(~x&(~y&z)),x*y+4*z-(x&y)-4*(y&z)-5*(x&z)+6*(x&y&z),x*y+4*z-(x&y)-4*(y&z)-5*(x&z)+6*(x&y&z),True,0.07485461235046387
21 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(y^~(~x|(y^z)))+2*(y^~(x|~z))+1*((x&y)^(y|~z))-1*~(x|(y|z))-4*~(x|(~y|z))-3*~(~x|(~y|z))-2*(~x&(~y&z))-2*(~x&(y&z)),x*y+2*(x&(y&z))+2*~(~x|(y|z)),x*y+2*x-2*(x&y)-2*(x&z)+4*(x&y&z),x*y+2*x-2*(x&y)-2*(x&z)+4*(x&y&z),True,0.05471205711364746
22 | (x&y)*(x|y)+(x&~y)*(~x&y)+11*(y^(~x|(y^z)))-7*(x^y)+1*(z^~(~x&(y|z)))-1*(~x|(y|z))-2*(~(x&~y)&(x^(y^z)))+1*(~z|~(x^y))+1*(y^~(x&(y^z)))+3*~(x&(y|z))-2*(~(x&y)&~(x^(y^z)))-5*~(~x&(~y|z))+1*((x&z)^~(x^(y&z)))+7*(x|~y)+5*(y^~(x&~z))-3*(~(x|y)|(y^z))+11*(~z|(x^y))-1*((x&~y)|(y^z))-11*~(x&(y&z))+14*~(x|(~y|z))-5*~(~x|(~y|z))-12*(~x&(~y&z))+6*(~x&(y&z))-5*(x&(~y&z))-11*(x&(y&z)),x*y+24*~(x|(y|z)),x*y-24*x-24*y-24*z+24*(x&y)+24*(y&z)+24*(x&z)-24*(x&y&z)+24*~(x&~x),x*y-24*x-24*y-24*z+24*(x&y)+24*(y&z)+24*(x&z)-24*(x&y&z)+24*~(x&~x),True,0.09815120697021484
23 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_poly_MBA.txt.simplify.txt.z3.verify.64bit.after.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,simcomplex,simground,z3res,verificationtime
2 | (x&y)*(x|y)+(x&~y)*(~x&y)-41,x*y-41,x*y+41*~(x&~x),x*y+41*~(x&~x),True,0.02458500862121582
3 | (x&y)*(x|y)+(x&~y)*(~x&y)-253,x*y-253,x*y+253*~(x&~x),x*y+253*~(x&~x),True,0.02291560173034668
4 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*~x+1*(x|~y)-1*~(x|~y)-3*(x&~y),x*y+1*(x&y)-2*(x^y),x*y+3*x+3*y-5*(x|y),x*y+3*x+3*y-5*(x|y),True,0.025364160537719727
5 | (x&y)*(x|y)+(x&~y)*(~x&y)+5*~y-11*(x|~y)+6*~(x|y)+8*(x&~y),x*y-13*(x&y)+2*x,x*y-11*x-13*y+13*(x|y),x*y-11*x-13*y+13*(x|y),True,0.024629592895507812
6 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*y+2*~(x&y)-2*(x^y)+1*(x&y),x*y-3*~(x|~y)+2*~x,x*y+x-3*(x|y)+2*~(x&~x),x*y+x-3*(x|y)+2*~(x&~x),True,0.023906230926513672
7 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*~(x&y)-11*~(x^y)+12*~(x|y)+1*~(x|~y)+11*(x&y),x*y+2*~x+1*(x&~y),x*y-2*x-y+(x|y)+2*~(x&~x),x*y-2*x-y+(x|y)+2*~(x&~x),True,0.025180816650390625
8 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*~x+5*x-2*~(x^y)+13*~(x|y)+11*~(x|~y),x*y+5*(x&~y)+3*(x&y),x*y+3*x-2*y+2*(x|y),x*y+3*x-2*y+2*(x|y),True,0.02537250518798828
9 | (x&y)*(x|y)+(x&~y)*(~x&y)-2*~(x&~x)+2*y+3*~(x|y)+1*~(x|~y)+2*(x&~y),x*y+1*~x,x*y-x+~(x&~x),x*y-x+~(x&~x),True,0.027803897857666016
10 | (x&y)*(x|y)+(x&~y)*(~x&y)+11*(x|~y)+3*~(x&~x)+5*~(x&y)-19*(x&~y)-14*(x&y),x*y+19*~(x|y)+8*~(x|~y),x*y-8*x-11*(x|y)+19*~(x&~x),x*y-8*x-11*(x|y)+19*~(x&~x),True,0.024382591247558594
11 | (x&y)*(x|y)+(x&~y)*(~x&y)+7*~y+4*~(x&y)+11*~(x&~x)-22*~(x|y)-11*(x&y),x*y+15*~(x|~y)+22*(x&~y),x*y-15*x-22*y+37*(x|y),x*y-15*x-22*y+37*(x|y),True,0.029717683792114258
12 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*(x|~y)-3*~y+2*x+14*~(x|y)+12*(x&~y),x*y-9*(x&y),x*y-9*x-9*y+9*(x|y),x*y-9*x-9*y+9*(x|y),True,0.025109291076660156
13 | (x&y)*(x|y)+(x&~y)*(~x&y)+2*(x|y)-4*~(x|y)-2*~(x|~y)-1*(x&~y)-7*(x&y),x*y-5*~(x^y)+1*~y,x*y-5*x-6*y+10*(x|y)-4*~(x&~x),x*y-5*x-6*y+10*(x|y)-4*~(x&~x),True,0.024605751037597656
14 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*~y+1*y+3*~(x|y)+3*(x&~y)+1*(x&y),x*y-1*~(x|~y)+2*~(x&~x),x*y+x-(x|y)+2*~(x&~x),x*y+x-(x|y)+2*~(x&~x),True,0.023714542388916016
15 | (x&y)*(x|y)+(x&~y)*(~x&y)+2*~(x&~y)-5*~(x&y)-1*x+5*~(x|y)+3*~(x|~y)+1*(x&y),x*y-6*(x&~y)+2*~(x^y),x*y+2*x+8*y-10*(x|y)+2*~(x&~x),x*y+2*x+8*y-10*(x|y)+2*~(x&~x),True,0.03356504440307617
16 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(y^~(~x|(~y&z)))-1*(y^~(x|~z))+1*~(x|(~y|z))+1*~(~x|(~y|z))+1*(x&(~y&z))+1*(x&(y&z)),x*y+1*(x^y)-1*(~x&(~y&z)),x*y+x+y-z-2*(x&y)+(y&z)+(x&z)-(x&y&z),x*y+x+y-z-2*(x&y)+(y&z)+(x&z)-(x&y&z),True,0.025049448013305664
17 | (x&y)*(x|y)+(x&~y)*(~x&y)+4*(y&z)-1*~(x^y)+2*(~x|(y&z))-1*~(x|(y|z))-2*~(x|(~y|z))+1*~(~x|(~y|z))-1*(~x&(~y&z)),x*y+6*(~x&(y&z))+5*(x&(y&z)),x*y+6*(y&z)-(x&y&z),x*y+6*(y&z)-(x&y&z),True,0.024612903594970703
18 | (x&y)*(x|y)+(x&~y)*(~x&y)+3*(z^(~x|(y&z)))-11*(y&~(x&z))+4*(z^(~x|(y|z)))-7*~(x|(y|z))+4*~(x|(~y|z))+7*~(~x|(~y|z))+11*(~x&(y&z)),x*y+3*(x&(~y&z)),x*y+3*(x&z)-3*(x&y&z),x*y+3*(x&z)-3*(x&y&z),True,0.024043798446655273
19 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(z^~(x&(y&z)))-2*((x|~y)&~(y^z))+1*~(x|(y|z))-1*~(x|(~y|z))-10*~(~x|(y|z))-12*~(~x|(~y|z))-11*(~x&(y&z))-10*(x&(y&z)),x*y-11*((x&z)^(x^(y&z))),x*y-11*x-11*(y&z)+11*(x&z),x*y-11*x-11*(y&z)+11*(x&z),True,0.024516820907592773
20 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*((y&~z)|~(~x|(~y&z)))+4*(z^~(~x|(y&z)))+11*~(x|(~y|z))+7*~(~x|(y|z))+6*~(~x|(~y|z))-4*(~x&(y&z))-1*(x&(~y&z))+7*(x&(y&z)),x*y-1*(x&(y^z))+4*(~x&(~y&z)),x*y+4*z-(x&y)-4*(y&z)-5*(x&z)+6*(x&y&z),x*y+4*z-(x&y)-4*(y&z)-5*(x&z)+6*(x&y&z),True,0.02718973159790039
21 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(y^~(~x|(y^z)))+2*(y^~(x|~z))+1*((x&y)^(y|~z))-1*~(x|(y|z))-4*~(x|(~y|z))-3*~(~x|(~y|z))-2*(~x&(~y&z))-2*(~x&(y&z)),x*y+2*(x&(y&z))+2*~(~x|(y|z)),x*y+2*x-2*(x&y)-2*(x&z)+4*(x&y&z),x*y+2*x-2*(x&y)-2*(x&z)+4*(x&y&z),True,0.025650978088378906
22 | (x&y)*(x|y)+(x&~y)*(~x&y)+11*(y^(~x|(y^z)))-7*(x^y)+1*(z^~(~x&(y|z)))-1*(~x|(y|z))-2*(~(x&~y)&(x^(y^z)))+1*(~z|~(x^y))+1*(y^~(x&(y^z)))+3*~(x&(y|z))-2*(~(x&y)&~(x^(y^z)))-5*~(~x&(~y|z))+1*((x&z)^~(x^(y&z)))+7*(x|~y)+5*(y^~(x&~z))-3*(~(x|y)|(y^z))+11*(~z|(x^y))-1*((x&~y)|(y^z))-11*~(x&(y&z))+14*~(x|(~y|z))-5*~(~x|(~y|z))-12*(~x&(~y&z))+6*(~x&(y&z))-5*(x&(~y&z))-11*(x&(y&z)),x*y+24*~(x|(y|z)),x*y-24*x-24*y-24*z+24*(x&y)+24*(y&z)+24*(x&z)-24*(x&y&z)+24*~(x&~x),x*y-24*x-24*y-24*z+24*(x&y)+24*(y&z)+24*(x&z)-24*(x&y&z)+24*~(x&~x),True,0.028421640396118164
23 |
--------------------------------------------------------------------------------
/dataset/pldi_dataset_poly_MBA.txt.z3.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,z3res,verificationtime
2 | (x&y)*(x|y)+(x&~y)*(~x&y)-41,x*y-41,Timeout,5.016896724700928
3 | (x&y)*(x|y)+(x&~y)*(~x&y)-253,x*y-253,Timeout,5.011383295059204
4 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*~x+1*(x|~y)-1*~(x|~y)-3*(x&~y),x*y+1*(x&y)-2*(x^y),Timeout,5.011294841766357
5 | (x&y)*(x|y)+(x&~y)*(~x&y)+5*~y-11*(x|~y)+6*~(x|y)+8*(x&~y),x*y-13*(x&y)+2*x,Timeout,5.010409832000732
6 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*y+2*~(x&y)-2*(x^y)+1*(x&y),x*y-3*~(x|~y)+2*~x,Timeout,5.012860298156738
7 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*~(x&y)-11*~(x^y)+12*~(x|y)+1*~(x|~y)+11*(x&y),x*y+2*~x+1*(x&~y),Timeout,5.016038417816162
8 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*~x+5*x-2*~(x^y)+13*~(x|y)+11*~(x|~y),x*y+5*(x&~y)+3*(x&y),Timeout,5.012874126434326
9 | (x&y)*(x|y)+(x&~y)*(~x&y)-2*~(x&~x)+2*y+3*~(x|y)+1*~(x|~y)+2*(x&~y),x*y+1*~x,Timeout,5.007569789886475
10 | (x&y)*(x|y)+(x&~y)*(~x&y)+11*(x|~y)+3*~(x&~x)+5*~(x&y)-19*(x&~y)-14*(x&y),x*y+19*~(x|y)+8*~(x|~y),Timeout,5.00753378868103
11 | (x&y)*(x|y)+(x&~y)*(~x&y)+7*~y+4*~(x&y)+11*~(x&~x)-22*~(x|y)-11*(x&y),x*y+15*~(x|~y)+22*(x&~y),Timeout,5.0125133991241455
12 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*(x|~y)-3*~y+2*x+14*~(x|y)+12*(x&~y),x*y-9*(x&y),Timeout,5.012587070465088
13 | (x&y)*(x|y)+(x&~y)*(~x&y)+2*(x|y)-4*~(x|y)-2*~(x|~y)-1*(x&~y)-7*(x&y),x*y-5*~(x^y)+1*~y,Timeout,5.007381200790405
14 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*~y+1*y+3*~(x|y)+3*(x&~y)+1*(x&y),x*y-1*~(x|~y)+2*~(x&~x),Timeout,5.01177191734314
15 | (x&y)*(x|y)+(x&~y)*(~x&y)+2*~(x&~y)-5*~(x&y)-1*x+5*~(x|y)+3*~(x|~y)+1*(x&y),x*y-6*(x&~y)+2*~(x^y),Timeout,5.0114476680755615
16 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(y^~(~x|(~y&z)))-1*(y^~(x|~z))+1*~(x|(~y|z))+1*~(~x|(~y|z))+1*(x&(~y&z))+1*(x&(y&z)),x*y+1*(x^y)-1*(~x&(~y&z)),Timeout,5.0108819007873535
17 | (x&y)*(x|y)+(x&~y)*(~x&y)+4*(y&z)-1*~(x^y)+2*(~x|(y&z))-1*~(x|(y|z))-2*~(x|(~y|z))+1*~(~x|(~y|z))-1*(~x&(~y&z)),x*y+6*(~x&(y&z))+5*(x&(y&z)),Timeout,5.0070273876190186
18 | (x&y)*(x|y)+(x&~y)*(~x&y)+3*(z^(~x|(y&z)))-11*(y&~(x&z))+4*(z^(~x|(y|z)))-7*~(x|(y|z))+4*~(x|(~y|z))+7*~(~x|(~y|z))+11*(~x&(y&z)),x*y+3*(x&(~y&z)),Timeout,5.011311292648315
19 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(z^~(x&(y&z)))-2*((x|~y)&~(y^z))+1*~(x|(y|z))-1*~(x|(~y|z))-10*~(~x|(y|z))-12*~(~x|(~y|z))-11*(~x&(y&z))-10*(x&(y&z)),x*y-11*((x&z)^(x^(y&z))),Timeout,5.009489059448242
20 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*((y&~z)|~(~x|(~y&z)))+4*(z^~(~x|(y&z)))+11*~(x|(~y|z))+7*~(~x|(y|z))+6*~(~x|(~y|z))-4*(~x&(y&z))-1*(x&(~y&z))+7*(x&(y&z)),x*y-1*(x&(y^z))+4*(~x&(~y&z)),Timeout,5.012082099914551
21 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(y^~(~x|(y^z)))+2*(y^~(x|~z))+1*((x&y)^(y|~z))-1*~(x|(y|z))-4*~(x|(~y|z))-3*~(~x|(~y|z))-2*(~x&(~y&z))-2*(~x&(y&z)),x*y+2*(x&(y&z))+2*~(~x|(y|z)),Timeout,5.011809825897217
22 | (x&y)*(x|y)+(x&~y)*(~x&y)+11*(y^(~x|(y^z)))-7*(x^y)+1*(z^~(~x&(y|z)))-1*(~x|(y|z))-2*(~(x&~y)&(x^(y^z)))+1*(~z|~(x^y))+1*(y^~(x&(y^z)))+3*~(x&(y|z))-2*(~(x&y)&~(x^(y^z)))-5*~(~x&(~y|z))+1*((x&z)^~(x^(y&z)))+7*(x|~y)+5*(y^~(x&~z))-3*(~(x|y)|(y^z))+11*(~z|(x^y))-1*((x&~y)|(y^z))-11*~(x&(y&z))+14*~(x|(~y|z))-5*~(~x|(~y|z))-12*(~x&(~y&z))+6*(~x&(y&z))-5*(x&(~y&z))-11*(x&(y&z)),x*y+24*~(x|(y|z)),Timeout,5.030344724655151
23 |
--------------------------------------------------------------------------------
/dataset/sub-dataset-generator.py:
--------------------------------------------------------------------------------
1 | #/usr/bin/python3
2 |
3 |
4 | def generate_sub_dataset():
5 | """generate a sub-dataset of the entire dataset.
6 | """
7 | linear_dataset = "../dataset/pldi_dataset_linear_MBA.txt"
8 | poly_dataset = "../dataset/pldi_dataset_poly_MBA.txt"
9 | nonpoly_dataset = "../dataset/pldi_dataset_nonpoly_MBA.txt"
10 |
11 | datasets = [linear_dataset, poly_dataset, nonpoly_dataset]
12 | subNameList = ["pldi_dataset_linear_MBA.txt", "pldi_dataset_poly_MBA.txt", "pldi_dataset_nonpoly_MBA.txt"]
13 | for (i, dataset) in enumerate(datasets):
14 | linenum = 0
15 | fw = open(subNameList[i], "w")
16 | print("#complex,groundtruth", file=fw)
17 | with open(dataset, "r") as fr:
18 | for line in fr:
19 | if "#" not in line:
20 | linenum += 1
21 | if linenum % 50 == 3:
22 | print(line, end="", file=fw)
23 |
24 | fw.close()
25 |
26 | return None
27 |
28 | if __name__ == "__main__":
29 | generate_sub_dataset()
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/full-dataset/pldi_dataset_linear_MBA.txt.boolector.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,boolectorres,verificationtime
2 | -x-1,~x,True,0.000498056411743
3 | -(x&y)-(x&~y),-x,True,0.000665187835693
4 | (x|y)+y-(~x&y),x+y,True,0.0560688972473
5 | (x|y)+3*~(x|y)-2*~(x^y)-~(x&y),-(x&y),True,0.460586071014
6 | x+y-(x&y),x|y,True,0.000893831253052
7 | -~(x&y)+(~x|y)+(x&~y),x&y,True,0.0530490875244
8 |
--------------------------------------------------------------------------------
/full-dataset/pldi_dataset_linear_MBA.txt.stp.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,stpres,verificationtime
2 | -x-1,~x,True,0.000393867492676
3 | -(x&y)-(x&~y),-x,True,0.0103130340576
4 | (x|y)+y-(~x&y),x+y,True,0.0138099193573
5 | (x|y)+3*~(x|y)-2*~(x^y)-~(x&y),-(x&y),True,0.758054971695
6 | x+y-(x&y),x|y,True,0.0224099159241
7 | -~(x&y)+(~x|y)+(x&~y),x&y,True,0.0029399394989
8 |
--------------------------------------------------------------------------------
/full-dataset/pldi_dataset_linear_MBA.txt.z3.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,z3res,verificationtime
2 | -x-1,~x,True,0.011144161224365234
3 | -(x&y)-(x&~y),-x,True,0.01035928726196289
4 | (x|y)+y-(~x&y),x+y,True,0.026297569274902344
5 |
--------------------------------------------------------------------------------
/full-dataset/pldi_dataset_poly_MBA.txt.boolector.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/softsec-unh/MBA-Solver/c76231aadb8b033d9e8e6be2baa05ff1464f247e/full-dataset/pldi_dataset_poly_MBA.txt.boolector.verify.64bit.before.simplify.txt
--------------------------------------------------------------------------------
/full-dataset/pldi_dataset_poly_MBA.txt.stp.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/softsec-unh/MBA-Solver/c76231aadb8b033d9e8e6be2baa05ff1464f247e/full-dataset/pldi_dataset_poly_MBA.txt.stp.verify.64bit.before.simplify.txt
--------------------------------------------------------------------------------
/full-dataset/pldi_dataset_poly_MBA.txt.z3.verify.64bit.before.simplify.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,z3res,verificationtime
2 | (x&y)*(x|y)+(x&~y)*(~x&y),x*y,False,13.843185186386108
3 | (x&x)*(x|x)+(x&~x)*(~x&x),x*x,True,0.010366201400756836
4 | (x&y)*(x|y)+(x&~y)*(~x&y)-41,x*y-41,False,2.078094720840454
5 | (x&y)*(x|y)+(x&~y)*(~x&y)-165,x*y-165,False,1.6393213272094727
6 | (x&y)*(x|y)+(x&~y)*(~x&y)-113,x*y-113,False,1.00537109375
7 | (x&y)*(x|y)+(x&~y)*(~x&y)+35,x*y+35,False,0.46757054328918457
8 | (x&y)*(x|y)+(x&~y)*(~x&y)+237,x*y+237,False,0.8047294616699219
9 | (x&y)*(x|y)+(x&~y)*(~x&y)-101,x*y-101,False,0.2569258213043213
10 | (x&y)*(x|y)+(x&~y)*(~x&y)+46,x*y+46,False,0.19785714149475098
11 | (x&y)*(x|y)+(x&~y)*(~x&y)-129,x*y-129,False,0.32764530181884766
12 |
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | MBA-Solver is free software: you can redistribute it and/or modify
2 | it under the terms of the GNU General Public License as published by
3 | the Free Software Foundation, either version 3 of the License, or
4 | (at your option) any later version.
5 |
6 | MBA-Solver is distributed in the hope that it will be useful,
7 | but WITHOUT ANY WARRANTY; without even the implied warranty of
8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 | GNU General Public License for more details.
10 |
11 | You should have received a copy of the GNU General Public License
12 | along with MBA-Solver. If not, see .
--------------------------------------------------------------------------------
/makefile:
--------------------------------------------------------------------------------
1 | quick-demo: z3-solving-original mba-solver-simplify-mba z3-solving-mba-solver-simplify
2 |
3 | boolector: boolector-solving-original boolector-solving-mba-solver-simplify boolector-solving-sspam-simplify boolector-solving-syntia-simplify
4 |
5 | stp: stp-solving-original stp-solving-mba-solver-simplify stp-solving-sspam-simplify stp-solving-syntia-simplify
6 |
7 | z3: z3-solving-original z3-solving-mba-solver-simplify z3-solving-sspam-simplify z3-solving-syntia-simplify
8 |
9 | boolector-solving-original:
10 | @cd boolector_solving && make boolector-solving-before-simplify
11 | boolector-solving-mba-solver-simplify:
12 | @cd boolector_solving && make boolector-solving-mba-solver
13 | boolector-solving-sspam-simplify:
14 | @cd boolector_solving && make boolector-solving-sspam
15 | boolector-solving-syntia-simplify:
16 | @cd boolector_solving && make boolector-solving-syntia
17 |
18 | stp-solving-original:
19 | @cd stp_solving && make stp-solving-before-simplify
20 | stp-solving-mba-solver-simplify:
21 | @cd stp_solving && make stp-solving-mba-solver
22 | stp-solving-sspam-simplify:
23 | @cd stp_solving && make stp-solving-sspam
24 | stp-solving-syntia-simplify:
25 | @cd stp_solving && make stp-solving-syntia
26 |
27 | z3-solving-original:
28 | @cd z3_solving && make z3-solving-before-simplify
29 | z3-solving-mba-solver-simplify:
30 | @cd z3_solving && make z3-solving-mba-solver
31 | z3-solving-sspam-simplify:
32 | @cd z3_solving && make z3-solving-sspam
33 | z3-solving-syntia-simplify:
34 | @cd z3_solving && make z3-solving-syntia
35 |
36 | mba-solver-simplify-mba:
37 | @cd ./mba-simplifier && make mba-solver-simplify
38 |
39 | sspam-simplify-mba:
40 | @cd ./sspam && make sspam-simplify
41 |
42 | syntia-simplify-mba:
43 | @cd ./syntia && make syntia-simplify
44 |
--------------------------------------------------------------------------------
/mba-simplifier/makefile:
--------------------------------------------------------------------------------
1 | linear-simplify:
2 | python3 pldi_dataset_simplify_linear.py ../dataset/pldi_dataset_linear_MBA.txt
3 |
4 | poly-simplify:
5 | python3 pldi_dataset_simplify_poly.py ../dataset/pldi_dataset_poly_MBA.txt
6 |
7 | nonpoly-simplify:
8 | python3 pldi_dataset_simplify_nonpoly.py ../dataset/pldi_dataset_nonpoly_MBA.txt
9 |
10 | mba-solver-simplify:
11 | @echo "-----------MBA-Solver simplify linear MBA samples------------------"
12 | @make linear-simplify
13 | @echo "-----------MBA-Solver simplify linear MBA samples completion-------"
14 | @echo "-----------MBA-Solver simplify poly MBA samples--------------------"
15 | @make poly-simplify
16 | @echo "-----------MBA-Solver simplify poly MBA samples completion---------"
17 | @echo "-----------MBA-Solver simplify nonpoly MBA samples-----------------"
18 | @make nonpoly-simplify
19 | @echo "-----------MBA-Solver simplify nonpoly MBA samples completion------"
20 |
--------------------------------------------------------------------------------
/mba-simplifier/pldi_dataset_simplify_linear.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 |
4 |
5 | import re
6 | import sys
7 | sys.path.append("../tools")
8 | import time
9 | from mba_string_operation import verify_mba_unsat, variable_list
10 | from svector_simplify import SvectorSimplify
11 | from truthtable_search_simplify import PMBASimplify
12 |
13 |
14 |
15 | def simplify_lmba(datafile):
16 | """simplify linear mba expression by the signatrue vector.
17 | Args:
18 | datafile: file storing the original mba expression.
19 | """
20 | filewrite = "{source}.simplify.txt".format(source=datafile)
21 |
22 | fw = open(filewrite, "w")
23 | print("#complex,groundtruth,simplifiedcomplex,simplifiedgroundtruth,z3flag,simtime", file=fw)
24 |
25 | svObj = SvectorSimplify()
26 | linenum = 0
27 | with open(datafile, "rt") as fr:
28 | for line in fr:
29 | if "#" not in line:
30 | linenum += 1
31 | line = line.strip()
32 | itemList = re.split(",", line)
33 | cmbaExpre = itemList[0]
34 | groundtruth = itemList[1]
35 | vnumber = len(variable_list(cmbaExpre))
36 | start = time.time()
37 | simExpre1 = svObj.standard_simplify(cmbaExpre, vnumber)
38 | simExpre2 = svObj.standard_simplify(groundtruth, vnumber)
39 | elapsed = time.time() - start
40 | print("z3 solving...")
41 | #z3res = verify_mba_unsat(groundtruth, simExpre)
42 | z3res = verify_mba_unsat(simExpre1, simExpre2, 2)
43 | print(linenum, cmbaExpre, groundtruth, simExpre1, simExpre2, z3res)
44 | print("z3 solved: ", z3res)
45 | print(cmbaExpre, groundtruth, simExpre1, simExpre2, z3res, elapsed, sep=",", file=fw)
46 |
47 | fw.close()
48 | return None
49 |
50 |
51 |
52 |
53 | def main(fileread):
54 | simplify_lmba(fileread)
55 |
56 | return None
57 |
58 |
59 |
60 | if __name__ == "__main__":
61 | fileread = sys.argv[1]
62 | main(fileread)
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/mba-simplifier/pldi_dataset_simplify_nonpoly.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 |
4 |
5 | import re
6 | import sys
7 | sys.path.append("../tools")
8 | import time
9 | from mba_string_operation import verify_mba_unsat, variable_list, expression_2_term
10 | from svector_simplify import SvectorSimplify
11 | from truthtable_search_simplify import PMBASimplify
12 |
13 |
14 | def simplify_pmba(mbaExpre):
15 | """
16 | """
17 | basisVec = ["x", "y", "(x|y)", "~(x&~x)"]
18 | vnumber = 2
19 | if re.search("z", mbaExpre):
20 | basisVec = ["x", "y", "z", "(x&y)", "(y&z)", "(x&z)", "(x&y&z)", "~(x&~x)"]
21 | vnumber = 3
22 | psObj = PMBASimplify(vnumber, basisVec)
23 | simExpre = psObj.simplify(mbaExpre)
24 | z3res = verify_mba_unsat(simExpre, mbaExpre, 2)
25 | if z3res:
26 | return simExpre
27 | else:
28 | print("error in simplify_pmba")
29 |
30 |
31 |
32 | def simplify_npmba(datafile):
33 | """simplify nonpoly mba expression by the signatrue vector.
34 | Args:
35 | datafile: file storing the original mba expression.
36 | """
37 | filewrite = "{source}.simplify.txt".format(source=datafile)
38 |
39 | fw = open(filewrite, "w")
40 | print("#complex,groundtruth,simplifiedcomplex,simplifiedgroundtruth,z3flag,simtime", file=fw)
41 |
42 | linenum = 0
43 | with open(datafile, "rt") as fr:
44 | for line in fr:
45 | if "#" not in line:
46 | linenum += 1
47 | line = line.strip()
48 | itemList = re.split(",", line)
49 | cmbaExpre = itemList[0]
50 | groundtruth = itemList[1]
51 |
52 | #cannot simplify
53 | if len(itemList) < 3:
54 | start = time.time()
55 | cmbaSimExpre = cmbaExpre
56 | #print("z3 solving: ")
57 | z3res = verify_mba_unsat(cmbaSimExpre, groundtruth, 2)
58 | elapsed = time.time() - start
59 | #print("z3 solved: ", z3res)
60 | if z3res:
61 | print("MBA Solver cannot process: unkown expression")
62 | print(linenum, cmbaExpre, groundtruth, cmbaSimExpre, groundtruth, "unknown")
63 | print(cmbaExpre, groundtruth, cmbaSimExpre, groundtruth, "unknown", elapsed, sep=",",file=fw)
64 | else:
65 | print("error in simplify_npmba")
66 | exit(1)
67 | continue
68 | #can simplify
69 | subExpre = itemList[2]
70 | start = time.time()
71 | #process complex MBA expression
72 | if re.search("x", cmbaExpre):
73 | #process sub-expression
74 | subExpre1 = subExpre.replace("a", "x").replace("b", "y")[1:-1]
75 | subSimExpre = simplify_pmba(subExpre1)
76 | subSimExpre = subSimExpre.replace("x", "a").replace("y", "b")
77 | #replace the sub expression with y variable
78 | cmbaExpre1 = cmbaExpre.replace(subExpre, "y")
79 | cmbaSimExpre = simplify_pmba(cmbaExpre1)
80 | #replace the "y" variable with subSimExpre
81 | cmbaSimExpre = cmbaSimExpre.replace("y", subSimExpre)
82 | elif re.search("y", cmbaExpre):
83 | #process sub-expression
84 | subExpre1 = subExpre.replace("a", "x").replace("b", "y")[1:-1]
85 | subSimExpre = simplify_pmba(subExpre1)
86 | subSimExpre = subSimExpre.replace("x", "a").replace("y", "b")
87 | #replace the sub expression with x variable
88 | cmbaExpre1 = cmbaExpre.replace(subExpre, "x")
89 | cmbaSimExpre = simplify_pmba(cmbaExpre1)
90 | #replace the "y" variable with subSimExpre
91 | cmbaSimExpre = cmbaSimExpre.replace("x", subSimExpre)
92 | #process ground truth
93 | if re.search("x", groundtruth):
94 | groundtruthSim = groundtruth.replace("b", "y")
95 | groundtruthSim = simplify_pmba(groundtruthSim)
96 | groundtruthSim = groundtruthSim.replace("y", "b")
97 | elif re.search("y", cmbaExpre):
98 | groundtruthSim = groundtruth.replace("a", "x")
99 | groundtruthSim = simplify_pmba(groundtruthSim)
100 | groundtruthSim = groundtruthSim.replace("x", "a")
101 |
102 | elapsed = time.time() - start
103 | print("z3 solving: ")
104 | z3res = verify_mba_unsat(cmbaSimExpre, groundtruth, 2)
105 | print("z3 solved: ", z3res)
106 | if z3res:
107 | print(linenum, cmbaExpre, groundtruth, cmbaSimExpre, groundtruthSim, z3res)
108 | print(cmbaExpre, groundtruth, cmbaSimExpre, groundtruthSim, z3res, elapsed, sep=",",file=fw)
109 | else:
110 | print("error in simplify_npmba")
111 | exit(1)
112 |
113 | fw.close()
114 | return None
115 |
116 |
117 |
118 | def main(fileread):
119 | simplify_npmba(fileread)
120 |
121 | return None
122 |
123 |
124 |
125 | if __name__ == "__main__":
126 | fileread = sys.argv[1]
127 | main(fileread)
128 |
129 |
130 |
131 |
--------------------------------------------------------------------------------
/mba-simplifier/pldi_dataset_simplify_poly.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 |
4 |
5 | import re
6 | import sys
7 | sys.path.append("../tools")
8 | import time
9 | from mba_string_operation import verify_mba_unsat, variable_list, expression_2_term
10 | from svector_simplify import SvectorSimplify
11 | from truthtable_search_simplify import PMBASimplify
12 |
13 |
14 | def simplify_linear_combination(mbaExpre):
15 | """
16 | """
17 | #basisVec2 = ["x", "y", "(x|y)", "~(x&~x)"]
18 | basisVec2 = ["(x&y)", "(~x&y)", "(x&~y)", "(~x&~y)"]
19 | basisVec4 = ["x", "y", "z", "t", "(x&y)", "(x&z)", "(x&t)", "(y&z)", "(y&t)","(z&t)", "(x&y&z)", "(x&y&t)", "(x&z&t)", "(y&z&t)", "(x&y&z&t)", "~(x&~x)"]
20 | #basisVec4 = ["(x&y&z&t)", "(~x&y&t&z)", "(x&~y&z&t)", "(x&y&~z&t)", "(x&y&z&~t)", "(~x&~y&z&t)", "(x&~y&~z&t)", "(x&y&~z&~t)", "(~x&y&~z&t)","(~x&y&z&~t)", "(x&~y&z&~t)", "(x&~y&~z&~t)", "(~x&y&~z&~t)", "(~x&~y&z&~t)", "(~x&~y&~z&t)", "(~x&~y&~z&~t)"]
21 | termList = expression_2_term(mbaExpre)
22 | xytermList = []
23 | nxytermList = []
24 | for term in termList:
25 | if len(variable_list(term)) == 2:
26 | xytermList.append(term)
27 | else:
28 | nxytermList.append(term)
29 | xyExpre = "".join(xytermList)
30 | nxyExpre = "".join(nxytermList)
31 | psObj = PMBASimplify(2, basisVec2)
32 | simxyExpre = psObj.simplify(xyExpre)
33 | psObj = PMBASimplify(4, basisVec4)
34 | simnxyExpre = psObj.simplify(nxyExpre)
35 | if simnxyExpre[0] == "-" or simnxyExpre[0] == "+":
36 | simExpre = simxyExpre + simnxyExpre
37 | else:
38 | simExpre = simxyExpre + "+" + simnxyExpre
39 |
40 | return simExpre
41 |
42 |
43 | def simplify_pmba(datafile):
44 | """simplify poly mba expression by the signatrue vector.
45 | Args:
46 | datafile: file storing the original mba expression.
47 | """
48 | filewrite = "{source}.simplify.txt".format(source=datafile)
49 |
50 | fw = open(filewrite, "w")
51 | print("#complex,groundtruth,simplifiedcomplex,simplifiedgroundtruth,z3flag,simtime", file=fw)
52 |
53 | linenum = 0
54 | with open(datafile, "rt") as fr:
55 | for line in fr:
56 | if "#" not in line:
57 | linenum += 1
58 | line = line.strip()
59 | itemList = re.split(",", line)
60 | cmbaExpre = itemList[0]
61 | groundtruth = itemList[1]
62 | vnumber = len(variable_list(cmbaExpre))
63 | if vnumber == 1:
64 | #basisVec = ["x","~(x&~x)"]
65 | basisVec = ["x","~x"]
66 | elif vnumber == 2:
67 | basisVec = ["x", "y", "(x|y)", "~(x&~x)"]
68 | #basisVec = ["(x&y)", "(~x&y)", "(x&~y)", "(~x&~y)"]
69 | elif vnumber == 3:
70 | basisVec = ["x", "y", "z", "(x&y)", "(y&z)", "(x&z)", "(x&y&z)", "~(x&~x)"]
71 | #basisVec = ["(x&y&z)", "(~x&y&z)", "(x&~y&z)", "(x&y&~z)", "(~x&~y&z)", "(~x&y&~z)", "(x&~y&~z)", "(~x&~y&~z)"]
72 | elif vnumber == 4:
73 | #basisVec = ["x", "y", "z", "t", "(x&y)", "(x&z)", "(x&t)", "(y&z)", "(y&t)","(z&t)", "(x&y&z)", "(x&y&t)", "(x&z&t)", "(y&z&t)", "(x&y&z&t)", "~(x&~x)"]
74 | basisVec = ["(x&y&z&t)", "(~x&y&t&z)", "(x&~y&z&t)", "(x&y&~z&t)", "(x&y&z&~t)", "(~x&~y&z&t)", "(x&~y&~z&t)", "(x&y&~z&~t)", "(~x&y&~z&t)","(~x&y&z&~t)", "(x&~y&z&~t)", "(x&~y&~z&~t)", "(~x&y&~z&~t)", "(~x&~y&z&~t)", "(~x&~y&~z&t)", "(~x&~y&~z&~t)"]
75 | if vnumber == 4:
76 | start = time.time()
77 | simExpre1 = simplify_linear_combination(cmbaExpre)
78 | simExpre2 = simplify_linear_combination(groundtruth)
79 | elapsed = time.time() - start
80 | print("z3 solving...")
81 | z3res = verify_mba_unsat(simExpre1, simExpre2, 2)
82 | print(linenum, cmbaExpre, groundtruth, simExpre1, simExpre2, z3res)
83 | print("z3 solved: ", z3res)
84 | print(cmbaExpre, groundtruth, simExpre1, simExpre2, z3res, elapsed, sep=",", file=fw)
85 | continue
86 | psObj = PMBASimplify(vnumber, basisVec)
87 | start = time.time()
88 | simExpre1 = psObj.simplify(cmbaExpre)
89 | simExpre2 = psObj.simplify(groundtruth)
90 | elapsed = time.time() - start
91 | print("z3 solving...")
92 | z3res = verify_mba_unsat(simExpre1, simExpre2, 2)
93 | print(linenum, cmbaExpre, groundtruth, simExpre1, simExpre2, z3res)
94 | print("z3 solved: ", z3res)
95 | print(cmbaExpre, groundtruth, simExpre1, simExpre2, z3res, elapsed, sep=",", file=fw)
96 |
97 | fw.close()
98 | return None
99 |
100 |
101 |
102 | def main(fileread):
103 | simplify_pmba(fileread)
104 |
105 | return None
106 |
107 |
108 |
109 | if __name__ == "__main__":
110 | fileread = sys.argv[1]
111 | main(fileread)
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/sspam/linear.MBA.SSPAM.result.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,simplified,simtime
2 | (x|y)+y-(~x&y),x+y,(x+y),1.20063877106
3 | 3*(x&~y)-(x^y)+~x-~(x&y),x-y,((((3*(x&(~y)))+(~x))-(~(x&y)))-(x^y)),6.81257891655
4 | -1*(~(x&y))+(x|y)-1*(x^y)-1*x+2*~x-1*(~(x&~y))-1*(~(x^y))-1*(x|~y)+3*(~(x|y))+1*(~(x|~y))+4*(x&~y)+4*(x&y),1*y+1*~y,((((((((13*x)+(5*(x&y)))+(4*(x&(15-y))))+(x&(~y)))-(2*(x|y)))-(x|(15-y)))-(x|(~y)))+13),437.961981058
5 | -2*(~(x&y))-2*~y-2*~x+(~(x^y))-2*x-1*y-1*(x|y)+(x|~y)+6*(~(x|y))+8*(~(x|~y))+7*(x&~y)+4*(x&y),1*(~(x&~x))+1*(~(x&~y)),(((((((y+(6*(x&y)))+(7*(x&(15-y))))-(7*(x|y)))+(x|(15-y)))-(8*(x|(~y))))-(x^y))+7),524.628734112
6 | -1*(x|y)+(~(x&~y))+2*y-2*~y-1*~x-1*(~(x&~x))+(~(x^y))+x+2*(~(x|y))-1*(~(x|~y))+3*(x&~y)-2*(x&y),-(~(x&y))+1*(x|~y),((((((3*y)-(3*(x|y)))-(x^y))+(x^(x&(3-y))))+(x^(~y)))-((3-y)^x)),289.070914984
7 | -1*x-1*~y+4*(~(x&~x))-1*(~(x^y))+y-4*(~(x&y))-1*(~(x&~y))+2*(~(x|y))-1*(~(x|~y))+2*(x&~y)-2*(x&y),-~x,((((((2*x)+y)-(4*(x&(15-x))))-(2*(x|y)))+(y^x))+1),178.024003029
8 | (~(x&~x))+y-2*(x^y)-1*~y+x-1*(~(x&~y))-2*~x-3*(~(x|y))-2*(~(x|~y))-4*(x&~y)-3*(x&y),-5*(~(x&y))-(~(x^y)),((((((((((3*x)+(2*y))-(3*(x&y)))-(4*(x&(15-y))))-(x&(~x)))+(x&(~y)))+(3*(x|y)))+(2*(x|(~y))))-(2*(x^y)))+8),356.784096956
9 | (~(x&y))+(x^y)-1*y+x-2*(x|~y)+2*(~(x&~y))+~y-1*(~(x^y))-1*(~(x|y))-4*(~(x|~y))-3*(x&~y),-(x|y),(((((-x)-(3*(x&(15-y))))+(4*(x|(~y))))+(3*(x^y)))+4),256.034775019
10 | -1*x-1*~x+4*(x|~y)-1*(~(x&~y))-1*~y-4*(x&~y)-1*(x&y),1*(~(x^y))-2*(x^y),(((((y-(x&y))-(4*(x&(15-y))))+(x&(~y)))+(4*(x|(15-y))))+3),98.1647589207
11 | 2*~x+5*(~(x^y))-1*(~(x&y))+(x^y)+x-1*(~(x&~y))+(x|~y)-7*(~(x|y))-3*(~(x|~y))-3*(x&~y)-8*(x&y),-y-(~(x&~x)),(((((((9*(x&y))-(3*(x&(15-y))))+(~y))+(7*(x|y)))+(3*(x|(~y))))-(4*(x^y)))+5),285.620533943
12 | -3*~(x^y)-6*~y-2*(x^y)-7*~(x&y)+1*~(x&~x)+2*~(x&~y)-11*(x|~y)-6*x-2*y+24*~(x|y)+8*~(x|~y)+31*(x&~y),-19*(x&y),(((((((((((250*x)+(4*y))+(7*(x&y)))+(31*(x&(255-y))))-(x&(~x)))-(2*(x&(~y))))-(24*(x|y)))-(11*(x|(255-y))))-(8*(x|(~y))))+(x^y))+237),460.661790133
13 | 1*((x|y)&~(y^z))+1*~(x|(y|z))-2*~(~x|(y|z))-2*(x&(y&z)),1*(~x&(~y|z))-1*((x|~y)&(x^(y^z))),((((2*(x&(y&z)))+((x|y)&(~(y^z))))+(~(x|(y|z))))-(2*(~((~x)|(y|z))))),24.5619001389
14 | -3*(z^~(~x|(~y&z)))-1*(x&(~y|z))-4*~(x|(~y|z))-1*~(~x|(~y|z))+3*(~x&(~y&z))-1*(~x&(y&z))-3*(x&(y&z)),-4*(x|y),(((((((13*(x&(y&z)))-((15-x)&(y&z)))+(3*((15-x)&((15-y)&z))))+(~x))+(4*(x|((~y)|z))))-(3*(z^(15-((~x)|((~y)&z))))))+5),120.689991951
15 | 2*(y|~(x^z))-1*(~x&(~y|z))+2*~(x^(y|z))-3*~(x|(y|z))-2*~(x|(~y|z))+1*(~x&(~y&z))-4*(x&(~y&z))-4*(x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),((((((((12*(x&(y&z)))-(4*(x&((~y)&z))))+((~x)&((~y)&z)))-((~x)&((~y)|z)))-(3*(~(x|(y|z)))))-(2*(~(x|((~y)|z)))))+(2*(~(x^(y|z)))))+(2*(y|(~(x^z))))),167.521622896
16 | 5*(~x&(y^z))+1*(x&(y^z))+1*((x&~y)|(x^(y^z)))-6*~(x|(~y|z))-1*~(~x|(y|z))-1*~(~x|(~y|z))-2*(x&(~y&z))-1*(x&(y&z)),6*(~x&(~y&z)),((((((((-(x&(y&z)))-(2*(x&((~y)&z))))+(x&(y^z)))+(5*((~x)&(y^z))))-(6*(~(x|((~y)|z)))))-(~((~x)|(y|z))))-(~((~x)|((~y)|z))))+((x&(~y))|(z^(x^y)))),247.096101999
17 | -7*((x^y)&~(x^z))+5*(~z|~(x^y))-3*~(x|(y|z))+4*~(x|(~y|z))-3*~(~x|(y|z))-3*~(~x|(~y|z))-3*(~x&(~y&z))+9*(x&(~y&z))-5*(x&(y&z)),2*~(y&z),(((((((((11*(x&(y&z)))+(9*(x&((~y)&z))))-(3*((~x)&((~y)&z))))-(7*((x^y)&(~(x^z)))))-(3*(~(x|(y|z)))))+(4*(~(x|((~y)|z)))))-(3*(~((~x)|(y|z)))))-(3*(~((~x)|((~y)|z)))))+(5*((~z)|(~(x^y))))),204.11549592
18 | -3*~(y^z)+5*(z^(~x|(y|z)))-12*~(x|(y|z))-15*~(x|(~y|z))-8*~(~x|(y|z))-16*~(~x|(~y|z))-8*(~x&(y&z))+1*(x&(~y&z))+3*(x&(y&z)),1*(z^(~x|(y&z)))-11*(z^~(~x&(y&z))),(((((((((3*(x&(y&z)))+(x&((~y)&z)))-(8*((~x)&(y&z))))-(12*(~(x|(y|z)))))-(15*(~(x|((~y)|z)))))-(8*(~((~x)|(y|z)))))-(16*(~((~x)|((~y)|z)))))-(3*(~(y^z))))+(5*(z^((~x)|(y|z))))),158.738569975
19 | -2*(y|~z)+1*(x^y)+2*~(x|(y|z))+3*~(~x|(y|z))+4*~(~x|(~y|z))+2*(~x&(~y&z))+3*(~x&(y&z))-1*(x&(~y&z))+4*(x&(y&z)),2*(z^~(~x|(y&z)))-1*~(x|(~y|z)),(((((((((4*(x&(y&z)))-(x&((~y)&z)))+(3*((~x)&(y&z))))+(2*((~x)&((~y)&z))))+(2*(~(x|(y|z)))))+(3*(~((~x)|(y|z)))))+(4*(~((~x)|((~y)|z)))))-(2*(y|(~z))))+(x^y)),221.283245087
20 | -1*((~(x^(~y&z))&~t)|((z^(~x|(y&z)))&t))+1*((((x&y)^(x^(y&z)))&~t)|(((x&~y)|~(y^z))&t))+1*(((z^~(x&y))&~t)|(((x|y)&~(x^(y^z)))&t))-2*~(~x|(y|(z|t)))-2*~(~x|(~y|(~z|t)))+1*(~x&(y&(~z&t)))-1*(x&(~y&(~z&t)))-2*(~x&(y&(z&t)))-1*(x&(y&(z&t))),1*(x&(y&(~z&t)))+1*(x&(~y&(z&t))),(((((((((-(x&(y&(z&t))))-(x&((~y)&((~z)&t))))-(2*((~x)&(y&(z&t)))))+((~x)&(y&((~z)&t))))-(2*(~((~x)|(y|(z|t))))))-(2*(~((~x)|((~y)|((~z)|t))))))-(((~(x^((~y)&z)))&(~t))|((z^((~x)|(y&z)))&t)))+(((z^(~(x&y)))&(~t))|(((x|y)&(~(z^(x^y))))&t)))+((((x&y)^(x^(y&z)))&(~t))|(((x&(~y))|(~(y^z)))&t))),548.3627491
21 | 2*((((y&z)|(~x&(y|z)))&~t)|((y^~(x&(~y&z)))&t))-2*(((z^~(~x&(y|z)))&~t)|(((x|y)&~(y^z))&t))-2*(((z^~(x|(~y&z)))&~t)|(((x&y)^(x^(~y|z)))&t))-2*((((x^y)&(x^z))&~t)|((~(x|y)|~(y^z))&t))+4*~(x|(y|(z|t)))+4*~(~x|(y|(z|t)))+2*~(~x|(~y|(z|t)))+2*~(x|(y|(~z|t)))+2*~(x|(~y|(~z|t)))+2*~(~x|(y|(~z|t)))+2*(~x&(~y&(~z&t)))+2*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),-2*(x&(~y&(~z&t))),((((((((((((((6*(x&(y&(z&t))))+(6*((~x)&(y&(z&t)))))+(2*((~x)&((~y)&(z&t)))))+(2*((~x)&((~y)&((~z)&t)))))+(4*(~(x|(y|(z|t))))))+(2*(~(x|(y|((~z)|t))))))+(2*(~(x|((~y)|((~z)|t))))))+(4*(~((~x)|(y|(z|t))))))+(2*(~((~x)|(y|((~z)|t))))))+(2*(~((~x)|((~y)|(z|t))))))-(2*((((x^y)&(x^z))&(~t))|(((~(x|y))|(~(y^z)))&t))))+(2*((((y&z)|((~x)&(y|z)))&(~t))|((y^(~(x&((~y)&z))))&t))))-(2*(((z^(~((~x)&(y|z))))&(~t))|(((x|y)&(~(y^z)))&t))))-(2*(((z^(~(x|((~y)&z))))&(~t))|(((x&y)^(x^((~y)|z)))&t)))),1117.31286597
22 | 3*(((z^~(x|y))&~t)|((y^~(x&(y&z)))&t))+7*(((~y&~(x^z))&~t)|(~(x&~y)&t))+1*(((y^~(~x|(y&z)))&~t)|((x&~x)&t))-1*((~(x|(y|z))&~t)|((z^~(x|(~y&z)))&t))+2*((((x&z)^(x^(~y&z)))&~t)|(((x&y)^~(x^(y&z)))&t))-9*(((x^(y|z))&~t)|(((y&z)|(~x&(y|z)))&t))+1*(((y|(x&~z))&~t)|((~(x|y)|~(x^(y^z)))&t))-5*(((~(x^y)|~(x^z))&~t)|(((x|y)&(x^(y^z)))&t))-4*((((x|~y)&~(x^(y^z)))&~t)|((y|(x^z))&t))+9*(((y^~(x|(~y&z)))&~t)|((x&z)&t))-1*((((x&y)^(x^(~y|z)))&~t)|((z^~(x&~y))&t))-3*(((y^~(x&(y^z)))&~t)|((z^~(~x&(~y|z)))&t))+1*((~(~x&(y&z))&~t)|(~(x^(~y&z))&t))-4*(((x&~z)&~t)|((z&~(x^y))&t))+11*~(x|(~y|(z|t)))+11*~(~x|(y|(z|t)))+3*~(~x|(~y|(z|t)))+15*~(x|(y|(~z|t)))+5*~(x|(~y|(~z|t)))-9*~(~x|(~y|(~z|t)))-12*(~x&(~y&(~z&t)))+13*(~x&(y&(~z&t)))+15*(x&(~y&(~z&t)))+4*(x&(y&(~z&t)))+14*(~x&(~y&(z&t)))+13*(~x&(y&(z&t)))-12*(x&(~y&(z&t)))+10*(x&(y&(z&t))),-1*~(~x|(y|(~z|t)))+6*(((~y&~(x^z))&~t)|((z^~(~x|(y&z)))&t)),((((((((((((((((((((((((((((10*(x&(y&(z&t))))+(4*(x&(y&((~z)&t)))))-(12*(x&((~y)&(z&t)))))+(15*(x&((~y)&((~z)&t)))))+(13*((~x)&(y&(z&t)))))+(13*((~x)&(y&((~z)&t)))))+(14*((~x)&((~y)&(z&t)))))-(12*((~x)&((~y)&((~z)&t)))))+(15*(~(x|(y|((~z)|t))))))+(11*(~(x|((~y)|(z|t))))))+(5*(~(x|((~y)|((~z)|t))))))+(11*(~((~x)|(y|(z|t))))))+(3*(~((~x)|((~y)|(z|t))))))-(9*(~((~x)|((~y)|((~z)|t))))))-(4*(((x&(~z))&(~t))|((z&(~(x^y)))&t))))+(7*((((~y)&(~(x^z)))&(~t))|((~(x&(~y)))&t))))-(4*((((x|(~y))&(~(z^(x^y))))&(~t))|((y|(x^z))&t))))+(((~((~x)&(y&z)))&(~t))|((~(x^((~y)&z)))&t)))-(((~(x|(y|z)))&(~t))|((z^(~(x|((~y)&z))))&t)))+(((y|(x&(~z)))&(~t))|(((~(x|y))|(~(z^(x^y))))&t)))-(5*((((~(x^y))|(~(x^z)))&(~t))|(((x|y)&(z^(x^y)))&t))))-(9*(((x^(y|z))&(~t))|(((y&z)|((~x)&(y|z)))&t))))-(3*(((y^(~(x&(y^z))))&(~t))|((z^(~((~x)&((~y)|z))))&t))))+(9*(((y^(~(x|((~y)&z))))&(~t))|((x&z)&t))))+(((y^(~((~x)|(y&z))))&(~t))|((x&(~x))&t)))+(3*(((z^(~(x|y)))&(~t))|((y^(~(x&(y&z))))&t))))-((((x&y)^(x^((~y)|z)))&(~t))|((z^(~(x&(~y))))&t)))+(2*((((x&z)^(x^((~y)&z)))&(~t))|(((x&y)^(~(x^(y&z))))&t)))),23207.72229
23 |
--------------------------------------------------------------------------------
/sspam/makefile:
--------------------------------------------------------------------------------
1 | sspam-mba-linear:
2 | python2 sspam-evaluation.py ../dataset/pldi_dataset_linear_MBA.txt linear.MBA.SSPAM.result.txt
3 |
4 | sspam-mba-poly:
5 | python2 sspam-evaluation.py ../dataset/pldi_dataset_poly_MBA.txt poly.MBA.SSPAM.result.txt
6 |
7 | sspam-mba-nonpoly:
8 | python2 sspam-evaluation.py ../dataset/pldi_dataset_nonpoly_MBA.txt nonpoly.MBA.SSPAM.result.txt
9 |
10 | sspam-simplify:
11 | @echo "----------------------sspam simplify linear MBA samples-------------------"
12 | @make sspam-mba-linear
13 | @echo "----------------------sspam simplify linear MBA samples completion---------"
14 | @echo "----------------------sspam simplify poly MBA samples----------------------"
15 | @make sspam-mba-poly
16 | @echo "----------------------sspam simplify poly MBA samples completion-----------"
17 | @echo "----------------------sspam simplify nonpoly MBA samples--------------------"
18 | @make sspam-mba-nonpoly
19 | @echo "----------------------sspam simplify nonpoly MBA samples completion---------"
20 |
21 |
--------------------------------------------------------------------------------
/sspam/poly.MBA.SSPAM.result.txt:
--------------------------------------------------------------------------------
1 | #complex,groundtruth,simplified,simtime
2 | (x&y)*(x|y)+(x&~y)*(~x&y)-41,x*y-41,((((x&y)*(x|y))+((x&(~y))*((~x)&y)))+215),5.90864896774
3 | (x&y)*(x|y)+(x&~y)*(~x&y)-253,x*y-253,((((x&y)*(x|y))+((x&(~y))*((~x)&y)))+3),5.78629302979
4 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*~x+1*(x|~y)-1*~(x|~y)-3*(x&~y),x*y+1*(x&y)-2*(x^y),(((((((x&y)*(x|y))+((x&(~y))*((~x)&y)))-(3*(x&(~y))))-(~x))-(~(x|(~y))))+(x|(~y))),86.0902190208
5 | (x&y)*(x|y)+(x&~y)*(~x&y)+5*~y-11*(x|~y)+6*~(x|y)+8*(x&~y),x*y-13*(x&y)+2*x,(((((((x&y)*(x|y))+((x&(~y))*((~x)&y)))+(8*(x&(~y))))+(5*(~y)))+(6*(~(x|y))))-(11*(x|(~y)))),69.03540802
6 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*y+2*~(x&y)-2*(x^y)+1*(x&y),x*y-3*~(x|~y)+2*~x,((((((-y)+((x&y)*(x|y)))+(x&y))+((x&(~y))*((~x)&y)))+(2*(~(x&y))))-(2*(x^y))),61.9674310684
7 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*~(x&y)-11*~(x^y)+12*~(x|y)+1*~(x|~y)+11*(x&y),x*y+2*~x+1*(x&~y),((((((((x&y)*(x|y))+(11*(x&y)))+((x&(~y))*((~x)&y)))+(~(x&y)))+(12*(~(x|y))))+(~(x|(~y))))-(11*(~(x^y)))),88.6971399784
8 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*~x+5*x-2*~(x^y)+13*~(x|y)+11*~(x|~y),x*y+5*(x&~y)+3*(x&y),(((((((5*x)+((x&y)*(x|y)))+((x&(~y))*((~x)&y)))-(11*(~x)))+(13*(~(x|y))))+(11*(~(x|(~y)))))-(2*(~(x^y)))),65.8701269627
9 | (x&y)*(x|y)+(x&~y)*(~x&y)-2*~(x&~x)+2*y+3*~(x|y)+1*~(x|~y)+2*(x&~y),x*y+1*~x,(((((((2*y)+((x&y)*(x|y)))+((x&(~y))*((~x)&y)))+(2*(x&(~y))))-(2*(~(x&(~x)))))+(3*(~(x|y))))+(~(x|(~y)))),127.249729872
10 | (x&y)*(x|y)+(x&~y)*(~x&y)+11*(x|~y)+3*~(x&~x)+5*~(x&y)-19*(x&~y)-14*(x&y),x*y+19*~(x|y)+8*~(x|~y),((((((((x&y)*(x|y))-(14*(x&y)))+((x&(~y))*((~x)&y)))-(19*(x&(~y))))+(5*(~(x&y))))+(3*(~(x&(~x)))))+(11*(x|(~y)))),112.562524796
11 | (x&y)*(x|y)+(x&~y)*(~x&y)+7*~y+4*~(x&y)+11*~(x&~x)-22*~(x|y)-11*(x&y),x*y+15*~(x|~y)+22*(x&~y),((((((249*y)+((x&y)*(x|y)))-(15*(x&y)))+((x&(255-y))*((255-x)&y)))-(11*(x&(~x))))+(22*(x|y))),134.239772081
12 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*(x|~y)-3*~y+2*x+14*~(x|y)+12*(x&~y),x*y-9*(x&y),(((((((2*x)+((x&y)*(x|y)))+((x&(~y))*((~x)&y)))+(12*(x&(~y))))-(3*(~y)))+(14*(~(x|y))))-(11*(x|(~y)))),113.309473038
13 | (x&y)*(x|y)+(x&~y)*(~x&y)+2*(x|y)-4*~(x|y)-2*~(x|~y)-1*(x&~y)-7*(x&y),x*y-5*~(x^y)+1*~y,((((((((x&y)*(x|y))-(7*(x&y)))+((x&(~y))*((~x)&y)))-(x&(~y)))-(4*(~(x|y))))-(2*(~(x|(~y)))))+(2*(x|y))),126.740795851
14 | (x&y)*(x|y)+(x&~y)*(~x&y)-1*~y+1*y+3*~(x|y)+3*(x&~y)+1*(x&y),x*y-1*~(x|~y)+2*~(x&~x),((((((y+((x&y)*(x|y)))+(x&y))+((x&(~y))*((~x)&y)))+(3*(x&(~y))))-(~y))+(3*(~(x|y)))),109.680879116
15 | (x&y)*(x|y)+(x&~y)*(~x&y)+2*~(x&~y)-5*~(x&y)-1*x+5*~(x|y)+3*~(x|~y)+1*(x&y),x*y-6*(x&~y)+2*~(x^y),((((((((-x)+((x&y)*(x|y)))+(x&y))+((x&(~y))*((~x)&y)))-(5*(~(x&y))))+(2*(~(x&(~y)))))+(5*(~(x|y))))+(3*(~(x|(~y))))),132.639131784
16 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(y^~(~x|(~y&z)))-1*(y^~(x|~z))+1*~(x|(~y|z))+1*~(~x|(~y|z))+1*(x&(~y&z))+1*(x&(y&z)),x*y+1*(x^y)-1*(~x&(~y&z)),(((((((((x&y)*(x|y))+(x&(y&z)))+(x&((~y)&z)))+((x&(~y))*((~x)&y)))+(~(x|((~y)|z))))+(~((~x)|((~y)|z))))-(y^(~(x|(~z)))))+(y^(~((~x)|((~y)&z))))),227.068584919
17 | (x&y)*(x|y)+(x&~y)*(~x&y)+4*(y&z)-1*~(x^y)+2*(~x|(y&z))-1*~(x|(y|z))-2*~(x|(~y|z))+1*~(~x|(~y|z))-1*(~x&(~y&z)),x*y+6*(~x&(y&z))+5*(x&(y&z)),((((((((((x&y)*(x|y))+((x&(~y))*((~x)&y)))+(4*(y&z)))-((~x)&((~y)&z)))-(~(x|(y|z))))-(2*(~(x|((~y)|z)))))+(~((~x)|((~y)|z))))-(~(x^y)))+(2*((~x)|(y&z)))),350.16226387
18 | (x&y)*(x|y)+(x&~y)*(~x&y)+3*(z^(~x|(y&z)))-11*(y&~(x&z))+4*(z^(~x|(y|z)))-7*~(x|(y|z))+4*~(x|(~y|z))+7*~(~x|(~y|z))+11*(~x&(y&z)),x*y+3*(x&(~y&z)),((((((((((x&y)*(x|y))+((x&(~y))*((~x)&y)))-(11*(y&(~(x&z)))))+(11*((~x)&(y&z))))-(7*(~(x|(y|z)))))+(4*(~(x|((~y)|z)))))+(7*(~((~x)|((~y)|z)))))+(3*(z^((~x)|(y&z)))))+(4*(z^((~x)|(y|z))))),228.91146493
19 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(z^~(x&(y&z)))-2*((x|~y)&~(y^z))+1*~(x|(y|z))-1*~(x|(~y|z))-10*~(~x|(y|z))-12*~(~x|(~y|z))-11*(~x&(y&z))-10*(x&(y&z)),x*y-11*((x&z)^(x^(y&z))),(((((((((((x&y)*(x|y))-(10*(x&(y&z))))+((x&(~y))*((~x)&y)))-(11*((~x)&(y&z))))-(2*((x|(~y))&(~(y^z)))))+(~(x|(y|z))))-(~(x|((~y)|z))))-(10*(~((~x)|(y|z)))))-(12*(~((~x)|((~y)|z)))))+(z^(~(x&(y&z))))),421.189121008
20 | (x&y)*(x|y)+(x&~y)*(~x&y)-11*((y&~z)|~(~x|(~y&z)))+4*(z^~(~x|(y&z)))+11*~(x|(~y|z))+7*~(~x|(y|z))+6*~(~x|(~y|z))-4*(~x&(y&z))-1*(x&(~y&z))+7*(x&(y&z)),x*y-1*(x&(y^z))+4*(~x&(~y&z)),(((((((((((x&y)*(x|y))+(7*(x&(y&z))))-(x&((~y)&z)))+((x&(~y))*((~x)&y)))-(4*((~x)&(y&z))))+(11*(~(x|((~y)|z)))))+(7*(~((~x)|(y|z)))))+(6*(~((~x)|((~y)|z)))))-(11*((y&(~z))|(~((~x)|((~y)&z))))))+(4*(z^(~((~x)|(y&z)))))),360.299180031
21 | (x&y)*(x|y)+(x&~y)*(~x&y)+1*(y^~(~x|(y^z)))+2*(y^~(x|~z))+1*((x&y)^(y|~z))-1*~(x|(y|z))-4*~(x|(~y|z))-3*~(~x|(~y|z))-2*(~x&(~y&z))-2*(~x&(y&z)),x*y+2*(x&(y&z))+2*~(~x|(y|z)),(((((((((((x&y)*(x|y))+((x&(~y))*((~x)&y)))-(2*((~x)&(y&z))))-(2*((~x)&((~y)&z))))-(~(x|(y|z))))-(4*(~(x|((~y)|z)))))-(3*(~((~x)|((~y)|z)))))+(2*(y^(~(x|(~z))))))+(y^(~((~x)|(y^z)))))+((x&y)^(y|(~z)))),379.76443696
22 | (x&y)*(x|y)+(x&~y)*(~x&y)+11*(y^(~x|(y^z)))-7*(x^y)+1*(z^~(~x&(y|z)))-1*(~x|(y|z))-2*(~(x&~y)&(x^(y^z)))+1*(~z|~(x^y))+1*(y^~(x&(y^z)))+3*~(x&(y|z))-2*(~(x&y)&~(x^(y^z)))-5*~(~x&(~y|z))+1*((x&z)^~(x^(y&z)))+7*(x|~y)+5*(y^~(x&~z))-3*(~(x|y)|(y^z))+11*(~z|(x^y))-1*((x&~y)|(y^z))-11*~(x&(y&z))+14*~(x|(~y|z))-5*~(~x|(~y|z))-12*(~x&(~y&z))+6*(~x&(y&z))-5*(x&(~y&z))-11*(x&(y&z)),x*y+24*~(x|(y|z)),((((((((((((((((((((((((((x&y)*(x|y))-(11*(x&(y&z))))-(5*(x&((~y)&z))))+((x&(~y))*((~x)&y)))+(6*((~x)&(y&z))))-(12*((~x)&((~y)&z))))-(2*((~(x&y))&(~(z^(x^y))))))-(2*((~(x&(~y)))&(z^(x^y)))))-(11*(~(x&(y&z)))))+(3*(~(x&(y|z)))))-(5*(~((~x)&((~y)|z)))))+(14*(~(x|((~y)|z)))))-(5*(~((~x)|((~y)|z)))))+(7*(x|(~y))))-((x&(~y))|(y^z)))-((~x)|(y|z)))+((~z)|(~(x^y))))+(11*((~z)|(x^y))))-(3*((~(x|y))|(y^z))))-(7*(x^y)))+(5*(y^(~(x&(~z))))))+(y^(~(x&(y^z)))))+(11*(y^((~x)|(y^z)))))+(z^(~((~x)&(y|z)))))+((x&z)^(~(x^(y&z))))),7693.47148085
23 |
--------------------------------------------------------------------------------
/sspam/sspam-evaluation.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 |
3 | import re
4 | import sspam
5 | from sspam import simplifier
6 | import sys
7 | import time
8 |
9 |
10 |
11 | def sspam_simplify(sourcefilename, desfilename):
12 | fwrite = open(desfilename, "w")
13 | fwrite.write("#complex,groundtruth,simplified,simtime\n")
14 |
15 | with open(sourcefilename) as data:
16 | linenum = 0
17 | for line in data:
18 | line = line.replace("\n","")
19 | if "#" not in line and line:
20 | expreStrList = re.split(",", line)
21 | sourceStr = expreStrList[0]
22 | start = time.time()
23 | simStr = simplifier.simplify(sourceStr).replace(" ", "")
24 | end = time.time()
25 | elapsed = end - start
26 | resultStr = line
27 | resultStr += "," + simStr + "," + str(elapsed) + "\n"
28 | fwrite.write(resultStr)
29 | fwrite.flush()
30 | print linenum, sourceStr, simStr
31 | linenum += 1
32 |
33 | return None
34 |
35 |
36 | def main(sourcefilename, desfilename):
37 | sspam_simplify(sourcefilename, desfilename)
38 |
39 |
40 |
41 | if __name__ == "__main__":
42 | sourcefilename = sys.argv[1]
43 | desfilename = sys.argv[2]
44 | main(sourcefilename, desfilename)
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/stp_solving/makefile:
--------------------------------------------------------------------------------
1 | timeout = 5
2 |
3 | stp-linear-before-simplify:
4 | python2 stp_check_before_simplify.py ../dataset/pldi_dataset_linear_MBA.txt $(timeout)
5 |
6 | stp-poly-before-simplify:
7 | python2 stp_check_before_simplify.py ../dataset/pldi_dataset_poly_MBA.txt $(timeout)
8 |
9 | stp-nonpoly-before-simplify:
10 | python2 stp_check_before_simplify.py ../dataset/pldi_dataset_nonpoly_MBA.txt $(timeout)
11 |
12 | stp-linear-after-simplify:
13 | python2 stp_check_after_simplify.py ../dataset/pldi_dataset_linear_MBA.txt.simplify.txt $(timeout)
14 |
15 | stp-poly-after-simplify:
16 | python2 stp_check_after_simplify.py ../dataset/pldi_dataset_poly_MBA.txt.simplify.txt $(timeout)
17 |
18 | stp-nonpoly-after-simplify:
19 | python2 stp_check_after_simplify.py ../dataset/pldi_dataset_nonpoly_MBA.txt.simplify.txt $(timeout)
20 |
21 | stp-linear-after-simplify-sspam:
22 | python2 stp_check_after_simplify_peertools.py ../sspam/linear.MBA.SSPAM.result.txt $(timeout)
23 |
24 | stp-poly-after-simplify-sspam:
25 | python2 stp_check_after_simplify_peertools.py ../sspam/poly.MBA.SSPAM.result.txt $(timeout)
26 |
27 | stp-nonpoly-after-simplify-sspam:
28 | python2 stp_check_after_simplify_peertools.py ../sspam/nonpoly.MBA.SSPAM.result.txt $(timeout)
29 |
30 | stp-linear-after-simplify-syntia:
31 | python2 stp_check_after_simplify_peertools.py ../syntia/linear.64bit.result.txt $(timeout)
32 |
33 | stp-poly-after-simplify-syntia:
34 | python2 stp_check_after_simplify_peertools.py ../syntia/poly.64bit.result.txt $(timeout)
35 |
36 | stp-nonpoly-after-simplify-syntia:
37 | python2 stp_check_after_simplify_peertools.py ../syntia/nonpoly.64bit.result.txt $(timeout)
38 |
39 |
40 | stp-solving-before-simplify-total:
41 | python3 total.py stp 0
42 | stp-solving-before-simplify:
43 | @echo "--------------------stp solving linear MBA samples-------------------------"
44 | @make stp-linear-before-simplify
45 | @echo "--------------------stp solving linear MBA samples completion--------------"
46 | @echo "--------------------stp solving poly MBA samples---------------------------"
47 | @make stp-poly-before-simplify
48 | @echo "--------------------stp solving poly MBA samples completion----------------"
49 | @echo "--------------------stp solving nonpoly MBA samples------------------------"
50 | @make stp-nonpoly-before-simplify
51 | @echo "--------------------stp solving nonpoly MBA samples completion-------------"
52 | @echo "--------------------stp solving MBA samples before simplification-------------"
53 | @make stp-solving-before-simplify-total
54 |
55 | stp-solving-mba-solver-total:
56 | python3 total.py stp 1 mba
57 | stp-solving-mba-solver:
58 | @echo "--------------------stp solving linear MBA samples after MBA-Solver simplification--------------------------"
59 | @make stp-linear-after-simplify
60 | @echo "--------------------stp solving linear MBA samples after MBA-Solver simplification completion---------------"
61 | @echo "--------------------stp solving poly MBA samples after MBA-Solver simplification----------------------------"
62 | @make stp-poly-after-simplify
63 | @echo "--------------------stp solving poly MBA samples after MBA-Solver simplification completion-----------------"
64 | @echo "--------------------stp solving nonpoly MBA samples after MBA-Solver simplification-------------------------"
65 | @make stp-nonpoly-after-simplify
66 | @echo "--------------------stp solving nonpoly MBA samples after MBA-Solver simplification completion--------------"
67 | @echo "--------------------stp solving MBA samples after MBA-Solver simplification --------------"
68 | @make stp-solving-mba-solver-total
69 |
70 | stp-solving-sspam-total:
71 | python3 total.py stp 1 sspam
72 | stp-solving-sspam:
73 | @echo "--------------------stp solving linear MBA samples after SSPAM simplification--------------------------"
74 | @make stp-linear-after-simplify-sspam
75 | @echo "--------------------stp solving linear MBA samples after SSPAM simplification completion---------------"
76 | @echo "--------------------stp solving poly MBA samples after SSPAM simplification----------------------------"
77 | @make stp-poly-after-simplify-sspam
78 | @echo "--------------------stp solving poly MBA samples after SSPAM simplification completion-----------------"
79 | @echo "--------------------stp solving nonpoly MBA samples after SSPAM simplification-------------------------"
80 | @make stp-nonpoly-after-simplify-sspam
81 | @echo "--------------------stp solving nonpoly MBA samples after SSPAM simplification completion--------------"
82 | @echo "--------------------stp solving MBA samples after SSPAM simplification --------------"
83 | @make stp-solving-sspam-total
84 |
85 | stp-solving-syntia-total:
86 | python3 total.py stp 1 syntia
87 | stp-solving-syntia:
88 | @echo "--------------------stp solving linear MBA samples after Syntia simplification--------------------------"
89 | @make stp-linear-after-simplify-syntia
90 | @echo "--------------------stp solving linear MBA samples after Syntia simplification completion---------------"
91 | @echo "--------------------stp solving poly MBA samples after Syntia simplification----------------------------"
92 | @make stp-poly-after-simplify-syntia
93 | @echo "--------------------stp solving poly MBA samples after Syntia simplification completion-----------------"
94 | @echo "--------------------stp solving nonpoly MBA samples after Syntia simplification-------------------------"
95 | @make stp-nonpoly-after-simplify-syntia
96 | @echo "--------------------stp solving nonpoly MBA samples after Syntia simplification completion--------------"
97 | @echo "--------------------stp solving MBA samples after Syntia simplification --------------"
98 | @make stp-solving-syntia-total
99 |
--------------------------------------------------------------------------------
/stp_solving/stp_check_after_simplify.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 |
3 | import re
4 | import sys
5 | import time
6 | import stp
7 | from multiprocessing import Process, Value
8 |
9 | def verify_mba_unsat(leftExpre, rightExpre, bitnumber, res):
10 | """check the relaion whether the left expression is euqal to the right expression.
11 | Args:
12 | leftExpre: left expression.
13 | rightExpre: right expression.
14 | bitnumber: the number of the bits of the variable.
15 | Returns:
16 | True: equation.
17 | False: unequal.
18 | Raises:
19 | None.
20 | """
21 | s = stp.Solver()
22 | x = s.bitvec("x", bitnumber)
23 | y = s.bitvec("y", bitnumber)
24 | z = s.bitvec("z", bitnumber)
25 | t = s.bitvec("t", bitnumber)
26 | a = s.bitvec("a", bitnumber)
27 | b = s.bitvec("b", bitnumber)
28 | c = s.bitvec("c", bitnumber)
29 | d = s.bitvec("d", bitnumber)
30 | e = s.bitvec("e", bitnumber)
31 | f = s.bitvec("f", bitnumber)
32 |
33 | try:
34 | leftEval = eval(leftExpre)
35 | rightEval = eval(rightExpre)
36 | except:
37 | res.value = 2
38 | return None
39 |
40 | if not re.search("[xyztabcdef]", leftExpre) and not re.search("[xyztabcdef]", rightExpre):
41 | #whether is a constant
42 | if leftEval - rightEval == 0:
43 | res.value = 1
44 | else:
45 | res.value = 2
46 | else:
47 | s.add(leftEval != rightEval)
48 | result = s.check()
49 |
50 | if result:
51 | res.value = 2
52 | else:
53 | res.value = 1
54 |
55 | return None
56 |
57 |
58 | def stp_check_time(sourcefilename, timeout, bv=64):
59 | """input the expression from the source file, then check the equation and output the time and memory of process to desination file.
60 | Args:
61 | sourcefilename: source file.
62 | """
63 | desfilename = "{source}.stp.verify.{bv}bit.after.simplify.txt".format(source=sourcefilename, bv=bv)
64 | fwrite = open(desfilename, "w")
65 | comment = "#complex,groundtruth,simcomplex,simground,stpres,verificationtime\n"
66 | fwrite.write(comment)
67 |
68 | solvingList = [0, 0, 0]
69 | with open(sourcefilename, "r") as data:
70 | linenum = 0
71 | for line in data:
72 | line = line.strip().replace(" ", "")
73 | if "#" not in line:
74 | expreStrList = re.split(",", line)
75 | sourceExpreStr = expreStrList[0]
76 | groundExpreStr = expreStrList[1]
77 | sourceSimStr = expreStrList[2]
78 | groundSimStr = expreStrList[3]
79 | start = time.time()
80 | #res = verify_mba_unsat(sourceSimStr, groundSimStr, bv)
81 | res = Value('i', 0)
82 | p = Process(target=verify_mba_unsat, args=(sourceSimStr, groundSimStr, bv, res,))
83 | p.start()
84 | p.join(timeout) # wait timeout seconds or it finishes
85 |
86 | if p.is_alive():
87 | print("Still solving, but kill it as timeout set to", timeout, "seconds ...")
88 | p.terminate()
89 | p.join()
90 |
91 | result = {
92 | 0: "Timeout",
93 | 1: "True",
94 | 2: "False",
95 | }
96 | end = time.time()
97 | elapsed = end - start
98 | resultStr = "{source},{ground},{ssim},{gsim},{res},{vtime}\n".format(source=sourceExpreStr, ground=groundExpreStr, ssim=sourceSimStr, gsim=groundSimStr, res=result[res.value], vtime=elapsed)
99 | fwrite.write(resultStr)
100 | fwrite.flush()
101 |
102 | # print linenum, sourceExpreStr, groundExpreStr, sourceSimStr, groundSimStr, result[res.value], elapsed
103 | print linenum, result[res.value], "Time =", elapsed
104 | linenum += 1
105 | solvingList[res.value] += 1
106 |
107 | fwrite.close()
108 | print("Timeout: ", solvingList[0])
109 | print("True: ", solvingList[1])
110 | print("False: ", solvingList[2])
111 | return None
112 |
113 |
114 |
115 | def main(sourcefilename, timeout):
116 | stp_check_time(sourcefilename, timeout)
117 |
118 | return None
119 |
120 |
121 |
122 | if __name__ =="__main__":
123 | sourcefilename = sys.argv[1]
124 | timeout = int(sys.argv[2])
125 | main(sourcefilename, timeout)
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/stp_solving/stp_check_after_simplify_peertools.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 |
3 | import re
4 | import sys
5 | import time
6 | import stp
7 | from multiprocessing import Process, Value
8 |
9 | def verify_mba_unsat(leftExpre, rightExpre, bitnumber, res):
10 | """check the relaion whether the left expression is euqal to the right expression.
11 | Args:
12 | leftExpre: left expression.
13 | rightExpre: right expression.
14 | bitnumber: the number of the bits of the variable.
15 | Returns:
16 | True: equation.
17 | False: unequal.
18 | Raises:
19 | None.
20 | """
21 | s = stp.Solver()
22 | x = s.bitvec("x", bitnumber)
23 | y = s.bitvec("y", bitnumber)
24 | z = s.bitvec("z", bitnumber)
25 | t = s.bitvec("t", bitnumber)
26 | a = s.bitvec("a", bitnumber)
27 | b = s.bitvec("b", bitnumber)
28 | c = s.bitvec("c", bitnumber)
29 | d = s.bitvec("d", bitnumber)
30 | e = s.bitvec("e", bitnumber)
31 | f = s.bitvec("f", bitnumber)
32 |
33 | try:
34 | leftEval = eval(leftExpre)
35 | rightEval = eval(rightExpre)
36 | except:
37 | res.value = 2
38 | return None
39 |
40 | if not re.search("[xyztabcdef]", leftExpre) and not re.search("[xyztabcdef]", rightExpre):
41 | #whether is a constant
42 | if leftEval - rightEval == 0:
43 | res.value = 1
44 | else:
45 | res.value = 2
46 | else:
47 | s.add(leftEval != rightEval)
48 | result = s.check()
49 |
50 | if result:
51 | res.value = 2
52 | else:
53 | res.value = 1
54 |
55 | return None
56 |
57 |
58 | def stp_check_time(sourcefilename, timeout, bv=64):
59 | """input the expression from the source file, then check the equation and output the time and memory of process to desination file.
60 | Args:
61 | sourcefilename: source file.
62 | """
63 | desfilename = "{source}.stp.verify.{bv}bit.after.simplify.txt".format(source=sourcefilename, bv=bv)
64 | fwrite = open(desfilename, "w")
65 | comment = "#complex,groundtruth,simcomplex,stpres,verificationtime\n"
66 | fwrite.write(comment)
67 |
68 | solvingList = [0, 0, 0]
69 | with open(sourcefilename, "r") as data:
70 | linenum = 0
71 | for line in data:
72 | line = line.strip().replace(" ", "")
73 | if "#" not in line:
74 | expreStrList = re.split(",", line)
75 | sourceExpreStr = expreStrList[0]
76 | groundExpreStr = expreStrList[1]
77 | sourceSimStr = expreStrList[2]
78 |
79 | start = time.time()
80 | #res = verify_mba_unsat(sourceSimStr, groundExpreStr, bv)
81 | res = Value('i', 0)
82 | p = Process(target=verify_mba_unsat, args=(sourceSimStr, groundExpreStr, bv, res,))
83 | p.start()
84 | p.join(timeout) # wait timeout seconds or it finishes
85 |
86 | if p.is_alive():
87 | print("Still solving, but kill it as timeout set to", timeout, "seconds ...")
88 | p.terminate()
89 | p.join()
90 |
91 | result = {
92 | 0: "Timeout",
93 | 1: "True",
94 | 2: "False",
95 | }
96 | end = time.time()
97 | elapsed = end - start
98 | resultStr = "{source},{ground},{ssim},{res},{vtime}\n".format(source=sourceExpreStr, ground=groundExpreStr, ssim=sourceSimStr, res=result[res.value], vtime=elapsed)
99 | fwrite.write(resultStr)
100 | fwrite.flush()
101 |
102 | # print linenum, sourceExpreStr, groundExpreStr, sourceSimStr, result[res.value], elapsed
103 | print linenum, result[res.value], "Time =", elapsed
104 | linenum += 1
105 | solvingList[res.value] += 1
106 |
107 | fwrite.close()
108 | print("Timeout: ", solvingList[0])
109 | print("True: ", solvingList[1])
110 | print("False: ", solvingList[2])
111 | return None
112 |
113 |
114 |
115 | def main(sourcefilename, timeout):
116 | stp_check_time(sourcefilename, timeout)
117 |
118 |
119 |
120 | if __name__ =="__main__":
121 | sourcefilename = sys.argv[1]
122 | timeout = int(sys.argv[2])
123 | main(sourcefilename, timeout)
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/stp_solving/stp_check_before_simplify.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python2
2 |
3 | import re
4 | import sys
5 | import time
6 | import stp
7 | from multiprocessing import Process, Value
8 |
9 | def verify_mba_unsat(leftExpre, rightExpre, bitnumber, res):
10 | """check the relaion whether the left expression is euqal to the right expression.
11 | Args:
12 | leftExpre: left expression.
13 | rightExpre: right expression.
14 | bitnumber: the number of the bits of the variable.
15 | Returns:
16 | True: equation.
17 | False: unequal.
18 | Raises:
19 | None.
20 | """
21 | s = stp.Solver()
22 | x = s.bitvec("x", bitnumber)
23 | y = s.bitvec("y", bitnumber)
24 | z = s.bitvec("z", bitnumber)
25 | t = s.bitvec("t", bitnumber)
26 | a = s.bitvec("a", bitnumber)
27 | b = s.bitvec("b", bitnumber)
28 | c = s.bitvec("c", bitnumber)
29 | d = s.bitvec("d", bitnumber)
30 | e = s.bitvec("e", bitnumber)
31 | f = s.bitvec("f", bitnumber)
32 |
33 | leftEval = eval(leftExpre)
34 | rightEval = eval(rightExpre)
35 |
36 | s.add(leftEval != rightEval)
37 | result = s.check()
38 |
39 | if result:
40 | res.value = 2
41 | else:
42 | res.value = 1
43 |
44 | return None
45 |
46 |
47 |
48 | def stp_check_time(sourcefilename, timeout, bv=64):
49 | """input the expression from the source file, then check the equation and output the time and memory of process to desination file.
50 | Args:
51 | sourcefilename: source file.
52 | """
53 | desfilename = "{source}.stp.verify.{bv}bit.before.simplify.txt".format(source=sourcefilename, bv=bv)
54 | fwrite = open(desfilename, "w")
55 | comment = "#complex,groundtruth,stpres,verificationtime\n"
56 | fwrite.write(comment)
57 |
58 | with open(sourcefilename, "r") as data:
59 | linenum = 0
60 | for line in data:
61 | line = line.strip().replace(" ", "")
62 | if "#" not in line:
63 | expreStrList = re.split(",", line)
64 | sourceExpreStr = expreStrList[0]
65 | groundExpreStr = expreStrList[1]
66 | start = time.time()
67 | res = Value('i', 0)
68 | #res = verify_mba_unsat(sourceExpreStr, groundExpreStr, bv)
69 | p = Process(target=verify_mba_unsat, args=(sourceExpreStr, groundExpreStr, bv, res,))
70 | p.start()
71 | p.join(timeout) # wait timeout seconds or it finishes
72 |
73 | if p.is_alive():
74 | print("Still solving, but kill it as timeout set to", timeout, "seconds ...")
75 | p.terminate()
76 | p.join()
77 |
78 | result = {
79 | 0: "Timeout",
80 | 1: "True",
81 | 2: "False",
82 | }
83 |
84 | end = time.time()
85 | elapsed = end - start
86 | resultStr = "{source},{ground},{res},{vtime}\n".format(source=sourceExpreStr, ground=groundExpreStr, res=result[res.value], vtime=elapsed)
87 | fwrite.write(resultStr)
88 | fwrite.flush()
89 |
90 | # print linenum, sourceExpreStr, groundExpreStr, result[res.value], elapsed
91 | print linenum, result[res.value], "Time =", elapsed
92 | linenum += 1
93 |
94 | fwrite.close()
95 | return None
96 |
97 |
98 |
99 | def main(sourcefilename, timeout):
100 | stp_check_time(sourcefilename, timeout)
101 |
102 |
103 |
104 | if __name__ =="__main__":
105 | sourcefilename = sys.argv[1]
106 | timeout = int(sys.argv[2])
107 | main(sourcefilename, timeout)
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/stp_solving/total.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | import re
4 | import sys
5 | import time
6 |
7 |
8 |
9 | def total_simplify(smtsolver, solver):
10 | """count the solving number after solving by smt solver.
11 | """
12 | true = 0
13 | false = 0
14 | timeout = 0
15 |
16 | if "mba" in solver:
17 | path = "../dataset"
18 | dataFile = ["linear", "poly", "nonpoly"]
19 | for data in dataFile:
20 | fileread = "{path}/pldi_dataset_{data}_MBA.txt.simplify.txt.{smtsolver}.verify.64bit.after.simplify.txt".format(path=path, data=data, smtsolver=smtsolver)
21 | with open(fileread, "r") as fr:
22 | for line in fr:
23 | line = line.strip().replace(" ", "")
24 | if "#" not in line:
25 | expreStrList = re.split(",", line)
26 | flag = expreStrList[4]
27 | if "ue" in flag:
28 | true += 1
29 | elif "out" in flag:
30 | timeout += 1
31 | else:
32 | false += 1
33 | elif "sspam" in solver:
34 | path = "../sspam"
35 | dataFile = ["linear", "poly", "nonpoly"]
36 | for data in dataFile:
37 | fileread = "{path}/{data}.MBA.SSPAM.result.txt.{smtsolver}.verify.64bit.after.simplify.txt".format(path=path, data=data, smtsolver=smtsolver)
38 | with open(fileread, "r") as fr:
39 | for line in fr:
40 | line = line.strip().replace(" ", "")
41 | if "#" not in line:
42 | expreStrList = re.split(",", line)
43 | flag = expreStrList[3]
44 | if "ue" in flag:
45 | true += 1
46 | elif "out" in flag:
47 | timeout += 1
48 | else:
49 | false += 1
50 | elif "syntia" in solver:
51 | path = "../syntia"
52 | dataFile = ["linear", "poly", "nonpoly"]
53 | for data in dataFile:
54 | fileread = "{path}/{data}.64bit.result.txt.{smtsolver}.verify.64bit.after.simplify.txt".format(path=path, data=data, smtsolver=smtsolver)
55 | with open(fileread, "r") as fr:
56 | for line in fr:
57 | line = line.strip().replace(" ", "")
58 | if "#" not in line:
59 | expreStrList = re.split(",", line)
60 | flag = expreStrList[3]
61 | if "ue" in flag:
62 | true += 1
63 | elif "out" in flag:
64 | timeout += 1
65 | else:
66 | false += 1
67 | total = true+false+timeout
68 | print("Total: ", total)
69 | print("True: ", true)
70 | print("False: ", false)
71 | print("Timeout: ", timeout)
72 |
73 | return None
74 |
75 |
76 |
77 | def total_original(smtsolver):
78 | """count the solving number before solving by smt solver.
79 | """
80 | true = 0
81 | false = 0
82 | timeout = 0
83 |
84 |
85 | path = "../dataset"
86 | dataFile = ["linear", "poly", "nonpoly"]
87 | for data in dataFile:
88 | fileread = "{path}/pldi_dataset_{data}_MBA.txt.{smtsolver}.verify.64bit.before.simplify.txt".format(path=path, data=data, smtsolver=smtsolver)
89 | with open(fileread, "r") as fr:
90 | for line in fr:
91 | line = line.strip().replace(" ", "")
92 | if "#" not in line:
93 | expreStrList = re.split(",", line)
94 | flag = expreStrList[2]
95 | if "ue" in flag:
96 | true += 1
97 | elif "out" in flag:
98 | timeout += 1
99 | else:
100 | false += 1
101 | total = true+false+timeout
102 | print("Total: ", total)
103 | print("True: ", true)
104 | print("False: ", false)
105 | print("Timeout: ", timeout)
106 |
107 | return None
108 |
109 |
110 |
111 |
112 |
113 | def main(smtsolver, flag, solver=None):
114 | if flag:
115 | #after simplification
116 | total_simplify(smtsolver, solver)
117 | else:
118 | #before simplification
119 | total_original(smtsolver)
120 |
121 |
122 |
123 | if __name__ =="__main__":
124 | #smt solver
125 | smtsolver = sys.argv[1]
126 | #before/after simplification
127 | flag = int(sys.argv[2])
128 | #if simplificationn, tools
129 | if len(sys.argv) > 3:
130 | solver = sys.argv[3]
131 | main(smtsolver, flag, solver)
132 | else:
133 | main(smtsolver, flag)
134 |
135 |
136 |
--------------------------------------------------------------------------------
/syntia/linear.64bit.result.txt:
--------------------------------------------------------------------------------
1 | #original,correct,simplified,simplificationTrue/False,z3time
2 | ##all synthesis time:1261.83443284
3 | (x|y)+y-(~x&y),x+y,(y ^ x),False,0.0168790817261
4 | 3*(x&~y)-(x^y)+~x-~(x&y),x-y,(x - y),True,0.0121159553528
5 | -1*(~(x&y))+(x|y)-1*(x^y)-1*x+2*~x-1*(~(x&~y))-1*(~(x^y))-1*(x|~y)+3*(~(x|y))+1*(~(x|~y))+4*(x&~y)+4*(x&y),1*y+1*~y,(x + ((b + d) << y)),0,0,0,0,False,0
6 | -2*(~(x&y))-2*~y-2*~x+(~(x^y))-2*x-1*y-1*(x|y)+(x|~y)+6*(~(x|y))+8*(~(x|~y))+7*(x&~y)+4*(x&y),1*(~(x&~x))+1*(~(x&~y)),(((z | c) & 1) + a),False,0.0132389068604
7 | -1*(x|y)+(~(x&~y))+2*y-2*~y-1*~x-1*(~(x&~x))+(~(x^y))+x+2*(~(x|y))-1*(~(x|~y))+3*(x&~y)-2*(x&y),-(~(x&y))+1*(x|~y),(((a & b) & 1) + b),False,0.0200791358948
8 | -1*x-1*~y+4*(~(x&~x))-1*(~(x^y))+y-4*(~(x&y))-1*(~(x&~y))+2*(~(x|y))-1*(~(x|~y))+2*(x&~y)-2*(x&y),-~x,(- (~ x)),True,0.0118489265442
9 | (~(x&~x))+y-2*(x^y)-1*~y+x-1*(~(x&~y))-2*~x-3*(~(x|y))-2*(~(x|~y))-4*(x&~y)-3*(x&y),-5*(~(x&y))-(~(x^y)),(1 + (f << e)),0,0,0,0,False,0
10 | (~(x&y))+(x^y)-1*y+x-2*(x|~y)+2*(~(x&~y))+~y-1*(~(x^y))-1*(~(x|y))-4*(~(x|~y))-3*(x&~y),-(x|y),((x & t) + e),False,0.0133409500122
11 | -1*x-1*~x+4*(x|~y)-1*(~(x&~y))-1*~y-4*(x&~y)-1*(x&y),1*(~(x^y))-2*(x^y),(1 | c),False,0.0364170074463
12 | 2*~x+5*(~(x^y))-1*(~(x&y))+(x^y)+x-1*(~(x&~y))+(x|~y)-7*(~(x|y))-3*(~(x|~y))-3*(x&~y)-8*(x&y),-y-(~(x&~x)),(~ (- y)),False,0.0151410102844
13 | -3*~(x^y)-6*~y-2*(x^y)-7*~(x&y)+1*~(x&~x)+2*~(x&~y)-11*(x|~y)-6*x-2*y+24*~(x|y)+8*~(x|~y)+31*(x&~y),-19*(x&y),(- (~ c)),False,0.0134990215302
14 | 1*((x|y)&~(y^z))+1*~(x|(y|z))-2*~(~x|(y|z))-2*(x&(y&z)),1*(~x&(~y|z))-1*((x|~y)&(x^(y^z))),(((~ z) & 1) + y),False,0.0202009677887
15 | -3*(z^~(~x|(~y&z)))-1*(x&(~y|z))-4*~(x|(~y|z))-1*~(~x|(~y|z))+3*(~x&(~y&z))-1*(~x&(y&z))-3*(x&(y&z)),-4*(x|y),(((x | y) & a) + a),False,0.0231871604919
16 | 2*(y|~(x^z))-1*(~x&(~y|z))+2*~(x^(y|z))-3*~(x|(y|z))-2*~(x|(~y|z))+1*(~x&(~y&z))-4*(x&(~y&z))-4*(x&(y&z)),4*~(~x|(~y|z))+1*(~x&(y&z)),((t & a) + d),False,0.0159850120544
17 | 5*(~x&(y^z))+1*(x&(y^z))+1*((x&~y)|(x^(y^z)))-6*~(x|(~y|z))-1*~(~x|(y|z))-1*~(~x|(~y|z))-2*(x&(~y&z))-1*(x&(y&z)),6*(~x&(~y&z)),(((z >> a) & t) + t),0,0,0,0,False,0
18 | -7*((x^y)&~(x^z))+5*(~z|~(x^y))-3*~(x|(y|z))+4*~(x|(~y|z))-3*~(~x|(y|z))-3*~(~x|(~y|z))-3*(~x&(~y&z))+9*(x&(~y&z))-5*(x&(y&z)),2*~(y&z),(t + (c & 1)),False,0.0141570568085
19 | -3*~(y^z)+5*(z^(~x|(y|z)))-12*~(x|(y|z))-15*~(x|(~y|z))-8*~(~x|(y|z))-16*~(~x|(~y|z))-8*(~x&(y&z))+1*(x&(~y&z))+3*(x&(y&z)),1*(z^(~x|(y&z)))-11*(z^~(~x&(y&z))),((x & c) + x),False,0.0656371116638
20 | -2*(y|~z)+1*(x^y)+2*~(x|(y|z))+3*~(~x|(y|z))+4*~(~x|(~y|z))+2*(~x&(~y&z))+3*(~x&(y&z))-1*(x&(~y&z))+4*(x&(y&z)),2*(z^~(~x|(y&z)))-1*~(x|(~y|z)),((d & y) + y),False,0.0224850177765
21 | -1*((~(x^(~y&z))&~t)|((z^(~x|(y&z)))&t))+1*((((x&y)^(x^(y&z)))&~t)|(((x&~y)|~(y^z))&t))+1*(((z^~(x&y))&~t)|(((x|y)&~(x^(y^z)))&t))-2*~(~x|(y|(z|t)))-2*~(~x|(~y|(~z|t)))+1*(~x&(y&(~z&t)))-1*(x&(~y&(~z&t)))-2*(~x&(y&(z&t)))-1*(x&(y&(z&t))),1*(x&(y&(~z&t)))+1*(x&(~y&(z&t))),((d & z) + z),False,0.0196537971497
22 | 2*((((y&z)|(~x&(y|z)))&~t)|((y^~(x&(~y&z)))&t))-2*(((z^~(~x&(y|z)))&~t)|(((x|y)&~(y^z))&t))-2*(((z^~(x|(~y&z)))&~t)|(((x&y)^(x^(~y|z)))&t))-2*((((x^y)&(x^z))&~t)|((~(x|y)|~(y^z))&t))+4*~(x|(y|(z|t)))+4*~(~x|(y|(z|t)))+2*~(~x|(~y|(z|t)))+2*~(x|(y|(~z|t)))+2*~(x|(~y|(~z|t)))+2*~(~x|(y|(~z|t)))+2*(~x&(~y&(~z&t)))+2*(~x&(~y&(z&t)))+6*(~x&(y&(z&t)))+6*(x&(y&(z&t))),-2*(x&(~y&(~z&t))),(b + (a & f)),False,0.0122909545898
23 | 3*(((z^~(x|y))&~t)|((y^~(x&(y&z)))&t))+7*(((~y&~(x^z))&~t)|(~(x&~y)&t))+1*(((y^~(~x|(y&z)))&~t)|((x&~x)&t))-1*((~(x|(y|z))&~t)|((z^~(x|(~y&z)))&t))+2*((((x&z)^(x^(~y&z)))&~t)|(((x&y)^~(x^(y&z)))&t))-9*(((x^(y|z))&~t)|(((y&z)|(~x&(y|z)))&t))+1*(((y|(x&~z))&~t)|((~(x|y)|~(x^(y^z)))&t))-5*(((~(x^y)|~(x^z))&~t)|(((x|y)&(x^(y^z)))&t))-4*((((x|~y)&~(x^(y^z)))&~t)|((y|(x^z))&t))+9*(((y^~(x|(~y&z)))&~t)|((x&z)&t))-1*((((x&y)^(x^(~y|z)))&~t)|((z^~(x&~y))&t))-3*(((y^~(x&(y^z)))&~t)|((z^~(~x&(~y|z)))&t))+1*((~(~x&(y&z))&~t)|(~(x^(~y&z))&t))-4*(((x&~z)&~t)|((z&~(x^y))&t))+11*~(x|(~y|(z|t)))+11*~(~x|(y|(z|t)))+3*~(~x|(~y|(z|t)))+15*~(x|(y|(~z|t)))+5*~(x|(~y|(~z|t)))-9*~(~x|(~y|(~z|t)))-12*(~x&(~y&(~z&t)))+13*(~x&(y&(~z&t)))+15*(x&(~y&(~z&t)))+4*(x&(y&(~z&t)))+14*(~x&(~y&(z&t)))+13*(~x&(y&(z&t)))-12*(x&(~y&(z&t)))+10*(x&(y&(z&t))),-1*~(~x|(y|(~z|t)))+6*(((~y&~(x^z))&~t)|((z^~(~x|(y&z)))&t)),((1 & z) + z),False,0.0253689289093
24 |
--------------------------------------------------------------------------------
/syntia/makefile:
--------------------------------------------------------------------------------
1 | linear-program-synthesis-64:testmcts.py
2 | python2 testmcts.py 64 ../dataset/pldi_dataset_linear_MBA.txt linear.syntia.64bit.middle.json
3 |
4 | linear-json-transformation-64:
5 | python2 transformation.py linear.syntia.64bit.middle.json linear.64bit.middle.txt
6 |
7 | linear-syntia-evaluation-64:linear-program-synthesis-64 linear-json-transformation-64
8 | python2 syntia-evaluation.py 64 linear.64bit.middle.txt linear.64bit.result.txt
9 |
10 | poly-program-synthesis-64:testmcts.py
11 | python2 testmcts.py 64 ../dataset/pldi_dataset_poly_MBA.txt poly.syntia.64bit.middle.json
12 |
13 | poly-json-transformation-64:
14 | python2 transformation.py poly.syntia.64bit.middle.json poly.64bit.middle.txt
15 |
16 | poly-syntia-evaluation-64:poly-program-synthesis-64 poly-json-transformation-64
17 | python2 syntia-evaluation.py 64 poly.64bit.middle.txt poly.64bit.result.txt
18 |
19 | nonpoly-program-synthesis-64:testmcts.py
20 | python2 testmcts.py 64 ../dataset/pldi_dataset_nonpoly_MBA.txt nonpoly.syntia.64bit.middle.json
21 |
22 | nonpoly-json-transformation-64:
23 | python2 transformation.py nonpoly.syntia.64bit.middle.json nonpoly.64bit.middle.txt
24 |
25 | nonpoly-syntia-evaluation-64:nonpoly-program-synthesis-64 nonpoly-json-transformation-64
26 | python2 syntia-evaluation.py 64 nonpoly.64bit.middle.txt nonpoly.64bit.result.txt
27 |
28 | syntia-simplify:
29 | @echo "------------syntia simplify linear MBA samples-------------------"
30 | @make linear-syntia-evaluation-64
31 | @echo "------------syntia simplify linear MBA samples completion--------"
32 | @echo "------------syntia simplify poly MBA samples-------------------"
33 | @make poly-syntia-evaluation-64
34 | @echo "------------syntia simplify poly MBA samples completion--------"
35 | @echo "------------syntia simplify nonpoly MBA samples-------------------"
36 | @make nonpoly-syntia-evaluation-64
37 | @echo "------------syntia simplify nonpoly MBA samples completion--------"
38 |
--------------------------------------------------------------------------------
/syntia/mcts_synthesis/grammar.py:
--------------------------------------------------------------------------------
1 | from collections import OrderedDict
2 | from orderedset import OrderedSet
3 |
4 | OP1 = OrderedSet(["bvnot",
5 | "bvneg",
6 | ])
7 | OP2 = OrderedSet(["bvadd",
8 | "bvsub",
9 | "bvmul",
10 | "bvudiv",
11 | "bvsdiv",
12 | "bvurem",
13 | "bvsrem",
14 | "bvshl",
15 | "bvlshr",
16 | "bvashr",
17 | "bvand",
18 | "bvor",
19 | "bvxor",
20 | "zero_extend",
21 | "bvconcat",
22 | ])
23 |
24 | OP3 = OrderedSet(["bvextract",
25 | "sign_extend"
26 | ])
27 |
28 | COMMUTATIVE_OPS = OrderedSet(["bvadd",
29 | "bvmul",
30 | "bvand",
31 | "bvor",
32 | "bvxor"])
33 |
34 | NON_TERMINALS = OrderedSet(["u8",
35 | "u16",
36 | "u32",
37 | "u64",
38 | ])
39 |
40 |
41 | class Grammar(object):
42 | def __init__(self, variables, constants=OrderedSet(), bitsize=64):
43 | self.variables = OrderedDict([(v.name, v.size) for v in variables])
44 | self.constants = constants
45 | self.bit_sizes = self.gen_sizes(bitsize)
46 |
47 | self.terminals = OrderedSet([v.name for v in variables] + list(constants))
48 | self.non_terminals = OrderedSet(["u{}".format(size) for size in self.bit_sizes])
49 |
50 | self.op1 = OP1.copy()
51 | self.op2 = OP2.copy()
52 | self.op3 = OP3.copy()
53 | self.commutative_ops = COMMUTATIVE_OPS.copy()
54 |
55 | self.rules = self.gen_rules()
56 |
57 | def gen_sizes(self, bit_size):
58 | sizes = set([bit_size])
59 | for v in self.variables:
60 | size = self.variables[v]
61 | sizes.add(size)
62 | return list(sizes)
63 |
64 | def gen_rules(self):
65 | rules = OrderedDict()
66 | for index in xrange(len(self.bit_sizes)):
67 | size = self.bit_sizes[index]
68 | non_terminal = self.non_terminals[index]
69 | rules[non_terminal] = self.gen_size_rules(size)
70 |
71 | return rules
72 |
73 | def gen_size_rules(self, size):
74 | rules = OrderedSet()
75 |
76 | rules.add("{} u{} u{} bvadd".format(size, size, size))
77 | rules.add("{} u{} u{} bvsub".format(size, size, size))
78 | rules.add("{} u{} u{} bvmul".format(size, size, size))
79 | rules.add("{} {} u{} u{} bvconcat u{} bvudiv".format(size, size, size, size, size))
80 | rules.add("{} {} u{} u{} bvconcat u{} bvsdiv".format(size, size, size, size, size))
81 | rules.add("{} {} u{} u{} bvconcat u{} bvurem".format(size, size, size, size, size))
82 | rules.add("{} {} u{} u{} bvconcat u{} bvsrem".format(size, size, size, size, size))
83 | # rules.add("{} u{} u{} bvudiv".format(size, size, size))
84 | # rules.add("{} u{} u{} bvsdiv".format(size, size, size))
85 | # rules.add("{} u{} u{} bvurem".format(size, size, size))
86 | # rules.add("{} u{} u{} bvsrem".format(size, size, size))
87 | rules.add("{} u{} u{} bvshl".format(size, size, size))
88 | rules.add("{} u{} u{} bvlshr".format(size, size, size))
89 | rules.add("{} u{} u{} bvashr".format(size, size, size))
90 | rules.add("{} u{} u{} bvand".format(size, size, size))
91 | rules.add("{} u{} u{} bvor".format(size, size, size))
92 | rules.add("{} u{} u{} bvxor".format(size, size, size))
93 | rules.add("{} u{} bvnot".format(size, size))
94 | rules.add("{} u{} bvneg".format(size, size))
95 |
96 | if size == 64:
97 | # movzx
98 | if 32 in self.bit_sizes:
99 | rules.add("32 64 u32 zero_extend")
100 | if 16 in self.bit_sizes:
101 | rules.add("16 64 u16 zero_extend")
102 | if 8 in self.bit_sizes:
103 | rules.add("8 64 u8 zero_extend")
104 | # movsx
105 | if 32 in self.bit_sizes:
106 | rules.add("32 64 32 u32 sign_extend")
107 | if 16 in self.bit_sizes:
108 | rules.add("16 64 16 u16 sign_extend")
109 | if 8 in self.bit_sizes:
110 | rules.add("8 64 8 u8 sign_extend")
111 | # concat
112 | if 32 in self.bit_sizes:
113 | rules.add("32 u32 u32 bvconcat")
114 | if size == 32:
115 | # movzx
116 | if 16 in self.bit_sizes:
117 | rules.add("16 32 u16 zero_extend".format(size))
118 | if 8 in self.bit_sizes:
119 | rules.add("8 32 u8 zero_extend".format(size))
120 | # movsx
121 | if 16 in self.bit_sizes:
122 | rules.add("16 32 16 u16 sign_extend")
123 | if 8 in self.bit_sizes:
124 | rules.add("8 32 8 u8 sign_extend")
125 | # extract
126 | if 64 in self.bit_sizes:
127 | rules.add("64 u64 0 31 bvextract")
128 | # concat
129 | if 16 in self.bit_sizes:
130 | rules.add("16 u16 u16 bvconcat")
131 | if size == 16:
132 | # movzx
133 | if 8 in self.bit_sizes:
134 | rules.add("8 16 u8 zero_extend".format(size))
135 | # movsx
136 | if 8 in self.bit_sizes:
137 | rules.add("8 16 8 u8 sign_extend")
138 | # extract
139 | if 64 in self.bit_sizes:
140 | rules.add("64 u64 0 15 bvextract")
141 | if 32 in self.bit_sizes:
142 | rules.add("32 u32 0 15 bvextract")
143 | # concat
144 | if 8 in self.bit_sizes:
145 | rules.add("8 u8 u8 bvconcat")
146 | if size == 8:
147 | # extract
148 | if 64 in self.bit_sizes:
149 | rules.add("64 u64 0 7 bvextract")
150 | rules.add("64 u64 8 15 bvextract")
151 | if 32 in self.bit_sizes:
152 | rules.add("32 u32 0 7 bvextract")
153 | rules.add("32 u32 8 15 bvextract")
154 | if 16 in self.bit_sizes:
155 | rules.add("16 u16 0 7 bvextract")
156 | rules.add("16 u16 8 15 bvextract")
157 |
158 | for v in self.variables:
159 | if self.variables[v] == size:
160 | rules.add(v)
161 |
162 | for c in self.constants:
163 | rules.add(c)
164 |
165 | return rules
166 |
167 | def dump(self):
168 | """
169 | Dumps state to a nested dict
170 | :return: dict
171 | """
172 | ret = OrderedDict()
173 | ret["variables"] = list(self.variables)
174 | ret["constants"] = list(self.constants)
175 | ret["terminals"] = list(self.terminals)
176 | ret["non_terminals"] = list(self.non_terminals)
177 | ret["op1"] = list(self.op1)
178 | ret["op2"] = list(self.op2)
179 | ret["commutative_ops"] = list(self.commutative_ops)
180 | ret["u64_rules"] = list(self.u64_rules)
181 |
182 | return ret
183 |
--------------------------------------------------------------------------------
/syntia/mcts_synthesis/mcts_synthesis_multi_core.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from z3 import simplify
3 | from mcts import *
4 | from game import Game, Variable
5 | from grammar import Grammar
6 | from mctsutils import get_random_inputs
7 | from paralleliser import Paralleliser
8 |
9 | BITSIZE = 32
10 | MAX_UNSIGNED = 2 ** BITSIZE
11 |
12 | if len(sys.argv) < 2:
13 | max_iter = 30000
14 | else:
15 | max_iter = int(sys.argv[1])
16 |
17 | if len(sys.argv) < 3:
18 | uct_scalar = 1.2
19 | else:
20 | uct_scalar = float(sys.argv[2])
21 |
22 |
23 | def oracle(args):
24 | x = args[0]
25 | y = args[1]
26 | z = args[2]
27 | return (x + x + x) % MAX_UNSIGNED
28 | # return ((x + y) - (x * z)) % MAX_UNSIGNED
29 |
30 |
31 | def synthesise(command, result, index):
32 | ret = ""
33 |
34 | max_iter = command[0]
35 | uct_scalar = command[1]
36 | game = command[2]
37 | oracle = command[3]
38 | synthesis_inputs = command[4]
39 |
40 | mc = MCTS(game, oracle, synthesis_inputs, uct_scalar=uct_scalar)
41 | mc.verbosity_level = 1
42 | s = State(game, BITSIZE)
43 |
44 | mc.search(s, max_iter)
45 |
46 | if mc.final_expression:
47 | ret = rpn_to_infix(mc.final_expression)
48 | print "{} ({} iterations)".format(rpn_to_infix(mc.final_expression), mc.current_iter)
49 | try:
50 | simplified = simplify(game.to_z3(mc.final_expression))
51 | print "{} (simplified)".format(simplified)
52 | except:
53 | pass
54 |
55 | result[index] = ret
56 |
57 |
58 | variables = []
59 | for var_index in xrange(3):
60 | v = Variable("V.{}".format(var_index), BITSIZE)
61 | variables.append(v)
62 |
63 | constants = OrderedSet(["1"])
64 |
65 | grammar = Grammar(variables, constants=constants)
66 |
67 | game = Game(grammar, variables, bitsize=BITSIZE)
68 |
69 | task_groups = []
70 | workers = []
71 | commands = []
72 |
73 | for index in xrange(1):
74 | task_group = "TG"
75 | task_groups.append(task_group)
76 |
77 | # this may take some time
78 | synthesis_inputs = get_random_inputs(len(variables), 20)
79 |
80 | command = [max_iter, uct_scalar, game, oracle, synthesis_inputs]
81 |
82 | workers.append(synthesise)
83 | commands.append(command)
84 |
85 | number_of_tasks = len(commands)
86 |
87 | print "Starting main synthesis"
88 | print number_of_tasks
89 |
90 | paralleliser = Paralleliser(commands, workers, number_of_tasks, task_groups)
91 |
92 | start_time = time()
93 | paralleliser.execute()
94 |
95 | end_time = time()
96 |
97 | print "Synthesis finished in {} seconds".format(end_time - start_time)
98 |
--------------------------------------------------------------------------------
/syntia/mcts_synthesis/metrics.py:
--------------------------------------------------------------------------------
1 | from __future__ import division
2 |
3 |
4 | def bitcount(v):
5 | """
6 | Number of set bits in v
7 | :param v: int
8 | :return: int
9 | """
10 | return bin(v).count("1")
11 |
12 |
13 | def leading_zeros(v, bitsize):
14 | """
15 | Count leading zeros
16 | :param v: int
17 | :param bitsize: bit length
18 | :return: int, leading zeros of v
19 | """
20 | # padd bit string
21 | s = format(v, "0{}b".format(bitsize))
22 |
23 | return len(s) - len(s.lstrip('0'))
24 |
25 |
26 | def trailing_zeros(v, bitsize):
27 | """
28 | Count trailing zeros
29 | :param v: int
30 | :param bitsize: int
31 | :return: int, leading zeros of v
32 | """
33 | # padd bit string
34 | s = format(v, "0{}b".format(bitsize))
35 |
36 | return len(s) - len(s.rstrip('0'))
37 |
38 |
39 | def leading_ones(v, bitsize):
40 | """
41 | Count leading ones
42 | :param v: int
43 | :param bitsize: bit length
44 | :return: int, leading ones of v
45 | """
46 | # padd bit string
47 | s = format(v, "0{}b".format(bitsize))
48 |
49 | return len(s) - len(s.lstrip('1'))
50 |
51 |
52 | def trailing_ones(v, bitsize):
53 | """
54 | Count trailing zeros
55 | :param v: int
56 | :param bitsize: int
57 | :return: int, leading ones of v
58 | """
59 | # padd bit string
60 | s = format(v, "0{}b".format(bitsize))
61 |
62 | return len(s) - len(s.rstrip('1'))
63 |
64 |
65 | def num_distance(a, b):
66 | """
67 | Numeric distance of a and b
68 | :param a: int
69 | :param b: int
70 | :return: int
71 | """
72 | return abs(a - b)
73 |
74 |
75 | def rotate_left(a, b, size):
76 | """
77 | Rotates bits of a to the left b times
78 |
79 | :param a: int to shift
80 | :param b: int, number of shifts
81 | :param size: bit length
82 | :return: int
83 | """
84 | shift = b & (size - 1)
85 | return ((a << shift) | (a >> size - shift)) % 2 ** size
86 |
87 |
88 | def metric_hamming_distance(a, b, bitsize):
89 | """
90 | Hamming distance
91 | :param a: int
92 | :param b: int
93 | :param bitsize: int
94 | :return: flaot
95 | """
96 | n = bitcount(a ^ b)
97 | return 1 - (n / bitsize)
98 |
99 |
100 | def metric_leading_zeros(a, b, bitsize):
101 | """
102 | Numeric difference of the leading
103 | zeros from a and b
104 | :param a: int
105 | :param b: int
106 | :param bitsize: int
107 | :return: float
108 | """
109 | # leading zeros
110 | a = leading_zeros(a, bitsize)
111 | b = leading_zeros(b, bitsize)
112 |
113 | # numeric difference
114 | n = abs(a - b)
115 |
116 | return 1 - float(n / bitsize)
117 |
118 |
119 | def metric_trailing_zeros(a, b, bitsize):
120 | """
121 | Numeric difference of the trailing
122 | zeros from a and b
123 | :param a: int
124 | :param b: int
125 | :param bitsize: int
126 | :return: float
127 | """
128 | # leading zeros
129 | a = trailing_zeros(a, bitsize)
130 | b = trailing_zeros(b, bitsize)
131 |
132 | # numeric difference
133 | n = abs(a - b)
134 |
135 | return 1 - float(n / bitsize)
136 |
137 |
138 | def metric_leading_ones(a, b, bitsize):
139 | """
140 | Numeric difference of the leading
141 | ones from a and b
142 | :param a: int
143 | :param b: int
144 | :param bitsize: int
145 | :return: float
146 | """
147 | # leading ones
148 | a = leading_ones(a, bitsize)
149 | b = leading_ones(b, bitsize)
150 |
151 | # numeric difference
152 | n = abs(a - b)
153 |
154 | return 1 - float(n / bitsize)
155 |
156 |
157 | def metric_trailing_ones(a, b, bitsize):
158 | """
159 | Numeric difference of the trailing
160 | ones from a and b
161 | :param a: int
162 | :param b: int
163 | :param bitsize: int
164 | :return: float
165 | """
166 | # trailing ones
167 | a = trailing_ones(a, bitsize)
168 | b = trailing_ones(b, bitsize)
169 |
170 | # numeric difference
171 | n = abs(a - b)
172 |
173 | return 1 - float(n / bitsize)
174 |
175 |
176 | def metric_num_distance(a, b):
177 | """
178 | Numeric distance of a and b.
179 | Normalised with their local
180 | maximum.
181 | :param a: int
182 | :param b: int
183 | :return: float
184 | """
185 | # numeric distance
186 | d = num_distance(a, b)
187 |
188 | # avoid division by 0
189 | if a == b:
190 | return 1
191 | else:
192 | # maximum of a and b
193 | maximum = max([abs(a), abs(b)])
194 | return 1 - (d / maximum)
195 |
196 |
197 | def distance_metric(a, b, bitsize):
198 | """
199 | Combines different distance metrics
200 | :param a: int
201 | :param b: int
202 | :param bitsize: int
203 | :return: float
204 | """
205 | # initial score
206 | score = 0.0
207 |
208 | # apply metrics
209 | for x, y in [(a, b)]:
210 | score += metric_hamming_distance(x, y, bitsize)
211 | score += metric_leading_zeros(x, y, bitsize)
212 | score += metric_trailing_zeros(x, y, bitsize)
213 | score += metric_leading_ones(x, y, bitsize)
214 | score += metric_trailing_ones(x, y, bitsize)
215 | score += metric_num_distance(x, y)
216 |
217 | # normalise weights
218 | d = score / 6
219 |
220 | return d
221 |
--------------------------------------------------------------------------------
/syntia/mcts_synthesis/paralleliser.py:
--------------------------------------------------------------------------------
1 | import multiprocessing
2 | from random import choice, shuffle
3 |
4 |
5 | class Paralleliser(object):
6 | def __init__(self, commands, workers, number_of_tasks, task_groups, number_of_cpus=0):
7 | self.commands = commands
8 | self.workers = workers
9 | self.number_of_tasks = number_of_tasks
10 | self.task_groups = task_groups
11 |
12 | self.process_to_task_group = dict()
13 | self.process_to_task_id = dict()
14 | self.task_group_results = dict()
15 |
16 | if not number_of_cpus:
17 | number_of_cpus = multiprocessing.cpu_count()
18 | self.number_of_cpus = number_of_cpus
19 |
20 | def execute(self):
21 | # initialise parallel data structures
22 | manager = multiprocessing.Manager()
23 | results = manager.list()
24 | processes = [None] * self.number_of_tasks
25 |
26 | # set task_groups to not-finished
27 | task_group_states = {}
28 | for task in self.task_groups:
29 | task_group_states[task] = 0
30 |
31 | # initialise process mappings
32 | process_to_task_group = dict()
33 | process_to_index = dict()
34 |
35 | # initialise processes
36 | for i in range(len(processes)):
37 | # extend results
38 | results.append(None)
39 |
40 | # get command
41 | command = self.commands[i]
42 |
43 | # create process
44 | processes[i] = multiprocessing.Process(target=self.workers[i], args=(command, results, i))
45 |
46 | # map process to process index
47 | process_to_index[processes[i]] = i
48 |
49 | # choose task group randomly
50 | process_to_task_group[processes[i]] = self.task_groups[i]
51 |
52 | # initialise data structures
53 | active_processes = set()
54 | done = set()
55 | process_counter = -1
56 |
57 | # random permutation of process indexes
58 | random_process_indices = list(range(len(processes)))
59 | shuffle(random_process_indices)
60 |
61 | # iterate until all processes have been processed
62 | while len(done) < len(processes):
63 | # add more processes, if # processes < # cpu cores and there are processes remaining
64 | while len(active_processes) < self.number_of_cpus and process_counter < len(processes) - 1:
65 | # increase index
66 | process_counter += 1
67 | # random process index
68 | random_process_index = random_process_indices.pop()
69 | # get next process
70 | process = processes[random_process_index]
71 |
72 | # get process' task group
73 | task_group = process_to_task_group[process]
74 |
75 | # print random_process_index, task_group
76 |
77 | # process' taskgroup has been solved
78 | if task_group_states[task_group]:
79 | done.add(process)
80 |
81 | # get next process
82 | if process in done:
83 | continue
84 |
85 | # start process
86 | process.start()
87 |
88 | # add to active processes
89 | active_processes.add(process)
90 |
91 | # if there are active processes
92 | if active_processes:
93 | # choose random process
94 | process = choice(list(active_processes.copy()))
95 |
96 | # process has been terminated
97 | if not process.is_alive():
98 | # get process index
99 | process_index = process_to_index[process]
100 | # get result
101 | result = results[process_index]
102 |
103 | # if process terminated with a result:
104 | if result:
105 | # get process' task group
106 | task_group = process_to_task_group[process]
107 | # set task group to finished
108 | task_group_states[task_group] = 1
109 |
110 | # store task group's result
111 | self.task_group_results[task_group] = result
112 |
113 | # terminate active processes in current task group
114 | for process in active_processes.copy():
115 | # process is in the same task group?
116 | if task_group == process_to_task_group[process]:
117 | # kill process
118 | process.terminate()
119 | # add to done
120 | done.add(process)
121 | # remove from active processes
122 | active_processes.remove(process)
123 |
124 | # delete process
125 | else:
126 | # add to done
127 | done.add(process)
128 | # remove from active processes
129 | active_processes.remove(process)
130 |
131 | return results
--------------------------------------------------------------------------------
/syntia/mcts_synthesis/sample_synthesis.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from orderedset import OrderedSet
3 | from collections import OrderedDict
4 |
5 | from sampling_synthesis_helpers import AssemblyOracleSynthesizer, worker_synthesize_from_assembly_oracle
6 | from utils import dump_to_json
7 |
8 | # check stdin
9 | if len(sys.argv) < 3:
10 | print "[*] Syntax: