tactics
This commit is contained in:
parent
d1b5dd85a7
commit
a840436701
1 changed files with 67 additions and 1 deletions
68
tactics.lean
68
tactics.lean
|
@ -2,8 +2,74 @@
|
||||||
-- 5. Tactics
|
-- 5. Tactics
|
||||||
--
|
--
|
||||||
|
|
||||||
--
|
-- Entering Tactic Mode
|
||||||
|
|
||||||
theorem test (p q : Prop) (hp : p) (hq : q) : p ∧ q ∧ p := by
|
theorem test (p q : Prop) (hp : p) (hq : q) : p ∧ q ∧ p := by
|
||||||
apply And.intro
|
apply And.intro
|
||||||
exact hp
|
exact hp
|
||||||
exact { left := hq, right := hp }
|
exact { left := hq, right := hp }
|
||||||
|
|
||||||
|
#print test
|
||||||
|
|
||||||
|
example (hp : p) (hq : q) : p ∧ q ∧ p := by
|
||||||
|
apply And.intro hp
|
||||||
|
exact And.intro hq hp
|
||||||
|
|
||||||
|
example (hp : p) (hq : q) : p ∧ q ∧ p := by
|
||||||
|
apply And.intro
|
||||||
|
case left => exact hp
|
||||||
|
case right =>
|
||||||
|
apply And.intro
|
||||||
|
case left => exact hq
|
||||||
|
case right => exact hp
|
||||||
|
|
||||||
|
example (hp : p) (hq : q) : p ∧ q ∧ p := by
|
||||||
|
apply And.intro
|
||||||
|
. exact hp
|
||||||
|
. apply And.intro
|
||||||
|
. exact hq
|
||||||
|
. exact hp
|
||||||
|
|
||||||
|
-- Basic Tactics
|
||||||
|
|
||||||
|
example (p q r : Prop) : p ∧ (q ∨ r) ↔ (p ∧ q) ∨ (p ∧ r) := by
|
||||||
|
apply Iff.intro
|
||||||
|
. intro h
|
||||||
|
apply Or.elim (And.right h)
|
||||||
|
. intro hq
|
||||||
|
apply Or.inl
|
||||||
|
apply And.intro
|
||||||
|
. exact And.left h
|
||||||
|
. exact hq
|
||||||
|
. intro hr
|
||||||
|
apply Or.inr
|
||||||
|
apply And.intro
|
||||||
|
. exact And.left h
|
||||||
|
. exact hr
|
||||||
|
. intro h
|
||||||
|
apply Or.elim h
|
||||||
|
. intro hpq
|
||||||
|
apply And.intro
|
||||||
|
. exact And.left hpq
|
||||||
|
. apply Or.inl
|
||||||
|
exact And.right hpq
|
||||||
|
. intro hpr
|
||||||
|
apply And.intro
|
||||||
|
. exact And.left hpr
|
||||||
|
. apply Or.inr
|
||||||
|
exact And.right hpr
|
||||||
|
|
||||||
|
example (α : Type) (p q : α → Prop) : (∃ x, p x ∧ q x) → ∃ x, q x ∧ p x := by
|
||||||
|
intro ⟨w, hpq⟩
|
||||||
|
exact ⟨w, hpq.symm⟩
|
||||||
|
|
||||||
|
example (α : Type) (p q : α → Prop) : (∃ x, p x ∧ q x) → ∃ x, q x ∧ p x := by
|
||||||
|
intro ⟨w, hp, hq⟩
|
||||||
|
exact ⟨w, hq, hp⟩
|
||||||
|
|
||||||
|
example (α : Type) (p q : α → Prop) : (∃ x, p x ∧ q x) → ∃ x, q x ∧ p x := by
|
||||||
|
intro ⟨w, hp, hq⟩
|
||||||
|
apply Exists.intro
|
||||||
|
case w => exact w
|
||||||
|
case h =>
|
||||||
|
exact ⟨hq, hp⟩
|
||||||
|
|
Loading…
Add table
Reference in a new issue