You are on page 1of 43

Version

2017

Logic Programming

Upekha
Vandebona
upe.vand@gmail.c
Introduction

Non-procedural programming
paradigm

First-
Reasonin order
g Predicate Prolog
Logic

Check Concept Ma
Lesson 01
Introduction to
Reasoning
Upekha Vandebona
upe.vand@gmail.co
m
Introduction
Drawing conclusions, solving problems, making
inference, etc.
Day-to-day Scientific
Reasoning Reasoning

Mathematical
so ning Reasoning
Rea
n amic
Dy
e asonin
ase dR
el-B
Game Mo d
Determini
s stic reason
ing
What is reasoning?

Search and match


Case-base reasoning

Exploring the available knowledge to


see what can be
concluded from the knowledge is
actually reasoning.
Nature of Knowledge

How we explore the available


knowledge is dependent on the
nature of knowledge
Examples

We solve a
mathematical
equation, which is a
form of knowledge,
through a step-by-step
deductive reasoning
Nature of Knowledge

In science we need a large number of


evidence to draw a conclusion.

For instance,
Paracetamole has
been concluded as a o n ing
as
pain killer because it e Re
t iv
uc
had worked as a pain In d

killer for thousands of


people.
Nature of Knowledge
However, just because 99
students solve a
mathematical problem in
one manner, it cannot be
concluded that the
solution is correct.
Perhaps, one student may
be correct.
Therefore, validity of a solution to
mathematical problem cannot be obtained
by the use of the reasoning strategy
applied in science.
Nature of Knowledge

The choice of the inappropriate


reasoning technique may result in a
wrong or invalid conclusion.
For Girls : Suppose you have to play Need for Speed.
When playing explain which reasoning techniques you
may use to decide which keys to use :D

For Boys : Suppose you have to make a Cake. When


preparing, explain which reasoning techniques you may
Activity use to decide on putting different items at different
times in different quantities :D
Types of Reasoning

Lets define this in a more formal way.

1. Deterministic reasoning
2. Dynamic reasoning
3. Non-deterministic reasoning
4. Search and match
5. Deductive reasoning
6. Abductive reasoning
7. Inductive reasoning
1. Deterministic Reasoning

Returns exactly ONE answer as the conclusion


for a given situation.
Based on the Aristotles Classical Logic that
deals with only two truth values: true or false.
A given statement is either true or false, but
it cannot be true and false at the same
time.
Ex: 4 < 5
2. Dynamic Reasoning

Used to draw conclusions in


situations where we have
incomplete and inconsistent
information. Information may vary
from time to time.
Current Information New Information
Suitable in Birds can fly Penguins cannot fly
real world Tweety is a bird Tweety is a penguin
problem
solving Conclusion Conclusion
because the Tweety can fly Tweety cannot fly
entire world
3. Non-deterministic
Reasoning
Drawingconclusions by giving
more than one answer
Example
When the price of 1kg of rice is Rs. 100/=, it can
be considered as rice is expensive.

This can be concluded as a true statement by


some people. Some other people say that this is
false. Another person might say that the
statement is closer to the truth, but it is not
exactly true. Here the answer is in between true
and false.
4. Search and Match
Very common reasoning strategy for drawing
conclusions.
Ex. Find the result mark of a particular student
from a list
Although this reasoning technique appears to be
very familiar, the search is such a complex task
when the search spaces are large and also have
many possibilities. (Use Search algorithms)
5. Deductive
Reasoning***
Drawing of conclusions on the basis of a
given set of true statements, named as
premises.
In deductive reasoning it preserves the
truth. In other words, the conclusions drawn
from deductive reasoning are always true.
Used in many areas including mathematics,
science, computing, court of law expert
systems like areas in Artificial Intelligence
etc.
Deductive Reasoning (contd.)

Mathematics is one of the major


areas that use logic to draw
conclusions from the premises.

Examples
We simplify the 2+3+0 as 2+3,
knowing the premise 3+0 is 3 in real
numbers.
Deductive Reasoning (contd.)

Elephants are vegetarian is a true


statement, while Computers are
machines is also true.
According to deductive reasoning
conjunction (and) of true statements
must also be true.
Therefore, we conclude that
Elephants are vegetarian and
Computers are Machines also true.
Deductive Reasoning (contd.)

It should be noted that deductive reasoning


needs not match with the real world
experiences, though it preserves the truth.
if baby does not cry then mother is happy
if baby is dead then baby does not cry Premis
es
Conclusion if baby is dead then mother is happy
???
Matching the conclusions with the real world is not a
concern of deductive reasoning. It primarily talks
about how to draw logically valid conclusions from
6. Abductive Reasoning
Knowing a conclusion, trying to establish the
premise(s).
Knowing the conclusion you have red patches we
arrival at the premise you have dengue fever
Obviously, the abductuve reasoning may not be true.
Because knowing that you have red patches there
can be many premises other than dengue fever.
So it does not preserve the truth.

P Q is not equivalent to QP
Abductive Reasoning (contd.)

However, it should be noted that


abductive reasoning is of great
importance to find facts for
establishing a deductive conclusion.
Example

battery is good, starter motor is good, spark


plugs are good and fuel is in the tank -
Premises
car should start - Conclusion
in order to find why the car does not start,
we begin with the conclusion part and check
for premises one by one.
Abductive Reasoning (contd.)

Abductive reasoning is applied in


medical diagnose.
Doctor suspects a disease and
recommend various tests for
establishing premises.
Having received the reports, doctor
logically analyses the report
(deductive reasoning) and come to
a conclusion.
7. Inductive Reasoning
Uses a large number of evidence or
observations for drawing a conclusion.
ex.: Having given Panadol for many patients,
scientists have noticed that it works as a pain
killer. Therefore, it is concluded that Panadol is
a pain killer.
But tomorrow one can find an evidence to say
that Panadol is not a pain killer and instead it
does damage to the brain.
Does not preserve the truth or its
conclusions are not always true.
Same like Scientific Conclusions
8. Case-based Reasoning
Cases are structured evidence to draw
conclusions.
In court of law, lawyers argue on the
basis of previous cases and judges come
to conclusion as per the cases presented.
Match against appropriate cases.
Otherwise conclusion may not relevant.
Example
For example, a case of driving without a license
cannot be compared with a murder case to decide
on the punishment for killing a person.
Case-based Reasoning (contd.)

Select cases from the same domain (area)


Example
In order to diagnose the fault of a certain television
you may consider a case of similar television but not
a case of radio or a bicycle.

Case-based reasoning can go with other reasoning


techniques
large number of cases that support the new case,
inductive reasoning can be used together with case-
based reasoning to draw a conclusion.
few cases that support the new case,
Deductive reasoning can be used together with case-
9. Analogical Reasoning
Similar to case-based reasoning, but do not
need to consider the cases or examples
from the same domain.
when we take the analogy that a computer
is like a brain, obviously the brain and the
computer are from different domains
Works very well in the real world (natural
algorithms, neural networks)
In order to describe an aircraft, to a person
who knows about birds, we can use the
analogy: an aircraft is like a bird.
Analogical Reasoning (contd.)

Further, to explain about an aircraft to a


person who knows about seagoing
vessels, we can use the analogy: an
aircraft is like a ship.
Analogical reasoning helps draw
conclusions not only in terms of
similarities but also through dissimilarities.
For examples, when we say a car is bigger
than a bicycle, we can notice the
difference between a number of seats of a
car and a bicycle to conclude about the
size of a car.
10. Model-Based
Reasoning
Models are proven examples for describing
something.
They are stronger than cases or analogies.
Ex: Newtonian theory F=ma is called a model which is
proven through scientific experiments.
All scientific models have the explanation
power. As such, model-based reasoning provides
not only conclusions but also reasons for such
conclusions.
It is a well known fact that explanation ability
is one of the key features of scientific theories.
Obviously, conclusions (solutions) with
justifications are more important than mere
conclusions.
1. C
One answer
Deterministi L
c Reasoning
t Information
2. Dynamic Incomplete/Inconsisten
C
Reasoning L

3. Non- More than one answer


deterministi
c Reasoning

4. Search From a content


and Match
***
Reasoning
From large number of Inductive
observations 7.
Premise from
Reasoning
Abductive
Conclusion 6.
Not Preserves truth
L
***
Conclusion from
C Reasoning
Premises Deductive
Preserves truth 5.
Reasoni
Scientific Models
Based
Model
ng
10.
Reasoni
No same domain al
Use analogy Analogic
9.
ng
Match against the Reasoni
appropriate same Based
domain cases 8. Case
Activity
Activity 1.2 given in the book

Identify what are the conclusions and what are the premis
Premise vs. Conclusion

Apremiseincludes the reasons and


evidence behind a conclusion.
Aconclusionis the statement that
the premise supports and is a way of
promoting a certain belief or point of
view.
Since carrots are full of vitamins, it
follows that your body will benefit if you
eat them.
Indicator Words
Since carrots are full of vitamins, it

follows that your body will benefit if you
eat them.
Examples of words or phrases that are typically included
in premises:

because Sometimes
since indicator
given that word may be
seeing that hidden
as shown by
assuming that e.g. Carrots
considering that have
for the reason thatsignificant
vitamin
Try to reverse this content,
Examples
statement
of words or phrases that are typically
according to
Exercise : Find the premises
and conclusions and reverse
the statement
Sinceall humans have the
capacity for creative thought
and all capacities could be
developed and used, it follows
that all humans can think
creatively.

All humans can think creatively because all


humans have the capacity for creative
thought and all capacities could be
Road accidents in Sri Lanka have gone up over
the last 10 years. According to RMV reports,
the number of vehicles introduced to the roads
has also been increased day by day. Many
people complain that accidents are due to
unethical behaviour of drivers. Drivers
say that road conditions are so poor and
this leads to the increase of the rate of
accidents and also send the vehicle
condition down. If the road condition is so
crucial all types of drivers must be
affected, but accidents are generally
caused by private bus divers. Therefore,
drivers unethical behaviour is more
relevant than road conditions for the
increase of accidents. There is also
Many people complain that accidents
are due to unethical behaviour of
drivers.
Inductive
Reasoning

This is an observation by many people.

Can rewrite as Accidents are happening because


of unethical behaviour of drivers.

Accidents are happening


because of unethical behaviour of
drivers.
Drivers say that road conditions are so
poor and this leads to the increase of
the rate of accidents and also send the
vehicle condition down. Inductive
Reasoning

This is an observation by drivers.

We can rewrite this as Road conditions are so


poor and as a result it leads to the increase of the
rate of accidents and also send the vehicle
condition down.

Road conditions are so poor and as a


result it leads to the increase of the rate
of accidents and also send the vehicle
If the road condition is so crucial all
types of drivers must be affected

Deductive
Reasoning

Can be write as a P Q statement. If P then Q.


If the road condition is so crucial then all types
of drivers must be affected [by the condition of
the road]

P = road condition is so
crucial
Q = all types of drivers must
be affected [by the condition
but accidents are generally caused by
private bus drivers. Therefore, drivers
unethical behaviour is more relevant
than road conditions for the increase of
accidents Deductive
Reasoning
Can be write as a P Q statement. If P then Q.
If accidents are generally caused by private bus
divers then drivers unethical behaviour is more
relevant than road conditions for the increase of
accidents

P = accidents are generally caused by


private bus divers
Q = drivers unethical behaviour is
more relevant than road conditions
There is also evidence to say that even
if you drive carefully, you are not safe
because drivers of other vehicles are
unethical
Case Based
Reasoning
Uses the structured evidence. (Precedent Cases)

Even you drive carefully,


you are not safe because
drivers of other vehicles
are unethical
More on Deductive
Reasoning
In the computing world, Deductive
Databases are some of the best
examples of application of deductive
reasoning for drawing conclusions
from huge databases.
Further, deductive reasoning has
been used in expert systems like
areas in Artificial Intelligence.
Logic Programming

Logic can explicitly represent


knowledge.
Logic has an elegant mechanism to
do reasoning.

Programs are written as collection of


predicate logic (first order logic
[FOL]) expressions.
Thank You!

Next Lecture On ...


Refresh on First Order

You might also like