320 likes | 450 Views
Predicate Calculus 1 Motivation Basics Encoding. Motivation: More Accurate and General Representations of Knowledge. “If Willy is a bird, then Willie can fly.” Propositional calculus: P: Willy is a bird Q: Willy can fly P Q “Any bird can fly.” Predicate calculus
E N D
Predicate Calculus 1MotivationBasicsEncoding CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Motivation: More Accurate and General Representations of Knowledge “If Willy is a bird, then Willie can fly.” Propositional calculus: P: Willy is a bird Q: Willy can fly P Q “Any bird can fly.” Predicate calculus x (Bird(x) CanFly(x) ) CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Another Example “John’s grandfather was a blacksmith, and his mother was a seamstress.” Propositional calculus: P1: John’s grandfather was a blacksmith. P2: John’s grandmother was a seamstress. P Q Predicate calculus: Q1(x): x is a blacksmith. Q2(x): x is a seamstress. f(x): grandfather of x. Q1(f(x)) Q2(m(x)) CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Terminology of the Predicate Calculus Predicate symbols: P, Q, R, P1, P2, ... , Q1, Q2, ..., R1, R2, ... If P takes n arguments, we call P an n-ary predicate P( term1, term2, . . . , termn) n 0 Function symbols: f, g, h, f1, f2, . . . , g1, g2, . . . , h1, h2, . . . A term is either: a constant: e.g., a, b, c, a1, a2, . . . , b1, b2, . . . , c1, c2, . . . a variable: e.g., x, y, z, x1, x2, . . . , y1, y2, . . . , z1, z2, . . . an n-ary function symbol, followed by n terms in parentheses. Examples of terms: x, a, f(x), g1(a, y), h(f(x), g(y, b)) CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Well-Formed Formulas Atomic formula: an n-ary predicate symbol followed by n terms in parentheses: e.g., P(x, f(x, a, y)) If F is an atomic formula, then it is a well-formed formula (WFF). Compound formula: a statement formed from one or more WFFs using logical connectives. If F is a compound formula, then it is a WFF. e.g., P(x, f(x, a, y)) v (Q R(x)) Quantified formula:a statement formed from a WFFs by prefixing it with a quantifier and a variable. e.g., ( x) (P(x, f(x, a, y)) v (Q R(x))) ( y) Q(y) If F is a quantified formula, then it is a WFF. CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
A Syllogism forPredicate Logic Resolution Coloured flowers are always scented. I dislike flowers that are not grown in the open air. No flowers grown in the open air are colourless. Therefore, I dislike all flowers that are not scented. Lewis Carroll CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding the Syllogism Predicate symbols: C(x) = x “is coloured.” S(x) = x “is scented.” D(x) = “I dislike” x. A(x) = x “is grown in the open air.” CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding the Syllogism Coloured flowers are always scented. ( x) ( C(x) S(x) ) I dislike flowers that are not grown in the open air. ( x) (A(x) D(x) ) No flowers grown in the open air are colourless. (x) ( A(x) C(x) ) Therefore, I dislike all flowers that are not scented. (x) (S(x) D(x) ) CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Proof by Resolution:(1) Negate the conclusion Coloured flowers are always scented. (x) ( C(x) S(x) ) I dislike flowers that are not grown in the open air. (x) (A(x) D(x) ) No flowers grown in the open air are colourless. (x) ( A(x) C(x) ) It is not the case that I dislike all flowers that are not scented. (x) (S(x) D(x) ) CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Proof by Resolution:(2) Obtain Clause Form Coloured flowers are always scented. (x) ( C(x) S(x) ) (x) (C(x) v S(x) ) Rewrite using and v. C(x) v S(x) Drop leading universal quant. The other clauses are: A(x) v D(x) A(x) v C(x) ( x) (S(x) D(x) ) Move negation inward ( x) (S(x) D(x) ) DeMorgan’s law S(a) D(a) Introduce Skolem constant S(a), D(a) Break into 2 clauses. CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Proof by Resolution:(3) Resolve P1:C(x) v S(x) P2: A(y) v D(y) variables are standardized apart. P3:A(z) v C(z) P4:S(a) P5:D(a) P6: A(a) P2, P5 { a/y } P7: C(a) P3, P6 { a/z } P8: S(a) P1, P7 { a/x } P9: [] P4, P8 { } CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
“Encoding” One of the most difficult parts of creating an AI system: Encoding = Formulating a logical representation of the relevant information that can be used to efficiently make the desired kinds of inferences. CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Steps in Encoding • Have the class of problems to be solved written down (in English) • Have the knowledge to be represented written down (in English) • Specify a domain of values or objects over which will be represented by terms (constants, variables, and functions). • Structure the domain by introducing predicates that separate the domain into the subsets meaningful for the application. • Determine whether there are useful functional relationships among any domain elements, and if so, introduce functions that express these relationships. • Develop WFFs based on the chosen predicates and functions to best capture the desired knowledge. CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Example Represent the following information using the predicate calculus in a form that captures most of the individual facts and which supports the inference presented: “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Specifying the Domain “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” Domain: CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Specifying the Domain “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” Domain: BUILDINGS U BOATS BUILDINGS – restricted to buildings belonging to the University of Central Lake Union. This restriction will reduce the number of subsets needed. BOATS – all normal boats. Restriction to UCLU seems unnecessary. Subsets: ANNEXES, ROWBOATS, DINGHIES CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Subdomain Predicates “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Subdomain Predicates “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” isBuilding(x), isRowboat(x), isAnnex(x), isDinghy(x) CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Properties “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” Properties: CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Properties “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” Properties: inViolation(x): x is in violation of the Lake Quake code. tempClosed(x): x will be temporarily closed. CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Constants “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” Constants: CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Constants “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” Constants: schwimmschachHall. CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Relations “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” Binary Relations: CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Relations “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” Binary Relations: has(x, y). x has y. annexOf(x, y). x is an annex of y. We could choose to use a function theAnnexOf(x) , but this makes assumptions about the number of annexes of each building, and would need a new domain element “None” for some buildings and for boats, which don’t have annexes. CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding by Statement “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding by Statement “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” (x) (isBuilding(x) ((has(x, y) isRowboat(y)) V inViolation(x)) CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding by Statement “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding by Statement “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” (x) (inViolation(x) tempClosed(x)) CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding by Statement “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding by Statement “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” (x) ( annexOf(schwimmschachHall, x) (y) (isDinghy(x) has(x, y)) (z) (isRowboat(z) has(x,z)) ) Here, that the annex exists is a presupposition, and we are choosing to represent it explicitly. CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding by Statement “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I
Encoding by Statement “Each University of Central Lake Union (UCLU) building must either have an emergency rowboat or be in violation of the Lake Quake code. Any building in violation of the Lake Quake code will be temporarily closed. The annex of Schwimmschach Hall has dinghies but no emergency rowboats. Therefore the annex of Schwimmschach Hall will be temporarily closed.” (x) ( annexOf(schwimmschachHall, x) tempClosed(x) ) We are re-representing the presupposition, and using the binding in “tempClosed(x).” CSE 415 -- (c) S. Tanimoto, 2008 Predicate Calculus I