statement
stringlengths
1
2.88k
proof
stringlengths
0
13.9k
type
stringclasses
10 values
symbolic_name
stringlengths
1
131
library
stringclasses
417 values
filename
stringlengths
17
80
imports
listlengths
0
16
deps
listlengths
0
64
docstring
stringlengths
0
10.2k
source_url
stringclasses
1 value
commit
stringclasses
1 value
instantiate_mvars_in_target : tactic unit
target >>= instantiate_mvars >>= change
def
tactic.instantiate_mvars_in_target
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Instantiates metavariables that appear in the current goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
instantiate_mvars_in_goals : tactic unit
all_goals' $ instantiate_mvars_in_target
def
tactic.instantiate_mvars_in_goals
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Instantiates metavariables in all goals.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_protected (n : name) : tactic unit
do env ← get_env, set_env (env.mk_protected n)
def
tactic.mk_protected
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Protect the declaration `n`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
repeat_at_least {α : Type} (p : lean.parser α) : ℕ → lean.parser (list α)
| 0 := many p | (n + 1) := list.cons <$> p <*> repeat_at_least n
def
lean.parser.repeat_at_least
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
A version of `lean.parser.many` that requires at least `n` items
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sep_by_trailing {α : Type} (s : lean.parser unit) (p : lean.parser α) : lean.parser (list α)
do fst ← p, some () ← optional s | pure [fst], some rest ← optional sep_by_trailing | pure [fst], pure (fst :: rest)
def
lean.parser.sep_by_trailing
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
A version of `lean.parser.sep_by` that allows trailing delimiters, but requires at least one item. Like `lean.parser.sep_by`, as a result of the `lean.parser` monad not being pure, this is only well-behaved if `p` and `s` are backtrackable; which in practice means they must not consume the input when they do not have a...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
emit_command_here (str : string) : lean.parser string
do (_, left) ← with_input command_like str, return left
def
lean.parser.emit_command_here
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`emit_command_here str` behaves as if the string `str` were placed as a user command at the current line.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
emit_code_here_aux : string → ℕ → lean.parser unit
| str slen := do left ← emit_command_here str, let llen := left.length, when (llen < slen ∧ llen ≠ 0) (emit_code_here_aux left llen)
def
lean.parser.emit_code_here_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Inner recursion for `emit_code_here`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
emit_code_here (s : string) : lean.parser unit
emit_code_here_aux s s.length
def
lean.parser.emit_code_here
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`emit_code_here str` behaves as if the string `str` were placed at the current location in source code.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
run_parser_cmd (_ : interactive.parse $ tk "run_parser") : lean.parser unit
do e ← lean.parser.pexpr 0, p ← eval_pexpr (lean.parser unit) e, p
def
lean.parser.run_parser_cmd
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`run_parser p` is like `run_cmd` but for the parser monad. It executes parser `p` at the top level, giving access to operations like `emit_code_here`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_current_namespace : lean.parser name
do env ← get_env, n ← tactic.mk_user_fresh_name, emit_code_here $ sformat!"def {n} := ()", nfull ← tactic.resolve_constant n, set_env env, return $ nfull.get_nth_prefix n.components.length
def
lean.parser.get_current_namespace
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "tactic.mk_user_fresh_name" ]
`get_current_namespace` returns the current namespace (it could be `name.anonymous`). This function deserves a C++ implementation in core lean, and will fail if it is not called from the body of a command (i.e. anywhere else that the `lean.parser` monad can be invoked).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_variables : lean.parser (list (name × binder_info × expr))
list.map expr.get_local_const_kind <$> list_available_include_vars
def
lean.parser.get_variables
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "expr.get_local_const_kind" ]
`get_variables` returns a list of existing variable names, along with their types and binder info.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_included_variables : lean.parser (list (name × binder_info × expr))
do ns ← list_include_var_names, list.filter (λ v, v.1 ∈ ns) <$> get_variables
def
lean.parser.get_included_variables
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`get_included_variables` returns those variables `v` returned by `get_variables` which have been "included" by an `include v` statement and are not (yet) `omit`ed.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
synthesize_tactic_state_with_variables_as_hyps (es : list pexpr) : lean.parser (tactic_state × list (expr × expr))
do /- First, in order to get `to_expr e` to resolve declared `variables`, we add all of the declared variables to a fake `tactic_state`, and perform the resolution. At the end, `to_expr e` has done the work of determining which variables were actually referenced, which we then obtain from `fe` via `ex...
def
lean.parser.synthesize_tactic_state_with_variables_as_hyps
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "expr.all_implicitly_included_variables" ]
From the `lean.parser` monad, synthesize a `tactic_state` which includes all of the local variables referenced in `es : list pexpr`, and those variables which have been `include`ed in the local context---precisely those variables which would be ambiently accessible if we were in a tactic-mode block where the goals had ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
instance_stub : hole_command
{ name := "Instance Stub", descr := "Generate a skeleton for the structure under construction.", action := λ _, do tgt ← target >>= whnf, let cl := tgt.get_app_fn.const_name, env ← get_env, fs ← expanded_field_list cl, let fs := fs.map prod.snd, let fs := format.intercalate (",\n " : for...
def
tactic.instance_stub
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "format.intercalate" ]
Hole command used to fill in a structure's field when specifying an instance. In the following: ```lean instance : monad id := {! !} ``` invoking the hole command "Instance Stub" ("Generate a skeleton for the structure under construction.") produces: ```lean instance : monad id := { map := _, map_const := _, pu...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
resolve_name' (n : name) : tactic pexpr
do [] ← get_goals | resolve_name n, g ← mk_mvar, set_goals [g], resolve_name n <* set_goals []
def
tactic.resolve_name'
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Like `resolve_name` except when the list of goals is empty. In that situation `resolve_name` fails whereas `resolve_name'` simply proceeds on a dummy goal
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
strip_prefix' (n : name) : list string → name → tactic name
| s name.anonymous := pure $ s.foldl (flip name.mk_string) name.anonymous | s (name.mk_string a p) := do let n' := s.foldl (flip name.mk_string) name.anonymous, do { n'' ← tactic.resolve_constant n', if n'' = n then pure n' else strip_prefix' (a :: s) p } <|> strip_prefix' ...
def
tactic.strip_prefix'
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
strip_prefix : name → tactic name
| n@(name.mk_string a a_1) := if (`_private).is_prefix_of n then let n' := n.update_prefix name.anonymous in n' <$ resolve_name' n' <|> pure n else strip_prefix' n [a] a_1 | n := pure n
def
tactic.strip_prefix
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Strips unnecessary prefixes from a name, e.g. if a namespace is open.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_patterns (t : expr) : tactic (list format)
do let cl := t.get_app_fn.const_name, env ← get_env, let fs := env.constructors_of cl, fs.mmap $ λ f, do { (vs,_) ← mk_const f >>= infer_type >>= open_pis, let vs := vs.filter (λ v, v.is_default_local), vs ← vs.mmap (λ v, do v' ← get_unused_name v.local_pp_name, ...
def
tactic.mk_patterns
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Used to format return strings for the hole commands `match_stub` and `eqn_stub`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_stub : hole_command
{ name := "Match Stub", descr := "Generate a list of equations for a `match` expression.", action := λ es, do [e] ← pure es | fail "expecting one expression", e ← to_expr e, t ← infer_type e >>= whnf, fs ← mk_patterns t, e ← pp e, let out := format.to_string format!"match {e} with\n{forma...
def
tactic.match_stub
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Hole command used to generate a `match` expression. In the following: ```lean meta def foo (e : expr) : tactic unit := {! e !} ``` invoking hole command "Match Stub" ("Generate a list of equations for a `match` expression") produces: ```lean meta def foo (e : expr) : tactic unit := match e with | (expr.var a) := _ ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
eqn_stub : hole_command
{ name := "Equations Stub", descr := "Generate a list of equations for a recursive definition.", action := λ es, do t ← match es with | [t] := to_expr t | [] := target | _ := fail "expecting one type" end, e ← whnf t, (v :: _,_) ← open_pis e | fail "expecting a Pi-typ...
def
tactic.eqn_stub
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Invoking hole command "Equations Stub" ("Generate a list of equations for a recursive definition") in the following: ```lean meta def foo : {! expr → tactic unit !} -- `:=` is omitted ``` produces: ```lean meta def foo : expr → tactic unit | (expr.var a) := _ | (expr.sort a) := _ | (expr.const a a_1) := _ | (expr.mv...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list_constructors_hole : hole_command
{ name := "List Constructors", descr := "Show the list of constructors of the expected type.", action := λ es, do t ← target >>= whnf, (_,t) ← open_pis t, let cl := t.get_app_fn.const_name, let args := t.get_app_args, env ← get_env, let cs := env.constructors_of cl, ts ← cs.mmap $ λ ...
def
tactic.list_constructors_hole
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "format.intercalate" ]
This command lists the constructors that can be used to satisfy the expected type. Invoking "List Constructors" ("Show the list of constructors of the expected type") in the following hole: ```lean def foo : ℤ ⊕ ℕ := {! !} ``` produces: ```lean def foo : ℤ ⊕ ℕ := {! sum.inl, sum.inr !} ``` and will display: ```le...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
classical (aggressive : bool := ff) : tactic unit
if aggressive then do h ← get_unused_name `_inst, mk_const `classical.prop_decidable >>= note h none, reset_instance_cache else do -- Turn on the `prop_decidable` instance. `9` is what we use in the `classical` locale tactic.set_basic_attribute `instance `classical.prop_decidable ff (some 9)
def
tactic.classical
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Makes the declaration `classical.prop_decidable` available to type class inference. This asserts that all propositions are decidable, but does not have computational content. The `aggressive` argument controls whether the instance is added globally, where it has low priority, or in the local context, where it has very...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_comp (v : expr) : expr → tactic expr
| (app f e) := if e = v then pure f else do guard (¬ v.occurs f) <|> fail "bad guard", e' ← mk_comp e >>= instantiate_mvars, f ← instantiate_mvars f, mk_mapp ``function.comp [none,none,none,f,e'] | e := do guard (e = v), t ← infer_type e, mk_mapp ``id [t]
def
tactic.mk_comp
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`mk_comp v e` checks whether `e` is a sequence of nested applications `f (g (h v))`, and if so, returns the expression `f ∘ g ∘ h`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_iff (e₀ : expr) (e₁ : expr) : expr
`(%%e₀ ↔ %%e₁)
def
tactic.mk_iff
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Given two expressions `e₀` and `e₁`, return the expression `` `(%%e₀ ↔ %%e₁)``.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_higher_order_type : expr → tactic expr
| (pi n bi d b@(pi _ _ _ _)) := do v ← mk_local_def n d, let b' := (b.instantiate_var v), (pi n bi d ∘ flip abstract_local v.local_uniq_name) <$> mk_higher_order_type b' | (pi n bi d b) := do v ← mk_local_def n d, let b' := (b.instantiate_var v), (l,r) ← match_eq b' <|> fail format!"not an equal...
def
tactic.mk_higher_order_type
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
From a lemma of the shape `∀ x, f (g x) = h x` derive an auxiliary lemma of the form `f ∘ g = h` for reasoning about higher-order functions.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
higher_order_attr : user_attribute unit (option name)
{ name := `higher_order, parser := optional ident, descr := "From a lemma of the shape `∀ x, f (g x) = h x` derive an auxiliary lemma of the form `f ∘ g = h` for reasoning about higher-order functions.", after_set := some $ λ lmm _ _, do env ← get_env, decl ← env.get lmm, let num := decl.univ_p...
def
tactic.higher_order_attr
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "num" ]
A user attribute that applies to lemmas of the shape `∀ x, f (g x) = h x`. It derives an auxiliary lemma of the form `f ∘ g = h` for reasoning about higher-order functions.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
interactive_attr : user_attribute
{ name := `interactive, descr := "Put a definition in the `tactic.interactive` namespace to make it usable in proof scripts.", after_set := some $ λ tac _ _, add_interactive [tac] }
def
tactic.interactive_attr
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Copies a definition into the `tactic.interactive` namespace to make it usable in proof scripts. It allows one to write ```lean @[interactive] meta def my_tactic := ... ``` instead of ```lean meta def my_tactic := ... run_cmd add_interactive [``my_tactic] ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
use_aux (h : pexpr) : tactic unit
(focus1 (refine h >> done)) <|> (fconstructor >> use_aux)
def
tactic.use_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Use `refine` to partially discharge the goal, or call `fconstructor` and try again.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
use (l : list pexpr) : tactic unit
focus1 $ seq' (l.mmap' $ λ h, use_aux h <|> fail format!"failed to instantiate goal with {h}") instantiate_mvars_in_target
def
tactic.use
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Similar to `existsi`, `use l` will use entries in `l` to instantiate existential obligations at the beginning of a target. Unlike `existsi`, the pexprs in `l` are elaborated with respect to the expected type. ```lean example : ∃ x : ℤ, x = x := by tactic.use ``(42) ``` See the doc string for `tactic.interactive.use` ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_aux_decl_aux : list expr → tactic unit
| [] := skip | (e::l) := do cond e.is_aux_decl (tactic.clear e) skip, clear_aux_decl_aux l
def
tactic.clear_aux_decl_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`clear_aux_decl_aux l` clears all expressions in `l` that represent aux decls from the local context.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_aux_decl : tactic unit
local_context >>= clear_aux_decl_aux
def
tactic.clear_aux_decl
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`clear_aux_decl` clears all expressions from the local context that represent aux decls.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_at_aux (arg t : expr) : list expr → expr → expr → tactic (expr × list expr)
| vs e (pi n bi d b) := do { v ← mk_meta_var d, apply_at_aux (v :: vs) (e v) (b.instantiate_var v) } <|> (e arg, vs) <$ unify d t | vs e _ := failed
def
tactic.apply_at_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`apply_at_aux e et [] h ht` (with `et` the type of `e` and `ht` the type of `h`) finds a list of expressions `vs` and returns `(e.mk_args (vs ++ [h]), vs)`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_at (e h : expr) : tactic unit
do ht ← infer_type h, et ← infer_type e, (h', gs') ← apply_at_aux h ht [] e et, note h.local_pp_name none h', clear h, gs' ← gs'.mfilter is_assigned, (g :: gs) ← get_goals, set_goals (g :: gs' ++ gs)
def
tactic.apply_at
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`apply_at e h` applies implication `e` on hypothesis `h` and replaces `h` with the result.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
symmetry_hyp (h : expr) (md := semireducible) : tactic unit
do tgt ← infer_type h, env ← get_env, let r := get_app_fn tgt, match env.symm_for (const_name r) with | (some symm) := do s ← mk_const symm, apply_at s h | none := fail "symmetry tactic failed, target is not a relation application with the expected property." en...
def
tactic.symmetry_hyp
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`symmetry_hyp h` applies `symmetry` on hypothesis `h`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
setup_tactic_parser_cmd (_ : interactive.parse $ tk "setup_tactic_parser") : lean.parser unit
emit_code_here " open _root_.lean open _root_.lean.parser open _root_.interactive _root_.interactive.types local postfix (name := parser.optional) `?`:9001 := optional local postfix (name := parser.many) *:9001 := many . "
def
tactic.setup_tactic_parser_cmd
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`setup_tactic_parser` is a user command that opens the namespaces used in writing interactive tactics, and declares the local postfix notation `?` for `optional` and `*` for `many`. It does *not* use the `namespace` command, so it will typically be used after `namespace tactic.interactive`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
finally {β} (tac : tactic α) (finalizer : tactic β) : tactic α
λ s, match tac s with | (result.success r s') := (finalizer >> pure r) s' | (result.exception msg p s') := (finalizer >> result.exception msg p) s' end
def
tactic.finally
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`finally tac finalizer` runs `tac` first, then runs `finalizer` even if `tac` fails. `finally tac finalizer` fails if either `tac` or `finalizer` fails.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
on_exception {β} (handler : tactic β) (tac : tactic α) : tactic α | s
match tac s with | result.exception msg p s' := (handler *> result.exception msg p) s' | ok := ok end
def
tactic.on_exception
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`on_exception handler tac` runs `tac` first, and then runs `handler` only if `tac` failed.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
decorate_error (add_msg : string) (tac : tactic α) : tactic α | s
match tac s with | result.exception msg p s := let msg (_ : unit) : format := match msg with | some msg := add_msg ++ format.line ++ msg () | none := add_msg
def
tactic.decorate_error
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`decorate_error add_msg tac` prepends `add_msg` to an exception produced by `tac`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
retrieve_or_report_error {α : Type u} (t : tactic α) : tactic (α ⊕ string)
λ s, match t s with | (interaction_monad.result.success a s') := result.success (sum.inl a) s | (interaction_monad.result.exception msg' _ s') := result.success (sum.inr (msg'.iget ()).to_string) s end
def
retrieve_or_report_error
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Applies tactic `t`. If it succeeds, revert the state, and return the value. If it fails, returns the error message.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
try_or_report_error {α : Type u} (t : tactic α) : tactic (α ⊕ string)
λ s, match t s with | (interaction_monad.result.success a s') := result.success (sum.inl a) s' | (interaction_monad.result.exception msg' _ s') := result.success (sum.inr (msg'.iget ()).to_string) s end
def
try_or_report_error
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Applies tactic `t`. If it succeeds, return the value. If it fails, returns the error message.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
succeeds_or_fails_with_msg {α : Type} (t : tactic α) (p : string → bool) : tactic unit
do x ← retrieve_or_report_error t, match x with | (sum.inl _) := skip | (sum.inr msg) := if p msg then skip else fail msg end
def
succeeds_or_fails_with_msg
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "retrieve_or_report_error" ]
This tactic succeeds if `t` succeeds or fails with message `msg` such that `p msg` is `tt`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
trace_error (msg : string) (t : tactic α) : tactic α
| s := match t s with | (result.success r s') := result.success r s' | (result.exception (some msg') p s') := (trace msg >> trace (msg' ()) >> result.exception (some msg') p) s' | (result.exception none p s') := result.exception none p s' end
def
trace_error
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`trace_error msg t` executes the tactic `t`. If `t` fails, traces `msg` and the failure message of `t`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
trace_if_enabled (n : name) {α : Type u} [has_to_tactic_format α] (msg : α) : tactic unit
when_tracing n (trace msg)
def
trace_if_enabled
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
``trace_if_enabled `n msg`` traces the message `msg` only if tracing is enabled for the name `n`. Create new names registered for tracing with `declare_trace n`. Then use `set_option trace.n true/false` to enable or disable tracing for `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
trace_state_if_enabled (n : name) (msg : string := "") : tactic unit
when_tracing n ((if msg = "" then skip else trace msg) >> trace_state)
def
trace_state_if_enabled
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
``trace_state_if_enabled `n msg`` prints the tactic state, preceded by the optional string `msg`, only if tracing is enabled for the name `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
success_if_fail_with_msg {α : Type u} (t : tactic α) (msg : string) : tactic unit
λ s, match t s with | (interaction_monad.result.exception msg' _ s') := let expected_msg := (msg'.iget ()).to_string in if msg = expected_msg then result.success () s else mk_exception format!"failure messages didn't match. Expected:\n{expected_msg}" none s | (interaction_monad.result.success a s) := mk_except...
def
success_if_fail_with_msg
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
This combinator is for testing purposes. It succeeds if `t` fails with message `msg`, and fails otherwise.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_statement (g : expr) : tactic string
do g ← instantiate_mvars g, g ← head_beta g, r ← pp (replace_mvars g), if g.has_meta_var then return (sformat!"Try this: refine {r}") else return (sformat!"Try this: exact {r}")
def
tactic_statement
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Construct a `Try this: refine ...` or `Try this: exact ...` string which would construct `g`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
with_local_goals {α} (gs : list expr) (tac : tactic α) : tactic (α × list expr)
do gs' ← get_goals, set_goals gs, finally (prod.mk <$> tac <*> get_goals) (set_goals gs')
def
with_local_goals
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`with_local_goals gs tac` runs `tac` on the goals `gs` and then restores the initial goals and returns the goals `tac` ended on.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
with_local_goals' {α} (gs : list expr) (tac : tactic α) : tactic α
prod.fst <$> with_local_goals gs tac
def
with_local_goals'
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "with_local_goals" ]
like `with_local_goals` but discards the resulting goals
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
packaged_goal
ℕ × expr
def
packaged_goal
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Representation of a proof goal that lends itself to comparison. The following goal: ```lean l₀ : T, l₁ : T ⊢ ∀ v : T, foo ``` is represented as ``` (2, ∀ l₀ l₁ v : T, foo) ``` The number 2 indicates that first the two bound variables of the `∀` are actually local constant. Comparing two such goals with `=` rather t...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
proof_state
list packaged_goal
def
proof_state
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "packaged_goal" ]
proof state made of multiple `goal` meant for comparing the result of running different tactics
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
goal.inhabited : inhabited packaged_goal
⟨(0,var 0)⟩
instance
goal.inhabited
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "packaged_goal" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
proof_state.inhabited : inhabited proof_state
(infer_instance : inhabited (list packaged_goal))
instance
proof_state.inhabited
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "packaged_goal", "proof_state" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_packaged_goal : tactic packaged_goal
do ls ← local_context, tgt ← target >>= instantiate_mvars, tgt ← pis ls tgt, pure (ls.length, tgt)
def
get_packaged_goal
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "packaged_goal" ]
create a `packaged_goal` corresponding to the current goal
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
goal_of_mvar (g : expr) : tactic packaged_goal
with_local_goals' [g] get_packaged_goal
def
goal_of_mvar
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "get_packaged_goal", "packaged_goal", "with_local_goals'" ]
`goal_of_mvar g`, with `g` a meta variable, creates a `packaged_goal` corresponding to `g` interpretted as a proof goal
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_proof_state : tactic proof_state
do gs ← get_goals, gs.mmap $ λ g, do ⟨n,g⟩ ← goal_of_mvar g, g ← gs.mfoldl (λ g v, do g ← kabstract g v reducible ff, pure $ pi `goal binder_info.default `(true) g ) g, pure (n,g)
def
get_proof_state
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "goal_of_mvar", "proof_state" ]
`get_proof_state` lists the user visible goal for each goal of the current state and for each goal, abstracts all of the meta variables of the other gaols. This produces a list of goals in the form of `ℕ × expr` where the `expr` encodes the following proof state: ```lean 2 goals l₁ : t₁, l₂ : t₂, l₃ : t₃ ⊢ tgt₁ ⊢ tg...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_proof_state_after (tac : tactic unit) : tactic (option proof_state)
try_core $ retrieve $ tac >> get_proof_state
def
get_proof_state_after
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "get_proof_state", "proof_state" ]
Run `tac` in a disposable proof state and return the state. See `proof_state`, `goal` and `get_proof_state`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pformat
tactic format
def
pformat
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
A type alias for `tactic format`, standing for "pretty print format".
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pformat.mk (fmt : format) : pformat
pure fmt
def
pformat.mk
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "pformat" ]
`mk` lifts `fmt : format` to the tactic monad (`pformat`).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
to_pfmt {α} [has_to_tactic_format α] (x : α) : pformat
pp x
def
to_pfmt
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "pformat" ]
an alias for `pp`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pformat.has_to_tactic_format : has_to_tactic_format pformat
⟨ id ⟩
instance
pformat.has_to_tactic_format
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "pformat" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic.has_to_tactic_format [has_to_tactic_format α] : has_to_tactic_format (tactic α)
⟨ λ x, x >>= to_pfmt ⟩
instance
tactic.has_to_tactic_format
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "to_pfmt" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_pformat : string → list char → parser pexpr
| acc [] := pure ``(to_pfmt %%(reflect acc)) | acc ('\n'::s) := do f ← parse_pformat "" s, pure ``(to_pfmt %%(reflect acc) ++ pformat.mk format.line ++ %%f) | acc ('{'::'{'::s) := parse_pformat (acc ++ "{") s | acc ('{'::s) := do (e, s) ← with_input (lean.parser.pexpr 0) s.as_string, '}'::s ← retur...
def
parse_pformat
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pformat_macro (_ : parse $ tk "pformat!") (s : string) : parser pexpr
do e ← parse_pformat "" s.to_list, return ``(%%e : pformat)
def
pformat_macro
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "parse_pformat" ]
See `format!` in `init/meta/interactive_base.lean`. The main differences are that `pp` is called instead of `to_fmt` and that we can use arguments of type `tactic α` in the quotations. Now, consider the following: ```lean e ← to_expr ``(3 + 7), trace format!"{e}" -- outputs `has_add.add.{0} nat nat.has_add ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
fail_macro (_ : parse $ tk "fail!") (s : string) : parser pexpr
do e ← pformat_macro () s, pure ``((%%e : pformat) >>= fail)
def
fail_macro
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "pformat_macro" ]
The combination of `pformat` and `fail`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
trace_macro (_ : parse $ tk "trace!") (s : string) : parser pexpr
do e ← pformat_macro () s, pure ``((%%e : pformat) >>= trace)
def
trace_macro
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "pformat_macro" ]
The combination of `pformat` and `trace`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_project_dir (n : name) (k : ℕ) : tactic string
do e ← get_env, s ← e.decl_olean n <|> fail!"Did not find declaration {n}. This command does not work in the file where {n} is declared.", return $ s.popn_back k
def
get_project_dir
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
A hackish way to get the `src` directory of any project. Requires as argument any declaration name `n` in that project, and `k`, the number of characters in the path of the file where `n` is declared not part of the `src` directory. Example: For `mathlib_dir_locator` this is the length of `tactic/project_dir.lean...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_mathlib_dir : tactic string
get_project_dir `mathlib_dir_locator 23
def
get_mathlib_dir
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "get_project_dir", "mathlib_dir_locator" ]
A hackish way to get the `src` directory of mathlib.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
is_in_mathlib (n : name) : tactic bool
do ml ← get_mathlib_dir, e ← get_env, return $ e.is_prefix_of_file ml n
def
is_in_mathlib
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "get_mathlib_dir" ]
Checks whether a declaration with the given name is declared in mathlib. If you want to run this tactic many times, you should use `environment.is_prefix_of_file` instead, since it is expensive to execute `get_mathlib_dir` many times.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
name_to_tactic (n : name) : tactic string
do d ← get_decl n, e ← mk_const n, let t := d.type, if (t =ₐ `(tactic unit)) then (eval_expr (tactic unit) e) >>= (λ t, t >> (name.to_string <$> strip_prefix n)) else if (t =ₐ `(tactic string)) then (eval_expr (tactic string) e) >>= (λ t, t) else fail! "name_to_tactic cannot take `{n} as i...
def
name_to_tactic
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Runs a tactic by name. If it is a `tactic string`, return whatever string it returns. If it is a `tactic unit`, return the name. (This is mostly used in invoking "self-reporting tactics", e.g. by `tidy` and `hint`.)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_under_n_pis_aux (func arg : pexpr) : ℕ → ℕ → expr → pexpr
| n 0 _ := let vars := ((list.range n).reverse.map (@expr.var ff)), bd := vars.foldl expr.app arg.mk_explicit in func bd | n (k+1) (expr.pi nm bi tp bd) := expr.pi nm bi (pexpr.of_expr tp) (apply_under_n_pis_aux (n+1) k bd) | n (k+1) t := apply_under_n_pis_aux n 0 t
def
apply_under_n_pis_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
auxiliary function for `apply_under_n_pis`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_under_n_pis (func arg : pexpr) (pi_expr : expr) (n : ℕ) : pexpr
apply_under_n_pis_aux func arg 0 n pi_expr
def
apply_under_n_pis
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "apply_under_n_pis_aux" ]
Assumes `pi_expr` is of the form `Π x1 ... xn xn+1..., _`. Creates a pexpr of the form `Π x1 ... xn, func (arg x1 ... xn)`. All arguments (implicit and explicit) to `arg` should be supplied.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_under_pis (func arg : pexpr) (pi_expr : expr) : pexpr
apply_under_n_pis func arg pi_expr pi_expr.pi_arity
def
apply_under_pis
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "apply_under_n_pis" ]
Assumes `pi_expr` is of the form `Π x1 ... xn, _`. Creates a pexpr of the form `Π x1 ... xn, func (arg x1 ... xn)`. All arguments (implicit and explicit) to `arg` should be supplied.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_pexpr_arg_arity_with_tgt (func : pexpr) (tgt : expr) : tactic ℕ
lock_tactic_state $ do mv ← mk_mvar, solve_aux tgt $ intros >> to_expr ``(%%func %%mv), expr.pi_arity <$> (infer_type mv >>= instantiate_mvars)
def
get_pexpr_arg_arity_with_tgt
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
If `func` is a `pexpr` representing a function that takes an argument `a`, `get_pexpr_arg_arity_with_tgt func tgt` returns the arity of `a`. When `tgt` is a `pi` expr, `func` is elaborated in a context with the domain of `tgt`. Examples: * ```get_pexpr_arg_arity ``(ring) `(true)``` returns 0, since `ring` takes one no...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_private_decl (n : name) (fr : option name) : tactic name
do env ← get_env, fn ← option_t.run (do fr ← option_t.mk (return fr), d ← monad_lift $ get_decl fr, option_t.mk (return $ env.decl_olean d.to_name) ), let p : string → bool := match fn with | (some fn) := λ x, fn = x | none := λ _, tt end, let xs := env.decl_filte...
def
find_private_decl
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`find_private_decl n none` finds a private declaration named `n` in any of the imported files. `find_private_decl n (some m)` finds a private declaration named `n` in the same file where a declaration named `m` can be found.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
import_private_cmd (_ : parse $ tk "import_private") : lean.parser unit
do n ← ident, fr ← optional (tk "from" *> ident), n ← find_private_decl n fr, c ← resolve_constant n, d ← get_decl n, let c := @expr.const tt c d.univ_levels, new_n ← new_aux_decl_name, add_decl $ declaration.defn new_n d.univ_params d.type c reducibility_hints.abbrev d.is_trusted, let new_not ...
def
import_private_cmd
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "find_private_decl" ]
`import_private foo from bar` finds a private declaration `foo` in the same file as `bar` and creates a local notation to refer to it. `import_private foo` looks for `foo` in all imported files. When possible, make `foo` non-private rather than using this feature.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_user_attribute_name (attr_name : name) : tactic name
do ns ← attribute.get_instances `user_attribute, ns.mfirst (λ nm, do d ← get_decl nm, e ← mk_app `user_attribute.name [d.value], attr_nm ← eval_expr name e, guard $ attr_nm = attr_name, return nm) <|> fail!"'{attr_name}' is not a user attribute."
def
get_user_attribute_name
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Given a user attribute name `attr_name`, `get_user_attribute_name attr_name` returns the name of the declaration that defines this attribute. Fails if there is no user attribute with this name. Example: ``get_user_attribute_name `norm_cast`` returns `` `norm_cast.norm_cast_attr``
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
set_attribute (attr_name : name) (c_name : name) (persistent := tt) (prio : option nat := none) : tactic unit
do get_decl c_name <|> fail!"unknown declaration {c_name}", s ← try_or_report_error (set_basic_attribute attr_name c_name persistent prio), sum.inr msg ← return s | skip, if msg = (format!"set_basic_attribute tactic failed, '{attr_name}' is not a basic attribute").to_string then do user_attr_nm ← get_user_attribute...
def
set_attribute
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "get_user_attribute_name", "try_or_report_error" ]
A tactic to set either a basic attribute or a user attribute. If the user attribute has a parameter, the default value will be used. This tactic raises an error if there is no `inhabited` instance for the parameter type.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list.find_defeq (red : tactic.transparency) {v} (m : list (expr × v)) (e : expr) : tactic (expr × v)
m.mfind $ λ ⟨e', val⟩, tactic.is_def_eq e e' red
def
list.find_defeq
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`find_defeq red m e` looks for a key in `m` that is defeq to `e` (up to transparency `red`), and returns the value associated with this key if it exists. Otherwise, it fails.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic.interactive.dec_trivial (revert_deps : parse (tk "!")?) : tactic unit
if revert_deps.is_some then revert_target_deps; tactic.exact_dec_trivial else tactic.exact_dec_trivial
def
tactic.interactive.dec_trivial
tactic
src/tactic/dec_trivial.lean
[ "tactic.interactive" ]
[ "tactic.exact_dec_trivial" ]
`dec_trivial` tries to use decidability to prove a goal (i.e., using `exact dec_trivial`). The variant `dec_trivial!` will revert all hypotheses on which the target depends, before it tries `exact dec_trivial`. Example: ```lean example (n : ℕ) (h : n < 2) : n = 0 ∨ n = 1 := by dec_trivial! ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
delta_instance (ids : list name) : tactic unit
dsimp_result (intros >> reset_instance_cache >> delta_target ids >> apply_instance >> done)
def
tactic.delta_instance
tactic
src/tactic/delta_instance.lean
[ "tactic.simp_result" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
delta_instance (ids : parse ident*) : itactic
tactic.delta_instance ids
def
tactic.interactive.delta_instance
tactic
src/tactic/delta_instance.lean
[ "tactic.simp_result" ]
[ "tactic.delta_instance" ]
`delta_instance id₁ id₂ ...` tries to solve the goal by calling `apply_instance`, first unfolding the definitions in `idᵢ`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
delta_instance_name : pexpr → string
| (expr.app f _) := delta_instance_name f | (expr.pi _ _ _ body) := delta_instance_name body | (expr.lam _ _ _ body) := delta_instance_name body | (expr.const nm _) := nm.last | _ := "inst"
def
tactic.delta_instance_name
tactic
src/tactic/delta_instance.lean
[ "tactic.simp_result" ]
[]
Guess a name for an instance from its expression. This is a poor-man's version of the C++ `heuristic_inst_name`, and tries much less hard to pick a good name.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
delta_instance_handler : derive_handler
λ cls new_decl_name, do env ← get_env, if env.is_inductive new_decl_name then return ff else do new_decl ← get_decl new_decl_name, new_decl_pexpr ← resolve_name new_decl_name, arity ← get_pexpr_arg_arity_with_tgt cls new_decl.type, tgt ← to_expr $ apply_under_n_pis cls new_decl_pexpr new_decl.type (new_de...
def
tactic.delta_instance_handler
tactic
src/tactic/delta_instance.lean
[ "tactic.simp_result" ]
[ "apply_under_n_pis", "arity", "get_pexpr_arg_arity_with_tgt", "tactic.delta_instance" ]
Tries to derive instances by unfolding the newly introduced type and applying type class resolution. For example, ```lean @[derive ring] def new_int : Type := ℤ ``` adds an instance `ring new_int`, defined to be the instance of `ring ℤ` found by `apply_instance`. Multiple instances can be added with `@[derive [ring, ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
type_has_local_in_name_set (h : expr) (ns : name_set) : tactic bool
do h_type ← infer_type h, pure $ h_type.has_local_in ns
def
tactic.type_has_local_in_name_set
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`type_has_local_in_name_set h ns` returns true iff the type of `h` contains a local constant whose unique name appears in `ns`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
type_has_local_in_set (h : expr) (hs : expr_set) : tactic bool
type_has_local_in_name_set h $ local_set_to_name_set hs
def
tactic.type_has_local_in_set
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`type_has_local_in_set h hs` returns true iff the type of `h` contains any of the local constants `hs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
type_has_local_in (h : expr) (hs : list expr) : tactic bool
type_has_local_in_name_set h $ local_list_to_name_set hs
def
tactic.type_has_local_in
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`type_has_local_in h hs` returns true iff the type of `h` contains any of the local constants `hs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
local_def_value_has_local_in_name_set (h : expr) (ns : name_set) : tactic bool
do (some h_val) ← try_core $ local_def_value h | pure ff, pure $ h_val.has_local_in ns
def
tactic.local_def_value_has_local_in_name_set
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`local_def_value_has_local_in_name_set h ns` returns true iff `h` is a local definition whose value contains a local constant whose unique name appears in `ns`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
local_def_value_has_local_in_set (h : expr) (hs : expr_set) : tactic bool
local_def_value_has_local_in_name_set h $ local_set_to_name_set hs
def
tactic.local_def_value_has_local_in_set
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`local_def_value_has_local_in_set h hs` returns true iff `h` is a local definition whose value contains any of the local constants `hs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
local_def_value_has_local_in (h : expr) (hs : list expr) : tactic bool
local_def_value_has_local_in_name_set h $ local_list_to_name_set hs
def
tactic.local_def_value_has_local_in
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`local_def_value_has_local_in h hs` returns true iff `h` is a local definition whose value contains any of the local constants `hs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hyp_directly_depends_on_local_name_set (h : expr) (ns : name_set) : tactic bool
list.mbor [ type_has_local_in_name_set h ns, local_def_value_has_local_in_name_set h ns ]
def
tactic.hyp_directly_depends_on_local_name_set
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[ "list.mbor" ]
`hyp_directly_depends_on_local_name_set h ns` is true iff the hypothesis `h` directly depends on a hypothesis whose unique name appears in `ns`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hyp_directly_depends_on_local_set (h : expr) (hs : expr_set) : tactic bool
hyp_directly_depends_on_local_name_set h $ local_set_to_name_set hs
def
tactic.hyp_directly_depends_on_local_set
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`hyp_directly_depends_on_local_set h hs` is true iff the hypothesis `h` directly depends on any of the hypotheses `hs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hyp_directly_depends_on_locals (h : expr) (hs : list expr) : tactic bool
hyp_directly_depends_on_local_name_set h $ local_list_to_name_set hs
def
tactic.hyp_directly_depends_on_locals
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`hyp_directly_depends_on_locals h hs` is true iff the hypothesis `h` directly depends on any of the hypotheses `hs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hyp_directly_depends_on_local_name_set_inclusive (h : expr) (ns : name_set) : tactic bool
list.mbor [ pure $ ns.contains h.local_uniq_name , hyp_directly_depends_on_local_name_set h ns ]
def
tactic.hyp_directly_depends_on_local_name_set_inclusive
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[ "list.mbor" ]
`hyp_directly_depends_on_local_name_set_inclusive h ns` is true iff the hypothesis `h` directly depends on a hypothesis whose unique name appears in `ns` or `h`'s name appears in `ns`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hyp_directly_depends_on_local_set_inclusive (h : expr) (hs : expr_set) : tactic bool
hyp_directly_depends_on_local_name_set_inclusive h $ local_set_to_name_set hs
def
tactic.hyp_directly_depends_on_local_set_inclusive
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`hyp_directly_depends_on_local_set_inclusive h ns` is true iff the hypothesis `h` directly depends on any of the hypotheses `hs` or `h` appears in `hs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hyp_directly_depends_on_locals_inclusive (h : expr) (hs : list expr) : tactic bool
hyp_directly_depends_on_local_name_set_inclusive h $ local_list_to_name_set hs
def
tactic.hyp_directly_depends_on_locals_inclusive
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`hyp_directly_depends_on_locals_inclusive h ns` is true iff the hypothesis `h` directly depends on any of the hypotheses `hs` or `h` appears in `hs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
direct_dependency_set_of_hyp (h : expr) : tactic expr_set
do t ← infer_type h, let deps := t.list_local_consts', (some val) ← try_core $ local_def_value h | pure deps, let deps := deps.union val.list_local_consts', pure deps
def
tactic.direct_dependency_set_of_hyp
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`direct_dependency_set_of_hyp h` is the set of hypotheses that the hypothesis `h` directly depends on. These are the hypotheses that appear in `h`'s type or value (if `h` is a local definition).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
direct_dependency_name_set_of_hyp (h : expr) : tactic name_set
local_set_to_name_set <$> direct_dependency_set_of_hyp h
def
tactic.direct_dependency_name_set_of_hyp
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`direct_dependency_name_set_of_hyp h` is the set of unique names of hypotheses that the hypothesis `h` directly depends on. These are the hypotheses that appear in `h`'s type or value (if `h` is a local definition).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
direct_dependencies_of_hyp (h : expr) : tactic (list expr)
rb_set.to_list <$> direct_dependency_set_of_hyp h
def
tactic.direct_dependencies_of_hyp
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`direct_dependencies_of_hyp h` is the list of hypotheses that the hypothesis `h` directly depends on. These are the hypotheses that appear in `h`'s type or value (if `h` is a local definition). The dependencies are returned in no particular order.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
direct_dependency_set_of_hyp_inclusive (h : expr) : tactic expr_set
do deps ← direct_dependency_set_of_hyp h, pure $ deps.insert h
def
tactic.direct_dependency_set_of_hyp_inclusive
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`direct_dependency_set_of_hyp_inclusive h` is the set of hypotheses that the hypothesis `h` directly depends on, plus `h` itself.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
direct_dependency_name_set_of_hyp_inclusive (h : expr) : tactic name_set
local_set_to_name_set <$> direct_dependency_set_of_hyp_inclusive h
def
tactic.direct_dependency_name_set_of_hyp_inclusive
tactic
src/tactic/dependencies.lean
[ "meta.rb_map", "tactic.core" ]
[]
`direct_dependency_name_set_of_hyp_inclusive h` is the set of unique names of hypotheses that the hypothesis `h` directly depends on, plus `h` itself.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83