(* Don't allow simpl to expand out these functions *)
Arguments natToWord : simpl never.
Arguments weq : simpl never.
(* Making wlt_dec opaque is necessary to prevent the [exact H] in the * example below from blowing up.. *)
Global Opaque wlt_dec.
Definition test_wlt_f (a : nat) (b : nat) : nat :=
if wlt_dec (natToWord 64 a) $0 then 0 else 0.

(* Specifications: *)
Theorem test_wlt_f_example: forall x y z, test_wlt_f x y = 0 -> test_wlt_f x z = 0.
Lemma wordToNat_eq1: forall sz (a b: word sz), a = b -> wordToNat a = wordToNat b.
Lemma wordToNat_eq2: forall sz (a b: word sz), wordToNat a = wordToNat b -> a = b.
Lemma wordToNat_lt1: forall sz (a b: word sz), a < b -> (wordToNat a < wordToNat b)%nat.
Lemma wordToNat_lt2: forall sz (a b: word sz), (wordToNat a < wordToNat b)%nat -> a < b.
Lemma wordToNat_gt1: forall sz (a b: word sz), a > b -> (wordToNat a > wordToNat b)%nat.
Lemma wordToNat_gt2: forall sz (a b: word sz), (wordToNat a > wordToNat b)%nat -> a > b.
Lemma wordToNat_le1: forall sz (a b: word sz), a <= b -> (wordToNat a <= wordToNat b)%nat.
Lemma wordToNat_le2: forall sz (a b: word sz), (wordToNat a <= wordToNat b)%nat -> a <= b.
Lemma wordToNat_ge1: forall sz (a b: word sz), a >= b -> (wordToNat a >= wordToNat b)%nat.
Lemma wordToNat_ge2: forall sz (a b: word sz), (wordToNat a >= wordToNat b)%nat -> a >= b.
Lemma wordToNat_neq1: forall sz (a b: word sz), a <> b -> wordToNat a <> wordToNat b.
Lemma wordToNat_neq2: forall sz (a b: word sz), wordToNat a <> wordToNat b -> a <> b.
Lemma wordToNat_wplus': forall sz (a b: word sz),
(#a + #b < pow2 sz)%nat ->
#(a ^+ b) = #a + #b.
Lemma wordToNat_wplus'': forall sz (a: word sz) (b: nat),
(#a + b < pow2 sz)%nat -> #(a ^+ $b) = #a + b.
Lemma wordToNat_wmult': forall sz (a b: word sz),
(#a * #b < pow2 sz)%nat ->
#(a ^* b) = #a * #b.
Lemma wordNotNot: forall sz (a b: word sz), (a <> b -> False) -> a = b.
Ltac pre_word_omega :=
unfold wzero, wone in *;
repeat match goal with
| H: @eq ?T ?a ?b |- _ =>
match T with
| word ?sz =>
apply (@wordToNat_eq1 sz a b) in H;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one in H;
simpl in H
end
| |- @eq ?T ?a ?b =>
match T with
| word ?sz =>
apply (@wordToNat_eq2 sz a b);
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one;
simpl
end
| H: ?a < ?b |- _ =>
apply wordToNat_lt1 in H;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one in H;
simpl in H
| |- ?a < ?b =>
apply wordToNat_lt2;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one;
simpl
| H: ?a > ?b |- _ =>
apply wordToNat_gt1 in H;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one in H;
simpl in H
| |- ?a > ?b =>
apply wordToNat_gt2;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one;
simpl
| H: ?a <= ?b |- _ =>
apply wordToNat_le1 in H;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one in H;
simpl in H
| |- ?a <= ?b =>
apply wordToNat_le2;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one;
simpl
| H: ?a > ?b -> False |- _ =>
apply wordToNat_le1 in H;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one in H;
simpl in H
| |- ?a > ?b -> False =>
apply wordToNat_le2;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one;
simpl
| H: ?a < ?b -> False |- _ =>
apply wordToNat_ge1 in H;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one in H;
simpl in H
| |- ?a < ?b -> False =>
apply wordToNat_ge2;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one;
simpl
| H: not (@eq ?T ?a ?b) |- _ =>
match T with
| word ?sz =>
apply (@wordToNat_neq1 sz a b) in H;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one in H;
simpl in H
end
| |- not (@eq ?T ?a ?b) =>
match T with
| word ?sz =>
apply (@wordToNat_neq2 sz a b);
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one;
simpl
end
| H: @eq ?T ?a ?b -> False |- _ =>
match T with
| word ?sz =>
apply (@wordToNat_neq1 sz a b) in H;
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one in H;
simpl in H
end
| |- @eq ?T ?a ?b -> False =>
match T with
| word ?sz =>
apply (@wordToNat_neq2 sz a b);
rewrite ?roundTrip_0, ?roundTrip_1, ?wones_pow2_minus_one;
simpl
end
| H: (@eq ?T ?a ?b -> False) -> False |- _ =>
match T with
| word ?sz =>
apply (@wordNotNot sz a b) in H
end
| H: (not (@eq ?T ?a ?b)) -> False |- _ =>
match T with
| word ?sz =>
apply (@wordNotNot sz a b) in H
end
| H: not (@eq ?T ?a ?b -> False) |- _ =>
match T with
| word ?sz =>
apply (@wordNotNot sz a b) in H
end
| H: not (not (@eq ?T ?a ?b)) |- _ =>
match T with
| word ?sz =>
apply (@wordNotNot sz a b) in H
end
end.