Documentation

Blaster.Optimize.Rewriting.FunPropagation

Given,

  • t := λ β₁ => ... => βₘ => ∀ α₁ → ∀ α₂ → ... → αₙ corresponding to a match expression returning functions as rhs; and
  • nbArgs ∈ [0..n] corresponding to the number of extra arguments applied to the match expression; and
  • α'₁, ..., α'ₘ := [ αᵢ | i ∈ [nbArgs, n] ] Return:
  • ∀ α'₁ → ∀ α'₂ → ... → α'ₘ Note that the returned type will correspond to αₙ when nbArgs = n.
Equations
Instances For

    Given application f x₁ ... xₙ, apply the following normalization rules:

    • When f := Blaster.dite' c (fun h : c => t₁) (fun h : ¬ c => t₂) Return Blaster.dite' c (fun h : c => t₁ x₁ ... xₙ) (fun h : ¬ c => t₂ x₁ ... xₙ)

    • When f := match₁ e₁, ..., eₙ with | p₍₁₎₍₁₎, ..., p₍₁₎₍ₙ₎ => t₁ ... | p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₙ₎ => tₘ Return match₁ e₁, ..., eₙ with | p₍₁₎₍₁₎, ..., p₍₁₎₍ₙ₎ => t₁ x₁ ... xₙ ... | p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₙ₎ => tₘ x₁ ... xₙ

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      Equations
      Instances For
        Equations
        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 Blaster.Optimize.funPropagation? (cf : Lean.Expr) (cargs : Array Lean.Expr) (skipPropCheck reorderArgs : Bool := false) :

              Apply the following propagation rules on any function application fn e₁ ... eₙ only when fn := Expr.const n l ∧ n ≠ Blaster.dite' ∧ ¬ isNotFun fn ∧ propagate fn e₁ ... eₙ

              • When ∃ i ∈ [1..n], eᵢ := Blaster.dite' c (fun h : c => d₁) (fun h : ¬ c => d₂) ∧ ∀ j ∈ [1..n], (i ≠ j → gⱼ = eⱼ) ∧ (i = j → gⱼ = d₁) ∧ (i ≠ j → hⱼ = eⱼ) ∧ (i = j → hⱼ = d₂) Return Blaster.dite' c then (fun h : c => fn g₁ ... gₙ) (fun h : ¬ c => fn h₁ ... hₙ)

              • When ∃ i ∈ [1..n], eᵢ := match₂ f₁, ..., fₚ with | p₍₁₎₍₁₎, ..., p₍₁₎₍ₚ₎ => t₁ ... | p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₚ₎ => tₘ ∧ ∀ k ∈ [1..m], ∀ j ∈ [1..n], (i ≠ j → g₍ₖ₎₍ⱼ₎ = eⱼ) ∧ (i = j → g₍ₖ₎₍ⱼ₎ = tₖ) Return match₂ f₁, ..., fₚ with | p₍₁₎₍₁₎, ..., p₍₁₎₍ₚ₎ => fn g₍₁₎₍₁₎, ..., g₍₁₎₍ₙ₎ ... | p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₚ₎ => fn g₍ₘ₎₍₁₎, ..., g₍ₘ₎₍ₙ₎

              with: propagate fn e₁ ... eₙ := isCtorExpr fn ∨ allExplicitParamsAreCtor fn e₁ ... eₙ (funPropagation := true) ∨ (fn = Eq ∧ n = 3 ∧ (isBoolValue? e₂).isSome ) NOTE: skipPropCheck is set to true only when it is known beforehand that cf is a recursive function for which allExplicitParamsAreCtor cf cargs (funPropagation := true) returns true. NOTE: reorderArgs is set to true only when funPropagation? is called before optimizeApp.

              Equations
              Instances For
                @[irreducible]
                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
                    Instances For

                      Implements dite over ctor rule

                      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

                          Implements match over ctor rule

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