Coqで定義された次の Inductive 型があります。
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 のリストに似ています)。以下の定義を使用して、2 つの 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ですか?
ヘルプやヒントは大歓迎です。