module Example_scan


use export ref.Ref
use export bool.Bool
use export int.Int


val foo (input : bool) (src : int) (tgt : ref int) : unit
writes { tgt }

(* This does not work *)
(*
ensures { orb input (!tgt = src) }
*)
(* This does not work either *)
ensures { orb (andb input (!tgt = src))
	      (andb (notb input) (!tgt= old !tgt)) }

(* This works
ensures { input \/ (!tgt = src) }
ensures { input -> (!tgt = src) }
ensures { input || (!tgt = src) }
*)

(**********************************************************************************)

val d0 [@model] [@model_trace:D0] : ref int
val d1 [@model] [@model_trace:D1] : ref int

let example_scan [@bddinfer] ()
  diverges
  requires { ((!d0) = 0) }
  requires { ((!d1) = 0) }
  =
  while True do
	foo true !d0 d1
  done

end
