coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Li-yao Xia <lysxia AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] run recursive programs in coq
- Date: Thu, 1 Nov 2018 12:35:15 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=lysxia AT gmail.com; spf=Pass smtp.mailfrom=lysxia AT gmail.com; spf=None smtp.helo=postmaster AT mail-ua1-f46.google.com
- Ironport-phdr: 9a23:YQX0ZRxqFXw1w9TXCy+O+j09IxM/srCxBDY+r6Qd1OkRIJqq85mqBkHD//Il1AaPAd2Eraocw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze+/94HRbglSmDaxfa55IQmrownWqsQYm5ZpJLwryhvOrHtIeuBWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbOSxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDwULs6Wymt771zRRH1likHOT43/mLZhMN+g61Uog6uqRNkzo7IYoyYLuZycr/TcN4YQ2dKQ8ZfVzZGAoO5d4YBCesBMf9YrobnoFsFsBqxBQi2C+jyzTJIgn/33bY10uQgCw7LxwMgH9cUv3TVqNX5LrsdUeewzKTRyzjIcv1Y2TD46IfScxAhp+mBXb1xccrNyUkvChjKgk+MpoziOjOY0PkGvWuD7+d4S+6jl2oqpxtyrzWv3MsglJfFipwPxl3L9Ch12Jg5KcG5RUJhfNKoDptduzubOodoWM8uXWFltSAnwbMco5G7ZjIFyJE/yh7fdfOHd4+I7wrmVOmLIDd4gGtpeK+liBqv6ESgxOLxW8iu3FZFqSpFldbMtnQT2BDJ9seHTf598l+g2TaJyQ/T9vlJLV4omaffMZIswb49moANvUjdACP6gkr7ga6OekUh4Oeo6uDnYrv8pp+bMo95kgX+M6Q1ms2wAOQ3KBMDX2ee+eum1b3j+Vf1T6lNjv0ziqXZqozVJdwHpq6lBA9Yypos6xGmDzu/zNsYmWQHI0ledRKcj4npPknOL+riAfe+hVSsijZryOrcMr3vGJWeZkTExbzmZPN271NW4As119FWoZxOWZ8bJ/emfk60pdXfRi84OkTgx/f8GNR0/owbUGOLRKSeNfWB4hez+uszLrzUN8cuszHnJq19vq+8vToCgVYYOJKR894SYXG8EO5hJhzAM3Xpi9YFV2wNu1hnFbC4uBi5STdWIk2Kceck/DhiUdCpCI7CQsamh7nThH7mTK0TXXhPDxW3KVmtd4iAXK1ROiebI8skjzVdELb9Fcku0hahsAK8wL1ifLLZ
If you're using fuel it is fairly easy to make it structurally decreasing with a simple Fixpoint because fuel can just decrease by 1, instead of using a Program and proving decreasingness with respect to lt.
Li-yao
---
Fixpoint ackermann_fuel (fuel : nat) (m n : nat) : nat :=
match fuel with
| 0 => 0 (* Ran out of fuel! Give a default value of 0. *)
| S fuel =>
match m with
| 0 => S n
| S m' =>
match n with
| 0 => ackermann_fuel fuel m' 1
| S n' => ackermann_fuel fuel m' (ackermann_fuel (pred fuel) m n')
end
end
end.
Compute (ackermann_fuel 100 3 3).
On 11/1/18 12:09 PM, Peter E Schmidt-Nielsen wrote:
Using a fuel quantity seems like a reasonable solution whenever you can easily produce a default value when you run out of fuel. Here's an example of performing this transformation generically on a recursive function, using a nat to track the fuel:
https://gist.github.com/petersn/361c40b3394a3ad9721b738ac61d48b1
Of course, if we switched to using a binary number for the fuel then we could trivially just pass in 2^300 for the fuel and get a definition which won't run out of fuel before the heat death of the universe.
However, some library theorems (N.lt_pred_l and N.lt_wf_0) are opaque, blocking the binary version in the above gist from computing. I'm wondering if anyone more experienced here knows if there're some transparent versions elsewhere I don't know about, or if I'm missing something silly?
-snp
On Thu, 1 Nov 2018, Klaus Ostermann wrote:
It's maybe not particularly elegant or sophisticated, but what about
just adding "fuel" as an additional argument
and initializing with a sufficient amout of fuel?
Klaus
Am 01.11.18 um 12:21 schrieb Thorsten Altenkirch:
Is there a way to run possibly non-terminating programs in the coq
type checker. In Agda you can just switch off the termination checker.
I think this is useful if you want to use something whose termination
you haven't yet proven but want to exploit reduction.
Hence it is not enough to add the assumption that it terminates as an
axiom because this won't reduce.
Thorsten
This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please contact the sender and delete the email and
attachment.
Any views or opinions expressed by the author of this email do not
necessarily reflect the views of the University of Nottingham. Email
communications with the University of Nottingham may be monitored
where permitted by law.
- [Coq-Club] run recursive programs in coq, Thorsten Altenkirch, 11/01/2018
- <Possible follow-up(s)>
- [Coq-Club] run recursive programs in coq, Thorsten Altenkirch, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Klaus Ostermann, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Peter E Schmidt-Nielsen, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Bas Spitters, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Li-yao Xia, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Daniel Schepler, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Peter E Schmidt-Nielsen, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Gaëtan Gilbert, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Jean-Christophe Léchenet, 11/09/2018
- Re: [Coq-Club] run recursive programs in coq, Peter E Schmidt-Nielsen, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Daniel Schepler, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Peter E Schmidt-Nielsen, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Anton Trunov, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Gaëtan Gilbert, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Jan Bessai, 11/01/2018
- Re: [Coq-Club] run recursive programs in coq, Klaus Ostermann, 11/01/2018
Archive powered by MHonArc 2.6.18.