Download presentation
Presentation is loading. Please wait.
Published bySara Quinn Modified over 9 years ago
1
Predicates & Quantifiers Goal: Introduce predicate logic, including existential & universal quantification Introduce translation between English sentences & logical expressions.
2
Copyright © Peter Cappello The Limits of Propositional Logic Consider the argument – All computer science courses are easy. –CS 2 is a computer science course. –Therefore, CS 2 is easy. Translating into propositions, gives the form: –p –q –Therefore, r. But, (p q) r is not a tautology: The argument is not valid in propositional logic.
3
Copyright © Peter Cappello Declaration = subject + predicate A declarative sentence has a subject & a predicate. –A subject is a thing (e.g., object, entity, concept). –A predicate asserts that its subject has some property.
4
Copyright © Peter Cappello Examples Joe’s serves prime rib. [ P( Joe’s ) ] 7 is a prime number. [Q( 7 ) ] Jill is a prime candidate. [R( Jill ) ] Variable values are in a set called the domain. Each proposition above has a different domain (i.e., restaurants, integers, candidates, respectively).
5
Copyright © Peter Cappello Using variables Consider the argument: If ( x is a CS course ) ( x is easy ) AND CS 2 is a CS course. then CS 2 is easy. “x is a CS course” is not a proposition because x is a variable.
6
Copyright © Peter Cappello Propositional Function Denote “x is a CS class” by P( x ). P( Math 3A ) is a proposition. Denote “x 2 + y 2 = z 2 ” by P( x, y, z ). P( -1, 1, 17 ) is a proposition.
7
Copyright © Peter Cappello Preconditions & Postconditions The Java assert statement incorporates an executable propositional function. assert x != null;
8
Copyright © Peter Cappello Preconditions & Postconditions Integer abs( Integer x ) { assert x != null; if ( x < 0 ) x = new Integer( -x ); assert x >= 0; return x; }
9
Copyright © Peter Cappello Quantifiers A propositional function also is converted to a proposition via quantification. Let C denote the set of all UCSB courses. Let C be the domain of discourse or domain. Let P( x ) denote “x is a CS class”.
10
Copyright © Peter Cappello Universal Quantification Universal quantification of P( x ) is –“For all x in the domain, P( x )” –“For all x in C, P( x )” –“For all x, P( x )” –“ x P( x )” This is a proposition. If C denotes the set of all UCSB courses, is x P( x ) true?
11
x P( x ): Logical Equivalence If S, a set with n elements, e i, 1 ≤ i ≤ n, is the domain of propositional function P( x ), Then x P( x ) ≡ P( e 1 ) ∧ P( e 2 ) ∧ … ∧ P( e n ) What if S is infinite? Copyright © Peter Cappello
12
Computational Interpretation // Pseudo-Java notation boolean forAllxPx( Set domain ) { for ( Object element : domain ) { if ( ! P( element ) ) return false; } return true; }
13
Copyright © Peter Cappello Existential Quantification Existential quantification of P( x ) is –“There exists an x in the domain, P( x )” –“There exists an x in C, P( x )” –“There exists an x, P( x )” –“ x P( x )” This is a proposition. Is x P( x ) true?
14
x P( x ): Logical Equivalence If S, a set with n elements, e i, 1 ≤ i ≤ n, is the domain of propositional function P( x ), Then x P( x ) ≡ P( e 1 ) ∨ P( e 2 ) ∨ … ∨ P( e n ) What if S is infinite? Copyright © Peter Cappello
15
Computational Interpretation // Pseudo-Java notation boolean thereExistsxPx( Set domain ) { for ( Object element : domain ) { if (P( element ) ) return true; } return false; }
16
Copyright © Peter Cappello Precedence of Quantifiers and have higher precedence than logical operators. x P( x ) P( x ) means ( x P( x ) ) P( x ) Is ( x P( x ) ) P( x ) a proposition? x in “ P( x )” is called an unbound or free variable
17
Copyright © Peter Cappello Logical Equivalence Let S & T be statements with predicates & quantifiers. For example S denotes “ x ( P( x ) Q (x ) ) T denotes “ x P( x ) x Q( x ) S is logically equivalent to T, denoted S ≡ T, when they have the same truth value regardless of which –Predicates are substituted into the statements –Domain of discourse is used for the variables. Is x ( P( x ) P( x ) ) ≡ x P( x ) x P( x ) ?
18
Copyright © Peter Cappello Logically Equivalent Forms Below, “one” means “at least one” “all true” x P( x ) ≡ ~ x ~P( x ) “none false” “all false” x ~P( x ) ≡ ~ x P( x ) “none true” “not all true” ~ x P( x ) ≡ x ~P( x ) “one false” “not all false” ~ x ~P( x ) ≡ x P( x ) “one true”
19
Copyright © Peter Cappello Translate English to a Logical Expression “A student is eligible to receive an MS degree, if the student has: –at least 60 units, or at least 45 units and written a master’s thesis –received a grade no lower than B in all required courses. ” Where –M( s ) denotes “student s is eligible to receive an MS degree.” –U( s, u ) denotes “student s has at least u units.” –T( s ) denotes “student s has written a master’s thesis.” –G( s ) denotes “student s received at least a B in all required courses.
20
Copyright © Peter Cappello One Translation –M( s ): “s eligible to receive an MS degree.” –U( s, u ): “s has taken at least u units.” –T( s ): “s has written a master’s thesis.” –G( s ): “s received at least a B in all required courses. s ( ( ( U( s, 60 ) ( U( s, 45 ) T( s ) ) ) G(s) ) M( s ) ) Is this what you think the department wanted?
21
Copyright © Peter Cappello Translate English to a Logical Expression “There is a student who has taken more than 21 units in a quarter and received all As.” Where P( s, q ) denotes “s took > 21 units in quarter q.” Q( s, q ) denotes “s got all As in quarter q.” (Is Q defined correctly?)
22
Copyright © Peter Cappello One Translation s q ( P( s, q ) Q( s, q ) ), where P( s, q ): “s took > 21 units in quarter q.” Q( s, q ): “Student s got all As in quarter q.” This is an example of nested quantifiers, our next topic.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.