Zulip Chat Archive

Stream: new members

Topic: mixing real and natural numbers


Jayden Vap (Jun 04 2021 at 15:31):

Hello, I am new to Lean, and I am attempting to do an inductive proof. The variable that I am doing induction on is a natural number, but in one part of the equation, the variable is seen as a real number because it is being multiplied to a real number. For the base case, is there a way to have lean read that variable as a natual number so it can be reduced? I hope this makes sense, thank you

Ruben Van de Velde (Jun 04 2021 at 15:32):

I don't follow - can you paste a #mwe?

Jayden Vap (Jun 04 2021 at 15:35):

theorem inductionProblemV1
(m: ℕ) (x: ℝ) (hn: m >=2) (h1x: x >-1)(h2x: x ≠ 0): (1+x)^(m+2)> 1 + (m+2)*x :=

Mario Carneiro (Jun 04 2021 at 15:36):

See the #mwe page, and #backticks

David Renshaw (Jun 04 2021 at 15:39):

If you want spoilers on how mathlib proves a similar inequality: https://leanprover-community.github.io/mathlib_docs/algebra/group_power/lemmas.html#one_add_mul_le_pow

Jayden Vap (Jun 04 2021 at 15:39):

theorem  inductionProblemV1
 (m: ) (x: ) (hn: m >=2) (h1x: x >-1)(h2x: x  0): (1+x)^(m+2)> 1 + (m+2)*x :=

Eric Wieser (Jun 04 2021 at 15:46):

Does induction m not work as a first step?

Jayden Vap (Jun 04 2021 at 16:03):

It does, but I am having difficulty reducing m on the righr side of the inequality for the base case because 0 is a real number in this case... maybe theres a simple solution but zero_add does not work when 0 is a real

Gihan Marasingha (Jun 04 2021 at 16:04):

For the base case, I'd just use the linarith tactic (unless you think that's cheating).

Mario Carneiro (Jun 04 2021 at 16:23):

Here's an #mwe with a bit more progress:

import data.real.basic

theorem inductionProblemV1
  (m: ) (x: ) (hn: m  2) (h1x: x > -1) (h2x: x  0) : (1+x)^(m+2)> 1 + (m+2)*x :=
begin
  induction m,
  { simp,
    -- ⊢ 1 + 2 * x < (1 + x) ^ 2
    sorry },
  { sorry }
end

Mario Carneiro (Jun 04 2021 at 16:23):

simp cleans up the coercion in the zero case

Huỳnh Trần Khanh (Jun 04 2021 at 16:27):

norm_num should work right? like norm_num should clean up the coercions right

Huỳnh Trần Khanh (Jun 04 2021 at 16:27):

but yeah I'd just use a sledgehammer (ring, linarith, simp) to demolish the base case

Kevin Buzzard (Jun 04 2021 at 16:28):

I am suspicious about the hypothesis m>=2 and the occurrences of m+2 in the goal. Are we sure we're proving the correct statement here?

Kevin Buzzard (Jun 04 2021 at 16:28):

For example the statement seems to be true for m=0

Gihan Marasingha (Jun 04 2021 at 16:50):

@Kevin Buzzard I proved the result and my first step was clear hn. Otherwise this messes up the induction!

Jayden Vap (Jun 04 2021 at 16:56):

It should be m=0, my mistake

Kevin Buzzard (Jun 04 2021 at 16:58):

Please post an #mwe to explain precisely what you mean.

Gihan Marasingha (Jun 04 2021 at 17:01):

This can be filled in, but linarith no longer solves the base case:

 theorem  inductionProblemV1 (m : ) (x : ) (hn : 2  m)
  (h1x : -1 < x) (h2x : x  0) : (1 + x)^(m + 2) > 1 + (m + 2) * x :=
 begin
    clear hn,
    induction m with k ih,
    { sorry },
    { sorry },
 end

Shadman Sakib (Jun 04 2021 at 21:25):

what is the distribution command on lean vs?
for something like (a+b) *(a-b)

Adam Topaz (Jun 04 2021 at 21:29):

@Shadman Sakib toward the bottom of the zulip window, you will see a "new topic" button. Please use that to create a new topic for this question (in the new members stream)

Eric Wieser (Jun 04 2021 at 21:37):

Or better yet, click the edit (pencil?) icon and edit your message title to something new

Eric Wieser (Jun 04 2021 at 21:58):

@Bryan Gin-ge Chen mind moving these messages too?


Last updated: Dec 20 2023 at 11:08 UTC