0% found this document useful (0 votes)
0 views

Unit 4 Knowledge Representation and Reasoning

Knowledge representation is crucial for problem-solving in AI, as it transforms informal knowledge into a computer-understandable format. Various systems exist, including semantic nets, frame-based representations, and rule-based systems, each with unique structures and applications. Key challenges include selecting important attributes, defining relationships, and ensuring representational and inferential adequacy.

Uploaded by

Lok Regmi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Unit 4 Knowledge Representation and Reasoning

Knowledge representation is crucial for problem-solving in AI, as it transforms informal knowledge into a computer-understandable format. Various systems exist, including semantic nets, frame-based representations, and rule-based systems, each with unique structures and applications. Key challenges include selecting important attributes, defining relationships, and ensuring representational and inferential adequacy.

Uploaded by

Lok Regmi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 78

Unit 4 - Knowledge Representation

Definition and importance of knowledge:-


Knowledge is what we know as facts. The facts are declarative sentences that are either true or false. In
case of problem solving by computer, Knowledge is the information about a particular domain that can be
used to solve problems in that domain.

Knowledge is important in problem solving by computer because to solve a problem by a computer, it first
must be represented in computer understandable form.

Few importance of knowledge are listed below:

Reasoning and decisioning making


Learning and adapting
understanding the world

The process of converting informal knowledge into computer understandable form is known as
knowledge representation scheme. A representation scheme specifies the form of the knowledge. A
knowledge base is the representation of all of the knowledge that is stored by an agent.

Sandesh Shiwakoti 9815945474


Issue in knowledge Representations
Some of the issue regarding knowledge representation can be formulated as questions as
follows:
a. How can the problem be represented ?
b. What distinctions in the world are needed to solve the problem ?
c. What specific knowledge abut the world is required ?
d. How can an agent acquire the knowledge from experts or from experience ?
e. How can the knowledge be debugged, maintained, and improved ?
The main issue in knowledge representations are :
selection of important attributes
How to find the important attribute from the bank of information about an object or world.

Relationships
What about the relationship between the attributes of an object, such as, inverses, existence, techniques for reasoning
about values and single valued attributes.

Granularity(the scale or level of detail in a set of data.) :


At what level should the knowledge be represented and what are the primitives. Choosing the granularity of
representation primitives are fundamental concepts such as holding , seeing , playing and as English is a very rich language with
over half a million worlds it is clear we will find difficulty in deciding upon which words to choose as our primitives in a series of
situations.
Knowledge Representation System and its properties

Knowledge representation system is a formalized structure and set of operations that embodies the descriptions, relationships,
and procedures provided in a in an artificial intelligence system. The process Considers how to represent the knowledge in the
system such that it can be used to solve problems.

It basically consists of two components:

1. Knowledge base 2. Inference Methods

A good knowledge representation system should consist of following properties.


1. Representational adequacy:-
The scheme is rich enough to express the knowledge needed to solve the problem in
other words, the ability to represent all the kinds of knowledge that are needed in a certain domain.

2. Inferential Adequacy:-
The ability to present all of the kinds of inferential procedures.

3. Acquisitional Efficiency:-
The ability to acquire new knowledge using automatic methods wherever possible rather than
reliance on human intervention.
Types of Knowledge Representations Systems:
1. Semantic Nets
2. Frame based knowledge representations
3. Conceptual Dependencies
4. Script structure
5. Rule Based( production system) Knowledge Representations System
6. Propositional Logic ( sentential logic and statement logic)
7. Predicate Logic (First Order Logic or Quantified logic)
Semantic Nets

Semantic nets are a knowledge representation scheme used in artificial intelligence


(AI) to model the world. It is a directed or undirected graph consisting of vertices
which represent concepts and ages which represent semantic relation between
concepts. It is a method of knowledge representation that represents semantic
relations between concepts in the form of a network. the resulting knowledge base is
also known as knowledge map.

It is a kind of directed graph where node may represent a fact description such as
. Physical object
. Concept
. Event

And an arc (or link) represents relationships between nodes. There are some
‘standard’ relationship types
Structure:

•Nodes: These represent concepts, entities, or objects in the world. Examples could be "cat," "bird," "Tom"
(a specific cat), or "Whiskers" (another specific cat).

•Links: These labeled arrows connect the nodes and represent the relationships between the concepts.
Common link types include:

•Is-a: This indicates a hierarchical relationship, like "cat is-a mammal."


•Has-a: This represents a possession relationship, like "Tom has-a tail."
•Can: This signifies an ability, like "bird can fly."

Advantages:

•Visually intuitive: Semantic nets are easy to understand due to their graphical nature. People can easily
grasp the connections between concepts.
•Natural representation: They mimic how humans categorize and link concepts in their minds.
•Efficient reasoning: The connections between concepts allow for inferencing new knowledge. For
instance, if "cat is-a mammal" and "mammal is-a warm-blooded animal," we can infer that
•"cat is-a warm-blooded animal."
•Inheritance: Knowledge about a general class (e.g., mammal) can be inherited by specific subclasses
(e.g., cat), reducing redundancy.
Disadvantages:

•Ambiguity: The meaning of links can be unclear, especially with a single "is-a" link. It might represent an instance-
of relationship (Tom is-a cat) or a subclass-of relationship (cat is-a mammal).

•Limited expressiveness: Compared to logic-based approaches, semantic nets struggle to represent complex
relationships or quantification (e.g., all cats are mammals).

•Scalability challenges: Large knowledge bases can become unwieldy and difficult to maintain with simple
semantic nets.

Overall, semantic nets are a valuable tool for representing knowledge in some AI applications,
Components of a semantic Network

The fundamental components of semantic networks are straightforward to identify:

Lexical part:
i. nodes – denoting object
ii. Links – denoting relations between objects
iii. Abels – denoting particular objects and relations

Structural part:
. The links and nodes from directed graphs the labels are placed on the links and nodes.

Semantic part:
. Meanings are associated with the link and node labels.

Procedural part:
.Constructors allow creation of new links and nodes destructors allow the deletion of links and
nodes writers allow the creation and alteration of labels.
. Readers can extract answers to questions
.
Different types of semantic networks:
•Definitional Networks: These emphasize hierarchical relationships, focusing on the "is-a" connection between
concepts. For example, a definitional network might show "car is-a vehicle" and "vehicle is-a machine."

•Assertional Networks: Designed to state facts or propositions. These networks don't focus on hierarchies but rather
on specific relationships between concepts. An example could be "car has-a color" or "John works-at hospital."

•Implicational Networks: Use implication as the primary link between concepts. These networks encode rules that
allow for reasoning and inferring new knowledge. For instance, an implication network might have a rule "if bird then
has-wings" which lets you infer that "robin has-wings" since robin is a bird.

•Executable Networks: These go beyond just storing information. They incorporate mechanisms to perform actions or
calculations based on the network structure. This might involve marker passing or attached procedures within the
network.

•Learning Networks: As the name suggests, these networks can learn and adapt. They can build or modify their
structure based on new information or examples they are exposed to.

•Hybrid Networks: These combine elements from two or more of the above categories. For instance, a network might have a
core of definitional relationships with additional learning capabilities to adapt over time.
Solve Examples

1. Represent the following sentences into a semantic network.


Birds are animals.
Birds have feathers, fly and lay eggs.
Albatros is a bird.
Donald is a bird.
Tracy is an albatross.

Solution:
The Semantic network representation of above sentences is : pg 103

2. Represent the following sentences into a semantic network.

Puss is a calico.
Herb is a tuna.
Charlie is a tuna.
All tunas are fishes.
All calicos are cats,.
All cats like to eat all kinds of fishes.
2. Represent the following sentences into a semantic network.

Cat is pet.
Dog is pet.
cat, Dog and Fish have a tail.
fish lives in water.
Frame based Knowledge Representations
Frame-based knowledge representation is a method for storing information in artificial
intelligence (AI) systems. It uses a concept called a "frame" to organize knowledge about specific
entities or situations.

Frames provide a convenient structure for representing objects that are typical to a stereotypical
situations. The situations to present may be visual scenes, structure of complex physical objects,
etc. Frames are also useful for representing commonsense knowledge . As frames allow nodes to
have structures they can be regarded as three-dimensional representations of knowledge.

A frame is similar to a record structure and corresponding to the fields and values are slots and
slot filters. Basically it is a group of slots and filters that defines a stereotypical object. A single
frame is not much useful. Frame systems usually have collection of frames connected to each
other.
Here's a breakdown of how it works:
•Frames:
•A frame is a data structure that acts like a record. It consists of slots (attributes) and
fillers (values) that describe a specific entity or concept. For example, a frame for a car
might have slots for attributes like color, number of wheels, and type of engine.
•Slots:
•Slots represent the different features or properties of the concept being described. Each slot
can have a specific data type, like text, numbers, or even other frames (for nested structures).
•Fillers:
•Fillers provide the actual values for the slots in a frame. These values define the specific
characteristics of an instance. Imagine a red car with 4 wheels and a gasoline engine. That
would be the filler for the corresponding slots in the car frame.
Applications of Frame-based Systems:

•Natural Language Processing (NLP):


Understanding the meaning of sentences by
using frames to represent concepts and their relationships.

•Medical Diagnosis Systems:


Storing medical knowledge about diseases and symptoms
for diagnosis and treatment planning.
•Expert Systems:
Capturing the knowledge of human experts in a specific domain for
decision-making and problem-solving.
A frame for a book is given below:

Slots Fillers
Publisher Thomson
Title Expert Systems
Author Giarratano
Edition Third
Year 1998
Pages 600
Conceptual Dependencies:

Conceptual dependencies theory was developed by schank in 1973 to 1975 to represent the meaning of natural language
sentences. Cd representation of a sentence is not built using words in the sentence rather built using conceptual primitives which
give the intended meaning of words. Since it represents meaning of sentence using primitives but not the exact words in a
sentence.
> It helps in drawing inferences
> It is independent of the language

CD provides structures and specific set of primitives from which representation can be built.

CD primitives: there are following standards CD primitives


Components of Conceptual Dependencies:

1.Primitive Actions: Basic actions that can be combined to describe more complex activities. Examples include:

1. PTRANS: Physical transfer of an object (e.g., moving from one place to another).
2. ATRANS: Abstract transfer (e.g., transferring ownership or information).
3. MTRANS: Mental transfer (e.g., transferring information within one's mind).

2.Case Relations: Roles played by different entities in the actions. Common case relations include:

1. Actor: The entity performing the action.


2. Object: The entity affected by the action.
3. Direction: The goal or endpoint of the action.

1.State Descriptions: Representing states or conditions of entities before and after actions. For example, an object
might be "owned" by someone before and "owned" by someone else after an action.

Example of Conceptual Dependencies:


For the sentence "John gave Mary a book," the CD representation might involve:
•ATRANS (John, book, Mary): An abstract transfer where John is the actor, the book is the object, and Mary is the
recipient.
•PTRANS (book, John, Mary): A physical transfer to indicate that the book physically moved from John to Mary.
Script Structure (knowledge representation system):

The scripts were introduced by Schank and Abelson introduced in 1977 that used CD framework.

The scripts were useful in describing certain stereotyped situations such as going to theater.

It consists of set of slots containing default values along with some information about the type of
values similar to frames.

It differs from FS as the values of the slots in the script must be ordered and have more
specialized roles.

In real world situations, We see that event tends to occur in known patterns because of causal
relationship to the occurrence of events
Components of Script Structure Knowledge Representation:

1.Entry Conditions:
1. Must be satisfied before events in the script can occur. Example: For a "restaurant script," the entry condition
might be that the person is hungry and has money.
2.Props:
1. Slots representing objects involved in the events.
3.Roles:
1. Persons involved in the events.
4.Scenes:
1. Scripts are broken down into smaller components called scenes, which represent specific actions or sets of
actions that occur as part of the larger event.
5.Tracks:
1. These represent alternative pathways or variations within the script, accounting for different possible
outcomes or sequences of events based on varying conditions.
6.Results:
1. These are the outcomes or end states resulting from the execution of the script. They describe the final
condition after the sequence of actions has taken place.
7.Subscripts:
1. These are smaller scripts that can be embedded within a larger script, representing detailed sequences for
more specific actions within the main event.
Restaurant Script:

1.Entry Conditions:
1. The person is hungry.
2. The person has money.

2.Props:
1. Menu, table, chair, utensils, food, bill.

3.Roles:
1. Customer, waiter, chef.

4.Scenes:
1. Entering: Customer enters the restaurant.
2. Seating: Waiter seats the customer.
3. Ordering: Customer orders food from the menu.
4. Eating: Chef prepares the food, and customer eats.
5. Paying: Customer receives the bill and pays.
5. Tracks:
1. Customer likes the food.
2. Customer dislikes the food and sends it back.

6. Results:
1. Customer is no longer hungry.
2. Customer has paid the bill.

7. Subscripts:
1. Paying Bill Subscript:
1.Waiter brings the bill.
2.Customer provides payment.
3.Waiter processes the payment.
Example: "Going to Meet the Doctor" Script
Entry Conditions:
•Feeling unwell or having a scheduled appointment.
•Access to transportation.

Props:
•Medical record, waiting room, examination room, medical equipment, prescription pad.

Roles:
•Patient, receptionist, nurse, doctor.

Scenes:
1.Arriving: Patient checks in.
2.Waiting: Patient waits in the waiting room.
3.Initial Examination: Nurse checks vital signs.
4.Consultation: Doctor discusses symptoms and performs an examination.
5.Diagnosis and Treatment: Doctor diagnoses and prescribes treatment.
6.Leaving: Patient schedules follow-up and leaves.
Tracks:
•Mild condition diagnosed and treated.
•Need for further tests or specialist referral.
•Immediate in-office treatment provided.

Results:
•Diagnosis and treatment plan.
•Patient reassured or informed of next steps.
•Prescription or treatment instructions provided.

Subscripts:
•Taking Vital Signs: Nurse measures and records vital signs.
•Scheduling Follow-Up: Receptionist schedules next appointment and provides confirmation.
Rule Based knowledge representation system:

A rule-base system (or production system) either knowledgeable based system in which the
knowledge is stored as rules; an export system is a RBSs in which the rules comes from human
experts in a particular domain.
The underlying idea of production system is to present knowledge in the form of condition action
pairs called production rules.

> if the condition C is satisfied then the action A is appropriate.

Rule based system can be used for problem solving or for control(animate motion). In RBS, the
knowledge is separated from the AI reasoning processed, which means that new RBS, are easy
to create.

The syntax of rules is


IF <premise> THEN <action>
Components of RBS:

Working Memory:- a small allocation of memory into which only appropriate rules are copied.

Rule Base:- The knowledge base is the heart of a rule-based system. It stores all the domain knowledge of the system in
the form of a set of rules.

Interpreter:- The processing engine which carries out reasoning on the rules and derives an answer.

User Interface:- The user interface allows users to interact with the rule-based system. Users can provide input data,
receive output from the system, and monitor the system's reasoning process.

The Interpreter Cycle:-


The Execution of a production system can be defined as a series of recognized act cycles:

> Match-memory contain matched against condition of production rules, this produces a subset of production called
conflict set.

> Conflict resolution – one of the production in the conflict set is then selected.

> Apply the rule.

This is also called Retrieval, Refinement and Execution cycle of Interpreter.


Example:-

Problem: Sorting a string a composed of letters a,b & c.


Short Term Memory : cbaca
Production set:
1. ba →ab
2. ca →ac
3. cb →bc

Interpreter: Chooses one rule according to some strategy.

Iteration # Memory Conflict Set Rule Fired


0 Cbaca 1,2,3 1
1 Cabca 2 2
2 Acbca 2,3 2
3 Acbac 1,3 1
4 Acabc 2 2
5 Aacbc 3 3
6 Aabcc 0 Halt
Logic Based knowledge representation system:
A logic-based knowledge representation (KR) system uses formal logic to represent information about the world in a way that a
computer system can utilize to perform tasks such as reasoning, inference, and decision-making. The primary goal of such
systems is to enable machines to process knowledge in a manner that mimics human cognitive abilities. Here’s a breakdown of
key components and concepts in logic-based KR systems:

Components of Logic-Based KR Systems

1.Syntax:
1. Symbols: Basic elements like variables, constants, predicates, and functions.
2. Formulas: Well-formed combinations of symbols that express propositions or relationships.
3. Logical Connectives: Operators like AND (∧), OR (∨), NOT (¬), IMPLIES (→) used to form complex sentences.
4. Quantifiers: Universal (∀) and existential (∃) quantifiers to express statements about all or some members of a
domain.
2.Semantics:
1. Defines the meaning of the syntactical elements and formulas.
2. Interpretations: Assigns truth values to sentences based on a specific model.
3. Models: Representations of a possible world where the sentences hold true.
3.Inference Mechanisms:
1. Deduction: Deriving logically valid conclusions from given premises.
2. Resolution: A common rule of inference used in automated theorem proving.
3. Modus Ponens: If 𝑃→𝑄 and 𝑃 are both true, then Q is true.
1.Knowledge Base:
1. A collection of facts and rules about the domain of interest.
2. Structured in a way that supports efficient querying and updating.
2.Reasoning Engines:
1. Tools that apply inference rules to the knowledge base to derive new information or make decisions.
2. Examples include Prolog interpreters and description logic reasoners.

Common Logic-Based KR Systems

1.Propositional Logic:
1. Simplest form of logic.
2. Deals with propositions that can be true or false.
3. Limited expressiveness as it cannot handle relationships between objects.
2.First-Order Logic (FOL)[predicate]:
1. Extends propositional logic by including objects, predicates, and quantifiers.
2. More expressive and can represent complex relationships and properties of objects.
3. Example: Predicate calculus.
3.Description Logic (DL):
1. A family of logics designed for representing structured knowledge.
2. Basis for ontologies and semantic web technologies like OWL (Web Ontology Language).
3. Balances expressiveness and computational tractability.
4.Modal Logic: 5. Fuzzy logic:
1. Extends classical logic to include modalities like necessity and possibility.
2. Used in reasoning about beliefs, knowledge, and temporal events.
Propositional Logic (PL):-
Propositional logic are formal languages for representing information such
that conclusions can be drawn: It has syntax and semantics:

Syntax defines the sentences in the language

Semantics define the meaning of sentences. That defines truth of a sentence in a world

Truth Tables

A truth table is a mathematical table used to determine the truth value of a logical expression
based on the truth values of its components. Here’s an example for basic connectives:
P Q -p P^Q PvQ P➔Q P ➔Q
False False True False False True True
False True Ture False True True False
True False False False True False False
True true false true True true True
Formal Logic-connectives :-

•Conjunction (∧): True if both operands are true.


•Disjunction (∨): True if at least one operand is true.
•Negation (¬): True if the operand is false.
•Implication (→): False only if the antecedent is true and the consequent is false.
•Biconditional ( ): True if both operands are either true or false.
•Exclusive Or (XOR, ⊕): True if operands have different truth values.
•NAND (↑): True if ∧ is false.
•NOR (↓): True if ∨ is false.
Example Scenario
Suppose we have the following propositions:
•𝑃: "It is raining."
•𝑄: "The ground is wet."
•𝑅: "I will take an umbrella.“

Syntax
We can use the formal logic connectives to construct logical statements:
1.𝑃→Q: (If it is raining, then the ground is wet.)
2.𝑃→R: (If it is raining, then I will take an umbrella.)
3.¬𝑃: (It is not raining.)

Semantics
The semantics of these statements involves interpreting their truth values. Let's assign truth
values to the propositions:
•𝑃: False (It is not raining.)
•𝑄: False (The ground is not wet.)
•𝑅: False (I will not take an umbrella.)
Validity in logic refers to a property of an argument or a deductive reasoning process. An argument is considered valid if and only
if it is impossible for the premises to be true and the conclusion to be false simultaneously. In other words, a valid argument
ensures that if the premises are true, the conclusion must necessarily be true.
Example of a Valid Argument
Premise 1: All humans are mortal. (If all humans are mortal, then anyone who is a human must be mortal)
Premise 2: Socrates is a human.
Conclusion: Socrates is mortal.

Here, the conclusion logically follows from the premises. If both premises are true, then the conclusion must also be true, making
the argument valid.
Formal Definition
In formal logic, an argument is valid if the truth of the premises guarantees the truth of the conclusion. This is often tested using
truth tables or proof techniques in formal systems like predicate logic.
Tautology
A tautology is a statement or formula that is true in every possible interpretation. In propositional logic, a tautology is a formula
that is always true regardless of the truth values of its component propositions.
Example of a Tautology
Statement: 𝑃∨¬𝑃

P∨¬P (Read as "P or not P")


This statement is always true because either 𝑃
SENTENCE: Whether it is raining or not. The school is open.
P is true, or ¬𝑃

A proposition formula which is always false is called Contradiction.

Precedence Operators

First Precedence Parenthesis


Second Precedence Negation
Third Precedence Conjunction(AND)
Fourth Precedence Disjunction(OR)
Fifth Precedence Implication
Six Precedence Biconditional
Example of Validity

Consider the following argument:

Premise 1: If it is raining, then the ground is wet. (𝑃→𝑄)


Premise 2: It is raining. (𝑃)
Conclusion: The ground is wet. (𝑄)

Let's break this down:

Premise 1: 𝑃→𝑄("If it is raining, then the ground is wet.")


Premise 2: 𝑃 ("It is raining.")
Conclusion: 𝑄

This argument is valid because if both premises are true, the conclusion must also be true. If it is true that "if it is raining, then
the ground is wet" and it is also true that "it is raining," then it must follow that "the ground is wet."
Truth Table for Validity
Well Formed Formula
In logic-based knowledge representation, a well-formed formula (WFF) is a formula that follows the specific rules
of a particular logic system. It's like a grammatically correct sentence in a language, but for logic. Here's a
breakdown:

•Logic System: There are different logic systems used for knowledge representation, like propositional logic and
first-order logic. Each system has its own set of symbols and rules for constructing valid formulas.

•Symbols: These can be propositional letters (representing basic statements), predicates (relations between
things), variables, and logical connectives (AND, OR, NOT, etc.).

•Rules: The rules define how these symbols can be combined to form meaningful formulas. They specify things
like the order of operations, proper use of parentheses, and valid combinations of symbols.

For example, in propositional logic:

•P and Q can be propositions like "It is raining" or "The sun is shining."


•¬ (NOT), ∧ (AND), and ∨ (OR) are connectives.
•(P ∧ Q) ∨ R is a well-formed formula because it combines propositions and connectives according to the rules.

On the other hand, PQR (without connectives) or (P ∧ OR Q) (misusing connectives) would not be well-formed
formulas.
Here's why WFFs are important:

•Clarity: They ensure that formulas are unambiguous and can be interpreted consistently within the logic
system.

•Reasoning: Logical reasoning algorithms rely on WFFs to manipulate and draw conclusions from the
knowledge base.

•Efficiency: By following the rules, WFFs allow for efficient processing and analysis of knowledge.
Inference using Resolution in propositional
Inference Rules in PL:
1) Modus Ponens a=>b,a 2) And-elimination a^b
b b
Inference using resolution is a powerful technique in automated theorem proving within logic.

set of rules for generating new sentences.


Resolution Rule:

This is the core inference rule that allows you to derive new logical statements from existing ones. It works by
combining two clauses (disjunctions of literals) that share complementary literals (one positive, one negated) and
creating a new clause, the resolvent.
(UR) Unit Resolution: Unit resolution rule takes a clause (a disjunction of literals) and a literal and produces a new
clause. Single literal is also called unit clause.
• General Resolution: The unit resolution rule can be
generalized to the full resolution rule,
Proof by resolution
Resolution is used with knowledge bases in CNF(Conjunctive Normal Form) (or clausal form),
and is complete for propositional logic.

• Resolution takes two clauses and produces a new clause containing all the literals of the two
original clauses except the two complementary literals.

• In addition the resulting clause should contain only one copy of each literal. The removal of
multiple copies of literals is called factoring.

• For example, if we resolve (A ∨ B) with (A∨¬B), we obtain (A ∨ A), which is reduced to just A.
Resolution Algorithm
Pros and cons of propositional logic

• Propositional logic is declarative


• Propositional logic is compositional: – meaning of B P is derived from meaning of B and of P
• Meaning in propositional logic is context-independent – (unlike natural language, where meaning depends on context)
• Propositional logic has very limited expressive power (unlike natural language)
Forward chaining
Forward chaining is the logical process of inferring unknown truth from known data and moving
forward using determined conditions and rules to find a solution.

It is also known as data driven reasoning.

Steps:
Given knowledge base of true facts:

Apply all rules that match facts in knowledge base.


Add conclusions to knowledge base.

Repeat until a goal is reached, OR repeat until no new facts


Backward chaining
Backward chaining, also called backward reasoning, is a problem-solving approach where
you start with the goal and work your way backwards to figure out the steps you need to take to
achieve it. It's like planning a trip by first identifying your destination and then looking up the
transportation options and figuring out the route to get there.

•Goal-driven: It starts with a specific goal in mind and focuses on what needs to be done to reach
that goal.

•Step-by-step: It breaks down complex tasks into smaller, more manageable steps.

•Success-oriented: By starting with the final step and gradually working backwards, it allows for a
sense of accomplishment with each completed step.
First Order Logic (predicate logic)
First-order logic (FOL), also known as predicate logic or first-order predicate calculus, is a formal
system used in AI, and computer science. It extends propositional logic by allowing the use of
quantifiers and predicates, thereby enabling more expressive statements about objects and their
properties.
In the context of first-order logic (FOL), a predicate is a symbol or function that represents
a property of objects or a relationship between objects within the domain of discourse.

Key Components of First-Order Logic:


1.Variables: Symbols that stand for objects in a domain of discourse. Examples include 𝑥,𝑦,𝑧

2.Constants: Symbols that refer to specific objects in the domain. Examples include 𝑎,𝑏,𝑐

3.Predicates: Functions that represent properties of objects or relationships between objects.


For example, 𝑃(𝑥) might represent "x is a prime number," and 𝑅(𝑥,𝑦) might represent "x is
greater than y."
4. Functions: Mappings from tuples of objects to objects within the domain. For example,
𝑓(𝑥) could represent "the father of x.“
1.Universal Quantifier, (for all, everyone, everything)
2.Existential quantifier, (for some, at least one).
5. Quantifiers:
1. Universal Quantifier (∀) “for all”: Indicates that a statement applies to all elements in
the domain. For example, ∀𝑥 𝑃(𝑥) means "P(x) is true for all x."
2. Existential Quantifier (∃) “there exists” : Indicates that there exists at least one
element in the domain for which the statement is true. For example, ∃𝑥 𝑃(𝑥) means
"There exists an x such that P(x) is true.“

6. Logical Connectives: Symbols used to build complex statements from simpler ones.
Common connectives include:
1. Conjunction (∧): "and"
2. Disjunction (∨): "or"
3. Negation (¬): "not"
4. Implication (→): "if...then"
5. Biconditional ( ): "if and only if"
Syntax and Semantics: FOL has two main parts

•Syntax: Defines the formal structure of well-formed formulas (WFFs) in FOL. A WFF might
be a simple atomic formula like P(a) or a complex formula involving quantifiers
and connectives, such as ∀𝑥(𝑃(𝑥)→∃𝑦𝑅(𝑥,𝑦)).

•Semantics: Provides meaning to the symbols and formulas. An interpretation assigns


values to constants, functions, and predicates, and determines the truth value of
formulas based on these assignments.
From Natural Language to First order logic (or vv.). Consider the following three sentences:

– “Each animal is an organism”


– “All animals are organisms”
– “If it is an animal then it is an organism”

Syntax: ∀x(Animal(x)→Organism(x))

Symentic: The formula ∀𝑥(Animal(𝑥)→Organism(𝑥))∀x(Animal(x)→Organism(x)) is true if, for every object 𝑥 in the
domain D, whenever Animal(x) is true, Organism(𝑥) is also true.

There are two types of sentence (well formed formula) in FOL:


A. Atomic Sentence
B. Complex

Atomic Sentence:- 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.

Example: Brother (Bill, Mary), [Bill is brother of mary] or b(x,y) [predicate b is : brother of , X is bill , y is mary]
Father (jack, John), Mother (jill, john), [jack is father of john], [jill is mother of john)
sister (jane, john),
married (jack, jill)
Translating natural language into First-Order Logic (FOL) can be Building the FOL Formula
challenging. Here are some tips to help you:
•Start with quantifiers: Introduce quantifiers for variables that
Understanding the Basics range over a domain.
•Define predicates: Use capital letters and appropriate
•Identify the key components: Quantifiers (∀, ∃), predicates, arguments.
constants, functions, and variables. •Use logical connectives: Combine predicates and quantifiers
•Grasp the logical connectives: ∧ (and), ∨ (or), ¬ (not), → using logical operators.
(implies), (if and only if). •Handle negation carefully: Ensure correct placement of
•Know the difference between predicates and functions: negation.
Predicates express properties or relations, while functions map
elements to other elements. Examples
•"All dogs bark": ∀x (Dog(x) → Barks(x))
Breaking Down the Sentence •"Some students like math": ∃x (Student(x) ∧ Likes(x, Math))
•"No one loves everyone": ¬∃x ∀y Loves(x, y)
•Identify the main verb: This often indicates a predicate.
•Determine the subject and objects: These can become •Confusing quantifiers: Ensure correct use of ∀ and ∃.
arguments for the predicate. •Misinterpreting negation: Place negation carefully.
•Look for quantifiers: Words like "all," "some," "every," and •Overlooking variables: Make sure all variables are properly
"no" usually indicate quantifiers. quantified.
•Consider the sentence structure: Pay attention to the order of •Ignoring sentence structure: Consider the order of words and
words and phrases. phrases.
By following these tips and practicing regularly, you can
improve your ability to translate English-like language into FOL.
Complex sentence: - Complex sentences are made from atomic sentences using connectives.
Sister (john, jane)

P(a)∧Q(b): A conjunction of two atomic sentences. This means "a has property P and b has property Q".

Properties of quantifiers

V x V y is same as V y V x
3x 3y is the same as 3y 3x
3x V y is not same as V y 3x

3x V y Loves (x,y)
“There is a person who loves everyone ins the world”

V y 3x loves (x,y)
“Everyone in the world is loved by at least one person”
FOPL Inference

There are many FOPL Inference method but we use here Resolution based method.

Resolution methods are a family of inference algorithms based on the resolution rule,
which is used to derive a contradiction from a set of clauses. These methods convert all
formulas into a standardized form, typically conjunctive normal form (CNF), and then apply
the resolution rule iteratively to derive new clauses until a contradiction is found or no
further inferences can be made.
first-order inference can be done by converting the knowledge base to propositional logic and using
propositional inference.

• Conversion can be done by using the following inference rules for quantifiers:

– Universal instantiation
– Existential instantiation

• above applied to sentences with quantifiers to obtain sentences without quantifiers.

• Universal instantiation (UI): –


UI Rule: Substitute ground term (term without variables) for the variables.
– a universally quantified sentence can be replaced by the set of all possible
instantiations. – After UI we discard the universally quantified sentence.
For example: suppose our knowledge base contains just the sentences

• ∀ x King(x) ∧ Greedy(x) ⇒ Evil(x) (all greedy kings are evil)

• King(John)
• Greedy(John)
• Brother (Richard, John) .

– Then we apply UI to the first sentence using all possible ground-term substitutions
from the vocabulary of the knowledge base (in this case, {x/John} and {x/Richard }).

– We obtain

• King(John) ∧ Greedy(John) ⇒ Evil(John)


• King(Richard ) ∧ Greedy(Richard) ⇒ Evil(Richard) ,

– and we discard the universally quantified sentence.


Existential instantiation(EI):

– EI rule: the variable is replaced by a single new constant symbol does not appear elsewhere
in the knowledge base.

– Basically, the existential sentence says there is some object satisfying a condition, and
applying the existential instantiation rule just gives a name to that object.

– So, Existential Instantiation can be applied once, and then the existentially quantified
sentence can be discarded.

– For example, we no longer need ∃ x Kill(x, Ram) once we have added the sentence Kill (Hari ,
Ram).
∃y(book(y)∧OnTable(y,library))

Breakdown of Components
•∃𝑦: The existential quantifier, meaning "there exists some y".

•book(𝑦): Predicate indicating 𝑦 is a book.

•OnTable(𝑦,library): Predicate indicating y is on a table in the library.

•∧: Logical conjunction (AND), meaning both conditions must be true simultaneously.

"There exists at least one y such that 𝑦 is a book and 𝑦 is on a table in the library.“

Or

"There is a book on a table in the library."


• After the universal instantiation and existential instantiation, the knowledge base is
propositional.

• Therefore, we can apply any of the complete propositional inference algorithms

Unification and lifting

• Unification is the process of finding substitutions that make different logical expressions look identical.

• takes two sentences and returns a list of substitutions(unifier) to make two sentences match, or failure if no match
possible.

• i.e., UNIFY(p, q)=θ , are matched where θ is the list of substitutions in p and q
• Example: unification

– Last unification is failed due to overlap of variables


– i.e., x can not take the values of John and OJ at the same time.
– We can avoid this problem(name clashes ) by renaming ( standardizing apart)

EG: Unify {Knows(John,x) Knowns (z, oj) = {x/0j, z/john}


Rules for unification
1.Predicate symbol must be same.
1. Knows(John, Jane)
2. Brother(John, Jane) fail
2.Number of arguments in both expressions must be identical.
1. Hate(Marry)
2. Hate(Marry, John) fail
3.Unification will fail if there are two similar variables present in the same expression.
1. UNIFY(Knows(John, x), Knows(x, Elizabeth)) = fail

Lifting

Lifting refers to the process of applying inference rules to first-order logic statements by
considering their general form (with quantifiers and variables) rather than their ground instances
(specific cases).

Example:
•From ∀𝑥(Human(𝑥)→Mortal(𝑥))∀x(Human(x)→Mortal(x)), we can infer
Human(𝑆𝑜𝑐𝑟𝑎𝑡𝑒𝑠)→Mortal(𝑆𝑜𝑐𝑟𝑎𝑡𝑒𝑠)Human(Socrates)→Mortal(Socrates) by lifting the rule to
the specific instance.
Handling Uncertain Knowledge

In Artificial Intelligence (AI), uncertain knowledge refers to the situations where an AI system lacks complete or
perfect information to make a definitive decision. This uncertainty can arise from various factors:

•Limited Data: If the data used to train an AI model is incomplete or not representative of the real world, the
model might not have enough information to make accurate predictions.

•Noisy Data: Real-world data often contains inconsistencies, errors, or missing values. This "noise" can make it
difficult for AI systems to learn clear patterns and lead to uncertain outcomes.

•Inherent Ambiguity: Some situations are inherently ambiguous, with multiple possible interpretations. For
example, an image recognition system might struggle to distinguish between a cat and a dog in a blurry picture.
AI systems employ various techniques to handle uncertainty Knowledge:
1. Random Variables 2. Prior and Posterior Probability 3. Inference Using Full Joint Distribution
4. Bayes’ Rule 5. Bayesian Networks 6. Fuzzy logic

Fuzzy logic can be viewed both as a knowledge representation system and as a technique for handling uncertain knowledge.
Random variable:
Random variables are variables that represent the possible outcomes of random processes.

For example, if you're rolling a fair six-sided die, the random variable could be the number showing on the top face after the roll,
which could be any number from 1 to 6.

Prior and Posterior Probability:-


Prior Probability: The probability of event A is the number of ways event A can occur divided by the total number of
possible outcomes.

P(A) = The number of ways Event A can Occur/The total number Of Possible Outcomes

Posterior Probability:- Posterior probability is the probability of one event occurring with some relationship to one or
more other events.

Suppose the factory produces two types of light bulbs, A and B. Light bulb A has a defect rate of 5%, while light bulb B has a
defect rate of 10%. However, 70% of the bulbs produced are of type A, and 30% are of type B.
Now, let's say you randomly select a light bulb from the factory's production line, but you don't know which type it is. You inspect
the bulb and find that it has a defect.
We want to calculate the posterior probability that the bulb you selected is of type A, given that it has a defect.
Let's define the events:
•Event 𝐴A: The bulb is of type A.
•Event 𝐵B: The bulb is of type B.
•Event 𝐷D: The bulb is defective.
We need to calculate:
𝑃(𝐴∣𝐷)=𝑃(𝐷∣𝐴)×𝑃(𝐴)𝑃(𝐷)P(A∣D)=P(D)P(D∣A)×P(A)​
Where:
•𝑃(𝐴∣𝐷)P(A∣D) is the posterior probability that the bulb is of type A given that it has a defect.
•𝑃(𝐷∣𝐴)P(D∣A) is the probability that a bulb is defective given that it's of type A (5%).
•𝑃(𝐴)P(A) is the prior probability that a randomly selected bulb is of type A (70%).
•𝑃(𝐷)P(D) is the total probability of a defective bulb, which is the sum of the probabilities of the bulb being defective and of
type A plus the probability of the bulb being defective and of type B.
Plugging in the values:
𝑃(𝐴∣𝐷)=(0.05×0.70)(0.05×0.70+0.10×0.30)P(A∣D)=(0.05×0.70+0.10×0.30)(0.05×0.70)​
𝑃(𝐴∣𝐷)=0.0350.035+0.030P(A∣D)=0.035+0.0300.035​
𝑃(𝐴∣𝐷)=0.0350.065P(A∣D)=0.0650.035​
𝑃(𝐴∣𝐷)≈0.538P(A∣D)≈0.538
So, given that the bulb you selected is defective, there's approximately a 53.8% chance that it is of
Inference using full joint distribution:-
Inference using the full joint distribution involves making predictions or drawing conclusions about
certain variables based on the complete probability distribution of all the variables involved in a given problem or scenario.

We have historical data on delivery times for various distances under different traffic conditions. This data can be used to
build a joint probability distribution, where each entry represents the probability of a specific delivery time given a
distance and traffic condition.
Distance (km) Traffic P(Distance, Traffic) Delivery Time (min)
5 L 0.3 30
5 H 0.2 60
10 L 0.2 45
10 H 0.3 90

Inference Task: A new delivery needs to be made at a distance of 8 kilometers. You want to predict the most likely
delivery time.

Real-world approach:
In practice, with continuous variables, full joint distribution tables become impractical.
Bayes’rule:-

Base rule or theorem is a way to apply conditional probability for prediction. Conditional
probability is the probability of an event happening, given that it has some relationship to
one or more other events.

For example your probability of getting a parking space is connected to the time of
day you park where you park and what conventions are going on at any time. Bayes’
theorem is slightly more notched.

Mathematically, Bayes theorem is defined as:

P(A/B) = P(B/A)*P(A)/P(B)
Ex 1: Find out a patient’s probability of having liver disease if they are an alcoholic. “Being an
alcoholic” is the test for liver disease with following.
Let A could mean the event “Patient has liver disease.” past data tells you that 10% of patients entering your
clinic have liver disease. P(A)=0.10.

B could mean the litmus test that “Patient is an alcoholic.” Five percent of the clinic’s patients are alcoholics.
P(B)=0.05.

Among those patients diagnosed with liver disease, 7% are alcoholics.


Then P(B/A): The probability that a patient is alcoholic, given that they haver liver disease, is 7%.

Now , By bayes’ theorem we get,


P(A/B) = (0.07 *0.1)/0.05=0.14

In other words, if the patient is an alcoholic, their chances of having liver disease is 0.14(14%).

Uses of Bayes' Rule:


Spam Filtering
Medical Diagnosis
Search Engines
Bayesian Networks:
Bayesian networks are type of probabilistic graphical model that uses Bayesian inference for probability computations
Bayesian networks aim to model conditional dependence, and therefore causation by representing conditional dependence by
edges in a directed graph. Through this relationships one can efficiently conduct influence on the random variables in the graph
through the use of vectors.

A Bayesian network is a directed acyclic graph which consists of:

A set of random variables which makes up the nodes of the network.

A set of directed links connecting pairs of nodes. If there is an arrow from node X to node Y, X is said to be a parent of Y.

Each node Xi has a conditional probability distribution P(Xi) parents(Xi) that quantifies the effect of the parents on the
node.
Reasoning in Belief Networks:
Reasoning in a belief network, also known as a Bayesian network, involves using the
network structure and conditional probability tables (CPTs) to answer questions about the
state of the variables in the network. Key concept Involved :-
1. Network Structure:
2. Conditional Probability Tables (CPTs):
3. Inference Tasks:
4. Inference Algorithms:
Reasoning Process:
Reasoning process in a belief network:
1.Identify the Query: What do you want to find out? This determines the type of inference task (e.g.,
posterior probability).

2.Set the Evidence: Specify the values of some variables for which you have observations.

3.Apply an Inference Algorithm: Use an appropriate algorithm based on the network structure and the
type of inference task.

1.Obtain the Results: The algorithm will calculate the probabilities or most likely explanations based on
the evidence and the network structure.
Fuzzy logic:-

The word fuzzy refers to things which are not clear. Any event, process, or function that is changing continuously
cannot always be defined as either true or false, which means that we need to define such activities in a fuzzy manner.

Classical logic only permits conclusions which are either true or false. However, there are also propositions with variable answers,
such as one might find when asking a group of people to identify a color.

Take a look at the following diagram. It shows that in fuzzy systems, the values are indicated by a number in the range from 0 to
1. Here 1.0 represents absolute truth and 0.0 represents about falseness. The number which indicates the value in fuzzy systems
is called the truth value.
In other words we can say that Fuzzy logic is not logic that is Fuzzy, but logic that is used to
describe fuzziness. There can be numerous other examples like this with the help of which we
can understand the concept of fuzzy logic.

Fuzzy logic was introduced in 1965 by lofty A Zadeh in his research paper “fuzzy sets”. He is
considered as the father of Fuzzy Logic.

Fuzzy Set:
A set X in which each element y has a grade of membership ux(y) in the range 0 to 1.

For example: if cold is a fuzzy set, exact temperature values might be mapped to the fuzzy set as
follows:
. 15 degrees -> 0.2 (slightly cold)
. 10 degrees -> 0.5 (quite cold)
. 0 degrees -> 1 (totally cold)
Fuzzy sets can be considered as an extension and gross oversimplification of classical sets.
Basically it allows partial membership which means that it contain elements that have varying
degrees of membership in the set.
Membership in fuzzy set

In fuzzy logic, membership in a fuzzy set refers to the degree to which an element belongs to
that set. Unlike classical sets where membership is a binary decision (either in or out), fuzzy
sets allow for a gradual transition between belonging and not belonging. This degree of
membership is represented by a value between 0 and 1:

•0: Represents complete non-membership in the fuzzy set.

•1: Represents complete membership in the fuzzy set.

The degree of membership in a fuzzy set is determined by a membership function. This


function is a mathematical formula that maps an element (e.g., a temperature value) to its
corresponding degree of membership in the set.
membership function using a triangular function:

•Temperature below 65°F (18.3°C): Degree of membership = 0 (completely not comfortable)

•Temperature between 65°F (18.3°C) and 72°F (22.2°C): Degree of membership gradually
increases from 0 to 1 (increasing comfort)

•Temperature between 72°F (22.2°C) and 78°F (25.5°C): Degree of membership stays at 1
(fully comfortable)

•Temperature above 78°F (25.5°C): Degree of membership gradually decreases from 1 to 0


(decreasing comfort)
Benefits of Fuzzy Set Approach:

•More Natural Control: This approach allows for a smoother transition between heating and
cooling. As the temperature deviates slightly from the ideal range, the system can gradually
adjust the heating/cooling power based on the degree of membership in the "comfortable
temperature" set.

•Flexibility: The membership function can be customized based on user preferences or


specific needs. Someone might prefer a slightly cooler "comfortable" range than another
person.

Fuzzification:-
The process of translating the major numerical values into fuzzy linguistic values is called
fuzzification. In other words, fuzzification is where membership functions are applied, and the degree of
membership is determined.

Defuzzification:-
Defuzzification is the process of producing a quantifiable result in fuzzy logic. The fuzzy inference will
output a fuzzy result, described in terms of degree of membership of the fuzzy sets. Defuzzification interprets the
membership degree in the fuzzy sets into a specific action or real value.
Advantages of Fuzzy logic System:-

Disadvantages of fuzzy logic system:-

Application of fuzzy logic system:-


Fuzzy rule based system:- A fuzzy rule-based system (FRBS) is a type of artificial intelligence system that combines fuzzy logic with
rule-based systems. It uses fuzzy sets and fuzzy rules to make decisions in situations where the data or knowledge is imprecise or
subjective.

Components of a Fuzzy Rule-Based System:


•Fuzzy Sets: As discussed earlier, these sets represent concepts with varying degrees of membership, allowing for
gradual transitions between categories.
•Membership Functions: These functions define the degree of membership for elements in a fuzzy set.
•Fuzzy Rules: These are "if-then" statements that use fuzzy sets to describe the conditions (antecedents) and the
consequences (consequents) of the rule. They allow the system to reason with imprecise information.
Scenario: A traffic light control system at an intersection.
Inputs:
•Number of cars waiting in the North-South direction (N-S): Fuzzy set with categories like "Low," "Medium," and "High"
based on car count.
•Number of cars waiting in the East-West direction (E-W): Another fuzzy set with categories like "Low," "Medium," and
"High" based on car count.
Outputs:
•Traffic light duration for N-S direction: Can be fuzzy sets like "Short," "Medium," "Long" representing the duration the light
stays green for N-S traffic.
Fuzzy Rules:
•Rule 1: "If N-S is High and E-W is Low, Then N-S light duration is Long"
•Rule 2: "If N-S is Medium and E-W is Low, Then N-S light duration is Medium"
•Rule 3: "If N-S is Low and E-W is High, Then N-S light duration is Short"
•Rule 4: "If N-S is Low and E-W is Medium, Then N-S light duration is Medium"

You might also like