由精益中的那种类型的列表构成的归纳类型

时间:2016-11-18 01:56:43

标签: type-theory lean

我想定义一个归纳类型,可以从精简列表中构建。然而

inductive a : Type :=
| aFromAs : list a → a

给出错误:

failed to infer inductive datatype resultant universe, provide the universe levels explicitly

很好,所以我set_option pp.universes truelist属于其参数的类型范围(除非参数是Prop)。因此,如果aType₁,一切都应该没问题。但

inductive a : Type₁ :=
| aFromAs : list a → a

给出错误

arg #1 of aFromAs contains an non valid occurrence of the datatype being declared

它看起来对我有用。这样接缝应该可以工作。

2 个答案:

答案 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