-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProofs_of_(1+p)^n_ge_1+np.lean
123 lines (110 loc) · 3.45 KB
/
Proofs_of_(1+p)^n_ge_1+np.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
-- Proofs_of_(1+p)^n_ge_1+np.lean
-- Proofs of "If p > -1, then (1+p)ⁿ ≥ 1+np"
-- José A. Alonso Jiménez <https://jaalonso.github.io>
-- Seville, September 12, 2024
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
-- Let p ∈ ℝ and n ∈ ℕ. Prove that if p > -1, then
-- (1 + p)^n ≥ 1 + n*p
-- ---------------------------------------------------------------------
-- Proof in natural language
-- =========================
-- By induction on n.
--
-- Base case: Let n = 0. Then,
-- (1+p)^n = (1+p)^0
-- = 1
-- ≥ 1
-- = 1 + 0
-- = 1 + 0·p
-- = 1 + n·p
--
-- Induction step: Let n = m+1 and assume the induction hypothesis
-- (IH)
-- (1 + p)^m ≥ 1 + mp
-- Then,
-- (1 + p)^n = (1 + p)^(m+1)
-- = (1 + p)^m(1 + p)
-- ≥ (1 + m * p)(1 + p) [by IH]
-- = (1 + p + mp) + m(pp)
-- ≥ 1 + p + mp
-- = 1 + (m + 1)p
-- = 1 + np
-- Proof with Lean4
-- ================
import Mathlib.Data.Real.Basic
import Mathlib.Tactic
open Nat
variable (p : ℝ)
variable (n : ℕ)
-- Proof 1
-- =======
example
(h : p > -1)
: (1 + p)^n ≥ 1 + n*p :=
by
induction n with
| zero =>
-- ⊢ (1 + p) ^ 0 ≥ 1 + ↑0 * p
have h1 : (1 + p) ^ 0 ≥ 1 + 0 * p :=
calc (1 + p) ^ 0
= 1 := pow_zero (1 + p)
_ ≥ 1 := le_refl 1
_ = 1 + 0 := (add_zero 1).symm
_ = 1 + 0 * p := congrArg (1 + .) (zero_mul p).symm
exact_mod_cast h1
| succ m IH =>
-- m : ℕ
-- IH : (1 + p) ^ m ≥ 1 + ↑m * p
-- ⊢ (1 + p) ^ (m + 1) ≥ 1 + ↑(m + 1) * p
have h1 : 1 + p > 0 := neg_lt_iff_pos_add'.mp h
have h2 : p*p ≥ 0 := mul_self_nonneg p
replace h2 : ↑m*(p*p) ≥ 0 := mul_nonneg (cast_nonneg m) h2
calc (1 + p)^(m+1)
= (1 + p)^m * (1 + p)
:= pow_succ (1 + p) m
_ ≥ (1 + m * p) * (1 + p)
:= (mul_le_mul_right h1).mpr IH
_ = (1 + p + m*p) + m*(p*p)
:= by ring
_ ≥ 1 + p + m*p
:= le_add_of_nonneg_right h2
_ = 1 + (m + 1) * p
:= by ring
_ = 1 + ↑(m+1) * p
:= by norm_num
-- Proof 2
-- =======
example
(h : p > -1)
: (1 + p)^n ≥ 1 + n*p :=
by
induction n with
| zero =>
-- ⊢ (1 + p) ^ 0 ≥ 1 + ↑0 * p
simp
| succ m IH =>
-- m : ℕ
-- IH : (1 + p) ^ m ≥ 1 + ↑m * p
-- ⊢ (1 + p) ^ (m + 1) ≥ 1 + ↑(m + 1) * p
calc (1 + p)^(m+1)
= (1 + p)^m * (1 + p) := by rfl
_ ≥ (1 + m * p) * (1 + p) := by nlinarith
_ = (1 + p + m*p) + m*(p*p) := by ring
_ ≥ 1 + p + m*p := by nlinarith
_ = 1 + (m + 1) * p := by ring
_ = 1 + ↑(m+1) * p := by norm_num
-- Used lemmas
-- ===========
-- variable (a b c : ℝ)
-- #check (add_zero a : a + 0 = a)
-- #check (cast_nonneg n : 0 ≤ ↑n)
-- #check (le_add_of_nonneg_right : 0 ≤ b → a ≤ a + b)
-- #check (le_refl a : a ≤ a)
-- #check (mul_le_mul_right : 0 < a → (b * a ≤ c * a ↔ b ≤ c))
-- #check (mul_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a * b)
-- #check (mul_self_nonneg a : 0 ≤ a * a)
-- #check (neg_lt_iff_pos_add' : -a < b ↔ 0 < a + b)
-- #check (pow_succ a n : a ^ (n + 1) = a ^ n * a)
-- #check (pow_zero a : a ^ 0 = 1)
-- #check (zero_mul a : 0 * a = 0)