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

Similar documents
Truth-Functional Logic

Logic Overview, I. and T T T T F F F T F F F F

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

Logic: Propositional Logic (Part I)

02 Propositional Logic

Learning Goals of CS245 Logic and Computation

Language of Propositional Logic

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

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

Topic 1: Propositional logic

CS156: The Calculus of Computation

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

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

CS100: DISCRETE STRUCTURES. Lecture 5: Logic (Ch1)

Compound Propositions

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

CSCI Homework Set 1 Due: September 11, 2018 at the beginning of class

Mat 243 Exam 1 Review

Introduction to Sets and Logic (MATH 1190)

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

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Tecniche di Verifica. Introduction to Propositional Logic

A brief introduction to Logic. (slides from

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Chapter 16. Logic Programming. Topics. Logic Programming. Logic Programming Paradigm

EECS 1028 M: Discrete Mathematics for Engineers

Logic and Proofs. (A brief summary)

MAT2345 Discrete Math

Advanced Topics in LP and FP

COMP 2600: Formal Methods for Software Engineeing

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

The statement calculus and logic

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

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.

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Chapter 1 Elementary Logic

Overview. Knowledge-Based Agents. Introduction. COMP219: Artificial Intelligence. Lecture 19: Logic for KR

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

Chapter Summary. Propositional Logic. Predicate Logic. Proofs. The Language of Propositions (1.1) Applications (1.2) Logical Equivalences (1.

Lecture 4: Proposition, Connectives and Truth Tables

Propositional Logic. Jason Filippou UMCP. ason Filippou UMCP) Propositional Logic / 38

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

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

Propositional Logic: Methods of Proof (Part II)

Propositional Logic. Spring Propositional Logic Spring / 32

Foundation of proofs. Jim Hefferon.

Overview. 1. Introduction to Propositional Logic. 2. Operations on Propositions. 3. Truth Tables. 4. Translating Sentences into Logical Expressions

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

Title: Logical Agents AIMA: Chapter 7 (Sections 7.4 and 7.5)

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

Lecture 7. Logic. Section1: Statement Logic.

Strong AI vs. Weak AI Automated Reasoning

Deductive Systems. Lecture - 3

Propositional Logic and Semantics

Propositional Logic: Part II - Syntax & Proofs 0-0

Chapter 4, Logic using Propositional Calculus Handout

Section 1.1: Logical Form and Logical Equivalence

Propositional Logic Language

Logic and Inferences

Logic as a Tool Chapter 1: Understanding Propositional Logic 1.1 Propositions and logical connectives. Truth tables and tautologies

Part I: Propositional Calculus

Formal Logic: Quantifiers, Predicates, and Validity. CS 130 Discrete Structures

Logic and Proof. Aiichiro Nakano

AI Programming CS S-09 Knowledge Representation

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

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

Introduction to Decision Sciences Lecture 2

Introduction to Metalogic

Propositional Logic: Review

Logic - recap. So far, we have seen that: Logic is a language which can be used to describe:

THE LOGIC OF COMPOUND STATEMENTS

LOGIC CONNECTIVES. Students who have an ACT score of at least 30 OR a GPA of at least 3.5 can receive a college scholarship.

UNIT-I: Propositional Logic

First Order Logic: Syntax and Semantics

Artificial Intelligence Knowledge Representation I

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

Logic and Proofs. (A brief summary)

Chapter 1, Part I: Propositional Logic. With Question/Answer Animations

software design & management Gachon University Chulyun Kim

Logic. Propositional Logic: Syntax. Wffs

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

Propositional and First-Order Logic

Propositional Logic Not Enough

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic

Propositional and Predicate Logic

CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 2: Propositional Logic

Logic. (Propositional Logic)

A. Propositional Logic

Predicate Calculus - Syntax

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

15414/614 Optional Lecture 1: Propositional Logic

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 1

Chapter 4: Classical Propositional Semantics

Propositional and Predicate Logic

Review. Propositional Logic. Propositions atomic and compound. Operators: negation, and, or, xor, implies, biconditional.

CHAPTER 1 - LOGIC OF COMPOUND STATEMENTS

Transcription:

3: Logic

Why logic? Logic about inference or argument Start from assumptions or axioms Make deductions according to rules of reasoning Logic 3-1

Why logic? (continued) If I don t buy a lottery ticket on Saturday I won t win the jackpot. If I win the lottery jackpot on Saturday then I must have bought a ticket. If I don t buy a lottery ticket on Saturday I won t win the jackpot. So, if I buy a ticket I will win the jackpot. If it is raining then there are clouds in the sky. Today is cloudy, so it must be raining. If I don t work on this course I won t pass the exams. I m not doing a thing, I wonder what will happen? Logic 3-2

Why logic? (continued) If I don t buy a lottery ticket on Saturday I won t win the jackpot. If I win the lottery jackpot on Saturday then I must have bought a ticket. If I don t buy a lottery ticket on Saturday I won t win the jackpot. So, if I buy a ticket I will win the jackpot. If it is raining then there are clouds in the sky. Today is cloudy, so it must be raining. If I don t work on this course I won t pass the exams. I m not doing a thing, I wonder what will happen? Logic 3-2

Why logic? (continued) If I don t buy a lottery ticket on Saturday I won t win the jackpot. If I win the lottery jackpot on Saturday then I must have bought a ticket. If I don t buy a lottery ticket on Saturday I won t win the jackpot. So, if I buy a ticket I will win the jackpot. If it is raining then there are clouds in the sky. Today is cloudy, so it must be raining. If I don t work on this course I won t pass the exams. I m not doing a thing, I wonder what will happen? Logic 3-2

Why logic? (continued) If I don t buy a lottery ticket on Saturday I won t win the jackpot. If I win the lottery jackpot on Saturday then I must have bought a ticket. If I don t buy a lottery ticket on Saturday I won t win the jackpot. So, if I buy a ticket I will win the jackpot. If it is raining then there are clouds in the sky. Today is cloudy, so it must be raining. If I don t work on this course I won t pass the exams. I m not doing a thing, I wonder what will happen? Logic 3-2

Why logic? (continued) If I don t buy a lottery ticket on Saturday I won t win the jackpot. If I win the lottery jackpot on Saturday then I must have bought a ticket. If I don t buy a lottery ticket on Saturday I won t win the jackpot. So, if I buy a ticket I will win the jackpot. If it is raining then there are clouds in the sky. Today is cloudy, so it must be raining. If I don t work on this course I won t pass the exams. I m not doing a thing, I wonder what will happen? Logic 3-2

Why logic? (continued) If I don t buy a lottery ticket on Saturday I won t win the jackpot. If I win the lottery jackpot on Saturday then I must have bought a ticket. If I don t buy a lottery ticket on Saturday I won t win the jackpot. So, if I buy a ticket I will win the jackpot. If it is raining then there are clouds in the sky. Today is cloudy, so it must be raining. If I don t work on this course I won t pass the exams. I m not doing a thing, I wonder what will happen? Logic 3-2

Why logic? (continued) Can formalize the rules of reasoning used symbolic logic Helps to clarify the process of reasoning Gives possibility of mechanizing reasoning process Logic 3-3

Applications of Logic in Computer Science Programming statements like if...then...else use Boolean expressions Computer Design Logic gates used as basis of all hardware design Program Specification piece of mathematics that describes precisely the desired behaviour of a piece of software Program Verification proving that a program satisfies its specification Automated theorem proving proving that a mathematical theorem is the consequence of a number of assumptions Logic 3-4

Applications of Logic in Computer Science Programming statements like if...then...else use Boolean expressions Computer Design Logic gates used as basis of all hardware design Program Specification piece of mathematics that describes precisely the desired behaviour of a piece of software Program Verification proving that a program satisfies its specification Automated theorem proving proving that a mathematical theorem is the consequence of a number of assumptions Logic 3-4

Applications of Logic in Computer Science Programming statements like if...then...else use Boolean expressions Computer Design Logic gates used as basis of all hardware design Program Specification piece of mathematics that describes precisely the desired behaviour of a piece of software Program Verification proving that a program satisfies its specification Automated theorem proving proving that a mathematical theorem is the consequence of a number of assumptions Logic 3-4

Applications of Logic in Computer Science Programming statements like if...then...else use Boolean expressions Computer Design Logic gates used as basis of all hardware design Program Specification piece of mathematics that describes precisely the desired behaviour of a piece of software Program Verification proving that a program satisfies its specification Automated theorem proving proving that a mathematical theorem is the consequence of a number of assumptions Logic 3-4

Applications of Logic in Computer Science Programming statements like if...then...else use Boolean expressions Computer Design Logic gates used as basis of all hardware design Program Specification piece of mathematics that describes precisely the desired behaviour of a piece of software Program Verification proving that a program satisfies its specification Automated theorem proving proving that a mathematical theorem is the consequence of a number of assumptions Logic 3-4

Applications of Logic in Computer Science Data Bases need to be able to structure and efficiently execute queries Knowledge bases need to be able to make deductions from existing body of facts Semantic Web searches need to be able to search for web content by knowing something about the meaning of the content, rather than just the syntax. Logic programming can use particular forms of logic as programming languages in their own right Logic 3-5

Applications of Logic in Computer Science Data Bases need to be able to structure and efficiently execute queries Knowledge bases need to be able to make deductions from existing body of facts Semantic Web searches need to be able to search for web content by knowing something about the meaning of the content, rather than just the syntax. Logic programming can use particular forms of logic as programming languages in their own right Logic 3-5

Applications of Logic in Computer Science Data Bases need to be able to structure and efficiently execute queries Knowledge bases need to be able to make deductions from existing body of facts Semantic Web searches need to be able to search for web content by knowing something about the meaning of the content, rather than just the syntax. Logic programming can use particular forms of logic as programming languages in their own right Logic 3-5

Applications of Logic in Computer Science Data Bases need to be able to structure and efficiently execute queries Knowledge bases need to be able to make deductions from existing body of facts Semantic Web searches need to be able to search for web content by knowing something about the meaning of the content, rather than just the syntax. Logic programming can use particular forms of logic as programming languages in their own right Logic 3-5

Symbolic logic Simplest form is concerned with propositions Statements that can take value true or false Blue is a colour 1 + 1 = 2 2 + 2 = 22 All computer scientists have beards Logic 3-6

Symbolic logic Simplest form is concerned with propositions Statements that can take value true or false Blue is a colour 1 + 1 = 2 2 + 2 = 22 All computer scientists have beards Logic 3-6

Symbolic logic Simplest form is concerned with propositions Statements that can take value true or false Blue is a colour 1 + 1 = 2 2 + 2 = 22 All computer scientists have beards Logic 3-6

Symbolic logic Simplest form is concerned with propositions Statements that can take value true or false Blue is a colour 1 + 1 = 2 2 + 2 = 22 All computer scientists have beards Logic 3-6

Symbolic logic (continued) The following are not propositions 42 Is it raining? Manchester United Logic 3-7

Symbolic logic (continued) The following are not propositions 42 Is it raining? Manchester United Logic 3-7

Symbolic logic (continued) The following are not propositions 42 Is it raining? Manchester United Logic 3-7

Symbolic logic (continued) Can form compound propositions using logical connectives (or operators) Today is Wednesday and it s raining Either this is Manchester or I m a Dutchman If it s Wednesday at 11 this must be CS1021 Logic 3-8

Symbolic logic (continued) Can form compound propositions using logical connectives (or operators) Today is Wednesday and it s raining Either this is Manchester or I m a Dutchman If it s Wednesday at 11 this must be CS1021 Logic 3-8

Symbolic logic (continued) Can form compound propositions using logical connectives (or operators) Today is Wednesday and it s raining Either this is Manchester or I m a Dutchman If it s Wednesday at 11 this must be CS1021 Logic 3-8

Symbolic logic (continued) Can form compound propositions using logical connectives (or operators) Today is Wednesday and it s raining Either this is Manchester or I m a Dutchman If it s Wednesday at 11 this must be CS1021 Will introduce the full range of logical connectives and study their properties. Logic 3-9

The Logical Connectives name symbol translation negation not conjunction and disjunction or implication implies bi-implication iff and are often used instead of and. - unary - prefix p, q others - binary - infix (p q) Logic 3-10

The Logical Connectives (continued) - and, but - inclusive or some English translations of A B. A implies B If A then B A only if B B if A A is a sufficient case for B B is necessary for A - if and only if, abbreviated to iff. Logic 3-11

The Logical Connectives (continued) - and, but - inclusive or some English translations of A B. A implies B If A then B A only if B B if A A is a sufficient case for B B is necessary for A - if and only if, abbreviated to iff. Logic 3-11

The Logical Connectives (continued) - and, but - inclusive or some English translations of A B. A implies B If A then B A only if B B if A A is a sufficient case for B B is necessary for A - if and only if, abbreviated to iff. Logic 3-11

The Logical Connectives (continued) - and, but - inclusive or some English translations of A B. A implies B If A then B A only if B B if A A is a sufficient case for B B is necessary for A - if and only if, abbreviated to iff. Logic 3-11

The Logical Connectives (continued) - and, but - inclusive or some English translations of A B. A implies B If A then B A only if B B if A A is a sufficient case for B B is necessary for A - if and only if, abbreviated to iff. Logic 3-11

Truth Tables Negation p p T F F T Logic 3-12

Truth Tables (continued) p 1 p 2 p 1 p 2 p 1 p 2 p 1 p 2 p 1 p 2 T T T T T T T F F T F F F T F T T F F F F F T T Logic 3-13

Why the table for? x > 3 implies x > 1 where x is an integer variable. Surely this sentence is universally true; i.e. it is true whatever integer value x may have. Now let us give x the values 4,2,0 in turn x x > 3 x > 1 x > 3 x > 1 4 T T T 2 F T T 0 F F T Logic 3-14

Some properties p 1 p 2 p 1 p 2 p 1 p 2 p 2 p 1 p 2 p 1 T T T T T T T F F T F T F T F T F T F F F F F F Both and are commutative They are also associative (p 1 p 2 ) p 3 = p 1 (p 2 p 3 ) Logic 3-15

Formulae Propositions denoted by names such as p,q, p 3,r 7 1. Every proposition is a formula (in fact an atomic formula). 2. If A is a formula then so is A. 3. If A,B are formulae then so are (A B),(A B),(A B) and (A B). Another formal language. Language PL of Propositional Logic Logic 3-16

Formulae (continued) ((p 1 p 2 ) ( p 3 p 4 )) has parse tree p 1 (p 1 p 2 ) p 2 ( ) p 3 ( ) p 3 p 4 ( ) ( p 3 p 4 ) ( ) ((p 1 p 2 ) ( p 3 p 4 )) ( ) ((p 1 p 2 ) ( p 3 p 4 )) Logic 3-17

Formulae (continued) or p 1. p 2 ( ).. p 3 ( ). p 4 ( ) ( ). ( ) Logic 3-18

Some syntactic conventions 1. When using formulae it is standard practice to leave off the outermost parentheses. 2. Leave out internal parentheses from repeated use of and repeated use of. e.g. p q abbreviates (p q) (p q (q r)) p abbreviates (((p q) (q r)) p). Logic 3-19

Truth Valuations Let p 1,..., p n be a list of n distinct atomic formulae. A truth valuation for the list is an allocation of a truth value x i to each p i in the list. (p 1 = x 1,..., p n = x n ) e.g. (p = T,q = F,r = F) is a truth valuation for p,q,r. Logic 3-20

Truth Valuations (continued) Can also think of a truth valuation as a function {p 1, p 2,... p n } {T,F} If all the atomic formulae occurring in a formula A are in the list p 1,... p n. Then given a truth valuation for the list, A can be evaluated. Logic 3-21

Truth Valuations (continued) This truth value is determined following the way the formula has been built up, using the truth tables for the connectives that are involved. If the formula is atomic then the truth valuation itself determines its truth value. For a compound (i.e. non-atomic) formula the truth value can be found using the truth tables for the connectives. Logic 3-22

Truth Valuations (continued) e.g. at the valuation (p = T,q = F,r = F) p q is F, (p q) r is T, ((p q) r) is F. Logic 3-23

Truth Valuations (continued) Instead of the truth tables truth schemes can be used. In each scheme the compound formula gets the truth value false if it is not true. Truth scheme just a description of the corresponding truth table. Logic 3-24

The Truth Schemes Negation Conjunction Disjunction Implication A is true iff A is false. A 1 A 2 is true iff both A 1,A 2 are true. A 1 A 2 is true iff at least one of A 1,A 2 are true. A 1 A 2 is true iff either A 1 is false or A 2 is true (or both). Bi-implication A 1 A 2 is true iff A 1,A 2 have the same truth value. Logic 3-25

Tautologies and Contradictions Let A be a formula and let p 1,..., p n be a list of atomic formulae that include all those occurring in A. Then A is a tautology if it evaluates to T in every truth valuation for the list. A is contradictory if it is always false; i.e. it gets the truth value F at every truth valuation for the list p 1,..., p n. Logic 3-26

Tautologies and Contradictions Let A be a formula and let p 1,..., p n be a list of atomic formulae that include all those occurring in A. Then A is a tautology if it evaluates to T in every truth valuation for the list. A is contradictory if it is always false; i.e. it gets the truth value F at every truth valuation for the list p 1,..., p n. Logic 3-26

Tautologies and Contradictions (continued) e.g. let p be an atomic formula. Then p p is a tautology. p p is contradictory. p p p p p p T F F T F T F T Logic 3-27

Tautologies and Contradictions (continued) If a formula is not contradictory then that means that it must be true at some truth valuations. We then sometimes write that the formula is satisfiable. For example p q is satisfiable Logic 3-28

Truth Tables p 1 p 2 p 3 p 1 p 2 p 3 p 1 (p 2 p 3 ) T T T F T T T T F F F F T F T F F F T F F F F F F T T T T T F T F T F T F F T T F T F F F T F T p 1 (p 2 p 3 ) is not a tautology. It is satisfiable. Logic 3-29

Logical Equivalence Two formulae, A,B, are logically equivalent if they have the same truth value at every truth valuation for any list of atomic formulae that includes those occurring in either A or B; i.e. A,B have the same truth tables. Logic 3-30

Logical Equivalence (continued) For example: p 1 p 2 p 1 p 1 p 2 p 1 p 2 T T F T T T F F F F F T T T T F F T T T So p 1 p 2 is logically equivalent to p 1 p 2. Logic 3-31

Notation: Write = A for A is a tautology. A is contradictory iff = A. A is satisfiable iff = A. Write A == B for A is logically equivalent to B. A == B iff = A B. Logic 3-32

Commutativity Logical Equivalence Laws A 1 A 2 == A 2 A 1 Associativity A 1 A 2 == A 2 A 1 A 1 (A 2 A 3 ) == (A 1 A 2 ) A 3 Distributivity A 1 (A 2 A 3 ) == (A 1 A 2 ) A 3 A (B 1 B 2 ) == (A B 1 ) (A B 2 ) A (B 1 B 2 ) == (A B 1 ) (A B 2 ) (B 1 B 2 ) A == (B 1 A) (B 2 A) Logic 3-33

Idempotency (B 1 B 2 ) A == (B 1 A) (B 2 A) A A == A Absorbtion A A == A Double Negation (Involution) A (A B) == A A (A B) == A A == A Logic 3-34

De Morgan (A 1 A 2 ) == A 1 A 2 (A 1 A 2 ) == A 1 A 2 A 1 A 2 == ( A 1 A 2 ) Redundancy If = B and = C then A 1 A 2 == ( A 1 A 2 ) A B == A A C == A Logic 3-35

Implication A B == A B (A B) == A B A B == B A A B == B A Logic 3-36

Bi-implication A B == (A B) (B A) A B == ( A B) ( B A) A B == (A B) ( A B) (A B) == (A B) (B A) (A B) == (A B) (A B) Logic 3-37

Logical Equivalence Laws (continued) Any of the above can be checked using truth tables. For example A (B 1 B 2 ) == (A B 1 ) (A B 2 ) A B 1 B 2 B 1 B 2 A (B 1 B 2 ) A B 1 A B 2 (A B 1 ) (A B 2 ) T T T T T F T F T T F F F T T F T F F F T F F F Logic 3-38

Implication A B == B A This equivalence is one we use often in everyday reasoning If we know that a implies b, and we also know that b is false, then we can deduce the fact that a must be false as well B A is called the contrapositive of A B Logic 3-39

Normal Forms Can simplify a formula to produce an equivalent formula in some standard (or normal form) There are three useful kinds of normal form for propositional logic, NNF, CNF and DNF. We will describe algorithms which, for any formula A, find a formula A, in the normal form, such that A == A. Logic 3-40

Negation Normal Form (NNF) A formula that is either atomic or is the negation of an atomic formula is called a literal; e.g. if p is an atomic formula (proposition) then both p and p are literals. A formula is in Negation Normal Form, abbreviated NNF, if it is built up from literals using only conjunction and disjunction. So (( p 1 p 2 ) p 3 ) p 2 is in NNF, (p 1 p 2 ) p 3 is NOT in NNF Logic 3-41

Negation Normal Form (NNF) (continued) Every formula of PL is logically equivalent to a formula in NNF. To produce the NNF formula carry out the following procedures:- 1. Eliminate connectives, from the formula, using the two laws A B == A B, A B == ( A B) ( B A). Logic 3-42

Negation Normal Form (NNF) (continued) 2. The resulting formula will be built up using only,,. May still not be in NNF because negation may be applied to a non-literal; i.e. there may be occurrences of formulae having one of the forms A, (A 1 A 2 ), (A 1 A 2 ). In the first case the double negation can be eliminated using the double negation law A == A In other two cases the negation can be driven inside the binary connective using the two De Morgan Laws (A 1 A 2 ) == A 1 A 2, (A 1 A 2 ) == A 1 A 2. Repeat these steps until we have a formula in NNF. Logic 3-43

1. Examples == == == ((p 1 p 2 ) p 3 }{{} ) ( (p 1 p 2 ) p 3 ) (p 1 p 2 ) }{{} p 3 (p 1 p 2 ) p 3 Logic 3-44

2. == == == == ((p 2 p 1 ) }{{} p 3) (( p 2 p 1 ) p 3 ) ( p 2 p 1 ) }{{} p 3 }{{} ( p 2 }{{} p 1) p 3 (p 2 p 1 ) p 3 Logic 3-45

Conjunctive Normal Form (CNF) A (disjunctive) clause is a disjunction of one or more literals. For example p p q p q p 1 p 2 p 3 p 4 A formula is in Conjunctive Normal Form, abbreviated CNF, if it is a conjunction of clauses; Logic 3-46

Examples 1. p 1 p 2 2. (p 2 p 3 ) ( p 1 p 3 ) 3. (p 1 p 2 p 1 ) (p 2 p 3 p 1 ) 4. p 1 p 2 p 3 Logic 3-47

Examples (continued) Every formula of PL is logically equivalent to a formula in CNF. First put the formula in NNF. If the resulting formula is not in CNF then repeatedly use the following procedures until a formula in CNF is eventually obtained:- 1. Get rid of inner parentheses from repeated conjunctions and disjunctions, using the laws (A 1 A n ) A == A 1 A n A, A (A 1 A n ) == A A 1 A n, (A 1 A n ) A == A 1 A n A, A (A 1 A n ) == A A 1 A n, Logic 3-48

Examples (continued) 2. Bring disjunctions inside conjunctions using the distributivity laws (A 1 A n ) A == (A 1 A) (A n A), A (A 1 A n ) == (A A 1 ) (A A n ), where n 2. Logic 3-49

Example Put ((p 2 p 1 ) p 3 ) in CNF. ((p 2 p 1 ) }{{} p 3) == (by example 2 of 3.1) (p 2 p 1 ) p 3 == (by distributivity) (p 2 p 3 ) ( p 1 p 3 ) Logic 3-50

CNF test for tautologies The only way that a clause can be a tautology is if one of the literals in the clause is the negation of another literal in the clause. So, for example, p 1 p 2 p 1 p 3 is a clause that is a tautology, but p 1 p 2 p 3 is not a tautology because it is false at the valuation (p 1 = T, p 2 = F, p 3 = F). Also, a conjunction is a tautology exactly when all the conjuncts are tautologies. Logic 3-51

CNF test for tautologies (continued) For example (p 1 p 3 p 4 p 3 ) ( p 4 p 3 p 1 ) (p 2 p 1 p 2 p 1 ) is not a tautology because the second clause p 4 p 3 p 1 does not have a literal and its negation. Logic 3-52

Disjunctive Normal Form (DNF) Disjunctive Normal Form (DNF) is defined just like CNF except that the roles of conjunction and disjunction are interchanged. A formula is a conjunctive clause if it is a conjunction of one or more literals A formula is in disjunctive normal form (DNF) if it is a disjunction of one or more conjunctive clauses. The method we have described for putting a formula in CNF also applies for putting a formula in DNF, provided that we interchange the roles of and. Logic 3-53

Disjunctive Normal Form (DNF) (continued) Corresponding to the CNF test for tautologies we get the following DNF test for contradictions:- To test a formula in DNF for being contradictory check that for each conjunctive clause in the formula there is an occurrence of a literal and its negation. For example the DNF formula is easily seen to be contradictory. (p 3 p 4 p 3 ) (p 1 p 1 ) Logic 3-54

Functional Completeness In this section we discuss the possibility of other connectives than the particular connectives we have been considering. Perhaps there are missing connectives that could be added to Propositional Logic to get a more expressive Logic. (What does expressive mean?) We will show that in a precise sense that is not the case - Propositional Logic is Functionally Complete. Logic 3-55

Functional Completeness (continued) A connective can be specified by giving a truth table that spells out how the truth value of a formula built with the connective depends on the truth values of its components. For example consider a new binary connective #. We specify the connective using a truth table. For example:- So we have the truth scheme:- p 1 p 2 p 1 # p 2 T T F T F T F T T F F F A 1 # A 2 is true iff exactly one of A 1,A 2 is true and the other is false. Logic 3-56

Functional Completeness (continued) You may already have noticed that the formula (p 1 p 2 ) has the same truth table as the above table for p 1 # p 2 ; So the two formulae are logically equivalent This means that # is redundant - the occurrences of # in a formula can be systematically eliminated using the logical equivalence. Logic 3-57

Functional Completeness (continued) There is a systematic way to find, given any truth table, a formula in DNF having that truth table. Suppose the truth table involves the atomic formulae p 1,..., p n We may associate a conjunctive clause l 1 l n with any row of the truth table, where l i is p i if p i is T in that row and p i if p i is F in that row. Now let A be the disjunction of those conjunctive clauses corresponding to the rows where the truth table gives the value T in the right hand column. It should be obvious that the truth table of A is exactly the truth table we started with. In the case of the truth table for # we would get the DNF formula (p 1 p 2 ) ( p 1 p 2 ). Logic 3-58

Example Find a formula A in DNF whose truth table is:- p 1 p 2 p 3 A T T T F T T F T T F T T T F F F F T T F F T F F F F T F F F F T Logic 3-59

Example Find a formula A in DNF whose truth table is:- p 1 p 2 p 3 A T T T F T T F T p 1 p 2 p 3 T F T T T F F F F T T F F T F F F F T F F F F T Logic 3-59

Example Find a formula A in DNF whose truth table is:- p 1 p 2 p 3 A T T T F T T F T p 1 p 2 p 3 T F T T p 1 p 2 p 3 T F F F F T T F F T F F F F T F F F F T Logic 3-59

Example Find a formula A in DNF whose truth table is:- p 1 p 2 p 3 A T T T F T T F T p 1 p 2 p 3 T F T T p 1 p 2 p 3 T F F F F T T F F T F F F F T F F F F T p 1 p 2 p 3 Logic 3-59

Example (continued) There are three rows of this table which have T under A and these determine the conjunctive clauses p 1 p 2 p 3, p 1 p 2 p 3 and p 1 p 2 p 3. The formula A that we want is their disjunction:- (p 1 p 2 p 3 ) (p 1 p 2 p 3 ) ( p 1 p 2 p 3 ). Logic 3-60

Example (continued) So, for every possible truth table there is a formula having that truth table. Moreover that formula can be in DNF So it only involves the connectives,,. We say that {,, } is a functionally complete set of connectives. There is no truth table which can not be expressed as a formula involving only these connectives. Logic 3-61

Example (continued) In fact there is still some redundancy because only one of, is needed together with. This is because the De Morgan Laws allow one of them to be defined in terms of the other. For example, because of the law A B == ( A B), all the occurrences of in a formula in DNF can be systematically eliminated so as to get a logically equivalent formula involving only the connectives,. Logic 3-62

Example (continued) For example we have:- == (p 1 p 2 ) }{{} ( p 1 p 2 ) }{{} ( p 1 p 2 ) (p 1 p 2 ) Logic 3-63

Predicates and Quantifiers One of the limitations of propositional calculus is that it has no way of handling arguments such as the following All computer science students are witty and intelligent. Eve is a computer science student. Therefore Eve is witty and intelligent. Logic 3-64

Predicates and Quantifiers (continued) We can identify the three propositions here p q r All computer science students are witty and intelligent Eve is a computer science student Eve is witty and intelligent. We want to argue that p q r, but have no way of formalising the fact that q and r are both statements about the same individual. Logic 3-65

Predicates and Quantifiers (continued) To do this we need to introduce the notion of a predicate. A predicate is just a boolean valued function. In the above example we have two such predicates CS(x) W(x) x is a computer science student x is witty and intelligent The above argument can then be recast as For all x CS(x) W(x) CS(Eve) Therefore W(Eve) Logic 3-66

Quantifiers Given a predicate P, there are two ways of obtaining a truth value, Can apply predicate to a a particular individual (for example CS(Eve) above) Can also quantify it. Logic 3-67

Quantifiers (continued) Given a predicate P, we can assert that P(x) is true whatever the value of x. For all x, I(x). This statement has one of the values true or false, and does not depend on a particular value of x. The predicate has been universally quantified, by the use of the word For all. Logic 3-68

Quantifiers (continued) The universal quantifier is denoted symbolically by the symbol, Write things like x, P(x). The argument regarding CS students becomes x,cs(x) W(x) CS(Eve) Therefore W(Eve) Logic 3-69

Quantifiers (continued) Can also use existential quantification In English usually done using phrases such as there exists or for some. Write this symbolically as, x,p(x), read as there exists a value for x such that P(x) is true. Logic 3-70

Quantifiers (continued) If CS and W are the predicates as above, note the difference between the following statements. x CS(x) W(x) x CS(x) W(x) x CS(x) W(x) x W(x) CS(x) Logic 3-71

Quantifiers (continued) Predicates can involve more than one variable, and statements can be built using more than one quantifier, for example Every dog has its day can be written x Dog(x) d HasDay(x, d) Logic 3-72

Quantifiers (continued) and There is someone in this room who is at least as tall as anyone else in the room x InRoom(x) ( y InRoom(y) AsTallAs(x, y)) Logic 3-73

Quantifiers (continued) What about the following? x InRoom(x) ( y InRoom(y) AsTallAs(x, y)) Logic 3-74

Quantifiers (continued) The predicates F and O are defined by F(x) iff x is a Unix file O(x,y) iff x is the owner of y Explain in English the meaning of the following statements i) x (F(x) y O(y,x)) ii) x ( y (F(y) O(x,y))) iii) x (F(x) ( y z (O(y,x) O(z,x) y = z))) Which, if any, of these statements do you think are true? Give reasons Logic 3-75

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Book b 1 has been borrowed. Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Book b 1 has been borrowed. p B(p,b 1 ) Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Book b 1 has been borrowed. p B(p,b 1 ) Person p 2 has borrowed at least two books. Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Book b 1 has been borrowed. p B(p,b 1 ) Person p 2 has borrowed at least two books. b 1,b 2 (B(p 2,b 1 ) B(p 2,b 2 ) b 1 b 2 ) Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Book b 1 has been borrowed. p B(p,b 1 ) Person p 2 has borrowed at least two books. b 1,b 2 (B(p 2,b 1 ) B(p 2,b 2 ) b 1 b 2 ) No book has been borrowed by more than one person. Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Book b 1 has been borrowed. p B(p,b 1 ) Person p 2 has borrowed at least two books. b 1,b 2 (B(p 2,b 1 ) B(p 2,b 2 ) b 1 b 2 ) No book has been borrowed by more than one person. b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Book b 1 has been borrowed. p B(p,b 1 ) Person p 2 has borrowed at least two books. b 1,b 2 (B(p 2,b 1 ) B(p 2,b 2 ) b 1 b 2 ) No book has been borrowed by more than one person. b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) If a book is overdue, then it must have been borrowed. Logic 3-76

Quantifiers (continued) In the design specification for a library system, B(p, b) denotes the predicate person p has borrowed book b and O(b) denotes the book b is overdue. Write the following sentences in symbolic form:- Person p 1 has borrowed at least one book. b B(p 1,b) Book b 1 has been borrowed. p B(p,b 1 ) Person p 2 has borrowed at least two books. b 1,b 2 (B(p 2,b 1 ) B(p 2,b 2 ) b 1 b 2 ) No book has been borrowed by more than one person. b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) If a book is overdue, then it must have been borrowed. b O(b) ( p B(p, b)) Logic 3-76

Negation of quantified statements If P is some predicate, then the expression x P(x), says that it is not the case that all x have the property described by P. This means that there must be at least one individual a, say, for which it is the case that P(a), is true. In other words x P(x). So negation turns the universal quantifier into the existential, and we have ( x P(x)) == ( x P(x)) Logic 3-77

Negation of quantified statements (continued) Similarly we have ( x P(x)) == ( x P(x)) If there is no x for which P(x) is true, it must be the case that, for all x, P(x) is true. Logic 3-78

Negation of quantified statements (continued) These rules of negation are an extension of the de Morgan Laws of propositional logic. How? Logic 3-79

Negation of quantified statements (continued) If X is a finite set {x 1,x 2,...x n } the statement x X p(x) can be rewritten as and can be rewritten as p(x 1 ) p(x 2 )... p(x n ) x X p(x) p(x 1 ) p(x 2 )... p(x n ) Logic 3-80

Some examples If CS and W are the predicates as above, x CS(x) W(x) All CS students are witty and intelligent x CS(x) W(x) There is a witty and intelligent CS student x W(x) CS(x) All witty and intelligent people are CS students We will construct the negations of these Logic 3-81

Some examples (continued) x CS(x) W(x) = x (CS(x) W(x)) = x CS(x) W(x)) Logic 3-82

Some examples (continued) x CS(x) W(x) = x (CS(x) W(x)) = x CS(x) W(x)) There is a CS student who is not witty and intlligent Logic 3-83

Some examples (continued) x CS(x) W(x) = x (CS(x) W(x)) = x CS(x) W(x) = x CS(x) W(x) = x CS(x) W(x) Logic 3-84

Some examples (continued) x CS(x) W(x) = x (CS(x) W(x)) = x CS(x) W(x) = x CS(x) W(x) = x CS(x) W(x) All CS students are not witty and intelligent Logic 3-85

Some examples (continued) x W(x) CS(x) = x (W(x) CS(x)) = x (W(x) CS(x)) Logic 3-86

Some examples (continued) x W(x) CS(x) = x (W(x) CS(x)) = x (W(x) CS(x)) There is someone who is not a CS student who is witty and intelligent Logic 3-87

Some examples (continued) The statement No book has been borrowed by more than one person can be rewritten as b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) = b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) = b p 1, p 2 ( B(p 1,b) B(p 2,b) p 1 = p 2 ) = b p 1, p 2 ((B(p 1,b) B(p 2,b)) p 1 = p 2 ) Logic 3-88

The statement No book has been borrowed by more than one person Some examples (continued) can be rewritten as b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) = b p 1, p 2 (B(p 1,b) B(p 2,b) p 1 p 2 ) = b p 1, p 2 ( B(p 1,b) B(p 2,b) p 1 = p 2 ) = b p 1, p 2 ((B(p 1,b) B(p 2,b)) p 1 = p 2 ) If two people have borrowed the same book, then they must have been the same person Logic 3-89

Some examples (continued) There is someone in this room who is at least as tall as anyone else in the room if we negate this statement, we get There is not someone in this room who is at least as tall as anyone else in the room Symbolically this becomes ( x InRoom(x) ( y InRoom(y) AsTallAs(x, y))) which can be rewritten as Logic 3-90

Some examples (continued) x (InRoom(x) ( y InRoom(y) AsTallAs(x, y))) = x (InRoom(x) ( y InRoom(y) AsTallAs(x, y))) = x( InRoom(x) ( y InRoom(y) AsTallAs(x, y))) = x( InRoom(x) ( y (InRoom(y) AsTallAs(x, y)))) = x( InRoom(x) ( y InRoom(y) AsTallAs(x, y))) = x(inroom(x) ( y InRoom(y) AsTallAs(x, y))) which in English is For everyone in the room there is someone in the room who they are not as tall as. Logic 3-91