We use aliases to implement the export
command.
An export A (x)
in the namespace B
produces an alias B.x ~> A.x
.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.addAlias env a e = Lean.PersistentEnvExtension.addEntry Lean.aliasExtension env (a, e)
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.getRevAliases env e = Lean.SMap.fold (fun as a es => if List.contains es e = true then a :: as else as) [] (Lean.SimplePersistentEnvExtension.getState Lean.aliasExtension env)
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
- Lean.ResolveName.resolveGlobalName.loop env ns openDecls extractionResult id projs = []
Equations
- One or more equations did not get rendered due to their size.
- Lean.ResolveName.resolveNamespaceUsingScope? env n Lean.Name.anonymous = if Lean.Environment.isNamespace env n = true then some n else none
Equations
- One or more equations did not get rendered due to their size.
- Lean.ResolveName.resolveNamespaceUsingOpenDecls env n [] = []
- Lean.ResolveName.resolveNamespaceUsingOpenDecls env n (head :: ds) = Lean.ResolveName.resolveNamespaceUsingOpenDecls env n ds
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 extact 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.
Equations
- One or more equations did not get rendered due to their size.
- getCurrNamespace : m Lean.Name
- getOpenDecls : m (List Lean.OpenDecl)
Equations
- Lean.instMonadResolveName m n = { getCurrNamespace := liftM Lean.getCurrNamespace, getOpenDecls := liftM Lean.getOpenDecls }
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])]
Equations
- Lean.resolveGlobalName id = do let a ← Lean.getEnv let a_1 ← Lean.getCurrNamespace let a_2 ← Lean.getOpenDecls pure (Lean.ResolveName.resolveGlobalName a a_1 a_2 id)
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Given a name n
, return 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.
Equations
- One or more equations did not get rendered due to their size.
For identifiers taken from syntax, use resolveGlobalConstNoOverload
instead, which respects preresolved names.
Equations
- One or more equations did not get rendered due to their size.
Interpret the syntax n
as an identifier for a global constant, and return a list of resolved
constant names that it could be refering 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.
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
Equations
- One or more equations did not get rendered due to their size.
Interpret 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.
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 identifierresolveGlobalConstNoOverload x.y
=>Foo.x.y
resolveGlobalConstNoOverload x.z.w
=> error: unknown constant
Equations
- One or more equations did not get rendered due to their size.