coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Joachim Breitner <mail AT joachim-breitner.de>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] When does the termination checker reduce a record accessor?
- Date: Fri, 03 Nov 2017 10:39:46 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mail AT joachim-breitner.de; spf=Neutral smtp.mailfrom=mail AT joachim-breitner.de; spf=None smtp.helo=postmaster AT hermes.serverama.de
- Ironport-phdr: 9a23:eE/mjBQWpSXBBzz2fdrs3mbbHdpsv+yvbD5Q0YIujvd0So/mwa67bBKN2/xhgRfzUJnB7Loc0qyN7PCmBDRIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnY/BBjlCgp0OumwX6eaz4Huj7jzqNXvZFBDgyP4ardvJj23qx/Qv48Ym9hMMKE0nznOq3BIeuEe73llJE6Vkgy0ssK5/ZpL8SNZsPIg8otKS6j7Y6I1V/pUAWJ1YCgO+MT3uEybHkO07XwGXzBTy0IQDg==
Hi,
Am Freitag, den 03.11.2017, 15:01 +0100 schrieb William J. Bowman:
> The Coq termination checker normalizes the body of a recursive
> function *before* checking that it terminates. The typing rule is
> something like:
>
> Γ,f:A ⊢ e : A
> Γ,f:A ⊢ v = eval(e)
> terminates(v)
> -------------
> Γ ⊢ (fix f:A.e) : A
I dug into the source code and found this:
(* Check if [def] is a guarded fixpoint body with decreasing arg.
given [recpos], the decreasing arguments of each mutually defined
fixpoint. *)
let check_one_fix renv recpos trees def =
let nfi = Array.length recpos in
(* Checks if [t] only make valid recursive calls *)
let rec check_rec_call renv stack t =
(* if [t] does not make recursive calls, it is guarded: *)
if noccur_with_meta renv.rel_min nfi t then ()
else
let (f,l) = decompose_app (whd_betaiotazeta t) in
(* Interesting bit ↑ *)
From this I conclude that your `eval(e)` in the typing rule is actually
ßɩζ-reduction.
Now ζ means “contraction of local definitions”, so that explains why it
works with a locally bound list_C'.
And the lack of δ (unfolding of transparent constants) explains why it
would not work with the globally defined list_C.
And indeed,
Eval cbv beta iota zeta in fun a C => (P (list_C C)).
does not reduce to list_P.
But this does not explain everything, and I’d like to get a better
understanding what precisly is happening:
Without δ, why does it unfold `list_P` and `existsb` to see that the
recursion on the list is nicely structural? And why do tree_P1 and
tree_P2 still work even when I specify Opaque list_P.?
And I expect the answer to be no… but is there any way to make the
termination checker reduce with delta on?
Thanks,
Joachim
--
Joachim Breitner
mail AT joachim-breitner.de
http://www.joachim-breitner.de/
Attachment:
signature.asc
Description: This is a digitally signed message part
- [Coq-Club] When does the termination checker reduce a record accessor?, Joachim Breitner, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Tej Chajed, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Joachim Breitner, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, William J. Bowman, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Joachim Breitner, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Joachim Breitner, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, William J. Bowman, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Joachim Breitner, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Joachim Breitner, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Joachim Breitner, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Maxime Dénès, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, William J. Bowman, 11/03/2017
- Re: [Coq-Club] When does the termination checker reduce a record accessor?, Tej Chajed, 11/03/2017
Archive powered by MHonArc 2.6.18.