-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_barrier.py
46 lines (34 loc) · 1.18 KB
/
run_barrier.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import argparse
import logging
import barrier
from sabbath.lzz.serialization import importLzz, importInvar
from pysmt.shortcuts import get_env, Solver, Not
from pysmt.logics import QF_NRA
from sabbath.compute_barrier import synth_barrier
parser = argparse.ArgumentParser()
parser.add_argument("problem",help="File containing the invariant verification")
parser.add_argument("--solver",
choices=["z3","mathsat","mathematica"],
default="z3",
help="SMT solver to use")
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG)
print("Parsing problem...")
env = get_env()
with open(args.problem, "r") as json_stream:
problem_list = importInvar(json_stream, env)
assert(len(problem_list) == 1)
for p in problem_list:
(problem_name, init, safe, dyn_sys, invariants, predicates) = p
degree = 2
max_degree = 10
solved = False
while ( (not solved) and degree < max_degree):
print("Finding barrier with %d degree..." % degree)
(res, barrier) = synth_barrier(dyn_sys, init, Not(safe), degree)
solved = res
degree += 1
if (solved):
print("Found barrier: ",sabbath.serialize())
else:
print("Barrier not found")