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

First Order Logic

Uploaded by

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

First Order Logic

Uploaded by

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

Artificial

Intelligence
FIRST ORDER LOGIC

Presented by:
DEEBA MUSHTAQ
BHARGAVI S R
AAYUSHI MAHESHWARI
FIDA KHANUM
Page 1
ASHMITA CHAVAN
DISHA A
Introduction to Representation in AI
Why structured Representation Matters in
AI ?
• Need for Structured Representation
AI systems require structured ways to represent knowledge to reason
about complex environments and make informed decisions.

• Limitations of Propositional Logic:


1. Propositional logic is simple but limited.
2. Lacks expressiveness for complex relationships and scalable
representation.

--> Example: To represent a relationship like “Squares adjacent to pits are


Page 2
breezy” requires redundant statements for each case.
Benefits of First-Order Logic
Why First-Order Logic (FOL) is Useful in AI

• Enhanced Expressiveness:
FOL allows us to represent general statements and relationships concisely.

Example: FOL can express “All squares adjacent to pits are breezy” in a single statement, unlike
propositional logic.

• Ontological Commitment
Assumes the existence of objects and relations, ideal for environments with complex interactions.

• Connecting Theory to Practical AI Page 2


Supports reasoning and inference, enabling complex problem-solving in AI.
what is First-Order Logic(FOL)
•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.

•First-order logic is another way of knowledge representation in artificial intelligence. It is an extension


to propositional logic.

•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.

•We can represent atomic sentences as Predicate (term1, term2, ......, term n).
Page 3
Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
First-order logic statements can be divided into two parts:
•Subject: Subject is the main part of the statement.
•Predicate: A predicate can be defined as a relation, which binds two atoms together in a
statement.

Quantifiers in First-Order Logic :


•Quantifiers specify the scope of variables. The two main quantifiers are:
•A quantifier is a language element which generates quantification, and quantification
specifies the quantity of specimen in the universe of discourse.

Page 6
Quantifiers:
Quantifiers are essential in first-order logic (FOL) because they allow us to make general or specific
statements about objects within a domain. In FOL, there are two main quantifiers:
1. Universal Quantifier ( ∀)
•Symbol: ∀ (read as "for all")
•Purpose: It states that a property or relation holds for all objects in the domain.
•Usage: If we want to say that "all humans are mortal," we can represent it as:

x(Human(x)→Mortal(x))
This means that for any object x, if x is a human, then x is also mortal.
•Interpretation: The statement is true only if the property holds for every single object in the domain.
2. Existential Quantifier ( ∃)
•Symbol: ∃ (read as "there exists" or "for some")
•Purpose:
• It states that there is at least one object in the domain for which a property or relation holds.
Usage: If we want to say "there exists a human who is a philosopher," we can represent it as:
∃ x ( Human(x)∧Philosopher(x))
This means that there is at least one object x such that x is a human and x is a philosopher.
•Interpretation: The statement is true if at least one object in the domain satisfies the property.
Syntax and Semantics

Sentence : A Sentence in FOL is a meaningful statement that can be true or false.


Atomic Sentence : The simplest kind of sentence.
ComplexSentence : Formed by combining one or more Sentences using logical
operators or quantifiers.
Basic Symbols Of FOL
Constant Symbols: Represent specific objects.
Predicate Symbols: Represent relationships between objects .
Function Symbols: Represent functions that map one object to another.
Convention: Symbols begin with uppercase letters for clarity.
Equality Symbol ( = ) : Used to denote that two terms refer to the same object.
Page 4
Connection Between ∀ and ∃
De Morgan’s Laws for Quantifiers:
∀x ¬P(x) is equivalent to ¬∃x P(x)
¬∀x P(x) is equivalent to ∃x ¬P(x)

Examples of Syntax and Semantics


Example 1: ∀x (Person(x) ⇒ King(x))
Interpretation: All persons are kings.

Example 2: Brother(Richard, John) ∧ King(John)


Interpretation: Richard is John’s brother, and John is a king

Operator Precedence

∧ ∨ ⇒ ⇔
Negation (¬), Equality (=),Conjunction ( ),Disjunction ( ),Implication ( ),Biconditional ( )
Page 5
USING FIRST-ORDER LOGIC

Assertions and queries in first-order logic

•Tell: Sentences are added to a knowledge base using TELL, exactly as in


popositional logic. Such sentences are called assertions.
For example, we can assert that John is a king, and all kings are persons:

TELL(KB, King(John)) .
∀ ⇒
TELL(KB, x King(x) Person(x)) .

•Ask :Questions asked with ASK are called queries or goals


For example:

ASK(KB, King(John))
ASK(KB, ∃ x Person(x)) .
The kinship domain
The kinship domain in first-order logic (FOL) is a structured way to represent
relationships within a family, such as parent, sibling, child, cousin, etc.

Predicates: Relationships between individuals, defined by binary or unary predicates.

For example, one’s mother is one’s female parent:


∀ ⇔ ∧
m, c Mother (c) = m Female(m) Parent(m, c) .

∀ x, y, z (Grandparent(x, y) ↔ (Parent(x, z) ∧ Parent(z, y)))


A grandparent is the parent of a parent.

Numbers, sets, and lists


Numbers, especially natural numbers

0 is a natural number, and for every object n, if n is a natural number, then S(n) is
a natural number. So the natural numbers are 0, S(0), S(S(0)), and so on.

x+0=x
x + S(y) = S(x + y) x*0=0
x * S(y) = (x * y) + x
Sets are collections of elements, typically defined with membership and other operations like union, intersection, and
subset.
Membership:Member(x, S)

Set Equality:∀ x (Member(x, S) ↔ Member(x, T))


Subset:Subset(S, T) ↔ ∀ x (Member(x, S) → Member(x, T))

Union and Intersection:∀ x (Member(x, U) ↔ (Member(x, S) ∨ Member(x, T)))

Intersection: ∀ x (Member(x, U) ↔ (Member(x, S) ∧ Member(x, T)))

Empty Set:Member(x, ∅)

Lists are ordered collections where each element has a position.

List(Head, Tail)

The wumpus world


Percept([Stench, Breeze, Glitter , None, None], 5) .

The actions in the wumpus world can be represented by logical terms:


Turn(Right), Turn(Left), Forward, Shoot, Grab, Climb
Knowledge Engineering in first – order logic

Knowledge engineering is the process of building a formal Application: used for special-purpose knowledge bases with a
knowledge base for a specific domain. well-defined scope and known query range. This process
A knowledge engineer investigates a domain, identifies key emphasizes clear and structured representation of domain
concepts, and formalizes objects and relationships within it. knowledge.
.

Knowledge – Engineering process :

Identify the task.


Assemble the relevant knowledge.
Decide on a vocabulary of predicates , functions , and constants.
Encode general knowledge about the domain.
Encode the description of the specific problem instance .
Pose queries to the inference procedure & get answers.
Debug the knowledge base .

Page 8
The Electronic circuits domain
.

33. Decide on a Vocabulary


1. Identify the Task - Choose functions, predicates &
- examining functionality of constants to represent circuits ,
terminals , signals , gates.
circuit(circuit verification, - Each gate is represented as an object
I/O gates) named by a constant.
- examining circuit Eg: Gate(X1) - OBJECT.
structure(connection of gates , Type of gate (constants like
feedback loops) AND,OR,XOR,NOT) determines its
- identifies the knowledge behaviour.
Eg: Function: Type(X1)= XOR
required to achieve result. Circuits & Terminals are identified by
predicates : Circuit(C1) &
1. Assemble the relevant Terminal(x)
In(1,X1) – 1ˢᵗ i/p terminal for X1.
knowledge Out(2,X1) – 2ⁿᵈ o/p terminal for X1.
Knowledge on how gates/ circuits Arity(c, I ,j) – circuit “c” has “I” i/p
transform their input signals. & “j” o/p terminals.
4 Types of gates: Connectivity b/w gates uses
AND , OR , XOR – 2 i/p predicate Connected
terminals Eg: Connected(Out(1,X1),In(1,X2)).
NOT – 1 i/p terminal Page 10
- Signal(t)=1 -> ON
Signal(t)=0 -> OFF
The Electronic circuits domain
.

4. Encode general knowledge of the domain

Page 10
The Electronic circuits domain
.

4. Encode general knowledge of the domain

Page 10
The Electronic circuits domain
.

5. Encode the description of the specific problem


instance .

Page 10
The Electronic circuits domain
.

6. Pose queries to the inference procedure & get answers.

This query searches for i1,i2,i3 values which would satisfy these output values.
These combinations of i/p values { 1,1,0}, {1,0,1},{0,1,1} in C1 would give sum bit as
0 and carry bit as 1.
These i/o values verify the circuit.

7. Debug the knowledge base


Problem: A key axiom (1 ≠ 0) is missing in the knowledge base for the circuit, causing the system to fail at deducing outputs,
except for specific inputs (000 and 110).
Diagnosis: By querying the output of each gate (e.g., X1), we find missing outputs for certain inputs (e.g., 10 and 01), indicating
a problem with the XOR gate logic.
Error Analysis: The XOR rule states Signal(Out(1, X1)) = 1 if Signal(In(1, X1)) ≠ Signal(In(2, X1)). Without 1 ≠ 0, the system
can’t confirm this inequality, leading to incomplete outputs. Page 10
Solution: Adding 1 ≠ 0 to the knowledge base allows correct evaluation, restoring expected behavior across all inputs.
Models for first order logic

Objects
Relations
Functions
Domain
1.Objects:
The model includes five objects:
Richard the Lionheart, King John,
their respective left legs, and a
crown.
2.Binary relation:
•Brotherhood Relation: {(Richard, John),
(John, Richard)}, indicating that Richard
is John’s brother and vice versa.
•On Head Relation: (crown, John),
, showing that the crown is on John's
head.

3.Unary relation:
•Person property: Both Richard and
John
•King Property: Only John has the "king"
property
•Crown Property: Only the crown has
this property
4. Functions:
Left Leg Function: The function maps
each person (Richard and John) to their
left leg. In mathematical notation:
•left-leg(Richard) = Richard's left leg
•left-leg(John) = John's left leg
,

5.Domain :
The domain of the model
includes all objects present:
Richard, John, both left legs, and
the crown.
Symbols:
The symbols come in three kinds:

1.Constant symbols-> which stand for objects;


eg : Richard and John

2.Predicate symbols-> which stand for relations;


eg : Brother, OnHead, Person, King and Crown

3.function symbols-> which stand for functions.


eg : LeftLeg
Interpretations:

An interpretation specifies exactly which objects, relations and functions are


referred to by the constant, predicate, and function symbols. One possible
interpretation for our example—is as follows:

• ‘Richard’ refers to Richard the Lionheart and ‘John’ refers to the evil King John.

‘Brother’ refers to the brotherhood relation, that is, the set of tuples of objects;

‘OnHead’ refers to the “on head” relation that holds between the crown and King
John;

‘Person’, ‘King’, and ‘Crown’ refer to the sets of objects that are persons, kings, and
crowns. •

‘LeftLeg’ refers to the “left leg” function.


Terms:

•A term is a logical expression that refers to an object.

•Constant symbols are therefore terms, but it is not always convenient to have
a distinct symbol to name every object .

•Consider a term f(t1,...,tn). The function symbol f refers to some function in the
model (call it F); the argument terms refer to objects in the domain (call them
d1,...,dn); and the term as a whole refers to the object that is the value of the
function F applied to d1,...,dn.

•For example, suppose the LeftLeg function symbol refers to the function and
John refers to King John, then LeftLeg(John) refers to King John’s left leg.
Atomic sentence:

•An atomic sentence (or atom for short) is formed from a predicate symbol
optionally followed by a parenthesized list of terms,
such as Brother(Richard , John).

•This states, under the intended interpretation given earlier, that Richard the
Lionheart is the brother of King John.

•Atomic sentences can have complex terms as arguments.


such as Married(Father (Richard),Mother(John))
states that Richard the Lionheart’s father is married to King John’s mother
(again, under a suitable interpretation).
Thank You
FOR YOUR ATTENTION

Presented by:
• 1DT22CS003
• 1DT22CS020
• 1DT22CS033
• 1DT22CS042
• 1DT22CS044
Page 13
• 1DT22CS046

You might also like