Ai-Module 2
Ai-Module 2
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.
The syntax defines the symbols and rules for constructing valid sentences in propositional
logic.
Basic Elements
Semantics defines the meaning of propositional formulas by specifying their truth values.
Truth Assignments
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
• A formula in CNF is a conjunction (∧)of clauses, where each clause is a disjunction (∨)
of literals (atomic propositions or their negations).
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)
Example:
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
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.
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
Key Elements
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. 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)).
Example in AI:
If opponent's piece threatens the king, then move the king to a safe position.
2. Declarative Knowledge
Example in AI:
In a knowledge-based system:
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
• 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
• 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