Module III
Module III
Propositional logic (PL) is the simplest form of logic where all the statements are made by
propositions. A proposition is a declarative statement which is either true or false. It is a
technique of knowledge representation in logical and mathematical form.
The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:
Atomic Propositions
Compound propositions
Example:
Logical connectives are used to connect two simpler propositions or representing a sentence
logically. We can create compound propositions with the help of logical connectives. There are
mainly five connectives, which are given as follows:
In the topic of Propositional logic, we have seen that how to represent statements using
propositional logic. But unfortunately, in propositional logic, we can only represent the facts,
which are either true or false. PL is not sufficient to represent 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.
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, squares, pits, wumpus,
......
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:
a. Syntax
b. Semantics
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.
Variables x, y, z, a, b,....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃
Atomic sentences:
o 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.
o We can represent atomic sentences as Predicate (term1, term2, ......, term n).
Complex Sentences:
o Complex sentences are made by combining atomic sentences using connectives.
Consider the statement: "x is an integer.", it consists of two parts, the first part x is the
subject of the statement and second part "is an integer," is known as a predicate.
Universal Quantifier:
Universal quantifier is a symbol of logical representation, which specifies that the statement
within its range is true for everything or every instance of a particular thing.
o For all x
o For each x
o For every x.
Example:
Let a variable x which refers to a cat so all x can be represented in UOD as below:
Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the statement within its
scope is true for at least one instance of something.
It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with a
predicate variable then it is called as an existential quantifier.
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
Example:
Some boys are intelligent.
It will be read as: There are some x where x is a boy who is intelligent.
Points to remember:
o The main connective for universal quantifier ∀ is implication →.
o The main connective for existential quantifier ∃ is and ∧.
Properties of Quantifiers:
o In universal quantifier, ∀x∀y is similar to ∀y∀x.
o In Existential quantifier, ∃x∃y is similar to ∃y∃x.
o ∃x∀y is not similar to ∀y∃x.
The quantifiers interact with variables which appear in a suitable way. There are two types of
variables in First-order logic which are given below:
Free Variable: A variable is said to be a free variable in a formula if it occurs outside the scope
of the quantifier.
Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.
Bound Variable: A variable is said to be a bound variable in a formula if it occurs within the
scope of the quantifier.
Unification:
Substitution θ = {John/x} is a unifier for these atoms and applying this substitution, and both
expressions will be identical.
o The UNIFY algorithm is used for unification, which takes two atomic sentences and
returns a unifier for those sentences (If any exist).
o Unification is a key component of all first-order inference algorithms.
o It returns fail if the expressions do not match with each other.
o The substitution variables are called Most General Unifier or MGU.
E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)).
In this example, we need to make both above statements identical to each other. For this, we
will perform the substitution.
P(x,y).........(i)
P(a, f(z))......... (ii)
o Substitute x with a, and y with f(z) in the first expression, and it will be represented
as a/x and f(z)/y.
o With both the substitutions, the first expression will be identical to the second
expression and the substitution set will be: [a/x, f(z)/y].
Unification Algorithm:
For each pair of the following atomic sentences find the most general unifier (If exist).
Hence, unification is not possible for these expressions.
As propositional logic we also have inference rules in first-order logic, so following are some
basic inference rules in FOL:
o Universal Generalization
o Universal Instantiation
o Existential Instantiation
o Existential introduction
1. Universal Generalization:
o Universal generalization is a valid inference rule which states that if premise P(c) is
true for any arbitrary element c in the universe of discourse, then we can have a
conclusion as ∀ x P(x).
Example: Let's represent, P(c): "A byte contains 8 bits", so for ∀ x P(x) "All bytes contain
8 bits.", it will also be true.
2. Universal Instantiation:
So from this information, we can infer any of the following statements using Universal
Instantiation:
o King(John) ∧ Greedy (John) → Evil (John),
o King(Richard) ∧ Greedy (Richard) → Evil (Richard),
o King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John)),
3. Existential Instantiation:
Example:
So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not appear in the
knowledge base.
4. Existential introduction
Resolution in FOL
Resolution
Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e.,
proofs by contradictions. It was invented by a Mathematician John Alan Robinson in the year
1965.
Resolution is used, if there are various statements are given, and we need to prove a conclusion
of those statements. Unification is a key concept in proofs by resolutions. Resolution is a single
inference rule which can efficiently operate on the conjunctive normal form or clausal form.
Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also known as a unit
clause.
The resolution rule for first-order logic is simply a lifted version of the propositional rule.
Resolution can resolve two clauses if they contain complementary literals, which are assumed
to be standardized apart so that they share no variables.
This rule is also called the binary resolution rule because it only resolves exactly two
literals.
Example:
Where two complimentary literals are: Loves (f(x), x) and ¬ Loves (a, b)
These literals can be unified with unifier θ= [a/f(x), and b/x] , and it will generate a resolvent
clause:
[Animal (g(x) V ¬ Kills(f(x), x)].
To better understand all the above steps, we will take an example in which we will apply
resolution.
Example:
a. John likes all kind of food.
b. Apple and vegetable are food
c. Anything anyone eats and not killed is food.
d. Anil eats peanuts and still alive
e. Harry eats everything that Anil eats.
Prove by resolution that:
f. John likes peanuts.
g. Step-1: Conversion of Facts into FOL
h. In the first step we will convert all the given statements into its first order logic.
In this statement, we will apply negation to the conclusion statements, which will be written as
¬likes(John, Peanuts)
Now in this step, we will solve the problem by resolution tree using substitution. For the above
problem, it will be given as follows:
Hence the negation of the conclusion has been proved as a complete contradiction with the
given set of statements.
Normal Forms
Disjunctive Normal Form (DNF): If p, q are two statements, then "p or q" is a compound
statement, denoted by p ∨ q and referred as the disjunction of p and q. The disjunction of p and
q is true whenever at least one of the two statements is true, and it is false only when both p
and q are false
p q p∨q
T T T
T F T
F T T
F F F
Example: - if p is "4 is a positive integer" and q is "√5 is a rational number", then p ∨ q is true
as statement p is true, although statement q is false.
Conjunctive Normal Form: If p, q are two statements, then "p and q" is a compound
statement, denoted by p ∧ q and referred as the conjunction of p and q. The conjunction of p
and q is true only when both p and q are true, otherwise, it is false
p q p∧q
T T T
T F F
F T F
F F F
Example: if statement p is "6<7" and statement q is "-3>-4" then the conjunction of p and q is
true as both p and q are true statements.
Structured Representation of Knowledge
There are mainly four ways of knowledge representation which are given as follows:
1. Logical Representation
2. Semantic Network Representation
3. Frame Representation
4. Production Rules
1. Logical Representation
Logical representation is a language with some concrete rules which deals with propositions
and has no ambiguity in representation. Logical representation means drawing a conclusion
based on various conditions. This representation lays down some important communication
rules. It consists of precisely defined syntax and semantics which supports the sound inference.
Each sentence can be translated into logics using syntax and semantics.
Syntax:
o Syntaxes are the rules which decide how we can construct legal sentences in the logic.
o It determines which symbol we can use in knowledge representation.
o How to write those symbols.
Semantics:
o Semantics are the rules by which we can interpret the sentence in the logic.
o Semantic also involves assigning a meaning to each sentence.
a. Propositional Logics
b. Predicate logics
Semantic networks are alternative of predicate logic for knowledge representation. In Semantic
networks, we can represent our knowledge in the form of graphical networks. This network
consists of nodes representing objects and arcs which describe the relationship between those
objects. Semantic networks can categorize the object in different forms and can also link those
objects. Semantic networks are easy to understand and can be easily extended.
Example: Following are some statements which we need to represent in the form of nodes and
arcs.
Statements:
a. Jerry is a cat.
b. Jerry is a mammal
c. Jerry is owned by Priya.
d. Jerry is brown colored.
e. All Mammals are animal.
In the above diagram, we have represented the different type of knowledge in the form of nodes
and arcs. Each object is connected with another object by some relation.
3. Frame Representation
A frame is a record like structure which consists of a collection of attributes and its values to
describe an entity in the world. Frames are the AI data structure which divides knowledge into
substructures by representing stereotypes situations. It consists of a collection of slots and slot
values. These slots may be of any type and sizes. Slots have names and values which are called
facets.
Facets: The various aspects of a slot is known as Facets. Facets are features of frames which
enable us to put constraints on the frames. Example: IF-NEEDED facts are called when data
of any particular slot is needed. A frame may consist of any number of slots, and a slot may
include any number of facets and facets may have any number of values. A frame is also known
as slot-filter knowledge representation in artificial intelligence.
Frames are derived from semantic networks and later evolved into our modern-day classes and
objects. A single frame is not much useful. Frames system consist of a collection of frames
which are connected. In the frame, knowledge about an object or event can be stored together
in the knowledge base. The frame is a type of technology which is widely used in various
applications including Natural language processing and machine visions.
Example: 1
Slots Filters
Year 1996
Page 1152
Example 2:
Let's suppose we are taking an entity, Peter. Peter is an engineer as a profession, and his age is
25, he lives in city London, and the country is England. So following is the frame representation
for this:
Slots Filter
Name Peter
Profession Doctor
Age 25
Weight 78
4. Production Rules
Production rules system consist of (condition, action) pairs which mean, "If condition then
action". It has mainly three parts:
In production rules agent checks for the condition and if the condition exists then production
rule fires and corresponding action is carried out. The condition part of the rule determines
which rule may be applied to a problem. And the action part carries out the associated problem-
solving steps. This complete process is called a recognize-act cycle.
The working memory contains the description of the current state of problems-solving and rule
can write knowledge to the working memory. This knowledge match and may fire other rules.
If there is a new situation (state) generates, then multiple production rules will be fired together,
this is called conflict set. In this situation, the agent needs to select a rule from these sets, and
it is called a conflict resolution.
Example:
o IF (at bus stop AND bus arrives) THEN action (get into the bus)
o IF (on the bus AND paid AND empty seat) THEN action (sit down).
o IF (on bus AND unpaid) THEN action (pay charges).
o IF (bus arrives at destination) THEN action (get down from the bus).
a. Logic
b. Semantic Network
c. Frame
d. Conceptual Graphs
e. Conceptual Dependency
f. Script
Logic
A logic is a formal language, with precisely defined syntax and semantics, which supports
sound inference. Different logics exist, which allow you to represent different kinds of things,
and which allow more or less efficient inference. The logic may be different types like
propositional logic, predicate logic, temporal logic, description logic etc. But representing
something in logic may not be very natural and inferences may not be efficient.
Semantic Network
The main idea behind semantic net is that the meaning of a concept comes, from the ways in
which it is connected to other concepts. The semantic network consists of different nodes and
arcs. Each node should contain the information about objects and each arc should contain the
relationship between objects. Semantic nets are used to find relationships among objects by
spreading activation about from each of two nodes and seeing where the activation met this
process is called intersection search.
The semantic network based knowledge representation mechanism is useful where an object
or concept is associated with many attributes and where relationships between objects are
important. Semantic nets have also been used in natural language research to represent complex
sentences expressed in English. The semantic representation is useful because it provides a
standard way of analyzing the meaning of sentence. It is a natural way to represent relationships
that would appear as ground instances of binary predicates in predicate logic. In this case we
can create one instance of each object. In instance based semantic net representations some
keywords are used like: IS A, INSTANCE, AGENT, HAS-PARTS etc.
Some complex sentences are there which cannot be represented by simple semantic nets and
for this we have to follow the technique partitioned semantic networks. Partitioned semantic
net allow for
2. Expressions to be quantified.
In partitioned semantic network, the network is broken into spaces which consist of groups of
nodes and arcs and regard each space as a node.
NOTE: On the above semantic network structures, the instance “IS A” is used. Also two terms
like assailant and victim are used. Assailant means “by which the work is done” and that of
victim refers t o “on which the work is applied”. Another term namely GS, which refers to
General Statement. For GS, make a node g which is an instance of Gs. Every element will have
at least two attributes. Firstly, a form that states which a relation is being asserted. Secondly,
one or more for all (") or there exists ($) connections which represent universally quantifiable
variables.
FRAME
A frame is a collection of attributes and associated values that describe some entity in the world.
Frames are general record like structures which consist of a collection of slots and slot values.
The slots may be of any size and type. Slots typically have names and values or subfields called
facets. Facets may also have names and any number of values. A frame may have any number
of slots, a slot may have any number of facets, each with any number of values. A slot contains
information such as attribute value pairs, default values, condition for filling a slot, pointers to
other related frames and procedures that are activated when needed for different purposes.
Sometimes a frame describes an entity in some absolute sense, sometimes it represents the
entity from a particular point of view. A single frame taken alone is rarely useful. We build
frame systems out of collection of frames that are connected to each other by virtue of the fact
that the value of an attribute of one frame may be another frame. Each frame should start with
an open parenthesis and closed with a closed parenthesis.
Syntax of a frame
Let us consider the below examples.
1) Create a frame of the person Ram who is a doctor. He is of 40. His wife name is Sita.
They have two children Babu and Gita. They live in 100 kps street in the city of Delhi in
India. The zip code is 756005.
(Ram
(ADDRESS
(CITY(VALUE Delhi))
(COUNTRY(VALUE India))
(Anand
(PROFESSION (VALUE Chemistry Professor))
(CHILDREN(VALUE RupaShipa)))
3) Create a frame of the person Akash who has a white maruti car of LX-400 Model. It
has 5 doors. Its weight is 225kg, capacity is 8, and mileage is 15 km /lit.
(Akash
The frames can be attached with another frame and can create a network of frames. The main
task of action frame is to provide the facility for procedural attachment and help in reasoning
process. Reasoning using frames is done by instantiation. Instantiation process begins, when
the given situation is matched with frames that are already in existence. The reasoning process
tries to match the current problem state with the frame slot and assigns them [Link]
valuesassigned to the slots depict a particular situation and by this, the reasoning process moves
towards a goal. The reasoning process can be defined as filling slot values in frames.
Conceptual Graphs
It is a knowledge representation technique which consists of basic concepts and the relationship
between them. As the name indicates, it tries to capture the concepts about the events and
represents them in the form of a graph. A concept may be individual or generic. An individual
concept has a type field followed by a reference field. For example person : Ram. Here person
indicates type and Ram indicates reference.
Consider an example
a. ACTS : Actions
b. PPs : Objects (Picture Producers)
c. AAs : Modifiers of Actions (Action Aiders)
d. Pas : Modifiers of PPs (Picture Aiders)
e. TS : Time of action
Conceptual dependency provides both a structure and a specific set of primitives at a particular
level of granularity, out of which representation of particular pieces of information can be
constructed.
For example
Double arrow indicates two way link between actor and action.
P: Past Tense
2) PTRANS: Transfer the physical location of an object ( Go, Come, Run, Walk)
It is an another knowledge representation technique. Scripts are frame like structures used to
represent commonly occurring experiences such as going to restaurant, visiting a doctor. A
script is a structure that describes a stereotyped sequence of events in a particular context. A
script consist of a set of slots. Associated with each slot may be some information about what
kinds of values it may contain as well as a default value to be used if no other information is
available. Scripts are useful because in the real world, there are no patterns to the occurrence
of events. These patterns arise because of clausal relationships between events. The events
described in a script form a giant casual chain. The beginning of the chain is the set of entry
conditions which enable the first events of the script to occur. The end of the chain is the set of
results which may enable later events to occur. The headers of a script can all serve as indicators
that the script should be activated.
Once a script has been activated, there are a variety of ways in which it can be useful in
interpreting a particular situation. A script has the ability to predict events that has not explicitly
been observed. An important use of scripts is to provide a way of building a single coherent
interpretation from a collection of observation. Scripts are less general structures than are
frames and so are not suitable for representing all kinds of knowledge. Scripts are very useful
for representing the specific kinds of knowledge for which they were designed.
1) Entry condition: It must be true before the events described in the script can occur. E.g.
in a restaurant script the entry condition must be the customer should be hungry and the
customer has money.
2) Tracks: It specifies particular position of the script e.g. In a supermarket script the tracks
may be cloth gallery, cosmetics gallery etc.
3) Result: It must be satisfied or true after the events described in the script have
occurred. e.g. In a restaurant script the result must be true if the customer is pleased. The
customer has less money.
4) Probs: It describes the inactive or dead participants in the script e.g. In a supermarket
script, the probes may be clothes, sticks, doors, tables, bills etc.
5) Roles: It specifies the various stages of the script. E.g. In a restaurant script the scenes
may be entering, ordering etc.
Now let us look on a movie script description according to the above component.
6) Scenes:
C ATTEND eyes towards the ticket counter C PTRANS C towards the ticket counters C
ATTEND eyes to the ticket chart
C ATRANS money to TS
TS ATRANS ticket to C
TC ATRANS ticket to C
SS ATRANS snacks to C
C ATRANS money to SS
7) Result:
D ATRANS prescription to P
P PTRANS prescription to P.
P PTRANS P for blood and urine test c. SCENE-3 (Entering into the Test
Lab)
P PTRANS P into the test room
P ATRANS Prescription to M
M ATRANS medicines to P
P ATRANS money to M
7) RESULT:
The system has over 4000 different types of links that can exist between concepts, such as
inheritance, and the “is–a” relationship that we have already looked at.
The idea behind CYC was that humans function in the world mainly on the basis of a large
base of knowledge built up over our lifetimes and our ancestors’ lifetimes.
By giving CYC access to this knowledge, and the ability to reason about it, they felt they would
be able to come up with a system with common sense. Ultimately, they predict, the system will
be built into word processors.
Then word processors will not just correct your spelling and grammar, but will also point out
inconsistencies in your document.
For example, if you promise to discuss a particular subject later in your document, and then
forget to do so, the system will point this out to you. They also predict that search engines and
other information retrieval systems will be able to find documents even though they do not
contain any of the words you entered as your query.
CYC’s knowledge is segmented into hundreds of different contexts to avoid the problem of
many pieces of knowledge in the system contradicting each other.