Knowledge Representation using FirstOrder Logic CMPT 310 CHAPTER

  • Slides: 39
Download presentation
Knowledge Representation using First-Order Logic CMPT 310 CHAPTER 8 OLIVER SCHULTE

Knowledge Representation using First-Order Logic CMPT 310 CHAPTER 8 OLIVER SCHULTE

Outline What is First-Order Logic (FOL)? Syntax and semantics Using FOL Wumpus world in

Outline What is First-Order Logic (FOL)? Syntax and semantics Using FOL Wumpus world in FOL Knowledge engineering in FOL

Limitations of propositional logic Propositional logic has limited expressive power unlike natural language E.

Limitations of propositional logic Propositional logic has limited expressive power unlike natural language E. g. , cannot say "pits cause breezes in adjacent squares“ except by writing one sentence for each square

Wumpus World and propositional logic Find Pits in Wumpus world Bx, y (Px, y+1

Wumpus World and propositional logic Find Pits in Wumpus world Bx, y (Px, y+1 Px, y-1 Px+1, y Px-1, y) (Breeze next to Pit) Find Wumpus Sx, y (Wx, y+1 Wx, y-1 Wx+1, y Wx-1, y) (stench next to Wumpus) 16 rules At least one Wumpus in world W 1, 1 W 1, 2 … W 4, 4 (at least 1 Wumpus) 1 rule At most one Wumpus 16 rules W 1, 1 W 1, 2 (155 RULES)

First-Order Logic

First-Order Logic

Knowledge engineering in FOL Identify the task 2. Assemble the relevant knowledge 3. Decide

Knowledge engineering in FOL Identify the task 2. Assemble the relevant knowledge 3. Decide on a vocabulary (predicates, functions, and constants). 4. Encode general knowledge about the domain. 5. Encode a description of the specific problem instance. 6. Pose queries to the inference procedure and get answers 7. Debug the knowledge base. 8. See text for full example: electric circuit knowledge base. 1.

First-Order Logic Propositional logic assumes that the world contains facts. First-order logic (like natural

First-Order Logic Propositional logic assumes that the world contains facts. First-order logic (like natural language) assumes the world contains Objects: people, houses, numbers, colors, baseball games, wars, … Relations: red, round, prime, brother of, bigger than, part of, comes between, … Functions: father of, best friend, one more than, plus, …

FOL Worlds: Graphical Example

FOL Worlds: Graphical Example

First-Order Logic SYNTAX

First-Order Logic SYNTAX

Syntax of FOL: Basic elements Constant Symbols: Stand for objects e. g. , King.

Syntax of FOL: Basic elements Constant Symbols: Stand for objects e. g. , King. John, 2, UCI, . . . Predicate Symbols Stand for relations E. g. , Brother(Richard, John), greater_than(3, 2). . . Function Symbols Stand for functions E. g. , Sqrt(3), Left. Leg. Of(John), . . .

Syntax of FOL: Basic elements Constants King. John, 2, UCI, . . . Predicates

Syntax of FOL: Basic elements Constants King. John, 2, UCI, . . . Predicates Brother, >, . . . Functions Sqrt, Left. Leg. Of, . . . Variables x, y, a, b, . . . Connectives , , Equality = Quantifiers ,

Relations Some relations are properties: they state some fact about a single object: Round(ball),

Relations Some relations are properties: they state some fact about a single object: Round(ball), Prime(7). n-ary relations state facts about two or more objects: Married(John, Mary), Larger. Than(3, 2). Some relations are functions: their value is another object: Plus(2, 3), Father(Dan).

Models for FOL: Graphical Example

Models for FOL: Graphical Example

Tabular Representation 14 A FOL model is basically equivalent to a relational database instance.

Tabular Representation 14 A FOL model is basically equivalent to a relational database instance. Historically, the relational data model comes from FOL. Student s-id Intelligence Ranking Jack 3 1 Kim 2 1 Paul 1 2 Professor Course c-id Rating Difficulty 101 3 1 Oliver 3 1 102 2 2 Jim 2 1 RA s-id Jack p-id Oliver Salary High Capability 3 Kim Paul Oliver Jim Low Med 1 2 p-id Popularity Teaching-a Registration s-id c. id Grade Satisfaction Jack 101 A 1 Jack 102 Kim 102 Paul 101 B A B 2 1 1

Terms Term = logical expression that refers to an object. There are 2 kinds

Terms Term = logical expression that refers to an object. There are 2 kinds of terms: constant symbols: Table, Computer function symbols: Left. Leg(Pete), Sqrt(3), Plus(2, 3) etc Functions can be nested: Pat_Grandfather(x) = father(x)) Terms can contain variables. No variables = ground term.

Atomic Sentences Atomic sentences state facts using terms and predicate symbols P(x, y) interpreted

Atomic Sentences Atomic sentences state facts using terms and predicate symbols P(x, y) interpreted as “x is P of y” Examples: Larger. Than(2, 3) is false. Brother_of(Mary, Pete) is false. Married(Father(Richard), Mother(John)) could be true or false Brother_of(Pete, Brother(Pete)) is True. Binary relation Term

Complex Sentences We make complex sentences with connectives (just like in propositional logic). binary

Complex Sentences We make complex sentences with connectives (just like in propositional logic). binary relation function objects connectives property

More Examples Brother(Richard, John) Brother(John, Richard) King(John) => King(Richard) Less. Than(Plus(1, 2) , 4)

More Examples Brother(Richard, John) Brother(John, Richard) King(John) => King(Richard) Less. Than(Plus(1, 2) , 4) Greater. Than(1, 2)

Variables Person(John) is true or false because we give it a single argument ‘John’

Variables Person(John) is true or false because we give it a single argument ‘John’ We can be much more flexible if we allow variables which can take on values in a domain. e. g. , all persons x, all integers i, etc. E. g. , can state rules like Person(x) => Has. Head(x) or Integer(i) => Integer(plus(i, 1)

Universal Quantification means “for all” Allows us to make statements about all objects that

Universal Quantification means “for all” Allows us to make statements about all objects that have certain properties Can now state general rules: ∀x King(x) => Person(x) ∀x Person(x) => Has. Head(x).

Exercise Using the predicate Reserve(x, b) to mean “person x has reserved boat b”),

Exercise Using the predicate Reserve(x, b) to mean “person x has reserved boat b”), formalize in FOL the sentence “Jack has reserved all red boats. ” Formalize in FOL the following English sentences: 1. “all kings are persons”. 2. “Every student who takes French passes it. ”

Existential Quantification x means “there exists an x such that…. ” (at least one

Existential Quantification x means “there exists an x such that…. ” (at least one object x) Allows us to make statements about some object without naming it Examples: x King(x) x Lives_in(John, Castle(x)) i Integer(i) Greater. Than(i, 0)

Exercise Formalize in FOL the following English sentence: “More than one student took French

Exercise Formalize in FOL the following English sentence: “More than one student took French in Spring 2011. ”

More examples For all real x, x>2 implies x>3. There exists some real x

More examples For all real x, x>2 implies x>3. There exists some real x whose square is minus 1. UBC AI space demo for rules

Combining Quantifiers x y Loves(x, y) For everyone (“all x”) there is someone (“y”)

Combining Quantifiers x y Loves(x, y) For everyone (“all x”) there is someone (“y”) that they love. y x Loves(x, y) There is someone (“y”) that is loved by everyone. Clearer with parentheses: y ( x Loves(x, y) )

Exercise Using the predicate Reserve(x, b) to mean “person x has reserved boat b”),

Exercise Using the predicate Reserve(x, b) to mean “person x has reserved boat b”), formalize the sentence “Every boat has been reserved by someone”.

Using FOL We want to TELL things to the KB, e. g. TELL(KB, King(John)

Using FOL We want to TELL things to the KB, e. g. TELL(KB, King(John) ) ) We also want to ASK things to the KB, ASK(KB, ) These are queries or goals

Deducing hidden properties Environment definition: x, y, a, b Adjacent([x, y], [a, b]) [a,

Deducing hidden properties Environment definition: x, y, a, b Adjacent([x, y], [a, b]) [a, b] {[x+1, y], [x-, y], [x, y+1], [x, y-1]} Properties of locations: s, t At(Agent, s, t) Breeze(t) Breezy(s) Location s and time t Squares are breezy near a pit: Diagnostic rule---infer cause from effect s Breezy(s) r Adjacent(r, s) Pit(r) Causal rule---infer effect from cause. r Pit(r) [ s Adjacent(r, s) Breezy(s)]

Resolution in First-Order Logic

Resolution in First-Order Logic

Basic Idea for Resolution in FOL Grounding: 1. Treat first-order sentences as a template.

Basic Idea for Resolution in FOL Grounding: 1. Treat first-order sentences as a template. 2. Instantiate variables with constants to get propositional clauses. 3. Apply propositional resolution. grounding FOL Knowledge Base Propositional Clauses

Knowledge Base in FOL The law says that it is a crime for an

Knowledge Base in FOL The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American. . . . it is a crime for an American to sell weapons to hostile nations: American(x) Weapon(y) Sells(x, y, z) Hostile(z) Criminal(x) Nono … has some missiles, i. e. , x Owns(Nono, x) Missile(x): Owns(Nono, M 1) and Missile(M 1) … all of its missiles were sold to it by Colonel West Missile(x) Owns(Nono, x) Sells(West, x, Nono) Missiles are weapons: Missile(x) Weapon(x) An enemy of America counts as "hostile“: Enemy(x, America) Hostile(x) West is American … American(West) The country Nono is an enemy of America … Enemy(Nono, America) Query: Criminal(West)?

Resolution proof �

Resolution proof �

Logics in General Ontological Commitment: What exists in the world — TRUTH PL :

Logics in General Ontological Commitment: What exists in the world — TRUTH PL : facts hold or do not hold. FOL : objects with relations between them that hold or do not hold Epistemological Commitment: What an agent believes about facts — BELIEF

Expressiveness vs. Tractability There is a Reasoning power fundamental tradeoff between expressiveness and tractability

Expressiveness vs. Tractability There is a Reasoning power fundamental tradeoff between expressiveness and tractability in Artificial Intelligence. • Similar, even more difficult issues with probabilistic reasoning (later). 1. Horn clause 2. Prolog 3. Description Logic FOL ? ? expressiveness

Summary First-order logic: Much more expressive than propositional logic Allows objects and relations as

Summary First-order logic: Much more expressive than propositional logic Allows objects and relations as semantic primitives Universal and existential quantifiers syntax: constants, functions, predicates, equality, quantifiers Knowledge engineering using FOL Capturing domain knowledge in logical form Inference and reasoning in FOL is more expressive but harder to reason with: Undecidable, Turing- complete.