module M
  use ref.Ref
  use list.List
  use int.Int

  let test_post (x: int) (y: ref int): unit
    ensures { old !y >= x }
      =
      y := x - 1 + !y

  let test_post2 (x: int) (y: ref int): unit
    requires { x > 42 }
    ensures { old !y > !y + x }
      =
      y := x - 1 + !y


  (**********************************************************
   ** Getting counterexamples for terms of primitive types **
   **********************************************************)
  val y :ref int

  let incr (x23: ref int): unit
  ensures { !x23 = old !x23 + 2 + !y }
  =
  (*#"random_path.random" 62 27 32#*)
  y := !y + 1;
  x23 := !x23 + 1;
  x23 := !x23 + 1

  let test_loop (x: ref int): unit
  ensures { !x < old !x }
  =
  label L in
  incr x;
  label M in
  while !x > 0 do
  invariant { !x > !x at L + !x at M }
  variant { !x }
    x := !x - 1
  done

end
