You are on page 1of 18

An Introduction to

Logical Programming
Lecture 1

Fall 2023 Logic Programming 1


Course Details
Slides PPT
• 4 Homework's MCQ

• Mid-term Exam 10%



Attendance and quiz 10%

Project (Oral exam) 20%
Final Exam 60%

Fall 2023 Logic Programming 2


Grading

• Mid-term Exam 10 %
• Project (Oral exam) 20 %
• Lab. & Semester work 10 %
• Final-term Exam 60 %

Fall 2023 Logic Programming 3


Course Description
• This course will introduce the theory and
concepts of logic programming.
• Prolog (PROgramming in LOGic) will be studied
as a logic programming approach for
declarative ‫ التصريحية‬logic programming.
• Python will be used as a logic programming tool
• Declarative programming is where you say what
you want without having to say how to do it.
• Procedural programming, you have to specify
exact steps to get the result.

Fall 2023 Logic Programming 4


Course Objectives
• Upon completion of the course, student
should:
– Knowledge of concepts and theories of logic
programming.
– Become familiar with Prolog and Python
language syntax ‫تركيب الجملة‬.
– Be able to solve problems.
– Be able to use knowledge in a suitable form
to be used in Prolog and python languages.

Fall 2023 Logic Programming 5


Programming Techniques
• Unstructured programming
‫برمدة غير مىظمة‬
• Procedural programming.
‫برمدة إخرائية‬
• Modular programming.
‫برمدة معيبرية‬
• Object-oriented programming
‫برمدة شيئية‬
• Logic Programming.
‫برمدة مىطقية‬
Fall 2023 Logic Programming 6
Unstructured Programming
• Usually, people start learning programming by writing small
and simple programs consisting only of one main program.
• ``main program'' stands for ‫ يمثل بـ‬a sequence of commands
or statements, which modify ‫ تعديل‬data, which is global ‫عبلمية‬
throughout the whole program.
• As you should all know these programming techniques
provide tremendous ‫ هائلة‬disadvantages ‫ عيوب‬once the
program gets sufficiently large.
• For example, if the same statement sequence is needed at
different locations within the program, the sequence must
be copied.
• This has lead to the idea to extract ‫ نستخلص‬these sequences,
name them and offering a technique to call and return from
these
Fall 2023 procedures. Logic Programming 7
Procedural Programming ‫إخرائية‬
• With procedural programming, you
combine sequence of statements into one
single place.
• A procedure call is used to invoke ‫وستدعى‬
the procedure.
• Now we have a single program, which is
divided into small pieces called
procedures.

Fall 2023 Logic Programming 8


Modular Programming ‫عيبرية‬
• With modular programming procedures of
a common functionality are grouped
together into separate modules.
• A program therefore no longer consists of
only one single part.
• They interact ‫ يتفبعل‬through procedure
calls.
• Each module can have its own data (it
manage an internal state).
Fall 2023 Logic Programming 9
Object-Oriented Programming
• Object-oriented programming (OOP)
‫ البرمجة الشيئية‬is a programming
paradigm ‫ نموذج‬based on the concept of
"objects ‫"األشياء‬, which may contain data.
• In the form of fields ‫مجاالت‬, often known
as attributes ‫سمات – صفات مميزة‬
• And code, in the form of procedures ‫إجراءات‬
often known as methods.
• Objects have a notion ‫ فكرة‬of "this" or
"self".

Fall 2023 Logic Programming 10


Object-Oriented Programming
• In OOP, computer programs are
designed by making them out of ‫يخرجون‬
‫ من‬objects that interact with one
another.
• There is significant diversity ‫ تنوع كبير‬of
OOP languages,
• but the most popular ones are class-
based, meaning that objects
are instances ‫ حاالت‬of classes ‫فئات‬, which
typically also determine their type.
Fall 2023 Logic Programming 11
Object-Oriented Programming
• Many of the most widely-used programming
languages (such as C++, Object Pascal, Java,
Python etc.) are multi-paradigm programming
languages that support object-oriented
programming to a greater or lesser degree,
typically in combination
with imperative‫الزامى‬, procedural programming
• Significant object-oriented languages
include Java, C++, C#(Sharp), Python, PHP,
Ruby, Perl, Object Pascal, Objective C, Dart,
Swift, Scala, Common Lisp, and Smalltalk.

Fall 2023 Logic Programming 12


Logic Programming: Prolog
is descriptive ‫وصفية – تصويرية‬
• Instead of a series of steps specifying how the computer
must work to solve a problem, a Prolog program
consists of a description of the problem.
• Conceptually ‫مه الىبحية الىظرية‬, this description is made
up of ‫ يتكون مه‬two components:
1. Descriptions of the objects involved ‫ المشبركة‬in the
problem.
2. Facts and rules describing the relations between
these objects.

Fall 2023 Logic Programming 13


Motivation ‫الحافز‬
1. Reduce the programming burden ‫العبء‬.
2. System should simply accept the necessary
information and the objective (goal), and
then figure out ‫ معرفة‬its own solution.
3. Have a program that looks more like its own
specification.
4. Take advantage of logical inference ‫ استىتبج‬to
automatically get many of the
consequences ‫ وتبئح‬of the given information.

Fall 2023 Logic Programming 14


Procedural Languages
• They are also called imperative ‫ الزامية‬languages.
• Programmer gives all steps to solve a problem.
• He must know an algorithm to solve a problem.
Example: find average of list of numbers:
Input total
Input number
Average = total/number
Print Average

Fall 2023 Logic Programming 15


Declarative Languages ‫تصريحية‬
• Programmer describe the problem without the
control flow, then the system will solve the
problem.
• Programmer must know the relations between
objects to solve the problem.
• Programmer does not need to know an
algorithm to solve the problem.
• Declarative languages consists of:
– Program or theory.
– Computation which is deduction ‫استنتاج‬.

Fall 2023 Logic Programming 16


What is Prolog and Python
Good at used for?
• Grammars and Language processing,
• Knowledge representation and reasoning,
• Unification ‫التوحيد‬,
• Pattern matching ‫مطابقة األنماط‬,
• Planning and Search.

Fall 2023 Logic Programming 17


End

Fall 2023 Logic Programming 18

You might also like