0% found this document useful (0 votes)
18 views86 pages

Ai Unit 4aad

The document discusses knowledge-based agents and their components. Knowledge-based agents have two main parts: a knowledge base and an inference system. The knowledge base stores the agent's knowledge about the world. The inference system allows the agent to derive new knowledge from what is stored in the knowledge base. An example of a knowledge-based agent domain discussed is the Wumpus World, where an agent must navigate a cave to find gold without falling in pits or being eaten by a monster.

Uploaded by

Ruchita Amale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views86 pages

Ai Unit 4aad

The document discusses knowledge-based agents and their components. Knowledge-based agents have two main parts: a knowledge base and an inference system. The knowledge base stores the agent's knowledge about the world. The inference system allows the agent to derive new knowledge from what is stored in the knowledge base. An example of a knowledge-based agent domain discussed is the Wumpus World, where an agent must navigate a cave to find gold without falling in pits or being eaten by a monster.

Uploaded by

Ruchita Amale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86

Unit 4

Knowledge
-A.A.Deshpande
Knowledge Based Reasoning: Agents

• 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.
• Knowledge-based agents are composed of two main parts:
• Knowledge-base and
• Inference system.
Knowledge-based Agent

• Knowledge base: Knowledge-base is a central component of a knowledge-


based agent, it is also known as KB. It is a collection of sentences
• Required for updating knowledge for an agent to learn with experiences
and take action accordingly.
• Inference system
• Inference means deriving new sentences from old. Inference system allows
us to add a new sentence to the knowledge base.
Operations Performed by KBA
Following are three operations which are performed by KBA in order to
show the intelligent behavior:
1.TELL: This operation tells the knowledge base what it perceives from the
environment.
2.ASK: This operation asks the knowledge base what action it should
perform.
3.Perform: It performs the selected action.
A generic knowledge-based agent:
• Takes a percept as input and returns an
action.
• The agent maintains a knowledge base,
KB , which may initially contain some
background knowledge.
Each time the agent program is called, it
does three things.
1. it TELLS the knowledge base what it
perceives.
2. it ASKS the knowledge base what action
it should perform.
3. the agent records its choice with TELL
and executes the action.
Knowledge-Based Agent Program

• MAKE-PERCEPT-SENTENCE constructs a sentence asserting that the agent


perceived the given percept at the given time.
• MAKE-ACTION-QUERY constructs a sentence that asks what action should
be done at the current time.
• Finally, MAKE-ACTION-SENTENCE constructs a sentence asserting that the
chosen action was executed.
Wumpus World
• The Wumpus world is a cave which has 4/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 Pit rooms which are
bottomless, and if agent falls in Pits, then he will be stuck
there forever.
• There is a possibility of finding a heap of gold. So the agent’s
goal is to find the gold and climb out the cave without falling
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.
• The rooms adjacent to the Wumpus room are smelly, so
that it would have some stench.
• The room adjacent to PITs has a breeze, so if the agent
reaches near to PIT, then he will perceive the breeze.
• There will be glitter in the room if and only if the room
has gold.
• The Wumpus can be killed by the agent if the agent is
facing to it, and Wumpus will emit a horrible scream
which can be heard anywhere in the cave.
Note: Here Wumpus is static
Wumpus World PEAS
Performance measure:
• +1000 reward points if the agent comes out of the cave with the gold.
• -1000 points penalty for being eaten by the Wumpus or falling into the pit.
• -1 for each action, and -10 for using an arrow.
• The game ends if either agent dies or came out of the cave.
Environment:
• A 4*4 grid of rooms.
• The agent initially in room square [1, 1], facing toward the right.
• Location of Wumpus and gold are chosen randomly except the first square
[1,1].
• Each square of the cave can be a pit with probability 0.2 except the first
square.
Actuators:
• Left turn,
• Right turn
• Move forward
• Grab
• Release
• Shoot.
Sensors:
• The agent will perceive the stench if he is in the room
adjacent to the Wumpus. (Not diagonally).
• The agent will perceive breeze if he is in the room
directly adjacent to the Pit.
• The agent will perceive the glitter in the room where the
gold is present.
• The agent will perceive the bump if he walks into a wall.
• When the Wumpus is shot, it emits a
horrible scream which can be perceived anywhere in the
cave.
• These percepts can be represented as five element list,
in which we will have different indicators for each
sensor.
• The percept is a list of 5 symbols:
[Stench, Breeze, Glitter, Bump, Scream]
• Example if agent perceives stench, breeze, but no glitter,
no bump, and no scream then it can be represented as:
[Stench, Breeze, None, None, None].
The Wumpus world Properties

• 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
• 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
Exploring the Wumpus world

Agent's First step:


• Initially, the agent is in the first
room or on the square [1,1], and
we already know that this room is
safe for the agent
• At Room [1,1] agent does not feel
any breeze or any Stench which
means the adjacent squares are
also OK.
• Agent's second Step:
• Now agent needs to move forward, so it
will either move to [1, 2], or [2,1]. Let's
suppose agent moves to the room [2, 1], at
this room agent perceives some breeze
which means Pit is around this room. The
pit can be in [3, 1], or [2,2], so we will add
symbol P? to say that, is this Pit room
• Now agent will stop and think and will not
make any harmful move. The agent will go
back to the [1, 1] room. The room [1,1], and
[2,1] are visited by the agent, so we will use
symbol V to represent the visited squares.
• Agent's third step:
• At the third step, now agent will move to
the room [1,2] which is OK. In the room
[1,2] agent perceives a stench which means
there must be a Wumpus nearby. But
Wumpus cannot be in the room [1,1] as by
rules of the game, and also not in [2,2]
(Agent had not detected any stench when
he was at [2,1]).
• Therefore agent infers that Wumpus is in
the room [1,3], and in current state, there is
no breeze which means in [2,2] there is no
Pit and no Wumpus. So it is safe, and we will
mark it OK, and the agent moves further in
[2,2].
• Agent's fourth step:
• At room [2,2], here no stench and
no breezes present so let's suppose
agent decides to move to [2,3]. At
room [2,3] agent perceives glitter,
so it should grab the gold and
climb out of the cave.
Logic and Inferences: Formal Logic, Propositional and First
Order Logic, Resolution in Propositional and First Order Logic,
Deductive Retrieval, Backward Chaining, Second order Logic.
Logic
• Logic is the primary vehicle for representing and
reasoning about knowledge.
▪Syntax defines the sentences in language
▪Semantics define the "meaning" of sentences;
• Specifically, we will be dealing with formal logic.
• The advantage of using formal logic as a language of AI is
that it is precise and definite.
Logic
• A logic consists of two parts, a language and a method
of reasoning.
• The logical language, in turn, has two aspects, syntax
and semantics.
• Thus, to specify or define a particular logic, one needs
to specify three things:
• Syntax
• Semantics
• Syntactic Inference Method
Logic
• Syntax: specifies the symbols in the language and
how they can be combined to form sentences.
• Semantics: specifies the meaning of the symbols in
the language.
• Syntactic Inference Method: The rules for
determining a subset of logical expressions, called
theorems of the logic. It refers to mechanical method
for computing (deriving) new (true) sentences from
existing sentences.
Formal Logic
• Machinery for realizing reasoning
• Given a set of statements taken to be true, determines what other
statements can be argued to be true
• The logical nature and validity of argument depends only on the form
of the argument.
• Doesn’t depend on the content
E.g.: From: "All men are mortal”
And: ”Socrates is a man”
Infer: ”Socrates is mortal ”
From: “All soccer stars are rich”
And: ”Steven is a soccer star”
Infer: ”Steven is rich”
Entailment

• Entailment means that one thing follows from another:


KB ╞ α
• Knowledge base KB entails sentence α if and only if α is true in all worlds
where KB is true

• E.g., the KB containing “the Giants won” and “the Reds won”
entails “Either the Giants won or the Reds won”
• E.g., x+y = 4 entails 4 = x+y
Entailment
Inference(Guess,idea,conclusion)

• An inference is an idea or conclusion that's drawn from evidence and


reasoning.
• In understanding entailment and inference, it might help to think of the
set of all consequences of KB as a haystack and of α as a needle.
• Entailment is like the needle being in the haystack; inference is like
finding it.
Propositional Logic
• 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:
a) It is Sunday.
b) The Sun rises from West (False proposition)
c) 3+3= 7(False proposition)
d) 5 is a prime number.
Propositional Logic Syntax
• The syntax of propositional logic defines the allowable sentences for the
knowledge representation. There are two types of Propositions:
1.Atomic Propositions
2.Compound propositions
Atomic Proposition: Atomic propositions are the simple propositions. It consists of a
single proposition symbol. These are the sentences which must be either true or
false.
Example:
1.a) 2+2 is 4, it is an atomic proposition as it is a true fact.
2.b) "The Sun is cold" is also a proposition as it is a false fact.
Compound proposition: Compound propositions are constructed by combining
simpler or atomic propositions, using parenthesis and logical connectives.
Example:
1.a) "It is raining today, and street is wet."
2.b) "Ankit is a doctor, and his clinic is in Mumbai."
Logical Connectives
Logical connectives are used to connect two simpler propositions or
representing a sentence logically. We can create compound propositions
with the help of logical connectives. There are mainly five connectives,
which are given as follows:
1.Negation: A sentence such as ¬ P is called negation of P. A literal can be
either Positive literal or negative literal.
2.Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called
a conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
1.Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called
disjunction, where P and Q are the propositions.
Example: “XYZ is a doctor or Engineer",
Here P= XYZ is Doctor. Q= XYZ is Doctor, so we can write it as P ∨ Q.
2.Implication: A sentence such as P → Q, is called an implication.
Implications are also known as if-then rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
3.Biconditional: A sentence such as P⇔ Q is a Biconditional sentence,
Example: If I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
Summarized table for Propositional Logic Connectives
• Truth Table:
Precedence of connectives
Logical equivalence:
• Logical equivalence is one of the features of propositional logic. Two
propositions are said to be logically equivalent if and only if the columns
in the truth table are identical to each other.
• 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: • Distributive:
• Commutativity: • P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
• P∧ Q= Q ∧ P, or • P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
• P ∨ Q = Q ∨ P. • DE Morgan's Law:
• Associativity: • ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
• (P ∧ Q) ∧ R= P ∧ (Q ∧ R), • ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
• (P ∨ Q) ∨ R= P ∨ (Q ∨ R) • Double-negation elimination:
• Identity element: • ¬ (¬P) = P.
• P ∧ True = P,
• P ∨ True= True.
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.
Reasoning Pattern in Propositional logic
• The patterns of inference are called inference rules.
• Patterns of inference that can be applied to derive chains of conclusions that lead to the
desired goal.

Types of Inference rules:


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:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true. Slide 99
2. Modus Tollens:
• The Modus Tollens rule states that if P→ Q is true and ¬ Q is true,
then ¬ P will also be true. It can be represented as:

Statement-1: "If I am sleepy then I go to bed" ==> P→ Q


Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not sleepy" => ~P
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:
Statement-1: Today is Sunday or Monday. ==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
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:
• Statement: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)
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:
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
Resolution in FOL
• Resolution is a theorem proving technique that proceeds by building
refutation proofs, i.e., proofs by contradictions.
• Resolution is used, if there are various statements 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.
• Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said to
be conjunctive normal form or CNF.
• The resolution inference rule:
• 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:
We can resolve two clauses which are given below:
[Animal (g(x) V Loves (f(x), x)] and [¬ Loves(a, b) V ¬Kills(a,
b)]
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:
[Animal (g(x) V ¬ Kills(f(x), x)].
• Steps for Resolution:
1.Conversion of facts into first-order logic.
2.Convert FOL statements into CNF
3.Negate the statement which needs to prove (proof by contradiction)
4.Draw resolution graph (unification).
• Step-1: Conversion of Facts into FOL
• Example: • In the first step we will convert all the given
1.John likes all kind of food. statements into its first order logic.

2.Apple and vegetable are food


3.Anything anyone eats and not
killed is food.
4.Anil eats peanuts and still alive
5.Harry eats everything that Anil
eats.
Prove by resolution that:
6.John likes peanuts.
• Step-2: Conversion of FOL into CNF • Move negation (¬)inwards and
• In First order logic resolution, it is required rewrite
to convert the FOL into CNF as CNF form • ∀x ¬ food(x) V likes(John, x)
makes easier for resolution proofs
• food(Apple) Λ food(vegetables)
• Eliminate all implication (→) and rewrite • ∀x ∀y ¬ eats(x, y) V killed(x) V food(y)
• ∀x ¬ food(x) V likes(John, x) • eats (Anil, Peanuts) Λ alive(Anil)
• food(Apple) Λ food(vegetables)
• ∀x ¬ eats(Anil, x) V eats(Harry, x)
• ∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)
• eats (Anil, Peanuts) Λ alive(Anil) • ∀x ¬killed(x) ] V alive(x)
• ∀x ¬ eats(Anil, x) V eats(Harry, x) • ∀x ¬ alive(x) V ¬ killed(x)
• ∀x¬ [¬ killed(x) ] V alive(x) • likes(John, Peanuts).
• ∀x ¬ alive(x) V ¬ killed(x)
• likes(John, Peanuts).
• Rename variables or Eliminate existential instantiation
standardize variables quantifier by elimination.
• ∀x ¬ food(x) V likes(John, x) In this step, we will eliminate
• food(Apple) Λ food(vegetables) existential quantifier ∃, and this
• ∀y ∀z ¬ eats(y, z) V killed(y) V process is known
food(z) as Skolemization. But in this
• eats (Anil, Peanuts) Λ alive(Anil) example problem since there is no
• ∀w¬ eats(Anil, w) V eats(Harry, w) existential quantifier so all the
• ∀g ¬killed(g) ] V alive(g) statements will remain same in
• ∀k ¬ alive(k) V ¬ killed(k) this step.
• likes(John, Peanuts).
• Drop Universal quantifiers.
In this step we will drop all universal Distribute conjunction ∧ over
quantifier since all the statements are not disjunction ¬.
implicitly quantified so we don't need it. This step will not make any change in
• ¬ food(x) V likes(John, x) this problem.
• food(Apple)
• food(vegetables)
• ¬ eats(y, z) V killed(y) V food(z)
• eats (Anil, Peanuts)
• alive(Anil)
• ¬ eats(Anil, w) V eats(Harry, w)
• killed(g) V alive(g)
• ¬ alive(k) V ¬ killed(k)
• likes(John, Peanuts).
• Step-3: Negate the statement to
be proved
• In this statement, we will apply
negation to the conclusion
statements, which will be written
as ¬likes(John, Peanuts)
• Step-4: Draw Resolution graph:
• Now in this step, we will solve the
problem by resolution tree using
substitution. For the above
problem, it will be given as follows:
• Explanation of Resolution graph:
• In the first step of resolution graph, ¬likes(John, Peanuts) , and likes(John, x) get
resolved(canceled) by substitution of {Peanuts/x}, and we are left with ¬
food(Peanuts)
• In the second step of the resolution graph, ¬ food(Peanuts) , and food(z) get
resolved (canceled) by substitution of { Peanuts/z}, and we are left with ¬ eats(y,
Peanuts) V killed(y) .
• In the third step of the resolution graph, ¬ eats(y, Peanuts) and eats (Anil,
Peanuts) get resolved by substitution {Anil/y}, and we are left with Killed(Anil) .
• In the fourth step of the resolution graph, Killed(Anil) and ¬ killed(k) get resolve
by substitution {Anil/k}, and we are left with ¬ alive(Anil) .
• In the last step of the resolution graph ¬ alive(Anil) and alive(Anil) get resolved.
Conjunctive Normal Form
• A sentence expressed as a conjunction of disjunctions of literals
is said to be in conjunctive normal form or CNF.
• Resolution works best when the formula is of the special form: it
is an ∧ of ∨s of (possibly negated, ¬) variables (called literals )
Example
FIRST ORDER LOGIC
Limitations of Propositional logic

• 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.
• "Some humans are intelligent", or
• "Sachin likes cricket."
• To represent the above statements, PL logic is not sufficient, so we required
some more powerful logic, such as first-order logic.
First Order Logic
• Another way of knowledge representation in artificial intelligence: It is an extension to
propositional logic.
• FOL is sufficiently expressive to represent the natural language statements in a concise way.
• First-order logic is also known as Predicate logic or First-order predicate 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.
• First-order logic (like natural language) does not only assume that the world contains facts
like propositional logic but also assumes the following things in the world:
• Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
• Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation
such as: the sister of, brother of, has color, comes between
• Function: Father of, best friend, third inning of, end of, ......
• As a natural language, first-order logic also has two main parts:
• Syntax
• Semantics
Basic Elements of First-order logic:

Constants 1, 2, A, John, Mumbai, cat,....

Variables x, y, z, a, b,....

Predicates Brother, Father, >,....

Function sqrt, LeftLegOf, ....

Connectives ∧, ∨, ¬, ⇒, ⇔

Equality ==

Quantifier ∀, ∃
Term
• A term is a logical expression that refers to an object.
• Constant symbols are therefore terms.
• Expression "King John's left leg“ is converted into Left Leg(John).
• Consider a term = f (d1 ,. . . , dn).
• The function symbol f refers to some function in the model (call it f);
the argument terms refer to objects in the domain (call them d1, . . . ,
dn); and the term as a whole refers to the object that is the value of
the function f applied to d1, . . . , dn.
Atomic Sentences

• Now that we have both terms for referring to objects


and predicate symbols for referring to relations, we
can put them together to make atomic sentences that
state facts.
• Atomic Sentences = Predicate Symbols + terms
• An atomic sentence is formed from a predicate symbol
followed by a parenthesized list of terms:
• Brother(Richard, John).
Quantifiers in First-order logic:

• These are the symbols that permit to determine or identify the range
and scope of the variable in the logical expression. There are two
types of quantifiers:
• Universal Quantifier, (for all, everyone, everything)
• Existential quantifier, (for some, at least one).
Universal Quantifier:

• Universal quantifier is a symbol of logical representation, which


specifies that the statement within its range is true for everything or
every instance of a particular thing.
• The Universal quantifier is represented by a symbol ∀, which
resembles an inverted A.
• All men drink coffee.
• ∀x man(x) → drink (x, coffee).
• It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier:

• If x is a variable, then existential quantifier will be ∃x or ∃(x). And it


will be read as:
• There exists a 'x.'
• For some 'x.'
• For at least one 'x.'
Example:
• Some boys are intelligent.
• ∃x: boys(x) ∧ intelligent(x)
• It will be read as: There are some x where x is a boy who is intelligent.
• The main connective for universal quantifier ∀ is implication →.
• The main connective for existential quantifier ∃ is and ∧.
Properties of quantifiers

• ∀ x ∀ y is the same as ∀ y ∀ x
• ∃ x ∃ y is the same as ∃ y ∃ x
• ∃ x ∀ y is not the same as ∀ y ∃ x
• ∃ x ∀ y Loves(x, y): “There is a person who loves everyone in the
world”
• ∀ y ∃ x Loves(x, y): “Everyone in the world is loved by at least one
person”
Examples
1. All birds fly.
In this question the predicate is "fly(bird)."
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)," Since there are some boys so we will
use ∃, and it will be represented as:
∃x boys(x) → play(x, cricket).
(a) Not all cars have carburetors
(b) Some people are either religious or pious
(c) No dogs are intelligent
(d) All babies are illogical
(e) Every number is either negative or has a square root
(f) Some numbers are not real
(g) Every connected and circuit-free graph is a tree
(h) Not every graph is connected
(i) All that glitters is not gold
(j) Not all that glitters is gold
Inference rules in FOL
As propositional logic we also have inference rules in first-order logic, so following
are some basic inference rules in FOL:
• Universal Generalization
• Universal Instantiation
• Existential Instantiation
• Existential introduction
1.Universal Generalization
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.
2. Universal Instantiation:
• 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.
• The new KB is logically equivalent to the previous KB.
• 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:1.
• IF "Every person like ice-cream"=> ∀x P(x) so we can infer that
"John likes ice-cream" => P(c)
Example: 2.
• Let's take a famous example,
• "All kings who are greedy are Evil." So let our knowledge base contains this detail as
in the form of FOL:
∀x king(x) ∧ greedy (x) → Evil (x),
• So from this information, we can infer any of the following statements using
Universal Instantiation:
• King(John) ∧ Greedy (John) → Evil (John),
• King(Richard) ∧ Greedy (Richard) → Evil (Richard),
• King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John)),
3.Existential Instantiation:
• Existential instantiation is also called as Existential Elimination.
• 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:
4.Existential introduction
Existential introduction
• An existential introduction is also known as an existential
generalization.
• 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,


“ABC got good marks in English."
"Therefore, someone got good marks in English."
Knowledge Engineering in First-order logic
• The process of constructing a knowledge-base in first-order logic is
called as knowledge- engineering.
• In knowledge-engineering, someone who investigates a particular
domain, learns important concept of that domain, and generates a
formal representation of the objects, is known as knowledge
engineer.
• In this topic, we will understand the Knowledge engineering process
in an electronic circuit domain, which is already familiar.
• This approach is mainly suitable for creating special-purpose
knowledge base.
The knowledge-engineering process:
• 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
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?
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).
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.
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:
1.∀ t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1)
= Signal (2).
• Signal at every terminal will have either value 0 or 1, it will be
represented as:
1.∀ t Terminal (t) →Signal (t) = 1 ∨Signal (t) = 0.
• Connect predicates are commutative:
1.∀ t1, t2 Connect(t1, t2) → Connect (t2, t1).
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:
1.For XOR gate: Type(x1)= XOR, Type(X2) = XOR
2.For AND gate: Type(A1) = AND, Type(A2)= AND
3.For OR gate: Type (O1) = OR.
• And then represent the connections between all the gates.
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?
1.∃ i1, i2, i3 Signal (In(1, C1))=i1 ∧ Signal (In(2, C1))=i2 ∧ Signal (In(3, C
1))= i3
2. ∧ Signal (Out(1, C1)) =0 ∧ Signal (Out(2, C1))=1
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.

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