File: .lake/packages/lean4/src/lean/Lean/Elab/Extra.lean

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.getMonadForIn
code: private def getMonadForIn (expectedType? : Option Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.throwForInFailure
code: private def throwForInFailure (forInInstance : Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: Lean.Elab.Term.elabForIn
code: @[builtin_term_elab forInMacro] def elabForIn : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.elabForIn'
code: @[builtin_term_elab forInMacro'] def elabForIn' : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.BinOpKind.regular
code: private inductive BinOpKind where
  | regular   -- `binop%`
  | lazy      -- `binop_lazy%`
  | leftact   -- `leftact%`
  | rightact  -- `rightact%`
deriving BEq
goal: Lean.Elab.Term.Op.BinOpKind

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.BinOpKind.rightact
code: private inductive BinOpKind where
  | regular   -- `binop%`
  | lazy      -- `binop_lazy%`
  | leftact   -- `leftact%`
  | rightact  -- `rightact%`
deriving BEq
goal: Lean.Elab.Term.Op.BinOpKind

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.BinOpKind.leftact
code: private inductive BinOpKind where
  | regular   -- `binop%`
  | lazy      -- `binop_lazy%`
  | leftact   -- `leftact%`
  | rightact  -- `rightact%`
deriving BEq
goal: Lean.Elab.Term.Op.BinOpKind

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.BinOpKind
code: private inductive BinOpKind where
  | regular   -- `binop%`
  | lazy      -- `binop_lazy%`
  | leftact   -- `leftact%`
  | rightact  -- `rightact%`
deriving BEq
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.BinOpKind.lazy
code: private inductive BinOpKind where
  | regular   -- `binop%`
  | lazy      -- `binop_lazy%`
  | leftact   -- `leftact%`
  | rightact  -- `rightact%`
deriving BEq
goal: Lean.Elab.Term.Op.BinOpKind

full_name: Lean.Elab.Term.Op.instBEqBinOpKind
code: BEq
goal: BEq Lean.Elab.Term.Op.BinOpKind

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.Tree.term
code: private inductive Tree where
  /--
  Leaf of the tree.
  We store the `infoTrees` generated when elaborating `val`. These trees become
  subtrees of the infotree nodes generated for `op` nodes.
  -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /--
  `ref` is the original syntax that expanded into `binop%/...`.
  -/
  | binop (ref : Syntax) (kind : BinOpKind) (f : Expr) (lhs rhs : Tree)
  /--
  `ref` is the original syntax that expanded into `unop%`.
  -/
  | unop (ref : Syntax) (f : Expr) (arg : Tree)
  /--
  Used for assembling the info tree. We store this information
  to make sure "go to definition" behaves similarly to notation defined without using `binop%` helper elaborator.
  -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.Tree.macroExpansion
code: private inductive Tree where
  /--
  Leaf of the tree.
  We store the `infoTrees` generated when elaborating `val`. These trees become
  subtrees of the infotree nodes generated for `op` nodes.
  -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /--
  `ref` is the original syntax that expanded into `binop%/...`.
  -/
  | binop (ref : Syntax) (kind : BinOpKind) (f : Expr) (lhs rhs : Tree)
  /--
  `ref` is the original syntax that expanded into `unop%`.
  -/
  | unop (ref : Syntax) (f : Expr) (arg : Tree)
  /--
  Used for assembling the info tree. We store this information
  to make sure "go to definition" behaves similarly to notation defined without using `binop%` helper elaborator.
  -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.Tree.unop
code: private inductive Tree where
  /--
  Leaf of the tree.
  We store the `infoTrees` generated when elaborating `val`. These trees become
  subtrees of the infotree nodes generated for `op` nodes.
  -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /--
  `ref` is the original syntax that expanded into `binop%/...`.
  -/
  | binop (ref : Syntax) (kind : BinOpKind) (f : Expr) (lhs rhs : Tree)
  /--
  `ref` is the original syntax that expanded into `unop%`.
  -/
  | unop (ref : Syntax) (f : Expr) (arg : Tree)
  /--
  Used for assembling the info tree. We store this information
  to make sure "go to definition" behaves similarly to notation defined without using `binop%` helper elaborator.
  -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.Tree
code: private inductive Tree where
  /--
  Leaf of the tree.
  We store the `infoTrees` generated when elaborating `val`. These trees become
  subtrees of the infotree nodes generated for `op` nodes.
  -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /--
  `ref` is the original syntax that expanded into `binop%/...`.
  -/
  | binop (ref : Syntax) (kind : BinOpKind) (f : Expr) (lhs rhs : Tree)
  /--
  `ref` is the original syntax that expanded into `unop%`.
  -/
  | unop (ref : Syntax) (f : Expr) (arg : Tree)
  /--
  Used for assembling the info tree. We store this information
  to make sure "go to definition" behaves similarly to notation defined without using `binop%` helper elaborator.
  -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.Tree.binop
code: private inductive Tree where
  /--
  Leaf of the tree.
  We store the `infoTrees` generated when elaborating `val`. These trees become
  subtrees of the infotree nodes generated for `op` nodes.
  -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /--
  `ref` is the original syntax that expanded into `binop%/...`.
  -/
  | binop (ref : Syntax) (kind : BinOpKind) (f : Expr) (lhs rhs : Tree)
  /--
  `ref` is the original syntax that expanded into `unop%`.
  -/
  | unop (ref : Syntax) (f : Expr) (arg : Tree)
  /--
  Used for assembling the info tree. We store this information
  to make sure "go to definition" behaves similarly to notation defined without using `binop%` helper elaborator.
  -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.toTree
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.toTree.processLeaf
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.toTree.go
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.toTree.processBinOp
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.toTree.processUnOp
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM Lean.Elab.Term.Op.Tree

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.hasCoe
code: private def hasCoe (fromType toType : Expr) : TermElabM Bool 
goal: Lean.Elab.TermElabM Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.AnalyzeResult.hasUncomparable
code: private structure AnalyzeResult where
  max?            : Option Expr := none
  /-- `true` if there are two types `α` and `β` where we don't have coercions in any direction. -/
  hasUncomparable : Bool := false
  /-- `true` if there are any leaf terms with an unknown type (according to `isUnknown`). -/
  hasUnknown      : Bool := false
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.AnalyzeResult
code: private structure AnalyzeResult where
  max?            : Option Expr := none
  /-- `true` if there are two types `α` and `β` where we don't have coercions in any direction. -/
  hasUncomparable : Bool := false
  /-- `true` if there are any leaf terms with an unknown type (according to `isUnknown`). -/
  hasUnknown      : Bool := false
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.AnalyzeResult.max?
code: private structure AnalyzeResult where
  max?            : Option Expr := none
  /-- `true` if there are two types `α` and `β` where we don't have coercions in any direction. -/
  hasUncomparable : Bool := false
  /-- `true` if there are any leaf terms with an unknown type (according to `isUnknown`). -/
  hasUnknown      : Bool := false
goal: Option Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.AnalyzeResult.hasUnknown
code: private structure AnalyzeResult where
  max?            : Option Expr := none
  /-- `true` if there are two types `α` and `β` where we don't have coercions in any direction. -/
  hasUncomparable : Bool := false
  /-- `true` if there are any leaf terms with an unknown type (according to `isUnknown`). -/
  hasUnknown      : Bool := false
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.isUnknown
code: private def isUnknown : Expr → Bool
  
goal: Lean.Expr → Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.analyze.go
code: private def analyze (t : Tree) (expectedType? : Option Expr) : TermElabM AnalyzeResult 
goal: StateRefT' IO.RealWorld Lean.Elab.Term.Op.AnalyzeResult Lean.Elab.TermElabM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.analyze
code: private def analyze (t : Tree) (expectedType? : Option Expr) : TermElabM AnalyzeResult 
goal: Lean.Elab.TermElabM Lean.Elab.Term.Op.AnalyzeResult

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.mkBinOp
code: private def mkBinOp (lazy : Bool) (f : Expr) (lhs rhs : Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.mkUnOp
code: private def mkUnOp (f : Expr) (arg : Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.toExprCore
code: private def toExprCore (t : Tree) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.hasHeterogeneousDefaultInstances
code: /--
  Auxiliary function to decide whether we should coerce `f`'s argument to `maxType` or not.
  - `f` is a binary operator.
  - `lhs == true` (`lhs == false`) if are trying to coerce the left-argument (right-argument).
  This function assumes `f` is a heterogeneous operator (e.g., `HAdd.hAdd`, `HMul.hMul`, etc).
  It returns true IF
  - `f` is a constant of the form `Cls.op` where `Cls` is a class name, and
  - `maxType` is of the form `C ...` where `C` is a constant, and
  - There are more than one default instance. That is, it assumes the class `Cls` for the heterogeneous operator `f`, and
    always has the monomorphic instance. (e.g., for `HAdd`, we have `instance [Add α] : HAdd α α α`), and
  - If `lhs == true`, then there is a default instance of the form `Cls _ (C ..) _`, and
  - If `lhs == false`, then there is a default instance of the form `Cls (C ..) _ _`.

  The motivation is to support default instances such as
  ```
  @[default_instance high]
  instance [Mul α] : HMul α (Array α) (Array α) where
    hMul a as := as.map (a * ·)

  #eval 2 * #[3, 4, 5]
  ```
  If the type of an argument is unknown we should not coerce it to `maxType` because it would prevent
  the default instance above from being even tried.
-/
private def hasHeterogeneousDefaultInstances (f : Expr) (maxType : Expr) (lhs : Bool) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.Extra.0.Lean.Elab.Term.Op.hasHomogeneousInstance
code: /--
  Return `true` if polymorphic function `f` has a homogenous instance of `maxType`.
  The coercions to `maxType` only makes sense if such instance exists.

  For example, suppose `maxType` is `Int`, and `f` is `HPow.hPow`. Then,
  adding coercions to `maxType` only make sense if we have an instance `HPow Int Int Int`.
-/
private def hasHomogeneousInstance (f : Expr) (maxType : Expr) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: Lean.Elab.Term.Op.elabOp
code: def elabOp : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.elabBinOp
code: @[builtin_term_elab binop] def elabBinOp : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.elabBinOpLazy
code: @[builtin_term_elab binop_lazy] def elabBinOpLazy : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.elabLeftact
code: @[builtin_term_elab leftact] def elabLeftact : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.elabRightact
code: @[builtin_term_elab rightact] def elabRightact : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.elabUnOp
code: @[builtin_term_elab unop] def elabUnOp : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.elabBinRelCore.toBoolIfNecessary
code: /--
  Elaboration functions for `binrel%` and `binrel_no_prop%` notations.
  We use the infrastructure for `binop%` to make sure we propagate information between the left and right hand sides
  of a binary relation.

  - `binrel% R x y` elaborates `R x y` using the `binop%/...` expression trees in both `x` and `y`.
    It is similar to how `binop% R x y` elaborates but with a significant difference:
    it does not use the expected type when computing the types of the operands.
  - `binrel_no_prop% R x y` elaborates `R x y` like `binrel% R x y`, but if the resulting type for `x` and `y`
    is `Prop` they are coerced to `Bool`.
    This is used for relations such as `==` which do not support `Prop`, but we still want
    to be able to write `(5 > 2) == (2 > 1)` for example.
-/
def elabBinRelCore (noProp : Bool) (stx : Syntax) (expectedType? : Option Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: Lean.Elab.Term.Op.elabBinRelCore
code: /--
  Elaboration functions for `binrel%` and `binrel_no_prop%` notations.
  We use the infrastructure for `binop%` to make sure we propagate information between the left and right hand sides
  of a binary relation.

  - `binrel% R x y` elaborates `R x y` using the `binop%/...` expression trees in both `x` and `y`.
    It is similar to how `binop% R x y` elaborates but with a significant difference:
    it does not use the expected type when computing the types of the operands.
  - `binrel_no_prop% R x y` elaborates `R x y` like `binrel% R x y`, but if the resulting type for `x` and `y`
    is `Prop` they are coerced to `Bool`.
    This is used for relations such as `==` which do not support `Prop`, but we still want
    to be able to write `(5 > 2) == (2 > 1)` for example.
-/
def elabBinRelCore (noProp : Bool) (stx : Syntax) (expectedType? : Option Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: Lean.Elab.Term.Op.elabBinRel
code: @[builtin_term_elab binrel] def elabBinRel : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.elabBinRelNoProp
code: @[builtin_term_elab binrel_no_prop] def elabBinRelNoProp : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.elabDefaultOrNonempty
code: @[builtin_term_elab defaultOrOfNonempty]
def elabDefaultOrNonempty : TermElab 
goal: Lean.Elab.Term.TermElab

full_name: Lean.Elab.Term.Op.initFn._@..lake.packages.lean4.src.lean.Lean.Elab.Extra._hyg.7032
code: builtin_initialize
  registerTraceClass `Elab.binop
  registerTraceClass `Elab.binrel
goal: IO Unit