You are on page 1of 31

Introduction to Logic Programming

Dr. Abdelaziz Said

1
Introduction to Logic Programming
Dr. Abdelaziz Said

2
Contents

1 Course Information

2 Course Description

3 Human Logic

4 Formal Logic

5 Logic Applications

3
Course Information

Saturday 10:20 - 12:00


Lecture

Monday 8:30 - 12:00


Office Hours

60% Final exam,


Grading
40% (Midterm+ Practical + Oral exam)
3 Quizzes across course
Assignments

4
Course Description

Propositional

Logic types

First order

Part _1

Classical
methods
Reasoning
procedures
Course
Resolution

Prolog
Part_2

Visual prolog

5
Introduction

❖ Logic of Computation: Program verification and


proving properties.

❖ Computational Logic: direct use of logic as a


programming tool.

6
Introduction

❖ Logic: means of formalizing the human thought


process.

7
Introduction

❖ Uses of Logic:

➢ Allows us to reason about the correctness of programs.

➢ Allows us to represent problems and solve them.

8
Human Logic

❖ Logic is the science of reasoning.

9
Human Logic

❖ Human brains are information processors.

❖ We acquire information about the world and use this


information to form our behavior and actions.

❖ The strengths of human information processing is our


ability to represent and manipulate logical information, not
just simple facts but also more complex forms of
information, such as negations, alternatives, constraints,
and so forth.

10
Human Logic
Example:

• All men are mortal.


• John is a man.
• Therefore, John is mortal.

11
Human Logic
Example:

• Some men are mortal.


• John is a man.
• Therefore, John is mortal.

12
Human Logic
Example:

13
Human Logic
Example:

14
Human Logic

15
Human Logic

Deduction reasoning

Induction reasoning

Reasoning Types
Abduction reasoning

Reasoning by analogy

16
Human Logic
Deductive Reasoning:

Reasoning from general to particular.

Example:

• All men are mortal.


• John is a man.
• Therefore, John is mortal.

17
Human Logic
Inductive Reasoning:

Reasoning from particular to general.

Example:

• I have seen 1000 black cars in my city.


• I have never seen a car that is not black.
• Therefore, every car in my city is black.

18
Human Logic

19
Human Logic
Abductive Reasoning:

Reasoning from effects to causes.

Example:

• If there is no fuel, the car will not start.


• The car does not start.
• Therefore, there is no fuel.

20
Human Logic

21
Human Logic
Reasoning by analogy:

Reasoning based on similarity of


two situations.

Example:
• The water flow in a pipe is proportional to its
diameter.
• Wires are like pipes.
• Therefore, the current in a wire is proportional to its
diameter.

22
Human Logic

Deductive reasoning is the only type that


guarantees its conclusion in all cases

23
Formal Logic

❖ Formal Logic is a formal version of human


logic.

▪ Provides a formal language with unambiguous


syntax and precise semantic.
▪ Provides rules for manipulating expressions in a
way that respects this meaning.

❖ Formal Logic eliminates natural Languages


difficulties using formal language for encoding
information.
24
Formal Logic

EXAMPLE :

▪ Ahmed is three times as old as Ali.


▪ Ahmed's age and Ali's age add up to twelve.
▪ How old are Ahmed and Ali ?

▪ x - 3y = 0 Formalization
▪ x + y = 12

25
Formal Logic

EXAMPLE :
▪ Ahmed likes reading and swimming .
▪ If Ahmed likes something, then Ali likes it.
▪ Does Ali like swimming ?

Formalization
Likes( Ahmed, reading)
Likes( Ahmed, swimming)
Likes( Ahmed, X) → likes ( Ali, X)

26
Formal Logic

❖ Given the syntax and semantics of this formal


language, we can give a precise definition for
the notion of logical conclusion.

❖ Example:

▪ Propositional logic
▪ First Order Logic ( predicate Logic)

27
Applications of Logic

❖ Artificial Intelligence
❖ Mathematics
▪ Automated reasoning programs could be used to check
mathematical proofs and in some cases, could be used to
produce proofs or portions of proofs.
❖ Software analysis
▪ verify various properties of programs such as
correctness, termination, complexity, etc.
❖ Law and business

28
Applications of Logic

❖ Hardware Engineering:

• Simulations
• Configuration and simplification
• Diagnosis
• Testing
29
Applications of Logic

❖ Data Bases:

30
Chapter 1

31

You might also like