☰ Functional and Logic Programming (2023-2024)
1. Instructors
- Lecture
- Prof.dr. Horia F. Pop, Email:
- Seminars
- Lect.dr. Alina Călin, Email:
- Drd. Horea Muresan, Email:
- Labs
- Lect.dr. Adriana Coroiu, Email:
- Lect.dr. Zsuzsanna Onet-Marian, Email:
- Drd. Horea Muresan, Email:
- Drd. Adrian Rosian, Email:
- Drd. Daniel Pop, Email:
- Ms Roberta Fabian, Email:
The Teams class access code is xf6vua7.
2. Contents
Introduction
- Programming and programming languages. Imperative programming vs. declarative programming. Introduction
Logic Programming. The PROLOG programming language
- Basic elements of Prolog. Facts and rules in Prolog. Goals. The control strategy in Prolog. Variables and composed propositions. Anonymous variables. Rules for matching. The flux model. Sections of a Prolog program. Examples.
- The Prolog program. Predefined domains. Internal and external goals. Multiple arity predicates. The IF symbol (Prolog) and the IF instruction (other languages). Compiler directives. Arithmetic expressions and comparisons. Input/output operations. Strings.
- Backtracking. The backtracking control. The "fail" and "!"(cut) predicates. Using the "!" predicate. Type of cuts. The "not" predicate. Lists in Prolog. Recursion. Examples for backtracking in Prolog. Finding all solutions in the same time. Examples of predicates in Prolog. Non-deterministic predicates.
- Composed objects and functors. Unifying composed objects. Arguments of multiple types; heterogeneous lists. Comparisons for composed objects. Backtracking with cycles. Examples of recursive procedures. The stack frame. Optimization using the "tail recursion". Using the "cut" predicate in order to keep the "tail recursion".
- Recursive data structures. Trees as data structures. Creating and transversing a tree. Search trees. The internal database of Prolog. The "database" section. Declaration of the internal database. Predicates concerning operations with the internal database.
- Advanced issues on backtracking and efficiency in Prolog.
- Files management in Prolog. Elements of graphic.
Functional Programming. The LISP programming language
- Basic elements in Lisp. Dynamic data structures. Syntactic and semantic rules. Functions' classification in Lisp. Primitive functions in Lisp. Basic predicates in Lisp. Predicates for lists; for numbers. Logic and arithmetic functions. Defining user functions. The conditional form. The collecting variable method. Examples.
- Symbols management. Other functions for lists' accessing. OBLIST and ALIST. Destructive functions. Comparisons. Other interesting functions. Examples.
- Definitional mechanisms. The EVAL form. Functional forms; the functions FUNCALL and APPLY. LAMBDA expressions, LABEL expressions. Generators, functional arguments. MAP functions. Iterative forms. Examples.
- Other elements in Lisp. Data structures. Macro-definitions. Optional arguments. Examples.
Other skills
- Other functional and logic languages. Versions of LISP. Versions of PROLOG.
- Examples of applications. Programs presented comparatively in Lisp, Prolog and in imperative languages. Specific applications.
3. Bibliography
- Gabriela Czibula, H.F. Pop, Elemente Avansate de Programare in Lisp si Prolog. Aplicatii in Inteligenta Artificiala, Editura Albastra, Cluj, 2012
Other references
- A. Field, Functional Programming, Addison Wesley, 1988
- C. Giumale et. al., LISP, 2 Volume, Editura Tehnica,1987
- C. J. Hogger, Introduction to Logic Programming, Academic Press, 1984
- B. Parv, A. Vancea, Fundamentele limbajelor de programare, Litografia Universitatii "Babes-Bolyai" ~Cluj-Napoca, 1992
- H. F. Pop, Gabriela Serban, Programare in Inteligenta Artificiala - Limbajele Lisp si Prolog, Editura Albastra, Cluj, 2003
- H. F. Pop, Programare Functionala si Logica, Litografia Universitatii "Babes-Bolyai", 1998
- C. Reede, Elements of Functional Programming, Addison Wesley, 1989
- I. Streinu, LISP, Editura Stiintifica si Enciclopedica, 1986
- A. Walker et. al., Knowledge Systems and Prolog. A Logical Approach to Expert Systems and Natural Processing, Addison Wesley, 1987
- P. H. Winston, Lisp, Addison Wesley, 1984, 2nd edition
- P. H. Winston, Artificial Intelligence, Addison Wesley, 1984, 2nd edition
- P. Flach, Simply Logical Intelligent reasoning by Example, John Wiley & Sons, Chichester, England, 1994
- Documentatia produselor: Gold Common Lisp 1.01 si 4.30, ~XLisp
- Documentatia produselor: Turbo Prolog 2.0, ~SWI-Prolog
- http://www.ifcomputer.com/IFProlog/home_en.html
- http://www.lpa.co.uk - Logic Programming
4. Course schedule
Week | Lecture topic |
1 | Introduction. Recursion |
2 | The Prolog program |
3 | Backtracking in Prolog |
4 | Composed objects and functors. Controlling recursion |
5 | Recursive data structures |
6 | Efficient backtracking |
7 | Basic elements of Lisp |
8 | Defining user functions. Ramification of operations The collector variable method. Examples |
9 (*) | Objects management. Other functions Binary trees. Examples |
10 | Evolved definitional mechanisms |
11 | Examples of MAP functions |
12 | Other elements of Lisp |
13 | Written test paper (first half of groups) |
14 | Written test paper (second half of groups) |
- (*) Due to the National Holiday celebrations, there will be no classes on 30/11 and 1/12.
5. Lab schedule
Lab | | Lab topic |
receive | deliver |
1 | 1 | R1 | Recursive programming |
1 | 2 | P1 | Prolog Lists |
2 | 3 | P2 | Prolog Heterogeneous Lists |
3 | 4 | P3 | Using backtracking in Prolog |
| 4 | | Practical test in Prolog (one hour) |
4 | 5 (*) | L1 | Recursive programming in Lisp (1) |
5 | 6 | L2 | Recursive programming in Lisp (2) |
6 | 7 | L3 | Using Map functions in Lisp |
| 7 | | Practical test in Lisp (one hour) |
- (*) The scheduling situations due to the National Holiday celebrations will be dealt with accordingly by the laboratory teacher.
6. Lecture notes
Study resources are available on the UBB Sharepoint platform.
7. Software and resources for Prolog
We will use the SWI Prolog interpreter:
Resources
8. Software and resources for Lisp
We will use the Common Lisp dialect. The preferred Lisp interpreter is:
Resources
© Prof.dr. Horia F. Pop