【发布时间】:2017-05-20 17:42:50
【问题描述】:
我对术语有以下定义:
Inductive term : Type :=
| Var : variable -> term
| Func : function_symbol -> list term -> term.
和一个函数pos_list 获取术语列表并返回每个子术语的“位置”列表。例如对于[Var "e"; Func "f" [Var "x"; Func "i" [Var "x"]]],我应该得到[[1]; [2]; [2; 1]; [2; 2]; [2; 2; 1]],其中每个元素代表子项树层次结构中的一个位置。
Definition pos_list (args:list term) : list position :=
let fix pos_list_aux ts is head :=
let enumeration := enumerate ts in
let fix post_enumeration ts is head :=
match is with
| [] => []
| y::ys =>
let new_head := (head++y) in
match ts with
| [] => []
| (Var _)::xs => [new_head] ++ (post_enumeration xs ys head)
| (Func _ args')::xs =>
[new_head] ++
(pos_list_aux args' [] new_head) ++
(post_enumeration xs ys head)
end
end
in post_enumeration ts enumeration head
in pos_list_aux args [] [].
使用上面的代码我得到了错误
错误:无法猜测
fix的递减参数
在第一个let fix 构造中,但在我看来,对(pos_list_aux args' [] new_head) 的调用(这会导致问题)将args' 作为参数(Func _ args') 的子项,而(Func _ args') 本身就是@987654331 的子项@。
怎么了?
【问题讨论】:
标签: functional-programming coq totality