Home /Modules/advantage/SLTrustMetric.sleela

SLTrustMetric.sleela

lib/advantage/physics/SLTrustMetric.sleela · 116 line(s) · sleela

<< lib/advantage/physics/SLTrustMetric.sleela
   SLeeLa Standard Library Definition.
   Definition: The trust field as a metric tensor g_mu_nu over a 2D economic
   manifold (operational distance x volume). >>
#sleela 3.0
material;
artifact;
pure;
gasoline;
< STRUCTURAL-ECONOMICS ANALOGY (not literal physics): trust is modelled AS a >
< metric tensor g_mu_nu that sets distance and curvature on an economic >
< manifold. High trust -> near-Euclidean (flat, cheap to cross); zero trust -> >
< warped hyperbolic (friction/distance inflate). >
<  >
< The metric is a symmetric 2x2 stored row-major in a flat double[4] (house >
< style, cf. lib/math/SLMatrix). We use a conformal family parameterized by a >
< trust level tau in (0,1]: >
<   g = f(tau) * I,   f(tau) = 1/tau. >
< So f -> 1 as tau -> 1 (Euclidean) and f -> +inf as tau -> 0 (distances >
< blow up). line-element length^2 of a displacement (dx,dy) is >
<   ds^2 = f(tau) * (dx^2 + dy^2). >
class SLTrustMetric {
  < ---- 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 = 10530;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-11-08";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-11-08";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 7;
  << metaNationalSchedule: the metric-tensor / geodesic machinery is Riemannian
     geometry and general relativity (Einstein 1915); an academic framework,
     not a statute, and here applied by economic ANALOGY. >>
  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; }

  < Conformal factor f(tau) = 1/tau. Clamps tiny tau to avoid overflow. >
  double conformalFactor(double tau) {
    double t = tau;
    if (t < 0.000001) { t = 0.000001; }
    return 1.0 / t;
  }

  < Build the 2x2 metric at a given trust level into a flat double[4]. >
  double[] metricAt(double tau) {
    double f = conformalFactor(tau);
    double[] g = new double[4];
    < row-major 2x2: g_xx, g_xy, g_yx, g_yy >
    g[0] = f;
    g[1] = 0.0;
    g[2] = 0.0;
    g[3] = f;
    return g;
  }

  < Squared line element of displacement (dx,dy) under trust tau: >
  < ds^2 = g_xx dx^2 + 2 g_xy dx dy + g_yy dy^2. >
  double lineElementSq(double tau, double dx, double dy) {
    double[] g = metricAt(tau);
    return g[0] * dx * dx + 2.0 * g[1] * dx * dy + g[3] * dy * dy;
  }

  < Effective operational distance (cost to cross) for a straight displacement >
  < (dx,dy) under trust tau: sqrt(ds^2) = sqrt(f) * sqrt(dx^2+dy^2). As tau->0 >
  < this inflates without bound; as tau->1 it approaches the Euclidean length. >
  double effectiveDistance(double tau, double dx, double dy, SLPhysicsMath m) {
    return m.sqrtD(lineElementSq(tau, dx, dy));
  }

  < Scalar curvature proxy for this conformal family in 2D: with g = e^{2 phi} I >
  < and phi = -0.5 ln(tau), the Gaussian curvature is K = -e^{-2 phi} lap(phi). >
  < Here phi depends only on the (constant-in-space) tau, so spatial curvature >
  < is 0 for a uniform field; the ECONOMIC curvature we report is the field's >
  < departure from flatness, f(tau) - 1 >= 0 (0 at full trust, growing as trust >
  < falls). This is the "warping" the analogy cares about. >
  double warping(double tau) { return conformalFactor(tau) - 1.0; }

  < Is the field effectively flat (Euclidean) at this trust level? >
  boolean isFlat(double tau, double tol) { return warping(tau) < tol; }

  String describe(double tau) {
    return "TrustMetric(tau=" + tau + "): f=" + conformalFactor(tau)
         + " warping=" + warping(tau);
  }
}