Definition wbring (sz : nat) : semi_ring_theory (wzero sz) (wones sz) (@wor sz) (@wand sz) (@eq _) :=
  mk_srt _ _ _ _ _
  (@wor_unit _) (@wor_comm _) (@wor_assoc _)
  (@wand_unit _) (@wand_kill _) (@wand_comm _) (@wand_assoc _)
  (@wand_or_distr _).(** * Inequality proofs *)

Ltac word_simpl := unfold sext, zext, wzero in *; simpl in *.Ltac word_eq := ring.Ltac word_eq1 := match goal with
                   | _ => ring
                   | [ H : _ = _ |- _ ] => ring [H]
                 end.Ltac word_neq := apply word_neq; let H := fresh "H" in intro H; simpl in H; ring_simplify in H; try discriminate.Ltac word_contra := match goal with
                      | [ H : _ <> _ |- False ] => apply H; ring
                    end.Ltac word_contra1 := match goal with
                       | [ H : _ <> _ |- False ] => apply H;
                         match goal with
                           | _ => ring
                           | [ H' : _ = _ |- _ ] => ring [H']
                         end
                     end.

(* Specifications: *)
Lemma not_wlt_ge : forall sz (l r : word sz), ((l < r) -> False) -> (r <= l).
Lemma not_wle_gt : forall sz (l r : word sz), ((l <= r) -> False) -> (r < l).
Lemma lt_le : forall sz (a b : word sz), a < b -> a <= b.
Lemma eq_le : forall sz (a b : word sz), a = b -> a <= b.
Lemma wordToN_inj : forall sz (a b : word sz), wordToN a = wordToN b -> a = b.
Lemma wordToNat_inj : forall sz (a b : word sz), wordToNat a = wordToNat b -> a = b.
Lemma sub_0_eq : forall sz (a b : word sz), a ^- b = wzero _ -> a = b.
Lemma le_neq_lt : forall sz (a b : word sz), b <= a -> a <> b -> b < a.
Lemma rewrite_weq : forall sz (a b : word sz) (pf : a = b), weq a b = left _ pf.
Theorem natToWord_inj : forall sz n m, natToWord sz n = natToWord sz m -> (n < pow2 sz)%nat -> (m < pow2 sz)%nat -> n = m.
Lemma wordToNat_natToWord_idempotent : forall sz n, (N.of_nat n < Npow2 sz)%N -> wordToNat (natToWord sz n) = n.
Lemma wneg_zero': forall sz, wneg (natToWord sz 0) = natToWord sz 0.
Lemma wones_pow2_minus_one: forall {sz}, wordToNat (wones sz) = pow2 sz - 1.
Lemma pow2_minus_one_wones: forall {sz} (w: word sz), wordToNat w = pow2 sz - 1 -> w = wones sz.
Lemma wordToNat_natToWord_pred: forall {sz} (w: word sz), w <> wzero sz -> pred (wordToNat w) = wordToNat (w ^- (natToWord sz 1)).
Lemma wlt_lt: forall sz (a b : word sz), a < b -> (wordToNat a < wordToNat b)%nat.
Lemma wle_le: forall sz (a b : word sz), (a <= b)%word -> (wordToNat a <= wordToNat b)%nat.
Lemma wlt_lt': forall sz a b, (a < pow2 sz)%nat -> natToWord sz a < b -> (wordToNat (natToWord sz a) < wordToNat b)%nat.
Lemma lt_word_lt_nat : forall (sz:nat) (n:word sz) (m:nat), (n < (natToWord sz m))%word -> (wordToNat n < m)%nat.
Lemma le_word_le_nat : forall (sz:nat) (n:word sz) (m:nat), (n <= (natToWord sz m))%word -> (wordToNat n <= m)%nat.
Lemma lt_word_le_nat : forall (sz:nat) (n:word sz) (m:nat), (n < (natToWord sz m))%word -> (wordToNat n <= m)%nat.
Lemma wordToNat_natToWord_idempotent' : forall sz n, (n < pow2 sz)%nat -> wordToNat (natToWord sz n) = n.
Lemma le_word_le_nat': forall (sz:nat) n m, (n < pow2 sz)%nat -> (natToWord sz n <= m)%word -> (n <= wordToNat m)%nat.
Lemma wordToNat_natToWord_bound : forall sz n (bound : word sz), (n <= wordToNat bound)%nat -> wordToNat (natToWord sz n) = n.
Lemma wordToNat_natToWord_le : forall sz n, (wordToNat (natToWord sz n) <= n)%nat.
Lemma wordToNat_natToWord_lt : forall sz n b, (n < b -> wordToNat (natToWord sz n) < b)%nat.
Lemma wordToNat_eq_natToWord : forall sz (w : word sz) n, wordToNat w = n -> w = natToWord sz n.
Lemma wlt_lt_bound: forall sz (a : word sz) (b bound : nat), (a < natToWord sz b)%word -> (b <= wordToNat (natToWord sz bound))%nat -> (wordToNat a < b)%nat.
Lemma lt_wlt: forall sz (n : word sz) m, (wordToNat n < wordToNat m)%nat -> n < m.
Lemma le_wle: forall sz (n : word sz) m, (wordToNat n <= wordToNat m)%nat -> n <= m.
Lemma wlt_wle_incl : forall sz (a b : word sz), (a < b)%word -> (a <= b)%word.
Lemma wminus_Alt2: forall sz x y, y <= x -> @wminusN sz x y = wordBinN minus x y.
Theorem wlt_wf: forall sz, well_founded (@wlt sz).