Type to cache inductive datatype instances and quantified functions that have already been translated.
- instName : Smt.SmtSymbol
Unique name generated for datatype instance/quantified functions.
E.g., Given datatype instances
List T1andList T2, namesList_<id1>andList_<id2>will respectively be generated,E.g., Given two quantified functions f1 : Int → Bool and f2 : Nat -> Bool, names
Fun_<id1>andFun_<id2>will respectively be generated. where<idX>is a Nat literal.
This unique name is mainly used when generating the corresponding smt predicate qualifier for the datatype instance/quantified functions, that is required to specify the expected domain values for quantified variables.
NOTE: Two (or more) polymorphic instances for an inductive datatype will generate the same name (see function
getIndInstinTranslate.Qualifier).NOTE: Two (or more) polymorphic quantified function will generate the same name (see function
getFunInstDeclinTranslate.Qualifier).NOTE: Polymorphic instances are detected transitively,
- instSort : Smt.SortExpr
Corresponding Smt instantiated sort for the inductive datatype instance, E.g.,
(List Int)for instance List Int. - applyInstName : Option Smt.SmtSymbol
unique @apply function generated for each HOF/quantified function or lambda term.
Instances For
Equations
Instances For
Equations
- Blaster.Optimize.instReprIndTypeDeclaration = { reprPrec := fun (x : Blaster.Optimize.IndTypeDeclaration) (x : Nat) => Std.Format.text "<IndTypeDeclaration>" }
- normalizeFunCall : Bool
- inFunApp : Bool
Flag set to
trueonly when optimizing function namefin expressionf x₁ ... xₙ. This is to avoid applying optimization twice on the body of non-recursive functions. - mcDepth : Nat
Keep track of the analysis Step reached for bmc and k-induction.
- solverOptions : Options.BlasterOptions
Options passed to the #solve command.
Instances For
- EqPattern
(altArgs : Array Lean.Expr)
: MatchEntry
instanitated alternative arguments for current match pattern when discriminator matches pattern
- NotEqPattern : MatchEntry
Constructor used when discriminator does not match current pattern in match context
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Instances For
Instances For
Instances For
Instances For
Type to keep hypothesis context
- hypothesisMap : HypothesisMap
Map keeping track of hypotheses introduced by implications/ite. Given an implication of the form
h : a → b, the following entries are introduced in this map:a := h∈ hypothesisMap- When
a := e₁ ∧ e₂- e₁ := Blaster.and_left e₁ e₂ h ∈ hypothesisMap
- e₂ := Blaster.and_right e₁ e₂ h ∈ hypothesisMap
The Map is populated only when Type(a) = Prop.
The updated Map is considered only when optimizing
b, which may also be an implication. (seeaddHypothesesfunction andoptimizeForallrule).
- equalityMap : EqualityMap
Map keeping track of equality introduced by implications/ite. An entry in this map is expected to be one of the following forms:
- fv := Expr
- Expr := C
- Expr := C x₁ ... xₙ Any occurrence of the key for a given context is replaced by the rhs value.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Blaster.Optimize.instInhabitedHypothesisContext = { default := { hypothesisMap := Std.HashMap.emptyWithCapacity, equalityMap := Std.HashMap.emptyWithCapacity } }
Type to keep parameter info for a given function
- binderInfo : Lean.BinderInfo
The binder annotation for the parameter.
- isProp : Bool
Flag set to true when parameter type is a Prop
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Type defining the memoization cache for internally demanding functions.
- isRecFunCache : Std.HashMap Lean.Name Bool
Cache memoizing the isRecursiveFun result
- isInstanceCache : Std.HashMap Lean.Name Bool
Cache memoizing the isInstance result
- isClassCache : Std.HashMap Lean.Name Bool
Cache memoizing the isClassConstraint result
- isInductiveCache : Std.HashMap Lean.Name Bool
Cache memoizing the isInductiveType result
- isResolvableCache : Std.HashMap Lean.Expr Bool
Cache memoizing the isResolvableType result
- getMatcherCache : Std.HashMap Lean.Name (Option MatcherRecInfo)
Cache memoizing the getMatcherRecInfo? result
- getConstInfoCache : Std.HashMap Lean.Name Lean.ConstantInfo
Cache memoizing the getConstInfo result
- inferTypeCache : Std.HashMap Lean.Expr Lean.Expr
Cache memoizing the inferType result
- isMatcherCache : Std.HashMap Lean.Name MatchInfo
Cache memoizing MatchInfo
- isPartialCache : Std.HashMap Lean.Name Bool
Cache memoizing isPartialDef
- getFunEnvInfoCache : Std.HashMap Lean.Expr FunEnvInfo
Cache memoizing getFunEnvInfo result
- isCstMatchPropCache : Std.HashMap Lean.Expr Bool
Cache memoizing isCstMatchProp result
- getFunBodyCache : Std.HashMap Lean.Expr (Option Lean.Expr)
Cache memoizing getFunBody result
- isPropCache : Std.HashMap Lean.Expr Bool
Cache memoizing isProp result
- isMatchToIte : Std.HashMap Lean.Name Bool
Cache memoizing match to ite normalization
- isNotFunCache : Std.HashMap Lean.Expr Bool
Cache memoizing isNotFun result
- isTypeCache : Std.HashMap Lean.Expr Bool
Cache memoizing isType result.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- ctx : Lean.LocalContext
local lean context updated when optimizing lambda and forall expression
- localInsts : Lean.LocalInstances
local instances updated when optimizing lambda and forall expression
Instances For
Equations
Instances For
Type defining the environment used when optimizing a lean theorem.
- globalRewriteCache : RewriteCacheMap
Cache memoizing the normalization and rewriting performed on the lean theorem according to a given context.
- localRewriteCache : RewriteCacheMap
- synthInstanceCache : Std.HashMap Lean.Expr (Option Lean.Expr)
Cache memoizing synthesized instances for Inhabited/LawfulBEq constraint.
- whnfCache : Std.HashMap Lean.Expr (Option Lean.Expr)
Cache memoizing the whnf result.
- matchCache : Std.HashMap Lean.Expr Lean.Expr
Cache memoizing type for a match application of the form
f.match.n [p₁, ..., pₙ, d₁, ..., dₖ,, pa₍₁₎₍₁₎ → .. → pa₍₁₎₍ₖ₎ → rhs₁, ..., pa₍ₘ₎₍₁₎ → .. → pa₍ₘ₎₍ₖ₎ → rhsₘ], s.t.: An entry in this map is expected to be of the formType(f.match.n [p₁, ..., pₙ]):= fun.match.n p₁ ... pₙwhere,p₁, ..., pₙcorrespond to the arguments instantiating polymorphic params. This is used to determine equivalence between match functions (see functionstructEqMatch?`). - recFunInstCache : Std.HashMap Lean.Expr Lean.Expr
Cache memoizing instances of recursive functions. An entry in this map is expected to be of the form
f x₁ ... xₙ := fdef, where:x₁ .. xₙ: correspond to the arguments instantiating the polymorphic parameters off(if any).- fdef: correspond to the recursive function body. TODO: UPDATE SPEC
- recFunCache : Std.HashSet Lean.Expr
Cache keeping track of visited recursive function. Note that we here keep track of each instantiated polymorphic function.
- recFunMap : Std.HashMap Lean.Expr Lean.Expr
Map to keep the normalized definition for each recursive function, which is also used to determine structural equivalence between functions (see function
storeRecFunDef). - hypothesisContext : HypothesisContext
Hypothesis context that is populated whether an implication or ite is encountered. The context is used only when optimization the implication's body or the then/else term of an ite.
- matchInContext : MatchContextMap
Map keeping track of match patterns when optimizing a match rhs. Given a match expression of the form: match₁ e₁, ..., eₙ with | p₍₁₎₍₁₎, ..., p₍₁₎₍ₙ₎ => t₁ x₁ ... xₙ ... | p₍ₘ₎₍₁₎, ..., p₍ₘ₎₍ₙ₎ => tₘ x₁ ... xₙ The following entries are introduced in this map context for each tᵢ:
- ∀ j ∈ [1..n], p₍ᵢ₎₍ⱼ₎ = eⱼ := (← retrieveAltsArgs #[p₍ᵢ₎₍ⱼ₎]).altArgs ∈ matchInContext
(see
optimizeMatchAltfunction).
NOTE: The updated Map context is considered only when optimizing each
tᵢ. - ∀ j ∈ [1..n], p₍ᵢ₎₍ⱼ₎ = eⱼ := (← retrieveAltsArgs #[p₍ᵢ₎₍ⱼ₎]).altArgs ∈ matchInContext
(see
- memCache : MemoizeEnv
Memoization maps (see not on MemoizeEnv)
- options : OptimizeOptions
Optimization options (see note on OptimizeOptions)
- restart : Bool
Flag to be set to
truewhen there is a need to apply optimization again on a given expression. - ctx : LocalDeclContext
local declaration context
Instances For
Equations
- One or more equations did not get rendered due to their size.
- typeUniverse : Bool
Flag set when universe @@Type has already been declared in Smt instance.
- arrowTypeArities : Std.HashMap Nat Smt.SmtSymbol
Cache keeping track of ArrowTN already declared in Smt instance, with
Ncorresponding to the function arity. - inPatternMatching : Std.HashSet Lean.FVarId
Set keeping track of all variables in matched terms, including named patterns. This set is provided only when translating matched terms and match rhs.
- axiomMap : Std.HashMap Lean.Name Smt.SmtSymbol
Map keeping track of axioms not of type Prop or opaque variables, encountered during translation. This set is used mainly to avoid multiple global declaration in the Smt instance.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
Instances For
Type defining the environment used when translating to Smt-Lib.
- translateCache : Std.HashMap Lean.Expr Smt.SmtTerm
Cache memoizing the translation to Smt-Lib term.
- smtCommands : Array Smt.SmtCommand
Smt-Lib commands emitted to the backend solver.
- smtProc : Option (IO.Process.Child { stdin := IO.Process.Stdio.piped, stdout := IO.Process.Stdio.piped, stderr := IO.Process.Stdio.piped })
Backend solver process.
- indTypeVisited : Std.HashSet Lean.Name
Cache keeping track of visited inductive datatype during translation.
- indTypeInstCache : Std.HashMap Lean.Expr IndTypeDeclaration
Map to keep inductive datatype instances and quantified functions that has already been translated. An entry in this map may correspond to one of the following:
Given
dthe name of an inductive data type andx₀ ... xₙits corresponding arguments (if any):- When
∀ i ∈ [0..n], ¬ isGenericParam xᵢ,d x₁ ... xₙ := {instName := n, instSort := (sd sx₀ .. sxₙ)}∈ indTypeInstCache - when
∃ i ∈ [0..n], isGenericParam xᵢ,λ b₀ → .. → bₘ → t x₀ ... xₙ:= {instName := n, instSort := (sd sx₀ .. sxₙ)}` ∈ indTypeInstCache withb₀ .. bₘcorresponding to the polymorphic arguments (seegetIndInst).
- When
Given
f : α₀ → α₁ ... → αₙa quantified function:- When
∀ i ∈ [0..n], ¬ isGenericParam αᵢ,α₀ → α₁ ... → αₙ := {instName := n, instSort := (Array sα₀ sα₁ ... sαₙ)}∈ indTypeInstCache - When
∃ i ∈ [0..n], isGenericParam αᵢ,λ b₀ → .. → bₘ → α₀ → ... → α:= {instName := n, instSort := (Array sα₀ ... sαₙ)} ∈ indTypeInstCache withb₀ .. bₘcorresponding to the polymorphic arguments (seegetFunInstDecl). See note onIndTypeDeclaration.
- When
- funInstCache : Std.HashMap Lean.Expr Smt.SmtQualifiedIdent
Cache keeping track of opaque functions, recursive function instances as well as undefined class functions that have already been translated. An entry in this map is expected to be of the form
f x₁ ... xₙ := n, where:x₁ .. xₙ: correspond to the arguments instantiating the polymorphic parameters off(if any).ncorresponds an smt qualified identifier that is expected to be unique for each recursive function or undefined class function instances. TODO: UPDATE SPEC
- sortCache : Std.HashMap Lean.FVarId Smt.SmtSymbol
Cache keeping track of sort that have already been declared.
- fvarsCache : Std.HashMap Lean.FVarId Nat
Hash keeping track of all translated fvars. (see function fvarIdToSmtSymbol)
- quantifiedFVars : Std.HashMap Lean.FVarId Bool
Hash keeping track of quantified fvars. This is essential to detect globally declared variables. The bool flag is set to
truefor globally declared variables or for top level forall quantifiers. - topLevelVars : TopLevelVars
Array list keeping track of globally declared variables and the ones in the top level forall quantifier. This list is used exclusively when retrieving counterexample after a
satresult is obtained from the backend smt solver. The Array index indicates the analysis step at which the variables where introduced. - symbolStrCache : Std.HashMap Smt.SmtSymbol String
Cache memoizing the string representation for an Smt Symbol
- funCtorCache : Std.HashMap Lean.Name FunEnvInfo
Hash Map keeping the FunEnvInfo for functions defined as Ctor arguments An entry in this Map will correspond to
{ctor}.{idx} := f ∈ funCtorCacheWhere ctor is the name of the ctor and idx the index label generated at the smt level. Example, Given structure Ratio where numerator : Int denominator : Int The corresponding smt datatype declaration will be:- (declare-datatype @Tests.Uplc.Onchain.Ratio ( (Tests.Uplc.Onchain.Ratio.mk (Tests.Uplc.Onchain.Ratio.mk.1 Int) (Tests.Uplc.Onchain.Ratio.mk.2 Int)) ) ) where
- {ctor} = Tests.Uplc.Onchain.Ratio.mk
- {idx} ∈ [1, 2]
- options : TranslateOptions
Translation options (see note on TranslateOptions)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Type defining the environment used when optimizing a lean theorem and translating to Smt-lib.
- smtEnv : SmtEnv
Environment used when translating to Smt-ling.
- optEnv : OptimizeEnv
Environment used when optimization a lean expression.
Instances For
Equations
Instances For
Equations
- Blaster.Optimize.getMCtx' = do let __do_lift ← get pure __do_lift.mctx
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Instances For
macro throwEnvError to avoid applying format on msg before throwEnvError is called
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Blaster.Optimize.getAppFnWithArgsAux (f.app a) x✝¹ x✝ = Blaster.Optimize.getAppFnWithArgsAux f (x✝¹.set! x✝ a) (x✝ - 1)
- Blaster.Optimize.getAppFnWithArgsAux x✝² x✝¹ x✝ = (x✝², x✝¹)
Instances For
Return a function and its arguments
Equations
Instances For
Return the current analysis Step
Equations
Instances For
set restart flag to true.
Equations
- One or more equations did not get rendered due to their size.
Instances For
reset restart flag to false.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return the restart flag.
Instances For
set optimize option normalizeFunCall to b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
set optimize option inFunApp to b.
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
- Blaster.Optimize.getMatchContext = do let __do_lift ← get pure __do_lift.optEnv.matchInContext
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
- Blaster.Optimize.mkLocalContext = do let __do_lift ← Lean.getLCtx let __do_lift_1 ← Lean.Meta.getLocalInstances pure { ctx := __do_lift, localInsts := __do_lift_1 }
Instances For
Equations
- Blaster.Optimize.withLocalContext f = do let __do_lift ← get have ctx : Blaster.Optimize.LocalDeclContext := __do_lift.optEnv.ctx Lean.Meta.withLCtx ctx.ctx ctx.localInsts f
Instances For
Same as the default getConstInfo but cache result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true if c corresponds to a constructor.
Equations
- Blaster.Optimize.isCtorName c = do let __do_lift ← Blaster.Optimize.getConstEnvInfo c pure __do_lift.isCtor
Instances For
Return true if e corresponds to a constructor expression.
Equations
- Blaster.Optimize.isCtorExpr (Lean.Expr.const n us) = do let __do_lift ← Blaster.Optimize.getConstEnvInfo n pure __do_lift.isCtor
- Blaster.Optimize.isCtorExpr e = pure false
Instances For
Same as the default isProp but cache result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
set optimize option inPatternMatchin to h.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Perform the following actions:
- let s := (← get).smtEnv.options.inPatternMatching
- set
inPatternMatchingtos ∪ h - execute
f - set
inPatternMatchingto s
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true if optimize option normalizeFunCall is set to true.
Equations
- Blaster.Optimize.isOptimizeRecCall = do let __do_lift ← get pure __do_lift.optEnv.options.normalizeFunCall
Instances For
Equations
- Blaster.Optimize.findGlobalCache a = do let __do_lift ← get pure (Std.HashMap.get? __do_lift.optEnv.globalRewriteCache a)
Instances For
Equations
- Blaster.Optimize.findLocalCache a = do let __do_lift ← get pure (Std.HashMap.get? __do_lift.optEnv.localRewriteCache a)
Instances For
Update global rewrite cache with a := b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Update local rewrite cache with a := b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Update synthesize decidable instance cache with a := b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return b if a := b is already in the synthesize cache
Otherwise, the following actions are performed:
- execute
b ← f () - update cache with
a := b - return
b
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return a' if a := a' is already in optimization cache.
Otherwise, the following actions are performed:
- add
a := ain cache only when cacheResult is set to true - return
a
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true only when both hypothesisMap and matchInContext are empty and isRefHyp flag is not set
Equations
- One or more equations did not get rendered due to their size.
Instances For
Perform the following:
- When isGlobal
- Add entry
a := btoglobalRewriteCache
- Add entry
- Otherwise
- Add entry
a := btolocalRewriteCache
- Add entry
Equations
- Blaster.Optimize.updateOptimizeEnvCache a b isGlobal = if isGlobal = true then Blaster.Optimize.updateGlobalRewriteCache a b else Blaster.Optimize.updateLocalRewriteCache a b
Instances For
Perform the following:
- When isGlobal
- When
a := b ∈ globalRewriteCache- return
some b
- return
- Otherwise
none
- When
- Otherwise
- When
a := b ∈ localRewriteCache- return
some b
- return
- Otherwise
none
- When
Equations
- Blaster.Optimize.isInOptimizeCache? a isGlobal = if isGlobal = true then Blaster.Optimize.findGlobalCache a else Blaster.Optimize.findLocalCache a
Instances For
Add an instance recursive application (see function getInstApp) to
the visited recursive function cache.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Remove an instance recursive application (see function getInstApp) from
the visited recursive function cache.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Internal generalized rec fun const to be used for in normalized recursive
definition kept in recFunMap.
Equations
- Blaster.Optimize.internalRecFun = `_recFun
Instances For
Tag expression as recursive call. This metadata is used when
replacing a recursive call function with internalRecfun.
Equations
- Blaster.Optimize.tagAsRecursiveCall e = Lean.mkAnnotation `_solver.recursivecall e
Instances For
Return some b if e := mkAnnotation _solver.recursivecall b'`.
Equations
- Blaster.Optimize.toTaggedRecursiveCall? (Lean.Expr.mdata d b) = if (Lean.KVMap.size d == 1 && Lean.KVMap.getBool d `_solver.recursivecall) = true then some b else none
- Blaster.Optimize.toTaggedRecursiveCall? e = none
Instances For
Return true if e := mkAnnotation _solver.recursivecall b'`.
Equations
- Blaster.Optimize.isTaggedRecursiveCall (Lean.Expr.mdata d b) = (Lean.KVMap.size d == 1 && Lean.KVMap.getBool d `_solver.recursivecall)
- Blaster.Optimize.isTaggedRecursiveCall e = false
Instances For
Return true if f is already in the recursive function cache.
Equations
- Blaster.Optimize.isVisitedRecFun f = do let __do_lift ← get pure (__do_lift.optEnv.recFunCache.contains f)
Instances For
Return true if f corresponds to a theorem name.
Equations
- Blaster.Optimize.isTheorem f = do let __do_lift ← Blaster.Optimize.getConstEnvInfo f match __do_lift with | Lean.ConstantInfo.thmInfo val => pure true | x => pure false
Instances For
Return true boolean constructor and cache result.
Equations
- Blaster.Optimize.mkBoolTrue = Blaster.Optimize.mkExpr (Lean.mkConst `Bool.true)
Instances For
Return false boolean constructor and cache result.
Equations
- Blaster.Optimize.mkBoolFalse = Blaster.Optimize.mkExpr (Lean.mkConst `Bool.false)
Instances For
Given b a boolean value return the corresponding
boolean constructor expression and cache result.
Equations
Instances For
Return not boolean operator and cache result.
Equations
Instances For
Return or boolean operator and cache result.
Equations
Instances For
Return and boolean operator and cache result.
Equations
Instances For
Return Prop type and cache result.
Instances For
Given b a boolean value return the corresponding
propositional expression and cache result.
Equations
Instances For
Return Blaster.dite' operator and cache result.
Equations
- Blaster.Optimize.mkBlasterDIteOp = Blaster.Optimize.mkExpr (Lean.mkConst `Blaster.dite' [Lean.levelOne])
Instances For
Return LE const expression and cache result.
Instances For
Return LT const expression and cache result.
Instances For
Return Decidable const expression and cache result.
Equations
- Blaster.Optimize.mkDecidableEqConst = Blaster.Optimize.mkExpr (Lean.mkConst `DecidableEq)
Instances For
Return decide const expression and cache result.
Equations
- Blaster.Optimize.mkDecideConst = Blaster.Optimize.mkExpr (Lean.mkConst `Decidable.decide)
Instances For
Return Blaster.decide' const expression and cache result.
Equations
- Blaster.Optimize.mkBlasterDecideConst = Blaster.Optimize.mkExpr (Lean.mkConst `Blaster.decide')
Instances For
Return instBEqOfDecidableEq const expression and cache result.
Equations
- Blaster.Optimize.mkInstBEqOfDecidableEq = Blaster.Optimize.mkExpr (Lean.mkConst `instBEqOfDecidableEq [Lean.levelZero])
Instances For
Return instDecidableEqNat const expression and cache result.
Equations
- Blaster.Optimize.mkInstDecidableEqNat = Blaster.Optimize.mkExpr (Lean.mkConst `instDecidableEqNat)
Instances For
Return True.intro const expression and cache result.
Equations
- Blaster.Optimize.mkTrueIntro = Blaster.Optimize.mkExpr (Lean.mkConst `True.intro)
Instances For
Return not_false const expression and cache result.
Equations
- Blaster.Optimize.mkNotFalse = Blaster.Optimize.mkExpr (Lean.mkConst `not_false)
Instances For
Return of_decide_eq_true const expression and cache result.
Equations
- Blaster.Optimize.mkOfDecideEqTrue = Blaster.Optimize.mkExpr (Lean.mkConst `of_decide_eq_true)
Instances For
Return of_decide_eq_false const expression and cache result.
Equations
- Blaster.Optimize.mkOfDecideEqFalse = Blaster.Optimize.mkExpr (Lean.mkConst `of_decide_eq_false)
Instances For
Create a Nat.add operator expression and cache result.
Instances For
Create a Nat.sub operator expression and cache result.
Instances For
Create a Nat.mul operator expression and cache result.
Instances For
Creata a Nat.div operator expression and cache result.
Instances For
Create a Nat.mod operator expression and cache result.
Instances For
Create a Nat.pow operator expression and cache result.
Instances For
Create an Int.pow operator expression and cache result.
Instances For
Create an Int.ediv operator expression and cache result.
Instances For
Create an Int.emod operator expression and cache result.
Instances For
Return Int.ofNat constructor and cache result.
Equations
- Blaster.Optimize.mkIntOfNat = Blaster.Optimize.mkExpr (Lean.mkConst `Int.ofNat)
Instances For
mkAppExpr f #[a₀, ..., aₙ] constructs the application f a₀ ... aₙ and cache the result.
Equations
- Blaster.Optimize.mkAppExpr f args = Blaster.Optimize.mkExpr (Lean.mkAppN f args)
Instances For
Return "==" Nat operator and cache result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return the ≤ Nat operator and cache result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return the < Nat operator and cache result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return the ≤ Int operator and cache result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return the < Int operator and cache result.
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
- Blaster.Optimize.mkForallFVars' fvars b = Array.foldrM (fun (v acc : Lean.Expr) => Blaster.Optimize.mkForallFVar v acc) b fvars
Instances For
mkForallExpr n b constructs ∀ n, b and cache result.
Equations
- Blaster.Optimize.mkForallExpr n b = do let __do_lift ← liftM (Blaster.Optimize.mkForallFVar n b) Blaster.Optimize.mkExpr __do_lift
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Blaster.Optimize.mkLambdaFVars' fvars b = Array.foldrM (fun (v acc : Lean.Expr) => Blaster.Optimize.mkLambdaFVar v acc) b fvars
Instances For
mkLambdaExpr n b constructs fun n => b and cache result.
Equations
- Blaster.Optimize.mkLambdaExpr n b = do let __do_lift ← liftM (Blaster.Optimize.mkLambdaFVar n b) Blaster.Optimize.mkExpr __do_lift
Instances For
Return Nat a = b but don't cache result.
Equations
- Blaster.Optimize.mkNatEqExpr a b = do let __do_lift ← Blaster.Optimize.mkEqOp let __do_lift_1 ← Blaster.Optimize.mkNatType pure (Lean.mkApp3 __do_lift __do_lift_1 a b)
Instances For
Return Nat a < b and don't cache result.
Equations
- Blaster.Optimize.mkNatLtExpr a b = do let __do_lift ← Blaster.Optimize.mkNatLtOp pure (Lean.mkApp2 __do_lift a b)
Instances For
Return Nat a ≤ b and don't cache result.
Equations
- Blaster.Optimize.mkNatLeExpr a b = do let __do_lift ← Blaster.Optimize.mkNatLeOp pure (Lean.mkApp2 __do_lift a b)
Instances For
`evalBinNatOp f n1 n2 perform the following:
- let r := f n1 n2
- construct nat literal for
r - cache result and return r
Equations
- Blaster.Optimize.evalBinNatOp f n1 n2 = Blaster.Optimize.mkNatLitExpr (f n1 n2)
Instances For
mkIntLitExpr n constructs and cache an Int literal expression, i.e.,
either Int.ofNat (Expr.lit (Literal.natVal n) or Int.negSucc (Expr.lit (Literal.natVal n).
Equations
- One or more equations did not get rendered due to their size.
- Blaster.Optimize.mkIntLitExpr (Int.negSucc n_2) = do let __do_lift ← Blaster.Optimize.mkNatLitExpr n_2 Blaster.Optimize.mkExpr (Lean.mkApp (Lean.mkConst `Int.negSucc) __do_lift)
Instances For
Return Int a = b and don't cache result.
Equations
- Blaster.Optimize.mkIntEqExpr a b = do let __do_lift ← Blaster.Optimize.mkEqOp let __do_lift_1 ← Blaster.Optimize.mkIntType pure (Lean.mkApp3 __do_lift __do_lift_1 a b)
Instances For
Returns Int a < b and don't cache result.
Equations
- Blaster.Optimize.mkIntLtExpr a b = do let __do_lift ← Blaster.Optimize.mkIntLtOp pure (Lean.mkApp2 __do_lift a b)
Instances For
Return Int a ≤ b and don't cache result.
Equations
- Blaster.Optimize.mkIntLeExpr a b = do let __do_lift ← Blaster.Optimize.mkIntLeOp pure (Lean.mkApp2 __do_lift a b)
Instances For
mkNatNegExpr n constructs and cache the negation of a Nat literal expression, i.e.,
Int.negSucc (Expr.lit (Literal.natVal (n - 1))`.
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
`evalBinIntOp f n1 n2 perform the following:
- let r := f n1 n2
- construct int literal for
r - cache result and return r
Equations
- Blaster.Optimize.evalBinIntOp f n1 n2 = Blaster.Optimize.mkIntLitExpr (f n1 n2)
Instances For
mkDecidableConstraint e constructs constraint [Decidable e] and cache the result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return d if there is already a synthesize instance for cstr in the synthesize cache.
Otherwise, the following actions are performed:
- When
LOption.some d ← trySynthInstance cstr- add
cstr := some dto synthesize cache - return
some d
- add
- When
trySynthInstancedoes not returnLOption.some:- add
cstr := noneto synthesize cache - return
none
- add
Equations
- One or more equations did not get rendered due to their size.
Instances For
Try to find an instance for [Decidable e].
Equations
- Blaster.Optimize.trySynthDecidableInstance? e cacheDecidableCst = do let dCstr ← Blaster.Optimize.mkDecidableConstraint e cacheDecidableCst Blaster.Optimize.trySynthConstraintInstance? dCstr
Instances For
Same as trySynthDecidableInstance but throws an error when a decidable instance cannot be found.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Same as trySynthDecidableInstance but cache and return the queried decidable
constraint when no decidable instance cannot be found.
In fact, after definitions have been unfolded, it can sometimes be the case
that Lean can't infer the proper Decidable instance. In this case, we return the queried decidable
instance.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true only when an instance for [Inhabited n] can be found.
Assume that n is a name expression for an inductive datatype.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true only when an instance for [LawfulBEq t beqInst] can be found.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given an expression c and a boolean value b, perform the following:
let d ← synthDecidableWithNotFound! c
- When b is
true:- return
of_decide_eq_true c d (Eq.refl true)
- return
- Otherwise:
- return
of_decide_eq_false c d (Eq.refl true)
- return
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given f x₁ ... xₙ, return true only when one of the following conditions is satisfied:
- f := BEq.beq with sort parameter that has a LawfulBEq instance
- f := LT.lt with sort parameter in relationalCompatibleTypes
- f : LE.le with sort parameter in relationalCompatibleTypes
In fact, we can't assume that BEq.beq, LT.lt and LE.le will properly be defined
for any user-defined types or parametric inductive types (e.g., List, Option, etc).
Equations
- One or more equations did not get rendered due to their size.
- Blaster.Optimize.isOpaqueRelational f args = pure false
Instances For
Return true if function name f is tagged as an opaque definition.
Equations
- Blaster.Optimize.isOpaqueFun f args = do let __do_lift ← Blaster.Optimize.isOpaqueRelational f args pure (Blaster.Optimize.opaqueFuns.contains f || __do_lift)
Instances For
Same as isOpaqueFun expect that f is an expression.
Equations
- Blaster.Optimize.isOpaqueFunExpr (Lean.Expr.const n us) args = Blaster.Optimize.isOpaqueFun n args
- Blaster.Optimize.isOpaqueFunExpr f args = pure false
Instances For
Return true only when f is a class instance.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true when f is neither a theorem nor a class instance and
is tagged as a well-founded recursive definition.
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
Return the body in a sequence of forall / lambda.
Equations
- Blaster.Optimize.getForallLambdaBody (Lean.Expr.lam binderName binderType b binderInfo) = Blaster.Optimize.getForallLambdaBody b
- Blaster.Optimize.getForallLambdaBody (Lean.Expr.forallE binderName binderType b binderInfo) = Blaster.Optimize.getForallLambdaBody b
- Blaster.Optimize.getForallLambdaBody e = e
Instances For
Return true if n corresponds to a class or is transitively an abbrevation
to a class definition (e.g., DecidableEq, DecidableLT, DecidableRel, etc).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Same as the default getMatcherInfo in the Lean library but also handles casesOn recursor application.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add n := mInfo to isMatcherCache
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return some mInfo when f := Expr.const n l ∧ n := mInfo ∈ isMatcherCache.
Otherwise none.
Equations
- Blaster.Optimize.isMatcher? (Lean.Expr.const n us) = do let __do_lift ← get pure (__do_lift.optEnv.memCache.isMatcherCache.get? n)
- Blaster.Optimize.isMatcher? f = pure none
Instances For
Determine if n corresponds to a partial definition and cache result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Same as the default inferType in the Lean codebase but caches the result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true if e corresponds to a class constraint expression
(see function isClassConstraint).
Equations
- Blaster.Optimize.isClassConstraintExpr e = match e.getAppFn' with | Lean.Expr.const n us => Blaster.Optimize.isClassConstraint n | x => pure false
Instances For
Return true if f corresponds to an inductive type or is an
abbrevation to an inductive type.
Return true if f corresponds to an inductive type or is an
abbrevation to an inductive type.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true if e corresponds to an inductive type or is an abbreviation to an inductive type.
Equations
- Blaster.Optimize.isInductiveTypeExpr e = match e.getAppFn with | Lean.Expr.const n l => Blaster.Optimize.isInductiveType n l | x => pure false
Instances For
- InitExpr (t : Lean.Expr) : ResolveTypeStack
- ArgsExpr (f : Lean.Expr) (args : Array Lean.Expr) (idx stop : Nat) : ResolveTypeStack
Instances For
Same as the default isType but cache result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return true is t is a potential resolvable type
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Return all fvar expressions in e. The return array preserved dependencies between fvars,
i.e., child fvars appear first.
TODO: change function to pure tail rec call using stack-based approach
Instances For
Return true whenever e satisfies one of the following:
eis a sort type;eis a const or variable of sort type;eis an application that transitively has at least one argument of sort type.
Type to represent the parameters instantiating the implicit arguments for a given function.
(see function getImplicitParameters)
- effectiveArg : Lean.Expr
Corresponds to an effective parameter for a given function (implicit or not).
- isInstance : Bool
Flag set to
truewhen the effective parameter instantiates an implicit parameter. - isGeneric : Bool
Flag set to
truewhen the effective parameter instantiates an implicit parameter but is still polymorphic, i.e., predicateisGenericParamis satisfied.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Instances For
Helper function for retrieveGenericFVars and retrieveGenericArgs -
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given arguments params obtained from getImplicitParameters, perform the following:
let V := #[α | i ∈ [0..n] ∧ α ∈ getFVarsInExpr params[i] ∧ params[i].isGeneric]
return V
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given params an implicit parameters perform the following:
let genArgs ← retrieveGenericFVars
let P := #[ params[i].effectiveArgs | i ∈ [0..params.size-1] ∧ ¬ params[i].isInstance ]
return genArgs ++ P
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a fun body λ α₀ → ... λ αₙ → body and params the implicit parameters info
for the corresponding function, perform the following actions:
- let A := [α₀, ..., αₙ]
- let B := [ A[i] | i ∈ [0..n] ∧ ¬ params[i].isInstance ]
- let S := [ A[i] | i ∈ [0..n] ∧ params[i].isInstance ]
- let R := [ params[i].effectiveArg | i ∈ [0..n] ∧ params[i].isInstance ]
- let β₀, .., βₘ = B
- return
λ β₀ → ... λ βₘ → body [S[0]/R[0]] ... [S[k]/R[k]]with k = S.size-1
Assume that params.size ≤ n TODO: change function to pure tail rec call using stack-based approach
Equations
- Blaster.Optimize.specializeLambda fbody params = Blaster.Optimize.specializeLambda.visit params 0 (Array.size params) fbody fun (e : Lean.Expr) => e
Instances For
Given f a function name expression, params its implicit parameters info (see getImplicitParameters),
and fbody corresponding the recursive definition for f, perform the following actions:
- let fbody' be
fbodyin which the recurisve call is annotated with_solver.recursivecall - When ∀ i ∈ [0..params.size-1], ¬ params[i].isInstance:
- return fbody'
- Otherwise:
- let genFVars ← retrieveGenericFVars params
- return mkLambdaFVars genFVars (specializeLambda fbody' params) (usedOnly := true)
An error is triggered when
fis not a name expression.
Equations
- One or more equations did not get rendered due to their size.
- Blaster.Optimize.generalizeRecCall f params fbody = Blaster.Optimize.throwEnvError (Lean.toMessageData "generalizeRecCall: name expression expected but got " ++ Lean.toMessageData (reprStr f))
Instances For
Equations
- Blaster.Optimize.generalizeRecCall.replacePred n e = match e.getAppFn with | Lean.Expr.const rn us => if (rn == n) = true then some (Blaster.Optimize.tagAsRecursiveCall e) else none | x => none
Instances For
Given f which is either a function name expression or a fully/partially instantiated polymorphic function (see getInstApp),
and fbody corresponding to f's definition, update the recursive instance cache (i.e., recFunInstCache),
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return fₙ if body[mkAnnotation _solver.recursivecall _'/_recFun α₁ ... αₖ x₁ ... xₙ] := fₙ` is already
in the recursive function map.
Otherwise,
- update recursive function map with
body[mkAnnotation_solver.recursivecall _'/_recFun α₁ ... αₖ x₁ ... xₙ] := f` - return
f. where: - α₁ ... αₖ
correspond to the implicit arguments off` that are still polymorphic (if any). x₁ ... xₙcorrespond to the effective parameters of the recursive call (excluding implicit arguments). NOTE:fis also removed from the visiting cache.- The polymorphic instance cache is updated with
f := body[mkAnnotation_solver.recursivecall _'/_recFun α₁ ... αₖ x₁ ... xₙ]` (if required) for all cases. This is essential to avoid performing structural equivalence check again on an already handled recursive function. Assumes that: fis either a function name expression or a fully/partially instantiated polymorphic function (seegetInstApp)- an entry exists for each opaque recursive function in
recFunMapbefore optimization is performed (see functioncacheOpaqueRecFun).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given instApp corresponding either to a function name expression or
to a fully/partially instantiated polymorphic function (see function getInstApp),
determine if instApp has already a mapping in recFunInstCache. If so then retrieve the corresponding
function application in recFunMap. Otherwise return none.
An error is triggered if no corresponding entry can be found in recFunMap.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns all axioms only defined in current module.
Equations
- One or more equations did not get rendered due to their size.