有一个如下的sig类型定义:
Inductive A: Set := mkA : nat-> A.
Function getId (a: A) : nat := match a with mkA n => n end.
Function filter (a: A) : bool := if (beq_nat (getId a) 0) then true else false.
Coercion is_true : bool >-> Sortclass.
Definition subsetA : Set := { a : A | filter a }.
我试图证明它的投影是单射的:
Lemma projection_injective :
forall t1 t2: subsetA, proj1_sig t1 = proj1_sig t2 -> t1 = t2.
Proof.
destruct t1.
destruct t2.
simpl.
intros.
rewrite -> H. (* <- stuck here *)
Abort.
此时,Coq已经知道:
x : A
i : is_true (filter x)
x0 : A
i0 : is_true (filter x0)
H : x = x0
我尝试了一些重写但没有成功。例如,为什么我不能将i
和H
重写成给Coq一个i0
?请问我在这里错过了什么?谢谢。
subst
是一种有用的策略(参见此答案)。 - eponier