Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] More than one ring structure (e.g. modulo ring) for one type

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] More than one ring structure (e.g. modulo ring) for one type


Chronological Thread 
  • From: Gaetan Gilbert <gaetan.gilbert AT ens-lyon.fr>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] More than one ring structure (e.g. modulo ring) for one type
  • Date: Mon, 17 Jul 2017 13:36:32 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=gaetan.gilbert AT ens-lyon.fr; spf=Neutral smtp.mailfrom=gaetan.gilbert AT ens-lyon.fr; spf=None smtp.helo=postmaster AT labbe.ens-lyon.fr
  • Ironport-phdr: 9a23:Xz70SBJkOe7M6LW/hdmcpTZWNBhigK39O0sv0rFitYgRL/nxwZ3uMQTl6Ol3ixeRBMOAuq0C07KempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9ZDeZwdFiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QLYpUjqg8qhrUgflhjoZOT438G/ZicJ+g6xUrx2juxNxzJXZYJ2WOfdkYq/RYd0XSGhHU81MVyJBGIS8b44XAuQAJ+lXsZX9qEEIrRCjBAesBefvxSRWiX/swa0xzuMsEQ7c0wM+A9IBqnLUoM/6NKcTVeC617fHzS/fb/5Nxzj97pPIfgklofCMWrJwd9DdyUc1Fw7ciFibtI/rPyuN2+gQvGWX8/BsWOCthmI9tg18ozqiyt0yhoXXmI4Z0lHJ+TtjzIooOdG0VlR3bcOrHZZTrS2WKop7T8wkTmp1oig10KcGtoS+fCUSyJQo2Rrfa/uffoiM+B3sT/2eLiliiH17frK/nA++8Uygy+37UMm4ylhKrjBdntnNsHACyQDT59CaRvZy4kutwzSC2gLJ5u1ZIE05l7DXJ4A/zrIujpYTtF7MHi7ymEX4lq+WcUAk9/Cn6+v9fLrmuoWTN4luhgHxM6QuntewDvoiMggSRGWU5+K81Kb68U39QLRKifs2nrPXsJDAPcgbvLK2AxdJ0oY/7BayFyup0NMBnXUeMF1FfA+HgJPyNlHVIPH4CO+/jE62nDdqwfDGJLzhDY/XInjNireyNYp6vkVb0U84yc1Vz5NSELAIZvzpCWHrs9mNIRY0LwWyi8nmDN9wzJ9WDW2GD7OQNuXdsFuC6/gzC+SKf8oRqTH7bfY/sa29xUQlkEMQKPH6laAcb2q1S6xr

You can also use a type alias.

#+BEGIN_SRC coq
From Coq Require Import Reals.

Variables (T : Type).
Variables (z1 o1 : T).
Variables (a1 m1 : T -> T -> T).

Definition T' := T.
Variables (z2 o2 : T).
Variables (a2 m2 : T -> T -> T).

Definition rm1 : semi_ring_theory z1 o1 a1 m1 eq.
Admitted.

Definition rm2 : semi_ring_theory z2 o2 a2 m2 (@eq T').
Admitted.

Add Ring rm1 : rm1.

Lemma t1 : a1 z1 o1 = o1.
Proof. ring. Qed.

Add Ring rm2 : rm2.

Lemma t2 : a2 z2 o2 = o2 :> T'.
Proof. ring. Qed.
#+END_SRC

This works because ring uses the relation to figure out which
structure should be used.

If you declare the operations foo2 in T' you won't need the explicit
T' annotations in the rm2 definition and in t2's type.

Gaëtan Gilbert

On 17/07/2017 12:50, Emilio Jesús Gallego Arias wrote:
Dear Michael,

"Soegtrop, Michael"
<michael.soegtrop AT intel.com>
writes:

I wanted to use the ring tactic in proofs of pretty much what you
describe (various variants of standard library CycliyType), so to use
it in this way I would have to define an intermediate type just for
the proofs, which is not so convenient.

So I either have to redefine the ring tactic from time to time or
extend it to take an options ring structure name.
Of course making the tactic more flexible would be great.

Note that a more cumbersome solution if you really want to use the same
type is to scope the ring declaration inside a module. Example:

#+BEGIN_SRC coq
From Coq Require Import Reals.

Variables (T : Type).
Variables (z1 o1 z2 o2 : T).
Variables (a1 m1 a2 m2 : T -> T -> T).

Definition rm1 : semi_ring_theory z1 o1 a1 m1 eq.
Admitted.

Definition rm2 : semi_ring_theory z2 o2 a2 m2 eq.
Admitted.

Module M1.

Add Ring rm1 : rm1.

Lemma t1 : a1 z1 o1 = o1.
Proof. ring. Qed.

End M1.

Module M2.

Add Ring rm2 : rm2.

Lemma t2 : a2 z2 o2 = o2.
Proof. ring. Qed.

End M2.
#+END_SRC

But note that you will have to alias the lemmas declared inside the
modules as opening them should (*) bring the ring declaration back.

Best,
E.

(*) Actually it may be more complicated than that.




Archive powered by MHonArc 2.6.18.

Top of Page