Skip to Content.
Sympa Menu

coq-club - [Coq-Club] cbv evaluation in Coq?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] cbv evaluation in Coq?


Chronological Thread 
  • From: Randy Pollack <rpollack0 AT gmail.com>
  • To: Coq-Club Club <coq-club AT inria.fr>
  • Subject: [Coq-Club] cbv evaluation in Coq?
  • Date: Wed, 13 Jan 2016 13:49:58 +0000
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=rpollack0 AT gmail.com; spf=Pass smtp.mailfrom=rpollack0 AT gmail.com; spf=None smtp.helo=postmaster AT mail-lb0-f182.google.com
  • Ironport-phdr: 9a23:+8rbcRPtaGItoJzjo40l6mtUPXoX/o7sNwtQ0KIMzox0KPv/rarrMEGX3/hxlliBBdydsKIazbqJ+Pq7EUU7or+/81k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i760zceF13FOBZvIaytQ8iJ35rxh7/5ocabSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6LoJvvRNWqTifqk+UacQTHF/azh0t4XXskzoShLKzX8BWC09lgdCS1zO6wi/VZPsuAP7sPB80W+UJ5ulY6ozXGGY5qFnWVfQjyMDPjU6uDXNkst0iKtQo0qJqBl2woqSa4aQYqktNpjBdM8XEDISFv1aUDZMV8blN9MC

The certicoq project (https://www.cs.princeton.edu/~appel/certicoq/)
has recently been discussing what "evaluation" should mean for Coq
programs (including programs with axioms). I noticed the following
Coq behavior that surprised me. I apologize for the long email, which
I attempt to make self contained. Consider the program [demo]

Definition bb := bool.
Definition demo (t:True) : bb := match t with I => true end.

To look beneath Print form, I use Malecha's quoting plugin,
template-coq (https://github.com/gmalecha/template-coq/tree/coq-8.5).
First quote the program

Quote Recursively Definition p_demo := demo.
Print p_demo.

p_demo =
PType "Coq.Init.Logic.True"
(("True", {| ctors := ("I", tRel 0, 0) :: nil |}) :: nil)
(PType "Coq.Init.Datatypes.bool"
(("bool",
{| ctors := ("true", tRel 0, 0) :: ("false", tRel 0, 0) :: nil |})
:: nil)
(PConstr "Top.bb" (tInd (mkInd "Coq.Init.Datatypes.bool" 0))
(PConstr "Top.demo"
(tLambda (nNamed "t") (tInd (mkInd "Coq.Init.Logic.True" 0))
(tCase 0
(tLambda (nNamed "t")
(tInd (mkInd "Coq.Init.Logic.True" 0))
(tConst "Top.bb")) (tRel 0)
((0, tConstruct (mkInd "Coq.Init.Datatypes.bool" 0) 0)
:: nil))) (PIn (tConst "Top.demo")))))
: program

This quotes everything in the Coq context that is hereditarily used in
the toplevel program. The toplevel program (item "PIn") is just the
defined constant (tConst "Top.demo"). The definiens of "Top.demo"
(bound in the quoted context as 'PConstr "Top.demo"') is

(tLambda (nNamed "t") (tInd (mkInd "Coq.Init.Logic.True" 0))
(tCase 0
(tLambda (nNamed "t")
(tInd (mkInd "Coq.Init.Logic.True" 0))
(tConst "Top.bb")) (tRel 0)
((0, tConstruct (mkInd "Coq.Init.Datatypes.bool" 0) 0)
:: nil)))

Notice the defined constant (tConst "Top.bb") under a lambda in the
mechanically generated return predicate of the Case statement.

Now we quote the cbv evaluated program

Quote Definition qcbv_demo := Eval cbv in demo.
Print qcbv_demo.

qcbv_demo =
tLambda (nNamed "t") (tInd (mkInd "Coq.Init.Logic.True" 0))
(tCase 0
(tLambda (nNamed "t")
(tInd (mkInd "Coq.Init.Logic.True" 0))
(tInd (mkInd "Coq.Init.Datatypes.bool" 0)))
(tRel 0)
((0, tConstruct (mkInd "Coq.Init.Datatypes.bool" 0) 0) :: nil))
: term

The instance of (tConst "Top.bb") under a lambda has been unfolded to
its definiens, (tInd (mkInd "Coq.Init.Datatypes.bool" 0)).

This is not the behavior I expect for Eval cbv. What is the
specification of cbv for Coq?

Best,
Randy



Archive powered by MHonArc 2.6.18.

Top of Page