Intern
Intern
Although some of these algorithms can solve any solvable problem, e.g. 8-puzzle, n-queens, vacuum cleaner world, towers of
Search
is the process of looking for the various sequence of actions that
lead to a goal state, evaluating them and choosing the optimal
sequence.
Execute 7
is the final step that the agent executes the chosen sequence of
actions to get it to the solution/goal
6/16/2023
10
Illustrate the use of logic in building a logical agent
These are not empty statements.
They make strong claims about how the Brief on knowledge based agents
intelligence of humans is achieved—not by Reasoning and Logic
purely reflex mechanisms but by processes of Inference
reasoning that operate on internal
Propositional logic
representations of knowledge.
In AI, this approach to intelligence is embodied First order logic: Syntax, semantics, inferences,
in knowledge-based agents. unification, chaining, resolution
MOTIVATION KNOWLEDGE
Knowledge-Based Systems (KBSs) are useless Knowledge includes facts about the real world
without the ability to represent knowledge entities and the relationship between them
Intelligent system require: Characteristics of Knowledge:
Knowledge (current state) of the world It is voluminous in nature and requires proper
formally represented using knowledge representation
structuring.
language It may be incomplete and imprecise.
COMPONENTS OF A KBA
KNOWLEDGE-BASED AGENT (KBA)
The agent is composed of:
Agents can be seen as knowing about their world, Knowledge base
and reasoning about their possible courses of It operates by storing a set of sentences (facts and relationship between
facts) about the world in its KB.
action.
Inference mechanism :
One can also design an autonomous agent that With the help of inference mechanism deduce new sentences and use them
to decide what action to take
learns and construct knowledge without human
interventions Learning mechanism:
Adapt to changes in the environment by updating the relevant knowledge
Input from Inference Output
environment Engine (actions)
Learning
13 (KB update) 14
Knowledge
Base
INFERENCE ENGINE
KNOWLEDGE BASE (KB)
The Inference engine derives new sentences from
Contains set of facts about the domain expressed in a the input and KB
suitable representation language The inference mechanism depends on
16
Each individual representation are called sentences representation in KB
Sentences are expressed in a (formal) knowledge The agent operates as follows:
representation (KR) language 1. It receives percepts from environment
2. It computes what action it should perform (by IE
A KBA is designed such that there is a way to:-
and KB)
TELL it (i.e. to add new sentences to the KB) and ASK it 3. It performs the chosen action (some actions are
(i.e. to query the KBA) simply inserting inferred new facts into KB).
When one ASKs a question, the answer should follow from Input from Inference Output
what has been TELLed to the KB previously environment Engine (actions)
Inference mechanism determines what follows from what Learning
has been TELLed to the KB 15 (KB update)
Knowledge
Base
6/16/2023
17
Example: An automated taxi might be said to know that the some knowledge of the world and of its own
Gojeb Bridge links Oromia Region and Southern Region
Logical Level. actions.
The level at which the knowledge is encoded into sentences.
For e.g. The taxi might be described as having the It uses logical reasoning to maintain a description of
logical sentences. the world as new percepts arrive, and to deduce a
Links(GB,OR,SR) in our knowledge base.
Implementation Level. course of action that will achieve its goals.
The physical representation of the sentences in the logical level
- how will it be represented in the computer? Let us see the example of Wumpus world
18
environment, in order to get motivation for
logical reasoning.
KNOWLEDGE REPRESENTATION, Syntax of a language: describes the possible configuration to form sentences.
E.g.: if x & y denote numbers, then x > y is a sentence about numbers
REASONING AND LOGIC Semantics: determines the facts in the world to which the sentences refer.
E.g.: x > y is false when y is greater than x and true otherwise
Proof theory (inference rules and proof procedures)
NATURAL LANGUAGES
LOGICS
Logic is the science or art of reasoning
Natural languages are certainly expressive,
Concerned with what is true and how we know
they help us for communication, not for whether something is true.
representation.
Two kinds of Logic
Propositional or Boolean Logic
A good way for a speaker to get a listener to come to First-order Logic
know something In both propositional and first order logic, a sentence
represents a fact and the agent either believes the sentence
Natural language also suffers from ambiguity. to be true, believes it to be false, or is unable to conclude
Small dogs and cats
either way. These logics therefore have three possible
states of belief.
Dangerous men and locations
Systems using probability theory, on the other hand, can
27
have any degree of belief, ranging from 0(total disbelief) to281
(total belief).
6/16/2023
29 30
QUIZ
1. Why we need to represent knowledge?
31
6/16/2023
TERMINOLOGY SEMANTICS
Entailment: mirrors the relation of one fact Facts and their representation:
Facts
are part of the world, where as their representation must be
following from another. encoded in some way that can be physically stored within an agent
A semantics maps sentences to facts in the world. In the
New sentences are generated that are necessarily true, given that simplest case, the semantics determines what objects in the
the old sentences are true. world are referenced by which objects in the language.
KB entails α (KB |= α) if and only if the conclusion α is true in The property of one fact following from another should be
mirrored by the property of one sentence being logically
every logically possible worlds in which all the premises in KB
entailed by another.
are true.
Derivation:
False True True False True True False True False False False False True
False False True False False True True False True True False True True
False False True False True True
Sentences in propositional logic tell you about what is true or false.
– P Q means that both P and Q are true.
39 Can you write the truth table for: 40
– P Q means that either P or Q is true (or both)
– (P Q) (R P)
– P Q means that if P is true, so is Q.
6/16/2023
INFERENCE RULES
INFERENCE RULES
Inference is used to create new sentences that logically RULE PREMISE CONCLUSION
follow from a given set of sentences in the KB. Modus Ponens A, A B B
It captures patterns of inferences that occur over & over again.
Modus Tolens B, A B A
Once a rule is established, it can be used to make inferences without
going through the tedious process of building truth tables And Elimination AB A
And Introduction A, B AB
An inference rule {, } |- Θ consists of two sentence
patterns & called the conditions (premises) and one Or Introduction A A1 A2 … An
sentence pattern Θ called the conclusion Double Negation Elimination A A
If & match two sentences of KB, then the corresponding Θ can be Unit Resolution A B, B A
inferred according to the rule Resolution A B, B C AC
Given set of inference rules (I) and set of sentences (KB); Hypothetical Syllogism PQ, QR PR
Inference is the process of applying successive inference rules
from I to KB, each rule inferring new facts and adding its In the case of modus ponens, if A is true and A B is true, then
conclusion to KB conclude B is true.
41 42
Example: Modus Ponens: { , } |-
43 44
6/16/2023
EXAMPLES EXAMPLE
From: Resolution vs. Hypothetical syllogism
From: Unit resolution vs. Modus ponens P Q ( P Q)
Engine-Starts Car-OK
Q R ( Q R)
Engine-Starts Engine-Starts Car-OK
Infer: P R ( P R)
Infer: Car-OK
Tautology/valid
FORMAL PROOFS
Aproof is a sequence of steps followed to generate FORMAL PROOFS
sentences, where each sentence is
either a premise or a sentence/formula derived from earlier sentences Example: The “weather problem”. Proof whether it is
(of the proof) using some of the rules of inference. raining or not.
The last step of the proof should deduce the formula (also called goal Can you proof using tree representation?
or query) that we want to prove. 1Q Premise “It is humid”
Example: The “weather problem”. Proof whether it is 2QP Premise “If it is humid, it is hot”
raining or not. 3P Modus Ponens(1,2) “It is hot”
Can you proof using tree representation? 4 (PQ) R Premise “If it’s hot & humid, it’s raining”
1Q Premise “It is humid” 5 P Q And Introduction(1,2) “It is hot and humid”
2QP Premise “If it is humid, it is hot” 6R Modus Ponens(4,5) “It is raining”
3 (PQ) R Premise “If it’s hot & humid, it’s raining”
47 48
6/16/2023
EXAMPLE 1 SOLUTION
Construct formal proof of validity for the following problem: Let
C: The investigation continues.
If the investigation continues, then new evidence is brought B: New evidence is brought to light.
to light. If new evidence is brought to light, then several I: Several leading citizens are implicated.
leading citizens are implicated. If several leading citizens S: The newspapers stop publicizing the case.
are implicated, then the newspapers stop publicizing the
case. If continuation of the investigation implies that the 1. CB
newspapers stop publicizing the case, then the bringing to 2. BI
light of new evidence implies that the investigation 3. IS
continues. The investigation does not continue. Therefore, 4. (C S) (B C)
new evidence is not brought to light. 5. C
6. CI 1,2 (Hypothetical Syllogism)
Represent using PL and proof the conclusion that “new
evidence is not brought to light”. 7. CS 6,3 (Hypothetical Syllogism)
8. IC 7,4 (Modus Ponens)
9. I 9,2(Modus Tollens)
49 10. B 8,5 50
EXAMPLE 3
EXAMPLE 2
1.Battery-OK Bulbs-OK Headlights-Work
Deme is either intelligent or a good actor. If Deme is 2.Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts
intelligent, then he can count from 1 to 10. Deme can only 3.Engine-Starts Flat-Tire Car-OK
count fom 1 to 2. Therefore Deme is a good actor. 4.Headlights-Work
5.Battery-OK
6.Starter-OK
Represent using PL and proof the conclusion that Deme is a good 7.Empty-Gas-Tank
actor or not. 8.Car-OK
CONCLUSION
Due to the ambiguity in natural languages there is a need to specify knowledge
through the use of formal languages
Formal languages give us a way to remove ambiguity and provide methods
for automating inference. PL is a first move in this direction
Inference: Theprocess of deriving new sentences from old one
Soundinference: derives true conclusions given true premises.
Complete inference: derives all true conclusions from a set of premises.
A valid sentence is true in all worlds under all interpretations.
If an implication sentence can be shown to be valid, then
given its premise - its consequent can be derived.
Differentlogics make different commitments about what the world is made of
and what kind of beliefs we can have regarding the facts.
Logics are useful for the commitments they do not make because lack of
commitment gives the knowledge base engineer more freedom.
PL commits only to the existence of facts that may or may not be the case in the
world being represented. 55 56