coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jason Gross <jasongross9 AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] normalize all closed terms of a given type
- Date: Thu, 15 Oct 2020 18:39:39 -0400
- 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-f51.google.com
- Ironport-phdr: 9a23:9OovXRBqNoOROtro+i3eUyQJP3N1i/DPJgcQr6AfoPdwSPT/pMbcNUDSrc9gkEXOFd2Cra4d1KyI7+u4CCQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagY75+NhS7oAreusUKhYZpN7o8xAbOrnZUYepd2HlmJUiUnxby58ew+IBs/iFNsP8/9MBOTLv3cb0gQbNXEDopPWY15Nb2tRbYVguA+mEcUmQNnRVWBQXO8Qz3UY3wsiv+sep9xTWaMMjrRr06RTiu86FmQwLuhSwaNTA27XvXh9R/g6JVoh2vpxJxzY3Jbo+LKPVzZbnScc8ASGdbQspdSy5MD4WhZIUPFeoBOuNYopH5qVQUthu+Ag+sD/7uxD9SgX/2xrY62PkmHAHExgMgBNUOsHLbrNXvM6cSSvu1wa3TwDXMavNZwzb96IzSfh89pvGMWKt9fMzMwkYgCw3LlE+fqZD5PzyLzOQNtXCW4u5uW++vl2IqpB18rzivyMsyhITEhZwZx07Y+Sh33Is4JNm1RUF0b9K4DpZetyOXOop2TM4tX2xmtyU3xLMYtJO9YSMExpMnxxvFZPyGdYiF+g7sVOGLITd+mn1lfLa/iwys/ke91+3xUNS/3lVSriddjNXAqnQA2wbQ58WHUPdx4Fut1DWV2w3T9+1JJ10/m7DBJJ472LEwk4IesUTdES/yn0X7lKqWeV8l+uis8ujofKjpqoKFO496igzyL74imsO4AeQ/PQgOW3aU9f6g273k+E31WLRKjvsonanFqJ3WO9gXq6qjDwJW0osv8QizAyul3dgCnXQLMUpJeBedgIjoP1HOLur4DfC6g1m0kjdk3evGPrrnApXCNHjDl6zhfa155kNHxwozyMpQ55NQCr0bPP3zXUrxuMTCDhAlKwy03/rnCNJl24wCXmKPG7aVP7/WsV+V/e0iOPKMZY8QuDblMfcp/f/ujXkjmV8cZ6alx5UXaGrrVshhdk6eeD/nhsoLWTMBuRN7R+j3gnWDVyRSbjC8RfRvyCs8DdeEBJzEQMiCmruax2/vHJRNYWZJEFeXCibAeICNWvNKYyWXdJwy2gcYXKSsHtdynSqlsxX3nuI+c7jkvxYAvJem7+Bbou3ekRZoqG5xBsWZlmyBFiR6wzpOSDgx06Ry50d6zwXbiPkqs7ljDdVWoshxfEI/PJ/YwfZ9DomrCA3Ed9aNDl2hR4f/WG1jfpcK29YLJn1FNZC6lBmahnilBrYUk/qAA5lmqq8=
Inductive marker := mark.
Ltac norm T :=
let check_and_change v :=
assert_fails has_evar v;
let T' := type of v in
unify T T';
let v' := (eval vm_compute in v) in
progress ( change v with v' in * ) in
pose proof mark;
repeat match goal with H : _ |- _ => revert H end;
repeat match goal with
| [ |- context[?e] ] => check_and_change e
end;
repeat lazymatch goal with
| [ |- marker -> _ ] => fail
| _ => intro
end;
intros _.
Goal forall a b c, a + (5 + 6) + c = 1 + 1 + b.
intros a b.
norm nat.
Ltac norm T :=
let check_and_change v :=
assert_fails has_evar v;
let T' := type of v in
unify T T';
let v' := (eval vm_compute in v) in
progress ( change v with v' in * ) in
pose proof mark;
repeat match goal with H : _ |- _ => revert H end;
repeat match goal with
| [ |- context[?e] ] => check_and_change e
end;
repeat lazymatch goal with
| [ |- marker -> _ ] => fail
| _ => intro
end;
intros _.
Goal forall a b c, a + (5 + 6) + c = 1 + 1 + b.
intros a b.
norm nat.
Note that this may not play well with section variables.
On Thu, Oct 15, 2020 at 5:56 PM Abhishek Anand <abhishek.anand.iitg AT gmail.com> wrote:
Yeah, closed means no evars and no local variables.For example, in the proof below, I want 2^64 to be normalized and leave everything else unchanged.I can use the tactic `norm` below to manually pick terms to normalize. But I wish there was an automatic way to pick all closed terms of a given type.Require Import ZArith.
Open Scope Z_scope.
Ltac norm T :=
match goal with
[ |- context[T] ] => let Tc := eval vm_compute in T in
change T with Tc
end.
Lemma xx (x:Z) : (2^64)*x=1.
norm (2^64).On Thu, Oct 15, 2020 at 5:44 AM Beta Ziliani <beta AT mpi-sws.org> wrote:I was going to ask the same question. Perhaps an example could help?On Thu, Oct 15, 2020 at 3:08 AM Fabian Kunze <fabian.kunze AT cs.uni-saarland.de> wrote:By closed, do you mean no evars, or no local variables?
15 Oct 2020 07:42:39 Abhishek Anand <abhishek.anand.iitg AT gmail.com>:
Sorry, I was not clear. I want to only strongly normalize closed subterms of the type and leave the rest unchanged.
On Wed, Oct 14, 2020 at 6:54 PM Jason Gross <jasongross9 AT gmail.com> wrote:
Sorry, that only does goal, but doing the context isn't much different
On Wed, Oct 14, 2020, 20:53 Jason Gross <jasongross9 AT gmail.com> wrote:
Here is a slow tactic to do this:Ltac norm T :=repeat match goal with| [ |- context [?e] ] => let e' := eval vm_compute in (e : T) in progress change e with e'end.
You may want a different typing check if you don't want coercion insertion or only want to check up to syntactic typing rather than unification.
On Wed, Oct 14, 2020, 20:20 Abhishek Anand <abhishek.anand.iitg AT gmail.com> wrote:
Is there a tactic to strongly normalize all closed terms of a given type in the Coq goal and context?Is there a way to write such a tactic in Ltac/Ltac2/Mtac2.... ?
-- Abhishekhttp://www.cs.cornell.edu/~aa755/
- [Coq-Club] normalize all closed terms of a given type, Abhishek Anand, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Jason Gross, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Jason Gross, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Abhishek Anand, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Fabian Kunze, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Beta Ziliani, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Abhishek Anand, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Jason Gross, 10/16/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Jason Gross, 10/16/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Abhishek Anand, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Beta Ziliani, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Fabian Kunze, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Abhishek Anand, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Jason Gross, 10/15/2020
- Re: [Coq-Club] normalize all closed terms of a given type, Jason Gross, 10/15/2020
Archive powered by MHonArc 2.6.19+.