File: .lake/packages/lean4/src/lean/Lean/Compiler/LCNF/Simp/DiscrM.lean

full_name: Lean.Compiler.LCNF.Simp.CtorInfo.natVal
code: inductive CtorInfo where
  | ctor (val : ConstructorVal) (args : Array Arg)
  | /-- Natural numbers are morally constructor applications -/
    natVal (n : Nat)
goal: Lean.Compiler.LCNF.Simp.CtorInfo

full_name: Lean.Compiler.LCNF.Simp.CtorInfo.ctor
code: inductive CtorInfo where
  | ctor (val : ConstructorVal) (args : Array Arg)
  | /-- Natural numbers are morally constructor applications -/
    natVal (n : Nat)
goal: Lean.Compiler.LCNF.Simp.CtorInfo

full_name: Lean.Compiler.LCNF.Simp.CtorInfo
code: inductive CtorInfo where
  | ctor (val : ConstructorVal) (args : Array Arg)
  | /-- Natural numbers are morally constructor applications -/
    natVal (n : Nat)
goal: Type

full_name: Lean.Compiler.LCNF.Simp.CtorInfo.getName
code: def CtorInfo.getName : CtorInfo → Name
  
goal: Lean.Compiler.LCNF.Simp.CtorInfo → Lean.Name

full_name: Lean.Compiler.LCNF.Simp.CtorInfo.getNumParams
code: def CtorInfo.getNumParams : CtorInfo → Nat
  
goal: Lean.Compiler.LCNF.Simp.CtorInfo → Nat

full_name: Lean.Compiler.LCNF.Simp.CtorInfo.getNumFields
code: def CtorInfo.getNumFields : CtorInfo → Nat
  
goal: Lean.Compiler.LCNF.Simp.CtorInfo → Nat

full_name: Lean.Compiler.LCNF.Simp.DiscrM.Context.discrCtorMap
code: structure DiscrM.Context where
  /--
  A mapping from discriminant to constructor application it is equal to in the current context.
  -/
  discrCtorMap : FVarIdMap CtorInfo := {}
  /--
  A mapping from constructor application to discriminant it is equal to in the current context.
  -/
  ctorDiscrMap : PersistentExprMap FVarId := {}
goal: Lean.FVarIdMap Lean.Compiler.LCNF.Simp.CtorInfo

full_name: Lean.Compiler.LCNF.Simp.DiscrM.Context
code: structure DiscrM.Context where
  /--
  A mapping from discriminant to constructor application it is equal to in the current context.
  -/
  discrCtorMap : FVarIdMap CtorInfo := {}
  /--
  A mapping from constructor application to discriminant it is equal to in the current context.
  -/
  ctorDiscrMap : PersistentExprMap FVarId := {}
goal: Type

full_name: Lean.Compiler.LCNF.Simp.DiscrM.Context.ctorDiscrMap
code: structure DiscrM.Context where
  /--
  A mapping from discriminant to constructor application it is equal to in the current context.
  -/
  discrCtorMap : FVarIdMap CtorInfo := {}
  /--
  A mapping from constructor application to discriminant it is equal to in the current context.
  -/
  ctorDiscrMap : PersistentExprMap FVarId := {}
goal: Lean.PersistentExprMap Lean.FVarId

full_name: Lean.Compiler.LCNF.Simp.DiscrM
code: /--
Helper monad for tracking mappings from discriminant to constructor applications and back.
The combinator `withDiscrCtor` should be used when visiting `cases` alternatives.
-/
abbrev DiscrM 
goal: Type

full_name: Lean.Compiler.LCNF.Simp.findCtor?
code: /--
If `fvarId` is a constructor application, returns constructor information.
Remark: we use the map `discrCtorMap`.
Remark: We use this method when simplifying projections and cases-constructor.
-/
def findCtor? (fvarId : FVarId) : DiscrM (Option CtorInfo) 
goal: Lean.Compiler.LCNF.Simp.DiscrM (Option Lean.Compiler.LCNF.Simp.CtorInfo)

full_name: Lean.Compiler.LCNF.Simp.findCtorName?
code: def findCtorName? (fvarId : FVarId) : DiscrM (Option Name) 
goal: Lean.Compiler.LCNF.Simp.DiscrM (Option Lean.Name)

full_name: Lean.Compiler.LCNF.Simp.getIndInfo?
code: /--
If `type` is an inductive datatype, return its universe levels and parameters.
-/
def getIndInfo? (type : Expr) : CoreM (Option (List Level × Array Arg)) 
goal: Lean.CoreM (Option (List Lean.Level × Array Lean.Compiler.LCNF.Arg))

full_name: Lean.Compiler.LCNF.Simp.withDiscrCtorImp
code: /--
Execute `x` with the information that `discr = ctorName ctorFields`.
We use this information to simplify nested cases on the same discriminant.
-/
@[inline] def withDiscrCtorImp (discr : FVarId) (ctorName : Name) (ctorFields : Array Param) (x : DiscrM α) : DiscrM α 
goal: Lean.Compiler.LCNF.Simp.DiscrM α

full_name: Lean.Compiler.LCNF.Simp.withDiscrCtorImp.updateCtx
code: /--
Execute `x` with the information that `discr = ctorName ctorFields`.
We use this information to simplify nested cases on the same discriminant.
-/
@[inline] def withDiscrCtorImp (discr : FVarId) (ctorName : Name) (ctorFields : Array Param) (x : DiscrM α) : DiscrM α 
goal: Lean.Compiler.LCNF.Simp.DiscrM Lean.Compiler.LCNF.Simp.DiscrM.Context

full_name: Lean.Compiler.LCNF.Simp.withDiscrCtor
code: @[inline, inherit_doc withDiscrCtorImp] def withDiscrCtor [MonadFunctorT DiscrM m] (discr : FVarId) (ctorName : Name) (ctorFields : Array Param) : m α → m α 
goal: m α → m α

full_name: Lean.Compiler.LCNF.Simp.simpCtorDiscrCore?
code: def simpCtorDiscrCore? (e : Expr) : DiscrM (Option FVarId) 
goal: Lean.Compiler.LCNF.Simp.DiscrM (Option Lean.FVarId)