Given application f x₁ ... xₙ, perform the following:
- When `isOpaqueRecFun f #[x₁ ... xₙ] ∧ allExplicitParamsAreCtor f #[x₁ ... xₙ]
- When some auxFun ← unfoldOpaqueFunDef f #[x₁ ... xₙ]
- When some body ← getFunBody auxFun.getAppFn'
- return
Expr.beta body auxFun.getAppArgs
- return
- Otherwise:
- return ⊥
- When some body ← getFunBody auxFun.getAppFn'
- Otherwise:
- return none
- When some auxFun ← unfoldOpaqueFunDef f #[x₁ ... xₙ]
- When `isRecursiveFun f ∧ ¬ isOpaqueFunExpr f #[x₁ ... xₙ] ∧ allExplicitParamsAreCtor f #[x₁ ... xₙ]
- When some body ← getFunBody f:
- return
Expr.beta body #[x₁ ... xₙ]
- return
- Otherwise:
- return ⊥
- When some body ← getFunBody f:
- Otherwise:
- return none
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.
- Blaster.Optimize.reduceApp?.isFunRecReduction? f args = pure none
Instances For
Perform constant propagation and apply simplification and normalization rules on application expressions.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Perform the following:
- apply normalization and simplification rrules on the given application expression
- When restart flag is set:
- add optimized application on continuation stack
- Otherwise:
- try tp apply function propagation over ite and match:
- When propagation rules are triggered:
- add result on continuation stack
- Otherwise:
- cache normalized application
- proceed with stack continuity
- When propagation rules are triggered:
- try tp apply function propagation over ite and match:
NOTE: skipPropCheck is set to true only when it is known beforehand that f
is a recursive function for which allExplicitParamsAreCtor f args (funPropagation := true)
returns true.
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
Given application f x₁ ... xₙ,
- When
isFunITE f(i.e., f is a Blaster.dite' that return a function)- return none
- when
isNotfun f- return none
- when
t₁ → ... → tₘ ← inferType f ∧ n < m:- when ∀ i ∈ [1..n], ¬ isExplicit tᵢ:
- return none
- otherwise:
- return
etaExpand (mkAppN f args)
- return
- when ∀ i ∈ [1..n], ¬ isExplicit tᵢ:
- otherwise
none
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Blaster.Optimize.normPartialFun?.isFunITE args (Lean.Expr.const `Blaster.dite' us) = decide (args.size > 4)
- Blaster.Optimize.normPartialFun?.isFunITE args e = false
Instances For
Given application f x₁ ... xₙ perform the following:
- when
fcorresponds to a recursive definitionλ p₁ ... pₙ → bodythe following actions are performed:- params ← getImplicitParameters f #[x₁ ... xₙ]
- fᵢₙₛ ← getInstApp f params
- When entry
fᵢₙₛ := fdefexists in the instance cache andfdef := fₙis in the recursive function map.- return
optimizeRecApp fₙ params
- return
- when no entry for
fᵢₙₛexists in the instance cache:- fbody' ← optimizer (← generalizeRecCall f params (λ p₁ ... pₙ → body))`
- call
storeRecFunDefto update instance cache and check if recursive definition already exists in map, i.e.: fᵢ ← storeRecFunDef fᵢₙₛ fbody' - return
optimizeRecApp fᵢ params
- when
fis not a recursive definition or is already in the recursive visited cache.- return
optimizeApp f x₁ ... xₙ. Assumes that an entry exists for each opaque recursive function inrecFunMapbefore optimization is performed (see functioncacheOpaqueRecFun).
- return
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a function application f x₁ ... xₙ, flag isOpaqueRec and default instance application instApp
perform the following:
- When isOpaqueRec:
- return
getInstApp (← getImplicitParameters f x₁ ... xₙ)
- return
- Otherwise:
- return instApp
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a function application f x₁ ... xₙ and flag isOpaqueRec perform the following:
- When isOpaqueRec:
let auxApp ← unfoldOpaqueFunDef f x₁ ... xₙ
- when auxApp := λ α₀ → ... → λ αₖ → fₑ x₀ ... xₙ` (i.e., partially applied opaque relational function)
- return (fₑ, x₀ ... xₙ₋ₖ)
- when auxApp := fₑ x₀ ... xₙ` (default case)
- return (fₑ, x₀ ...xₙ)
- when auxApp := λ α₀ → ... → λ αₖ → fₑ x₀ ... xₙ` (i.e., partially applied opaque relational function)
- Otherwise:
- return (f, x₁ ... xₙ)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Given rf a function application instance (see function getInstApp) and params its
implicit parameter inffo (see function getImplicitParameters), perform the following:
let instanceArgs := [ params[i] | ∀ i ∈ [0..params.size-1] ∧ params[i].isInstance ]
- When params.isEmpty :
- return rf
- When instanceArgs.isEmpty ∨ f =ₚₜᵣ rf (i.e., non ploymorphic function or rec call in fun body)
- return
optimizeApp rf args
- return
- When rf.isConst (i.e., polymorphic function equivalent to a non-polymorphic one)
- return
optimizeApp rf [params[i] | ∀ i ∈ [0..params.size-1] ∧ ¬ params[i].instance]
- return
- Otherwise:
let auxApp := Expr.beta rf (getEffectiveParams params)
- When
auxApp := λ α₀ → ... → λ αₖ → fₑ x₀ ... xₙ(i.e., partially applied polymorphic function)- return
optimizeApp fₑ x₀ ...xₙ₋ₖ
- return
- When
auxApp := fₑ x₀ ... xₙ(default case)- return
optimizeApp fₑ x₀ ...xₙ
- return
- When
Equations
- One or more equations did not get rendered due to their size.