Metamath a Computer Language for Mathematical Proofs
Total Page:16
File Type:pdf, Size:1020Kb
Metamath A Computer Language for Mathematical Proofs Norman Megill with extensive revisions by David A. Wheeler 2019-06-02 iii ∼ Public Domain ∼ This book (including its later revisions) has been released into the Public Domain by Norman Megill per the Creative Commons CC0 1.0 Universal (CC0 1.0) Public Domain Dedication (https: //creativecommons.org/publicdomain/zero/1.0/). David A. Wheeler has done the same. The public domain release applies worldwide. In case this is not legally possible, the right is granted to use the work for any purpose, without any conditions, unless such conditions are required by law. Several short, attributed quotations from copyrighted works appear in this book under the \fair use" provision of Section 107 of the United States Copyright Act (Title 17 of the United States Code). The public-domain status of this book is not applicable to those quotations. Any trademarks used in this book are the property of their owners. ISBN: 978-0-359-70223-7 Lulu Press Morrisville, North Carolina iv USA Norman Megill 93 Bridge St., Lexington, MA 02421 E-mail address: [email protected] David A. Wheeler E-mail address: [email protected] http://metamath.org Contents Preface . xiii 1 Introduction 1 1.1 Mathematics as a Computer Language . 8 1.1.1 Is Mathematics \User-Friendly"? . 8 1.1.2 Mathematics and the Non-Specialist 25 1.1.3 An Impossible Dream? . 28 1.1.4 Beauty . 31 1.1.5 Simplicity . 33 1.1.6 Rigor . 36 1.2 Computers and Mathematicians . 42 1.2.1 Trusting the Computer . 44 1.2.2 Trusting the Mathematician . 45 1.3 The Use of Computers in Mathematics . 50 1.3.1 Computer Algebra Systems . 50 1.3.2 Automated Theorem Provers . 52 1.3.3 Interactive Theorem Provers . 57 v vi CONTENTS 1.3.4 Proof Verifiers . 58 1.3.5 Creating a Database of Formalized Mathematics . 60 1.3.6 In Summary . 64 1.4 Mathematics and Metamath . 65 1.4.1 Standard Mathematics . 65 1.4.2 Other Formal Systems . 66 1.4.3 Metamath and Its Philosophy . 68 1.4.4 A History of the Approach Behind Metamath . 69 1.4.5 Metamath and First-Order Logic . 71 2 Using the Metamath Program 75 2.1 Installation . 75 2.2 Your First Formal System . 77 2.2.1 From Nothing to Zero . 77 2.2.2 Converting It to Metamath . 82 2.3 A Trial Run . 90 2.3.1 Some Hints for Using the Command Line Interface . 98 2.4 Your First Proof . 101 2.5 A Note About Editing a Database File . 112 3 Abstract Mathematics Revealed 115 3.1 Logic and Set Theory . 115 3.2 The Axioms for All of Mathematics . 121 3.2.1 Propositional Calculus . 122 3.2.2 Predicate Calculus . 126 CONTENTS vii 3.2.3 Set Theory . 133 3.2.4 Other Axioms . 137 3.3 The Axioms in the Metamath Language . 138 3.3.1 Propositional Calculus . 138 3.3.2 Axioms of Predicate Calculus with Equality|Tarski's S2 . 139 3.3.3 Axioms of Predicate Calculus with Equality|Auxiliary . 140 3.3.4 Set Theory . 140 3.3.5 That's It . 142 3.4 A Hierarchy of Definitions . 142 3.4.1 Definitions for Propositional Calculus147 3.4.2 Definitions for Predicate Calculus . 149 3.4.3 Definitions for Set Theory . 151 3.5 Tricks of the Trade . 167 3.6 A Theorem Sampler . 170 3.7 Axioms for Real and Complex Numbers . 175 3.7.1 The Axioms for Real and Complex Numbers Themselves . 176 3.7.2 Complex Number Axioms in Anal- ysis Texts . 180 3.7.3 Eliminating Unnecessary Complex Number Axioms . 180 3.8 Two Plus Two Equals Four . 182 3.9 Deduction . 184 3.9.1 The Standard Deduction Theorem 186 3.9.2 Weak Deduction Theorem . 188 viii CONTENTS 3.9.3 Deduction Style . 191 3.9.4 Natural Deduction . 194 3.9.5 Strengths of Our Approach . 199 3.10 Exploring the Set Theory Database . 201 3.10.1 A Note on the \Compact" Proof Format . 216 4 The Metamath Language 219 4.1 Specification of the Metamath Language . 221 4.1.1 Preliminaries . 222 4.1.2 Preprocessing . 223 4.1.3 Basic Syntax . 224 4.1.4 Proof Verification . 227 4.2 The Basic Keywords . 229 4.2.1 User-Defined Tokens . 232 4.2.2 Constants and Variables . 235 4.2.3 The $c and $v Declaration State- ments . 236 4.2.4 The $d Statement . 238 4.2.5 The $f and $e Statements . 248 4.2.6 Assertions ($a and $p Statements) 251 4.2.7 Frames . 255 4.2.8 Scoping Statements ($f and $g) . 261 4.3 The Anatomy of a Proof . 266 4.3.1 The Concept of Unification . 274 4.4 Extensions to the Metamath Language . 275 4.4.1 Comments in the Metamath Lan- guage . 275 CONTENTS ix 4.4.2 The Typesetting Comment ($t) . 284 4.4.3 Additional Information Comment ($j) . 290 4.4.4 Including Other Files in a Meta- math Source File . 293 4.4.5 Compressed Proof Format . 295 4.4.6 Specifying Unknown Proofs or Sub- proofs . 297 4.5 Axioms vs. Definitions . 298 4.5.1 What is a Definition? . 298 4.5.2 The Approach to Definitions in set.mm301 4.5.3 Adding Constraints on Definitions 306 4.5.4 Summary of Approach to Definitions308 5 The Metamath Program 309 5.1 Invoking Metamath . 310 5.2 Controlling Metamath . 311 5.2.1 exit Command . 313 5.2.2 open log Command . 314 5.2.3 close log Command . 314 5.2.4 submit Command . 315 5.2.5 erase Command . 315 5.2.6 set echo Command . 316 5.2.7 set scroll Command . 316 5.2.8 set width Command . 316 5.2.9 set height Command . 317 5.2.10 beep Command . 317 5.2.11 more Command . 318 x CONTENTS 5.2.12 Operating System Commands . 318 5.2.13 Size Limitations in Metamath . 318 5.3 Reading and Writing Files . 319 5.3.1 read Command . 319 5.3.2 write source Command . 320 5.4 Showing Status and Statements . 322 5.4.1 show settings Command . 322 5.4.2 show memory Command . 322 5.4.3 show labels Command . 322 5.4.4 show statement Command . 323 5.4.5 search Command . 324 5.5 Displaying and Verifying Proofs . 325 5.5.1 show proof Command . 325 5.5.2 show usage Command . 327 5.5.3 show trace back Command . 327 5.5.4 verify proof Command . 328 5.5.5 verify markup Command . 329 5.5.6 save proof Command . 330 5.6 Creating Proofs . 330 5.6.1 prove Command . 336 5.6.2 set unification timeout Command336 5.6.3 set empty substitution Command337 5.6.4 set search limit Command . 338 5.6.5 show new proof Command . 338 5.6.6 assign Command . 339 5.6.7 match Command . 340 5.6.8 let Command . 341 CONTENTS xi 5.6.9 unify Command . 342 5.6.10 initialize Command . 343 5.6.11 delete Command . 344 5.6.12 improve Command . 345 5.6.13 save new proof Command . 346 5.7 Creating LATEX Output . 347 5.7.1 open tex Command . 348 5.7.2 close tex Command . 349 5.8 Creating HTML Output . 349 5.8.1 write theorem list Command . 351 5.8.2 write bibliography Command . 352 5.8.3 write recent additions Command352 5.9 Text File Utilities . 353 5.9.1 tools Command . 353 5.9.2 help Command (in tools) . 354 5.9.3 Using tools to Build Metamath submit Scripts . 356 5.9.4 Example of a tools Session . 356 A Sample Representations 359 B Compressed Proofs 367 C Metamath's Formal System 371 C.1 Introduction . 371 C.2 The Formal Description . 373 C.2.1 Preliminaries . 373 xii CONTENTS C.2.2 Constants, Variables, and Expres- sions . 374 C.2.3 Substitution . 376 C.2.4 Statements . 376 C.2.5 Formal Systems . 379 C.3 Examples of Formal Systems . 381 C.3.1 Example 1|Propositional Calculus 381 C.3.2 Example 2|Predicate Calculus with Equality . 385 C.3.3 Free Variables and Proper Substi- tution . 389 C.3.4 Metalogical Completeness . 391 C.3.5 Example 3|Metalogically Complete Predicate Calculus with Equality . 392 C.3.6 Example 4|Adding Definitions . 395 C.3.7 Example 5|ZFC Set Theory . 396 C.3.8 Example 6|Class Notation in Set Theory . 398 C.4 Metamath as a Formal System . 401 D The MIU System 405 E Metamath Language EBNF 411 Bibliography 417 Index 429 Preface Overview Metamath is a computer language and an associated computer program for archiving, verifying, and study- ing mathematical proofs at a very detailed level. The Metamath language incorporates no mathematics per se but treats all mathematical statements as mere sequences of symbols. You provide Metamath with certain special sequences (axioms) that tell it what rules of inference are allowed. Metamath is not limited to any specific field of mathematics. The Metamath language is simple and robust, with an almost total absence of hard-wired syntax, and we1 believe that it provides about the simplest possi- ble framework that allows essentially all of mathematics 1Unless otherwise noted, the words \I," \me," and \my" refer to Norman Megill, while \we," \us," and \our" refer to Norman Megill and David A.