【发布时间】:2021-06-12 15:01:08
【问题描述】:
我想出了函数 applyN 的两个等效定义,它将给定函数 f 应用于参数 x n 次:
Variable A : Type.
Fixpoint applyN1 (n : nat) (f : A -> A) (x : A) :=
match n with
| 0 => x
| S n0 => applyN1 n0 f (f x)
end.
Fixpoint applyN2 (n : nat) (f : A -> A) (x : A) :=
match n with
| 0 => x
| S n0 => f (applyN2 n0 f x)
end.
我想证明这些函数在 Coq 中是外延相等的:
Theorem applyEq : forall n f x, applyN1 n f x = applyN2 n f x.
Proof.
intros.
induction n.
reflexivity. (* base case *)
simpl.
rewrite <- IHn.
我被困在这里。我真的想不出一个有用且更容易证明的引理。在没有显式累加器的情况下,如何证明直接式和基于累加器的递归函数的相等性?
【问题讨论】:
标签: functional-programming coq theorem-proving