380 likes | 402 Views
This chapter outlines the importance, syntax, and semantics of First-Order Logic (FOL) in Artificial Intelligence. It covers using FOL, knowledge engineering in FOL, and provides examples of models and quantification.
E N D
CS3243: Introduction to Artificial Intelligence Semester 2, 2017/2018
First-Order Logic (FOL) AIMA Chapter 8
Outline • Why FOL? • Syntax and semantics of FOL • Using FOL • Wumpus world in FOL • Knowledge engineering in FOL
First-Order Logic • Propositional logic assumes that the world contains facts • First-order logic (like natural language) assumes that the world contains • Objects: people, houses, numbers, colors, baseball games, wars, … • Relations: unary relations or properties such as red, round, prime, …, or more general -ary relations such as brother of, bigger than, part of, comes between, … • Functions: father of, best friend, one more than, plus, …
Atomic Sentences Functions can be viewed as complex names for constants Term:constant or variable or Atomic sentence: or E.g.,
Complex Sentences Constructed from atomic sentences via connectives E.g.,
Truth in First-Order Logic • Sentences are true in amodel • Model comprises a set of objects (domain elements) and an interpretation • Interpretation specifies referents for • An atomic sentence is true in a given model if the relation referred to by holds among the objectsreferred to by .
Models for FOL: Example 1 Model contains 5 objects, 2 binary relations (black), 3 unary relations (blue), 1 unary function (red) R J
Models for FOL: Example 2 • 2 constant symbols, and , and 1 binary relation symbol • Number of possible models unbounded → Checking entailment by enumeration of all models infeasible • Restricting to ≤ 6 objects produces 137,506,194,466 models
Universal Quantification • e.g., everyone at NUS is smart: • is true in a given model if is true with referring to each possible object in the model • Roughly speaking, it is equivalent to the conjunction of instantiations of
A Common Mistake to Avoid • Typically, is the main connective with • Common mistake: using as the main connective with : What does the above mean?
Existential Quantification e.g., someone at NUS is smart: • is true in a given model if is true with referring to at least one object in the model • Roughly speaking, it is equivalent to the disjunction of instantiations of
Another Common Mistake to Avoid • Typically, is the main connective with • Common mistake: using as the main connective with : What does this mean?
Negation • Negation of is • Negation of is
Equality • is true under a given interpretation iff and refer to the same object • With function: e.g., • With negation: e.g., definition of in terms of :
Interacting with FOL KBs • A Wumpus-world agent is using a FOL and perceives a smell, a breeze, and glitter at : Tell(, Percept([Smell, Breeze, Glitter, None, None], )) Ask(, BestAction()) • Quantified query: does the entail some best action at? Answer: Yes. • AskVars() returns the binding list or substitutions such that • e.g., AskVars(, BestAction()) • Answer: {} ← substitution (binding list)
KB for theWumpusWorld • Perception rule • Process agent’s inputs • “If observed a glitter at time , set ” • Reflex rule • Process agent’s outputs • Above rules yield How would we write the above rule in propositional logic?
KB for the Wumpus World Properties of squares: Squares are breezy near a pit:
Knowledge Engineering in FOL • Identify the task • Assemble the relevant knowledge • Decide on a vocabulary of predicates, functions, and constants • Encode general knowledge about the domain • Encode a description of the specific problem instance • Pose queries to the inference procedure and get answers • Debug the knowledge base
Optimal Traffic Management • We are approached by the Singapore Police • Want to optimally position traffic cameras in major intersections so as to cover all relevant intersections. • A camera in an intersection also covers adjacent ones. • Please help!
Assemble Relevant Knowledge • Number of cameras? • How many major intersections? • What roads are relevant?
Decide on Vocabulary • – set of intersections • – is there a road connecting and • - there is a camera in location . • Maximal number of cameras -
Encode General Domain Knowledge • Edges are bidirectional – • Coverage property – • Total coverage – • Is providing total coverage?
Pose Queries • Is there a solution using cameras? • Will a specific solution work?
Debug Database • …
Packet Dropoff • We are approached by a Waste Disposal Service • Want to optimally collect garbage from various locations. • Don’t want to visit same location twice
Assemble Relevant Knowledge • Pickup locations • Routes
Decide on Vocabulary • – set of locations • – is there a road connecting and • : we move from to . • Start location:
Encode General Domain Knowledge • : there is an edge between and . • Start location is unique: • Can only travel on edges:
Pose Queries • Is there a solution covering all vertices exactly once? • Will a specific solution work?
Debug Database • …
Summary • First-order logic: • objects and relations are semantic primitives • syntax: constants, functions, predicates, equality, quantifiers • Increased expressive power over propositional logic: sufficient to define many non-trivial problems