module M

  use int.Int
  use int.EuclideanDivision

  predicate even (x : int) = x = 2 * (div x 2)
  predicate odd  (x : int) = x = 2 * (div x 2) + 1

  let rec is_even x : bool variant {x}
    requires { 0 <= x }
    ensures  { result = even x }
    = if x = 0 then True else is_odd (x-1)

  with is_odd x : bool variant {x}
    requires { 0 <= x }
    ensures  { result = odd x }
    = if x = 0 then False else is_even (x-1)

end
