Type theory is a goodfoundation for logic, mathematics and computer science, except that, by making bothtypes and functions fundamental, it is more complex than either set theory or the
Trang 1MATHEMATICS AND COMPUTER SCIENCE
bySamuel Howse
Submitted in partial fulfillment of therequirements for the degree ofDoctor of Philosophy
at
Dalhousie UniversityHalifax, Nova ScotiaOctober 2006
© Copyright by Samuel Howse, 2006
Trang 2Your file Votre référence ISBN: 978-0-494-19613-7 Our file Notre référence ISBN: 978-0-494-19613-7
NOTICE: AVIS:
The author has granted a
non-exclusive license allowing Library
and Archives Canada to reproduce,
publish, archive, preserve, conserve,
communicate to the public by
telecommunication or on the Internet,
loan, distribute and sell theses
worldwide, for commercial or
non-commercial purposes, in microform,
paper, electronic and/or any other
formats
The author retains copyright
ownership and moral rights in
this thesis Neither the thesis
nor substantial extracts from it
may be printed or otherwise
reproduced without the author's
permission
L'auteur a accordé une licence non exclusivepermettant a la Bibliotheque et ArchivesCanada de reproduire, publier, archiver,sauvegarder, conserver, transmettre au publicpar télécommunication ou par I'Internet, préter,distribuer et vendre des théses partout dans
le monde, a des fins commerciales ou autres,sur support microforme, papier, électroniqueet/ou autres formats
L'auteur conserve la propriété du droit d'auteur
et des droits moraux qui protége cette these
Ni la thése ni des extraits substantiels decelle-ci ne doivent être imprimés ou autrementreproduits sans son autorisation
In compliance with the Canadian
Privacy Act some supporting
forms may have been removed
from this thesis
While these forms may be included
in the document page count,
their removal does not represent
any loss of content from the
thesis
Canada
Conformément a la loi canadiennesur la protection de la vie privée,quelques formulaires secondairesont été enlevés de cette these
Bien que ces formulairesaient inclus dans la pagination,
il n'y aura aucun contenu manquant
Trang 3To comply with the Canadian Privacy Act the National Library of Canada has requestedthat the following pages be removed from this copy of the thesis:
Trang 4iv
Trang 5LISTOFTABILES << ¬ eee xx
ACKNOWLEDGMENTS ¬ eee eee oe ee es» XXỈỈ
CHAPTER 2 NUMMSQUARED OVERVIEW AND COMPARISON 4
2.1 UNTYPED LAMBDA CALCULUS AND IMPROVEMENTS 5
2.2 SET THEORY, VON NEUMANNANDJONES 6
23 FUNDAMENTALCONCEPIS 7
2.4 SMALLANDLARGEFUNCHONS 8
2.5 WELL-FOUNDEDNESS AND COEROION 9
26 VARIABLE-FREE 1.2 2 ee eee 9 27 REFLECTION Q Q ee ee ee ee 10 2.8 EQUALITY 0 ee HH ee ene 11 2.9 NSGO 2 cc ee ee eee ee ee ee eens 12 CHAPTER 4 WHERETO FIND THEFORMALPART 15
CHAPTER 5 NOTATIONINTHEINFORMALPART 16
6.2 NULL 2 ee ee ee ee ee ee 17
Trang 66.6
6.7
6.8
6.9
7.1
7.2
7.3
7.4
7.5
7.6
7.7
7.8
7.9
7.10
7.11
7.12
7.13
7.14
7.15
7.16
7.17
WELL-FOUNDED RELATONS 20
SMALL LANGUAGES 2 0c 20 CHAPTER 7 NUMMSQUAREDSEMANTICS 21
SMALL FUNCTION EXTENSIONS 22
DOMAIN AND SPECIFIC RESULT OF A SMALL FUNC-TION EXTENSION c 25
RANK OF A SMALL FUNCTION EXIENSION 26
IDENTITY SMALL FUNCTION EXTENSIONS 28
DOMAIN EXTENSIONS 2 0 ce ee eee en 29 DOMAIN, DOMAIN EXTENSION AND SPECIFIC RESULT OF A DOMAIN EXTENSION FAMIIY 31
DOMAIN, RANK AND VALIDITY OF A DOMAIN EXTENSION 31
DOMAIN EXTENSION IRRELEVANCE THEOREM 33
DOMAIN EXTENSIONINFERENCE 37
TAGGED SMALL FUNCTION EXTENSIONS 40
UNTAGGED, TAG IRRELEVANCE THEOREM, TAGGED AND TAGGABLE 0 ee ee et ee ee 4] DOMAIN, DOMAIN EXTENSION, SPECIFIC RESULT AND RANK OF A TAGGED SMALL FUNCTION EXTENSION 46
IDENTITY TAGGED SMALL FUNCTION EXTENSIONS 50
COERCION OF A TAGGED SMALL FUNCTION EXTEN-SION, AND COERCION STABILITY THEOREM 52
RESULT OF A TAGGED SMALL FUNCTION EXTENSION 58
EXTENSIONALITYTHEOREM 61
SOME TAGGED SMALL FUNCTION EXTENSIONS 63
LARGE FUNCTION EXTENSIONS AND TRUTH 66 7.18
Trang 77.21
SOME COMPUTATIONAL COMBINATIONS OF LARGE
FUNCTION EXTENSIONS 68
SOME NON-COMPUTATIONAL LARGE FUNCTION EXTENSIONS AND COMBINATIONS 71
CHAPTER 8 NUMMSQUAREDSYNTAX 73
8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 8.10 8.11 8.12 8.13 8.14 8.15 8.16 8.17 8.18 8.19 8.20 NORMALIZED LARGEFUNCTIONS 74
EXTENSION AND TRUTH OF A NORMALIZED LARGE FUNCTION 78
REDUCTION: COMPUTED OF A NORMALIZED LARGE FUNCTION 79
NORMAL FORM OF ANATURALNUMBER 84
QUOTED OF A NORMALIZED LARGEFUNCTION 84
UNQUOTED OF A NORMALIZED LARGE FUNCTION 86
MACRO EXPANDED 0 0 eee eee ee ee es 87 SUBSTITUTION AND SUBSTITUTION THEOREM 87
COMMENTS 0 0 ee ee ee ee et ee ene 88 IDENTIFIERS 2.0 ee eee 88 LARGEFUNCTIONS 89
DEFINITIONS, DEFINITION LISTS, MODULES AND ABSTRACTPROGRAMS o 99 CONTEXIS O ee HH HH HH ee ko 102 NORMAL FORM OFAPRIMITIVE 104
NORMAL FORM OF A NORMALIZED CONSTANT 104
NORMAL FORM OF A GLOBALNAME 104
PSEUDO-NUMMSQUARED 105
NORMAL FORM OFALOCALNAME 105
LOCAL TUPLE ACCESSOR CHECK 107
NORMAL FORM OF A COMPUTATIONAL NON-NORMALIZED CONSTANT OR COMPUTATIONAL COMBINATION 20.0 ee ee ee ees 108 8.20.1 CONFIRMATIIONWITHNULL 108
Trang 88.20.3 NULLTOZERO Ặ ee es 109 8.20.4 KINDPREDICATES co 110
8.20.5 TREEPREDICATE 111
8.20.66 RESULT 2 ee ee es 114 8.20.7 RESTRICT 0 0 cee ee es 114 8.20.8 RESTRICTTORANGE 114
8.20.9 NUROSETRESULT 115
8.20.10 TREESETRESULIT 115
8.20.11 DEPENDENTSUMRESULT 116
8.20.12 DEPENDENT PRODUCT RESULT 0 117
8.20.13 CURRYAUGMENTED 118
8.20.14 CURRYRESULT 119
8.20.15 RECURSION RIGHT-HAND-SIDE 119
8.20.16 NEGATION 1 ee ee ee ee 120 8.20.17 IMPLICATION WITHNULL 120
8.20.18 IMPLICATIION 121
8.21 NORMAL FORM OF A COMPUTATIONAL NON-NORMALIZED CONSTANT OR NON-COMPUTATIONAL COMBINATION 2.2.0 eee ee ee ee ens 121 8.21.1 EXISTENTIALQUANTIFICAHION 122
8.21.2 UNIVERSALQUANTIFICATION 122
8.21.3 UNARY UNIVERSAL QUANTIFICATION 123
8.21.4 SMALL UNIVERSAL QUANTIFICATION 123
8.21.5 EQUAISRIGHT-HAND-SIDE 124
8.216 NOTEQUALS 126
8.217 INDUCTIVECASE 0 cece eee eee 127 8.22 NORMAL FORM AND VALIDITY OF ALARGE FUNCTION 128
Trang 98.24 PSEUDO-NUMMSQUAREDCOMPLETE 1318.25 SOME TRUE LARGE FUNCTION EXTENSIONS 1318.25.1 IDENTITY 2 ce eee eee eee eee 131
8.2512 DEPENDENTSUM 1448.2513 DEPENDENTPRODUCT 145
8.25.15 IF-THEN-ELSE ee 1498.25.16 RECURSION 0 ee eee ee ee eee eee 1508.25.17 PROPOSITIONALLOGIC 150
8.25.19 EQUALS 1 ee 1528.25.20 HILBERT 2.0.0 ce ee ee ee ee ee 1528.25.21 INDUCTION 1 0 eee ee ee et ee 1538.25.22 LEFTOVERS 0.0 eee eee eee ee ee ee 1548.26 SOME INFERENCES FROM TRUE LARGE FUNCTION EXTENSIONS 1568.26.1 MODUSPONENS 0.0 0 ce eee ee eee 156
Trang 108.28
8.29
8.30
8.31
8.32
8.33
SOME TRUE NORMALIZED LARGEFUNCTIONS 157
SOME INFERENCES FROM TRUE NORMALIZED LARGE FUNCTIONS 157 8.28.1 7 MODUSPONENS 157
8.28.2 SPECIAULIZAHON 158
8283 SUBSTITUHION 158
PROOFS ee ee es 158 PROPOSITION AND VALIDITY OF A PROOF AND SOUNDNESSTHEOREM 159
QUOTEDOFAPROOF 161
PROOF UNQUOTED OF A NORMALIZED LARGEFUNCTION 162
RUSSELLS PARADOXAVERTED 162
91 PREFACE TO THEFORMALPART 164
9.1.1 THEFORMALPART 164
9.1.2 AQUICKSURVEYOFCOQ 164
9.1.2.1 COQ TERMS, CONTEXTS, ENVI-RONMENTS, TYPE-CHECKING, REDUCTION, NORMAL FORMS AND CONVERTIBILITY 164
9.1.2.2 COQSORTS 165
9.1.2.3 COQ PROOFS 166
9.1.2.4 COQ DEPENDENT PRODUCTS, FUNCTIONS AND APPLICATIONS 166
9.1.2.5 COQTYPECASIS 166
9.1.2.6 COQ MODULES, COMMANDS AND GLOBAL DECLARATIONS 167
9.1.2.7 NAMING OF COQ MODULES AND GLOBALDECLARATONS 167
913 NUMMSQUARED FORMALLY STYLE 167
Trang 119.1.3.2 USE TYPENOTSET 168
9.1.3.3 MAKE REUSABLE TERMS INTO SEPARATE GLOBAL DECLARATIONS 168
9.1.3.4 USE UNDERSCORE FOR HIERARCHI-CALNAMING 168
9.2 FUNDAMENTALS:OPERATORS:MAIN 168
9.2.1 OPERATORS -.O ee ee So 169 9.2.2 THECONSTANTOPERATOR 169
9.2.3 SIMPLEOPERATORS 0000 e eevee neue 169 9.2.4 THEIDENTITYSIMPLEOPERATOR 169
9.2.5 BINARYOPERATIORS 169
9.2.6 | CONNECTIVE BINARY OPERATORS 170
9.2.7 SIMPLEBINARYOPERATORS 170
9.2.8 | TRINARYOPERATORS 170
9.2.9 | CONNECTIVETRINARYOPERATORS 170
9.2.10 SIMPLETRINARYOPERATORS 171
9.2.11 QUATERNARYOPERATORS 171
9.2.12 CONNECTIVE QUATERNARY OPERATORS 171
9.2.13 SIMPLEQUATERNARYOPERATORS 171
9.2.14 QUINARYOPERATORS 171
9.2.15 CONNECTIVE QUINARY OPERATORS 172
9.2.16 SIMPLEQUINARVOPERATORS 172
93 EFUNDAMENTAILS:PROPOSITONS:MAIN 172
9.3.1 DEPENDENCGIS 173
9.3.2 | PROPOSIHONALPREDICATES 173
9.3.3 THECONSTANT PROPOSITIONAL PREDICATE 173
9.3.4 | BINARY PROPOSITIONAL PREDICATES 173
Trang 129.3.6 | TRINARY PROPOSITIONAL PREDICATES 174
9.3.7 CONNECTIVE TRINARY PROPOSITIONAL PREDICATES 174
9.3.8 | QUATERNARY PROPOSITIONAL PREDICATES 174
9.3.9 CONNECTIVE QUATERNARY PROPOSITIONAL PREDICATES 174 9.3.10 QUINARY PROPOSITIONAL PREDICATES 175
9.3.11 _ CONNECTIVE QUINARY PROPOSITIONAL PREDICATES 175
9.3.12 THETRUEPROPOSITION 175
9.3.13 THEFALSEPROPOSITION 176
FUNDAMENTALS: BOOLEANS: MAIN 176
9.4.1 DEPENDENCIES 176
9.4.2 BOOLEANS cece e ee ee eee 176 9.4.3 BOOLEANPREDICATES 177
9.4.4 THECONSTANTBOOLEANPREDICATE 177
9.45 BINARYBOOLEANPREDICATES 177
9.4.6 CONNECTIVE BINARY BOOLEAN PREDICATES 177
9.47 TRINARYBOOLEANPREDICATES 177
9.4.8 CONNECTIVETRINARYBOOLEAN PREDICATES 178
9.4.9 | QUATERNARY BOOLEAN PREDICATES 178
9.4.10 CONNECTIVE QUATERNARY BOOLEAN PREDICATES 178
9.4.11 QUINARYBOOLEAN PREDICATES 178
9.4.12 CONNECTIVE QUINARY BOOLEAN PREDICATES 179
9.4.13 BOOLEANTOPROPOSITION 179
9.4.14 BOOLEANEQUAIS 179
9.4.15 BOOLEANNOT cece 180 FUNDAMENTALS: NATURALS:MAIN 180
9.5.1 DEPENDENCIES 180
9.5.2 NATURALNUMBERS 180
Trang 139.5.4 NATURALNUMBEREQUAIS 184
9.5.5 NATURALNUMBERITERATE 185
9.5.6 © NATURALNUMBERADD 185
9.5.7 NATURALNUMBERMULIHPU 186
9.6 FUNDAMENTALS: NATURALS: EFFICIENT: MAIN 186
9.6.1 DEPENDENOIES 186
9.6.2 EFFICIENT NATURALNUMBERS 187
9.6.3 EFFICIENT NATURALNUMBEREQUAIS 187
9.7 FUNDAMENTAIS:UNITS:MAIN 187
9.7.1 DEPENDENCIES co 187 97.2 UNIIS Q Q Q ee kia 187 973 UNITEQUAIS 187
9.8 FUNDAMENTAIS:OPTIONALS:MAIN 188
981 DEPENDENOIES 188
9.8.2 OPHONAIS Q ee HH So 188 983 OPTIONALRELATEDTO 188
9.8.4 OPTIONAL RELATED TO, CONNECTIVE 189
9.8.5 OPHONALNON-EMPTY 189
9.8.66 OPIONALEMPTY 190
9.8.7 THEOPTIONALONEOPERATOR 190
9.8.8 OPHONALSELECT 190
9.8.9 OPTIONAL SELECT, TOELEMENT 191
9.9 FUNDAMENTALS: BOOLEANS: AND OPTIONALS 192
9.9.1 DEPENDENCIES 192
9.9.2 BOOLEANTOOPTHIONAL 192
9.9.3 THEBOOLEAN OPTIONALOPERATOR 192
9.10 FUNDAMENTALS: CHOICES:MAIN 193
Trang 149.12
9.102 CHOICES c co 193
9.103 CHOICERELATEDTO 194
9.104 CHOICERELATEDTO,CONNECTIVE 194
9.105 CHOICETOOPTIONAL 195
9.106 CHOICEMERGE 195
FUNDAMENTALS: PAIRS: MAIN 196
9.111 DEPENDENCIES 196
911.2 PAIRS - .——Áa 196 9113 PAIRRELATEDTO 197
9.114 PAIRRELATEDTO,CONNECTIVE 197
9115 TRIPLES cẶ cu 198 9.116 TRIPLELEFTO c ccc co 198 9.117 TRIPLERIGHT0 198
9.118 TRIPLELEFTI 199
9119 TRIPLERIGHTI 199
9.1110 QUADRUPLES 199
9.1111 QUADRUPLELEFT0 200
9.1112 QUADRUPLERIGHT0 200
9.1113 QUADRUPLELEFTI 201
9.1114 QUADRUPLELEFT2 201
9.1115 QUADRUPLERIGHT2 202
FUNDAMENTALS: LISTS: MAIN 202
9.12.1 DEPENDENCIES 202
9.12.2 LISTS oo eee eee eee 202 9.12.3 LISTNOTATION 203
9.12.4 LISTRELATEDTO 203
9.12.5 LISTRELATEDTO,CONNECTIVE 204
xiv
Trang 159.14
9.15
9.12.7 ULISTREST Q Q Q Q Q HQ HH HH K 205
9128 2 LISTNON-EMPTY -.c .c 205 9.12.9 LISTEMPTY OQ Q Q eee ee ko 206
9.1210 LISTCONCATENATE 206
9.12.11 LISTAPPEND ee eee ee he 206 9.12.12 THELIST SINGLETON OPERATOR 207
9.12.13 THE LIST SINGLETON BINARY OPERATOR 207
9.12.14 THELISTPREFXOPERATOR 207
9.12.15 THE LISTSUFFXOPERATOR 208
9.12.16 LISTGENERATE 2 2.0 eee ee ee ee 208 9.12.17 LISTGENERATETOELEMENT 209
9.1218 NON-EMPTYLISTS 209
9.12.19 NON-EMPTYLISTRELATEDTO 210
9.12.20 NON-EMPTY LIST RELATED TO, CONNECTIVE 210
9.12.21 NON-EMPTY LIST SINGLETON 211
9.12.22 NON-EMPTYLISTTOLHIST 211
9.12.23 THE NON-EMPTY LIST HEAD OPERATOR 211
9.12.24 LISTTONON-EMPTYLIST 212
9.12.25 2PLUSLISTS 0 ee ee eee 212 FUNDAMENTALS: OPTIONALS:ANDLISTS 213
9.13.1 DEPENDENOGIES 213
9.13.2 OPHIONALTOLIST 213
FUNDAMENTAIS:BOOLEANS:.ANDLISIS 213
9.14.1 DEPENDENCIES 214
9.142 BOOLEANTOLIST 214
9.14.3 THEBOOLEAN LSTOPERATOR 214
FUNDAMENTAIS:NATURALS:ANDLISTS 215
Trang 169.17
9.18
9.152 NATURALNUMBERLISTS 215
9.15.3 NATURALNUMBERLISTEQUAIS 215
FUNDAMENTALS: NATURALS: EFFICGIENT:ANDHISIS 215
9.16.1 DEPENDENOCIES 216
9.16.2 EFFICIENT NATURAL NUMBERLISTS 216
9.16.3 EFFICIENT NATURAL NUMBER LIST EQUALS 216
FUNDAMENTALS: PAIRS:ANDHISTS 216
9.17.1 DEPENDENOIES 216
9.17.2 PAIROF HEAD AND REST TO NON-EMPTYLIST 216
FUNDAMENTAILS:LISTS:SELECT 217
9181 2 DEPENDENGIEHS 217
9.18.2 LISTSELECT Q Q Q Q HH HQ HH ees 217 9.183 LISTSELECTSIMPLE 218
9.18.4 LISTSELECTITERATE 219
9.18.5 LISTSELECT TOELEMENT 219
9.18.6 LIST SELECT TO ELEMENTSIMPLE 219
9.18.7 LIST SELECT, TO ELEMENTITERATE 220
9.18.8 LISTSELECTUBYELEMENT 220
9.18.9 LIST SELECT, BY ELEMENT, SIMPLE 221
9.18.10 LIST SELECT, BY ELEMENT, ITERATE 221
9.18.11 LIST SELECT, BY ELEMENT, INTRODUCED 222
9.18.12 LIST SELECT, BY ELEMENT, TERMINATED 222
9.18.13 LIST SELECT, BY ELEMENT, SEPARATED 223
9.18.14 LIST SELECT, BY ELEMENT, TOELEMENT 223
9.18.15 LIST SELECT, BY ELEMENT, TO ELEMENT, SIMPLE 224
9.18.16 LIST SELECT, BY ELEMENT, TO ELEMENT, ITERATE 224
9.18.17 LIST SELECT, BY PREFIX, RECURSIVE 225
Trang 179.20
9.18.19 LIST SELECT, BY PREFRX SIMPLE 226
9.18.20 LIST SELECT, BY PREFIX, ITERATE 226
9.18.21 LIST SELECT, BY PREFIX, TOELEMENT 227
9.18.22 LIST SELECT, BY PREFIX, TO ELEMENT, SIMPLE 227
9.18.23 LIST SELECT, BY PREFIX, TO ELEMENT, ITERATE 228
9.18.24 LISTSEARCH 0 ce ee ee es 228 9.18.25 LISTSEARCH,FIRST 229
9.18.26 LISTSEARCH,ISFOUND 229
918.27 LISTINTERSECTION,MATCH 230
9.18.28 LISTINTERSECTION 230
9.18.29 LISTINTERSECTION,CONNECTTIVE 231
9.18.30 LISTINTERSECTION,HIRST 231
9.18.31 LIST INTERSECTION, FIRST, CONNECTIVE 231
9.18.32 LISTINTERSECTION,NON-EMPTY 232
9.18.33 LIST INTERSECTION, NON-EMPTY, CONNECTIVE 232
9.18.34 LISTTO BOOLEAN PREDICATE 233
FUNDAMENTALS: OPTIONALS: AND LISTS SELECT 233
9.19.1 DEPENDENCIES 233
9.19.2 OPHONALFLATTENLIST 233
FUNDAMENTALS: LISTFUNCTIONS:MAIN 234
9.20.1 7 DEPENDENCIES 234
9.20.2 HLISTFUNCTIONS co 234 9.20.3 LISTFUNCTION TO BOOLEAN PREDICATE 234
9.20.4 SIMPLELISTFUNCIONS 235
9.20.5 SIMPLE LISTFUNCTION TO BOOLEAN PREDICATE 235
9.20.6 SIMPLELISTFUNCTIONITERATE 235
9.20.7 SIMPLE LISTFUNCTION ITERATE, CURRY2 236
Trang 189.21 NUMMSQUARED: SYNTAX: ABSTRACT: MAIN
9.21.1 9.21.2 9.21.3 9.21.4 9.21.5 9.21.6 9.21.7 9.21.8 9.21.9 9.21.10 9.21.11 9.21.12 9.21.13 9.21.14 9.21.15 9.21.16 9.21.17 9.21.18 9.21.19 9.21.20 9.21.21 9.21.22 9.21.23 DEPENDENCIES o NUMMSQUARED DIGIT CHARACTERS
NUMMSQUARED DIGIT CHARACTER EQUALS
NUMMSQUARED IDENTIFIER START CHARACTERS
NUMMSQUARED IDENTIFIER START CHARAC-TER EQUAIS
NUMMSQUARED IDENTIFIER CONTINUE CHARACTERS
NUMMSQUARED IDENTIFIER CONTINUE CHARACTEREQUALS
NUMMSQUAREDCOMMENIS
NUMMSQUARED COMMENT EQUALS
NUMMSQUARED SIMPLE IDENTIFIERS
NUMMSQUARED SIMPLE IDENTIFIER EQUALS
NUMMSQUAREDIDENTIFIERS
NUMMSQUARED IDENTIFIER EQUALS
NUMMSQUARED SIMPLE IDENTIFIER TO NUMMSQUAREDIDENTIFIER
NUMMSQUARED NATURAL NUMBER PRIMITIVES
NUMMSQUARED NATURAL NUMBER PRIMI-TIVEEQUALS
NUMMSQUARED CHARACTER PRIMITIVES
NUMMSQUARED CHARACTER PRIMITIVE EQUALS
NUMMSQUARED STRING PRIMITIVES
NUMMSQUARED STRING PRIMITIVE EQUALS
NUMMSQUARED PRIMITIVES
NUMMSQUARED PRIMITTIVEEQUALS
NUMMSQUARED COMPUTATIONAL NORMAL-LZEDCONSTANIS
Trang 199.21.26
9.21.27
9.21.28
9.21.29
9.21.30
9.21.31
9.21.32
9.21.33
9.21.34
9.21.35
9.21.36
NUMMSQUARED NORMALIZED CONSTANTS 249
NUMMSQUARED COMPUTATIONAL NON-NORMALIZED CONSTANIS 249
NUMMSQUARED NON-COMPUTATIONAL NON-NORMALIZED CONSTANTS 252
NUMMSQUARED NON-NORMALIZED CONSTANTS 253
NUMMSQUAREDCONSTANIS 253
NUMMSQUARED LARGE FUNCTIONS 254
NUMMSQUARED LOCAL TUPLE ACCESSOR LISTS 265
NUMMSQUARED LOCALCONTEXTS 265
NUMMSQUARED DEHINIHIONS 266
NUMMSQUARED GLOBALCONTEXTS 266
NUMMSQUARED MODULES 266
NUMMSQUARED ABSTRACT PROGRAMS 266
CHAPTER 10 CONCLUSION Sn ee ee) 267 BIBLIOGRAPHY
INDEX
¬ aee a ¬ nee 269
" HH Y
Trang 202.1 VON NEUMANN’S AXIOMATIZATION AND
COMBINA-TORY LOGICROUGHIYCOMPARED
Trang 217.1 SMALL FUNCTION EXTENSIONS ee © © © © © © ee ee 6 8 óc 98 lll ell
Trang 22NummSquared Explained is the thesis version of the comprehensive formal ment NummSquared 2006a0 Done Formally, which is available at http: //nummist com/poohbist/.
docu-Set theory is the standard foundation for mathematics, but often does not includerules of reduction for function calls Therefore, for computer science, the untypedlambda calculus or type theory is usually preferred The untyped lambda calculus(and several improvements on it) make functions fundamental, but suffer from non-terminating reductions and have partially non-classical logics Type theory is a goodfoundation for logic, mathematics and computer science, except that, by making bothtypes and functions fundamental, it is more complex than either set theory or the un-typed lambda calculus This document proposes a new foundational formal languagecalled NummSquared that makes only functions fundamental, while simultaneouslyensuring that reduction terminates, having a classical logic, and attempting to followset theory as much as possible NummSquared builds on earlier works by John vonNeumann in 1925 and Roger Bishop Jones in 1998 that have perhaps not received suffi-cient attention in computer science
A soundness theorem for NummSquared is proved
Usual set theory, the work of Jones, and NummSquared are all well-founded
NummSquared improves upon the works of von Neumann and Jones by having tion and proof, by supporting computation and reflection, and by having an interpretercalled NsGo (work in progress) so the language can be practically used NummSquared
Trang 23Many thanks to Dr Malcolm Heywood, my PhD supervisor at Dalhousie sity, for unbounded good ideas, patience and support throughout the lengthy PhDprocess Thanks to Dr Peter Hitchcock for insights into software engineering and pro-gram correctness Thanks to Dr Anthony Cox for discussions about programming lan-guages, and for suggesting many useful improvements to the thesis Thanks to Dr PaulGilmore for discussions about his Intensional Type Theory, and for suggesting manyuseful improvements to the thesis Thanks to Hugo Herbelin for discussions about Coqand type theory, and for suggesting many useful improvements to the thesis My PhDwork would not have been possible without funding from Dalhousie University, theKillam Memorial Scholarship and the National Research Council Canada.
Univer-Thanks to Jan, Bob, Joe and Dr L S River for many helpful conversations and ing Thanks to Joe for graphic design services Thanks to Mopsy for lots of stuff Thanks
edit-to Dame P P Paws for suggesting a clean approach edit-to programming Thanks edit-to the Rt.Hon Leo L Lion, my manager at Poohbist Technology, for providing the necessary im-petus to complete this work Thanks to Miss Plasma Tigerlilly Zoya for helping me di-gest the literature
Trang 24The modern personal computer comes bundled with an impressive assortment ofsoftware, and much more software and content is available on the Web (often at noadditional cost) For typical use, disk space for storing software and documents is prac-tically unlimited Powerful CPUs sit idle most of the time
Unrestricted functionality comes at low initial monetary cost, but at a high cost incomplexity and security Most installed software has almost unrestricted access to alldata and other software on the computer Even for Web content that is not explicitlyinstalled by the user, security loopholes are frequently exploited And even trusted soft-ware may contain errors that interfere with other software, damage data, or impactsystem stability
For the most part, programmers are aware of these issues, and want to write securesoftware that has minimal impact on the remainder of the system Languages withmemory safety and automatic memory management (such as C#, Java and OCaml -see (31, chapter 1], [14, chapter 1] and [24]) offer substantial improvements by prevent-ing memory corruption and memory leak errors As a result, the programmer may takethe convenient view that memory is a safe place to store data, and be mostly correct inthis view However, in the imperative paradigm, side-effects can still result in memorycontents changing unexpectedly The functional paradigm eliminates side-effects, thuspresenting a view of memory that is both safe and mathematically elegant
A substantial part of the complexity and security problem is the view of the puter (aside from memory) that the operating system and language present to the pro-grammer The typical view is easily summarized in two words: global state
com-Because all processes share access to a single file system, any one process must viewthe state of the file system as being almost completely indeterminate (Two notable
Trang 25non-determinism non-deterministically Good software will at least handle the errors,but still cannot always provide the desired functionality.
Interprocess communication is another source of complexity and security lems, since typically any process can send a message to any other In the physicalworld, much is possible because agents can act independently and interact freely Thedigital world we have created is a reflection of the physical one, in both its endless pos-sibilities, and its occasional descent into chaos
prob-This document does not suggest that the complexity of the modern personal puter is unnecessary But it does propose a way in which much is possible with verysimple and mathematically elegant tools
com-Set theory is the standard foundation for mathematics, but often does not includerules of reduction for function calls Therefore, for computer science, the untypedlambda calculus or type theory is usually preferred The untyped lambda calculus(and several improvements on it) make functions fundamental, but suffer from non-terminating reductions and have partially non-classical logics Type theory is a goodfoundation for logic, mathematics and computer science, except that, by making bothtypes and functions fundamental, it is more complex than either set theory or the un-typed lambda calculus This document proposes a new foundational formal languagecalled NummSquared that makes only functions fundamental, while simultaneouslyensuring that reduction terminates, having a classical logic, and attempting to followset theory as much as possible NummSquared builds on earlier works by John vonNeumann in 1925 ([40]) and Roger Bishop Jones in 1998 ([26]) that have perhaps notreceived sufficient attention in computer science
A soundness theorem for NummSquared is proved
Usual set theory, the work of Jones, and NummSquared are all well-founded
NummSquared improves upon the works of von Neumann and Jones by having tion and proof, by supporting computation and reflection, and by having an interpretercalled NsGo (work in progress) so the language can be practically used NummSquared
Trang 26proof, yet reduction terminates NummSquared supports proofs as desired, but notrequired.
NummSquared aims to hide much complexity from the programmer The grammer sees only mathematical functions, and proofs of their properties Because
pro-a NummSqupro-ared progrpro-am mpro-ay include propositions, computpro-ations pro-and proofs, it mpro-ayserve as specification, implementation, and proof that implementation satisfies spec-ification Side-effects and global state, including the file system and processes, are notpart of the NummSquared view Such a simplified view is ideal for the computationaland logical tasks that are the core of almost any software Mixing global state manipu-lation with these tasks would obscure their essentially mathematical nature
A NummSquared program may be a component of a larger software project Othercomponents can handle interaction with the global state, while delegating the compu-tational and logical tasks to NummSquared programs Because NummSquared has asimple variable-free syntax and is untyped, it is easy for other components to generateand process NummSquared programs
Much has already been accomplished with formal methods For example, PraxissSPARK language is a subset of Ada that enables formal reasoning, and has been usedfor major industrial projects (see (33]) And [13] used Coq to check a proof of the FourColour Theorem The goal of NummSquared is to provide a foundation that is partic-ularly simple, since it is based on untyped functions Future research will apply andadapt NummSquared to large software projects, with the hypothesis that its simplicity
is an asset
Trang 27NUMMSQUARED OVERVIEW AND
COMPARISON
NummSquared is a formal language, and a new well-founded functional tion for logic, mathematics and computer science A language ‘L is well-founded iff ‘Lincludes a well-founded relation on all ‘L objects
founda-NummSquared meets all of the following goals:
¢ Functions are the only fundamental concept There are no side-effects or global
state.
¢ Include reduction and ensure that it always terminates
® Minimize constraints on the logician, mathematician or programmer In lar, because of coercion, there are no types, and functions are defined and calledwithout proof, yet reduction terminates NummSquared coercion is (loosely) ageneralization to higher order functions of coercion (type conversion) found inmany programming languages
particu-* Proofs as desired, but not required Because a NummSquared program may clude propositions, computations and proofs, it may serve as specification, im-plementation, and proof that implementation satisfies specification
in-The motivation behind these goals is the idea that formal methods is more ing when the language is simple, when proofs do not get in the way, and when termi-nation of reduction is nonetheless ensured It seems that many mathematicians havelittle interest in types, and many programmers have little interest in proofs (Logicians,due to their focus on foundations, are often interested in both.) Perhaps by removing
Trang 28appeal-ods appealing to a wider audience.
NummSquared has a classical logic Also, NummSquared attempts to follow set ory as much as possible, since set theory is the standard foundation for mathematics
the-A soundness theorem for NummSquared is proved
NummSquared is variable-free
NummSquared supports reflection for extending the syntax of the language, and formanipulating NummSquared functions and proofs
NummSquared has an interpreter, NsGo (work in progress), so the language can
be practically used For enhanced reliability, NsGo is an F#/C# NET assembly that ismostly automatically extracted from a program of the Cog proof assistant (See [8] and[32].) NsGo (and hence NummSquared programs) inherit memory safety and auto-matic memory management from NET
NummSquared is now overviewed and compared to existing foundations
2.1 UNTYPED LAMBDA CALCULUS AND
suf-in Curry’s paradox (see [35, p.17])
Church invented the untyped lambda calculus in 1932 and, in reponse to the dox, Church's type theory in 1940 (see (35, p.4,8]) However, Russell discovered in 1902his paradox in Frege’s predicate calculus (see [41, section 2] and [25]) Russell’s para-dox exploits Frege’s course-of-values notation (which is somewhat similar to lambdanotation), together with Frege’s Basic Law V and Rule of Substitution Course-of-valuesnotation, together with Basic Law V, create a distinct object for each function, but thereare more functions than objects Russell’s solution to the paradox in 1903 was Russell’stheory of types In summary, Frege’s predicate calculus and Russell’s theory of types
Trang 29fur-Grue’s map theory (see [16, p.13-14, section 8.6, chapter 11]) is an improvement onthe untyped lambda calculus that includes ZFC set theory, but excluded middle is false
in general, although excluded middle is true in an important special case
[21, section 2.2] defines a programming language that includes the untyped lambdaterms and also set-theoretic functions Untyped lambda terms can be restricted to setdomains, and thus used as arguments to set-theoretic functions
None of the above improvements on the untyped lambda calculus eliminate terminating reductions, and each, except Howe, has a logic that is partially non-
non-classical (In the case of NaDSyL non-classicality appears differently: as ity of the set of formulas In the case of Howe, the programming language is not itself alogic, although it is used to give semantics to Nuprl.)
undecidabil-2.2 SET THEORY, VON NEUMANN AND JONES
Zermelo’s solution to Russell’s paradox in Frege’s predicate calculus, with sions by Fraenkel, resulted in ZF set theory, which builds up sets from existing sets(see [17, p.156-157,180-181]) ZF does not use types to avoid paradox Instead, ZF re-places Frege's course-of-values notation with more restricted abstraction: the axiom ofreplacement ZF plus the axiom of choice is called ZFC (see [36, p.84,132-133]) In ZEbecause of the axiom of regularity, membership is a well-founded relation on ZF sets -see [36, p.21] Thus ZF is well-founded
exten-The axiomatization of functions by von Neumann ([40]) is conceptually related toZFC, and has been adapted by others into a set theory called von Neumann-Bernays-Gédel (NBG) - see [30, p.176] Since set theory is the standard mathematical founda-tion, it is understandable that von Neumann's work was adapted into a set theory forpurposes of comparison with other set theories But computer science is primarilyabout computable functions, and many set theories, including ZFC and NBG, do notinclude rules of reduction for function calls, or even rules of reduction for set member-
Trang 30convention is set theory in first order logic; in computer science, the convention is atheory of functions.)
Even though von Neumann's axiomatization lacks rules of reduction, it is ally somewhat similar (see table 2.1) to combinatory logic (see [37, section 3]), which
conceptu-is closely related to the untyped lambda calculus But, while von Neumann's atization is a good foundation for logic and mathematics, combinatory logic and theuntyped lambda calculus are not (because, when augmented by negation and excludedmiddle, they suffer from Russells paradox; and augmenting by implication results inCurry’s paradox) So it is interesting that the most popular foundations for computerscience are the untyped lambda calculus, and untyped (but partially non-classical) andtyped improvements on it which eliminate the paradoxes, rather than von Neumann'saxiomatization which is more closely related to set theory in classical logic
axiom-von Neumann | combinatory logic
axiom II.1 I combinator
axiom IT.2 K combinator
axiom II.6 S combinator
Table 2.1: Von Neumann's axiomatization and combinatory logic roughly compared
Jones proposed Pure Functions ([26] as an axiomatization of functions that is lated to ZFC Pure Functions is defined using the formal language HOL (augmentedwith ZFC) However, Pure Functions lacks rules of reduction
re-Farmer ([10]) proposed “STMM: A Set Theory for Mechanized Mathematics” STMM
is based on NBG and, in STMM, sets, not functions, are fundamental However, STMMdoes have lambda notation for functions, and notation for function calls
Trang 31In von Neumann's axiomatization, there is a particular object representing false Afunction can itself be used as an argument iff the result of the function does not toooften differ from false (see [40, p.397], which includes a more precise definition) Falsemight be considered as the default result of the function, and the default cannot toooften be overridden The criterion for being used as an argument is not computable,which is problematic from a practical perspective.
In von Neumann's axiomatization there are also functions that cannot be used as anargument or result In Pure Functions there are functions that are external functions(taking the form of HOL functions- see (26, “Functional Abstraction”]) An externalfunction can be restricted to the domain of an internal function, in order to obtain aninternal function
Somewhat similarly to von Neumann and Pure Functions, NummSquared guishes small and large functions Like von Neumann, both small and large functionsare defined over all small functions, and they always return smail functions
distin-In NummSquared, for simplicity, only large functions appear directly in Squared programs, which differs from von Neumann and Pure Functions
Numm-In NummSquared, a large function ‘f can be Curried The partial call to to ‘fis asmall function, and is restricted using the domain of a small function
Neither von Neumann nor Jones attempt to make functions computable
NummSquared improves upon von Neumann's axiomatization and Pure Functions
func-¢ NummSquared supports reflection
* NummSquared has an interpreter, NsGo (work in progress), so the language can
be practically used
Trang 32As already mentioned, ZF is well-founded So is NBG when the axiom of ity is included - see [30, p.216] In Pure Functions, membership in the field of a PureFunction is a well-founded relation on Pure Functions Thus Pure Functions is well-founded.
regular-An important subset of map theory (called the classical maps) is well-founded - see[15, p.18] The range of a classical map is built up from existing classical maps How-ever, classical maps are defined over all maps, so the inductive hypothesis involves aninteresting complexity metric in place of assumptions about elements of the domain.NummSquared, unlike map theory, is well-founded in a similar way to Pure Func-tions: membership in the field of a NummSquared non-null small function is a well-founded relation on small functions However, NummSquared small functions, likemap theory classical maps, are defined over all small functions (in keeping with thegoal of minimizing constraints) This is accomplished as follows: a NummSquaredsmall function ‘f has a domain (a snall sub-language of the language of all small func-tions), but coercion (which is computable) is used to define ‘f over all small functions,even those outside the domain of ‘f NummSquared coercion is somewhat related tothe restriction of untyped lambda terms to set domains in [21, section 2.2] Obser-vational Type Theory in [1, section 2.2] has explicit coercion requiring proof of typeequality, whereas NummSquared coercion is automatic and does not require the pro-grammer to supply proof
The well-foundedness of NummSquared strengthens the connection betweenNummSquared and set theory
Function calls do not appear in NummSquared Sometimes it is said that free languages are difficult to read Actually, it is mostly a question of the notation towhich one is accustomed Therefore, although NummSquared is variable-free, Numm-Squared large and small composition combinations are written, in the concrete syntax,
Trang 33variable-using lambda calculus function call notation So NummSquared looks, in the concretesyntax, somewhat like the corresponding lambda calculus notation with the variablesremoved Furthermore, NummSquared has local tuple accessors as a replacement forargument variables.
2.7 REFLECTION
Programmers often find it useful to extend the syntax of a language Macro guages can provide such functionality, but a macro language often lacks the nice fea-tures of the language being extended Therefore, a better solution is reflection: For alanguage ‘L, ‘L supports reflection iff ‘L programs can manipulate (to some extent) ‘L
lan-programs.
As pointed out by [19, section 7], a language ‘L with terminating reduction (such asNummSquared) cannot express the ‘L interpreter There are several ways of dealingwith Hoare’s incomputability result:
s® Common usage of macro languages involves syntactic manipulations, meaningoperations that do not require calling the ‘L interpreter Expressing in ‘L macrosperforming syntactic manipulations does not require expressing in ‘L the ‘L inter-preter.
¢ Partial reflection, as proposed by (20, p.2-3]: For some part of ‘L, it may be ble to express in ‘L the interpreter for that part of ‘L Clearly, the chosen part of ‘Lcannot express the interpreter for that part
possi-¢ It may be possible to express in ‘L the bounded interpreter for ‘L, meaning thefunction identical to the ‘L interpreter, except that it halts with an error if inter-pretation does not complete in a pre-specified number of steps
Gilmore's ITT supports a very useful implicit quotation facility by allowing tain terms of a predicate type to have a secondary type: the type of subjects (see[11,p.xii,74]) Subject terms may be “mentioned”, but not “used” (called)
cer-Even without reflection, NummSquared’s large functions allow abstraction over allsmall functions Therefore, reflection in NummSquared is directed at allowing abstrac-tion over all large functions, without resorting to introducing super-large functions,
etc.
NummSquared reflection works as follows: In NummSquared, quotation convertsfrom a large function to a tree representation that can be manipulated by functions
Trang 34(small and large), and unquotation is the inverse process Unquotation cannot be usedwithin small or large functions - a necessary restriction since unquotation is effectivelythe interpreter for large functions That restriction does not prevent syntactic manipu-lations, thus NummSquared reflection partly eliminates the need for a macro language.NummSquared quotation and unquotation have some conceptual similarities withHowe's partial reflection and Gilmore's implicit quotation (although NummSquaredquotation is explicit) NummSquared reflection is greatly simplified by the fact thatNummSquared is variable-free.
In logic, reflection is also useful: For a language ‘L, ‘L supports logical reflection iff
‘L programs can manipulate ‘L proofs For example:
¢ Artemov’s Explicit Reflection Principle allows one to infer a formula from an ternal proof of that formula (see [3, section 7])
in-¢ Because Cog is typed, Coq proofs are Coq terms according to the Curry-Howardisomorphism (see [8, “Introduction”, section 4.1.1])
NummSquared proof reflection works as follows: In NummSquared, all proofs are in
a tree representation that can be manipulated by functions (small and large)
2.8 EQUALITY
A relation ‘R on functions is an extensional equality iff, for any two functions ‘f and
‘g, ‘Rrelates ‘f and ‘g iff the domains of ‘f and ‘g are equal, and the results of ‘f and ‘g(for any program of the common domain) are equal An extensional equality equatesfunctions that implement different algorithms (see [18, question 35]) Furthermore, anextensional equality is not computable Therefore, an extensional equality is somewhatproblematic in computer science In von Neumann's axiomatization and Pure Func-tions, equality is extensional
In NummSquared, rule small functions are represented by rules, whereas simplesmall functions are represented by simpler means NummSquared has equality, which
is extensional on rule small functions Equality cannot be used in reduction because it
is not computable, but equality is essential in propositions However, equality deeplyexcluding rule small functions is computable and can be used in reduction
Gilmore's Intensional Type Theory (ITT) includes an appealing Rule of
Intension-ality stating that the intensions of two predicates are Leibniz equal iff their names are
Trang 35Leibniz equal Gilmore avoids Russell's paradox by treating a predicate term as a nameonly when the predicate term has no free predicate variable (See [11, p.xii,85-86].) Theconcept of the Rule of Intensionality is important for equality in computer science.HiLog equality ([7, p.2-3]) is based on names, and is computable.
In future, NummSquared equality on rule small functions may be adapted to clude some aspects of ITT and HiLog At present, an extensional equality on rule smallfunctions is chosen for logical and mathematical simplicity, despite the problems forcomputer science An extensional equality on rule small functions strengthens theconnection between NummSquared and set theory (for example, the axiom of exten-sionality in ZF - see [36, p.8])
¢ Alternatively, because NsGo is a NET assembly, NsGo can be used as a library(and called in various ways) from within NET programs
Progress towards NsGo can be found in [22]
Trang 36CHAPTER 3
FORMAL AND INFORMAL,
A language is an unordered collection of things without duplicates For a language
‘L, a program of ‘Lis a thing belonging to ‘L For languages ‘LO and “L1, ‘LO = “L1 iff, foreach thing ‘x, ‘x is an ‘LO program iff ‘x is an ‘L1 program
A language ‘L is formal iff ‘L is defined precisely A language ‘L is informal iff ‘L isnot formal Mathematical English is an example of an informal language
A document (such as the one you are reading) comprises programs of one or morelanguages For a document ‘d, the formal part of ‘d is that part of ‘d comprising pro-grams of formal languages; and the informal part of ‘d is that part of ‘d comprisingprograms of informal languages Informal comments written within the formal partare considered to belong to the informal part, not the formal part
Here are some uses for the formal and informal parts of a document:
se Some practical aspects are best expressed in the informal part For example, theinformal part of the document you are reading is now being used to discuss theroles of the formal and informal parts of documents in general
¢ Although it is preferable to define ideas in the formal part, the informal part isstill useful for explaining ideas, and for relating ideas in the formal part to exist-ing ideas in the informal part
s The informal part is sometimes useful for defining a new formal language andrelating it to existing languages (formal and informal) However, with the avail-ability of good existing formal languages, it is preferable to use the formal part
to define a new formal language and relate it to existing formal languages, usingthe informal part only when necessary to relate a new formal language to existinginformal languages
Trang 37_ The formal part and informal part are the formal and informal parts, respectively,
of the document you are reading
Trang 38CHAPTER 4
WHERE TO FIND THE FORMAL PART
The document you are reading consists firstly of the informal part, including tailed definitions, theorems and proofs in mathematical English of the NummSquaredmetatheory At the end of this document, NummSquared metatheory is expressed inthe formal language Cog - this is currently a work in progress
Trang 39de-CHAPTER 5
NOTATION IN THE INFORMAL PART
Some notation is used in the informal part
Where a phrase is defined, the phrase is written like this
Text is given emphasis by writing it like this
When quoting sources, the text is written “like this”, as with the following pearl from
Dr L S River:
“LSR + T = F — TOTAL CLUELESS”
Informal identifiers are words beginning with grave accent (‘) Informal identifiersare case-sensitive, and may include periods (.) Here are four distinct informal identi-fiers: ‘x, “X, ‘XO and ‘A.x Informal identifiers are distinct from identifiers in the formalpart, and from identifiers of some language being discussed
Anatural number is one of the things 0, 1, 2, (each distinct from the others) Let
‘Nat be the language of all natural numbers
A Unicode code point (see [39, section 2.4]) is a natural number in the range
0-1114111 Let ‘Unicode be the language of all Unicode code points
Asingle isolated character in fixed-width font (the font distinguishes it from othertext) represents a Unicode code point Example: H
Two or more adjacent characters in fixed-width font represent a list (see below) of
‘Unicode Example:
"Hello, world! *
Trang 40CHAPTER 6
DATA IN THE INFORMAL PART
Various kinds of data are now defined for use in the informal part The language ofthe informal part is intended to provide approximately the same capabilities as NBGset theory (see [30, p.176])