
module Test2

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

let to_true (ii : bool) (arg : bool) : bool
    writes { }
    ensures { if ii then result = true else result = arg}
    = if ii then true else arg

val x0 : ref bool
val x1 : ref bool
val x2 : ref bool
val x3 : ref bool

let pgmtest [@infer] [@bddinfer] () : unit = [@vc:divergent]
    let a = ref false in
    let b = ref false in
    let c = ref false in
    let d = ref false in
    let e = ref false in
	while (!x3 && not !x1 && not !x2) do

	      label Init in
	      (* ****** *)
	      let tmp1 = (!x0 || !a) && not !e in
	      let a1 = tmp1 in
	      let tmp2 = tmp1 && !x1 && !x3 in
	      let d1 = tmp2 in
	      let b1 = to_true tmp1 !b in
	      let tmp3 = tmp1 && !b && !x2 in
	      let c1 = to_true tmp3 !c in
 	      (* ****** *)
	      a := a1 ;
	      b := b1 ;
	      c := c1 ;
	      d := d1 ;
	      (* ****** *)
	      [@bddinfer:Assert] assert {  !x0 \/ (!a at Init) -> !a } ;

	done ;

end
