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

Unit 2

Uploaded by

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

Unit 2

Uploaded by

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

ARTIFICIAL INTELLIGENCE

AND
EXPERT SYSTEMS (CSE209)

Harwinder Singh Sohal


UID: 32306
Introduction
Knowledge Representation
• Representations & mappings
• Approaches in knowledge representation
• Issues in knowledge representation, Propositional logic
• Predicate logic, Procedural versus declarative knowledge
• Logic programming, Forward versus backward reasoning
Statistical reasoning
• Probability & Bayes' theorem
• Bayesian networks
• Dempster-Shafer-Theory, Certainty factors & rule-based systems
2
Knowledge Representation
• The field concerned with how knowledge about the world can be
represented in a form that a computer system can utilize to solve complex
tasks like diagnosing a medical condition or having a conversation in
natural language.
Representations

Propositional Logic:
• Definition: Represents facts as simple, atomic propositions (true/false statements).
• Example: "The sky is blue" can be represented as a proposition like P, where P could
be true or false.
First-Order Logic (Predicate Logic):
• Definition: Extends propositional logic by including objects, properties of
objects, and relations between objects.
• Example: "All humans are mortal" could be represented as ∀x (Human(x) →
Mortal(x)).
Semantic Networks:
• Definition: Represents knowledge as a network of nodes (concepts) and
edges (relationships).
• Example: A network could represent the concept of a "Dog" with edges
linking to properties like "has fur", "is a mammal", etc.
Semantic Networks:
Definition: Represents knowledge as a network of nodes
(concepts) and edges (relationships).
Example: A network could represent the concept of a "Dog"
with edges linking to properties like "has fur", "is a
mammal", etc.
Frames:
Definition: Structured data representations, often used to
represent stereotyped situations.
Example: A "House" frame might include slots like "rooms",
"roof type", "address", etc., each with possible values or sub-
frames.
Ontologies:
Definition: Structured frameworks for organizing information,
often hierarchical and used in knowledge-based systems.
Example: An ontology for animals might classify "Mammals"
as a subclass of "Animals", with further subdivisions into
species like "Dogs", "Cats", etc.
Rules:
Definition: Represent knowledge in the form of "if-then"
statements that define actions or conclusions.
Example: "If it is raining, then bring an umbrella" can be
represented as IF raining THEN bring(umbrella).
Bayesian Networks:
Definition: Graphical models representing probabilistic
relationships among variables.
Example: A Bayesian network might represent the
probability of having a disease given certain symptoms.
Fuzzy Logic:
Definition: Represents knowledge with degrees of truth
rather than binary true/false.
Example: "The weather is hot" could be 0.8 true, indicating
a high degree of truth, but not absolute.
Mappings
Mappings in knowledge representation refer to how real-world concepts and relationships
are translated into these representational formats. This involves defining the relationships
between concepts, how they interact, and the rules governing these interactions.
From Real World to Representation:
Example: Mapping a real-world scenario like "A dog chasing a cat" into a semantic
network could involve creating nodes for "dog", "cat", and "chase", and linking them
with directed edges.
Example: "Dog" → "Chases" → "Cat“

Visualization Example:
Nodes:
"Dog"
"Chase" (action)
"Cat"
Edges:
"Dog" → "Chase"
"Chase" → "Cat"
Inference:
Definition: The process of deriving new knowledge from existing representations.
Example: In a rule-based system, if we know "If A then B" and "A is true", we can
infer that "B is true".

• Start: Represent the beginning of the reasoning process.


Premise 1: "If A then B"
• Represent this with an arrow pointing to the next step.
Premise 2: "A is true"
• Another arrow leading to the next step.
Inference: "B is true"
• This is the conclusion drawn based on the premises.
Transformation Between Representations:
Example: Converting a semantic network into a set of logical propositions or vice
versa.
Integration:

Definition: Combining different types of knowledge

representations into a cohesive system.

Example: Integrating a rule-based system with a Bayesian

network to make decisions under uncertainty.


Integrating a Rule-Based System with a Bayesian Network:
•Rule-Based System: Uses predefined rules to make decisions. For example, a rule
might be "If symptom A is present, then diagnosis B is likely."
•Bayesian Network: A probabilistic graphical model that represents variables and
their conditional dependencies using a directed acyclic graph. It helps in reasoning
under uncertainty.
Integration Example:
•Scenario: In a medical diagnosis system, you might integrate a rule-based system with a Bayesian
network.
• Rule-Based Component: Determines initial diagnosis based on specific symptoms using a set of
rules.
• Bayesian Network Component: Refines the diagnosis by considering probabilities and
uncertainties, incorporating additional data such as patient history or test results.
Normalization:
Definition: The process of ensuring that the knowledge
representation is consistent, unambiguous, and optimized
for processing.
Example: Normalizing an ontology by ensuring that each
concept is uniquely defined and properly categorized.
Normalizing an Ontology:
•Ontology: A formal representation of knowledge as a set of concepts and their relationships within a
domain.
•Normalization Process:
• Unique Definition: Ensuring each concept is defined in a way that avoids duplication and
overlapping with other concepts. For example, "Person" and "Human" should not be used
interchangeably if they have distinct meanings in the ontology.
• Proper Categorization: Organizing concepts into a hierarchical structure that accurately reflects
their relationships. For instance, categorizing "Mammal" as a subclass of "Animal" and ensuring
all specific mammals (e.g., "Dog," "Cat") are correctly placed under "Mammal."
[Concept: Animal]
|
v
[Subclass: Mammal]
|
v
[Specific Concepts: Dog, Cat]

In this graph:
1.Animal is the root concept.
2.Mammal is a subclass of Animal.
3.Dog and Cat are specific examples of Mammal.
Normalization Steps:
4.Ensure Unique Definitions: Verify that each concept like "Animal," "Mammal," and "Dog" has a unique and clear
definition.
5.Proper Categorization: Place concepts into the correct hierarchical structure, reflecting their relationships accurately.
Approaches in
knowledge representation
Approaches in knowledge representation refer to the different methods and strategies
used to encode information in a way that AI systems can utilize to perform reasoning,
learning, and decision-making. Here are some common approaches:

1. Logical Representation
Propositional Logic: Encodes knowledge as simple, declarative statements that are
either true or false.
Example: "It is raining" is represented as a single proposition P.
First-Order Logic (Predicate Logic): Extends propositional logic by including quantifiers
and predicates that can represent relationships between objects.
Example: "All humans are mortal" can be represented as ∀x (Human(x) →
Mortal(x)).
Description Logic: A subset of first-order logic used primarily for defining and reasoning
about concepts and their relationships within ontologies.
Example: Describing the concept of "Animal" with properties like "hasOrganism",
"isLiving", etc.
2. Procedural Representation
Production Rules: Knowledge is represented as "if-then" rules, which are used
to infer new information or perform actions.
Example: "If it is raining, then bring an umbrella" is represented as IF raining
THEN bring(umbrella).
Scripts: Predetermined sequences of actions or events, often used to represent
stereotypical situations.
Example: A "restaurant script" might include steps like entering the
restaurant, ordering food, eating, and paying the bill.
3. Semantic Networks
Represents knowledge as a graph of nodes (concepts) and edges (relationships
between concepts). This approach is particularly effective for representing
hierarchical and associative relationships.
Example: A semantic network for "Bird" might include nodes for "Animal",
"Bird", "CanFly", with edges indicating relationships like "isA" or
"hasProperty".
4. Frame-Based Representation
Frames: Data structures that represent stereotyped situations, with
slots for filling in details. Frames can inherit properties from other
frames, enabling efficient organization of knowledge.
Example: A frame for a "Car" might include slots like "make",
"model", "color", with possible sub-frames for "Engine", "Wheels",
etc.
5. Ontology-Based Representation
Ontologies: Structured frameworks that define the concepts,
categories, properties, and relationships within a specific domain.
Ontologies are used to ensure consistency and interoperability
between systems.
Example: An ontology for medical knowledge might define
relationships between diseases, symptoms, treatments, and
medical procedures.
6. Bayesian Networks
Represents probabilistic relationships between variables using directed
acyclic graphs (DAGs). Each node represents a variable, and the edges
represent probabilistic dependencies.
Example: A Bayesian network might model the probability of having a
disease based on various symptoms and risk factors.

7. Fuzzy Logic
Extends classical logic by allowing values to range between 0 and 1,
representing degrees of truth. This is particularly useful in handling
uncertainty and imprecision in knowledge representation.
Example: "The weather is somewhat hot" might be represented with a
truth value of 0.7 rather than a binary true/false.
8. Connectionist Models (Neural Networks)
Represents knowledge as patterns of activation across networks of
simple units (neurons). While this approach is more focused on learning
and pattern recognition, it can be used for knowledge representation in
the form of learned weights and connections.
Example: A neural network might learn to recognize images of cats
by adjusting the weights of connections between neurons based on
training data.
9. Hybrid Approaches
Combines two or more of the above approaches to leverage their
strengths and mitigate their weaknesses.
Example: A hybrid system might use frames for structured
knowledge representation and Bayesian networks to handle
uncertainty in decision-making processes.
Issues in knowledge representation
Knowledge representation is a critical aspect of artificial intelligence
and expert systems, but it comes with several challenges and issues
that can impact the effectiveness of AI systems. Here are some of the
key issues in knowledge representation:

1. Complexity
Representation of Complex Knowledge: Capturing and representing
complex, real-world knowledge in a structured format can be
challenging. Real-world scenarios often involve numerous interrelated
concepts, and accurately modeling these relationships requires
sophisticated representation techniques.
Example: Modeling the nuanced relationships between various
medical symptoms, diseases, and treatments in a healthcare
system.
2. Ambiguity
Handling Ambiguous Information: Language and real-world scenarios
often contain ambiguities that are difficult to represent and reason
about in a knowledge-based system. Ambiguity arises when a concept
or statement can have multiple interpretations.
Example: The word "bank" can refer to a financial institution or the
side of a river, depending on the context.
3. Incomplete Knowledge
Dealing with Incomplete Information: In many cases, the knowledge
available to a system is incomplete or missing important details.
Representing and reasoning with incomplete knowledge is a significant
challenge.
Example: An expert system might not have all the data needed to
make a precise medical diagnosis but still needs to provide
recommendations.
4. Uncertainty
Managing Uncertainty: Real-world knowledge often involves
uncertainty, such as the likelihood of an event occurring or the
probability of a particular outcome. Representing and reasoning with
uncertain knowledge is complex.
Example: A weather prediction system might need to represent the
probability of rain, which can never be stated with absolute certainty.
5. Scalability
Scalability of Representation: As the amount of knowledge grows, the
representation system must scale accordingly. Large knowledge bases
can become difficult to manage, leading to performance issues in
reasoning and retrieval.
Example: A knowledge base for a legal expert system might contain
millions of rules and facts, making efficient retrieval and reasoning
challenging.
6. Inference and Reasoning
Efficient Inference: Deriving conclusions from a large knowledge base can be
computationally expensive. Ensuring that the reasoning process is efficient
and scalable is a major issue.
Example: In a rule-based system, checking all possible rules to infer a new
piece of knowledge can become infeasible as the number of rules
increases.
7. Knowledge Acquisition
Difficulty in Acquiring Knowledge: Extracting and formalizing expert
knowledge is often a slow and labor-intensive process. Experts may struggle
to articulate their knowledge, and translating it into a formal representation
can introduce errors.
Example: Capturing the tacit knowledge of a medical expert about how to
diagnose rare diseases can be difficult and time-consuming.
8. Consistency
Ensuring Consistency: In large knowledge bases, maintaining consistency
between different pieces of knowledge can be challenging. Inconsistencies
can lead to incorrect inferences or system failures.
Example: An expert system that contains conflicting rules about the side
effects of a medication may give contradictory advice to users.
9. Context Sensitivity
Handling Context: Knowledge is often context-dependent, meaning that
the relevance or interpretation of a piece of information can change
depending on the situation. Representing and reasoning with context-
sensitive knowledge is complex.
Example: The statement "It is cold" can mean different things depending
on the location (e.g., "cold" in Alaska vs. "cold" in the tropics).
10. Interoperability
Interoperability between Systems: Different systems may use different
representations for similar concepts, leading to challenges in integrating
knowledge from multiple sources.
Example: Integrating knowledge from different medical databases that
use varying terminologies and ontologies can be difficult.

11. Updating Knowledge


Dynamic and Real-Time Knowledge Updating: Knowledge is not static and often changes
over time. Ensuring that a knowledge-based system can update its knowledge base in
real-time without disrupting ongoing processes is challenging.
Example: A stock trading system needs to update its knowledge about market
conditions continuously, requiring real-time updates to its knowledge base.
12. Expressiveness vs. Efficiency

Balancing Expressiveness and Efficiency: More expressive knowledge representations can capture

complex relationships but may require more computational resources. Finding a balance between

expressiveness and efficiency is an ongoing challenge.

Example: First-order logic is more expressive than propositional logic, but it is also computationally

more expensive to process.


Propositional logic
• Propositional logic, also known as sentential logic or boolean logic, is a branch of
logic that deals with propositions, which are statements that are either true or
false. It is the simplest form of logic used in various fields, including computer
science, mathematics, and philosophy, to represent and reason about truth
values.

• Key Concepts in Propositional Logic

• Propositions:
• A proposition is a declarative statement that can be either true or false, but not both.

• Examples:

• "The sky is blue." (True)


30
• "2 + 2 = 5." (False)
Logical Connectives:
• AND (∧): The conjunction of two propositions is true if both propositions are true.
Example: P ∧ Q is true if both P and Q are true.
• OR (∨): The disjunction of two propositions is true if at least one of the propositions is true.
Example: P ∨ Q is true if either P or Q is true.
• NOT (¬): The negation of a proposition is true if the proposition is false, and vice versa.
Example: ¬P is true if P is false.
• IMPLIES (→): The implication P → Q means "if P, then Q." It is true except when P is true and Q is false.
Example: "If it rains, then the ground will be wet." If it rains (P is true) and the ground is not wet (Q is false),
the implication is false.
• BICONDITIONAL (↔): The biconditional P ↔ Q means "P if and only if Q." It is true when both P and Q have
the same truth value.
Example: "You can go to the party if and only if you finish your homework." This is true if both conditions
are either true or false.
Truth Tables:
A truth table is a systematic way of listing all possible truth values of
propositions and their combinations using logical connectives.

Tautologies, Contradictions, and Contingencies:


Tautology: A proposition that is always true, regardless of the truth
values of its components.
Example: P ∨ ¬P is always true.
Contradiction: A proposition that is always false, regardless of the
truth values of its components.
Example: P ∧ ¬P is always false.
Contingency: A proposition that can be either true or false, depending
on the truth values of its components.
Example: P ∧ Q is true only if both P and Q are true.
Logical Equivalence:
Two propositions are logically equivalent if they have the same truth value
in all possible scenarios.
Example: ¬(P ∨ Q) is logically equivalent to ¬P ∧ ¬Q. This is known as De
Morgan's law.
Implication and Inference:
In propositional logic, one can draw inferences based on implications.
Modus Ponens: If P → Q and P are both true, then Q must be true.
Modus Tollens: If P → Q is true and Q is false, then P must be false.
Applications of Propositional Logic
Digital Circuit Design: Propositional logic is fundamental in designing and analyzing digital
circuits, where logical connectives correspond to logic gates.
Automated Reasoning: It is used in AI for automated theorem proving and reasoning
systems.
Programming: Propositional logic forms the basis for conditions and control flow in
programming.
Formal Verification: Ensures that systems behave correctly according to their specifications,
especially in safety-critical systems.
Limitations of Propositional Logic
Expressiveness: Propositional logic can only express simple true/false
statements and lacks the ability to represent more complex statements
involving objects, relationships, or quantifiers (such as "all", "some").
Scalability: For large problems, the number of propositions and
combinations can become unmanageable.
Inability to Handle Uncertainty: Propositional logic deals with absolute
truths, not probabilities or degrees of truth.
Predicate logic
It is a formal language that uses predicates, variables, and
quantifiers to express propositions. It's used in many fields,
including artificial intelligence, mathematics, computer
science, and natural language processing
Predicate logic
Predicate logic, also known as first-order logic (FOL), extends propositional logic by introducing
predicates, quantifiers, and variables, allowing for a more expressive form of reasoning. While
propositional logic deals with simple true/false propositions, predicate logic allows for the expression of
more complex statements involving objects and their properties or relationships.
Key Concepts in Predicate Logic
Predicates:
A predicate is a function that takes one or more arguments and returns a truth value (true or false).
Predicates describe properties of objects or relationships between objects.
Examples:
Human(x): Predicate indicating that "x is a human."
Loves(x, y): Predicate indicating that "x loves y."
Terms:
Constants: Represent specific objects in the domain.
Example: John, Apple, 3.
Variables: Symbols that can represent any object in the domain.
Example: x, y, z.
Functions: Map objects to other objects within the domain.
Example: FatherOf(x) might represent the father of x.
Quantifiers:
Quantifiers are used to express statements about multiple objects in the domain.
Universal Quantifier ( ∀ ): Indicates that a statement applies to all objects in the domain (for all, every).
Example: ∀x (Human(x) → Mortal(x)) means "For all x, if x is a human, then x is mortal."
Existential Quantifier ( ∃ ): Indicates that there exists at least one object in the domain for which the
statement is true (some , any)
Complex Formulas:
Negation (¬): Negates the truth value of a formula.
Example: ¬Human(Socrates) means "Socrates is not a human."
Conjunction ( ∧ ): Combines two formulas, both of which must be true for the conjunction to be true.
Example: Human(Socrates) ∧ Mortal(Socrates) means "Socrates is human and mortal."
Disjunction ( ∨ ): Combines two formulas, at least one of which must be true.
Example: Human(Socrates) ∨ Human(Plato) means "Socrates is a human or Plato is a human."
Implication ( → ): If the first formula is true, then the second formula must also be true.
Example: Human(Socrates) → Mortal(Socrates) means "If Socrates is human, then he is mortal."
Biconditional ( ↔ ): Both formulas must have the same truth value.
Example: Human(Socrates) ↔ Mortal(Socrates) means "Socrates is human if and only if he is
mortal."
Inference Rules:
Predicate logic supports various inference rules that allow deriving new formulas from
existing ones.
Universal Instantiation: Allows substituting a specific instance for a universally
quantified variable.
Example: From ∀x (Human(x) → Mortal(x)), you can infer Human(Socrates) →
Mortal(Socrates).
Existential Instantiation: Allows introducing a specific instance for an existentially
quantified variable.
Example: From ∃x (Human(x)), you can infer Human(John), assuming John is an
instance of x.
Modus Ponens: If P → Q and P are both true, then Q must be true.
Applications of Predicate Logic
• Database Query Languages: SQL and other query languages often use concepts from
predicate logic to express queries.
• Automated Theorem Proving: Predicate logic is the foundation for systems that prove
mathematical theorems automatically.
• Artificial Intelligence: It is used for knowledge representation and reasoning in expert
systems, natural language processing, and more.
• Formal Verification: Predicate logic is used in verifying the correctness of software and
hardware systems.
Limitations of Predicate Logic

• Undecidability: Some problems in predicate logic are undecidable, meaning no

algorithm can determine whether certain statements are true or false in all

cases.

• Complexity: Predicate logic can become computationally expensive, especially

when dealing with large domains or complex relationships.

• Interpretation: The meaning of predicates and functions depends on the

specific interpretation of the domain, which can lead to ambiguity or

misinterpretation.
Procedural versus declarative knowledge
Procedural and declarative knowledge are two fundamental types of knowledge that
describe how we understand and use information. They differ in both their nature and
their application in various fields, including artificial intelligence, cognitive science, and
education.
Procedural knowledge refers to the knowledge of how to do something. It involves
knowing the processes, methods, or steps required to accomplish tasks. It is sometimes
called "know-how" knowledge.
Declarative knowledge refers to facts, information, and concepts that one knows and can
explicitly state or declare. It is sometimes called "know-what" knowledge.
Characteristics of Procedural Knowledge
• Implicit: Procedural knowledge is often difficult to articulate fully in words; it’s
more about "doing" than "knowing." It's typically acquired through practice and
experience.
Example: Knowing how to ride a bicycle, tie your shoes, or play a musical
instrument.
• Dynamic: It involves sequences of actions or operations, often executed over time.
• Performance-Oriented: Procedural knowledge is directly related to performing
tasks or operations effectively.
• Less Easily Transferred: Since it’s implicit, procedural knowledge is harder to teach
or transfer to others without hands-on practice or demonstration.
Characteristics of Declarative knowledge

• Explicit: Declarative knowledge can be articulated in words, symbols, or images. It’s the type of

knowledge you can express through statements.

Example: "Paris is the capital of France" or "A triangle has three sides."

• Static: Declarative knowledge represents facts or data that do not change in the context of its use.

• Cognitive Representation: It is stored in memory as facts, concepts, and relationships. It often

involves the use of schemas or frameworks to organize and categorize information.

• Easily Transferred: Since declarative knowledge is explicit, it can be easily communicated, taught,

or shared with others.


Aspect Declarative Knowledge Procedural Knowledge

Nature Facts, information, "know-what" Processes, methods, "know-how"

Expression Can be explicitly stated Often implicit and hard to articulate

Learned through study and Learned through practice and


Learning Method
memorization repetition
Difficult to transfer without
Transferability Easily communicated and taught
demonstration

Examples "Paris is the capital of France." Knowing how to ride a bike

Helps in understanding and Helps in performing tasks and


Cognitive Role
explaining solving problems
Knowledge bases, rule-based Algorithms, expert systems,
AI Application
systems procedural code
Logic programming
Logic programming is a programming paradigm based on formal logic. In
logic programming, programs are written as a set of logical statements, and
computation is performed by applying inference rules to derive conclusions
or solve problems. The most common logic programming language is
Prolog (short for "Programming in Logic").
Key Concepts in Logic Programming
1.Declarative Nature:
•Logic programming is a declarative paradigm, meaning that
you specify what you want to achieve rather than how to achieve
it. The program consists of a set of facts and rules, and the logic
programming engine determines how to satisfy the queries
posed to it.
2.Facts:
•A fact is a basic assertion about some information that is
considered to be true.
•Example: parent(john, mary). states that John is a parent of
Mary.
•Rules:
•A rule is a logical statement that defines a relationship between
facts. It usually takes the form of an implication.
•Example: grandparent(X, Y) :- parent(X, Z), parent(Z, Y). means "X is a grandparent of Y if X is a
parent of Z and Z is a parent of Y."

•Queries:
•A query is a question posed to the logic programming system to find
out whether certain facts are true or to find values that satisfy certain
conditions.
•Example: ?- grandparent(john, X). asks the system to find all X such that John is a grandparent of X.
•Inference Engine:
•The inference engine is the core component of a logic programming system that applies
inference rules to the facts and rules to derive conclusions. The most common inference method
used in logic programming is backward chaining.
•Unification:
•Unification is the process of matching two logical terms by finding a substitution for variables
that makes the terms identical.
•Example: To unify parent(X, mary) with parent(john, mary), the system identifies that X must be
john.

•Recursion:
•Logic programming frequently uses recursion to define complex relationships or solve problems.
Prolog: A Logic Programming Language
Prolog (Programming in Logic) is the most widely known logic programming

language. It was developed in the early 1970s and is used in fields like artificial
intelligence, computational linguistics, and symbolic reasoning.

Prolog Syntax and Semantics


•Facts: Represent basic assertions prolog
sibling(john, mary).
•Rules: Define relationships based on existing facts. prolog
cousin(X, Y) :- parent(Z, X), sibling(Z, W), parent(W, Y).
•Queries: Ask questions of the system prolog
?- cousin(jane, mary).
•Lists: Prolog has built-in support for lists, which are essential for many
algorithms prolog
member(X, [X|_]).
member(X, [_|Tail]) :- member(X, Tail).
Applications of Logic Programming
1.Artificial Intelligence: Logic programming is extensively used in AI for tasks such as
knowledge representation, natural language processing, and automated reasoning.
2.Expert Systems: Logic programming is used to build expert systems, which are computer
programs that emulate the decision-making ability of a human expert.
3.Symbolic Reasoning: Logic programming excels at solving problems that involve
symbolic manipulation, such as theorem proving and symbolic mathematics.
4.Constraint Logic Programming: A variant of logic programming that allows the inclusion
of constraints (e.g., arithmetic constraints) within the logic programming framework.
5.Natural Language Processing: Logic programming is used for parsing and understanding
natural language, where grammar rules can be represented as logical rules.
Advantages of Logic Programming
•Expressiveness: Logic programming allows for the concise
representation of complex relationships and constraints.
•Ease of Reasoning: The declarative nature of logic programming makes
it easier to reason about programs and verify their correctness.
•Flexibility: It’s well-suited for problems that involve symbolic
reasoning, pattern matching, and searching.
Challenges of Logic Programming
•Efficiency: Logic programming can be less efficient than imperative
programming for certain types of problems, particularly those that
require extensive numerical computation.
•Learning Curve: The paradigm is quite different from procedural or
object-oriented programming, so it can be challenging for those
accustomed to other styles of programming.
•Limited Use Cases: Logic programming is not as widely used as other
paradigms, so it’s often reserved for specific applications where its
strengths are most needed.
Forward versus backward reasoning
Forward Reasoning (Forward Chaining) (Data-driven):
Forward reasoning, also known as forward chaining, is a data-driven approach where
reasoning starts from known facts and applies inference rules to derive new facts or
conclusions until a goal or conclusion is reached.
Forward chaining starts with facts and applies rules to reach a goal.
Key Characteristics:
•Data-Driven: The process begins with available data or initial facts.
•Inference Rules: These rules are applied to the data to derive new facts.
•Goal Discovery: The reasoning process continues until a specific goal or a conclusion
is derived.
Process:
1.Start with Known Facts: Begin with a set of known facts or observations.
2.Apply Rules: Apply inference rules to these facts to derive new facts.
3.Repeat: Continue applying rules to newly derived facts, iterating through the
knowledge base.
4.Goal Reached: Stop when the goal or conclusion is reached, or no more rules can be
applied.
1. Applications of Forward Chaining:

a) Expert Systems (Medical Diagnosis)

•Example: A healthcare expert system can diagnose diseases based on symptoms. The system starts with the

patient's symptoms (facts) and applies medical rules to conclude a diagnosis.

•Reason: Forward chaining is suitable here as it involves gathering data (symptoms) and using rules to arrive

at a potential diagnosis.

b) Rule-based Systems in Monitoring and Control

•Example: In industrial automation, forward chaining is used in systems that monitor machine conditions. If

certain conditions are met (e.g., high temperature), the system will trigger alarms or shut down machinery.

•Reason: The system continuously monitors sensor data and applies rules to take action as conditions

change.
Example:
Let’s consider a medical diagnosis system.
Rules:
1.If the patient has a fever and cough, then the patient has the flu.
2.If the patient has the flu, then prescribe rest and fluids.
Facts: The patient has a fever and cough.
Process:
•Start with the known facts: the patient has a fever and cough.
•Apply Rule 1: Since the patient has both symptoms, we conclude the patient has the flu.
•Apply Rule 2: Since the patient has the flu, the system concludes to prescribe rest and
fluids.
In forward chaining, the process moves from facts to conclusions.
Backward Reasoning (Backward Chaining) (Goal-driven):
Backward reasoning, also known as backward chaining, is a goal-driven approach
where reasoning starts from a specific goal or hypothesis, and inference rules are
applied in reverse to determine if the goal can be satisfied by existing facts.
Key Characteristics:
•Goal-Driven: The process begins with a specific goal or conclusion that needs to be
proven or achieved.
•Rule Application: Rules are applied in reverse to see if the goal can be derived from
existing facts.
•Fact Validation: The system works backward from the goal, validating whether the facts
can support the goal.
Process:
1.Start with a Goal: Begin with a hypothesis or goal you want to prove or
achieve.
2.Apply Rules Backward: Identify rules that could lead to the goal and check if
their premises are satisfied.
3.Check Facts: For each premise, check if it can be supported by existing facts
or if it needs to be further broken down.
4.Goal Satisfied: The process continues until the goal is proven true by existing
facts or the goal is deemed unachievable.
2. Applications of Backward Chaining:

a) AI-based Diagnostic Systems

•Example: Used in medical systems to diagnose diseases by working from potential diseases (goals) and checking

whether the patient's symptoms (facts) match.

•Reason: Backward chaining is efficient when there are many possible diseases

and the system works backward to verify which one fits the symptoms, focusing only on relevant possibilities.

b) Expert Systems for Troubleshooting (Technical Support)

•Example: In systems troubleshooting (e.g., IT or automotive), backward chaining helps identify the cause of a

failure. If a system isn't working (goal), backward chaining checks possible causes by verifying conditions step by

step.

•Reason: The system starts from the desired state (goal) and traces potential reasons until the actual fault is

identified.
Example:
Same medical diagnosis system as above.
Goal: Prescribe rest and fluids (i.e., we want to know if this is the correct prescription).
Rules:
1.If the patient has a fever and cough, then the patient has the flu.
2.If the patient has the flu, then prescribe rest and fluids.
Facts: The patient has a fever and cough.
Process:
•Start with the goal: prescribe rest and fluids.
•Check if Rule 2 applies: The rule states we can prescribe rest and fluids if the patient has the flu.
•Now, work backward to see if the patient has the flu.
•Check Rule 1: The patient will have the flu if they have a fever and cough.
•Since the patient has a fever and cough (known facts), we conclude the goal is satisfied, and rest and fluids
are prescribed.
Forward Reasoning (Forward Backward Reasoning (Backward
Aspect Chaining) Chaining)
Starting Point Known facts or data A specific goal or hypothesis
Moves from the goal to check if
Direction Moves from facts to conclusions
facts support it
Nature Data-driven Goal-driven
Apply rules to known facts to Apply rules in reverse to prove
Process derive new facts the goal
Can generate many
intermediate conclusions, More focused on the goal,
Efficiency potentially inefficient if the goal potentially more efficient
is far from initial facts
Expert systems, data analysis, Problem-solving, theorem
Common Use Cases rule-based systems proving, diagnostics
Deriving that Socrates is mortal Proving Socrates is mortal by
Example from known facts validating premises
Probability & Bayes' Theorem
Probability
Probability is the mathematical framework for quantifying uncertainty. It represents the
likelihood of an event occurring within a certain context.
•Probability of an Event (P(A)): The likelihood that event A will occur, where 0 ≤ P(A) ≤ 1. A
probability of 0 indicates the event will not occur, and 1 indicates the event is certain to
occur.
Probability of an Event:
Simple Event: An event with a single outcome.
Compound Event: An event with multiple outcomes.
Formula: For a simple event A in a sample space S, P(A)=Number of favorable outcomes
Total number of possible outcomes
•Joint Probability: The probability of two events occurring together (e.g., P(A ∩ B) is the
probability that both A and B occur).
•Conditional Probability (P(A|B)): The probability that event A occurs given that event B
has already occurred. This is a key concept in Bayesian reasoning.

•Marginal Probability:
•The probability of an event occurring irrespective of other events. It is calculated by summing or
integrating over all possible values of the other variables.
•Independence:
•Two events A and B are independent if P(A∩B)=P(A)⋅P(B)
Examples of Conditional Probability

1.Medical Testing:

1. Scenario: Suppose there is a medical test for a disease with a known prevalence in the

population.

2. Events: Let A be the event that a person has the disease, and BBB be the event that the

person tests positive for the disease.

3. Conditional Probability: P(A∣B) is the probability that a person has the disease given that

they tested positive. This is useful in assessing the reliability of the test.
1. Medical Diagnosis
Scenario: A doctor wants to determine the probability that a patient has a
rare disease given that they tested positive for it.
•Prior Probability P(D): The probability of having the disease before the test
is 0.01 (1% prevalence).
•Likelihood P(T∣D): The probability of testing positive given the disease is
0.95(95% sensitivity).
•False Positive Rate P(T∣D′) : The probability of testing positive without the
disease is 0.05 (5% false positive rate).
Example : Weather Forecasting
•Scenario: Historical data shows that 30% of the days are rainy. On rainy days,
80% of the time it is cloudy. On non-rainy days, 20% of the time it is cloudy.
•Events:
• A: It rains.
• B: It is cloudy.
Objective: Find P(A∣B), the probability it will rain given that it is cloudy.
Bayes' Theorem
Bayes' Theorem is a fundamental concept in probability theory that describes how to
update the probability of an event based on new evidence. It provides a way to calculate
the conditional probability of an event, given the occurrence of another
event.P(H∣E)=(P(E∣H)⋅P(H)) / P(E)
•P(H∣E) is the posterior probability: the probability of the hypothesis H given the evidence E.

•P(E∣H) is the likelihood: the probability of the evidence E given that the hypothesis H is true.

•P(H) is the prior probability: the initial probability of the hypothesis before considering the evidence.

•P(E) is the marginal likelihood: the total probability of the evidence under all possible hypotheses.
Example 1: Medical Diagnosis

A certain disease affects 1% of a population. A diagnostic test for the disease is

90% accurate, meaning it correctly identifies 90% of people with the disease

(true positive rate), and it correctly identifies 90% of people without the

disease (true negative rate). If a person tests positive, what is the probability

they actually have the disease?


Example 2

Suppose a doctor is testing for a rare disease, which only affects 1% of the

population. There is a medical test available that is 90% accurate for

detecting the disease (sensitivity), and it also has a 95% accuracy for

correctly identifying those who don't have the disease (specificity).

Now, let's say a patient tests positive. We want to calculate the probability

that the patient actually has the disease, given the positive test result.
Bayesian Networks
Bayesian Networks (also known as Belief Networks) are graphical models that represent
the probabilistic relationships among a set of variables. Each node in the network
represents a variable, and the edges represent dependencies between them.
Key Features:
•Directed Acyclic Graph (DAG): The network is structured as a DAG, where each node
corresponds to a random variable, and edges indicate conditional dependencies.
•Conditional Probability Tables (CPTs): Each node has a CPT that specifies the probability
of the node given its parents in the network.
•Inference: Bayesian networks can be used to perform probabilistic inference, updating
beliefs about the state of the world as new evidence is introduced.
Components of Bayesian Networks
1.Nodes:
1. Represent random variables in the network. Each node can represent
discrete or continuous variables.
2. For example, in a medical diagnosis network, nodes might represent variables
like "Fever," "Cough," "Flu," and "Cold."
2.Edges:
1. Directed edges (arrows) between nodes represent probabilistic dependencies
or causal relationships.
2. An edge from node A to node B indicates that A has a direct influence on B.
3. Conditional Probability Tables (CPTs):
•Each node has an associated CPT that quantifies the effect of the parent nodes on
the node.
•For a node with discrete parents, the CPT provides the probability distribution of the
node given each combination of parent values.
•For example, if node B is influenced by nodes A and C, the CPT of B will give the
probability distribution P(B∣A,C).
Example 1: Medical Diagnosis
Scenario: A simple Bayesian Network for diagnosing a disease based on symptoms.
•Variables:
• D: Disease (e.g., flu) D
|
• S: Symptom (e.g., cough) +--+--+
| |
• F: Fever S F

Description:
•D (Disease) influences both S (Symptom) and F (Fever).
•The presence of the disease affects whether the patient shows symptoms and has a fever.
Example 2: Weather Prediction
Scenario: A Bayesian Network to predict the likelihood of rain given the weather forecast and
humidity levels.
F
•Variables: |
v
• R: Rain R
• F: Forecast (e.g., forecast predicts rain) |
v
• H: Humidity H

Description:
•F (Forecast) affects R (Rain).
•R (Rain) influences H (Humidity).
Inference in Bayesian Networks
Inference involves calculating the probabilities of certain variables given evidence about others. This can
be done through various methods:
1.Exact Inference:
1. Algorithms like Variable Elimination and Belief Propagation are used to perform exact inference
in Bayesian Networks.
2. These methods compute the marginal probability distribution of a subset of variables given
evidence.
2.Approximate Inference:
1. When exact inference is computationally infeasible, approximate methods such as Monte Carlo
Sampling (e.g., Gibbs Sampling) can be used to estimate probabilities.
Example of a Bayesian Network
Consider a simple Bayesian Network for a medical diagnosis:
•Nodes: "Cough," "Fever," and "Flu."
•Edges:
• "Flu" → "Cough"
• "Flu" → "Fever"
This network suggests that "Flu" is a cause of both "Cough" and "Fever."
This network suggests that "Flu" is a cause of both "Cough" and "Fever."
1.Conditional Probability Tables:
1. P(Cough | Flu): Probability of having a cough given that the patient has the flu.
2. P(Fever | Flu): Probability of having a fever given that the patient has the flu.
3. P(Flu): Prior probability of having the flu.
2.Inference Example:
1. Given that a patient has a cough and fever, you can use the network to infer the
probability of having the flu.
2. Use the CPTs and evidence to update the belief about the probability of "Flu" given
the observed symptoms.
Example: A Bayesian network could model the probability
of a patient having a disease based on various symptoms
and test results, where each symptom and test result is a
node in the network.
For a network with three variables A, B, and C where
A→B→C, the joint probability distribution can be
written as:
P(A,B,C)=P(A)⋅P(B∣A)⋅P(C∣B)
Here:
P(A) is the probability of A.
P(B∣A) is the conditional probability of BBB given A.
P(C∣B) is the conditional probability of CCC given B.
Dempster-Shafer Theory (DST): Overview

Dempster-Shafer Theory (DST), also known as the Theory of Belief Functions, is a

mathematical framework for modeling and combining uncertain, imprecise, or incomplete

information. It is often used in scenarios where evidence is gathered from multiple sources,

and the goal is to combine this evidence to make a decision or estimate probabilities.

DST generalizes Bayesian probability by allowing for the representation of uncertainty

without requiring prior probabilities. Instead of assigning probabilities directly to

hypotheses, DST assigns "beliefs" that account for the evidence and its degree of

uncertainty.
Key Concepts in DST

1.Frame of Discernment (Θ): A set of mutually exclusive hypotheses or propositions. For example, if

diagnosing a disease, Θ might be {Disease X, Disease Y, No Disease}.

2.Mass Function (Belief Assignment): A function that assigns a belief mass to each subset of the frame

of discernment. The mass assigned to a subset reflects the amount of evidence supporting that subset.

3.Belief (Bel): Represents the total belief supporting a particular hypothesis, accounting for all evidence

directly supporting it and all evidence supporting its subsets.

4.Plausibility (Pl): Measures how plausible a hypothesis is, considering all the evidence that does not

contradict it.

5.Conflict Factor (K): Represents the degree of conflict between two sets of evidence.
Example 1: Medical Diagnosis
•Scenario: You have two diagnostic tests for a disease. Each test provides evidence with some level of
uncertainty.
•Sources:
• Test 1: Provides a BPA with some degree of belief that the patient has the disease.
• Test 2: Provides a BPA with some degree of belief that the patient has the disease.
•Combination: Use Dempster’s Rule to combine the BPAs from both tests to get a more comprehensive belief
about the patient's health.

Example 2: Decision Making with Incomplete Information


•Scenario: A decision-maker has incomplete information about several options.
•Options: Each option has a BPA representing the degree of belief in its success.
•Combination: Combine evidence from different sources (e.g., expert opinions) to make a decision based
on the combined BPA.
Example 1: Medical Diagnosis
•Scenario: Diagnosing a disease with two tests.
•Belief Assignments:
• Test A: Disease X (0.7), Disease Y (0.2), Uncertainty (0.1)
• Test B: Disease X (0.6), Disease Y (0.3), No Disease (0.1)
•Result: Combined belief may show stronger support for Disease X,
reflecting both tests' evidence while still recognizing uncertainty.
Example 2 : Identity Recognition
Scenario: A security system is trying to identify a person using facial recognition software from two cameras. Each
camera provides some evidence about who the person might be. The possible identities are:
•Person A
•Person B
•Unknown Person (U)
Belief Assignments:
•Camera 1's belief (m₁):
• Person A: 0.7
• Person B: 0.2
• Uncertainty (U): 0.1
•Camera 2's belief (m₂):
• Person A: 0.6
• Person B: 0.3
• Unknown: 0.1
Example 3: Diagnosing a Car Problem
Scenario: Two mechanics provide opinions about what might be wrong with a car.
The possible issues are:
•Engine Failure (E)
•Battery Problem (B)
•Transmission Issue (T)
Belief Assignments:
•Mechanic A's belief (m₁):
• Engine Failure: 0.6
• Transmission Issue: 0.3
• Uncertainty: 0.1
•Mechanic B's belief (m₂):
• Engine Failure: 0.5
• Battery Problem: 0.4
• Uncertainty: 0.1
Example 4: Identity Recognition
Scenario: A security system is trying to identify a person using facial recognition software from two
cameras. Each camera provides some evidence about who the person might be. The possible identities
are:
•Person A
•Person B
•Unknown Person (U)
Belief Assignments:
•Camera 1's belief (m₁):
• Person A: 0.7
• Person B: 0.2
• Uncertainty (U): 0.1
•Camera 2's belief (m₂):
• Person A: 0.6
• Person B: 0.3
• Unknown: 0.1
Using Dempster-Shafer Theory, the combined belief in the identity of the person can be calculated. This
might lead to a stronger belief in Person A, while still accounting for uncertainty.
Certainty Factors & Rule-Based Systems
Certainty Factors (CFs) are a measure of the confidence in a rule-based expert system,
representing the degree to which a piece of evidence supports or contradicts a hypothesis.
Key Concepts:
•Certainty Factor (CF): Ranges from -1 to 1, where 1 indicates absolute certainty, -1
indicates absolute certainty of the negation, and 0 indicates total uncertainty.
•Rule-Based Systems: Use a set of "if-then" rules to infer conclusions from given data.
Certainty factors allow these systems to handle uncertainty by quantifying the strength of
the conclusions.
Key Concepts
1.Certainty Factor:
1. A Certainty Factor is a numerical value that quantifies the degree of certainty
or confidence in a particular piece of information or rule.
2. Typically, CFs range from -1 to 1:
1 represents full certainty that the statement is true.
-1 represents full certainty that the statement is false.
0 indicates no certainty.
•Base CF and Expected CF:
•Base CF: The initial certainty factor assigned to a piece of information or rule based on expert
knowledge or evidence.
•Expected CF: The adjusted certainty factor after combining multiple pieces of evidence or rules.
•Combination of Certainty Factors:
•When combining multiple sources of information or rules, Certainty Factors are adjusted using
formulas that consider the degree of agreement or conflict between them.
•Common formulas include: CFcombined=CF1+CF2⋅(1− ∣CF1 ∣)
•This formula adjusts the certainty factor of the combined evidence based on how much confidence
each piece of evidence provides.
Rule-Based Systems
Rule-Based Systems use a set of explicit "if-then" rules to perform inference, decision-
making, or problem-solving tasks. They are a common form of expert systems.
Key Characteristics:
•Rules: Each rule consists of a condition (if) and an action (then).
•Inference Engine: Applies the rules to the given data to draw conclusions or perform
actions.
•Forward or Backward Chaining: Rule-based systems can use either forward reasoning
(data-driven) or backward reasoning (goal-driven) to apply rules.
Example: An expert system for loan approval might use rules like "If the applicant's
credit score is above 700, then approve the loan."
Key Concepts
1.Rules:
1. IF condition(s) THEN action(s)
2. Each rule consists of a condition part (antecedent) and an action part (consequent).
3. For example: IF a patient has a fever AND a cough, THEN diagnose flu.
2.Inference Engine:
1. The inference engine is responsible for applying rules to the facts or data to derive conclusions or actions.
2. Two main types of reasoning are used:
1. Forward Chaining: Starts with known facts and applies rules to infer new facts (data-driven reasoning).
2. Backward Chaining: Starts with a goal or hypothesis and works backward to find evidence supporting the
goal (goal-driven reasoning).
3.Knowledge Base:
1. The knowledge base contains the set of rules and facts used by the inference engine.
2. It represents domain-specific knowledge and can be updated as new information becomes available.
Example 1: Scenario: A rule-based system for diagnosing diseases based on symptoms.
•Knowledge Base:
• Rule 1: IF cough AND fever THEN flu.
• Rule 2: IF headache AND runny nose THEN cold.
•Facts:
• The patient has a cough and fever.
Forward Chaining:
•Start with the facts: cough and fever.
•Apply Rule 1: Since the conditions (cough AND fever) are met, the system infers that the patient likely has the flu.
Backward Chaining:
•Goal: Diagnose the disease.
•Check if the symptoms match the conditions for flu (Rule 1).
•Since the patient has a cough and fever, the system concludes that the patient likely has the flu.
Example 2: Rule-Based System for Medical Diagnosis
A rule-based system is used to diagnose flu based on symptoms. The system contains a set of rules as
follows:
Rules:
1.IF the patient has a fever AND a cough, THEN the diagnosis is likely flu.
2.IF the patient has a sore throat AND body aches, THEN the diagnosis is likely flu.
3.IF the patient has a fever AND body aches AND difficulty breathing, THEN the diagnosis could be more
serious than flu.
Scenario:
•The patient has a fever, cough, and body aches.
Step-by-Step Application of Rules:
1.Rule 1: The patient has a fever and a cough. This rule is applicable. The diagnosis is likely flu.
2.Rule 2: The patient has a sore throat, but this symptom is not present. This rule is not applicable.
3.Rule 3: The patient has a fever and body aches, but no difficulty breathing. This rule is not applicable.
Conclusion: Based on Rule 1, the system suggests that the patient likely has flu.
Combining Certainty Factors in Rule-Based Systems

When integrating certainty factors (CFs) into a rule-based system, the goal is to combine the results

of different rules to make a final decision. Different strategies are used depending on whether the

rules reinforce each other or are in conflict. Here’s a breakdown of the two major concepts involved:

1.Aggregation: Combining the CFs of different rules using methods such as averaging or weighted

sum. Aggregation involves combining CFs from multiple rules to determine the final CF for a

conclusion. Some of the common methods include:

You might also like