File: .lake/packages/lean4/src/lean/Lean/Meta/Tactic/Simp/Simproc.lean

full_name: Lean.Meta.Simp.BuiltinSimprocs
code: /--
Builtin simproc declaration extension state.

It contains:
- The discrimination tree keys for each simproc (including symbolic evaluation procedures) name.
- The actual procedure associated with a name.
-/
structure BuiltinSimprocs where
  keys  : HashMap Name (Array SimpTheoremKey) := {}
  procs : HashMap Name (Sum Simproc DSimproc) := {}
  deriving Inhabited
goal: Type

full_name: Lean.Meta.Simp.BuiltinSimprocs.procs
code: /--
Builtin simproc declaration extension state.

It contains:
- The discrimination tree keys for each simproc (including symbolic evaluation procedures) name.
- The actual procedure associated with a name.
-/
structure BuiltinSimprocs where
  keys  : HashMap Name (Array SimpTheoremKey) := {}
  procs : HashMap Name (Sum Simproc DSimproc) := {}
  deriving Inhabited
goal: Lean.HashMap Lean.Name (Lean.Meta.Simp.Simproc ⊕ Lean.Meta.Simp.DSimproc)

full_name: Lean.Meta.Simp.instInhabitedBuiltinSimprocs
code: /--
Builtin simproc declaration extension state.

It contains:
- The discrimination tree keys for each simproc (including symbolic evaluation procedures) name.
- The actual procedure associated with a name.
-/
structure BuiltinSimprocs where
  keys  : HashMap Name (Array SimpTheoremKey) := {}
  procs : HashMap Name (Sum Simproc DSimproc) := {}
  deriving Inhabited
goal: Inhabited Lean.Meta.Simp.BuiltinSimprocs

full_name: Lean.Meta.Simp.BuiltinSimprocs.keys
code: /--
Builtin simproc declaration extension state.

It contains:
- The discrimination tree keys for each simproc (including symbolic evaluation procedures) name.
- The actual procedure associated with a name.
-/
structure BuiltinSimprocs where
  keys  : HashMap Name (Array SimpTheoremKey) := {}
  procs : HashMap Name (Sum Simproc DSimproc) := {}
  deriving Inhabited
goal: Lean.HashMap Lean.Name (Array Lean.Meta.SimpTheoremKey)

full_name: Lean.Meta.Simp.builtinSimprocDeclsRef
code: /--
This global reference is populated using the command `builtin_simproc_pattern%`.

This reference is then used to process the attributes `builtin_simproc` and `builtin_sevalproc`.
Both attributes need the keys and the actual procedure registered using the command `builtin_simproc_pattern%`.
-/
builtin_initialize builtinSimprocDeclsRef : IO.Ref BuiltinSimprocs ← IO.mkRef {}
goal: IO.Ref Lean.Meta.Simp.BuiltinSimprocs

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.60
code: /--
This global reference is populated using the command `builtin_simproc_pattern%`.

This reference is then used to process the attributes `builtin_simproc` and `builtin_sevalproc`.
Both attributes need the keys and the actual procedure registered using the command `builtin_simproc_pattern%`.
-/
builtin_initialize builtinSimprocDeclsRef : IO.Ref BuiltinSimprocs ← IO.mkRef {}
goal: IO (IO.Ref Lean.Meta.Simp.BuiltinSimprocs)

full_name: Lean.Meta.Simp.SimprocDecl
code: structure SimprocDecl where
  declName : Name
  keys     : Array SimpTheoremKey
  deriving Inhabited
goal: Type

full_name: Lean.Meta.Simp.SimprocDecl.declName
code: structure SimprocDecl where
  declName : Name
  keys     : Array SimpTheoremKey
  deriving Inhabited
goal: Lean.Name

full_name: Lean.Meta.Simp.instInhabitedSimprocDecl
code: structure SimprocDecl where
  declName : Name
  keys     : Array SimpTheoremKey
  deriving Inhabited
goal: Inhabited Lean.Meta.Simp.SimprocDecl

full_name: Lean.Meta.Simp.SimprocDecl.keys
code: structure SimprocDecl where
  declName : Name
  keys     : Array SimpTheoremKey
  deriving Inhabited
goal: Array Lean.Meta.SimpTheoremKey

full_name: Lean.Meta.Simp.SimprocDeclExtState
code: structure SimprocDeclExtState where
  builtin    : HashMap Name (Array SimpTheoremKey)
  newEntries : PHashMap Name (Array SimpTheoremKey) := {}
  deriving Inhabited
goal: Type

full_name: Lean.Meta.Simp.instInhabitedSimprocDeclExtState
code: structure SimprocDeclExtState where
  builtin    : HashMap Name (Array SimpTheoremKey)
  newEntries : PHashMap Name (Array SimpTheoremKey) := {}
  deriving Inhabited
goal: Inhabited Lean.Meta.Simp.SimprocDeclExtState

full_name: Lean.Meta.Simp.SimprocDeclExtState.builtin
code: structure SimprocDeclExtState where
  builtin    : HashMap Name (Array SimpTheoremKey)
  newEntries : PHashMap Name (Array SimpTheoremKey) := {}
  deriving Inhabited
goal: Lean.HashMap Lean.Name (Array Lean.Meta.SimpTheoremKey)

full_name: Lean.Meta.Simp.SimprocDeclExtState.newEntries
code: structure SimprocDeclExtState where
  builtin    : HashMap Name (Array SimpTheoremKey)
  newEntries : PHashMap Name (Array SimpTheoremKey) := {}
  deriving Inhabited
goal: Lean.PHashMap Lean.Name (Array Lean.Meta.SimpTheoremKey)

full_name: Lean.Meta.Simp.SimprocDecl.lt
code: def SimprocDecl.lt (decl₁ decl₂ : SimprocDecl) : Bool 
goal: Bool

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.189
code: builtin_initialize simprocDeclExt : PersistentEnvExtension SimprocDecl SimprocDecl SimprocDeclExtState ←
  registerPersistentEnvExtension {
    mkInitial       := return { builtin := (← builtinSimprocDeclsRef.get).keys }
    addImportedFn   := fun _ => return { builtin := (← builtinSimprocDeclsRef.get).keys }
    addEntryFn      := fun s d => { s with newEntries := s.newEntries.insert d.declName d.keys }
    exportEntriesFn := fun s =>
      let result := s.newEntries.foldl (init := #[]) fun result declName keys => result.push { declName, keys }
      result.qsort SimprocDecl.lt
  }
goal: IO
  (Lean.PersistentEnvExtension Lean.Meta.Simp.SimprocDecl Lean.Meta.Simp.SimprocDecl Lean.Meta.Simp.SimprocDeclExtState)

full_name: Lean.Meta.Simp.simprocDeclExt
code: builtin_initialize simprocDeclExt : PersistentEnvExtension SimprocDecl SimprocDecl SimprocDeclExtState ←
  registerPersistentEnvExtension {
    mkInitial       := return { builtin := (← builtinSimprocDeclsRef.get).keys }
    addImportedFn   := fun _ => return { builtin := (← builtinSimprocDeclsRef.get).keys }
    addEntryFn      := fun s d => { s with newEntries := s.newEntries.insert d.declName d.keys }
    exportEntriesFn := fun s =>
      let result := s.newEntries.foldl (init := #[]) fun result declName keys => result.push { declName, keys }
      result.qsort SimprocDecl.lt
  }
goal: Lean.PersistentEnvExtension Lean.Meta.Simp.SimprocDecl Lean.Meta.Simp.SimprocDecl Lean.Meta.Simp.SimprocDeclExtState

full_name: Lean.Meta.Simp.getSimprocDeclKeys?
code: def getSimprocDeclKeys? (declName : Name) : CoreM (Option (Array SimpTheoremKey)) 
goal: Lean.CoreM (Option (Array Lean.Meta.SimpTheoremKey))

full_name: Lean.Meta.Simp.isBuiltinSimproc
code: def isBuiltinSimproc (declName : Name) : CoreM Bool 
goal: Lean.CoreM Bool

full_name: Lean.Meta.Simp.isSimproc
code: def isSimproc (declName : Name) : CoreM Bool 
goal: Lean.CoreM Bool

full_name: Lean.Meta.Simp.registerBuiltinSimprocCore
code: /--
Given a declaration name `declName`, store the discrimination tree keys and the actual procedure.

This method is invoked by the command `builtin_simproc_pattern%` elaborator.
-/
def registerBuiltinSimprocCore (declName : Name) (key : Array SimpTheoremKey) (proc : Sum Simproc DSimproc) : IO Unit 
goal: IO Unit

full_name: Lean.Meta.Simp.registerBuiltinSimproc
code: def registerBuiltinSimproc (declName : Name) (key : Array SimpTheoremKey) (proc : Simproc) : IO Unit 
goal: IO Unit

full_name: Lean.Meta.Simp.registerBuiltinDSimproc
code: def registerBuiltinDSimproc (declName : Name) (key : Array SimpTheoremKey) (proc : DSimproc) : IO Unit 
goal: IO Unit

full_name: Lean.Meta.Simp.registerSimproc
code: def registerSimproc (declName : Name) (keys : Array SimpTheoremKey) : CoreM Unit 
goal: Lean.CoreM Unit

full_name: Lean.Meta.Simp.«instBEqSimprocEntry_.lake»
code: instance : BEq SimprocEntry 
goal: BEq Lean.Meta.Simp.SimprocEntry

full_name: Lean.Meta.Simp.«instToFormatSimprocEntry_.lake»
code: instance : ToFormat SimprocEntry 
goal: Lean.ToFormat Lean.Meta.Simp.SimprocEntry

full_name: Lean.Meta.Simp.Simprocs.erase
code: def Simprocs.erase (s : Simprocs) (declName : Name) : Simprocs 
goal: Lean.Meta.Simprocs

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.1144
code: /-- Builtin simprocs. -/
builtin_initialize builtinSimprocsRef : IO.Ref Simprocs ← IO.mkRef {}
goal: IO (IO.Ref Lean.Meta.Simprocs)

full_name: Lean.Meta.Simp.builtinSimprocsRef
code: /-- Builtin simprocs. -/
builtin_initialize builtinSimprocsRef : IO.Ref Simprocs ← IO.mkRef {}
goal: IO.Ref Lean.Meta.Simprocs

full_name: Lean.Meta.Simp.builtinSEvalprocsRef
code: /-- Builtin symbolic evaluation procedures. -/
builtin_initialize builtinSEvalprocsRef : IO.Ref Simprocs ← IO.mkRef {}
goal: IO.Ref Lean.Meta.Simprocs

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.1180
code: /-- Builtin symbolic evaluation procedures. -/
builtin_initialize builtinSEvalprocsRef : IO.Ref Simprocs ← IO.mkRef {}
goal: IO (IO.Ref Lean.Meta.Simprocs)

full_name: Lean.Meta.Simp.SimprocExtension
code: abbrev SimprocExtension 
goal: Type

full_name: Lean.Meta.Simp.getSimprocFromDeclImpl
code: unsafe def getSimprocFromDeclImpl (declName : Name) : ImportM (Sum Simproc DSimproc) 
goal: Lean.ImportM (Lean.Meta.Simp.Simproc ⊕ Lean.Meta.Simp.DSimproc)

full_name: Lean.Meta.Simp.getSimprocFromDecl
code: @[implemented_by getSimprocFromDeclImpl]
opaque getSimprocFromDecl (declName: Name) : ImportM (Sum Simproc DSimproc)
goal: Lean.ImportM (Lean.Meta.Simp.Simproc ⊕ Lean.Meta.Simp.DSimproc)

full_name: Lean.Meta.Simp.toSimprocEntry
code: def toSimprocEntry (e : SimprocOLeanEntry) : ImportM SimprocEntry 
goal: Lean.ImportM Lean.Meta.Simp.SimprocEntry

full_name: Lean.Meta.Simp.eraseSimprocAttr
code: def eraseSimprocAttr (ext : SimprocExtension) (declName : Name) : AttrM Unit 
goal: Lean.AttrM Unit

full_name: Lean.Meta.Simp.addSimprocAttrCore
code: def addSimprocAttrCore (ext : SimprocExtension) (declName : Name) (kind : AttributeKind) (post : Bool) : CoreM Unit 
goal: Lean.CoreM Unit

full_name: Lean.Meta.Simp.Simprocs.addCore
code: def Simprocs.addCore (s : Simprocs) (keys : Array SimpTheoremKey) (declName : Name) (post : Bool) (proc : Sum Simproc DSimproc) : Simprocs 
goal: Lean.Meta.Simprocs

full_name: Lean.Meta.Simp.addSimprocBuiltinAttrCore
code: /--
Implements attributes `builtin_simproc` and `builtin_sevalproc`.
-/
def addSimprocBuiltinAttrCore (ref : IO.Ref Simprocs) (declName : Name) (post : Bool) (proc : Sum Simproc DSimproc) : IO Unit 
goal: IO Unit

full_name: Lean.Meta.Simp.addSimprocBuiltinAttr
code: def addSimprocBuiltinAttr (declName : Name) (post : Bool) (proc : Sum Simproc DSimproc) : IO Unit 
goal: IO Unit

full_name: Lean.Meta.Simp.addSEvalprocBuiltinAttr
code: def addSEvalprocBuiltinAttr (declName : Name) (post : Bool) (proc : Sum Simproc DSimproc) : IO Unit 
goal: IO Unit

full_name: Lean.Meta.Simp.Simprocs.add
code: def Simprocs.add (s : Simprocs) (declName : Name) (post : Bool) : CoreM Simprocs 
goal: Lean.CoreM Lean.Meta.Simprocs

full_name: Lean.Meta.Simp.SimprocEntry.try
code: def SimprocEntry.try (s : SimprocEntry) (numExtraArgs : Nat) (e : Expr) : SimpM Step 
goal: Lean.Meta.SimpM Lean.Meta.Simp.Step

full_name: Lean.Meta.Simp.SimprocEntry.tryD
code: /-- Similar to `try`, but only consider `DSimproc` case. That is, if `s.proc` is a `Simproc`, treat it as a `.continue`. -/
def SimprocEntry.tryD (s : SimprocEntry) (numExtraArgs : Nat) (e : Expr) : SimpM DStep 
goal: Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: Lean.Meta.Simp.simprocCore
code: def simprocCore (post : Bool) (s : SimprocTree) (erased : PHashSet Name) (e : Expr) : SimpM Step 
goal: Lean.Meta.SimpM Lean.Meta.Simp.Step

full_name: Lean.Meta.Simp.dsimprocCore
code: def dsimprocCore (post : Bool) (s : SimprocTree) (erased : PHashSet Name) (e : Expr) : SimpM DStep 
goal: Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: Lean.Meta.Simp.SimprocsArray
code: abbrev SimprocsArray 
goal: Type

full_name: Lean.Meta.Simp.SimprocsArray.add
code: def SimprocsArray.add (ss : SimprocsArray) (declName : Name) (post : Bool) : CoreM SimprocsArray 
goal: Lean.CoreM Lean.Meta.Simp.SimprocsArray

full_name: Lean.Meta.Simp.SimprocsArray.erase
code: def SimprocsArray.erase (ss : SimprocsArray) (declName : Name) : SimprocsArray 
goal: Lean.Meta.Simp.SimprocsArray

full_name: Lean.Meta.Simp.SimprocsArray.isErased
code: def SimprocsArray.isErased (ss : SimprocsArray) (declName : Name) : Bool 
goal: Bool

full_name: Lean.Meta.Simp.simprocArrayCore
code: def simprocArrayCore (post : Bool) (ss : SimprocsArray) (e : Expr) : SimpM Step 
goal: Lean.Meta.SimpM Lean.Meta.Simp.Step

full_name: Lean.Meta.Simp.dsimprocArrayCore
code: def dsimprocArrayCore (post : Bool) (ss : SimprocsArray) (e : Expr) : SimpM DStep 
goal: Lean.Meta.SimpM Lean.Meta.Simp.DStep

full_name: Lean.Meta.Simp.simprocs
code: register_builtin_option simprocs : Bool := {
  defValue := true
  group    := "backward compatibility"
  descr    := "Enable/disable `simproc`s (simplification procedures)."
}
goal: Lean.Option Bool

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.5431
code: register_builtin_option simprocs : Bool := {
  defValue := true
  group    := "backward compatibility"
  descr    := "Enable/disable `simproc`s (simplification procedures)."
}
goal: IO (Lean.Option Bool)

full_name: Lean.Meta.Simp.userPreSimprocs
code: def userPreSimprocs (s : SimprocsArray) : Simproc 
goal: Lean.Meta.Simp.Simproc

full_name: Lean.Meta.Simp.userPostSimprocs
code: def userPostSimprocs (s : SimprocsArray) : Simproc 
goal: Lean.Meta.Simp.Simproc

full_name: Lean.Meta.Simp.userPreDSimprocs
code: def userPreDSimprocs (s : SimprocsArray) : DSimproc 
goal: Lean.Meta.Simp.DSimproc

full_name: Lean.Meta.Simp.userPostDSimprocs
code: def userPostDSimprocs (s : SimprocsArray) : DSimproc 
goal: Lean.Meta.Simp.DSimproc

full_name: Lean.Meta.Simp.mkSimprocExt
code: def mkSimprocExt (name : Name := by exact decl_name%) (ref? : Option (IO.Ref Simprocs)) : IO SimprocExtension 
goal: IO Lean.Meta.Simp.SimprocExtension

full_name: Lean.Meta.Simp.addSimprocAttr
code: def addSimprocAttr (ext : SimprocExtension) (declName : Name) (stx : Syntax) (attrKind : AttributeKind) : AttrM Unit 
goal: Lean.AttrM Unit

full_name: Lean.Meta.Simp.mkSimprocAttr
code: def mkSimprocAttr (attrName : Name) (attrDescr : String) (ext : SimprocExtension) (name : Name) : IO Unit 
goal: IO Unit

full_name: Lean.Meta.Simp.SimprocExtensionMap
code: abbrev SimprocExtensionMap 
goal: Type

full_name: Lean.Meta.Simp.simprocExtensionMapRef
code: builtin_initialize simprocExtensionMapRef : IO.Ref SimprocExtensionMap ← IO.mkRef {}
goal: IO.Ref Lean.Meta.Simp.SimprocExtensionMap

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.6021
code: builtin_initialize simprocExtensionMapRef : IO.Ref SimprocExtensionMap ← IO.mkRef {}
goal: IO (IO.Ref Lean.Meta.Simp.SimprocExtensionMap)

full_name: Lean.Meta.Simp.registerSimprocAttr
code: def registerSimprocAttr (attrName : Name) (attrDescr : String) (ref? : Option (IO.Ref Simprocs))
    (name : Name := by exact decl_name%) : IO SimprocExtension 
goal: IO Lean.Meta.Simp.SimprocExtension

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.6136
code: builtin_initialize simprocExtension : SimprocExtension ← registerSimprocAttr `simprocAttr "Simplification procedure" (some builtinSimprocsRef)
goal: IO Lean.Meta.Simp.SimprocExtension

full_name: Lean.Meta.Simp.simprocExtension
code: builtin_initialize simprocExtension : SimprocExtension ← registerSimprocAttr `simprocAttr "Simplification procedure" (some builtinSimprocsRef)
goal: Lean.Meta.Simp.SimprocExtension

full_name: Lean.Meta.Simp.simprocSEvalExtension
code: builtin_initialize simprocSEvalExtension : SimprocExtension ← registerSimprocAttr `sevalprocAttr "Symbolic evaluator procedure" (some builtinSEvalprocsRef)
goal: Lean.Meta.Simp.SimprocExtension

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.6168
code: builtin_initialize simprocSEvalExtension : SimprocExtension ← registerSimprocAttr `sevalprocAttr "Symbolic evaluator procedure" (some builtinSEvalprocsRef)
goal: IO Lean.Meta.Simp.SimprocExtension

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc.0.Lean.Meta.Simp.addBuiltin
code: private def addBuiltin (declName : Name) (stx : Syntax) (addDeclName : Name) : AttrM Unit 
goal: Lean.AttrM Unit

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.6614
code: builtin_initialize
  registerBuiltinAttribute {
    ref             := by exact decl_name%
    name            := `simprocBuiltinAttr
    descr           := "Builtin simplification procedure"
    applicationTime := AttributeApplicationTime.afterCompilation
    erase           := fun _ => throwError "Not implemented yet, [-builtin_simproc]"
    add             := fun declName stx _ => addBuiltin declName stx ``addSimprocBuiltinAttr
  }
goal: IO Unit

full_name: Lean.Meta.Simp.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Tactic.Simp.Simproc._hyg.6700
code: builtin_initialize
  registerBuiltinAttribute {
    ref             := by exact decl_name%
    name            := `sevalprocBuiltinAttr
    descr           := "Builtin symbolic evaluation procedure"
    applicationTime := AttributeApplicationTime.afterCompilation
    erase           := fun _ => throwError "Not implemented yet, [-builtin_sevalproc]"
    add             := fun declName stx _ => addBuiltin declName stx ``addSEvalprocBuiltinAttr
  }
goal: IO Unit

full_name: Lean.Meta.Simp.getSimprocs
code: def getSimprocs : CoreM Simprocs 
goal: Lean.CoreM Lean.Meta.Simprocs

full_name: Lean.Meta.Simp.getSEvalSimprocs
code: def getSEvalSimprocs : CoreM Simprocs 
goal: Lean.CoreM Lean.Meta.Simprocs

full_name: Lean.Meta.Simp.getSimprocExtensionCore?
code: def getSimprocExtensionCore? (attrName : Name) : IO (Option SimprocExtension) 
goal: IO (Option Lean.Meta.Simp.SimprocExtension)

full_name: Lean.Meta.Simp.simpAttrNameToSimprocAttrName
code: def simpAttrNameToSimprocAttrName (attrName : Name) : Name 
goal: Lean.Name

full_name: Lean.Meta.Simp.getSimprocExtension?
code: /--
Try to retrieve the simproc set using the `simp` or `simproc` attribute names.
Recall that when we declare a `simp` set using `register_simp_attr`, an associated
`simproc` set is automatically created. We use the function `simpAttrNameToSimprocAttrName` to
find the `simproc` associated with the `simp` attribute.
-/
def getSimprocExtension? (simprocAttrNameOrsimpAttrName : Name)
    : IO (Option SimprocExtension) 
goal: IO (Option Lean.Meta.Simp.SimprocExtension)

full_name: Lean.Meta.Simp.SimprocExtension.getSimprocs
code: def SimprocExtension.getSimprocs (ext : SimprocExtension) : CoreM Simprocs 
goal: Lean.CoreM Lean.Meta.Simprocs