-
Notifications
You must be signed in to change notification settings - Fork 1
/
Igualdad_de_cuadrados.lean
102 lines (92 loc) · 2.87 KB
/
Igualdad_de_cuadrados.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
-- ---------------------------------------------------------------------
-- Ejercicio 1. Realizar las siguientes acciones:
-- 1. Importar la teoría de números reales.
-- 2. Declarar x e y como variables sobre los reales.
-- ----------------------------------------------------------------------
import data.real.basic -- 1
variables (x y : ℝ) -- 2
-- ---------------------------------------------------------------------
-- Ejercicio 2. Demostrar que si
-- x^2 = 1
-- entonces
-- x = 1 ∨ x = -1
-- ----------------------------------------------------------------------
example
(h : x^2 = 1)
: x = 1 ∨ x = -1 :=
begin
have h1 : (x - 1) * (x + 1) = 0,
calc (x - 1) * (x + 1) = x^2 - 1 : by ring
... = 1 - 1 : by rw h
... = 0 : by ring,
have h2 : x - 1 = 0 ∨ x + 1 = 0,
{ apply eq_zero_or_eq_zero_of_mul_eq_zero h1 },
cases h2,
{ left,
exact sub_eq_zero.mp h2 },
{ right,
exact eq_neg_of_add_eq_zero h2 },
end
-- Prueba
-- ======
/-
x : ℝ,
h : x ^ 2 = 1
⊢ x = 1 ∨ x = -1
>> have h1 : (x - 1) * (x + 1) = 0,
>> calc (x - 1) * (x + 1) = x^2 - 1 : by ring
>> ... = 1 - 1 : by rw h
>> ... = 0 : by ring,
h1 : (x - 1) * (x + 1) = 0
⊢ x = 1 ∨ x = -1
>> have h2 : x - 1 = 0 ∨ x + 1 = 0,
>> { apply eq_zero_or_eq_zero_of_mul_eq_zero h1 },
h2 : x - 1 = 0 ∨ x + 1 = 0
⊢ x = 1 ∨ x = -1
>> cases h2,
| h2 : x - 1 = 0
| ⊢ x = 1 ∨ x = -1
| >> { left,
| ⊢ x = 1
| >> exact sub_eq_zero.mp h2 },
h2 : x + 1 = 0
⊢ x = 1 ∨ x = -1
>> { right,
⊢ x = -1
>> exact eq_neg_of_add_eq_zero h2 },
no goals
-/
-- Comentario: Se han usado los siguientes lemas
-- + eq_zero_or_eq_zero_of_mul_eq_zero : x * y = 0 → x = 0 ∨ y = 0
-- + sub_eq_zero : x - y = 0 ↔ x = y
-- + eq_neg_of_add_eq_zero : x + y = 0 → x = -y
-- Comprobación
-- #check (@eq_zero_or_eq_zero_of_mul_eq_zero ℝ _ _ _ x y)
-- #check (@sub_eq_zero ℝ _ x y)
-- #check (@eq_neg_of_add_eq_zero ℝ _ x y)
-- ---------------------------------------------------------------------
-- Ejercicio. Demostrar si
-- x^2 = y^2
-- entonces
-- x = y ∨ x = -y
-- ----------------------------------------------------------------------
example
(h : x^2 = y^2)
: x = y ∨ x = -y :=
begin
have h1 : (x - y) * (x + y) = 0,
calc (x - y) * (x + y) = x^2 - y^2 : by ring
... = y^2 - y^2 : by rw h
... = 0 : by ring,
have h2 : x - y = 0 ∨ x + y = 0,
{ apply eq_zero_or_eq_zero_of_mul_eq_zero h1 },
cases h2,
{ left,
exact sub_eq_zero.mp h2 },
{ right,
exact eq_neg_of_add_eq_zero h2 },
end
-- Comentario: Se han usado los siguientes lemas
-- + eq_zero_or_eq_zero_of_mul_eq_zero : x * y = 0 → x = 0 ∨ y = 0
-- + sub_eq_zero : x - y = 0 ↔ x = y
-- + eq_neg_of_add_eq_zero : x + y = 0 → x = -y