File: .lake/packages/lean4/src/lean/Lean/Meta/InferType.lean

full_name: Lean.Expr.instantiateBetaRevRange
code: /--
Auxiliary function for instantiating the loose bound variables in `e` with `args[start:stop]`.
This function is similar to `instantiateRevRange`, but it applies beta-reduction when
we instantiate a bound variable with a lambda expression.
Example: Given the term `#0 a`, and `start := 0, stop := 1, args := #[fun x => x]` the result is
`a` instead of `(fun x => x) a`.
This reduction is useful when we are inferring the type of eliminator-like applications.
For example, given `(n m : Nat) (f : Nat → Nat) (h : m = n)`,
the type of `Eq.subst (motive := fun x => f m = f x) h rfl`
is `motive n` which is `(fun (x : Nat) => f m = f x) n`
This function reduces the new application to `f m = f n`

We use it to implement `inferAppType`
-/
partial def Expr.instantiateBetaRevRange (e : Expr) (start : Nat) (stop : Nat) (args : Array Expr) : Expr 
goal: Lean.Expr

full_name: Lean.Expr.instantiateBetaRevRange.visit
code: /--
Auxiliary function for instantiating the loose bound variables in `e` with `args[start:stop]`.
This function is similar to `instantiateRevRange`, but it applies beta-reduction when
we instantiate a bound variable with a lambda expression.
Example: Given the term `#0 a`, and `start := 0, stop := 1, args := #[fun x => x]` the result is
`a` instead of `(fun x => x) a`.
This reduction is useful when we are inferring the type of eliminator-like applications.
For example, given `(n m : Nat) (f : Nat → Nat) (h : m = n)`,
the type of `Eq.subst (motive := fun x => f m = f x) h rfl`
is `motive n` which is `(fun (x : Nat) => f m = f x) n`
This function reduces the new application to `f m = f n`

We use it to implement `inferAppType`
-/
partial def Expr.instantiateBetaRevRange (e : Expr) (start : Nat) (stop : Nat) (args : Array Expr) : Expr 
goal: Lean.MonadStateCacheT (Lean.ExprStructEq × Nat) Lean.Expr Id Lean.Expr

full_name: Lean.Meta.throwFunctionExpected
code: def throwFunctionExpected {α} (f : Expr) : MetaM α 
goal: Lean.MetaM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.inferAppType
code: private def inferAppType (f : Expr) (args : Array Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Meta.throwIncorrectNumberOfLevels
code: def throwIncorrectNumberOfLevels {α} (constName : Name) (us : List Level) : MetaM α 
goal: Lean.MetaM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.inferConstType
code: private def inferConstType (c : Name) (us : List Level) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.inferProjType
code: private def inferProjType (structName : Name) (idx : Nat) (e : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Meta.throwTypeExcepted
code: def throwTypeExcepted {α} (type : Expr) : MetaM α 
goal: Lean.MetaM α

full_name: Lean.Meta.getLevel
code: def getLevel (type : Expr) : MetaM Level 
goal: Lean.MetaM Lean.Level

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.inferForallType
code: private def inferForallType (e : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.inferLambdaType
code: /-- Infer type of lambda and let expressions -/
private def inferLambdaType (e : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Meta.throwUnknownMVar
code: def throwUnknownMVar {α} (mvarId : MVarId) : MetaM α 
goal: Lean.MetaM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.inferMVarType
code: private def inferMVarType (mvarId : MVarId) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.inferFVarType
code: private def inferFVarType (fvarId : FVarId) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.checkInferTypeCache
code: @[inline] private def checkInferTypeCache (e : Expr) (inferType : MetaM Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Meta.inferTypeImp
code: @[export lean_infer_type]
def inferTypeImp (e : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Meta.inferTypeImp.infer
code: @[export lean_infer_type]
def inferTypeImp (e : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.isAlwaysZero
code: /--
  Return `LBool.true` if given level is always equivalent to universe level zero.
  It is used to implement `isProp`. -/
private def isAlwaysZero : Level → Bool
  
goal: Lean.Level → Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.isArrowProp
code: /--
  `isArrowProp type n` is an "approximate" predicate which returns `LBool.true`
   if `type` is of the form `A_1 -> ... -> A_n -> Prop`.
   Remark: `type` can be a dependent arrow. -/
private partial def isArrowProp : Expr → Nat → MetaM LBool
  
goal: Lean.Expr → Nat → Lean.MetaM Lean.LBool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.isPropQuickApp
code: /--
  `isPropQuickApp f n` is an "approximate" predicate which returns `LBool.true`
   if `f` applied to `n` arguments is a proposition. -/
private partial def isPropQuickApp : Expr → Nat → MetaM LBool
  
goal: Lean.Expr → Nat → Lean.MetaM Lean.LBool

full_name: Lean.Meta.isPropQuick
code: /--
  `isPropQuick e` is an "approximate" predicate which returns `LBool.true`
  if `e` is a proposition. -/
partial def isPropQuick : Expr → MetaM LBool
  
goal: Lean.Expr → Lean.MetaM Lean.LBool

full_name: Lean.Meta.isProp
code: /-- `isProp e` returns `true` if `e` is a proposition.

     If `e` contains metavariables, it may not be possible
     to decide whether is a proposition or not. We return `false` in this
     case. We considered using `LBool` and retuning `LBool.undef`, but
     we have no applications for it. -/
def isProp (e : Expr) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.isArrowProposition
code: /--
  `isArrowProposition type n` is an "approximate" predicate which returns `LBool.true`
   if `type` is of the form `A_1 -> ... -> A_n -> B`, where `B` is a proposition.
   Remark: `type` can be a dependent arrow. -/
private partial def isArrowProposition : Expr → Nat → MetaM LBool
  
goal: Lean.Expr → Nat → Lean.MetaM Lean.LBool

full_name: Lean.Meta.isProof
code: def isProof (e : Expr) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.isArrowType
code: /--
  `isArrowType type n` is an "approximate" predicate which returns `LBool.true`
   if `type` is of the form `A_1 -> ... -> A_n -> Sort _`.
   Remark: `type` can be a dependent arrow. -/
private partial def isArrowType : Expr → Nat → MetaM LBool
  
goal: Lean.Expr → Nat → Lean.MetaM Lean.LBool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.isTypeQuickApp
code: /--
  `isTypeQuickApp f n` is an "approximate" predicate which returns `LBool.true`
   if `f` applied to `n` arguments is a type. -/
private partial def isTypeQuickApp : Expr → Nat → MetaM LBool
  
goal: Lean.Expr → Nat → Lean.MetaM Lean.LBool

full_name: Lean.Meta.isTypeQuick
code: /--
  `isTypeQuick e` is an "approximate" predicate which returns `LBool.true`
  if `e` is a type. -/
partial def isTypeQuick : Expr → MetaM LBool
  
goal: Lean.Expr → Lean.MetaM Lean.LBool

full_name: Lean.Meta.isType
code: /--
Return `true` iff the type of `e` is a `Sort _`.
-/
def isType (e : Expr) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.InferType.0.Lean.Meta.withLocalDecl'
code: @[inline] private def withLocalDecl' {α} (name : Name) (bi : BinderInfo) (type : Expr) (x : Expr → MetaM α) : MetaM α 
goal: Lean.MetaM α

full_name: Lean.Meta.typeFormerTypeLevelQuick
code: def typeFormerTypeLevelQuick : Expr → Option Level
  
goal: Lean.Expr → Option Lean.Level

full_name: Lean.Meta.typeFormerTypeLevel
code: /--
Return `u` iff `type` is `Sort u` or `As → Sort u`.
-/
partial def typeFormerTypeLevel (type : Expr) : MetaM (Option Level) 
goal: Lean.MetaM (Option Lean.Level)

full_name: Lean.Meta.typeFormerTypeLevel.go
code: /--
Return `u` iff `type` is `Sort u` or `As → Sort u`.
-/
partial def typeFormerTypeLevel (type : Expr) : MetaM (Option Level) 
goal: Lean.MetaM (Option Lean.Level)

full_name: Lean.Meta.isTypeFormerType
code: /--
Return true iff `type` is `Sort _` or `As → Sort _`.
-/
partial def isTypeFormerType (type : Expr) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: Lean.Meta.isPropFormerType
code: /--
Return true iff `type` is `Prop` or `As → Prop`.
-/
partial def isPropFormerType (type : Expr) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: Lean.Meta.isTypeFormer
code: /--
Return true iff `e : Sort _` or `e : (forall As, Sort _)`.
Remark: it subsumes `isType`
-/
def isTypeFormer (e : Expr) : MetaM Bool 
goal: Lean.MetaM Bool