Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can represent programs as a set of Horn clauses. For your program you can represent it as follows:</p> <pre><code> (set-logic HORN) (set-option :fixedpoint.engine bmc) (declare-fun L0 (Bool Bool) Bool) (declare-fun L1 (Bool Bool) Bool) (declare-fun L2 (Bool Bool) Bool) (declare-fun L3 (Bool Bool) Bool) (assert (forall ((x Bool) (y Bool)) (L0 x y))) ; all values of x,y are possible at L0 (assert (forall ((x Bool) (y Bool)) (=&gt; (L0 x y) (L1 x y)))) ; from L0 move to L1 without changing x, y (assert (forall ((x Bool) (y Bool) (x1 Bool) (y1 Bool)) (=&gt; (and (not x) (L1 x y) (= x1 (or x y)) (= y1 (and x1 y))) (L1 x1 y1)))); assignment in while loop (assert (forall ((x Bool) (y Bool)) (=&gt; (and x (L1 x y)) (L2 x y)))) ; exit while loop (assert (forall ((x Bool) (y Bool)) (=&gt; (L2 x y) (L3 x (or x y))))) ; assignment after while loop (assert (forall ((x Bool) (y Bool)) (=&gt; (L3 true true) false))) ; say x = true, y = true is unreachable. (check-sat) </code></pre> <p>I have added a last assertion to make a reachability statement. I have also instructed Z3 to use a BMC engine to unfold the Horn clauses using bounded model checking. Other engines are available as well, for the example the PDR/IC3 engine (set-option :fixedpoint.engine pdr), does not unfold transition relations.</p> <p>Now the meaning of reachability vs. satisfiability is going to be different for Horn clauses, as compared to a conjunction of the unfolded transition relation: the above clauses are UNSAT. This does in fact correspond to a feasible path from L0 to (L3 true true). If you change the last statement to (L3 true false), you get the answer "sat" (The BMC problem is UNSAT). While BMC itself would not terminate on with such a loop, it turns out that the last transition and loop exit condition are enough to prune out the possibility of (L3 true false) so Z3 solves this problem by pre-processing the horn clauses.</p> <p>You can of course also write down the transition relation for the program statements you have and unfold this directly yourself into a logical formula that you check satisfiability of.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload