が減少している。Coqのベストプラクティス:相互再帰は、一つだけの機能は、構造的に型指定されていないラムダ計算のために、次のおもちゃの表現を考えてみましょう
Require Import String.
Open Scope string_scope.
Inductive term : Set :=
| Var : string -> term
| Abs : string -> term -> term
| App : term -> term -> term.
Fixpoint print (term : term) :=
match term return string with
| Var id => id
| Abs id term => "\" ++ id ++ " " ++ print term
| App term1 term2 => print_inner term1 ++ " " ++ print_inner term2
end
with print_inner (term : term) :=
match term return string with
| Var id => id
| term => "(" ++ print term ++ ")"
end.
型チェックprint
は、次のエラーで失敗します。
Recursive definition of print_inner is ill-formed.
[...]
Recursive call to print has principal argument equal to "term" instead of "t".
これを実装する最も読みやすい/人間工学的/効率的な方法は何でしょうか?
@CarlPatenaudePoulinお受け取りいただきありがとうございます!私は少し高度なプリンタを追加しました。 –