Texts in Computing Volume 19 Computational Logic Volume 1: Classical Deductive Computing with Classical Logic Volume 6 Automata and Dictionaries Denis Maurel and Franz Guenthner Volume 7 Learn Prolog Now! Patrick Blackburn, Johan Bos and Kristina Striegnitz Volume 8 A Meeting of the Minds: Proceedings of the Workshop on Logic, Rationality and Interaction, Beijing 2007 Johan van Benthem, Shier Jun and Frank Veltman, eds. Volume 9 Logic for Artificial Intelligence & Information Technology Dov M. Gabbay Volume 10 Foundations of Logic and Theory of Computation Amílcar Sernadas and Cristina Sernadas Volume 11 Invariants: A Generative Approach to Programming Daniel Zingaro Volume 12 The Mathematics of the Models of Reference Francesco Berto, Gabriele Rossi and Jacopo Tagliabue Volume 13 Picturing Programs Stephen Bloch Volume 14 JAVA: Just in Time John Latham Volume 15 Design and Analysis of Purely Functional Programs Christian Rinderknecht Volume 16 Implementing Programming Languages. An Introduction to Compilers and Interpreters Aarne Ranta, with an appendix coauthored by Markus Forsberg Volume 17 Acts of the Programme Semantics and Syntax. Isaac Newton Institute for the Mathematical Sciences, January to July 2012. Arnold Beckmann and Benedikt Löwe, eds. Volume 18 What Is a Computer and What Can It Do? An Algorithms-Oriented Introduction to the Theory of Computation Thomas C. O'Connell Volume 19 Computational Logic. Volume 1: Classical Deductive Computing with Classical Logic Luis M. Augusto Texts in Computing Series Editor Ian Mackie mackie@lix.polytechnique.fr Computational Logic Volume 1: Classical Deductive Computing with Classical Logic Luis M. Augusto © Individual author and College Publications 2018. All rights reserved. ISBN 978-1-84890-280-1 College Publications Scientific Director: Dov Gabbay Managing Director: Jane Spurr http://www.collegepublications.co.uk Cover produced by Laraine Welch Printed by Lightning Source, Milton Keynes, UK All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form, or by any means, electronic, mechanical, photocopying, recording or otherwise without prior permission, in writing, from the publisher. Contents Preface xiii I Introduction 1 0.1 Symbolic computation and classical computing . . . . . . 3 0.2 Logic: Formal, symbolic, deductive, and classical . . . . . 5 0.3 Computational logic and its subfields . . . . . . . . . . . . 8 0.4 Classical deductive computing and its assumptions . . . . 10 II Mathematical foundations 15 1 Mathematical notions 17 1.1 Basic notions . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.1.1 Sets, relations, functions, and operations . . . . . . 17 1.1.2 Binary relations and ordered sets . . . . . . . . . . 24 1.2 Discrete structures . . . . . . . . . . . . . . . . . . . . . . 29 1.2.1 Algebras and models . . . . . . . . . . . . . . . . . 29 1.2.2 Lattices . . . . . . . . . . . . . . . . . . . . . . . . 34 1.2.3 Graphs and trees . . . . . . . . . . . . . . . . . . . 41 1.3 Mathematical induction . . . . . . . . . . . . . . . . . . . 45 III Classical computing 49 2 Fundamentals of classical computing 51 2.1 Formal languages and grammars . . . . . . . . . . . . . . 51 2.1.1 Regular languages . . . . . . . . . . . . . . . . . . 59 2.1.2 Context-free languages . . . . . . . . . . . . . . . . 63 2.1.3 Recursively enumerable languages . . . . . . . . . 76 2.1.4 The Chomsky hierarchy (I) . . . . . . . . . . . . . 78 2.2 Models of computation . . . . . . . . . . . . . . . . . . . . 80 2.2.1 Finite-state machines . . . . . . . . . . . . . . . . 81 2.2.2 Pushdown automata . . . . . . . . . . . . . . . . . 99 2.2.3 Turing machines . . . . . . . . . . . . . . . . . . . 120 v Contents 2.2.4 The Chomsky hierarchy (II) . . . . . . . . . . . . . 132 2.3 Computability and complexity . . . . . . . . . . . . . . . 135 2.3.1 The decision problem and Turing-decidability . . . 135 2.3.2 Undecidable problems and Turing-reducibility . . . 139 2.3.3 The Chomsky hierarchy (III) . . . . . . . . . . . . 145 2.3.4 Computational complexity . . . . . . . . . . . . . . 147 2.3.5 The Chomsky hierarchy (IV) . . . . . . . . . . . . 163 IV Classical deduction and classical logic 165 3 Preliminaries: Formal logic, deduction, and deductive computation 167 3.1 Logical form I: Logical languages . . . . . . . . . . . . . . 168 3.1.1 Alphabets, expressions, and formulae logical . . . . 168 3.1.2 Orders . . . . . . . . . . . . . . . . . . . . . . . . . 171 3.1.3 Formalization . . . . . . . . . . . . . . . . . . . . . 176 3.2 Logical form II: Argument form . . . . . . . . . . . . . . . 184 3.3 Logical meaning: Valuations and interpretations . . . . . 191 3.4 Logical systems, logics, and logical theories . . . . . . . . 202 3.4.1 Logical consequence, inference, and deduction . . . 203 3.4.2 Syntactical consequence and proof theory . . . . . 209 3.4.3 Semantical consequence and model theory . . . . . 215 3.4.4 Adequateness of a deductive system . . . . . . . . 220 3.4.5 Logical theories . . . . . . . . . . . . . . . . . . . . 224 3.5 Deductive computation . . . . . . . . . . . . . . . . . . . 226 3.5.1 Logical problems and computational solutions . . . 227 3.5.2 Taming FOL undecidability . . . . . . . . . . . . . 230 3.5.2.1 Finite satisfiability and ground extensions 230 3.5.2.2 Finite models and prefix classes . . . . . 235 3.5.3 The complexity of logical problems . . . . . . . . . 237 4 The system CL and the logic CL 243 4.1 The language of classical logic . . . . . . . . . . . . . . . . 243 4.1.1 The language L1 . . . . . . . . . . . . . . . . . . . 243 4.1.2 Substitutions and unification for L1 . . . . . . . . 245 4.2 Classical logical consequence . . . . . . . . . . . . . . . . 251 4.2.1 Classical ♥-consequences . . . . . . . . . . . . . . 251 4.2.1.1 Classical syntactical ♥-consequences . . . 252 4.2.1.2 Classical semantical ♥-consequences . . 254 4.2.2 Classical -consequences . . . . . . . . . . . . . . 256 4.3 The logic of CL . . . . . . . . . . . . . . . . . . . . . . . . 258 vi Contents 4.4 Classical FO theories and the adequateness of CFOL . . . 261 4.5 The extension CL=: CL with equality . . . . . . . . . . . 269 5 Classical proofs 275 5.1 The axiom system L . . . . . . . . . . . . . . . . . . . . . 276 5.2 The natural deduction calculus NK . . . . . . . . . . . . 279 5.3 The sequent calculus LK . . . . . . . . . . . . . . . . . . . 284 6 Classical models 291 6.1 Tarskian semantics . . . . . . . . . . . . . . . . . . . . . . 291 6.2 Herbrand semantics . . . . . . . . . . . . . . . . . . . . . 295 6.3 Algebraic semantics: Boolean algebras . . . . . . . . . . . 302 V Classical deductive computing with classical logic 311 7 Classical logic and deductive computation 313 7.1 The computational problem of classical satisfiability, or SAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 7.2 Computerizing CFOL . . . . . . . . . . . . . . . . . . . . 321 7.2.1 Literals and clauses . . . . . . . . . . . . . . . . . 322 7.2.2 Negation normal form . . . . . . . . . . . . . . . . 323 7.2.3 Prenex normal form . . . . . . . . . . . . . . . . . 323 7.2.4 Skolem normal form . . . . . . . . . . . . . . . . . 324 7.2.5 Conjunctive and disjunctive normal forms . . . . . 325 7.3 Computing the SAT . . . . . . . . . . . . . . . . . . . . . 331 7.3.1 The different forms of the SAT . . . . . . . . . . . 331 7.3.2 The SAT and unsatisfiability I: The DPLL procedure and model finding . . . . . . . . . . . . . . . 333 7.3.3 The SAT and unsatisfiability II: Herbrand theorem and refutation . . . . . . . . . . . . . . . . . . 336 8 Automated theorem proving 343 8.1 Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . 344 8.1.1 The resolution principle for propositional logic . . 344 8.1.2 The resolution principle for FOL . . . . . . . . . . 350 8.1.3 Completeness of the resolution principle . . . . . . 359 8.1.4 Resolution refinements . . . . . . . . . . . . . . . . 360 8.1.4.1 A-ordering . . . . . . . . . . . . . . . . . 361 8.1.4.2 Hyper-resolution and semantic resolution 365 8.1.5 Paramodulation . . . . . . . . . . . . . . . . . . . 373 8.2 Analytic tableaux . . . . . . . . . . . . . . . . . . . . . . . 379 8.2.1 Analytic tableaux as a propositional calculus . . . 379 vii Contents 8.2.2 Analytic tableaux as a FO predicate calculus . . . 388 8.2.2.1 FOL tableaux without unification . . . . 389 8.2.2.2 FOL tableaux with unification . . . . . . 392 9 Programming 397 9.1 Logic programming as deductive programming . . . . . . 398 9.1.1 Query systems and programming systems . . . . . 398 9.1.2 LP programs and their meaning . . . . . . . . . . 403 9.1.3 Resolution and LP computations . . . . . . . . . . 411 9.1.4 Negation as failure . . . . . . . . . . . . . . . . . . 422 9.2 Prolog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430 9.2.1 Prolog and Prolog . . . . . . . . . . . . . . . . . . 430 9.2.2 Logic + control: ! and fail . . . . . . . . . . . . 435 9.2.3 Negation in Prolog: The predicate not . . . . . . 441 Bibliography 447 Bibliographical references 449 Index 457 viii List of Figures 1.1.1 A partially ordered set. . . . . . . . . . . . . . . . . . . . . 25 1.1.2 Hasse diagram of a poset. . . . . . . . . . . . . . . . . . . . 28 1.2.1 Join table of 2A. . . . . . . . . . . . . . . . . . . . . . . . . 36 1.2.2 Meet table of 2A. . . . . . . . . . . . . . . . . . . . . . . . 37 1.2.3 The lattice (S,∪,∩). . . . . . . . . . . . . . . . . . . . . . 37 1.2.4 The non-distributive lattices L1 and L2. . . . . . . . . . . 38 1.2.5 A simple graph with five vertices and seven edges. . . . . . 42 2.1.1 Derivation tree of the string w = acbabc ∈ L (G) with the corresponding partial derivation trees. . . . . . . . . . . . . 67 2.1.2 Two leftmost derivations of the string a + a ∗ a. . . . . . . 69 2.1.3 Parse tree of an unambiguously derived string. . . . . . . . 70 2.1.4 Parse trees for productions (1) S → a and (2) S → AB. . . 71 2.1.5 Parse tree for z = uviwxiy. . . . . . . . . . . . . . . . . . . 73 2.1.6 An algorithm based on the Chomsky hierarchy for deciding on the class of a language. . . . . . . . . . . . . . . . . . . 80 2.2.1 State diagrams of FSRs. . . . . . . . . . . . . . . . . . . . 84 2.2.2 A FSR with two accepting states and one rejecting state. . 84 2.2.3 A NDFSR accepting the language L = {001}∗ {0, 010}∗. . . 86 2.2.4 Equivalent NDFSR (1) and FSR (2). . . . . . . . . . . . . 91 2.2.5 Schematic diagrams for finite automata accepting (i) L1 ∪ L2, (ii) L1L2, and (iii) (L1) ∗. . . . . . . . . . . . . . . . . . 93 2.2.6 A finite automaton M for the pumping lemma. . . . . . . 95 2.2.7 Mealy (1) and Moore (2) machines. . . . . . . . . . . . . . 96 2.2.8 A PDA M accepting the language L (M) = {ambm|m ≥ 0}. 102 2.2.9 Proving the equivalence of L (M) = N (M). . . . . . . . . 105 2.2.10 NDFSR recognizing the viable prefixes for the CFG of Balanced Parentheses. . . . . . . . . . . . . . . . . . . . . 114 2.2.11 A Turing machine computing the function f (m,n) = m+n.123 2.2.12 The encodings 〈MT 〉 and 〈MT , z〉. . . . . . . . . . . . . . . 126 2.2.13 A Turing machine that computes the function f (n,m) = 2n + 3m. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 2.2.14 Program for a Turing machine computing the function f (n,m) = 2n + 3m. . . . . . . . . . . . . . . . . . . . . . 129 ix List of Figures 2.2.15 A combination of Turing machines. . . . . . . . . . . . . . 132 2.2.16 A Turing machine. . . . . . . . . . . . . . . . . . . . . . . 133 2.3.1 A combination of Turing machines. . . . . . . . . . . . . . 145 2.3.2 The Chomsky hierarchy and beyond: Decidable, Turingrecognizable, and not-Turing-recognizable languages. . . . 146 2.3.3 The hierarchy of complexity classes with corresponding tractability status. . . . . . . . . . . . . . . . . . . . . . . . 156 2.3.4 Typical structure of NP-completeness proofs by polynomialtime reductions. . . . . . . . . . . . . . . . . . . . . . . . . 160 3.1.1 Formalizations for English by means of the language of classical propositional logic. . . . . . . . . . . . . . . . . . 180 3.1.2 Formalizations for English by means of the language of classical FO logic. . . . . . . . . . . . . . . . . . . . . . . . 182 3.2.1 Some classical formally correct arguments. . . . . . . . . . 188 3.3.1 Truth table for the connective → in the 3-valued logics L3, KW 3 , and Rn3. . . . . . . . . . . . . . . . . . . . . . . . . 196 3.4.1 Adequateness of a deductive system L = (F, ). . . . . . . 223 4.1.1 Unifying the pair 〈P (a, x, h (g (z))) , P (z, h (y) , h (y))〉 . . 249 5.1.1 Proof of ⊢ L φ → φ . . . . . . . . . . . . . . . . . . . . . . . 277 5.1.2 Proof of {φ, ∀x (φ) → χ} ⊢ Lq ∀x (χ). . . . . . . . . . . . . . 277 5.2.1 Proof of ⊢NK ((A → B) ∧ (A → C)) → (A → (B ∧ C)). . . 281 5.2.2 Proof of an argument in (extended) NK. . . . . . . . . . . 283 5.2.3 A FO NK proof. . . . . . . . . . . . . . . . . . . . . . . . 283 5.3.1 Proof in LK of a FO validity. . . . . . . . . . . . . . . . . 287 5.3.2 Proof in LK of axiom L 2 of the axiom system L . . . . . 288 7.1.1 A tableau for the Turing machine M. . . . . . . . . . . . . 319 7.2.1 Tseitin transformations for the connectives of L. . . . . . . 329 7.3.1 A DPLL proof procedure. . . . . . . . . . . . . . . . . . . 335 7.3.2 Closed semantic tree of C = {C1, C2, C3, C4, C5} in Example 4.3.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 7.3.3 A closed semantic tree. . . . . . . . . . . . . . . . . . . . 340 8.1.1 A refutation tree. . . . . . . . . . . . . . . . . . . . . . . . 346 8.1.2 A propositional argument as input in Prover9-Mace4. . . . 346 8.1.3 Output by Prover9: A valid propositional argument. . . . 347 8.1.4 Output by Prover 9: A valid formula. . . . . . . . . . . . . 349 8.1.5 Output by Mace4: A counter-model. . . . . . . . . . . . . 349 8.1.6 A refutation failure tree. . . . . . . . . . . . . . . . . . . . 351 8.1.7 Input in Prover9-Mace4: A FO theory. . . . . . . . . . . . 352 x List of Figures 8.1.8 Output by Prover9. . . . . . . . . . . . . . . . . . . . . . . 353 8.1.9 Output by Prover9. . . . . . . . . . . . . . . . . . . . . . . 354 8.1.10 Schubert's steamroller in natural language. . . . . . . . . . 355 8.1.11 Schubert's steamroller in FOL. . . . . . . . . . . . . . . . . 356 8.1.12 Proof of Schubert's steamroller by Prover9. . . . . . . . . . 357 8.1.13 Hyper-resolution of Ξ = (C3; C1, C2). . . . . . . . . . . . . . 366 8.1.14 Theory of distributive lattices and commutativity of meet: Input in Prover9-Mace4. . . . . . . . . . . . . . . . . . . . 369 8.1.15 Proof by Prover9 of the commutativity of meet in a distributive lattice. . . . . . . . . . . . . . . . . . . . . . . . . 370 8.1.16 A linear-resolution refutation. . . . . . . . . . . . . . . . . 371 8.1.17 Theory of commutative groups: Input in Prover9-Mace4. . 376 8.1.18 Output by Prover9. . . . . . . . . . . . . . . . . . . . . . . 377 8.2.1 Analytic tableaux expansion rules: αβ-classification. . . . 382 8.2.2 A propositional tableau proof. . . . . . . . . . . . . . . . . 384 8.2.3 Analytic tableaux expansion rules: γδ-classification. . . . . 389 8.2.4 A FO tableau proof without unification. . . . . . . . . . . 391 8.2.5 A FO tableau with unification. . . . . . . . . . . . . . . . . 394 9.1.1 The abstract interpreter Ψ with input (π,G) operating with ground reductions. . . . . . . . . . . . . . . . . . . . . 412 9.1.2 A LI-resolution proof on a LP program. . . . . . . . . . . . 414 9.1.3 A LI-resolution proof tree. . . . . . . . . . . . . . . . . . . 415 9.1.4 A SLD-resolution proof. . . . . . . . . . . . . . . . . . . . 417 9.1.5 A complete proof tree. . . . . . . . . . . . . . . . . . . . . 418 9.1.6 SWI-Prolog answering a query and outputting traces for some "true" instantiations. . . . . . . . . . . . . . . . . . . 420 9.1.7 SWI-Prolog traces of a "true" and a "false" instantiation. . 421 9.2.1 A proof tree for a Prolog program with !. . . . . . . . . . . 438 xi

Preface It is often the case that computer science is considered merely a branch of mathematics. This (still) often motivates the belief that logic is required for computer science just because it is required for mathematics, namely for proofs. However, logic in computing goes well beyond the context of mathematical proof, being present today in fields such as artificial intelligence and cognitive science, and having significant engineering and industrial applications. This impressive plethora of computational applications of logic could not be possible without a large variety of logics, which for our purposes can be elegantly–i.e. by means of the English connector and–segregated in two major classes: classical logic(s) and non-classical logics. Yet another, but perhaps not so elegant, segregation must be contemplated when speaking of computing today: classical computing or non-classical computing. While in the latter kind one can include a large variety of computation models and computers (e.g., quantum computers, artificial neural networks, evolutionary computing), we shall consider classical computing to be the processing of information carried out by the von Neumann, or industrial-scale digital computer, which has as a major theoretical foundation the Turing computing paradigm. This paradigm, concretized in the Turing machine, sees computation as a spatial-temporal discrete business over symbols that can best be carried out in binary code. While this paradigm does not take into account the resources available for computation, the von Neumann computer is in fact constrained by physical–i.e. spatial and temporal–resources, which means that classical computing has more or less clearly established limitations. When logic, whether classical or non-classical, is applied in computing, either classical or non-classical, we speak of computational logic. This is an important label in at least two senses. Firstly, it captures the fact that there is a subfield of formal logic that can be applied in a computational setting. This subfield might be obtained by imposing restrictions (for example, on the sets of operators), but also by extensions or just plain variations. Secondly, it helps us to distinguish clearly between computation carried out with a logical language from computation carried out with other formal languages. In effect, while the latter xiii Preface typically is concerned with preserving the legality of symbol strings (legal strings are processed into further legal strings), the former often aims at truth-preservation. Say that we have a theory and wish to know whether some assertion follows logically from it, i.e. belongs to it, or is true in it. The deduction theorem allows us to express this logical following in a single symbol string, known as a logical formula, and our question is notoriously best concretized in the validity and satisfiability problems, which ask whether a logical formula is always true, or is true in some interpretation, respectively. When these problems–in particular the latter–are posed in a computational context, we accordingly speak of deductive computation. When the computational solution is to be found by means of classical computing, we then speak of classical deductive computing. In this book we elaborate on classical deductive computing with classical logic, and we do so without a specific regard to the field of application. Our foci are first and foremost two main subjects in which classical deductive computing with classical logic has a prominent role: automated theorem proving and logic programming. This is thus a book on applied logic. Furthermore, this is a book on applied mathematical logic. We take here the label mathematical logic as synonymous with formal logic, and this in a very narrow sense: formal logic is logic whose foundations lie in mathematical objects and structures. Although these mathematical foundations may be inconspicuous at the object-language level, at the metalanguage level they do become more conspicuous or even explicit. Interestingly enough–though not surprising anymore–, the mathematical structures and objects usually required in mathematical logic are precisely those needed for classical deductive computing; we talk here of lattices, graphs, trees, etc., all known as discrete structures and objects. This accounts for a whole chapter (Chapter 1) dedicated to the topics of discrete mathematics required for a satisfactory grasping of the material in this book. More specifically, we restrictively provide the mathematical notions that are foundational for both the theory of classical computing and classical deduction. Chapter 1 constitutes Part II of this volume, Part I being the Introduction. Were this book on formal logic alone, there would be no need for a chapter on the theory of computing. Although logical languages are first and foremost formal languages, outside a computational context no issues of computability or complexity arise–certainly not in the usual treatment of logic for philosophy courses, but not even in pure mathematical logic textbooks. These issues arise when we need to compute with logical languages (e.g., Turing-completeness of programming lanxiv guages). Because these issues arise here, we need to approach Turing machines, which, in turn, require the fundamentals of formal languages and models of computation, in order to be satisfactorily understood. We thus provide the basics of the general theory of classical computing, which includes the study of formal languages and grammars, models of computation, and computability theory. As a matter of fact, we provide more than the basics, doing so in the belief that such knowledge often comes in handy for anyone interested in computational logic. This material constitutes Chapter 2, which is Part III. This book is one–the first–of two volumes addressing the topic of classical deductive computing. In it we focus on computing with classical logic. Although new technologies have opened a path that led to a proliferation of new logics, the so-called non-classical logics, classical logic remains as the standard logical system which the other, newer, systems extend or from which they diverge. This would be reason enough to justify this volume, but the fact is that, despite the many technological advances witnessed in the last decades, classical logic is still the logical system of choice for many technological applications requiring what in this book we call deductive computation. Although the literature on classical logic is prolific, with many good introductions to the subject, with self-containment in view we provide a whole chapter (Chapter 4) on classical logic. This follows a comprehensive discussion on formal logic, deduction, and deductive computation carried out in Chapter 3, in which such fundamental notions as logical language, from the viewpoints of both form and meaning, and logical consequence, in relation to inference and deductive systems, as well as to computation, are thoroughly discussed. The decision problem in computational logic is overwhelmingly tackled by checking for (un)satisfiability, namely by means of the so-called SAT testers or solvers. However, we thought that a working knowledge of classical validity testing methods is also required. These–the classical calculi–we present in Chapter 5, which is followed, in Chapter 6, by the different semantics that provide a foundation for meaning in classical logic. Chapters 3 to 6, constituting Part IV of this book, comprise our discussion of classical deduction and classical logic. In Part V, we begin by elaborating on the (classical) satisfiability problem, already introduced in Chapter 2, and by providing the means to computerize classical logic with a view to finding computational solutions to this problem. This satisfiability testing is extensively discussed in the remaining Sections of this Chapter 7. We then proceed with extensive treatments of the aforementioned main fields of computational xv Preface logic, to wit, automated theorem proving (Chapter 8) and logic programming (Chapter 9). With respect to the former, we give an equal weight to resolution and analytic tableaux. This is uncommon, as the resolution calculus has all but obliterated the analytic tableaux calculus in the context of automated theorem proving, but we think this obliteration is not justified and hope to contribute to the reassessment of the pay-offs of further automating the analytic tableaux calculus. Precisely due to this imbalance our treatment of this calculus is not as comprehensive as our elaboration on resolution. As far as logic programming is concerned, we naturally focus on Prolog, as this is the major (family of) language(s) in this programming paradigm. It is our belief that by mastering the essential aspects of Prolog related to its deductive capabilities, as well as the general theory of logic programming, the reader will be well equipped to tackle most tasks involving this programming paradigm, as well as other (sub-)languages thereof such as Datalog and Answer Set Programming. We restrict our elaboration on classical computing to first-order predicate logic, which is known to be adequate (i.e. sound and complete) and as such provides us with a reliable means for classical deductive computation. This by no means entails that we disfavor higher-order logics, but we leave their inclusion in this text to possible future editions thereof. As said above, this is the first of two volumes. Born in the late 1960s / early 1970s, computational logic has quickly grown to have many subfields or subjects; many, indeed (see Introduction). Clearly, this proliferation cannot be covered by a single volume, and we decided to divide the material we find essential in two volumes, the main segregation between both being that we dedicate this (first) volume to computing with classical logic, and we shall elaborate on computation with non-classical logics in a second volume. This segregation is justified not only by the fact that classical and non-classical logics have very different computational assumptions and applications, but also by the sheer quantity of topics that need to be addressed; a single book would certainly be too voluminous and readers may be interested in only one of these, classical or non-classical logics. An advantage of this project over other works in the field is the breadth of its covering: the reader has in it far more content on computational logic than is usually the case in a single monograph or textbook. This, like any advantage, comes at a price, though: depth had to be relinquished. This is, however, remediated by bibliographical references to works of a more limited breadth but with greater depth of treatment. Moreover, this work contains a large selection of exercises on all the approached topics. Having in mind both that most specialized monoxvi graphs and handbooks lack any exercises and the large variety of topics here approached, this is indeed yet another advantage, at least for the reader of a more practical persuasion. In our selection of exercises we included novel material (e.g., theorems not given in the main text), so that the reader is expected also to approach problems in computational logic in a creative way. Exercises asking the reader to reflect on some statements or passages, as well as to engage in research, are also included. These latter exercises are meant to complement the main text with some topics that, while not being secondary, would require some extended discussion, making of this a much larger volume. Some final remarks: Some of the material in this volume draws on two books of ours also published in College Publications, to wit, Augusto (2017a, b). This material either is as was first published, or has been submitted to some, often substantial, revisions and extensions. As was or revised/extended, it is mostly to be found in Chapters 1, 7, and 8, as well as in all Chapters of Part IV, though not in all Sections thereof. Chapters 2 and 9, as well as many Sections in Part IV (e.g., Sections 3.1-3), are completely novel, drawing only from folklore or from works by other authors. These are orthodoxly cited and indicated in the bibliographical references, but not always did we see it necessary to do so, especially with respect to material that has to some extent already acquired the character of mathematical or logical folklore. Being a book on computational logic, this is, as said,–also–a book on mathematical logic. This explains the usual distinction in the main text of statements into definitions (abbreviated Def.), propositions (Prop.), and the odd undistinguished paragraph that for ends of internal reference is referred to as "§"; these are all given a number indicating the Section (two digits separated by a dot) and the order in the Section. For example, 2.1.3 (Def.) indicates Definition 3 in Section 2.1. Theorems, as well as their companion lemmas and corollaries, are numbered in the same way but separately from the other numbered statements, and the same holds for examples. Exercises are numbered according to not only Section, but also Subsection. It is usual to provide the reader with a schematic guide for the reading of a book in the fields that are our foci. With this in mind, but not wishing to direct the reader more than the Table of Contents already is expected to do, we think that in order for the lay reader to have a minimal satisfactory grasping of classical deductive computing with classical logic the following topics are essential: The system of classical logic CL and the logic CL (Chapter 4), Herbrand semantics (concentrated in Sections 6.2 and 7.3.3), and Sections 7.1-2 for the satisfiability problem and for the necessary means to make logical formulae of CL xvii Preface amenable to computation. These are sine-qua-non requirements for a good understanding of automated theorem proving (Chapter 8) or logic programming (Chapter 9), or both. The novice reader wishing to gain a full grasp of our main topic cannot eschew the reading of the whole volume. It should be remarked, however, that some Chapters are selfstanding in the sense that they can be used independently from the rest of the volume. This is particularly true of Chapter 2, which is largely conceived as a condensed treatment–with the usual selection of exercises–of the theory of classical computing, and thus can be of use for readers whose interest might fall exclusively on this topic. For reasons to do with time, we do not include solutions to any of the exercises in this edition, but sooner or later they are expected to be provided, either online or in later editions. Readers wishing to contribute with original solutions to problems other than the most basic ones (e.g., proofs of theorems) are welcome to contact me for this end. My thanks go to Dov M. Gabbay for including this work in this excellent series of College Publications, and to Jane Spurr for her usual impeccable assistance in the publication process. Madrid, June 2018 Luis M. Augusto xviii