forked from ImperialCollegeLondon/M40001_lean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sheet3.lean
120 lines (88 loc) · 2.3 KB
/
sheet3.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
/-
Copyright (c) 2021 Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author : Kevin Buzzard
-/
import tactic -- imports all the Lean tactics
/-!
# Logic in Lean, example sheet 3 : "not" (`¬`)
We learn about how to manipulate `¬ P` in Lean.
# Important : the definition of `¬ P`
In Lean, `¬ P` is *defined* to mean `P → false`. So `¬ P` and `P → false`
are *the same thing* and can be used interchangeably. You can change
from one to the other for free.
## Tactics
You'll need to know about the tactics from the previous sheets,
and also the following tactics:
* `change` (optional)
* `by_contra`
* `by_cases`
### The `change` tactic
The `change` tactic changes a goal to a goal which
is *equal to it by definition*. The example you need to know
is that `¬ P` and `P → false` are equal by definition.
If your goal is `⊢ ¬ P` then `change P → false,` will
change it to `P → false`. Similarly if you have a hypothesis
`h : ¬ P` then `change P → false at h,` will change it to `h : P → false`.
Note that this tactic is just for psychological purposes. If you finish
a proof which uses this tactic, try commenting out the `change` lines
and note that it doesn't break.
### The `by_contra` tactic
If your goal is `⊢ P` and you want to prove it by contradiction,
`by_contra h,` will change the goal to `false` and add a hypothesis
`h : ¬ P`.
### The `by_cases` tactic
If `P : Prop` is a true-false statement then `by_cases hP : P,`
turns your goal into two goals, one with hypothesis `hP : P`
and the other with hypothesis `hP : ¬ P`.
-/
-- Throughout this sheet, `P`, `Q` and `R` will denote propositions.
variables (P Q R : Prop)
example : ¬ P → (P → false) :=
begin
sorry,
end
example : ¬ true → false :=
begin
sorry
end
example : false → ¬ true :=
begin
sorry
end
example : ¬ false → true :=
begin
sorry
end
example : true → ¬ false :=
begin
sorry
end
example : false → ¬ P :=
begin
sorry
end
example : P → ¬ P → false :=
begin
sorry
end
example : P → ¬ (¬ P) :=
begin
sorry
end
example : (P → Q) → (¬ Q → ¬ P) :=
begin
sorry
end
example : ¬ ¬ false → false :=
begin
sorry
end
example : ¬ ¬ P → P :=
begin
sorry
end
example : (¬ Q → ¬ P) → (P → Q) :=
begin
sorry,
end