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" <jwiegley AT gmail.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-f170.google.com
  • Ironport-phdr: 9a23:A3WXVRRr2iWRgOlyODP/Gboim9psv+yvbD5Q0YIujvd0So/mwa69YxGN2/xhgRfzUJnB7Loc0qyN4vymATRIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSijewZbx/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbDVwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4rx1QxH0ligIKz858HnWisNuiqJbvAmhrAF7z4LNfY2ZKOZycqbbcNgHR2ROQ9xRWjRBDI2icoUBAekPMuhXoIbhqFUDtge+BRC2Ce/z1jNFnH370Ksn2OohCwHG2wkgEsoAvHrQq9X1NKESWv21w6nJ0zrDYPdW1in96YTGbxsspvOMXLxxccXPxkkvEx3Kj1WLpIzqOjOazOUNs2yB4+V8UuKvjncqpgdsqTas3schkpfFip4Rx1ze9ih0wJw5KcC8RUJle9KoDZlduz2CO4Z0Q84uWX9ktSg1x7EcuJO2eDIGxIkoyhPbbfGMbpKG7Qj5VOmLJDd1nHJld6y7hxa16UWgz/fzVsiw0FpTtipFnMXAumkD1xDO6MWLVuFx/kim2TaI2ADT7v9LLVoomqrcLp4t2r8wlpwNvkTfBiL6hln6gauMekgn+uWk8fnrb7H4qpOGKoN5iB3yPrwrmsOlAOQ4NgYOX3Kc+eS5zLDj/0P4QLRUgf05lqnWrpDbKN8Upq68GQBV04Ij5wyjADeh1dQUhWMHI05deBKbk4jpPEnDL+z/DfemmlijjDNrx+3dMbD6GZXMLn3DkK/7crpn6k5czhAzzdFF6J5OBLEBOqG7Zkikn9vBRjQ9Lgb8l+3gEZB20p4UcWOJGK6Qdq3I5wym/OUqdqOuY48T8An8Jvch6u+kxSs7hl4Qcq2kzLMYbXm5GrJtJEDPMimkucsIDWpf5ll2d+ftklDXFGcLP3s=

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.



Archive powered by MHonArc 2.6.18.

Top of Page