coq-club AT inria.fr
Subject: The Coq mailing list
List archive
Re: [Coq-Club] simpl (unfold definition) only if the argument is in fully normal form
Chronological Thread
- From: Jason Gross <jasongross9 AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] simpl (unfold definition) only if the argument is in fully normal form
- Date: Thu, 19 Dec 2019 18:47:00 -0500
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jasongross9 AT gmail.com; spf=Pass smtp.mailfrom=jasongross9 AT gmail.com; spf=None smtp.helo=postmaster AT mail-ed1-f41.google.com
- Ironport-phdr: 9a23:gvdA+hdCs16TUMapm7d+/FialGMj4u6mDksu8pMizoh2WeGdxcu/bB7h7PlgxGXEQZ/co6odzbaP6Oa6ADZLuM/JmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MRu7oR/PusULn4duJbs9xgbUqXZUZupawn9lK0iOlBjm/Mew+5Bj8yVUu/0/8sNLTLv3caclQ7FGFToqK2866tHluhnFVguP+2ATUn4KnRpSAgjK9w/1U5HsuSbnrOV92S2aPcrrTbAoXDmp8qlmRAP0hCoBKjU09nzchM5tg6JBuB+uqBJ/zIzUbo+bN/RwY73Tcs8BSGVbQspcTTZMDp+gY4YNCecKIOZWr5P6p1sLtRawAROjBPjoyj9Om3T43Lc60+M6EQHdwQctGNAOv27PrNXyMqcSXvq1zK7TzTXYa/5bwjj96I3SfRAgpfGAR65/cc3UyUQ2EQ7Ok1ueqYvgPzyP1+QNtXCW4PZnVeK1jW4otQVxojy1ysgyl4bJm4QYwU3H+yVh2Is5O8G0RUphbdOnEJZcrT+WO5d1T884TGxkpSA3waAct5GhZigF0pEnygbfa/OZd4iI5QruVOOLLjd5gHJpYaywiAuv/US5xO3xWdS43ExFripCldnMuXQN2ALJ5sebTft9+1+t2TeJ1w/N9uFJOV44mbbfJpI7wbM9loAfvVrfEiL1gkn7g7Kael0h+uey6uTnZrvmpoWbN49xkgz+ML4hmte4AeQ+PQgORW+b+f+n1LDn5kD5T7BKgec3kqndqpzVOcMbpquhDw9Pzokj8wq/Dyuh0NkAgXYHK0tFdAubgIjtJlHBO+v1Dey/glSpiDdk3erKPrznApXXL3jMiq3tfbhn6x0U9A1mxtdGoplQF7tJdPn0Qwr6sMHSJh4/KQ29hej9XoZTzIQbDECGGaifeIzItkSTrrYtKvKLYoAPvy3metAq4vfviTkynlpLLvrh5ocedH3tRqcuGE6ee3e52o5cQ1dPhRI3SanRsHPHUTNXYCzvDac15zV+BY7/SImfH8aih7uO2Cr9FZpTNDgfWwK8VEzwfoDBYM8iLSebI8tviDsBDOHzRIoo1BXovwj/meM+crjkvxYAvJem7+BbovXJnEhrpzNxBsWZlWqKSjMskw==
If you add `Arguments Nat.divmod : simpl nomatch.`, then `Eval simpl in (Nat.modulo (S n) (S n)).` gives `n - snd (Nat.divmod (S n) n 0 n)`.
On Thu, Dec 19, 2019 at 5:23 PM Abhishek Anand <abhishek.anand.iitg AT gmail.com> wrote:
Thanks. That is better but does not completely solve the problem:Require Import ZArith.
Axiom n:nat.
Arguments Nat.modulo !x !y/: simpl nomatch.
Eval simpl in (Nat.modulo (S n) 3).
(*
= S n mod 3
: nat
*)
Eval simpl in (Nat.modulo 5 3).
(*
2
*)
However, I want this to not simplify, but it does:
Eval simpl in (Nat.modulo (S n) (S n)).(*
= n -
snd
match n with
| 0 => Nat.divmod n n 1 n
| S u' => Nat.divmod n n 0 u'
end
: nat
*)Similarly, I want the following to not simplify, but it does:Arguments Z.of_nat !n: simpl nomatch.
Eval simpl in (Z.of_nat (S n)).(*= Z.pos (Pos.of_succ_nat n)
: Z*)On Thu, Dec 19, 2019 at 1:55 PM Gaëtan Gilbert <gaetan.gilbert AT skyskimmer.net> wrote:add ": simpl nomatch" at the end of the Arguments command?
Gaëtan Gilbert
On 19/12/2019 22:51, Abhishek Anand wrote:
> Currently, I can use the Arguments command to tell simpl to unfold a
> definition iff its arguments are in head normal form. In many cases when
> the argument are not in fully normal form, `simpl` then only makes the
> term less "simple":
>
> Require Import ZArith.
> Axiom n:nat.
> Arguments Nat.modulo !x !y/.
> Eval simpl in (Nat.modulo (S n) 3).
> (*
> = match snd (Nat.divmod n 2 0 1) with
> | 0 => 2
> | 1 => 1
> | S (S _) => 0
> end
> : nat
> *)
>
> Nevertheless, we usually do want to unfold such definitions when the
> argument is in fully normal form:
> Eval simpl in (Nat.modulo 5 3).
>
> Is there a way to tell `simpl` to unfold a definition only when some
> chosen arguments are in fully normal form?
>
> Thanks,
> -- Abhishek
> http://www.cs.cornell.edu/~aa755/
- [Coq-Club] simpl (unfold definition) only if the argument is in fully normal form, Abhishek Anand, 12/19/2019
- Re: [Coq-Club] simpl (unfold definition) only if the argument is in fully normal form, Gaëtan Gilbert, 12/19/2019
- Re: [Coq-Club] simpl (unfold definition) only if the argument is in fully normal form, Abhishek Anand, 12/19/2019
- Re: [Coq-Club] simpl (unfold definition) only if the argument is in fully normal form, Jason Gross, 12/20/2019
- Re: [Coq-Club] simpl (unfold definition) only if the argument is in fully normal form, Abhishek Anand, 12/19/2019
- Re: [Coq-Club] simpl (unfold definition) only if the argument is in fully normal form, Gaëtan Gilbert, 12/19/2019
Archive powered by MHonArc 2.6.18.