Additional operations on Expr and related types #
This file defines basic operations on the types expr, name, declaration, level, environment.
This file is mostly for non-tactics.
Converts an Expr
into a Syntax
, by creating a fresh metavariable
assigned to the expr and returning a named metavariable syntax ?a
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the number of leading ∀
binders of an expression. Ignores metadata.
Equations
- Lean.Expr.forallArity (Lean.Expr.mdata data b) = Lean.Expr.forallArity b
- Lean.Expr.forallArity (Lean.Expr.forallE binderName binderType body binderInfo) = 1 + Lean.Expr.forallArity body
- Lean.Expr.forallArity x = 0
Instances For
Returns the number of leading λ
binders of an expression. Ignores metadata.
Equations
- Lean.Expr.lambdaArity (Lean.Expr.mdata data b) = Lean.Expr.lambdaArity b
- Lean.Expr.lambdaArity (Lean.Expr.lam binderName binderType b binderInfo) = 1 + Lean.Expr.lambdaArity b
- Lean.Expr.lambdaArity x = 0
Instances For
Like getAppFn
but ignores metadata.
Equations
- Lean.Expr.getAppFn' (Lean.Expr.mdata data b) = Lean.Expr.getAppFn' b
- Lean.Expr.getAppFn' (Lean.Expr.app f arg) = Lean.Expr.getAppFn' f
- Lean.Expr.getAppFn' x = x
Instances For
Like getAppNumArgs
but ignores metadata.
Equations
Instances For
Auxiliary definition for getAppNumArgs'
.
Equations
- Lean.Expr.getAppNumArgs'.go (Lean.Expr.mdata data b) x = Lean.Expr.getAppNumArgs'.go b x
- Lean.Expr.getAppNumArgs'.go (Lean.Expr.app f arg) x = Lean.Expr.getAppNumArgs'.go f (x + 1)
- Lean.Expr.getAppNumArgs'.go x✝ x = x
Instances For
Like withApp
but ignores metadata.
Equations
- Lean.Expr.withApp' e k = let dummy := Lean.mkSort Lean.levelZero; let nargs := Lean.Expr.getAppNumArgs' e; Lean.Expr.withApp'.go k e (mkArray nargs dummy) (nargs - 1)
Instances For
Auxiliary definition for withApp'
.
Equations
- Lean.Expr.withApp'.go k (Lean.Expr.mdata data b) x✝ x = Lean.Expr.withApp'.go k b x✝ x
- Lean.Expr.withApp'.go k (Lean.Expr.app f a) x✝ x = Lean.Expr.withApp'.go k f (Array.set! x✝ x a) (x - 1)
- Lean.Expr.withApp'.go k x✝¹ x✝ x = k x✝¹ x✝
Instances For
Like getAppArgs
but ignores metadata.
Equations
- Lean.Expr.getAppArgs' e = Lean.Expr.withApp' e fun (x : Lean.Expr) (as : Array Lean.Expr) => as
Instances For
Like withAppRev
but ignores metadata.
Equations
Instances For
Auxiliary definition for withAppRev'
.
Equations
- Lean.Expr.withAppRev'.go k (Lean.Expr.mdata data b) x = Lean.Expr.withAppRev'.go k b x
- Lean.Expr.withAppRev'.go k (Lean.Expr.app f a) x = Lean.Expr.withAppRev'.go k f (Array.push x a)
- Lean.Expr.withAppRev'.go k x✝ x = k x✝ x
Instances For
Like getAppRevArgs
but ignores metadata.
Equations
- Lean.Expr.getAppRevArgs' e = Lean.Expr.withAppRev' e fun (x : Lean.Expr) (as : Array Lean.Expr) => as
Instances For
Like getRevArgD
but ignores metadata.
Equations
- Lean.Expr.getRevArgD' (Lean.Expr.mdata data b) x✝ x = Lean.Expr.getRevArgD' b x✝ x
- Lean.Expr.getRevArgD' (Lean.Expr.app fn a) 0 x = a
- Lean.Expr.getRevArgD' (Lean.Expr.app f arg) (Nat.succ i) x = Lean.Expr.getRevArgD' f i x
- Lean.Expr.getRevArgD' x✝¹ x✝ x = x
Instances For
Like getRevArg!
but ignores metadata.
Equations
- Lean.Expr.getRevArg!' (Lean.Expr.mdata data b) x = Lean.Expr.getRevArg!' b x
- Lean.Expr.getRevArg!' (Lean.Expr.app fn a) 0 = a
- Lean.Expr.getRevArg!' (Lean.Expr.app f arg) (Nat.succ i) = Lean.Expr.getRevArg!' f i
- Lean.Expr.getRevArg!' x✝ x = panicWithPosWithDecl "Std.Lean.Expr" "Lean.Expr.getRevArg!'" 113 22 "invalid index"
Instances For
Like getArgD
but ignores metadata.
Equations
- Lean.Expr.getArgD' e i v₀ n = Lean.Expr.getRevArgD' e (n - i - 1) v₀
Instances For
Like getArg!
but ignores metadata.
Equations
- Lean.Expr.getArg!' e i n = Lean.Expr.getRevArg!' e (n - i - 1)
Instances For
Like isAppOf
but ignores metadata.
Equations
- Lean.Expr.isAppOf' e n = match Lean.Expr.getAppFn' e with | Lean.Expr.const c us => c == n | x => false
Instances For
If the expression is a constant, return that name. Otherwise return Name.anonymous
.
Equations
Instances For
Return the function (name) and arguments of an application.
Equations
- Lean.Expr.getAppFnArgs e = Lean.Expr.withApp e fun (e : Lean.Expr) (a : Array Lean.Expr) => (Lean.Expr.constName e, a)
Instances For
Turns an expression that is a natural number literal into a natural number.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Turns an expression that is a constructor of Int
applied to a natural number literal
into an integer.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks if an expression is an "integer in normal form", i.e. either a natural number in normal form, or the negation of a positive natural number, and if so returns the integer.
Equations
- One or more equations did not get rendered due to their size.