我想定义一个归纳类型,可以从精简列表中构建。然而
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
属于其参数的类型范围(除非参数是Prop)。因此,如果a
为Type₁
,一切都应该没问题。但
inductive a : Type₁ :=
| aFromAs : list a → a
给出错误
arg #1 of aFromAs contains an non valid occurrence of the datatype being declared
它看起来对我有用。这样接缝应该可以工作。
答案 0 :(得分:3)
精益3现在支持嵌套的归纳声明:
inductive a : Type
| aFromAs : list a → a
答案 1 :(得分:2)
它看起来像Lean doesn't have support for nested datatypes所以你最好把它们编码为相互递归的定义:
inductive a := node : as -> a
with as :=
| nil : as
| cons : a -> as -> as