Zulip Chat Archive
Stream: new members
Topic: Nested inductive type with vector
Rui Liu (Dec 03 2020 at 00:45):
Lean seems to allow the following definition even when tree
is nested in the list
class, as described under https://leanprover.github.io/theorem_proving_in_lean/inductive_types.html#mutual-and-nested-inductive-types
inductive tree (α : Type u)
| mk : α → list tree → tree
However, I can't seem to get this work with vector
, the following code doesn't compile:
import data.vector
universe u
inductive tree (α : Type u)
| mk : α → vector tree 2 → tree
Any way to get lean work with vector
? Maybe define a custom vector that allows nested inductive definition?
Yakov Pechersky (Dec 03 2020 at 00:50):
import data.fin
universe u
inductive tree (α : Type u)
| mk : α → (fin 2 → tree) → tree
Yakov Pechersky (Dec 03 2020 at 00:50):
and then if you really want a vector, you can do vector.of_fn
.
Rui Liu (Dec 03 2020 at 00:57):
@Yakov Pechersky
I don't seem to be able to import data.fin
? I'm developing from vscode after downloading the release here https://github.com/leanprover/lean/releases
Eric Wieser (Dec 03 2020 at 01:00):
That's the old abandoned version of lean
Rui Liu (Dec 03 2020 at 01:01):
Oh actually if I just don't run import data.fin
it also seems to work...
Rui Liu (Dec 03 2020 at 01:04):
@Eric Wieser What version should I use instead?
Eric Wieser (Dec 03 2020 at 01:05):
leanprover-community/lean
Rui Liu (Dec 03 2020 at 01:11):
Oh actually I did download from there https://github.com/leanprover-community/lean/releases/tag/v3.23.0
Alex J. Best (Dec 03 2020 at 01:13):
Try following the recommended instructions at #install
Mario Carneiro (Dec 03 2020 at 01:18):
Lean's support for nested inductive types is spotty, and in particular it does not support dependent nested inductives. These inductives are not part of the kernel but are instead simulated by a compilation strategy that doesn't work in the dependent case. Like Yakov says, you should use functions instead, because these are native inductives and have all the nice properties you would expect
Last updated: Dec 20 2023 at 11:08 UTC