How can I prove the following statement in Coq?
forall x: nat,
x >= 1 -> 2 * 2 ^ (x - 1) = 2 ^ x.
I found lemma pow_add_r
in module NZPow
but for some reason I can´t use it.
Thanks, Marcus.
I just saw your answer, but here is an explanation why your initial attempt didn't work, and how to make it run:
You can't directly use Nat.pow_add_r
because your goal neither contains a term of the shape a ^ (b + c)
nor a ^ b * a ^ c
. You have to help Coq to recognize this pattern. In the following script, I first change 2
into 2 ^ 1
, then use the lemma you provided.
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: you can Require Import Nat
if you don't want to prefix the lemmas like I did.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With