Skip to content

Declarative logic, state-space search algorithms, and knowledge-based systems implemented in Prolog.

License

Notifications You must be signed in to change notification settings

lukamaga/logic-programming-prolog

Repository files navigation

Logic Programming in Prolog

This repository contains laboratory assignments for the "Loginis Programavimas" (Logic Programming) university course. The projects focus on declarative problem-solving, recursive logic, and state-space exploration using Prolog.

Project Overviews

Lab 1: Family Relations Database

  • Implementation of a knowledge base using facts and rules.
  • Logic for determining complex family ties (siblings, descendants).
  • Implementation of hobby-based longevity filters and person classification.

Lab 2: Pathfinding and Peano Arithmetic

  • Graph traversal logic to determine paths between cities with step counting.
  • Implementation of subtraction using Peano axioms (s(X) notation) to demonstrate fundamental arithmetic logic.

Lab 3: State-Space Search (Blocks World)

  • Solving a block manipulation problem with height constraints.
  • Implementation of a recursive solver that explores possible moves and avoids infinite loops using a visited-states list.
  • Features automatic move formatting for solution output.

Lab 4: Advanced List Processing

  • High-level list manipulation algorithms:
    • Splitting lists by numeric polarity (positive/negative).
    • Extracting the last K elements without built-in primitives.
    • Implementation of Insertion Sort.
    • Infinite-precision addition: Summing large numbers represented as digit lists.

Concepts Demonstrated

  • Knowledge Base reasoning (facts vs rules).
  • Depth-first search (DFS) in state space.
  • Recursive data structures and pattern matching.
  • Pruning search trees with the cut operator (!).

Usage

These modules are designed for the SWI-Prolog interpreter.

  1. Install SWI-Prolog.
  2. Load a specific module: swipl -s lab1-family-relations/family_logic.pl
  3. Query the predicates (e.g., ?- sprendimas(Pradinis, Galinis, N, K, Spr).).

License

MIT License

About

Declarative logic, state-space search algorithms, and knowledge-based systems implemented in Prolog.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages