Miscellaneous HOL Examples December 12, 2016 Contents 1 Some Isar command definitions 15 1.1 Diagnostic command: no state change............. 16 1.2 Old-style global theory declaration............... 16 1.3 Local theory specification.................... 16 2 Infinite Sets and Related Concepts 17 2.1 Infinitely Many and Almost All................. 18 2.2 Enumeration of an Infinite Set................. 21 3 Ad Hoc Overloading 24 3.1 Plain Ad Hoc Overloading.................... 24 3.2 Adhoc Overloading inside Locales................ 25 4 Permutation Types 27 5 Example of Declaring an Oracle 29 5.1 Oracle declaration........................ 29 5.2 Oracle as low-level rule...................... 29 5.3 Oracle as proof method..................... 30 6 Abstract Natural Numbers primitive recursion 34 7 Proof by guessing 37 8 Examples of function definitions 38 8.1 Very basic............................. 38 8.2 Currying.............................. 38 8.3 Nested recursion......................... 38 8.3.1 Here comes McCarthy's 91-function.......... 39 8.4 More general patterns...................... 39 8.4.1 Overlapping patterns................... 39 8.4.2 Guards.......................... 40 1 8.5 Mutual Recursion......................... 41 8.6 Definitions in local contexts................... 41 8.7 fun-cases ............................. 42 8.7.1 Predecessor........................ 42 8.7.2 List to option....................... 42 8.7.3 Boolean Functions.................... 43 8.7.4 Many parameters..................... 43 8.8 Partial Function Definitions................... 43 8.9 Regression tests.......................... 43 8.9.1 Context recursion.................... 44 8.9.2 A combination of context and nested recursion.... 44 8.9.3 Context, but no recursive call.............. 44 8.9.4 Tupled nested recursion................. 44 8.9.5 Let............................. 44 8.9.6 Abbreviations....................... 45 8.9.7 Simple Higher-Order Recursion............. 45 8.9.8 Pattern matching on records.............. 45 8.9.9 The diagonal function.................. 45 8.9.10 Many equations (quadratic blowup).......... 46 8.9.11 Automatic pattern splitting............... 46 8.9.12 Polymorphic partial-function.............. 46 9 Examples of automatically derived induction rules 47 9.1 Some simple induction principles on nat............ 47 10 Test of Locale Interpretation 48 11 Interpretation of Defined Concepts 48 11.1 Lattices.............................. 48 11.1.1 Definitions........................ 48 11.1.2 Total order <= on int .................. 57 11.1.3 Total order <= on nat .................. 58 11.1.4 Lattice dvd on nat .................... 59 11.2 Group example with defined operations inv and unit ..... 61 11.2.1 Locale declarations and lemmas............. 61 11.2.2 Interpretation of Functions............... 65 12 Using extensible records in HOL { points and coloured points 66 12.1 Points............................... 67 12.1.1 Introducing concrete records and record schemes... 67 12.1.2 Record selection and record update........... 67 12.1.3 Some lemmas about records............... 67 12.2 Coloured points: record extension................ 69 12.2.1 Non-coercive structural subtyping........... 70 2 12.3 Other features.......................... 70 12.4 A more complex record expression............... 72 12.5 Some code generation...................... 72 13 A general \while" combinator 72 13.1 Partial version.......................... 72 13.2 Total version........................... 76 14 An application of the While combinator 82 14.1 Example.............................. 82 15 Monoids and Groups as predicates over record schemes 83 16 Binary arithmetic examples 83 16.1 Regression Testing for Cancellation Simprocs......... 83 16.2 Arithmetic Method Tests.................... 85 16.3 The Integers............................ 86 16.4 The Natural Numbers...................... 89 16.5 Real Arithmetic.......................... 91 16.5.1 Addition.......................... 91 16.5.2 Negation......................... 91 16.5.3 Multiplication....................... 91 16.5.4 Inequalities........................ 91 16.5.5 Powers........................... 92 16.5.6 Tests............................ 92 16.6 Complex Arithmetic....................... 98 17 Examples for hexadecimal and binary numerals 99 18 Antiquotations 99 19 Multiple nested quotations and anti-quotations 100 20 Partial equivalence relations 101 20.1 Partial equivalence........................ 101 20.2 Equivalence on function spaces................. 102 20.3 Total equivalence......................... 103 20.4 Quotient types.......................... 103 20.5 Equality on quotients...................... 104 20.6 Picking representing elements.................. 105 21 Summing natural numbers 106 3 22 Three Divides Theorem 108 22.1 Abstract.............................. 108 22.2 Formal proof........................... 108 22.2.1 Miscellaneous summation lemmas............ 108 22.2.2 Generalised Three Divides................ 109 22.2.3 Three Divides Natural.................. 110 23 The Cubic and Quartic Root Formulas 112 24 The Cubic Formula 112 25 The Quartic Formula 115 26 The Pythagorean Theorem 115 27 Higher-Order Logic: Intuitionistic predicate calculus prob- lems 116 28 CTL formulae 122 28.1 Basic fixed point properties................... 123 28.2 The tree induction principle.................. 125 28.3 An application of tree induction................ 127 29 Arithmetic 127 29.1 Splitting of Operators: max, min, abs, op −, nat, op mod, op div ................................. 128 29.2 Meta-Logic............................ 130 29.3 Various Other Examples..................... 130 30 2-3 Trees 132 31 (Finite) multisets 141 31.1 The type of multisets....................... 141 31.2 Representing multisets...................... 142 31.3 Basic operations......................... 144 31.3.1 Conversion to set and membership........... 144 31.3.2 Union........................... 146 31.3.3 Difference......................... 147 31.3.4 Equality of multisets................... 149 31.3.5 Pointwise ordering induced by count.......... 151 31.3.6 Intersection and bounded union............. 155 31.3.7 Additional intersection facts............... 156 31.3.8 Additional bounded union facts............. 159 31.3.9 Subset is an order.................... 160 31.4 Replicate and repeat operations................. 160 4 31.4.1 Simprocs......................... 161 31.4.2 Conditionally complete lattice.............. 162 31.4.3 Filter (with comprehension syntax)........... 167 31.4.4 Size............................ 169 31.5 Induction and case splits..................... 171 31.5.1 Strong induction and subset induction for multisets. 172 31.6 The fold combinator....................... 173 31.7 Image............................... 175 31.8 Further conversions........................ 177 31.9 More properties of the replicate and repeat operations.... 183 31.10Big operators........................... 184 31.11Alternative representations................... 191 31.11.1 Lists............................ 191 31.12The multiset order........................ 195 31.12.1 Well-foundedness..................... 195 31.12.2 Closure-free presentation................ 198 31.13The multiset extension is cancellative for multiset union... 199 31.14Quasi-executable version of the multiset extension...... 200 31.14.1 Partial-order properties................. 201 31.14.2 Monotonicity of multiset union............. 203 31.14.3 Termination proofs with multiset orders........ 203 31.15Legacy theorem bindings..................... 206 31.16Naive implementation using lists................ 208 31.17BNF setup............................ 212 31.18Size setup............................. 219 32 Bubblesort 219 33 Merge Sort 221 34 A lemma for Lagrange's theorem 222 35 Groebner Basis Examples 223 35.1 Basic examples.......................... 223 35.2 Lemmas for Lagrange's theorem................. 224 35.3 Colinearity is invariant by rotation............... 225 36 Substitution and Unification 225 36.1 Terms............................... 226 36.2 Substitutions........................... 226 36.3 Unifiers and Most General Unifiers............... 228 36.4 The unification algorithm.................... 229 36.5 Properties used in termination proof.............. 229 36.6 Termination proof........................ 233 5 36.7 Unification returns a Most General Unifier........... 233 36.8 Unification returns Idempotent Substitution.......... 234 37 Primitive Recursive Functions 236 37.1 Ackermann's Function...................... 236 37.2 Primitive Recursive Functions.................. 238 38 The Full Theorem of Tarski 241 38.1 Partial Order........................... 244 38.2 sublattice............................. 248 38.3 lub................................. 248 38.4 glb................................. 250 38.5 fixed points............................ 251 38.6 lemmas for Tarski, lub...................... 251 38.7 Tarski fixpoint theorem 1, first part.............. 252 38.8 interval.............................. 253 38.9 Top and Bottom......................... 256 38.10fixed points form a partial order................ 257 39 Classical Predicate Calculus Problems 260 39.1 Traditional Classical Reasoner.................. 260 39.1.1 Pelletier's examples................... 260 39.1.2 Classical Logic: examples with quantifiers....... 262 39.1.3 Problems requiring quantifier duplication....... 262 39.1.4 Hard examples with quantifiers............. 263 39.1.5 Problems (mainly)
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages815 Page
-
File Size-