Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Problem with constructive rewriting

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Problem with constructive rewriting


Chronological Thread 
  • From: "John Wiegley" <johnw AT newartisans.com>
  • To: Coq Club <coq-club AT inria.fr>
  • Subject: [Coq-Club] Problem with constructive rewriting
  • Date: Fri, 12 May 2017 10:29:43 -0700
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jwiegley AT gmail.com; spf=Pass smtp.mailfrom=jwiegley AT gmail.com; spf=None smtp.helo=postmaster AT mail-pf0-f169.google.com
  • Ironport-phdr: 9a23:Qo4l0RTQs/vJFERYoCKYgXGvY9psv+yvbD5Q0YIujvd0So/mwa6yZxCN2/xhgRfzUJnB7Loc0qyN4vymATRIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSijewZbx/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbDVwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4rx1QxH0ligIKz858HnWisNuiqJbvAmhrAF7z4LNfY2ZKOZycqbbcNgHR2ROQ9xRWjRBDI2icoUBAe0BM+VWoIbyu1QAogCzBRW1BO711jNEmmX70K883u88EQ/GxgsgH9cWvXjaqNv1M6cSUeaox6bIzDXMcfxW2TPj54nIfBwqvPaBXbB3ccrRz0kuGRjIjlOOpo3rJTyVzPgNs2mA7+V6U+KvkHQrpB12ojiq38ohjJTCiIwSylDB7yp5wYA1KMW+SEFlb9+rCoFQtz2bN4ttWMwiRXpotDwmxb0BvJ62ejUBxpc/xxPHdfCLb4yF7gjgWeuROzt0mXZodKylixqv8EWtzvXwW8u13VpQsCZInNbBumoM2hHX8MSLV/Rw80On1D2SzQ7c8PtELloxlafDK54u3Lowlp0LvETGBCD2mUH2gLaOdkUq5uSk8urnbqjnq5KYLYN0hQb+MqMhmsy7H+s0KBQBX2+e+eik1b3j+1P2QKlSg/EojqXUtIrWKMcbq6KjHgNY1pgv5wyiAzqn1NkUhXwHI0hEeBKDgYjpIVbOIPXgAPe9jVWskSlkx//CPrL/ApTANXfDkLL7crZ8705Q0hY8zdda555MELEOPOrzWlPttNzfFhI2Lwu0w//+BNph0oMeRHmAD7SCMKLStF+I/vggL/ONZI8Tojb9KuIq6+TgjX8jyhchevyC2oJfQ3SlFLwyKEKAJHHon90pEGEQvwN4Qva823OYVjsGLVS1X6R02TA2B4arHM2LEoKqgLqe9CG2AZRMemFdA1aXV3zvctPXCL83dCuOL5o5wXQ/Xr+7RtpkjEn2uQ==
  • Organization: New Artisans LLC

In the code below I'm trying to develop a notion of "isomorphism" that allows
for rewriting. However, I'm getting a strange error that I can't yet make any
sense of:

Error: Illegal application:
The term "@flip" of type "∀ A B C : Type, (A → B → C) → B → A → C"
cannot be applied to the terms
"Type" : "Type"
"Type" : "Type"
"Type" : "Type"
"arrow" : "Type → Type → Type"
The 4th term has type
"Type@{Top.8164} → Type@{Top.8165} → Type@{max(Top.8164, Top.8165)}"
which should be coercible to
"Type@{max(Coq.Classes.CEquivalence.6, Top.4)}
→ Type@{max(Coq.Classes.CEquivalence.6, Top.4)} → Type@{Top.8166}".

If instead I use transitivity, the same proof passes easily.

Below is the test case, if anyone has any thoughts.

Thank you,
John

Require Export
Coq.Unicode.Utf8
Coq.Program.Program
Coq.Classes.CEquivalence.

Close Scope nat_scope.

Notation "f ≈ g" := (equiv f g) (at level 79, only parsing).

Reserved Infix "~>" (at level 90, right associativity).
Reserved Infix "∘" (at level 40, left associativity).

Class Category := {
ob : Type;

uhom := Type : Type;
hom : ob -> ob -> uhom where "a ~> b" := (hom a b);

id {A} : A ~> A;
compose {A B C} (f: B ~> C) (g : A ~> B) : A ~> C
where "f ∘ g" := (compose f g);

id_left {X Y} (f : X ~> Y) : id ∘ f ≈ f;

comp_assoc {X Y Z W} (f : Z ~> W) (g : Y ~> Z) (h : X ~> Y) :
f ∘ (g ∘ h) ≈ (f ∘ g) ∘ h
}.

Notation "X ~> Y" := (@hom _ X Y) (at level 90, right associativity).
Notation "f ∘ g" := (@compose _ _ _ _ f g).

Coercion ob : Category >-> Sortclass.

Class Isomorphism `{C : Category} (X Y : C) : Type := {
to :> X ~> Y;
from : Y ~> X;

iso_to_from : to ∘ from ≈ id;
iso_from_to : from ∘ to ≈ id
}.

Ltac reassoc f :=
repeat match goal with
| [ |- context[(?F ∘ f) ∘ ?G] ] => rewrite <- (comp_assoc F f G)
| [ |- context[f ∘ (?G ∘ ?H)] ] => rewrite (comp_assoc f G H)
end.

Program Instance isomorphism_equivalence `{C : Category} :
Equivalence Isomorphism.
Next Obligation.
repeat intro.
apply Build_Isomorphism with (to:=id) (from:=id);
rewrite id_left; reflexivity.
Defined.
Next Obligation.
repeat intro; destruct X.
apply Build_Isomorphism with (to:=from0) (from:=to0); assumption.
Defined.
Next Obligation.
repeat intro; destruct X, X0.
apply Build_Isomorphism with (to:=to1 ∘ to0) (from:=from0 ∘ from1).
repeat match goal with
| [ H : equiv (?F ∘ ?G) _
|- context[(_ ∘ ?F) ∘ (?G ∘ _)] ] => reassoc F; rewrite H
| [ H : equiv (?F ∘ ?G) _
|- context[?F ∘ (?G ∘ _)] ] => reassoc F; rewrite H
| [ H : equiv (?F ∘ ?G) _
|- context[(_ ∘ ?F) ∘ ?G] ] => reassoc F; rewrite H
| [ H : equiv (?F ∘ ?G) _
|- context[?F ∘ ?G] ] => rewrite H
| [ |- equiv ?F ?F ] => reflexivity
| [ |- context[id ∘ ?F] ] => rewrite (id_left F)
end.
reassoc from1; rewrite iso_from_to1.
rewrite id_left; assumption.
Defined.

Notation "X ≅ Y" := (@Isomorphism _ X Y) (at level 91).

Goal forall `{C : Category} {X Y Z : C} (f : Y ≅ Z) (g : X ≅ Y), X ≅ Z.
intros.
(* transitivity Y; auto. *)
rewrite g.
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2



Archive powered by MHonArc 2.6.18.

Top of Page