

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

  let f [@bddinfer] [@infer](x: int) : bool =
    requires {x <= 0}
    ensures  { result = true }
    let x = ref x in
    let y = ref true in
    while !x < 0 do
      variant {0 - !x}
      y := andb !y (!x < 0);
      x := !x + 1
    done;
    !y

  let f2 [@bddinfer] [@infer:oct](x: int) : bool =
    requires {x <= 0}
    ensures  { result = true }
    let x = ref x in
    let y = ref true in
    while !x < 0 do
      variant {0 - !x}
      y := andb !y (!x < 0);
      x := !x + 1
    done;
    !y

  let f3 [@bddinfer] [@infer:box](x: int) : bool =
    requires {x <= 0}
    ensures  { result = true }
    let x = ref x in
    let y = ref true in
    while !x < 0 do
      variant {0 - !x}
      y := andb !y (!x < 0);
      x := !x + 1
    done;
    !y

end
