Logic Programming · Prolog · Facts · Rules · Queries · Backtracking · Pattern Matching
| Paradigm | Focus | Example |
|---|---|---|
| Imperative | HOW (step by step) | Python loops |
| OOP | Objects and state | Java classes |
| Functional | Pure transformations | Haskell |
| Declarative / Logic | WHAT is true | Prolog |
teaches(smith, computing). teaches(jones, maths). teaches(smith, physics).
likes(ann, computing). likes(ann, maths). likes(bob, physics).
willTake(S, T) :- likes(S, Sub), teaches(T, Sub).?- willTake(ann, T). showing all solutions and how backtracking is used. [4]