Tushar Lachman
Melbourne · RMIT ’27
LOGIC PROGRAMMINGRMIT · individual

Flight Routing & Trip Planner in Prolog

Finding the cheapest trip without being allowed to collect the alternatives and sort them.

Intelligent Decision Making · 2026
WHY IT EXISTS

A flight network reasoner in pure Prolog: a route database, path validity and non-redundancy, the cost and duration of a trip, then trips bounded by a budget and finally the best trip under a chosen criterion — written under language restrictions that remove almost every shortcut.

How it’s put together

L00
SWI-Prolog
L01
Declarative programming
L02
Recursion
L03
Negation as failure

Built with

SWI-PrologDeclarative programmingRecursionNegation as failure
PERIOD
Intelligent Decision Making · 2026
ROLE
Solo — implementation

The hard parts

06 NOTES
1

The restrictions are the assignment. No `findall`, `setof`, `aggregate`, `forall`, `assert`, `retract` or `fail` — which rules out the obvious approach of gathering every candidate route into a list and picking the minimum. Everything has to be expressed as relations and recursion.

2

So superlatives become negations. “The cheapest flight out of Toronto” is written as a flight for which no cheaper flight exists; “the most expensive airport tax” the same way. Negation as failure replaces the aggregate, and it only works because the search space is finite and ground — which is the point the exercise is making.

3

Trip pricing carries state through the recursion rather than post-processing it: an airport tax applies on the first leg and again only when the airline changes, so the accumulator has to remember which carrier the previous leg used. Staying on one airline through a connection is genuinely cheaper, and the predicate has to model that.

4

Bounded trips prune during the search instead of after it — the running cost is checked against the limit at every leg, so a path that has already blown the budget is abandoned rather than completed and then discarded.

5

Best trip is built from bounded trip by iterative tightening: find any trip, use its cost as a ceiling, ask for something strictly cheaper, repeat until nothing cheaper exists, then re-solve at that bound. It is branch-and-bound written in a language that will not let you hold the candidates in a list.

6

The route database stores each connection once and a bridging rule makes flights bidirectional, so the network cannot drift out of sync with itself — and a visited-city list threaded through the recursion is what stops the whole thing looping forever on a cyclic graph.

Want the parts that aren’t on this page — the architecture arguments, the things that broke, a live walkthrough?

NEXTThe GOAT Debate — YouTube Comment Network Analysis