coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Pierre Courtieu <pierre.courtieu AT gmail.com>
- To: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Equations 1.2beta is out!
- Date: Wed, 6 Feb 2019 21:39:23 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=pierre.courtieu AT gmail.com; spf=Pass smtp.mailfrom=pierre.courtieu AT gmail.com; spf=None smtp.helo=postmaster AT mail-it1-f178.google.com
- Ironport-phdr: 9a23:tPi6jhVe7pAfPwJOyhYz9LweWJTV8LGtZVwlr6E/grcLSJyIuqrYYxyAt8tkgFKBZ4jH8fUM07OQ7/iwHzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba9xIRmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KpwVhTmlDkIOCI48GHPi8x/kqRboA66pxdix4LYeZyZOOZicq/Ye94RWGhPUdtLVyFZDYy8YYkAAeoPM+hbsofzuUcBoxSlCAmwHePi0CNEimPq0aA41ekqDAHI3BYnH9ILqHnattT1O7kIUeCv0qbD0CvOb/RL2Tfn9IjIcw4uoeyRVr93acrRyFcgFxnfjlqOs4DqIzSV1vkXs2iH7upvS/+vhnUoqwF0uDevx8MshpPViYISz1DJ7CN0y5s2K92gUEN3f8KoHZ9KuyyZN4Z6WN4uTmBptSog17ELu522cS4Xw5o93RHfceaIc42Q7xLjSumRJTB4iWpgeL2lhhay9VGsyuzgVsWpyVpKoDdJn9vPu3wX2BzT7c+HSvR5/ki/wzqAywfT6uRcLUA1k6rUNYIhz6YumpYPtUnPBCz7lUXsgKOLd0gp+/Kk5/nlb7jlvpOcMpV7igD6MqQggMy/BuE4PxAWX2ia5+u8zqfj8lPjTLpWif02j7PZsIzbJcsFu660GABV0oM55Ba+CzeqysgXnX4CLF5dYhKIk5DpO03SIPD/Ffqwn1OskC5yy//aOr3hH47CI2PYkLbheLZ981RTxBAyzdBZ/ZJUC6sOLOj9Wk/r55TkCUoSNBX86OL6Ap0p3YQHHGmLH6WxMaXIsFbO6Ph5cMeWY4pAgDfwMeIor9XpkGUlmFIANf2x3JYNcn3+FfN7OVmYbGfEjdIIEGNMtQ07Gr+5wGaeWCJeMi7hF5k34Ss2Xcf/Vd+aF9KdxYeZ1SL+JaV4I2VPC1SCC3DtLtzWVPIFaSbUKchkwGVdCeqRDrQ53BTrjzfUjqJ9J7ONqCIdvJPnktNy4r+LzExgxXlPF82Yllq1YSR0k2cPHWFk2al+pQl81g7G3/En07pXEttc4/4PWQA/Z8bR
Equations is much more powerfull than Function, especially with
dependent types, but Function allows to use functional induction,
which makes proofs easier for students (no need to look for the right
induction principle + destructs done automatically). Equations should
allow for that in a future version of Coq.
Best
Pierre
From Coq Require Import Arith Lia.
Require Import Recdef.
Goal forall x y n : nat, y = S n -> S n <= x
-> x - S n < x.
Proof.
intros x y n H H0.
lia.
Qed.
Function Div (x y : nat) {wf lt x} : nat :=
match y with
| 0 => 0
| _ => if le_lt_dec y x then 1 + Div (x - y) y else 0
end.
Proof.
- intros x y n teq anonymous teq0.
clear teq0. (* lia does not like dependent hyps over its variables *)
lia.
- apply lt_wf.
Qed.
Function Mod (x y : nat) {wf lt x} : nat :=
match y with
| 0 => 0
| _ => if le_lt_dec y x then Mod (x - y) y else x
end.
Proof.
- intros x y n teq anonymous teq0.
clear teq0;lia.
- apply lt_wf.
Qed.
Fact Div_Mod2 x y :
x = S y * Div x (S y) + Mod x (S y) .
Proof.
remember (S y) as y'.
functional induction Div x y'.
- discriminate.
- rewrite Mod_equation.
rewrite e0 in *|-*.
specialize IHn with (1:=eq_refl).
clear e0.
lia.
- rewrite Mod_equation.
rewrite e0 in *|-*.
clear e0;lia.
Qed.
Le mer. 6 févr. 2019 à 16:31, Laurent Thery
<Laurent.Thery AT inria.fr>
a écrit :
>
>
> Or using the Proof with.
>
> Fact Div_Mod x y :
> x = S y * Div x (S y) + Mod x (S y).
> Proof with simp Div Mod in *; try lia.
> induction x as [x IH] using lt_wf_ind...
> destruct (le_lt_dec _ _) as [H|H]...
> assert (x - S y < x) as IH1%IH...
> Qed.
- Re: [Coq-Club] Equations 1.2beta is out!, Gert Smolka, 02/06/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Laurent Thery, 02/06/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Laurent Thery, 02/06/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Pierre Courtieu, 02/06/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Jason -Zhong Sheng- Hu, 02/06/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Matthieu Sozeau, 02/07/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Pierre Courtieu, 02/11/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Matthieu Sozeau, 02/11/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Pierre Courtieu, 02/11/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Matthieu Sozeau, 02/07/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Jason -Zhong Sheng- Hu, 02/06/2019
- Re: [Coq-Club] Equations 1.2beta is out!, Pierre Courtieu, 02/06/2019
Archive powered by MHonArc 2.6.18.