SE 212: Logic and Computation. se212 Nancy Day

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

02 Propositional Logic

Computation and Logic Definitions

Propositional Logic. Spring Propositional Logic Spring / 32

Truth-Functional Logic

CSC Discrete Math I, Spring Propositional Logic

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

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

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

PL: Truth Trees. Handout Truth Trees: The Setup

3 Propositional Logic

Natural Deduction for Propositional Logic

15414/614 Optional Lecture 1: Propositional Logic

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

Propositional Logic Review

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

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Topic 1: Propositional logic

1 Propositional Logic

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

Introduction to Artificial Intelligence. Logical Agents

Logic: Propositional Logic (Part I)

Deductive Systems. Lecture - 3

Propositional Logic: Methods of Proof (Part II)

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

1.1 Statements and Compound Statements

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

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

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Propositional Logic: Methods of Proof (Part II)

Formal Verification Methods 1: Propositional Logic

Part 1: Propositional Logic

Manual of Logical Style

Advanced Topics in LP and FP

The statement calculus and logic

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

Intelligent Agents. Pınar Yolum Utrecht University

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

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

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)

Language of Propositional Logic

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

Logical Agents. Chapter 7

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

3 The Semantics of the Propositional Calculus

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

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

Learning Goals of CS245 Logic and Computation

The semantics of propositional logic

Classical Propositional Logic

Logical Agents. Chapter 7

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Propositional logic. Programming and Modal Logic

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

Supplementary Logic Notes CSE 321 Winter 2009

Formal (natural) deduction in propositional logic

Kecerdasan Buatan M. Ali Fauzi

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

THE LOGIC OF COMPOUND STATEMENTS

Propositional Language - Semantics

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

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

10/5/2012. Logic? What is logic? Propositional Logic. Propositional Logic (Rosen, Chapter ) Logic is a truth-preserving system of inference

COMP 2600: Formal Methods for Software Engineeing

Part Two: The Basic Components of the SOFL Specification Language

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

Part 1: Propositional Logic

Chapter 1 Elementary Logic

Foundations of Artificial Intelligence

Propositional Equivalence

Propositional Logic: Deductive Proof & Natural Deduction Part 1

Propositional natural deduction

Propositional Logic: Methods of Proof. Chapter 7, Part II

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

Section 1.1 Propositions

Propositional Logic Language

Logical Agents. Outline

What is Logic? Introduction to Logic. Simple Statements. Which one is statement?

CHAPTER 6 - THINKING ABOUT AND PRACTICING PROPOSITIONAL LOGIC

(p == train arrives late) (q == there are taxis) (r == If p and not q, then r. Not r. p. Therefore, q. Propositional Logic

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

Introduction to Metalogic

Section 1.2: Propositional Logic

Natural Deduction is a method for deriving the conclusion of valid arguments expressed in the symbolism of propositional logic.

Propositional logic ( ): Review from Mat 1348

Manual of Logical Style (fresh version 2018)

2/13/2012. Logic: Truth Tables. CS160 Rosen Chapter 1. Logic?

1 The Foundation: Logic and Proofs

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

03 Propositional Logic II

1 Propositional Logic

n logical not (negation) n logical or (disjunction) n logical and (conjunction) n logical exclusive or n logical implication (conditional)

Tecniche di Verifica. Introduction to Propositional Logic

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

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

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

LOGIC PROPOSITIONAL REASONING

Logical Agents: Propositional Logic. Chapter 7

Transcription:

E 212, Fall 2018, University of Waterloo, Module 2, Page 1 SE 212: Logic and Computation Module 2: Propositional Logic http://www.student.cs.uwaterloo.ca/ se212 se212@uwaterloo.ca Nancy Day

E 212, Fall 2018, University of Waterloo, Module 2, Page 2 Topics in Module 2 1. Elements of a logic 2. Propositional Logic: Syntax 3. Propositional Logic: Semantics 4. Propositional Logic: Proof Theory

E 212, Fall 2018, University of Waterloo, Module 2, Page 3 Elements of a Logic A logic consists of: 1. syntax 2. semantics 3. proof theory (often multiple proof theories)

SE 212, Fall 2018, University of Waterloo, Module 2, Page 4 Syntax and Semantics syntax: define well-formed formula (wff) semantics: define = (pronounced entails or valid or semantic entailment ) = P means the formula P is valid (always true ), where P is a wff in the logic P 1, P 2,..., P n = Q means from the premises P 1, P 2,..., P n, we may conclude Q, where P 1, P 2,..., P n and Q are all wff Note: As a convention in these slides, upper case letters are used to represent any formula and lower case letters are used to represent a symbol in the syntax.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 5 Proof Theories (Deductive Systems) proof theories: define (pronounced proves ) P 1, P 2,..., P n Q is called a sequent. P 1, P 2,..., P n Q means that from P 1, P 2,..., P n we can prove Q using a proof theory. There may be multiple proof theories for the same logic. For some logics, no algorithm exists that always terminates for any sequent.

E 212, Fall 2018, University of Waterloo, Module 2, Page 6 Proof Theory Proof theories are methods that perform mechanical manipulations on strings of symbols. A proof theory doesn t make use of the meanings of sentences, it just manipulates them as strings of characters. Proof theories are based on pattern matching. For a given proof theory, there may be multiple ways to prove a formula.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 7 Soundness and Completeness The semantics and proof theories ( = and ) are related by the concepts of soundness and completeness. Definition. A proof theory is sound if P 1, P 2,..., P n Q (proof) then P 1, P 2,..., P n = Q (valid). Definition. A proof theory is complete if P 1, P 2,..., P n (valid) then P 1, P 2,..., P n Q (proof). = Q

E 212, Fall 2018, University of Waterloo, Module 2, Page 8 Topics in Module 2 1. Elements of a logic (syntax, semantics, proof theories) 2. Propositional Logic: Syntax 3. Propositional Logic: Semantics 4. Propositional Logic: Proof Theory

SE 212, Fall 2018, University of Waterloo, Module 2, Page 9 Propositional Logic Invented by George Boole (1815-64). An Investigation of the Laws of Thought on which are founded The Mathematical Theories of Logic and Probabilities. Image scanned from Makers of Mathematics by Stuart Hollingdale, Penguin Books, 1994.

E 212, Fall 2018, University of Waterloo, Module 2, Page 10 Boole The design of the following treatise is to investigate the fundamental laws of those operations of the mind by which reasoning is performed; to give expression to them in the language of a Calculus, and upon this foundation to establish the science of Logic and construct its method... George Boole An Investigation of the Laws of Thought..., 1854. Propositional logic is also called sentential logic, i.e., the logic of sentences. It is also called propositional calculus, sentential calculus or Boolean logic.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 11 Propositional Logic 1. syntax (well-formed formulas) Proposition symbols Propositional connectives Syntax and well-formed formulas Precedence, associativity of connectives Formalizing natural language Ambiguities in English 2. semantics (truth tables) 3. proof theories transformational proof (sideways proof) natural deduction (forward proof) semantic tableaux (backward proof)

E 212, Fall 2018, University of Waterloo, Module 2, Page 12 Propositional Logic: Syntax A formula in propositional logic consists of the following symbols: 1. two constant symbols: true and false 2. proposition symbols (Usually we just use lower case letters for proposition symbols.) 3. propositional connectives (,,,, ) 4. brackets

SE 212, Fall 2018, University of Waterloo, Module 2, Page 13 Propositional Connectives Definition. The propositional (logical) connectives (operators) are: Symbol Informal Meaning george negation (not)! conjunction (and, both) & disjunction (or, at least one of) implication (implies, conditional, if... then ) => equivalent (biconditional, if and only if) <=> Other texts may use different symbols for these operations.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 14 Propositional Logic: Syntax Definition. The well-formed formulas (wff) of propositional logic are those obtained by the following construction rules: 1. The proposition symbols, and the constants, true and false, are formulas. These are called prime propositions. 2. If P and Q are formulas, then each of the following are formulas: ( P) (P Q) (P Q) (P Q) (P Q) These are compound propositions. No other expressions are formulas. These rules show how a formula is constructed from its subformulas. From now on, when we say formula, we mean well-formed formula.

E 212, Fall 2018, University of Waterloo, Module 2, Page 15 Brackets and Precedence Brackets around the outermost formula are usually omitted. Brackets can be omitted using the following rules of precedence of operators: highest lowest

E 212, Fall 2018, University of Waterloo, Module 2, Page 16 Associativity All binary logical connectives are right associative. Examples a b c means a (b c) a b c means a (b c)

E 212, Fall 2018, University of Waterloo, Module 2, Page 17 Terminology For P Q, P and Q are conjuncts. For P Q, P and Q are disjuncts. In implication, as in P Q: P is the premise or antecedent or hypothesis Q is the consequent or conclusion The contrapositive of P Q is Q P.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 18 Formalizing Natural Language Definition. Proposition symbols represent declarative sentences, i.e., sentences that are true or false. Examples: It is snowing outside. 2 + 5 = 3. The value of program variable a is 42. Sentences that are interrogative (questions), or imperative (commands) are not propositions. (e.g., Is it snowing? is not a proposition).

E 212, Fall 2018, University of Waterloo, Module 2, Page 19 Using Symbols Logic is concerned with the structure of arguments and in particular with the structure of valid arguments. Therefore, we encode sentences in symbols to create a more compact and clearer representation of the argument. DO NOT use T, F, t, or f in any font as proposition symbols because it is confusing!

SE 212, Fall 2018, University of Waterloo, Module 2, Page 20 Example of Using Symbols Example: If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Therefore, there are taxis at the station. Letter p q r Declarative Sentence the train is late there are taxis at the station John is late for his meeting Argument: If p and not q then r. Not r. p. q

SE 212, Fall 2018, University of Waterloo, Module 2, Page 21 Prime and Compound Propositions Example: The snow is red. This example can be represented as a prime proposition because it is atomic (indecomposable). The sentence does not contain any connectives so we can use one proposition symbol to represent it. Example: The snow is red and the grass is green. This example would be represented as a compound proposition because it contains multiple prime propositions joined by the connective and.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 22 Formalizing Natural Language Heuristic: Pick the smallest statements without logical connectives ( and, or, if... then, etc.), about which you can answer the question Is it true or false?. Using proposition symbols to represent these sentences, connect them with the relevant propositional connectives. Our goal is to formalize all the details found in an English sentence while matching the form of the sentence as closely as possible so we can see the correspondence. As closely as possible means matching the order of the conjuncts, etc.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 23 Formalizing Natural Language From p. 16 of the Nissanke text: Connective Possible interpretations in English P not P, P does not hold, it is not the case that P, P is false P Q P and Q, P but Q, not only P but Q, P while Q, P despite Q, P yet Q, P although Q P Q P or Q, P or Q or both, P and/or Q, P unless Q P Q if P then Q, Q if P, P only if Q, Q when P, P is sufficient for Q, Q is necessary for P, P implies Q P Q P if and only if Q (P iff Q), P is necessary and sufficient for Q, P exactly if Q, P is equivalent to Q We will be using these rules in formalizing English statements. There is a summary page on the course web page with this information.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 24 Examples Connective Possible interpretations in English P not P, P does not hold, it is not the case that P, P is false P Q P and Q, P but Q, not only P but Q, P while Q, P despite Q, P yet Q, P although Q P Q P or Q, P or Q or both, P and/or Q, P unless Q P Q if P then Q, Q if P, P only if Q, Q when P, P is sufficient for Q, Q is necessary for P, P implies Q P Q P if and only if Q (P iff Q), P is necessary and sufficient for Q, P exactly if Q, P is equivalent to Q 1. It is cold but not snowing. 2. It is neither snowing nor cold. 3. It is cold if it is snowing. 4. It is snowing only if it is cold. 5. If a request occurs then it will be acknowledged or the process does not make progress.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 25 Ask george 1 #u nday 2 #a 01 3 #q 01a 4 5 % It is cold but not snowing. 6 7 # check PROP 8 9 c &!s 10 11 % where 12 % c means " it is cold " 13 % s means " it is snowing " george checks the syntax of your formula!

SE 212, Fall 2018, University of Waterloo, Module 2, Page 26 Translating Logic into English (o n) ( o m) Symbol o n m Meaning he is in the office we will tell him the news we will leave him a message If he is in the office then we will tell him the news, or if he is not in the office then we will leave him a message.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 27 Example If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Therefore, there are taxis at the station. Letter p q r English the train is late there are taxis at the station John is late for his meeting If p and not q then r. Not r. p. q p q r, r, p = q

E 212, Fall 2018, University of Waterloo, Module 2, Page 28 Ambiguity in English An ambiguous sentence can have more than one distinct meaning. We ve given ourselves fixed rules for how to formalize sentences in logic, but English sentences can be ambiguous. Example from Suzanne Stevenson s (U of T) lecture on natural language understanding at U Waterloo fall, 2001: Mi kmaq can fish for a week.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 29 Ambiguity: Conjunction The use of the logical connectives sometimes doesn t exactly match their meaning in English. In English, there is a difference in meaning between: The driver hit the cyclist and drove on. and The driver drove on and hit the cyclist. The connective and used in logic is commutative, i.e. P Q is equivalent to Q P.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 30 Ambiguity: Disjunction Disjunction, P Q, means at least one of P or Q is true. Both disjuncts could be true. P Q is different from exclusive or, where exactly one disjunct is true. Exclusive or means (P Q) (P Q). Examples: 1. You may take Thursday or Friday off. 2. The error is in the main program or the sensor data.

E 212, Fall 2018, University of Waterloo, Module 2, Page 31 Ambiguity: Unless Example: It rains unless I take an umbrella.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 32 Ambiguity: Implication We have to be careful of the meaning of implication: Example: If an animal moos then it is a cow. m c Watch out for the false implies anything problem!

SE 212, Fall 2018, University of Waterloo, Module 2, Page 33 Ambiguity: Implication ( ) vs Equivalence ( ) Example: If you do not behave then I will take the toy away. Implicitly, the child may keep the toy if they behave.

E 212, Fall 2018, University of Waterloo, Module 2, Page 34 Ambiguity Because a sentence in natural language is often open to multiple interpretations, logic helps us clarify the meanings of descriptions. To describe computer systems and check that they are correct we need precise and unambiguous descriptions. In formalizing sentences for assignments and exams, we will use Nissanke s rules from slide 23.

E 212, Fall 2018, University of Waterloo, Module 2, Page 35 Propositional Logic: Syntax Summary Proposition symbols Propositional connectives Syntax and well-formed formulas Precedence and associativity of connectives Formalizing natural language Ambiguities in English

E 212, Fall 2018, University of Waterloo, Module 2, Page 36 Topics in Module 2 1. Elements of a logic (syntax, semantics, proof theories) 2. Propositional Logic: Syntax 3. Propositional Logic: Semantics ( = ) Boolean valuations Truth tables Satisfiability, tautologies, contradictions, contingent formulas Logical implication ( = ) Logical equivalence ( ) Consistency 4. Propositional Logic: Proof Theory

E 212, Fall 2018, University of Waterloo, Module 2, Page 37 Semantics Semantics means meaning. Semantics relate two worlds. Semantics provide an interpretation (mapping) of expressions in one world in terms of values in another world. Semantics are often a function from expressions in one world to expressions in another world. Proof theories transform the well-formed formulas in ways that respect the semantics of the logic.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 38 Semantics of Propositional Logic We ve described the syntax for propositional logic, which is the domain of the semantic function. Classical logic is two-valued. The two possible truth values are T, and F, which are two distinct values. T F denotes the property of a formula being True denotes the property of a formula being False These are NOT part of the syntax of propositional logic. The range of the semantic function for propositional logic is the set of truth values: Tr = {T, F}

SE 212, Fall 2018, University of Waterloo, Module 2, Page 39 Boolean Valuations Definition. A Boolean valuation is a function from the set of formulas in propositional logic to the set Tr. The semantics of propositional logic are described using Boolean valuations. A Boolean valuation is also called a model or an interpretation. Given a formula p q, we write [p q] to mean the meaning of the formula in a certain Boolean valuation. The [] is a function mapping syntax to its value.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 40 Semantics of Propositional Logic There are functions on these truth values that correspond to the meaning of the propositional connectives: NOT is a function that takes a truth value and returns a truth value, and is the meaning of. AND, OR, IMP, IFF are functions that take two truth values and return a truth value and correspond to,,, respectively. p T F NOT p F T p q p AND q p OR q p IMP q p IFF q T T T T T T T F F T F F F T F T T F F F F F T T

SE 212, Fall 2018, University of Waterloo, Module 2, Page 41 Boolean Valuations In all Boolean valuations: 1. [false] = F, [true] = T 2. [ P] = NOT ([P]) 3. For the connectives: [P Q] = [P] AND [Q] [P Q] = [P] OR [Q] [P Q] = [P] IMP [Q] [P Q] = [P] IFF [Q] The truth value associated with the formula is uniquely determined by the truth values associated with the proposition symbols. When describing a Boolean valuation, we only need to describe the association of truth values with the proposition symbols.

E 212, Fall 2018, University of Waterloo, Module 2, Page 42 Example Show the truth value associated with the formula (p q) r in the Boolean valuation where, [p] = T [q] = F [r] = F [(p q) r] = [p q] AND [r] = ([p] IMP [q]) AND [r] = (T IMP F) AND F = F AND F = F

SE 212, Fall 2018, University of Waterloo, Module 2, Page 43 Example (p q) r What is the meaning of the formula in the following different Boolean valuation? [p] = F [q] = F [r] = T

E 212, Fall 2018, University of Waterloo, Module 2, Page 44 Truth Tables We use truth tables to describe the meaning of a formula in all Boolean valuations. Definition. A truth table has: A row for each possible Boolean valuation (i.e., an assignment of truth values to the proposition symbols in the formula). Each cell contains the truth value for the subformula given by the Boolean valuation of that row.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 45 Example What is the truth table for: (p q)? p q q p q (p q) syntax T T F F T T F T T F one Boolean valuation F T F F T F F T F T In the truth table, there are columns for each proposition symbol and many of the subformulas. The order of the rows in the truth table doesn t matter (although we recommend that you choose a systematic order).

SE 212, Fall 2018, University of Waterloo, Module 2, Page 46 Ask george Here s how to make an ASCII soln to a Boolean valuation question: 1 #u nday 2 #a 01 3 #q 03 4 5 #check NONE 6 7 For the Boolean v a l u a t i o n [ p ] = F, [ q ] = F, [ r ] = T 8 9 [ ( p => q ) & r ) ] 10 = ( [ p ] IMP [ q ] ) AND [ r ] 11 = (F IMP F) AND T 12 = T george does not do any correctness checks.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 47 Ask george Here s how to make an ASCII soln to a truth table question: 1 #u nday 2 #a 01 3 #q 06 4 5 #check NONE 6 7 p q r p => q ( p => q ) & r 8 F F F T F 9 F F T T T 10 F T F T F 11 e t c. george does not do any correctness checks.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 48 Satisfiability Definition. A formula P is satisfiable if there is a Boolean valuation such that [P] = T. We sometimes say that the formula has a satisfying assignment to mean that it is satisfiable. A formula is satisfiable if its truth table has some T s in the last column. Example: p q q p q (p q) T T F F T T F T T F F T F F T F F T F T Therefore (p q) is satisfiable.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 49 Tautologies Definition. A propositional formula P is a tautology (or valid) if [P] = T for all Boolean valuations. A tautology is a formula that is T for all truth values of the proposition symbols used in the formula. The last column of the truth table for a tautology contains all T s. Example: p p p p T F T F T T

SE 212, Fall 2018, University of Waterloo, Module 2, Page 50 Tautologies and Semantics Definition. When a formula Q is a tautology, we write: = Q Therefore, based on the truth table on the previous slide, we can write: = p p

SE 212, Fall 2018, University of Waterloo, Module 2, Page 51 Logical Implication Definition. A formula P logically implies a formula Q if and only if for all Boolean valuations, if [P] = T then [Q] = T. P = Q P = Q iff = P Q Note: the text uses the symbol for logical implication. We will use =, which is more commonly used for describing logics.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 52 Logical Implication We can generalize this to talk about P 1, P 2,..., P n = Q Definition. A set of formulas P 1, P 2,..., P n logically imply a formula Q if and only if for all Boolean valuations, if [P 1 ] = T and [P 2 ] = T,...,[P n ] = T then [Q] = T. P 1, P 2,..., P n = Q This is also called a valid argument. This is equivalent to saying P 1 P 2... P n and also = P 1 P 2... P n Q = Q

SE 212, Fall 2018, University of Waterloo, Module 2, Page 53 Contradiction Definition. A propositional formula A is a contradiction (or falsehood) if [A] = F for all Boolean valuations. The last column of a truth table for a contradiction contains all F s. Example: p p p p T F F F T F

SE 212, Fall 2018, University of Waterloo, Module 2, Page 54 Contingent Definition. A contingent formula is one that is neither a tautology nor a contradiction. A contingent formula has a mixture of T s and F s in the column representing the formula in the truth table.

E 212, Fall 2018, University of Waterloo, Module 2, Page 55 Truth Tables We can use truth tables to determine if a formula is satisfiable, a tautology, a contradiction, or a contingent formula.

E 212, Fall 2018, University of Waterloo, Module 2, Page 56 Relationships among Concepts 1. If a formula is contingent, 2. If a formula is satisfiable, 3. A formula is not satisfiable iff 4. A formula P is a tautology iff P

E 212, Fall 2018, University of Waterloo, Module 2, Page 57 Logical Equivalence Definition. Two formulas, P and Q, are logically equivalent if and only if in all Boolean valuations, [P] = [Q]. P Q P Q iff = P Q is called material equivalence (name of syntactic symbol) is called logical equivalence (name of semantic symbol).

SE 212, Fall 2018, University of Waterloo, Module 2, Page 58 Example of Logical Equivalence p q q p p q p q q p T T T T T F T T F T T T F F F F

E 212, Fall 2018, University of Waterloo, Module 2, Page 59 Consistency Example: 1. If it s snowing out then I have my jacket on. 2. If I have my jacket on then I m not cold. 3. It s snowing out. 4. I m cold. Can this collection of sentences all be true at the same time?

SE 212, Fall 2018, University of Waterloo, Module 2, Page 60 Consistency Definition. A collection of formulas is consistent if there is a Boolean valuation in which all the formulas are T.

E 212, Fall 2018, University of Waterloo, Module 2, Page 61 Checking Consistency To check that a set of formulas is consistent, we check that the conjunction of the formulas is satisfiable, or equivalently: there is a Boolean valuation that maps each formula in the set to T, or there is a Boolean valuation that maps the conjunction of the formulas to T, or the conjunction of the formulas is not a contradiction.

E 212, Fall 2018, University of Waterloo, Module 2, Page 62 Example of Checking Consistency 1. Sales of houses fall off if interest rates rise. 2. Auctioneers are not happy if sales of houses fall off. 3. Interest rates are rising. 4. Auctioneers are happy.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 63 Example of Checking Consistency Does the following have a satisfying assignment? (r s) (s h) r h S3 S4 S1 S2 s r h h r s s h (r s) (s h) r h F F F T T T F F F T F T T F F T F T F T F F T T F F T F T F F T T T F T F T F T F F T T F T T T F T T T F T F F

E 212, Fall 2018, University of Waterloo, Module 2, Page 64 Consistency If the set of formulas in the premise of an implication are not consistent, they can be used to prove a contradiction, i.e., p, p = q q or p, p = false This is called the false implies anything problem, meaning that nothing is proven about a system if there are inconsistent premises. Often our premises describe the environment in which a system executes. We need to ensure that these premises are consistent, i.e., that the environment we describe could possibly exist.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 65 Truth Tables We can use truth tables to find out whether a formula is a tautology, etc. Truth tables describe the truth value of the formula for every combination of truth values for its proposition letters. # prop. symbols # rows in truth table 1 2 2 4 3 8 4 16 5 32 For n proposition symbols in a formula, we need a truth table with 2 n rows.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 66 Proof Theories Using truth tables to check whether a formula is a tautology can be tedious since the size of the truth table grows exponentially with the number of proposition symbols. A proof theory for propositional logic is another way of determining whether a formula is a tautology. As long as the proof theory is sound, we can use the proof theory in place of truth tables to determine tautologies (and valid arguments).

E 212, Fall 2018, University of Waterloo, Module 2, Page 67 Propositional Logic: Semantics Summary: Boolean valuations Truth tables Satisfiability, tautologies, contradictions, contingent formulas Logical implication Logical equivalence Consistency

SE 212, Fall 2018, University of Waterloo, Module 2, Page 68 Topics in Module 2 1. Elements of a logic (syntax, semantics, proof theories) 2. Propositional Logic: Syntax 3. Propositional Logic: Semantics (, = ) 4. Propositional Logic: Proof Theory (, ) 4.1 Transformational Proof 4.2 Natural Deduction 4.3 Semantic Tableaux

Proof Theories for Propositional Logic There are many proof theories for propositional logic. Some match the human reasoning process. Others are better suited to automation by computers. Examples of proof theories are: Transformational proofs (sideways proof, statement algebra, ) Natural Deduction (forward proof, ) Semantic Tableaux (backward proof, ) Hilbert Systems (axiom systems) Resolution DPLL (Davis Putnam Logeman Loveland) Binary Decision Diagrams Each is... based on different insights into the processes by which one recognizes that a formula expresses a logical truth. (M. Fitting, First-Order Logic and Automated Theorem Proving, p. 77) E 212, Fall 2018, University of Waterloo, Module 2, Page 69

E 212, Fall 2018, University of Waterloo, Module 2, Page 70 Topics in Transformational Proof Transformational Proof ( ) Proving equivalence of formulas Logical laws Rules of thumb Relationship between transformational proof and semantics Applications Simplifying conditionals in programming Conjunctive normal form (CNF) and disjunctive normal form (DNF)

SE 212, Fall 2018, University of Waterloo, Module 2, Page 71 Review: Equivalence of Formulas ( ) Two formulas, P and Q, are logically equivalent (P Q) iff For all boolean valuations [P] = [Q]. The last columns of their truth tables are identical. = P Q. What method do we currently know to check if two formulas are equivalent? Build their truth table and check if they have identical last columns. Recall that the size of truth tables grows exponentially in the number of prime propositions in the formula. Is there a better way? Perhaps one that allows us to re-use previously known results about what formulas are equivalent?

SE 212, Fall 2018, University of Waterloo, Module 2, Page 72 Algebra Recall in standard algebra, symbols are used to represent numbers. Algebraic laws are used to manipulate expressions. For example, the following are algebraic laws: 1. (X + Y ) Z = X + (Y Z) 2. Y Y = 0 3. X + 0 = X Using these rules, we can prove: ((a 2) + (b + c)) (b + c) = (a 2) ((a 2) + (b + c)) (b + c) = (a 2) + ((b + c) (b + c)) by Rule 1 = (a 2) + 0 by Rule 2 = (a 2) by Rule 3

SE 212, Fall 2018, University of Waterloo, Module 2, Page 73 Transformational Proofs Now we re going to do the same kind of algebraic manipulation of formulas in propositional logic. Quick example: ((c d) (b a)) (b a) false Sample laws: assoc: (P Q) R P (Q R) contr: P P false simp1: P false false ((c d) (b a)) (b a) (c d) ((b a) (b a)) by assoc (c d) false by contr false by simp1

SE 212, Fall 2018, University of Waterloo, Module 2, Page 74 Transformational Proof Definition. Transformational proof is a means of determining that two well-formed formulas of propositional logic, P and Q, are logically equivalent by the (repeated) exchange of subformulas of P for logically equivalent subformulas that results in P being transformed into Q. Each step must follow a logical law. The logical laws are expressed using the symbol. Equivalences that we can derive using transformational proof are expressed using the symbol.

E 212, Fall 2018, University of Waterloo, Module 2, Page 75 Logical Laws There is a summary page for transformational proof on the course web page. In proofs, please use the short form name that is at the top of the box on the summary page as your justification. Note: Some logical laws can be derived from other logical laws.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 76 Transformational Proof Rules comm P Q Q P P Q Q P P Q Q P P (Q R) (P Q) R P (Q R) (P Q) R assoc lem P P true (P Q) P Q (P Q) P Q dm contr P P false P (Q R) (P Q) (P R) P (Q R) (P Q) (P R) distr impl P Q P Q P Q Q P contrapos idemp P P P P P P P Q (P Q) (Q P) equiv neg ( P) P P true P simp1 P true true P false false P false P This slide includes a few instances of every proof rule. See your summary page for more instances of the proof rules.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 77 Transformational Proof Rules comm P Q Q P P Q Q P P Q Q P P (Q R) (P Q) R P (Q R) (P Q) R assoc lem P P true (P Q) P Q (P Q) P Q dm contr P P false P (Q R) (P Q) (P R) P (Q R) (P Q) (P R) distr impl P Q P Q P Q Q P contrapos idemp P P P P P P P Q (P Q) (Q P) equiv neg ( P) P P true P simp1 P true true P (P Q) P P false false P (P Q) P simp2 P false P This slide includes a few instances of every proof rule. See your summary page for more instances of the proof rules.

Ask george 1 #u nday 2 #a 01 3 #q 01 4 5 # check TP 6 7 p & (!(! q &!p) p) <-> p 8 9 1) p & (!(! q &!p) p) 10 2) p & ((!! q!!p) p) by dm 11 3) p & ((q p) p) by neg * 2 12 4) p & (q (p p)) by assoc 13 5) p & (q p) by idemp 14 6) p by simp2 george checks the syntax of your formulas, the rule names, and the format of your proof! SE 212, Fall 2018, University of Waterloo, Module 2, Page 78

E 212, Fall 2018, University of Waterloo, Module 2, Page 79 Transformational Proofs Two rules are used implicitly in transformational proofs: 1. Rule of substitution: substituting an equivalent formula for a subformula. 2. Rule of transitivity: If P Q and Q R, then P R. This rule is what connects the steps of the proof.

E 212, Fall 2018, University of Waterloo, Module 2, Page 80 Rules of Thumb There are multiple ways to do transformational proofs using different logical laws or applying the logical laws in a different order. Here are some rules of thumb: 1. Eliminate implication and equivalence using the law of implication, the law of equivalence and the contrapositive law backwards. 2. Simplify as soon as you can (simp 1, simp 2, idempotence, negation, law of contradiction, law of excluded middle). 3. Sometimes use the various kinds of simplification backwards to prepare for using distributivity.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 81 Proofs Notes: 1. Apply only one rule per line of your proof. 2. You may apply the same rule to different subformulas in a single proof step and then list the number of times applied (e.g., neg * 2 ) 3. You may apply simplifications, and distributions over multiple conjuncts or disjuncts in a single step. For example, a (b c d) (a b) (a c) (a d) 4. You may use associativity and commutativity of and implicitly (i.e., you don t have to show these steps).

SE 212, Fall 2018, University of Waterloo, Module 2, Page 82 Transformational Proofs and Semantics How do (semantics based on truth tables) and (transformational proof theory) relate? Transformational proof ( ) satisfies the following: 1. If P Q can be proved, then P Q (soundness) 2. If P Q, then P Q can be proved (completeness) Thus, the transformational proof is sound and complete for propositional logic. Therefore, we can use transformational proof to show the logical equivalence of two formulas.

E 212, Fall 2018, University of Waterloo, Module 2, Page 83 Logical Equivalence Now we have two ways to check if two formulas in propositional logic are logically equivalent: (P Q) Build their truth table and check if they have identical last columns Show P Q, and using the soundness of the transformational proof, conclude P Q. (often less tedious than the truth tables) Note that P and Q may be compound formulas.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 84 Propositional Logic: Transformational Proof ( ) Summary: Proving equivalence of formulas Logical laws Rules of thumb Relationship between transformational proof and semantics Applications Simplifying conditionals in programming CNF and DNF

E 212, Fall 2018, University of Waterloo, Module 2, Page 84 Application: Simplifying Conditionals if (i OR NOT o) { if (NOT (o AND q) ) { C1 } else { if (o AND NOT q) { C2 } else { C3 } } } else { C4 } i o q Action T T T C3 T T F C1 T F T C1 T F F C1 F T T C4 F T F C4 F F T C1 F F F C1

SE 212, Fall 2018, University of Waterloo, Module 2, Page 85 Reachable Code How can we show a part of the code (e.g., C3) isn t dead code? C3 is executed when (i o) (o q) (o q) Provide a satisfying assignment for this expression.

E 212, Fall 2018, University of Waterloo, Module 2, Page 86 Simplifying Conditionals C4 is executed when (i o). We can make this condition a little simpler using transformational proof: (i o) i o dm i o neg

SE 212, Fall 2018, University of Waterloo, Module 2, Page 87 Simplified Code if (i AND o AND q) { C3 } else { if (NOT(i) AND o) { C4 } else { C1 } }

SE 212, Fall 2018, University of Waterloo, Module 2, Page 88 Normal Forms Definition. A literal is a proposition symbol or the negation of a proposition symbol. Definition. A formula is in conjunctive normal form (CNF) if it is a conjunction of clauses, where a clause is a disjunction of literals or a single literal. Definition. A formula is in disjunctive normal form (DNF) if it is a disjunction of clauses, where a clause is a conjunction of literals or a single literal. Every formula can be converted to an equivalent formula in CNF and DNF. The formulas true and false are in both CNF and DNF. The normal form of a formula is NOT unique.

E 212, Fall 2018, University of Waterloo, Module 2, Page 89 Converting Formulas to CNF 1. Remove all and using impl and equiv laws. 2. If the formula in question contains any negated compound subformulas, either remove the negation by using the negation law or use DM to push the negation in. 3. Once a formula with no negated compound subformulas is found, use the following distributivity laws: A (B C) (A B) (A C) (A B) C (A C) (B C) 4. Simplify so there are no repeated literals in a clause, and no clause contains true or false and no two clauses with the same set of literals.

E 212, Fall 2018, University of Waterloo, Module 2, Page 90 Converting Formulas to DNF Here is a method for converting a propositional logic formula to DNF. It is very similar to the method for converting to CNF except that different distributive laws are used: 1. Remove all and using impland equivlaws. 2. If the formula in question contains any negated compound subformulas, either remove the negation by using the neglaw or use dmto push the negations in. 3. Once a formula with no negated compound subformulas is found, use the following distributivity laws: a (b c) (a b) (a c) (a b) c (a c) (b c) 4. Simplify until there are no repeated literals and no clause contains true or false and no two clauses contain the same literals.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 91 Propositional Logic: Transformational Proof ( ) Summary: Proving equivalence of formulas Logical laws Rules of thumb Relationship between transformational proof and semantics Applications Simplifying conditionals in programming CNF and DNF

E 212, Fall 2018, University of Waterloo, Module 2, Page 92 Topics in Module 2 1. Elements of a logic (syntax, semantics, proof theories) 2. Propositional Logic: Syntax 3. Propositional Logic: Semantics ( = ) 4. Propositional Logic: Proof Theory 4.1 Transformational Proof 4.2 Natural Deduction Valid Arguments (logical implication) Invalid Arguments Proving validity: natural deduction proof rules 4.3 Semantic Tableaux

Arguments Definition. An argument is a collection of formulas, one of which, referred to as the conclusion, is justified by the others, referred to as the premises. Premises: 1. If the train arrives late and there are no taxis at the station, then John is late for his meeting. (p q r) 2. John is not late for his meeting. ( r) 3. The train did arrive late. (p) Conclusion: There were taxis at the station. (q) p q r, r, p = q where: p = the train is late q = there are taxis at the station r = John is late for his meeting SE 212, Fall 2018, University of Waterloo, Module 2, Page 93

E 212, Fall 2018, University of Waterloo, Module 2, Page 94 Kinds of Arguments Definition. If the conclusion of an argument is wholly justified by the premises, the argument is said to be deductive. Definition. Inductive arguments conclude more general new knowledge from a small number of particular facts or observations. We will only be studying deductive arguments. Later in the course we will look at mathematical induction.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 95 Review: Valid Arguments (Logical Implication) Definition. An argument is a valid argument if in all Boolean valuations where the premises have the value T, the conclusion has the truth value T. P 1, P 2,..., P n = C P 1, P 2,..., P n are premises. C is the conclusion. An argument is valid if and only if the conjunction of the premises logically imply the conclusion. = P means formula P is a tautology. We can also say P is valid to mean P is a tautology.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 96 Review: Consistency of Premises An argument is valid if in the Boolean valuations where the premises are T, then the conclusion is T. What if there is no Boolean valuation in which the premises are all true? We haven t really proven much! Thus, it is important to know there is a way to satisfy the premises. In other words, we should check the consistency of the premises. (You do not have to check the consistency of the premises on an assignment or exam unless specifically asked.)

SE 212, Fall 2018, University of Waterloo, Module 2, Page 97 Review: Invalid Arguments Definition. An argument is invalid if and only if there is at least one Boolean valuation in which the premises are T, but the conclusion is F. How do we show an argument is invalid? Find a counterexample: a Boolean valuation where the premises are T and the conclusion is F. If asked to demonstrate that the Boolean valuation shows the argument is invalid: Method #1 Work out the meaning of the premises and the conclusion in the Boolean valuation. Method #2 Show one row of the truth table where the premises are T and the conclusion is F.

E 212, Fall 2018, University of Waterloo, Module 2, Page 98 Natural Deduction Natural deduction is a deductive system for showing the validity of an argument in propositional logic. Natural deduction is a collection of rules, called inference rules, each of which allows us to infer new formulas from given formulas. Natural deduction is a form of forward proof. Starting from the premises, we use the inference rules to deduce new formulas that logically follow from the premises. Using the formulas we have proven and the premises, we use the rules to deduce more formulas. We continue this process until we have deduced the conclusion. P 1, P 2,..., P n Q

SE 212, Fall 2018, University of Waterloo, Module 2, Page 99 Natural Deduction Gerhard Gentzen (1909 1945). Natural deduction was introduced in his paper Investigations into Logical Deduction, 1935. Src: http://www-groups.dcs.st-andrews.ac.uk/ history/mathematicians/gentzen.html

SE 212, Fall 2018, University of Waterloo, Module 2, Page 100 Inference Rules Definition. An inference rule is a primitive valid argument form. Each inference rule enables the elimination or the introduction of a logical connective. Most inference rules have names that consist of: 1. a logical connective, 2. a letter: i indicates that the rule introduces the connective e indicates that the rule eliminates the connective Examples: and i, imp e

E 212, Fall 2018, University of Waterloo, Module 2, Page 101 Rules for Conjunction and-introduction P Q P Q and i and-elimination P Q and e P P Q Q and e Above the line are the premises of the rule. Below the line is the conclusion. To the right of the line is the name of the rule. P and Q are any formulas. The order of the formula above the line does not matter. These premises must appear in the proof on a step prior to this step.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 102 Using the Conjunction Rules Prove a b, c b c 1) a b premise 2) c premise 3) b by and e on 1 4) b c by and i on 2,3

SE 212, Fall 2018, University of Waterloo, Module 2, Page 103 Ask george 1 #u nday 2 #a 01 3 #q 01 4 5 # check ND 6 7 a & b & c, s & w - b & c & s 8 9 1) a & b & c premise 10 2) s & w premise 11 3) b & c by and_ e on 1 12 4) s by and_ e on 2 13 5) b & c & s by and_ i on 3,4 george checks the syntax of your formula, the form of the proof, and it check your proof steps!!

E 212, Fall 2018, University of Waterloo, Module 2, Page 104 Proofs in Natural Deduction We present proofs in a linear format using line labels. First, we list each of the premises on a line with the word premise beside them. To use an inference rule, formulas matching the premises of the rule must appear on existing lines of the proof. If they do, then we can add the formula matching the conclusion to the proof. The rule must apply to the whole formula on the line (meaning the pattern is matched by the entire formula), not a subpart of the formula. (This is different from transformational proof where the context of the formula didn t matter.)

E 212, Fall 2018, University of Waterloo, Module 2, Page 105 Proofs in Natural Deduction For each step, we list the inference rule and the line labels of the previously deduced formulas that are used to deduce the new formula. Similar to the logical laws of transformational proofs, these are rule schemas, meaning that each symbol in the statement of the inference rule can stand for an arbitrarily complex formula. There is a summary page on the inference rules for natural deduction available from the course web page.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 106 Summary of Natural Deduction Rules INTRODUCTION ELIMINATION INTRODUCTION ELIMINATION P Q P Q and i P Q P and e P P Q or i P Q P Q P P not not i P P imp e not not e P Q Q P P Q iff i P P Q not e P Q P Q iff e

SE 212, Fall 2018, University of Waterloo, Module 2, Page 107 Subproofs Some natural deduction rules use subordinate proofs (subproofs). In a subproof, we start by choosing a formula that we assume is true within the subproof. Then we see what we can prove based on that assumption and any previously deduced formulas. Three proof rules use this approach: Conditional proof (imp i) Indirect proof/proof by contradiction (raa) Case analysis (cases) Every subproof must be closed with one of these rules before you are finished the proof.

General Form of Subproofs. x) P by rule on... x+1) sub proof opening R {. x+y) Q by rule A on... } x+y+1) conclusion by rule B on x+1 x+y. There can be nested subproofs. rule B must be one of the inference rules: imp i, raa or cases. Once the indented part is completed, the subproof is said to be closed. Lines x+1 through x+y are NOT available for use with inference rules after line x+y+1. SE 212, Fall 2018, University of Waterloo, Module 2, Page 108

SE 212, Fall 2018, University of Waterloo, Module 2, Page 109 Subproofs Subproofs are enclosed within {... } and indented, with the opening line of the subproof stating the assumption made in that subproof. The first line after the indented part shows what we are able to conclude from the subproof. The formulas active at a stage in the proof are those that do NOT occur in a closed subproof. We can only use active formulas to derive new formulas meaning we can only use a formula in the proof if it occurs prior to this line in the proof and it doesn t occur within a closed subproof. We have to close all subproofs to complete the proof.

E 212, Fall 2018, University of Waterloo, Module 2, Page 110 Rule: Conditional Proof Implies Introduction (Deduction Thm) assume R {... Q } imp i R Q In the conclusion of this proof rule, we discharge the assumption by creating an implication whose antecedent is the assumption of the subproof, and whose conclusion is the last line of the subproof. The conclusion is outside the scope of the subproof because it explicitly states the dependency on the assumption.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 111 Summary of Natural Deduction Rules INTRODUCTION ELIMINATION INTRODUCTION ELIMINATION P Q P Q and i P Q P and e P P Q or i assume R {... Q } R Q imp i P Q P Q P P not not i P P imp e not not e P Q Q P P Q iff i P P Q not e P Q P Q iff e

SE 212, Fall 2018, University of Waterloo, Module 2, Page 112 Ask george 1 #check ND 2 3 ( c => d ) =>((! c =>! b ) =>(b => d ) ) 4 5 1) assume c=>d { 6 2) assume! c =>!b { 7 3) assume b { 8 4)!! c by imp e on 2,3 9 5) c by n o t n o t e on 4 10 6) d by imp e on 1, 5 11 } 12 7) b => d by i m p i on 3 6 13 } 14 8) (! c =>! b ) =>(b => d ) by i m p i on 2 7 15 } 16 9) ( c =>d ) =>((! c =>!b ) =>(b =>d ) ) by i m p i on 1 8

E 212, Fall 2018, University of Waterloo, Module 2, Page 113 george : Magic (Incremental Development of ND Proofs) george has a magic rule that allows you to conclude anything and continue making progress on your proof. 1 1) assume c=>d { 2 2) assume! c =>!b { 3 3) assume b { 4 6) d by magic 5 } 6 7) b => d by i m p i on 3 6 7 } 8 8) (! c =>! b ) =>(b => d ) by i m p i on 2 7 9 } 10 9) ( c =>d ) =>((! c =>!b ) =>(b =>d ) ) by i m p i on 1 8 A proof with magic in it is NOT a correct proof but it can be marked for part marks. george will note Warning: magic rule has been used. (The magic rule only works in natural deduction.)

SE 212, Fall 2018, University of Waterloo, Module 2, Page 114 Rule: Indirect Proof (Not-introduction, Proof by Contradiction, Reductio ad absurdum) disprove R {... false } raa R disprove R {... false } raa R

SE 212, Fall 2018, University of Waterloo, Module 2, Page 115 Summary of Natural Deduction Rules INTRODUCTION ELIMINATION INTRODUCTION ELIMINATION P Q P Q and i P Q P and e P P Q or i assume R {... Q } R Q imp i P Q P Q P P not not i P P imp e not not e disprove R {... false } raa R P Q Q P iff i P Q P P Q not e P Q P Q iff e

E 212, Fall 2018, University of Waterloo, Module 2, Page 116 Example Premises: 1. If the train arrives late and there are no taxis at the station, then John is late for his meeting. (p q r) 2. John is not late for his meeting. ( r) 3. The train did arrive late. (p) Conclusion: There were taxis at the station. (q) p q r, r, p = q where: p means the train is late q means there are taxis at the station r means John is late for his meeting

E 212, Fall 2018, University of Waterloo, Module 2, Page 117 Case Analysis: Example I get peanut butter or I get jam. If I get peanut butter then I make a sandwich. If I get jam then I make a sandwich. Therefore, I make a sandwich.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 118 Rule: Case Analysis P R case P {. Q } case R {. Q } Q cases

Summary of Natural Deduction Rules INTRODUCTION ELIMINATION INTRODUCTION ELIMINATION P Q P Q assume R {... Q } R Q and i imp i P Q P P Q P Q P P not not i P P and e imp e not not e SE 212, Fall 2018, University of Waterloo, Module 2, Page 119 P P Q or i disprove R {... false } raa R P Q Q P iff i P Q P R case P {... Q } case R {... Q } Q P P Q cases not e P Q P Q iff e

E 212, Fall 2018, University of Waterloo, Module 2, Page 120 Derived Rules Disjunctive Syllogism P Q P Q or e P Q Q P or e

SE 212, Fall 2018, University of Waterloo, Module 2, Page 121 Derived Rules Law of the Excluded Middle P P lem

Summary of Natural Deduction Rules INTRODUCTION ELIMINATION INTRODUCTION ELIMINATION P Q P Q assume R {... Q } R Q and i imp i P Q P P Q P Q P P not not i P P and e imp e not not e SE 212, Fall 2018, University of Waterloo, Module 2, Page 122 P P Q or i P P lem disprove R {... false } raa R P Q Q P iff i P Q P R case P {... Q } case R {... Q } Q P P Q cases not e P Q P Q iff e

SE 212, Fall 2018, University of Waterloo, Module 2, Page 123 Setting subgoals In doing forward proof, we have to guess at will be useful steps toward the conclusion. We can think of these stepping stones as subgoals. Here are some useful strategies: To prove A B A B A B A A Possible subgoals Both A and B Either A or B assume A then prove B (conditional proof) A B for some B A and derive a contradiction (indirect proof)

SE 212, Fall 2018, University of Waterloo, Module 2, Page 124 Form of Proofs You can apply and e to a formula with multiple conjuncts to deduce one of those conjuncts in a single step. You can apply cases over multiple disjuncts in a single step. You can apply and i to introduce multiple conjuncts in a single step (not yet implemented in George).

SE 212, Fall 2018, University of Waterloo, Module 2, Page 125 Soundness and Completeness of Natural Deduction Natural deduction for propositional logic is sound and complete. Soundness: if P 1, P 2,..., P n Q then P 1, P 2,..., P n = Q Natural deduction proves only valid arguments. Completeness: if P 1, P 2,..., P n = Q then P 1, P 2,..., P n Q Natural deduction can be used to prove all valid arguments.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 126 Summary of Natural Deduction Valid arguments Invalid arguments Consistency of premises Inference rules Subproofs Conditional proof (imp i) Indirect proof (proof by contradiction) (raa) Case analysis (cases) Use the summary page of natural deduction rules!

E 212, Fall 2018, University of Waterloo, Module 2, Page 127 Topics in Module 2 1. Elements of a logic (syntax, semantics, proof theories) 2. Propositional Logic: Syntax 3. Propositional Logic: Semantics ( = ) 4. Propositional Logic: Proof Theory 4.1 Transformational Proof 4.2 Natural Deduction 4.3 Semantic Tableaux General form of tableaux Using a tableau to show a set of formulas is inconsistent Tableau expansion rules Heuristic for tableau expansion Using a tableau to show an argument is valid Soundness and completeness

E 212, Fall 2018, University of Waterloo, Module 2, Page 128 Text Reference For semantic tableaux, we are using Ch. 2 from Kelly (see the course pack). Kelly uses different symbols for implication and equivalence: Kelly Nissanke Also Kelly uses mutually consistent where we have used consistent when talking about a set of formulas.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 129 General Form of Tableaux A semantic tableau is a tree representing all ways the conjunction of the formulas at the root of the tree can be true. rule # 1 formula 2 formula rule # 3 smaller formula 4 smaller formula.. 5 smaller formula CLOSED #, # 6 smaller formula CLOSED #, #

SE 212, Fall 2018, University of Waterloo, Module 2, Page 130 Semantic Tableaux Semantic tableaux was invented by E.W. Beth and J. Hintikka (1965). In each step in a semantic tableau proof, we either: Use a semantic tableau rule to expand one compound formula and add new formula(s) to that branch. The rules are based on the outermost propositional connective used in the compound formula (pattern match to the entire formula). Close a branch because it contains contradictory formulas. A branch is a path from the root to the leaf. If all branches of the tree contains contradictory formulas (i.e., every branch is closed), then the formulas at the root of the tree are inconsistent (i.e., there is no Boolean valuation in which the conjunction of the formulas at the root is true).

SE 212, Fall 2018, University of Waterloo, Module 2, Page 131 Rules for Conjunction Rule 1 and nb p q p q not and br p Rule 6 (p q) q

E 212, Fall 2018, University of Waterloo, Module 2, Page 132 Semantic Tableaux A branch is closed if P and P both appear on the path from the root of the tree to the leaf of the branch (i.e., there is a contradiction on the branch). P could be a compound formula. The conjunction of the formulas on a closed branch is a contradiction. We will label all the formulas in the tableau, and list these along with rule names to justify the expansion of the tableau. (The order that formulas get assigned numbers doesn t matter, as long as each formula has a unique number.) The line labels of the formulas listed with a CLOSED line contradict each other.

E 212, Fall 2018, University of Waterloo, Module 2, Page 133 Tableau Expansion Rules There are rules for: each of the binary logical connectives the negation of a formula with each binary logical connective double negation The rules must be applied to the outermost logical connective in the formula (as was true with natural deduction rules). There is a summary sheet available on the course web page with the semantic tableau expansion rules.

Summary of Semantic Tableaux Rules POSITIVE and nb P Q P Q NEGATIVE (P Q) not and br P Q P Q (P Q) or br P Q not or nb P Q P Q imp br P Q P Q iff br P Q P Q SE 212, Fall 2018, University of Waterloo, Module 2, Page 134 not imp nb not not nb not iff br P Q (P Q) P P P Q (P Q) P Q

SE 212, Fall 2018, University of Waterloo, Module 2, Page 135 Heuristic Heuristic: Apply the non-branching rules first. Usually this will result in shorter proofs.

Ask george 1 # check ST 2 3 b & c, d,!( c & d) - false 4 5 1) b & c 6 2) d 7 3)!(c & d) 8 by not_and_br on 3 9 { 10 4)!c 11 by and_nb on 1 12 { % it is optional to put curly braces around 13 % the result of a non - branching step. 14 6) b 15 7) c 16 closed on 4,7 17 } 18 } % more to follow george checks the syntax of your formulas, the rule names, the format of your proof, and that the rules have been correctly applied. SE 212, Fall 2018, University of Waterloo, Module 2, Page 136

SE 212, Fall 2018, University of Waterloo, Module 2, Page 137 Valid Arguments We re trying to prove: P 1, P 2,..., P n Q Can we use semantic tableaux to do this? For an argument to be invalid, there has to be a Boolean valuation in which the premises are T and the conclusion is F there has to be a Boolean valuation in which the premises are T and the negation of the conclusion is T P 1, P 2,..., P n, Q is a consistent set of formulas

E 212, Fall 2018, University of Waterloo, Module 2, Page 138 Valid Arguments To show an argument is valid, we use a semantic tableau to show that P 1, P 2,..., P n, Q is an inconsistent set of formulas: we put the premises and the negation of the conclusion at the root of a tableau. If we can close all the branches of the tableau, then this set of formulas is inconsistent. This means the argument is valid and we can write: P 1, P 2,..., P n Q

SE 212, Fall 2018, University of Waterloo, Module 2, Page 139 Proving Valid Arguments Using Semantic Tableaux 1 premise 2 premise 3 negation of conclusion rule # 4 smaller formula rule #. 5 smaller formula CLOSED #, #. 6 smaller formula CLOSED #, #

E 212, Fall 2018, University of Waterloo, Module 2, Page 140 Proving Valid Arguments Using Semantic Tableaux Semantic tableau is based on the idea of proof by contradiction. It is a refutation-based system.

Summary of Semantic Tableaux Rules POSITIVE and nb P Q P Q NEGATIVE (P Q) not and br P Q P Q (P Q) or br P Q not or nb P Q P Q imp br P Q P Q iff br P Q P Q SE 212, Fall 2018, University of Waterloo, Module 2, Page 141 not imp nb not not nb not iff br P Q (P Q) P P P Q (P Q) P Q

E 212, Fall 2018, University of Waterloo, Module 2, Page 142 Form of Proof A semantic tableaux rule only applies to one formula (i.e., one line of the tree) and must apply to the outermost propositional connective of that formula. Closing a tableau requires two formulas that contradict each other (i.e., two lines of the proof). They must be on the same branch in the tableau. Branching captures disjunction: there are multiple ways to make the formula true. The rules for and (both positive and negative) can be applied to a formula with more than two conjuncts or disjuncts in a single step. You can expand the branches in any order. It s fine if the left and right branches are swapped.

SE 212, Fall 2018, University of Waterloo, Module 2, Page 143 Ask george 1 # check ST 2 3 p &!q => r,!r, p - q 4 5 1) p &!q => r 6 2)!r 7 3) p 8 4)!q 9 by imp_br on 1 10 { 11 5)!(p &!q) 12 by not_and_br on 5 13 { 14 7)!p 15 closed on 3,7 16 } 17 { 18 8)!!q 19 closed on 4,8 20 } 21 } 22 % etc

SE 212, Fall 2018, University of Waterloo, Module 2, Page 144 George: Incremental Development of ST Proofs George will check a ST proof even if a branch is left opened. It will give the feedback Almost Pass... Warning: branch is open. 1 # check ST 2 3 h => s, r=>!s, h -!r 4 5 1) h => s 6 2) r=>!s 7 3) h 8 4)!!r 9 by imp_br on 2 10 { 11 5)!r 12 closed on 4,5 13 } 14 { 15 6)!s 16 }

E 212, Fall 2018, University of Waterloo, Module 2, Page 145 Differences from Kelly Text To show an argument is invalid, provide a Boolean valuation in which the premises are T and the conclusion is F. To show a set of formulas is consistent, provide a Boolean valuation in which all the formulas are T. (This is unlike the Kelly text, which uses an unclosed tableau to say a set of formulas is consistent.)

SE 212, Fall 2018, University of Waterloo, Module 2, Page 146 Soundness and Completeness of Semantic Tableaux Semantic tableaux for propositional logic is sound and complete. Soundness: if P 1, P 2,..., P n Q then P 1, P 2,..., P n = Q Semantic tableaux proves only valid arguments. Completeness: if P 1, P 2,..., P n = Q then P 1, P 2,..., P n Q Semantic tableaux can be used to prove all valid arguments.

E 212, Fall 2018, University of Waterloo, Module 2, Page 147 Summary of Semantic Tableaux General form of tableaux Using a tableau to show a set of formulas is inconsistent Tableau expansion rules Heuristic for tableau expansion Using a tableau to show an argument is valid Soundness and completeness

E 212, Fall 2018, University of Waterloo, Module 2, Page 148 Topics in Module 2 1. Elements of a logic 2. Propositional Logic: Syntax 3. Propositional Logic: Semantics 4. Propositional Logic: Proof Theory 5. Big Example!!

Canadian Automated Air Traffic Control System (CAATS) SE 212, Fall 2018, University of Waterloo, Module 2, Page 149

CAATS SE 212, Fall 2018, University of Waterloo, Module 2, Page 150

E 212, Fall 2018, University of Waterloo, Module 2, Page 151 CAATS 1991(?) 2001 5.8 million square miles of controlled airspace approximately $500 million cost (?) safety standards: MIL-STD-882B, IEEE St.d 1228, IEC 61508 customer: NavCanada developer: Raytheon Systems Canada, Richmond, BC Sources: http://www.raytheon.com/products/caats/ http://www.navcanada.ca/ (search for CAATS)

North Atlantic (NAT) Region SE 212, Fall 2018, University of Waterloo, Module 2, Page 152

SE 212, Fall 2018, University of Waterloo, Module 2, Page 153 Specification (Published by Transport Canada)

Kinds of Separation SE 212, Fall 2018, University of Waterloo, Module 2, Page 154

SE 212, Fall 2018, University of Waterloo, Module 2, Page 155