Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Recursion over indexed/mapped finite data structure

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Recursion over indexed/mapped finite data structure


Chronological Thread 
  • From: Christopher Ernest Sally <christopherernestsally AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Recursion over indexed/mapped finite data structure
  • Date: Tue, 25 May 2021 08:31:47 -0700
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=christopherernestsally AT gmail.com; spf=Pass smtp.mailfrom=christopherernestsally AT gmail.com; spf=None smtp.helo=postmaster AT mail-io1-f49.google.com
  • Ironport-data: A9a23:fAW646jyF5J8TUis697C6+AeX161FhEKZh0ujC45NGQNrF6WrkVVy2BJCjjSM6uMYTT0c911a421p08F7MTcmN9mSFY//1hgHilAwSbnLYTAfx2oZ0t+DeWaERk5t51GAjX4wXFdokb0/n9BCZC86ykmvU20buCkUrecZ3osHVUMpBoJ0HqPpcZp2uaEvvDiW2thifuqyyHuEAfNNwxcagr42IrfwP9bh8kejRtD1rAIiV+ni3eF/5UdJMp3yahctBIUSKEMdgKxb76rIL1UYgrkExkR5tONyt4Xc2UPS7/WeAmJ0z9YB/nkjR9FqSg/lK08MZLwa28N02TPz403kYsT88DhIesqFvWkdOA1WBlCEjpiOrVG9aXKO36yqtCIxknCYlPjxvxvCAc9OohwFuNfXDkfpaxJeGtXBvyEr7vunOjTpvNXrs8kNYzgOJ4VkmpxyCnQS/cgW5HKBavQjeK0dh8k3pUUW6nKPp9BL2J7NkGYJUceaw4DU8dm2rq82SzWbRlzrXa5pY4W6k7v1ihP0Z35aYKAKpjXUa25hW6dr2PCumX+W1QUaI3Zxj2C/XahwOTImEvGtEspPOXQ3pZXbJe7nTx75NwquVqHTT2Rj0e/X5deLBVR9HZ/66c180OvQ5/2WBjQTLus1vIDc4I4LgH4wFjlJmnoD8KxCW0NTzoHY9sj3CPzbSJ/zUeHxrsFG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4+u82bv+9kP6WLVHluM6nrXdvZzAJskWprS1DxJU34si8RqyADOr3dIFlncdNl1FYgiIj43xNlHOPv/4CfC/jkypkDhxxvDGOqTtApTKLnTeibvhc7lw5kpGxAo8ytBf4J1UCrUfL/7pRkDxs9nYAgc4Mwyy3ennFM1w2p0CVW+LGKOUM6PfvUWV6u8uIuSAfoAYtTLlJ/gg/fHujHs5mVEHfamu2JsacGy3HvR8I0WYenrsntABEX8KvgUgVuzllkeCUThNaHapQ6I8/Ss0CIaiDYbDXY2tj7mB0z26Hp1SfGxJFleMEXLwe4WeR/gMcD6SItNmkjEcSbehTJYh2Qiyuw/+1rpoNfHZ+jYYtJLmzNh6/ffflRA09TxuDsSSyXuBT29unjBAezhj16dm5Ed5113LhaN/mrlTEcFZz/JPSAYzc5DGmb9UEdf3DynBZNaSVFG+Qti8SRwrSN8q35c1akJ5Cp32hRDZ3jG2BKcVmqaGHpo56b7H1nz1Nu5yzn/H0O8qiFxwEZgHDnGvmqMqr1ubPIXOiUjMz85CmowT2SfM8CGIym/c5SmwsSZ1WKTBGHEYPw7Y8YW/6UTFQLujT78gN1kZoSZnAqRPY9zty15BQaW7UOk=

Dear Sylvain

Ah, thank you for those excellent pointers! Indeed, I had forgotten all about the analyses.

Cordialement
Chris



On Mon, 24 May 2021 at 23:48, Sylvain Boulmé <Sylvain.Boulme AT univ-grenoble-alpes.fr> wrote:
Hello Christopher,

Le 25/05/2021 à 01:21, Christopher Ernest Sally a écrit :
> Hi Club
>
> a finite data structure consisting of a map (from keys to elements) and
> elements that contain (along with their own data) a key to a successor
> element. Some elements have no successor key, indicating a kind of
> "endpoint", resulting in DAGs. (actually, control-flow graphs).
>
> I want to write a recursive function over this data structure (but there
> is no naive/obvious decreasing struct). I could use a fuel based
> approach (# of elements as the bound) but wonder if that might hinder
> any proofs I would later want to do over the function. I have not worked
> much with Program before.
>
> Do people have experience with this, and any insights to the way forward?
>
> Bonus information:
> In fact, I am working with RTL from CompCert. (CompCert's pass out of
> RTL is a validated pass i.e. the compiler code is in Ocaml and thus does
> not provide an example) and the function is a translation of RTL code.
>


Actually, you will find examples of various approaches in CompCert.


1) The "fuel" approach:

For the "fuel" approach, look at Kildall, and in particular
[fixpoint_from] function:

http://compcert.inria.fr/verasco/coqdoc/1.3/html/Kildall.html#Dataflow_Solver.fixpoint_from

It uses the "fuel" approach defined in the [PremIter] module:
http://compcert.inria.fr/verasco/coqdoc/1.3/html/Iteration.html#PrimIter

When you use this approach, you are in a kind of "partial correctness"
setting: your fixpoint computation may fail on a "no fuel left error",
and you prove properties only when the computation succeeds.

2) The "oracle" approach:

Thus, I often than an even simpler approach is to let an external oracle
in OCaml compute the fixpoint and only program in Coq a verifier that
checks that the result of the oracle is actually a fixpoint. This seems
to me much modular, since you can tune/change the oracle without redoing
any additional proof.

An example is provided by the register allocation, as you previously
mentioned.

Another example is provided by my version of "branch tunneling" (on LTL,
which is very similar to RTL):

https://certicompil.gricad-pages.univ-grenoble-alpes.fr/compcert-kvx/html/compcert.backend.Tunneling.html

with the OCaml oracle here:

https://gricad-gitlab.univ-grenoble-alpes.fr/certicompil/compcert-kvx/-/blob/master/backend/Tunnelingaux.ml

This approach avoids the need to formalize in Coq a variant of
union-find data-structure in contrast to Xavier Leroy's solution. In my
approach, this data-structure is directly implemented in the above
oracle, with imperative features of OCaml.

3) The "full correctness" approach, (with a termination proof):

An example is provided by [Postorder] (which computes a Postorder
numbering on the graph):

https://compcert.org/doc/html/compcert.lib.Postorder.html

Regards,

Sylvain.







Archive powered by MHonArc 2.6.19+.

Top of Page