Return true only when
isConstructor p ∨g
( p := Blaster.dite' c (fun h : c => e₁) (fun h : ¬ c => e₂) ∧ isCstMatchProp e₁ ∧ isCstMatchProp e₂ ) ∨
( p := match e₁, ..., eₙ with
| p₍₁₎₍₁₎, ..., p₍₁₎₍ₙ₎ => t₁
...
| p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₙ₎ => tₘ
∧ ∀ i ∈ [1..m], isCstMatchProp t₁ )
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given f x₁ ... xₙ return true when the following conditions are satisfied:
- ∃ i ∈ [1..n], isExplicit xᵢ ∧
- ∀ i ∈ [1..n], isExplicit xᵢ → isCstProp xᵢ ∨ isPropFunType f xₓ with
- isCstProp e := isCstMatchProp e IF funpropagaton isCstProp e := isConstructor e Otherwise
- isPropFunType e := isProp e.Type ∨ isFunType' e.Type NOTE: constructors may contain free variables.
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.allExplicitParamsAreCtor.isFunExpr (Lean.Expr.lam binderName binderType body binderInfo) = pure true
- Blaster.Optimize.allExplicitParamsAreCtor.isFunExpr (Lean.Expr.fvar fv) = do let __do_lift ← liftM fv.getType pure (Blaster.Optimize.isFunType' __do_lift)
- Blaster.Optimize.allExplicitParamsAreCtor.isFunExpr (Lean.Expr.const n us) = do let cInfo ← Blaster.Optimize.getConstEnvInfo n pure (Blaster.Optimize.isFunType' cInfo.type)
- Blaster.Optimize.allExplicitParamsAreCtor.isFunExpr e = pure false
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given m := f x₁ ... xₙ with f corresponding to a match function
and mInfo the corresponding matcher info, perform the following:
- When
¬ allMatchDiscrsAreCtor x₁ ... xₙ minfo:- return none
- When
m := bis already in the weak head cache- return
b
- return
- Otherwise:
- When .reduced e ← reduceMatcher? m
- update cache with
m := some e - return
some e
- update cache with
- Otherwise
- update cache with
m := none - return
noneAssume thatmis a match expression.
- update cache with
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
Equations
- One or more equations did not get rendered due to their size.
Instances For
Apply the following constant propagation rules on match expressions, such that: Given match₁ e₁, ..., eₙ with | p₍₁₎₍₁₎, ..., p₍₁₎₍ₙ₎ => t₁ ... | p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₙ₎ => tₘ
When ∀ i ∈ [1..n], isCstMatchProp eᵢ ∧ ∃ j ∈ [1..n],
eⱼ := Blaster.dite' c (fun h : c => d₁) (fun h : ¬ c => d₂)∧ (i ≠ j → gᵢ = eᵢ) ∧ (i = j → gᵢ = d₁) ∧ (i ≠ j → hᵢ = eᵢ) ∧ (i = j → hᵢ = d₂) ReturnBlaster.dite' c (fun h : c => match₁ g₁, ..., gₙ with ...) (fun h : ¬ c => match₁ h₁, ..., hₙ with ...)When ∀ i ∈ [1..n], isCstMatchProp eᵢ ∧ ∃ j ∈ [1..n], eⱼ := match₂ f₁, ..., fₚ with | fp₍₁₎₍₁₎, ..., fp₍₁₎₍ₚ₎ => t₁ ... | fp₍ₘ₎₍₁₎, ..., fp₍ₘ₎₍ₚ₎ => tₘ ∧
∀ k ∈ [1..m], (i ≠ j → g₍ₖ₎₍ᵢ₎ = eᵢ) ∧ (i = j → g₍ₖ₎₍ᵢ₎ = tₖ)Return
match₂ f₁, ..., fₚ with | fp₍₁₎₍₁₎, ..., fp₍₁₎₍ₚ₎ => match₁ g₍₁₎₍₁₎, ..., g₍₁₎₍ₙ₎ with ... ... | fp₍ₘ₎₍₁₎, ..., fp₍ₘ₎₍ₚ₎ => match₁ g₍ₘ₎₍₁₎, ..., g₍ₘ₎₍ₙ₎ with ...
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.constMatchPropagation?.pushMatchInDIteExpr mInfo f args idxDiscr e = Blaster.Optimize.throwEnvError (Lean.toMessageData "pushMatchInDIteExpr: lambda term expected !!!")
Instances For
Given a match expression try reduceMatch? first and afterwards try constMatchpropagation?.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Blaster.Optimize.isFVarPattern (Lean.Expr.fvar fvarId) = true
- Blaster.Optimize.isFVarPattern (((((Lean.Expr.const `namedPattern us).app _t).app _n).app pe).app _h) = Blaster.Optimize.isFVarPattern pe
- Blaster.Optimize.isFVarPattern e = false
Instances For
Given match info mInfo and args the arguments of a match expression of the form:
match₁ e₁, ..., eₙ with
| p₍₁₎₍₁₎, ..., p₍₁₎₍ₙ₎ => t₁
...
| p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₙ₎ => tₘ
Given rhs the current match alternative to be optimized, i.e., p₍ᵢ₎₍₁₎, ..., p₍₁₎₍ₙ₎ => tᵢ and
altIdx its index in args, perform the following actions:
- let h := (← get).optEnv.options.matchInContext
- let h1 := h ∪ [ eⱼ := pmᵢ ∪ p₍ᵢ₎₍ⱼ₎ := EqPattern (retrieveAltsArgs #[p₍ᵢ₎₍ⱼ₎]) | j ∈ [1..n] ∧ (h[eⱼ]? = some pmᵢ ∨ pmᵢ = []) ]
- let h2 := h1 ∪ [ eⱼ := pmⱼ ∪ p₍ₖ₎₍ⱼ₎ := NotEqPattern | k ∈ [1..i-1] ∧ ∃! j ∈ [1..n], (h1[eⱼ]? = some pmᵢ ∨ pmᵢ = []) ∧ ¬ isFVarPattern p₍ₖ₎₍ⱼ₎ ]
- let se₁ ... seₚ := [eⱼ | j ∈ [1..n] ∧ isFVar p₍ᵢ₎₍ⱼ₎ ]
- let sp₁ ... spₚ := [p₍ᵢ₎₍ⱼ₎ | j ∈ [1..n] ∧ isFVar p₍ᵢ₎₍ⱼ₎ ]
- withMatchContext h2 $ optimizer tᵢ[sp₁/seᵢ] ... [spₚ/seₚ]
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
Equations
- One or more equations did not get rendered due to their size.
Instances For
Apply the following reduction rules, such that: Given match₁ e₁, ..., eₙ with | p₍₁₎₍₁₎, ..., p₍₁₎₍ₙ₎ => t₁ ... | p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₙ₎ => tₘ
When ∀ i ∈ [1..m], ¬ tᵢ.hasLooseBVars ∧ tᵢ = t₁
- return
some t₁
- return
When ∃ i ∈ [1..m], ∀ j ∈ [1..n], eⱼ := pm ∈ matchInContext ∧ p₍ᵢ₎₍ⱼ₎ := EqPattern altArgs ∈ pm ∧ ¬ isFVarPattern p₍ᵢ₎₍ⱼ₎
- return
some tᵢ
- return
When ∀ j ∈ [1..n], isFVar p₍ₘ₎₍ⱼ₎ ∧ ∀ k ∈ [1..m-1], ∃ h ∈ [1..n], ( eₕ := pm ∈ matchInContext ∧ p₍ₖ₎₍ₕ₎ := NotEqPattern ∈ pm ) - return
some tₘ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.
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
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 a match application expression of the form
f.match_n #[p₁, ..., pₙ, rt, d₁, ..., dₖ, pa₍₁₎₍₁₎ → .. → pa₍₁₎₍ₖ₎ → rhs₁, ..., pa₍ₘ₎₍₁₎ → .. → pa₍ₘ₎₍ₖ₎ → rhsₘ],
perform the following actions:
- params ← getImplicitParameters f #[p₁, ..., pₙ]
- let genFVars ← retrieveGenericFVars params
- appType ← genericMatchType (λ (α₁ : Type₁) → λ (αₘ : Typeₘ) → mInfo.instApp p₁, ..., pₙ, rt),
with
α₁ : Type₁, ..., αₘ : Typeₘ = genFVars - return
g.match.n α₁ ..., αₘ, rt, d₁ ... dₖ pa₍₁₎₍₁₎ → .. → pa₍₁₎₍ₖ₎ → rhs₁ ... pa₍ₘ₎₍₁₎ → .. → pa₍ₘ₎₍ₖ₎ → rhsₘonly whenappType := λ (α₁ : Type₁) → λ (αₘ : Typeₘ) → g.match.n q₁ ... qₕexists in match cache. - Otherwise, perform the following:
- Add
appType := λ (α₁ : Type₁) → λ (αₘ : Typeₘ) → f.match.n p₁ ... pₙin match cache - return
f.match.n p₁, ..., pₙ, rt, d₁ ... dₖ pa₍₁₎₍₁₎ → .. → pa₍₁₎₍ₖ₎ → rhs₁ ... pa₍ₘ₎₍₁₎ → .. → pa₍ₘ₎₍ₖ₎ → rhsₘWhere:
- Add
- p₁, ..., pₙ: correspond to the arguments instantiating polymorphic params.
- rt : correspond to the match expression's return type
- d₁, ..., dₖ: correspond to the match expresson discriminators
- pa₍₁₎₍₁₎ → .. → pa₍₁₎₍ₖ₎ → rhs₁, ..., pa₍ₘ₎₍₁₎ → .. → pa₍ₘ₎₍ₖ₎ → rhsₘ: correspond to the rhs for each pattern matching.
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
Apply simplification and normalization rules on match expressions.
Assumes that f x₁ ... xₙ is a match application
Equations
- One or more equations did not get rendered due to their size.