Skip to content

Commit 1022b56

Browse files
author
Trequetrum
committed
Iff Redux
1 parent dba1a0a commit 1022b56

File tree

5 files changed

+128
-7
lines changed

5 files changed

+128
-7
lines changed

Game/Doc/Tactics.lean

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,36 +150,92 @@ For example, if your goal is `P ∧ Q` then the `constructor` tactic will replac
150150
TacticDoc constructor
151151

152152
/--
153-
TODO
153+
# Conjunction/Biconditional
154+
`cases` will deconstruct an `∧` or an `↔` into it's parts, removing the assumption and replacing it with two new assumptions.
155+
# Disjunction
156+
Used with an `∨` cases will split the main goal, replacing it with a goal for each of the two possibilities.
154157
-/
155158
TacticDoc cases
156159

157160
/--
158-
TODO
161+
# It suffices to show
162+
To prove `Q` by `P → Q`, it suffices to show `P`.
163+
### More Generally
164+
To prove `Q` by `P₁ → P₂ → P₃ → ... → Q`, it suffices to show `P₁, P₂, P₃, ...`. One way to convince yourself this is true is to prove that `(P₁ → P₂ → Q) → (P₁ ∧ P₂ → Q)` and convince yourself there exists a procedure for any `(P₁ → P₂ → ... → Q) → (P₁ ∧ P₂ ∧ ... → Q)`
165+
### In Practice
166+
The `apply` tactic returns as many subgoals as the number of premises that have not been fixed by the Goal.
167+
### Example:
168+
If you have:
169+
```
170+
Assumptions:
171+
h : P → Q
172+
Goal : Q
173+
```
174+
then `apply h` will change your proof state to:
175+
```
176+
Assumptions:
177+
h : P → Q
178+
Goal : P
179+
```
159180
-/
160181
TacticDoc apply
161182

162183
/--
163-
TODO
184+
# Sub-Proof
185+
If your Goal is an implication, this tactic introduces one or more hypotheses, optionally naming and/or pattern-matching them.
186+
187+
The effect on a goal like `P → Q` is to add `P` as an assumption and change the Goal to `Q`. If the implication is already a part of a sub-proof, then once you show evidence for `Q`, the assumption `P` is discharged and can not be used for the rest of the proof.
188+
189+
This is is the interactive way of defining a function using tactics. You can think of discharging an assumption as the same as parameters being limited in scope to the function's body/definition.
164190
-/
165191
TacticDoc intro
166192

167193
/--
168-
TODO
194+
contradiction closes the current goal there are assumptions which are "trivially contradictory".
195+
196+
### Example
197+
```
198+
Assumptions:
199+
h : False
200+
```
201+
### Example
202+
```
203+
Assumptions:
204+
h₁ : P
205+
h₂ : ¬P
206+
```
169207
-/
170208
TacticDoc contradiction
171209

172210
/--
173-
TODO
211+
Change the goal to `False`. This is only helpful when there are assumptions which are in some way contradictory.
212+
### Example
213+
```
214+
Assumptions
215+
h : P ∧ ¬P
216+
Goal: Q
217+
```
218+
I cannot show evidence for `Q` directly, but because `False → Q` is trivially true (False implies anything), I can use the tactic `exfalso` which changes the Goal:
219+
```
220+
Assumptions
221+
h : P ∧ ¬P
222+
Goal: Q
223+
```
224+
After which `exact h.right r.left` meets the current goal.
225+
### Apply
226+
`exfalso` is the same as `apply false_elim`.
227+
∴ to show `Q` by `False → Q`, it suffices to show `False`.
174228
-/
175229
TacticDoc exfalso
176230

177231
/--
178-
TODO
232+
# Show a Disjunction
233+
Evidence for `P ∨ Q` can be created in two ways. `left` changes the goal to `P` while `right` changes the goal to `Q`.
179234
-/
180235
TacticDoc left
181236

182237
/--
183-
TODO
238+
# Show a Disjunction
239+
Evidence for `P ∨ Q` can be created in two ways. `left` changes the goal to `P` while `right` changes the goal to `Q`.
184240
-/
185241
TacticDoc right

Game/Levels/IffIntro.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Game.Levels.IffIntro.L03
44
import Game.Levels.IffIntro.L04
55
import Game.Levels.IffIntro.L05
66
import Game.Levels.IffIntro.L06
7+
import Game.Levels.IffIntro.L07
78

89
World "IffIntro"
910
Title "↔ Tutorial: Party Games"

Game/Levels/IffIntro/L07.lean

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Game.Metadata
2+
3+
namespace GameLogic
4+
5+
World "IffIntro"
6+
Level 7
7+
Title "IffBoss"
8+
9+
OnlyTactic
10+
exact
11+
«have»
12+
rw
13+
«repeat»
14+
nth_rewrite
15+
16+
Introduction "
17+
# BOSS LEVEL
18+
This is an involved level. It doesn't require you to do anything tricky, but there are a lot of moving parts and it is easy to lose track of what you're doing.
19+
"
20+
21+
Statement (P Q R : Prop): (P ∧ Q ↔ R ∧ Q) ↔ Q → (P ↔ R) := by
22+
exact ⟨
23+
λ⟨pr,rp⟩ q ↦ ⟨λp ↦ (pr ⟨p,q⟩).left, λr ↦ (rp ⟨r,q⟩).left⟩,
24+
λqpr ↦ ⟨λ⟨p,q⟩ ↦ ⟨(qpr q).mp p, q⟩, λ⟨r,q⟩ ↦ ⟨(qpr q).mpr r, q⟩⟩
25+

Game/Levels/IffTactic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Game.Levels.IffTactic.L03
44
import Game.Levels.IffTactic.L04
55
import Game.Levels.IffTactic.L05
66
import Game.Levels.IffTactic.L06
7+
import Game.Levels.IffTactic.L07
78

89
World "IffTactic"
910
Title "Redux: ↔ World Tactics"

Game/Levels/IffTactic/L07.lean

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Game.Metadata
2+
3+
namespace GameLogic
4+
5+
World "IffTactic"
6+
Level 7
7+
Title "IffBoss"
8+
9+
Introduction "
10+
# BOSS LEVEL
11+
This is an involved level. Tactics can be especially helpful in that much of the bookkeeping is done on your behalf. Good luck.
12+
"
13+
14+
Statement (P Q R : Prop): (P ∧ Q ↔ R ∧ Q) ↔ Q → (P ↔ R) := by
15+
constructor
16+
intro ⟨pr, rp⟩
17+
intro q
18+
constructor
19+
intro p
20+
apply and_left
21+
apply pr
22+
constructor
23+
repeat assumption
24+
intro r
25+
apply and_left
26+
apply rp
27+
constructor
28+
repeat assumption
29+
intro qpr
30+
constructor
31+
intro ⟨p,q⟩
32+
rw [← qpr q]
33+
constructor
34+
repeat assumption
35+
intro ⟨r,q⟩
36+
rw [qpr q]
37+
constructor
38+
repeat assumption

0 commit comments

Comments
 (0)