-
Notifications
You must be signed in to change notification settings - Fork 1
/
Desigualdades_con_calc.lean
45 lines (39 loc) · 1.21 KB
/
Desigualdades_con_calc.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
-- ---------------------------------------------------------------------
-- Ejercicio. Sean a y b números reales. Demostrar que
-- 2*a*b ≤ a^2 + b^2
-- ----------------------------------------------------------------------
import data.real.basic
import tactic
variables a b : ℝ
-- 1ª demostración
example : 2*a*b ≤ a^2 + b^2 :=
begin
have : 0 ≤ (a - b)^2 := sq_nonneg (a - b),
have : 0 ≤ a^2 - 2*a*b + b^2, by linarith,
show 2*a*b ≤ a^2 + b^2, by linarith,
end
-- 2ª demostración
example : 2*a*b ≤ a^2 + b^2 :=
begin
have h : 0 ≤ a^2 - 2*a*b + b^2,
{ calc a^2 - 2*a*b + b^2
= (a - b)^2 : by ring
... ≥ 0 : by apply pow_two_nonneg },
calc 2*a*b
= 2*a*b + 0 : by ring
... ≤ 2*a*b + (a^2 - 2*a*b + b^2) : add_le_add (le_refl _) h
... = a^2 + b^2 : by ring
end
-- 3ª demostración
example : 2*a*b ≤ a^2 + b^2 :=
begin
have : 0 ≤ a^2 - 2*a*b + b^2,
{ calc a^2 - 2*a*b + b^2
= (a - b)^2 : by ring
... ≥ 0 : by apply pow_two_nonneg },
linarith,
end
-- 4ª demostración
example : 2*a*b ≤ a^2 + b^2 :=
-- by library_search
two_mul_le_add_sq a b