560 likes | 572 Views
This lecture provides an overview of logical agents and their role in dealing with partial or imperfect information. It discusses the syntax, semantics, and algorithms necessary for reasoning and decision-making in logical agents. The exploration of the Wumpus World is used as a case study.
E N D
Notes adapted from lecture notes for CMSC 421 by B.J. Dorr, with slides from Tom Lenaerts Intelligent Systems: logical agents Lecturer:Stefan Schlobach 15 January 2018
Part 1 LogicalagentsWhat’s a logic? IS: Logical Agents
The general idea: Logic Generic method to deal with: Partial or imperfect information Implicit information Knowledge about environment and task IS: Logical Agents
What do we need? Syntax to write statements about rules and knowledge of the game IS: Logical Agents
What do we need? Semantics to formalise the meaning of these statements IS: Logical Agents
What do we need? Algorithms to determine whether statements are true or not, according to the intended semantics. IS: Logical Agents
Knowledge-based/Logical agents • Logical Agent must be able to: • Represent states and actions, • Incorporate new percepts • Update internal representation of the world • Deduce hidden properties of the world • Deduce appropriate actions IS: Logical Agents
A Wumpus World Wumpus IS: Logical Agents
Wumpus World PEAS Description IS: Logical Agents
Wumpus World Characterization • Observable? No, only local perception • Deterministic? Yes, outcome exactly specified • Static? Yes, Wumpus and pits do not move • Discrete? Yes • Single-agent? Yes, Wumpus is essentially a natural feature. This is actually online search/exploratory search IS: Logical Agents
Exploring the Wumpus World [1,1] The KB initially contains the rules of the environment. The first percept is [none, none,none,none,none], move to safe cell e.g. 2,1 [2,1] breeze which indicates that there is a pit in [2,2] or [3,1], return to [1,1] to try next safe cell IS: Logical Agents
Exploring the Wumpus World [1,2] Stench in cell which means that wumpus is in [1,3] or [2,2] YET … not in [1,1] YET … not in [2,2] or stench would have been detected in [2,1] THUS … wumpus is in [1,3] THUS [2,2] is safe because of lack of breeze in [1,2] THUS pit in [1,3] move to next safe cell [2,2] IS: Logical Agents
Exploring the Wumpus World [2,2] move to [2,3] [2,3] detect glitter, smell, breeze THUS pick up gold THUS pit in [3,3] or [2,4] IS: Logical Agents
Logical Agents (in games) • Wumpus (online/exploration game) • Base transitions on explicit statements (“safe state”, wumpus(3,3), breeze(1,2) • Card Game (multiplayer game, (im)perfect information) • Base exploration on explicit statements • Explicit definitions of redundancy • Explicit definitions of heuristics • Logics as languagestoexpressknowledge IS: Logical Agents
Logic! Logic! Logic! I think you should be more explicit here in step 2 IS: Logical Agents
What is a logic? • A formal language • Syntax • Which expressions are legal (well-formed) • Semantics • what legal expressions mean • the meaning of each sentence with respect to interpretations • Calculus: • how to determine meaning for legal expressions IS: Logical Agents
An example: A simple language of arithmetic Syntax: • X+2 >= y is a sentence, x2+y is not a sentence Semantics: • X+2 >= y is true in a world where x=7 and y =1 • X+2< X+3 is true in all worlds • X+2 >= y is false in a world where x=0 and y =6 Calculus: • Rule based IS: Logical Agents
Part 2 Propositional logic IS: Logical Agents
Yet Another example: A logic for propositions A proposition is the “content of a sentence” • Syntax • Semantic • Calculus We will use PL later to represent facts about the Wumpus World (and reason over it) IS: Logical Agents
Syntax IS: Logical Agents
Propositional Logic: Syntax IS: Logical Agents
Semantics IS: Logical Agents
Models • Truth is a terribly difficult philosophical notion. • Models are formal interpretations of the world with respect to which truth can be evaluated. • m is a model of a sentence if • holds in m -> m adheres to the constraints of • M() is the set of all models of IS: Logical Agents
Entailment • The KB entails (KB |= ) means that follows from the information in KB • Formally: • KB entails iff holds in all the worlds where KB is true. • Based on models we can unambiguously and formally define semantics for entailment IS: Logical Agents
Wumpus world model IS: Logical Agents
Wumpus world model IS: Logical Agents
Wumpus world model IS: Logical Agents
Entailment • The KB entails (KB |= ) means that follows from the information in KB • Formally: • KB entails iff holds in all the worlds where KB is true. • E.g. x+y=4 entails 4=x+y • Based on models we can unambiguously and formally define semantics for entailment IS: Logical Agents
Wumpus world model IS: Logical Agents
Wumpus world model IS: Logical Agents
Semantic notions: Entailment, Validity and satisfiability • A sentence is entailed by a KB K iffholds/is true in all models of KB • A sentence is valid if it is true in all models, • e.g., True, A A, A A, (A (A B)) B • A sentence is satisfiable if it is true in some model • e.g., A B, C • A sentence is unsatisfiable if it is true in no models • e.g., AA IS: Logical Agents
Propositional Logic Meaning of operators is recursively defined: IS: Logical Agents
Logical equivalence • Two sentences are logically equivalent iff true in same set of models or ß iff |=ßand ß |= . IS: Logical Agents
Wumpus world knowledge base IS: Logical Agents
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 IS: Logical Agents
Modelling Schnapsen TrumpWedding(x) <-> Q(x) & Trump(x) & exists y (samecolor(x,y) & K(y) & myCard(y)) samecolor(x,y) <-> (C(x)&C(y)) v (D(x)&D(y)) v (H(x)&H(y)) v (S(x)&S(y) A(0), A(5),A(10),A(15),Ten(1),Ten(6),...J(14),J(19) card-value C(0),C(1),...S(18),S(19) the color-value of the 20 cards. myCard(5),myCard(7),myCard(13),myCard(17),myCard(18) IS: Logical Agents
Part 3 First order logic IS: Logical Agents
First-order logic • 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, … IS: Logical Agents
Syntax of FOL: Basic elements IS: Logical Agents
Atomic sentences Atomic sentence = predicate (term1,...,termn) or term1 = term2 Term = function (term1,...,termn) or constant or variable • E.g., Brother(KingJohn,RichardTheLionheart) > (Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn))) IS: Logical Agents
Complex sentences • Complex sentences are made from atomic sentences using connectives S, S1 S2, S1 S2, S1 S2, S1S2, E.g. Sibling(KingJohn,Richard) Sibling(Richard,KingJohn) >(1,2) ≤ (1,2) >(1,2) >(1,2) IS: Logical Agents
Truth in first-order logic • Sentences are true with respect to a model and an interpretation • Model contains objects (domainelements) and relations among them • Interpretation specifies referents for constantsymbols→objectspredicatesymbols→relationsfunctionsymbols→ functional relations • An atomic sentence predicate(term1,...,termn) is true iff the objects referred to by term1,...,termn are in the relation referred to by predicate IS: Logical Agents
Models for FOL: Example IS: Logical Agents
Universal quantification • <variables> <sentence> Everyone at USGov is smart: x At(x,USGov) Smart(x) • x P is true in a model m iff P is true with x being each possible object in the model • Roughly speaking, equivalent to the conjunction of instantiations of P At(KingJohn,USGov) Smart(KingJohn) At(Richard,USGov) Smart(Richard) At(USGov, USGov) Smart(USGov) ... IS: Logical Agents
A common mistake to avoid • Typically, is the main connective with • Common mistake: using as the main connective with : x At(x, USGov) Smart(x) means “Everyone is at USGov and everyone is smart” IS: Logical Agents
Existential quantification • <variables> <sentence> • Someone at USGov is smart: • x At(x,USGov) Smart(x) • xP is true in a model m iff P is true with x being some possible object in the model • Roughly speaking, equivalent to the disjunction of instantiations of P At(KingJohn,USGov) Smart(KingJohn) At(Richard,USGov) Smart(Richard) At(USGov,USGov) Smart(USGov) ... IS: Logical Agents
Another common mistake to avoid • Typically, is the main connective with • Common mistake: using as the main connective with : x (At(x,USGov) Smart(x)) is true if there is anyone who is not at USGov! IS: Logical Agents
Properties of quantifiers • x y is the same as yxx y is the same as yx • x y is not the same as yx • x y Loves(x,y) • “There is a person who loves everyone in the world” • yx Loves(x,y) • “Everyone in the world is loved by at least one person” • Quantifier duality: each can be expressed using the other • x Likes(x,IceCream) same as x Likes(x,IceCream) x Likes(x,Broccoli) same as xLikes(x,Broccoli) IS: Logical Agents
Using FOL The kinship domain: • Brothers are siblingsx,y Brother(x,y) ->Sibling(x,y) • One's mother is one's female parentm,c Mother(c) = m <->(Female(m) Parent(m,c))“Sibling” is symmetric x,y Sibling(x,y) Sibling(y,x) IS: Logical Agents
Using FOL The set domain: s Set(s) (s = {} ) (x,s2 Set(s2) s = {x|s2}) x,s {x|s} = {} x,s x s s = {x|s} x,s x s [ y,s2} (s = {y|s2} (x = y x s2))] s1,s2 s1 s2 (x x s1 x s2) s1,s2 (s1 = s2) (s1 s2 s2 s1) x,s1,s2 x (s1 s2) (x s1 x s2) x,s1,s2 x (s1 s2) (x s1 x s2) IS: Logical Agents