Functional & Logic Programming — Free Notes & Tutorial
Free Functional and Logic Programming notes for BTech CS — Haskell & GHCi, lambda calculus, graph reduction, type classes, algebraic types, Prolog, unification, logic grammars and search techniques, with all lab experiments solved. 100% free. Free Functional & Logic Programming course on SikshaSarovar.
This Functional & Logic Programming course is part of Siksha Sarovar and is 100% free for students in India — no sign-up required to read. It contains 17 structured lessons with examples, and pairs with our free online compiler and AI tutor.
What you will learn
- Haskell
- GHCi
- Lambda calculus
- Beta reduction
- Combinators
- Graph reduction
- Pattern matching
- Recursion
- Type classes
- Algebraic data types
- Prolog
- Unification
- Backtracking
- Cut
- Findall
- DCG grammars
- DFS/BFS search
Course content (17 lessons)
- Course Introduction: Two New Ways of Thinking About Programs — Welcome to Functional & Logic Programming Until now, almost every program you have written has been imperative — a sequence of commands that change variables step by step. This…
- Unit 1: The Functional Paradigm & Getting Started with Haskell — 1.1 What is functional programming? In a functional language, a program is built entirely from expressions and function definitions . Computation means evaluating an expression to…
- Unit 1: Basic Types, Definitions & Designing Programs — 2.1 The basic types of Haskell Type Values Example literals :--- :--- :--- Bool truth values True , False Int fixed-size integers (at least 30 bits) 42 , -7 Integer…
- Unit 1: Tuples, Lists, Input/Output & Control Structures — 3.1 Tuples — fixed-size, mixed-type packages A tuple groups a fixed number of values that may have different types : For pairs, the standard projection functions are fst and snd :…
- Unit 1: The Lambda Calculus — Syntax, Conversions & Church–Rosser — 4.1 Why the lambda calculus? The lambda calculus (Alonzo Church, 1930s) is the mathematical core of every functional language. It has exactly three kinds of expression, yet it can…
- Unit 1: How Haskell Runs — Graph Reduction & the Three Instruction Machine — 5.1 From rewriting to running The lambda calculus says programs run by rewriting expressions . But real hardware runs instructions on memory. Graph reduction is the bridge:…
- Unit 2: Programming with Lists & Building Vocabulary — 1.1 Building vocabulary — the standard list toolkit Fluent Haskell programmers compose programs from a small, powerful vocabulary of list functions. Learn these with their types —…
- Unit 2: Pattern Matching & Recursion over Lists — 2.1 Pattern matching — branching on the shape of data A pattern appears on the left of a defining equation and does two jobs at once: it tests the shape of the argument and names…
- Unit 2: Overloading, Type Classes & Type Checking — 3.1 The problem: one symbol, many types == should work on Int , Char , Bool , lists... but not on functions (equality of functions is undecidable). + should work on Int and Double…
- Unit 2: Algebraic Data Types — 4.1 What "algebraic" means An algebraic data type (ADT) is built from two algebra-like operations: Sum ("or"): a value is one of several alternatives → multiple constructors.…
- Unit 3: Introduction to Logic Programming & Basic Constructs — 1.1 The logic programming idea A logic program does not describe how to compute. It states facts and rules about a world, and computation happens when you ask a query — the system…
- Unit 3: Database Programming & Recursive Programming — 2.1 Logic programs as databases A collection of facts is a relational database — predicates are tables, facts are rows: Rules then play the role of SQL queries and views:…
- Unit 3: The Computation Model, Theory & Applications of Logic Programs — 3.1 The abstract interpreter (SLD resolution) A logic program runs by SLD resolution (Selective Linear Definite-clause resolution). State = the current list of goals (the…
- Unit 4: Programming in Prolog — Syntax, Arithmetic & Control — 1.1 From theory to tool Unit 3 gave the model; this unit is hands-on Prolog (PROgramming in LOGique, Colmerauer & Roussel, 1972). Install SWI-Prolog (free, all platforms). Save…
- Unit 4: Structure Inspection & Second-Order Programming — 2.1 Structure inspection — programs that examine terms Prolog terms are data structures you can take apart at runtime. The inspection built-ins: Type tests: Test Succeeds when…
- Unit 4: Logic Grammars & Search Techniques — 3.1 Logic grammars — parsing by deduction Prolog was born for language processing. A context-free grammar can be written almost verbatim as a DCG (Definite Clause Grammar) using…
- Lab Practicals: Haskell & Prolog Experiments — How to use this lesson The lab list for this subject has two halves — Haskell (experiments 1–6) and Prolog (experiments 7–10). Each practical below names the theory lesson it…
Course Introduction: Two New Ways of Thinking About Programs
Welcome to Functional & Logic Programming
Until now, almost every program you have written has been imperative — a sequence of commands that change variables step by step. This course introduces two radically different paradigms:
- Functional programming (Haskell): a program is a collection of mathematical functions. There are no assignment statements, no loops, and no changing state — only expressions that are evaluated.
- Logic programming (Prolog): a program is a collection of facts and rules. You don't tell the computer how to compute an answer — you describe what is true, ask a question, and the system searches for the answer itself.
The paradigm map
How this course is organised
| Syllabus block | Lessons that cover it |
|---|---|
| Intro to FP, Haskell & GHCi, basic types, designing programs | Unit 1 → "The Functional Paradigm" and "Basic Types & Definitions" |
| Data types, tuples, lists, input/output, control structures | Unit 1 → "Tuples, Lists, I/O & Control Structures" |
| Lambda calculus: syntax, conversions, normal forms, Church–Rosser, combinators | Unit 1 → "The Lambda Calculus" |
| Graph reduction, Three Instruction Machine | Unit 1 → "How Haskell Runs: Graph Reduction & the TIM" |
| Programming with lists, building vocabulary, functions over lists | Unit 2 → "Programming with Lists" |
| Pattern matching and recursion | Unit 2 → "Pattern Matching & Recursion" |
| Overloading, type classes, type checking | Unit 2 → "Overloading, Type Classes & Type Checking" |
| Algebraic types | Unit 2 → "Algebraic Data Types" |
| Intro to logic programming, basic constructs | Unit 3 → "Introduction to Logic Programming" |
| Database & recursive programming | Unit 3 → "Database & Recursive Programming" |
| Computation model, theory & applications of logic programs | Unit 3 → "The Computation Model of Logic Programs" |
| Prolog: introduction, programming, arithmetic, structure inspection | Unit 4 → "Programming in Prolog" and "Structure Inspection" |
| Second-order programming, logic grammars, search techniques | Unit 4 → "Second-Order Programming" and "Logic Grammars & Search" |
| Lab experiments (Haskell + Prolog) | "Lab Practicals" lesson at the end |
Why learn paradigms you may never "use at work"?
- They change how you think. Recursion, immutability and pattern matching — once they click in Haskell — make you a better Java/Python programmer too.
- Mainstream languages are absorbing them. Lambdas in Java, list comprehensions in Python,
Option/Resulttypes in Rust, LINQ in C# —
Continue reading: Course Introduction: Two New Ways of Thinking About Programs →
Frequently asked questions
Is the Functional & Logic Programming course really free?
Yes. The entire Functional & Logic Programming course on Siksha Sarovar is free to read with no account required. You can optionally sign in with Google to save your progress.
Do I get a certificate for Functional & Logic Programming?
Yes — finish the lessons and pass the quiz to earn a free, verifiable certificate you can share on LinkedIn or with recruiters.
Can I run code while learning?
Yes. The built-in online compiler runs C, C++, Python, Java, PHP, JavaScript, C# and SQL directly in your browser — no installation needed.