Equations
- Lean.instInhabitedLiteral = { default := Lean.Literal.natVal default }
Equations
- Lean.instBEqLiteral = { beq := [anonymous] }
Equations
- Lean.instReprLiteral = { reprPrec := [anonymous] }
Equations
- Lean.Literal.hash _fun_discr = match _fun_discr with | Lean.Literal.natVal v => hash v | Lean.Literal.strVal v => hash v
Equations
- Lean.instHashableLiteral = { hash := Lean.Literal.hash }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.instLTLiteral = { lt := fun a b => Lean.Literal.lt a b = true }
Equations
- default: Lean.BinderInfo
- implicit: Lean.BinderInfo
- strictImplicit: Lean.BinderInfo
- instImplicit: Lean.BinderInfo
- auxDecl: Lean.BinderInfo
Arguments in forallE binders can be labelled as implicit or explicit.
Each lam
or forallE
binder comes with a binderInfo
argument (stored in ExprData).
This can be set to
default
--(x : α)
implicit
--{x : α}
strict_implicit
--⦃x : α⦄
inst_implicit
--[x : α]
.aux_decl
-- Auxillary definitions are helper methods that Lean generates.aux_decl
is used for_match
,_fun_match
,_let_match
and the self reference that appears in recursive pattern matching.
The difference between implicit {}
and strict-implicit ⦃⦄
is how
implicit arguments are treated that are not followed by explicit arguments.
{}
arguments are applied eagerly, while ⦃⦄
arguments are left partially applied:
def foo {x : Nat} : Nat := x
def bar ⦃x : Nat⦄ : Nat := x
#check foo -- foo : Nat
#check bar -- bar : ⦃x : Nat⦄ → Nat
See also the Lean manual: https://leanprover.github.io/lean4/doc/expressions.html#implicit-arguments
Equations
- Lean.instInhabitedBinderInfo = { default := Lean.BinderInfo.default }
Equations
- Lean.instBEqBinderInfo = { beq := [anonymous] }
Equations
- Lean.instReprBinderInfo = { reprPrec := [anonymous] }
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.
Equations
- Lean.instHashableBinderInfo = { hash := Lean.BinderInfo.hash }
Equations
- Lean.BinderInfo.isInstImplicit _fun_discr = match _fun_discr with | Lean.BinderInfo.instImplicit => true | x => false
Equations
- Lean.BinderInfo.isImplicit _fun_discr = match _fun_discr with | Lean.BinderInfo.implicit => true | x => false
Equations
- Lean.BinderInfo.isStrictImplicit _fun_discr = match _fun_discr with | Lean.BinderInfo.strictImplicit => true | x => false
Equations
- Lean.BinderInfo.isAuxDecl _fun_discr = match _fun_discr with | Lean.BinderInfo.auxDecl => true | x => false
Expression metadata. Used with the Expr.mdata
constructor.
Equations
Cached hash code, cached results, and other data for Expr
.
hash : 32-bits
hasFVar : 1-bit -- does it contain free variables?
hasExprMVar : 1-bit -- does it contain metavariables?
hasLevelMVar : 1-bit -- does it contain level metavariables?
hasLevelParam : 1-bit -- does it contain level parameters?
nonDepLet : 1-bit -- internal flag, for tracking whether let x := v; b is equivalent to (fun x => b) v
binderInfo : 3-bits -- encoding of BinderInfo
approxDepth : 8-bits -- the approximate depth is used to minimize the number of hash collisions
looseBVarRange : 16-bits
Equations
Equations
Equations
- Lean.instBEqData_1 = { beq := fun a b => a == b }
Equations
- Lean.Expr.Data.approxDepth c = UInt64.toUInt8 (UInt64.land (UInt64.shiftRight c 40) 255)
Equations
Equations
- Lean.Expr.Data.hasFVar c = (UInt64.land (UInt64.shiftRight c 32) 1 == 1)
Equations
- Lean.Expr.Data.hasExprMVar c = (UInt64.land (UInt64.shiftRight c 33) 1 == 1)
Equations
- Lean.Expr.Data.hasLevelMVar c = (UInt64.land (UInt64.shiftRight c 34) 1 == 1)
Equations
- Lean.Expr.Data.hasLevelParam c = (UInt64.land (UInt64.shiftRight c 35) 1 == 1)
Equations
- Lean.Expr.Data.nonDepLet c = (UInt64.land (UInt64.shiftRight c 36) 1 == 1)
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.
Equations
- One or more equations did not get rendered due to their size.
Optimized version of Expr.mkData
for applications.
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.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.instInhabitedFVarId = { default := { name := default } }
Equations
- Lean.instBEqFVarId = { beq := [anonymous] }
Equations
- Lean.instHashableFVarId = { hash := [anonymous] }
Equations
- Lean.instReprFVarId = { reprPrec := fun n p => reprPrec n.name p }
Equations
- Lean.FVarIdSet = Std.RBTree Lean.FVarId fun a a_1 => Lean.Name.quickCmp a.name a_1.name
Equations
- Lean.instForInFVarIdSetFVarId = inferInstanceAs (ForIn m (Std.RBTree Lean.FVarId fun a a_1 => Lean.Name.quickCmp a.name a_1.name) Lean.FVarId)
Equations
- Lean.FVarIdMap α = Std.RBMap Lean.FVarId α fun a a_1 => Lean.Name.quickCmp a.name a_1.name
Equations
- Lean.instEmptyCollectionFVarIdMap = inferInstanceAs (EmptyCollection (Std.RBMap Lean.FVarId α fun a a_1 => Lean.Name.quickCmp a.name a_1.name))
- bvar: Nat → Lean.Expr.Data → Lean.Expr
- fvar: Lean.FVarId → Lean.Expr.Data → Lean.Expr
- mvar: Lean.MVarId → Lean.Expr.Data → Lean.Expr
- sort: Lean.Level → Lean.Expr.Data → Lean.Expr
- const: Lean.Name → List Lean.Level → Lean.Expr.Data → Lean.Expr
- app: Lean.Expr → Lean.Expr → Lean.Expr.Data → Lean.Expr
- lam: Lean.Name → Lean.Expr → Lean.Expr → Lean.Expr.Data → Lean.Expr
- forallE: Lean.Name → Lean.Expr → Lean.Expr → Lean.Expr.Data → Lean.Expr
- letE: Lean.Name → Lean.Expr → Lean.Expr → Lean.Expr → Lean.Expr.Data → Lean.Expr
- lit: Lean.Literal → Lean.Expr.Data → Lean.Expr
- mdata: Lean.MData → Lean.Expr → Lean.Expr.Data → Lean.Expr
- proj: Lean.Name → Nat → Lean.Expr → Lean.Expr.Data → Lean.Expr
Equations
- Lean.instInhabitedExpr = { default := Lean.Expr.bvar default default }
Equations
- Lean.instReprExpr = { reprPrec := [anonymous] }
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.
Equations
Equations
- Lean.Expr.instHashableExpr = { hash := Lean.Expr.hash }
Equations
Equations
Equations
Does the expression contain level or expression metavariables?
Equations
- Lean.Expr.hasMVar e = let d := Lean.Expr.data e; Lean.Expr.Data.hasExprMVar d || Lean.Expr.Data.hasLevelMVar d
Equations
Equations
The range of de-Bruijn variables that are loose.
That is, bvars that are not bound by a binder.
For example, bvar i
has range i + 1
and
an expression with no loose bvars has range 0
.
Equations
Equations
Equations
- Lean.Expr.hashEx = hash
Equations
Equations
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Literal.type _fun_discr = match _fun_discr with | Lean.Literal.natVal val => Lean.mkConst `Nat | Lean.Literal.strVal val => Lean.mkConst `String
Equations
Equations
- Lean.mkBVar idx = Lean.Expr.bvar idx (Lean.Expr.mkData (mixHash 7 (hash idx)) (idx + 1) 0 false false false false Lean.BinderInfo.default)
Equations
- Lean.mkSort lvl = Lean.Expr.sort lvl (Lean.Expr.mkData (mixHash 11 (hash lvl)) 0 0 false false (Lean.Level.hasMVar lvl) (Lean.Level.hasParam lvl) Lean.BinderInfo.default)
Equations
- Lean.mkFVar fvarId = Lean.Expr.fvar fvarId (Lean.Expr.mkData (mixHash 13 (hash fvarId)) 0 0 true false false false Lean.BinderInfo.default)
Equations
- Lean.mkMVar fvarId = Lean.Expr.mvar fvarId (Lean.Expr.mkData (mixHash 17 (hash fvarId)) 0 0 false true false false Lean.BinderInfo.default)
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.mkApp f a = Lean.Expr.app f a (Lean.Expr.mkAppData (Lean.Expr.data f) (Lean.Expr.data a))
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.
Return Unit -> type
. Do not confuse with Thunk type
Equations
- Lean.mkSimpleThunkType type = Lean.mkForall Lean.Name.anonymous Lean.BinderInfo.default (Lean.mkConst `Unit) type
Return fun (_ : Unit), e
Equations
- Lean.mkSimpleThunk type = Lean.mkLambda `_ Lean.BinderInfo.default (Lean.mkConst `Unit) type
Equations
- Lean.mkAppB f a b = Lean.mkApp (Lean.mkApp f a) b
Equations
- Lean.mkApp2 f a b = Lean.mkAppB f a b
Equations
- Lean.mkApp3 f a b c = Lean.mkApp (Lean.mkAppB f a b) c
Equations
- Lean.mkApp4 f a b c d = Lean.mkAppB (Lean.mkAppB f a b) c d
Equations
- Lean.mkApp5 f a b c d e = Lean.mkApp (Lean.mkApp4 f a b c d) e
Equations
- Lean.mkApp6 f a b c d e₁ e₂ = Lean.mkAppB (Lean.mkApp4 f a b c d) e₁ e₂
Equations
- Lean.mkApp7 f a b c d e₁ e₂ e₃ = Lean.mkApp3 (Lean.mkApp4 f a b c d) e₁ e₂ e₃
Equations
- Lean.mkApp8 f a b c d e₁ e₂ e₃ e₄ = Lean.mkApp4 (Lean.mkApp4 f a b c d) e₁ e₂ e₃ e₄
Equations
- Lean.mkApp9 f a b c d e₁ e₂ e₃ e₄ e₅ = Lean.mkApp5 (Lean.mkApp4 f a b c d) e₁ e₂ e₃ e₄ e₅
Equations
- Lean.mkApp10 f a b c d e₁ e₂ e₃ e₄ e₅ e₆ = Lean.mkApp6 (Lean.mkApp4 f a b c d) e₁ e₂ e₃ e₄ e₅ e₆
Equations
- Lean.mkLit l = Lean.Expr.lit l (Lean.Expr.mkData (mixHash 3 (hash l)) 0 0 false false false false Lean.BinderInfo.default)
Equations
Equations
- Lean.mkNatLit n = let r := Lean.mkRawNatLit n; Lean.mkApp3 (Lean.mkConst `OfNat.ofNat [Lean.levelZero]) (Lean.mkConst `Nat) r (Lean.mkApp (Lean.mkConst `instOfNatNat) r)
Equations
Equations
Equations
Equations
Equations
Equations
- Lean.mkConstEx c lvls = Lean.mkConst c lvls
Equations
Equations
- Lean.mkLambdaEx n d b bi = Lean.mkLambda n bi d b
Equations
- Lean.mkForallEx n d b bi = Lean.mkForall n bi d b
Equations
- Lean.mkLetEx n t v b = Lean.mkLet n t v b
Equations
Equations
Equations
mkAppN f #[a₀, ..., aₙ]
==> f a₀ a₁ .. aₙ
Equations
- Lean.mkAppN f args = Array.foldl Lean.mkApp f args 0 (Array.size args)
mkAppRange f i j #[a_1, ..., a_i, ..., a_j, ... ]
==> the expression f a_i ... a_{j-1}
Equations
- Lean.mkAppRange f i j args = Lean.mkAppRangeAux j args i f
Same as mkApp f args
but reversing args
.
Equations
- Lean.mkAppRev fn revArgs = Array.foldr (fun a r => Lean.mkApp r a) fn revArgs (Array.size revArgs)
Return true iff a
and b
are alpha equivalent.
Binder annotations are ignored.
Equations
- Lean.Expr.instBEqExpr = { beq := Lean.Expr.eqv }
Equations
- Lean.Expr.ptrEq a b = (ptrAddrUnsafe a == ptrAddrUnsafe b)
Equations
- Lean.Expr.isSort _fun_discr = match _fun_discr with | Lean.Expr.sort a a_1 => true | x => false
Equations
- Lean.Expr.isType _fun_discr = match _fun_discr with | Lean.Expr.sort (Lean.Level.succ a a_1) a_2 => true | x => false
Equations
- Lean.Expr.isProp _fun_discr = match _fun_discr with | Lean.Expr.sort (Lean.Level.zero a) a_1 => true | x => false
Equations
- Lean.Expr.isBVar _fun_discr = match _fun_discr with | Lean.Expr.bvar a a_1 => true | x => false
Equations
- Lean.Expr.isMVar _fun_discr = match _fun_discr with | Lean.Expr.mvar a a_1 => true | x => false
Equations
- Lean.Expr.isFVar _fun_discr = match _fun_discr with | Lean.Expr.fvar a a_1 => true | x => false
Equations
- Lean.Expr.isApp _fun_discr = match _fun_discr with | Lean.Expr.app a a_1 a_2 => true | x => false
Equations
- Lean.Expr.isProj _fun_discr = match _fun_discr with | Lean.Expr.proj a a_1 a_2 a_3 => true | x => false
Equations
- Lean.Expr.isConst _fun_discr = match _fun_discr with | Lean.Expr.const a a_1 a_2 => true | x => false
Equations
- Lean.Expr.isConstOf _fun_discr _fun_discr = match _fun_discr, _fun_discr with | Lean.Expr.const n a a_1, m => n == m | x, x_1 => false
Equations
- Lean.Expr.isForall _fun_discr = match _fun_discr with | Lean.Expr.forallE a a_1 a_2 a_3 => true | x => false
Equations
- Lean.Expr.isLambda _fun_discr = match _fun_discr with | Lean.Expr.lam a a_1 a_2 a_3 => true | x => false
Equations
- Lean.Expr.isBinding _fun_discr = match _fun_discr with | Lean.Expr.lam a a_1 a_2 a_3 => true | Lean.Expr.forallE a a_1 a_2 a_3 => true | x => false
Equations
- Lean.Expr.isLet _fun_discr = match _fun_discr with | Lean.Expr.letE a a_1 a_2 a_3 a_4 => true | x => false
Equations
- Lean.Expr.isMData _fun_discr = match _fun_discr with | Lean.Expr.mdata a a_1 a_2 => true | x => false
Equations
- Lean.Expr.isLit _fun_discr = match _fun_discr with | Lean.Expr.lit a a_1 => true | x => false
Equations
- Lean.Expr.getForallBody (Lean.Expr.forallE a a_1 a_2 a_3) = Lean.Expr.getForallBody a_2
- Lean.Expr.getForallBody _fun_discr = _fun_discr
If the given expression is a sequence of
function applications f a₁ .. aₙ
, return f
.
Otherwise return the input expression.
Equations
- Lean.Expr.getAppFn (Lean.Expr.app a a_1 a_2) = Lean.Expr.getAppFn a
- Lean.Expr.getAppFn _fun_discr = _fun_discr
Equations
- Lean.Expr.getAppNumArgsAux (Lean.Expr.app f a a_1) _fun_discr = Lean.Expr.getAppNumArgsAux f (_fun_discr + 1)
- Lean.Expr.getAppNumArgsAux _fun_discr _fun_discr = _fun_discr
Counts the number n
of arguments for an expression f a₁ .. aₙ
.
Equations
Given f a₁ a₂ ... aₙ
, returns #[a₁, ..., aₙ]
Equations
- Lean.Expr.getAppArgs e = let dummy := Lean.mkSort Lean.levelZero; let nargs := Lean.Expr.getAppNumArgs e; Lean.Expr.getAppArgsAux e (mkArray nargs dummy) (nargs - 1)
Equations
- Lean.Expr.withAppAux k (Lean.Expr.app f a a_1) _fun_discr _fun_discr = Lean.Expr.withAppAux k f (Array.set! _fun_discr _fun_discr a) (_fun_discr - 1)
- Lean.Expr.withAppAux k _fun_discr _fun_discr _fun_discr = k _fun_discr _fun_discr
Given e = f a₁ a₂ ... aₙ
, returns k f #[a₁, ..., aₙ]
.
Equations
- Lean.Expr.withApp e k = let dummy := Lean.mkSort Lean.levelZero; let nargs := Lean.Expr.getAppNumArgs e; Lean.Expr.withAppAux k e (mkArray nargs dummy) (nargs - 1)
Given e = fn a₁ ... aₙ
, runs f
on fn
and each of the arguments aᵢ
and
makes a new function application with the results.
Equations
- Lean.Expr.traverseApp f e = Lean.Expr.withApp e fun fn args => Seq.seq (Lean.mkAppN <$> f fn) fun x => Array.mapM f args
Equations
- Lean.Expr.getRevArgD (Lean.Expr.app a a_1 a_2) 0 _fun_discr = a_1
- Lean.Expr.getRevArgD (Lean.Expr.app f a a_1) (Nat.succ i) _fun_discr = Lean.Expr.getRevArgD f i _fun_discr
- Lean.Expr.getRevArgD _fun_discr _fun_discr _fun_discr = _fun_discr
Equations
- Lean.Expr.getRevArg! (Lean.Expr.app a a_1 a_2) 0 = a_1
- Lean.Expr.getRevArg! (Lean.Expr.app f a a_1) (Nat.succ i) = Lean.Expr.getRevArg! f i
- Lean.Expr.getRevArg! _fun_discr _fun_discr = panicWithPosWithDecl "Lean.Expr" "Lean.Expr.getRevArg!" 622 22 "invalid index"
Given f a₀ a₁ ... aₙ
, returns the i
th argument or panics if out of bounds.
Equations
- Lean.Expr.getArg! e i n = Lean.Expr.getRevArg! e (n - i - 1)
Given f a₀ a₁ ... aₙ
, returns the i
th argument or returns v₀
if out of bounds.
Equations
- Lean.Expr.getArgD e i v₀ n = Lean.Expr.getRevArgD e (n - i - 1) v₀
Given f a₀ a₁ ... aₙ
, returns true if f
is a constant with name n
.
Equations
- Lean.Expr.isAppOf e n = match Lean.Expr.getAppFn e with | Lean.Expr.const c a a_1 => c == n | x => false
Similar to isAppOfArity
but skips Expr.mdata
.
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.
Equations
- Lean.Expr.appFn!' (Lean.Expr.mdata a b a_1) = Lean.Expr.appFn!' b
- Lean.Expr.appFn!' (Lean.Expr.app f a a_1) = f
- Lean.Expr.appFn!' _fun_discr = panicWithPosWithDecl "Lean.Expr" "Lean.Expr.appFn!'" 663 19 "application expected"
Equations
- Lean.Expr.appArg!' (Lean.Expr.mdata a b a_1) = Lean.Expr.appArg!' b
- Lean.Expr.appArg!' (Lean.Expr.app f a a_1) = a
- Lean.Expr.appArg!' _fun_discr = panicWithPosWithDecl "Lean.Expr" "Lean.Expr.appArg!'" 668 19 "application expected"
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.
Equations
- Lean.Expr.isNatLit _fun_discr = match _fun_discr with | Lean.Expr.lit (Lean.Literal.natVal val) a => true | x => false
Equations
- Lean.Expr.natLit? _fun_discr = match _fun_discr with | Lean.Expr.lit (Lean.Literal.natVal v) a => some v | x => none
Equations
- Lean.Expr.isStringLit _fun_discr = match _fun_discr with | Lean.Expr.lit (Lean.Literal.strVal val) a => true | x => false
Equations
- Lean.Expr.isCharLit e = (Lean.Expr.isAppOfArity e `Char.ofNat 1 && Lean.Expr.isNatLit (Lean.Expr.appArg! e))
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Expr.constName? _fun_discr = match _fun_discr with | Lean.Expr.const n a a_1 => some n | x => none
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.
Equations
- Lean.Expr.fvarId! _fun_discr = match _fun_discr with | Lean.Expr.fvar n a => n | x => panicWithPosWithDecl "Lean.Expr" "Lean.Expr.fvarId!" 711 16 "fvar expected"
Equations
- Lean.Expr.mvarId! _fun_discr = match _fun_discr with | Lean.Expr.mvar n a => n | x => panicWithPosWithDecl "Lean.Expr" "Lean.Expr.mvarId!" 715 16 "mvar expected"
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.
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.
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.
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.
Equations
- Lean.Expr.consumeMData (Lean.Expr.mdata a a_1 a_2) = Lean.Expr.consumeMData a_1
- Lean.Expr.consumeMData _fun_discr = _fun_discr
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.
Equations
- One or more equations did not get rendered due to their size.
Equations
Equations
- Lean.Expr.isArrow e = match e with | Lean.Expr.forallE a a_1 b a_2 => !Lean.Expr.hasLooseBVars b | x => false
Return true if e
contains the loose bound variable bvarIdx
in an explicit parameter, or in the range if tryRange == true
.
Equations
- One or more equations did not get rendered due to their size.
- Lean.Expr.hasLooseBVarInExplicitDomain _fun_discr _fun_discr _fun_discr = (_fun_discr && Lean.Expr.hasLooseBVar _fun_discr _fun_discr)
inferImplicit e numParams considerRange
updates the first numParams
parameter binder annotations of the e
forall type.
It marks any parameter with an explicit binder annotation if there is another explicit arguments that depends on it or
the resulting type if considerRange == true
.
Remark: we use this function to infer the bind annotations of inductive datatype constructors, and structure projections.
When the {}
annotation is used in these commands, we set considerRange == false
.
Similar to instantiate
, but consider only the variables xs
in the range [beginIdx, endIdx)
.
Function panics if beginIdx <= endIdx <= xs.size
does not hold.
Similar to instantiateRev
, but consider only the variables xs
in the range [beginIdx, endIdx)
.
Function panics if beginIdx <= endIdx <= xs.size
does not hold.
Replace occurrences of the free variable fvar
in e
with v
Equations
- Lean.Expr.replaceFVar e fvar v = Lean.Expr.instantiate1 (Lean.Expr.abstract e #[fvar]) v
Replace occurrences of the free variable fvarId
in e
with v
Equations
- Lean.Expr.replaceFVarId e fvarId v = Lean.Expr.replaceFVar e (Lean.mkFVar fvarId) v
Replace occurrences of the free variables fvars
in e
with vs
Equations
- Lean.Expr.replaceFVars e fvars vs = Lean.Expr.instantiateRev (Lean.Expr.abstract e fvars) vs
Equations
- Lean.Expr.instToStringExpr = { toString := Lean.Expr.dbgToString }
Returns true when the expression does not have any sub-expressions.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.mkDecIsTrue pred proof = Lean.mkAppB (Lean.mkConst `Decidable.isTrue) pred proof
Equations
- Lean.mkDecIsFalse pred proof = Lean.mkAppB (Lean.mkConst `Decidable.isFalse) pred proof
Equations
Equations
Equations
Equations
- Lean.instInhabitedExprStructEq = { default := { val := default } }
Equations
- Lean.instCoeExprExprStructEq = { coe := Lean.ExprStructEq.mk }
Equations
- Lean.ExprStructEq.beq _fun_discr _fun_discr = match _fun_discr, _fun_discr with | { val := e₁ }, { val := e₂ } => Lean.Expr.equal e₁ e₂
Equations
- Lean.ExprStructEq.hash _fun_discr = match _fun_discr with | { val := e } => Lean.Expr.hash e
Equations
Equations
- Lean.ExprStructEq.instToStringExprStructEq = { toString := fun e => toString e.val }
Equations
Equations
mkAppRevRange f b e args == mkAppRev f (revArgs.extract b e)
Equations
- Lean.Expr.mkAppRevRange f beginIdx endIdx revArgs = Lean.Expr.mkAppRevRangeAux revArgs beginIdx f endIdx
If f
is a lambda expression, than "beta-reduce" it using revArgs
.
This function is often used with getAppRev
or withAppRev
.
Examples:
betaRev (fun x y => t x y) #[]
==>fun x y => t x y
betaRev (fun x y => t x y) #[a]
==>fun y => t a y
betaRev (fun x y => t x y) #[a, b]
==>t b a
betaRev (fun x y => t x y) #[a, b, c, d]
==>t d c b a
Supposet
is(fun x y => t x y) a b c d
, thenargs := t.getAppRev
is#[d, c, b, a]
, andbetaRev (fun x y => t x y) #[d, c, b, a]
ist a b c d
.
If useZeta
is true, the function also performs zeta-reduction (reduction of let binders) to create further
opportunities for beta reduction.
Equations
- Lean.Expr.betaRev f revArgs useZeta preserveMData = if (Array.size revArgs == 0) = true then f else let sz := Array.size revArgs; Lean.Expr.betaRev.go revArgs useZeta preserveMData sz f 0
Apply the given arguments to f
, beta-reducing if f
is a
lambda expression. See docstring for betaRev
for examples.
Equations
- Lean.Expr.beta f args = Lean.Expr.betaRev f (Array.reverse args) false
(fun x => e) a
==> e[x/a]
.
Equations
- Lean.Expr.headBeta e = let f := Lean.Expr.getAppFn e; if Lean.Expr.isHeadBetaTargetFn false f = true then Lean.Expr.betaRev f (Lean.Expr.getAppRevArgs e) false else e
Equations
- Lean.Expr.isHeadBetaTarget e useZeta = Lean.Expr.isHeadBetaTargetFn useZeta (Lean.Expr.getAppFn e)
If e
is of the form (fun x₁ ... xₙ => f x₁ ... xₙ)
and f
does not contain x₁
, ..., xₙ
,
then return some f
. Otherwise, return none
.
It assumes e
does not have loose bound variables.
Remark: ₙ
may be 0
Equations
Similar to etaExpanded?
, but only succeeds if ₙ ≥ 1
.
Equations
- Lean.Expr.etaExpandedStrict? _fun_discr = match _fun_discr with | Lean.Expr.lam a a_1 b a_2 => Lean.Expr.etaExpandedAux b 1 | x => none
Equations
- Lean.Expr.getOptParamDefault? e = if Lean.Expr.isAppOfArity e `optParam 2 = true then some (Lean.Expr.appArg! e) else none
Equations
- Lean.Expr.getAutoParamTactic? e = if Lean.Expr.isAppOfArity e `autoParam 2 = true then some (Lean.Expr.appArg! e) else none
Equations
- Lean.Expr.isOutParam e = Lean.Expr.isAppOfArity e `outParam 1
Equations
- Lean.Expr.isOptParam e = Lean.Expr.isAppOfArity e `optParam 2
Equations
- Lean.Expr.isAutoParam e = Lean.Expr.isAppOfArity e `autoParam 2
Return true iff e
contains a free variable which statisfies p
.
Equations
Equations
- Lean.Expr.containsFVar e fvarId = Lean.Expr.hasAnyFVar e fun a => a == fvarId
Equations
- Lean.Expr.updateApp e newFn newArg h = Lean.mkApp newFn newArg
Equations
- Lean.Expr.updateConst e newLevels h = Lean.mkConst (Lean.Expr.constName! e) newLevels
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Expr.updateSort e newLevel h = Lean.mkSort newLevel
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Expr.updateProj e newExpr h = match e, h with | Lean.Expr.proj s i a a_1, h => Lean.mkProj s i newExpr | x, h => e
Equations
- Lean.Expr.updateMData e newExpr h = match e, h with | Lean.Expr.mdata d a a_1, h => Lean.mkMData d newExpr | x, h => e
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.
Equations
- Lean.Expr.updateForall e newBinfo newDomain newBody h = Lean.mkForall (Lean.Expr.bindingName! e) newBinfo newDomain newBody
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Expr.updateLambda e newBinfo newDomain newBody h = Lean.mkLambda (Lean.Expr.bindingName! e) newBinfo newDomain newBody
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Expr.updateLet e newType newVal newBody h = Lean.mkLet (Lean.Expr.letName! e) newType newVal newBody
Equations
- Lean.Expr.updateFn (Lean.Expr.app f a a_1) _fun_discr = Lean.Expr.updateApp! (Lean.Expr.app f a a_1) (Lean.Expr.updateFn f _fun_discr) a
- Lean.Expr.updateFn _fun_discr _fun_discr = _fun_discr
Equations
- Lean.Expr.instantiateLevelParams e paramNames lvls = Lean.Expr.instantiateLevelParamsCore (Lean.Expr.getParamSubst paramNames lvls) e
Equations
- Lean.Expr.instantiateLevelParamsArray e paramNames lvls = Lean.Expr.instantiateLevelParamsCore (fun p => Lean.Expr.getParamSubstArray paramNames lvls p 0) e
Annotate e
with the given option.
Equations
- Lean.Expr.setOption e optionName val = Lean.mkMData (Lean.KVMap.set Lean.MData.empty optionName val) e
Annotate e
with pp.explicit := true
The delaborator uses pp
options.
Equations
- Lean.Expr.setPPExplicit e flag = Lean.Expr.setOption e `pp.explicit flag
Equations
- Lean.Expr.setPPUniverses e flag = Lean.Expr.setOption e `pp.universes flag
If e
is an application f a_1 ... a_n
annotate f
, a_1
... a_n
with pp.explicit := false
,
and annotate e
with pp.explicit := true
.
Equations
- One or more equations did not get rendered due to their size.
Similar for setAppPPExplicit
, but only annotate children with pp.explicit := false
if
e
does not contain metavariables.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.mkAnnotation kind e = Lean.mkMData (Lean.KVMap.insert Lean.KVMap.empty kind (Lean.DataValue.ofBool true)) e
Equations
- Lean.annotation? kind e = match e with | Lean.Expr.mdata d b a => if (Lean.KVMap.size d == 1 && Lean.KVMap.getBool d kind) = true then some b else none | x => none
Equations
- Lean.mkLetFunAnnotation e = Lean.mkAnnotation `let_fun e
Equations
- Lean.letFunAnnotation? e = Lean.annotation? `let_fun e
Equations
- Lean.isLetFun e = match Lean.letFunAnnotation? e with | none => false | some e => Lean.Expr.isApp e && Lean.Expr.isLambda (Lean.Expr.appFn! e)
Auxiliary annotation used to mark terms marked with the "inaccessible" annotation .(t)
and
_
in patterns.
Equations
- Lean.mkInaccessible e = Lean.mkAnnotation `_inaccessible e
Equations
- Lean.inaccessible? e = Lean.annotation? `_inaccessible e
During elaboration expressions corresponding to pattern matching terms
are annotated with Syntax
objects. This function returns some (stx, p')
if
p
is the pattern p'
annotated with stx
Equations
- One or more equations did not get rendered due to their size.
Annotate the pattern p
with stx
. This is an auxiliary annotation
for producing better hover information.
Equations
- One or more equations did not get rendered due to their size.
Return some p
if e
is an annotated pattern (inaccessible?
or patternWithRef?
)
Equations
- Lean.patternAnnotation? e = match Lean.inaccessible? e with | some e => some e | x => match Lean.patternWithRef? e with | some (fst, e) => some e | x => none
Annotate e
with the LHS annotation. The delaborator displays
expressions of the form lhs = rhs
as lhs
when they have this annotation.
Equations
- Lean.mkLHSGoal e = Lean.mkAnnotation `_lhsGoal e
Equations
- Lean.isLHSGoal? e = match Lean.annotation? `_lhsGoal e with | none => none | some e => if Lean.Expr.isAppOfArity e `Eq 3 = true then some (Lean.Expr.appArg! (Lean.Expr.appFn! e)) else none
Equations
- Lean.mkNot p = Lean.mkApp (Lean.mkConst `Not) p
Equations
- Lean.mkOr p q = Lean.mkApp2 (Lean.mkConst `Or) p q
Equations
- Lean.mkAnd p q = Lean.mkApp2 (Lean.mkConst `And) p q
Equations
- Lean.mkEM p = Lean.mkApp (Lean.mkConst `Classical.em) p