## Essential Logic for Computer Science

by Page, Gamboa

### Instructor Requests

An introduction to applying predicate logic to testing and verification of software and digital circuits that focuses on applications rather than theory.

Computer scientists use logic for testing and verification of software and digital circuits, but many computer science students study logic only in the context of traditional mathematics, encountering the subject in a few lectures and a handful of problem sets in a discrete math course. This book offers a more substantive and rigorous approach to logic that focuses on applications in computer science. Topics covered include predicate logic, equation-based software, automated testing and theorem proving, and large-scale computation.

Formalism is emphasized, and the book employs three formal notations: traditional algebraic formulas of propositional and predicate logic; digital circuit diagrams; and the widely used partially automated theorem prover, ACL2, which provides an accessible introduction to mechanized formalism. For readers who want to see formalization in action, the text presents examples using Proof Pad, a lightweight ACL2 environment. Readers will not become ALC2 experts, but will learn how mechanized logic can benefit software and hardware engineers. In addition, 180 exercises, some of them extremely challenging, offer opportunities for problem solving. There are no prerequisites beyond high school algebra. Programming experience is not required to understand the book's equation-based approach. The book can be used in undergraduate courses in logic for computer science and introduction to computer science and in math courses for computer science students.

Expand/Collapse All
Contents (pg. vii)
Preface (pg. xiii)
I. LOGIC AND EQUATIONS (pg. 1)
1. Computer Systems: Simple Principles Lead to Complex Behavior (pg. 3)
1.1 Hardware and Software (pg. 3)
1.2 Structure of a Program (pg. 5)
1.3 Deep Blue and Inductive Definitions (pg. 9)
2. Boolean Formulas and Equations (pg. 15)
2.1 Reasoning with Equations (pg. 15)
2.2 Boolean Equations (pg. 19)
2.3 Boolean Formulas (pg. 27)
2.4 Digital Circuits (pg. 33)
2.5 Deduction (pg. 37)
2.6 Predicates and Quantifiers (pg. 51)
2.7 Reasoning with Quantified Predicates (pg. 55)
2.8 Boolean Models (pg. 63)
2.9 More General Models with Predicates and Quantifiers (pg. 68)
3. Software Testing and Prefix Notation (pg. 71)
Exercises (pg. 76)
4. Mathematical Induction (pg. 79)
4.1 Lists as Mathematical Objects (pg. 79)
4.2 Mathematical Induction (pg. 85)
4.3 Defun: Defining Operators in ACL2 (pg. 92)
4.4 Concatenation, Prefixes, and Suffixes (pg. 93)
5. Mechanized Logic (pg. 101)
5.1 ACL2 Theorems and Proofs (pg. 102)
5.2 Using Books of Proven Theorems (pg. 103)
5.3 Theorems with Constraints (pg. 105)
5.4 Helping Mechanized Logic Find Its Way (pg. 107)
5.5 Proof Automation and Things That Can’t Be Done& (pg. 112)
II. COMPUTER ARITHMETIC (pg. 121)
6. Binary Numerals (pg. 123)
6.1 Numbers and Numerals (pg. 123)
6.2 Numbers from Numerals (pg. 129)
6.3 Binary Numerals (pg. 134)
7.2 Circuits for Adding One-Bit Binary Numerals (pg. 140)
7.3 Circuit for Adding Two-Bit Binary Numerals (pg. 143)
7.4 Adding w-Bit Binary Numerals (pg. 145)
7.5 Numerals for Negative Numbers (pg. 150)
8. Multipliers and Bignum Arithmetic (pg. 157)
III. ALGORITHMS (pg. 167)
9. Multiplexers and Demultiplexers (pg. 169)
9.1 Multiplexer (pg. 169)
9.2 Demultiplexer (pg. 173)
10. Sorting (pg. 177)
10.1 Insertion-Sort (pg. 178)
10.2 Order-Preserving Merge (pg. 182)
10.3 Merge-Sort (pg. 184)
10.4 Analysis of Sorting Algorithms (pg. 186)
11. Search Trees (pg. 201)
11.1 Finding Things (pg. 201)
11.2 The AVL Solution (pg. 203)
11.3 Representing Search Trees (pg. 206)
11.4 Ordered Search Trees (pg. 207)
11.5 Balanced Search Trees (pg. 208)
11.6 Inserting a New Item in a Search Tree (pg. 210)
11.7 Insertion, Case by Case (pg. 212)
11.8 Double Rotations (pg. 218)
11.9 Fast Insertion (pg. 223)
12. Hash Tables (pg. 227)
12.1 Lists and Arrays (pg. 227)
12.2 Hash Operators (pg. 229)
12.3 Some Applications (pg. 236)
IV. COMPUTATION IN PRACTICE (pg. 241)
13. Sharding with Facebook (pg. 243)
13.1 The Technical Challenge (pg. 243)
13.2 Stopgap Remedies (pg. 245)
13.3 The Cassandra Solution (pg. 247)
13.4 Summary (pg. 249)
14. Parallel Computation with MapReduce (pg. 251)
14.1 Vertical and Horizontal Scaling (pg. 251)
14.2 The MapReduce Strategy (pg. 252)
14.3 Data Mining with MapReduce (pg. 256)
14.4 Summary (pg. 261)
15. Generating Art with Computers (pg. 263)
15.1 Representing Images in a Computer (pg. 263)
15.2 Generating Images Randomly (pg. 266)
15.3 Generating Purposeful Images (pg. 270)
Index (pg. 273)
Contents (pg. vii)
Preface (pg. xiii)
I. LOGIC AND EQUATIONS (pg. 1)
1. Computer Systems: Simple Principles Lead to Complex Behavior (pg. 3)
1.1 Hardware and Software (pg. 3)
1.2 Structure of a Program (pg. 5)
1.3 Deep Blue and Inductive Definitions (pg. 9)
2. Boolean Formulas and Equations (pg. 15)
2.1 Reasoning with Equations (pg. 15)
2.2 Boolean Equations (pg. 19)
2.3 Boolean Formulas (pg. 27)
2.4 Digital Circuits (pg. 33)
2.5 Deduction (pg. 37)
2.6 Predicates and Quantifiers (pg. 51)
2.7 Reasoning with Quantified Predicates (pg. 55)
2.8 Boolean Models (pg. 63)
2.9 More General Models with Predicates and Quantifiers (pg. 68)
3. Software Testing and Prefix Notation (pg. 71)
Exercises (pg. 76)
4. Mathematical Induction (pg. 79)
4.1 Lists as Mathematical Objects (pg. 79)
4.2 Mathematical Induction (pg. 85)
4.3 Defun: Defining Operators in ACL2 (pg. 92)
4.4 Concatenation, Prefixes, and Suffixes (pg. 93)
5. Mechanized Logic (pg. 101)
5.1 ACL2 Theorems and Proofs (pg. 102)
5.2 Using Books of Proven Theorems (pg. 103)
5.3 Theorems with Constraints (pg. 105)
5.4 Helping Mechanized Logic Find Its Way (pg. 107)
5.5 Proof Automation and Things That Can’t Be Done& (pg. 112)
II. COMPUTER ARITHMETIC (pg. 121)
6. Binary Numerals (pg. 123)
6.1 Numbers and Numerals (pg. 123)
6.2 Numbers from Numerals (pg. 129)
6.3 Binary Numerals (pg. 134)
7.2 Circuits for Adding One-Bit Binary Numerals (pg. 140)
7.3 Circuit for Adding Two-Bit Binary Numerals (pg. 143)
7.4 Adding w-Bit Binary Numerals (pg. 145)
7.5 Numerals for Negative Numbers (pg. 150)
8. Multipliers and Bignum Arithmetic (pg. 157)
III. ALGORITHMS (pg. 167)
9. Multiplexers and Demultiplexers (pg. 169)
9.1 Multiplexer (pg. 169)
9.2 Demultiplexer (pg. 173)
10. Sorting (pg. 177)
10.1 Insertion-Sort (pg. 178)
10.2 Order-Preserving Merge (pg. 182)
10.3 Merge-Sort (pg. 184)
10.4 Analysis of Sorting Algorithms (pg. 186)
11. Search Trees (pg. 201)
11.1 Finding Things (pg. 201)
11.2 The AVL Solution (pg. 203)
11.3 Representing Search Trees (pg. 206)
11.4 Ordered Search Trees (pg. 207)
11.5 Balanced Search Trees (pg. 208)
11.6 Inserting a New Item in a Search Tree (pg. 210)
11.7 Insertion, Case by Case (pg. 212)
11.8 Double Rotations (pg. 218)
11.9 Fast Insertion (pg. 223)
12. Hash Tables (pg. 227)
12.1 Lists and Arrays (pg. 227)
12.2 Hash Operators (pg. 229)
12.3 Some Applications (pg. 236)
IV. COMPUTATION IN PRACTICE (pg. 241)
13. Sharding with Facebook (pg. 243)
13.1 The Technical Challenge (pg. 243)
13.2 Stopgap Remedies (pg. 245)
13.3 The Cassandra Solution (pg. 247)
13.4 Summary (pg. 249)
14. Parallel Computation with MapReduce (pg. 251)
14.1 Vertical and Horizontal Scaling (pg. 251)
14.2 The MapReduce Strategy (pg. 252)
14.3 Data Mining with MapReduce (pg. 256)
14.4 Summary (pg. 261)
15. Generating Art with Computers (pg. 263)
15.1 Representing Images in a Computer (pg. 263)
15.2 Generating Images Randomly (pg. 266)
15.3 Generating Purposeful Images (pg. 270)
Index (pg. 273)

#### Rex Page

Rex Page is Professor Emeritus in the School of Computer Science at the University of Wyoming.

#### Ruben Gamboa

Ruben Gamboa is Professor in the Department of Computer Science at the University of Wyoming.

Instructors
You must have an instructor account and submit a request to access instructor materials for this book.
 eTextbook Go paperless today! Available online anytime, nothing to download or install. 6 months / \$20.00 12 months / \$30.00