Presentation is loading. Please wait.

Presentation is loading. Please wait.

Artificial Intelligence

Similar presentations


Presentation on theme: "Artificial Intelligence"— Presentation transcript:

1 Artificial Intelligence
Lecture 9 – Knowledge-Based Agents and Logic Dr. Muhammad Adnan Hashmi 26 December 2018

2 Outline Knowledge-based agents Wumpus world
Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem proving Forward chaining Backward chaining Resolution. 26 December 2018

3 Knowledge Base Knowledge base: Set of sentences in a formal language
Declarative approach for building an agent TELL it what it needs to know Then it can ASK itself what to do - answers should follow from the KB Agents can be viewed at the knowledge level What they know, regardless of implementation Or at the implementation level Data structures in KB and algorithms that manipulate them. 26 December 2018

4 A Knowledge-based Agent
The agent must be able to: Represent states, actions, etc. Incorporate new percepts Update internal representations of the world Deduce hidden properties of the world Deduce appropriate actions. 26 December 2018

5 Wumpus World Performance measure: Gold +1000, Death -1000, -1 per step, -10 for using the arrow Environment: Squares adjacent to wumpus are smelly Squares adjacent to pit are breezy Glitter iff gold is in the same square Shooting kills wumpus if you are facing it Shooting uses up the only arrow Grabbing picks up gold if in same square Releasing drops the gold in same square Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot Sensors: Breeze, Glitter, Smell. 26 December 2018

6 Wumpus World Characterization
Observable? No - only local perception Deterministic? Yes -outcomes exactly specified Episodic? No - sequential at the level of actions Static? Yes -Wumpus and Pits do not move Discrete? Yes Single-agent? Yes 26 December 2018

7 Exploring the Wumpus World
26 December 2018

8 Exploring the Wumpus World
26 December 2018

9 Exploring the Wumpus World
26 December 2018

10 Exploring the Wumpus World
26 December 2018

11 Exploring the Wumpus World
26 December 2018

12 Exploring the Wumpus World
26 December 2018

13 Exploring the Wumpus World
26 December 2018

14 Exploring the Wumpus World
26 December 2018

15 Logic In General Logics are formal languages for representing information, such that conclusions can be drawn Syntax defines the sentences in the language Semantics define the “meaning" of sentences, i.e., define truth of a sentence in a world E.g., the language of arithmetic x + 2 ≥ y is a sentence; x2 + y > is not a sentence x + 2 ≥ y is true iff the number x + 2 is no less than the number y x + 2 ≥ y is true in a world where x=7; y =1 x + 2 ≥ y is false in a world where x=0; y =6 26 December 2018

16 Entailment Entailment means that one thing follows from another
Knowledge base KB entails sentence B iff B is true in all worlds where KB is true E.g., the KB containing “the Giants won" and “the Reds won” entails “Either the Giants won or the Reds won“ E.g., x + y =4 entails 4=x + y Entailment is a relationship between sentences (i.e., syntax) that is based on semantics. 26 December 2018

17 Models Logicians typically think in terms of models, which are formally structured worlds with respect to which truth can be evaluated We say m is a model of a sentence B if B is true in m M(B) is the set of all models of B Then KB |= B if and only if M(KB) M(B) E.g. KB = Giants won and Reds won B = Giants won M(B) could be also true for worlds that are different than the worlds of KB 26 December 2018

18 Models M(B) 26 December 2018

19 Entailment in the Wumpus World
Situation after detecting nothing in [1,1], moving right, breeze in [2,1] Consider possible models for ?s, assuming only pits 3 Boolean choices, i.e., 8 possible models 26 December 2018

20 Wumpus Models 26 December 2018

21 Wumpus Models KB = Wumpus World Rules + Observations 26 December 2018

22 Wumpus Models KB = Wumpus World Rules + Observations
Alpha_1 = “(1,2) is safe, KB |= Alpha_1 26 December 2018

23 Wumpus Models KB = Wumpus World Rules + Observations 26 December 2018

24 Wumpus Models KB = Wumpus World Rules + Observations
Alpha_2 = “(2,2) is safe, KB |= Alpha_2 is false 26 December 2018

25 Inference First Order Logic (FOL): Allows complete and sound inference procedures Will answer any question whose answer follows from what is known by the KB. 26 December 2018 25

26 Propositional Logic Order of Precedence If S1 then S2 If and Only If
26 December 2018 If and Only If 26

27 Propositional Logic: Semantics
If S1 is true, then I am claiming that S2 is true 26 December 2018 27

28 Truth Table for Connectives
26 December 2018 28

29 Wumpus World Sentences
26 December 2018 29

30 Wumpus World Sentences
26 December 2018 30

31 Wumpus World Truth Table
128 possible rows, only 3 make the KB true P1,2 is false for all 3; hence, no pit in P1,2 Evaluate the entailed sentences in these rows P2,2 is both false and true; hence, no conclusion can be drawn about the pit being in P2,2 26 December 2018 31

32 Inference by Enumeration
26 December 2018 32

33 Logical Equivalence 26 December 2018 33

34 Validity and Satisfiability
If KB is true, alpha is always true. Hence, I can say that alpha follows from KB Suppose that KB=true. Then, this will become unsatisfiable only when alpha is true. Hence, I can say that alpha follows from KB 26 December 2018 34

35 Proof (A Sequence of Application of Inference Rules)
26 December 2018 35

36 Two Famous Inference Rules
Modus Ponens And Rule Given that P implies Q, and I know that P is true, then I can infer Q Given that P AND Q is true, I can infer that P is true, and I can also infer that Q is true. 26 December 2018 36

37 Resolution 26 December 2018 37

38 Conversion to CNF 26 December 2018 38

39 Resolution Algorithm 26 December 2018 39

40 Example 26 December 2018 40

41 Resolution Example Add P1,2 P2,1 already added Del P2,1 Del P1,2
This returns an empty clause. So, alpha is true. 26 December 2018 41

42 Forward and Backward Chaining
If this is true, and we know that the set of alphas is true, then we can infer beta. 26 December 2018 42

43 A and B are facts (leaves)
Forward Chaining What you want to check whether it can be entailed (or not) A and B are facts (leaves) of the AND-OR graph) AND-OR Graph – Multiple links with Arcs indicate Conjunction, and without Arcs indicate Disjunction 26 December 2018 43

44 Forward Chaining Algorithm
26 December 2018 44

45 Forward Chaining Example
26 December 2018 45

46 Forward Chaining Example
26 December 2018 46

47 Forward Chaining Example
26 December 2018 47 47

48 Forward Chaining Example
26 December 2018 48

49 Forward Chaining Example
26 December 2018 49

50 Forward Chaining Example
26 December 2018 50

51 Forward Chaining Example
26 December 2018 51

52 Forward Chaining Example
26 December 2018 52

53 Soundness and Completeness
It is sound: every inference is an application of Modus Ponens 26 December 2018 53

54 Backward Chaining 26 December 2018 54

55 Backward Chaining Example
26 December 2018 55

56 Backward Chaining Example
26 December 2018 56

57 Backward Chaining Example
26 December 2018 57

58 Backward Chaining Example
26 December 2018 58

59 Backward Chaining Example
26 December 2018 59

60 Backward Chaining Example
26 December 2018 60

61 Backward Chaining Example
26 December 2018 61

62 Backward Chaining Example
26 December 2018 62

63 Backward Chaining Example
26 December 2018 63

64 Backward Chaining Example
26 December 2018 64

65 Backward Chaining Example
26 December 2018 65

66 FC vs. BC 26 December 2018 66

67 Questions 26 December 2018


Download ppt "Artificial Intelligence"

Similar presentations


Ads by Google