SMT with Z3 from Scratch

2019-01-15

I’m not sure what this is building up to, but another thing on my to-do list is to learn how to use the Z3 theorem prover. This repo is where I’m saving my experiments.

Example (1):

; https://stackoverflow.com/questions/30998111/executing-a-z3-script-in-command-line-prompt
(declare-const a Int)
(declare-fun f (Int Bool) Int)
(assert (> a 10))
(assert (< (f a true) 100))
(check-sat)
view raw ex1.smt2 hosted with ❤ by GitHub

Example (2):

; https://stackoverflow.com/questions/13395391/z3-finding-all-satisfying-models
(declare-const f Bool)
(assert (or (= f true) (= f false)))
(check-sat)
view raw ex2.smt2 hosted with ❤ by GitHub

Update (2019-01-17)

Added some examples.

Tags

Z3
SMT
Theorem solvers

Content © 2025 Richard Cook. All rights reserved.