Home /Modules/boolean/boolean-demo.sleela

boolean-demo.sleela

lib/boolean/boolean-demo.sleela · 111 line(s) · sleela

<< lib/boolean/boolean-demo.sleela
   SLeeLa Standard Library Definition.
   Definition: Runnable demonstrator for the boolean package — a Return Value
     may plainly imply TRUE/FALSE, or it may imply a further relation. This
     program reconstructs, inline, the HEAD (result) + CARRY (caveat) reading of
     Boolean/Binary syllable words at depth 8, 16, and 32. >>
#sleela 2.5
material;
< SLeeLa boolean package demonstrator. >
< A word is BOOLEAN.<syllable>.<syllable>...  The HEAD syllable is the RESULT; >
< every trailing syllable is CARRY (a caveat structure) that must be observed >
< or agree. BOOLEAN.TRUE.FALSE says: result is TRUE, but FALSE is carried as a >
< caveat — a concern of carry that must be observed. The split per-class files >
< (BooleanTrue, BooleanFalse, boolean/8, boolean/16, boolean/32) are the full >
< vocabulary; this file is the one-shot runnable walkthrough. >
class BooleanDemo {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 10827;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-10";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }

  String intToStr(int v) { return "" + v; }

  < Render a word from its summary: head bit (1=TRUE,0=FALSE) and the counts of >
  < carried TRUE / carried FALSE syllables, exactly as BooleanWord16/32 model it. >
  String headSyllable(int headBit) { return headBit == 1 ? "TRUE" : "FALSE"; }

  boolean caveat(int carryFalse) { return carryFalse > 0; }

  < The headline reading: result + whether a carry caveat must be observed. >
  String reading(String name, int depth, int headBit, int carryTrue, int carryFalse) {
    String head = name + " (depth " + intToStr(depth) + "): result "
                + headSyllable(headBit);
    if (caveat(carryFalse)) {
      return head + ", CAVEAT — " + intToStr(carryFalse)
           + " FALSE carried (must be observed); " + intToStr(carryTrue)
           + " TRUE carried.";
    }
    return head + ", CLEAN — carry agrees (" + intToStr(carryTrue)
         + " TRUE carried).";
  }

  void banner(String t) {
    print("================================================================");
    print("  " + t);
    print("================================================================");
  }

  void main() {
    banner("SLeeLa BOOLEAN syllable words: result + carry (caveat)");

    < The two primitive syllables. >
    print(reading("BOOLEAN.TRUE",  1, 1, 0, 0));
    print(reading("BOOLEAN.FALSE", 1, 0, 0, 0));

    < The canonical two-syllable caveat: TRUE result, one FALSE carried. >
    < BOOLEAN.TRUE.FALSE -> result TRUE, caveat on the carry. >
    print(reading("BOOLEAN.TRUE.FALSE", 2, 1, 0, 1));

    < Depth 8 (enumerated as Bool_TFFFFFFF): TRUE result, 7 FALSE carried. >
    print(reading("BOOLEAN.TRUE.FALSE.FALSE.FALSE.FALSE.FALSE.FALSE.FALSE",
                  8, 1, 0, 7));

    < Depth 16 (BooleanWord16): TRUE result, 15 FALSE carried -> full caveat. >
    print(reading("boolean/16 TRUE+carry-FALSE", 16, 1, 0, 15));

    < Depth 32 (BooleanWord32): all-TRUE -> clean, no caveat. >
    print(reading("boolean/32 all-TRUE", 32, 1, 31, 0));

    banner("Done");
    print("TRUE is the result; a carried FALSE is a caveat that must be observed.");
  }
}