-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrueba_por_induccion_5.lean
162 lines (144 loc) · 4.16 KB
/
Prueba_por_induccion_5.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
-- Prueba por inducción 5: m^(succ n) = m * m^n
-- ============================================
-- ----------------------------------------------------
-- Ej. 1. Sean m y n números naturales. Demostrar que
-- m^(succ n) = m * m^n
-- ----------------------------------------------------
import data.nat.basic
open nat
variables (m n : ℕ)
-- #check nat.pow_zero
-- #check nat.pow_succ
-- #check nat.mul_one
-- #check nat.one_mul
-- #check nat.mul_assoc
-- #check nat.mul_comm
-- 1ª demostración
example : m^(succ n) = m * m^n :=
begin
induction n with n HI,
{ rw pow_succ',
rw pow_zero,
rw nat.one_mul,
rw nat.mul_one, },
{ rw pow_succ',
rw HI,
rw nat.mul_assoc,
rw nat.mul_comm (m^n), },
end
-- 2ª demostración
example : m^(succ n) = m * m^n :=
begin
induction n with n HI,
rw [pow_succ', pow_zero, one_mul, mul_one],
rw [pow_succ', HI, mul_assoc, mul_comm (m^n)],
end
-- 3ª demostración
example : m^(succ n) = m * m^n :=
begin
induction n with n HI,
{ simp only [pow_succ', pow_zero, one_mul, mul_one]},
{ simp only [pow_succ', HI, mul_assoc, mul_comm (m^n)]},
end
-- 4ª demostración
example : m^(succ n) = m * m^n :=
by induction n;
simp only [*,
pow_succ',
pow_zero,
nat.one_mul,
nat.mul_one,
nat.mul_assoc,
nat.mul_comm]
-- 5ª demostración
example : m^(succ n) = m * m^n :=
by induction n;
simp [*,
pow_succ',
mul_comm]
-- 6ª demostración
example : m^(succ n) = m * m^n :=
begin
induction n with n HI,
{ simp, },
{ simp [pow_succ', HI],
cc, },
end
-- 7ª demostración
example : m^(succ n) = m * m^n :=
begin
induction n with n HI,
{ calc
m^(succ 0)
= m^0 * m : by rw pow_succ'
... = 1 * m : by rw pow_zero
... = m : by rw nat.one_mul
... = m * 1 : by rw nat.mul_one
... = m * m^0 : by rw pow_zero, },
{ calc
m^(succ (succ n))
= m^(succ n) * m : by rw pow_succ'
... = (m * m^n) * m : by rw HI
... = m * (m^n * m) : by rw nat.mul_assoc
... = m * m^(succ n) : by rw pow_succ', },
end
-- 8ª demostración
example : m^(succ n) = m * m^n :=
nat.rec_on n
(show m^(succ 0) = m * m^0, from calc
m^(succ 0) = m^0 * m : by rw pow_succ'
... = 1 * m : by rw pow_zero
... = m : by rw one_mul
... = m * 1 : by rw mul_one
... = m * m^0 : by rw pow_zero)
(assume n,
assume HI : m^(succ n) = m * m^n,
show m^(succ (succ n)) = m * m^(succ n), from calc
m^(succ (succ n)) = m^(succ n) * m : by rw pow_succ'
... = (m * m^n) * m : by rw HI
... = m * (m^n * m) : by rw mul_assoc
... = m * m^(succ n) : by rw pow_succ')
-- 9ª demostración
example : m^(succ n) = m * (m^n) :=
nat.rec_on n
(show m^(succ 0) = m * m^0,
by rw [pow_succ', pow_zero, mul_one, one_mul])
(assume n,
assume HI : m^(succ n) = m * m^n,
show m^(succ (succ n)) = m * m^(succ n),
by rw [pow_succ', HI, mul_assoc, mul_comm (m^n)])
-- 10ª demostración
example : m^(succ n) = m * (m^n) :=
nat.rec_on n
(show m^(succ 0) = m * m^0,
by simp )
(assume n,
assume HI : m^(succ n) = m * m^n,
show m^(succ (succ n)) = m * m^(succ n),
by finish [pow_succ', HI] )
-- 11ª demostración
example : m^(succ n) = m * (m^n) :=
nat.rec_on n
(by simp)
(λ n HI, by finish [pow_succ', HI])
-- 12ª demostración
lemma aux : ∀ m n : ℕ, m^(succ n) = m * (m^n)
| m 0 := by simp
| m (n+1) := by simp [pow_succ',
aux m n,
mul_assoc,
mul_comm (m^n)]
-- 13ª demostración
lemma aux2 : ∀ m n : ℕ, m^(succ n) = m * (m^n)
| m 0 := by simp only [pow_succ',
pow_zero,
one_mul,
mul_one]
| m (n+1) := by simp only [pow_succ',
aux2 m n,
mul_assoc,
mul_comm (m^n)]
-- 14ª demostración
lemma aux3 : ∀ m n : ℕ, m^(succ n) = m * (m^n)
| m 0 := by simp
| m (n+1) := by simp [pow_succ', aux3 m n] ; cc