Logic and Proof Release 3.18.4
Total Page:16
File Type:pdf, Size:1020Kb
Logic and Proof Release 3.18.4 Jeremy Avigad, Robert Y. Lewis, and Floris van Doorn Sep 10, 2021 CONTENTS 1 Introduction 1 1.1 Mathematical Proof ............................................ 1 1.2 Symbolic Logic .............................................. 2 1.3 Interactive Theorem Proving ....................................... 4 1.4 The Semantic Point of View ....................................... 5 1.5 Goals Summarized ............................................ 6 1.6 About this Textbook ........................................... 6 2 Propositional Logic 7 2.1 A Puzzle ................................................. 7 2.2 A Solution ................................................ 7 2.3 Rules of Inference ............................................ 8 2.4 The Language of Propositional Logic ................................... 15 2.5 Exercises ................................................. 16 3 Natural Deduction for Propositional Logic 17 3.1 Derivations in Natural Deduction ..................................... 17 3.2 Examples ................................................. 19 3.3 Forward and Backward Reasoning .................................... 20 3.4 Reasoning by Cases ............................................ 22 3.5 Some Logical Identities .......................................... 23 3.6 Exercises ................................................. 24 4 Propositional Logic in Lean 25 4.1 Expressions for Propositions and Proofs ................................. 25 4.2 More commands ............................................. 28 4.3 Building Natural Deduction Proofs .................................... 30 4.4 Forward Reasoning ............................................ 34 4.5 Definitions and Theorems ......................................... 36 4.6 Additional Syntax ............................................. 38 4.7 Exercises ................................................. 39 5 Classical Reasoning 41 5.1 Proof by Contradiction .......................................... 41 5.2 Some Classical Principles ......................................... 43 5.3 Exercises ................................................. 45 6 Semantics of Propositional Logic 47 6.1 Truth Values and Assignments ...................................... 47 6.2 Truth Tables ............................................... 50 6.3 Soundness and Completeness ....................................... 51 i 6.4 Exercises ................................................. 52 7 First Order Logic 55 7.1 Functions, Predicates, and Relations ................................... 55 7.2 The Universal Quantifier ......................................... 57 7.3 The Existential Quantifier ........................................ 59 7.4 Relativization and Sorts .......................................... 60 7.5 Equality .................................................. 61 7.6 Exercises ................................................. 62 8 Natural Deduction for First Order Logic 65 8.1 Rules of Inference ............................................ 65 8.2 The Universal Quantifier ......................................... 65 8.3 The Existential Quantifier ........................................ 67 8.4 Equality .................................................. 68 8.5 Counterexamples and Relativized Quantifiers .............................. 69 8.6 Exercises ................................................. 71 9 First Order Logic in Lean 73 9.1 Functions, Predicates, and Relations ................................... 73 9.2 Using the Universal Quantifier ...................................... 76 9.3 Using the Existential Quantifier ...................................... 78 9.4 Equality and calculational proofs ..................................... 81 9.5 Exercises ................................................. 85 10 Semantics of First Order Logic 89 10.1 Interpretations .............................................. 89 10.2 Truth in a Model ............................................. 90 10.3 Examples ................................................. 91 10.4 Validity and Logical Consequence .................................... 93 10.5 Soundness and Completeness ....................................... 93 10.6 Exercises ................................................. 94 11 Sets 97 11.1 Elementary Set Theory .......................................... 97 11.2 Calculations with Sets ........................................... 100 11.3 Indexed Families of Sets ......................................... 104 11.4 Cartesian Product and Power Set ..................................... 105 11.5 Exercises ................................................. 106 12 Sets in Lean 109 12.1 Basics ................................................... 109 12.2 Some Identities .............................................. 113 12.3 Indexed Families ............................................. 114 12.4 Power Sets ................................................ 118 12.5 Exercises ................................................. 118 13 Relations 121 13.1 Order Relations .............................................. 121 13.2 More on Orderings ............................................ 123 13.3 Equivalence Relations and Equality .................................... 124 13.4 Exercises ................................................. 125 14 Relations in Lean 127 14.1 Order Relations .............................................. 127 ii 14.2 Orderings on Numbers .......................................... 130 14.3 Equivalence Relations ........................................... 131 14.4 Exercises ................................................. 133 15 Functions 135 15.1 The Function Concept .......................................... 135 15.2 Injective, Surjective, and Bijective Functions ............................... 137 15.3 Functions and Subsets of the Domain .................................. 139 15.4 Functions and Relations .......................................... 140 15.5 Exercises ................................................. 141 16 Functions in Lean 143 16.1 Functions and Symbolic Logic ...................................... 143 16.2 Second- and Higher-Order Logic ..................................... 144 16.3 Functions in Lean ............................................. 145 16.4 Defining the Inverse Classically ...................................... 148 16.5 Functions and Sets in Lean ........................................ 149 16.6 Exercises ................................................. 151 17 The Natural Numbers and Induction 155 17.1 The Principle of Induction ........................................ 155 17.2 Variants of Induction ........................................... 157 17.3 Recursive Definitions ........................................... 160 17.4 Defining Arithmetic Operations ..................................... 162 17.5 Arithmetic on the Natural Numbers ................................... 164 17.6 The Integers ............................................... 166 17.7 Exercises ................................................. 167 18 The Natural Numbers and Induction in Lean 169 18.1 Induction and Recursion in Lean ..................................... 169 18.2 Defining the Arithmetic Operations in Lean ............................... 172 18.3 Exercises ................................................. 173 19 Elementary Number Theory 175 19.1 The Quotient-Remainder Theorem .................................... 175 19.2 Divisibility ................................................ 176 19.3 Prime Numbers .............................................. 179 19.4 Modular Arithmetic ........................................... 180 19.5 Properties of Squares ........................................... 182 19.6 Exercises ................................................. 183 20 Combinatorics 185 20.1 Finite Sets and Cardinality ........................................ 185 20.2 Counting Principles ............................................ 186 20.3 Ordered Selections ............................................ 188 20.4 Combinations and Binomial Coefficients ................................. 189 20.5 The Inclusion-Exclusion Principle .................................... 191 20.6 Exercises ................................................. 192 21 The Real Numbers 195 21.1 The Number Systems ........................................... 195 21.2 Quotient Constructions .......................................... 196 21.3 Constructing the Real Numbers ..................................... 198 21.4 The Completeness of the Real Numbers ................................. 199 21.5 An Alternative Construction ....................................... 200 iii 21.6 Exercises ................................................. 201 22 The Infinite 203 22.1 Equinumerosity .............................................. 203 22.2 Countably Infinite Sets .......................................... 204 22.3 Cantor’s Theorem ............................................. 207 22.4 An Alternative Definition of Finiteness .................................. 208 22.5 The Cantor-Bernstein Theorem ...................................... 209 22.6 Exercises ................................................. 209 23 Axiomatic Foundations 211 23.1 Basic Axioms for Sets .......................................... 211 23.2 The Axiom of Infinity .......................................... 213 23.3 The Remaining Axioms ......................................... 215 23.4 Type Theory ..............................................