python - how to convert z3py expression to smtlib 2 format -


my question related to: z3: convert z3py expression smt-lib2?

i trying convert z3py expression smtlib2 format. using following script, after conversion when feeding result z3 or other smt, get:

"syntax error, unexpected let"

is there way can bring in smtlib2 format using z3py dont have write long expression again.

following code using conversion:

def convertor(f, status="unknown", name="benchmark", logic=""): v = (ast * 0)() if isinstance(f, solver): = f.assertions() if len(a) == 0:   f = boolval(true) else:   f = and(*a) return z3_benchmark_to_smtlib_string(f.ctx_ref(), name, logic, status, "", 0, v, f.as_ast())  x = int('x') y = int('y') s = solver() s.add(x > 0) s.add( x < 100000) s.add(x==2*y) print convertor(s, logic="qf_lia")    

and output:

(set-info :status unknown) (set-logic qf_lia) (declare-fun y () int) (declare-fun x () int) (let (($x34 (= x (* 2 y)))) (let (($x31 (< x 100000))) (let (($x10 (> x 0))) (let (($x35 (and $x10 $x31 $x34))) (assert $x35))))) (check-sat) 

this related question here.

most likely, problem because of outdated version of z3. there have been numerous bugfixes haven't made master branch yet , using unstable branch (or precompiled nightly binaries here) different output, accepted z3 without errors:

(set-info :status unknown) (set-logic qf_lia) (declare-fun y () int) (declare-fun x () int) (assert (let (($x34 (= x (* 2 y)))) (let (($x31 (< x 100000))) (let (($x10 (> x 0))) (and $x10 $x31 $x34))))) (check-sat) 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -