假设我具有以下记录类型:
Record R (A : Type) (P : A -> Prop) := {val : A; prop : P val}.
要证明两个这样的记录相等,就足以(通过证明不相关)证明它们的字段val
相等:
Goal forall A P (r1 r2 : R A P), val _ _ r1 = val _ _ r2 -> r1 = r2.
destruct r1, r2.
simpl.
intro H.
revert prop0.
rewrite H.
intros.
f_equal.
apply proof_irrelevance.
Qed.
就约翰·梅杰(John Major)的平等而言,是否可以证明类似的目标(可能依赖于安全的公理)?这是我失败的尝试:
Goal forall A1 A2 P1 P2 (r1 : R A1 P1) (r2 : R A2 P2),
JMeq (val _ _ r1) (val _ _ r2) -> JMeq r1 r2.
destruct r1, r2.
simpl.
intro H.
revert prop0.
Fail rewrite H.
答案 0 :(得分:3)
不,不是(当然要假设False
除外)。问题在于JMeq
意味着类型相等:
Require Import Coq.Logic.JMeq.
Record R (A : Type) (P : A -> Prop) := {val : A; prop : P val}.
Axiom contra : forall A1 A2 P1 P2 (r1 : R A1 P1) (r2 : R A2 P2),
JMeq (val _ _ r1) (val _ _ r2) -> JMeq r1 r2.
Goal False.
assert (H1 := contra nat nat (fun n => True) (eq 0) (Build_R _ _ 0 I) (Build_R _ _ 0 eq_refl)).
assert (H2 : R nat (fun n => True) = R nat (eq 0) :> Type).
{ now destruct H1. }
assert (H3 : forall r1 r2 : R nat (fun _ => True), r1 = r2).
{ rewrite H2. intros [n1 p1] [n2 p2].
now destruct p1; destruct p2. }
specialize (H3 (Build_R _ _ 0 I) (Build_R _ _ 1 I)).
discriminate.
Qed.