Documentation

Linglib.Tactics.RSAPredict.RSABuilder

RSA Bottom-Up RExpr Builder #

Constructs RExpr trees for RSA expressions bottom-up from evaluated leaf values, completely bypassing the generic reifier's top-down unfoldDefinition? chain.

The generic reifier discovers expression structure by unfolding definitions one at a time (~31K unfoldDefinition? calls for the first cross-utterance theorem). The builder knows the RSA layered structure and constructs RExpr trees directly:

  1. Leaf evaluation: Evaluate meaning Bool values natively, reify priors/costs via the generic reifier (small expressions, ~0.1ms each).
  2. Layer composition: Build L0 → S1 → L1 RExpr trees by direct construction.
  3. Direct return: Return the full RExpr to the caller, bypassing reifyToRExpr.

The kernel verifies denote(rexpr) ≡ original_expr by reducing both sides. The builder's RExpr matches because:

Stored state for a built RSA model — all layer RExprs indexed by (l, u, w).

Instances For

    Module-scope cache for RSA build results. Keyed by config expression hash. Avoids rebuilding the full layer stack (L0→S1→L1) when the same RSAConfig is used across multiple theorems in the same file.

    Scan an expression tree for RSA.RSAConfig.L1agent applied to a cfg argument. Returns the cfg Expr if found.

    Try to build RExpr trees for an RSA comparison, bypassing the generic reifier. Returns (lhsRExpr, lhsBounds, rhsRExpr, rhsBounds) on success.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Build L1 and L1_latent RExprs for an RSAConfig by:

      1. Instantiating the s1Score lambda body directly (bypassing S1→S1agent→policy chain)
      2. Reifying each instantiated body via the generic reifier
      3. Assembling S1→L1 layers algebraically

      This avoids the expensive whnf chain through cfg.S1 l w u → (S1agent l).policy w u → RationalAction.policy → iteZero → Finset.sum. Instead, we substitute concrete L0 policy function + args into the s1Score body and reify the resulting simple arithmetic expression (ite/exp/log/Finset.sum).

      Seeds the reification cache with L1/L1_latent values so the generic reifier finds them immediately when processing S2Utility or similar composite expressions.

      Recursively detects nested RSA configs in worldPrior/meaning (e.g., seqAdjCfg's worldPrior is (evalCfg mu).L1) and builds them first.

      Pre-seed the reification cache with L1/L1_latent values for RSAConfig references found in the expression. Call before reifyToRExpr to avoid expensive whnf of nested L1 computations (e.g., in S2Utility).

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For