val lemma_of_nat_of_uint (n:nat) (x:nat) : Lemma
  (requires x < pow2 n)
  (ensures of_nat x == of_uint_ n x)
let rec lemma_of_nat_of_uint n x
  =
  if n > 0 then
  (
    lemma_of_nat_of_uint (n - 1) (x / 2);
    lemma_bitwise_all ();
    lemma_equal (of_nat x) (of_uint n x)
  )
val lemma_of_nat_of_uint (n:nat) (x:nat) : Lemma
  (requires x < pow2 n)
  (ensures of_nat x == of_uint_ n x)
let rec lemma_of_nat_of_uint n x =
if n > 0
then
  (lemma_of_nat_of_uint (n - 1) (x / 2);
    lemma_bitwise_all ();
    lemma_equal (of_nat x) (of_uint n x))
Vale.Math.Poly2.Bits.fst.checked
Vale.Arch.TypesNative.fsti.checked prims.fst.checked FStar.UInt.fsti.checked FStar.Pervasives.fsti.checked FStar.Mul.fst.checked FStar.Classical.fsti.checked
Vale.Math.Poly2.Bits.fst
Prims.nat Prims.op_GreaterThan Vale.Math.Poly2.lemma_equal Vale.Math.Poly2.Bits.of_nat Vale.Math.Poly2.Bits_s.of_uint Prims.unit Vale.Math.Poly2.Lemmas.lemma_bitwise_all Vale.Math.Poly2.Bits.lemma_of_nat_of_uint Prims.op_Subtraction Prims.op_Division Prims.bool
module Vale.Math.Poly2.Bits
open FStar.Mul
open Vale.Arch.TypesNative

let lemma_to_of_uint n u =
  let a = of_uint n u in
  let u' = to_uint n a in
  lemma_index a;
  lemma_reverse_define_all ();
  let s = UInt.to_vec #n u in
  let s' = UInt.to_vec #n u' in
  assert (equal s s');
  ()

let rec of_nat x =
  if x = 0 then zero
  else
    let p = shift (of_nat (x / 2)) 1 in
    if x % 2 = 0 then p else p +. one

let rec lemma_of_to_vec_zero (i:nat) (n:nat) : Lemma
  (requires i < n)
  (ensures index (to_vec #n 0) i == false)
  [SMTPat (index (to_vec #n 0) i)]
  =
  if i + 1 < n then lemma_of_to_vec_zero i (n - 1)

let lemma_of_uint_zero (n:nat) : Lemma
  (ensures of_uint_ n 0 == zero)
  =
  lemma_bitwise_all ();
  lemma_equal (of_uint_ n 0) zero

let rec lemma_of_nat_of_uint n x
val lemma_of_nat_of_uint (n:nat) (x:nat) : Lemma
  (requires x < pow2 n)
  (ensures of_nat x == of_uint_ n x)
n: Prims.nat -> x: Prims.nat
  -> FStar.Pervasives.Lemma (requires x < Prims.pow2 n)
      (ensures Vale.Math.Poly2.Bits.of_nat x == Vale.Math.Poly2.Bits.of_uint_ n x)