Download presentation
Presentation is loading. Please wait.
Published byRose Jean Williams Modified over 9 years ago
1
CS 285- Discrete Mathematics Lecture 2
2
Section 1.1 Propositional Logic Propositions Conditional Statements Truth Tables of Compound Propositions Translating English Sentences 2 Propositional logic
3
Propositional Logic Definition Rules of Logic are what gives meaning to mathematical statements Propositional logic is the logic of compound statements built from simpler statements using so-called Boolean connectives Some of its applications in Computer Science ▫Design of digital electronic circuits ▫Expressing Conditions in programs ▫Queries to database and search engines Propositional logic 3
4
Propositions Definition: a proposition (denoted by p, q, r, …) is ▫A statement or declarative sentence with a clear and un ambiguous meaning Ex. It is raining today ▫Having a truth value that is either True(T) or False (F). It never has both, neither, or anywhere “in between” Ex. 1 + 1 = 2 (True) 2 + 2 = 3 (False) Propositional logic 4
5
Examples of Propositions “It is raining.” (In a given situation.) “Beijing is the capital of China.” “1 + 2 = 3” ▫But, the following are NOT propositions: “Who’s there?” (interrogative, question) “Just do it!” (imperative, command) “1 + 2” (expression with a non-true/false value) “ x = y + 2 ’’ Propositional logic 5
6
Operators / Connectives An operator or connective combines one or more operand expressions into a larger expression. (E.g., “+” in numeric exprs.) ▫Unary Operators take 1 operand (ex. – 3) ▫Binary operators take 2 operands (ex. 3 × 4). ▫ Propositional or Boolean operators operate on propositions (or their truth values) instead of numbers. Propositional logic 6
7
Popular Boolean Operators Formal NameLogic nameParitySymbol Negation OperatorNOTUnary¬ Conjunction OperatorANDBinary ∧ Disjunction OperatorORBinary ∨ Exclusive-OR OperatorXORBinary ⊕ Implication Operator (Conditional) ImpliesBinary → Bi-conditional OperatorIFFBinary ↔ Propositional logic 7
8
Operators - Negation The unary negation operator “¬” (NOT) transforms a prop. into its logical negation. ▫Ex. If p = “I have brown hair.” then ¬p = “I do not have brown hair.” The truth table for NOT: ◦T : ≡ True; F : ≡ False ◦ “: ≡ ” means “is defined as” Propositional logic 8 p¬p TF FT
9
Operators – Conjunction The binary conjunction operator “ ∧ ” (AND) combines two propositions to form their logical conjunction. ▫Ex. 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.” ▫The Truth Table is Propositional logic 9 pq p∧qp∧q FFF TFF FTF TTT Note that a conjunction p1 ∧ p2 ∧ … ∧ pn of n propositions will have 2n rows in its truth table.
10
Operators – Disjunction The binary disjunction operator “ ∨ ” (OR) combines two propositions to form their logical disjunction. ▫Ex. p=“My car has a bad engine.” & q=“My car has a bad carburetor.” ▫p ∨ q=“Either my car has a bad engine, or my car has a bad carburetor, or both.” Meaning is like and/or in English ▫The Truth Table is Propositional logic 10 pq p ∨ q FFF TFT FTT TTT 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.
11
Operators – Exclusive OR The binary exclusive-or operator “ ⊕ ” (XOR) combines two propositions to form their logical “exclusive or” ▫Ex. p = “I will earn an A in this course,” q = “I will drop this course,” Then ▫p ⊕ q = “I will either earn an A in this course, or I will drop it (but not both!)” ▫The Truth Table is Propositional logic 11 pq p⊕ qp⊕ q FFF TFT FTT TTF 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.
12
Natural Language Ambiguity Note that English “or” can be ambiguous regarding the “both” case! ▫“Pat is a singer or Pat is a writer.” - ∨ ▫“Pat is a man or Pat is a woman.” - ⊕ ▫Need context to understand the meaning! ▫For this class, we will assume “or” means inclusive unless specified otherwise. Propositional logic 12
13
Operator - Implication 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. ▫Ex., 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.” (else, it could go either way) ▫The Truth Table is: Propositional logic 13 pqp→ qp→ q FFT TFF FTT TTT 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 require that p or q are ever true! Ex. “(1=0) → pigs can fly” is TRUE
14
Propositional logic 14 English Phrases Meaning p → q “p implies q” “if p, then q” “if p, q” “when p, q” “whenever p, q” “q if p” “q when 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” “ q unless ¬ p’’
15
Intricacies -- I “if p then q’’ expresses the same thing as “p only if q’’ (which really says q is necessary for p) To remember this, note that “p only if q’’ says that p cannot be true when q is not true (check the truth table of implication) “if p then q’’ expresses the same thing as “p only if q’’. In other words, if q is false, p must be false. Do not mistake this for p if q: this says, if q is false, p may or may not be false. Propositional logic 15
16
Intricacies -- II “if p then q’’ expresses the same thing as “q unless ¬ p’’: ▫Ex: If Maria learns discrete Mathematics, then she will find a good job. Maria will find a good job unless she does not learn discrete mathematics. Propositional logic 16
17
Converse, Inverse, Contrapositive Some terminology, for an implication p → q: ▫Its converse is: q → p. ▫ Its inverse is: ¬p → ¬q. ▫ Its contrapositive: ¬q → ¬ p. One of these three has the same meaning (same truth table) as p → q. Can you figure out which? Propositional logic 17
18
Proof Proving the equivalence of p → q and its contrapositive using truth tables: Propositional logic 18 ¬q → ¬pp→qp→q¬p¬qqp TTTTFF TTTFTF FFFTFT TTFFTT
19
Exercise The converse and the inverse of a conditional statement are also equivalent. But neither is equivalent to the original conditional statement. What are the contrapositive, the converse, and the inverse of the conditional statement: “If it is raining, then the home team wins.’’? Propositional logic 19
20
Intricacies Re-visited Why “if p then q’’ expresses the same thing as “p only if q’’. We know that p → q is equivalent to ¬ q → ¬ p Then this must express p only if q, because if ¬ q, then ¬ p, a contradiction. Notice we are not claiming p if q (because here, if ¬ q, then we have p or ¬ p. Propositional logic 20
21
The biconditional operator The biconditional p ↔ q states that p is true if and only if (IFF) q is true. ▫p = “You can take the flight.” ▫q = “You buy a ticket.” ▫p ↔ q = “You can take the flight if and only if you buy a ticket.” ▫The truth table: Propositional logic 21 pqp↔ qp↔ q FFT TFF FTF TTT p ↔ q means that p & q have the same truth value. Note this truth table is the exact opposite of ⊕ ’s! 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, or that they have a common cause..
22
Intricacies p → q ▫ p is sufficient but not necessary for q ▫q is necessary but not sufficient for p p ↔ q ▫p is necessary and sufficient for q ▫q is necessary and sufficient for p Propositional logic 22
23
Truth Tables of Compound Propositions Compound propositions involve any number of propositional variables and logical connectors. Construct the truth table of the compound proposition: (p ∨ ¬q) → (p ∧ q) Propositional logic 23
24
Precedence of Logical Operators Example, how do you interpret ¬ p ∧ q? In order of most dominating: ▫¬ ▫ ∧ ▫ ∨ ▫ → ▫ ↔ Propositional logic 24
25
Translating English Sentences -- I “You can access the internet from campus only if you are a computer science major or you are not a freshman’’. Let a, c and f, represent `` You can access the internet from campus’’, ``you are a computer science major’’, and ``you are a freshman’’, respectively. ▫We then have: a → (c ∨ ¬f) Propositional logic 25
26
Translating English Sentences -- II “You cannot ride the roller coaster if you are under 4 feet tall unless you are older than 16 years old.’’ q = “You can ride the roller-coaster’’ r = “You are under 4 feet tall’’ S = “You are older than 16 years old’’ ▫We then have:(r ∧ ¬ s) → ¬ q Propositional logic 26
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.