Theorem Proving and Algebra
Total Page:16
File Type:pdf, Size:1020Kb
SSSS Theorem Proving and Algebra SSSS Theorem Proving and SSSS Algebra Joseph A. Goguen SSSS Joseph A. Goguen SSSS SSSS S Theorem Proving and Algebra Theorem Proving and Algebra Joseph A. Goguen University of California, San Diego Joseph A. Goguen (1941–2006) Department of Computer Science and Engineering University of California, San Diego 9500 Gilman Drive, La Jolla CA 92093-0114 USA April 2006 © Joseph A. Goguen, 1990–2006. Edited by: Kokichi Futatsugi Narciso Martí-Oliet José Meseguer Text reviewed and commented by: Kokichi Futatsugi Daniel Mircea Gaina Narciso Martí-Oliet José Meseguer Masaki Nakamura Miguel Palomino Book designed and typeset by: Alberto Verdejo Contents Foreword by Editors xiii 1 Introduction 1 1.1 What is Theorem Proving? . 1 1.2 Applications of Theorem Proving . 2 1.3 Logic for Foundations versus Logic for Applications . 2 1.4 Why Equational Logic and Algebra? . 3 1.5 What Kind of Algebra? . 4 1.6 Term Rewriting . 5 1.7 Logical Systems and Proof Scores . 5 1.8 Semantics and Soundness . 6 1.9 Loose versus Standard Semantics . 7 1.10 Human Interface Design . 8 1.11 OBJ . 9 1.12 Some History and Related Work . 10 1.13 Using this Text . 12 1.13.1 Synopsis . 13 1.13.2 Novel Features . 13 1.14 Acknowledgements . 14 2 Signature and Algebra 15 2.1 Sets and Arrows . 15 2.2 Sorted Sets . 16 2.3 Signature . 18 2.4 Signatures in OBJ . 20 2.5 Algebras . 22 2.6 Term Algebras . 24 2.7 Unsorted Signature and Algebra . 26 2.8 Literature . 26 3 Homomorphism, Equation and Satisfaction 29 3.1 Homomorphism and Isomorphism . 29 3.1.1 Unsorted Homomorphisms . 32 3.2 Initiality of the Term Algebra . 33 vi Contents 3.2.1 Initiality and Structural Induction . 37 3.3 Equation and Satisfaction . 37 3.4 Conditional Equations and Satisfaction . 44 3.5 Substitution . 45 3.6 Pasting and Chasing . 46 3.7 (?) Parse . 52 3.8 Literature . 55 4 Equational Deduction 57 4.1 Rules of Deduction . 57 4.2 Equational Proof . 61 4.3 Soundness and Counterexamples . 63 4.3.1 What is a Counterexample? . 65 4.3.2 The Need for Quantifiers . 65 4.4 Completeness . 67 4.5 Subterm Replacement . 68 4.5.1 (?) An Alternative Congruence Rule . 72 4.5.2 Discussion . 73 4.6 Deduction using OBJ . 73 4.7 Two More Rules of Deduction . 76 4.8 Conditional Deduction and its Completeness . 77 4.8.1 Deduction with Conditional Equations in OBJ3 . 79 4.9 Conditional Subterm Replacement . 81 4.10 (?) Specification Equivalence . 83 4.11 (?) A More Abstract Formulation of Deduction . 88 4.12 Literature . 89 5 Rewriting 91 5.1 Term Rewriting . 91 5.2 Canonical Form . 97 5.3 Adding Constants . 106 5.4 Evaluation Strategies . 108 5.4.1 Memoization . 110 5.5 Proving Termination . 111 5.6 Proving Church-Rosser . 116 5.7 Abstract Rewrite Systems . 121 5.8 Conditional Term Rewriting . 127 5.8.1 Adding Constants . 130 5.8.2 Proving Termination . 131 5.8.3 (?) Noetherian Orderings . 141 5.8.4 Proving Church-Rosser . 149 5.9 (?) Relation between Abstract and Term Rewriting Sys- tems . 152 5.10 Literature . 154 Contents vii 6 Initial Algebras, Standard Models and Induction 159 6.1 Quotient and Initiality . 159 6.1.1 Congruence, Quotient and Image . 159 6.1.2 Initiality and Freedom . 165 6.1.3 Substitution Modulo Equations . 166 6.2 Abstract Data Types . 167 6.2.1 Motivation . 167 6.2.2 Formal Definition . 168 6.3 Standard Models are Initial Models . 171 6.4 Initial Truth and Subalgebras . 173 6.5 Induction . 174 6.5.1 Simple Inductive Proofs with OBJ . 176 6.5.2 Many-Sorted Induction . 179 6.6 A Closer Look at State, Encapsulation and Implemen- tation . 181 6.7 Literature . 182 7 Deduction and Rewriting Modulo Equations 183 7.1 Motivation . 183 7.2 Deduction Modulo Equations . 185 7.2.1 Some Implementation Issues . 187 7.2.2 Deduction Modulo Equations in OBJ3 . 189 7.3 Term Rewriting Modulo Equations . 192 7.3.1 Some Inductive Proofs Modulo Equations . 197 7.3.2 The Propositional Calculus . 200 7.3.3 Weak Rewriting Modulo Equations . 207 7.4 Verification of Hardware Circuits . 207 7.4.1 Unconditional Combinatorial Circuits . 208 7.4.2 Conditional Triangular Systems . 214 7.4.3 Proof Techniques . 218 7.4.4 Conditional Combinatorial Circuits . 220 7.4.5 Bidirectional Circuits . 224 7.5 Proving Termination Modulo Equations . 227 7.6 Proving Church-Rosser Modulo Equations . 232 7.6.1 Adding Constants . 235 7.7 Conditional Term Rewriting Modulo Equations . 235 7.7.1 Adding Constants . 240 7.7.2 Proving Termination . 241 7.7.3 Proving Church-Rosser . 243 7.8 Literature . 244 8 First-Order Logic and Proof Planning 247 8.1 First-Order Signatures, Models and Morphisms . 247 8.2 Horn Clause Logic . 249 8.2.1 (?) Initial Horn Models . 250 8.3 First-Order Logic . 253 viii Contents 8.3.1 First-Order Syntax . 254 8.3.2 Scope . 255 8.3.3 First-Order Semantics . 256 8.3.4 Substitution . 266 8.3.5 First-Order Logic with Equality . 269 8.3.6 Logic over a Fixed Model . 270 8.4 Proof Planning . 271 8.4.1 Deduction vs. Planning . 281 8.4.2 Correctness of a Ripple Carry Adder . 283 8.4.3 The Working Signature . 286 8.5 Reasoning with Existential Quantifiers . 287 8.6 Case Analysis . 291 8.7 Algebraic Induction . 294 8.8 Literature . 303 9 Second-Order Equational Logic 307 9.1 Theorem of Constants . 309 9.2 Second-Order Logic . 313 9.3 Verification of Sequential Circuits . 314 9.4 Literature and Discussion . 317 10 Order-Sorted Algebra and Term Rewriting 319 10.1 Signature, Algebra, and Homomorphism . 321 10.2 Term and Equation . 323 10.3 Deduction . 331 10.4 Congruence, Quotient, and Initiality . 334 10.5 Class Deduction . 339 10.6 Error, Coercion, and Retract . 340 10.6.1 Semantics of Retracts . 344 10.7 Order-Sorted Rewriting . 346 10.7.1 Adding Constants . 353 10.7.2 Proving Termination . 353 10.7.3 Proving Church-Rosser . 354 10.8 A Number System . 355 10.9 Multiple Representation and Coercion . 361 10.10 Literature . 362 11 Generic Modules 365 12 Unification 367 12.1 Blending . 368 13 Hidden Algebra 369 14 A General Framework (Institutions) 371 A OBJ3 Syntax and Usage 373 Contents ix B Exiled Proofs 379 B.1 Many-Sorted Algebra . 379 B.2 Rewriting . 381 B.2.1 (?) Orthogonal Term Rewriting Systems . 384 B.3 Rewriting Modulo Equations . 389 B.4 First-Order Logic . 389 B.5 Order-Sorted Algebra . 390 C Some Background on Relations 397 C.1 OBJ Theories for Relations . 401 D Social Implications 405 Bibliography 407 Editors’ Notes 423 x Contents List of Figures 2.1 Signature for Automata . 16 2.2 Signature for Numerical Expressions . ..