91 lines
2.0 KiB
Markdown
91 lines
2.0 KiB
Markdown
# Unit 3 — Propositions and Proofs
|
||
|
||
**Tutorial 1: Lean 4 Fundamentals** · [← Back to README](../README.md)
|
||
|
||
## Goals
|
||
|
||
- Understand propositions as types (Curry-Howard)
|
||
- Write basic proofs using `example` and `theorem`
|
||
- Use the tactic language: `intro`, `apply`, `exact`, `have`
|
||
|
||
## Source
|
||
|
||
*Theorem Proving in Lean 4* (TPIL), Chapters 2–3
|
||
→ https://leanprover.github.io/theorem_proving_in_lean4/
|
||
|
||
## Concepts
|
||
|
||
| Concept | Lean |
|
||
|---------|------|
|
||
| Proposition | `P : Prop` — a type whose terms are proofs |
|
||
| Implication `P → Q` | Function from proofs of `P` to proofs of `Q` |
|
||
| Conjunction `P ∧ Q` | `And.intro` (constructor), `.left` / `.right` (projections) |
|
||
| Disjunction `P ∨ Q` | `Or.inl` / `Or.inr` |
|
||
| Negation `¬ P` | `P → False` |
|
||
| Tactics | `intro`, `apply`, `exact`, `have`, `assumption` |
|
||
|
||
## Exercises
|
||
|
||
### Exercise 3.1 — Implicational logic
|
||
|
||
```lean
|
||
-- (a) Identity
|
||
theorem id_prop (A : Prop) : A → A :=
|
||
by
|
||
intro h
|
||
exact h
|
||
|
||
-- (b) Composition
|
||
theorem compose (A B C : Prop) : (A → B) → (B → C) → (A → C) :=
|
||
by
|
||
sorry
|
||
|
||
-- (c) Currying
|
||
theorem curry (A B C : Prop) : (A → B → C) → (A ∧ B → C) :=
|
||
by
|
||
sorry
|
||
```
|
||
|
||
### Exercise 3.2 — Conjunction and disjunction
|
||
|
||
```lean
|
||
-- (a) Swap conjuncts
|
||
theorem and_comm (A B : Prop) : A ∧ B → B ∧ A :=
|
||
by
|
||
sorry
|
||
|
||
-- (b) Disjunction is symmetric
|
||
theorem or_comm (A B : Prop) : A ∨ B → B ∨ A :=
|
||
by
|
||
sorry
|
||
|
||
-- (c) Forward reasoning with `have`
|
||
theorem forward_example (A B C : Prop) (h1 : A → B) (h2 : B → C) (ha : A) : C :=
|
||
by
|
||
have hb : B := h1 ha
|
||
sorry
|
||
```
|
||
|
||
### Exercise 3.3 — Negation
|
||
|
||
```lean
|
||
-- (a) Contradiction
|
||
theorem contrapositive (A B : Prop) : (A → B) → (¬ B → ¬ A) :=
|
||
by
|
||
sorry
|
||
|
||
-- (b) Double negation introduction
|
||
theorem double_neg_intro (A : Prop) : A → ¬ ¬ A :=
|
||
by
|
||
sorry
|
||
|
||
-- (c) Ex falso quodlibet
|
||
theorem ex_falso (A : Prop) : False → A :=
|
||
by
|
||
sorry
|
||
```
|
||
|
||
---
|
||
|
||
← [Previous: Unit 2](02-inductive-types.md) · Next: [Unit 4 — Quantifiers and Equality](04-quantifiers-and-equality.md)
|