0% found this document useful (0 votes)
7 views12 pages

Ai-Module 2

Uploaded by

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

Ai-Module 2

Uploaded by

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

MODULE II

KNOWLEDGE REPRESENTATION & REASONING


PROPOSITIONAL LOGIC

Propositional Logic is a branch of logic that deals with propositions and their relationships. It
is a fundamental component of Artificial Intelligence for reasoning and problem-solving.

1. Syntax of Propositional Logic

The syntax defines the symbols and rules for constructing valid sentences in propositional
logic.

Basic Elements

1. Propositions (Atomic Sentences):


o Represented by letters like P,Q,RP, Q, RP,Q,R.
o Each proposition is either true or false.
o Example: P: "It is raining." Q:”it is cold.”
2. Logical Connectives:
o Negation (¬): NOT
▪ Example: ¬P: "It is not raining."
o Conjunction (∧): AND
▪ Example: P∧Q: "It is raining, and it is cold."
o Disjunction (∨): OR
▪ Example: P∨QP: "It is raining or it is cold."
o Implication (→): IF...THEN
▪ Example: P→QP: "If it is raining, then it is cold."
o Biconditional (↔left↔): IF AND ONLY IF
▪ Example: P↔QP: "It is raining if and only if it is cold."
3. Parentheses:
o Used to group propositions and ensure clarity.
o Example: (P∨Q)∧¬R

Well-Formed Formulas (WFFs)

• Formulas constructed using valid symbols and rules.


• Example of valid WFF: (P∨Q)∧¬R
• Example of invalid WFF: P∨∧QP
2. Semantics of Propositional Logic

Semantics defines the meaning of propositional formulas by specifying their truth values.

Truth Assignments

• Each atomic proposition can be either True (T) or False (F).


• The truth values of complex formulas depend on the connectives and the truth
values of their components.

Truth Tables for Connectives


P Q ¬P P∧Q P∨Q P→QP P↔Q

T T F T T T T

T F F F T F F

F T T F T T F

F F T F F T T

Example

• Formula: (P∧Q)→¬R
• Truth assignment:
o P=T, Q=T, R=F:
▪ P∧Q=T,
▪ ¬R=T,
▪ (P∧Q)→¬R=T

3. Normal Forms

Normal forms are standard ways of expressing propositional formulas.

a. Conjunctive Normal Form (CNF)

• A formula in CNF is a conjunction (∧)of clauses, where each clause is a disjunction (∨)
of literals (atomic propositions or their negations).

Steps to Convert to CNF:

1. Eliminate ↔and →:
o Example: P→Q≡¬P∨Q.
2. Apply De Morgan's laws to push negations inward:
o Example: ¬(P∨Q)≡¬P∧¬Q
3. Distribute ∨lor∨ over ∧land∧:
o Example: (P∨(Q∧R))≡(P∨Q)∧(P∨R

Example:

• Formula: (P∨Q)∧¬R
• CNF: (P∨Q)∧(¬R)

b. Disjunctive Normal Form (DNF)

• A formula in DNF is a disjunction (∨) of conjunctions (∧) of literals.

Steps to Convert to DNF:

1. Eliminate ↔ and →→.


2. Apply De Morgan's laws.
3. Distribute ∧land∧ over ∨lor∨.

Example:

• Formula: (P∧Q)∨R(P land Q) lor R(P∧Q)∨R.


• DNF: (P∧Q)∨R(P land Q) lor R(P∧Q)∨R.

c. Negation Normal Form (NNF)

• A formula is in NNF if negations appear only directly in front of atomic propositions.

Example:

• Formula: ¬(P∧Q)
• NNF: ¬P∨¬Q

4. Applications in AI

1. Knowledge Representation:
o Represent facts about the world using propositions.
o Example: In an expert system, PPP: "Patient has a fever."
2. Logical Inference:
o Derive conclusions using rules of inference (e.g., Modus Ponens).
o Example: P→QP QP→Q and P, infer Q.
3. Automated Theorem Proving:
o Use CNF for resolution-based proof systems.
4. Planning:
o Represent actions and their effects as propositions.
PREDICATE LOGIC IN AI

Predicate logic, also known as first-order logic (FOL), extends propositional logic by
introducing quantifiers, variables, predicates, and functions. It is widely used in artificial
intelligence for knowledge representation and reasoning.

Predicate Logic deals with predicates, which are propositions, consist of variables.
Predicate logic - definition

A predicate is an expression of one or more variables determined on some specific domain. A


predicate with variables can be made a proposition by either authorizing a value to the variable
or by quantifying the variable.

In propositional logic, we can only represent the facts, which are either true or false. PL is not
sufficient to represent the complex sentences or natural language statements. The
propositional logic has very limited expressive power. Consider the following sentence, which
we cannot represent using PL logic.

o "Some humans are intelligent", or


o "Sachin likes cricket."

To represent the above statements, PL logic is not sufficient, so we required some more
powerful logic, such as first-order logic.
First-Order logic:
o First-order logic is another way of knowledge representation in artificial intelligence. It is an
extension to propositional logic.
o FOL is sufficiently expressive to represent the natural language statements in a concise way.
o First-order logic is also known as Predicate logic or First-order predicate logic. First-order
logic is a powerful language that develops information about the objects in a more easy way
and can also express the relationship between those objects.
o First-order logic (like natural language) does not only assume that the world contains facts
like propositional logic but also assumes the following things in the world:
o Objects: A, B, people, numbers, colors, wars, theories, ......
o Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation
such as: the sister of, brother of, has color, comes between
o Function: Father of, best friend, third inning of, end of, ......
o As a natural language, first-order logic also has two main parts:
o Syntax
o Semantics
Syntax:
Syntax has to do with what ‘things’ (symbols, notations) one is allowed to use in the
language and in what way; there is/are a(n):

• Alphabet
• Language constructs
• Sentences to assert knowledge

The syntax of FOL determines which collection of symbols is a logical expression in first-
order logic. The basic syntactic elements of first-order logic are symbols. We write
statements in short-hand notation in FOL.
Syntax of FOPL
The symbols and rules of combination permitted in FOPL are defined as follows.
Connectives. There are five connective symbols: (not or negation), A and or conjunction), V
(or or inclusive disjunction, that is, A or B or both A and B), (implication), (equivalence or if
and only if).
Quantifiers. The two quantifier symbols are 3 (existential quantification) and V (universal
quantification), where (3x) means for some x or there is an x and (x) means for all x. When
there is no possibility of confusion, we will omit the parentheses for brevity. Furthermore,
when more than one variable is being quantified by the same quantifier such as (Vx) (Vy)
(Vz) we abbreviate with a single quantifier and drop the parentheses to get Vxyz.
Variables. Variables are terms that can assume different values over a given domain. They
are denoted by words and small letters near the end of the alphabet. such as aircraft-type,
individuals, x, y, and z.
Functions. Function symbols denote relations defined on a domain D. They map n elements
(n ≥ 0) to a single element of the domain. Symbols f. g. h. and words such as father-of, or
age-of, represent functions. An n place (n-ary) function is written as fit. 12. 1) where the 1,
are terms (constants, variables, or functions) defined over some domain. A 0-ary function is
a constant.
Predicates. Predicate symbols denote relations or functional mappings from the elements of
a domain D to the values true or false. Capital letters and capitalized words such as P, Q, R,
EQUAL, and MARRIED are used to represent predicates. Like functions, predicates may have
n (n≥0) terms for arguments written as P(11. 12. 1), where the terms 1,, i 1, 2.. are defined
over some domain. A 0-ary predicate is a proposition, that is, a constant predicate.
Constants, variables, and functions are referred to as terms, and predicates are referred to
as atomic formulas or atoms for short. Furthermore, when we want to refer to an atom or
its negation, we often use the word literal.
In addition to the above symbols, left and right parentheses, square brackets, braces, and
the period are used for punctuation in symbolic expressions.
As an example of the above concepts, suppose we wish to represent the following
statements in symbolic form.
E1: All employees earning $1400 or more per year pay taxes.
E2: Some employees are sick today.
E3: No employee earns more than the president.
1. Syntax of Predicate Logic

The syntax defines the valid structure of statements in predicate logic.

Key Elements

1. Constants: Represent specific objects in the domain.


o Example: a,b,ca, b, ca,b,c.
2. Variables: Represent unspecified objects in the domain.
o Example: x,y,zx, y, zx,y,z.
3. Predicates: Represent properties or relations between objects.
o Example: Loves(x,y)Loves(x, y)Loves(x,y): "x loves y."
4. Functions: Map objects to other objects in the domain.
o Example: Father(x)Father(x)Father(x): "Father of x."
5. Quantifiers:
o Universal Quantifier (∀forall∀): True for all elements in the domain.
▪ Example: ∀x P(x)forall x P(x)∀x P(x): "P is true for all x."
o Existential Quantifier (∃exists∃): True for at least one element in the
domain.
▪ Example: ∃x P(x)exists x P(x)∃x P(x): "P is true for some x."
6. Logical Connectives:
o Same as in propositional logic: ¬,∧,∨,→,↔.
7. Atomic Formulae:
o Formed by applying a predicate to arguments.
o Example: Likes(John,IceCream).
8. Complex Formulae:
o Combine atomic formulae using logical connectives.
o Example: ∀x(Student(x)→Studies(x,Math))forall x (Student(x) Studies(x,
Math))∀x(Student(x)→Studies(x,Math)).
2. Semantics of Predicate Logic

The semantics defines the meaning of predicate logic statements. It involves interpreting
the symbols in the context of a domain of discourse (the set of objects being discussed).

Key Components

1. Domain (D): The set of objects under discussion.


o Example: D={Alice,Bob,Charlie}.
2. Interpretation:
o Assigns meaning to constants, predicates, and functions.
o Example:
▪ Constant a → Alice
▪ Predicate Likes(x,y) → Relation "likes."
3. Truth Value:
o An atomic formula P(x) is true if x satisfies P under the interpretation.
Example:

• Statement: ∀x(Student(x)→Studies(x,Math))forall x (Student(x) Studies(x,


Math))∀x(Student(x)→Studies(x,Math)).
• Interpretation:
o D={Alice,Bob}
o Student(x)={Alice}
o Studies(x,Math)={Alice}Studies(x, Math) = {Alice}Studies(x,Math)={Alice}.
• Truth: The statement is true since all students study math.
3. Clausal Normal Form (CNF)

Clausal Normal Form is a standardized representation of predicate logic statements as a


conjunction of disjunctions of literals (atoms or their negations). It is crucial for automated
reasoning and resolution-based proof systems.

Steps to Convert to CNF

1. Eliminate Implications and Biconditionals:


o A→B≡¬A∨B
o A↔B≡(¬A∨B)∧(¬B∨A)
2. Move Negations Inward (Using De Morgan’s laws):
o ¬(∀x P(x))≡∃x ¬P(x)neg (forall x P(x)) equiv exists x neg
P(x)¬(∀x P(x))≡∃x ¬P(x),
o ¬(∃x P(x))≡∀x ¬P(x)neg (exists x P(x)) equiv forall x neg
P(x)¬(∃x P(x))≡∀x ¬P(x).
3. Standardize Variables:
o Rename variables to avoid conflicts.
4. Move Quantifiers Left:
o Ensure all quantifiers are at the beginning of the statement.
5. Skolemization (for eliminating existential quantifiers):
o Replace ∃x P(x)exists x P(x)∃x P(x) with a Skolem function P(f(y)) where y is
universally quantified.
6. Drop Universal Quantifiers:
o Assume all variables are universally quantified.
7. Distribute ∧land∧ over ∨lor∨:
o Convert to conjunctive normal form.
Example Conversion to CNF

1. Original Formula:
∀x(∃y Loves(x,y)→Happy(x))forall x (exists y Loves(x, y)
Happy(x))∀x(∃y Loves(x,y)→Happy(x)).
2. Eliminate Implication:
∀x(¬∃y Loves(x,y)∨Happy(x))forall x (neg exists y Loves(x, y) lor
Happy(x))∀x(¬∃y Loves(x,y)∨Happy(x)).
3. Move Negations Inward:
∀x(∀y ¬Loves(x,y)∨Happy(x))forall x (forall y neg Loves(x, y) lor
Happy(x))∀x(∀y ¬Loves(x,y)∨Happy(x)).
4. Skolemization:
∀x(¬Loves(x,f(x))∨Happy(x))forall x (neg Loves(x, f(x)) lor
Happy(x))∀x(¬Loves(x,f(x))∨Happy(x)).
5. Drop Universal Quantifiers:
¬Loves(x,f(x))∨Happy(x)neg Loves(x, f(x)) lor Happy(x)¬Loves(x,f(x))∨Happy(x).
6. Final CNF:
(¬Loves(x,f(x))∨Happy(x))(neg Loves(x, f(x)) lor Happy(x))(¬Loves(x,f(x))∨Happy(x)).

PROCEDURAL VS. DECLARATIVE KNOWLEDGE REPRESENTATION

Knowledge representation in Artificial Intelligence (AI) involves storing information so that a


machine can access and utilize it efficiently to solve problems, reason, and learn. Two
fundamental types of knowledge representation are procedural and declarative knowledge.
1. Procedural Knowledge

• Definition: Procedural knowledge refers to the type of knowledge that is concerned


with knowing "how" to perform tasks and operations. It involves a series of
instructions or processes that guide an agent to achieve specific goals. This type of
knowledge is dynamic and action-oriented, often represented in the form of
algorithms, production rules, or scripts that define the steps to solve a problem or
accomplish a task.
• Characteristics:
o Action-oriented: It focuses on "how" to achieve a goal.
o Encapsulated: The knowledge is embedded within procedures and not easily
separable.
o Often represented in the form of code, production rules, or scripts.
• Examples:
o A sorting algorithm (e.g., bubble sort) is procedural knowledge.
o Inference rules in expert systems like: If (condition) then (action).

Example in AI:

A chess program uses procedural knowledge to decide moves:

If opponent's piece threatens the king, then move the king to a safe position.
2. Declarative Knowledge

• Definition: Declarative knowledge represents the type of knowledge that is


concerned with "what is true" about the world. It is focused on facts, relationships,
and data that describe entities, their properties, and the interactions between them.
This type of knowledge is static, easily understandable, and is represented using
statements, rules, or structured formats such as semantic networks or logic systems.
• Characteristics:
o Fact-based: Focuses on explicit data and relationships.
o Separable: Easy to update and modify.
o Often represented using semantic nets, frames, or first-order logic.
• Examples:
o "Paris is the capital of France."
o In a semantic network: is_capital(Paris, France).

Example in AI:

In a knowledge-based system:

• Fact: "Birds can fly."


• Fact: "Penguins are birds, but penguins cannot fly." This distinction can be encoded
declaratively and used for reasoning.
KNOWLEDGE REPRESENTATION TECHNIQUES
1. Semantic Nets

• Definition: A semantic net (or semantic network) is a graphical representation of


knowledge that models concepts as nodes and relationships between concepts as
edges. It provides a way to visually and structurally organize knowledge, showing
how different entities are connected and related in a hierarchical or associative
manner. Semantic nets are particularly effective for representing taxonomies and
ontologies.
• Purpose: To represent relationships among objects, concepts, or ideas.
• Key Features:
o Nodes represent entities or concepts.
o Edges represent relationships (e.g., "is-a," "part-of," "has-property").
o Useful for hierarchical relationships.
• Example: A semantic net representing animals:

Animal
|
is-a
|
Mammal ------ Bird
| |
has-fur has-feathers
| |
Dog Penguin
| |
barks cannot-fly

• Advantages:
o Visual and intuitive.
o Enables inheritance (e.g., Penguins inherit properties of Birds).
• Limitations:
o Cannot handle complex relationships effectively.
o Lacks standardized semantics.

2. Frames

• Definition: Frames are structured data representations designed to capture


stereotypical knowledge about objects, situations, or events. Each frame is like a
"blueprint" or "template" that describes an entity in terms of its attributes (slots)
and their associated values. Frames allow default values and inheritance, making
them useful for hierarchical and organized knowledge representation.
• Components:
o Frame Name: Identifies the object or situation.
o Slots: Attributes or properties of the frame.
o Values: Information or data for each slot (can include default values).
• Purpose: To capture structured knowledge about a domain.
• Example: Frame for a car:
Car Frame:
- Manufacturer: Toyota
- Model: Corolla
- Year: 2022
- Color: Red
- Engine:
- Type: Hybrid
- Horsepower: 150 HP

• Advantages:
o Highly organized and modular.
o Allows default values and inheritance.
• Limitations:
o Difficult to represent procedural knowledge.
o Not ideal for dynamic or non-stereotypical knowledge.

3. Scripts

• Definition: Scripts are pre-defined knowledge structures that represent a sequence


of events or actions typically occurring in a specific context. They are used to model
routine or predictable scenarios, encoding the roles, actions, and outcomes involved.
Scripts are particularly effective for reasoning about events and understanding
natural language descriptions of familiar situations.
• Structure:
o Entry Conditions: Conditions that must be true for the script to execute.
o Results: Outcomes of the script.
o Props: Objects involved in the script.
o Roles: Actors participating in the script.
o Scenes: Sub-events or steps in the script.
• Purpose: To predict and understand human behavior in common situations.
• Example: Script for dining at a restaurant:

Script: Dining at a Restaurant


- Entry Conditions: Customer is hungry.
- Props: Table, menu, food, bill.
- Roles: Customer, waiter, chef.
- Scenes:
1. Customer enters the restaurant and is seated.
2. Waiter provides the menu.
3. Customer orders food.
4. Chef prepares the food.
5. Waiter serves the food.
6. Customer eats and requests the bill.
7. Customer pays and leaves.
- Results: Customer is no longer hungry.

• Advantages:
o Captures temporal and causal relationships.
o Useful in natural language understanding.
• Limitations:
o Limited flexibility (scripts are rigid).
o Not ideal for representing knowledge outside typical scenarios.

Comparison of Techniques
Technique Structure Strengths Weaknesses

Semantic Intuitive, good for Poor at handling exceptions or


Graph
Nets relationships procedures

Data Modular, supports


Frames Difficult for procedural knowledge
Structure inheritance

Captures temporal order, Rigid, not adaptable to novel


Scripts Sequence
realistic situations

You might also like