Explore a new tool to make changes to an SMT2 file.
Current features include:
- tagging asserts with names and inserting a call to get-unsat-core
- being able to remove clauses not in the unsat core
- tagging quantified expressions with a QID
- setting the weight of quantified expressions
cargo run -p smt2patch -- --get-unsat-core FILE | z3 -in | tail -n 1 > unsat_core.txt
cargo run -p smt2patch -- --keep-only-clauses "$(cat unsat_core.txt)" -- FILE | z3 -in
cargo run -p smt2patch -- --tag-quantifiers FILE | z3 trace=true -in # z3.log now contains quant!N names
cargo run -p smt2patch -- --set-weights quant!0=100 -- FILE
Example of output using --get-unsat-core
and --tag-quantifiers
:
(set-option :produce-unsat-cores true)
(set-info :smt-lib-version 2.6)
(set-logic ALIA)
(set-info :source piVC)
(set-info :category "industrial")
(set-info :status unsat)
(declare-fun V_9 () Int)
(declare-fun a () (Array Int Int))
(assert (! (let ((?v_0 (and true (>= V_9 0)))) (and (and ?v_0 ?v_0) (and (forall ((?V_7 Int)) (! (=> (and (<= 0 ?V_7) (<= ?V_7 5)) (forall ((?V_8 Int)) (! (let ((?v_1 (store (store a 0 5) 5 7))) (=> (and (<= 0 ?V_8) (<= ?V_8 ?V_7)) (<= (select ?v_1 ?V_8) (select ?v_1 ?V_7)))) :qid quant!0))) :qid quant!1)) (forall ((?V_5 Int)) (! (=> (and (<= 0 ?V_5) (<= ?V_5 5)) (forall ((?V_6 Int)) (! (let ((?v_2 (store (store a 0 1) 5 3))) (=> (and (<= 0 ?V_6) (<= ?V_6 ?V_5)) (<= (select ?v_2 ?V_6) (select ?v_2 ?V_5)))) :qid quant!2))) :qid quant!3))))) :named clause!0))
(check-sat)
(get-unsat-core)
(exit)
Original file:
(set-info :smt-lib-version 2.6)
(set-logic ALIA)
(set-info :source |piVC|)
(set-info :category "industrial")
(set-info :status unsat)
(declare-fun V_9 () Int)
(declare-fun a () (Array Int Int))
(assert (let ((?v_0 (and true (>= V_9 0)))) (and (and ?v_0 ?v_0) (and (forall ((?V_7 Int)) (=> (and (<= 0 ?V_7) (<= ?V_7 5)) (forall ((?V_8 Int)) (let ((?v_1 (store (store a 0 5) 5 7))) (=> (and (<= 0 ?V_8) (<= ?V_8 ?V_7)) (<= (select ?v_1 ?V_8) (select ?v_1 ?V_7))))))) (forall ((?V_5 Int)) (=> (and (<= 0 ?V_5) (<= ?V_5 5)) (forall ((?V_6 Int)) (let ((?v_2 (store (store a 0 1) 5 3))) (=> (and (<= 0 ?V_6) (<= ?V_6 ?V_5)) (<= (select ?v_2 ?V_6) (select ?v_2 ?V_5)))))))))))
(check-sat)
(exit)
CLA Signed