Download presentation
Presentation is loading. Please wait.
Published byAubrey Robbins Modified over 8 years ago
1
Copyright © Peter Cappello 2011 Predicates & Quantifiers
2
Copyright © Peter Cappello 2011 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.
3
Copyright © Peter Cappello 2011 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 2013 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 2011 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.
6
Copyright © Peter Cappello 2011 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 2011 Preconditions & Postconditions The Java assert statement incorporates an executable propositional function. assert x != null;
8
Copyright © Peter Cappello 2011 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 2011 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 2011 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
Copyright © Peter Cappello 2011 Computational Interpretation // Pseudo-Java notation boolean forAllxPx( Set domain ) { for ( Object element : domain ) { if ( ! P( element ) ) return false; } return true; }
12
Copyright © Peter Cappello 2011 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?
13
Copyright © Peter Cappello 2011 Computational Interpretation // Pseudo-Java notation boolean thereExistsxPx( Set domain ) { for ( Object element : domain ) { if (P( element ) ) return true; } return false; }
14
Copyright © Peter Cappello 2011 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
15
Copyright © Peter Cappello 2013 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 ) ?
16
Copyright © Peter Cappello 2013 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”
17
Copyright © Peter Cappello 2011 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.
18
Copyright © Peter Cappello 2013 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?
19
Copyright © Peter Cappello 2013 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 corrrectly?)
20
Copyright © Peter Cappello 2011 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
© 2024 SlidePlayer.com. Inc.
All rights reserved.