File: Mathlib/Tactic/FunProp/FunctionData.lean

full_name: Mathlib.Meta.FunProp.FunctionData.args
code: /-- Structure storing parts of a function in funProp-normal form. -/
structure FunctionData where
  /-- local context where `mainVar` exists -/
  lctx : LocalContext
  /-- local instances -/
  insts : LocalInstances
  /-- main function -/
  fn : Expr
  /-- applied function arguments -/
  args : Array Mor.Arg
  /-- main variable -/
  mainVar : Expr
  /-- indices of `args` that contain `mainVars` -/
  mainArgs : Array Nat
goal: Array Mathlib.Meta.FunProp.Mor.Arg

full_name: Mathlib.Meta.FunProp.FunctionData.fn
code: /-- Structure storing parts of a function in funProp-normal form. -/
structure FunctionData where
  /-- local context where `mainVar` exists -/
  lctx : LocalContext
  /-- local instances -/
  insts : LocalInstances
  /-- main function -/
  fn : Expr
  /-- applied function arguments -/
  args : Array Mor.Arg
  /-- main variable -/
  mainVar : Expr
  /-- indices of `args` that contain `mainVars` -/
  mainArgs : Array Nat
goal: Lean.Expr

full_name: Mathlib.Meta.FunProp.FunctionData.lctx
code: /-- Structure storing parts of a function in funProp-normal form. -/
structure FunctionData where
  /-- local context where `mainVar` exists -/
  lctx : LocalContext
  /-- local instances -/
  insts : LocalInstances
  /-- main function -/
  fn : Expr
  /-- applied function arguments -/
  args : Array Mor.Arg
  /-- main variable -/
  mainVar : Expr
  /-- indices of `args` that contain `mainVars` -/
  mainArgs : Array Nat
goal: Lean.LocalContext

full_name: Mathlib.Meta.FunProp.FunctionData.insts
code: /-- Structure storing parts of a function in funProp-normal form. -/
structure FunctionData where
  /-- local context where `mainVar` exists -/
  lctx : LocalContext
  /-- local instances -/
  insts : LocalInstances
  /-- main function -/
  fn : Expr
  /-- applied function arguments -/
  args : Array Mor.Arg
  /-- main variable -/
  mainVar : Expr
  /-- indices of `args` that contain `mainVars` -/
  mainArgs : Array Nat
goal: Lean.LocalInstances

full_name: Mathlib.Meta.FunProp.FunctionData.mainVar
code: /-- Structure storing parts of a function in funProp-normal form. -/
structure FunctionData where
  /-- local context where `mainVar` exists -/
  lctx : LocalContext
  /-- local instances -/
  insts : LocalInstances
  /-- main function -/
  fn : Expr
  /-- applied function arguments -/
  args : Array Mor.Arg
  /-- main variable -/
  mainVar : Expr
  /-- indices of `args` that contain `mainVars` -/
  mainArgs : Array Nat
goal: Lean.Expr

full_name: Mathlib.Meta.FunProp.FunctionData.mainArgs
code: /-- Structure storing parts of a function in funProp-normal form. -/
structure FunctionData where
  /-- local context where `mainVar` exists -/
  lctx : LocalContext
  /-- local instances -/
  insts : LocalInstances
  /-- main function -/
  fn : Expr
  /-- applied function arguments -/
  args : Array Mor.Arg
  /-- main variable -/
  mainVar : Expr
  /-- indices of `args` that contain `mainVars` -/
  mainArgs : Array Nat
goal: Array ℕ

full_name: Mathlib.Meta.FunProp.FunctionData
code: /-- Structure storing parts of a function in funProp-normal form. -/
structure FunctionData where
  /-- local context where `mainVar` exists -/
  lctx : LocalContext
  /-- local instances -/
  insts : LocalInstances
  /-- main function -/
  fn : Expr
  /-- applied function arguments -/
  args : Array Mor.Arg
  /-- main variable -/
  mainVar : Expr
  /-- indices of `args` that contain `mainVars` -/
  mainArgs : Array Nat
goal: Type

full_name: Mathlib.Meta.FunProp.FunctionData.toExpr
code: /-- Turn function data back to expression. -/
def FunctionData.toExpr (f : FunctionData) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Mathlib.Meta.FunProp.FunctionData.isIdentityFun
code: /-- Is `f` an indentity function? -/
def FunctionData.isIdentityFun (f : FunctionData) : Bool 
goal: Bool

full_name: Mathlib.Meta.FunProp.FunctionData.isConstantFun
code: /-- Is `f` a constant function? -/
def FunctionData.isConstantFun (f : FunctionData) : Bool 
goal: Bool

full_name: Mathlib.Meta.FunProp.FunctionData.domainType
code: /-- Domain type of `f`. -/
def FunctionData.domainType (f : FunctionData) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Mathlib.Meta.FunProp.FunctionData.getFnConstName?
code: /-- Is head function of `f` a constant?

If the head of `f` is a projection return the name of corresponding projection function. -/
def FunctionData.getFnConstName? (f : FunctionData) : MetaM (Option Name) 
goal: Lean.MetaM (Option Lean.Name)

full_name: Mathlib.Meta.FunProp.getFunctionData
code: /-- Get `FunctionData` for `f`. Throws if `f` can't be put into funProp-normal form. -/
def getFunctionData (f : Expr) : MetaM FunctionData 
goal: Lean.MetaM Mathlib.Meta.FunProp.FunctionData

full_name: Mathlib.Meta.FunProp.MaybeFunctionData.lam
code: /-- Result of `getFunctionData?`. It returns function data if the function is in the form
`fun x => f y₁ ... yₙ`. Two other cases are `fun x => let y := ...` or `fun x y => ...` -/
inductive MaybeFunctionData where
  /-- Can't generate function data as function body has let binder. -/
  | letE (f : Expr)
  /-- Can't generate function data as function body has lambda binder. -/
  | lam (f : Expr)
  /-- Function data has been successfully generated. -/
  | data (fData : FunctionData)
goal: Mathlib.Meta.FunProp.MaybeFunctionData

full_name: Mathlib.Meta.FunProp.MaybeFunctionData.data
code: /-- Result of `getFunctionData?`. It returns function data if the function is in the form
`fun x => f y₁ ... yₙ`. Two other cases are `fun x => let y := ...` or `fun x y => ...` -/
inductive MaybeFunctionData where
  /-- Can't generate function data as function body has let binder. -/
  | letE (f : Expr)
  /-- Can't generate function data as function body has lambda binder. -/
  | lam (f : Expr)
  /-- Function data has been successfully generated. -/
  | data (fData : FunctionData)
goal: Mathlib.Meta.FunProp.MaybeFunctionData

full_name: Mathlib.Meta.FunProp.MaybeFunctionData
code: /-- Result of `getFunctionData?`. It returns function data if the function is in the form
`fun x => f y₁ ... yₙ`. Two other cases are `fun x => let y := ...` or `fun x y => ...` -/
inductive MaybeFunctionData where
  /-- Can't generate function data as function body has let binder. -/
  | letE (f : Expr)
  /-- Can't generate function data as function body has lambda binder. -/
  | lam (f : Expr)
  /-- Function data has been successfully generated. -/
  | data (fData : FunctionData)
goal: Type

full_name: Mathlib.Meta.FunProp.MaybeFunctionData.letE
code: /-- Result of `getFunctionData?`. It returns function data if the function is in the form
`fun x => f y₁ ... yₙ`. Two other cases are `fun x => let y := ...` or `fun x y => ...` -/
inductive MaybeFunctionData where
  /-- Can't generate function data as function body has let binder. -/
  | letE (f : Expr)
  /-- Can't generate function data as function body has lambda binder. -/
  | lam (f : Expr)
  /-- Function data has been successfully generated. -/
  | data (fData : FunctionData)
goal: Mathlib.Meta.FunProp.MaybeFunctionData

full_name: Mathlib.Meta.FunProp.MaybeFunctionData.get
code: /-- Turn `MaybeFunctionData` to the function. -/
def MaybeFunctionData.get (fData : MaybeFunctionData) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Mathlib.Meta.FunProp.getFunctionData?
code: /-- Get `FunctionData` for `f`. -/
def getFunctionData? (f : Expr)
    (unfoldPred : Name → Bool := fun _ => false) (cfg : WhnfCoreConfig := {}) :
    MetaM MaybeFunctionData 
goal: Lean.MetaM Mathlib.Meta.FunProp.MaybeFunctionData

full_name: Mathlib.Meta.FunProp.FunctionData.unfoldHeadFVar?
code: /-- If head function is a let-fvar unfold it and return resulting function.
Return `none` otherwise. -/
def FunctionData.unfoldHeadFVar? (fData : FunctionData) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: Mathlib.Meta.FunProp.instInhabitedMorApplication
code: /-- Type of morphism application. -/
inductive MorApplication where
  /-- Of the form `⇑f` i.e. missing argument. -/
  | underApplied
  /-- Of the form `⇑f x` i.e. morphism and one argument is provided. -/
  | exact
  /-- Of the form `⇑f x y ...` i.e. additional applied arguments `y ...`. -/
  | overApplied
  /-- Not a morphism application. -/
  | none
  deriving Inhabited, BEq
goal: Inhabited Mathlib.Meta.FunProp.MorApplication

full_name: Mathlib.Meta.FunProp.MorApplication.none
code: /-- Type of morphism application. -/
inductive MorApplication where
  /-- Of the form `⇑f` i.e. missing argument. -/
  | underApplied
  /-- Of the form `⇑f x` i.e. morphism and one argument is provided. -/
  | exact
  /-- Of the form `⇑f x y ...` i.e. additional applied arguments `y ...`. -/
  | overApplied
  /-- Not a morphism application. -/
  | none
  deriving Inhabited, BEq
goal: Mathlib.Meta.FunProp.MorApplication

full_name: Mathlib.Meta.FunProp.MorApplication
code: /-- Type of morphism application. -/
inductive MorApplication where
  /-- Of the form `⇑f` i.e. missing argument. -/
  | underApplied
  /-- Of the form `⇑f x` i.e. morphism and one argument is provided. -/
  | exact
  /-- Of the form `⇑f x y ...` i.e. additional applied arguments `y ...`. -/
  | overApplied
  /-- Not a morphism application. -/
  | none
  deriving Inhabited, BEq
goal: Type

full_name: Mathlib.Meta.FunProp.MorApplication.underApplied
code: /-- Type of morphism application. -/
inductive MorApplication where
  /-- Of the form `⇑f` i.e. missing argument. -/
  | underApplied
  /-- Of the form `⇑f x` i.e. morphism and one argument is provided. -/
  | exact
  /-- Of the form `⇑f x y ...` i.e. additional applied arguments `y ...`. -/
  | overApplied
  /-- Not a morphism application. -/
  | none
  deriving Inhabited, BEq
goal: Mathlib.Meta.FunProp.MorApplication

full_name: Mathlib.Meta.FunProp.MorApplication.exact
code: /-- Type of morphism application. -/
inductive MorApplication where
  /-- Of the form `⇑f` i.e. missing argument. -/
  | underApplied
  /-- Of the form `⇑f x` i.e. morphism and one argument is provided. -/
  | exact
  /-- Of the form `⇑f x y ...` i.e. additional applied arguments `y ...`. -/
  | overApplied
  /-- Not a morphism application. -/
  | none
  deriving Inhabited, BEq
goal: Mathlib.Meta.FunProp.MorApplication

full_name: Mathlib.Meta.FunProp.MorApplication.overApplied
code: /-- Type of morphism application. -/
inductive MorApplication where
  /-- Of the form `⇑f` i.e. missing argument. -/
  | underApplied
  /-- Of the form `⇑f x` i.e. morphism and one argument is provided. -/
  | exact
  /-- Of the form `⇑f x y ...` i.e. additional applied arguments `y ...`. -/
  | overApplied
  /-- Not a morphism application. -/
  | none
  deriving Inhabited, BEq
goal: Mathlib.Meta.FunProp.MorApplication

full_name: Mathlib.Meta.FunProp.instBEqMorApplication
code: BEq
goal: BEq Mathlib.Meta.FunProp.MorApplication

full_name: Mathlib.Meta.FunProp.FunctionData.isMorApplication
code: /-- Is function body of `f` a morphism application? What kind? -/
def FunctionData.isMorApplication (f : FunctionData) : MetaM MorApplication 
goal: Lean.MetaM Mathlib.Meta.FunProp.MorApplication

full_name: Mathlib.Meta.FunProp.FunctionData.peeloffArgDecomposition
code: /-- Decomposes `fun x => f y₁ ... yₙ` into `(fun g => g yₙ) ∘ (fun x y => f y₁ ... yₙ₋₁ y)`

Returns none if:
  - `n=0`
  - `yₙ` contains `x`
  - `n=1` and `(fun x y => f y)` is identity function i.e. `x=f` -/
def FunctionData.peeloffArgDecomposition (fData : FunctionData) : MetaM (Option (Expr × Expr)) 
goal: Lean.MetaM (Option (Lean.Expr × Lean.Expr))

full_name: Mathlib.Meta.FunProp.FunctionData.nontrivialDecomposition
code: /-- Decompose function `f = (← fData.toExpr)` into composition of two functions.

Returns none if the decomposition would produce composition with identity function. -/
def FunctionData.nontrivialDecomposition (fData : FunctionData) : MetaM (Option (Expr × Expr)) 
goal: Lean.MetaM (Option (Lean.Expr × Lean.Expr))

full_name: Mathlib.Meta.FunProp.FunctionData.decompositionOverArgs
code: /-- Decompose function `fun x => f y₁ ... yₙ` over specified argument indices `#[i, j, ...]`.

The result is:
```
(fun (yᵢ',yⱼ',...) => f y₁ .. yᵢ' .. yⱼ' .. yₙ) ∘ (fun x => (yᵢ, yⱼ, ...))
```

This is not possible if `yₗ` for `l ∉ #[i,j,...]` still contains `x`.
In such case `none` is returned.
-/
def FunctionData.decompositionOverArgs (fData : FunctionData) (args : Array Nat) :
    MetaM (Option (Expr × Expr)) 
goal: Lean.MetaM (Option (Lean.Expr × Lean.Expr))