Download presentation
Presentation is loading. Please wait.
1
Predicates & Quantifiers
Goal: Introduce predicate logic, including existential & universal quantification Introduce translation between English sentences & logical expressions.
2
The Limits of Propositional Logic
Consider the argument All computer science courses are easy. CS 40 is a computer science course. Therefore, CS 40 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. Copyright © Peter Cappello
3
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. Copyright © Peter Cappello
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 ) ] In a propositional function, each variable takes values from a set called the variable’s domain. Each propositional function above has a different domain (restaurants, integers, candidates). Copyright © Peter Cappello
5
Copyright © Peter Cappello
Using variables Consider the argument: If ( x is a CS course ) ( x is easy ) AND CS 40 is a CS course. then CS 40 is easy. “x is a CS course” is not a proposition because x is a variable. Copyright © Peter Cappello
6
Propositional Function
Denote “x is a CS class” by P( x ). P( Math 3A ) is a proposition. Denote “x2 + y2 = z2” by P( x, y, z ). P( -1, 1, 17 ) is a proposition. Copyright © Peter Cappello
7
Preconditions & Postconditions
The Java assert statement incorporates an executable propositional function. assert x != null; Copyright © Peter Cappello
8
Preconditions & Postconditions
Integer abs( Integer x ) { assert x != null; if ( x < 0 ) x = new Integer( -x ); assert x >= 0; return x; } Copyright © Peter Cappello
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”. Copyright © Peter Cappello
10
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? Copyright © Peter Cappello
11
x P( x ): Logical Equivalence
If S, a set with n elements, ei, 1 ≤ i ≤ n, is the domain of propositional function P( x ), Then x P( x ) ≡ P( e1 ) ∧ P( e2 ) ∧ … ∧ P( en ) What if S is infinite? Copyright © Peter Cappello
12
Computational Interpretation for Finite Domains
// Pseudo-Java notation boolean forAllxPx( Set domain ) { for ( Object element : domain ) if ( ! P( element ) ) return false; } return true; Copyright © Peter Cappello
13
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? Copyright © Peter Cappello
14
x P( x ): Logical Equivalence
If S, a set with n elements, ei, 1 ≤ i ≤ n, is the domain of propositional function P( x ), Then x P( x ) ≡ P( e1 ) ∨ P( e2 ) ∨ … ∨ P( en ) What if S is infinite? Copyright © Peter Cappello
15
Computational Interpretation for Finite Domains
// Pseudo-Java notation boolean thereExistsxPx( Set domain ) { for ( Object element : domain ) if (P( element ) ) return true; } return false; Copyright © Peter Cappello
16
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 Copyright © Peter Cappello
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 ) ? Copyright © Peter Cappello
18
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” Copyright © Peter Cappello
19
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 E( 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.” Copyright © Peter Cappello
20
Copyright © Peter Cappello
One Translation E( 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) ) E( s ) ) Is this what you think the department wanted to state? Copyright © Peter Cappello
21
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 received all As in quarter q.” (Is Q defined correctly?) Copyright © Peter Cappello
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 ): “s received all As in quarter q.” This is an example of nested quantifiers, our next topic. Copyright © Peter Cappello
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.