I'm working on a proof using bit vectors from the bbv library which look like word : nat -> Set
. I'm trying to prove that the most significant bit is the same if you chop off some lower-order bits:
Require Import bbv.Word.
Require Import Coq.Arith.PeanoNat.
Require Import Coq.Arith.Plus.
Lemma drop_msb : forall (n : nat) (x : word (S (S n))),
wmsb x false = wmsb (wtl x) false.
To prove this, the following lemma seems useful:
Check wmsb_split2.
(*
wmsb_split2 :
forall sz (w: word (sz + 1)) b,
wmsb w b = if weq (split2 _ 1 w) (natToWord _ 0) then false else true.
*)
Now, here's my attempt at the proof:
Proof.
intros n x.
assert (Snp : S (S n) = S n + 1). {
rewrite <- Nat.add_1_l.
apply plus_comm.
}
assert (xeq : word (S (S n)) = word ((S n) + 1)). {
rewrite Snp.
reflexivity.
}
rewrite wmsb_split2. (* Error: Found no subterm matching "wmsb ?M1864 ?M1865" in the current goal. *)
Here is the proof state.
n : nat
x : word (S (S n))
Snp : S (S n) = S n + 1
xeq : word (S (S n)) = word (S n + 1)
============================
wmsb x false = wmsb (wtl x) false
I'm confused why wmsb_split2
can't be applied; I see wmsb _ _
right there in the conclusion! Do I need some form of the uniqueness of identity proofs given in EqDepFacts?
I also have the extra assertions there in case I need to rewrite x
, but I can't do that either.