Ai Unit 2
Ai Unit 2
Lecture 2.1.1
• Knowledge-Based Agent in Artificial intelligence
o An intelligent agent needs knowledge about the real world for taking decisions
and reasoning to act efficiently.
o 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.
o Knowledge-based agents are composed of two main parts:
o Knowledge-base and
o Inference system.
Knowledge-base is required for updating knowledge for an agent to learn with experiences
and take action as per the knowledge.
Inference system
Inference means deriving new sentences from old. Inference system allows us to add a new
sentence to the knowledge base. A sentence is a proposition about the world. Inference system
applies logical rules to the KB to deduce new information.
Inference system generates new facts so that an agent can update the KB. An inference system
works mainly in two rules which are given as:
o Forward chaining
o Backward chaining
Operations Performed by KBA
Following are three operations which are performed by KBA in order to show the intelligent
behavior:
12. TELL: This operation tells the knowledge base what it perceives from the
environment.
13. ASK: This operation asks the knowledge base what action it should perform.
14. Perform: It performs the selected action.
A generic knowledge-based agent:
1. function KB-AGENT(percept):
7. t=t+1
8. return action
The knowledge-based agent takes percept as input and returns an action as output. The agent
maintains the knowledge base, KB, and it initially has some background knowledge of the real
world. It also has a counter to indicate the time for the whole process, and this counter is
initialized with zero.
Each time when the function is called, it performs its three operations:
o Firstly it TELLs the KB what it perceives.
o Secondly, it asks KB what action it should take
o Third agent program TELLS the KB that which action was chosen.
The MAKE-PERCEPT-SENTENCE generates a sentence as setting that the agent perceived the
given percept at the given time.
The MAKE-ACTION-QUERY generates a sentence to ask which action should be done at the
current time.
MAKE-ACTION-SENTENCE generates a sentence which asserts that the chosen action was
executed.
A knowledge-based agent can be viewed at different levels which are given below:
1. Knowledge level
Knowledge level is the first level of knowledge-based agent, and in this level, we need to
specify what the agent knows, and what the agent goals are. With these specifications, we can
fix its behavior. For example, suppose an automated taxi agent needs to go from a station A to
station B, and he knows the way from A to B, so this comes at the knowledge level.
2. Logical level:
At this level, we understand that how the knowledge representation of knowledge is stored.
At this level, sentences are encoded into different logics. At the logical level, an encoding of
knowledge into logical sentences occurs. At the logical level we can expect to the automated
taxi agent to reach to the destination B.
3. Implementation level:
This is the physical representation of logic and knowledge. At the implementation level agent
perform actions as per logical and knowledge level. At this level, an automated taxi agent
actually implement his knowledge and logic so that he can reach to the destination.
However, in the real world, a successful agent can be built by combining both declarative and
procedural approaches, and declarative knowledge can often be compiled into more efficient
procedural code.
Humans are best at understanding, reasoning, and interpreting knowledge. Human knows
things, which is knowledge and as per their knowledge they perform various actions in the
real world. But how machines do all these things comes under knowledge
representation and reasoning. Hence we can describe Knowledge representation as
following:
What to Represent:
o Object: All the facts about objects in our world domain. E.g., Guitars contains strings,
trumpets are brass instruments.
o Events: Events are the actions which occur in our world.
o Performance: It describe behavior which involves knowledge about how to do
things.
o Meta-knowledge: It is knowledge about what we know.
o Facts: Facts are the truths about the real world and what we represent.
o Knowledge-Base: The central component of the knowledge-based agents is the
knowledge base. It is represented as KB. The Knowledgebase is a group of the
Sentences (Here, sentences are used as a technical term and not identical with the
English language).
Types of knowledge
1. Declarative Knowledge:
3. Meta-knowledge:
4. Heuristic knowledge:
5. Structural knowledge:
Knowledge of real-worlds plays a vital role in intelligence and same for creating artificial
intelligence. Knowledge plays an important role in demonstrating intelligent behavior in AI
agents. An agent is only able to accurately act on some input when he has some knowledge or
experience about that input.
Let's suppose if you met some person who is speaking in a language which you don't know,
then how you will able to act on that. The same thing applies to the intelligent behavior of the
agents.
As we can see in below diagram, there is one decision maker which act by sensing the
environment and using knowledge. But if the knowledge part will not present then, it cannot
display intelligent behavior.
AI knowledge cycle:
An Artificial intelligence system has the following components for displaying intelligent
behavior:
o Perception
o Learning
o Knowledge Representation and Reasoning
o Planning
o Execution
The above diagram is showing how an AI system can interact with the real world and what
components help it to show intelligence. AI system has Perception component by which it
retrieves information from its environment. It can be visual, audio or another form of sensory
input. The learning component is responsible for learning from data captured by Perception
comportment. In the complete cycle, the main components are knowledge representation and
Reasoning. These two components are involved in showing the intelligence in machine-like
humans. These two components are independent with each other but also coupled together.
The planning and execution depend on analysis of Knowledge representation and reasoning.
There are mainly four approaches to knowledge representation, which are given below:
o It is the simplest way of storing facts which uses the relational method, and each fact
about a set of the object is set out systematically in columns.
o This approach of knowledge representation is famous in database systems where the
relationship between different entities is represented.
o This approach has little opportunity for inference.
Player Weight Ag
Player1 65 23
Player2 58 18
Player3 75 24
2. Inheritable knowledge:
o In the inheritable knowledge approach, all data must be stored into a hierarchy of
classes.
o All classes should be arranged in a generalized form or a hierarchal manner.
o In this approach, we apply inheritance property.
o Elements inherit values from other members of a class.
o This approach contains inheritable knowledge which shows a relation between
instance and class, and it is called instance relation.
o Every individual frame can represent the collection of attributes and its value.
o In this approach, objects and values are represented in Boxed nodes.
o We use Arrows which point from objects to their values.
o Example:
3. Inferential knowledge:
man(Marcus)
4. Procedural knowledge:
o Procedural knowledge approach uses small programs and codes which describes how
to do specific things, and how to proceed.
o In this approach, one important rule is used which is If-Then rule.
o In this knowledge, we can use various coding languages such as LISP
language and Prolog language.
o We can easily represent heuristic or domain-specific knowledge using this approach.
o But it is not necessary that we can represent all cases in this approach.
Link:
https://www.youtube.com/watch?v=SEJhMO1IXZs&list=PLwdnzlV3ogoXaceHrrFVZCJKbm_
laSHcH&index=11
Lecture 2.1.2
• Techniques of knowledge representation
There are mainly four ways of knowledge representation which are given as
follows:
Logical Representation
1. Logical Representation
Logical representation is a language with some concrete rules which deals with
propositions and has no ambiguity in representation. Logical representation
means drawing a conclusion based on various conditions. This representation lays
down some important communication rules. It consists of precisely defined syntax
and semantics which supports the sound inference. Each sentence can be
translated into logics using syntax and semantics.
Syntax:
o Syntaxes are the rules which decide how we can construct legal sentences
in the logic.
o It determines which symbol we can use in knowledge representation.
o How to write those symbols.
Semantics:
o Semantics are the rules by which we can interpret the sentence in the logic.
o Semantic also involves assigning a meaning to each sentence.
o Propositional Logics
o Predicate logics
12. Logical representations have some restrictions and are challenging to work
with.
13. Logical representation technique may not be very natural, and inference
may not be so efficient.
Example: Following are some statements which we need to represent in the form
of nodes and arcs.
Statements:
Frame Representation
Facets: The various aspects of a slot is known as Facets. Facets are features of
frames which enable us to put constraints on the frames. Example: IF-NEEDED
facts are called when data of any particular slot is needed. A frame may consist of
any number of slots, and a slot may include any number of facets and facets may
have any number of values. A frame is also known as slot-filter knowledge
representation in artificial intelligence.
Frames are derived from semantic networks and later evolved into our modern-
day classes and objects. A single frame is not much useful. Frames system consist
of a collection of frames which are connected. In the frame, knowledge about an
object or event can be stored together in the knowledge base. The frame is a type
of technology which is widely used in various applications including Natural
language processing and machine visions.
Example: 1
4. Production Rules
Production rules system consist of (condition, action) pairs which mean, "If
condition then action". It has mainly three parts:
In production rules agent checks for the condition and if the condition exists then
production rule fires and corresponding action is carried out. The condition part
of the rule determines which rule may be applied to a problem. And the action part
carries out the associated problem-solving steps. This complete process is called
a recognize-act cycle.
The working memory contains the description of the current state of problems-
solving and rule can write knowledge to the working memory. This knowledge
match and may fire other rules.
If there is a new situation (state) generates, then multiple production rules will be
fired together, this is called conflict set. In this situation, the agent needs to select
a rule from these sets, and it is called a conflict resolution.
Example:
o IF (at bus stop AND bus arrives) THEN action (get into the bus)
o IF (on the bus AND paid AND empty seat) THEN action (sit down).
o IF (on bus AND unpaid) THEN action (pay charges).
o IF (bus arrives at destination) THEN action (get down from the bus).
46. Production rule system does not exhibit any learning capabilities, as it does
not store the result of the problem for the future uses.
47. During the execution of the program, many rules may be active hence rule-
based production systems are inefficient.
Propositional logic (PL) is the simplest form of logic where all the statements are
made by propositions. A proposition is a declarative statement which is either true
or false. It is a technique of knowledge representation in logical and mathematical
form.
Example:
1. It is Sunday.
2. The Sun rises from West (False proposition)
4. 5 is a prime number.
The syntax of propositional logic defines the allowable sentences for the
knowledge representation. There are two types of Propositions:
Example:
Logical Connectives:
Truth Table:
Precedence of connectives:
Precedence Operators
First Precedence Parenthesis
Second Precedence Negation
Third Precedence Conjunction(AND)
Fourth Precedence Disjunction(OR)
Fifth Precedence Implication
Six Precedence Biconditional
Logical equivalence:
Let's take two propositions A and B, so for logical equivalence, we can write it as
A⇔B. In below truth table we can see that column for ¬A∨ B and A→B, are identical
hence A is Equivalent to B
Properties of Operators:
o Commutativity:
o P∧ Q= Q ∧ P, or
o P ∨ Q = Q ∨ P.
o Associativity:
o (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
o (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
o Identity element:
o P ∧ True = P,
o P ∨ True= True.
o Distributive:
o P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
o P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
o DE Morgan's Law:
o ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
o ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
o Double-negation elimination:
o ¬ (¬P) = P.
Inference:
In artificial intelligence, we need intelligent computers which can create new logic
from old logic or by evidence, so generating the conclusions from evidence and
facts is termed as Inference.
Inference rules:
Inference rules are the templates for generating valid arguments. Inference rules
are applied to derive proofs in artificial intelligence, and the proof is a sequence of
the conclusion that leads to the desired goal.
In inference rules, the implication among all the connectives plays an important
role. Following are some terminologies related to inference rules:
From the above term some of the compound statements are equivalent to each
other, which we can prove using truth table:
Hence from the above truth table, we can prove that P → Q is equivalent to ¬ Q →
¬ P, and Q→ P is equivalent to ¬ P → ¬ Q.
1. Modus Ponens:
The Modus Ponens rule is one of the most important rules of inference, and it
states that if P and P → Q is true, then we can infer that Q will be true. It can be
represented as:
Example:
Hence, we can say that, if P→ Q is true and P is true then Q will be true.
2. Modus Tollens:
The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then ¬ P will also
true. It can be represented as:
3. Hypothetical Syllogism:
The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true,
and Q→R is true. It can be represented as the following notation:
Example:
Statement-1: If you have my home key then you can unlock my home. P→Q
Statement-2: If you can unlock my home then you can take my money. Q→R
Conclusion: If you have my home key then you can take my money. P→R
4. Disjunctive Syllogism:
The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true, then Q will
be true. It can be represented as:
Example:
Proof by truth-table:
5. Addition:
The Addition rule is one the common inference rule, and it states that If P is true,
then P∨Q will be true.
Example:
Proof by Truth-Table:
6. Simplification:
The simplification rule state that if P∧ Q is true, then Q or P will also be true. It
can be represented as:
Proof by Truth-Table:
7. Resolution:
The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will also be
true. It can be represented as
Proof by Truth-Table:
Lecture 2.1.4 Predicate Logics
•
In the topic of Propositional logic, we have seen that how to represent statements
using propositional logic. But unfortunately, in propositional logic, we can only
represent the facts, which are either true or false. PL is not sufficient to represent
the complex sentences or natural language statements. The propositional logic has
very limited expressive power. Consider the following sentence, which we cannot
represent using PL logic.
First-Order logic:
Atomic sentences:
o Atomic sentences are the most basic sentences of first-order logic. These
sentences are formed from a predicate symbol followed by a parenthesis
with a sequence of terms.
o We can represent atomic sentences as Predicate (term1, term2, ......,
term n).
Complex Sentences:
o Complex sentences are made by combining atomic sentences using
connectives.
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.
oFor all x
oFor each x
oFor every x.
Example:
Let a variable x which refers to a cat so all x can be represented in UOD as below:
It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the
statement within its scope is true for at least one instance of something.
It will be read as: There are some x where x is a boy who is intelligent.
Points to remember:
Properties of Quantifiers:
The quantifiers interact with variables which appear in a suitable way. There are
two types of variables in First-order logic which are given below:
Free Variable: A variable is said to be a free variable in a formula if it occurs
outside the scope of the quantifier.
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
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:
At the second level, we will examine the circuit structure details such as:
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:
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 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.
We use a unary predicate On (t), which is true if the signal at a terminal is on.
To encode the general knowledge about the logic circuit, we need some following
rules:
o If two terminals are connected then they have the same input signal, it can
be represented as:
∀ t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1) = Si
gnal (2).
o Signal at every terminal will have either value 0 or 1, it will berepresented
as:
52.
o Connect predicates are commutative:
o Output of AND gate will be zero if and only if any of its input is zero.
∀ g Gate(g) ∧ Type(g) = XOR → Signal (Out(1, g)) = 1 ⇔ Signal (In(1, g)) ≠ Signal
(In(2, g)).
o All the gates in the above circuit have two inputs and one output (except
NOT gate).
∀ g Gate(g) ∧ r =Type(g) ∧ (r= AND ∨r= OR ∨r= XOR) → Arity (g, 2, 1).
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:
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?
1. ∃ i1, i2, i3 Signal (In(1, C1))=i1 ∧ Signal (In(2, C1))=i2 ∧ Signal (In(3, C1))= i
3
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.
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 in FOL.
Substitution:
Equality:
First-Order logic does not only use predicate and terms for making atomic sentences but also
uses another way, which is equality in FOL. For this, we can use equality symbols which
specify that the two terms refer to the same object.
As propositional logic we also have inference rules in first-order logic, so following are some
basic inference rules in FOL:
o Universal Generalization
o Universal Instantiation
o Existential Instantiation
o Existential introduction
1. Universal Generalization:
o 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).
o It can be represented as:
o This rule can be used if we want to show that every element has a similar property.
o 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.
2. Universal Instantiation:
Example: 2.
"All kings who are greedy are Evil." So let our knowledge base contains this detail as in the
form of FOL:
So from this information, we can infer any of the following statements using Universal
Instantiation:
3. Existential Instantiation:
Example:
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the
knowledge base.
For the inference process in FOL, we have a single inference rule which is called Generalized
Modus Ponens. It is lifted version of Modus ponens.
Generalized Modus Ponens can be summarized as, " P implies Q and P is asserted to be true,
therefore Q must be True."
According to Modus Ponens, for atomic sentences pi, pi', q. Where there is a substitution θ
such that SUBST (θ, pi',) = SUBST(θ, pi), it can be represented as:
Example:
We will use this rule for Kings are evil, so we will find some x such that x is king, and x
is greedy so we can infer that x is evil.
4. SUBST(θ,q).
Unification:
o Unification is a process of making two different logical atomic expressions identical
by finding a substitution. Unification depends on the substitution process.
o It takes two literals as input and makes them identical using substitution.
o Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that, Ψ1𝜎 = Ψ2𝜎, then
it can be expressed as UNIFY(Ψ1, Ψ2).
o Example: Find the MGU for Unify{King(x), King(John)}
Substitution θ = {John/x} is a unifier for these atoms and applying this substitution, and both
expressions will be identical.
o The UNIFY algorithm is used for unification, which takes two atomic sentences and
returns a unifier for those sentences (If any exist).
o Unification is a key component of all first-order inference algorithms.
o It returns fail if the expressions do not match with each other.
o The substitution variables are called Most General Unifier or MGU.
E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)).
In this example, we need to make both above statements identical to each other. For this, we
will perform the substitution.
o Substitute x with a, and y with f(z) in the first expression, and it will be represented
as a/x and f(z)/y.
o With both the substitutions, the first expression will be identical to the second
expression and the substitution set will be: [a/x, f(z)/y].
Conditions for Unification:
o Predicate symbol must be same, atoms or expression with different predicate symbol
can never be unified.
o Number of Arguments in both expressions must be identical.
o Unification will fail if there are two similar variables present in the same expression.
Unification Algorithm:
c) Else if Ψ2 is a variable,
a. If Ψ2 occurs in Ψ1 then return FAILURE,
Step.2: If the initial Predicate symbol in Ψ1 and Ψ2 are not same, then return FAILURE.
a) Call Unify function with the ith element of Ψ1 and ith element of Ψ2, and put the result
into S.
b. If one expression is a variable vi, and the other is a term ti which does not contain
variable vi, then:
c. If both the expressions are functions, then function name must be similar, and the
number of arguments must be the same in both the expression.
For each pair of the following atomic sentences find the most general unifier (If exist).
SUBST θ= {f(a) / X}
SUBST θ={b/Z}
SUBST θ= {X/Z}
SUBST θ= {11/y}
Unifier: {11/y}.
5. Find the MGU of Q(a, g(x, a), f(y)), Q(a, g(f(b), a), x)}
SUBST θ= {f(b)/x}
S1 => {Q(a, g(f(b), a), f(y)); Q(a, g(f(b), a), f(b))}
SUBST θ= {b/y}
S1 => {Q(a, g(f(b), a), f(b)); Q(a, g(f(b), a), f(b))}, Successfully Unified.
SUBST θ= {John/x}
Unifier: {John/x}.
Resolution
Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e.,
proofs by contradictions. It was invented by a Mathematician John Alan Robinson in the year
1965.
Resolution is used, if there are various statements are given, and we need to prove a
conclusion of those statements. Unification is a key concept in proofs by resolutions.
Resolution is a single inference rule which can efficiently operate on the conjunctive normal
form or clausal form.
Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also known as a unit
clause.
The resolution rule for first-order logic is simply a lifted version of the propositional rule.
Resolution can resolve two clauses if they contain complementary literals, which are assumed
to be standardized apart so that they share no variables.
Where li and mj are complementary literals.
This rule is also called the binary resolution rule because it only resolves exactly two literals.
Example:
Where two complimentary literals are: Loves (f(x), x) and ¬ Loves (a, b)
These literals can be unified with unifier θ= [a/f(x), and b/x] , and it will generate a resolvent
clause:
To better understand all the above steps, we will take an example in which we will apply
resolution.
Example:
In the first step we will convert all the given statements into its first order logic.
In First order logic resolution, it is required to convert the FOL into CNF as CNF form makes
easier for resolution proofs.
Eliminate all implication (→) and rewrite
∀x ¬ food(x) V likes(John, x)
food(Apple) Λ food(vegetables)
∀x ¬ eats(Anil, x) V eats(Harry, x)
∀x ¬ alive(x) V ¬ killed(x)
likes(John, Peanuts).
∀x ¬ food(x) V likes(John, x)
food(Apple) Λ food(vegetables)
∀x ¬ eats(Anil, x) V eats(Harry, x)
∀x ¬killed(x) ] V alive(x)
∀x ¬ alive(x) V ¬ killed(x)
likes(John, Peanuts).
∀x ¬ food(x) V likes(John, x)
food(Apple) Λ food(vegetables)
∀g ¬killed(g) ] V alive(g)
∀k ¬ alive(k) V ¬ killed(k)
likes(John, Peanuts).
In this step we will drop all universal quantifier since all the statements are not implicitly
quantified so we don't need it.
¬ food(x) V likes(John, x)
food(Apple)
food(vegetables)
alive(Anil)
¬ eats(Anil, w) V eats(Harry, w)
killed(g) V alive(g)
¬ alive(k) V ¬ killed(k)
likes(John, Peanuts).
In this statement, we will apply negation to the conclusion statements, which will be written
as ¬likes(John, Peanuts)
Now in this step, we will solve the problem by resolution tree using substitution. For the above
problem, it will be given as follows:
Hence the negation of the conclusion has been proved as a complete contradiction with the
given set of statements.
Example: Following are some statements which we need to represent in the form of nodes
and arcs.
Statements:
2. Jerry is a cat.
3. Jerry is a mammal
4. Jerry is owned by Priya.
5. Jerry is brown colored.
6. All Mammals are animal.
In the above diagram, we have represented the different type of knowledge in the form of
nodes and arcs. Each object is connected with another object by some relation.
3. Frame Representation
A frame is a record like structure which consists of a collection of attributes and its values to
describe an entity in the world. Frames are the AI data structure which divides knowledge
into substructures by representing stereotypes situations. It consists of a collection of slots
and slot values. These slots may be of any type and sizes. Slots have names and values which
are called facets.
Facets: The various aspects of a slot is known as Facets. Facets are features of frames which
enable us to put constraints on the frames. Example: IF-NEEDED facts are called when data of
any particular slot is needed. A frame may consist of any number of slots, and a slot may
include any number of facets and facets may have any number of values. A frame is also known
as slot-filter knowledge representation in artificial intelligence.
Frames are derived from semantic networks and later evolved into our modern-day classes
and objects. A single frame is not much useful. Frames system consist of a collection of frames
which are connected. In the frame, knowledge about an object or event can be stored together
in the knowledge base. The frame is a type of technology which is widely used in various
applications including Natural language processing and machine visions.
Example: 1
Slots Filters
Title Artificial Intelligence
Genre Computer Science
Author Peter Norvig
Edition Third Edition
Year 1996
Page 1152
Example 2:
Let's suppose we are taking an entity, Peter. Peter is an engineer as a profession, and his age
is 25, he lives in city London, and the country is England. So following is the frame
representation for this:
Slots Filter
Name Peter
Profession Doctor
Age 25
Marital status Single
Weight 78
15. The frame knowledge representation makes the programming easier by grouping the
related data.
16. The frame representation is comparably flexible and used by many applications in AI.
17. It is very easy to add slots for new attribute and relations.
18. It is easy to include default data and to search for missing values.
19. Frame representation is easy to understand and visualize.
Conceptual Graphs (CG) is a logical formalism that includes classes, relations, individuals
and quantifiers. This formalism is based on semantic networks, but it has direct translation
to the language of first order predicate logic, from which it takes its semantics. The main
feature is standardized graphical representation that like in the case of semantic networks
allows human to get quick overview of what the graph means. Conceptual graph is a
bipartite orientated graph where instances of concepts are displayed as rectangle and
conceptual relations are displayed as ellipse. Oriented edges then link these vertices and
denote the existence and orientation of relation. A relation can have more than one edges, in
which case edges are numbered. An example of a graphical representation, so called Display
Form (DF), of a sentence "a cat is on a mat" is shown in the figure below.
Simple conceptual graph in the graphical representation DF
Using textual notation Linear Form (LF) this sentence would be written as
[Cat]-(On)-[Mat]
DF and LF are intended as representation (and presentation) formats for human. There is
also a formal language CG Interchange Form (CGIF) defined. In this language the sentence
would be expressed as
The conversion between the three languages is defined as well as direct conversion between
CGIF and KIF (Knowledge Interchange Format, see next section). In the KIF language this
example would be expressed as
All these forms have the same semantics in the predicate logic:
Conceptual graphs have the same expressing power as predicate logic. As we have seen
there is again a possibility to define concepts (i.e., ontology) and then use them to express
particular state of affairs.
Lecture 2.2.1 AI Learning Models
• Learning is one of the fundamental building blocks of artificial intelligence (AI) solutions.
From a conceptual standpoint, learning is a process that improves the knowledge of an AI
program by making observations about its environment. From a technical/mathematical
standpoint, AI learning processes focused on processing a collection of input-output pairs for
a specific function and predict the outputs for new inputs. Most of the artificial intelligence
(AI) basic literature identifies two main groups of learning models:
o Supervised and
o Unsupervised.
To understand the different types of AI learning models, we can use two of the main elements
of human learning processes:
o knowledge and
o Feedback.
From the knowledge perspective, learning models can be classified based on the
representation of input and output data points.
In terms of the feedback, AI learning models can be classified based on the interactions with
the outside environment, users and other external factors.
Factoring its representation of knowledge, AI learning models can be classified in two main
types: inductive and deductive.
— Inductive Learning: This type of AI learning model is based on inferring a general rule
from datasets of input-output pairs.. Algorithms such as knowledge based inductive
learning(KBIL) are a great example of this type of AI learning technique. KBIL focused on
finding inductive hypotheses on a dataset with the help of background information.
— Deductive Learning: This type of AI learning technique starts with te series of rules nad
infers new rules that are more efficient in the context of a specific AI algorithm. Explanation-
Based Learning(EBL) and Relevance-0Based Learning(RBL) are examples examples o f
deductive techniques. EBL extracts general rules from examples by “generalizing” the
explanation. RBL focuses on identifying attributes and deductive generalizations from simple
example.
General Learning Model: Learning can be accomplished using a number of different methods,
such as by memorization facts, by being told, or by studying examples like problem solution.
Learning requires that new knowledge structures be created from some form of input
stimulus. This new knowledge must then be assimilated into a knowledge base and be tested
in some way for its utility.
Testing means that the knowledge should be used in performance of some task from which
meaningful feedback can be obtained, where the feedback provides some measure of the
accuracy and usefulness of the newly acquired knowledge.
General learning model is depicted in the above figure, where the environment has been
included as a part of the overall learner system. The environment may be regarded as either
a form of nature which produces random stimuli or as a more organized training source such
as a teacher which provides carefully selected training examples for the learner component.
The actual form of environment used will depend on the particular learning paradigm. In any
case, some representation language must be assumed for communication between the
environment and the learner.
The language may be the same representation scheme as that used in the knowledge base
(such as a form of predicate calculus). When they are chosen to be the same, we say the single
representation trick is being used. This usually results in a simpler implementation since it is
not necessary to transform between two or more different representations.
For some systems the environment may be a user working at a keyboard . Other systems will
use program modules to simulate a particular environment. In even more realistic cases the
system will have real physical sensors which interface with some world environment.
Inputs to the learner component may be physical stimuli of some type or descriptive , symbolic
training examples. The information conveyed to the learner component is used to create and
modify knowledge structures in the knowledge base. This same knowledge is used by the
performance component to carry out some tasks, such as solving a problem playing a game,
or classifying instances of some concept.
given a task, the performance component produces a response describing its action in
performing the task. The critic module then evaluates this response relative to an optimal
response.
Feedback , indicating whether or not the performance was acceptable , is then sent by the
critic module to the learner component for its subsequent use in modifying the structures in
the knowledge base. If proper learning was accomplished, the system’s performance will have
improved with the changes made to the knowledge base.
The cycle described above may be repeated a number of times until the performance of the
system has reached some acceptable level, until a known learning goal has been reached, or
until changes ceases to occur in the knowledge base after some chosen number of training
examples have been observed.
There are several important factors which influence a system’s ability to learn in addition to
the form of representation used. They include the types of training provided, the form and
extent of any initial background knowledge , the type of feedback provided, and the learning
algorithms used.
The type of training used in a system can have a strong effect on performance, much the same
as it does for humans. Training may consist of randomly selected instance or examples that
have been carefully selected and ordered for presentation. The instances may be positive
examples of some concept or task a being learned, they may be negative, or they may be
mixture of both positive and negative. The instances may be well focused using only relevant
information, or they may contain a variety of facts and details including irrelevant data.
There are Many forms of learning can be characterized as a search through a space of possible
hypotheses or solutions. To make learning more efficient. It is necessary to constrain this
search process or reduce the search space. One method of achieving this is through the use of
background knowledge which can be used to constrain the search space or exercise control
operations which limit the search process.
Feedback is essential to the learner component since otherwise it would never know if the
knowledge structures in the knowledge base were improving or if they were adequate for the
performance of the given tasks.
The feedback may be a simple yes or no type of evaluation, or it may contain more useful
information describing why a particular action was good or bad. Also , the feedback may be
completely reliable, providing an accurate assessment of the performance or it may contain
noise, that is the feedback may actually be incorrect some of the time. Intuitively , the feedback
must be accurate more than 50% of the time; otherwise the system carries useful information,
the learner should also to build up a useful corpus of knowledge quickly. On the other hand, if
the feedback is noisy or unreliable, the learning process may be very slow and the resultant
knowledge incorrect.
The Stochastic Automaton represents one approach to machine learning that is useful in a
variety of situations involving learning from examples, or learning by doing.The stochastic
automaton tries to reach a solution to a problem without any information about the optimal
action. By interacting with an Environment, a stochastic automaton can be used to learn the
optimal action offered by that Environment. A random action is selected, based on a
probability vector, and then from the observation of the Environment’s response, the action
probabilities are updated, and the procedure is repeated. A stochastic automaton that behaves
in this way to improve its performance is called a learning automaton (LA). The learning
approach that LA use may be described as learning by doing.
o Deterministic,
o Fixed structure stochastic, and
o Variable structure stochastic.
For deterministic automata, the transition and the output matrices are deterministic. For
fixed structure stochastic automata (FSSA), their transitions are determined by state
transition probabilities that are fixed with time , Variable structure stochastic automata
(VSSA) have a stochastic transition matrix whose transition probabilities or action
probabilities are adjusted as the learning system operates.
Basic Mathematical Definition
Models in which the output of the Environment can take only one of two values (0 and 1 for
example) are referred to as P-models. In 5-models, the output can take the form of a
continuous random variable in the interval [0, 1].
In Q-models, the Environment output can have discrete values in the interval [0, 1], for
example {0, 0.1, 0.2,...} or {0, 0.05, 0.10, 0.15,....... }.
The following is the mathematical definition of the LA model (FSSA in the model
Environment). This includes the definition of the automaton, the interacting Environment, the
objectives of this interaction, and the learning method.
Lecture 2.2.5 INDUCTIVE LEARNING
• INDUCTIVE LEARNING
This involves the process of learning by example -- where a system tries to induce a general
rule from a set of observed instances.
This involves classification -- assigning, to a particular input, the name of a class to which it
belongs. Classification is important to many problem solving tasks.
Formally, Inductive Learning in supervised learning we have a set of {xi, f (xi)} for 1≤i≤n, and
our aim is to determine 'f' by some adaptive algorithm. It is a machine learning approach in
which rules are inferred from facts or data.
In logic, reasoning from the specific to the general Conditional or antecedent reasoning.
Theoretical results in machine learning mainly deal with a type of inductive learning called
supervised learning. In supervised learning, an algorithm is given samples that are labeled in
some useful way.
In case of inductive learning algorithms, like artificial neural networks, the real robot may
learn only from previously gathered data. Another option is to let the bot learn everything
around him by inducing facts from the environment. This is known as inductive learning.
Finally, you could get the bot to evolve, and optimise his performance over several
generations.
F(x) gives a training set of examples D = {[xi,f(xi) ]}, i = 1,2,…,N Construct h so that it agrees
with f.
· Inductive Learning, also known as Concept Learning , is how AI systems attempt to use a
generalized rule to carry out observations.
· To generate a set of classification rules, Inductive Learning Algorithms (APIs) are used.
These generated rules are in the “If this then that” format.
· These rules determine the state of an entity at each iteration step in Learning and how the
Learning can be effectively changed by adding more rules to the existing ruleset.
· When the output and examples of the function are fed into the AI system, inductive
Learning attempts to learn the function for new data.
Examples:
2. Disease diagnosis.
3. Face recognition.
· The f(x) is the degree to which the steering wheel should be turned.
There are basically two methods for knowledge extraction firstly from domain experts and
then with machine learning.
For a very large amount of data, the domain experts are not very useful and reliable. So we
move towards the machine learning approach for this work.
To use machine learning One method is to replicate the experts logic in the form of algorithms
but this work is very tedious, time taking and expensive.
So we move towards the inductive algorithms which itself generate the strategy for
performing a task and need not instruct separately at each step.
The ILA is a new algorithm which was needed even when other reinforcement learnings like
ID3 and AQ were available.
· The need was due to the pitfalls which were present in the previous algorithms, one of
the major pitfalls was lack of generalisation of rules.
· The ID3 and AQ used the decision tree production method which was too specific which
were difficult to analyse and was very slow to perform for basic short classification problems.
· The decision tree-based algorithm was unable to work for a new problem if some
attributes are missing.
· The ILA uses the method of production of a general set of rules instead of decision trees,
which overcome the above problems.
1. list the examples in the form of a table ‘T’ where each row corresponds to an example and
each column contains an attribute value.
2. create a set of m training examples, each example composed of k attributes and a class
attribute with n possible decisions.
3. create a rule set, R, having the initial value false.
Step 1:
divide the table ‘T’ containing m examples into n sub-tables (t1, t2,…..tn). One table for each
possible value of the class attribute. (repeat steps 2-8 for each sub-table)
Step 2:
Step 3:
For the sub-table on which work is going on, divide the attribute list into distinct
combinations, each combination with ‘j ‘ distinct attributes.
Step 4:
For each combination of attributes, count the number of occurrences of attribute values that
appear under the same combination of attributes in unmarked rows of the sub-table under
consideration, and at the same time, not appears under the same combination of attributes of
other sub-tables. Call the first combination with the maximum number of occurrences the
max-combination ‘ MAX’.
Step 5:
Step 6:
Mark all rows of the sub-table where working, in which the values of ‘MAX’ appear, as
classi?ed.
Step 7:
Add a rule (IF attribute = “XYZ” –> THEN decision is YES/ NO) to R whose left-hand side will
have attribute names of the ‘MAX’ with their values separated by AND, and its right-hand side
contains the decision attribute value associated with the sub-table.
Step 8:
If all rows are marked as classi?ed, then move on to process another sub-table and go to Step
2. else, go to Step 4. If no sub-tables are available, exit with the set of rules obtained till then.
suppose an example set having attributes Place type, weather, location, decision and seven
examples, our task is to generate a set of rules that under what condition what is the decision.
\
Example no. Place type Weather Location Decision
I) hilly winter kullu Yes
II ) mountain windy Mumbai No
III ) mountain windy Shimla Yes
IV ) beach windy Mumbai No
V) beach warm goa Yes
VI ) beach windy goa No
VII ) beach warm Shimla Yes
step 1
subset 1
subset 2
Step (2-8)
at iteration 1
row 3 & 4 column weather is selected and row 3 & 4 are marked.
at iteration 2
the rule is added to R IF place type is hilly then the decision is yes.
at iteration 3
row 2 column location is selected and row 2 is marked.
at iteration 4
row 5&6 column location is selected and row 5&6 are marked.
at iteration 5
row 7 column place type & the weather is selected and row 7 is marked.
rule is added to R IF place type is beach AND weather is windy then the decision is no.
Rule Set
· Rule 5: IF place type is beach AND the weather is windy THEN the decision is no.