File: Mathlib/Lean/Expr/Basic.lean

full_name: Lean.BinderInfo.brackets
code: /-- The brackets corresponding to a given `BinderInfo`. -/
def brackets : BinderInfo → String × String
  
goal: Lean.BinderInfo → String × String

full_name: Lean.Name.mapPrefix
code: /-- Find the largest prefix `n` of a `Name` such that `f n != none`, then replace this prefix
with the value of `f n`. -/
def mapPrefix (f : Name → Option Name) (n : Name) : Name 
goal: Lean.Name

full_name: Lean.Name.fromComponents.go
code: /-- Build a name from components. For example ``from_components [`foo, `bar]`` becomes
  ``` `foo.bar```.
  It is the inverse of `Name.components` on list of names that have single components. -/
def fromComponents : List Name → Name 
goal: Lean.Name → List Lean.Name → Lean.Name

full_name: Lean.Name.fromComponents
code: /-- Build a name from components. For example ``from_components [`foo, `bar]`` becomes
  ``` `foo.bar```.
  It is the inverse of `Name.components` on list of names that have single components. -/
def fromComponents : List Name → Name 
goal: List Lean.Name → Lean.Name

full_name: Lean.Name.updateLast
code: /-- Update the last component of a name. -/
def updateLast (f : String → String) : Name → Name
  
goal: Lean.Name → Lean.Name

full_name: Lean.Name.lastComponentAsString
code: /-- Get the last field of a name as a string.
Doesn't raise an error when the last component is a numeric field. -/
def lastComponentAsString : Name → String
  
goal: Lean.Name → String

full_name: Lean.Name.splitAt
code: /-- `nm.splitAt n` splits a name `nm` in two parts, such that the *second* part has depth `n`, i.e.
  `(nm.splitAt n).2.getNumParts = n` (assuming `nm.getNumParts ≥ n`).
  Example: ``splitAt `foo.bar.baz.back.bat 1 = (`foo.bar.baz.back, `bat)``. -/
def splitAt (nm : Name) (n : Nat) : Name × Name 
goal: Lean.Name × Lean.Name

full_name: Lean.Name.isPrefixOf?
code: /-- `isPrefixOf? pre nm` returns `some post` if `nm = pre ++ post`.
  Note that this includes the case where `nm` has multiple more namespaces.
  If `pre` is not a prefix of `nm`, it returns `none`. -/
def isPrefixOf? (pre nm : Name) : Option Name 
goal: Option Lean.Name

full_name: Lean.Name.isBlackListed
code: def isBlackListed {m} [Monad m] [MonadEnv m] (declName : Name) : m Bool 
goal: m Bool

full_name: Lean.ConstantInfo.isDef
code: /-- Checks whether this `ConstantInfo` is a definition, -/
def isDef : ConstantInfo → Bool
  
goal: Lean.ConstantInfo → Bool

full_name: Lean.ConstantInfo.isThm
code: /-- Checks whether this `ConstantInfo` is a theorem, -/
def isThm : ConstantInfo → Bool
  
goal: Lean.ConstantInfo → Bool

full_name: Lean.ConstantInfo.updateConstantVal
code: /-- Update `ConstantVal` (the data common to all constructors of `ConstantInfo`)
in a `ConstantInfo`. -/
def updateConstantVal : ConstantInfo → ConstantVal → ConstantInfo
  
goal: Lean.ConstantInfo → Lean.ConstantVal → Lean.ConstantInfo

full_name: Lean.ConstantInfo.updateName
code: /-- Update the name of a `ConstantInfo`. -/
def updateName (c : ConstantInfo) (name : Name) : ConstantInfo 
goal: Lean.ConstantInfo

full_name: Lean.ConstantInfo.updateType
code: /-- Update the type of a `ConstantInfo`. -/
def updateType (c : ConstantInfo) (type : Expr) : ConstantInfo 
goal: Lean.ConstantInfo

full_name: Lean.ConstantInfo.updateLevelParams
code: /-- Update the level parameters of a `ConstantInfo`. -/
def updateLevelParams (c : ConstantInfo) (levelParams : List Name) :
    ConstantInfo 
goal: Lean.ConstantInfo

full_name: Lean.ConstantInfo.updateValue
code: /-- Update the value of a `ConstantInfo`, if it has one. -/
def updateValue : ConstantInfo → Expr → ConstantInfo
  
goal: Lean.ConstantInfo → Lean.Expr → Lean.ConstantInfo

full_name: Lean.ConstantInfo.toDeclaration!
code: /-- Turn a `ConstantInfo` into a declaration. -/
def toDeclaration! : ConstantInfo → Declaration
  
goal: Lean.ConstantInfo → Lean.Declaration

full_name: Lean.mkConst'
code: /-- Same as `mkConst`, but with fresh level metavariables. -/
def mkConst' (constName : Name) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Expr.bvarIdx?
code: def bvarIdx? : Expr → Option Nat
  
goal: Lean.Expr → Option Nat

full_name: _private.Mathlib.Lean.Expr.Basic.0.Lean.Expr.getAppAppsAux
code: /-- Invariant: `i : ℕ` should be less than the size of `as : Array Expr`. -/
private def getAppAppsAux : Expr → Array Expr → Nat → Array Expr
  
goal: Lean.Expr → Array Lean.Expr → Nat → Array Lean.Expr

full_name: Lean.Expr.getAppApps
code: /-- Given `f a b c`, return `#[f a, f a b, f a b c]`.
Each entry in the array is an `Expr.app`,
and this array has the same length as the one returned by `Lean.Expr.getAppArgs`. -/
@[inline]
def getAppApps (e : Expr) : Array Expr 
goal: Array Lean.Expr

full_name: Lean.Expr.eraseProofs
code: /-- Erase proofs in an expression by replacing them with `sorry`s.

This function replaces all proofs in the expression
and in the types that appear in the expression
by `sorryAx`s.
The resulting expression has the same type as the old one.

It is useful, e.g., to verify if the proof-irrelevant part of a definition depends on a variable.
-/
def eraseProofs (e : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Expr.rat?
code: /--
Check if an expression is a "rational in normal form",
i.e. either an integer number in normal form,
or `n / d` where `n` is an integer in normal form, `d` is a natural number in normal form,
`d ≠ 1`, and `n` and `d` are coprime (in particular, we check that `(mkRat n d).den = d`).
If so returns the rational number.
-/
def rat? (e : Expr) : Option Rat 
goal: Option Rat

full_name: Lean.Expr.isExplicitNumber
code: /--
Test if an expression represents an explicit number written in normal form:
* A "natural number in normal form" is an expression `OfNat.ofNat n`, even if it is not of type `ℕ`,
  as long as `n` is a literal.
* An "integer in normal form" is an expression which is either a natural number in number form,
  or `-n`, where `n` is a natural number in normal form.
* A "rational in normal form" is an expressions which is either an integer in normal form,
  or `n / d` where `n` is an integer in normal form, `d` is a natural number in normal form,
  `d ≠ 1`, and `n` and `d` are coprime (in particular, we check that `(mkRat n d).den = d`).
-/
def isExplicitNumber : Expr → Bool
  
goal: Lean.Expr → Bool

full_name: Lean.Expr.fvarId?
code: /-- If an `Expr` has form `.fvar n`, then returns `some n`, otherwise `none`. -/
def fvarId? : Expr → Option FVarId
  
goal: Lean.Expr → Option Lean.FVarId

full_name: Lean.Expr.type?
code: /-- If an `Expr` has the form `Type u`, then return `some u`, otherwise `none`. -/
def type? : Expr → Option Level
  
goal: Lean.Expr → Option Lean.Level

full_name: Lean.Expr.isConstantApplication.aux
code: /-- `isConstantApplication e` checks whether `e` is syntactically an application of the form
  `(fun x₁ ⋯ xₙ => H) y₁ ⋯ yₙ` where `H` does not contain the variable `xₙ`. In other words,
  it does a syntactic check that the expression does not depend on `yₙ`. -/
def isConstantApplication (e : Expr) 
goal: Lean.Expr → Nat → Bool

full_name: Lean.Expr.isConstantApplication
code: /-- `isConstantApplication e` checks whether `e` is syntactically an application of the form
  `(fun x₁ ⋯ xₙ => H) y₁ ⋯ yₙ` where `H` does not contain the variable `xₙ`. In other words,
  it does a syntactic check that the expression does not depend on `yₙ`. -/
def isConstantApplication (e : Expr) 
goal: Bool

full_name: Lean.Expr.letDepth
code: /-- Counts the immediate depth of a nested `let` expression. -/
def letDepth : Expr → Nat
  
goal: Lean.Expr → Nat

full_name: Lean.Expr.ensureHasNoMVars
code: /-- Check that an expression contains no metavariables (after instantiation). -/
-- There is a `TacticM` level version of this, but it's useful to have in `MetaM`.
def ensureHasNoMVars (e : Expr) : MetaM Unit 
goal: Lean.MetaM Unit

full_name: Lean.Expr.ofNat
code: /-- Construct the term of type `α` for a given natural number
(doing typeclass search for the `OfNat` instance required). -/
def ofNat (α : Expr) (n : Nat) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Expr.ofInt
code: /-- Construct the term of type `α` for a given integer
(doing typeclass search for the `OfNat` and `Neg` instances required). -/
def ofInt (α : Expr) : Int → MetaM Expr
  
goal: Int → Lean.MetaM Lean.Expr

full_name: Lean.Expr.numeral?
code: /--
  Return `some n` if `e` is one of the following
  - A nat literal (numeral)
  - `Nat.zero`
  - `Nat.succ x` where `isNumeral x`
  - `OfNat.ofNat _ x _` where `isNumeral x` -/
partial def numeral? (e : Expr) : Option Nat 
goal: Option Nat

full_name: Lean.Expr.zero?
code: /-- Test if an expression is either `Nat.zero`, or `OfNat.ofNat 0`. -/
def zero? (e : Expr) : Bool 
goal: Bool

full_name: Lean.Expr.ne?'
code: /-- Tests is if an expression matches either `x ≠ y` or `¬ (x = y)`.
If it matches, returns `some (type, x, y)`. -/
def ne?' (e : Expr) : Option (Expr × Expr × Expr) 
goal: Option (Lean.Expr × Lean.Expr × Lean.Expr)

full_name: Lean.Expr.le?
code: /-- `Lean.Expr.le? e` takes `e : Expr` as input.
If `e` represents `a ≤ b`, then it returns `some (t, a, b)`, where `t` is the Type of `a`,
otherwise, it returns `none`. -/
@[inline] def le? (p : Expr) : Option (Expr × Expr × Expr) 
goal: Option (Lean.Expr × Lean.Expr × Lean.Expr)

full_name: Lean.Expr.sides?
code: /-- Given a proposition `ty` that is an `Eq`, `Iff`, or `HEq`, returns `(tyLhs, lhs, tyRhs, rhs)`,
where `lhs : tyLhs` and `rhs : tyRhs`,
and where `lhs` is related to `rhs` by the respective relation.

See also `Lean.Expr.iff?`, `Lean.Expr.eq?`, and `Lean.Expr.heq?`. -/
def sides? (ty : Expr) : Option (Expr × Expr × Expr × Expr) 
goal: Option (Lean.Expr × Lean.Expr × Lean.Expr × Lean.Expr)

full_name: Lean.Expr.modifyAppArgM
code: def modifyAppArgM {M : Type → Type u} [Functor M] [Pure M]
    (modifier : Expr → M Expr) : Expr → M Expr
  
goal: Lean.Expr → M Lean.Expr

full_name: Lean.Expr.modifyRevArg
code: def modifyRevArg (modifier : Expr → Expr) : Nat → Expr → Expr
  
goal: Nat → Lean.Expr → Lean.Expr

full_name: Lean.Expr.modifyArg
code: /-- Given `f a₀ a₁ ... aₙ₋₁`, runs `modifier` on the `i`th argument or
returns the original expression if out of bounds. -/
def modifyArg (modifier : Expr → Expr) (e : Expr) (i : Nat) (n := e.getAppNumArgs) : Expr 
goal: Lean.Expr

full_name: Lean.Expr.setArg
code: /-- Given `f a₀ a₁ ... aₙ₋₁`, sets the argument on the `i`th argument to `x` or
returns the original expression if out of bounds. -/
def setArg (e : Expr) (i : Nat) (x : Expr) (n := e.getAppNumArgs) : Expr 
goal: Lean.Expr

full_name: Lean.Expr.getRevArg?
code: def getRevArg? : Expr → Nat → Option Expr
  
goal: Lean.Expr → Nat → Option Lean.Expr

full_name: Lean.Expr.getArg?
code: /-- Given `f a₀ a₁ ... aₙ₋₁`, returns the `i`th argument or none if out of bounds. -/
def getArg? (e : Expr) (i : Nat) (n := e.getAppNumArgs) : Option Expr 
goal: Option Lean.Expr

full_name: Lean.Expr.modifyArgM
code: /-- Given `f a₀ a₁ ... aₙ₋₁`, runs `modifier` on the `i`th argument.
An argument `n` may be provided which says how many arguments we are expecting `e` to have. -/
def modifyArgM {M : Type → Type u} [Monad M] (modifier : Expr → M Expr)
    (e : Expr) (i : Nat) (n := e.getAppNumArgs) : M Expr 
goal: M Lean.Expr

full_name: Lean.Expr.renameBVar
code: /-- Traverses an expression `e` and renames bound variables named `old` to `new`. -/
def renameBVar (e : Expr) (old new : Name) : Expr 
goal: Lean.Expr

full_name: Lean.Expr.getBinderName
code: /-- `getBinderName e` returns `some n` if `e` is an expression of the form `∀ n, ...`
and `none` otherwise. -/
def getBinderName (e : Expr) : MetaM (Option Name) 
goal: Lean.MetaM (Option Lean.Name)

full_name: Lean.Expr.addLocalVarInfoForBinderIdent
code: /-- Annotates a `binderIdent` with the binder information from an `fvar`. -/
def addLocalVarInfoForBinderIdent (fvar : Expr) (tk : TSyntax ``binderIdent) : MetaM Unit 
goal: Lean.MetaM Unit

full_name: Lean.Expr.mkDirectProjection
code: /-- If `e` has a structure as type with field `fieldName`, `mkDirectProjection e fieldName` creates
the projection expression `e.fieldName` -/
def mkDirectProjection (e : Expr) (fieldName : Name) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Expr.mkProjection
code: /-- If `e` has a structure as type with field `fieldName` (either directly or in a parent
structure), `mkProjection e fieldName` creates the projection expression `e.fieldName` -/
def mkProjection (e : Expr) (fieldName : Name) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Expr.reduceProjStruct?
code: /-- If `e` is a projection of the structure constructor, reduce the projection.
Otherwise returns `none`. If this function detects that expression is ill-typed, throws an error.
For example, given `Prod.fst (x, y)`, returns `some x`. -/
def reduceProjStruct? (e : Expr) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: Lean.Expr.containsConst
code: /-- Returns true if `e` contains a name `n` where `p n` is true. -/
def containsConst (e : Expr) (p : Name → Bool) : Bool 
goal: Bool

full_name: Lean.Expr.rewrite
code: /--
Rewrites `e` via some `eq`, producing a proof `e = e'` for some `e'`.

Rewrites with a fresh metavariable as the ambient goal.
Fails if the rewrite produces any subgoals.
-/
def rewrite (e eq : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Expr.rewriteType
code: /--
Rewrites the type of `e` via some `eq`, then moves `e` into the new type via `Eq.mp`.

Rewrites with a fresh metavariable as the ambient goal.
Fails if the rewrite produces any subgoals.
-/
def rewriteType (e eq : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Expr.forallNot_of_notExists.go
code: /-- Given `(hNotEx : Not ex)` where `ex` is of the form `Exists x, p x`,
    return a `forall x, Not (p x)` and a proof for it.

    This function handles nested existentials. -/
partial def forallNot_of_notExists (ex hNotEx : Expr) : MetaM (Expr × Expr) 
goal: Lean.MetaM (Lean.Expr × Lean.Expr)

full_name: Lean.Expr.forallNot_of_notExists
code: /-- Given `(hNotEx : Not ex)` where `ex` is of the form `Exists x, p x`,
    return a `forall x, Not (p x)` and a proof for it.

    This function handles nested existentials. -/
partial def forallNot_of_notExists (ex hNotEx : Expr) : MetaM (Expr × Expr) 
goal: Lean.MetaM (Lean.Expr × Lean.Expr)

full_name: Lean.getFieldsToParents
code: /-- Get the projections that are projections to parent structures. Similar to `getParentStructures`,
  except that this returns the (last component of the) projection names instead of the parent names.
-/
def getFieldsToParents (env : Environment) (structName : Name) : Array Name 
goal: Array Lean.Name