Endsem Imp Artificial Intelligence Unit - 4
Endsem Imp Artificial Intelligence Unit - 4
Q.1] List the inference rules used in prepositional logic? Explain them in detail
with suitable example.
ANS: In propositional logic, inference rules are used to derive new propositions from
existing ones. Here's a simplified explanation of some common inference rules along
with examples:
1. Modus Ponens:
o If we have a proposition of the form "if A then B" (A implies B), and we
know that A is true, then we can infer that B is true.
o Example:
Proposition 1: If it is raining, then the streets are wet. (A implies B)
Proposition 2: It is raining. (A)
Conclusion: Therefore, the streets are wet. (B)
2. Modus Tollens:
o If we have a proposition of the form "if A then B" (A implies B), and we
know that B is false, then we can infer that A is false.
o Example:
Proposition 1: If it is raining, then the streets are wet. (A implies B)
Proposition 2: The streets are not wet. (not B)
Conclusion: Therefore, it is not raining. (not A)
3. Hypothetical Syllogism:
o If we have two propositions of the form "if A then B" and "if B then C",
then we can infer "if A then C".
o Example:
Proposition 1: If it is raining, then the streets are wet. (A implies B)
Proposition 2: If the streets are wet, then people use umbrellas. (B
implies C)
Conclusion: Therefore, if it is raining, then people use umbrellas. (A
implies C)
4. Disjunctive Syllogism:
o If we have a disjunction (A or B), and one of the disjuncts is known to be
false (not A or not B), then we can infer the truth of the other disjunct.
o Example:
Proposition 1: Either it is raining or the sun is shining. (A or B)
Proposition 2: It is not raining. (not A)
Conclusion: Therefore, the sun is shining. (B)
5. Addition:
o If we have a proposition A, we can infer the disjunction "A or B" for any
proposition B.
o Example:
Proposition 1: It is raining. (A)
Conclusion: Therefore, it is raining or the sun is shining. (A or B)
Q.2] Explain syntax and semantics of First Order Logic in detail.
ANS: here's a breakdown of the syntax and semantics of First Order Logic (FOL) in a
simple and easy-to-understand point-wise format:
Syntax of First Order Logic:
1. Terms:
o Terms are basic building blocks representing objects or individuals in the
domain of discourse.
o They can be constants, variables, or functions applied to arguments.
o Constants represent specific objects (e.g., "John", "Mary").
o Variables represent unspecified objects (e.g., "x", "y").
o Functions take one or more arguments and return a term (e.g.,
"FatherOf(x)").
2. Predicates:
o Predicates represent properties or relations between objects.
o They are often denoted by symbols followed by arguments within
parentheses.
o Predicates can be unary (e.g., "IsAlive(x)"), binary (e.g., "Likes(x, y)"),
or n-ary (e.g., "Owns(x, y, z)").
3. Connectives:
o Connectives are logical operators used to combine atomic formulas to
form complex formulas.
o Common connectives include "AND" (∧), "OR" (∨), "NOT" (¬), "IMPLIES"
(→), and "IF AND ONLY IF" (↔).
4. Quantifiers:
o Quantifiers are used to specify the scope of variables in formulas.
o The universal quantifier (∀) indicates that a formula holds for all objects
in the domain.
o The existential quantifier (∃) indicates that a formula holds for at least
one object in the domain.
5. Formulas:
o Formulas in FOL are constructed using terms, predicates, connectives,
and quantifiers.
o Atomic formulas consist of a predicate followed by terms.
o Complex formulas are formed by combining atomic formulas using
connectives and quantifiers.
Semantics of First Order Logic:
1. Interpretation:
o An interpretation assigns meaning to the symbols and formulas in FOL.
o It consists of a domain of discourse (set of objects) and interpretations
for predicates, functions, and constants.
2. Satisfaction:
o A formula is satisfied under an interpretation if it evaluates to true in
that interpretation.
o The satisfaction of atomic formulas depends on the interpretation of
predicates and the objects they refer to.
3. Quantifier Interpretation:
o Universal quantification (∀x) states that a formula holds for all objects
in the domain.
o Existential quantification (∃x) states that a formula holds for at least
one object in the domain.
4. Models:
o A model is an interpretation that satisfies all the formulas in a given
logical system.
o A logical system is consistent if it has at least one model.
5. Logical Consequence:
o A formula A is a logical consequence of a set of formulas Γ if every
interpretation that satisfies all formulas in Γ also satisfies A.
o This relationship is denoted as Γ ⊨ A.
Q.3] Detail the algorithm for deciding entailment in prepositional logic.
ANS: Here's a simplified algorithm for deciding entailment in propositional logic:
2. Construct Truth Tables: Create truth tables for both propositions P and Q. A
truth table exhaustively lists all possible truth values for the atomic
statements within each proposition, along with the truth values of compound
statements formed using logical connectives.
3. Compare Truth Values: Examine the truth values of the compound statements
in both P and Q for all possible combinations of truth values of the atomic
statements.
4. Check Entailment: Check if every row where P is true, Q is also true. If this
condition holds true for all rows where P is true, then P entails Q, denoted as
P⊨Q.
7. Final Result: Conclude the result based on the truth table. If every row where
PP is true, Q is also true, then P entails Q. Otherwise, P does not entail Q.
Now, let's explain the concept of a knowledge-based agent using the Wumpus
World example:
In the Wumpus World environment, a knowledge-based agent utilizes logical
reasoning and domain-specific knowledge to navigate and make decisions. Here's
how it works:
iv) There is a barber who shaves all men in the town who do not shave themselves:
These formulations represent the given statements in a concise and logical manner
using First Order Logic.
Q.12] What is Resolution? Solve the following statement by using resolution
algorithm. Draw suitable resolution graph.
i) Rajesh like all kind of food.
ii) Apple and vegetables are food.
iii) Anything anyone eats and is not killed is food.
iv) Ajay eats peanuts and still alive.
Prove that Rajesh like bananas. .
ANS: Resolution is a logical inference rule used in propositional logic and first-order
logic to prove the validity of a statement. It involves using a proof by contradiction
method to show that a statement follows logically from a set of premises.
Here's how to solve the given statement using the resolution algorithm, along with a
resolution graph:
1. Convert Statements to Clauses:
o i) Rajesh likes all kinds of food. => Rajesh likes all kinds of food.
o ii) Apple and vegetables are food. => Food(apple) ∧ Food(vegetables).
o iii) Anything anyone eats and is not killed is food. => Eats(x, y) ∧
¬Killed(y) => Food(y).
o iv) Ajay eats peanuts and is still alive. => Eats(Ajay, peanuts) ∧
¬Killed(Ajay).
2. Convert to Clausal Form:
o i) Rajesh likes all kinds of food. => ¬Likes(Rajesh, x) ∨ Food(x).
o ii) Food(apple) ∧ Food(vegetables).
o iii) Eats(x, y) ∧ ¬Killed(y) => Food(y).
o iv) Eats(Ajay, peanuts) ∧ ¬Killed(Ajay).
3. Negate the Conclusion:
o We want to prove that Rajesh likes bananas, so we negate it:
¬Likes(Rajesh, bananas).
4. Apply Resolution Algorithm:
o Combine all clauses and the negation of the conclusion.
o Look for a contradiction.
5. Resolution Steps:
o Start with the initial clauses and apply resolution to derive new clauses
until a contradiction or the conclusion is reached.
6. Resolution Graph:
o Draw a graph where each node represents a clause.
o Connect nodes with edges representing the resolution steps.
7. Conclusion:
o If the contradiction is reached, then the negation of the conclusion is
proved.
o If the conclusion is reached, then the statement is proved.
8. Result:
o After applying resolution, if we reach the clause ¬Likes(Rajesh,
bananas), then we have proved that Rajesh likes bananas. If we reach a
contradiction, then it implies that Rajesh does not like bananas.
DIAGRAM :
¬Likes(Rajesh, bananas)
/ \
Likes(Rajesh, x) ¬Food(bananas)
/ \
Food(x) Food(bananas)
/\ |
Food(apple) Food(vegetables)
|
Eats(x, y) ∧ ¬Killed(y)
|
Eats(Ajay, peanuts) ∧ ¬Killed(Ajay)
Q.13] What is an Agent. Name any 5 agents around you Explain Knowledge
based agent with Wumpus World. List and explain in short the various
steps of knowledge engineering process
Consider the following axioms: If a triangle is equilateral then it is isosceles.
ANS: Agent:
An agent is a system or entity that perceives its environment through sensors and
acts upon that environment through actuators, based on its observations and
internal state. Agents are commonly used in artificial intelligence and robotics to
accomplish tasks autonomously or semi-autonomously.
Examples of Agents:
1. Chatbots: These are agents designed to interact with users through text or
speech, often used for customer service or information retrieval.
2. Autonomous Vehicles: Self-driving cars are agents that perceive their
surroundings using sensors like cameras and lidar, and make decisions on
steering, acceleration, and braking to navigate safely.
3. Virtual Assistants: Agents like Siri, Google Assistant, and Alexa respond to
voice commands and perform various tasks such as setting reminders, playing
music, or providing information.
4. Robotic Arms: Industrial robots equipped with sensors and actuators to
manipulate objects in manufacturing processes.
5. Search Algorithms: Web crawlers used by search engines to discover and index
web pages, based on predefined rules and algorithms.
1. Requirement Analysis: Identify the goals and objectives of the system, as well
as the knowledge sources and constraints.
2. Knowledge Acquisition: Gather knowledge from experts, documents,
databases, or other sources relevant to the problem domain.
3. Knowledge Representation: Choose appropriate formalisms to represent the
acquired knowledge, such as rules, ontologies, frames, or graphs.
4. Knowledge Engineering: Design and implement the knowledge-based system,
including encoding the acquired knowledge into a form understandable by
the system.
5. Knowledge Validation: Test and evaluate the system to ensure that it behaves
correctly and produces the desired results.
6. Knowledge Maintenance: Continuously update and refine the knowledge base
to adapt to changing requirements or new insights.
Axioms:
1. If a triangle is equilateral, then it is isosceles.
Explanation:
An equilateral triangle is a triangle in which all three sides are of equal
length.
An isosceles triangle is a triangle with at least two sides of equal length.
The axiom states that any equilateral triangle is also isosceles, which is true
because in an equilateral triangle, all sides are equal, meeting the definition
of an isosceles triangle. Therefore, this axiom is true in Euclidean geometry.
Q.14] Write the following sentences in FOL(using types of quantifiers)
i) All birds fly
ii) Some boys play cricket
iii) A first cousin is a child of a parent’s sibling
iv) You can fool all the people some of the time and some of the
people all the time, but you cannot fool all the people all the time
ANS: let's represent each of these sentences in First-Order Logic (FOL) using
quantifiers and explain them in detail:
i) All birds fly:
Predicate: F(x) represents "x flies".
Domain: Let xx be any object, and B(x) represent "x is a bird".
FOL Representation: ∀x(B(x)→F(x))
Explanation:
1. ∀x: This quantifier states "for all x" or "for every x", where x represents
any object.
2. B(x)→F(x): This is the implication that if xx is a bird, then x flies. It
means every object that falls under the domain of birds flies.
ii) Some boys play cricket:
Predicate: P(x) represents "x plays cricket".
Domain: Let xx be any object, and B(x) represent "x is a boy".
FOL Representation: ∃x(B(x)∧P(x))
Explanation:
1. ∃x: This quantifier states "there exists an x" or "some x", meaning at least
one object exists that satisfies the condition.
2. B(x)∧P(x): This conjunction states that the object xx is both a boy and
plays cricket. Thus, there exists at least one boy who plays cricket.
iii) A first cousin is a child of a parent’s sibling:
Predicate: C(x,y) represents "x is a first cousin of y".
Domain: Let x and y be any objects representing individuals.
FOL Representation: ∀x∀y(C(x,y)↔(∃z(P(z,x)∧P(z,y)∧x≠y)))
Explanation:
1. ∀x∀y: This quantifier states "for all x and for all y".
2. C(x,y)↔(∃z(P(z,x)∧P(z,y)∧x≠y)): This bi-conditional statement states
that x is a first cousin of y if and only if there exists a third person, z, who
is a sibling of both x and y, and x and y are not the same person.
iv) You can fool all the people some of the time and some of the people all the time,
but you cannot fool all the people all the time:
Predicate: F(x,y) represents "x can fool y".
Domain: Let xx and yy be any objects representing individuals.
FOL Representation: ∃x∀y(F(x,y)∧(∃t(T(t)∧P(y,t)))) where T(t) represents "t is
some of the time".
Explanation:
1. ∃x: This quantifier states "there exists an x" or "some x", implying that
there is at least one person who can fool others.
2. ∀y: This quantifier states "for all y", meaning that the statement applies
to all individuals.
3. F(x,y)∧(∃t(T(t)∧P(y,t))): This conjunction states that person xx can fool
person yy and there exists some time tt where yy can be fooled by xx.
This captures the idea that all people can be fooled some of the time.
Q.15] What is Knowledge Representation using propositional Logic? Compare
propositional and predicate Logic.
ANS: here's a simple and easy point-wise comparison of propositional and predicate
logic, focusing on knowledge representation:
Propositional Logic:
1. Basic Units: Propositional logic deals with propositions, which are statements
that are either true or false.
2. Syntax: It uses logical connectives such as AND (∧), OR (∨), NOT (¬),
IMPLICATION (→), and BICONDITIONAL (↔) to combine propositions.
3. Knowledge Representation: Propositional logic is limited in its ability to
represent complex relationships and structures. It's suitable for representing
simple facts or relationships where the truth value of each proposition is clear
and fixed.
4. Example:
o Proposition: "It is raining."
o Compound Proposition: "It is raining and the sun is shining."
Predicate Logic:
1. Basic Units: Predicate logic deals with predicates, which are statements that
can have variables and quantifiers.
2. Syntax: It includes variables, constants, predicates, quantifiers (such as ∀ for
universal quantification and ∃ for existential quantification), and logical
connectives similar to propositional logic.
3. Knowledge Representation: Predicate logic allows for more complex
representation of knowledge by introducing variables and quantifiers,
enabling the representation of relationships between objects and properties.
4. Example:
o Predicate: "x is a student."
o Compound Predicate: "For all x, if x is a student, then x attends
lectures."
Comparison:
1. Expressiveness: Predicate logic is more expressive than propositional logic
because it allows for the representation of relationships and properties
involving variables and quantifiers.
2. Complexity: Propositional logic is simpler and more straightforward compared
to predicate logic, which can handle more complex relationships but requires
understanding of quantifiers and variables.
3. Scope: Propositional logic is suitable for simple, fixed truths, while predicate
logic is better suited for representing more nuanced and variable
relationships.
4. Applications: Propositional logic is commonly used in simple decision-making
systems or where the knowledge domain is limited and well-defined.
Predicate logic finds applications in areas such as artificial intelligence,
natural language processing, and database querying, where complex
relationships need to be represented and reasoned about.