在精益中由该类型的列表构造的归纳类型
Inductive type constructed by a list of that type in Lean
我想定义一个归纳类型,它可以在 lean 中从自身列表构造。不过
inductive a : Type :=
| aFromAs : list a → a
报错:
failed to infer inductive datatype resultant universe, provide the universe levels explicitly
好吧,所以我set_option pp.universes true
和list
属于它参数的类型universe(除非参数是Prop)。所以如果 a
是 Type₁
一切都应该没问题。但是
inductive a : Type₁ :=
| aFromAs : list a → a
给出错误
arg #1 of aFromAs contains an non valid occurrence of the datatype being declared
我觉得它有效。这种接缝应该可以工作。
看起来像 Lean doesn't have support for nested datatypes 所以最好将它们编码为相互递归定义:
inductive a := node : as -> a
with as :=
| nil : as
| cons : a -> as -> as
精益 3 现在支持嵌套归纳声明:
inductive a : Type
| aFromAs : list a → a
我想定义一个归纳类型,它可以在 lean 中从自身列表构造。不过
inductive a : Type :=
| aFromAs : list a → a
报错:
failed to infer inductive datatype resultant universe, provide the universe levels explicitly
好吧,所以我set_option pp.universes true
和list
属于它参数的类型universe(除非参数是Prop)。所以如果 a
是 Type₁
一切都应该没问题。但是
inductive a : Type₁ :=
| aFromAs : list a → a
给出错误
arg #1 of aFromAs contains an non valid occurrence of the datatype being declared
我觉得它有效。这种接缝应该可以工作。
看起来像 Lean doesn't have support for nested datatypes 所以最好将它们编码为相互递归定义:
inductive a := node : as -> a
with as :=
| nil : as
| cons : a -> as -> as
精益 3 现在支持嵌套归纳声明:
inductive a : Type
| aFromAs : list a → a