coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Adam Chlipala <adamc AT csail.mit.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] help with automating derived UIP_refl proofs
- Date: Sun, 28 Aug 2016 15:44:39 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=adamc AT csail.mit.edu; spf=Pass smtp.mailfrom=adamc AT csail.mit.edu; spf=None smtp.helo=postmaster AT outgoing-stata.csail.mit.edu
- Ironport-phdr: 9a23:u1fUMhbzkKymMSQwZuwqMhX/LSx+4OfEezUN459isYplN5qZpsu4bnLW6fgltlLVR4KTs6sC0LuP9fy7EjVbut7B6ClEK8McEUddyI0/pE8JPo2sMQXDNvnkbig3ToxpdWRO2DWFC3VTA9v0fFbIo3e/vnY4ExT7MhdpdKyuQtaBx5f/6+fn8JrKJg5MmTCVYLVoLRzwox+CmNMRhN5LJq80gjDJpnpQcuBfjTdhKVuWlD73/c6x+Nhm8jgWtv48oZ0TGZ7mdrg1GOQLRA8tNHo4sZXm
I think proving this kind of goal is simpler via first building a library of theorems for porting UIP between types, like so:
Set Implicit Arguments.
(** * Step 1: UIP ports across type isomorphism. *)
Section UIP_iso.
Variables A B : Type.
Variable AtoB : A -> B.
Variable BtoA : B -> A.
Hypothesis AtoB_BtoA : forall a, AtoB (BtoA a) = a.
Hypothesis A_UIP_refl : forall (a : A) (e : a = a), e = eq_refl.
Lemma f_equal_cancel : forall (x y : B) (e : x = y),
e = match AtoB_BtoA x in _ = X return X = _ with
| eq_refl =>
match AtoB_BtoA y in _ = Y return _ = Y with
| eq_refl => f_equal AtoB (f_equal BtoA e)
end
end.
Proof.
intros.
subst.
simpl.
generalize (AtoB_BtoA y).
destruct e.
reflexivity.
Qed.
Theorem UIP_iso : forall (b : B) (e : b = b), e = eq_refl.
Proof.
intros.
rewrite (f_equal_cancel e).
rewrite (A_UIP_refl (f_equal BtoA e)).
simpl.
generalize (AtoB_BtoA b).
generalize (AtoB (BtoA b)).
intros.
subst.
reflexivity.
Qed.
End UIP_iso.
Section example.
Variable A : Type.
Hypothesis A_UIP_refl : forall (a : A)(e : a=a), e=eq_refl.
Record Foo := foo { foo_a : A }.
Lemma Foo_UIP_refl : forall (f : Foo)(e: f=f), e=eq_refl.
Proof.
apply UIP_iso with (AtoB := foo) (BtoA := foo_a); auto.
destruct a; auto.
Qed.
End example.
(** * Step 2: UIP is preserved by pairing. *)
Section UIP_pair.
Variables A B : Type.
Hypothesis A_UIP_refl : forall (a : A) (e : a = a), e = eq_refl.
Hypothesis B_UIP_refl : forall (b : B) (e : b = b), e = eq_refl.
Lemma pair_eta : forall p : A * B,
(fst p, snd p) = p.
Proof.
destruct p; reflexivity.
Defined.
Lemma pair_cong : forall (a1 a2 : A) (b1 b2 : B),
a1 = a2
-> b1 = b2
-> (a1, b1) = (a2, b2).
Proof.
intros.
subst.
reflexivity.
Defined.
Lemma f_equal_cancel' : forall (x y : A * B) (e : x = y),
e = match pair_eta x in _ = X return X = _ with
| eq_refl =>
match pair_eta y in _ = Y return _ = Y with
| eq_refl => pair_cong (f_equal (@fst _ _) e) (f_equal (@snd _ _) e)
end
end.
Proof.
intros.
subst.
generalize (pair_eta y).
destruct e.
reflexivity.
Qed.
Theorem UIP_pair : forall (a_b : A * B) (e : a_b = a_b), e = eq_refl.
Proof.
intros.
destruct a_b.
rewrite (f_equal_cancel' e).
rewrite (A_UIP_refl (f_equal (@fst _ _) e)).
rewrite (B_UIP_refl (f_equal (@snd _ _) e)).
reflexivity.
Qed.
End UIP_pair.
Section example2.
Variables A B : Type.
Hypothesis A_UIP_refl : forall (a : A)(e : a=a), e=eq_refl.
Hypothesis B_UIP_refl : forall (b : B)(e : b=b), e=eq_refl.
Record Bar := bar { bar_a : A; bar_b : B }.
Lemma Bar_UIP_refl : forall (f : Bar)(e: f=f), e=eq_refl.
Proof.
apply UIP_iso with (AtoB := fun x => bar (fst x) (snd x))
(BtoA := fun x => (bar_a x, bar_b x)).
destruct a; auto.
apply UIP_pair; auto.
Qed.
End example2.
- [Coq-Club] help with automating derived UIP_refl proofs, Jonathan Leivent, 08/28/2016
- Re: [Coq-Club] help with automating derived UIP_refl proofs, Jonathan Leivent, 08/28/2016
- Re: [Coq-Club] help with automating derived UIP_refl proofs, Adam Chlipala, 08/28/2016
- Re: [Coq-Club] help with automating derived UIP_refl proofs, Jonathan Leivent, 08/29/2016
- Re: [Coq-Club] help with automating derived UIP_refl proofs, Dominique Larchey-Wendling, 08/31/2016
- Re: [Coq-Club] help with automating derived UIP_refl proofs, Jonathan Leivent, 08/31/2016
- Re: [Coq-Club] help with automating derived UIP_refl proofs, Adam Chlipala, 08/28/2016
- Re: [Coq-Club] help with automating derived UIP_refl proofs, Jonathan Leivent, 08/28/2016
Archive powered by MHonArc 2.6.18.