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 |
|---|---|---|---|---|---|---|---|---|---|---|
classical.implies_iff_not_or : (p → q) ↔ (¬ p ∨ q) | imp_iff_not_or | theorem | auto.classical.implies_iff_not_or | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"imp_iff_not_or"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
common_normalize_lemma_names : list name | [``bex_def, ``forall_and_distrib, ``exists_imp_distrib, ``or.assoc, ``or.comm, ``or.left_comm,
``and.assoc, ``and.comm, ``and.left_comm] | def | auto.common_normalize_lemma_names | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"bex_def",
"exists_imp_distrib",
"forall_and_distrib"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
classical_normalize_lemma_names : list name | common_normalize_lemma_names ++ [``classical.implies_iff_not_or] | def | auto.classical_normalize_lemma_names | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
transform_negation_step (cfg : auto_config) (e : expr) :
tactic (option (expr × expr)) | do e ← whnf_reducible e,
match e with
| `(¬ %%ne) :=
(do ne ← whnf_reducible ne,
match ne with
| `(¬ %%a) := do pr ← mk_app ``not_not_eq [a],
return (some (a, pr))
| `(%%a ∧ %%b) := do pr ← mk_app ``not_and_eq [a, b],
return (so... | def | auto.transform_negation_step | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | optionally returns an equivalent expression and proof of equivalence | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
transform_negation (cfg : auto_config) : expr → tactic (option (expr × expr)) | λ e, do
opr ← transform_negation_step cfg e,
match opr with
| (some (e', pr)) := do
opr' ← transform_negation e',
match opr' with
| none := return (some (e', pr))
| (some (e'', pr')) := do pr'' ← mk_eq_trans pr pr',
return (some (e'', pr''))
end
| n... | def | auto.transform_negation | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | given an expr `e`, returns a new expression and a proof of equality | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
normalize_negations (cfg : auto_config) (h : expr) : tactic unit | do t ← infer_type h,
(_, e, pr) ← simplify_top_down ()
(λ _, λ e, do
oepr ← transform_negation cfg e,
match oepr with
| (some (e', pr)) := return ((), e', pr)
| none := do pr ← mk_eq_refl e, retu... | def | auto.normalize_negations | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_hyp (cfg : auto_config) (simps : simp_lemmas) (h : expr) : tactic unit | (do (h, _) ← simp_hyp simps [] h, try (normalize_negations cfg h)) <|>
try (normalize_negations cfg h) | def | auto.normalize_hyp | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_hyps (cfg : auto_config) : tactic unit | do simps ← add_simps simp_lemmas.mk classical_normalize_lemma_names,
local_context >>= monad.mapm' (normalize_hyp cfg simps) | def | auto.normalize_hyps | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
eelim : tactic unit | do ctx ← local_context,
first $ ctx.map $ λ h,
do t ← infer_type h >>= whnf_reducible,
guard (is_app_of t ``Exists),
tgt ← target,
to_expr ``(@exists.elim _ _ %%tgt %%h) >>= apply,
intros,
clear h | def | auto.eelim | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | eliminate an existential quantifier if there is one | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eelims : tactic unit | eelim >> repeat eelim | def | auto.eelims | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | eliminate all existential quantifiers, fails if there aren't any | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
do_subst : tactic unit | do ctx ← local_context,
first $ ctx.map $ λ h,
do t ← infer_type h >>= whnf_reducible,
match t with
| `(%%a = %%b) := subst h
| _ := failed
end | def | auto.do_subst | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | carries out a subst if there is one, fails otherwise | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
do_substs : tactic unit | do_subst >> repeat do_subst | def | auto.do_substs | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_conjuncts : expr → expr → tactic bool | λ pr t,
let assert_consequences := λ e t, mcond (add_conjuncts e t) skip (note_anon t e >> skip) in
do t' ← whnf_reducible t,
match t' with
| `(%%a ∧ %%b) :=
do e₁ ← mk_app ``and.left [pr],
assert_consequences e₁ a,
e₂ ← mk_app ``and.right [pr],
assert_consequences e₂ b,
retur... | def | auto.add_conjuncts | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | Assumes `pr` is a proof of `t`. Adds the consequences of `t` to the context
and returns `tt` if anything nontrivial has been added. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
split_hyp (h : expr) : tactic bool | do t ← infer_type h,
mcond (add_conjuncts h t) (clear h >> return tt) (return ff) | def | auto.split_hyp | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | return `tt` if any progress is made | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
split_hyps_aux : list expr → tactic bool | | [] := return ff
| (h :: hs) := do b₁ ← split_hyp h,
b₂ ← split_hyps_aux hs,
return (b₁ || b₂) | def | auto.split_hyps_aux | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | return `tt` if any progress is made | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
split_hyps : tactic unit | local_context >>= split_hyps_aux >>= guardb | def | auto.split_hyps | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | fail if no progress is made | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
preprocess_hyps (cfg : auto_config) : tactic unit | do repeat (intro1 >> skip),
preprocess_goal,
normalize_hyps cfg,
repeat (do_substs <|> split_hyps <|> eelim /-<|> self_simplify_hyps-/) | def | auto.preprocess_hyps | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | Eagerly apply all the preprocessing rules | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_hinst_lemmas : list expr → smt_tactic hinst_lemmas | | [] := -- return hinst_lemmas.mk
do get_hinst_lemmas_for_attr `ematch
| (h :: hs) := do his ← mk_hinst_lemmas hs,
t ← infer_type h,
match t with
| (pi _ _ _ _) :=
do t' ← infer_type t,
if t' = `(Prop)... | def | auto.mk_hinst_lemmas | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | The terminal tactic, used to try to finish off goals:
- Call the contradiction tactic.
- Open an SMT state, and use ematching and congruence closure, with all the universal
statements in the context.
TODO(Jeremy): allow users to specify attribute for ematching lemmas? | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
report_invalid_em_lemma {α : Type} (n : name) : smt_tactic α | fail format!"invalid ematch lemma '{n}'" | def | auto.report_invalid_em_lemma | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_hinst_lemma_from_name (md : transparency) (lhs_lemma : bool) (n : name)
(hs : hinst_lemmas) (ref : pexpr) : smt_tactic hinst_lemmas | do p ← resolve_name n,
match p with
| expr.const n _ := (do h ← hinst_lemma.mk_from_decl_core md n lhs_lemma,
tactic.save_const_type_info n ref, return $ hs.add h) <|>
(do hs₁ ← smt_tactic.mk_ematch_eqn_lemmas_for_core md n,
tactic.save_... | def | auto.add_hinst_lemma_from_name | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_hinst_lemma_from_pexpr (md : transparency) (lhs_lemma : bool)
(hs : hinst_lemmas) : pexpr → smt_tactic hinst_lemmas | | p@(expr.const c []) := add_hinst_lemma_from_name md lhs_lemma c hs p
| p@(expr.local_const c _ _ _) := add_hinst_lemma_from_name md lhs_lemma c hs p
| p := do new_e ← to_expr p, h ← hinst_lemma.mk_core md new_e lhs_lemma,
return $ hs.add h | def | auto.add_hinst_lemma_from_pexpr | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_hinst_lemmas_from_pexprs (md : transparency) (lhs_lemma : bool)
(ps : list pexpr) (hs : hinst_lemmas) : smt_tactic hinst_lemmas | list.mfoldl (add_hinst_lemma_from_pexpr md lhs_lemma) hs ps | def | auto.add_hinst_lemmas_from_pexprs | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
done (ps : list pexpr) (cfg : auto_config := {}) : tactic unit | do trace_state_if_enabled `auto.done "entering done",
contradiction <|>
(solve1 $
(do revert_all,
using_smt
(do smt_tactic.intros,
ctx ← local_context,
hs ← mk_hinst_lemmas ctx,
hs' ← add_hinst_lemmas_from_pexprs reducible ff ps hs,
smt_ta... | def | auto.done | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"trace_state_if_enabled"
] | `done` first attempts to close the goal using `contradiction`. If this fails, it creates an
SMT state and will repeatedly use `ematch` (using `ematch` lemmas in the environment,
universally quantified assumptions, and the supplied lemmas `ps`) and congruence closure. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
case_option
| force -- fail unless all goals are solved
| at_most_one -- leave at most one goal
| accept | inductive | auto.case_option | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | ||
case_cont (s : case_option) (cont : case_option → tactic unit) : tactic unit | do match s with
| case_option.force := cont case_option.force >> cont case_option.force
| case_option.at_most_one :=
-- if the first one succeeds, commit to it, and try the second
(mcond (cont case_option.force >> return tt) (cont case_option.at_most_one) skip) <|>
-- otherwise, try the secon... | def | auto.case_cont | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"cont"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
case_hyp (h : expr) (s : case_option) (cont : case_option → tactic unit) : tactic bool | do t ← infer_type h,
match t with
| `(%%a ∨ %%b) := cases h >> case_cont s cont >> return tt
| _ := return ff
end | def | auto.case_hyp | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"cont"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
case_some_hyp_aux (s : case_option) (cont : case_option → tactic unit) :
list expr → tactic bool | | [] := return ff
| (h::hs) := mcond (case_hyp h s cont) (return tt) (case_some_hyp_aux hs) | def | auto.case_some_hyp_aux | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"cont"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
case_some_hyp (s : case_option) (cont : case_option → tactic unit) : tactic bool | local_context >>= case_some_hyp_aux s cont | def | auto.case_some_hyp | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"cont"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
safe_core (s : simp_lemmas × list name) (ps : list pexpr) (cfg : auto_config) :
case_option → tactic unit | λ co, focus1 $
do trace_state_if_enabled `auto.finish "entering safe_core",
if cfg.use_simp then do
trace_if_enabled `auto.finish "simplifying hypotheses",
simp_all s.1 s.2 { fail_if_unchanged := ff },
trace_state_if_enabled `auto.finish "result:"
else skip,
tactic.done <|>
do trace_if_enable... | def | auto.safe_core | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"auto.finish",
"trace_if_enabled",
"trace_state_if_enabled"
] | `safe_core s ps cfg opt` negates the goal, normalizes hypotheses
(by splitting conjunctions, eliminating existentials, pushing negations inwards,
and calling `simp` with the supplied lemmas `s`), and then tries `contradiction`.
If this fails, it will create an SMT state and repeatedly use `ematch`
(using `ematch` lemm... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
clarify (s : simp_lemmas × list name) (ps : list pexpr)
(cfg : auto_config := {}) : tactic unit | safe_core s ps cfg case_option.at_most_one | def | auto.clarify | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | `clarify` is `safe_core`, but with the `(opt : case_option)`
parameter fixed at `case_option.at_most_one`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
safe (s : simp_lemmas × list name) (ps : list pexpr)
(cfg : auto_config := {}) : tactic unit | safe_core s ps cfg case_option.accept | def | auto.safe | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | `safe` is `safe_core`, but with the `(opt : case_option)`
parameter fixed at `case_option.accept`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
finish (s : simp_lemmas × list name) (ps : list pexpr)
(cfg : auto_config := {}) : tactic unit | safe_core s ps cfg case_option.force | def | auto.finish | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [] | `finish` is `safe_core`, but with the `(opt : case_option)`
parameter fixed at `case_option.force`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
clarify (hs : parse simp_arg_list) (ps : parse (tk "using" *> pexpr_list_or_texpr)?)
(cfg : auto_config := {}) : tactic unit | do s ← mk_simp_set ff [] hs,
auto.clarify s (ps.get_or_else []) cfg | def | tactic.interactive.clarify | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"auto.clarify"
] | `clarify [h1,...,hn] using [e1,...,en]` negates the goal, normalizes hypotheses
(by splitting conjunctions, eliminating existentials, pushing negations inwards,
and calling `simp` with the supplied lemmas `h1,...,hn`), and then tries `contradiction`.
If this fails, it will create an SMT state and repeatedly use `ematc... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
safe (hs : parse simp_arg_list) (ps : parse (tk "using" *> pexpr_list_or_texpr)?)
(cfg : auto_config := {}) : tactic unit | do s ← mk_simp_set ff [] hs,
auto.safe s (ps.get_or_else []) cfg | def | tactic.interactive.safe | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"auto.safe"
] | `safe [h1,...,hn] using [e1,...,en]` negates the goal, normalizes hypotheses
(by splitting conjunctions, eliminating existentials, pushing negations inwards,
and calling `simp` with the supplied lemmas `h1,...,hn`), and then tries `contradiction`.
If this fails, it will create an SMT state and repeatedly use `ematch`
... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
finish (hs : parse simp_arg_list) (ps : parse (tk "using" *> pexpr_list_or_texpr)?)
(cfg : auto_config := {}) : tactic unit | do s ← mk_simp_set ff [] hs,
auto.finish s (ps.get_or_else []) cfg | def | tactic.interactive.finish | tactic | src/tactic/finish.lean | [
"tactic.hint"
] | [
"auto.finish"
] | `finish [h1,...,hn] using [e1,...,en]` negates the goal, normalizes hypotheses
(by splitting conjunctions, eliminating existentials, pushing negations inwards,
and calling `simp` with the supplied lemmas `h1,...,hn`), and then tries `contradiction`.
If this fails, it will create an SMT state and repeatedly use `ematch... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
guard_mem_fin (e : expr) : tactic expr | do t ← infer_type e,
α ← mk_mvar,
to_expr ``(_ ∈ (_ : finset %%α)) tt ff >>= unify t <|>
to_expr ``(_ ∈ (_ : multiset %%α)) tt ff >>= unify t <|>
to_expr ``(_ ∈ (_ : list %%α)) tt ff >>= unify t,
instantiate_mvars α | def | tactic.guard_mem_fin | tactic | src/tactic/fin_cases.lean | [
"data.fintype.basic",
"tactic.norm_num"
] | [] | Checks that the expression looks like `x ∈ A` for `A : finset α`, `multiset α` or `A : list α`,
and returns the type α. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
expr_list_to_list_expr : Π (e : expr), tactic (list expr) | | `(list.cons %%h %%t) := list.cons h <$> expr_list_to_list_expr t
| `([]) := return []
| _ := failed | def | tactic.expr_list_to_list_expr | tactic | src/tactic/fin_cases.lean | [
"data.fintype.basic",
"tactic.norm_num"
] | [] | `expr_list_to_list_expr` converts an `expr` of type `list α`
to a list of `expr`s each with type `α`.
TODO: this should be moved, and possibly duplicates an existing definition. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
fin_cases_at_aux : Π (with_list : list expr) (e : expr), tactic unit | | with_list e :=
(do
result ← cases_core e,
match result with
-- We have a goal with an equation `s`, and a second goal with a smaller `e : x ∈ _`.
| [(_, [s], _), (_, [e], _)] :=
do let sn := local_pp_name s,
ng ← num_goals,
-- tidy up the new value
match with_list.nth 0 with
... | def | tactic.fin_cases_at_aux | tactic | src/tactic/fin_cases.lean | [
"data.fintype.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
fin_cases_at (nm : option name) : Π (with_list : option pexpr) (e : expr), tactic unit | | with_list e := focus1 $
do ty ← try_core $ guard_mem_fin e,
match ty with
| none := -- Deal with `x : A`, where `[fintype A]` is available:
(do
ty ← infer_type e,
i ← to_expr ``(fintype %%ty) >>= mk_instance <|> fail "Failed to find `fintype` instance.",
t ← to_expr ``(%%e ∈ @f... | def | tactic.fin_cases_at | tactic | src/tactic/fin_cases.lean | [
"data.fintype.basic",
"tactic.norm_num"
] | [] | `fin_cases_at with_list e` performs case analysis on `e : α`, where `α` is a fintype.
The optional list of expressions `with_list` provides descriptions for the cases of `e`,
for example, to display nats as `n.succ` instead of `n+1`.
These should be defeq to and in the same order as the terms in the enumeration of `α`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
hyp | tk "*" *> return none <|> some <$> ident | def | tactic.interactive.hyp | tactic | src/tactic/fin_cases.lean | [
"data.fintype.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
fin_cases :
parse hyp → parse (tk "with" *> texpr)? → parse (tk "using" *> ident)? → tactic unit | | none none nm := do
ctx ← local_context,
ctx.mfirst (fin_cases_at nm none) <|>
fail ("No hypothesis of the forms `x ∈ A`, where " ++
"`A : finset X`, `A : list X`, or `A : multiset X`, or `x : A`, with `[fintype A]`.")
| none (some _) _ := fail "Specify a single hypothesis when using a `with` arg... | def | tactic.interactive.fin_cases | tactic | src/tactic/fin_cases.lean | [
"data.fintype.basic",
"tactic.norm_num"
] | [] | `fin_cases h` performs case analysis on a hypothesis of the form
`h : A`, where `[fintype A]` is available, or
`h : a ∈ A`, where `A : finset X`, `A : multiset X` or `A : list X`.
`fin_cases *` performs case analysis on all suitable hypotheses.
As an example, in
```
example (f : ℕ → Prop) (p : fin 3) (h0 : f 0) (h1 :... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_unused_name_reserved_aux (n : name) (reserved : name_set) :
option nat → tactic name | λ suffix, do
n ← get_unused_name n suffix,
if ¬ reserved.contains n
then pure n
else do
let new_suffix :=
match suffix with
| none := some 1
| some n := some (n + 1)
end,
get_unused_name_reserved_aux new_suffix | def | tactic.get_unused_name_reserved_aux | tactic | src/tactic/fresh_names.lean | [
"data.sum.basic",
"tactic.dependencies"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
get_unused_name_reserved (ns : list name) (reserved : name_set) :
tactic name | (first $ ns.map $ λ n, do
{ guard (¬ reserved.contains n),
fail_if_success (resolve_name n),
pure n })
<|>
(do let fallback := match ns with | [] := `x | x :: _ := x end,
get_unused_name_reserved_aux fallback reserved none) | def | tactic.get_unused_name_reserved | tactic | src/tactic/fresh_names.lean | [
"data.sum.basic",
"tactic.dependencies"
] | [] | `get_unused_name_reserved ns reserved` returns the first name from `ns` that
occurs neither in `reserved` nor in the environment. If there is no such name in
`ns`, it returns a name of the form `n_i`, where `n` is the first name from `ns`
and `i` is a natural number (like `tactic.get_unused_name`). If `ns` is empty,
it... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
intro_fresh_reserved (ns : list name) (reserved : name_set) :
tactic expr | get_unused_name_reserved ns reserved >>= intro | def | tactic.intro_fresh_reserved | tactic | src/tactic/fresh_names.lean | [
"data.sum.basic",
"tactic.dependencies"
] | [] | `intro_fresh_reserved ns reserved` introduces a hypothesis. The hypothesis
receives a fresh name from `ns`, excluding the names in `reserved`. `ns` must be
nonempty. See `tactic.get_unused_name_reserved` for the full algorithm. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
intro_lst_fresh_reserved (ns : list (name ⊕ list name))
(reserved : name_set) :
tactic (list expr) | ns.mmap $ λ spec,
match spec with
| sum.inl n := intro n
| sum.inr ns := intro_fresh_reserved ns reserved
end | def | tactic.intro_lst_fresh_reserved | tactic | src/tactic/fresh_names.lean | [
"data.sum.basic",
"tactic.dependencies"
] | [] | `intro_lst_fresh_reserved ns reserved` introduces one hypothesis for every
element of `ns`. If the element is `sum.inl n`, the hypothesis receives the name
`n` (which may or may not be fresh). If the element is `sum.inr ns'`, the
hypothesis receives a fresh name from `ns`, excluding the names in `reserved`.
`ns` must b... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
rename_fresh (renames : name_map (name ⊕ list name))
(reserved : name_set) : tactic (list (expr × expr)) | do
(_, reverted) ← revert_name_set $ name_set.of_list $ renames.keys,
let renames := reverted.map $ λ h,
match renames.find h.local_uniq_name with
| none := sum.inl h.local_pp_name
| some new_names := new_names
end,
let reserved := reserved.insert_list $ renames.filter_map sum.get_left,
new_hyps... | def | tactic.rename_fresh | tactic | src/tactic/fresh_names.lean | [
"data.sum.basic",
"tactic.dependencies"
] | [
"sum.get_left"
] | `rename_fresh renames reserved`, given a map `renames` which associates the
unique names of some hypotheses `hᵢ` with either a name `nᵢ` or a nonempty (!)
name list `nsᵢ`, renames each `hᵢ` as follows:
- If `hᵢ` is associated with a name `nᵢ`, it is renamed to `nᵢ`. This may
introduce shadowing if there is another h... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
step1 (md : transparency) (unify : bool)
(e : expr) (to_generalize : list (name × expr)) : tactic (expr × list expr) | do
let go : name × expr → expr × list expr → tactic (expr × list expr) :=
λ ⟨n, j⟩ ⟨e, ks⟩, do
{ J ← infer_type j,
k ← mk_local' n binder_info.default J,
e ← kreplace e j k md unify,
ks ← ks.mmap $ λ k', kreplace k' j k md unify,
pure (e, k :: ks) },
to_genera... | def | tactic.generalizes.step1 | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [] | Input:
- Target expression `e`.
- List of expressions `jᵢ` to be generalised, along with a name for the local
const that will replace them. The `jᵢ` must be in dependency order:
`[n, fin n]` is okay but `[fin n, n]` is not.
Output:
- List of new local constants `kᵢ`, one for each `jᵢ`.
- `e` with the `jᵢ` replac... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
step2 (md : transparency)
(to_generalize : list (name × expr × expr))
: tactic (list (expr × expr)) | to_generalize.mmap $ λ ⟨n, j, k⟩, do
J ← infer_type j,
K ← infer_type k,
sort u ← infer_type K |
fail! "generalizes'/step2: expected the type of {K} to be a sort",
homogeneous ← succeeds $ is_def_eq J K md,
let ⟨eq_type, eq_proof⟩ :=
if homogeneous
then ((const `eq [u]) K k j , (const `eq.refl... | def | tactic.generalizes.step2 | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [
"succeeds"
] | Input: for each equation that should be generated: the equation name, the
argument `jᵢ` and the corresponding local constant `kᵢ` from step 1.
Output: for each element of the input list a new local constant of type
`jᵢ = kᵢ` or `jᵢ == kᵢ` and a proof of `jᵢ = jᵢ` or `jᵢ == jᵢ`.
The transparency `md` is used when dete... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
step3 (e : expr) (js ks eqs eq_proofs : list expr)
: tactic unit | focus1 $ do
let new_target_type := (e.pis eqs).pis ks,
type_check new_target_type <|> fail!
("generalizes': unable to generalize the target because the generalized target type does not" ++
" type check:\n{new_target_type}"),
n ← mk_fresh_name,
new_target ← assert n new_target_type,
swap,
let target_... | def | tactic.generalizes.step3 | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [] | Input: The `jᵢ`; the local constants `kᵢ` from step 1; the equations and their
proofs from step 2.
This step is the first one that changes the goal (and also the last one
overall). It asserts the generalized goal, then derives the current goal from
it. This leaves us with the generalized goal. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
generalizes' (args : list (name × option name × expr))
(md := semireducible) (unify := tt) : tactic unit | do
tgt ← target,
let stage1_args := args.map $ λ ⟨n, _, j⟩, (n, j),
⟨e, ks⟩ ← step1 md unify tgt stage1_args,
let stage2_args : list (option (name × expr × expr)) :=
args.map₂ (λ ⟨_, eq_name, j⟩ k, eq_name.map $ λ eq_name, (eq_name, j, k)) ks,
let stage2_args := stage2_args.reduce_option,
eqs_and_proofs... | def | tactic.generalizes' | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [] | Generalizes the target over each of the expressions in `args`. Given
`args = [(a₁, h₁, arg₁), ...]`, this changes the target to
∀ (a₁ : T₁) ... (h₁ : a₁ = arg₁) ..., U
where `U` is the current target with every occurrence of `argᵢ` replaced by
`aᵢ`. A similar effect can be achieved by using `generalize` once for ... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
generalizes_intro (args : list (name × option name × expr))
(md := semireducible) (unify := tt) : tactic (list expr × list expr) | do
generalizes' args md unify,
ks ← intron' args.length,
eqs ← intron' $ args.countp $ λ x, x.snd.fst.is_some,
pure (ks, eqs) | def | tactic.generalizes_intro | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [] | Like `generalizes'`, but also introduces the generalized constants and their
associated equations into the context. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
generalizes_arg_parser_eq : pexpr → lean.parser (pexpr × name) | | (app (app (macro _ [const `eq _ ]) e) (local_const x _ _ _)) := pure (e, x)
| (app (app (macro _ [const `heq _ ]) e) (local_const x _ _ _)) := pure (e, x)
| _ := failure | def | tactic.interactive.generalizes_arg_parser_eq | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
generalizes_arg_parser : lean.parser (name × option name × pexpr) | with_desc "(id :)? expr = id" $ do
lhs ← lean.parser.pexpr 0,
(tk ":" >> match lhs with
| local_const hyp_name _ _ _ := do
(arg, arg_name) ← lean.parser.pexpr 0 >>= generalizes_arg_parser_eq,
pure (arg_name, some hyp_name, arg)
| _ := failure
end) <|>
(do
(arg, arg_name) ← generalizes_... | def | tactic.interactive.generalizes_arg_parser | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
generalizes_args_parser
: lean.parser (list (name × option name × pexpr)) | with_desc "[(id :)? expr = id, ...]" $
tk "[" *> sep_by (tk ",") generalizes_arg_parser <* tk "]" | def | tactic.interactive.generalizes_args_parser | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
generalizes (args : parse generalizes_args_parser) : tactic unit | propagate_tags $ do
args ← args.mmap $ λ ⟨arg_name, hyp_name, arg⟩, do
{ arg ← to_expr arg,
pure (arg_name, hyp_name, arg) },
generalizes_intro args,
pure () | def | tactic.interactive.generalizes | tactic | src/tactic/generalizes.lean | [
"tactic.core"
] | [] | Generalizes the target over multiple expressions. For example, given the goal
P : ∀ n, fin n → Prop
n : ℕ
f : fin n
⊢ P (nat.succ n) (fin.succ f)
you can use `generalizes [n'_eq : nat.succ n = n', f'_eq : fin.succ f == f']` to
get
P : ∀ n, fin n → Prop
n : ℕ
f : fin n
n' : ℕ
n'_eq... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
collect_proofs_in :
expr → list expr → list name × list expr → tactic (list name × list expr) | | e ctx (ns, hs) :=
let go (tac : list name × list expr → tactic (list name × list expr)) :
tactic (list name × list expr) :=
do t ← infer_type e,
mcond (is_prop t) (do
first (hs.map $ λ h, do
t' ← infer_type h,
is_def_eq t t',
g ← target,
change $ g.replace (λ a n, if a = e then s... | def | tactic.collect_proofs_in | tactic | src/tactic/generalize_proofs.lean | [
"tactic.doc_commands"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
generalize_proofs (ns : list name) (loc : interactive.loc) : tactic unit | do intros_dep,
hs ← local_context >>= mfilter is_proof,
n ← loc.get_locals >>= revert_lst,
t ← target,
collect_proofs_in t [] (ns, hs),
intron n <|> (intros $> ()) | def | tactic.generalize_proofs | tactic | src/tactic/generalize_proofs.lean | [
"tactic.doc_commands"
] | [] | Generalize proofs in the goal, naming them with the provided list. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
generalize_proofs : parse ident_* → parse location → tactic unit | tactic.generalize_proofs | def | tactic.interactive.generalize_proofs | tactic | src/tactic/generalize_proofs.lean | [
"tactic.doc_commands"
] | [
"tactic.generalize_proofs"
] | Generalize proofs in the goal, naming them with the provided list.
For example:
```lean
example : list.nth_le [1, 2] 1 dec_trivial = 2 :=
begin
-- ⊢ [1, 2].nth_le 1 _ = 2
generalize_proofs h,
-- h : 1 < [1, 2].length
-- ⊢ [1, 2].nth_le 1 h = 2
end
``` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
tactic.group.zpow_trick {G : Type*} [group G] (a b : G) (n m : ℤ) : a*b^n*b^m = a*b^(n+m) | by rw [mul_assoc, ← zpow_add] | lemma | tactic.group.zpow_trick | tactic | src/tactic/group.lean | [
"tactic.ring",
"tactic.doc_commands",
"algebra.group.commutator"
] | [
"group",
"mul_assoc",
"zpow_add"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
tactic.group.zpow_trick_one {G : Type*} [group G] (a b : G) (m : ℤ) : a*b*b^m = a*b^(m+1) | by rw [mul_assoc, mul_self_zpow] | lemma | tactic.group.zpow_trick_one | tactic | src/tactic/group.lean | [
"tactic.ring",
"tactic.doc_commands",
"algebra.group.commutator"
] | [
"group",
"mul_assoc",
"mul_self_zpow"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
tactic.group.zpow_trick_one' {G : Type*} [group G] (a b : G) (n : ℤ) : a*b^n*b = a*b^(n+1) | by rw [mul_assoc, mul_zpow_self] | lemma | tactic.group.zpow_trick_one' | tactic | src/tactic/group.lean | [
"tactic.ring",
"tactic.doc_commands",
"algebra.group.commutator"
] | [
"group",
"mul_assoc",
"mul_zpow_self"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
tactic.group.zpow_trick_sub {G : Type*} [group G] (a b : G) (n m : ℤ) :
a*b^n*b^(-m) = a*b^(n-m) | by rw [mul_assoc, ← zpow_add] ; refl | lemma | tactic.group.zpow_trick_sub | tactic | src/tactic/group.lean | [
"tactic.ring",
"tactic.doc_commands",
"algebra.group.commutator"
] | [
"group",
"mul_assoc",
"zpow_add"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
aux_group₁ (locat : loc) : tactic unit | simp_core { fail_if_unchanged := ff } skip tt [
expr ``(commutator_element_def),
expr ``(mul_one),
expr ``(one_mul),
expr ``(one_pow),
expr ``(one_zpow),
expr ``(sub_self),
expr ``(add_neg_self),
expr ``(neg_add_self),
expr ``(neg_neg),
expr ``(tsub_self),
expr ``(int.coe_nat_add),
expr ``(int.c... | def | tactic.aux_group₁ | tactic | src/tactic/group.lean | [
"tactic.ring",
"tactic.doc_commands",
"algebra.group.commutator"
] | [] | Auxiliary tactic for the `group` tactic. Calls the simplifier only. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
aux_group₂ (locat : loc) : tactic unit | ring_nf none tactic.ring.normalize_mode.raw locat | def | tactic.aux_group₂ | tactic | src/tactic/group.lean | [
"tactic.ring",
"tactic.doc_commands",
"algebra.group.commutator"
] | [] | Auxiliary tactic for the `group` tactic. Calls `ring_nf` to normalize exponents. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
group (locat : parse location) : tactic unit | do when locat.include_goal `[rw ← mul_inv_eq_one],
aux_group₁ locat,
repeat (aux_group₂ locat ; aux_group₁ locat) | def | tactic.interactive.group | tactic | src/tactic/group.lean | [
"tactic.ring",
"tactic.doc_commands",
"algebra.group.commutator"
] | [
"group",
"mul_inv_eq_one"
] | Tactic for normalizing expressions in multiplicative groups, without assuming
commutativity, using only the group axioms without any information about which group
is manipulated.
(For additive commutative groups, use the `abel` tactic instead.)
Example:
```lean
example {G : Type} [group G] (a b c d : G) (h : c = (a*b... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
has_variable_names (α : Sort u) : Type | (names : list name)
(names_nonempty : 0 < names.length . tactic.exact_dec_trivial) | class | has_variable_names | tactic | src/tactic/has_variable_names.lean | [
"tactic.core"
] | [
"tactic.exact_dec_trivial"
] | Type class for associating a type `α` with typical variable names for elements
of `α`. See `tactic.typical_variable_names`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
typical_variable_names (t : expr) : tactic (list name) | (do
names ← to_expr ``(has_variable_names.names %%t),
eval_expr (list name) names)
<|> fail! "typical_variable_names: unable to get typical variable names for type {t}" | def | tactic.typical_variable_names | tactic | src/tactic/has_variable_names.lean | [
"tactic.core"
] | [] | `typical_variable_names t` obtains typical names for variables of type `t`.
The returned list is guaranteed to be nonempty. Fails if there is no instance
`has_typical_variable_names t`.
```
typical_variable_names `(ℕ) = [`n, `m, `o]
``` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
make_listlike_instance (α : Sort u) [has_variable_names α]
{β : Sort v} : has_variable_names β | ⟨ (names α).map $ λ n, n.append_suffix "s",
by simp [names_nonempty] ⟩ | def | has_variable_names.make_listlike_instance | tactic | src/tactic/has_variable_names.lean | [
"tactic.core"
] | [
"has_variable_names"
] | `@make_listlike_instance α _ β` creates an instance `has_variable_names β` from
an instance `has_variable_names α`. If `α` has associated names `a`, `b`, ...,
the generated instance for `β` has names `as`, `bs`, ... This can be used to
create instances for 'containers' such as lists or sets. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
make_inheriting_instance (α : Sort u) [has_variable_names α]
{β : Sort v} : has_variable_names β | ⟨names α, names_nonempty⟩ | def | has_variable_names.make_inheriting_instance | tactic | src/tactic/has_variable_names.lean | [
"tactic.core"
] | [
"has_variable_names"
] | `@make_inheriting_instance α _ β` creates an instance `has_variable_names β`
from an instance `has_variable_names α`. The generated instance contains the
same variable names as that of `α`. This can be used to create instances for
'wrapper' types like `option` and `subtype`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
Prop.has_variable_names : has_variable_names Prop | ⟨[`P, `Q, `R]⟩ | instance | Prop.has_variable_names | tactic | src/tactic/has_variable_names.lean | [
"tactic.core"
] | [
"has_variable_names"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
hint_tactic_attribute : user_attribute | { name := `hint_tactic,
descr := "A tactic that should be tried by `hint`." } | def | tactic.hint.hint_tactic_attribute | tactic | src/tactic/hint.lean | [
"tactic.solve_by_elim",
"tactic.interactive"
] | [] | An attribute marking a `tactic unit` or `tactic string` which should be used by the `hint`
tactic. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
add_tactic_hint (n : name) (t : expr) : tactic unit | do
add_decl $ declaration.defn n [] `(tactic string) t reducibility_hints.opaque ff,
hint_tactic_attribute.set n () tt | def | tactic.hint.add_tactic_hint | tactic | src/tactic/hint.lean | [
"tactic.solve_by_elim",
"tactic.interactive"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_hint_tactic (_ : parse (tk "add_hint_tactic")) : parser unit | do n ← parser.pexpr,
e ← to_expr n,
s ← eval_expr string e,
let t := "`[" ++ s ++ "]",
(t, _) ← with_input parser.pexpr t,
of_tactic $ do
let h := s <.> "_hint",
t ← to_expr ``(do %%t, pure %%n),
add_tactic_hint h t. | def | tactic.hint.add_hint_tactic | tactic | src/tactic/hint.lean | [
"tactic.solve_by_elim",
"tactic.interactive"
] | [] | `add_hint_tactic t` runs the tactic `t` whenever `hint` is invoked.
The typical use case is `add_hint_tactic "foo"` for some interactive tactic `foo`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
hint : tactic (list (string × ℕ)) | do
names ← attribute.get_instances `hint_tactic,
focus1 $ try_all_sorted (names.reverse.map name_to_tactic) | def | tactic.hint | tactic | src/tactic/hint.lean | [
"tactic.solve_by_elim",
"tactic.interactive"
] | [
"name_to_tactic"
] | Report a list of tactics that can make progress against the current goal,
and for each such tactic, the number of remaining goals afterwards. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
hint : tactic unit | do
hints ← tactic.hint,
if hints.length = 0 then
fail "no hints available"
else do
t ← hints.nth 0,
if t.2 = 0 then do
trace "the following tactics solve the goal:\n----",
(hints.filter (λ p : string × ℕ, p.2 = 0)).mmap' (λ p, tactic.trace format!"Try this: {p.1}")
else do
trace ... | def | tactic.interactive.hint | tactic | src/tactic/hint.lean | [
"tactic.solve_by_elim",
"tactic.interactive"
] | [
"tactic.hint"
] | Report a list of tactics that can make progress against the current goal. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
trace_eliminate_hyp {α} [has_to_format α] (msg : thunk α) : tactic unit | when_tracing `eliminate_hyp $ trace $ to_fmt "eliminate_hyp: " ++ to_fmt (msg ()) | def | tactic.eliminate.trace_eliminate_hyp | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | `trace_eliminate_hyp msg` traces `msg` if the option `trace.eliminate_hyp` is
`true`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
trace_state_eliminate_hyp {α} [has_to_format α] (msg : thunk α) :
tactic unit | do
state ← read,
trace_eliminate_hyp $ format.join
[to_fmt (msg ()), "\n-----\n", to_fmt state, "\n-----"] | def | tactic.eliminate.trace_state_eliminate_hyp | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | `trace_state_eliminate_hyp msg` traces `msg` followed by the tactic state if the
option `trace.eliminate_hyp` is `true`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_info | (aname : name)
(type : expr)
(dependent : bool)
(index_occurrences : list ℕ)
(recursive_leading_pis : option ℕ) | structure | tactic.eliminate.constructor_argument_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Information about a constructor argument. E.g. given the declaration
```
induction ℕ : Type
| zero : ℕ
| suc (n : ℕ) : ℕ
```
the `zero` constructor has no arguments and the `suc` constructor has one
argument, `n`.
We record the following information:
- `aname`: the argument's name. If the argument was not explicitl... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
is_recursive (c : constructor_argument_info) | c.recursive_leading_pis.is_some | def | tactic.eliminate.constructor_argument_info.is_recursive | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | `is_recursive c` is true iff the constructor argument described by `c` is
recursive. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_info | (cname : name)
(non_param_args : list constructor_argument_info)
(num_non_param_args : ℕ)
(rec_args : list constructor_argument_info)
(num_rec_args : ℕ) | structure | tactic.eliminate.constructor_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Information about a constructor. Contains:
- `cname`: the constructor's name.
- `non_param_args`: information about the arguments of the constructor,
excluding the arguments induced by the parameters of the inductive type.
- `num_non_param_args`: the length of `non_param_args`.
- `rec_args`: the subset of `non_param... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_info.num_nameable_hypotheses (c : constructor_info) : ℕ | c.num_non_param_args + c.num_rec_args | def | tactic.eliminate.constructor_info.num_nameable_hypotheses | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | When we construct the goal for the minor premise of a given constructor, this is
the number of hypotheses we must name. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
inductive_info | (iname : name)
(constructors : list constructor_info)
(num_constructors : ℕ)
(type : expr)
(num_params : ℕ)
(num_indices : ℕ) | structure | tactic.eliminate.inductive_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Information about an inductive type. Contains:
- `iname`: the type's name.
- `constructors`: information about the type's constructors.
- `num_constructors`: the length of `constructors`.
- `type`: the type's type.
- `num_param`: the type's number of parameters.
- `num_indices`: the type's number of indices. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
major_premise_info | (mpname : name)
(mpexpr : expr)
(type : expr)
(args : rb_map ℕ expr) | structure | tactic.eliminate.major_premise_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Information about a major premise (i.e. the hypothesis on which we are
performing induction). Contains:
- `mpname`: the major premise's name.
- `mpexpr`: the major premise itself.
- `type`: the type of `mpexpr`.
- `args`: the arguments of the major premise. The major premise has type
`I x₀ ... xₙ`, where `I` is an i... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
index_occurrence_type_match (t s : expr) : tactic bool | succeeds $ is_def_eq t s | def | tactic.eliminate.index_occurrence_type_match | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [
"succeeds"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
get_index_occurrences (num_params : ℕ) (ret_type : expr) :
tactic (rb_lmap expr ℕ) | do
ret_args ← get_app_args_whnf ret_type,
ret_args.mfoldl_with_index
(λ i occ_map ret_arg, do
if i < num_params
then pure occ_map
else do
let ret_arg_consts := ret_arg.list_local_consts',
ret_arg_consts.mfold occ_map $ λ c occ_map, do
ret_arg_type ← infer_ty... | def | tactic.eliminate.get_index_occurrences | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | From the return type of a constructor `C` of an inductive type `I`, determine
the index occurrences of the constructor arguments of `C`.
Input:
- `num_params:` the number of parameters of `I`.
- `ret_type`: the return type of `C`. `e` must be of the form `I x₁ ... xₙ`.
Output: A map associating each local constant `... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
match_recursive_constructor_arg (I : name) (T : expr) :
tactic (option ℕ) | do
(pis, base) ← open_pis_whnf T,
base ← get_app_fn_whnf base,
pure $
match base with
| (const c _) := if c = I then some pis.length else none
| _ := none
end | def | tactic.eliminate.match_recursive_constructor_arg | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | `match_recursive_constructor_arg I T`, given `I` the name of an inductive type
and `T` the type of an argument of a constructor of `I`, returns `none` if the
argument is non-recursive (i.e. `I` does not appear in `T`). If the argument is
recursive, `T` is of the form `Π (x₁ : T₁) ... (xₙ : Tₙ), I ...`, in which case
`m... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_constructor_argument_info (inductive_name : name)
(num_params : ℕ) (T : expr) :
tactic (list constructor_argument_info) | do
⟨args, ret⟩ ← open_pis_whnf_dep T,
index_occs ← get_index_occurrences num_params ret,
args.mmap $ λ ⟨c, dep⟩, do
let occs := rb_set.of_list $ index_occs.find c,
let type := c.local_type,
recursive_leading_pis ← match_recursive_constructor_arg inductive_name type,
pure ⟨c.local_pp_name, type, de... | def | tactic.eliminate.get_constructor_argument_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [
"ret"
] | Get information about the arguments of a constructor `C` of an inductive type
`I`.
Input:
- `inductive_name`: the name of `I`.
- `num_params`: the number of parameters of `I`.
- `T`: the type of `C`.
Output: a `constructor_argument_info` structure for each argument of `C`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_constructor_info (iname : name) (num_params : ℕ) (c : name) :
tactic constructor_info | do
env ← get_env,
when (¬ env.is_constructor c) $ fail! "Expected {c} to be a constructor.",
decl ← env.get c,
args ← get_constructor_argument_info iname num_params decl.type,
let non_param_args := args.drop num_params,
let rec_args := non_param_args.filter $ λ ainfo, ainfo.is_recursive,
pure
{ cname ... | def | tactic.eliminate.get_constructor_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Get information about a constructor `C` of an inductive type `I`.
Input:
- `iname`: the name of `I`.
- `num_params`: the number of parameters of `I`.
- `c` : the name of `C`.
Output:
A `constructor_info` structure for `C`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_inductive_info (I : name) : tactic inductive_info | do
env ← get_env,
when (¬ env.is_inductive I) $ fail! "Expected {I} to be an inductive type.",
decl ← env.get I,
let type := decl.type,
let num_params := env.inductive_num_params I,
let num_indices := env.inductive_num_indices I,
let constructor_names := env.constructors_of I,
constructors ← constructor... | def | tactic.eliminate.get_inductive_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Get information about an inductive type `I`, given `I`'s name. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_major_premise_info (major_premise : expr) :
tactic major_premise_info | do
type ← infer_type major_premise,
⟨f, args⟩ ← get_app_fn_args_whnf type,
pure
{ mpname := major_premise.local_pp_name,
mpexpr := major_premise,
type := type,
args := args.to_rb_map } | def | tactic.eliminate.get_major_premise_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Get information about a major premise. The given `expr` must be a local
hypothesis. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_naming_info | (mpinfo : major_premise_info)
(iinfo : inductive_info)
(cinfo : constructor_info)
(ainfo : constructor_argument_info) | structure | tactic.eliminate.constructor_argument_naming_info | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Information used when naming a constructor argument. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_naming_rule : Type | constructor_argument_naming_info → tactic (list name) | def | tactic.eliminate.constructor_argument_naming_rule | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | A constructor argument naming rule takes a `constructor_argument_naming_info`
structure and returns a list of suitable names for the argument. If the rule is
not applicable to the given constructor argument, the returned list is empty. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_naming_rule_rec : constructor_argument_naming_rule | λ i, pure $ if i.ainfo.is_recursive then [i.mpinfo.mpname] else [] | def | tactic.eliminate.constructor_argument_naming_rule_rec | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Naming rule for recursive constructor arguments. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_naming_rule_index : constructor_argument_naming_rule | λ i,
let index_occs := i.ainfo.index_occurrences in
let major_premise_args := i.mpinfo.args in
let get_major_premise_arg_local_names : ℕ → option (name × name) := λ i, do
{ arg ← major_premise_args.find i,
(uname, ppname, _) ← arg.match_local_const,
pure (uname, ppname) } in
let local_index_instantiations :=
(ind... | def | tactic.eliminate.constructor_argument_naming_rule_index | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Naming rule for constructor arguments associated with an index. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_naming_rule_named : constructor_argument_naming_rule | λ i,
let arg_name := i.ainfo.aname in
let arg_dep := i.ainfo.dependent in
pure $
if ! arg_dep && arg_name.is_likely_generated_binder_name
then []
else [arg_name] | def | tactic.eliminate.constructor_argument_naming_rule_named | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Naming rule for constructor arguments which are named in the constructor
declaration. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_naming_rule_type : constructor_argument_naming_rule | λ i, typical_variable_names i.ainfo.type <|> pure [] | def | tactic.eliminate.constructor_argument_naming_rule_type | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Naming rule for constructor arguments whose type is associated with a list of
typical variable names. See `tactic.typical_variable_names`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_naming_rule_prop : constructor_argument_naming_rule | λ i, do
(sort level.zero) ← infer_type i.ainfo.type | pure [],
pure [`h] | def | tactic.eliminate.constructor_argument_naming_rule_prop | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Naming rule for constructor arguments whose type is in `Prop`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_naming_rule_fallback : constructor_argument_naming_rule | λ _, pure [`x] | def | tactic.eliminate.constructor_argument_naming_rule_fallback | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Fallback constructor argument naming rule. This rule never fails. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
apply_constructor_argument_naming_rules
(info : constructor_argument_naming_info)
(rules : list constructor_argument_naming_rule) : tactic (list name) | do
names ← try_core $ rules.mfirst (λ r, do
names ← r info,
match names with
| [] := failed
| _ := pure names
end),
match names with
| none := fail
"apply_constructor_argument_naming_rules: no applicable naming rule"
| (some names) := pure names
end | def | tactic.eliminate.apply_constructor_argument_naming_rules | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | `apply_constructor_argument_naming_rules info rules` applies the constructor
argument naming rules in `rules` to the constructor argument given by `info`.
Returns the result of the first applicable rule. Fails if no rule is applicable. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
constructor_argument_names (info : constructor_argument_naming_info) :
tactic (list name) | apply_constructor_argument_naming_rules info
[ constructor_argument_naming_rule_rec
, constructor_argument_naming_rule_index
, constructor_argument_naming_rule_named
, constructor_argument_naming_rule_type
, constructor_argument_naming_rule_prop
, constructor_argument_naming_rule_fallback ] | def | tactic.eliminate.constructor_argument_names | tactic | src/tactic/induction.lean | [
"tactic.clear",
"tactic.dependencies",
"tactic.fresh_names",
"tactic.generalizes",
"tactic.has_variable_names",
"tactic.unify_equations"
] | [] | Get possible names for a constructor argument. This tactic applies all the
previously defined rules in order. It cannot fail and always returns a nonempty
list. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.