coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Tej Chajed <tchajed AT mit.edu>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Getting lra to work with canonical rationals
- Date: Thu, 8 Oct 2020 08:18:40 -0500
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=tchajed AT mit.edu; spf=Pass smtp.mailfrom=tchajed AT mit.edu; spf=None smtp.helo=postmaster AT outgoing.mit.edu
- Ironport-phdr: 9a23:m8WKWBeC9JglaAJtQ+8fE2pUlGMj4u6mDksu8pMizoh2WeGdxcu9Zh7h7PlgxGXEQZ/co6odzbaP7Oa8CCdbvd6oizMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVrO+/7BpDdj9it1+C15pbffxhEiCCybL9vLhi6twrcu80ZjYZsJas61wfErGZPd+lK321jOEidnwz75se+/Z5j9zpftvc8/MNeUqv0Yro1Q6VAADspL2466svrtQLeTQSU/XsTTn8WkhtTDAfb6hzxQ4r8vTH7tup53ymaINH2QLUpUjms86tnVBnlgzoBOjUk8m/Yl9ZwgbpUrxKvpRNxw4DaboKIOvRgYqzQZskVSXZbU8tLSyBNHoGxYo0SBOQBJ+ZYqIz9qkMQoxSgBwmnGf3iyj9SiX/0w6I1zvkqHAba3AM8H9IBqnbUo8voO6oJVOC1zbXIwS/dYPxLxDfw8Y7FeQ0urv+QR7x/a9bRyVUxGAPfiFWdsYLrMjyJ2+oCsmWV4PZsWOGghWMlpAx8vDmiy8Mxh4TUm44YylPJ+DhnzYorJtC1VE92bN+4HZZOtSyXOI97T8wkTmp1uyg60qULtYO4cSQQzJkr3QDTZv+df4SV/x7vTPidLSt8iX5/e7+yhwy+/Va9xuD4TMW531JHoyxYmdfWrH8NzQbc6s2fR/t94Eih3TGP2hjU6uFZPUA0mq3bK58nwr4/jJYTtEXDHjPslErokaCWa10o+umu6+v5frXrvoKQOoxuhgz6KKgihM+yDf4lPgQTR2Sb/P6z1Lzn/U33WrVKifg2n7HFsJ/GJcQUvKy5DBFI3Ys47ha/Dium3M4GknYaMVJJYAiHgJTxO1HSPPD4Cu+yjEirkDdy3vzJIrnhAojWIXXYi7fgfbN961ZGxwYpzNBf4YhUCrAbL/7pVE/xro+QMhhsOAuthu3jFd81gogZQCeEBrKTGKLUq16BoOw1dbqifogQ7QrwKbAO5/fsgHNxzUMWfaCr0Jc/bXGkWPlqPhPKMjLXnt4dHDJS7UIFR+vwhQjaCGIBVzOJR6s5owoDJse+F46SFIWsnPqM0DrpRsQHNFADMUiFFDLTT6vBXv4NbCyIJcowwDkFSf6sR5JzjEjz5j+/8KJuK6/vwgNdtZ/n04ElterOiR419Dp7ScGczyeAQ3wmxm4=
I ran into exactly this problem recently. It turns out that the Qc operators are reasonably close to Q, so you might be able to do the preprocessing yourself:
Ltac qc_lra :=
unfold Qclt, Qcle in *; cbv [Qcanon.this Qcplus Q2Qc] in *;
try rewrite -> !Qred_correct in *;
lra.
I can't really tell if Frederic's solution is more robust than doing it manually since I don't know how much of an abuse of zify it is.
On Thu, Oct 8, 2020 at 7:52 AM Frédéric Besson <frederic.besson AT inria.fr> wrote:
Hi Elias,
`lra` does not support Qc.
This could probably be done but this requires writing some Ocaml code.
Attached is a solution which exploits `zify` to pre-process operators
in Qc. I say `exploit` because, as the name implies, `zify` has been
designed to pre-process towards Z. So, it kind of works by chance...
Best,
--
Frédéric
On Thu, 2020-10-08 at 11:39 +0000, Elias Castegren wrote:
> Hi all
>
> I have a Coq development which uses the rational numbers from QArith.
> Most arithmetic issues can be nicely solved by the lra tactic:
>
> Require Import QArith.
> Require Import Psatz.
>
> Example q_le_trans :
> forall q1 q2 : Q,
> 0 <= q1 ->
> 0 <= q2 ->
> 0 <= q1 + q2.
> Proof.
> intros q1 q2 Hle1 Hle2.
> lra.
> Qed.
>
> Because rational numbers use their own equivalence rather than
> syntactic equality, I would like to move to the Qc type from
> QArith.Qcanon, which are rational numbers which are know to be
> irreducible. However, when doing that, lra stops working:
>
> Require Import QArith.Qcanon.
>
> Example qc_le_trans :
> forall q1 q2 : Qc,
> 0 <= q1 ->
> 0 <= q2 ->
> 0 <= q1 + q2.
> Proof.
> intros q1 q2 Hle1 Hle2.
> Fail lra.
> Abort.
>
> I understand that this is because addition is now defined as Q2Qc (q1
> + q2), where Q2Qc is a function that takes rational numbers to their
> irreducible counterpart, and I guess that lra does not ”understand"
> this function. However, it feels like any arithmetic result over Q
> should hold for Qc as well. Is there any way of extending lra, or
> some simple preprocessing I can do to the proofs to turn the proof
> context to one that lra can work with?
>
> Thanks
>
> /Elias
- [Coq-Club] Getting lra to work with canonical rationals, Elias Castegren, 10/08/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Frédéric Besson, 10/08/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Tej Chajed, 10/08/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Raphaël Cauderlier, 10/09/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Théo Zimmermann, 10/09/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Raphaël Cauderlier, 10/09/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Théo Zimmermann, 10/09/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Raphaël Cauderlier, 10/09/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Tej Chajed, 10/08/2020
- Re: [Coq-Club] Getting lra to work with canonical rationals, Frédéric Besson, 10/08/2020
Archive powered by MHonArc 2.6.19+.