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
- 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
- Tactics.RSAPredict.getNatCast? e = do guard (e.isAppOfArity `Nat.cast 3 = true) e.getAppArgs[2]!.rawNatLit?
Instances For
Equations
- Tactics.RSAPredict.getNat? e = (e.rawNatLit? <|> Tactics.RSAPredict.getOfNat? e <|> Tactics.RSAPredict.getNatCast? e)
Instances For
Equations
- 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.
- lo : ℚ
- hi : ℚ
Instances For
Equations
- Tactics.RSAPredict.instInhabitedMetaBounds.default = { lo := default, hi := default }
Instances For
Equations
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
- Tactics.RSAPredict.roundDownBin q bits = ↑(q.num.toNat * 2 ^ bits / q.den) / ↑(2 ^ bits)
Instances For
Round a nonneg ℚ up to bits binary digits: ceil(q · 2^bits) / 2^bits.
Equations
- Tactics.RSAPredict.roundUpBin q bits = ↑((q.num.toNat * 2 ^ bits + q.den - 1) / q.den) / ↑(2 ^ bits)
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
- Tactics.RSAPredict.roundBounds b bits = if (b.lo == b.hi) = true then b else { lo := Tactics.RSAPredict.roundDownBin b.lo bits, hi := Tactics.RSAPredict.roundUpBin b.hi bits }
Instances For
Instances For
Equations
- Tactics.RSAPredict.metaQISumMap scores = Array.foldl 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.