Lecture 8 Introduction to Logic CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine
CSCI 1900 Lecture Lecture Introduction Reading –Rosen - Section 1.1 Logical Statements Logical Connectives / Compound Statements –Negation –Conjunction –Disjunction Truth Tables Quantifiers –Universal –Existential
CSCI 1900 Lecture Statement of Proposition Proposition (statement of proposition) – a declarative sentence that is either true or false, but not both Examples: –Star Trek was a TV series: True –2+3 = 5: True –Do you speak Klingon? This is a question, not a statement
CSCI 1900 Lecture Statement of Proposition (cont) –x - 3 = 5: a declarative sentence, but not a statement since it is true or false depending on the value of x –Take two aspirins: a command, not a statement –The current temperature on the surface of the planet Venus is 800 o F: a proposition of whose truth is unknown to us –The sun will come out tomorrow: a proposition that is either true or false, but not both, although we will have to wait until tomorrow to determine the answer
CSCI 1900 Lecture Notation x, y, z, … denote variables that can represent real numbers p, q, r,… denote propositional variables that can be replaced by statements –p: The sun is shining today –q: It is cold
CSCI 1900 Lecture Negation (Not) If p is a statement, the negation of p is the statement not p Denoted ~p ( alternately: !p or p or p ) If p is True, –~p is False If p is False, –~p is True not is a unary operator for the collection of statements and ~p is a statement if p is a statement
CSCI 1900 Lecture Negation Truth Table p~ p TF FT
CSCI 1900 Lecture Examples of Negation If p: 2+3 > 1 Then ~p: 2+3 < 1 If q: It is night Then –~q: It is not the case that it is night, It is not night It is day
CSCI 1900 Lecture Conjunction If p and q are statements –The conjunction of p and q is the compound statement “p and q” –Denoted p q p q is true only if both p and q are true Example: –p: ETSU parking permits are readily available –q: ETSU has plenty of parking –p q = ?
CSCI 1900 Lecture Conjunction Truth Table pq p q TTT TFF FTF FFF
English Conjunctives The following are common conjunctives in English: And, Now, But, Still, So, Only, Therefore, Moreover, Besides, Consequently, Nevertheless, For, However, Hence, Both... And, Not only... but also, While, Then, So then CSCI 1900 Lecture
CSCI 1900 Lecture Disjunction (Inclusive) If p and q are statements, –The (inclusive) disjunction of p and q is the compound statement “p or q” –Denoted p q p q is true if either p is true or q is true or both are true Example: –p: I am a male q: I am under 90 years old –p q = ? –p: I am a male q: I am under 20 years old –p q = ?
CSCI 1900 Lecture Disjunction (Inclusive) Truth Table pq p q TTT TFT FTT FFF
CSCI 1900 Lecture Exclusive Disjunction If p and q are statements –The exclusive disjunction true if either p is true or q is true, but not both are true –Denoted p q Example: –p: It is daytime –q: It is night time –p q (in the exclusive sense) = ?
CSCI 1900 Lecture Disjunction(Exclusive) Truth Table pq p q TTF TFT FTT FFF
CSCI 1900 Lecture Exclusive versus Inclusive Depending on the circumstances, some English disjunctions are inclusive and some of exclusive. Examples of Inclusive –“I have a dog” or “I have a cat” –“It is warm outside” or “It is raining” Examples of Exclusive –Today is either Tuesday or it is Thursday –The light is either on or off
CSCI 1900 Lecture Compound Statements A compound statement is a statement made by joining simple propositions with logical connectors For n individual propositions, there are 2 n possible combinations of truth values The truth table contains 2 n rows identifying the truth values for the statement represented by the table Use parenthesis to denote order of precedence has precedence over Use parenthesis to ensure meaning is clear
CSCI 1900 Lecture Truth Tables as Tools Compound statements can be easily and systematically investigated with truth tables Assign a portion of the compound statement to a column Final column represents the complete compound statement
CSCI 1900 Lecture Compound Statement Example pq p q ~p (p q) (~p) TTTFT TFFFF FTFTT FFFTT
CSCI 1900 Lecture Quantifiers Recall from Section 1.1, a set may be defined by its properties {x | P(x)} For a specific element e to be a member of the set, P(e) must evaluate to “true” P(x) is called a predicate or a propositional function
CSCI 1900 Lecture Computer Science Functions if P(x) then execute certain steps while Q(x) do specified actions
CSCI 1900 Lecture Universal Quantification Universal quantification of the predicate P(x) means “For all values of x, P(x) is true” Denoted x P(x) The symbol is called the universal quantifier The order in which multiple universal quantifications are applied does not matter (e.g., x y P(x,y) ≡ y x P(x,y) )
CSCI 1900 Lecture Universal Examples: P(x): -(-x) = x –This predicate makes sense for all real numbers x R –The universal quantification of P(x), x P(x), is a true statement, because for all real numbers, -(-x) = x Q(x): x+1<4 – x Q(x) is a false statement, because, for example, Q(5) is not true
CSCI 1900 Lecture Existential Quantification Existential quantification of a predicate P(x) is the statement: “There exists a value of x for which P(x) is true.” Denoted x P(x) Existential quantification may be applied to several variables in a predicate The order in which multiple existential quantifications are considered does not matter
CSCI 1900 Lecture Existential Examples: P(x): -(-x) = x –The existential quantification of P(x), x P(x), is a true statement, because there is at least one real number where -(-x) = x Q(x): x+1<4 – x Q(x) is a true statement, because, for example, Q(2) is true Nota Bene: is not the complement of –An Example N(x): x ≠ x x N(x) is false and x N(x) is also false
CSCI 1900 Lecture Applying Both and Quantifications Order of application matters Example: Let A and B be n x n matrices The statement A ( B | A + B = I n ) Reads: for every A there is a B such that A + B = I n Prove by coming up for equations for b ii and b ij (j i) Now reverse the order: B ( A | A + B = I n) Reads: there exists a B, for all A, such that, A + B = I n The second proposition is F A L S E !
CSCI 1900 Lecture Assigning Quantification - 1 Let p: x R(x) [R(x): a person is good] –If p is true then x ~R(x) is false If every person is good, then there does not exist person who is not good –If p is true then x R(x) is true If every person is good, then there exists a person who is good –If p is false then x ~R(x) is true If not every person is good, then there exists a person who is not good
CSCI 1900 Lecture Assigning Quantification - 2 Let p: x R(x) [R(x): a person is good] –If p is true then x ~R(x) is false If there exists a person who is good, then it is not true that all people are not good –If p is false then x ~R(x) is true If there does not exist a good person then every person is not good
CSCI 1900 Lecture Implications of the Previous Slide Assume a statement is made that “for all x, P(x) is true” –If we can find one case that is not true The statement is false –If there isn’t one case that is not true The statement is true Example: positive integers, n, n P(n) = n 2 - n + 41 is a prime number –This is false because an integer resulting in a non- prime value, i.e., n such that P(n) is false
CSCI 1900 Lecture Key Concepts Summary Statement of Proposition Logical Connectives / Compound Statements –Negation –Conjunction –Disjunction Truth Tables Quantifiers –Universal –Existential