Functional and Logic Programming
Keywords |
Classification |
Keyword |
OFICIAL |
Informatics Engineering and Computing |
Instance: 2023/2024 - 1S

Cycles of Study/Courses
Acronym |
No. of Students |
Study Plan |
Curricular Years |
Credits UCN |
Credits ECTS |
Contact hours |
Total Time |
L.EIC |
343 |
Syllabus |
3 |
- |
6 |
52 |
162 |
Teaching language
Portuguese
Obs.: Suitable for english-speaking students
Objectives
The Functional Programming and Logic Programming paradigms present declarative approaches to programming, based on formal reasoning processes, which are more appropriate to the resolution of some types of problems.
Objectives: become familiar with the Functional Programming and Logic Programming paradigms. Develop skills in abstract reasoning and declarative problem representation.
Learning outcomes and competences
At the end of the course, students should be able to:
- Use pre-defined and algebraic types in Haskell to represent values of a specific domain
- Define generic transformations on inductive data structures (for example, trees) as polymorphic functions in Haskell
- Decompose programming problems into pure Haskell functions operating over structured data types
- Prove equivalence of Haskell functions using definitions by equations and induction
- Represent facts and relations as Prolog programs
- Understand the execution model of Prolog programs
- Model search problems as logic programs and queries in Prolog.
Working method
Presencial
Program
- Logic Programming (6-7 weeks)
- Propositional and predicate logic. Horn clauses. Facts and rules. Herbrand terms. Unification.
- The Prolog language. Execution model. SLD resolution. Negation by failure.
- Databases of facts and relations. Programming with recursive structures.
- Arithmetic. Extra-logic and control predicates.
- Examples of logic programs: search, games, symbolic manipulation.
- Functional Programming (6 weeks)
- Expressions, reductions, and values. Built-in simple and structured types. Definitions using equations.
- Parametric and bounded polymorphism. Fundamental type classes.
- Lambda expressions. Currying and partial application. Higher-order functions of the standard prelude.
- Defining algebraic data types; pattern matching and recursive definitions.
- Programming examples: search trees; syntax trees; text layout; visualization and games.
- Programming with I/O.
- Equivalence proofs using equational theory and induction.
Mandatory literature
Simon Thompson;
Haskell the craft of functional programming. ISBN: 0- 201-34275-8
Graham Hutton;
Programming in Haskell, Cambridge University Press, 2016. ISBN: 978-1316626221
Leon Sterling;
The Art of Prolog. ISBN: 0-262-69163-9
Complementary Bibliography
Bryan O'Sullivan, Don Stewart, and John Goerzen; Real World Haskell, O'Reilly Media, 2008. ISBN: 9780596514983
Richard Bird;
Introduction to Functional Programming using Haskell, Pearson, 1998. ISBN: 978-0-13-484346-9
Ivan Bratko;
Prolog programming for artificial intelligence. ISBN: 0-201-40375-7
Teaching methods and learning activities
Theoretical lectures are used to explain fundamentals, accompanied by the presentation and discussion of illustrative examples. Theoretical-practical (TP) classes allow for the systematization of knowledge through the resolution of programming exercises and monitoring of progress in student’s assignments.
Software
GHC
SICStus Prolog
Evaluation Type
Distributed evaluation without final exam
Assessment Components
Designation |
Weight (%) |
Teste |
50,00 |
Trabalho prático ou de projeto |
50,00 |
Total: |
100,00 |
Amount of time allocated to each course unit
Designation |
Time (hours) |
Elaboração de projeto |
60,00 |
Estudo autónomo |
50,00 |
Frequência das aulas |
52,00 |
Total: |
162,00 |
Eligibility for exams
A student obtains frequency in this course if he concludes both practical assignments (TP1 and TP2) with a minimum grade of 35% in each one.
Calculation formula of final grade
(CF = Final Classification, P = Practical Component, T = Theoretical Component, ER = Appeal Exam)
(TP1, TP2 = Practical Assignment 1 and 2, respectively)
(MT1, MT2 = Mini-Test 1 and 2, respectively)
P = 50% * TP1 + 50% * TP2
T = 50% * MT1 + 50% * MT2
In Regular Exam Season:
CF = 50% * P + 50% * T
In Appeal Exam Season:
CF = 50% * P + 50% * ER
Notes:
- The minimum grade in each component (TP1, MT1, TP2, and MT2) is 35%
- In the appeal exam season, the minimum grade is 35% for each part of the exam
- The maximum grade between components TP1 and MT1 is, at most, the minimum grade of these two components plus 6 marks
- The maximum grade between components TP2 and MT2 is, at most, the minimum grade of these two components plus 6 marks
- In the appeal exam season, the same rules apply, replacing MT1 and MT2 with the corresponding parts of the exam
Examinations or Special Assignments
There are no special tests or assignments.
Special assessment (TE, DA, ...)
Evaluation rules apply to all students, regardless of their status or condition. Students who, by their status or condition are not obliged to attend the practical classes must contact their teachers for assignment consultation and evaluation sessions.
Classification improvement
The practical component can only be improved in subsequent editions of the course.
The theoretical component can be improved in an exam during the appeal exam season.