AI CH 4
AI CH 4
AI CH 4
Knowledge-based agents are those agents who have the capability of maintaining an internal state
of knowledge, reason over that knowledge, update their knowledge after observations and take
actions.
These agents can represent the world with some formal representation and act intelligently.
Key Aspects:
How to add new sentences to the knowledge base/TELL/ and
Both operations may involve inference—that is, a process of deriving new sentences from old.
Given a percept,
Starting with an empty knowledge base, the agent designer can TELL sentences one by one until
the agent knows how to operate in its environment. This is called the declarative approach to
system building.
In contrast, the procedural approach encodes desired behaviors directly as program code. In the
1970s and 1980s, advocates of the two approaches engaged in heated debates.
We now understand that a successful agent often combines both declarative and procedural
elements in its design, and that declarative knowledge can often be compiled into more efficient
procedural code.
The cave has a room with a beast which is called Wumpus, who eats anyone who enters the room.
The Wumpus can be shot by the agent, but the agent has a single arrow.
In the Wumpus world, there are some Pits rooms which are bottomless, and if agent falls in Pits,
then he will be stuck there forever.
The agent goal is to find the gold and climb out the cave without fallen into Pits or eaten by
Wumpus.
The agent will get a reward if he comes out with gold, and he will get a penalty if eaten by
Wumpus or falls in the pit.
9 Prepared by Chala S. (MSc in CSE) 6/19/2022
The Wumpus World
Environment: A 4 × 4 grid of rooms. The agent always starts in the square labeled [1,1], facing to
the right. The locations of the gold and the wumpus are chosen randomly, with a uniform
distribution, from the squares other than the start square. In addition, each square other than the
start can be a pit, with probability 0.2.
Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot, Climb
Sensors: Stench, Breeze, Glitter (in gold room), Bump (walking into walls), Scream (when the wumpus
is shoted)
Example: if there is a stench and a breeze, but no glitter, bump, or scream, the agent
program will get:
Deterministic: It is deterministic, as the result and outcome of the world are already known.
One agent: The environment is a single agent as we have one agent only and Wumpus is not
considered as an agent.
for example, having x men and y women sitting at a table playing bridge, and
The possible models are just all possible assignments of real numbers to the variables x and y.
Each such assignment fixes the truth of any sentence of arithmetic whose variables are x and y.
Example: sentence x = 0 entails the sentence xy = 0. Obviously, in any model where x is zero, it is
the case that xy is zero (regardless of the value of y).
The atomic sentences consist of a single proposition symbol, a symbols that start with an
uppercase letter and may contain other letters or subscripts: P, Q, R, W1,3 and North.
Each such symbol stands for a proposition that can be true or false.
Complex sentences are constructed from simpler sentences, using parentheses and logical
connectives.
Though there are many connectives, we are going to use the following five basic connectives here:
The BNF grammar by itself is ambiguous; a sentence with several operators can be parsed by the
grammar in multiple ways. To eliminate the ambiguity we define a precedence for each operator.
The “not” operator (¬) has the highest precedence, which means that in the sentence ¬A ∧ B the
¬ binds most tightly, giving us the equivalent of (¬A) ∧B rather than ¬(A∧B).
In propositional logic, a model simply fixes the truth value—true or false—for every proposition
symbol.
For example, if the sentences in the knowledge base make use of the proposition symbols P1,2,
P2,2, and P3,1, then one possible model is
m1 = {P1,2 = false, P2,2 = false, P3,1 = true} .
The rules can also be expressed with truth tables that specify the truth value of a complex
sentence for each possible assignment of truth values to its components.
21 Prepared by Chala S. (MSc in CSE) 6/19/2022
Properties of Operators
Commutativity: Distributive:
P∧ Q= Q ∧ P, or P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
P ∨ Q = Q ∨ P. P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
(P ∨ Q) ∨ R= P ∨ (Q ∨ R) ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
P ∨ True= True.
Example:
All the girls are intelligent.
Some apples are sweet.
The notation means that, whenever any sentences of the form α ⇒ β and α are given, then
the sentence β can be inferred.
Another useful inference rule is And-Elimination, which says that, from a conjunction, any of the
conjuncts can be inferred:
By considering the possible truth values of α and β, one can show easily that Modus Ponens and
And-Elimination are sound once and for all. These rules can then be used in any particular
instances where they apply, generating sound inferences without the need for enumerating models.
Sentence is satisfiable iff there is some interpretation in some world for which it
is true
“There is a wumpus at (1,2)” could be true in some situation
“There is a wall in front of me and there is no wall in front of me” is unsatisfiable
First-order logic is a powerful language that develops information about the objects in a more easy
way and can also express the relationship between those objects.
Whereas propositional logic assumes the world contains facts, first-order logic (like natural
language) assumes the world contains
Consider the statement: "x is an integer.", it consists of two parts, the first part x is the subject of
the statement and second part "is an integer," is known as a predicate.
We adopt the convention that these symbols will begin with uppercase letters.
An atomic sentence is formed from a predicate symbol optionally followed by a parenthesized list
of terms.
Ex:Richard and John are brothers => Brother(Richard, John), Chinky is a cat: => cat (Chinky)
An atomic sentence is true in a given model if the relation referred to by the predicate symbol
holds among the objects referred to by the arguments.
¬Brother(LeftLeg(Richard), John)
King(Richard) ∨ King(John)
¬King(Richard) ⇒ King(John) .
A well-formed formula (wff) is a sentence containing no “free” variables. That is, all variables are
“bound” by universal or existential quantifiers.
Existential quantification
( x)P(x) means that P holds for some value of x in the domain associated with that variable
E.g., “There is a mammal that can lay eggs” is written as: ( x) mammal(x) lays-eggs(x)
Permits one to make a statement about some object without naming it
Universal quantification is rarely used to make blanket statements about every individual in the
world:
(x)student(x)smart(x) means “Everyone in the world is a student and is smart”
Existential quantifiers are usually used with “and” to specify a list of properties about an
individual:
(x) student(x) smart(x) means “There is a student who is smart”
Properties of Quantifier
Switching the order of universal quantifiers does not change the meaning:
Equality: For this, we can use equality symbols which specify that the two terms refer to the same
object. Example: Brother (John) = Smith.
As in the above example, the object referred by the Brother (John) is similar to the object referred
by Smith. The equality symbol can also be used with negation to represent that two terms are not
the same objects. Example: ¬(x=y) which is equivalent to x ≠y.
This rule can be used if we want to show that every element has a similar property.
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀ x P(x) "All bytes contain 8
bits.", it will also be true.
As per UI, we can infer any sentence obtained by substituting a ground term for the variable.
The UI rule state that we can infer any sentence P(c) by substituting a ground term c (a constant
within domain x) from ∀ x P(x) for any object in the universe of discourse.
This rule states that one can infer P(c) from the formula given in the form of ∃x P(x) for a new
constant symbol c.
The restriction with this rule is that c used in the rule must be a new term for which P(c ) is true.
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the knowledge
base. The above used K is a constant symbol, which is called Skolem constant. The Existential
instantiation is a special case of Skolemization process.
42 Prepared by Chala S. (MSc in CSE) 6/19/2022
FOL inference rules for quantifier cont..
4. Existential introduction: is also known as an existential generalization, which is a valid
inference rule in first-order logic.
This rule states that if there is some element c in the universe of discourse which has a property P,
then we can infer that there exists something in the universe which has the property P.
A knowledge engineer is someone who investigates a particular domain, learns what concepts are
important in that domain, and creates a formal representation of the objects and relations in the
domain.
Following are some main steps of the knowledge-engineering process. Using these steps, we will
develop a knowledge base which will allow us to reason about digital circuit (One-bit full adder)
which is given below
At the first level or highest level, we will examine the functionality of the circuit:
Does the circuit add properly?
What will be the output of gate A2, if all the inputs are high?
At the second level, we will examine the circuit structure details such as:
Which gate is connected to the first input terminal?
Signal flows through wires to the input terminal of the gate, and each gate produces the
corresponding output which flows further.
In this logic circuit, there are four types of gates used: AND, OR, XOR, and NOT.
All these gates have one output terminal and two input terminals (except NOT gate, it has one
input terminal).
For gate input, we will use the function In(1, X1) for denoting the first input terminal of the gate,
and for output terminal we will use Out (1, X1).
The function Arity(c, i, j) is used to denote that circuit c has i input, j output.
The connectivity between gates can be represented by predicate Connect(Out(1, X1), In(1, X1)).
We use a unary predicate On (t), which is true if the signal at a terminal is on.
47 Prepared by Chala S. (MSc in CSE) 6/19/2022
4. Encode general knowledge about the domain:
To encode the general knowledge about the logic circuit, we need some following rules:
If two terminals are connected then they have the same input signal, it can be represented as:
For the given circuit C1, we can encode the problem instance in atomic sentences as below:
Since in the circuit there are two XOR, two AND, and one OR gate so atomic sentences for these
gates will be: Gate(X1) ∧ Type(X1) = XOR
Gate(X2) ∧ Type(X2) = XOR
Gate(A1) ∧ Type(A1) = AND
Gate(A2) ∧ Type(A2) = AND
Gate(O1) ∧ Type(O1) = OR
And then represent the connections between all the gates using connected predicate.
What should be the combination of input which would generate the first output of circuit C1, as 0
and a second output to be 1?
An Expert system is a domain in which Artificial Intelligence stimulates the behavior and
judgment of a human or an organization containing experts.
It acquires relevant knowledge from its knowledge base, and interprets it as per the user’s problem.
The data in the knowledge base is essentially added by humans who are experts in a particular
domain. However, the software is used by non-experts to gain information.
It is used in various areas of medical diagnosis, accounting, coding, gaming and more.
Knowledge is required to exhibit intelligence. The success of any ES majorly depends upon the
collection of highly accurate and precise knowledge.
Heuristic Knowledge: It is about practice, accurate judgment, one’s ability of evaluation, and guessing.
The success of any expert system majorly depends on the quality, completeness, and accuracy of
the information stored in the knowledge base.
The knowledge base is formed by readings from various experts, scholars, and the Knowledge
Engineers.
The knowledge engineer is a person with the qualities of empathy, quick learning, and case
analyzing skills. He acquires information from subject expert by recording, interviewing, and
observing him at work, etc. He then categorizes and organizes the information in a meaningful
way, in the form of IF-THEN-ELSE rules, to be used by interference machine.
In case of knowledge-based ES, the Inference Engine acquires and manipulates the knowledge
from the knowledge base to arrive at a particular solution.
Resolves rules conflict when multiple rules are applicable to a particular case.
Here, the Inference Engine follows the chain of conditions and derivations and finally deduces the
outcome. It considers all the facts and rules, and sorts them before concluding to a solution.
This strategy is followed for working on conclusion, result, or effect. For example, prediction of
share market status as an effect of changes in interest rates.
On the basis of what has already happened, the Inference Engine tries to find out which
conditions could have happened in the past for this result. This strategy is followed for finding out
cause or reason. For example, diagnosis of blood cancer in humans.
It explains how the ES has arrived at a particular recommendation. The explanation may appear
in the following forms :
Natural language displayed on screen.
Verbal narrations in natural language.
Listing of rule numbers displayed on the screen.
The user interface makes it easy to trace the credibility of the deductions.
Its technology should be adaptable to user’s requirements; not the other way round.
Know and establish the degree of integration with the other systems and databases.
Realize how the concepts can represent the domain knowledge best.
Cater for new interfaces with other information systems, as those systems evolve.
66 Prepared by Chala S. (MSc in CSE) 6/19/2022
Advantages of Expert Systems
Availability − They are easily available due to mass production of software.
Less Production Cost − Production costs of expert systems are extremely reasonable and
affordable.
Speed − They offer great speed and reduce the amount of work.
Less Error Rate − Error rate is much lower as opposed to human errors.
Low Risks − They are capable of working in environments that are dangerous to humans.
Limitations of Es include:
Difficult knowledge acquisition
Maintenance costs
Development costs
Adheres only to specific domains.
Requires constant manual updates, it cannot learn by itself.
It is incapable of providing logic behind the decisions.
Any doubt?
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: