This project implements a relational, logic-based factory management system in Python, inspired by the paper
Rel: A Programming Language for Relational Data.
Because Rel currently does not provide a freely available runtime environment, this project recreates core Rel concepts using the Python library PyDatalog. The goal is not to reimplement Rel itself, but to apply the same relational and declarative thinking principles in a practical, executable environment.
The system models machines, employees, maintenance orders, quality control, and release workflows entirely as relations and derives system state through logical rules, not imperative code.
- Everything is a relation (no classes, no objects)
- Declarative logic instead of procedural control flow
- Derived relations instead of mutable state
- Implicit joins via shared variables
- Business semantics expressed as logic rules
| Component | Description |
|---|---|
| Language | Python 3.x |
| Library | PyDatalog |
| Paradigm | Declarative / Logic Programming |
| Inspiration | RelationalAI – Rel |
| Domain | Factory / Manufacturing Management |
Base relations:
- machine(MachineID, Type)
- employee(EmployeeID, Name, Role)
- maintenance_order(OrderID, MachineID, EmployeeID, Status)
- qc(QCID, MachineID, InspectorID, Result)
- release(ReleaseID, WorkOrderID, QCID, Status)
Derived relations are computed using logical rules.
Open maintenance orders:
PendingOrders(X, Y, Z) <= maintenance_order(X, Y, Z, 'pending')
Machines with failed QC:
MachinesFailedQC(M) <= qc(QCID, M, EmpID, 'failed')
Derived maintenance requirements:
NewMaintenance(QCID, M, 'E2', 'pending') <= qc(QCID, M, EmpID, 'failed')
Nigel