University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner Adapted from Michael P. Frank ' s course based on the text.

Slides:



Advertisements
Similar presentations
Exercises for CS1512 Weeks 7 and 8 Propositional Logic 1 (questions + solutions)
Advertisements

CSE 311: Foundations of Computing Fall 2013 Lecture 3: Logic and Boolean algebra.
Grading Lecture attendance: -1% per 2 unexcused absences
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Foundations of Logic Mathematical Logic is a tool for working with elaborate compound statements. It includes: A formal language for expressing them.
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
Introduction to Logic Sections 1.1 and 1.2 of Rosen Spring 2010
From Chapter 4 Formal Specification using Z David Lightfoot
Introduction to Logic Sections 1.1 and 1.2 of Rosen Fall 2010 CSCE 235 Introduction to Discrete Structures URL: cse.unl.edu/~cse235 Questions:
Propositional Calculus Math Foundations of Computer Science.
Logic Gates Circuits to manipulate 0’s and 1’s. 0’s and 1’s used for numbers Also to make decisions within the computer. In that context, 1 corresponds.
Adapted from Discrete Math
Propositional Logic Review
The Foundations: Logic and Proofs
Intro to Discrete Structures
Logical Equivalence & Predicate Logic
2009/9 1 Logic and Proofs §1.1 Introduction §1.2 Propositional Equivalences §1.3 Predicates and Quantifiers §1.4 Nested Quantifiers §1.5~7 Methods of Proofs.
Discrete Maths 2. Propositional Logic Objective
Discrete Mathematics and Its Applications
CompSci 102 Discrete Math for Computer Science January 17, 2012 Prof. Rodger.
2009/9 1 Logic and Proofs §1.1 Introduction §1.2 Propositional Equivalences §1.3 Predicates and Quantifiers §1.4 Nested Quantifiers §1.5~7 Methods of.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Ch.1 (Part 1): The Foundations: Logic and Proofs Introduction.
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
1 Propositional Logic Rosen 5 th ed., § Foundations of Logic: Overview Propositional logic:Propositional logic: –Basic definitions. –Equivalence.
Propositional Logic Foundations of Logic: Overview Propositional logic (§ ): – Basic definitions. (§1.1) – Equivalence rules & derivations. (§1.2)
CS 285- Discrete Mathematics Lecture 2. Section 1.1 Propositional Logic Propositions Conditional Statements Truth Tables of Compound Propositions Translating.
Chapter 1: The Foundations: Logic and Proofs
1.1 CompSci 102© Michael Frank Today’s topics Propositional equivalencesPropositional equivalences Predicate logicPredicate logic Reading: Sections Reading:
Review I Rosen , 3.1 Know your definitions!
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
Reading: Chapter 4 (44-59) from the text book
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Propositional Logic. Propositions Any statement that is either True (T) or False (F) is a proposition Propositional variables: a variable that can assume.
1/10/ Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007 Suprakash Datta Office: CSEB 3043 Phone:
Propositional Logic ITCS 2175 (Rosen Section 1.1, 1.2)
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
Chapter 1: The Foundations: Logic and Proofs
The Foundations: Logic and Proof, Sets, and Foundations PROPOSITIONS A proposition is a declarative sentence that is either True or False, but not the.
Logic UNIT 1.
CS1Q Computer Systems Lecture 6 Simon Gay. Lecture 6CS1Q Computer Systems - Simon Gay2 Algebraic Notation Writing AND, OR, NOT etc. is long-winded and.
Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences.
Fall 2013 Foundations of Logic
رياضيات متقطعة لعلوم الحاسب MATH 226. Text books: (Discrete Mathematics and its applications) Kenneth H. Rosen, seventh Edition, 2012, McGraw- Hill.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.
Module #1 - Logic 2016/7/91 Module #1: Logic (Textbook: §1.1~1.4) Dr. Chih-Wei Yi Department of Computer Science National Chiao Tung University.
Propositional Logic. Logic Logic: the science of reasoning, proof, thinking or inference. Logic allows us to analyze a piece of reasoning and determine.
Logic I 권태경 To do so, it should include a language to express statements, a notation to simplify expressions. Logic Mathematical Logic.
Discrete Structures for Computer Science Presented By: Andrew F. Conn Slides adapted from: Adam J. Lee Lecture #1: Introduction, Propositional Logic August.
Lecture 1 – Formal Logic.
CS 202, Spring 2008 Epp, sections 1.1 and 1.2
6/20/2018 Arab Open University Faculty of Computer Studies M131 - Discrete Mathematics 6/20/2018.
COT 3100, Spr Applications of Discrete Structures
(CSC 102) Discrete Structures Lecture 2.
Ch.1 (Part 1): The Foundations: Logic and Proofs
Mathematics for Computing
The Foundations: Logic and Proofs
Principles of Computing – UFCFA3-30-1
Propositional Calculus: Boolean Algebra and Simplification
Information Technology Department
Propositional Equivalence (§1.2)
CS 220: Discrete Structures and their Applications
CS201: Data Structures and Discrete Mathematics I
Lecture 2: Propositional Equivalences
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
Cs Discrete Mathematics
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Discrete Structures Prepositional Logic 2
CS201: Data Structures and Discrete Mathematics I
The Foundations: Logic and Proofs
Presentation transcript:

University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner Adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen

Propositional Logic Rosen 5 th ed., §§ (but much extended) ~85 slides, ~2 lectures

Foundations of Logic Mathematical Logic is a tool for working with compound statements. It includes: A formal language for expressing them. A methodology for reasoning about their truth or falsity. It is the foundation for expressing formal proofs in all branches of mathematics. CS2013 Univ of Aberdeen2

Two Logical Systems: 1.Propositional logic 2.Predicate logic (extends 1. ) Many other logical `calculi` exist, but they tend to resemble these two Many other logical `calculi` exist, but they tend to resemble these two CS2013 Univ of Aberdeen3

Propositional Logic (§1.1) Propositional Logic is the logic of compound statements built from simpler statements using so-called Boolean connectives. Some applications in computer science: Design of digital electronic circuits.Design of digital electronic circuits. Expressing conditions in programs.Expressing conditions in programs. Queries to databases & search engines.Queries to databases & search engines. George Boole ( ) Chrysippus of Soli (ca. 281 B.C. – 205 B.C.) CS2013 Univ of Aberdeen4

Propositions in natural language In propositional logic, a proposition is simply: a statement (i.e., a declarative sentence)a statement (i.e., a declarative sentence) –with some definite meaning having a truth value that ’ s either true (T) or false (F). Only values statements can have.having a truth value that ’ s either true (T) or false (F). Only values statements can have. –Never both, or somewhere “ in between ”. However, you might not know the truth value CS2013 Univ of Aberdeen5

Examples of NL Propositions “ It is raining. ” (In a given situation.)“ It is raining. ” (In a given situation.) “ Beijing is the capital of China, and = 2 ”“ Beijing is the capital of China, and = 2 ” But, the following are NOT propositions: “ Who ’ s there? ” (interrogative: no truth value)“ Who ’ s there? ” (interrogative: no truth value) “ x := x+1 ” (imperative: no truth value)“ x := x+1 ” (imperative: no truth value) “ ” (term: no truth value)“ ” (term: no truth value) CS2013 Univ of Aberdeen6

Propositions in Propositional Logic Atoms: p, q, r, … (Corresponds with simple English sentences, e.g. ‘ I had salad for lunch ’ )Atoms: p, q, r, … (Corresponds with simple English sentences, e.g. ‘ I had salad for lunch ’ ) Complex propositions : built up from atoms using operators: p  q (Corresponds with compound English sentences, e.g., “I had salad for lunch and I had steak for dinner. ” )Complex propositions : built up from atoms using operators: p  q (Corresponds with compound English sentences, e.g., “I had salad for lunch and I had steak for dinner. ” ) CS2013 Univ of Aberdeen7

Defining Propositions Logic defines notions of atomic and complex propositions and what complex propositions “mean”.Logic defines notions of atomic and complex propositions and what complex propositions “mean”. We explain by example, giving precise definitions.We explain by example, giving precise definitions. CS2013 Univ of Aberdeen8

An operator or connective combines with n operand expressions into a larger expression. Unary operators take 1 operand;Unary operators take 1 operand; Binary operators take 2 operands.Binary operators take 2 operands. Propositional or Boolean operators operate on propositions instead of on numbers (+,-).Propositional or Boolean operators operate on propositions instead of on numbers (+,-). Operators / Connectives CS2013 Univ of Aberdeen9

Common Boolean Operators Formal Name NicknameAritySymbol Negation operator NOTUnary¬ Conjunction operator ANDBinary Disjunction operator ORBinary Exclusive-OR operator XORBinary Implication operator IMPLIESBinary Biconditional operator IFFBinary↔ CS2013 Univ of Aberdeen10

The Negation Operator The unary negation operator “ ¬ ” (NOT) combines with one prop, transforming the prop into its negation. E.g. If p = “ I have brown hair. ” then ¬p = “ I do not have brown hair. ” then ¬p = “ I do not have brown hair. ” The truth table for NOT: T :≡ True; F :≡ False “ :≡ ” means “ is defined as ” Operand column Result column CS2013 Univ of Aberdeen11

Truth-functionality Truth table expresses truth/falsity of ¬p in terms of truth/falsity of pTruth table expresses truth/falsity of ¬p in terms of truth/falsity of p This not possible for the operator ‘tomorrow’, or `probably’:This not possible for the operator ‘tomorrow’, or `probably’: –‘Tomorrow p’ is true iff p is ….’?? –‘Probably p’ is true iff p is ….’?? CS2013 Univ of Aberdeen12

Truth-functionality Truth table expresses truth/falsity of ¬p in terms of truth/falsity of p.Truth table expresses truth/falsity of ¬p in terms of truth/falsity of p. Each horizontal line of the table expresses some alternative context.Each horizontal line of the table expresses some alternative context. Truth-functional operator: an operator that is a function from the truth values of the component expressions to a truth value.Truth-functional operator: an operator that is a function from the truth values of the component expressions to a truth value. NOT is truth functional. Yesterday is not.NOT is truth functional. Yesterday is not. Propositional logic is only about truth-functional operators.Propositional logic is only about truth-functional operators. We can compute the values of the complex expressions.We can compute the values of the complex expressions. CS2013 Univ of Aberdeen13

Comment on Truth Not concerned with the "meaning" of a proposition other than whether it is true or false. Not about "how" we know it is true or false, but supposing it is, what else do we know. Abstraction.Not concerned with the "meaning" of a proposition other than whether it is true or false. Not about "how" we know it is true or false, but supposing it is, what else do we know. Abstraction. The "truth" of a proposition determined "by inspection" – The book is on the table. The "real" world.The "truth" of a proposition determined "by inspection" – The book is on the table. The "real" world. The "truth" determined by "stipulation"- suppose The book is on the table is true. Not the "real" world.The "truth" determined by "stipulation"- suppose The book is on the table is true. Not the "real" world. Mostly we are stipulate truth of a proposition. The truth value of P is true/false.Mostly we are stipulate truth of a proposition. The truth value of P is true/false. CS2013 Univ of Aberdeen14

The Conjunction Operator The binary conjunction operator “  ” (AND) combines two propositions to form their logical conjunction. E.g. If p= “ I will have salad for lunch. ” and q= “ I will have steak for dinner. ”, then p  q= “ I will have salad for lunch and I will have steak for dinner. ” CS2013 Univ of Aberdeen15

Note that a conjunction p 1  p 2  …  p n of n propositions will have 2 n rows in its truth table.Note that a conjunction p 1  p 2  …  p n of n propositions will have 2 n rows in its truth table. Also: ¬ and  operations together can express any Boolean truth table!Also: ¬ and  operations together can express any Boolean truth table! Conjunction Truth Table Operand columns CS2013 Univ of Aberdeen16 more later

The Disjunction Operator The binary disjunction operator “  ” (OR) combines two propositions to form their logical disjunction. p= “ My car has a bad engine. ” q= “ My car has a bad carburator. ” p  q= “ Either my car has a bad engine, or my car has a bad carburetor. ” CS2013 Univ of Aberdeen17

Note that p  q means that p is true, or q is true, or both are true!Note that p  q means that p is true, or q is true, or both are true! So, this operation is also called inclusive or, because it includes the possibility that both p and q are true.So, this operation is also called inclusive or, because it includes the possibility that both p and q are true. “ ¬ ” and “  ” together are also universal.“ ¬ ” and “  ” together are also universal. Disjunction Truth Table Note difference from AND CS2013 Univ of Aberdeen18

Nested Propositional Expressions Use parentheses to group sub-expressions: “ I just saw my old friend, and either he ’ s grown or I ’ ve shrunk. ” = f  (g  s)Use parentheses to group sub-expressions: “ I just saw my old friend, and either he ’ s grown or I ’ ve shrunk. ” = f  (g  s) (f  g)  s would mean something different f  g  s would be ambiguous By convention, “ ¬ ” takes precedence over both “  ” and “  ”.By convention, “ ¬ ” takes precedence over both “  ” and “  ”. ¬s  f means (¬s)  f rather than ¬ (s  f) CS2013 Univ of Aberdeen19

Logic as shorthand for NL Let p= “ It rained last night ”, q= “ The sprinklers came on last night, ” r= “ The lawn was wet this morning. ” ¬p = r  ¬p = ¬ r  p  q = It didn't rain last night. The lawn was wet this morning, and it didn ’ t rain last night. Either the lawn wasn ' t wet this morning, or it rained last night, or the sprinklers came on last night. CS2013 Univ of Aberdeen20

Some important ideas: Distinguishing between different kinds of formulasDistinguishing between different kinds of formulas Seeing that some formulas that look different may express the same informationSeeing that some formulas that look different may express the same information First: different kinds of formulasFirst: different kinds of formulas CS2013 Univ of Aberdeen21

Tautologies A tautology is a compound proposition that is true no matter what the truth values of its atomic propositions are! Ex. p   p [What is its truth table?] CS2013 Univ of Aberdeen22

Tautologies When every row of the truth table gives.When every row of the truth table gives T. Example: p   p T T FT F T TFExample: p   p T T FT F T TF CS2013 Univ of Aberdeen23

Contradictions A contradiction is a compound proposition that is false no matter what! Ex. p   p [Truth table?] CS2013 Univ of Aberdeen24

Contradictions When every row of the truth table gives FWhen every row of the truth table gives F Example: p   p T F FT F F TFExample: p   p T F FT F F TF CS2013 Univ of Aberdeen25

Contingencies All other props. are contingencies: Some rows give T, others give F Some rows give T, others give F Now: formulas that have the same meaning CS2013 Univ of Aberdeen26

Propositional Equivalence Two syntactically (i.e., textually) different compound propositions may be semantically identical (i.e., have the same meaning). Here semantically identical means just that they have the same truth table for input truth values of the propositions. We call them logically equivalent. Notation: …  … CS2013 Univ of Aberdeen27

Logical Equivalence Compound proposition p is logically equivalent to compound proposition q, written p  q, IFF p and q contain the same truth values in all rows of their truth tables We will also say: they express the same truth function (= the same function from values for atoms to values for the whole formula). CS2013 Univ of Aberdeen28

Ex. Prove that p  q   (  p   q). Proving Equivalence via Truth Tables F T T T T T T T T T F F F F F F F F T T CS2013 Univ of Aberdeen29 Shows that OR is equivalent to a combination of NOT and AND.

Before introducing more connectives … let us step back and ask a few questions about truth tables… let us step back and ask a few questions about truth tables CS2013 Univ of Aberdeen30

1.What does each line of the table "mean"? 2.Consider a conjunction p 1  p 2  p 3 How many rows are there in its truth table? 3.Consider a conjunction p 1  p 2  …  p n of n propositions. How many rows are there in its truth table? 4.Explain why ¬ and  together are sufficient to express any Boolean truth table Questions for you to think about CS2013 Univ of Aberdeen31

1.Consider a conjunction p 1  p 2  p 3 How many rows are there in its truth table? 8 p 1  p 2  p Questions for you to think about CS2013 Univ of Aberdeen32 Two truth values (0,1) and three propositions: 2 3 = 8.

2. Consider p 1  p 2  …  p n How many rows are there in its truth table? 2*2*2* … *2 (n factors) Hence 2 n (This grows exponentially!) Questions for you to think about CS2013 Univ of Aberdeen33

3. Explain why ¬ and  together are sufficient to express any other complex expression in propositional logic. Questions for you to think about CS2013 Univ of Aberdeen34

3.Explain why ¬ and  together are sufficient to express any other complex expression in propositional logic. Obviously, if we add new connectives (like  ) we can write new formulas.Obviously, if we add new connectives (like  ) we can write new formulas. CLAIM: these formulas would always be equivalent with ones that only use ¬ and  (This is what we need to prove).CLAIM: these formulas would always be equivalent with ones that only use ¬ and  (This is what we need to prove). Questions for you to think about CS2013 Univ of Aberdeen35

Saying this in a different way: if we add new connectives, we can write new formulas, but these formulas will always only express truth functions that can already be expressed by formulas that only use ¬ and .Saying this in a different way: if we add new connectives, we can write new formulas, but these formulas will always only express truth functions that can already be expressed by formulas that only use ¬ and . That is, they will be equivalent.That is, they will be equivalent. Example of writing a disjunction in another form (equivalence shown before): p  q  ¬(¬p  ¬q)Example of writing a disjunction in another form (equivalence shown before): p  q  ¬(¬p  ¬q) Relating AND and OR CS2013 Univ of Aberdeen36

Mystery Operator PQR Formula (containing P,Q,R) Does there exist such a Formula? CS2013 Univ of Aberdeen37 Suppose, given the truth values of P, Q, and R, we construct a Formula with the given resulting truth value. This is our 'mystery' operator. Can it be written equivalently with NOT and AND.

3. Explain why ¬ and  together are sufficient to express any Boolean truth table Suppose precisely two rows give T. For example, the rows whereSuppose precisely two rows give T. For example, the rows where –P=T, Q=T, R=F. This is P  Q  ¬R –P=T, Q=F, R=T. This is P  ¬Q  R T-values in Conjunction CS2013 Univ of Aberdeen38

Suppose precisely two rows give T. For example, the rows where –P=T, Q=T, R=F. This is P  Q  ¬R –P=T, Q=F, R=T. This is P  ¬Q  R We’ve proven our claim if we can express the disjunction of these two rows: (P  Q  ¬R)  (P  ¬Q  R)We’ve proven our claim if we can express the disjunction of these two rows: (P  Q  ¬R)  (P  ¬Q  R) Table as a disjunction of T-rows CS2013 Univ of Aberdeen39

We’ve arrived if we can express their disjunction: (P  Q  ¬R)  (P  ¬Q  R)We’ve arrived if we can express their disjunction: (P  Q  ¬R)  (P  ¬Q  R) But we’ve seen that disjunction can be expressed using  and ¬: A  B  ¬(¬A  ¬B)But we’ve seen that disjunction can be expressed using  and ¬: A  B  ¬(¬A  ¬B) So: (P  Q  ¬R)  (P  ¬Q  R)  ¬(¬ (P  Q  ¬R)   (P  ¬Q  R))So: (P  Q  ¬R)  (P  ¬Q  R)  ¬(¬ (P  Q  ¬R)   (P  ¬Q  R)) We’ve only used  and .We’ve only used  and . Disjoining rows of the table CS2013 Univ of Aberdeen40

(P  Q  ¬R)  (P  ¬Q  R)  ¬(¬ (P  Q  ¬R)   (P  ¬Q  R)) Check CS2013 Univ of Aberdeen41 Notice that we only state where the new mystery connective is true as it is false elsewhere.

About this proof … We’ve made our task a bit easier, assuming that there were only 2 rows resulting in TWe’ve made our task a bit easier, assuming that there were only 2 rows resulting in T But the case with 1 or 3 or 4 or …. rows is analogous (and there are always only finitely many rows.)But the case with 1 or 3 or 4 or …. rows is analogous (and there are always only finitely many rows.) So, the proof can be made preciseSo, the proof can be made precise CS2013 Univ of Aberdeen42

Having proved this … We can express every possible truth-functional operator in propositional logic in terms of AND and NOTWe can express every possible truth-functional operator in propositional logic in terms of AND and NOT This is sometimes called functional completeness. Also universality.This is sometimes called functional completeness. Also universality. Reduce other operators to other more basic operators.Reduce other operators to other more basic operators. Very useful in computing to reduce complexity of formulas (Normal forms)Very useful in computing to reduce complexity of formulas (Normal forms) CS2013 Univ of Aberdeen43

Let’s introduce some additional connectives A variant of disjunctionA variant of disjunction The conditionalThe conditional The biconditionalThe biconditional CS2013 Univ of Aberdeen44

The Exclusive Or Operator The binary exclusive-or operator “  ” (XOR) combines two propositions to form their logical “ exclusive or ”. p = “ I will earn an A in this course, ” q = “ I will drop this course, ” p  q = “ I will either earn an A in this course, or I will drop it (but not both!) ” CS2013 Univ of Aberdeen45

Note that p  q means that p is true, or q is true, but not both!Note that p  q means that p is true, or q is true, but not both! This operation is called exclusive or, because it excludes the possibility that both p and q are true.This operation is called exclusive or, because it excludes the possibility that both p and q are true. “ ¬ ” and “  ” together are not universal.“ ¬ ” and “  ” together are not universal. Exclusive-Or Truth Table Note difference from OR. CS2013 Univ of Aberdeen46

Note that English “ or ” can be ambiguous regarding the “ both ” case! Need context to disambiguate the meaning! For this class, assume “ or ” means inclusive. Natural Language is Ambiguous CS2013 Univ of Aberdeen47

Test your understanding of the two types of disjunction 1.Suppose p  q is true. Does it follow that p  q is true? 2.Suppose p  q is true. Does it follow that p  q is true? CS2013 Univ of Aberdeen48

Test your understanding of the two types of disjunction 1.Suppose p  q is true. Does it follow that p  q is true? No: consider p TRUE, q TRUE 2.Suppose p  q is true. Does it follow that p  q is true? Yes. Check each of the two assignments that make p  q true: a) p TRUE, q FALSE (makes p  q true) b) p FALSE, q TRUE (makes p  q true) CS2013 Univ of Aberdeen49

The Implication Operator The implication p  q states that p implies q. I.e., If p is true, then q is true; but if p is not true, then q could be either true or false. E.g., let p = “ You study hard. ” q = “ You will get a good grade. ” p  q = “ If you study hard, then you will get a good grade. ” antecedentconsequent CS2013 Univ of Aberdeen50

Implication Truth Table p  q is false only when (p is true but q is not true)p  q is false only when (p is true but q is not true) p  q does not say that p causes q!p  q does not say that p causes q! p  q does not require that p or q are true!p  q does not require that p or q are true! E.g. “ (1=0)  pigs can fly ” is TRUE!E.g. “ (1=0)  pigs can fly ” is TRUE! The only False case! CS2013 Univ of Aberdeen51

Implication Truth Table Suppose you know that q is T. What do you know about p  q ?Suppose you know that q is T. What do you know about p  q ? CS2013 Univ of Aberdeen52

Implication Truth Table Suppose you know that q is T. What do you know about p  q ?Suppose you know that q is T. What do you know about p  q ? The conditional must be TThe conditional must be T CS2013 Univ of Aberdeen53

Implication Truth Table Suppose you know that p is F. What do you know about p  q ?Suppose you know that p is F. What do you know about p  q ? The conditional must be TThe conditional must be T CS2013 Univ of Aberdeen54

Implication Truth Table Suppose you know that p is T.Suppose you know that p is T. What do you know about p  q ? T or F.What do you know about p  q ? T or F. What do you know aboutWhat do you know about q? T or F. q? T or F. CS2013 Univ of Aberdeen55

Implications between real sentencs “ If this lecture ever ends, then the sun has risen this morning. ” True or False?“ If this lecture ever ends, then the sun has risen this morning. ” True or False? “ If Tuesday is a day of the week, then I am a penguin. ” True or False?“ If Tuesday is a day of the week, then I am a penguin. ” True or False? “ If 1+1=6, then Bush is president. ” True or False?“ If 1+1=6, then Bush is president. ” True or False? “ If the moon is made of green cheese, then 1+1=7. ” True or False?“ If the moon is made of green cheese, then 1+1=7. ” True or False? CS2013 Univ of Aberdeen56

Why does this seem wrong? Recall “If [you study hard] then [you’ll get a good grade]”Recall “If [you study hard] then [you’ll get a good grade]” In normal English, this asserts a causal connection between the two propositions. The connective  does not capture this connection.In normal English, this asserts a causal connection between the two propositions. The connective  does not capture this connection. CS2013 Univ of Aberdeen57

English Phrases Meaning p  q “ p implies q ”“ p implies q ” “ if p, then q ”“ if p, then q ” “ if p, q ”“ if p, q ” “ when p, q ”“ when p, q ” “ whenever p, q ”“ whenever p, q ” “ q if p ”“ q if p ” “ q when p ”“ q when p ” “ q whenever p ”“ q whenever p ” “ p only if q ” “ p is sufficient for q ” “ q is necessary for p ” “ q follows from p ” “ q is implied by p ” CS2013 Univ of Aberdeen58 Tricky: "only if" is p  q. "p only if q" says that p cannot be true when q is not true. The statement "p only if q" is false where p is true, but q is false. Where p is true, then so is q.

But we’re not studying English.. Probably no two of these expressions have exactly the same meaning in EnglishProbably no two of these expressions have exactly the same meaning in English For example, ‘I’ll go to the party if Mary goes’ can be interpreted as implying ‘I’ll only go to the party if Mary goes’ turning the sentence into a biconditional: I go IFF Mary goesFor example, ‘I’ll go to the party if Mary goes’ can be interpreted as implying ‘I’ll only go to the party if Mary goes’ turning the sentence into a biconditional: I go IFF Mary goes CS2013 Univ of Aberdeen59

Biconditional Truth Table p q means that p and q have the same truth value.p  q means that p and q have the same truth value. Note this truth table is the exact opposite of  ’ s!Note this truth table is the exact opposite of  ’ s! Thus, p q means ¬(p  q) Thus, p  q means ¬(p  q) p q does not imply that p and q are true, or that either of them causes the other.p  q does not imply that p and q are true, or that either of them causes the other. CS2013 Univ of Aberdeen60

Consider... The truth of p q, where The truth of p  q, where 1.p= Scotland is in the UK q= 2+2 =4 2.p= Scotland is not in the UK q= 2+2 =5 3.p= Scotland is in the UK q= Wales is not in the UK CS2013 Univ of Aberdeen61

Consider... The truth of p q, where The truth of p  q, where 1.p= Scotland is in the UK q= 2+2 =4 TRUE 2.p= Scotland is not in the UK q= 2+2 =5 TRUE 3.p= Scotland is in the UK q= Wales is not in the UK FALSE CS2013 Univ of Aberdeen62

The difference between  and  A B says that A and B happen to have the same truth value. They could be atomic. A  B says that A and B happen to have the same truth value. They could be atomic. A  B says that no assignment of truth values to A and B can make A B false A  B says that no assignment of truth values to A and B can make A  B false So, A  B can only hold between well- chosen compound A and B. So, A  B can only hold between well- chosen compound A and B. A  B says “A B is a tautology” A  B says “A  B is a tautology” CS2013 Univ of Aberdeen63

Consider... The truth of p  q, where 1.p= Scotland is in the UK q= 2+2 =4 2.p= Scotland is not in the UK q= Wales is not in the UK 3.p= Scotland is in UK  Wales is in UK q= Wales is in UK  Scotland is in UK CS2013 Univ of Aberdeen64

Consider... The truth of p  q, where 1.p= Scotland is in the UK q= 2+2 =4 FALSE 2.p= Scotland is not in the UK q= Wales is not in the UK FALSE 3.p= Scotland is in UK  Wales is in UK q= Wales is in UK  Scotland is in UK TRUE CS2013 Univ of Aberdeen65

The language of propositional logic defined more properly (i.e., as a formal language) Atoms: p1, p2, p3,..Atoms: p1, p2, p3,.. Formulas:Formulas: –All atoms are formulas –For all , if  is a formula then ¬  is a formula –For all  and , if  and  are formulas then the following are formulas: (    ), (    ), (    ) (etc.) CS2013 Univ of Aberdeen66

The language of propositional logic defined more properly (i.e., as a formal language) Which of these are formulas, according to this strict definition?Which of these are formulas, according to this strict definition? p1  ¬ p2 p1  ¬ p2 (p1  ¬ p2)(p1  ¬ p2) ¬ ¬ ¬(p9  p8) ¬ ¬ ¬(p9  p8) (p1  p2  p3)(p1  p2  p3) (p1  (p2  p3))(p1  (p2  p3)) CS2013 Univ of Aberdeen67

The language of propositional logic defined more properly (i.e., as a formal language) Which of these are formulas, according to this strict definition?Which of these are formulas, according to this strict definition? p1  ¬ p2 No p1  ¬ p2 No (p1  ¬ p2) Yes(p1  ¬ p2) Yes ¬ ¬ ¬(p9  p8) Yes ¬ ¬ ¬(p9  p8) Yes (p1  p2  p3) No(p1  p2  p3) No (p1  (p2  p3)) Yes(p1  (p2  p3)) Yes CS2013 Univ of Aberdeen68

Simplifying conventions Convention 1: outermost brackets may be omitted,: p1  ¬ p2, ¬ ¬ ¬(p9  p8), p1  (p2  p3)Convention 1: outermost brackets may be omitted,: p1  ¬ p2, ¬ ¬ ¬(p9  p8), p1  (p2  p3) Convention 2: associativity allows us to omit even more brackets, e.g.: p1  p2  p3, p1  p2  p3Convention 2: associativity allows us to omit even more brackets, e.g.: p1  p2  p3, p1  p2  p3 CS2013 Univ of Aberdeen69

The language of propositional logic defined more properly (i.e., as a formal language) Which of these are formulas, when using these two conventions?Which of these are formulas, when using these two conventions? p1  ¬ p2 Yes p1  ¬ p2 Yes (p1  ¬ p2) Yes(p1  ¬ p2) Yes ¬ ¬ ¬(p9  p8) Yes ¬ ¬ ¬(p9  p8) Yes (p1  p2  p3) No(p1  p2  p3) No (p1  (p2  p3)) Yes(p1  (p2  p3)) Yes CS2013 Univ of Aberdeen70

Contrapositive Some terminology, for an implication p  q: Its converse is: q  p.Its converse is: q  p. Its contrapositive:¬q  ¬ p.Its contrapositive:¬q  ¬ p. Which of these two has/have the same meaning (express same truth function) as p  q? Prove it.Which of these two has/have the same meaning (express same truth function) as p  q? Prove it. CS2013 Univ of Aberdeen71

Contrapositive Proving the equivalence of p  q and its contrapositive, using truth tables: CS2013 Univ of Aberdeen72

Boolean Operations Summary We have seen 1 unary operator (out of the 4 possible ones) and 5 binary operators:We have seen 1 unary operator (out of the 4 possible ones) and 5 binary operators: CS2013 Univ of Aberdeen73

For you to think about: 1.Can you think of yet another 2-place connective? How many possible connectives do there exist? CS2013 Univ of Aberdeen74

For you to think about: 1.How many possible connectives do there exist? p connective q T ? T T ? F F ? T F ? F Each question mark can be T or F, hence 2*2*2*2=16 connectives p connective q T ? T T ? F F ? T F ? F Each question mark can be T or F, hence 2*2*2*2=16 connectives CS2013 Univ of Aberdeen75

Example of another connective p connective q compare: p and q p connective q compare: p and q T F T T T T F F F T T F F T F F T F T T T T F F F T T F F T F F Names: NAND, Sheffer stroke CS2013 Univ of Aberdeen76

Some Alternative Notations CS2013 Univ of Aberdeen77

To this point You have learned about: Propositional logic operators ’Propositional logic operators ’ –Symbolic notations. –English equivalents –Truth tables. –Logical equivalence Next: –More about logical equivalences. –How to prove them. CS2013 Univ of Aberdeen78

Tautologies revisited We’ve introduced the notion of a tautology using the example p   pWe’ve introduced the notion of a tautology using the example p   p Now, you know more operators, so can formulate many more tautologies, e.g., the following are tautologies: (p  q)   (  p   q) (p  q)  (¬q  ¬ p), and so onNow, you know more operators, so can formulate many more tautologies, e.g., the following are tautologies: (p  q)   (  p   q) (p  q)  (¬q  ¬ p), and so on CS2013 Univ of Aberdeen79

Equivalence Laws Similar to arithmetic identities in algebraSimilar to arithmetic identities in algebra Patterns that can be used to match (part of) another propositionPatterns that can be used to match (part of) another proposition Abbreviation: T stands for an arbitrary tautology; F an arbitrary contradictionAbbreviation: T stands for an arbitrary tautology; F an arbitrary contradiction CS2013 Univ of Aberdeen80

Equivalence Laws - Examples Identity: p  T  p p  F  pIdentity: p  T  p p  F  p Domination: p  T  T p  F  FDomination: p  T  T p  F  F Idempotence: p  p  p p  p  pIdempotence: p  p  p p  p  p Double negation:  p  pDouble negation:  p  p Commutativity: p  q  q  p p  q  q  pCommutativity: p  q  q  p p  q  q  p Associativity: (p  q)  r  p  (q  r) (p  q)  r  p  (q  r)Associativity: (p  q)  r  p  (q  r) (p  q)  r  p  (q  r) CS2013 Univ of Aberdeen81

More Equivalence Laws Distributive: p  (q  r)  (p  q)  (p  r) p  (q  r)  (p  q)  (p  r)Distributive: p  (q  r)  (p  q)  (p  r) p  (q  r)  (p  q)  (p  r) De Morgan ’ s:  (p  q)   p   q  (p  q)   p   qDe Morgan ’ s:  (p  q)   p   q  (p  q)   p   q Trivial tautology/contradiction: p   p  T p   p  FTrivial tautology/contradiction: p   p  T p   p  F Augustus De Morgan ( ) CS2013 Univ of Aberdeen82

Defining Operators via Equivalences Some equivalences can be thought of as definitions of one operator in terms of others: Exclusive or: p  q  (p  q)  (p  q) p  q  (p  q)  (q  p)Exclusive or: p  q  (p  q)  (p  q) p  q  (p  q)  (q  p) Implies: p  q   p  qImplies: p  q   p  q Biconditional: p  q  (p  q)  (q  p) p  q   (p  q)Biconditional: p  q  (p  q)  (q  p) p  q   (p  q) CS2013 Univ of Aberdeen83

How you may use equivalence laws: Example (1) Use equivalences to prove that  (  r   s)  s  r.Use equivalences to prove that  (  r   s)  s  r. CS2013 Univ of Aberdeen84

How you may use equivalence laws: Example (1)  (  r   s)  (De Morgan)  (  r   s)  (De Morgan)  r   s  (Commutativity)  s   r  (2x Double Negation) s  r.s  r.s  r.s  r. CS2013 Univ of Aberdeen85

How you may use equivalence laws: Example (2) Use equivalences to prove that (p   q)  (p  r)   p  q   r.Use equivalences to prove that (p   q)  (p  r)   p  q   r. (This would be much easier using truth tables!)(This would be much easier using truth tables!) (p   q)  (p  r) [Expand “ definition ” of  ]   (p   q)  (p  r) [Expand “ definition ” of  ]   (p   q)  (p  r) [Expand “ definition ” of  ]   (p   q)  ((p  r)   (p  r)) [DeMorgan]  (  p  q)  ((p  r)   (p  r)) cont. cont. CS2013 Univ of Aberdeen86 Underline just focuses interest.

Long example Continued... (  p  q)  ((p  r)   (p  r))  [  commutes]  (q   p)  ((p  r)   (p  r)) [  is associative]  q  (  p  ((p  r)   (p  r))) [distrib.  over  ]  q  (((  p  (p  r))  (  p   (p  r))) [assoc.]  q  (((  p  p)  r)  (  p   (p  r))) [taut.]  q  ((T  r)  (  p   (p  r))) [domination]  q  (T  (  p   (p  r))) [identity]  q  (  p   (p  r))  cont. CS2013 Univ of Aberdeen87

End of Long Example q  (  p   (p  r)) [DeMorgan]  q  (  p  (  p   r)) [Assoc.]  q  ((  p   p)   r) [Idempotent]  q  (  p   r) [Associativity]  (q   p)   r [Commutativity]   p  q   r Q.E.D. (quod erat demonstrandum) CS2013 Univ of Aberdeen88

Summary In practice, Propositional Logic equivalences are seldom strung together into long proofs: using truth tables is usually much easier.In practice, Propositional Logic equivalences are seldom strung together into long proofs: using truth tables is usually much easier. We shall now turn to a more complex logic, where nothing like truth tables is available.We shall now turn to a more complex logic, where nothing like truth tables is available. CS2013 Univ of Aberdeen89