-
Notifications
You must be signed in to change notification settings - Fork 1
/
Prueba_por_induccion_3.lean
100 lines (84 loc) · 2.55 KB
/
Prueba_por_induccion_3.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
-- Prueba por inducción 3: ∀ m n : ℕ, succ m + n = succ (m + n)
-- ============================================================
-- ----------------------------------------------------
-- Ej. 1. Sean m y n números naturales. Demostrar que
-- succ m + n = succ (m + n)
-- ----------------------------------------------------
import tactic
open nat
variables (m n : ℕ)
-- 1ª demostración
example : succ m + n = succ (m + n) :=
begin
induction n with n HI,
{ rw nat.add_zero,
rw nat.add_zero, },
{ rw add_succ,
rw HI, },
end
-- 2ª demostración
example : succ m + n = succ (m + n) :=
begin
induction n with n HI,
{ simp only [nat.add_zero], },
{ simp only [add_succ, HI], },
end
-- 3ª demostración
example : succ m + n = succ (m + n) :=
by induction n;
simp only [*, nat.add_zero, add_succ]
-- 4ª demostración
example : succ m + n = succ (m + n) :=
by induction n;
simp [*, add_succ]
-- 5ª demostración
example : succ m + n = succ (m + n) :=
nat.rec_on n
(show succ m + 0 = succ (m + 0), from
calc
succ m + 0
= succ m : by rw nat.add_zero
... = succ (m + 0) : by rw nat.add_zero)
(assume n,
assume HI : succ m + n = succ (m + n),
show succ m + succ n = succ (m + succ n), from
calc
succ m + succ n
= succ (succ m + n) : by rw add_succ
... = succ (succ (m + n)) : by rw HI
... = succ (m + succ n) : by rw add_succ)
-- 6ª demostración
example : succ m + n = succ (m + n) :=
nat.rec_on n
(show succ m + 0 = succ (m + 0), from rfl)
(assume n,
assume HI : succ m + n = succ (m + n),
show succ m + succ n = succ (m + succ n), from
calc
succ m + succ n
= succ (succ m + n) : rfl
... = succ (succ (m + n)) : by rw HI
... = succ (m + succ n) : rfl)
-- 7ª demostración
example : succ m + n = succ (m + n) :=
nat.rec_on n rfl (λ n HI, by simp only [add_succ, HI])
-- 8ª demostración
example : succ m + n = succ (m + n) :=
-- by library_search
succ_add m n
-- 9ª demostración
example : succ m + n = succ (m + n) :=
-- by hint
by omega
-- 10ª demostración
lemma suc_suma : ∀ n m : ℕ, (succ n) + m = succ (n + m)
| n 0 := rfl
| n (m+1) := congr_arg succ (suc_suma n m)
-- 11ª demostración
lemma suc_suma2 : ∀ n m : ℕ, (succ n) + m = succ (n + m)
| n 0 := by simp
| n (m+1) := by simp [add_succ, suc_suma2 n m]
-- 12ª demostración
lemma suc_suma3 : ∀ n m : ℕ, (succ n) + m = succ (n + m)
| n 0 := by simp only [add_zero]
| n (m+1) := by simp only [add_zero, add_succ, suc_suma3 n m]