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: [Coq-Club] Question about fold and, probably, inductive definitions
- Date: Mon, 1 Feb 2016 13:16:31 +0200
- Authentication-results: mail2-smtp-roc.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-f182.google.com
- Ironport-phdr: 9a23:oiL68BcZ1+vouWC0VfgfCs3RlGMj4u6mDksu8pMizoh2WeGdxc68YB7h7PlgxGXEQZ/co6odzbGG7Oa5ASdaud6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDtvcSLKF8QzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IAu3GePFyRrtBST8iLmod5cvxtBCFQxHFri8XVXxTmR5VCSDE6gv7V9H/qH2pmPB63Xy7OchdV6t8cjW48qNqU1e8iSMCPiQitmrWkNF0jblzrxeophg5yInRNtLGfMFid7/QKItJDVFKWdxcAnRM
What's the difference between 1st and 2nd example? The 2nd isn't accepted.
(* 1 *)
Require Import Utf8 List.
Set Implicit Arguments.
Inductive tree (A: Type) :=
| leaf
| root: list (tree A) → tree A.
Fixpoint count (T: tree nat) :=
match T with
| leaf _ => 1
| root l => fold_right (λ x, plus (count x)) O l
end.
(*2*)
Require Import Utf8.
Set Implicit Arguments.
Inductive list A: nat → Type :=
| nil: list A 0
| cons: ∀ n, A → list A n → list A (S n).
Inductive tree (A: Type) :=
| leaf
| root: ∀ n, list (tree A) n → tree A.
Fixpoint fold_right A B n (f: B → A → A) (a: A) (L: list B n): A :=
match L with
| nil _ => a
| cons x t => f x (fold_right f a t)
end.
Fixpoint count (T: tree nat) :=
match T with
| leaf _ => 1
| root l => fold_right (λ x, plus (count x)) O l
end.
(* Error:
Recursive definition of count is ill-formed.
In environment
count : tree nat → nat
T : tree nat
n : nat
l : list (tree nat) n
x : tree nat
Recursive call to count has principal argument equal to
"x" instead of "l".
Recursive definition is:
"λ T : tree nat,
match T with
| leaf _ => 1
| @root _ n l => fold_right (λ x : tree nat, Nat.add (count x)) 0 l
end". *)
- [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.