Documentation

Linglib.Tactics.RSAPredict.Helpers

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
Instances For

    Extract a natural number from @Nat.cast T inst n.

    Equations
    Instances For
      Equations
      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
            • 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 a nonneg ℚ up to bits binary digits: ceil(q · 2^bits) / 2^bits.

                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
                    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
                        def Linglib.Tactics.RSAPredict.metaL1Score (nL nW nU : ) (s1Bounds : Array MetaBounds) (wpValues lpValues : Array ) (uIdx wIdx : ) :

                        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
                          def Linglib.Tactics.RSAPredict.metaL1LatentScore (nL nW nU : ) (s1Bounds : Array MetaBounds) (wpValues lpValues : Array ) (uIdx lIdx : ) :

                          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
                            def Linglib.Tactics.RSAPredict.metaL1Policy (nL nW nU : ) (s1Bounds : Array MetaBounds) (wpValues lpValues : Array ) (uIdx : ) (allWIndices : Array ) (targetWIdx : ) :

                            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
                              def Linglib.Tactics.RSAPredict.metaS2Score (nL nW nU : ) (s1Bounds : Array MetaBounds) (wpValues lpValues : Array ) (allUIndices : Array ) (targetUIdx wIdx : ) :

                              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.
                                    Instances For
                                      @[implemented_by _private.Linglib.Tactics.RSAPredict.Helpers.0.Linglib.Tactics.RSAPredict.tryEvalBoolUnsafe]