Lean2Js.Cost
How much fuel a program can possibly need #
How much fuel a program can possibly need. Fuel counts the nesting of the expression being evaluated and
the depth of the call stack, and nothing else: the traversals (evalArgs, evalMapItems and the four
beside it) hand the rest of the list the same fuel they were given, so a longer array costs nothing.
That leaves the call stack, and the subset is built so that it cannot grow without end. A call from the
declaration at index i lands on a declaration at an index below i -- directly, because callsPrecede
refuses a call that does not go backwards, and through a function-typed parameter, because a function
argument has to be a declared function named before the callee. So the depth is at most the number of
declarations, and each level costs at most the deepest body in the program.
The conditions are collected in progOk, a Bool the emitter checks once per program rather than a
hypothesis a caller has to discharge.
Depth #
The fuel one expression needs before any call is followed. evalExpr spends one on every node and hands
f to each of the parts, so this is the height of the tree.
Lean2Js.Cost.exprDepth
sourceEquations
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.lit l) = 1
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.var name) = 1
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.fnRef name) = 1
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.noneE elem) = 1
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.un op x_1) = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.strUn op x_1) = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth x_1.someE = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.okE err x_1) = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.errorE ok x_1) = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth (x_1.proj field) = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth x_1.length = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth x_1.arrayReverse = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth x_1.dictKeys = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth x_1.dictValues = 1 + Lean2Js.Cost.exprDepth x_1
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.bin op a b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.strBin op a b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.index b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.dictGet b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.dictHas b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.dictDelete b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.letE name ty a b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.mapE binder b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.filterE binder b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.findE binder b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.quantE op a binder b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.sortByKeyE binder b) = 1 + max (Lean2Js.Cost.exprDepth a) (Lean2Js.Cost.exprDepth b)
- Lean2Js.Cost.exprDepth (a.cond b c) = 1 + max (Lean2Js.Cost.exprDepth a) (max (Lean2Js.Cost.exprDepth b) (Lean2Js.Cost.exprDepth c))
- Lean2Js.Cost.exprDepth (a.substring b c) = 1 + max (Lean2Js.Cost.exprDepth a) (max (Lean2Js.Cost.exprDepth b) (Lean2Js.Cost.exprDepth c))
- Lean2Js.Cost.exprDepth (a.arraySlice b c) = 1 + max (Lean2Js.Cost.exprDepth a) (max (Lean2Js.Cost.exprDepth b) (Lean2Js.Cost.exprDepth c))
- Lean2Js.Cost.exprDepth (a.dictSet b c) = 1 + max (Lean2Js.Cost.exprDepth a) (max (Lean2Js.Cost.exprDepth b) (Lean2Js.Cost.exprDepth c))
- Lean2Js.Cost.exprDepth (a.reduceE b accName elemName c) = 1 + max (Lean2Js.Cost.exprDepth a) (max (Lean2Js.Cost.exprDepth b) (Lean2Js.Cost.exprDepth c))
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.call fn args) = 1 + Lean2Js.Cost.exprDepthList args
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.ctor typeName tyArgs ctorName args) = 1 + Lean2Js.Cost.exprDepthList args
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.arrayLit elem args) = 1 + Lean2Js.Cost.exprDepthList args
- Lean2Js.Cost.exprDepth (Lean2Js.Core.Expr.dictLit value obj entries) = 1 + Lean2Js.Cost.exprDepthEntries entries
- Lean2Js.Cost.exprDepth (scrut.matchE alts) = 1 + max (Lean2Js.Cost.exprDepth scrut) (Lean2Js.Cost.exprDepthAlts alts)
- Lean2Js.Cost.exprDepth (scrut.foldE typeName tyArgs result alts) = 1 + max (Lean2Js.Cost.exprDepth scrut) (Lean2Js.Cost.exprDepthAlts alts)
Instances For
Used by
Lean2Js.Cost.exprDepthList
sourceEquations
- Lean2Js.Cost.exprDepthList [] = 0
- Lean2Js.Cost.exprDepthList (e :: rest) = max (Lean2Js.Cost.exprDepth e) (Lean2Js.Cost.exprDepthList rest)
Instances For
Used by
Lean2Js.Cost.exprDepthAlts
sourceEquations
- Lean2Js.Cost.exprDepthAlts [] = 0
- Lean2Js.Cost.exprDepthAlts (a :: rest) = max (Lean2Js.Cost.exprDepth a.snd) (Lean2Js.Cost.exprDepthAlts rest)
Instances For
Used by
Lean2Js.Cost.exprDepthEntries
sourceEquations
Instances For
Used by
Lean2Js.Cost.maxBodyDepth
sourceEquations
- Lean2Js.Cost.maxBodyDepth [] = 0
- Lean2Js.Cost.maxBodyDepth (d :: rest) = max (Lean2Js.Cost.exprDepth d.body) (Lean2Js.Cost.maxBodyDepth rest)
Instances For
Used by
Lean2Js.Cost.callStep
sourceWhat one level of the call stack costs: the deepest body, plus the node the call itself spends.
Equations
Instances For
Used by
Lean2Js.Cost.cost
sourceThe fuel no evaluation of this program can outrun: the deepest body, plus one level per declaration.
Equations
Instances For
Used by
Where a name is declared #
Program.find? answers with the declaration; the proof needs its position too, since that is what
decreases at every call.
Lean2Js.Cost.declAtFrom
sourceEquations
Instances For
Used by
Lean2Js.Cost.declAt?
sourceEquations
- Lean2Js.Cost.declAt? p name = Lean2Js.Cost.declAtFrom 0 p.decls name
Instances For
Used by
Lean2Js.Cost.fnBefore
sourceEquations
Instances For
Used by
The conditions #
bodyOk is Compile.callsPrecede -- every call and function reference goes backwards -- together with
the two restrictions that keep a function value from reaching a call site the check has not seen:
a fnRef may only stand as an argument, and a function-typed parameter may only be called, never read.
The parameter it stands in for has to be function-typed, which is what makes the callee's environment say which of its names can hold a function at all.
Lean2Js.Cost.notFnRef
sourceWhether an argument is anything but a function reference. A function reference is the only shape a function-typed parameter may be given, and the only expression that answers with a function.
Equations
Instances For
Used by
Lean2Js.Cost.argFnOk
sourceThe condition on one argument of a call to the declaration at index j: a function reference has to
stand at a function-typed parameter and name a declaration before j.
Equations
- Lean2Js.Cost.argFnOk p j pm (Lean2Js.Core.Expr.fnRef name) = (pm.ty.isFn && Lean2Js.Cost.fnBefore p j name)
- Lean2Js.Cost.argFnOk p j pm x✝ = true
Instances For
Used by
Lean2Js.Cost.fnRefArgsOk
sourceEquations
- Lean2Js.Cost.fnRefArgsOk p j [] [] = true
- Lean2Js.Cost.fnRefArgsOk p j (pm :: ps) (a :: rest) = (Lean2Js.Cost.argFnOk p j pm a && Lean2Js.Cost.fnRefArgsOk p j ps rest)
- Lean2Js.Cost.fnRefArgsOk p j x✝¹ x✝ = false
Instances For
Used by
Lean2Js.Cost.bodyOk
sourcefns are the names that may hold a function value: the function-typed parameters of the declaration
whose body this is. A shadowed one stays in the list, so a body that rebinds such a name and reads the
rebinding is refused; erasing it on the way in would take a binders walk over patterns to buy a program
nobody writes.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.lit l) = true
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.noneE elem) = true
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.var x_1) = !fns.contains x_1
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.fnRef name) = false
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.un op x_1) = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.strUn op x_1) = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns x_1.someE = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.okE err x_1) = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.errorE ok x_1) = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns (x_1.proj field) = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns x_1.length = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns x_1.arrayReverse = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns x_1.dictKeys = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns x_1.dictValues = Lean2Js.Cost.bodyOk p i fns x_1
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.bin op a b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.strBin op a b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.index b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.dictGet b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.dictHas b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.dictDelete b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.letE name ty a b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.mapE binder b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.filterE binder b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.findE binder b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.quantE op a binder b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.sortByKeyE binder b) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b)
- Lean2Js.Cost.bodyOk p i fns (a.cond b c) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b && Lean2Js.Cost.bodyOk p i fns c)
- Lean2Js.Cost.bodyOk p i fns (a.substring b c) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b && Lean2Js.Cost.bodyOk p i fns c)
- Lean2Js.Cost.bodyOk p i fns (a.arraySlice b c) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b && Lean2Js.Cost.bodyOk p i fns c)
- Lean2Js.Cost.bodyOk p i fns (a.dictSet b c) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b && Lean2Js.Cost.bodyOk p i fns c)
- Lean2Js.Cost.bodyOk p i fns (a.reduceE b accName elemName c) = (Lean2Js.Cost.bodyOk p i fns a && Lean2Js.Cost.bodyOk p i fns b && Lean2Js.Cost.bodyOk p i fns c)
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.ctor typeName tyArgs ctorName args) = Lean2Js.Cost.bodyOkList p i fns args
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.arrayLit elem args) = Lean2Js.Cost.bodyOkList p i fns args
- Lean2Js.Cost.bodyOk p i fns (Lean2Js.Core.Expr.dictLit value obj entries) = Lean2Js.Cost.bodyOkEntries p i fns entries
- Lean2Js.Cost.bodyOk p i fns (scrut.matchE alts) = (Lean2Js.Cost.bodyOk p i fns scrut && Lean2Js.Cost.bodyOkAlts p i fns alts)
- Lean2Js.Cost.bodyOk p i fns (scrut.foldE typeName tyArgs result alts) = (Lean2Js.Cost.bodyOk p i fns scrut && Lean2Js.Cost.bodyOkAlts p i fns alts)
Instances For
Used by
Lean2Js.Cost.bodyOkList
sourceEquations
- Lean2Js.Cost.bodyOkList p i fns [] = true
- Lean2Js.Cost.bodyOkList p i fns (e :: rest) = (Lean2Js.Cost.bodyOk p i fns e && Lean2Js.Cost.bodyOkList p i fns rest)
Instances For
Used by
Lean2Js.Cost.bodyOkArgs
sourceEquations
- Lean2Js.Cost.bodyOkArgs p i fns [] = true
- Lean2Js.Cost.bodyOkArgs p i fns (e :: rest) = ((!Lean2Js.Cost.notFnRef e || Lean2Js.Cost.bodyOk p i fns e) && Lean2Js.Cost.bodyOkArgs p i fns rest)
Instances For
Used by
Lean2Js.Cost.bodyOkAlts
sourceEquations
- Lean2Js.Cost.bodyOkAlts p i fns [] = true
- Lean2Js.Cost.bodyOkAlts p i fns (a :: rest) = (Lean2Js.Cost.bodyOk p i fns a.snd && Lean2Js.Cost.bodyOkAlts p i fns rest)
Instances For
Used by
Lean2Js.Cost.bodyOkEntries
sourceEquations
- Lean2Js.Cost.bodyOkEntries p i fns [] = true
- Lean2Js.Cost.bodyOkEntries p i fns (e :: rest) = (Lean2Js.Cost.bodyOk p i fns e.snd && Lean2Js.Cost.bodyOkEntries p i fns rest)
Instances For
Used by
Lean2Js.Cost.declFns
sourceEquations
- Lean2Js.Cost.declFns d = List.filterMap (fun (pm : Lean2Js.Core.Param) => if pm.ty.isFn = true then some pm.name else none) d.params
Instances For
Used by
Lean2Js.Cost.declsOk
sourceEquations
- Lean2Js.Cost.declsOk p x✝ [] = true
- Lean2Js.Cost.declsOk p x✝ (d :: rest) = (Lean2Js.Cost.bodyOk p x✝ (Lean2Js.Cost.declFns d) d.body && Lean2Js.Cost.declsOk p (x✝ + 1) rest)
Instances For
Used by
Lean2Js.Cost.tyFirstOrder
sourceA type with no function in it. The entry check is what fixes the shape of the arguments a public function starts with, and it can only rule out a function value where the type cannot hide one.
Equations
- Lean2Js.Cost.tyFirstOrder Lean2Js.Core.Ty.bool = true
- Lean2Js.Cost.tyFirstOrder Lean2Js.Core.Ty.int53 = true
- Lean2Js.Cost.tyFirstOrder Lean2Js.Core.Ty.uint32 = true
- Lean2Js.Cost.tyFirstOrder Lean2Js.Core.Ty.string = true
- Lean2Js.Cost.tyFirstOrder Lean2Js.Core.Ty.bigint = true
- Lean2Js.Cost.tyFirstOrder (Lean2Js.Core.Ty.var name) = true
- Lean2Js.Cost.tyFirstOrder t.option = Lean2Js.Cost.tyFirstOrder t
- Lean2Js.Cost.tyFirstOrder t.array = Lean2Js.Cost.tyFirstOrder t
- Lean2Js.Cost.tyFirstOrder t.dict = Lean2Js.Cost.tyFirstOrder t
- Lean2Js.Cost.tyFirstOrder t.dictObj = Lean2Js.Cost.tyFirstOrder t
- Lean2Js.Cost.tyFirstOrder (ok.result err) = (Lean2Js.Cost.tyFirstOrder ok && Lean2Js.Cost.tyFirstOrder err)
- Lean2Js.Cost.tyFirstOrder (Lean2Js.Core.Ty.named n args) = Lean2Js.Cost.tyFirstOrderList args
- Lean2Js.Cost.tyFirstOrder (Lean2Js.Core.Ty.fn params ret) = false
Instances For
Used by
Lean2Js.Cost.tyFirstOrderList
sourceEquations
Instances For
Used by
Lean2Js.Cost.typesFirstOrder
sourceThe declared field types the entry check walks into. A function value can only be turned away where the type it is checked against cannot hide one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Cost.paramTyOk
sourceA function type is allowed on a parameter and nowhere inside one, which is Compile.wfParamTy.
Equations
- Lean2Js.Cost.paramTyOk (Lean2Js.Core.Ty.fn params ret) = (Lean2Js.Cost.tyFirstOrderList params && Lean2Js.Cost.tyFirstOrder ret)
- Lean2Js.Cost.paramTyOk ty = Lean2Js.Cost.tyFirstOrder ty
Instances For
Used by
Lean2Js.Cost.declParamsOk
sourceEquations
- Lean2Js.Cost.declParamsOk d = d.params.all fun (pm : Lean2Js.Core.Param) => Lean2Js.Cost.paramTyOk pm.ty
Instances For
Used by
Lean2Js.Cost.progOk
sourceEverything the fuel bound rests on, as one Bool the emitter runs once per program.
Equations
Instances For
Used by
Function values #
The invariant the proof carries: a function value is only ever bound to a function-typed parameter, and the declaration it names comes before the one whose body is running. Nothing else in a value is a function, which is what keeps a function from being smuggled into a call through an array.
Lean2Js.Cost.noFn
sourceEquations
- Lean2Js.Cost.noFn (Lean2Js.Value.bool b) = true
- Lean2Js.Cost.noFn (Lean2Js.Value.int53 i) = true
- Lean2Js.Cost.noFn (Lean2Js.Value.uint32 n) = true
- Lean2Js.Cost.noFn (Lean2Js.Value.str s) = true
- Lean2Js.Cost.noFn (Lean2Js.Value.bigint i) = true
- Lean2Js.Cost.noFn (Lean2Js.Value.obj ctor fields) = Lean2Js.Cost.noFnFields fields
- Lean2Js.Cost.noFn (Lean2Js.Value.arr xs) = Lean2Js.Cost.noFnList xs
- Lean2Js.Cost.noFn (Lean2Js.Value.dict entries) = Lean2Js.Cost.noFnFields entries
- Lean2Js.Cost.noFn (Lean2Js.Value.fn name) = false
Instances For
Used by
Lean2Js.Cost.noFnList
sourceEquations
- Lean2Js.Cost.noFnList [] = true
- Lean2Js.Cost.noFnList (v :: rest) = (Lean2Js.Cost.noFn v && Lean2Js.Cost.noFnList rest)
Instances For
Used by
Lean2Js.Cost.noFnFields
sourceEquations
- Lean2Js.Cost.noFnFields [] = true
- Lean2Js.Cost.noFnFields (e :: rest) = (Lean2Js.Cost.noFn e.snd && Lean2Js.Cost.noFnFields rest)
Instances For
Used by
Lean2Js.Cost.EnvOk
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Reading a declaration's position back #
Lean2Js.Cost.declAtFrom_find
sourceUsed by
Lean2Js.Cost.declAt?_find
sourceUsed by
Lean2Js.Cost.declAtFrom_depth
sourceUsed by
Lean2Js.Cost.declAt?_depth
sourceUsed by
Lean2Js.Cost.declAtFrom_lt
sourceUsed by
Lean2Js.Cost.declAt?_lt
sourceUsed by
Lean2Js.Cost.declsOkFrom_bodyOk
sourceUsed by
Lean2Js.Cost.declAt?_bodyOk
sourceUsed by
Values that hold no function #
Lean2Js.Cost.except_bind_ok
sourceUsed by
Lean2Js.Cost.except_bind_ne
sourceUsed by
Lean2Js.Cost.noFnList_iff
sourceUsed by
Lean2Js.Cost.noFnFields_iff
sourceUsed by
Lean2Js.Cost.noFn_arr
sourceUsed by
Lean2Js.Cost.noFn_lookupFieldV
sourceUsed by
Lean2Js.Cost.noFn_obj
sourceUsed by
Lean2Js.Cost.noFn_dict
sourceUsed by
Lean2Js.Cost.arr_noFn
sourceUsed by
Lean2Js.Cost.obj_noFn
sourceUsed by
Lean2Js.Cost.dict_noFn
sourceUsed by
Lean2Js.Cost.noFn_litValue
sourceUsed by
Lean2Js.Cost.noFn_mkInt53
sourceUsed by
Lean2Js.Cost.noFn_applyUn
sourceUsed by
Lean2Js.Cost.noFn_applyArith
sourceUsed by
Lean2Js.Cost.noFn_compareValues
sourceUsed by
Lean2Js.Cost.noFn_applyMinMax
sourceUsed by
Lean2Js.Cost.noFn_applyBin
sourceUsed by
Lean2Js.Cost.noFn_applyStrUn
sourceUsed by
Lean2Js.Cost.noFn_applyStrBin
sourceUsed by
Lean2Js.Cost.noFn_sliceStr
sourceUsed by
Lean2Js.Cost.noFn_sliceArr
sourceUsed by
Lean2Js.Cost.noFn_asBool
sourceUsed by
Lean2Js.Cost.noFn_dictLookup
sourceUsed by
Lean2Js.Cost.noFn_dictWith
sourceUsed by
Running without running out #
Safe r P is the pair of facts the induction carries: r is not what running out of fuel looks like,
and if it answered, the answer holds no function. Both travel through do the same way, so every case
is one Safe.bind' per part.
Lean2Js.Cost.Safe
sourceEquations
- Lean2Js.Cost.Safe r P = (r ≠ Except.error Lean2Js.Err.outOfFuel ∧ ∀ (v : α), r = Except.ok v → P v)
Instances For
Used by
Lean2Js.Cost.Safe.ok'
sourceUsed by
Lean2Js.Cost.Safe.err
sourceUsed by
Lean2Js.Cost.Safe.bind'
sourceUsed by
Lean2Js.Cost.Safe.weaken
sourceUsed by
Lean2Js.Cost.safe_mkInt53
sourceUsed by
Lean2Js.Cost.safe_applyUn
sourceUsed by
Lean2Js.Cost.safe_applyArith
sourceUsed by
Lean2Js.Cost.safe_compareValues
sourceUsed by
Lean2Js.Cost.safe_applyMinMax
sourceUsed by
Lean2Js.Cost.safe_applyBin
sourceUsed by
Lean2Js.Cost.safe_applyStrUn
sourceUsed by
Lean2Js.Cost.safe_applyStrBin
sourceUsed by
Lean2Js.Cost.safe_sliceStr
sourceUsed by
Lean2Js.Cost.safe_sliceArr
sourceUsed by
Lean2Js.Cost.safe_asBool
sourceUsed by
Environments #
Lean2Js.Cost.lookup_cons
sourceUsed by
Lean2Js.Cost.lookup_append_cases
sourceUsed by
Lean2Js.Cost.lookup_noFn
sourceUsed by
Lean2Js.Cost.envOk_cons
sourceUsed by
Lean2Js.Cost.envOk_append
sourceUsed by
What a pattern binds #
Lean2Js.Cost.matchPat_noFn
sourceUsed by
Lean2Js.Cost.matchPats_noFn
sourceUsed by
Lean2Js.Cost.firstMatch_noFn
sourceUsed by
Lean2Js.Cost.firstMatch_body
sourceUsed by
Reading the checks back #
Lean2Js.Cost.exprDepth_pos
sourceUsed by
Lean2Js.Cost.exprDepthList_mem
sourceUsed by
Lean2Js.Cost.exprDepthAlts_mem
sourceUsed by
Lean2Js.Cost.exprDepthEntries_mem
sourceUsed by
Lean2Js.Cost.bodyOkAlts_mem
sourceUsed by
Lean2Js.Cost.declAtFrom_none
sourceUsed by
Lean2Js.Cost.declAt?_none
sourceUsed by
Lean2Js.Cost.fnBefore_inv
sourceUsed by
The value a call binds to a parameter #
Lean2Js.Cost.ArgVal
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Cost.ArgsVals
sourceEquations
- Lean2Js.Cost.ArgsVals p j (pm :: ps) (v :: vs) = (Lean2Js.Cost.ArgVal p j pm.ty.isFn v ∧ Lean2Js.Cost.ArgsVals p j ps vs)
- Lean2Js.Cost.ArgsVals p j x✝¹ x✝ = True
Instances For
Used by
Lean2Js.Cost.bindParams_nil_left
sourceUsed by
Lean2Js.Cost.bindParams_nil_right
sourceUsed by
Lean2Js.Cost.fnRefArgsOk_nil_cons
sourceUsed by
Lean2Js.Cost.fnRefArgsOk_cons
sourceUsed by
Lean2Js.Cost.bodyOkArgs_cons
sourceUsed by
Lean2Js.Cost.argsVals_nil_right
sourceUsed by
Lean2Js.Cost.envOk_bindParams
sourceUsed by
Lean2Js.Cost.declFns_mem
sourceUsed by
Lean2Js.Cost.bindParams_mem
sourceUsed by
Lean2Js.Cost.envOk_of_noFn
sourceUsed by
Lean2Js.Cost.calleeOf_cases
sourceUsed by
Lean2Js.Cost.safe_typeError
sourceUsed by
Lean2Js.Cost.safe_unknownVar
sourceUsed by
Lean2Js.Cost.safe_unknownFn
sourceUsed by
Lean2Js.Cost.safe_arity
sourceUsed by
Lean2Js.Cost.safe_indexOutOfBounds
sourceUsed by
Lean2Js.Cost.safe_noMatch
sourceUsed by
Lean2Js.Cost.noFn_wrap
sourceUsed by
Lean2Js.Cost.zip_snd_mem
sourceUsed by
Lean2Js.Cost.getElem?_mem
sourceUsed by
Lean2Js.Cost.bodyOkEntries_map
sourceUsed by
Lean2Js.Cost.exprDepthEntries_map
sourceUsed by
Lean2Js.Cost.bodyOkArg_not_fnRef
sourceUsed by
Lean2Js.Cost.safe_arg
sourceUsed by
Lean2Js.Cost.eval_safe
sourceEnough fuel and the reference semantics never runs out of it, and the answer it gives holds no
function value. The induction is on the fuel, so a call is reached at a strictly smaller one; what makes
that terminate is the index of the declaration being entered, which bodyOk keeps going down.
Used by
The arguments a public function starts with #
evalCall lets a value into the body only if it has the declared type. That is what rules a function
value out at the entry -- but only where the type cannot hide one, which is why progOk asks the
declared field types to be first order too.
Lean2Js.Cost.tyFirstOrder_subst
sourceUsed by
Lean2Js.Cost.tyFirstOrderList_subst
sourceUsed by
Lean2Js.Cost.tyFirstOrderList_mem
sourceUsed by
Lean2Js.Cost.ctorAt_field_firstOrder
sourceUsed by
Lean2Js.Cost.hasTy_noFn
sourceUsed by
Lean2Js.Cost.hasFieldTys_noFn
sourceUsed by
Lean2Js.Cost.hasElemTy_noFn
sourceUsed by
Lean2Js.Cost.hasEntryTys_noFn
sourceUsed by
What the shipped fuel buys #
Lean2Js.Cost.declAtFrom_of_find
sourceUsed by
Lean2Js.Cost.declAt?_of_find
sourceUsed by
Lean2Js.Cost.paramTyOk_firstOrder
sourceUsed by
Lean2Js.Cost.bindParams_noFn
sourceUsed by
Lean2Js.Cost.evalCall_ne_outOfFuel
sourceThe fuel the artifact runs at is enough for every call the program can make: a program that passes
progOk and whose cost fits in defaultFuel never answers outOfFuel to a call whose arguments the
entry check can read.