Learning materials and exercises for theorem proving and formal logic using the Lean 4 proof assistant.
This repository contains coursework and exercises focused on:
- Propositional logic and natural deduction
- Formal proof construction in Lean 4
- First-order logic reasoning
- Mathematical theorem proving
-
lean_inference_rules.md- Comprehensive reference table of inference rules in Lean 4, covering:- Implication (→-Intro, →-Elim, Modus Tollens)
- Conjunction (∧-Intro, ∧-Elim)
- Disjunction (∨-Intro, ∨-Elim)
- Negation (¬-Intro, ¬-Elim)
- Biconditional (↔-Intro, ↔-Elim)
- Universal quantification (∀-Intro, ∀-Elim)
- Existential quantification (∃-Intro, ∃-Elim)
- Each rule shown in both term mode and tactic mode
-
lean_inference_rules_printable.pdf- Printable reference card for inference rules
-
assessment1.lean- Main assessment file working with axioms and proof construction- Custom axioms for conjunction operations
- Proofs involving
provablepredicates - Exercises on contradiction, conjunction rearrangement, and negation
-
assessment.experiments.lean- Experimental work related to assessments
unit3.l1.lean- Unit 3, Lesson 1 exercisesunit3.l2.lean- Unit 3, Lesson 2 exercisesunit3.l3.lean- Unit 3, Lesson 3 main contentunit3.l3.examples.lean- Examples for Unit 3, Lesson 3unit3.l3.formative.lean- Formative assessment for Unit 3, Lesson 3unit3.l5.lean- Unit 3, Lesson 5 exercisesunit5.l5.formative.lean- Formative assessment for Unit 5, Lesson 5
examples.lean- Real-world AI and decision scenario examples translated into propositional logicadditionalGuidance.lean- Extra guidance on proof techniqueslearningfp.lean- Functional programming concepts in Leansimpleleanproof.lean- Basic proof examplesuniversalAndExistential.lean- Quantifier exercises
tarski.jar- Tarski's World application for logic visualization (Java)
The exercises focus on constructing proofs using natural deduction rules in Lean 4. Both term mode (direct proof construction) and tactic mode (interactive proof construction) are used throughout.
Several files work with custom axiom systems, such as:
opaque conj : Prop -> Prop -> Prop
opaque provable : Prop -> Prop
axiom AxConjElimRight : ∀ x y, provable (conj x y) -> provable y
axiom AxConjElimLeft : ∀ x y, provable (conj x y) -> provable x
axiom AxConjIntro : ∀ x y, provable x -> provable y -> provable (conj x y)These axioms define custom logical operators and their elimination/introduction rules.
- Implication introduction and elimination (Modus Ponens, Modus Tollens)
- Conjunction (introduction and both elimination rules)
- Disjunction (case analysis)
- Negation (proof by contradiction)
- Ex Falso Quodlibet (from contradiction, anything follows)
- Universal and existential quantification
The materials progress through:
- Basic propositional logic (implication, conjunction, disjunction)
- Negation and contradiction
- Natural deduction inference rules
- First-order logic with quantifiers
- Real-world scenario modeling in formal logic
- Custom axiom systems and abstract reasoning
- Lean 4 - Theorem prover and proof assistant
- Natural Deduction - Proof methodology
- First-Order Logic - Logical framework
To work with these files:
- Install Lean 4 from https://leanprover.github.io/
- Install a Lean 4-compatible editor (VS Code with Lean 4 extension recommended)
- Open any
.leanfile to see proofs and exercises - Replace
sorryplaceholders with actual proofs
-- Term mode
theorem example1 (P Q : Prop) (hp : P) (hq : Q) : P ∧ Q :=
And.intro hp hq
-- Tactic mode
theorem example2 (P Q : Prop) (hp : P) (hq : Q) : P ∧ Q := by
exact And.intro hp hqThe examples.lean file demonstrates translating real-world scenarios into formal logic, such as:
- Student grant eligibility based on competition wins or publications
- Verification by supervisors or committees
- Decision-making under multiple conditions