Documentation

Blaster.Optimize.Telescope

@[inline]
def Blaster.Optimize.mapTranslateEnvT {m : Type → Type u_1} {β : Sort u_2} [MonadControlT TranslateEnvT m] [Monad m] (f : {α : Type} → (β → TranslateEnvT α) → TranslateEnvT α) {α : Type} (k : β → m α) :
m α
Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[inline]
    def Blaster.Optimize.map2TranslateEnvT {m : Type → Type u_1} {β : Sort u_2} {γ : Sort u_3} [MonadControlT TranslateEnvT m] [Monad m] (f : {α : Type} → (β → γ → TranslateEnvT α) → TranslateEnvT α) {α : Type} (k : β → γ → m α) :
    m α
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[inline]

      Return some className if n corresponds to a class or is transitively an abbrevation to a class definition (e.g., DecidableEq, DecidableLT, DecidableRel, etc).

      Equations
      Instances For
        @[inline]

        Return true if e corresponds to a class constraint expression (see function isClassConstraint).

        Equations
        Instances For
          @[inline]
          def Blaster.Optimize.forallTelescope {n : Type → Type u_1} [MonadControlT TranslateEnvT n] [Monad n] {α : Type} (type : Lean.Expr) (k : Array Lean.Expr → Lean.Expr → n α) :
          n α

          Given type of the form forall xs, A, execute k xs A. This combinator will declare local declarations, create free variables for them, execute k with updated local context, and make sure the cache is restored after executing k.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[inline]
            def Blaster.Optimize.forallBoundedTelescope {n : Type → Type u_1} [MonadControlT TranslateEnvT n] [Monad n] {α : Type} (type : Lean.Expr) (maxFVars : Nat) (k : Array Lean.Expr → Lean.Expr → n α) :
            n α

            Similar to forallTelescope, stops constructing the telescope when it reaches size maxFVars.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[inline]
              def Blaster.Optimize.lambdaTelescope {n : Type → Type u_1} [MonadControlT TranslateEnvT n] [Monad n] {α : Type} (e : Lean.Expr) (k : Array Lean.Expr → Lean.Expr → n α) :
              n α

              Given e of the form fun ..xs => A, execute k xs A. This combinator will declare local declarations, create free variables for them, execute k with updated local context, and make sure the cache is restored after executing k.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[inline]
                def Blaster.Optimize.lambdaBoundedTelescope {n : Type → Type u_1} [MonadControlT TranslateEnvT n] [Monad n] {α : Type} (e : Lean.Expr) (maxFVars : Nat) (k : Array Lean.Expr → Lean.Expr → n α) :
                n α

                Given e of the form fun ..xs ..ys => A, execute k xs (fun ..ys => A) where xs.size ≤ maxFVars. This combinator will declare local declarations, create free variables for them, execute k with updated local context, and make sure the cache is restored after executing k.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  @[inline]
                  def Blaster.Optimize.withLocalDecl' {n : Type → Type u_1} [MonadControlT TranslateEnvT n] [Monad n] {α : Type} (name : Lean.Name) (bi : Lean.BinderInfo) (type : Lean.Expr) (k : Lean.Expr → n α) :
                  n α

                  Same as default withLocalDecl but rests heartbeats.

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

                    Eta expand the given expression. Example:

                    etaExpand (mkConst ``Nat.add)
                    

                    produces fun x y => Nat.add x y

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

                      Given e of the form λ (a₁ : α₁) → ... → λ (aₙ : αₙ) → b, return λ (a₁ : α₁) → ... → λ (aₙ : αₙ) → f b. NOTE: This function can be used only it is guaranteed the modifications induced by f will not break the de-bruijn indices. E.g.,

                      • f b ===> b * 2
                      • f b ===> b x₁ ... xₙ s.t., x₁ .. xₙ don't have any bounded variables.
                      • etc
                      Equations
                      Instances For
                        @[inline]

                        Given e of the form λ (a₁ : α₁) → ... → λ (aₙ : αₙ) → b, return λ (a₁ : α₁) → f λ (aₖ : αₖ → ... → λ (aₙ : αₙ) where k < maxBinders NOTE: This function can be used only it is guaranteed the modifications induced by f will not break the de-bruijn indices. E.g.,

                        • f b ===> b * 2
                        • f b ===> b x₁ ... xₙ s.t., x₁ .. xₙ don't have any bounded variables.
                        • etc
                        Equations
                        Instances For
                          @[inline]

                          Given a sequence of nested lambdas (a₁ : α₁) → ... → (aₙ : αₙ) → _, perform the following:

                          • let k = maxTypes
                          • return #[α₁ ... αₖ] Note: Dependent types are instantiated (whenever necessary).
                          Equations
                          Instances For
                            @[inline]

                            Given a sequence of nested lambdas (a₁ : α₁) → ... → (aₙ : αₙ) → _, return #[α₁ ... αₙ]. Note: Dependent types are instantiated (whenever necessary).

                            Equations
                            Instances For

                              Return pInfo when f := pInfo ∈ getFunEnvInfoCache. Otherwise, performing the following

                              • Let v₁ : t₁ → .. → vₙ : tₙ := inferTypeEnv f
                              • Let p := #[ { binderInfo := declᵢ.binderInfo, isProp := ← isProp declᵢ.type } | ∀ i ∈ [1..n-1], declᵢ ← getFVarLocalDecl vᵢ ]
                              • Let pInfo := { paramsInfo := p, type := v₁ : t₁ → .. → vₙ : tₙ }
                              • add f := pInfo to getFunEnvInfoCache
                              • return pInfo
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Given t := ∀ α₀ → ∀ α₂ → ... → αₙ corresponding to function type and x₁ ... xₘ the function's applied arguments, determine the instantiated fun type by properly instantiating the implicit arguments.

                                TODO: change function to pure tail rec call using stack-based approach

                                Equations
                                Instances For

                                  Given t := ∀ α₀ → ∀ α₂ → ... → αₙ corresponding to function type and x₁ ... xₘ the function's applied arguments, determine the application type by properly instantiating the implicit arguments.

                                  Equations
                                  Instances For

                                    Given a f : Expr.const n l a function name expression, return true if f has at least one implicit argument.

                                    Equations
                                    Instances For

                                      Given application f x₀ ... xₙ, return the following sequence: let A := [x₀ ... xₙ] let instanceArgs := [ { implicitArg := A[i], isInstance := ¬ isExplicit A[i], isGeneric := isGenericParam A[i], idxArg := i} | i ∈ [0..n] ] return instanceArgs NOTE: It is also assumed that args does not contain any meta or bounded variables.

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

                                        Given function f and params its implicit parameter info (see getImplicitParameters), perform the following: let instanceArgs := [ params[i] | i ∈ [0..params.size-1] ∧ params[i].isInstance ] let genFVars ← retrieveGenericFVars params

                                        • When instanceArgs.isEmpty
                                          • return f
                                        • Otherwise:
                                          • When instanceArgs.size == params.size (i.e., only implicit arguments provided)
                                            • return mkLambdaFVars genFVars f
                                          • Otherwise:
                                            • return mkLambdaFVars genFVars (specializeLambda (← etaExpand f) params)
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For