Topic 1: Propositional logic

Similar documents
Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

CM10196 Topic 2: Sets, Predicates, Boolean algebras

Discrete Mathematics and Its Applications

Propositional natural deduction

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Propositional Logic and Semantics

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

4 Derivations in the Propositional Calculus

Truth-Functional Logic

Propositional logic (revision) & semantic entailment. p. 1/34

1.3 Propositional Equivalences

LING 106. Knowledge of Meaning Lecture 3-1 Yimei Xiang Feb 6, Propositional logic

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

A statement is a sentence that is definitely either true or false but not both.

Logic As Algebra COMP1600 / COMP6260. Dirk Pattinson Australian National University. Semester 2, 2017

Computation and Logic Definitions

Section 1.1: Logical Form and Logical Equivalence

CS 2800: Logic and Computation Fall 2010 (Lecture 13)

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

Proof strategies, or, a manual of logical style

Logic: Propositional Logic (Part I)

Logic. Propositional Logic: Syntax

Warm-Up Problem. Is the following true or false? 1/35

Compound Propositions

Propositional Equivalence

MA103 STATEMENTS, PROOF, LOGIC

Propositional Logic. Spring Propositional Logic Spring / 32

Tautologies, Contradictions, and Contingencies

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows.

The statement calculus and logic

Language of Propositional Logic

CSE 20: Discrete Mathematics

15414/614 Optional Lecture 1: Propositional Logic

CSC Discrete Math I, Spring Propositional Logic

Manual of Logical Style (fresh version 2018)

Definition 2. Conjunction of p and q

Solutions to Homework I (1.1)

Discrete Structures & Algorithms. Propositional Logic EECE 320 // UBC

Section 1.2 Propositional Equivalences. A tautology is a proposition which is always true. A contradiction is a proposition which is always false.

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims

Propositional Logic: Syntax

Logic. Definition [1] A logic is a formal language that comes with rules for deducing the truth of one proposition from the truth of another.

Propositional Logic. Yimei Xiang 11 February format strictly follow the laws and never skip any step.

Inference in Propositional Logic

3.0. OBJECTIVES 3.1.INTRODUCTION

CSE20: Discrete Mathematics for Computer Science. Lecture Unit 2: Boolan Functions, Logic Circuits, and Implication

Propositional Logic: Equivalence

Logic. Propositional Logic: Syntax. Wffs

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 15 Propositional Calculus (PC)

Introduction to Metalogic

Propositional logic ( ): Review from Mat 1348

Tecniche di Verifica. Introduction to Propositional Logic

Arguments and Proofs. 1. A set of sentences (the premises) 2. A sentence (the conclusion)

1.1 Statements and Compound Statements

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 1

CS1800: Hex & Logic. Professor Kevin Gold

3 The Semantics of the Propositional Calculus

Lecture 7. Logic. Section1: Statement Logic.

CS70 is a course about on Discrete Mathematics for Computer Scientists. The purpose of the course is to teach you about:

CISC-102 Winter 2016 Lecture 17

Discrete Mathematics and Probability Theory Fall 2012 Vazirani Note 1

Comp487/587 - Boolean Formulas

Example. Logic. Logical Statements. Outline of logic topics. Logical Connectives. Logical Connectives

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 1

Boolean Algebra. Philipp Koehn. 9 September 2016

Introducing Proof 1. hsn.uk.net. Contents

3 The language of proof

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:

Lecture 4: Proposition, Connectives and Truth Tables

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

CSE 311: Foundations of Computing. Lecture 2: More Logic, Equivalence & Digital Circuits

1 Propositional Logic

It rains now. (true) The followings are not propositions.

Unit 1. Propositional Logic Reading do all quick-checks Propositional Logic: Ch. 2.intro, 2.2, 2.3, 2.4. Review 2.9

cis32-ai lecture # 18 mon-3-apr-2006

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Boolean algebra. Examples of these individual laws of Boolean, rules and theorems for Boolean algebra are given in the following table.

AI Principles, Semester 2, Week 2, Lecture 5 Propositional Logic and Predicate Logic

Math 144 Summer 2012 (UCR) Pro-Notes June 24, / 15

THE LOGIC OF COMPOUND STATEMENTS

Propositional Logic. Logical Expressions. Logic Minimization. CNF and DNF. Algebraic Laws for Logical Expressions CSC 173

The semantics of propositional logic

CHAPTER 10. Gentzen Style Proof Systems for Classical Logic

Mathematical Logic Part One

CHAPTER 1. MATHEMATICAL LOGIC 1.1 Fundamentals of Mathematical Logic

1.1 Language and Logic

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Chapter 4: Classical Propositional Semantics

Logic, Sets, and Proofs

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic

CITS2211 Discrete Structures Proofs

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example

Announcements. CS311H: Discrete Mathematics. Propositional Logic II. Inverse of an Implication. Converse of a Implication

Equivalence and Implication

Symbolic Logic 3. For an inference to be deductively valid it is impossible for the conclusion to be false if the premises are true.

Natural Deduction for Propositional Logic

Mathematical Logic Part One

Logic and Proofs. (A brief summary)

Supplementary Logic Notes CSE 321 Winter 2009

Transcription:

Topic 1: Propositional logic Guy McCusker 1 1 University of Bath Logic! This lecture is about the simplest kind of mathematical logic: propositional calculus. We discuss propositions, which are statements that can be either true or false. Every proposition is either true or false; there is no middle ground. Guy McCusker (University of Bath) Topic 1: Propositional logic 2 / 50 Propositions This view of propositions is rather simple minded. Is it reasonable for the following statements? 2 + 2 = 4. 3 * 5 = 23948723894. it is raining. Bath is a beautiful city. Guy McCusker (University of Bath) Topic 1: Propositional logic 3 / 50

Connectives, laws,... We will study the logic of these simple propositions by considering: connectives ways of combining propositions laws facts about propositions that hold regardless of the truth values of those propositions tautologies propositions that are always true, no matter what the world looks like. Guy McCusker (University of Bath) Topic 1: Propositional logic 4 / 50 Proofs A central theme of mathematical logic is that of proofs. Important questions include: what constitutes a valid proof? can we be sure that things we prove are actually true? can we prove everything that is true? We will not consider these ideas much in this course. Guy McCusker (University of Bath) Topic 1: Propositional logic 5 / 50 Conjunction and disjunction The two most basic connectives are conjunction (AND) and disjunction (OR). In symbols, conjunction is, while disjunction is. Given propositions x and y, we can form new propositions x y x y. x y is true if both x and y are; it is false otherwise. x y is true if either x or y is true, or if both are true; it is false otherwise. Guy McCusker (University of Bath) Topic 1: Propositional logic 6 / 50

Truth tables This kind of definition is often expressed as a truth table (cf. multiplication tables). Truth table for : x y x y t t t t f f f t f f f f And for : x y x y t t t t f t f t t f f f Guy McCusker (University of Bath) Topic 1: Propositional logic 7 / 50 Negation As well as talking about a statement, such as Angela is Bens sister, we can talk about its negation: Angela is not Bens sister. The negation of a proposition x is written x and pronounced not x. It has an easy truth table: x x t f f t Guy McCusker (University of Bath) Topic 1: Propositional logic 8 / 50 Implication Implication is the connective corresponding to if... then... Here are some examples... which ones are true? if n > m then n + 1 > m + 1. if n > m then 2 + 2 = 4. if 2 + 2 = 3 then I m a Dutchman. if 2 + 2 = 4 then I m a Dutchman. Guy McCusker (University of Bath) Topic 1: Propositional logic 9 / 50

Truth of implication An implication, written, says that if something (the antecedent) is true, then something else (the consequent) is also true. It says nothing about what happens if the antecedent is false. Therefore, the only way an implication can be false is the antecedent must be true, so that the implication statement has something to say; the consequent must be false, so that what the implication statement is saying is false. Guy McCusker (University of Bath) Topic 1: Propositional logic 10 / 50 Truth table for implication Truth table for : x y x y t t t t f f f t t f f t Guy McCusker (University of Bath) Topic 1: Propositional logic 11 / 50 Boolean formulae We will now take a very simple, but very common mathematical step. We ve defined a collection of operations (,,, ) which operate on a collection of values (t, f). We now begin to talk about formulae, in which we use variables like X and Y to stand for unknown values, and combine them with the operations. This is just like the beginnings of algebra in school: we can start to talk about formulae like X + X = 2 X and wonder whether they are true or not... Guy McCusker (University of Bath) Topic 1: Propositional logic 12 / 50

Boolean formulae Here s a formal definition. Definition Given a collection of variables, X 1...X n, a Boolean formula is a string of symbols from the set of the following form: {X 1,...,X n,,,,, (, )} any variable X i is a Boolean formula if F and G are Boolean formulae, so are (F G), (F G), (F G) and F. Guy McCusker (University of Bath) Topic 1: Propositional logic 13 / 50 Boolean formulae That definition is extremely formal. All it says is that we build Boolean formulae by starting with variables and combining them with the operations, etc., adding brackets to keep things unambiguous. In practice we will often not bother to write all the brackets. Guy McCusker (University of Bath) Topic 1: Propositional logic 14 / 50 Boolean formulae Which of these are Boolean formulae? (X Y ) (X Y ) (X (Y Z)) (X ) X ((X Y ) ( Z Y )) Guy McCusker (University of Bath) Topic 1: Propositional logic 15 / 50

Evaluating Boolean formulas Given a Boolean formula containing variables X 1,...,X n, we can evaluate that formula for any given truth values of those variables. If we re told whether each X i is true or false, we can replace each X i in the formula by t or f appropriately work out the truth value of the whole formula using truth tables. Guy McCusker (University of Bath) Topic 1: Propositional logic 16 / 50 Evaluating Boolean formulas Different truth values for the variables will give different truth values for the whole formula. For instance, the formula (X Y ) ( Z Y ) will evaluate to t if we set but to f if we set X Y Z X Y Z t t f t t t Guy McCusker (University of Bath) Topic 1: Propositional logic 17 / 50 Evaluating a formula Let s evaluate (X Y ) ( Z Y ) with X, Y and Z all set to t. (X Y ) ( Z Y ) (t t) ( t t) (t f) ( t t) f ( t t) f (f t) f f f Guy McCusker (University of Bath) Topic 1: Propositional logic 18 / 50

Tautologies Some formulas are true regardless of what truth values their variables take. These are called tautologies. Definition A Boolean formula F with variables X 1,...,X n is called a tautology if the value of F is t for any assignment of true/false values to the variables X i. Example The following are tautologies: X X X X X X (X X) (( X Y ) ( X Y )) X. Guy McCusker (University of Bath) Topic 1: Propositional logic 19 / 50 Checking that X X is a tautology To check that X X is a tautology, we have to check that setting X to t makes the formula true, and that setting X to f makes the formula true. Setting X to t: (X X) (t t) (t f) t Setting X to f: (X X) (f f) (f t) t Guy McCusker (University of Bath) Topic 1: Propositional logic 20 / 50 Exercise Now check that the other examples from a few slides back are all tautologies. Since most of them involve only the variable X, there are only two cases to consider: when X is t and when X is f. For the last one, (( X Y ) ( X Y )) X, there are two variables and hence four cases. However, remember that an implication is always true if the right hand side (the consequent) is true, so in practice you only need to worry about the cases when X is set to f. Make sure you understand why! Guy McCusker (University of Bath) Topic 1: Propositional logic 21 / 50

Substituting in tautologies A tautology like X X is true regardless of what X is. This means that we can replace X by any proposition, or any other formula, and we still have a tautology. For example, replacing X by Y Z gives us which is still a tautology. (Y Z) (Y Z) Guy McCusker (University of Bath) Topic 1: Propositional logic 22 / 50 Logical equivalence A pair of formulas F 1 and F 2 are logically equivalent if one holds whenever the other does. That is to say: if F 1 is true then so is F 2 i.e. F 1 F 2 if F 2 is true then so is F 1 i.e. F 2 F 1. That is to say, F 1 and F 2 are equivalent if is a tautology. (F 1 F 2 ) (F 2 F 1 ) This formula is so important we introduce special notation for it: we write F 1 F 2 as an abbreviation for the above. Guy McCusker (University of Bath) Topic 1: Propositional logic 23 / 50 Laws Mathematicians like to talk about laws that various operators obey, for instance: Commutativity Addition and multiplication are commutative: 3 + 4 = 4 + 3, 2 9 = 9 2 etc. In general, x + y = y + x and x y = y x. Associativity When doing more than one addition or multiplication, the order in which you do the operations does not matter: 3 (4 5) = (3 4) 5 and so on. What s the general form? Distributivity There are laws that let you distribute one operation over another: 3 (4 + 5) = (3 4) + (3 5). What s the general form? Guy McCusker (University of Bath) Topic 1: Propositional logic 24 / 50

Laws of logic The basic laws of the operations and are very much like those of and +: the operations are commutative and associative, and there s a distributive law for over. (Unlike in arithmetic, there s another distributive law too.) Commutativity of and Let x and y be propositions. Then x y is true if and only if y x is true. x y is true if and only if y x is true. We could also phrase this by saying: given variables X, Y, the formulas X Y Y X X Y Y X are tautologies. Guy McCusker (University of Bath) Topic 1: Propositional logic 25 / 50 Associativity Associativity of For variables X, Y and Z, the formula X (Y Z) (X Y ) Z is a tautology. Associativity of For variables X, Y and Z, the formula X (Y Z) (X Y ) Z is a tautology. Guy McCusker (University of Bath) Topic 1: Propositional logic 26 / 50 Distributive laws In arithmetic, we have the distributive law In logic there are two similar laws: x (y + z) = (x y) + (x z). Distribution of over Given variables X, Y and Z, the formula is a tautology. X (Y Z) (X Y ) (X Z) Distribution of over Given variables X, Y and Z, the formula is a tautology. X (Y Z) (X Y ) (X Z) Guy McCusker (University of Bath) Topic 1: Propositional logic 27 / 50

Easy exercises 1 Prove that all these laws hold by evaluating the appropriate truth tables. 2 We have one distributive law for + and and two for and. What would the second law for + and look like? Why is it not true? Guy McCusker (University of Bath) Topic 1: Propositional logic 28 / 50 De Morgan s Laws The de Morgan laws relate and via : de Morgan s laws Given variables X and Y, the formulae (X Y ) ( X Y ) (X Y ) ( X Y ) are tautologies. You should check this! Guy McCusker (University of Bath) Topic 1: Propositional logic 29 / 50 More laws of logic 1 X X. The law of excluded middle. 2 X X. 3 (X X). 4 (( X Y ) ( X Y ) X. Reductio ad absurdum, or proof by contradiction. 5 (X Y ) ( X Y ). Check all these! Guy McCusker (University of Bath) Topic 1: Propositional logic 30 / 50

What do the laws mean? The law X X says that, whatever proposition you re thinking of (X), either it s true, or its negation is true. Put another way, every proposition is either true or false. Put another way, there is no middle ground between true and false. That s why it s called the law of excluded middle. Guy McCusker (University of Bath) Topic 1: Propositional logic 31 / 50 What do the laws mean? The law (( X Y ) ( X Y ) X is called proof by contradiction. It is used as follows. We want to prove that something (X) is true. Instead of showing that X is true, we show that it cannot be false. To do this, show that if X holds then so do two contradictory statements: Y and Y. Since that is impossible, X cannot be true, so X must be. Guy McCusker (University of Bath) Topic 1: Propositional logic 32 / 50 A proof by contradiction Theorem There are infinitely many prime numbers. Proof Suppose there are finitely many prime numbers. Then for some numner n there are exactly n primes. Call these p 1,..., p n. Consider the number (p 1 p 2 p n ) + 1. It s easy to see that this does not divide by any of the primes p 1,..., p n. It is therefore a prime. So there are more than n primes. We have shown that there are both n primes and more than n primes, a contradiction. So our assumption must be false, i.e. there are infinitely many primes. Guy McCusker (University of Bath) Topic 1: Propositional logic 33 / 50

Doing without connectives The law (X Y ) ( X Y ) means that any formula involving can be rewritten to an equivalent one using and. This means that, if we want to, we can always do without and just use and instead. Similarly, we have X Y (X Y ) so we can replace with and too. ( X Y ) This means that any boolean formula can be equivalently written using just and. Guy McCusker (University of Bath) Topic 1: Propositional logic 34 / 50 Doing without connectives Alternatively, we could use and to express, so we can write any formula just using and. Similarly, and would do. In Boolean circuits, there s an operation called NAND, which is short for not and. It s defined by x NAND y = (x y). It s important because it turns out that you can write everything just in terms of NAND. exercise Show how to express,, and using just NAND. Guy McCusker (University of Bath) Topic 1: Propositional logic 35 / 50 Disjunctive normal form We re now going to show that every Boolean formula can be written in a particular special shape, called a normal form. This is helpful for various reasons. One is that it gives you a handle on what kinds of formulas there are. Another is that it makes it relatively easy to design circuits to implement formulas. Definition A formula is in disjunctive normal form (DNF) if it is of the form where each F i is of the form F 1 F 2 F n L 1 L 2 L ki and each L i is either a variable, X, or the negation of a variable, X. Guy McCusker (University of Bath) Topic 1: Propositional logic 36 / 50

Disjunctive normal form Example The following formulas are in disjunctive normal form: X (Y Z). X Y. X. (X Y ) (Y Z). The following are not in disjunctive normal form: X (Y Z). (X Y ). X X. Guy McCusker (University of Bath) Topic 1: Propositional logic 37 / 50 DNFs as truth tables DNFs are just a kind of truth table written as a formula. A formula like (X Y ) ( Z Y ) can be thought of as having a truth table: X Y Z (X Y ) ( Z Y ) t t t f t t f t t f t t t f f t f t t t f t f t f f t t f f f t Guy McCusker (University of Bath) Topic 1: Propositional logic 38 / 50 DNFs as truth tables This truth table tells us that the formula is true if the values of the variables are those on any of the lines apart from the top one. The second line has X and Y true, and Z false. This happens exactly when X Y Z holds. Similarly, the third line comes into play when holds. X Y Z We can write similar formulae expressing each of those seven lines. The truth table tells us that, if line 2 holds or line 3 holds or line 4 holds or line 5 holds or line 6 holds or line 7 holds or line 8 holds, then the formula is true, and otherwise it is false. Guy McCusker (University of Bath) Topic 1: Propositional logic 39 / 50

DNFs as truth tables That means that the formula is true exactly when (X Y Z) (X Y Z) (X Y Z) ( X Y Z) ( X Y Z) ( X Y Z) ( X Y Z) which is a DNF! We can do the same trick to generate a DNF for any formula. Guy McCusker (University of Bath) Topic 1: Propositional logic 40 / 50 The DNF Theorem Theorem Every Boolean formula is equivalent to one in DNF. Proof Do the truth table trick outlined above. Guy McCusker (University of Bath) Topic 1: Propositional logic 41 / 50 Simpler DNFs The DNF we just created is not as simple as it could be. (X Y Z) (X Y Z) (X Y Z) ( X Y Z) ( X Y Z) ( X Y Z) ( X Y Z) The two lines in red, when taken together, are equivalent to just X Y. Guy McCusker (University of Bath) Topic 1: Propositional logic 42 / 50

Simpler DNFs This gives us ( X Y ) (X Y Z) (X Y Z) (X Y Z) ( X Y Z) ( X Y Z) Again we can simplify the red lines to just X Y. Guy McCusker (University of Bath) Topic 1: Propositional logic 43 / 50 Simpler DNFs This gives us ( X Y ) ( X Y ) (X Y Z) (X Y Z) (X Y Z) Again we can simplify the red lines to just X. Guy McCusker (University of Bath) Topic 1: Propositional logic 44 / 50 Simpler DNFs This gives us X (X Y Z) (X Y Z) (X Y Z) Now the red lines simplify to just X Y. Guy McCusker (University of Bath) Topic 1: Propositional logic 45 / 50

Simpler DNFs This gives us X (X Y ) (X Y Z) Since the first line handles all the cases where X is not true, we can drop all the Xs in later lines. This gives us: X Y (Y Z) Guy McCusker (University of Bath) Topic 1: Propositional logic 46 / 50 Simpler DNFs X Y (Y Z) Similarly, the second line handles all the cases where Y is not true, so we can drop Y from the last line giving us just which is a lot simpler! X Y Z Guy McCusker (University of Bath) Topic 1: Propositional logic 47 / 50 Calculating DNFs using laws We don t have to go through the truth table to produce a DNF. Often it s easier just to use the laws that we know: (X Y ) ( Z Y ) ( X Y ) ( Z Y ) = X Y ( Z Y ) which is a DNF. Again we can simplify it to X Y Z if we want to. Guy McCusker (University of Bath) Topic 1: Propositional logic 48 / 50

Conjunctive normal form There s another kind of normal form called conjunctive normal form which is sometimes useful. Definition A formula is in conjunctive normal form (CNF) if it is of the form where each F i is of the form F 1 F 2 F n L 1 L 2 L ki and each L i is either a variable, X, or the negation of a variable, X. Guy McCusker (University of Bath) Topic 1: Propositional logic 49 / 50 The CNF theorem Theorem Every Boolean formula is equivalent to one in CNF. Proof Let B be a boolean formula. By the DNF theorem, B it is equivalent to a DNF F 1 F n. Therefore B is equivalent to (F 1 F n ). By de Morgan s law, (F 1 F n ) F 1 F n. Each F i is L 1 L ki so again by de Morgan s law, each F i is equivalent to L 1 L ki. Each L j is either X or X which is equivalent to X, so this gives us a CNF equivalent to B. Guy McCusker (University of Bath) Topic 1: Propositional logic 50 / 50