【发布时间】:2019-05-05 12:27:01
【问题描述】:
在逻辑章节中介绍了反向列表函数的尾递归版本。我们需要证明它工作正常:
Fixpoint rev_append {X} (l1 l2 : list X) : list X :=
match l1 with
| [] => l2
| x :: l1' => rev_append l1' (x :: l2)
end.
(* Tail recursion rev *)
Definition tr_rev {X} (l : list X) : list X :=
rev_append l [].
但在证明之前我想证明一个引理:
Lemma rev_append_app: forall (X: Type) (x: X) (l : list X),
rev_append l [x] = rev_append l [] ++ [x].
Proof.
intros X x l. induction l as [| h t IH].
- simpl. reflexivity.
- simpl.
我卡住了:
X : Type
x, h : X
t : list X
IH : rev_append t [x] = rev_append t [ ] ++ [x]
============================
rev_append t [h; x] = rev_append t [h] ++ [x]
接下来要做什么?
【问题讨论】:
-
简短的回答是,这个引理并不比原始引理更容易证明。
-
@Li-yaoXia 请给点提示。