announcements: assignments announcements: …torsten/csc384-f11/lectures/csc384f...1 torsten...
TRANSCRIPT
1
1Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Announcements: Assignments
1. A1: will not be marked before the midterm; maybe back next Monday (no promises!)
– Direct remarking requests first to Alexandra; only if it cannot be corrected/clarified, talk to me.
– Submit remarking requests in writing (email is sufficient) !
2. A2: Will be out by tomorrow
– You are advised to look at the CSP questions (5-8) before the midterm and at question 1 (Interpretations) before, it will be good preparation for the midterm
– Not much programming; should take significantly less time that A1
3. A2 Help Sessions:
• Wednesday, Nov 2nd : 2:30 – 3:30PM
• Tuesday, Nov 8th 5:30 – 6:30 PM
2Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Announcements: Midterm & Final
• Midterm next week in class: October 24th, 6pm• BE ON TIME! Start writing at 6:10pm, 80 min long
• Afterwards: 1h lecture or a tutorial on common problems with A1
• If you have a conflict, let me know by Wed.
• If you miss the midterm for medical reasons, you need the officalUofT medical certificate
• Midterm: No aids allowed!
• Some sample midterms on the website
• Two office hours this week: • Tuesday, Oct. 18th 5:15 – 6:45 PM (BA4261 – standard room)
• Wednesday, Oct. 19th 2:30 – 3:30PM (BA3289)
3Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Midterm Topics
Essentially everything up to now.• Introduction (What is AI, Agents)• Focus: Search (Uninformed, Heuristic, Game-tree,
Backtracking/CSP)• Need to know how the algorithms work, their
properties, their advantages & disadvantages, problem formulation, etc.
• Some first-order logic: interpretations and models(as covered today and question 1 of Assignment 2)
• Do not need to:• Reproduce complex proofs (but unterstand the ideas)• Write (pseudo)code for algorithms or Prolog code
4Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Other announcements
• Date for the final exam has been announced (see Exam Calendar)
• I believe Dec. 13th (check yourself!)
• Midterm feedback: Let us improve the
learning experience together.
• please fill out during break
• need a volunteer to collect them
2
5Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Some unfinished business: CSP
• Conversion of n-ary constraints into binary constraints. – Remember: finite CSPs have finite number of variables
and finite number of domain values for variable (no real values for example)
• Library of problems: csplib.org
• Some constraint solvers:– Choco (Java)
– Minion (C++)
• CSP research here at UofT:– Fahiem Bacchus (also extensions to QBF)
– Chris Beck (MIE): scheduling & optimization
6Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Where are we?
1. Heuristic Search: “Formulate problem as search problem”
� Requires domain-dependent heuristic to efficiently guide the search
2. Games: “Restricted to specific applications of interest to AI”
� Special kind of search over utilities
3. Constraint Satisfaction Problems: “Wider class of AI problems”
� More general: good for a large class of problems; do need to encode algorithms and heuristics for each new problem
4. Logic-based Knowledge representation
� Even more general, we can encode knowledge and reuse general purpose inference engines:
5. Planning (specific kind of logic-based knowledge representation)
6. Reasoning under uncertainty
7. If time permits: Decision making under uncertainty.
7Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Knowledge Representation (KR)
• This material is covered in chapters 7– 9 and 12 of the textbook.
• Chapter 7 provides useful motivation for logic, and an introduction to some basic ideas. It also introduces propositional logic, which is a good background for first-order logic.
• Instead we focus immediately on the first-order case as covered in Chapter 8.
• Chapter 8 contains more examples that we won’t be able to cover in class
• We focus on resolution (9.2 and 9.5) as first-order inference mechanism, other mechanisms covered in Chapter 9 are forward and backward chaining.
• Chapter 12 covers some of the additional notions that have to be dealt with when using knowledge representation in AI. These are geared towards modern uses of logic for logic representation.
8Torsten Hahmann, CSC384, University of Toronto, Fall 2011
What is KNOWLEDGE?Easier question: how do we talk about it?
• We say “John knows that …” and fill in the blank
(can be true/false, right/wrong)
• Contrast: “John fears that …”
(same content, different attitude)
Other forms of knowledge:
- know how, who, what, when, …
- sensorimotor: typing, riding a bicycle
- affective: deep understanding
Belief: not necessarily true and/or held for appropriate reasons
Here we make no distinction between knowledge and belief
MAIN IDEA
Taking the world to be one way and not another
3
9Torsten Hahmann, CSC384, University of Toronto, Fall 2011
What is REPRESENTATION?Symbols standing for things in the world
� first aid
� women
“John” � John
“John loves Mary” � the proposition that John loves Mary
Knowledge Representation:
Symbolic encoding of propositions believed
(by some agent)
10Torsten Hahmann, CSC384, University of Toronto, Fall 2011
What is REASONING?
Reasoning:
Manipulation of symbols encoding propositions to
produce new representations of new propositions
Analogy: arithmetic “1011” + “10” → “1101”
↓ ↓ ↓
eleven two thirteen
Modus ponens (forward chaining):
All men are mortals, socrates is a man. Thus, socrates is mortal
All foobars are bliffs, bebong is a foobar. Thus, bebong is a bliff
11Torsten Hahmann, CSC384, University of Toronto, Fall 2011
WHY Knowledge?Taking an intentional stance (Daniel Dennet):
For sufficiently complex systems, it is sometimes compelling to describe
systems in terms of beliefs, goals, fears, intentions
E.g., in a game-playing program
“because it believed its queen was in danger, but wanted to still
control the centre of the board”
More useful than description about actual techniques used for
deciding how to move
“because evaluation procedure P using minimax returned a value
of +7 for this position.”
Is KR just a convenient way of talking about complex systems?
- sometimes such anthropomorphizing is inappropriate (e.g., thermostat)
- can also be very misleading!
fooling users into thinking a system knows more than it does
12Torsten Hahmann, CSC384, University of Toronto, Fall 2011
• We can reuse general knowledge in many different
applications or domains
– Knowledge of time, of general process, of spatial features, of
physics, etc. are useful for many different applications
– E.g. “a door can usually be opened and used to move into a building
or room”
• This is the idea of ontologies = reusable and shareable
formalisations of knowledge
WHY Knowledge?
4
13Torsten Hahmann, CSC384, University of Toronto, Fall 2011
WHY Representation?Taking Dennet’s intentional stance says nothing about what is or is not represented symbolically
e.g., in game playing, perhaps the board position is represented but the goal of getting a knight out early is not
KR Hypothesis (Brian Smith)“Any mechanically embodied intelligent process will be comprised of structural
ingredients that a) we as external observers naturally take to represent a propositional account of the knowledge that the overall process exhibits, and b) independent of such external semantic attribution, play a formal but causal and essential role in engendering the behaviour that manifests that knowledge”
Two issues: existence of structures that
• we can interpret propositionally
• determine how the system behaves
KNOWLEDGE-BASED SYSTEM: one designed this way!
14Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Two ExamplesBoth of the following systems can be described intentionally.
However, only the 2nd has a separate collection of symbolic structures (following the KR Hypothesis)
Example 2 has a knowledge base and thus the system is a knowledge-based system.
Example 1:
printColour(snow) :- !, write(``It’s white.’’).
printColour(grass) :- !, write(``It’s green. ’’).
printColour(sky) :- !, write(``It’s yellow. ’’).
printColour(X) :- !, write(``Beats me. ’’).
Example 2:
printColour(X) :- colour(S,Y),!,
``````````````````write(``It’s’’), write(Y), write (``. ’’)
printColour(X) :- !, write(``Beats me. ’’).
colour(snow,white).
colour(sky,yellow).
colour(X,Y) :- madeof(X,Z), colour(Z,Y).
madeof(grass,vegetation).
colour(vegetation,green).
15Torsten Hahmann, CSC384, University of Toronto, Fall 2011
KR and AIMuch of AI involves building systems that are knowledge based
Ability derives in part from reasoning over explicitly represented knowledge
• language understanding,
• planning,
• diagnosis, etc.
Some to a certain extent
game-playing, vision, etc.
Some to a lesser extent
speech, motor control, etc.
Current research question:
how much of intelligent behaviour is knowledge-based?
16Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Why bother?Why not “compile out” knowledge into specialized procedures?
• distribute KB to procedures that need it (as in Example 1)
• almost always achieves better performance
No need to think. Just do it!
• riding a bike
• driving a car
• playing chess?
• doing math?
• staying alive?
Skills (Hubert Dreyfus)
• novices think, experts react
• Compare to “expert systems” which are knowledge based.
5
17Torsten Hahmann, CSC384, University of Toronto, Fall 2011
AdvantageKnowledge-based system most suitable for open-ended tasks
can structurally isolate reasons for particular behaviour
Good for
• explanation and justification
• “Because grass is a form of vegetation”
• informality: debugging the KB
• “No the sky is not yellow. It’s blue.”
• extensibility: new relations (add new info)
• “Canaries are yellow”
• extensibility: new applications (use your KB for different tasks)
• Return a list of all the white things
• Painting pictures
18Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Cognitive Penetrability
Cognitive penetrability (Zenon Pylyshyn)
Actions that are conditioned by what is currently believed
An example:
we normally leave the room if we hear a fire alarm
we do not leave the room on hearing a fire alarm if we believe that the alarm is being tested/tampered
- can come to this belief in very many ways
so this action is cognitively penetrable
A non-example:
blinking reflex
Hallmark of knowledge-based system:
The ability to be told facts about the world and adjust our behaviour
correspondingly E.g.,
read a book about canaries learn they’re yellow and add it to the KB
19Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Why reasoning?
Want knowledge to affect action
not do action A if sentence P is in KB
but do action A if world believed in satisfies P
Difference:
P may not be explicitly represented
Need to apply what is known in general to the particulars of the
situation
Example:
“patient x is allergic to medication m.”
“Anybody allergic to medication m is also allergic to n.”
Is it OK to prescribe n for x?
Usually need more than just DB-style retrieval of facts in the KB!
20Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Using Logic
No universal language/semantics
• Why not English?
• Different tasks/worlds
• Different ways to carve up the world
No universal reasoning scheme
• Geared to language
• Sometimes want “extralogical” reasoning
Start with first-order predicate calculus (FOL)
• Invented by philosopher Frege for the formalization of mathematics
6
21Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Why Knowledge Representation?
An Example &
An Argument for Logic
22Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Why Knowledge Representation? An Example
• Consider the task of understanding a simple story.
• How do we test understanding?
• Not easy, but understanding at least entails some ability to answer simple questions about the story.
23Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Example.
• Three little pigs: Mother sends them to “seek their fortune”
�1st pig builds a house of straw
�2nd pig builds a house of sticks
�3rd pig builds a house of bricks
24Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Example.
• Three little pigs
�Wolf blows down the straw house, and eats the pig!
�Wolf blows down the sticks house, and eats the pig!
�Wolf cannot huff and poof the brick house!
7
25Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Example
• Why couldn’t the wolf blow down the house made of bricks?
• What background knowledge are we applying to come to that conclusion?• Brick structures are stronger than straw and stick structures.
• Objects, like the wolf, have physical limitations. The wolf can only blow so hard.
26Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Why Knowledge Representation?
• Large amounts of knowledge are used to understand the
world around us, and to communicate with others.
• We also have to be able to reason with that knowledge
• Our knowledge won’t be about the blowing ability of wolfs in particular,
it is about physical limits of objects in general.
• We have to employ reasoning to make conclusions about the wolf.
• More generally, reasoning provides an exponential or more
compression in the knowledge we need to store. I.e., without
reasoning we would have to store a infeasible amount of information:
e.g., Elephants can’t fit into teacups.
27Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Logical Representations
• AI typically employs logical representations of knowledge.
• Logical representations useful for a number of
reasons:
28Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Logical Representations
• They are mathematically precise, thus we can analyze their limitations, their properties, the complexity of inference etc.
• They are formal languages, thus computer programs can manipulate sentences in the language.
• They come with both a formal syntax and a formal semantics.
• Typically, have well developed proof theories: formal procedures for reasoning (achieved by manipulating sentences).
8
29Torsten Hahmann, CSC384, University of Toronto, Fall 2011
The Knowledge Base
• The Knowledge Base is a set of sentences.
• Syntactically well-formed
• Semantically meaningful
• A user can perform two actions to the KB:
� Tell the KB a new fact
� Ask the KB a question
30Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Syntax of Sentences
English acceptable an one is sentence This.
vs.
This English sentence is an acceptable one.
- P ¬ . Q R
vs.
P - ¬Q . R
31Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics of Sentences
This hungry classroom is a jobless moon.
• Why is this syntactically correct sentence not meaningful?
P - (¬Q . R)
• Represents a world where either P is true, or Q is not true and R is true.
32Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Entailments
α ⊨⊨⊨⊨ β
• read as “α entails β”, or “β follows logically from α”
• meaning that in any world in which α is true, β is
true as well.
For example
(P . Q) ⊨ (P V R)
9
33Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Syntactical Derivation
α ⊢ β• read as “α derives β”
• meaning “from sentence α, following the syntactical derivation rules, we can obtain sentence β”
For example
¬(A - B) ⊢ (¬A . ¬B)
Usually with respect to a proof procedure.
34Torsten Hahmann, CSC384, University of Toronto, Fall 2011
The Reasoning Process
35Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Desired Properties of Reasoning
Soundness
• KB ⊢ f → KB ⊨ f• i.e all conclusions arrived at via the proof procedure
are correct: they are logical consequences.
Completeness
•KB ⊨ f → KB ⊢ f• i.e. every logical consequence can be generated by
the proof procedure.
36Torsten Hahmann, CSC384, University of Toronto, Fall 2011
KR with Propositional Logic
• We assume that you have learned Propositional Logic from a previous course, e.g. CSC165 or
CSC236.
• Read Chapter 7 in the textbook for a review!
10
37Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Pros and cons of propositional logic
☺ Propositional logic is declarative
☺ Propositional logic allows partial/disjunctive/negated information
• (unlike most data structures and databases)
☺ Propositional logic is compositional:
• meaning of B1,1 ∧ P1,2 is derived from meaning of B1,1 and of P1,2
☺ Meaning in propositional logic is context-independent
• (unlike natural language, where meaning depends on context)
� Propositional logic has very limited expressive power
• (unlike natural language)
• E.g., cannot say "pits cause breezes in adjacent squares“
• except by writing one sentence for each square
38Torsten Hahmann, CSC384, University of Toronto, Fall 2011
First-Order Logic (FOL)
• Whereas propositional logic assumes 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, …
39Torsten Hahmann, CSC384, University of Toronto, Fall 2011
First-Order Logic
Syntax: A grammar specifying what are legal syntactic constructs of the representation.
Semantics: A formal mapping from syntactic constructs to set theoretic assertions.
40Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Syntax of FOL: Basic elements
• Constants sheila, 2, blockA,...
• Predicates colour, on, brotherOf, >,...
• Functions sqrt, leftLegOf,...
• Variables x, y, a, b,...
• Connectives ¬, ⇒, ∧, ∨, ⇔
• Equality =
• Quantifiers ∀, ∃
11
41Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Syntax of Propositional Logic
• Constants sheila, 2, blockA,...
• Predicates colour, on, brotherOf, >,...
• Functions sqrt, leftLegOf,...
• Variables x, y, a, b,...
• Connectives ¬, ⇒, ∧, ∨, ⇔
• Equality =
• Quantifiers ∀, ∃
Propositions a-ison-b, b-ison-c, …
42Torsten Hahmann, CSC384, University of Toronto, Fall 2011
First Order Syntax
Start with a set of primitive symbols.
• constant symbols.
• function symbols.
• predicate symbols (for predicates and relations).
• variables.
Each function and predicate symbol has a specific arity(determines the number of arguments it takes).
43Torsten Hahmann, CSC384, University of Toronto, Fall 2011
First Order Syntax—Building up.
A term is either:• a variable
• a constant
• an expression of the form f(t1, … tk) where
(a) f is a function symbol;
(b) k is its arity;
(c) each ti is a term
44Torsten Hahmann, CSC384, University of Toronto, Fall 2011
First Order Syntax—Building up.
An atom is
An expression of the form p(t1, … tk) where
• p is a predicate symbol;
• k is its arity;
• each ti is a term
Note:
• constants are functions taking zero arguments.
• In slides, UPPER CASE denotes variables, lower case denote function/constant/predicate symbols.
• In Assignment 2: vice versa!
12
45Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantic Intuition (formalized later)
Terms denote individuals: • constants denote specific individuals;
• functions map tuples of individuals to other individuals
• bill, jane, father(jane), father(father(jane))
• X, father(X), hotel7, rating(hotel7), cost(hotel7)
Atoms denote facts that can be true or false
about the world• father_of(jane, bill), female(jane), system_down()
• satisfied(client15), satisfied(C)
• desires(client15,rome,week29), desires(X,Y,Z)
• rating(hotel7, 4), cost(hotel7, 125)
46Torsten Hahmann, CSC384, University of Toronto, Fall 2011
First Order Syntax—Building up.
Atoms are formulas. (Atomic formulas).
• The negation (NOT) of a formula is a new formula
¬ f
Asserts that f is false.
• The conjunction (AND) of a set of formulas is a formula.
f1 Λ f2 Λ … Λ fn where each fi is formula
Asserts that each formula fi is true.
47Torsten Hahmann, CSC384, University of Toronto, Fall 2011
First Order Syntax—Building up.
• The disjunction (OR) of a set of formulas is a formula.
f1 V f2 V … V fn where each fi is formula
Asserts that at least one formula fi is true.
• Existential Quantification ∃. ∃X. f where X is a variable and f is a formula.
Asserts there is some individual such that f under than binding will be true.
• Universal Quantification ∀. ∀X.f where X is a variable and f is a formula.
Assets that f is true for every individual.
48Torsten Hahmann, CSC384, University of Toronto, Fall 2011
First Order Syntax—abbreviations.
• Implication (→):
f1→ f2 is equivalent to ¬f1 V f2.
• Other symbols used for implication:
• f1⇒ f2
• f1⊃ f2
• If and only if (↔):
f1 ↔ f2 is equivalent to (f1 → f2) . (f2 → f1).
• Other symbols used for implication:
• f1⇔ f2
• f1≡ f2
13
49Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics.
• Formulas (syntax) can be built up recursively, and can become arbitrarily complex.
• Intuitively, there are various distinct formulas (viewed as strings) that really are asserting the same thing∀X,Y. elephant(X) Λ teacup(Y) → largerThan(X,Y)
∀X,Y. teacup(Y) Λ elephant(X) → largerThan(X,Y)
• To capture this equivalence and to make sense of complex formulas we utilize the semantics.
50Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics.
• A formal mapping from formulas to semantic entities (individuals, sets and relations over individuals, functions over individuals).
• The mapping mirrors the recursive structure of the syntax, so we can give any formula, no
matter how complex a mapping to semantic entities.
51Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics—Formal Details
First, we must fix the particular first-order language we are
going to provide semantics for. The primitive symbols included in the syntax defines the particular language.L(F,P,V)
• F = set of function (and constant symbols)
• Each symbol f in F has a particular arity.
• P = set of predicate symbols.
• Each symbol p in P has a particular arity.
• V = an infinite set of variables.
52Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics—Formal Details
An interpretation (model) is a tuple
⟨D, Φ, Ψ,v⟩
•D is a non-empty set (domain of individuals)
• Φ (Phi) is a mapping: Φ(f) : Dk→ D
• maps k-ary function symbol f, to a function from k-ary tuples of
individuals to individuals.
• Ψ (Psi) is a mapping: Ψ(p) : Dk → True/False
• maps k-ary predicate symbol p, to an indicator function over k-ary
tuples of individuals (a subset of Dk)
•v is a variable assignment function. v(X) = d ∈ D (it maps every variable to some individual)
14
53Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Intuitions: Domain of Discourse
•Domain D: d∈D is an individual
E.g., { craig, jane, grandhotel, le-fleabag,
rome, portofino, 100, 110, 120 …}
•Underlined symbols denote domain individuals (as opposed
to symbols of the first-order language)
•Domains often infinite, but we’ll use finite models to prime our
intuitions
54Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Intuitions: Φ (individual denoted by fn.)
Φ(f): Dk→ D
Given k-ary function f, k individuals,
what individual does f(d1, …, dk) denote
• 0-ary functions (constants) are mapped to specific
individuals in D.
• Φ(client17) = craig, Φ(hotel5) = le-fleabag,Φ (rome) = rome
• Note that we can have:(rome) = rome and (italian_capital) = rome
55Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Intuitions: Φ (individual denoted by fn.)
Φ(f): Dk→ D
• 1-ary functions are mapped to functions in D → D
• Φ(minquality)=f_minquality:
f_minquality(craig) = 3stars
• Φ(rating)=f_rating:
f_rating(grandhotel) = 5stars
• 2-ary functions are mapped to functions from D2 → D
• Φ(distance)=f_distance:
f_distance(toronto, sienna) = 3256
• n-ary functions are mapped similarly.
56Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Intuitions: Ψ (truth or falsity of formula)
Ψ(p): Dk → True/False
Given k-ary predicate, k individuals,
does the relation denoted by p hold of these?
Ψ(p)(<d1, … dk>) = true?
•0-ary predicates are mapped to true or false.Ψ(rainy) = True Ψ(sunny) = False
•1-ary predicates are mapped indicator functions (True/False) of subsets of D. • Ψ(satisfied) = p_satisfied:
p_satisfied(craig) = True • Ψ(privatebeach) = p_privatebeach:
p_privatebeach(le-fleabag) = False
15
57Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Intuitions: Ψ (truth or falsity of formula)
Ψ(p): Dk → True/False
• 2-ary predicates are mapped to indicator functions over D2
• Ψ(location) = p_location: p_location(grandhotel, rome) = Truep_location(grandhotel, sienna) = Falsep_location(grandhotel, portofino) = False
• Ψ(in_country) = p_in_country: p_in_country (rome, italy) = Truep_in_country (sienna, italy) = Truep_in_country (portofino, italy) = Truep_in_country (rome, craig) = False…
• Ψ(available) = p_available: p_available(grandhotel, week29) = True
• n-ary predicates..
58Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Intuitions: v
v exists to take care of quantification.
As we will see the exact mapping it specifies will not matter.
Notation: v[X/d] is a new variable assignment function.
• Exactly like v, except that it maps the variable X to the
individual d.
• Maps every other variable exactly like v:
v’(Y) = v[X/d](Y)
59Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics—Building up
Given language L(F,P,V), and an interpretation I = ⟨D, Φ, Ψ,v⟩
a) Constant c (0-ary function) denotes an individual
I(c) = Φ(c) ∈ D
b) Variable X denotes an individual
I(X) = v(X) ∈ D (variable assignment function).
c) term t = f(t1,…, tk) denotes an individual
I(t) = Φ(f)(I(t1),… I(tk)) ∈ D
We recursively find the denotation of each term, then we apply the function denoted by f to get a new individual.
Hence terms always denote individuals under an interpretation I
60Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics—Building up
Formulas
a) atom a = p(t1,… tk) has truth value
I(a) = Ψ(p)(I(t1), …, I(tk)) ∈ { True, False }
We recursively find the individuals denoted by
the ti, then we check to see if this tuple of
individuals is in the relation denoted by p.
16
61Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics—Building up
Formulas
a) Negated formulas ¬f has truth value
I(¬f) = True if I(f) = FalseI(¬f) = False if I(f) = True
b) And formulas f1 Λ f2 Λ … Λ fn have truth value
I(f1 Λ f2 Λ … Λ fn) = True if every I(fi) = True.I(f1 Λ f2 Λ … Λ fn) = False otherwise.
c) Or formulas f1 v f2 v … v fn have truth value
I(f1 v f2 v … v fn) = True if any I(fi) = True.I(f1 v f2 v … v fn) = False otherwise.
62Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics—Building up
Formulas
a) Existential formulas ∃X. f have truth value
I(∃X. f) = True
if there exists a d ∈ D such that I’(f) = True
where I’ = ⟨D, Φ, Ψ,v[X/d]⟩
I(∃X. f) = False otherwise.
I’ is just like I except that its variable assignment function now maps X to d. “d” is the individual of which “f” is true.
63Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Semantics—Building up
Formulas
a) Universal formulas ∀X.f have truth value
I(∀X.f ) = True if for all d ∈ D I’(f) = True
where I’ = ⟨D, Φ, Ψ,v[X/d]⟩
I(∀X.f ) = False otherwise.
Now “f” must be true of every individual “d”.
Hence formulas are always either True or False under an interpretation I
64Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Example
D = {bob, jack, fred}I(∀X.happy(X))
1. Ψ(happy)(v[X/bob](X)) = Ψ(happy)(bob) = True
2. Ψ(happy)(v[X/jack](X)) = Ψ(happy)(jack) = True
3. Ψ(happy)(v[X/fred](X)) = Ψ(happy)(fred) = True
Therefore I(∀X.happy(X)) = True.
17
65Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Models – Examples.
A
B
C E
Environment� Constants: a,b,c,e
� Functions:
�No function
� Predicates:
�on: binary
�above: binary
�clear: unary
�ontable: unary
Language (Syntax)
66Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Models—Examples.
A possible Model I1 (semantics)
�D = {A, B, C, E}
�Φ(a) = A, Φ(b) = B, Φ(c) = C, Φ(e) = E.
�Ψ(on) = {(A,B),(B,C)}
�Ψ(above)=
{(A,B),(B,C),(A,C)}
�Ψ(clear)={A,E}
�Ψ(ontable)={C,E}
� Constants: a,b,c,e
� Predicates:
�on (binary)
�above (binary)
�clear (unary)
� ontable(unary)
Language (syntax)
Think of it as possible way the world could be
67Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Models—Examples.
Model I1
�D = {A, B, C, E}
�Φ(a) = A, Φ(b) = B, Φ(c) = C, Φ(e) = E.
�Ψ(on) = {(A,B),(B,C)}
�Ψ(above) = {(A,B),(B,C),(A,C)}
�Ψ(clear)={A,E}
�Ψ(ontable)={C,E}
A
B
C E
Environment
68Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Aside on Notation.
Model I1
�D = {A, B, C, E}
�Φ(a) = A, Φ(b) = B, Φ(c) = C, Φ(e) = E.
�Ψ(on) = {(A,B),(B,C)}
�Ψ(above) = {(A,B),(B,C),(A,C)}
�Ψ(clear)={A,E}
�Ψ(ontable)={C,E}
Comment on notation:
To this point we have represented an interpretation as a tuple,
⟨D, Φ, Ψ,v⟩. It is also common
practice to abbreviate this and
refer to an interpretation function
as σ and to denote the application of the interpretation function by a superscripting of σ.
E.g.,
aσ = A, bσ =B, etc.
onσ = {(A,B),(B,C)},
aboveσ = {(A,B),(B,C),(A,C)}clearσ = {A,E}
18
69Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Models—Formulas true or false?
Model I1
�D = {A, B, C, E}
�Φ(a) = A, Φ(b) = B, Φ(c) = C, Φ(e) = E.
�Ψ(on) = {(A,B),(B,C)}
�Ψ(above) = {(A,B),(B,C),(A,C)}
�Ψ(clear)={A,E}
�Ψ(ontable)={C,E}
∀X,Y. on(X,Y)→above(X,Y)
�X=A, Y=B
�X=C, Y=A � …
∀X,Y. above(X,Y)→on(X,Y)
�X=A, Y=B
× X=A, Y=C
70Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Models—Examples.
Model I1
�D = {A, B, C, E}
�Φ(a) = A, Φ(b) = B, Φ(c) = C, Φ(e) = E.
�Ψ(on) = {(A,B),(B,C)}
�Ψ(above) = {(A,B),(B,C),(A,C)}
�Ψ(clear)={A,E}
�Ψ(ontable)={C,E}
∀X∃Y. (clear(X) ∨ on(Y,X))� X=A� X=C, Y=B� …
∃Y∀X.(clear(X) ∨ on(Y,X)) × Y=A ? No! (X=C)× Y=C? No! (X=B)
× Y=E? No! (X=B)
× Y=B ? No! (X=B)
71Torsten Hahmann, CSC384, University of Toronto, Fall 2011
KB—many models
KB
1.on(b,c)
2.clear(e)
A
B
C E
B
C E
B
C E
A
72Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Models
• Let our knowledge base KB, consist of a set of formulas.
• We say that I is a model of KB or that I satisfies KB
if every formula f ∈ KB is true under I
• We write I ⊨ KB if I satisfies KB, and I⊨f if f is
true under I.
19
73Torsten Hahmann, CSC384, University of Toronto, Fall 2011
What’s Special About Models?
• When we write KB, we have an intended interpretation for it – a way that we think the real
world will be.
• This means that every statement in KB is true in the real world.
• Note however, that not every thing true in the real world need be contained in KB. We might
have only incomplete knowledge.
74Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Models support reasoning.
• Suppose formula f is not mentioned in KB, but is true in every model of KB; i.e.,
For all I, I ⊨ KB → I ⊨ f
then we say that f is a logical consequence of KB or that KB entails f and we write KB ⊨ f.
• Since the real world is a model of KB, f must be true in the real world.
• This means that entailment is a way of finding new true facts that were not explicitly mentioned in KB.
? If KB doesn’t entail f, is f false in the real world?
75Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Logical Consequence Example
• elephant(clyde)
• the individual denoted by the symbol clyde in the set denoted
by elephant (has the property that it is an elephant).
• teacup(cup)
• cup is a teacup.
• Note that in both cases a unary predicate specifies a set
of individuals. Asserting a unary predicate to be true of a term means that the individual denoted by that term is in the specified set.
• Formally, we map individuals to TRUE/FALSE (this is an
indicator function for the set).
76Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Logical Consequence Example
∀X,Y.elephant(X) Λ teacup(Y) →largerThan(X,Y)
• For all pairs of individuals if the first is an elephant and the second is a teacup, then the pair of objects are
related to each other by the largerThan relation.
• For pairs of individuals that are not elephants and
teacups, the formula is immediately true.
20
77Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Logical Consequence Example
∀X,Y.largerThan(X,Y) → ¬fitsIn(X,Y)
• For all pairs of individuals if X is larger than Y (the pair is in the largerThan relation) then we cannot have that
X fits in Y (the pair cannot be in the fitsIn relation).
• (The relation largerThan has a empty intersection with
the fitsIn relation).
78Torsten Hahmann, CSC384, University of Toronto, Fall 2011
• ¬fitsIn(clyde,cup)
• We know largerThan(clyde,teacup) from the first implication. Thus we know this from the second implication.
Logical Consequence Example
79Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Elephants × teacups
largerThan
(clyde , cup)
¬fitsIn
fitsIn
Logical Consequence Example
80Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Logical Consequence Example
• If an interpretation satisfies KB, then the set of pairs
elephant X teacup must be a subset of largerThan, which is disjoint from fitsIn.
• Therefore, the pair (clyde,cup) must be in the complement of the set fitsIn.
• Hence, ¬fitsIn(clyde,cup) must be true in every interpretation that satisfies KB.
• ¬fitsIn(clyde,cup) is a logical consequence of KB.
21
81Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Logical Consequences
∃X.elephant(X) → ¬extinct(s_elephant)
• “If there exists something that is an elephant, then the elephant_species is not extinct.”
• When is this sentence true?
(1) ¬extinct(s_elephant):
Φ(s_elephant) = elephant_species, and
Ψ(extinct) = p_extinct: p_extinct(elephant_species) = False
(2) No elephant exists and
Φ(s_elephants) = f_elephant, and
Ψ(extinct) = p_extinct: p_extinct(f_elephant) = True
Not just true when there exists an elephant!
82Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Propositional KB: a, c → b, b → c, d → b, ¬b → ¬c
a b c d
a b c ¬d
a ¬b ¬c ¬d
Set of All Interpretations
Models of KB
Models: A Propositional Example
83Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Models and Interpretations
• the more sentences in KB, the fewer models (satisfying interpretations) there are.
•The more you write down (as long as it’s all true!), the “closer” you get to the “real world”! Because each sentence in KB rules out certain unintended
interpretations.
•This is called axiomatizing the domain
84Torsten Hahmann, CSC384, University of Toronto, Fall 2011
Computing logical consequences
• We want procedures for computing logical consequences that can be implemented in our
programs.
• This would allow us to reason with our knowledge
• Represent the knowledge as logical formulas
• Apply procedures for generating logical consequences
• These procedures are called proof procedures.
• Covered in next lecture