AI CH 4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 69

Chapter Four

Knowledge Representation and Reasoning

1 Prepared by Chala S. (MSc in CSE) 6/19/2022


Knowledge-Based Agent
 An intelligent agent needs knowledge about the real world for taking decisions and reasoning to
act efficiently.

 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.

 Knowledge-based agents are composed of two main parts:


 Knowledge-base and
 Inference system.

2 Prepared by Chala S. (MSc in CSE) 6/19/2022


Knowledge-Based Agent cont..
 A knowledge-based agent must able to do the following:
 An agent should be able to represent states, actions, etc.
 An agent Should be able to incorporate new percepts
 An agent can update the internal representation of the world
 An agent can deduce the internal representation of the world
 An agent can deduce appropriate actions.

3 Prepared by Chala S. (MSc in CSE) 6/19/2022


Architecture of Knowledge-Based agent
 The knowledge-based agent (KBA)
take input from the environment by
perceiving the environment.

 The input is taken by the inference


engine of the agent and which also
communicate with KB to decide as
per the knowledge store in KB.

 The learning element of KBA


regularly updates the KB by learning
new knowledge.

4 Prepared by Chala S. (MSc in CSE) 6/19/2022


Knowledge-base
 The central component of a knowledge-based agent is its knowledge base, or KB.

 A KB is a collection of sentences (related but not identical to the sentences of English).

 Each sentence is expressed in a language called a knowledge representation language and


represents some assertion about the world.

 Key Aspects:
 How to add new sentences to the knowledge base/TELL/ and

 How to query what is known/ASK/.

 Both operations may involve inference—that is, a process of deriving new sentences from old.

 KBA is composed of:


 Knowledge base: domain-Specific content
 Inference mechanism: domain-Independent Algorithms
5 Prepared by Chala S. (MSc in CSE) 6/19/2022
Operations Performed by KBA
 Following are three operations which are performed by Knowledge-Based Agent
in order to show the intelligent behavior:
 TELL: This operation tells the knowledge base what it perceives from the environment.
 ASK: This operation asks the knowledge base what action it should perform. In the process
of answering this query, extensive reasoning may be done about the current state of the
world, about the outcomes of possible action sequences, and so on.
 Perform: It performs the selected action.

6 Prepared by Chala S. (MSc in CSE) 6/19/2022


A generic knowledge-based agent

 Given a percept,

 the agent adds the percept/TELLs to its knowledge base,

 asks the knowledge base for the best action, and

 tells the knowledge base that which action was taken.

7 Prepared by Chala S. (MSc in CSE) 6/19/2022


Approaches to designing a KBA
 A knowledge-based agent can be built simply by TELLing it what it needs to know.

 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.

8 Prepared by Chala S. (MSc in CSE) 6/19/2022


The Wumpus World
 The Wumpus world is a cave which has 4 x 4 rooms connected with passageways.

 We have a knowledge-based agent who will go forward in this world.

 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

10 Prepared by Chala S. (MSc in CSE) 6/19/2022


The PEAS description of Wumpus World
 Performance measure: +1000 for climbing out of the cave with the gold, –1000 for falling into a
pit or being eaten by the wumpus, –1 for each action taken and –10 for using up the arrow.

 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)

11 Prepared by Chala S. (MSc in CSE) 6/19/2022


Percept representation
 The Sensors percepts will be given to the agent program in the form of a list of five
symbols;

 Example: if there is a stench and a breeze, but no glitter, bump, or scream, the agent
program will get:

[Stench, Breeze, None, None, None].

12 Prepared by Chala S. (MSc in CSE) 6/19/2022


Wumpus World Environment
 Partially observable: The Wumpus world is partially observable because the agent can only
perceive the close environment such as an adjacent room.

 Deterministic: It is deterministic, as the result and outcome of the world are already known.

 Sequential: The order is important, so it is sequential.

 Static: It is static as Wumpus and Pits are not moving.

 Discrete: The environment is discrete.

 One agent: The environment is a single agent as we have one agent only and Wumpus is not
considered as an agent.

13 Prepared by Chala S. (MSc in CSE) 6/19/2022


Logical Knowledge Representation
 Logics are formal languages for representing knowledge such that conclusions can be
drawn.
 Syntax defines the sentences in the language, it specifies all the sentences that are well formed

 Example: “x + y = 4” is a well-formed sentence, whereas “x4y+ =” is not.


 Semantics define the "meaning" of sentences; it defines the truth of each sentence with respect
to each possible world.

 Example: “x + y = 4” is true in a world where x is 2 and y is 2, but false in a world


where x is 1 and y is 1.
 In standard logics, every sentence must be either true or false in each possible world—there is no
“in between.”
14 Prepared by Chala S. (MSc in CSE) 6/19/2022
Model
 When we need to be precise, we use the term model in place of “possible world.” Whereas
possible worlds might be thought of as (potentially) real environments that the agent might or
might not be in, models are mathematical abstractions, each of which simply fixes the truth or
falsehood of every relevant sentence.

 for example, having x men and y women sitting at a table playing bridge, and

the sentence x + y = 4 is true when there are four people in total.

 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.

 If a sentence α is true in model m, we say that m satisfies α or sometimes m is a model of α. We


use the notation M(α) to mean the set of all models of α.

15 Prepared by Chala S. (MSc in CSE) 6/19/2022


Entailment
 Entailment is the idea that a sentence follows logically from another sentence.

 In mathematical notation, we write

α |= β mean that the sentence α entails the sentence β.

 The formal definition of entailment is this:


α |= β if and only if, in every model in which α is true, β is also true. Using the notation just
introduced, we can write α |= β if and only if M(α) ⊆ M(β) .

 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).

16 Prepared by Chala S. (MSc in CSE) 6/19/2022


Propositional Logic
 Syntax: defines the allowable sentences.

 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:

NOT, AND, OR, IF_THEN (IMPLY), and IF_AND_ONLY_IF (BIDIRECTIONAL).

17 Prepared by Chala S. (MSc in CSE) 6/19/2022


Connectives used in propositional logic

18 Prepared by Chala S. (MSc in CSE) 6/19/2022


A BNF (Backus–Naur Form)
 A BNF (Backus–Naur Form) gives a formal grammar of propositional logic.

 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).

19 Prepared by Chala S. (MSc in CSE) 6/19/2022


Propositional Logic Cont..
 Semantics: defines the rules for determining the truth of a sentence with respect to a particular
model.

 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} .

 With three proposition symbols, there are 23 = 8 possible models.

 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.

20 Prepared by Chala S. (MSc in CSE) 6/19/2022


Semantics Cont..
 For complex sentences, we have five rules, which hold for any subsentences P and Q in any
model m:
• ¬P is true iff P is false in m.
• P ∧ Q is true iff both P and Q are true in m.
• P ∨ Q is true iff either P or Q is true in m.
• P ⇒ Q is true unless P is true and Q is false in m.
• P ⇔ Q is true iff P and Q are both true or both false in m


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).

 Associativity:  DE Morgan's Law:


 (P ∧ Q) ∧ R= P ∧ (Q ∧ R),  ¬ (P ∧ Q) = (¬P) ∨ (¬Q)

 (P ∨ Q) ∨ R= P ∨ (Q ∨ R)  ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).

 Identity element:  Double-negation elimination:


 P ∧ True = P,  ¬ (¬P) = P.

 P ∨ True= True.

22 Prepared by Chala S. (MSc in CSE) 6/19/2022


Limitations of Propositional logic
 We cannot represent relations like ALL, some, or none with propositional logic.

 Example:
 All the girls are intelligent.
 Some apples are sweet.

 Propositional logic has limited expressive power.

 In propositional logic, we cannot describe statements in terms of their properties


or logical relationships.

23 Prepared by Chala S. (MSc in CSE) 6/19/2022


Inference:
 Inference is a process of deriving new sentences from old. There are standard patterns of
inference that can be applied to derive chains of conclusions that lead to the desired goal. These
patterns of inference are called inference rules.
I. Modus Ponens

 The best-known rule is called Modus Ponens and is written as follows:

 The notation means that, whenever any sentences of the form α ⇒ β and α are given, then
the sentence β can be inferred.

 For example, if (WumpusAhead ∧WumpusAlive) ⇒ Shoot and (WumpusAhead ∧ WumpusAlive) are


given, then Shoot can be inferred.

24 Prepared by Chala S. (MSc in CSE) 6/19/2022


Inference cont..
II. And-Elimination

 Another useful inference rule is And-Elimination, which says that, from a conjunction, any of the
conjuncts can be inferred:

 For example, from (WumpusAhead ∧ WumpusAlive), WumpusAlive 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.

25 Prepared by Chala S. (MSc in CSE) 6/19/2022


Inference cont..
 Sentence is valid iff it is true under all possible interpretations in all possible
worlds
 Also called tautologies

 “There is a stench at (1,1) or there is not a stench at (1,1)”


 “There is an open area in front of me” is not valid in all worlds

 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

26 Prepared by Chala S. (MSc in CSE) 6/19/2022


Predicate (First-Order)Logic
 First-order logic is another way of knowledge representation in artificial intelligence. It is an
extension to propositional logic.

 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

 Objects: people, houses, numbers, colors, baseball games, wars, …


 Relations: red, round, prime, brother of, bigger than, part of, father of, comes between….
 Functions: best friend, one more than, plus,…

27 Prepared by Chala S. (MSc in CSE) 6/19/2022


First-order logic cont..
 First-order logic statements can be divided into two parts:
 Subject: Subject is the main part of the statement.
 Predicate: A predicate can be defined as a relation, which binds two atoms together in a
statement.

 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.

28 Prepared by Chala S. (MSc in CSE) 6/19/2022


Syntax of First-order logic
 The basic syntactic elements of first-order logic are the symbols that stand for objects, relations,
and functions.

 The symbols, come in three kinds:


constant symbols, which stand for objects;
predicate symbols, which stand for relations; and

function symbols, which stand for functions.

 We adopt the convention that these symbols will begin with uppercase letters.

 Example: Constant symbols : Mary, 3, Green;

Predicate symbols : father-of(Mary) = John, color-of(Sky) = Blue;

Function symbol : greater(5,3), green(Grass), color(Grass, Green).


29 Prepared by Chala S. (MSc in CSE) 6/19/2022
Basic Elements of First-order logic
 Following are the basic elements of FOL syntax:

30 Prepared by Chala S. (MSc in CSE) 6/19/2022


Atomic sentences
 A term is a constant symbol, a variable symbol, or an n-place function of n terms. : x and f(x1, ...,
xn) are terms, where each xi is a term. A term with no variables is a ground term

 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)

 Atomic sentences can have complex terms as arguments.


Ex: Married(Father(Richard), Mother(John))

 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.

31 Prepared by Chala S. (MSc in CSE) 6/19/2022


Complex Sentences
 A complex sentence is formed from atomic sentences connected by the logical connectives:
P, PQ, PQ, PQ, PQ where P and Q are sentences.

 ¬Brother(LeftLeg(Richard), John)

 Brother(Richard, John) ∧ Brother(John, Richard)

 King(Richard) ∨ King(John)

 ¬King(Richard) ⇒ King(John) .

 A quantified sentence adds quantifiers  and 

 A well-formed formula (wff) is a sentence containing no “free” variables. That is, all variables are
“bound” by universal or existential quantifiers.

Ex: (x)P(x,y) has x bound as a universally quantified variable, but y is free.

32 Prepared by Chala S. (MSc in CSE) 6/19/2022


first-order logic in BNF grammar

33 Prepared by Chala S. (MSc in CSE) 6/19/2022


Quantifiers
 Universal quantification
 (x)P(x) means that P holds for all values of x in the domain associated with that variable
 Ex: “All dolphins are mammals” is Written in FOL as: (x) dolphin(x)  mammal(x)

 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

34 Prepared by Chala S. (MSc in CSE) 6/19/2022


Quantifiers cont..
 Universal quantifiers are often used with “implies” to form “rules”:
(x) student(x)  smart(x) means “All students are smart”

 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:

 (x)(y)P(x,y) ↔ (y)(x) P(x,y)


 Similarly, you can switch the order of existential quantifiers:

 (x)(y)P(x,y) ↔ (y)(x) P(x,y)


 Switching the order of universals and existentials does change meaning:

 Everyone likes someone: (x)(y) likes(x,y)


 Someone is liked by everyone: (y)(x) likes(x,y)
Some Examples of FOL using quantifier:
 1. All birds fly.
In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be represented as follows.
∀x bird(x) →fly(x).

 2. Every man respects his parent.


In this question, the predicate is "respect(x, y)," where x=man, and y= parent.
Since there is every man so will use ∀, and it will be represented as follows:
∀x man(x) → respects (x, parent).

 3. Some boys play cricket.


In this question, the predicate is "play(x, y)," where x= boys, and y= game. Since there are some boys so we
will use ∃, and it will be represented as:
∃x boys(x) → play(x, cricket).
Some Examples of FOL using quantifier cont..
 4. Not all students like both Mathematics and Science.
In this question, the predicate is "like(x, y)," where x= student, and y= subject.
Since there are not all students, so we will use ∀ with negation, so following representation for
this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)].

 5. Only one student failed in Mathematics.


In this question, the predicate is "failed(x, y)," where x= student, and y= subject.
Since there is only one student who failed in Mathematics, so we will use following representation
for this:
∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y) [¬(x==y) ∧ student(y) → ¬failed (x,
Mathematics)].
38 Prepared by Chala S. (MSc in CSE) 6/19/2022
Inference in First-Order Logic
 Inference in First-Order Logic is used to deduce new facts or sentences from existing sentences.
Before understanding the FOL inference rule, let's understand some basic terminologies used.

 Substitution: is a fundamental operation performed on terms and formulas. It occurs in all


inference systems in first-order logic. The substitution is complex in the presence of quantifiers in
FOL. If we write F[a/x], so it refers to substitute a constant "a" in place of variable "x".

 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.

39 Prepared by Chala S. (MSc in CSE) 6/19/2022


FOL inference rules for quantifier:
 1. Universal Generalization: is a valid inference rule which states that if premise P(c) is true for
any arbitrary element c in the universe of discourse, then we can have a conclusion as ∀ x P(x).

 It can be represented as:

 This rule can be used if we want to show that every element has a similar property.

 In this rule, x must not appear as a free variable.

 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.

40 Prepared by Chala S. (MSc in CSE) 6/19/2022


FOL inference rules for quantifier cont..
 2. Universal instantiation: is also called as universal elimination or UI is a valid inference rule. It
can be applied multiple times to add new sentences.

 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.

 It can be represented as:

 Example: IF "Every person like ice-cream"=> ∀x P(x) so we can infer that

"John likes ice-cream" => P(c)

41 Prepared by Chala S. (MSc in CSE) 6/19/2022


FOL inference rules for quantifier cont..
 3. Existential Instantiation: is also called as Existential Elimination, which is a valid inference
rule in first-order logic.

 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.

 It can be represented as:

 Example: From the given sentence: ∃x Crown(x) ∧ OnHead(x, John),

 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.

 It can be represented as:

 Example: Let's say that,

 "Priyanka got good marks in English."

 "Therefore, someone got good marks in English."

43 Prepared by Chala S. (MSc in CSE) 6/19/2022


Knowledge Engineering
 Knowledge Engineering is a general process of knowledge-base construction.

 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

44 Prepared by Chala S. (MSc in CSE) 6/19/2022


1. Identify the task:
 The first step of the process is to identify the task, and for the digital circuit, there are various
reasoning tasks.

 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?

 Does the circuit have feedback loops?

45 Prepared by Chala S. (MSc in CSE) 6/19/2022


2. Assemble the relevant knowledge:
 In the second step, we will assemble the relevant knowledge which is required for digital circuits.
So for digital circuits, we have the following required knowledge:

 Logic circuits are made up of wires and gates.

 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).

46 Prepared by Chala S. (MSc in CSE) 6/19/2022


3. Decide on vocabulary:
 The next step of the process is to select functions, predicate, and constants to represent the circuits,
terminals, signals, and gates. Firstly we will distinguish the gates from each other and from other
objects. Each gate is represented as an object which is named by a constant, such as, Gate(X1).
The functionality of each gate is determined by its type, which is taken as constants such as AND,
OR, XOR, or NOT. Circuits will be identified by a predicate: Circuit (C1).

 For the terminal, we will use predicate: Terminal(x).

 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:

∀ t1, t2 Terminal(t1) ∧ Terminal(t2) ∧ Connected(t1, t2) ⇒ Signal(t1) = Signal(t2)


 Signal at every terminal will have either value 0 or 1, it will be represented as:

∀ t Terminal(t) ⇒ Signal(t) = 1 ∨ Signal(t) = 0


 Connect predicates are commutative:

∀ t1, t2 Connected(t1, t2) ⇔ Connected(t2, t1)


 Representation of types of gates:

∀ g Gate(g) ∧ k = Type(g) ⇒ k = AND ∨ k = OR ∨ k = XOR ∨ k = NOT

48 Prepared by Chala S. (MSc in CSE) 6/19/2022


Cont..
 Output of AND gate will be zero if and only if any of its input is zero.
∀ g Gate(g) ∧ Type(g) = AND ⇒ Signal(Out(1, g)) = 0 ⇔ ∃ n Signal(In(n, g)) = 0
 Output of OR gate is 1 if and only if any of its input is 1:
∀ g Gate(g) ∧ Type(g) = AND ⇒ Signal(Out(1, g)) = 0 ⇔ ∃ n Signal(In(n, g)) = 0
 Output of XOR gate is 1 if and only if its inputs are different:
∀ g Gate(g) ∧ Type(g) = XOR ⇒ Signal(Out(1, g)) = 1 ⇔ Signal(In(1, g)) = Signal(In(2, g))
 Output of NOT gate is invert of its input:
∀ g Gate(g) ∧ (Type(g) = NOT) ⇒ Signal(Out(1, g)) = Signal(In(1, g))
 All the gates in the above circuit have two inputs and one output (except NOT gate).
∀ g Gate(g) ∧ Type(g) = NOT ⇒ Arity(g, 1, 1)
∀ g Gate(g) ∧ k = Type(g) ∧ (k = AND ∨ k = OR ∨ k = XOR) ⇒ Arity(g, 2, 1)
 All gates are logic circuits:
∀ g Gate(g) ⇒ Circuit(g)

49 Prepared by Chala S. (MSc in CSE) 6/19/2022


5. Encode a description of the problem instance:
 Now we encode problem of circuit C1, firstly we categorize the circuit and its gate components.
This step is easy if ontology about the problem is already thought. This step involves the writing
simple atomics sentences of instances of concepts, which is known as ontology.

 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.

50 Prepared by Chala S. (MSc in CSE) 6/19/2022


6. Pose queries to the inference procedure and
get answers:
 In this step, we will find all the possible set of values of all the terminal for the adder circuit. The
first query will be:

 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?

51 Prepared by Chala S. (MSc in CSE) 6/19/2022


7. Debug the knowledge base:
 Now we will debug the knowledge base, and this is the last step of the complete process. In this
step, we will try to debug the issues of knowledge base.

 In the knowledge base, we may have omitted assertions like 1 ≠ 0.

52 Prepared by Chala S. (MSc in CSE) 6/19/2022


Introduction to Expert System
 Expert system in Artificial Intelligence are a prominent domain for research in AI. It was initially
introduced by researchers at Stanford University and were developed to solve complex problems in
a particular domain.

 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.

53 Prepared by Chala S. (MSc in CSE) 6/19/2022


The Three C’s of ES
 Characteristics of Expert Systems
They have high-performance levels
They are easy to understand
They are completely reliable
They are highly responsive

54 Prepared by Chala S. (MSc in CSE) 6/19/2022


Capabilities of Expert Systems
 The expert systems are capable of a number of actions including:
 Advising

 Assistance in human decision making


 Demonstrations and instructions
 Deriving solutions
 Diagnosis

 Interpreting inputs and providing relevant outputs


 Predicting results
 Justification of conclusions
 Suggestions for alternative solutions to a problem
55 Prepared by Chala S. (MSc in CSE) 6/19/2022
Cont..
 They are incapable of :
Substituting human decision makers
Possessing human capabilities
Producing accurate output for inadequate knowledge base
Refining their own knowledge

56 Prepared by Chala S. (MSc in CSE) 6/19/2022


Architecture of Expert Systems
 There are 5 Components of expert systems:
Knowledge Base
Inference Engine
User Interface

57 Prepared by Chala S. (MSc in CSE) 6/19/2022


Knowledge Base
 Knowledge Base: in an expert system represents facts and rules. It contains domain-specific and
high-quality knowledge.

 Knowledge is required to exhibit intelligence. The success of any ES majorly depends upon the
collection of highly accurate and precise knowledge.

 The knowledge base of an ES is a store of both, factual and heuristic knowledge.


 Factual Knowledge: It is the information widely accepted by the Knowledge Engineers and scholars in the
task domain.

 Heuristic Knowledge: It is about practice, accurate judgment, one’s ability of evaluation, and guessing.

58 Prepared by Chala S. (MSc in CSE) 6/19/2022


Knowledge Representation in ES
 It is the method used to organize and formalize the knowledge in the knowledge base of the ES. It
is in the form of IF-THEN-ELSE rules.

 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.

59 Prepared by Chala S. (MSc in CSE) 6/19/2022


Inference Engine
 Use of efficient procedures and rules by the Inference Engine is essential in deducting a correct,
flawless solution.

 In case of knowledge-based ES, the Inference Engine acquires and manipulates the knowledge
from the knowledge base to arrive at a particular solution.

 In case of rule based ES, it −


 Applies rules repeatedly to the facts, which are obtained from earlier rule application.
 Adds new knowledge into the knowledge base if required.

 Resolves rules conflict when multiple rules are applicable to a particular case.

 To recommend a solution, the Inference Engine uses the following strategies −


 Forward Chaining
 Backward Chaining
60 Prepared by Chala S. (MSc in CSE) 6/19/2022
Forward Chaining
 It is a strategy of an expert system to answer the question, “What can happen next?”

 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.

61 Prepared by Chala S. (MSc in CSE) 6/19/2022


Backward Chaining
 With this strategy, an expert system finds out the answer to the question, “Why this happened?”

 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.

62 Prepared by Chala S. (MSc in CSE) 6/19/2022


User Interface
 User interface provides interaction between user of the ES and the ES itself. It is generally
Natural Language Processing so as to be used by the user who is well-versed in the task domain.
The user of the ES need not be necessarily an expert in Artificial Intelligence.

 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.

63 Prepared by Chala S. (MSc in CSE) 6/19/2022


Requirements of Efficient ES User Interface
 It should help users to accomplish their goals in shortest possible way.

 It should be designed to work for user’s existing or desired work practices.

 Its technology should be adaptable to user’s requirements; not the other way round.

 It should make efficient use of user input.

64 Prepared by Chala S. (MSc in CSE) 6/19/2022


Development of Expert Systems: General Steps
 The process of ES development is iterative. Steps in developing the ES include −
 Identify Problem Domain
 The problem must be suitable for an expert system to solve it.

 Find the experts in task domain for the ES project.

 Establish cost-effectiveness of the system.

 Design the System


 Identify the ES Technology

 Know and establish the degree of integration with the other systems and databases.

 Realize how the concepts can represent the domain knowledge best.

 Develop the Prototype


 From Knowledge Base: The knowledge engineer works to −

 Acquire domain knowledge from the expert.

 Represent it in the form of If-THEN-ELSE rules.


65 Prepared by Chala S. (MSc in CSE) 6/19/2022
General Steps cont..
 Test and Refine the Prototype
 The knowledge engineer uses sample cases to test the prototype for any deficiencies in performance.

 End users test the prototypes of the ES.

 Develop and Complete the ES


 Test and ensure the interaction of the ES with all elements of its environment, including end users,
databases, and other information systems.

 Document the ES project well.

 Train the user to use ES.

 Maintain the System


 Keep the knowledge base up-to-date by regular review and update.

 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.

 Steady response − They avoid motions, tensions and fatigues.

67 Prepared by Chala S. (MSc in CSE) 6/19/2022


Limitations of Expert Systems
 It is evident that no technology is entirely perfect to offer easy and complete solutions. Larger
systems are not only expensive but also require a significant amount of development time and
computer resources.

 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.

68 Prepared by Chala S. (MSc in CSE) 6/19/2022


End of Chapter Four

Any doubt?

69 Prepared by Chala S. (MSc in CSE) 6/19/2022

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy