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: Abhishek Anand <abhishek.anand.iitg 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 14:21:56 -0800
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=abhishek.anand.iitg AT gmail.com; spf=Pass smtp.mailfrom=abhishek.anand.iitg AT gmail.com; spf=None smtp.helo=postmaster AT mail-io1-f52.google.com
- Ironport-phdr: 9a23:BTTHuh9X9Jurc/9uRHKM819IXTAuvvDOBiVQ1KB30uocTK2v8tzYMVDF4r011RmVBN6dsasdwLOL7OjJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglVijexe61+IAiroQneq8UbgYlvIbstxxXUpXdFZ/5Yzn5yK1KJmBb86Maw/Jp9/ClVpvks6c1OX7jkcqohVbBXAygoPG4z5M3wqBnMVhCP6WcGUmUXiRVHHQ7I5wznU5jrsyv6su192DSGPcDzULs5Vyiu47ttRRT1jioMKjw3/3zNisFog61brhCuqRxxzYDXfY+bKuZxc7jHct8GX2dMRNpdWzBDD466coABD/ABPeFdr4Tlu1YBthu+BQi3BOPv1DBIhWL90LE80+s7FwHJwRErEtUUv3vPrNX1NbwSUeCrw6nL1znMdfVW1i376IfVaBwhoPCMXa5/ccfKxkkvEhnKjlSUqYD/IzyV0eENvnGd4uF9W+yvjGsnpBtwojip3sojlo7JhpgTyl/a8SV5xJw5KsOlR05mZ9OvDZhetzmCOodoXs8vR3tktSU6x7EcpJK2fSkHxI4nyhLBbfGMbpKG7Qj5VOmLJDd1nHJld6y7hxa16UWgz/fzVsiw0FpTrypFlcTAumkD1xHT9MSLUPR9/kCm2TaA0wDc9PtILlwzlareM5Ihw7gwmYQPsUnbACP6hEH7gLWVe0gk4OSk9uXqb7T8qpKcKYN4kgT+Pb4vmsy7D+Q4KA8OX22D9Oumz7Lj/Uz5QK5KjvIokanVqorVJcIBqa6/HgBZyIcj6xejDzepy9kYknwHI0hEeBKDlYTmJ1bOIPXgAfeln1usiCtrx+zBPrD5HprNKWHDnK79crZ59k5T0xE+zctf5pJRErEOOuj/Wk73tNzCDx82KRa4w+j9CIY16oRLUmWWR6SdLama5VSP/6ckJ/SGTI4Tojf0bfY/sa3Al3g8zHYXfaiy3ZYUIFm+F/JqaxGQa3rtmdcMEiEDuAM4QKrriUGNeTFWbne2Gak742doW8qdEY7fS9X10/S61yChE8gOPzwUOhW3CX7tMr68dbIUcivLe51ulzUFUf6qTIpzjUjz5j+/8KJuK6/vwgNdtZ/n04IotejalBV39DstSsrAiSeCSGZ7mm5OTDgzjvgm8B5Nj2yb2K09uMR2UNla5vdHSAA/bMeOwOlzCtS0UQXELI6E
Thanks. That is better but does not completely solve the problem:
Eval simpl in (Nat.modulo (S n) (S n)).
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:
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
*)
= 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)).
Eval simpl in (Z.of_nat (S n)).
(*
= Z.pos (Pos.of_succ_nat n)
: Z
: 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.