File: Mathlib/Tactic/FBinop.lean

full_name: FBinopElab.initFn._@.Mathlib.Tactic.FBinop._hyg.6
code: initialize registerTraceClass `Elab.fbinop
goal: IO Unit

full_name: FBinopElab.prodSyntax
code: /-- `fbinop% f x y` elaborates `f x y` for `x : S α` and `y : S' β`, taking into account
any coercions that the "functors" `S` and `S'` possess. -/
syntax:max (name := prodSyntax) "fbinop% " ident ppSpace term:max ppSpace term:max : term
goal: Lean.ParserDescr

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.Tree.macroExpansion
code: /-- Tree recording the structure of the `fbinop%` expression. -/
private inductive Tree where
  /-- Leaf of the tree. Stores the generated `InfoTree` from elaborating `val`. -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /-- An `fbinop%` node.
  `ref` is the original syntax that expanded into `binop%`.
  `f` is the constant for the binary operator -/
  | binop (ref : Syntax) (f : Expr) (lhs rhs : Tree)
  /-- Store macro expansion information to make sure that "go to definition" behaves
  similarly to notation defined without using `fbinop%`. -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: FBinopElab.Tree

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.Tree
code: /-- Tree recording the structure of the `fbinop%` expression. -/
private inductive Tree where
  /-- Leaf of the tree. Stores the generated `InfoTree` from elaborating `val`. -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /-- An `fbinop%` node.
  `ref` is the original syntax that expanded into `binop%`.
  `f` is the constant for the binary operator -/
  | binop (ref : Syntax) (f : Expr) (lhs rhs : Tree)
  /-- Store macro expansion information to make sure that "go to definition" behaves
  similarly to notation defined without using `fbinop%`. -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: Type

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.Tree.binop
code: /-- Tree recording the structure of the `fbinop%` expression. -/
private inductive Tree where
  /-- Leaf of the tree. Stores the generated `InfoTree` from elaborating `val`. -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /-- An `fbinop%` node.
  `ref` is the original syntax that expanded into `binop%`.
  `f` is the constant for the binary operator -/
  | binop (ref : Syntax) (f : Expr) (lhs rhs : Tree)
  /-- Store macro expansion information to make sure that "go to definition" behaves
  similarly to notation defined without using `fbinop%`. -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: FBinopElab.Tree

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.Tree.term
code: /-- Tree recording the structure of the `fbinop%` expression. -/
private inductive Tree where
  /-- Leaf of the tree. Stores the generated `InfoTree` from elaborating `val`. -/
  | term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
  /-- An `fbinop%` node.
  `ref` is the original syntax that expanded into `binop%`.
  `f` is the constant for the binary operator -/
  | binop (ref : Syntax) (f : Expr) (lhs rhs : Tree)
  /-- Store macro expansion information to make sure that "go to definition" behaves
  similarly to notation defined without using `fbinop%`. -/
  | macroExpansion (macroName : Name) (stx stx' : Syntax) (nested : Tree)
goal: FBinopElab.Tree

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.toTree.processBinOp
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM FBinopElab.Tree

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.toTree.go
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM FBinopElab.Tree

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.toTree.processLeaf
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM FBinopElab.Tree

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.toTree
code: private partial def toTree (s : Syntax) : TermElabM Tree 
goal: Lean.Elab.TermElabM FBinopElab.Tree

full_name: FBinopElab.SRec.args
code: /-- Records a "functor", which is some function `Type u → Type v`. We only
allow `c a1 ... an` for `c` a constant. This is so we can abstract out the universe variables. -/
structure SRec where
  name : Name
  args : Array Expr
  deriving Inhabited, ToExpr
goal: Array Lean.Expr

full_name: FBinopElab.SRec.name
code: /-- Records a "functor", which is some function `Type u → Type v`. We only
allow `c a1 ... an` for `c` a constant. This is so we can abstract out the universe variables. -/
structure SRec where
  name : Name
  args : Array Expr
  deriving Inhabited, ToExpr
goal: Lean.Name

full_name: FBinopElab.instInhabitedSRec
code: /-- Records a "functor", which is some function `Type u → Type v`. We only
allow `c a1 ... an` for `c` a constant. This is so we can abstract out the universe variables. -/
structure SRec where
  name : Name
  args : Array Expr
  deriving Inhabited, ToExpr
goal: Inhabited FBinopElab.SRec

full_name: FBinopElab.SRec
code: /-- Records a "functor", which is some function `Type u → Type v`. We only
allow `c a1 ... an` for `c` a constant. This is so we can abstract out the universe variables. -/
structure SRec where
  name : Name
  args : Array Expr
  deriving Inhabited, ToExpr
goal: Type

full_name: FBinopElab.instToExprSRec
code: /-- Records a "functor", which is some function `Type u → Type v`. We only
allow `c a1 ... an` for `c` a constant. This is so we can abstract out the universe variables. -/
structure SRec where
  name : Name
  args : Array Expr
  deriving Inhabited, ToExpr
goal: Lean.ToExpr FBinopElab.SRec

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.extractS
code: /-- Given a type expression, try to remove the last argument(s) and create an `SRec` for the
underlying "functor". Only applies to function applications with a constant head, and,
after dropping all instance arguments, it requires that the remaining last argument be a type.
Returns the `SRec` and the argument. -/
private partial def extractS (e : Expr) : TermElabM (Option (SRec × Expr)) 
goal: Lean.Elab.TermElabM (Option (FBinopElab.SRec × Lean.Expr))

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.applyS
code: /-- Computes `S x := c a1 ... an x` if it is type correct.
Inserts instance arguments after `x`. -/
private def applyS (S : SRec) (x : Expr) : TermElabM (Option Expr) 
goal: Lean.Elab.TermElabM (Option Lean.Expr)

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.hasCoeS
code: /-- For a given argument `x`, checks if there is a coercion from `fromS x` to `toS x`
if these expressions are type correct. -/
private def hasCoeS (fromS toS : SRec) (x : Expr) : TermElabM Bool 
goal: Lean.Elab.TermElabM Bool

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.AnalyzeResult.maxS?
code: /-- Result returned by `analyze`. -/
private structure AnalyzeResult where
  maxS? : Option SRec := none
  /-- `true` if there are two types `α` and `β` where we don't have coercions in any direction. -/
  hasUncomparable : Bool := false
goal: Option FBinopElab.SRec

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.AnalyzeResult.hasUncomparable
code: /-- Result returned by `analyze`. -/
private structure AnalyzeResult where
  maxS? : Option SRec := none
  /-- `true` if there are two types `α` and `β` where we don't have coercions in any direction. -/
  hasUncomparable : Bool := false
goal: Bool

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.AnalyzeResult
code: /-- Result returned by `analyze`. -/
private structure AnalyzeResult where
  maxS? : Option SRec := none
  /-- `true` if there are two types `α` and `β` where we don't have coercions in any direction. -/
  hasUncomparable : Bool := false
goal: Type

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.analyze
code: /-- Compute a minimal `SRec` for an expression tree. -/
private def analyze (t : Tree) (expectedType? : Option Expr) : TermElabM AnalyzeResult 
goal: Lean.Elab.TermElabM FBinopElab.AnalyzeResult

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.analyze.go
code: /-- Compute a minimal `SRec` for an expression tree. -/
private def analyze (t : Tree) (expectedType? : Option Expr) : TermElabM AnalyzeResult 
goal: StateRefT' IO.RealWorld FBinopElab.AnalyzeResult Lean.Elab.TermElabM Unit

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.mkBinOp
code: private def mkBinOp (f : Expr) (lhs rhs : Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.toExprCore
code: /-- Turn a tree back into an expression. -/
private def toExprCore (t : Tree) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.applyCoe.go
code: /-- Try to coerce elements in the tree to `maxS` when needed. -/
private def applyCoe (t : Tree) (maxS : SRec) : TermElabM Tree 
goal: Lean.Elab.TermElabM FBinopElab.Tree

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.applyCoe
code: /-- Try to coerce elements in the tree to `maxS` when needed. -/
private def applyCoe (t : Tree) (maxS : SRec) : TermElabM Tree 
goal: Lean.Elab.TermElabM FBinopElab.Tree

full_name: _private.Mathlib.Tactic.FBinop.0.FBinopElab.toExpr
code: private def toExpr (tree : Tree) (expectedType? : Option Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: FBinopElab.elabBinOp
code: @[term_elab prodSyntax]
def elabBinOp : TermElab 
goal: Lean.Elab.Term.TermElab