This project implements a small predicate‑calculus interpreter using a restricted Lojban‑like syntax, per your assignment. It:
- Scans four token kinds (short words / cmavo, predicate words / gismu, integer numbers, names
.like.this.) and validates whitespace rules. - Parses a sequence of statements, each beginning with
ifollowed by whitespace. - Evaluates predefined short words and predicates:
- cmavo (short words):
lo,se - predicates:
fatci,sumji,vujni,dunli,steni,steko,cmavo
- cmavo (short words):
- Builds a database of facts and user‑declared predicates (
cmavo). - Outputs bindings for variables appearing in the final statement.
Design note. Names like
.Brook.act as logical symbols. In arithmetic contexts, a name can be a numeric variable that receives a value. In predicate contexts, names serve as symbols, and variables in the final statement are reported.
python main.py
# Input text, then Ctrl+D (Linux/macOS) or Ctrl+Z Enter (Windows)Input:
i lo .Brook. fatci i lo .coffee. fatci
i lo pinxe cmavo lo steko lo .Brook. lo steko lo .coffee. lo steni
i lo .X. pinxe lo .coffee.
Output:
.Brook.
See full code in main.py. Includes:
- Tokenizer (Scanner)
- Parser
- Evaluator (predicate logic engine)
Supports:
| Type | Rules |
|---|---|
| Short words | CV (e.g., lo, se) |
| Predicate words | 5‑letter CVCCV / CCVCV |
| Numbers | integers without leading zero |
| Names | .name. format |
| Word | Meaning |
|---|---|
| fatci | existence |
| sumji | plus |
| vujni | minus |
| dunli | equals |
| steni | empty list |
| steko | cons cell |
| cmavo | user predicate declaration |
- Deep recursion not supported
- Only integer math
- Limited rule support
Submitted for assignment requirements including scanning, parsing, and predefined logical operations.