2

Coq beginner here, I recently went by myself through the first 7 chapters of "Logical Foundations".

I am trying to create a proof by induction in Coq of ∀ n>= 3, 2n+1 < 2^n.

I start with destruct removing the false hypotheses until reaching n=3. Then, I do induction on n, the case for n=3 is trivial but, how can I prove the inductive step??

I can see the goal holds. I can prove it by case analysis using destruct but, haven't been able to show it in a general form.

The functions I'm using are from "Logical Foundations" and can be seen here.

My proof so far:

(* n>=3, 2n+1 < 2^n *)
Theorem two_n_plus_one_leq_three_lt_wo_pow_n : forall n:nat,
    (blt_nat (two_n_plus_one n) (exp 2 n)) = true
       -> (bge_nat n 3) = true.   
Proof.
  intros n.
  destruct n.
  (* n = 0 *)
  compute.
  intros H.
  inversion H.

  destruct n.
  (* n = 1 *)
  compute.
  intros H.
  inversion H.  

  destruct n.
  (* n = 2 *)
  compute.
  intros H.
  inversion H.

  induction n as [ | k IHk].
  (* n = 3 *)
  - compute.
    reflexivity.
  - rewrite <- IHk.
    (* Inductive step... *)
user454322
  • 7,300
  • 5
  • 41
  • 52
  • It's not clear what you are trying to prove exactly. Proving `n>= 3, 2n+1 < 2^n` does not make any sense. According to the Coq code, you want to prove `2n+1 < 2^n -> n >=3`. Shouldn't it be the other way around? – eponier Sep 17 '18 at 15:47
  • Just thought it might be worth mentioning that you can do all those `destruct n`'s in one step if you do `intros [|[|[|n]]]`. Then based on what you've already written, `intros [|[|[|n]]]; try (compute; intro H; inversion H).` should be able to create and then immediately clear the `n=0,1,2` cases. – tlon Sep 19 '18 at 16:13

2 Answers2

1

Well, as this is homework I cannot help you a lot. Just let me write down the lemma you pose in math-comp, which already allows for the use of a sane notation:

Theorem two_n_plus_one_leq_three_lt_wo_pow_n n :
  2*n.+1 < 2^n -> 3 <= n.
ejgallego
  • 6,709
  • 1
  • 14
  • 29
  • I tried using Ssreflect but since I'm not familiar with it yet, I decided to rewrite in the _manual_ less natural notation. Thank you anyway @ejgallego – user454322 Sep 18 '18 at 05:50
1

The important part missing was making the inductive hypothesis general. I was able to complete the proof using generalize dependent k..

So the proof looks like this:

(* n ≥ 3, 2n + 1 < 2^n *)
Theorem two_n_plus_one_leq_three_lt_wo_pow_n : forall n:nat,
    (blt_nat (two_n_plus_one n) (exp 2 n)) = true
       -> (bge_nat n 3) = true.
Proof.
  intros n.
  destruct n.
  (* n = 0 *)
  compute.
  intros HF. (* Discard the cases where n is not >= 3 *)
  inversion HF.

  destruct n.
  (* n = 1 *)
  compute.
  intros HF.
  inversion HF.

  destruct n.
  (* n = 2 *)
  compute.
  intros HF.
  inversion HF.

  induction n as [ | k IHk].
  (* n = 3 *)
  - compute.
    reflexivity.
  (* n+1 inductive step *)
  - generalize dependent k.
    intros.
    compute.
    reflexivity.
Qed.
user454322
  • 7,300
  • 5
  • 41
  • 52
  • 1
    Two big problems in your solution. First, as stated in my first comment, you're trying to prove `forall n, 2n+1 < 2^n -> n >= 3`, but according to your edit, what you really want to prove is `forall n, n >= 3 -> 2n+1 < 2^n`. Second, assume that you really want to prove `forall n, 2n+1 < 2^n -> n >= 3`, then you don't need induction. All you have to do is to test that with `n = 0, 1, 2` the hypothesis is contradictory. In the other cases, we obviously have `n >= 3`. – eponier Sep 18 '18 at 12:52
  • @eponier Thanks for commenting and looking at the proof. **1)** This is a proof of _For all integers n ≥ 3, 2n + 1 < 2^n._ I think this translates in coq to `forall n, 2n+1 < 2^n -> n >= 3`. **2)** Induction is required for this exercise, it comes from proposition 5.3.2 of "Discrete Mathematics with Applications" by Susanna S. Epp – user454322 Sep 18 '18 at 13:13
  • 1
    I don't get how you read `forall n, 2n+1 < 2^n -> n >= 3`. As usual, this means: "forall n, if 2n+1 < 2^n, then n >= 3" and this is *not* what you want to prove. Surely you need induction for the initial problem, but not for this one. – eponier Sep 18 '18 at 13:20
  • @eponier is correct. If you are proving the English statement, *For all integers n >= 3, 2 n + 1 < 2^n*, the correct Coq translation is `forall n, n >= 3 -> 2*n+1 < 2^n`. – K. A. Buhr Sep 19 '18 at 19:07