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
intron_fresh (n : ℕ) : tactic (list expr)
iterate_exactly n (mk_fresh_name >>= intro)
def
tactic.eliminate.intron_fresh
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
`intron_fresh n` introduces `n` hypotheses with names generated by `tactic.mk_fresh_name`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
constructor_intros (generate_induction_hyps : bool) (cinfo : constructor_info) : tactic (list (name × constructor_argument_info) × list (name × name × constructor_argument_info))
do let args := cinfo.non_param_args, arg_hyps ← intron_fresh cinfo.num_non_param_args, let args := (arg_hyps.map expr.local_pp_name).zip args, tt ← pure generate_induction_hyps | pure (args, []), let rec_args := args.filter $ λ x, x.2.is_recursive, ih_hyps ← intron_fresh cinfo.num_rec_args, let ihs := (i...
def
tactic.eliminate.constructor_intros
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
Introduce the new hypotheses generated by the minor premise for a given constructor. The new hypotheses are given fresh (unique, non-human-friendly) names. They are later renamed by `constructor_renames`. We delay the generation of the human-friendly names because when `constructor_renames` is called, more names may ha...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ih_name (arg_name : name) : name
mk_simple_name ("ih_" ++ arg_name.to_string)
def
tactic.eliminate.ih_name
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
`ih_name arg_name` is the name `ih_<arg_name>`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
with_pattern | auto | clear | exact (n : name)
inductive
tactic.eliminate.with_pattern
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
Representation of a pattern in the `with n ...` syntax supported by `induction'` and `cases'`. A `with_pattern` can be: - `with_pattern.auto` (`with _` or no `with` clause): use the name generated by the tactic. - `with_pattern.clear` (`with -`): clear this hypothesis and any hypotheses depending on it. - `with_patter...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parser : lean.parser with_pattern
(tk "-" *> pure with_pattern.clear) <|> (tk "_" *> pure with_pattern.auto) <|> (with_pattern.exact <$> ident)
def
tactic.eliminate.with_pattern.parser
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
Parser for a `with_pattern`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clause_parser : lean.parser (list with_pattern)
(tk "with" *> many with_pattern.parser) <|> pure []
def
tactic.eliminate.with_pattern.clause_parser
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
Parser for a `with` clause.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
to_name_spec (auto_candidates : tactic (list name)) : with_pattern → tactic (option (name ⊕ list name))
| auto := (some ∘ sum.inr) <$> auto_candidates | clear := pure none | (exact n) := pure $ some $ sum.inl n
def
tactic.eliminate.with_pattern.to_name_spec
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
`to_name_spec auto_candidates p` returns a description of how the hypothesis to which the `with_pattern` `p` applies should be named. If this function returns `none`, the hypothesis should be cleared. If it returns `some (inl n)`, it should receive exactly the name `n`, even if this shadows other hypotheses. If it retu...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_dependent_if_exists (h : name) : tactic unit
do (some h) ← try_core $ get_local h | pure (), clear' tt [h]
def
tactic.eliminate.clear_dependent_if_exists
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
If `h` refers to a hypothesis, `clear_dependent_if_exists h` clears `h` and any hypotheses which depend on it. Otherwise, the tactic does nothing.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
constructor_renames (generate_induction_hyps : bool) (mpinfo : major_premise_info) (iinfo : inductive_info) (cinfo : constructor_info) (with_patterns : list with_pattern) (args : list (name × constructor_argument_info)) (ihs : list (name × name × constructor_argument_info)) : tactic (list expr × list expr)
do -- Rename constructor arguments let arg_pp_name_set := name_set.of_list $ args.map prod.fst, let iname := iinfo.iname, let ⟨args, with_patterns⟩ := args.map₂_left' (λ arg p, (arg, p.get_or_else with_pattern.auto)) with_patterns, arg_renames ← args.mmap_filter $ λ ⟨⟨old_ppname, ainfo⟩, with_pat⟩,...
def
tactic.eliminate.constructor_renames
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[ "ih" ]
Rename the new hypotheses in the goal for a minor premise. Input: - `generate_induction_hyps`: whether we generate induction hypotheses (i.e. whether `eliminate_hyp` is in `induction` or `cases` mode). - `mpinfo`: information about the major premise. - `iinfo`: information about the inductive type. - `cinfo`: infor...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalization_mode | generalize_all_except (hs : list name) : generalization_mode | generalize_only (hs : list name) : generalization_mode
inductive
tactic.eliminate.generalization_mode
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
A value of `generalization_mode` describes the behaviour of the auto-generalisation functionality: - `generalize_all_except hs` means that the `hs` remain fixed and all other hypotheses are generalised. However, there are three exceptions: * Hypotheses depending on any `h` in `hs` also remain fixed. If we were to...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
to_generalize (major_premise : expr) : generalization_mode → tactic name_set
| (generalize_only ns) := do major_premise_rev_deps ← reverse_dependencies_of_hyps [major_premise], let major_premise_rev_deps := name_set.of_list $ major_premise_rev_deps.map local_uniq_name, ns ← ns.mmap (functor.map local_uniq_name ∘ get_local), pure $ major_premise_rev_deps.insert_list ns | (generalize_...
def
tactic.eliminate.generalization_mode.to_generalize
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
Given the major premise and a generalization_mode, this function returns the unique names of the hypotheses that should be generalized. See `generalization_mode` for what these are.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalize_hyps (major_premise : expr) (gm : generalization_mode) : tactic ℕ
do to_revert ← gm.to_generalize major_premise, ⟨n, _⟩ ← unfreezing (revert_name_set to_revert), pure n
def
tactic.eliminate.generalize_hyps
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
Generalize hypotheses for the given major premise and generalization mode. See `generalization_mode` and `to_generalize`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalize_complex_index_args (major_premise : expr) (num_params : ℕ) (generate_induction_hyps : bool) : tactic (expr × ℕ × list name × ℕ)
focus1 $ do major_premise_type ← infer_type major_premise, (major_premise_head, major_premise_args) ← get_app_fn_args_whnf major_premise_type, let ⟨major_premise_param_args, major_premise_index_args⟩ := major_premise_args.split_at num_params, -- TODO Add equations only for complex index args (not all i...
def
tactic.eliminate.generalize_complex_index_args
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
process_index_equation : expr → tactic (expr × option expr)
| h@(local_const _ ppname binfo T@(app (app (app (const `eq [u]) type) lhs) rhs)) := do rhs_eq_lhs ← succeeds $ unify rhs lhs, -- Note: It is important that we `unify rhs lhs` rather than `unify lhs rhs`. -- This is because `lhs` and `rhs` may be metavariables which represent -- Π-bound variables, so if the...
def
tactic.eliminate.process_index_equation
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[ "succeeds" ]
Process one index equation for `simplify_ih`. Input: a local constant `h : x = y` or `h : x == y`. Output: A proof of `x = y` or `x == y` and possibly a local constant of type `x = y` or `x == y` used in the proof. More specifically: - For `h : x = y` and `x` defeq `y`, we return the proof of `x = y` by reflexivit...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assign_local_to_unassigned_mvar (mv : expr) (pp_name : name) (binfo : binder_info) : tactic (option expr)
do ff ← is_assigned mv | pure none, type ← infer_type mv, c ← mk_local' pp_name binfo type, unify mv c, pure c
def
tactic.eliminate.assign_local_to_unassigned_mvar
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
`assign_local_to_unassigned_mvar mv pp_name binfo`, where `mv` is a metavariable, acts as follows: - If `mv` is assigned, it is not changed and the tactic returns `none`. - If `mv` is not assigned, it is assigned a fresh local constant with the type of `mv`, pretty name `pp_name` and binder info `binfo`. This local ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assign_locals_to_unassigned_mvars (mvars : list (expr × name × binder_info)) : tactic (list expr)
mvars.mmap_filter $ λ ⟨mv, pp_name, binfo⟩, assign_local_to_unassigned_mvar mv pp_name binfo
def
tactic.eliminate.assign_locals_to_unassigned_mvars
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
Apply `assign_local_to_unassigned_mvar` to a list of metavariables. Returns the newly created local constants.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
simplify_ih (num_leading_pis : ℕ) (num_generalized : ℕ) (num_index_vars : ℕ) (ih : expr) : tactic expr
do T ← infer_type ih, -- Replace the `xᵢ` with fresh metavariables. (generalized_arg_mvars, body) ← open_n_pis_metas' T (num_leading_pis + num_generalized), -- Replace the `eqᵢ` with fresh local constants. (index_eq_lcs, body) ← open_n_pis body num_index_vars, -- Process the `eqᵢ` local constants, yieldi...
def
tactic.eliminate.simplify_ih
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[ "ih" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
set_cases_tags (in_tag : tag) (rs : list (name × list expr)) : tactic unit
do gs ← get_goals, match gs with -- if only one goal was produced, we should not make the tag longer | [g] := set_tag g in_tag | _ := let tgs : list (name × list expr × expr) := rs.map₂ (λ ⟨n, new_hyps⟩ g, ⟨n, new_hyps, g⟩) gs in tgs.mmap' $ λ ⟨n, new_hyps, g⟩, with_enable_tags $ ...
def
tactic.eliminate.set_cases_tags
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
eliminate_hyp (generate_ihs : bool) (major_premise : expr) (gm := generalization_mode.generalize_all_except []) (with_patterns : list with_pattern := []) : tactic unit
focus1 $ do mpinfo ← get_major_premise_info major_premise, let major_premise_type := mpinfo.type, let major_premise_args := mpinfo.args.values.reverse, env ← get_env, -- Get info about the inductive type iname ← get_app_fn_const_whnf major_premise_type <|> fail! "The type of {major_premise} should be a...
def
tactic.eliminate_hyp
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[ "ih", "list.replicate" ]
`eliminate_hyp generate_ihs h gm with_patterns` performs induction or case analysis on the hypothesis `h`. If `generate_ihs` is true, the tactic performs induction, otherwise case analysis. In case analysis mode, `eliminate_hyp` is very similar to `tactic.cases`. The only differences (assuming no bugs in `eliminate_hy...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
eliminate_expr (generate_induction_hyps : bool) (major_premise : expr) (eq_name : option name := none) (gm := generalization_mode.generalize_all_except []) (with_patterns : list with_pattern := []) : tactic unit
do major_premise_revdeps ← reverse_dependencies_of_hyps [major_premise], num_reverted ← unfreezing (revert_lst major_premise_revdeps), hyp ← match eq_name with | some h := do x ← get_unused_name `x, interactive.generalize h () (to_pexpr major_premise, x), get_local x | no...
def
tactic.eliminate_expr
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
A variant of `tactic.eliminate_hyp` which performs induction or case analysis on an arbitrary expression. `eliminate_hyp` requires that the major premise is a hypothesis. `eliminate_expr` lifts this restriction by generalising the goal over the major premise before calling `eliminate_hyp`. The generalisation replaces t...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalisation_mode_parser : lean.parser generalization_mode
(tk "fixing" *> ((tk "*" *> pure (generalization_mode.generalize_only [])) <|> generalization_mode.generalize_all_except <$> many ident)) <|> (tk "generalizing" *> generalization_mode.generalize_only <$> many ident) <|> pure (generalization_mode.generalize_all_except [])
def
tactic.interactive.generalisation_mode_parser
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
Parse a `fixing` or `generalizing` clause for `induction'` or `cases'`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
induction' (major_premise : parse cases_arg_p) (gm : parse generalisation_mode_parser) (with_patterns : parse with_pattern.clause_parser) : tactic unit
do let ⟨eq_name, e⟩ := major_premise, e ← to_expr e, eliminate_expr tt e eq_name gm with_patterns
def
tactic.interactive.induction'
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
A variant of `tactic.interactive.induction`, with the following differences: - If the major premise (the hypothesis we are performing induction on) has complex indices, `induction'` 'remembers' them. A complex expression is any expression that is not merely a local hypothesis. A major premise `h : I p₁ ... pₙ j₁...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cases' (major_premise : parse cases_arg_p) (with_patterns : parse with_pattern.clause_parser) : tactic unit
do let ⟨eq_name, e⟩ := major_premise, e ← to_expr e, eliminate_expr ff e eq_name (generalization_mode.generalize_only []) with_patterns
def
tactic.interactive.cases'
tactic
src/tactic/induction.lean
[ "tactic.clear", "tactic.dependencies", "tactic.fresh_names", "tactic.generalizes", "tactic.has_variable_names", "tactic.unify_equations" ]
[]
A variant of `tactic.interactive.cases`, with minor changes: - `cases'` can perform case analysis on some (rare) goals that `cases` does not support. - `cases'` generates much more human-friendly names for the new hypotheses it introduces. This tactic supports the same modifiers as `cases`, e.g. ``` cases' H : e...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
fconstructor : tactic unit
concat_tags tactic.fconstructor
def
tactic.interactive.fconstructor
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Similar to `constructor`, but does not reorder goals.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
try_for (max : parse parser.pexpr) (tac : itactic) : tactic unit
do max ← i_to_expr_strict max >>= tactic.eval_expr nat, λ s, match _root_.try_for max (tac s) with | some r := r | none := (tactic.trace "try_for timeout, using sorry" >> tactic.admit) s end
def
tactic.interactive.try_for
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`try_for n { tac }` executes `tac` for `n` ticks, otherwise uses `sorry` to close the goal. Never fails. Useful for debugging.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
substs (l : parse ident*) : tactic unit
propagate_tags $ l.mmap' (λ h, get_local h >>= tactic.subst) >> try (tactic.reflexivity reducible)
def
tactic.interactive.substs
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Multiple `subst`. `substs x y z` is the same as `subst x, subst y, subst z`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unfold_coes (loc : parse location) : tactic unit
unfold [ ``coe, ``coe_t, ``has_coe_t.coe, ``coe_b,``has_coe.coe, ``lift, ``has_lift.lift, ``lift_t, ``has_lift_t.lift, ``coe_fn, ``has_coe_to_fun.coe, ``coe_sort, ``has_coe_to_sort.coe] loc
def
tactic.interactive.unfold_coes
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "lift" ]
Unfold coercion-related definitions
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unfold_wf
propagate_tags (well_founded_tactics.unfold_wf_rel; well_founded_tactics.unfold_sizeof)
def
tactic.interactive.unfold_wf
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Unfold `has_well_founded.r`, `sizeof` and other such definitions.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unfold_aux : tactic unit
do tgt ← target, name ← decl_name, let to_unfold := (tgt.list_names_with_prefix name), guard (¬ to_unfold.empty), -- should we be using simp_lemmas.mk_default? simp_lemmas.mk.dsimplify to_unfold.to_list tgt >>= tactic.change
def
tactic.interactive.unfold_aux
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Unfold auxiliary definitions associated with the current declaration.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
recover : tactic unit
metavariables >>= tactic.set_goals
def
tactic.interactive.recover
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
For debugging only. This tactic checks the current state for any missing dropped goals and restores them. Useful when there are no goals to solve but "result contains meta-variables".
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
continue (tac : itactic) : tactic unit
λ s, result.cases_on (tac s) (λ a, result.success ()) (λ e ref, result.success ())
def
tactic.interactive.continue
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Like `try { tac }`, but in the case of failure it continues from the failure state instead of reverting to the original state.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
id (tac : itactic) : tactic unit
tac
def
tactic.interactive.id
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`id { tac }` is the same as `tac`, but it is useful for creating a block scope without requiring the goal to be solved at the end like `{ tac }`. It can also be used to enclose a non-interactive tactic for patterns like `tac1; id {tac2}` where `tac2` is non-interactive.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
work_on_goal : parse small_nat → itactic → tactic unit
| 0 t := fail "work_on_goal failed: goals are 1-indexed" | (n+1) t := do goals ← get_goals, let earlier_goals := goals.take n, let later_goals := goals.drop (n+1), set_goals (goals.nth n).to_list, t, new_goals ← get_goals, set_goals (earlier_goals ++ new_goals ++ later_goals)
def
tactic.interactive.work_on_goal
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`work_on_goal n { tac }` creates a block scope for the `n`-goal, and does not require that the goal be solved at the end (any remaining subgoals are inserted back into the list of goals). Typically usage might look like: ```` intros, simp, apply lemma_1, work_on_goal 3 { dsimp, simp }, refl ```` See also `id { tac ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
swap (n := 2) : tactic unit
do gs ← get_goals, match gs.nth (n-1) with | (some g) := set_goals (g :: gs.remove_nth (n-1)) | _ := skip end
def
tactic.interactive.swap
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`swap n` will move the `n`th goal to the front. `swap` defaults to `swap 2`, and so interchanges the first and second goals. See also `tactic.interactive.rotate`, which moves the first `n` goals to the back.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rotate (n := 1) : tactic unit
tactic.rotate n
def
tactic.interactive.rotate
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`rotate` moves the first goal to the back. `rotate n` will do this `n` times. See also `tactic.interactive.swap`, which moves the `n`th goal to the front.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_ : tactic unit
tactic.repeat $ do l ← local_context, l.reverse.mfirst $ λ h, do name.mk_string s p ← return $ local_pp_name h, guard (s.front = '_'), cl ← infer_type h >>= is_class, guard (¬ cl), tactic.clear h
def
tactic.interactive.clear_
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Clear all hypotheses starting with `_`, like `_match` and `_let_match`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
replace (h : parse ident?) (q₁ : parse (tk ":" *> texpr)?) (q₂ : parse $ (tk ":=" *> texpr)?) : tactic unit
do let h := h.get_or_else `this, old ← try_core (get_local h), «have» h q₁ q₂, match old, q₂ with | none, _ := skip | some o, some _ := tactic.clear o | some o, none := swap >> tactic.clear o >> swap end
def
tactic.interactive.replace
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Acts like `have`, but removes a hypothesis with the same name as this one. For example if the state is `h : p ⊢ goal` and `f : p → q`, then after `replace h := f h` the goal will be `h : q ⊢ goal`, where `have h := f h` would result in the state `h : p, h : q ⊢ goal`. This can be used to simulate the `specialize` and `...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
classical (bang : parse $ (tk "!")?)
tactic.classical bang.is_some
def
tactic.interactive.classical
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.classical" ]
Make every proposition in the context decidable. `classical!` does this more aggressively, such that even if a decidable instance is already available for a specific proposition, the noncomputable one will be used instead.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalize_arg_p_aux : pexpr → parser (pexpr × name)
| (app (app (macro _ [const `eq _ ]) h) (local_const x _ _ _)) := pure (h, x) | _ := fail "parse error"
def
tactic.interactive.generalize_arg_p_aux
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalize_arg_p : parser (pexpr × name)
with_desc "expr = id" $ parser.pexpr 0 >>= generalize_arg_p_aux
def
tactic.interactive.generalize_arg_p
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
{u} generalize_a_aux {α : Sort u} (h : ∀ x : Sort u, (α → x) → x) : α
h α id
lemma
tactic.interactive.generalize_a_aux
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalize_hyp (h : parse ident?) (_ : parse $ tk ":") (p : parse generalize_arg_p) (l : parse location) : tactic unit
do h' ← get_unused_name `h, x' ← get_unused_name `x, g ← if ¬ l.include_goal then do refine ``(generalize_a_aux _), some <$> (prod.mk <$> tactic.intro x' <*> tactic.intro h') else pure none, n ← l.get_locals >>= tactic.revert_lst, generalize h () p, intron n, match g with | so...
def
tactic.interactive.generalize_hyp
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Like `generalize` but also considers assumptions specified by the user. The user can also specify to omit the goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
compact_decl_aux : list name → binder_info → expr → list expr → tactic (list (list name × binder_info × expr))
| ns bi t [] := pure [(ns.reverse, bi, t)] | ns bi t (v'@(local_const n pp bi' t') :: xs) := do t' ← infer_type v', if bi = bi' ∧ t = t' then compact_decl_aux (pp :: ns) bi t xs else do vs ← compact_decl_aux [pp] bi' t' xs, pure $ (ns.reverse, bi, t) :: vs | ns bi t (_ :: xs) := comp...
def
tactic.interactive.compact_decl_aux
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
compact_decl : list expr → tactic (list (list name × binder_info × expr))
| [] := pure [] | (v@(local_const n pp bi t) :: xs) := do t ← infer_type v, compact_decl_aux [pp] bi t xs | (_ :: xs) := compact_decl xs
def
tactic.interactive.compact_decl
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
go from (x₀ : t₀) (x₁ : t₀) (x₂ : t₀) to (x₀ x₁ x₂ : t₀)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clean (q : parse texpr) : tactic unit
do tgt : expr ← target, e ← i_to_expr_strict ``(%%q : %%tgt), tactic.exact $ e.clean
def
tactic.interactive.clean
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Remove identity functions from a term. These are normally automatically generated with terms like `show t, from p` or `(p : t)` which translate to some variant on `@id t p` in order to retain the type.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
source_fields (missing : list name) (e : pexpr) : tactic (list (name × pexpr))
do e ← to_expr e, t ← infer_type e, let struct_n : name := t.get_app_fn.const_name, fields ← expanded_field_list struct_n, let exp_fields := fields.filter (λ x, x.2 ∈ missing), exp_fields.mmap $ λ ⟨p,n⟩, (prod.mk n ∘ to_pexpr) <$> mk_mapp (n.update_prefix p) [none,some e]
def
tactic.interactive.source_fields
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
collect_struct' : pexpr → state_t (list $ expr×structure_instance_info) tactic pexpr | e
do some str ← pure (e.get_structure_instance_info) | e.traverse collect_struct', v ← monad_lift mk_mvar, modify (list.cons (v,str)), pure $ to_pexpr v
def
tactic.interactive.collect_struct'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
collect_struct (e : pexpr) : tactic $ pexpr × list (expr×structure_instance_info)
prod.map id list.reverse <$> (collect_struct' e).run []
def
tactic.interactive.collect_struct
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
refine_one (str : structure_instance_info) : tactic $ list (expr×structure_instance_info)
do tgt ← target >>= whnf, let struct_n : name := tgt.get_app_fn.const_name, exp_fields ← expanded_field_list struct_n, let missing_f := exp_fields.filter (λ f, (f.2 : name) ∉ str.field_names), (src_field_names,src_field_vals) ← (@list.unzip name _ ∘ list.join) <$> str.sources.mmap (so...
def
tactic.interactive.refine_one
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "mzip_with" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
refine_recursively : expr × structure_instance_info → tactic (list expr) | (e,str)
do set_goals [e], rs ← refine_one str, gs ← get_goals, gs' ← rs.mmap refine_recursively, return $ gs'.join ++ gs
def
tactic.interactive.refine_recursively
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
refine_struct : parse texpr → tactic unit | e
do (x,xs) ← collect_struct e, refine x, gs ← get_goals, xs' ← xs.mmap refine_recursively, set_goals (xs'.join ++ gs)
def
tactic.interactive.refine_struct
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`refine_struct { .. }` acts like `refine` but works only with structure instance literals. It creates a goal for each missing field and tags it with the name of the field so that `have_field` can be used to generically refer to the field currently being refined. As an example, we can use `refine_struct` to automate th...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_hyp' (n : parse ident) (p : parse $ tk ":" *> texpr) : tactic unit
do h ← get_local n >>= infer_type >>= instantiate_mvars, guard_expr_eq h p
def
tactic.interactive.guard_hyp'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`guard_hyp' h : t` fails if the hypothesis `h` does not have type `t`. We use this tactic for writing tests. Fixes `guard_hyp` by instantiating meta variables
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_hyp (n : parse ident) (p : parse $ tk ":" *> texpr) (m := reducible) : tactic (list expr)
do h ← get_local n >>= infer_type >>= instantiate_mvars, match_expr p h m
def
tactic.interactive.match_hyp
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`match_hyp h : t` fails if the hypothesis `h` does not match the type `t` (which may be a pattern). We use this tactic for writing tests.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_expr_strict (t : expr) (p : parse $ tk ":=" *> texpr) : tactic unit
do e ← to_expr p, guard (t = e)
def
tactic.interactive.guard_expr_strict
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`guard_expr_strict t := e` fails if the expr `t` is not equal to `e`. By contrast to `guard_expr`, this tests strict (syntactic) equality. We use this tactic for writing tests.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_target_strict (p : parse texpr) : tactic unit
do t ← target, guard_expr_strict t p
def
tactic.interactive.guard_target_strict
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`guard_target_strict t` fails if the target of the main goal is not syntactically `t`. We use this tactic for writing tests.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_hyp_strict (n : parse ident) (p : parse $ tk ":" *> texpr) : tactic unit
do h ← get_local n >>= infer_type >>= instantiate_mvars, guard_expr_strict h p
def
tactic.interactive.guard_hyp_strict
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`guard_hyp_strict h : t` fails if the hypothesis `h` does not have type syntactically equal to `t`. We use this tactic for writing tests.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_hyp_nums (n : ℕ) : tactic unit
do k ← local_context, guard (n = k.length) <|> fail format!"{k.length} hypotheses found"
def
tactic.interactive.guard_hyp_nums
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Tests that there are `n` hypotheses in the current context.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_hyp_mod_implicit (n : parse ident) (p : parse $ tk ":" *> texpr) : tactic unit
do h ← get_local n >>= infer_type >>= instantiate_mvars, e ← to_expr p, is_def_eq h e transparency.none
def
tactic.interactive.guard_hyp_mod_implicit
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`guard_hyp_mod_implicit h : t` fails if the type of the hypothesis `h` is not definitionally equal to `t` modulo none transparency (i.e., unifying the implicit arguments modulo semireducible transparency). We use this tactic for writing tests.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_target_mod_implicit (p : parse texpr) : tactic unit
do tgt ← target, e ← to_expr p, is_def_eq tgt e transparency.none
def
tactic.interactive.guard_target_mod_implicit
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`guard_target_mod_implicit t` fails if the target of the main goal is not definitionally equal to `t` modulo none transparency (i.e., unifying the implicit arguments modulo semireducible transparency). We use this tactic for writing tests.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_tags (tags : parse ident*) : tactic unit
do (t : list name) ← get_main_tag, guard (t = tags)
def
tactic.interactive.guard_tags
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Test that `t` is the tag of the main goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_proof_term (t : itactic) (p : parse texpr) : itactic
do g :: _ ← get_goals, e ← to_expr p, t, g ← instantiate_mvars g, unify e g
def
tactic.interactive.guard_proof_term
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`guard_proof_term { t } e` applies tactic `t` and tests whether the resulting proof term unifies with `p`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
success_if_fail_with_msg (tac : tactic.interactive.itactic)
tactic.success_if_fail_with_msg tac
def
tactic.interactive.success_if_fail_with_msg
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "success_if_fail_with_msg" ]
`success_if_fail_with_msg { tac } msg` succeeds if the interactive tactic `tac` fails with error message `msg` (for test writing purposes).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_current_field : tactic name
do [_,field,str] ← get_main_tag, expr.const_name <$> resolve_name (field.update_prefix str)
def
tactic.interactive.get_current_field
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "field" ]
Get the field of the current goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
field (n : parse ident) (tac : itactic) : tactic unit
do gs ← get_goals, ts ← gs.mmap get_tag, ([g],gs') ← pure $ (list.zip gs ts).partition (λ x, x.snd.nth 1 = some n), set_goals [g.1], tac, done, set_goals $ gs'.map prod.fst
def
tactic.interactive.field
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "field" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
have_field : tactic unit
propagate_tags $ get_current_field >>= mk_const >>= note `field none >> return ()
def
tactic.interactive.have_field
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "field" ]
`have_field`, used after `refine_struct _` poses `field` as a local constant with the type of the field of the current goal: ```lean refine_struct ({ .. } : semigroup α), { have_field, ... }, { have_field, ... }, ``` behaves like ```lean refine_struct ({ .. } : semigroup α), { have field := @semigroup.mul, ... }, { ha...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_field : tactic unit
propagate_tags $ get_current_field >>= applyc
def
tactic.interactive.apply_field
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`apply_field` functions as `have_field, apply field, clear field`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_rules (args : parse opt_pexpr_list) (attrs : parse with_ident_list) (n : nat := 50) (opt : apply_cfg := {}) : tactic unit
tactic.apply_rules args attrs n opt
def
tactic.interactive.apply_rules
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.apply_rules" ]
`apply_rules hs with attrs n` applies the list of lemmas `hs` and all lemmas tagged with an attribute from the list `attrs`, as well as the `assumption` tactic on the first goal and the resulting subgoals, iteratively, at most `n` times. `n` is optional, equal to 50 by default. You can pass an `apply_cfg` option argume...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
return_cast (f : option expr) (t : option (expr × expr)) (es : list (expr × expr × expr)) (e x x' eq_h : expr) : tactic (option (expr × expr) × list (expr × expr × expr))
(do guard (¬ e.has_var), unify x x', u ← mk_meta_univ, f ← f <|> mk_mapp ``_root_.id [(expr.sort u : expr)], t' ← infer_type e, some (f',t) ← pure t | return (some (f,t'), (e,x',eq_h) :: es), infer_type e >>= is_def_eq t, unify f f', return (some (f,t), (e,x',eq_h) :: es)) <|> return (t,...
def
tactic.interactive.return_cast
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list_cast_of_aux (x : expr) (t : option (expr × expr)) (es : list (expr × expr × expr)) : expr → tactic (option (expr × expr) × list (expr × expr × expr))
| e@`(cast %%eq_h %%x') := return_cast none t es e x x' eq_h | e@`(eq.mp %%eq_h %%x') := return_cast none t es e x x' eq_h | e@`(eq.mpr %%eq_h %%x') := mk_eq_symm eq_h >>= return_cast none t es e x x' | e@`(@eq.subst %%α %%p %%a %%b %%eq_h %%x') := return_cast p t es e x x' eq_h | e@`(@eq.substr %%α %%p %%a %%b %%eq_h...
def
tactic.interactive.list_cast_of_aux
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list_cast_of (x tgt : expr) : tactic (list (expr × expr × expr))
(list.reverse ∘ prod.snd) <$> tgt.mfold (none, []) (λ e i es, list_cast_of_aux x es.1 es.2 e)
def
tactic.interactive.list_cast_of
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
h_generalize_arg_p_aux : pexpr → parser (pexpr × name)
| (app (app (macro _ [const `heq _ ]) h) (local_const x _ _ _)) := pure (h, x) | _ := fail "parse error"
def
tactic.interactive.h_generalize_arg_p_aux
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
h_generalize_arg_p : parser (pexpr × name)
with_desc "expr == id" $ parser.pexpr 0 >>= h_generalize_arg_p_aux
def
tactic.interactive.h_generalize_arg_p
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
h_generalize (rev : parse (tk "!")?) (h : parse ident_?) (_ : parse (tk ":")) (arg : parse h_generalize_arg_p) (eqs_h : parse ( (tk "with" *> pure <$> ident_) <|> pure [])) : tactic unit
do let (e,n) := arg, let h' := if h = `_ then none else h, h' ← (h' : tactic name) <|> get_unused_name ("h" ++ n.to_string : string), e ← to_expr e, tgt ← target, ((e,x,eq_h)::es) ← list_cast_of e tgt | fail "no cast found", interactive.generalize h' () (to_pexpr e, n), asm ← get_local h', v ← g...
def
tactic.interactive.h_generalize
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`h_generalize Hx : e == x` matches on `cast _ e` in the goal and replaces it with `x`. It also adds `Hx : e == x` as an assumption. If `cast _ e` appears multiple times (not necessarily with the same proof), they are all replaced by `x`. `cast` `eq.mp`, `eq.mpr`, `eq.subst`, `eq.substr`, `eq.rec` and `eq.rec_on` are al...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_expr_eq' (t : expr) (p : parse $ tk ":=" *> texpr) : tactic unit
do e ← to_expr p, is_def_eq t e
def
tactic.interactive.guard_expr_eq'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Tests whether `t` is definitionally equal to `p`. The difference with `guard_expr_eq` is that this uses definitional equality instead of alpha-equivalence.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guard_target' (p : parse texpr) : tactic unit
do t ← target, guard_expr_eq' t p
def
tactic.interactive.guard_target'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`guard_target' t` fails if the target of the main goal is not definitionally equal to `t`. We use this tactic for writing tests. The difference with `guard_target` is that this uses definitional equality instead of alpha-equivalence.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
triv : tactic unit
tactic.triv <|> tactic.reflexivity <|> fail "triv tactic failed"
def
tactic.interactive.triv
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
Tries to solve the goal using a canonical proof of `true` or the `reflexivity` tactic. Unlike `trivial` or `trivial'`, does not the `contradiction` tactic.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
trivial' : tactic unit
tactic.triv' <|> tactic.reflexivity reducible <|> tactic.contradiction <|> fail "trivial' tactic failed"
def
tactic.interactive.trivial'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.triv'" ]
A weaker version of `trivial` that tries to solve the goal using a canonical proof of `true` or the `reflexivity` tactic (unfolding only `reducible` constants, so can fail faster than `trivial`), and otherwise tries the `contradiction` tactic.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
use (l : parse pexpr_list_or_texpr) : tactic unit
focus1 $ tactic.use l; try (trivial' <|> (do `(Exists %%p) ← target, to_expr ``(exists_prop.mpr) >>= tactic.apply >> skip))
def
tactic.interactive.use
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.use" ]
Similar to `existsi`. `use x` will instantiate the first term of an `∃` or `Σ` goal with `x`. It will then try to close the new goal using `trivial'`, or try to simplify it by applying `exists_prop`. Unlike `existsi`, `x` is elaborated with respect to the expected type. `use` will alternatively take a list of terms `[x...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_aux_decl : tactic unit
tactic.clear_aux_decl
def
tactic.interactive.clear_aux_decl
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.clear_aux_decl" ]
`clear_aux_decl` clears every `aux_decl` in the local context for the current goal. This includes the induction hypothesis when using the equation compiler and `_let_match` and `_fun_match`. It is useful when using a tactic such as `finish`, `simp *` or `subst` that may use these auxiliary declarations, and produce an...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
loc.get_local_pp_names : loc → tactic (list name)
| loc.wildcard := list.map expr.local_pp_name <$> local_context | (loc.ns l) := return l.reduce_option
def
tactic.interactive.loc.get_local_pp_names
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
loc.get_local_uniq_names (l : loc) : tactic (list name)
list.map expr.local_uniq_name <$> l.get_locals
def
tactic.interactive.loc.get_local_uniq_names
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
change' (q : parse texpr) : parse (tk "with" *> texpr)? → parse location → tactic unit
| none (loc.ns [none]) := do e ← i_to_expr q, change_core e none | none (loc.ns [some h]) := do eq ← i_to_expr q, eh ← get_local h, change_core eq (some eh) | none _ := fail "change-at does not support multiple locations" | (some w) l := do l' ← loc.get_local_pp_names l, l'.mmap' (λ e, try (change_with_at q w e)...
def
tactic.interactive.change'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
The logic of `change x with y at l` fails when there are dependencies. `change'` mimics the behavior of `change`, except in the case of `change x with y at l`. In this case, it will correctly replace occurences of `x` with `y` at all possible hypotheses in `l`. As long as `x` and `y` are defeq, it should never fail.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
opt_dir_with : parser (option (bool × name))
(tk "with" *> ((λ arrow h, (option.is_some arrow, h)) <$> (tk "<-")? <*> ident))?
def
tactic.interactive.opt_dir_with
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
set (h_simp : parse (tk "!")?) (a : parse ident) (tp : parse ((tk ":") *> texpr)?) (_ : parse (tk ":=")) (pv : parse texpr) (rev_name : parse opt_dir_with)
do tp ← i_to_expr $ let t := tp.get_or_else pexpr.mk_placeholder in ``(%%t : Sort*), pv ← to_expr ``(%%pv : %%tp), tp ← instantiate_mvars tp, definev a tp pv, when h_simp.is_none $ change' ``(%%pv) (some (expr.const a [])) $ interactive.loc.wildcard, match rev_name with | some (flip, id) := do nv...
def
tactic.interactive.set
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`set a := t with h` is a variant of `let a := t`. It adds the hypothesis `h : a = t` to the local context and replaces `t` with `a` everywhere it can. `set a := t with ←h` will add `h : t = a` instead. `set! a := t with h` does not do any replacing. ```lean example (x : ℕ) (h : x = 3) : x + x + x = 9 := begin set...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_except (xs : parse ident *) : tactic unit
do n ← xs.mmap (try_core ∘ get_local) >>= revert_lst ∘ list.filter_map id, ls ← local_context, ls.reverse.mmap' $ try ∘ tactic.clear, intron_no_renames n
def
tactic.interactive.clear_except
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`clear_except h₀ h₁` deletes all the assumptions it can except for `h₀` and `h₁`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
format_names (ns : list name) : format
format.join $ list.intersperse " " (ns.map to_fmt)
def
tactic.interactive.format_names
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
indent_bindents (l r : string) : option (list name) → expr → tactic format
| none e := do e ← pp e, pformat!"{l}{format.nest l.length e}{r}" | (some ns) e := do e ← pp e, let ns := format_names ns, let margin := l.length + ns.to_string.length + " : ".length, pformat!"{l}{ns} : {format.nest margin e}{r}"
def
tactic.interactive.indent_bindents
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
format_binders : list name × binder_info × expr → tactic format
| (ns, binder_info.default, t) := indent_bindents "(" ")" ns t | (ns, binder_info.implicit, t) := indent_bindents "{" "}" ns t | (ns, binder_info.strict_implicit, t) := indent_bindents "⦃" "⦄" ns t | ([n], binder_info.inst_implicit, t) := if "_".is_prefix_of n.to_string then indent_bindents "[" "]" none t els...
def
tactic.interactive.format_binders
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
partition_vars' (s : name_set) : list expr → list expr → list expr → tactic (list expr × list expr)
| [] as bs := pure (as.reverse, bs.reverse) | (x :: xs) as bs := do t ← infer_type x, if t.has_local_in s then partition_vars' xs as (x :: bs) else partition_vars' xs (x :: as) bs
def
tactic.interactive.partition_vars'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
partition_vars : tactic (list expr × list expr)
do ls ← local_context, partition_vars' (name_set.of_list $ ls.map expr.local_uniq_name) ls [] []
def
tactic.interactive.partition_vars
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
extract_goal (print_use : parse $ (tk "!" *> pure tt) <|> pure ff) (n : parse ident?) (vs : parse (tk "with" *> ident*)?) : tactic unit
do tgt ← target, solve_aux tgt $ do { ((cxt₀,cxt₁,ls,tgt),_) ← solve_aux tgt $ do { vs.mmap clear_except, ls ← local_context, ls ← ls.mfilter $ succeeds ∘ is_local_def, n ← revert_lst ls, (c₀,c₁) ← partition_vars, tgt ← target, ls ← intron' n, ...
def
tactic.interactive.extract_goal
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "format.intercalate", "succeeds" ]
Format the current goal as a stand-alone example. Useful for testing tactics or creating [minimal working examples](https://leanprover-community.github.io/mwe.html). * `extract_goal`: formats the statement as an `example` declaration * `extract_goal my_decl`: formats the statement as a `lemma` or `def` declaration c...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
inhabit (t : parse parser.pexpr) (inst_name : parse ident?) : tactic unit
do ty ← i_to_expr t, nm ← returnopt inst_name <|> get_unused_name `inst, tgt ← target, tgt_is_prop ← is_prop tgt, if tgt_is_prop then do decorate_error "could not infer nonempty instance:" $ mk_mapp ``nonempty.elim_to_inhabited [ty, none, tgt] >>= tactic.apply, introI nm else do dec...
def
tactic.interactive.inhabit
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "classical.inhabited_of_nonempty'", "nonempty.elim_to_inhabited" ]
`inhabit α` tries to derive a `nonempty α` instance and then upgrades this to an `inhabited α` instance. If the target is a `Prop`, this is done constructively; otherwise, it uses `classical.choice`. ```lean example (α) [nonempty α] : ∃ a : α, true := begin inhabit α, existsi default, trivial end ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
revert_deps (ns : parse ident*) : tactic unit
propagate_tags $ ns.mmap get_local >>= revert_reverse_dependencies_of_hyps >> skip
def
tactic.interactive.revert_deps
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[]
`revert_deps n₁ n₂ ...` reverts all the hypotheses that depend on one of `n₁, n₂, ...` It does not revert `n₁, n₂, ...` themselves (unless they depend on another `nᵢ`).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
revert_after (n : parse ident) : tactic unit
propagate_tags $ get_local n >>= tactic.revert_after >> skip
def
tactic.interactive.revert_after
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.revert_after" ]
`revert_after n` reverts all the hypotheses after `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
revert_target_deps : tactic unit
propagate_tags $ tactic.revert_target_deps >> skip
def
tactic.interactive.revert_target_deps
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.revert_target_deps" ]
Reverts all local constants on which the target depends (recursively).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_value (ns : parse ident*) : tactic unit
propagate_tags $ ns.reverse.mmap get_local >>= tactic.clear_value
def
tactic.interactive.clear_value
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.clear_value" ]
`clear_value n₁ n₂ ...` clears the bodies of the local definitions `n₁, n₂ ...`, changing them into regular hypotheses. A hypothesis `n : α := t` is changed to `n : α`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
generalize' (h : parse ident?) (_ : parse $ tk ":") (p : parse generalize_arg_p) : tactic unit
propagate_tags $ do let (p, x) := p, e ← i_to_expr p, some h ← pure h | tactic.generalize' e x >> skip, -- `h` is given, the regular implementation of `generalize` works. tgt ← target, tgt' ← do { ⟨tgt', _⟩ ← solve_aux tgt (tactic.generalize e x >> target), to_expr ``(Π x, %%e = x → %%(tgt'.bindi...
def
tactic.interactive.generalize'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.generalize'" ]
`generalize' : e = x` replaces all occurrences of `e` in the target with a new hypothesis `x` of the same type. `generalize' h : e = x` in addition registers the hypothesis `h : e = x`. `generalize'` is similar to `generalize`. The difference is that `generalize' : e = x` also succeeds when `e` does not occur in the ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
subst' (q : parse texpr) : tactic unit
do i_to_expr q >>= tactic.subst' >> try (tactic.reflexivity reducible)
def
tactic.interactive.subst'
tactic
src/tactic/interactive.lean
[ "logic.nonempty", "tactic.lint", "tactic.dependencies" ]
[ "tactic.subst'" ]
If the expression `q` is a local variable with type `x = t` or `t = x`, where `x` is a local constant, `tactic.interactive.subst' q` substitutes `x` by `t` everywhere in the main goal and then clears `q`. If `q` is another local variable, then we find a local constant with type `q = t` or `t = q` and substitute `t` for...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sf : Type | tag_expr : expr.address → expr → sf → sf | compose : sf → sf → sf | of_string : string → sf | highlight : format.color → sf → sf | block : ℕ → sf → sf
inductive
widget_override.interactive_expression.sf
tactic
src/tactic/interactive_expr.lean
[]
[]
eformat but without any of the formatting stuff like highlighting, groups etc.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sf.repr : sf → format
| (sf.tag_expr addr e a) := format.group $ format.nest 2 $ "(tag_expr " ++ to_fmt addr ++ format.line ++ "`(" ++ to_fmt e ++ ")" ++ format.line ++ a.repr ++ ")" | (sf.compose a b) := a.repr ++ format.line ++ b.repr | (sf.of_string s) := repr s | (sf.block i a) := "(block " ++ to_fmt i ++ format.line ++ a.repr ++ ...
def
widget_override.interactive_expression.sf.repr
tactic
src/tactic/interactive_expr.lean
[]
[]
Prints a debugging representation of an `sf` object.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83