RSAPredict Helpers #
Low-level expression utilities, MetaBounds interval arithmetic, and enum extraction
used across the RSAPredict tactic submodules.
Extract a natural number from @OfNat.ofNat T n inst.
Equations
- Linglib.Tactics.RSAPredict.getOfNat? e = do guard (e.isAppOfArity `OfNat.ofNat 3 = true) e.appFn!.appArg!.rawNatLit?
Instances For
Extract a natural number from @Nat.cast T inst n.
Equations
- Linglib.Tactics.RSAPredict.getNatCast? e = do guard (e.isAppOfArity `Nat.cast 3 = true) e.getAppArgs[2]!.rawNatLit?
Instances For
Equations
Instances For
Equations
- Linglib.Tactics.RSAPredict.isAppOfMin e name minArgs = (e.getAppFn.isConstOf name && decide (e.getAppNumArgs ≥ minArgs))
Instances For
Try to extract a natural number, unfolding/reducing as needed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Meta-level interval bounds for early checks.
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Round a nonneg ℚ down to bits binary digits: floor(q · 2^bits) / 2^bits.
The result has a power-of-2 denominator, preventing denominator blowup.
Equations
Instances For
Round MetaBounds outward (lo down, hi up) to bits binary digits.
Maintains soundness: the rounded interval contains the original.
Assumes both bounds are nonneg (always true for RSA scores).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- Linglib.Tactics.RSAPredict.metaQISumMap scores = Array.foldl Linglib.Tactics.RSAPredict.metaQIAdd { lo := 0, hi := 0 } scores
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compute L1 unnormalized score at meta level using MetaBounds. L1(u,w) = worldPrior(w) · Σ_l latentPrior(w,l) · S1_policy(l,w,u) where S1_policy(l,w,u) = S1(l,w,u) / Σ_{u'} S1(l,w,u'). lpValues is indexed as lpValues[wIdx * nL + lIdx].
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compute latent inference score at meta level: latent_score(l) = Σ_w worldPrior(w) · latentPrior(w,l) · S1_policy(l,w,u) where S1_policy(l,w,u) = S1(l,w,u) / Σ_{u'} S1(l,w,u'). lpValues is indexed as lpValues[wIdx * nL + lIdx].
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compute L1 policy bounds at meta level (score / total). Used for cross-utterance comparisons where denominators differ.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compute S2 policy bounds at meta level (cross-world comparison). S2(u|w) = L1(u,w) / Σ_{u'} L1(u',w), where L1 is the normalized posterior. S2agent.score(w,u) = cfg.L1(u,w) = L1agent.policy(u,w).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Find the index of target in elems by definitional equality.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Extract a concrete List from a Lean Expr, extracting cons cells.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Get all elements of a finite type as a List, represented as Lean Exprs.
Returns (listExpr, elemExprs) where listExpr : Expr of type List T
and elemExprs are the individual elements.
Build a Lean Expr for a ℚ literal.
Equations
- One or more equations did not get rendered due to their size.