Professional Documents
Culture Documents
PROPOSITIONAL LOGIC
A proposition is a declarative statement that’s either TRUE or FALSE (but not both).
Propositions Not Propositions
3 + 2 = 32 Bring me coffee!
CS173 is Bryan’s favorite class. CS173 is her favorite class.
Every cow has 4 legs. 3+2
There is other life in the universe. Do you like Cake?
Disjunction
Disjunction corresponds to English “or.”
p q is when p or q (or both) are true.
Ex. Michael is brave OR nuts.
p Q pq
T T T
T F T
F T T
F F F
Implication
Implication: p q corresponds to English “if p then q,” or “p implies q.”
If it is raining then it is cloudy.
If there are 200 people in the room, then I am the Easter Bunny.
If p then 2+2=4.
p Q pq
T T T
T F F
F T T
F F T
Propositional Logic: Truth Tables
Truth table for different connectives for Negation, Disjunction (AND), Conjunction (OR), Condition,
Bicondition, NAND, NOR, XOR
Contrapositives: p q and q p
Ex. “If it is noon, then I am hungry.”
“If I am not hungry, then it is not noon.”
Converses: p q and q p
Ex. “If it is noon, then I am hungry.”
“If I am hungry, then it is noon.”
Inverses: p q and p q
Ex. “If it is noon, then I am hungry.”
“If it is not noon, then I am not hungry.”
RESOLUTION
Resolution is a procedure used in proving that arguments which are expressible in predicate logic are
correct. Resolution is a procedure that produces proofs by refutation or contradiction. Resolution leads to
refute a theorem-proving technique for sentences in propositional logic and first order logic. Resolution is
a rule of inference. Resolution is a computerized theorem prover
Algorithm: Propositional Resolution
Let F be a set of axioms and P the theorem to prove.
1. Convert all the propositions of F to clause form.
2. Negate P and convert the result to clause form. Add it to the set of clauses obtained in step 1.
3. Repeat until either a contradiction is found or no progress can be made
(a) Select two clauses. Call these the parent clauses.
(b) Resolve them together. The resulting clause called the resolvent, will be the disjunction of all
of the literals of both of the parent clauses with the following exception: If there are any pair of
literals L and L such that one of the parent clauses contains L and the other contains L, then
select one such pair and eliminate both L and L from the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has been found. If it is not, then add
it to the set of clauses available to the procedure.
Example 1
1. If a triangle is equilateral then it is isosceles.
2. If a triangle is isosceles the two sides AB and AC are equal.
3. If AB and AC are equal then angle B and angle C are equal.
4. ABC is an Equilateral triangle.
Prove “Angle B is equal to angle C”
Propositional Logic
4. Equilateral(ABC)
1. Equilateral(ABC)Isosceles(ABC)
2. Isosceles(ABC)Equal(AB,AC)
3. Equal(AB,AC) Equal(B,C)
Convert to clausal form
1. Equilateral(ABC) Isosceles(ABC)
2. Isosceles(ABC) Equal(AB,AC)
3. Equal(AB,AC) Equal(B,C)
4. Equilateral(ABC)
To prove ” Equal (B,C)”. Let us disprove “Not equal B and C Equal (B,C)”
Equilateral(ABC) Equilateral(ABC)
None
Thus we proved that angle B is equal to angle C
Example 2
1. Mammals drink milk.
2. Man is mortal.
3. Man is mammal.
4. Tom is a man.
Man(Tom) Man(Tom)
None
Thus we proved “Tom drinks Milk”
ii) To prove ” Tom is Mortal”Mortal(Tom)
Let us disprove “Not Tom is Mortal” Mortal(Tom)
Man(Tom) Man(Tom)
None
Thus we proved “Tom is Mortal”:
Disadvantage: Propositional logic only deals with finite number of propositions.
RESOLUTION:
A resolution inference step chooses two clauses having the property that one contains a disjunction X (a
positive literal) and the other contains a disjunct ¬X (a negative literal), these disjuncts are known as
complementary.
ALGORITHM: RESOLUTION-PREDICATE LOGIC
1. Convert all the statements of F to clause form.
Clausal form is a subset of first order logic. It is a normal form in which a sentence is defined by an
universal prefix (a string of universal quantifiers) and a matrix (a quantifier-free conjunction of a clause).
2. Negate P and convert the result to clause form. Add it to the set of clauses obtained in step 1.
3. Repeat until either a contradiction is found or no progress can be made
(a) Select two clauses. Call these the parent clauses.
(b) Resolve them together. The resolvent will be the disjunction of all the literals of both parent
clauses with appropriate substitutions performed and with the following exceptions: If there is
one pair of literals T1 and ¬T2 such that one of the parent clause contains T2 and the other
contains t1 and if t1 and t2 are unifiable, then neither T1 nor T2 should appear in the resolvent.
We call T1 and T2 as complementary literals. Use the substitution produced by the unificationto
create the resolvent. If there is more than pair of complementary literals, only one pair should be
omitted from the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has been found. If it is not, then add it
to the set of clauses available to the procedure.
There exists a procedure for making the choice that can speed up the process considerably
Only resolve pairs of clauses that contain complementary literals
Eliminate certain clauses as soon as they are generated so that they cannot participate in later
resolutions.
Whenever possible resolve either with one of the clauses that is part of the statement we are
trying to refute or with clause generated by a resolution with such clause. This is called set of
support strategy
Whenever possible resolve with clauses that have a single literal. Such resolution generate new
clauses with fewer literals. This is called unit preference strategy.
Algorithm: Predicate to Clausal Form Conversion
1- Eliminate the implication (→)
2- Move the negation down to the atomic formulas (by using the following rules)
3- Purge existential quantifiers The function that is eliminate the existential are called “ Skolem
function”
4- Rename variables, as necessary, so that no two variables are the same
5- Move the Universal quantifiers to the left of the statement.
6- Move the disjunction down to the literals, using distributive laws
7- Eliminate the conjunctions
8- Rename all the variables, as necessary, so that no two variables are the same.
9- Eliminate the universal quantifiers.
Problem 1
1. All people who are graduating are happy.
2. All happy people smile.
3. Someone is graduating.
4. Conclusion: Is someone smiling?
Solution:
Convert the sentences into predicate Logic
1. ∀x graduating(x)happy(x)
2. ∀x happy(x)smile(x)
3. ∃x graduating(x)
4. ∃x smile(x)
. graduating(name1) graduating(x)
None
Thus, we proved someone is smiling.
Problem 2
Explain the unification algorithm used for reasoning under predicate logic with an example.
Consider the following facts
a. Team India
b. Team Australia
c. Final match between India and Australia
d. India scored 350 runs, Australia scored 350 runs, India lost 5 wickets, Australia lost 7
wickets.
e. The team which scored the maximum runs wins.
f. If the scores are same the team which lost minimum wickets wins the match.
Represent the facts in predicate, convert to clause form and prove by resolution “India wins the
match”.
Solution:
Convert in to predicate Logic
(a) team(India)
(b) team(Australia)
(c) team(India) team(Australia)final_match(India, Australia)
(d) score(India,350) score(Australia,350) wicket(India,5) wicket(Australia,7)
(e) ∃x team(x) wins(x)score(x, max_runs))
(f) ∃xy score(x,equal(y)) wicket(x, min) final_match(x,y)win(x)
(vi) Eliminate ∀
(vii) Convert to conjunct of disjuncts form.
(viii) Make each conjunct a separate clause.
(a) team(India)
(b) team(Australia)
(c) team(India) team(Australia) final_match(India, Australia)
(d) score(India,350)
score(Australia,350)
wicket(India,5)
wicket(Australia,7)
(e) team(x) wins(x) score(x, max_runs))
(f) score(x, equal(y)) wicket(x, min_wicket) final_match(x, y)) win(x)
(ix) Standardize variables apart again.
To prove: win(India)
Disprove: win(India)
score(x, equal(y)) wicket(x, min_wicket) final_match(x, y)) win(x) win(India)
team(India)
team(India) team(Australia)
score(x,equal(y))wick
et(x, min_wicket)
None
Thus, proved India wins match.
Problem 3
Consider the following facts and represent them in predicate form:
F1. There are 500 employees in ABC company.
F2. Employees earning more than Rs. 5000 pay tax.
F3. John is a manager in ABC company.
F4. Manager earns Rs. 10,000.
Convert the facts in predicate form to clauses and then prove by resolution: “John pays tax”.
Solution:
Convert in to predicate Logic
1. company(ABC) employee(500,ABC)
2. ∃x company(ABC) employee(x, ABC) earns(x,5000)pays(x, tax)
3. manager(John, ABC)
4. ∃x manager(x, ABC)earns(x,10000)
Convert to clausal form
(i) Eliminate the sign
1. company(ABC) employee(500,ABC)
2. ∃x (company(ABC) employee(x, ABC) earns(x,5000)) pays(x, tax)
3. manager(John, ABC)
4. ∃x manager(x, ABC) earns(x, 10000)
(ii) Reduce the scope of negation
1. company(ABC) employee(500,ABC)
2. ∃x company(ABC) employee(x, ABC) earns(x,5000) pays(x, tax)
3. manager(John, ABC)
4. ∃x manager(x, ABC) earns(x, 10000)
(iii) Standardize variables apart
1. company(ABC) employee(500,ABC)
2. ∃x company(ABC) employee(x, ABC) earns(x,5000) pays(x, tax)
3. manager(John, ABC)
4. ∃y manager(x, ABC) earns(y, 10000)
(iv) Move all quantifiers to the left
(v) Eliminate ∃
1. company(ABC) employee(500,ABC)
2. company(ABC) employee(x, ABC) earns(x,5000) pays(x, tax)
3. manager(John, ABC)
4. manager(x, ABC) earns(y, 10000)
(vi) Eliminate ∀
(vii) Convert to conjunct of disjuncts form.
(viii) Make each conjunct a separate clause.
1. (a)company(ABC)
(b)employee(500,ABC)
2. company(ABC) employee(x, ABC) earns(x,5000) pays(x, tax)
3. manager(John, ABC)
4. manager(x, ABC) earns(y, 10000)
(ix) Standardize variables apart again.
Prove :pays(John, tax)
Disprove: pays(John, tax)
None
Thus, proved john pays tax.
Problem 4
If a perfect square is divisible by a prime p then it is also divisible by square of p.
Every perfect square is divisible by some prime.
36 is a perfect square.
Convert in to predicate Logic
1. ∀xy perfect_sq(x) prime(y) divides(x,y)divides(x,square(y))
2. ∀x∃y perfect_sq(x) prime(y) divides(x,y)
3. perfect_sq(36)
Problem 5
1. Marcus was a man
man(Marcus)
2. Marcus was a Pompeian
Pompeian(Marcus)
3. All Pompeians were Romans
∀x (Pompeian(x) Roman(x))
4. Caesar was a ruler
ruler(Caesar)
5. All Romans were either loyal to Caesar or hated him
∀x (Roman(x) loyalto(x,Caesar) hate(x,Caesar))
6. Everyone is loyal to someone
∀x ∃y (person(x) person(y) loyalto(x,y))
7. People only try to assassinate rulers they are not loyal to
∀x ∀y (person(x) ruler(y) tryassassinate(x,y) ¬loyalto(x,y))
8. Marcus tried to assassinate Caesar
tryassassinate(Marcus, Caesar)
9. All men are persons
∀x (man(x) person(x))
UNIFICATION ALGORITHM
When attempting to match 2 literals, all substitutions must be made to the entire literal. There
may be many substitutions that unify 2 literals, the most general unifier is always desired
Algorithm :Unify(L1,L2)
1. If L1 or L2 are both variables or constants, then:
(a) If L1 and L2 are identical, then return NIL.
(b) Else if L1 is a variable, then if L1 occurs in L2 the return {FAIL}, else return (L2/L1).
(c) Else if L2 is a variable, then if L2 occurs in L1 the return {FAIL}, else return (L1/L2).
(d) Else return {FAIL}
2. If the initial predicate symbols in L1 and L2 are not identical, the return {FAIL}.
3. If L1 and L2 have a different number of arguments, then return {FAIL}.
4. Set SUBST to NIL.
5. For i1 to number of arguments in L1:
(a) Call Unify with the ith argument of L1 and the ith argument of L2, putting result in S.
(b)If s contains FAIL then return {FAIL}
(c) If S is not equal to NIL then:
(i) Apply S to the remainder of both L1 and L2
(ii) SUBST=APPEND(S,SUBST).
6. Return SUBST.
Example
P(x) and P(y) :substitution = (x/y)
• P(x,x) and P(y,z) : (z/y)(y/x)
• P(x,f(y)) and P(Joe,z) : (Joe/x, f(y)/z)
• P(f(x)) and P(x) : can’t do it!
• P(x) Ú Q(Jane) and P(Bill) Q(y): (Bill/x, Jane/y)
FORWARD CHAINING
Forward chaining is one of the two main methods of reasoning when using an inference engine and can
be described logically as repeated application of modus ponens. Forward chaining is a popular
implementation strategy for expert systems, business and production rule systems. Forward chaining is
also known as data driven approach. Forward chaining starts with the facts and see what rules apply.
Facts are held in the working memory (ie., contains the current state of the world). Rules represent the
action to be taken when specified facts occur in the working memory. The actions involve adding or
deleting facts from the working memory.
Algorithm: Forward chaining
i) Collect the rules whose conditions match facts in working memory.
ii) If more than one rule matches then
(a) Use conflict resolution strategy to select the rules.
iii) Do the actions indicated by the rules. ie add facts to working memory or delete facts from working
memory.
iv) Repeat these steps until the goal is reached or no condition match found.\
Example
Rule R1: IF hot and smoky THEN fire
Rule R2: IF alarm_beeps THEN smoky
Rule R3: IF fire THEN switch_on_sprinklers
Inference
Rule R1: IF hot and smoky THEN fire
Rule R2: IF alarm_beeps THEN smoky
Rule R3: IF fire THEN switch_on_sprinklers
Suppose that we know the facts A, B, C, D, E and the rules shown in the knowledge base to the left
What facts can we infer from this?
After inferring facts X, L, Y and Z there are no more rules that can be fired.
BACKWARD CHAINING
This is also called goal driven approach. A desired goal is placed in working memory, inference
cycle attempts to find evidence to prove it.
The knowledge base (rule base) is searched for rules that might lead to goal. If condition of such rule
matches fact in working memory then rule is fired and goal is proved.
Backward chaining means reasoning from goals to facts. Rules and facts are processed using
backward chaining interpreter.
Algorithm: Backward Chaining
i) Prove goal G.
ii) if G is the initial fact, it is proven.
iii) Otherwise, find a rule which can be used to conclude G, and try to prove each of the rules conditions.
Example 1
Rule R1: IF hot and smoky THEN fire
Rule R2: IF alarm_beeps THEN smoky
Rule R3: IF fire THEN switch_on_sprinklers
Suppose that we know the facts A, B, C, D, E and the rules shown in the knowledge base to the
left. Can we infer the fact Z?
Backward chaining inferred Z from the facts and rules that were available.
Advantages
Most efficient to infer one particular fact.
User may be asked to input additional facts
KNOWLEDGE REPRESENTATION
A good system for the representation of structured knowledge in a particular domain should possess the
following four properties:
(i) Representational Adequacy:- The ability to represent all kinds of knowledge that are needed in that
domain.
(ii) Inferential Adequacy:- The ability to manipulate the represented structure to derive new structures
corresponding to the new knowledge inferred from old.
(iii) Inferential Efficiency:- The ability to incorporate additional information into the knowledge
structure that can be used to focus the attention of the inference mechanisms in the most promising
directions.
(iv) Acquisitional Efficiency :- The ability to acquire new knowledge using automatic methods wherever
possible rather than reliance on human intervention.
Given the fact that it is not [possible to answer a simple question such as “Who is the heaviest
player?”. But, if the procedure for finding the heaviest player is provided, then these facts will be enable
that procedure to compute an answer. This representation provides only little opportunity for inference.
Team(Pee-Wee-Reese)=Brooklyn Dodger
Batting average(Three finger Brown)=0.106
Height(Pee-Wee-Reese)=6.1
Bats(Three finger Brown)=right
iii) Inferential Knowledge
Inferential knowledge is inferred from objects through relations among objects. A word alone is a
simple syntax, but with the help of other words in phrase the reader may infer more from a word; this
inference with in linguistic is called semantics.
This knowledge generates new information from the given information. This information does
not require further data gathering from source, but does require analysis of the given information to
generate a new knowledge.
Example
Given a set of values and relations, one may infer other values or relations. Predicate logic is used
to infer from a set of attributes. Inference from a predicate logic uses a set of logical operations to relate
individual data.
i) Wonder is a name of a dog.
Dog(Wonder)
ii) All dogs belong to the class of animals.
∀x:dog(x) animal(x)
iii) All animals either live on land or in water.
∀x:animal(x) live(x, land) ∨ live(x, water)
From these three statements we infer that
Wonder lives either on land or on water
iv) Procedural Knowledge
Procedural Knowledge specifies what to do when. The procedural knowledge is represented in
program in many ways. The machine uses the knowledge when it executes the code to perform a task.
Example: A parser in a natural language has the knowledge that a noun phrase may contain articles
adjectives and nouns. Thus accordingly call routines that know how to process articles, adjectives and
nouns.
ONTOLOGICAL ENGINEERING
An ontology defines a common vocabulary for researchers who need to share information in a
domain. It includes machine-interpretable definitions of basic concepts in the domain and relations among
them.
Ontology is a branch of philosophy studying entities that exist, their classification, and the
relations between them. The types of entities are physical objects, abstract objects, time, locations,
actions, events and beliefs.
Upper ontology which consists of very general terms (such as "object", "property", "relation")
that are common across all domains. Upper ontology is the convention of drawing graphs with the general
concepts at the top and the more specific concepts below them
Physical Composition
The idea that one object can be part of another.
The general PartOf relation to say that one thing is part of another. Objects can be grouped into PartOf
hierarchies, reminiscent of the Subset hierarchy:
PartOf (Bucharest, Romania)
PartOf (Romania, EasternEurope)
PartOf (EasternEurope, Europe)
PartOf (Europe, Earth)
The PartOf relation is transitive and reflexive; that is, PartOf (x, y) ∧ PartOf (y, z) ⇒ PartOf (x, z)
Therefore, we can conclude PartOf (Bucharest, Earth).
Categories of composite objects are often characterized by structural relations among parts. For example,
a biped has two legs attached to a body:
Biped(a) ⇒ ∃l1,l2,b Leg(l1) ∧ Leg(l2) ∧ Body(b) ∧ PartOf (l1, a) ∧ PartOf (l2, a) ∧ PartOf (b, a) ∧
Attached(l1, b) ∧ Attached(l2, b) ∧ l1 ≠ l2 ∧ [∀ l3 Leg(l3) ∧ PartOf (l3, a) ⇒ (l3 = l1 ∨ l3 = l2)] .
Natural Kinds
Some categories have strict definitions: an object is a triangle if and only if it is a polygon with
three sides. On the other hand, most categories in the real world have no clear-cut definition; these are
called natural kind categories.
For example, tomatoes tend to be a dull scarlet; roughly spherical; with an indentation at the top
where the stem was; about two to four inches in diameter; with a thin but tough skin; and with flesh,
seeds, and juice inside. There is, however, variation. This poses a problem for a logical agent. The agent
cannot be sure that an object it has perceived is a tomato. One useful approach is to separate what is true
of all instances of a category from what is true only of typical instances. So in addition to the category
Tomatoes, we will also have the category
Typical (Tomatoes)
Most knowledge about natural kinds will actually be about their typical instances:
x ∈ Typical(Tomatoes) Red(x) Spherical(x).
Measurements
In both scientific and commonsense theories of the world, objects have height, mass, cost, and so on.
The values that we assign for these properties are called measures. Length has different names in our
language. We represent the length with a units function that takes a number as argument. If the line
segment is called L1, we can write
Length (L1) = Inches (1.5) = Centimeters (3.81)
Conversion between units is done by equating multiples of one unit to another:
Centimeters (2.54 × d) = Inches (d)
However, some measures have no scale: Beauty, Difficulty, etc.
EVENTS
Event calculus, which is based on points of time rather than on situations. Event calculus reifies
fluents and events. The fluent At(Shankar , Berkeley) is an object that refers to the fact of Shankar being
in Berkeley, but does not by itself say anything about whether it is true. To assert that a fluent is actually
true at some point in time we use the predicate T, as in T(At(Shankar , Berkeley), t).
Events are described as instances of event categories. The event E1 of Shankar flying from San
Francisco to Washington, D.C. is described as
E1 ∈ Flyings ∧ Flyer (E1, Shankar ) ∧ Origin(E1, SF) ∧ Destination(E1, DC )
The complete set of predicates for one version of the event calculus is
T(f, t) Fluent f is true at time t
Happens(e, i) Event e happens over the time interval i
Initiates(e, f, t) Event e causes fluent f to start to hold at time t
Terminates(e, f, t) Event e causes fluent f to cease to hold at time t
Clipped(f, i) Fluent f ceases to be true at some point during time interval i
Restored(f, i) Fluent f becomes true sometime during time interval i
A fluent does not hold if it was terminated by an event and not made true (restored) by another event.
Formally, the axioms are:
Happens(e,(t1, t2)) ∧ Initiates(e, f, t1) ∧ ¬Clipped(f,(t1, t)) ∧ t1 < t ⇒ T(f, t)
Happens(e,(t1, t2)) ∧ Terminates(e, f, t1) ∧ ¬Restored(f,(t1, t)) ∧ t1 < t ⇒ ¬T(f, t)
where Clipped and Restored are defined by
Clipped(f,(t1, t2)) ⇔ ∃ e, t, t3 Happens(e,(t, t3)) ∧ t1 ≤ t<t2∧Terminates(e, f, t)
Restored(f,(t1, t2)) ⇔ ∃ e, t, t3 Happens(e,(t, t3)) ∧ t1 ≤ t
Processes
Any process e that happens over an interval also happens over any subinterval:
(e ∈ Processes) ∧ Happens(e,(t1, t4)) ∧ (t1 < t2 < t3 < t4) ⇒ Happens(e,(t2, t3)).
The distinction between liquid and non-liquid events is exactly analogous to the difference between
substances, or stuff, and individual objects, or things.
Time intervals
Event calculus opens us up to the possibility of talking about time, and time intervals. We will
consider two kinds of time intervals: moments and extended intervals. The distinction is that only
moments have zero duration:
Partition({Moments, ExtendedIntervals},Intervals )
i∈ Moments ⇔ Duration(i) = Seconds(0) .
Possible words and accessibility relations: KSuperman (solid arrows) and KLois (dotted arrows)
R means “the weather report for tomorrow is rain” and I means “Superman’s secret identity is
Clark Kent.”
In the diagram, represent the scenario where it is common knowledge that Superman knows his identity,
and Lois might or might not have seen the weather report. We represent this by combining the two top
scenarios.
REASONING SYSTEMS FOR CATEGORIES
The reasoning is the mental process of deriving logical conclusion and making predictions from
available knowledge, facts, and beliefs. Or we can say, "Reasoning is a way to infer facts from existing
data." It is a general process of thinking rationally, to find valid conclusions. Categories are the primary
building blocks of large-scale knowledge representation schemes. There are two closely related families
of systems:
(i) Semantic networks
(ii) Description logics
Semantic networks
Semantic networks provide graphical aids for visualizing a knowledge base and efficient algorithms
for inferring properties of an object on the basis of its category membership. Semantics—are a form of
logic.
There are many variants of semantic networks, but all are capable of representing individual objects,
categories of objects, and relations among objects. A typical graphical notation displays object or
category names in ovals or boxes, and connects them with labeled links.
A semantic network with four objects (John, Mary, 1, and 2) and four categories. Relations are
denoted by labeled links.
For example, has a MemberOf link between Mary and FemalePersons, corresponding to the logical
assertion Mary ∈FemalePersons ; similarly, the SisterOf link between Mary and John corresponds to the
assertion SisterOf (Mary, John). This link asserts that
∀ x x∈Persons ⇒ [∀ y HasMother (x, y) ⇒ y ∈ FemalePersons] .
We might also want to assert that persons have two legs,
∀ x x∈Persons ⇒ Legs(x, 2) .
(i) Inheritance
The semantic network notation makes it convenient to perform inheritance reasoning. Inheritance
becomes complicated when an object can belong to more than one category or when a category can be a
subset of more than one other category; this is called multiple inheritance. In such cases, the inheritance
algorithm might find two or more conflicting values answering the query.
For example, the sentence Fly(Shankar , NewYork, NewDelhi, Yesterday) cannot be asserted directly in a
semantic network
One of the most important aspects of semantic networks is their ability to represent default values for
categories. Examining carefully, one notices that John has one leg, despite the fact that he is a person and
all persons have two legs. In a strictly logical KB, this would be a contradiction, but in a semantic
network, the assertion that all persons have two legs has only default status; that is, a person is assumed to
have two legs unless this is contradicted by more specific information.
We can retain a strictly logical semantics for the network if we say that the Legs assertion for Persons
includes an exception for John:
∀ x x∈Persons ∧ x ≠John ⇒ Legs(x, 2)
Description Logics
Description logics provide a formal language for constructing and combining category definitions
and efficient algorithms for deciding subset and superset relationships between categories. Description
logics are notations that are designed to make it easier to describe definitions and properties of categories.
The principal inference tasks for description logics are subsumption (checking if one category is a
subset of another by comparing their definitions) and classification (checking whether an object belongs
to a category). Some systems also include consistency of a category definition—whether the membership
criteria are logically satisfiable.
Logical Operators
a :- b. /* a if b */ :- means ‘if’ or ‘implied by’
a :- b,c. /* a if b and c. */ comma ‘,’ stands for ‘and’ or ‘conjunction’
a :- b;c. /* a if b or c. */ semicolon ‘;’ stands for ‘or’ or ‘disjunction’
a :- not b. /* a if b fails */
a :- b -> c;d. /* a if (if b then c else d) */
Prolog program
A program consists of clauses. These are of three types: (i) facts, (ii) rules and (iii) questions. A
procedure is a set of clauses about the same relation.
Facts: Facts describe the explicit relationship between objects and object properties.
Example: Mani is a cat.
Ram has phone number “112233” is written in prolog as
phoneno(ram,112233).
It should be noted that
Names of properties/relationships begin with lower-case letters
The relationship name appears as the first term
Objects appear as comma-separated arguments within parenthesis
A period ”.” must end a fact
Objects also begin with lower-case letters. They can also begin with digits and can string
of characters enclosed in quotes, E.g. color(penink, ‘red’).
color(penink, ‘red’) is also called predicate or clause.
The following are the facts that will be stored in the prolog database
%teaches(X,Y):person x teaches in course Y
teaches(sudhir, course001).
teaches(tapas, course002).
teaches(pranab, course003).
teaches(joydeb, course001).
%student(X,Y):student X studies in course Y
studies(suparna, course001).
studies(santanu, course001).
studies(sudip, course002).
studies(shobana, course003).
studies(subin, course003).
studies(swarna, course003).
Rules: Define implicit relationship between objects (brother realtionship) and object properties
(A is a child of B if B is parent of A).
Consider the following case which produces a general rule
One teacher will guide a student if that student studies that course id on which the teacher
teaches
In prolo it will be written as
guide(Teacher, Courseid), studies(Student, Courseid).
Queries: Asking questions about relationship between objects and object properties. Example:
Rathna is parent of whom?
Queries will be based on facts and rules. We can ask questions based on the stored
information.
Suppose we want to know id sudhir lectures in course001 or not, then we can ask
?-teaches(sudhir,course001).
Yes
In GNU prolog, queries are terminated by a full stop.
To answer this query, prolog consults its database to see if this is a known fact or not.
?-teaches(suhir, X).
X=course001
If the answer is true or yes, then the query succeeded and if the answer is false or no, then
the query failed.
Features of Prolog
Prolog’s fast incremental development cycle and rapid prototyping capabilities have
encouraged the use of the language as a tool for solving AI problems.
Prolog is a powerful tool for building robust commercial applications
Prolog features include interfaces to other languages and database products, stand-alone
application generators, and more recently, support techniques such as object oriented and
constraint based programming.
Object oriented extensions to prolog have increased the attractiveness and expressive
power of the language and provide prolog users with a powerful and flexible object
oriented development language.
Constraints replace prolog’s usual pattern-matching mechanisms with a more general
operation called “constraint satisfaction”.
Constraints are a powerful way to reduce the size of the search space and thus increase
the efficiency of the scheduler.
Applications of prolog
Intelligent Database Retrieval
Natural Language Understanding
Expert System
Specification Language
Machine Learning
Robot Planning
Automated Reasoning
Problem Solving