Additional version description like "nightly-2018-03-11"
This function can be used to detect whether the compiler has support for generating LLVM instead of C. It is used by lake instead of the --features flag in order to avoid having to run a compiler for this every time on startup. See #2572.
Equations
Instances For
Creates a round-trippable string name component if possible, otherwise returns none.
Names that are valid identifiers are not escaped, and otherwise, if they do not contain », they are escaped.
- If
forceistrue, then even valid identifiers are escaped.
Equations
Instances For
Uses the separator sep (usually ".") to combine the components of the Name into a string.
See the documentation for Name.toString for an explanation of escape and isToken.
Equations
Instances For
Converts a name to a string.
- If
escapeistrue, then escapes name components using«and»to ensure that those names that can appear in source files round trip. Names with number components, anonymous names, and names containing»might not round trip. Furthermore, "pseudo-syntax" produced by the delaborator, such as_,#0or?u, is not escaped. - The optional
isTokenfunction is used whenescapeistrueto determine whether more escaping is necessary to avoid parser tokens. The insertion algorithm works so long as parser tokens do not themselves contain«or».
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
- getNGen : m NameGenerator
- setNGen : NameGenerator → m Unit
Instances
Creates a globally unique Name, without any semantic interpretation.
The names are not intended to be user-visible.
With the default name generator, names use _uniq as a base and have a numeric suffix.
This is used for example by Lean.mkFreshFVarId, Lean.mkFreshMVarId, and Lean.mkFreshLMVarId.
To create fresh user-visible identifiers, use functions such as Lean.Core.mkFreshUserName instead.
Equations
Instances For
Equations
Syntax that represents a Lean term.
Equations
Instances For
Syntax that represents a command.
Equations
Instances For
Syntax that represents a universe level.
Equations
Instances For
Syntax that represents a tactic.
Equations
Instances For
Syntax that represents a precedence (e.g. for an operator).
Equations
Instances For
Syntax that represents a priority (e.g. for an instance declaration).
Equations
Instances For
Syntax that represents an identifier.
Equations
Instances For
Syntax that represents a string literal.
Equations
Instances For
Syntax that represents a character literal.
Equations
Instances For
Syntax that represents a quoted name literal that begins with a back-tick.
Equations
Instances For
Syntax that represents a scientific numeric literal that may have decimal and exponential parts.
Equations
Instances For
Syntax that represents a numeric literal.
Equations
Instances For
Syntax that represents macro hygiene info.
Equations
Instances For
Equations
Equations
Equations
Equations
Instances For
Equations
Instances For
Compare syntax structures modulo source info.
Finds the first SourceInfo from the back of stx or none if no SourceInfo can be found.
Finds the first SourceInfo from the back of stx or SourceInfo.none
if no SourceInfo can be found.
Equations
Instances For
Finds the trailing size of the first SourceInfo from the back of stx.
If no SourceInfo can be found or the first SourceInfo from the back of stx contains no
trailing whitespace, the result is 0.
Equations
Instances For
Finds the trailing whitespace substring of the first SourceInfo from the back of stx.
If no SourceInfo can be found or the first SourceInfo from the back of stx contains
no trailing whitespace, the result is none.
Equations
Instances For
Finds the tail position of the trailing whitespace of the first SourceInfo from the back of stx.
If no SourceInfo can be found or the first SourceInfo from the back of stx contains
no trailing whitespace and lacks a tail position, the result is none.
Equations
Instances For
Return substring of original input covering stx.
Result is meaningful only if all involved SourceInfo.originals refer to the same string (as is the case after parsing).
Equations
Instances For
Replaces the trailing whitespace in stx, if any, with an empty substring.
The trailing substring's startPos and str are preserved in order to ensure that the result could
have been produced by the parser, in case any syntax consumers rely on such an assumption.
Equations
Instances For
Return the first atom/identifier that has position information
Ensure head position is synthetic. The server regards syntax as "original" only if both head and tail info are original.
Equations
Instances For
Expand macros in the given syntax.
A node with kind k is visited only if p k is true.
Note that the default value for p returns false for by ... nodes.
This is a "hack". The tactic framework abuses the macro system to implement extensible tactics.
For example, one can define
syntax "my_trivial" : tactic -- extensible tactic
macro_rules | `(tactic| my_trivial) => `(tactic| decide)
macro_rules | `(tactic| my_trivial) => `(tactic| assumption)
When the tactic evaluator finds the tactic my_trivial, it tries to evaluate the macro_rule expansions
until one "works", i.e., the macro expansion is evaluated without producing an exception.
We say this solution is a bit hackish because the term elaborator may invoke expandMacros with (p := fun _ => true),
and expand the tactic macros as just macros. In the example above, my_trivial would be replaced with assumption,
decide would not be tried if assumption fails at tactic evaluation time.
We are considering two possible solutions for this issue: 1- A proper extensible tactic feature that does not rely on the macro system.
2- Typed macros that know the syntax categories they're working in. Then, we would be able to select which
syntactic categories are expanded by expandMacros.
Helper functions for processing Syntax programmatically #
Create an identifier copying the position from src.
To refer to a specific constant, use mkCIdentFrom instead.
Equations
Instances For
Create an identifier referring to a constant c copying the position from src.
This variant of mkIdentFrom makes sure that the identifier cannot accidentally
be captured.
Equations
Instances For
Constructs a typed separated array from elements. The given array does not include the separators.
Like Syntax.SepArray.ofElems but for typed syntax.
Equations
Instances For
Equations
Create syntax representing a Lean term application, but avoid degenerate empty applications.
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Recall that we don't have special Syntax constructors for storing numeric and string atoms.
The idea is to have an extensible approach where embedded DSLs may have new kind of atoms and/or
different ways of representing them. So, our atoms contain just the parsed string.
The main Lean parser uses the kind numLitKind for storing natural numbers that can be encoded
in binary, octal, decimal and hexadecimal format. isNatLit implements a "decoder"
for Syntax objects representing these numerals.
Equations
Instances For
Decodes a 'scientific number' string which is consumed by the OfScientific class.
Takes as input a string such as 123, 123.456e7 and returns a triple (n, sign, e) with value given by
n * 10^-e if sign else n * 10^e.
Equations
Instances For
Equations
Instances For
Decodes a valid string gap after the \.
Note that this function matches "\" whitespace+ rather than
the more restrictive "\" newline whitespace* since this simplifies the implementation.
Justification: this does not overlap with any other sequences beginning with \.
Equations
Instances For
Takes a raw string literal, counts the number of #'s after the r, and interprets it as a string.
The position i should start at 1, which is the character after the leading r.
The algorithm is simple: we are given r##...#"...string..."##...# with zero or more #s.
By counting the number of leading #'s, we can extract the ...string....
Takes the string literal lexical syntax parsed by the parser and interprets it as a string.
This is where escape sequences are processed for example.
The string s is either a plain string literal or a raw string literal.
If it returns none then the string literal is ill-formed, which indicates a bug in the parser.
The function is not required to return none if the string literal is ill-formed.
Equations
Instances For
If the provided Syntax is a string literal, returns the string it represents.
Even if the Syntax is a str node, the function may return none if its internally ill-formed.
The parser should always create well-formed str nodes.
Equations
Instances For
Split a name literal (without the backtick) into its dot-separated components. For example,
foo.bla.«bo.o» ↦ ["foo", "bla", "«bo.o»"]. If the literal cannot be parsed, return [].
Equations
Instances For
Converts a substring to the Lean compiler's representation of names. The resulting name is
hierarchical, and the string is split at the dots ('.').
"a.b".toSubstring.toName is the name a.b, not «a.b». For the latter, use
Name.mkSimple ∘ Substring.toString.
Equations
Instances For
Converts a string to the Lean compiler's representation of names. The resulting name is
hierarchical, and the string is split at the dots ('.').
"a.b".toName is the name a.b, not «a.b». For the latter, use Name.mkSimple.
Equations
Instances For
Interprets a numeric literal as a natural number.
Returns 0 if the syntax is malformed.
Equations
Instances For
Extracts the parsed name from the syntax of an identifier.
Returns Name.anonymous if the syntax is malformed.
Equations
Instances For
Decodes a string literal, removing quotation marks and unescaping escaped characters.
Returns "" if the syntax is malformed.
Equations
Instances For
Decodes a character literal.
Returns (default : Char) if the syntax is malformed.
Equations
Instances For
Decodes a quoted name literal, returning the name.
Returns Lean.Name.anonymous if the syntax is malformed.
Equations
Instances For
Decodes macro hygiene information.
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Equations
Instances For
Filters an array of syntax, treating every other element as a separator rather than an element to
test with the monadic predicate p. The resulting array contains the tested elements for which p
returns true, separated by the corresponding separator elements.
Equations
Instances For
Filters an array of syntax, treating every other element as a separator rather than an element to
test with the predicate p. The resulting array contains the tested elements for which p returns
true, separated by the corresponding separator elements.
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Equations
Equations
Equations
Equations
Equations
Equations
Helper functions for manipulating interpolated strings #
Equations
Instances For
Equations
Instances For
Controls which new mvars are turned in to goals by the apply tactic.
nonDependentFirstmvars that don't depend on other goals appear first in the goal list.nonDependentOnlyonly mvars that don't depend on other goals are added to goal list.allall unassigned mvars are added to the goal list.
- nonDependentFirst : ApplyNewGoals
- nonDependentOnly : ApplyNewGoals
- all : ApplyNewGoals
Instances For
Configures the behaviour of the apply tactic.
- newGoals : ApplyNewGoals
- synthAssignedInstances : Bool
If
synthAssignedInstancesistrue, thenapplywill synthesize instance implicit arguments even if they have assigned byisDefEq, and then check whether the synthesized value matches the one inferred. Thecongrtactic sets this flag to false. - allowSynthFailures : Bool
If
allowSynthFailuresistrue, thenapplywill return instance implicit arguments for which typeclass search failed as new goals. - approx : Bool
If
approx := true, then we turn onisDefEqapproximations. That is, we use theapproxDefEqcombinator.
Instances For
Controls which new mvars are turned in to goals by the apply tactic.
nonDependentFirstmvars that don't depend on other goals appear first in the goal list.nonDependentOnlyonly mvars that don't depend on other goals are added to goal list.allall unassigned mvars are added to the goal list.
Equations
Instances For
Configures the behavior of the rewrite and rw tactics.
- transparency : TransparencyMode
The transparency mode to use for unfolding
- offsetCnstrs : Bool
Whether to support offset constraints such as
?x + 1 =?= e - occs : Occurrences
Which occurrences to rewrite
- newGoals : NewGoals
How to convert the resulting metavariables into new goals
Instances For
Configures the behaviour of the omega tactic.
- splitDisjunctions : Bool
Split disjunctions in the context.
Note that with
splitDisjunctions := falseomega will not be able to solvex = ygoals as these are usually handled by introducing¬ x = yas a hypothesis, then replacing this withx < y ∨ x > y.On the other hand,
omegadoes not currently detect disjunctions which, when split, introduce no new useful information, so the presence of irrelevant disjunctions in the context can significantly increase run time. - splitNatSub : Bool
Whenever
((a - b : Nat) : Int)is found, register the disjunctionb ≤ a ∧ ((a - b : Nat) : Int) = a - b ∨ a < b ∧ ((a - b : Nat) : Int) = 0for later splitting. - splitNatAbs : Bool
Whenever
Int.natAbs ais found, register the disjunction0 ≤ a ∧ Int.natAbs a = a ∨ a < 0 ∧ Int.natAbs a = - afor later splitting. - splitMinMax : Bool
Whenever
min a bormax a bis found, rewrite in terms of the definitionif a ≤ b ..., for later case splitting.
Instances For
Type used to lift an arbitrary value into a type parameter so it can appear in a proof goal.
It is used by the #check_tactic command.
- intro {α : Sort u} (val : α) : CheckGoalType val
Instances For
Extracts the items from a tactic configuration,
either a Lean.Parser.Tactic.optConfig, Lean.Parser.Tactic.config, or these wrapped in null nodes.
Equations
Instances For
Appends two tactic configurations.
The configurations can be Lean.Parser.Tactic.optConfig, Lean.Parser.Tactic.config,
or these wrapped in null nodes (for example because the syntax is (config)?).
Equations
Instances For
erw [rules] is a shorthand for rw (transparency := .default) [rules].
This does rewriting up to unfolding of regular definitions (by comparison to regular rw
which only unfolds @[reducible] definitions).
Equations
Instances For
simp! is shorthand for simp with autoUnfold := true.
This will rewrite with all equation lemmas, which can be used to
partially evaluate many definitions.
Equations
Instances For
simp_arith has been deprecated. It was a shorthand for simp +arith +decide.
Note that +decide is not needed for reducing arithmetic terms since simprocs have been added to Lean.
Equations
Instances For
simp_arith! has been deprecated. It was a shorthand for simp! +arith +decide.
Note that +decide is not needed for reducing arithmetic terms since simprocs have been added to Lean.
Equations
Instances For
simp_all! is shorthand for simp_all with autoUnfold := true.
This will rewrite with all equation lemmas, which can be used to
partially evaluate many definitions.
Equations
Instances For
simp_all_arith has been deprecated. It was a shorthand for simp_all +arith +decide.
Note that +decide is not needed for reducing arithmetic terms since simprocs have been added to Lean.
Equations
Instances For
simp_all_arith! has been deprecated. It was a shorthand for simp_all! +arith +decide.
Note that +decide is not needed for reducing arithmetic terms since simprocs have been added to Lean.
Equations
Instances For
dsimp! is shorthand for dsimp with autoUnfold := true.
This will rewrite with all equation lemmas, which can be used to
partially evaluate many definitions.