Nested Quantifiers Goals: 1. Explain how to work with nested quantifiers 2. Show that the order of quantification matters. 3. Work with logical expressions involving multiple quantifiers. Nested Iteration • Let the domain be { 1, 2, …, 10 }. • Let P( x, y ) denote x > y. • x y P( x, y ) means x ( y P( x, y ) ) Is the above statement true? Copyright © Peter Cappello 2 boolean axEyP() // x y P( x, y ) { for ( int x = 1; x <= 10; x++ ) { boolean b = false; for ( int y = 1; y <= 10; y++ ) { if ( x > y ) { b = true; break; // finding 1 y value is enough } } if ( ! b ) return false; } return true; } Copyright © Peter Cappello Computational Interpretation 3 Multiple Quantifiers Legend: A B is valid x y P(x, y) y x P(x, y) y x P(x, y) x y P(x, y) x y P(x, y) y x P(x, y) y x P(x, y) x y P(x, y) Copyright © Peter Cappello 4 Translate to English • Let the domain be the real numbers. x y ( ( x ≥ 0 y < 0 ) x – y > 0 ) • Is there something wrong with x ( ( x ≥ 0 y ( y < 0 ) ) x – y > 0 ) Copyright © Peter Cappello 5 Translate to a Logical Expression • Let Q( s, q ) denote “s has been a contestant on quiz show q” • I( s1, s2 ) denote “student s1 is student s2” • The domain for s, s1, s2 is students at UCSB. • The domain for q is quiz shows on TV. • Give a logical expression for: 1. Every TV quiz show has had a student from UCSB as a contestant. 2. At least 2 students from UCSB have been contestants on Jeopardy. Copyright © Peter Cappello 6 Translations 1. q s Q( s, q ) Copyright © Peter Cappello 7 2. s1 s2 ( I( s1, s2 ) Q( s1, Jeopardy ) Q( s2 , Jeopardy ) ) Copyright © Peter Cappello 8 Negating Nested Quantifiers Negate x y ( P( x, y ) Q( x, y ) ) so that no quantifiers are negated. 1. x y ( P( x, y ) Q( x, y ) ). Copyright © Peter Cappello 9 Negating Nested Quantifiers Negate x y ( P( x, y ) Q( x, y ) ) so that no quantifiers are negated. 1. x y ( P( x, y ) Q( x, y ) ). 2. x y ( P( x, y ) Q( x, y ) ). Copyright © Peter Cappello 10 Negating Nested Quantifiers Negate x y ( P( x, y ) Q( x, y ) ) so that no quantifiers are negated. 1. x y ( P( x, y ) Q( x, y ) ). 2. x y ( P( x, y ) Q( x, y ) ). 3. x y ( P( x, y ) Q( x, y ) ). Copyright © Peter Cappello 11 Negating Nested Quantifiers Negate x y ( P( x, y ) Q( x, y ) ) so that no quantifiers are negated. 1. x y ( P( x, y ) Q( x, y ) ). 2. x y ( P( x, y ) Q( x, y ) ). 3. x y ( P( x, y ) Q( x, y ) ). 4. x y ( P( x, y ) Q( x, y ) ). Copyright © Peter Cappello 12