Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
• Propositional Logic
• Logical Operators
• Truth Tables
• Implication
• Logical Equivalence
• Inference Rules
10/1/12 CS160 Fall Semester 2012 2
n A proposition is a statement that is either true n ¬ logical not (negation)
or false n ∨ logical or (disjunction)
n Examples: n ∧ logical and (conjunction)
Fort Collins is in Nebraska (false)
n
n ⊕ logical exclusive or
n Java is case sensitive (true)
n → logical implication (conditional)
n We are not alone in the universe (?)
n ↔ logical bi-implication (biconditional)
n Every proposition is true or false, but its truth
value may be unknown
10/1/12 CS160 Fall Semester 2012 3 10/1/12 CS160 Fall Semester 2012 4
1
10/29/12
n (3) You should be able to translate natural n (4) You should be able to translate
language to logic (can be ambiguous!): propositional logic to natural language:
n English: n Logic:
“If the car is out of gas, then it will stop” p equals “it is raining”
n Logic: q equals “the grass will be wet”
p equals “the car is out of gas” p→q
q equals “the car will stop” n English:
p→q “If it is raining, the grass will be wet.”
10/1/12 CS160 Fall Semester 2012 7 10/1/12 CS160 Fall Semester 2012 8
2
10/29/12
n Certain propositions are equivalent (meaning n (5) And you should know how to prove logical
they share exactly the same truth values): equivalence with a truth table
n For example: n For example: ¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∧ q) ≡ ¬p ∨ ¬q De Morgan’s p q ¬p ¬q (p ∧ q) ¬(p ∧ q) ¬p ∨ ¬q
(p ∧ T) ≡ p Identity Law T T F F T F F
(p ∧ ¬p) ≡ F Negation Law T F F T F T T
F T T F F T T
F F T T F T T
10/1/12 CS160 Fall Semester 2012 9 10/1/12 CS160 Fall Semester 2012 10
10/1/12 CS160 Fall Semester 2012 11 10/1/12 CS160 Fall Semester 2012 12
3
10/29/12
10/1/12 CS160 Fall Semester 2012 15 10/1/12 CS160 Fall Semester 2012 16
4
10/29/12
10/1/12 CS160 Fall Semester 2012 19 10/1/12 CS160 Fall Semester 2012 20
5
10/29/12
10/1/12 CS160 Fall Semester 2012 21 10/1/12 CS160 Fall Semester 2012 22
6
10/29/12
n (11) You should recognize predicate logic n Specifies a proposition (and optionally a
symbols, i.e. quantifications. domain), for example:
n Quantification express the extent to which a n ∃x ∈ N, -10 < x < -5 // False, since no negative x
predicate is true over a set of elements: n ∀x ∈ N, x > -1 // True, since no negative x
n Universal ∀, “for all” n Predicate logic has similar equivalences and
n Existential ∃, “there exists” inference rules (De Morgan’s):
n (12) You should able to translate between n ∀x: P(x) = ¬∃x : ¬P(x) // True for all = false for none
predicate logic and English, in both directions. n ¬∀x: P(x) = ∃x : ¬P(x) // Not true for all = false for some
10/1/12 CS160 Fall Semester 2012 27 10/1/12 CS160 Fall Semester 2012 28