Home /Modules/rrs/SLRrs.sleela

SLRrs.sleela

lib/rrs/SLRrs.sleela · 213 line(s) · sleela

<< lib/rrs/SLRrs.sleela
   SLeeLa Standard Library Definition.
   Definition: SLeeLa mirror of RRS -- Reasonable Responsibility Solidity
   (sllmrrs_ in artificial-intelligence/rrs/rrs.h). Three congruent models are
   chained feed-forward over a ternary signal: 1 = AFFIRM, 0 = ELIMINATE,
   2 = POWER_ADD. Stage 1 is conjunctive (strict AND), stage 2 is the
   reasonable-responsibility prelude, stage 3 is the solidity culmination.
   RRS subtracts faith: any faith or trial premise is forced to ELIMINATE.
   It ships no weights; the ternary net is a tiny conjunctive accumulator. >>
#sleela 3.0
material;
class SLRrs {
  < ---- 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 = 8221;
  String metaAuthor = "Max Rupplin";
  String metaDate = "2026-11-06";
  String metaCopyright = "MEARVK LLC";
  String metaTrademark = "none";
  String metaCorporation = "MEARVK LLC";
  String metaOrigin = "International";
  String metaBirthDate = "2026-11-06";
  int metaScienceRating = 7;
  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; }

  << sllmrrs_signal: values chosen so AFFIRM/POWER_ADD contribute power and
     ELIMINATE is a hard zero that breaks the stage conjunction. >>
  static final int SIGNAL_ELIMINATE = 0;
  static final int SIGNAL_AFFIRM = 1;
  static final int SIGNAL_POWER_ADD = 2;

  < sllmrrs_stage. >
  static final int STAGE_CONJUNCTIVE = 0;
  static final int STAGE_RESPONSIBILITY = 1;
  static final int STAGE_SOLIDITY = 2;
  static final int STAGE_COUNT = 3;

  < sllmrrs_potestas: graded warranted capacity-to-continue. >
  static final int POTESTAS_NONE = 0;
  static final int POTESTAS_PROVISIONAL = 1;
  static final int POTESTAS_WARRANTED = 2;

  < sllmrrs_status. >
  static final int STATUS_OK = 0;
  static final int STATUS_INVALID_ARGUMENT = 1;
  static final int STATUS_FAITH_PREMISE = 2;
  static final int STATUS_NOT_SOLID = 3;
  static final int STATUS_RESPONSIBILITY_UNMET = 4;
  static final int STATUS_CAPACITY = 5;

  < Per-stage accumulator (sllmrrs_accumulator). >
  int accPower;
  int accAffirmed;
  int accEliminated;
  boolean accConjunction;

  < Result (sllmrrs_result) across the three stages. >
  int totalPower;
  int potestas;
  boolean solid;
  int faithEliminated;
  < Per-stage power snapshot kept parallel to STAGE_COUNT. >
  int stage0Power;
  int stage1Affirmed;

  << The effective signal a premise contributes at a given stage, after faith
     subtraction and the responsibility prelude. Mirrors the fold kernel rule. >>
  int effectiveSignal(int stage, int signal, boolean faithOrTrial,
                      boolean responsibilityMet) {
    if (faithOrTrial) { return SIGNAL_ELIMINATE; }
    if (stage == STAGE_RESPONSIBILITY && !responsibilityMet) {
      return SIGNAL_ELIMINATE;
    }
    return signal;
  }

  << sllmrrs_fold_stage: the single congruent kernel reused by all three stages.
     Resets the accumulator, then folds each premise. ELIMINATE breaks the strict
     AND (conjunction = false) and counts an elimination; AFFIRM adds +1 power,
     POWER_ADD adds +2, both count an affirmation. Parallel arrays describe the
     premises so this stays portable. >>
  void foldStage(int stage, int[] signals, boolean[] faith,
                 boolean[] respMet, int n) {
    accPower = 0;
    accAffirmed = 0;
    accEliminated = 0;
    accConjunction = true;
    int i = 0;
    while (i < n) {
      int eff = effectiveSignal(stage, signals[i], faith[i], respMet[i]);
      if (faith[i]) { faithEliminated = faithEliminated + 1; }
      if (eff == SIGNAL_ELIMINATE) {
        accEliminated = accEliminated + 1;
        accConjunction = false;
      } else {
        if (eff == SIGNAL_AFFIRM) { accPower = accPower + 1; }
        if (eff == SIGNAL_POWER_ADD) { accPower = accPower + 2; }
        accAffirmed = accAffirmed + 1;
      }
      i = i + 1;
    }
  }

  << sllmrrs_feed_forward: run stage1 -> stage2 -> stage3, accumulating power and
     counting faith eliminations. Fails closed: a broken conjunction stops the
     forward pass and yields an honest NONE. An empty stage 3 inherits the prior
     conjunction and the accumulated power, so it does not break solidity. >>
  int feedForward(int[] s1, boolean[] f1, boolean[] r1, int n1,
                  int[] s2, boolean[] f2, boolean[] r2, int n2,
                  int[] s3, boolean[] f3, boolean[] r3, int n3) {
    totalPower = 0;
    potestas = POTESTAS_NONE;
    solid = false;
    faithEliminated = 0;

    foldStage(STAGE_CONJUNCTIVE, s1, f1, r1, n1);
    stage0Power = accPower;
    totalPower = totalPower + accPower;
    if (!accConjunction) { return STATUS_OK; }

    foldStage(STAGE_RESPONSIBILITY, s2, f2, r2, n2);
    stage1Affirmed = accAffirmed;
    totalPower = totalPower + accPower;
    if (!accConjunction) { return STATUS_OK; }

    boolean carriedConjunction = true;
    if (n3 > 0) {
      foldStage(STAGE_SOLIDITY, s3, f3, r3, n3);
      totalPower = totalPower + accPower;
      carriedConjunction = accConjunction;
    }
    if (!carriedConjunction) { return STATUS_OK; }

    << Culmination: WARRANTED needs solid + responsibility affirmed + power>=4;
       PROVISIONAL needs solid + power>=2; else NONE. >>
    solid = true;
    if (stage1Affirmed > 0 && totalPower >= 4) {
      potestas = POTESTAS_WARRANTED;
    } else {
      if (totalPower >= 2) {
        potestas = POTESTAS_PROVISIONAL;
      } else {
        potestas = POTESTAS_NONE;
      }
    }
    return STATUS_OK;
  }

  int getTotalPower() { return totalPower; }
  int getPotestas() { return potestas; }
  boolean isSolid() { return solid; }
  int getFaithEliminated() { return faithEliminated; }

  String signalName(int signal) {
    if (signal == SIGNAL_ELIMINATE) { return "eliminate"; }
    if (signal == SIGNAL_AFFIRM) { return "affirm"; }
    if (signal == SIGNAL_POWER_ADD) { return "power-add"; }
    return "unknown";
  }

  String stageName(int stage) {
    if (stage == STAGE_CONJUNCTIVE) { return "conjunctive"; }
    if (stage == STAGE_RESPONSIBILITY) { return "responsibility"; }
    if (stage == STAGE_SOLIDITY) { return "solidity"; }
    return "unknown";
  }

  String potestasName(int p) {
    if (p == POTESTAS_NONE) { return "none"; }
    if (p == POTESTAS_PROVISIONAL) { return "provisional"; }
    if (p == POTESTAS_WARRANTED) { return "warranted"; }
    return "unknown";
  }

  String statusString(int status) {
    if (status == STATUS_OK) { return "ok"; }
    if (status == STATUS_INVALID_ARGUMENT) { return "invalid argument"; }
    if (status == STATUS_FAITH_PREMISE) { return "faith premise"; }
    if (status == STATUS_NOT_SOLID) { return "not solid"; }
    if (status == STATUS_RESPONSIBILITY_UNMET) { return "responsibility unmet"; }
    if (status == STATUS_CAPACITY) { return "capacity"; }
    return "unknown";
  }

  boolean available() { return STAGE_COUNT == 3; }
}