【发布时间】:2019-04-03 21:29:05
【问题描述】:
Lemma rev_firstn : forall (x : list bool) (n : nat),
rev (firstn n x) = firstn n (rev x).
我在这方面花了很多时间。我从一个合理的目标开始,但总是以一个无法证明的目标结束。
这是我目前的做法:
Proof.
intros. generalize dependent x. induction n.
+ easy.
+ induction x.
- easy.
-
在我的上下文中,我现在有:
IHn : forall x : list bool, rev (firstn n x) = firstn n (rev x)
IHx : rev (firstn (S n) x) = firstn (S n) (rev x)
我的目标是:
rev (firstn (S n) (a :: x)) = firstn (S n) (rev (a :: x))
有没有办法在 IHx 中泛化 x 以便我可以将其专门用于 (a :: x)?由于我不知道执行此操作的正确策略,因此我尝试了以下操作,并最终达到了前面提到的不可能的目标。
Proof.
intros. generalize dependent x. induction n.
+ easy.
+ induction x.
- easy.
- assert (rev_cons : forall (b : bool) (l : list bool),
rev (b :: l) = rev l ++ [b]).
{ easy. } rewrite firstn_cons.
rewrite rev_cons. rewrite rev_cons. specialize (@IHn x).
rewrite IHn.
Goal: firstn n (rev x) ++ [a] = firstn (S n) (rev x ++ [a])
这个目标是不可能的,因为对于 n = 0 和 rev x = h :: t,目标
减少到[a] = List.hd (rev (h :: t)) ++ [a]。
这个引理实际上是不合理的,还是我只是错过了一些策略?
【问题讨论】:
标签: coq