coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jason -Zhong Sheng- Hu <fdhzs2010 AT hotmail.com>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: RE: [Coq-Club] getting a definition as an equality theorem
- Date: Tue, 13 Nov 2018 18:17:44 +0000
- Accept-language: en-CA, en-US
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=fdhzs2010 AT hotmail.com; spf=Pass smtp.mailfrom=fdhzs2010 AT hotmail.com; spf=Pass smtp.helo=postmaster AT NAM01-BN3-obe.outbound.protection.outlook.com
- Ironport-phdr: 9a23:iakB3xHuhV1Pfs5j3YUurJ1GYnF86YWxBRYc798ds5kLTJ7zpMqwAkXT6L1XgUPTWs2DsrQY07WQ6/iocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmDiwbaluIBmqsA7cqtQYjYx+J6gr1xDHuGFIe+NYxWNpIVKcgRPx7dqu8ZBg7ipdpesv+9ZPXqvmcas4S6dYDCk9PGAu+MLrrxjDQhCR6XYaT24bjwBHAwnB7BH9Q5fxri73vfdz1SWGIcH7S60/VDK/5KlpVRDokj8KOT4n/m/Klsx+gqFVoByjqBNjzIHZe5uaOOZicq7HYd8WWXdNU8BMXCJBGIO8aI4PAvIFM+lCtIn9oF0OpganCQavBOPvzTlIhnDr1qMn0+QuDwfG3AM5E9kTsnrUscj+OaAcUe+ozKnJzC7DY+1K1Tvg9ITFaRAhofaQXbJ1a8XRyE0vGxnZgVWXrIzoJjWY3fkOvWiD9+dtWv6jh3Qjpg1vuDSj2t0gh4fNi44NxFDL6yZ0zJowKNC9SUN2Zd+pHZpVuiyZNIZ5WN8tTmRotSs4yLALtpu2cDUWx5Qp2xLSbeGMfZKS7RL5TumRJC91hHJ7d7K7gBa/6VCux/H7WMWozVpGtzdInMHCu3wU0Bzc8daIRuF6/ke8xTaAzAfT6vxCIU8pj6bbM4QhwrkslpUNrUvDAi72mELwjKOMcUUk5/So6+DgYrXhpZ+QLZN7igb7Mqg2m8y/B/o3MhQWUmWU5eiwzrnu8VPjTLlWlPE7nK3UvIjfJcsBp665BwFV0pwk6xa6Fzqm3skXnXkGLVJeZh6Lk5XlN03VLfD4Cve/n1Gsny1qx/DCJLHuHpLNLn3bnLf7Ybl981JcyBY0zd1H+51UDagBLOvvVU/1qdzXFQQ0Mxe0wubiENVyzJkSWWOJAq+DMaPdq0WE5uw1I7rEWIhA8j36Mr0u4+PkpX4/g14UO6ezl9NDY3ehW/9iPk+xYHz2g95HH31c7SQkS+m/qlSZVjgbIkSyWKQzrgo7BYSpSM/jW8j5jrCBzjzhRsQOTmBBFlWFEHOufIKBDaRfIBmOK9Nsx2RXHYOqTJUsgEn35V3KjoF/J++RwRU28Jfq1dx7/erWzEpg9TtoCs2c1yeGSGQmxzpUFQ9z57h2pAlG8nnGybJx2qcKFdtP4vpIVkExMpuOl7UnWeC3YRrIe5KycHjjQtiiBm1uHPQY5odXJmxbQJClhB2F2De2CbgIkbDNHIYz7q/Xw3n2IYB61mrC064iyVIhR5kWOA==
As a slight improvement, making a function opaque is probably too much. You can tell Coq to not handle fact only in certain reduction cases:
Arguments fact n : simpl never.
Thanks,
Jason Hu
-------- Original message --------
From: Dominique Larchey-Wendling <dominique.larchey-wendling AT loria.fr>
Date: 11/13/18 09:07 (GMT-05:00)
To: coq-club AT inria.fr
Subject: Re: [Coq-Club] getting a definition as an equality theorem
Hi Jeremy,
This is a very common situation where the "simpl" tactic
unfolds to much or is difficult to control. The easy
(but verbose) way is to generate equations and use rewrite.
Fixpoint fact n :=
match n with
| 0 => 1
| S n => (S n) * fact n
end.
Fact fact_0 : fact 0 = 1.
Proof. reflexivity. Qed.
Fact fact_S n : fact (S n) = (S n) * fact n.
Proof. reflexivity. Qed.
You can even make fact opaque after that
Opaque fact.
if you need to control the unfolding of the
fixpoint very precisely
That way if you want
fact (S (S (S n))))
to rewrite as
(S (S (S n))) * ( (S (S n)) * fact (S n) )
the tactic "do 2 rewrite fact_S" will do it.
Best regards,
Dominique
----------------------
Le 13/11/2018 à 04:22, Jeremy Dawson a écrit :
> Hi coq-club,
>
> Having made a definition f x y z = a b c
> how do I get this as an equality theorem that can be used to rewrite
> a b c to f x y z?
>
> (I realise I can set it out as a lemma and prove it using unfold, but
> I'm assuming it's already there as a theorem that I just need to find
> out how to get hold of it)
>
> thanks
>
> Jeremy
>
This is a very common situation where the "simpl" tactic
unfolds to much or is difficult to control. The easy
(but verbose) way is to generate equations and use rewrite.
Fixpoint fact n :=
match n with
| 0 => 1
| S n => (S n) * fact n
end.
Fact fact_0 : fact 0 = 1.
Proof. reflexivity. Qed.
Fact fact_S n : fact (S n) = (S n) * fact n.
Proof. reflexivity. Qed.
You can even make fact opaque after that
Opaque fact.
if you need to control the unfolding of the
fixpoint very precisely
That way if you want
fact (S (S (S n))))
to rewrite as
(S (S (S n))) * ( (S (S n)) * fact (S n) )
the tactic "do 2 rewrite fact_S" will do it.
Best regards,
Dominique
----------------------
Le 13/11/2018 à 04:22, Jeremy Dawson a écrit :
> Hi coq-club,
>
> Having made a definition f x y z = a b c
> how do I get this as an equality theorem that can be used to rewrite
> a b c to f x y z?
>
> (I realise I can set it out as a lemma and prove it using unfold, but
> I'm assuming it's already there as a theorem that I just need to find
> out how to get hold of it)
>
> thanks
>
> Jeremy
>
- [Coq-Club] getting a definition as an equality theorem, Jeremy Dawson, 11/13/2018
- Re: [Coq-Club] getting a definition as an equality theorem, Laurent Thery, 11/13/2018
- Re: [Coq-Club] getting a definition as an equality theorem, Tej Chajed, 11/13/2018
- Re: [Coq-Club] getting a definition as an equality theorem, Dominique Larchey-Wendling, 11/13/2018
- RE: [Coq-Club] getting a definition as an equality theorem, Jason -Zhong Sheng- Hu, 11/13/2018
Archive powered by MHonArc 2.6.18.