Skip to content

LewenLin/Implementing-Simple-Logic-Programming-in-Simple-Lojban

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

README

Overview

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 i followed by whitespace.
  • Evaluates predefined short words and predicates:
    • cmavo (short words): lo, se
    • predicates: fatci, sumji, vujni, dunli, steni, steko, cmavo
  • 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.


How to run

python main.py
# Input text, then Ctrl+D (Linux/macOS) or Ctrl+Z Enter (Windows)

Example

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.

Implementation

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

Predicates Supported

Word Meaning
fatci existence
sumji plus
vujni minus
dunli equals
steni empty list
steko cons cell
cmavo user predicate declaration

Limitations

  • Deep recursion not supported
  • Only integer math
  • Limited rule support

Submitted for assignment requirements including scanning, parsing, and predefined logical operations.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages