如何在Coq中证明以下陈述?
forall x: nat,
x >= 1 -> 2 * 2 ^ (x - 1) = 2 ^ x.
我在模块pow_add_r
中找到了引理NZPow
但由于某种原因我无法使用它。
谢谢, 马库斯。
答案 0 :(得分:5)
我刚看到你的答案,但这里有一个解释为什么你的初步尝试不起作用,以及如何让它运行:
您无法直接使用Nat.pow_add_r
,因为您的目标既不包含形状a ^ (b + c)
也不包含a ^ b * a ^ c
的字词。你必须帮助Coq识别这种模式。在以下脚本中,我首先将2
更改为2 ^ 1
,然后使用您提供的引理。
Require Import Arith.
Lemma foo: forall x: nat, x >= 1 -> 2 * 2 ^ (x - 1) = 2 ^ x.
Proof.
intros x hx.
(* I only want to rewrite one occurrence of 2 *)
pattern 2 at 1; rewrite <- (Nat.pow_1_r 2).
(* now my goal is 2 ^ 1 * 2 ^ (x-1) = 2 ^ x *)
rewrite <- Nat.pow_add_r.
(* now my goal is 2 ^ (1 + (x - 1)) = 2 ^ x
since x >= 1, we can rewrite the first term and conclude *)
now rewrite le_plus_minus_r.
Qed.
PS:你可以Require Import Nat
如果你不想像我那样为前列词加前缀。
答案 1 :(得分:2)
如果有人有兴趣,只需设法制作证明:
Lemma add_exp:
forall n: nat,
n >= 1 -> 2 * 2 ^ (n - 1) = 2 ^ n.
Proof.
destruct n.
- intros H.
omega.
- intros H.
assert (H1: n = 0 \/ n >= 1) by omega.
destruct H1 as [H1 | H1].
+ subst.
simpl.
reflexivity.
+ simpl.
rewrite <- minus_n_O.
rewrite <- plus_n_O.
reflexivity.
Qed.
最诚挚的问候, 马库斯。