Functional and Logic Programming

Instructors

Objectives

Final grade

Minimal passing criteria

If the final grade is less than 5 while at least one of the activities (written evaluations, practical tests) was absented, the final mark will be absent, and not failed. The final grade will be determined during the retake session.

Class activities

All activities require physical class participation. This is a full attendance, not a distance learning program.

According to the National Education Act (1/2011), the recording of didactical activity by any means is only possible by explicit agreement of the teaching person. Consequently, no recording of any didactical activity, by any means and on any support, is allowed.

The Teams class access code is r6h7r85.

The seminars and labs attendance sheet is available here. The identification code is the unique code from Academic Info.

Contents

Introduction

  1. Programming and programming languages. Imperative programming vs. declarative programming. Introduction

Logic Programming. The PROLOG programming language

  1. 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.
  2. 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.
  3. 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.
  4. 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".
  5. 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.
  6. Advanced issues on backtracking and efficiency in Prolog.
  7. Files management in Prolog. Elements of graphic.

Functional Programming. The LISP programming language

  1. 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.
  2. Symbols management. Other functions for lists' accessing. OBLIST and ALIST. Destructive functions. Comparisons. Other interesting functions. Examples.
  3. Definitional mechanisms. The EVAL form. Functional forms; the functions FUNCALL and APPLY. LAMBDA expressions, LABEL expressions. Generators, functional arguments. MAP functions. Iterative forms. Examples.
  4. Other elements in Lisp. Data structures. Macro-definitions. Optional arguments. Examples.

Other skills

  1. Other functional and logic languages. Versions of LISP. Versions of PROLOG.
  2. Examples of applications. Programs presented comparatively in Lisp, Prolog and in imperative languages. Specific applications.

Bibliography

  1. Gabriela Czibula, H.F. Pop, Elemente Avansate de Programare in Lisp si Prolog. Aplicatii in Inteligenta Artificiala, Editura Albastra, Cluj, 2012

Other references

  1. A. Field, Functional Programming, Addison Wesley, 1988
  2. C. Giumale et. al., LISP, 2 Volume, Editura Tehnica,1987
  3. C. J. Hogger, Introduction to Logic Programming, Academic Press, 1984
  4. B. Parv, A. Vancea, Fundamentele limbajelor de programare, Litografia Universitatii "Babes-Bolyai" ~Cluj-Napoca, 1992
  5. H. F. Pop, Gabriela Serban, Programare in Inteligenta Artificiala - Limbajele Lisp si Prolog, Editura Albastra, Cluj, 2003
  6. H. F. Pop, Programare Functionala si Logica, Litografia Universitatii "Babes-Bolyai", 1998
  7. C. Reede, Elements of Functional Programming, Addison Wesley, 1989
  8. I. Streinu, LISP, Editura Stiintifica si Enciclopedica, 1986
  9. A. Walker et. al., Knowledge Systems and Prolog. A Logical Approach to Expert Systems and Natural Processing, Addison Wesley, 1987
  10. P. H. Winston, Lisp, Addison Wesley, 1984, 2nd edition
  11. P. H. Winston, Artificial Intelligence, Addison Wesley, 1984, 2nd edition
  12. P. Flach, Simply Logical Intelligent reasoning by Example, John Wiley & Sons, Chichester, England, 1994
  13. Documentatia implementarilor Common Lisp
  14. Documentatia implementarilor Prolog
  15. http://www.ifcomputer.com/IFProlog/home_en.html
  16. http://www.lpa.co.uk - Logic Programming

Course schedule

Lab schedule

LabLab topic
receivedeliver
11R1Recursive programming
12P1Prolog Lists
23P2Prolog Heterogeneous Lists
34P3Using backtracking in Prolog
 4 Practical test in Prolog (one hour)
45L1Recursive programming in Lisp (1)
56L2Recursive programming in Lisp (2)
67L3Using Map functions in Lisp
 7 Practical test in Lisp (one hour)

Lecture notes

Software and resources for Prolog

Software

SWI-Prolog

Resources

Software and resources for Lisp

Software

GNU CLisp Steel Bank Common Lisp

Resources

Written test paper

The written test paper will take place during the last two weeks of school. Specific details on how the written test will take place will be communicated later.

This is not an exam, but a written test organized as part of a colloquium assessment. As such, the students will participate at the test at the specific date the test is offered for each of them, as scheduled. There are no exceptions.

Seminar attendance requirements

Attendance at seminar activities is compulsory in proportion of 75% (minimum 5 seminars out of 7).

The seminar attendance may be redone with another group inside the two weeks allocated to that seminar, with the explicit agreement of the seminar instructor (pending space availability).

The students without minimum 5 attendances at seminar activities CANNOT participate to the written paper (during weeks 13-14 and during the resit session) and CANNOT get a passing grade.

Lab attendance requirements

Attendance at lab activities is compulsory in proportion of 90% (minimum 6 seminars out of 7).

The lab attendance may be redone for at most one lab, during the two weeks allocated to that lab, with the explicit agreement of the lab instructor (pending space availability), but the lab doc is graded in the usual way, considering the delay penalty.

In case of illness, the absence is justified to the lab instructor based on medical evidence only. Medical documentation will be provided with a maximum delay of one week after the missed event.

The students without minimum 6 attendances at laboratory activities CANNOT participate to the written paper (during weeks 13-14 and during the resit session) and CANNOT get a passing grade.

Lab papers grading and submission

Each lab paper is evaluated with a grade from 1 to 10 in the following way:

A copied lab paper means cheating and will be graded with 0 (zero).

If a lab paper is submitted with another lab subgroup inside the same two weeks frame, the lab grade is multiplied by 0.8; if the submission is delayed one lab, the lab grade is multiplied by 0.6; if the delay is larger than one lab, the final grade is 0 (zero).

At most two lab themes may be delivered during one lab class. As well, the Prolog labs may be delivered until no later than ween 7/8.

The lab grade will be determined as the average of the grades of all the lab works. If a lab doc is not delivered, its grade is 0.

Resit session

In the resit session the same grading algorithm will apply.

© Prof.dr. Horia F. Pop