Skip to Content.
Sympa Menu

ssreflect - Re: [ssreflect] Adding ring tactic to integers

Subject: Ssreflect Users Discussion List

List archive

Re: [ssreflect] Adding ring tactic to integers


Chronological Thread 
  • From: Bas Spitters <>
  • To: Erik Martin-Dorel <>
  • Cc: Benjamin Salling Hvass <>, "" <>
  • Subject: Re: [ssreflect] Adding ring tactic to integers
  • Date: Tue, 24 Sep 2019 09:56:03 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:ByzhwBGQjl1Pqkz8az9CHJ1GYnF86YWxBRYc798ds5kLTJ7zosiwAkXT6L1XgUPTWs2DsrQY0rGQ6fGrADZfqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba58IRmsswncssYajZZ8Jqsz1xDEvmZGd+NKyG1yOFmdhQz85sC+/J5i9yRfpfcs/NNeXKv5Yqo1U6VWACwpPG4p6sLrswLDTRaU6XsHTmoWiBtIDBPb4xz8Q5z8rzH1tut52CmdIM32UbU5Uims4qt3VBPljjoMOiUn+2/LlMN/kKNboAqgpxNhxY7UfJqVP+d6cq/EYN8WWXZNUsNXWidcAI2zcpEPAvIOMuZWrYbzp1UAoxijCweyGOzhxSRFhmPv3aAgz+gtDR3K0Q4mEtkTsHrUttL1NKIKXO2o1qbI1ijIYe5O2Tf89IjIbg4uoeuXXbltdsfe0lMjGBnfglSes4DlJCuV1uURs2iH8eVgT/mvhnUoqwF0uDevx8MshpPViYISz1DJ7CN0y5s7K92/TU50e9+kEJ1IuiGbMYt2WMIiTHtytCY00L0KoZ+7fDILyJQ73RLfZeaHfo6V6RzgTOacOSl0iG5hdb6lhBu/8VKsxvPhWsSwylpGsylInsXKu3sQzRLc8NKHReF4/kq52TaAyQTT6uZcLEAxj6XbKpohzqcwl5UIrEjPByH2lFj1gaOKbEkk9e+o6+PoYrXiuJCQLZN7igb7Mqg2m8y/B/o3MhQWUmSF5eix0Kfv8E75TblQkPE6j63UvIrHKckYuqK1GwpV3Zwi6xa7ATemytMYnXwfIV1eYh6IlZLlOl/ULPDjFfe/gkiskCt1yPDcJb3sGZrNLn3Zn7fgebZx8VJTyA02zdxH/ZJbFqkBIO7vWk/2rNHYFQQ5MxaqzObpDNVyyJ8RWX6UD6+CMKLStEeI6fg1L+mNYo8Vojf9JOI/6/7gl39q0WMaKISz3JhfTXmiAvVgZmmee3foyoMMC2YJ+A83VvDrjhiOViReY16zRaMgoD8hXtGIF4DGE6qkm/S6xCanApBMfSgSABaFV2iubJ2FR+sBcjm6LcpokzhCXr+kHdxynSqyvRP3nuI0ZtHf/TcV4Ne6jIAsur/j0Coq/DkxNPyzlmGAS2YuwDENTj4ymbF1+Alzkwfbl6d/hPNcGJpY4PYbCl5mZ66Z9PRzDpXJYiyEZs2AEQ/0TdCvADV3RdU0kYdXMhRNXu66hxWG5BKERroclriFHpsxq/uO0H34JsI7wHHDhvAs

I think we'd like to use the ring tactic whenever we have a canonical
Ring structure.
However, Add Ring does not seem to allow for ring structures to be
parametrized.
Am I missing something?

On Mon, Sep 23, 2019 at 10:57 PM Erik Martin-Dorel
<>
wrote:
>
> Dear Benjamin,
>
> I had noticed a similar behavior when doing some experiments with
> ssrint and "cring"
> (http://tamadi.gforge.inria.fr/CoqHensel/coqhensel-2.1.0-coqdoc/CoqHensel.ssr_tactics.html)
>
> The issue you observe is due to the fact that the ring_theory implicit
> argument is automatically inferred to
> "(GRing.Zmodule.sort (GRing.Ring.zmodType int_Ring))"
> (which is unfortunate in this case, as it should be "int")
>
> You can address this issue just by using the "@" prefix to make this
> type parameter choice explicit. See complete excerpt below.
>
> --8<---------------cut here---------------start------------->8---
> From mathcomp Require Export all_ssreflect.
> From mathcomp Require Export all_algebra.
>
> Open Scope ring_scope.
> Open Scope int_scope.
>
> Export intRing.
> Export intZmod.
>
> Lemma int_ring : ring_theory 0 1 addz mulz (fun n m => n - m) oppz (@eq _).
> Set Printing All.
> (* @ring_theory (GRing.Zmodule.sort (GRing.Ring.zmodType int_Ring))
> (GRing.zero (GRing.Ring.zmodType int_Ring)) (GRing.one int_Ring) addz
> mulz
> (fun n m : GRing.Zmodule.sort (GRing.Ring.zmodType int_Ring) =>
> @GRing.add (GRing.Ring.zmodType int_Ring) n (@GRing.opp
> (GRing.Ring.zmodType int_Ring) m)) oppz
> (@eq (GRing.Zmodule.sort (GRing.Ring.zmodType int_Ring)))
> *)
> Abort.
> Unset Printing All.
>
> Lemma int_ring : @ring_theory int 0 1 addz mulz (fun n m => n - m) oppz
> (@eq _).
> Proof. split.
> exact add0z.
> exact addzC.
> exact addzA.
> exact mul1z.
> exact mulzC.
> exact mulzA.
> exact mulz_addl.
> by [].
> move=> x. rewrite addzC. apply addNz. Qed.
>
> Add Ring int_ring_ssr : int_ring.
>
> Lemma test (n m : int) : addz n m = addz m n.
> Proof. ring. Qed.
> --8<---------------cut here---------------end--------------->8---
>
> But I let the mathcomp devs comment on whether a similar "Add Ring"
> invocation should be directly added to core coq-mathcomp-algebra?
>
> Best regards,
> Erik
>
> Le lundi 23 septembre 2019 à 16:01 +0000, Benjamin Salling Hvass a écrit :
> > I tried making the ring tactic work for the int type by running the
> > following code
> >
> > From mathcomp Require Export all_ssreflect.
> > From mathcomp Require Export all_algebra.
> >
> > Open Scope ring_scope.
> > Open Scope int_scope.
> >
> > Export intRing.
> > Export intZmod.
> >
> > Lemma int_ring : ring_theory 0 1 addz mulz (fun n m => n - m) oppz (@eq
> > _).
> > Proof. split.
> > exact add0z.
> > exact addzC.
> > exact addzA.
> > exact mul1z.
> > exact mulzC.
> > exact mulzA.
> > exact mulz_addl.
> > by [].
> > move=> x. rewrite addzC. apply addNz. Qed.
> >
> > Add Ring int_ring_ssr : int_ring.
> >
> > Lemma test (n m : int) : addz n m = addz m n.
> > Proof. ring.
> >
> > But it complains that it cannot find a declared ring structure for int?
> > According to the documentation for Add Ring this should work. What have I
> > missed?
> >
> > Best regards,
> > Benjamin
>
> --
> Érik Martin-Dorel, PhD
> Maître de Conférences, Lab. IRIT, Univ. Toulouse 3
>
>
> https://www.irit.fr/~Erik.Martin-Dorel



Archive powered by MHonArc 2.6.18.

Top of Page