我在Coq中定义了以下归纳类型。
Inductive natlist : Type :=
| nil : natlist
| cons : nat -> natlist -> natlist.
Notation "x :: l" := (cons x l) (at level 60, right associativity).
Notation "[ ]" := nil.
Notation "[ x , .. , y ]" := (cons x .. (cons y nil) ..).
natlist 基本上是一个自然数列表(类似于 Python 中的列表)。我正在尝试使用下面的定义找到两个 natlist 的联合。
Definition union_of_lists : natlist -> natlist -> natlist
即
Eval simpl in (union_of_lists [1,2,3] [1,4,1])
应该返回 [1,2,3,1,4,1]
我有以下疑问。
- 由于这个定义没有参数,我如何实际获取输入并处理它们?
- union_of_lists 的定义究竟返回了什么?它只是一个natlist吗?
非常感谢任何帮助或提示。