【发布时间】:2017-04-01 08:14:27
【问题描述】:
给定一个函数的规范,例如specification_of_sum,我如何在 Coq 中证明只有一个这样的函数存在?
我正在学习数学,我可以亲自证明这一点,但我在 Coq 方面的技能有限(使用 rewrite 和 apply 证明)。
我在下面找到了代码 sn-p,我已经为此苦苦挣扎了一段时间。
我尝试在证明中展开规范,但使用我的老朋友rewrite 似乎并没有让我走得更远。
有人能解释一下如何使用简单的语法来解决这个问题吗?
Definition specification_of_sum (sum : (nat -> nat) -> nat -> nat) :=
forall f : nat -> nat,
sum f 0 = f 0
/\
forall n' : nat,
sum f (S n') = sum f n' + f (S n').
(* ********** *)
Theorem there_is_only_one_sum :
forall sum1 sum2 : (nat -> nat) -> nat -> nat,
specification_of_sum sum1 ->
specification_of_sum sum2 ->
forall (f : nat -> nat)
(n : nat),
sum1 f n = sum2 f n.
Proof.
Abort.
【问题讨论】:
标签: functional-programming coq