Equations
Instances For
Instances For
Additional version description like "nightly-2018-03-11"
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
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
- Lean.isIdFirst c = (c.isAlpha || decide (c = '_') || Lean.isLetterLike c)
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
force
istrue
, then even valid identifiers are escaped.
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
.
Instances For
Equations
- Lean.Name.toStringWithSep.maybeEscape escape s force = if escape = true then (Lean.Name.escapePart s force).getD s else s
Instances For
Converts a name to a string.
- If
escape
istrue
, 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_
,#0
or?u
, is not escaped. - The optional
isToken
function is used whenescape
istrue
to determine whether more escaping is necessary to avoid parser tokens. The insertion algorithm works so long as parser tokens do not themselves contain«
or»
.
Instances For
Equations
- Lean.Name.instToString = { toString := fun (n : Lean.Name) => n.toString }
Equations
- Lean.Name.instRepr = { reprPrec := Lean.Name.reprPrec }
Instances For
Instances For
Instances For
Instances For
- getNGen : m Lean.NameGenerator
- setNGen : Lean.NameGenerator → m Unit
Instances
Equations
- Lean.mkFreshId = do let ngen ← Lean.getNGen let r : Lean.Name := ngen.curr Lean.setNGen ngen.next pure r
Instances For
Equations
- Lean.monadNameGeneratorLift m n = { getNGen := liftM Lean.getNGen, setNGen := fun (ngen : Lean.NameGenerator) => liftM (Lean.setNGen ngen) }
Equations
- Lean.Syntax.instReprPreresolved = { reprPrec := Lean.Syntax.reprPreresolved✝ }
Equations
- Lean.Syntax.instRepr = { reprPrec := Lean.Syntax.reprSyntax✝ }
Equations
- Lean.Syntax.instReprTSyntax = { reprPrec := Lean.Syntax.reprTSyntax✝ }
Instances For
Equations
Instances For
Equations
- Lean.TSyntax.instCoeConsSyntaxNodeKindNil = { coe := fun (stx : Lean.TSyntax k) => { raw := stx.raw } }
Equations
- Lean.TSyntax.instCoeIdentTerm = { coe := fun (s : Lean.Ident) => { raw := s.raw } }
Equations
- Lean.TSyntax.instCoeNameLitTerm = { coe := fun (s : Lean.NameLit) => { raw := s.raw } }
Equations
- Lean.TSyntax.instCoeNumLitTerm = { coe := fun (s : Lean.NumLit) => { raw := s.raw } }
Equations
- Lean.TSyntax.instCoeCharLitTerm = { coe := fun (s : Lean.CharLit) => { raw := s.raw } }
Equations
- Lean.TSyntax.instCoeNumLitPrio = { coe := fun (s : Lean.NumLit) => { raw := s.raw } }
Equations
- Lean.TSyntax.instCoeNumLitPrec = { coe := fun (s : Lean.NumLit) => { raw := s.raw } }
Instances For
Equations
- Lean.TSyntax.Compat.instCoeTailArraySyntaxTSyntaxArray = { coe := Lean.TSyntaxArray.mk }
Instances For
Compare syntax structures modulo source info.
Equations
- Lean.Syntax.instBEqTSyntax = { beq := fun (x1 x2 : Lean.TSyntax k) => x1.raw == x2.raw }
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
- stx.getTailInfo = stx.getTailInfo?.getD Lean.SourceInfo.none
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
.
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
- stx.getTrailing? = stx.getTailInfo.getTrailing?
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
- stx.getTrailingTailPos? canonicalOnly = stx.getTailInfo.getTrailingTailPos? canonicalOnly
Instances For
Return substring of original input covering stx
.
Result is meaningful only if all involved SourceInfo.original
s refer to the same string (as is the case after parsing).
Instances For
Equations
- stx.setTailInfo info = match Lean.Syntax.setTailInfoAux info stx with | some stx => stx | none => stx
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
- One or more equations did not get rendered due to their size.
Instances For
Equations
- stx.setHeadInfo info = match Lean.Syntax.setHeadInfoAux info stx with | some stx => stx | none => stx
Instances For
Equations
- Lean.Syntax.setInfo info (Lean.Syntax.atom info_1 val) = Lean.Syntax.atom info val
- Lean.Syntax.setInfo info (Lean.Syntax.ident info_1 rawVal val pre) = Lean.Syntax.ident info rawVal val pre
- Lean.Syntax.setInfo info (Lean.Syntax.node info_1 kind args) = Lean.Syntax.node info kind args
- Lean.Syntax.setInfo info Lean.Syntax.missing = Lean.Syntax.missing
Instances For
Return the first atom/identifier that has position information
Equations
- target.copyHeadTailInfoFrom source = (target.setHeadInfo source.getHeadInfo).setTailInfo source.getTailInfo
Instances For
Ensure head position is synthetic. The server regards syntax as "original" only if both head and tail info are original
.
Equations
- stx.mkSynthetic = stx.setHeadInfo (Lean.SourceInfo.fromRef stx)
Instances For
Use the head atom/identifier of the current ref
as the ref
Equations
- Lean.withHeadRefOnly x = do let __do_lift ← Lean.getRef match __do_lift.getHead? with | none => x | some ref => Lean.withRef ref x
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.
Instances For
Equations
- Lean.mkIdentFromRef val canonical = do let __do_lift ← Lean.getRef pure (Lean.mkIdentFrom __do_lift val canonical)
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
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
Instances For
Equations
- Lean.mkIdent val = { raw := Lean.Syntax.ident Lean.SourceInfo.none (toString val).toSubstring val [] }
Instances For
Instances For
Equations
- Lean.mkHole ref canonical = (Lean.mkNode `Lean.Parser.Term.hole #[Lean.mkAtomFrom ref "_" canonical]).raw
Instances For
Equations
- Lean.Syntax.SepArray.ofElems elems = { elemsAndSeps := Lean.mkSepArray elems (if sep.isEmpty = true then Lean.mkNullNode else Lean.mkAtom sep) }
Instances For
Equations
- One or more equations did not get rendered due to their size.
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
- Lean.Syntax.TSepArray.ofElems elems = { elemsAndSeps := (Lean.Syntax.SepArray.ofElems (Lean.TSyntaxArray.raw elems)).elemsAndSeps }
Instances For
Create syntax representing a Lean term application, but avoid degenerate empty applications.
Equations
- Lean.Syntax.mkApp fn x = match x with | #[] => fn | args => { raw := (Lean.mkNode `Lean.Parser.Term.app #[fn.raw, Lean.mkNullNode args.raw]).raw }
Instances For
Instances For
Equations
- Lean.Syntax.mkLit kind val info = Lean.mkNode kind #[Lean.Syntax.atom info val]
Instances For
Equations
- Lean.Syntax.mkCharLit val info = Lean.Syntax.mkLit Lean.charLitKind val.quote info
Instances For
Equations
- Lean.Syntax.mkStrLit val info = Lean.Syntax.mkLit Lean.strLitKind val.quote info
Instances For
Equations
- Lean.Syntax.mkNumLit val info = Lean.Syntax.mkLit Lean.numLitKind val info
Instances For
Equations
- Lean.Syntax.mkNatLit val info = Lean.Syntax.mkLit Lean.numLitKind (toString val) info
Instances For
Equations
- Lean.Syntax.mkScientificLit val info = Lean.Syntax.mkLit Lean.scientificLitKind val info
Instances For
Equations
- Lean.Syntax.mkNameLit val info = Lean.Syntax.mkLit Lean.nameLitKind val info
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
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Syntax.isLit? litKind stx = none
Instances For
Equations
- s.isNatLit? = Lean.Syntax.isNatLitAux✝ Lean.numLitKind s
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
- Lean.Syntax.decodeScientificLitVal? s = if (s.length == 0) = true then none else let c := s.get 0; if c.isDigit = true then Lean.Syntax.decodeScientificLitVal?.decode s 0 0 else none
Instances For
Equations
- One or more equations did not get rendered due to their size.
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 \
.
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
- Lean.Syntax.decodeStrLit s = if (s.get 0 == 'r') = true then some (Lean.Syntax.decodeRawStrLitAux s { byteIdx := 1 } 0) else Lean.Syntax.decodeStrLitAux s { byteIdx := 1 } ""
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.
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
- Lean.Syntax.splitNameLit ss = (Lean.Syntax.splitNameLitAux✝ ss []).reverse
Instances For
Instances For
Equations
- Lean.Syntax.isToken token (Lean.Syntax.atom info val) = (val.trim == token.trim)
- Lean.Syntax.isToken token x = false
Instances For
Equations
Instances For
Equations
- stx.find? p = Lean.Syntax.findAux p stx
Instances For
Equations
- Lean.TSyntax.getNat s = s.raw.isNatLit?.getD 0
Instances For
Equations
- Lean.TSyntax.getId s = s.raw.getId
Instances For
Equations
- Lean.TSyntax.getScientific s = s.raw.isScientificLit?.getD (0, false, 0)
Instances For
Equations
- Lean.TSyntax.getChar s = s.raw.isCharLit?.getD default
Instances For
Equations
- Lean.TSyntax.getHygieneInfo s = s.raw[0].getId
Instances For
Equations
- Lean.TSyntax.Compat.instCoeTailArraySyntaxTSepArray = { coe := fun (a : Array Lean.Syntax) => Lean.Syntax.TSepArray.ofElems (Lean.TSyntaxArray.mk a) }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.instQuoteStringStrLitKind = { quote := fun (val : String) => Lean.Syntax.mkStrLit val }
Equations
- Lean.instQuoteNatNumLitKind = { quote := fun (n : Nat) => Lean.Syntax.mkNumLit (toString n) }
Equations
- Lean.quoteNameMk Lean.Name.anonymous = { raw := (Lean.mkCIdent `Lean.Name.anonymous).raw }
- Lean.quoteNameMk (p.str s) = Lean.Syntax.mkCApp `Lean.Name.mkStr #[Lean.quoteNameMk p, Lean.quote `term s]
- Lean.quoteNameMk (p.num n) = Lean.Syntax.mkCApp `Lean.Name.mkNum #[Lean.quoteNameMk p, Lean.quote `term n]
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.instQuoteArrayMkStr1 = Lean.Quote.mk `term Lean.quoteArray✝
Evaluator for prec
DSL
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.termEval_prio_ = Lean.ParserDescr.node `Lean.termEval_prio_ 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "eval_prio ") (Lean.ParserDescr.cat `prio 1024))
Instances For
Equations
- Lean.evalOptPrio (some prio) = Lean.evalPrio prio.raw
- Lean.evalOptPrio none = pure 1000
Instances For
Instances For
Equations
- a.filterSepElemsM p = Array.filterSepElemsMAux✝ a p 0 #[]
Instances For
Equations
- a.filterSepElems p = (a.filterSepElemsM p).run
Instances For
Equations
- a.mapSepElemsM f = Array.mapSepElemsMAux✝ a f 0 #[]
Instances For
Instances For
Equations
- sa.getElems = sa.elemsAndSeps.getSepElems
Instances For
Equations
- sa.getElems = Lean.TSyntaxArray.mk sa.elemsAndSeps.getSepElems
Instances For
Equations
- sa.push e = if sa.elemsAndSeps.isEmpty = true then { elemsAndSeps := #[e.raw] } else { elemsAndSeps := (sa.elemsAndSeps.push (Lean.mkAtom sep)).push e.raw }
Instances For
Equations
- Lean.Syntax.instCoeOutTSepArrayTSyntaxArray = { coe := Lean.Syntax.TSepArray.getElems }
Equations
- Lean.Syntax.instCoeTSyntaxArrayOfTSyntax = { coe := fun (a : Lean.TSyntaxArray k) => Array.map Coe.coe a }
Equations
- Lean.Syntax.instCoeIdentTSyntaxConsSyntaxNodeKindMkStr4Nil = { coe := fun (id : Lean.Ident) => Lean.mkNode `Lean.Parser.Command.declId #[id.raw, Lean.mkNullNode #[]] }
Helper functions for manipulating interpolated strings #
Equations
- stx.getSepArgs = stx.getArgs.getSepElems
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- Lean.Meta.instReprEtaStructMode = { reprPrec := Lean.Meta.reprEtaStructMode✝ }
Equations
- Lean.Meta.instReprConfig = { reprPrec := Lean.Meta.reprConfig✝ }
Equations
- Lean.Meta.instReprTransparencyMode = { reprPrec := Lean.Meta.reprTransparencyMode✝ }
Equations
- Lean.Meta.Occurrences.all.contains x = true
- (Lean.Meta.Occurrences.pos idxs).contains x = idxs.contains x
- (Lean.Meta.Occurrences.neg idxs).contains x = !idxs.contains x
Instances For
Controls which new mvars are turned in to goals by the apply
tactic.
nonDependentFirst
mvars that don't depend on other goals appear first in the goal list.nonDependentOnly
only mvars that don't depend on other goals are added to goal list.all
all unassigned mvars are added to the goal list.
- nonDependentFirst: Lean.Meta.ApplyNewGoals
- nonDependentOnly: Lean.Meta.ApplyNewGoals
- all: Lean.Meta.ApplyNewGoals
Instances For
Configures the behaviour of the apply
tactic.
- newGoals : Lean.Meta.ApplyNewGoals
- synthAssignedInstances : Bool
If
synthAssignedInstances
istrue
, thenapply
will synthesize instance implicit arguments even if they have assigned byisDefEq
, and then check whether the synthesized value matches the one inferred. Thecongr
tactic sets this flag to false. - allowSynthFailures : Bool
If
allowSynthFailures
istrue
, thenapply
will return instance implicit arguments for which typeclass search failed as new goals. - approx : Bool
If
approx := true
, then we turn onisDefEq
approximations. That is, we use theapproxDefEq
combinator.
Instances For
Instances For
- transparency : Lean.Meta.TransparencyMode
- offsetCnstrs : Bool
- occs : Lean.Meta.Occurrences
- newGoals : Lean.Meta.Rewrite.NewGoals
Instances For
Configures the behaviour of the omega
tactic.
- splitDisjunctions : Bool
Split disjunctions in the context.
Note that with
splitDisjunctions := false
omega will not be able to solvex = y
goals as these are usually handled by introducing¬ x = y
as a hypothesis, then replacing this withx < y ∨ x > y
.On the other hand,
omega
does 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) = 0
for later splitting. - splitNatAbs : Bool
Whenever
Int.natAbs a
is found, register the disjunction0 ≤ a ∧ Int.natAbs a = a ∨ a < 0 ∧ Int.natAbs a = - a
for later splitting. - splitMinMax : Bool
Whenever
min a b
ormax a b
is 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 : α), Lean.Meta.CheckTactic.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.
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).
Instances For
Equations
- One or more equations did not get rendered due to their size.
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.
Instances For
simp_arith
is shorthand for simp
with arith := true
and decide := true
.
This enables the use of normalization by linear arithmetic.
Equations
- One or more equations did not get rendered due to their size.
Instances For
simp_arith!
is shorthand for simp_arith
with autoUnfold := true
.
This will rewrite with all equation lemmas, which can be used to
partially evaluate many definitions.
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
- One or more equations did not get rendered due to their size.
Instances For
simp_all_arith
combines the effects of simp_all
and simp_arith
.
Instances For
simp_all_arith!
combines the effects of simp_all
, simp_arith
and simp!
.
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.
Equations
- One or more equations did not get rendered due to their size.