coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Ilmārs Cīrulis <ilmars.cirulis AT gmail.com>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Question about fold and, probably, inductive definitions
- Date: Mon, 1 Feb 2016 14:27:01 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=ilmars.cirulis AT gmail.com; spf=Pass smtp.mailfrom=ilmars.cirulis AT gmail.com; spf=None smtp.helo=postmaster AT mail-yk0-f175.google.com
- Ironport-phdr: 9a23:7WAN0R1Z9bJJx4S7smDT+DRfVm0co7zxezQtwd8ZsegQLvad9pjvdHbS+e9qxAeQG96LtLQd06GN7ejJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd6NyZ3vnLvss7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cY6Lod8JsKWqLjOq88ULZwDTI8Mmlz6teh/U3IShLK7X8BWE0XlABJCk7L9kepcI32t37bsu/WwjLSFszsULQ1Qnz27qNuQQXzziwGLSM98Xr/hcl5jaYdqxWk8U8si7XIaZ2YYaItNpjWeskXEDJM
So that's the difference I missed.
On Mon, Feb 1, 2016 at 1:28 PM, Robbert Krebbers <mailinglists AT robbertkrebbers.nl> wrote:
On 02/01/2016 12:16 PM, Ilmārs Cīrulis wrote:
Fixpoint fold_right A B n (f: B → A → A) (a: A) (L: list B n): A :=You have to write this function in a slightly different way so as to convince Coq that f remains constant during each recursive call:
match L with
| nil _ => a
| cons x t => f x (fold_right f a t)
end.
Definition fold_right A B (f: B → A → A) :
forall n, A -> list B n -> A :=
fix go n a L :=
match L with
| nil _ => a
| cons x t => f x (go _ a t)
end.
Now f is no longer an argument of the fix.
List.fold_right is written in this way too.
- [Coq-Club] Question about fold and, probably, inductive definitions, Ilmārs Cīrulis, 02/01/2016
- Re: [Coq-Club] Question about fold and, probably, inductive definitions, Robbert Krebbers, 02/01/2016
- Re: [Coq-Club] Question about fold and, probably, inductive definitions, Ilmārs Cīrulis, 02/01/2016
- Re: [Coq-Club] Question about fold and, probably, inductive definitions, Cedric Auger, 02/01/2016
- Re: [Coq-Club] Question about fold and, probably, inductive definitions, Clément Pit--Claudel, 02/01/2016
- Re: [Coq-Club] Question about fold and, probably, inductive definitions, Cedric Auger, 02/01/2016
- Re: [Coq-Club] Question about fold and, probably, inductive definitions, Ilmārs Cīrulis, 02/01/2016
- Re: [Coq-Club] Question about fold and, probably, inductive definitions, Robbert Krebbers, 02/01/2016
Archive powered by MHonArc 2.6.18.