Documentation

Linglib.Tactics.RSAPredict.Helpers

RSAPredict Helpers #

Low-level expression utilities, MetaBounds interval arithmetic, and enum extraction used across the RSAPredict tactic submodules.

def Tactics.RSAPredict.getOfNat? (e : Lean.Expr) :
Option

Extract a natural number from @OfNat.ofNat T n inst.

Equations
Instances For
    def Tactics.RSAPredict.getNatCast? (e : Lean.Expr) :
    Option

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

    Equations
    Instances For
      def Tactics.RSAPredict.getNat? (e : Lean.Expr) :
      Option
      Equations
      Instances For
        def Tactics.RSAPredict.isAppOfMin (e : Lean.Expr) (name : Lean.Name) (minArgs : ) :
        Bool
        Equations
        Instances For
          def Tactics.RSAPredict.resolveNat? (e : Lean.Expr) :
          Lean.MetaM (Option )

          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
              • One or more equations did not get rendered due to their size.
              Instances For
                def Tactics.RSAPredict.roundDownBin (q : ) (bits : ) :

                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
                  def Tactics.RSAPredict.roundUpBin (q : ) (bits : ) :

                  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
                    Instances For
                      Equations
                      Instances For
                        Equations
                        Instances For
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def Tactics.RSAPredict.metaQINormalize (scores : Array MetaBounds) (targetIdx : ) :
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def 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 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 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 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
                                      def Tactics.RSAPredict.findElemIdx (elems : Array Lean.Expr) (target : Lean.Expr) :
                                      Lean.MetaM

                                      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
                                        def Tactics.RSAPredict.extractList (e : Lean.Expr) :
                                        Lean.MetaM (Array Lean.Expr)

                                        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
                                          partial def Tactics.RSAPredict.getFiniteElems (T : Lean.Expr) :
                                          Lean.MetaM (Lean.Expr × Array Lean.Expr)

                                          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.

                                          def Tactics.RSAPredict.mkRatExpr (q : ) :
                                          Lean.MetaM Lean.Expr

                                          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.Tactics.RSAPredict.tryEvalBoolUnsafe]
                                            opaque Tactics.RSAPredict.tryEvalBool (e : Lean.Expr) :
                                            Lean.MetaM (Option Bool)