Introductory logic and sets for Computer scientists

Similar documents
Logic and its Applications

LOGIC AND DISCRETE MATHEMATICS

MATHEMATICAL STRUCTURES FOR COMPUTER SCIENCE

Win32 Network Programming

Mathematica for Scientists and Engineers

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

DISCRETE MATHEMATICS

Automatic Text Processing

Contents. Chapter 1 SPECIFYING SYNTAX 1

Summary of Course Coverage

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

An Introduction to Object-Oriented Programming

CSE 20 DISCRETE MATH. Fall

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

COMPUTER AND ROBOT VISION

Mathematically Rigorous Software Design Review of mathematical prerequisites

EXTENSIONS OF FIRST ORDER LOGIC

CSE 20 DISCRETE MATH. Winter

Discrete Mathematics Lecture 4. Harper Langston New York University

Boolean Reasoning. The Logic of Boolean Equations. Frank Markham Brown Air Force Institute of Technology

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

Lecture 1: Conjunctive Queries

System BIOS for IBM PCs, Compatibles, and EISA Computers, Second Edition

Data Structures in C++ Using the Standard Template Library

COMPUTATIONAL SEMANTICS WITH FUNCTIONAL PROGRAMMING JAN VAN EIJCK AND CHRISTINA UNGER. lg Cambridge UNIVERSITY PRESS

Programming. In Ada JOHN BARNES TT ADDISON-WESLEY

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

Advanced Programming in the UNIX Environment W. Richard Stevens

Propositional Logic Formal Syntax and Semantics. Computability and Logic

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England

Programming in Python 3

CMSC 330: Organization of Programming Languages. Operational Semantics

CSC 501 Semantics of Programming Languages

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

AXIOMS FOR THE INTEGERS

Propositional Calculus. Math Foundations of Computer Science

An Evolution of Mathematical Tools

Software Engineering Lecture Notes

Notes. Notes. Introduction. Notes. Propositional Functions. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Programming Languages Third Edition

quanüfied Statements; valid well-formed formulas; comparison of propositional and predicate wffs. Exercises

Designing the User Interface

CSC Discrete Math I, Spring Sets

Fundamentals of Discrete Mathematical Structures

Lecture 5. Logic I. Statement Logic

Systems:;-'./'--'.; r. Ramez Elmasri Department of Computer Science and Engineering The University of Texas at Arlington

An Annotated Language

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

MECHATRONICS. William Bolton. Sixth Edition ELECTRONIC CONTROL SYSTEMS ENGINEERING IN MECHANICAL AND ELECTRICAL PEARSON

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Logic as a framework for NL semantics. Outline. Syntax of FOL [1] Semantic Theory Type Theory

logic with quantifiers (informally)

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

AN INTRODUCTION TO FUZZY SETS Analysis and Design. Witold Pedrycz and Fernando Gomide

Digital System Design with SystemVerilog

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Warm-Up Problem. Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol. Give an interpretation where

Introduction to dependent types in Coq

PYTHON. p ykos vtawynivis. Second eciitiovl. CO Ve, WESLEY J. CHUN

Chapter 3: Propositional Languages

Proofs-Programs correspondance and Security

Introductory Combinatorics

FUNDAMENTALS OF. Database S wctpmc. Shamkant B. Navathe College of Computing Georgia Institute of Technology. Addison-Wesley

FUZZY SPECIFICATION IN SOFTWARE ENGINEERING

COURSE: DATA STRUCTURES USING C & C++ CODE: 05BMCAR17161 CREDITS: 05

BOOLEAN ALGEBRA AND CIRCUITS

Real-Time Systems and Programming Languages

15-819M: Data, Code, Decisions

1.3. Conditional expressions To express case distinctions like

Data Integration: Logic Query Languages

Automated Reasoning. Natural Deduction in First-Order Logic

MATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).

Research Collection. Reusable mathematical models. Master Thesis. ETH Library. Author(s): Widmer, Tobias K. Publication Date: 2004

Semantics. There is no single widely acceptable notation or formalism for describing semantics Operational Semantics

Th(N, +) is decidable

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

An Introduction to Programming and Proving in Agda (incomplete draft)

Computation Engineering Applied Automata Theory and Logic. Ganesh Gopalakrishnan University of Utah. ^J Springer

About the Author. Dependency Chart. Chapter 1: Logic and Sets 1. Chapter 2: Relations and Functions, Boolean Algebra, and Circuit Design

Formal Predicate Calculus. Michael Meyling

Formal Methods in Software Engineering 1

Solutions to In-Class Problems Week 1, Fri

Towards a Logical Reconstruction of Relational Database Theory

Modern Information Retrieval

A Survey of Mathematics with Applications 8 th Edition, 2009

Propositional Logic. Andreas Klappenecker

The Unified Modeling Language User Guide

Z Notation. June 21, 2018

Dynamic Logic David Harel, The Weizmann Institute Dexter Kozen, Cornell University Jerzy Tiuryn, University of Warsaw The MIT Press, Cambridge, Massac

SOFTWARE ENGINEERING DESIGN I

We ve studied the main models and concepts of the theory of computation:

The three faces of homotopy type theory. Type theory and category theory. Minicourse plan. Typing judgments. Michael Shulman.

ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES. Nikolay Kosovskiy

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Formal Specification: Z Notation. CITS5501 Software Testing and Quality Assurance

Transcription:

Introductory logic and sets for Computer scientists Nimal Nissanke University of Reading ADDISON WESLEY LONGMAN Harlow, England II Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Amsterdam «* Bonn Sydney Singapore Tokyo Madrid II San Juan Milan Mexico City Seoul # Taipei

Contents Preface A note on the exercises XIII xvi 1 An overview of logic 1.1 1.2 1.3 1.4 1.5 1.6 1.7 What is logic? Logic in real arguments Arguments and deduction The logical Systems Scientific theories and specifications Mathematical modeis Limitations of our study 1 2 3 3 5 7 8 2 Propositions and propositional connectives 10 2.1 Propositions 11 2.2 Connectives 12 2.3 Ambiguity and imprecision 19 3 Propositional logic as a language 22 3.1 About formal languages 23 3.2 Grammar of propositional logic 24 3.3 The semantics 28 3.4 Truth tables 29 3.5 Tautologies, contradictions and contingent propositions 30 3.6 Notations: T vs true and F vs false 33 3.7 Logical equivalence and logical implication 35 3.8 An application: digital circuits 37 4 Transformational proofs 45 4.1 Logical laws and how to establish them 45 4.2 The logical laws listed 49

4.3 On the art of proofs 52 4.4 An application: programming 55 4.5 An application: digital circuits 57 5 Deductive proofs 60 5.1 Arguments 60 5.2 Validity 62 5.3 Demonstrating validity using truth tables 63 5.4 Demonstrating invalidity 64 5.5 Proving validity using deductive proofs 66 5.6 Inference rules 66 5.7 On the art of proofs 71 5.8 An application: reasoning in theories 78 6 Predicates and quantifiers 80 6.1 The need for predicate logic 80 6.2 Predicates 81 6.3 Unary predicates 83 6.4 Predicate logic and propositional logic 84 6.5 Quantifiers 85 6.6 Elementary reasoning in predicate logic 87 6.7 Predicates with higher arities 88 6.8 An application: program specification 90 7 Further predicate logic 96 7.1 Scope of quantifiers 96 7.2 Bound and free variables 98 7.3 Types of values 100 7.4 Some Conventions 102 7.5 Comparison with variable usage in programming 104 7.6 Comparison with variable usage in mathematics 106 8 Interpretation of formulae 108 8.1 Interpretation of universal quantification 108 8.2 Interpretation of existential quantification 110 8.3 Theorems in predicate logic and proofs 110 8.4 Useful theorems in predicate logic 112 9 Proofs in predicate logic 113 9.1 Recapitulation 114 9.2 Formulae in propositional form 114 9.3 Unknowns and genuine variables 116 9.4 Notation for new inference rules 118 9.5 What to guard against 119

Contents ix 9.6 Theorems in predicate logic 129 9.7 An application: program refinement 133 10 Proof by mathematical induction 141 10.1 What is mathematical induction? 141 10.2 Relationship with induction 142 10.3 The technique of mathematical induction 144 10.4 An application: algorithm analysis 153 11 Basic set theoretical concepts 163 11.1 Whataresets? 163 11.2 How to define sets? 164 11.3 Setequality 166 11.4 The empty set 167 11.5 The universal set 167 11.6 Subsets 168 11.7 Sizeofsets 170 11.8 Power set 171 11.9 An extended notation for sets 172 12 Operations on sets 174 12.1 Binary set Operations 174 12.2 Uses of sets 177 12.3 Set theoretic laws listed 179 12.4 Set theoretic proofs 181 12.5 Generalized set Operations 183 12.6 Disjointsets 185 12.7 An application: formal System specification 185 13 Relations: basic concepts 195 13.1 Pairs and tuples 195 13.2 Cartesian product 196 13.3 Relations as sets 198 1 3.4 Relations as predicates 200 13.5 Graphical representation of relations 202 13.6 Domain, ränge and field 203 13.7 Inverse relation 204 1 3.8 Identity relation 206 1 3.9 An application: relational model of databases 207 14 Advanced relational Operations 211 14.1 Relational composition 211 14.2 Iteration 214 14.3 An application: relational image 216

14.4 Domain and ränge restriction and co-restriction 218 14.5 Relational overriding 220 15 Properties of binary relations 224 15.1 Properties of binary relations 225 15.2 Equivalence relations 227 15.3 Partitions and equivalence classes 232 15.4 Relational closures 236 16 Functions and their Classification 240 16.1 Functions as relations 241 16.2 Classification of functions 243 16.3 Functions as expressions 251 16.4 Function composition 253 16.5 An application: more on formal System specification 256 16.6 An application: functional programming 261 17 Numbers 273 17.1 Natural numbers 273 17.2 Integers 279 17.3 A tour through other number Systems 283 1 7.4 Dense vs sparse sets 288 17.5 Countability 288 17.6 Numbers in Computers 289 18 Sequencesand bags 299 18.1 Sequences as sets 299 18.2 Operations on sequences 301 18.3 Bags 304 18.4 Operations on bags 305 19 Boolean algebra 308 19.1 What is Boolean algebra? 309 19.2 Theorems in Boolean algebra 310 19.3 Proof of theorems 312 19.4 Propositional Interpretation of Boolean algebra 314 19.5 Set interpretation of Boolean algebra 315 19.6 Significance of Boolean algebra 316 20 Lambda abstraction of functions 317 20.1 Curried functions 317 20.2 Infix Operators 318 20.3 Function names 319

Contents xi 20.4 Lambda abstraction 320 20.5 Lambda calculus 322 20.6 Modeiling mathematical objects 334 Appendix: Outline answers to exercises 336 References 374 Index 375