Download Lecture Slides on Inference - Artificial Intelligence Programming | CS 662 and more Study notes Computer Science in PDF only on Docsity!
Artificial IntelligenceProgramming
Inference^ Chris BrooksDepartment of Computer ScienceUniversity of San Francisco
Logic-based agents The big picture: our agent needs to make decisionsabout what to do in a complex environment. In order to do this, it needs a model of the world. Logic is a language for representing this model. Our agent will maintain and update a
knowledge base
(KB) which stores this model. Our agent will use
inference
to derive new facts that are
added to the KB. These new facts will help our agent make decisions.
Department of Computer Science — University of San Francisco – p.1/
Logic Summary A big weakness of propositional logic is its closed-worldassumption^ No way to talk about objects that cannot be named. Also, no way to specify classes or relations In practice, this leads to an exponential number ofsentences in the agent’s KB.
Department of Computer Science — University of San Francisco – p.3/
Logic Summary First order logic addresses these issues by providingvariables and quantification over these variables.^ FOL works with objects and relations between them,which form atomic sentences.^ Atomic sentences can be joined with logicalconnectives. objects.^ Example:
Siblings
(Bart, Lisa
),^ ∀xlikes
(x, M arge
)^ ⇒
likes(x, homer
Department of Computer Science — University of San Francisco – p.4/
Quantifiers In general,
⇒^ makes sense with
∀^ (∧^ is usually too
strong). ∧^ makes sense with
∃^ (⇒^ is generally too weak.)
Some examples:^ One of the Simpsons works at a nuclear plant.^ All of the Simpsons are cartoon characters.^ There is a Simpson with blue hair and a green dress.^ There is a Simpson who doesn’t have hair.
Department of Computer Science — University of San Francisco – p.6/
Nesting quantifiers Often, we’ll want to express more complexquantifications. For example, “every person has amother”^ ∀x^ ∃y mother
(x, y)
Notice the scope - for each
x, a different
y^ is
(potentially) chosen. What if we said
∃y^ ∀x mother
(x, y)?
this is not a problem when nesting quantifiers of thesame type. ∀x^ ∀y brotherOf
(x, y)^ ⇒^
siblingOf
(x, y)^ and
∀y^ ∀x brotherOf
(x, y)^ ⇒^
siblingOf
(x, y)^ are equivalent.
We often write that as ∀x, y brotherOf
(x, y)^ ⇒^
siblingOf
(x, y)^ Department of Computer Science — University of San Francisco – p.7/
More examples A husband is a male spouse^ ∀x, y husband
(x, y)^ ⇔^ spouse
(x, y)^ ∧^ male
(x)
Two siblings have a parent in common^ ∀x, y sibling
(x, y)^ ⇔ ¬(x^ =^ y)^
∧ ∃p P arent
(x, p)^ ∧^ P arent
(y, p)
Everyone who goes to Moe’s likes either Homer orBarney (but not both)^ ∀x goesT o
(moes, x)
(Likes(x, Homer
)^ ⇔ ¬Likes
(x, Barney
)) Department of Computer Science — University of San Francisco – p.9/
More examples Everyone knows someone who is angry at Homer.^ ∀x^ ∃y knows
(x, y)^ ∧^ angryAt
(y, homer
Everyone who works at the power plant is scared of Mr.Burns^ ∀x worksAt
(P owerP lant, x
)^ ⇒^ scaredOf
(x, burns
Department of Computer Science — University of San Francisco – p.10/
Representing useful knowledge in FO We can use FOL to represent class/subclassinformation, causality, existence, and disjoint sets. Example: Let’s suppose we are interested in building anagent that can help recommend music. We want it to be able to reason about musical artists,songs, albums, and genres. It would be tedious to enter every bit of informationabout every artist; instead, we’ll enter some rules and letour agent derive entailed knowledge.
Department of Computer Science — University of San Francisco – p.12/
Music example ∀xgenre(x, P unk
)^ →^ genre
(x, Rock)
songs are Rock songs. member(JohnLennon, Beatles
)^ ∧
member(P aulM cCartney, Beatles
)^ ∧
member(GeorgeHarrison, Beatles
)^ ∧
member(RingoStarr, Beatles
)^ ∧ ∀x member
(x, Beatles
)^ →
x^ ∈ {John, P aul, George, Ringo
}^ - exclusive membership:
John, Paul, George, and Ringo are the Beatles. perf ormedBy
(Beatles, W hiteAlbum
)^ The WhiteAlbum is
a Beatles album ∀x, y, zmember
(x, y)∧perf ormedBy
(y, z)^ →^ playedOn
(x, z)
if someone is a member of a group, and that groupperformed an album, then that person played on thatalbum.
Department of Computer Science — University of San Francisco – p.13/
Inference in Propositional logic We talked about two basic mechanisms for performinginference in propositional logic:^ Forward chaining: Begin with the facts in your KB.Apply inference rules until no more conclusions canbe drawn.^ Backward chaining: Begin with a fact (or its negation)that you wish to prove. Find facts that will justify thisfact. Work backwards until you find facts in your KBthat support (contradict) the fact you wish to prove.
Department of Computer Science — University of San Francisco – p.15/
Inference in FOL Can we do the same sorts of inference with First-orderlogic that we do with propositional logic? Yes, with some extra details. Need to keep track of variable bindings (substitution)
Department of Computer Science — University of San Francisco – p.16/
Removing quantifiers Universal Instantiation: we can always substitute aground term for a variable. This will typically be a term that occurs in some othersentence of interest. Choose a substitution for
x^ that helps us with our proof.
∀xLivesIn
(x, Springf ield
)^ ⇒^ knows
(x, Homer
Since this is true for all
x, we can substitute
{x^ =^ Bart
LivesIn(Bart, Springf ield
)^ ⇒^ knows
(Bart, Homer
Department of Computer Science — University of San Francisco – p.18/
Removing quantifiers Existential Instantiation: we can give a name to theobject that satisfies a sentence.^ ∃xLivesIn
(x, Springf ield
)^ ∧^ knows
(x, Homer
We know this must hold for at least one object. Let’scall that object
K.
LivesIn(K, Springf ield
)^ ∧^ knows
(K, Homer
K^ is called a
Skolem constant
K^ must be unused - gives us a way of referring to anexistential object. Once we’ve removed quantifiers, we can usepropositional inference rules.
Department of Computer Science — University of San Francisco – p.19/