Propositional Language - Semantics

Similar documents
Formal (natural) deduction in propositional logic

Chapter 4: Classical Propositional Semantics

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

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

CSC Discrete Math I, Spring Propositional Logic

Truth-Functional Logic

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims

CHAPTER 1 - LOGIC OF COMPOUND STATEMENTS

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

CSE 20: Discrete Mathematics

The Logic of Compound Statements cont.

Propositional logic. First order logic. Alexander Clark. Autumn 2014

Natural Deduction for Propositional Logic

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

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

Computation and Logic Definitions

Introduction to Metalogic 1

Propositional Logic: Semantics

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

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

PL: Truth Trees. Handout Truth Trees: The Setup

Learning Goals of CS245 Logic and Computation

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

Language of Propositional Logic

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

Introduction to Metalogic

Section 1.1: Logical Form and Logical Equivalence

a. ~p : if p is T, then ~p is F, and vice versa

Natural Deduction. Formal Methods in Verification of Computer Systems Jeremy Johnson

CHAPTER 10. Gentzen Style Proof Systems for Classical Logic

Logic and Proofs. Jan COT3100: Applications of Discrete Structures Jan 2007

2.2: Logical Equivalence: The Laws of Logic

Logic: Propositional Logic (Part I)

Definition 2. Conjunction of p and q

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

Formal (Natural) Deduction for Predicate Calculus

Propositional Logic and Semantics

THE LOGIC OF COMPOUND STATEMENTS

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

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

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

15414/614 Optional Lecture 1: Propositional Logic

Propositional Logic: Equivalence

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

Artificial Intelligence: Knowledge Representation and Reasoning Week 2 Assessment 1 - Answers

Tautologies, Contradictions, and Contingencies

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

CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS

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

Proofs. Joe Patten August 10, 2018

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

7 LOGICAL AGENTS. OHJ-2556 Artificial Intelligence, Spring OHJ-2556 Artificial Intelligence, Spring

It is not the case that ϕ. p = It is not the case that it is snowing = It is not. r = It is not the case that Mary will go to the party =

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

Propositional Logic: Models and Proofs

Chapter 11: Automated Proof Systems

Compound Propositions

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

Classical Propositional Logic

Overview. I Review of natural deduction. I Soundness and completeness. I Semantics of propositional formulas. I Soundness proof. I Completeness proof.

Chapter 1: The Logic of Compound Statements. January 7, 2008

Propositional and Predicate Logic - II

Chapter 11: Automated Proof Systems (1)

Propositional Logic. Spring Propositional Logic Spring / 32

Logical Agents. Knowledge based agents. Knowledge based agents. Knowledge based agents. The Wumpus World. Knowledge Bases 10/20/14

3 The Semantics of the Propositional Calculus

First-Degree Entailment

Logical Agents. Outline

Tecniche di Verifica. Introduction to Propositional Logic

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

HANDOUT AND SET THEORY. Ariyadi Wijaya

02 Propositional Logic

Artificial Intelligence. Propositional logic

Homework assignment 1: Solutions

Introduction to Artificial Intelligence. Logical Agents

Topics in Logic and Proofs

Predicate Calculus - Syntax

Part 1: Propositional Logic

Propositional Logic 1

Mathematical Logic Part One

Propositional Equivalence

The Foundations: Logic and Proofs. Part I

MACM 101 Discrete Mathematics I. Exercises on Propositional Logic. Due: Tuesday, September 29th (at the beginning of the class)

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

Warm-Up Problem. Write a Resolution Proof for. Res 1/32

Artificial Intelligence

Topic 1: Propositional logic

Intermediate Logic. Natural Deduction for TFL

Comp487/587 - Boolean Formulas

Syntax of propositional logic. Syntax tree of a formula. Semantics of propositional logic (I) Subformulas

Propositional Logic. Fall () Propositional Logic Fall / 30

Logic. Part I: Propositional Logic. Max Schäfer. Formosan Summer School on Logic, Language, and Computation 2010

1. Propositional Calculus

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19

Logic for Computer Science - Week 4 Natural Deduction

CSCE 222 Discrete Structures for Computing. Propositional Logic. Dr. Hyunyoung Lee. !!!!!! Based on slides by Andreas Klappenecker

Decision Procedures for Satisfiability and Validity in Propositional Logic

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

Propositional Logic Language

PHIL12A Section answers, 16 February 2011

Transcription:

Propositional Language - Semantics Lila Kari University of Waterloo Propositional Language - Semantics CS245, Logic and Computation 1 / 41

Syntax and semantics Syntax Semantics analyzes Form analyzes Meaning (p q) r - syntactically correct When is a formula true? (it is a well-formed formula) p ))))) - syntactically incorrect When is a formula false? Propositional Language - Semantics CS245, Logic and Computation 2 / 41

Propositional language: Semantics The meaning of a nonatomic formula, that is, its truth values (true or false) must be derived from the truth values of its constituent atomic formulas. Before this can be done, the formula must be parsed; that is, all subformulas of the formula must be found. If you take a class in computers and if you do not understand recursion, you will not pass. We want to know exactly when this statement is true and when it is false. Define: p: You take a class in computers. q: You understand recursion. r: You pass. The stament becomes (p q) r. Propositional Language - Semantics CS245, Logic and Computation 3 / 41

Meaning of a formula - truth table Truth table for (p q) r p q r q p q r (p q) r 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 1 1 1 0 0 1 0 0 1 1 1 1 0 1 1 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 0 0 1 0 0 0 1 0 1 1 Propositional Language - Semantics CS245, Logic and Computation 4 / 41

Using truth tables to solve logical puzzles There are two identical twins, Jenny and Susan. One of them is a knave (always lies) and one is a knight (always tells the truth) You don t know which one is which. You meet one of them, and you want to find out if she is Jenny or Susan by asking one yes/no question. What is the question and why does it work? Question (for the person you are talking to): Is Susan a knave? Claim: The answer to this question is yes iff you are talking to Jenny. (Anna Lubiw, CS245 W15 Notes) Propositional Language - Semantics CS245, Logic and Computation 5 / 41

Value (truth) assignments A truth table list the values of a formula under all possible value assignments. Fix a set {0, 1} of truth values. We interpret 0 as false and 1 as true. Definition. A (Boolean, truth) value assignment (called also truth assignment, respectively valuation or model in the text) is a function v v : Atom(L p ) {0, 1}, with the set of all proposition variables as domain and {0, 1} as range. Propositional Language - Semantics CS245, Logic and Computation 6 / 41

Truth value of a formula under a value assignment Definition. The value of a formula A in Form(L p ) with respect to the value assignment v is defined recursively as follows: (1) If A is in Atom(L p ) then v(a) is in {0, 1} as defined previously. (2) v( A) = 1 if v(a) = 0, and 0 otherwise. (3) v(a B) = 1 if v(a) = v(b) = 1, and 0 otherwise. (4) v(a B) = 1 if v(a) = 1 or v(b) = 1 (or both), and 0 otherwise. (5) v(a B) = 1 if v(a) = 0 or v(b) = 1, and 0 otherwise. (6) v(a B) = 1 if v(a) = v(b), and 0 otherwise. Propositional Language - Semantics CS245, Logic and Computation 7 / 41

Example Suppose A = p q q r, and v is a value assignment such that v(p) = v(q) = v(r) = 1. Then we have v(p q) = 1, v(q r) = 1 and therefore v(a) = 1. Suppose v 1 is another value assignment, v 1 (p) = v 1 (q) = v 1 (r) = 0. Then we have v 1 (p q) = 0, v 1 (q r) = 0 and therefore v 1 (A) = 1. If v 2 is a third value assignment such that v 2 (p) = 1 and v 2 (r) = v 2 (q) = 0, then v 2 (A) = 0. The above example illustrates that the values which various value assignments assign to a formula may or may not be different. Propositional Language - Semantics CS245, Logic and Computation 8 / 41

Satisfiability Definition. We say that a value assignment v satisfies a formula A in Form(L p ) iff v(a) = 1. We use the Greek letter Σ to denote any set of formulas. Define { 1 if for each formula B Σ, v(b) = 1, v(σ) = 0 otherwise Definition. A set of formulas Σ Form(L p ) is satisfiable iff there exists a value assignment v such that v(σ) = 1. When v(σ) = 1, then v is said to satisfy Σ, and Σ is said to be true under v. Propositional Language - Semantics CS245, Logic and Computation 9 / 41

Observations (a) Note that v(σ) = 1 means that under the value assignment v, all the formulas of Σ are true. (b) On the other hand,v(σ) = 0 means that for at least one formula B Σ, v(b) = 0. (Note that (b) does not necessarily mean that v(c) = 0 for every formula C in Σ.) Propositional Language - Semantics CS245, Logic and Computation 10 / 41

Sudoku as a Satisfiability Problem In a 4 x 4 Sudoku puzzle, each value in {1, 2, 3, 4} must appear exactly once in each row, column, and 2x2 block. Write a formula that requires all the following to be true: (a) Solution must be consistent with the starting grid (b) At most one digit per square (c) In each row, each digit must appear exactly once (d) In each column, each digit must appear exactly once (e) In each block, each digit must appear exactly once Propositional Language - Semantics CS245, Logic and Computation 11 / 41

Sudoku as SAT problem Set up variables v ijk, 1 i, j, k 4, so that: v ijk = 1, iff the cell at position (i, j) equals number k, and v ijk = 0, otherwise Solution of the Sudoku puzzle = determining the satisfiability of the formula obtained by taking the conjunction of all formulas below: (a) Consistency with starting grid: If the cell (1, 1) has digit 3 in it, then add the formula v 113, etc. Do not add anything for unfilled cells. (b) At most one digit per cell: For every cell (i, j), and each pair of different digits k, k, add the formula (v ijk v ijk ) Propositional Language - Semantics CS245, Logic and Computation 12 / 41

Sudoku as SAT problem contd. (c) In each row each digit appears exactly once: at least once : For each row i and digit k, add the formula (v i1k v i2k v i3k v i4k ) at most once : Look at every pair of cells in a row, (i, j) and (i, j ), j j, and require that they do not both contain k by adding (v ijk v ij k) (d) In each column each digit appears exactly once: Like rows, but fixes the column j and digit k. (e) In each block, each digit appears exactly once: Same pattern as rows and columns, but the row and column indexes must vary over the cells within a given block. Propositional Language - Semantics CS245, Logic and Computation 13 / 41

Tautologies and contradictions Definition A formula A is a tautology iff it is true under all possible value assignments, i.e. iff for any value assignment v, v(a) = 1. Definition. A formula A is a contradiction iff it is false under all possible value assignments, i.e., iff for any value assignment v, v(a) = 0. Definition A formula that is neither a tautology nor a contradiction is called contingent. Propositional Language - Semantics CS245, Logic and Computation 14 / 41

Tautology example Consider the formula (p q) q. Is this formula a tautology? Truth table for a tautology p q (p q) (p q) (p q) q 1 1 1 0 1 1 0 0 1 1 0 1 0 1 1 0 0 0 1 1 Propositional Language - Semantics CS245, Logic and Computation 15 / 41

Important tautology Law of the excluded middle ( tertium non datur ) states that p p is a tautology. In other words, p is either true or false, everything else is excluded. The table below proves this law by showing that it is true for all value assignments: p p p p 1 0 1 0 1 1 Propositional Language - Semantics CS245, Logic and Computation 16 / 41

Tautology: Observations If A is a tautology that contains the variable p, one can determine a new expression by replacing all instances of p by an arbitrary formula. The resulting formula A is also a tautology. For example, p p is a tautology. Replace all instances of p by any formula we like, say by p q. The resulting formula A = (p q) (p q) is again a tautology. Theorem. Let A be a tautology and let p 1, p 2,... p n be the propositional variables of A. Suppose that B 1, B 2,... B n are arbitrary formulas. Then, the formula obtained by replacing p 1 by B 1, p 2 by B 2... p n by B n is a tautology. Example. Use the fact that (p q) q is a tautology to prove that ((p q) r) r is a tautology. Propositional Language - Semantics CS245, Logic and Computation 17 / 41

Important contradiction Law of contradiction: Nothing can both be, and not be, that is, (p p) is a tautology; equivalently, (p p) is a contradiction. Truth table for a contradiction p p p p 1 0 0 0 1 0 Contradictions are related to tautologies: A is a tautology if and only if A is a contradiction. Propositional Language - Semantics CS245, Logic and Computation 18 / 41

Three essential laws of thought - Plato 1 Law of identity: Whatever is, is. p = p 2 Law of contradiction: Nothing can both be and not be. (p p) 3 Law of excluded middle: Everything must either be, or not be. (p p) Plato (428-348 B.C.) Propositional Language - Semantics CS245, Logic and Computation 19 / 41

Fuzzy Logic Truth values are real numbers in the interval [0, 1] true = 1, false = 0, partially true = a number between 0 and 1 AND(x, y) = min{x, y} OR(x, y) = max{x, y} NOT(x) = 1 x If the values of the variables are 0 and 1, these definitions amount to classical logic connectives Does the law of excluded middle hold? For p = 0.2, we have p p =max{0.2, 0.8} = 0.8 1. Does the law of contradiction hold? For p = 0.2, we have p p = min{0.2, 0.8} = 0.2 0. Propositional Language - Semantics CS245, Logic and Computation 20 / 41

Proving arguments valid Logical argument: Premise 1 Premise 2... Premise n Conclusion Logical arguments can be Correct (valid, sound) Incorrect (invalid, unsound) Propositional Language - Semantics CS245, Logic and Computation 21 / 41

Formalizing argument validity: Tautological consequence Definition Suppose Σ Form(L p ) and A Form(L p ). A is a tautological consequence of Σ (that is, of the formulas in Σ), written as Σ = A, iff for any value assignment v, we have that v(σ) = 1 implies v(a) = 1. Observations = is not a symbol of the formal propositional language and Σ = A is not a formula. Σ = A is a statement (in the metalanguage) about Σ and A. We write Σ = A for not Σ = A. = is called semantic entailment in [Huth&Ryan] Propositional Language - Semantics CS245, Logic and Computation 22 / 41

A special case: = A When Σ is the empty set, we obtain the important special case of tautological consequence, = A By definition, = A means that the following holds: For any value assignment v, if v( ) = 1 then v(a) = 1. where v( ) = 1 means For any B, if B then v(b) = 1 Because B is false, v( ) = 1 is always (vacuously) true. Consequently, = A means that A is always true (is a tautology). Intuitively speaking, Σ = A means that the truth of the formulas in Σ is a sufficient condition for the truth of A. Since has no formulas, = A means that the truth of A is unconditional, hence A is a tautology. Propositional Language - Semantics CS245, Logic and Computation 23 / 41

Tautological consequence and valid arguments Let Σ = {A 1, A 2,..., A n } be a set of formulas (premises) and A be a formula (conclusion). The following are equivalent: The argument with premises A 1, A 2,..., A n and conclusion A is valid. (A 1 A 2... A n ) A is a tautology. (A 1 A 2... A n A) is a contradiction. A is a tautological consequence of Σ, i.e. {A 1, A 2,..., A n } = A. If A = B, we say that formula A (tauto)logically implies formula B. Propositional Language - Semantics CS245, Logic and Computation 24 / 41

Tautological equivalence Definition: For two formulas we write to denote A = B and B = A. A = B A and B are said to be tautologically equivalent (or simply equivalent) iff A = B holds. Tautologically equivalent formulas are assigned the same truth values by any value assignment. Propositional Language - Semantics CS245, Logic and Computation 25 / 41

Notes Note that (tauto)logically implies is different from implies. A = B if and only if A B is a tautology. A B is a formula, which can be true or false. Note that (tauto)logically equivalent, A = B, is different from equivalent. A = B if and only if A B is a tautology. A B is a formula, which can be true or false. Propositional Language - Semantics CS245, Logic and Computation 26 / 41

Proving argument validity by truth tables To prove a tautological consequence Σ = A we must show that any value assignment v satisfying Σ also satisfies A. One way to show this is by using truth tables. Show that {A B, B C} = (A C) The premises are p 1 = A B and p 2 = B C; the conclusion is A C. A B C A B B C p 1 p 2 concl: A C 0 0 0 1 1 1 1 0 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 1 1 0 0 0 1 0 0 1 0 1 0 1 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 Propositional Language - Semantics CS245, Logic and Computation 27 / 41

Proving argument validity by truth tables The value assignments in rows 1, 2, 4, 8 are the only ones that satisfy Σ = {A B, B C}. For these value assignments also A C is satisfied. This shows that This means that the argument Premise 1: A B Premise 2: B C - Conclusion: A C is a valid argument. {A B, B C} = (A C), Propositional Language - Semantics CS245, Logic and Computation 28 / 41

When the argument is not valid Prove that (A B) (A C) = A (B C). Find at least one row in the truth table for which the premises are true but the conclusion is false. Propositional Language - Semantics CS245, Logic and Computation 29 / 41

Size of truth tables If the formula has n variables and m connectives How many rows does the truth table have? 2 n How many columns does the truth table have? n + m We need another method for proving argument validity when the number of variables is too large. Propositional Language - Semantics CS245, Logic and Computation 30 / 41

Proving argument validity without truth tables We use proof by contradiction (here the word contradiction has a different meaning from the use of the word contradiction in logic, where it means a logical formula that is always false.) Show that {A B, B C} = (A C). Proof: Assume the contrary, that is {A B, B C} = (A C). This means that there is a value assignment v such that (1) v(a B) = 1, (2) v(b C) = 1, (3) v(a C) = 0. By (3) we have (4) v(a) = 1, and (5) v(c) = 0. By (1) and (4) we have v(b) = 1. From v(b) = 1 and (2) we have v(c) = 1 which contradicts (5). As we reached a contradiction, our assumption was false, hence the argument is valid. Propositional Language - Semantics CS245, Logic and Computation 31 / 41

Example A patient is administered three different tests. Test A will give a positive result if and only if either virus X or virus Y is present. Test B will give a positive result if and only if virus Y or Z is present. If test C is positive, virus Y can be excluded. The patient reacts positively to all three tests. Prove that he has virus X and virus Z but not virus Y. Propositional Language - Semantics CS245, Logic and Computation 32 / 41

Proving argument invalidity without truth tables To prove Σ = A, we must construct a counter-example: A value assignment v satisfying Σ but not satisfying A. Show that {(A B) C, B C, A C} = ( A (B C)). Proof: Provide a counter-example. Let v be the value assignment v(a) = 0, v(b) = 1 and v(c) = 0. Then we have v((a B) C) = 1 v(b C) = 1. v(a C) = 1 v( A (B C)) = 0. We found a counter-example (a value assignment that makes all premises true but the conclusion false), hence the argument is invalid. Propositional Language - Semantics CS245, Logic and Computation 33 / 41

Important (tauto)logical equivalences De Morgan s Laws Consider the following two statements: He is either not informed, or he is not honest. It is not true that he is informed and honest. Intuitively, these two statements are logically equivalent. We prove this now. Define p and q to be the statements that he is honest and that he is well informed respectively. The first statement translates into p q, whereas the second into (p q). Propositional Language - Semantics CS245, Logic and Computation 34 / 41

De Morgan s Laws De Morgan s law: (p q) = ( p q) which means that (p q) ( p q) is a tautology. p q p q (p q) p q (p q) ( p q) 1 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 De Morgan s Laws are used to negate conjuctions and disjunctions: To negate a conjunction, take the disjunction of the negations of the conjuncts. Dual De Morgan s Law: (p q) = ( p q) To negate a disjunction, take the conjunction of the negations of the disjuncts. Propositional Language - Semantics CS245, Logic and Computation 35 / 41

Important (tauto)logical equivalences - contrapositives Consider the following pair of statements: If the goods were not delivered, the customer cannot have paid. If the customer has paid, the goods must have been delivered. If q and p stand for goods were delivered and customer paid respectively, then these two statements translate into q p and p q. q p and p q are contrapositives of each other. Propositional Language - Semantics CS245, Logic and Computation 36 / 41

Contrapositives The table below shows that contrapositives are equivalent, that is p q = q p p q p q q p p q 1 1 0 0 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 0 1 1 1 1 How to use contrapositives in proofs: Sometimes, instead of proving that p q, it is easier to prove the contrapositive, q p. Propositional Language - Semantics CS245, Logic and Computation 37 / 41

Logic humour Rene Descartes (1596-1650), French philosopher, famous for his statement I think, therefore I am. Rene Descartes is sitting in a bar, having a drink. The bartender asks him if he would like another. I think not, he says, and vanishes in a puff of smoke. What is wrong with this joke? Propositional Language - Semantics CS245, Logic and Computation 38 / 41

Important (tauto)logical equivalences - biconditional Consider the following two statements: (1) p and q have the same truth value (2) If p, then q, and if q then p. The first statement becomes p q, the second (p q) (q p). The table below shows that p q = (p q) (q p) p q p q p q q p (p q) (q p) 1 1 1 1 1 1 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1 1 1 1 How to use this in proofs: If we have to prove that p q, we must prove both the direct implication p q, and the converse implication q p. Propositional Language - Semantics CS245, Logic and Computation 39 / 41

Tautological equivalences Lemma If A = A and B = B, then 1 A = A. 2 A B = A B. 3 A B = A B. 4 A B = A B. 5 A B = A B. Propositional Language - Semantics CS245, Logic and Computation 40 / 41

Replaceability of Equivalent Formulas, and How to Negate a Formula Theorem. Let B = C. If A results from A by replacing some (not necessarily all) occurrences of B in A by C, then A = A. Proof By structural induction. Theorem. Suppose A is a formula composed by atoms and the connectives,, only, by the formation rules concerned. Suppose that (A) results by replacing in A with, with, and each propositional variable with its negation. Then A = (A). Proof By structural induction. Example. Let A = (p q) ( r s). Find the negation of A, i.e. find A. Propositional Language - Semantics CS245, Logic and Computation 41 / 41