0% found this document useful (1 vote)
174 views15 pages

First Order Logic: Artificial Intelligence COSC-3112 Ms. Humaira Anwer

The document discusses first-order logic and its applications. It provides examples of representing the wumpus world and an electronic circuit in first-order logic. It outlines the knowledge engineering process for developing first-order logic knowledge bases, including identifying the task, assembling relevant domain knowledge, defining predicates and constants, encoding general domain knowledge and specific problems, posing queries, and debugging. It then provides a detailed example of representing knowledge about a one-bit full adder circuit in first-order logic, including defining the circuit components as terms and encoding the circuit connectivity and component behaviors.

Uploaded by

Khizrah Rafique
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 (1 vote)
174 views15 pages

First Order Logic: Artificial Intelligence COSC-3112 Ms. Humaira Anwer

The document discusses first-order logic and its applications. It provides examples of representing the wumpus world and an electronic circuit in first-order logic. It outlines the knowledge engineering process for developing first-order logic knowledge bases, including identifying the task, assembling relevant domain knowledge, defining predicates and constants, encoding general domain knowledge and specific problems, posing queries, and debugging. It then provides a detailed example of representing knowledge about a one-bit full adder circuit in first-order logic, including defining the circuit components as terms and encoding the circuit connectivity and component behaviors.

Uploaded by

Khizrah Rafique
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/ 15

Lecture 24

First Order Logic


Chapter 08

Artificial Intelligence
COSC-3112

Ms. Humaira Anwer


[email protected]

Lecture 24- First Order Logic 1


Outline
• Interacting with FOL KBs
• Knowledge engineering in FOL

Lecture 24- First Order Logic 2


Interacting with FOL KBs
• Recall that the wumpus agent receives a percept
vector with five elements.
• Percept ([Stench, Breeze, Glitter , None, None],
5) .
• Here, Percept is a binary predicate, and Stench
and so on are constants placed in a list.
• The actions in the wumpus world can be
represented by logical terms:
• Turn(Right ), Turn(Left ), Forward , Shoot , Grab.

Lecture 24- First Order Logic 3


Interacting with FOL KBs
• Suppose a wumpus-world agent is using an FOL KB and
perceives a smell and a breeze (but no glitter) at t=5:
Tell(KB,Percept([Smell,Breeze,None],5))

• To determine which is best, the agent program


executes the query
Ask(KB,a BestAction(a,5))

• Which returns the best action at t=5?


• Answer: Yes, {a/Shoot} ← substitution (binding list)

Lecture 24- First Order Logic 4


Knowledge base for the wumpus
world
• Perception
• t,s,b Percept([s,b,Glitter],t)  Glitter(t)

• Reflex
• t Glitter(t)  BestAction(Grab,t)

Lecture 24- First Order Logic 5


Knowledge Engineering Process

• Identify the task.


• This step is analogous to the PEAS process for designing
agents in Chapter 2.
• Assemble the relevant knowledge.
• The idea is to understand the scope of the knowledge
base, as determined by the task, and to understand how
the domain actually works.
• Decide on a vocabulary of predicates, functions,
and constants.
• Translate the important domain-level concepts into
logic-level names.

Lecture 24- First Order Logic 6


Knowledge Engineering Process
• Encode general knowledge about the domain
• The knowledge engineer writes down the axioms for all
the vocabulary terms.
• Encode a description of the specific problem
instance.
• It will involve writing simple atomic sentences about
instances of concepts that are already part of the KB.
• Pose queries to the inference procedure and get
answers.
• This is where the reward is: we can let the inference
procedure operate on the axioms and problem-specific
facts to derive the facts we are interested in knowing.

Lecture 24- First Order Logic 7


Knowledge Engineering Process
• Debug the knowledge base.
• Alas, the answers to queries will seldom be correct on
the first try.
• More precisely, the answers will be correct for the
knowledge base as written,

Lecture 24- First Order Logic 8


The electronic circuits domain
One-bit full adder

Lecture 24- First Order Logic 9


The electronic circuits domain
1. Identify the task
• Does the circuit actually add properly? (circuit
verification)
2. Assemble the relevant knowledge
• Composed of wires and gates; Types of gates
(AND, OR, XOR, NOT)
• Irrelevant: size, shape, color, cost of gates
3. Decide on a vocabulary
Type(X1) = XOR
Type(X1, XOR)
XOR(X1)
CIRCUIT(C1)

Lecture 24- First Order Logic 10


The electronic circuits domain
4. Encode general knowledge of the domain
• t1,t2 Connected(t1, t2)  Signal(t1) = Signal(t2)
• t Signal(t) = 1  Signal(t) = 0
• 1≠0
• t1,t2 Connected(t1, t2)  Connected(t2, t1)
• g Type(g) = OR  Signal(Out(1,g)) = 1  n
Signal(In(n,g)) = 1
• g Type(g) = AND  Signal(Out(1,g)) = 0  n
Signal(In(n,g)) = 0
• g Type(g) = XOR  Signal(Out(1,g)) = 1  Signal(In(1,g))
≠ Signal(In(2,g))
• g Type(g) = NOT  Signal(Out(1,g)) ≠ Signal(In(1,g))
• ∀ g Gate(g) ⇒ Circuit(g)
Lecture 24- First Order Logic 11
The electronic circuits domain
5. Encode the specific problem instance
Type(X1) = XOR Type(X2) = XOR
Type(A1) = AND Type(A2) = AND
Type(O1) = OR

Connected(Out(1,X1),In(1,X2)) Connected(In(1,C1),In(1,X1))
Connected(Out(1,X1),In(2,A2)) Connected(In(1,C1),In(1,A1))
Connected(Out(1,A2),In(1,O1)) Connected(In(2,C1),In(2,X1))
Connected(Out(1,A1),In(2,O1)) Connected(In(2,C1),In(2,A1))
Connected(Out(1,X2),Out(1,C1)) Connected(In(3,C1),In(2,X2))
Connected(Out(1,O1),Out(2,C1)) Connected(In(3,C1),In(1,A2))

Lecture 24- First Order Logic 12


The electronic circuits domain
6. Pose queries to the inference procedure
What are the possible sets of values of all the terminals for the
adder circuit?

i1,i2,i3,o1,o2 Signal(In(1,C_1)) = i1  Signal(In(2,C1)) = i2 


Signal(In(3,C1)) = i3  Signal(Out(1,C1)) = o1  Signal(Out(2,C1))
= o2

7. Debug the knowledge base


May have omitted assertions like 1 ≠ 0

Lecture 24- First Order Logic 13


Summary
• First-order logic:
• objects and relations are semantic primitives
• syntax: constants, functions, predicates, equality,
quantifiers

• Increased expressive power: sufficient to define


wumpus world

Lecture 24- First Order Logic 14


Quiz 03 10 marks
Q1. Express following using logic either FOL or
Propositional (Whichever you find consistent)
• Square(s) are not smelly or breezy if neighboring
square(s) doesn't have wumpus or pit in it.
• In RYK everyone is driving slow due to fog.
• One cannot take exam unless he has registered in the
subject
• You will fail unless you study hard.
• Humans are mortal.

Lecture 24- First Order Logic 15

You might also like