A two-language restaurant management system, built for a Concepts of Programming Languages (CPL) course. The same domain — reservations, ingredients, and supply costs — is modeled twice: once declaratively in Prolog and once functionally in Haskell, to compare how each paradigm handles the same problem.
A restaurant takes reservations from groups of people, seats them at tables, cooks their orders from recipes, and needs to track when ingredients must be delivered and how much everything costs. Both halves of this project solve pieces of that puzzle:
| Prolog | Haskell | |
|---|---|---|
| Models | Groups, staff, tables, recipes, orders | Ingredients, recipes, shopping lists, deliveries, expenses |
| Solves | Who gets seated where, and when | When ingredients must arrive, and what they cost |
| Style | Constraint logic / backtracking search | Recursive, type-driven data transformation |
sample_KB.pl / Tests/public_kb.pl define the world as facts:
group(Name, Count, Timing)— a group of people wanting a table, with a preferred morning/evening slotstaff(Day, Count)— how many staff are on duty on a given day (caps how many reservations a slot can handle)tables(Tables)— the restaurant's tables and their seating capacityrecipe(Dish, Ingredients)andorder(Group, Dishes)— what each group ordered, and what each dish needs
utilities.pl builds on top of that knowledge base:
schedule_all_reservations/2— either generates a valid seating schedule from scratch (biggest groups seated first, so smaller groups still have somewhere to fit), or validates an existing schedule against the staffing and table-capacity rules, depending on whetherScheduleis boundcheck_staff/3— confirms a given day/time doesn't have more reservations than staff can supportneeded_ingredients/2— works out the full list of ingredients required per day, given a finalized schedulewrite_reservations_to_csv/2andwrite_ingredients_to_csv/2— export a schedule or shopping list to CSV
Sample CSV output (Prolog/Sample outputs (for CSV predicate)/) shows what write_reservations_to_csv and write_ingredients_to_csv produce for both the sample and public knowledge bases.
Starter_File.hs models the supply chain with a small set of types:
Ingredient— either aSimpleIngredientor aRecipemade of other ingredients (recursive, so recipes can nest)Expense— either a singleItem, or aCategorycontaining other expenses (also recursive, for grouping costs)Delivery— a date paired with the supplies needed on that date
On top of these types:
calculateDeliveryDates— given an order date and a list of ingredients, flattens nested recipes into simple ingredients and works out how many days in advance each one needs to be delivered (looking up lead time and price fromingredient_info)summarizeAllDeliveries— takes a list of order dates, pulls each day's shopping list, calculates every ingredient's delivery date, then merges and sorts everything into a clean per-date delivery schedulegetDeliveryExpenses/calculateTotalExpenses— turns a list of deliveries into anExpensetree and sums it upmostPopularDish— frequency-counts a list of dish names and returns the one(s) ordered most
Prolog (tested with SWI-Prolog):
swipl
?- consult('Prolog/utilities.pl').
?- schedule_all_reservations([day(15,2), day(16,2), day(17,2)], Schedule).Haskell (tested with GHC/GHCi):
ghci Haskell/Starter_File.hs
ghci> summarizeAllDeliveries [(15,Feb,2026), (17,Feb,2026)]Test cases for both halves are provided as spreadsheets (Prolog/Tests/tests.xlsx, Haskell/Public_Test_Cases.xlsx) alongside a public knowledge base (Prolog/Tests/public_kb.pl) to test against.
Built by:
- Abdo-N
- Abdelrahman Sameh
- Mariam
- Sara Elesseily