coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Ben Sherman <sherman AT csail.mit.edu>
- To: coq-club AT inria.fr
- Subject: [Coq-Club] Avoiding unnecessary universe variables when rewriting in Type
- Date: Wed, 18 Jan 2017 21:52:42 -0500
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=sherman AT csail.mit.edu; spf=Pass smtp.mailfrom=sherman AT csail.mit.edu; spf=None smtp.helo=postmaster AT outgoing-stata.csail.mit.edu
- Ironport-phdr: 9a23:SANw3BarrxgC6vFvoY8oXwX/LSx+4OfEezUN459isYplN5qZoM+ybnLW6fgltlLVR4KTs6sC0LuK9fy4EjFaqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjSwbLd9IRmsogjdqsYajIt8Jq0s1hbHv3xEdvhMy2h1P1yThRH85smx/J5n7Stdvu8q+tBDX6vnYak2VKRUAzs6PW874s3rrgTDQhCU5nQASGUWkwFHDBbD4RrnQ5r+qCr6tu562CmHIc37SK0/VDq+46t3ThLjlSEKPCM7/m7KkMx9lKJVrw6uqRJiwIDabp+bO/V5cK7GYdMaXG9BUtpRVyBdHI+xaZYEAeobPeZfqonwv0YDogW4BQKxGe3vyiFHhmXz3aIg1eQqDAbL3BcgH90QqnTUqc/6NKEJXO+p16nH1zTDb/dM1Tf46YjIbgotru+RUrJtaMfcz1QkGQDdjliItIDpITCY2v4DvmSH9eZsS/ijh3A6pw1tujSj28QhhpPUio8Wzl3I7yd0zJovKdGlTEN2btipG4ZKuS6ALYt5WMYiTnlouCkkzr0Gvoa2fC8XyJQ7yB7fbP2Hc46H4h76T+aRPS13hG5/d76lmxmy6lKvyuz4VsWu1VZKrzZFnsPSuX8Qyhzf8smHSv1j8Ue9wTuDyh7f5+JeLU06iabXMYAtzqQumpYOrUjPBir2l1/3jK+SeEUk4O+o6+H/b7X9pp+TKZV0igTkPaQogcGwHf84PRIPX2if4+i80bzj/VHjTLpUk/I2j7HVsIrGKsQDuq65HwhV354/5Ba4FjeqycgXnX0aLF1eYx+HlIjoO1TWIP/iF/u/glKskC1qx//cJLHhDI/NfTD/l+Lqeq844EpBwiIyy8pe7tRaEOIvOvX2D2X8spTjDhIjNgWyi7L8CNhn04oYcWmUC66ddqbTrRmF6v95cLrEX5McpDuoc6tt3PXpl3JswVI=
Hi all,
Coq 8.5 allows rewriting with Type-valued relations. This is useful, but I've
found that using rewriting in Type to define a term often adds many
unnecessary universe variables and constraints. If I'm not careful, these add
up and soon enough a definition in my library has thousands of universe
variables. Does anyone have ideas on how to avoid this, other than avoiding
using rewriting in Type altogether? What follows is a short code example
illustrating how unnecessary universe variables are added.
Thanks,
Ben
-----------------
Set Universe Polymorphism.
Require Coq.Setoids.Setoid.
Require Import CRelationClasses CMorphisms.
Section Test.
Universes I P IP.
Variable U : Type@{I}.
Variable eqU : U -> U -> Type@{P}.
Variable star : U -> U -> U.
Local Infix "==" := eqU (at level 70, no associativity).
Local Infix "*" := star (at level 40, left associativity).
Axiom eqU_Equivalence : Equivalence eqU.
Axiom star_proper : forall (x x' y y' : U), x == x' -> y == y'
-> x * y == x' * y'.
Instance star_Proper@{} : Proper@{I IP}
(respectful@{I P I IP I IP} eqU (eqU ==> eqU)) star.
Proof.
repeat intro. apply star_proper; assumption.
Qed.
Set Printing Universes.
Definition goal@{} := forall a b a' b',
a == a' -> b == b' -> a * b == a' * b'.
Theorem test1 : goal.
Proof.
unfold goal. intros.
rewrite X, X0. reflexivity.
Qed.
Print test1.
(* 9 extraneous universe variables, and 26 constraints. *)
Theorem test2@{} : goal.
Proof.
unfold goal. intros.
apply star_proper; assumption.
Qed.
Print test2.
(* No extraneous universe variables or constraints.*)
End Test.
- [Coq-Club] Avoiding unnecessary universe variables when rewriting in Type, Ben Sherman, 01/19/2017
- Re: [Coq-Club] Avoiding unnecessary universe variables when rewriting in Type, Jason Gross, 01/19/2017
Archive powered by MHonArc 2.6.18.