Logic programming ( Handbook of Logic in Artificial Intelligence, Vol) by D. M. Gabbay, C. Hogger,...

Preview:

Citation preview

1

Logic programming

( Handbook of Logic in Artificial Intelligence, Vol) by D. M. Gabbay, C. Hogger, J.A. Robinson .

2

Gnu prolog program

http://gnu-prolog.soft112.com/download.html

3

Instruction

• You should print slides before classes.• You will be Assessment like this:• 40% on exams• 10% attendant and activity during class.• 10% activity file and assignment.• Your file will be assessment with second exam.• Zero mark for absent student on exams.

4

Objective:

• The aim of this course is to present the key concepts behind logic programming

• let you know about one of logic programming languages(prolog).

• how to write programs with logic.• how to make efficient implementations

(Queries).

5

Logic..

• Logic– is the study of the logic relationships between objects and – forms the basis of all mathematical reasoning and all

automated reasoning• Propositional Logic (PL) • In Propositional Logic, the objects are called propositions• Definition: A proposition is a statement that is either

true or false, but not both• We usually denote a proposition by a letter: p, q, r, s, …

6

Propositions: Examples

• The following are propositions– Today is Monday M– The grass is wet W– It is raining R

• The following are not propositions– C++ is the best language– What is your name?– Do your homework

7

Are these propositions?

• 2+2=5• Every integer is divisible by 12• Microsoft is an excellent company

8

Logical connectives• Connectives are used to create a compound

proposition from two or more propositions– Negation (e.g., a or !a or ā) $\neg$, $\bar$– And or logical conjunction (denoted ) $\wedge$– OR or logical disjunction (denoted ) $\vee$– XOR or exclusive or (denoted ) $\oplus$– Impli ion (denoted or )

$\Rightarrow$, $\rightarrow$ – Biconditional (denoted or )

$\LeftRightarrow$, $\leftrightarrow$• We define the meaning (semantics) of the logical

connectives using truth tables

9

Logical Arguments

• Consider the following statements.1. if you study then you succeed2. you study3. you succeed

• These three statements create a logical argument.• Lines 1 and 2 are premises and line 3 is the conclusion.• This logical argument is sound.– Premises can be true or false.– If the premises are true, the conclusion must be true.– If one (or more than one) of the premises is false, the

argument is still sound, but we don’t know whether the conclusion is true or false.

10

11

Rule of inference

12

Modus Ponens

if you study then you succeedyou studyyou succeed

Aristotle called this modus ponens:

if P then QP

Q

PremisesConclusion

(a rule of inference – one of the most important rules)

13

Important!

• We are dealing with the validity of an argument, NOT with the validity of the result!

• In logic, it doesn’t matter if a logical statement makes sense or not.

• What does matter is that if the premises are correct, then so is the result.

14

Modus Ponens Examples

• P: I study hardQ: I get an A

• P: cows give milkQ: doors open

Makes sense

Doesn’t make sense

if P then QP

Q

15

if thinks(‘Jill’) then exists(‘Jill’)thinks(‘Jill’)exists(‘Jill’)

if P(‘Jill’) then Q(‘Jill’)P(‘Jill’)Q(‘Jill’)

Predicates and Arguments

if ‘Jill’ thinks then ‘Jill’ exists‘Jill’ thinks‘Jill’ exists

if thinks(X) then exists(X)thinks(X)exists(X)

16

Predicates in arguments (continued…)

thinks(X) exists(X)thinks(X)exists(X)

thinks(X) -: exists(X)thinks(X)exists(X)

if thinks(X) then exists(X)thinks(X)exists(X)

17

18

19

20

21

22

23

24

Recommended