File: .lake/packages/lean4/src/lean/Lean/ResolveName.lean

full_name: Lean.throwReservedNameNotAvailable
code: def throwReservedNameNotAvailable [Monad m] [MonadError m] (declName : Name) (reservedName : Name) : m Unit 
goal: m Unit

full_name: Lean.ensureReservedNameAvailable
code: def ensureReservedNameAvailable [Monad m] [MonadEnv m] [MonadError m] (declName : Name) (suffix : String) : m Unit 
goal: m Unit

full_name: Lean.reservedNamePredicatesRef
code: /-- Global reference containing all reserved name predicates. -/
builtin_initialize reservedNamePredicatesRef : IO.Ref (Array (Environment → Name → Bool)) ← IO.mkRef #[]
goal: IO.Ref (Array (Lean.Environment → Lean.Name → Bool))

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.ResolveName._hyg.121
code: /-- Global reference containing all reserved name predicates. -/
builtin_initialize reservedNamePredicatesRef : IO.Ref (Array (Environment → Name → Bool)) ← IO.mkRef #[]
goal: IO (IO.Ref (Array (Lean.Environment → Lean.Name → Bool)))

full_name: Lean.registerReservedNamePredicate
code: /--
Registers a new reserved name predicate.
-/
def registerReservedNamePredicate (p : Environment → Name → Bool) : IO Unit 
goal: IO Unit

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.ResolveName._hyg.265
code: builtin_initialize reservedNamePredicatesExt : EnvExtension (Array (Environment → Name → Bool)) ←
  registerEnvExtension reservedNamePredicatesRef.get
goal: IO (Lean.EnvExtension (Array (Lean.Environment → Lean.Name → Bool)))

full_name: Lean.reservedNamePredicatesExt
code: builtin_initialize reservedNamePredicatesExt : EnvExtension (Array (Environment → Name → Bool)) ←
  registerEnvExtension reservedNamePredicatesRef.get
goal: Lean.EnvExtension (Array (Lean.Environment → Lean.Name → Bool))

full_name: Lean.isReservedName
code: /--
Returns `true` if `name` is a reserved name.
-/
def isReservedName (env : Environment) (name : Name) : Bool 
goal: Bool

full_name: Lean.AliasState
code: abbrev AliasState 
goal: Type

full_name: Lean.AliasEntry
code: abbrev AliasEntry 
goal: Type

full_name: Lean.addAliasEntry
code: def addAliasEntry (s : AliasState) (e : AliasEntry) : AliasState 
goal: Lean.AliasState

full_name: Lean.aliasExtension
code: builtin_initialize aliasExtension : SimplePersistentEnvExtension AliasEntry AliasState ←
  registerSimplePersistentEnvExtension {
    addEntryFn    := addAliasEntry,
    addImportedFn := fun es => mkStateFromImportedEntries addAliasEntry {} es |>.switch
  }
goal: Lean.SimplePersistentEnvExtension Lean.AliasEntry Lean.AliasState

full_name: Lean.initFn._@..lake.packages.lean4.src.lean.Lean.ResolveName._hyg.390
code: builtin_initialize aliasExtension : SimplePersistentEnvExtension AliasEntry AliasState ←
  registerSimplePersistentEnvExtension {
    addEntryFn    := addAliasEntry,
    addImportedFn := fun es => mkStateFromImportedEntries addAliasEntry {} es |>.switch
  }
goal: IO (Lean.SimplePersistentEnvExtension Lean.AliasEntry Lean.AliasState)

full_name: Lean.addAlias
code: /-- Add alias `a` for `e` -/
@[export lean_add_alias] def addAlias (env : Environment) (a : Name) (e : Name) : Environment 
goal: Lean.Environment

full_name: Lean.getAliasState
code: def getAliasState (env : Environment) : AliasState 
goal: Lean.AliasState

full_name: Lean.getAliases
code: /--
  Retrieve aliases for `a`. If `skipProtected` is `true`, then the resulting list only includes
  declarations that are not marked as `proctected`.
-/
def getAliases (env : Environment) (a : Name) (skipProtected : Bool) : List Name 
goal: List Lean.Name

full_name: Lean.getRevAliases
code: def getRevAliases (env : Environment) (e : Name) : List Name 
goal: List Lean.Name

full_name: _private.«.lake».packages.lean4.src.lean.Lean.ResolveName.0.Lean.ResolveName.containsDeclOrReserved
code: private def containsDeclOrReserved (env : Environment) (declName : Name) : Bool 
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.ResolveName.0.Lean.ResolveName.resolveQualifiedName
code: /-- Check whether `ns ++ id` is a valid namespace name and/or there are aliases names `ns ++ id`. -/
private def resolveQualifiedName (env : Environment) (ns : Name) (id : Name) : List Name 
goal: List Lean.Name

full_name: _private.«.lake».packages.lean4.src.lean.Lean.ResolveName.0.Lean.ResolveName.resolveUsingNamespace
code: /-- Check surrounding namespaces -/
private def resolveUsingNamespace (env : Environment) (id : Name) : Name → List Name
  
goal: Lean.Name → List Lean.Name

full_name: _private.«.lake».packages.lean4.src.lean.Lean.ResolveName.0.Lean.ResolveName.resolveExact
code: /-- Check exact name -/
private def resolveExact (env : Environment) (id : Name) : Option Name 
goal: Option Lean.Name

full_name: _private.«.lake».packages.lean4.src.lean.Lean.ResolveName.0.Lean.ResolveName.resolveOpenDecls
code: /-- Check `OpenDecl`s -/
private def resolveOpenDecls (env : Environment) (id : Name) : List OpenDecl → List Name → List Name
  
goal: List Lean.OpenDecl → List Lean.Name → List Lean.Name

full_name: Lean.ResolveName.resolveGlobalName
code: /--
Primitive global name resolution procedure. It does not trigger actions associated with reserved names.
Recall that Lean has reserved names. For example, a definition `foo` has a reserved name `foo.def` for theorem
containing stating that `foo` is equal to its definition. The action associated with `foo.def`
automatically proves the theorem. At the macro level, the name is resolved, but the action is not
executed.
-/
def resolveGlobalName (env : Environment) (ns : Name) (openDecls : List OpenDecl) (id : Name) : List (Name × List String) 
goal: List (Lean.Name × List String)

full_name: Lean.ResolveName.resolveGlobalName.loop
code: /--
Primitive global name resolution procedure. It does not trigger actions associated with reserved names.
Recall that Lean has reserved names. For example, a definition `foo` has a reserved name `foo.def` for theorem
containing stating that `foo` is equal to its definition. The action associated with `foo.def`
automatically proves the theorem. At the macro level, the name is resolved, but the action is not
executed.
-/
def resolveGlobalName (env : Environment) (ns : Name) (openDecls : List OpenDecl) (id : Name) : List (Name × List String) 
goal: List (Lean.Name × List String)

full_name: Lean.ResolveName.resolveNamespaceUsingScope?
code: def resolveNamespaceUsingScope? (env : Environment) (n : Name) (ns : Name) : Option Name 
goal: Option Lean.Name

full_name: Lean.ResolveName.resolveNamespaceUsingOpenDecls
code: def resolveNamespaceUsingOpenDecls (env : Environment) (n : Name) : List OpenDecl → List Name
  
goal: List Lean.OpenDecl → List Lean.Name

full_name: Lean.ResolveName.resolveNamespace
code: /--
Given a name `id` try to find namespaces it may refer to. The resolution procedure works as follows

1- If `id` is in the scope of `namespace` commands the namespace `s_1. ... . s_n`,
   then we include `s_1 . ... . s_i ++ n` in the result if it is the name of an existing namespace.
   We search "backwards", and include at most one of the in the list of resulting namespaces.

2- If `id` is the exact name of an existing namespace, then include `id`

3- Finally, for each command `open N`, include in the result `N ++ n` if it is the name of an existing namespace.
   We only consider simple `open` commands. -/
def resolveNamespace (env : Environment) (ns : Name) (openDecls : List OpenDecl) (id : Name) : List Name 
goal: List Lean.Name

full_name: Lean.MonadResolveName
code: class MonadResolveName (m : Type → Type) where
  getCurrNamespace   : m Name
  getOpenDecls       : m (List OpenDecl)
goal: Type

full_name: Lean.MonadResolveName.getOpenDecls
code: class MonadResolveName (m : Type → Type) where
  getCurrNamespace   : m Name
  getOpenDecls       : m (List OpenDecl)
goal: m (List Lean.OpenDecl)

full_name: Lean.MonadResolveName.getCurrNamespace
code: class MonadResolveName (m : Type → Type) where
  getCurrNamespace   : m Name
  getOpenDecls       : m (List OpenDecl)
goal: m Lean.Name

full_name: Lean.instMonadResolveNameOfMonadLift
code: instance (m n) [MonadLift m n] [MonadResolveName m] : MonadResolveName n 
goal: Lean.MonadResolveName n

full_name: Lean.resolveGlobalName
code: /--
Given a name `n`, return a list of possible interpretations.
Each interpretation is a pair `(declName, fieldList)`, where `declName`
is the name of a declaration in the current environment, and `fieldList` are
(potential) field names.
The pair is needed because in Lean `.` may be part of a qualified name or
a field (aka dot-notation).
As an example, consider the following definitions
```
def Boo.x   := 1
def Foo.x   := 2
def Foo.x.y := 3
```
After `open Foo`, we have
- `resolveGlobalName x`     => `[(Foo.x, [])]`
- `resolveGlobalName x.y`   => `[(Foo.x.y, [])]`
- `resolveGlobalName x.z.w` => `[(Foo.x, [z, w])]`

After `open Foo open Boo`, we have
- `resolveGlobalName x`     => `[(Foo.x, []), (Boo.x, [])]`
- `resolveGlobalName x.y`   => `[(Foo.x.y, [])]`
- `resolveGlobalName x.z.w` => `[(Foo.x, [z, w]), (Boo.x, [z, w])]`
-/
def resolveGlobalName [Monad m] [MonadResolveName m] [MonadEnv m] (id : Name) : m (List (Name × List String)) 
goal: m (List (Lean.Name × List String))

full_name: Lean.resolveNamespaceCore
code: /--
Given a namespace name, return a list of possible interpretations.
Names extracted from syntax should be passed to `resolveNamespace` instead.
-/
def resolveNamespaceCore [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (id : Name) (allowEmpty := false) : m (List Name) 
goal: m (List Lean.Name)

full_name: Lean.resolveNamespace
code: /-- Given a namespace identifier, return a list of possible interpretations. -/
def resolveNamespace [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] : Ident → m (List Name)
  
goal: Lean.Ident → m (List Lean.Name)

full_name: Lean.resolveUniqueNamespace
code: /-- Given a namespace identifier, return the unique interpretation or else fail. -/
def resolveUniqueNamespace [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (id : Ident) : m Name 
goal: m Lean.Name

full_name: Lean.filterFieldList
code: /-- Helper function for `resolveGlobalConstCore`. -/
def filterFieldList [Monad m] [MonadError m] (n : Name) (cs : List (Name × List String)) : m (List Name) 
goal: m (List Lean.Name)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.ResolveName.0.Lean.resolveGlobalConstCore
code: /-- Given a name `n`, returns a list of possible interpretations for global constants.

Similar to `resolveGlobalName`, but discard any candidate whose `fieldList` is not empty.
For identifiers taken from syntax, use `resolveGlobalConst` instead, which respects preresolved names. -/
private def resolveGlobalConstCore [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (n : Name) : m (List Name) 
goal: m (List Lean.Name)

full_name: Lean.ensureNoOverload
code: /-- Helper function for `resolveGlobalConstNoOverloadCore` -/
def ensureNoOverload [Monad m] [MonadError m] (n : Name) (cs : List Name) : m Name 
goal: m Lean.Name

full_name: Lean.resolveGlobalConstNoOverloadCore
code: /-- For identifiers taken from syntax, use `resolveGlobalConstNoOverload` instead, which respects preresolved names. -/
def resolveGlobalConstNoOverloadCore [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (n : Name) : m Name 
goal: m Lean.Name

full_name: Lean.preprocessSyntaxAndResolve
code: def preprocessSyntaxAndResolve [Monad m] [MonadEnv m] [MonadError m] (stx : Syntax) (k : Name → m (List Name)) : m (List Name) 
goal: m (List Lean.Name)

full_name: Lean.resolveGlobalConst
code: /--
Interprets the syntax `n` as an identifier for a global constant, and returns a list of resolved
constant names that it could be referring to based on the currently open namespaces.
This should be used instead of `resolveGlobalConstCore` for identifiers taken from syntax
because `Syntax` objects may have names that have already been resolved.

Consider using `realizeGlobalConst` if you need to handle reserved names, and
`realizeGlobalConstWithInfo` if you want the syntax to show the resulting name's info on hover.

## Example:
```
def Boo.x   := 1
def Foo.x   := 2
def Foo.x.y := 3
```
After `open Foo`, we have
- `resolveGlobalConst x`     => `[Foo.x]`
- `resolveGlobalConst x.y`   => `[Foo.x.y]`
- `resolveGlobalConst x.z.w` => error: unknown constant

After `open Foo open Boo`, we have
- `resolveGlobalConst x`     => `[Foo.x, Boo.x]`
- `resolveGlobalConst x.y`   => `[Foo.x.y]`
- `resolveGlobalConst x.z.w` => error: unknown constant
-/
def resolveGlobalConst [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (stx : Syntax) : m (List Name) 
goal: m (List Lean.Name)

full_name: Lean.ensureNonAmbiguous
code: /--
Given a list of names produced by `resolveGlobalConst`, throws an error if the list does not contain
exactly one element.
Recall that `resolveGlobalConst` does not return empty lists.
-/
def ensureNonAmbiguous [Monad m] [MonadError m] (id : Syntax) (cs : List Name) : m Name 
goal: m Lean.Name

full_name: Lean.resolveGlobalConstNoOverload
code: /-- Interprets the syntax `n` as an identifier for a global constant, and return a resolved
constant name. If there are multiple possible interpretations it will throw.

Consider using `realizeGlobalConstNoOverload` if you need to handle reserved names, and
`realizeGlobalConstNoOverloadWithInfo` if you
want the syntax to show the resulting name's info on hover.

## Example:
```
def Boo.x   := 1
def Foo.x   := 2
def Foo.x.y := 3
```
After `open Foo`, we have
- `resolveGlobalConstNoOverload x`     => `Foo.x`
- `resolveGlobalConstNoOverload x.y`   => `Foo.x.y`
- `resolveGlobalConstNoOverload x.z.w` => error: unknown constant

After `open Foo open Boo`, we have
- `resolveGlobalConstNoOverload x`     => error: ambiguous identifier
- `resolveGlobalConstNoOverload x.y`   => `Foo.x.y`
- `resolveGlobalConstNoOverload x.z.w` => error: unknown constant
-/
def resolveGlobalConstNoOverload [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (id : Syntax) : m Name 
goal: m Lean.Name

full_name: Lean.unresolveNameGlobal
code: /--
Finds a name that unambiguously resolves to the given name `n₀`.
Considers suffixes of `n₀` and suffixes of aliases of `n₀` when "unresolving".
Aliases are considered first.

When `fullNames` is true, returns either `n₀` or `_root_.n₀`.

This function is meant to be used for pretty printing.
If `n₀` is an accessible name, then the result will be an accessible name.
-/
def unresolveNameGlobal [Monad m] [MonadResolveName m] [MonadEnv m] (n₀ : Name) (fullNames := false) : m Name 
goal: m Lean.Name

full_name: Lean.unresolveNameGlobal.unresolveNameCore
code: /--
Finds a name that unambiguously resolves to the given name `n₀`.
Considers suffixes of `n₀` and suffixes of aliases of `n₀` when "unresolving".
Aliases are considered first.

When `fullNames` is true, returns either `n₀` or `_root_.n₀`.

This function is meant to be used for pretty printing.
If `n₀` is an accessible name, then the result will be an accessible name.
-/
def unresolveNameGlobal [Monad m] [MonadResolveName m] [MonadEnv m] (n₀ : Name) (fullNames := false) : m Name 
goal: m (Option Lean.Name)