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
get_pi_binders_nondep_aux : ℕ → expr → tactic (list (ℕ × binder) × expr)
λ i e, do some (name, bi, type, body) ← get_binder none tt e | pure ([], e), replacement ← mk_local' name bi type, (rs, rest) ← get_pi_binders_nondep_aux (i + 1) (body.instantiate_var replacement), let rs' := if body.has_var then rs else (i, replacement.to_binder) :: rs, pure (rs', rest)
def
tactic.get_pi_binders_nondep_aux
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[ "binder" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_pi_binders_nondep : expr → tactic (list (ℕ × binder) × expr)
get_pi_binders_nondep_aux 0
def
tactic.get_pi_binders_nondep
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[ "binder" ]
`get_pi_binders_nondep e` instantiates all leading Π binders of `e` with fresh local constants (like `open_pis`). Returns the remainder of `e` and information about the *nondependent* binders that were instantiated (but not the new local constants). A nondependent binder is one that does not appear later in the express...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_lambdas : expr → tactic (list expr × expr)
open_binders none ff tt
def
tactic.open_lambdas
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_lambdas e` instantiates all leading λ binders of `e` with fresh local constants. Returns the new local constants and the remainder of `e`. This is `open_pis` but for λ binders rather than Π binders.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_lambdas_metas : expr → tactic (list expr × expr)
open_binders none ff ff
def
tactic.open_lambdas_metas
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_lambdas_metas e` instantiates all leading λ binders of `e` with fresh metavariables. Returns the new metavariables and the remainder of `e`. This is `open_lambdas` but with metavariables instead of local constants.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_n_lambdas : expr → ℕ → tactic (list expr × expr)
open_n_binders none ff tt
def
tactic.open_n_lambdas
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_n_lambdas e n` instantiates the first `n` λ binders of `e` with fresh local constants. Returns the new local constants and the remainder of `e`. Fails if `e` does not start with at least `n` λ binders. This is `open_lambdas` but restricted to the first `n` binders.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_n_lambdas_metas : expr → ℕ → tactic (list expr × expr)
open_n_binders none ff ff
def
tactic.open_n_lambdas_metas
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_n_lambdas_metas e n` instantiates the first `n` λ binders of `e` with fresh metavariables. Returns the new metavariables and the remainder of `e`. Fails if `e` does not start with at least `n` λ binders. This is `open_lambdas_metas` but restricted to the first `n` binders.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_lambdas_whnf (e : expr) (md := semireducible) (unfold_ginductive := tt) : tactic (list expr × expr)
open_binders (some (md, unfold_ginductive)) ff tt e
def
tactic.open_lambdas_whnf
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_lambdas_whnf e md unfold_ginductive` instantiates all leading λ binders of `e` with fresh local constants. The leading λ binders of `e` are matched up to normalisation with transparency `md`. `unfold_ginductive` determines whether constructors of generalised inductive types are unfolded during normalisation. This...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_lambdas_metas_whnf (e : expr) (md := semireducible) (unfold_ginductive := tt) : tactic (list expr × expr)
open_binders (some (md, unfold_ginductive)) ff ff e
def
tactic.open_lambdas_metas_whnf
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_lambdas_metas_whnf e md unfold_ginductive` instantiates all leading λ binders of `e` with fresh metavariables. The leading λ binders of `e` are matched up to normalisation with transparency `md`. `unfold_ginductive` determines whether constructors of generalised inductive types are unfolded during normalisation. ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_n_lambdas_whnf (e : expr) (n : ℕ) (md := semireducible) (unfold_ginductive := tt) : tactic (list expr × expr)
open_n_binders (some (md, unfold_ginductive)) ff tt e n
def
tactic.open_n_lambdas_whnf
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_n_lambdas_whnf e md unfold_ginductive` instantiates the first `n` λ binders of `e` with fresh local constants. The λ binders are matched up to normalisation with transparency `md`. `unfold_ginductive` determines whether constructors of generalised inductive types are unfolded during normalisation. Fails if `e` do...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_n_lambdas_metas_whnf (e : expr) (n : ℕ) (md := semireducible) (unfold_ginductive := tt) : tactic (list expr × expr)
open_n_binders (some (md, unfold_ginductive)) ff ff e n
def
tactic.open_n_lambdas_metas_whnf
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_n_lambdas_metas_whnf e md unfold_ginductive` instantiates the first `n` λ binders of `e` with fresh metavariables. The λ binders are matched up to normalisation with transparency `md`. `unfold_ginductive` determines whether constructors of generalised inductive types are unfolded during normalisation. Fails if `e...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_pis_whnf_dep : expr → tactic (list (expr × bool) × expr)
λ e, do e' ← whnf e, match e' with | (pi n bi t rest) := do c ← mk_local' n bi t, let dep := rest.has_var, (cs, rest) ← open_pis_whnf_dep $ rest.instantiate_var c, pure ((c, dep) :: cs, rest) | _ := pure ([], e) end
def
tactic.open_pis_whnf_dep
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_pis_whnf_dep e` instantiates all leading Π binders of `e` with fresh local constants (like `tactic.open_pis`). It returns the remainder of the expression and, for each binder, the corresponding local constant and whether the binder was dependent.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
open_n_pis_metas' : expr → ℕ → tactic (list (expr × name × binder_info) × expr)
| e 0 := pure ([], e) | (pi nam bi t rest) (n + 1) := do m ← mk_meta_var t, (ms, rest) ← open_n_pis_metas' (rest.instantiate_var m) n, pure ((m, nam, bi) :: ms, rest) | e (n + 1) := fail $ to_fmt "expected an expression starting with a Π, but got: " ++ to_fmt e
def
tactic.open_n_pis_metas'
tactic
src/tactic/binder_matching.lean
[ "data.option.defs", "meta.expr" ]
[]
`open_n_pis_metas' e n` instantiates the first `n` leading Π binders of `e` with fresh metavariables. It returns the remainder of the expression and, for each binder, the corresponding metavariable, the name of the bound variable and the binder's `binder_info`. Fails if `e` does not have at least `n` leading Π binders.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
by_contra' (h : parse ident?) (t : parse (tk ":" *> texpr)?) : tactic unit
do let h := h.get_or_else `this, tgt ← target, mk_mapp `classical.by_contradiction [some tgt] >>= tactic.eapply, h₁ ← tactic.intro h, t' ← infer_type h₁, -- negation-normalize `t'` to the expression `e'` and get a proof `pr'` of `t' = e'` (e', pr') ← push_neg.normalize_negations t' <|> refl_conv t', mat...
def
tactic.interactive.by_contra'
tactic
src/tactic/by_contra.lean
[ "tactic.core", "tactic.push_neg" ]
[ "push_neg.normalize_negations" ]
If the target of the main goal is a proposition `p`, `by_contra'` reduces the goal to proving `false` using the additional hypothesis `h : ¬ p`. `by_contra' h` can be used to name the hypothesis `h : ¬ p`. The hypothesis `¬ p` will be negation normalized using `push_neg`. For instance, `¬ a < b` will be changed to `b ≤...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mul_subst {α} [comm_ring α] {n1 n2 k e1 e2 t1 t2 : α} (h1 : n1 * e1 = t1) (h2 : n2 * e2 = t2) (h3 : n1*n2 = k) : k * (e1 * e2) = t1 * t2
by rw [←h3, mul_comm n1, mul_assoc n2, ←mul_assoc n1, h1, ←mul_assoc n2, mul_comm n2, mul_assoc, h2]
lemma
cancel_factors.mul_subst
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "comm_ring", "mul_assoc", "mul_comm" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
div_subst {α} [field α] {n1 n2 k e1 e2 t1 : α} (h1 : n1 * e1 = t1) (h2 : n2 / e2 = 1) (h3 : n1*n2 = k) : k * (e1 / e2) = t1
by rw [←h3, mul_assoc, mul_div_left_comm, h2, ←mul_assoc, h1, mul_comm, one_mul]
lemma
cancel_factors.div_subst
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "field", "mul_assoc", "mul_comm", "mul_div_left_comm", "one_mul" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cancel_factors_eq_div {α} [field α] {n e e' : α} (h : n*e = e') (h2 : n ≠ 0) : e = e' / n
eq_div_of_mul_eq h2 $ by rwa mul_comm at h
lemma
cancel_factors.cancel_factors_eq_div
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "eq_div_of_mul_eq", "field", "mul_comm" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_subst {α} [ring α] {n e1 e2 t1 t2 : α} (h1 : n * e1 = t1) (h2 : n * e2 = t2) : n * (e1 + e2) = t1 + t2
by simp [left_distrib, *]
lemma
cancel_factors.add_subst
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "left_distrib", "ring" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sub_subst {α} [ring α] {n e1 e2 t1 t2 : α} (h1 : n * e1 = t1) (h2 : n * e2 = t2) : n * (e1 - e2) = t1 - t2
by simp [left_distrib, *, sub_eq_add_neg]
lemma
cancel_factors.sub_subst
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "left_distrib", "ring" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
neg_subst {α} [ring α] {n e t : α} (h1 : n * e = t) : n * (-e) = -t
by simp *
lemma
cancel_factors.neg_subst
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "ring" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cancel_factors_lt {α} [linear_ordered_field α] {a b ad bd a' b' gcd : α} (ha : ad*a = a') (hb : bd*b = b') (had : 0 < ad) (hbd : 0 < bd) (hgcd : 0 < gcd) : a < b = ((1/gcd)*(bd*a') < (1/gcd)*(ad*b'))
begin rw [mul_lt_mul_left, ←ha, ←hb, ←mul_assoc, ←mul_assoc, mul_comm bd, mul_lt_mul_left], exact mul_pos had hbd, exact one_div_pos.2 hgcd end
lemma
cancel_factors.cancel_factors_lt
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "linear_ordered_field", "mul_comm", "mul_lt_mul_left" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cancel_factors_le {α} [linear_ordered_field α] {a b ad bd a' b' gcd : α} (ha : ad*a = a') (hb : bd*b = b') (had : 0 < ad) (hbd : 0 < bd) (hgcd : 0 < gcd) : a ≤ b = ((1/gcd)*(bd*a') ≤ (1/gcd)*(ad*b'))
begin rw [mul_le_mul_left, ←ha, ←hb, ←mul_assoc, ←mul_assoc, mul_comm bd, mul_le_mul_left], exact mul_pos had hbd, exact one_div_pos.2 hgcd end
lemma
cancel_factors.cancel_factors_le
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "linear_ordered_field", "mul_comm", "mul_le_mul_left" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cancel_factors_eq {α} [linear_ordered_field α] {a b ad bd a' b' gcd : α} (ha : ad*a = a') (hb : bd*b = b') (had : 0 < ad) (hbd : 0 < bd) (hgcd : 0 < gcd) : a = b = ((1/gcd)*(bd*a') = (1/gcd)*(ad*b'))
begin rw [←ha, ←hb, ←mul_assoc bd, ←mul_assoc ad, mul_comm bd], ext, split, { rintro rfl, refl }, { intro h, simp only [←mul_assoc] at h, refine mul_left_cancel₀ (mul_ne_zero _ _) h, apply mul_ne_zero, apply div_ne_zero, all_goals {apply ne_of_gt; assumption <|> exact zero_lt_one}} end
lemma
cancel_factors.cancel_factors_eq
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "div_ne_zero", "linear_ordered_field", "mul_comm", "mul_left_cancel₀", "mul_ne_zero", "zero_lt_one" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_cancel_factor : expr → ℕ × tree ℕ
| `(%%e1 + %%e2) := let (v1, t1) := find_cancel_factor e1, (v2, t2) := find_cancel_factor e2, lcm := v1.lcm v2 in (lcm, node lcm t1 t2) | `(%%e1 - %%e2) := let (v1, t1) := find_cancel_factor e1, (v2, t2) := find_cancel_factor e2, lcm := v1.lcm v2 in (lcm, node lcm t1 t2) | `(%%e1 * %%e2) := let (v1, t1) := fi...
def
cancel_factors.find_cancel_factor
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "tree" ]
`find_cancel_factor e` produces a natural number `n`, such that multiplying `e` by `n` will be able to cancel all the numeric denominators in `e`. The returned `tree` describes how to distribute the value `n` over products inside `e`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_prod_prf : ℕ → tree ℕ → expr → tactic expr
| v (node _ lhs rhs) `(%%e1 + %%e2) := do v1 ← mk_prod_prf v lhs e1, v2 ← mk_prod_prf v rhs e2, mk_app ``add_subst [v1, v2] | v (node _ lhs rhs) `(%%e1 - %%e2) := do v1 ← mk_prod_prf v lhs e1, v2 ← mk_prod_prf v rhs e2, mk_app ``sub_subst [v1, v2] | v (node n lhs@(node ln _ _) rhs) `(%%e1 * %%e2) := do tp ← infer...
def
cancel_factors.mk_prod_prf
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "tree" ]
`mk_prod_prf n tr e` produces a proof of `n*e = e'`, where numeric denominators have been canceled in `e'`, distributing `n` proportionally according to `tr`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
derive (e : expr) : tactic (ℕ × expr)
let (n, t) := find_cancel_factor e in prod.mk n <$> mk_prod_prf n t e <|> fail!"cancel_factors.derive failed to normalize {e}. Are you sure this is well-behaved division?"
def
cancel_factors.derive
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[]
Given `e`, a term with rational division, produces a natural number `n` and a proof of `n*e = e'`, where `e'` has no division. Assumes "well-behaved" division.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
derive_div (e : expr) : tactic (ℕ × expr)
do (n, p) ← derive e, tp ← infer_type e, n' ← tp.of_nat n, tgt ← to_expr ``(%%n' ≠ 0), (_, pn) ← solve_aux tgt `[norm_num, done], prod.mk n <$> mk_mapp ``cancel_factors_eq_div [none, none, n', none, none, p, pn]
def
cancel_factors.derive_div
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[]
Given `e`, a term with rational divison, produces a natural number `n` and a proof of `e = e' / n`, where `e'` has no divison. Assumes "well-behaved" division.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_comp_lemma : expr → option (expr × expr × name)
| `(%%a < %%b) := (a, b, ``cancel_factors_lt) | `(%%a ≤ %%b) := (a, b, ``cancel_factors_le) | `(%%a = %%b) := (a, b, ``cancel_factors_eq) | `(%%a ≥ %%b) := (b, a, ``cancel_factors_le) | `(%%a > %%b) := (b, a, ``cancel_factors_lt) | _ := none
def
cancel_factors.find_comp_lemma
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[]
`find_comp_lemma e` arranges `e` in the form `lhs R rhs`, where `R ∈ {<, ≤, =}`, and returns `lhs`, `rhs`, and the `cancel_factors` lemma corresponding to `R`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cancel_denominators_in_type (h : expr) : tactic (expr × expr)
do some (lhs, rhs, lem) ← return $ find_comp_lemma h | fail "cannot kill factors", (al, lhs_p) ← derive lhs, (ar, rhs_p) ← derive rhs, let gcd := al.gcd ar, tp ← infer_type lhs, al ← tp.of_nat al, ar ← tp.of_nat ar, gcd ← tp.of_nat gcd, al_pos ← to_expr ``(0 < %%al), ar_pos ← to_expr ``(0 < %...
def
cancel_factors.cancel_denominators_in_type
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[]
`cancel_denominators_in_type h` assumes that `h` is of the form `lhs R rhs`, where `R ∈ {<, ≤, =, ≥, >}`. It produces an expression `h'` of the form `lhs' R rhs'` and a proof that `h = h'`. Numeric denominators have been canceled in `lhs'` and `rhs'`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic.interactive.cancel_denoms (l : parse location) : tactic unit
do locs ← l.get_locals, tactic.replace_at cancel_denominators_in_type locs l.include_goal >>= guardb <|> fail "failed to cancel any denominators", tactic.interactive.norm_num [simp_arg_type.symm_expr ``(mul_assoc)] l
def
tactic.interactive.cancel_denoms
tactic
src/tactic/cancel_denoms.lean
[ "data.rat.meta_defs", "tactic.norm_num", "data.tree", "meta.expr" ]
[ "tactic.replace_at" ]
`cancel_denoms` attempts to remove numerals from the denominators of fractions. It works on propositions that are field-valued inequalities. ```lean variables {α : Type} [linear_ordered_field α] (a b c : α) example (h : a / 5 + b / 4 < c) : 4*a + 5*b < 20*c := begin cancel_denoms at h, exact h end example (h : a...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_script (α : Type) : Type | base : α → tactic_script | work (index : ℕ) (first : α) (later : list tactic_script) (closed : bool) : tactic_script
inductive
tactic.tactic_script
tactic
src/tactic/chain.lean
[ "tactic.ext" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_script.to_string : tactic_script string → string
| (tactic_script.base a) := a | (tactic_script.work n a l c) := "work_on_goal " ++ (to_string (n+1)) ++ " { " ++ (", ".intercalate (a :: l.map tactic_script.to_string)) ++ " }"
def
tactic.tactic_script.to_string
tactic
src/tactic/chain.lean
[ "tactic.ext" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_script_unit_has_to_string : has_to_string (tactic_script unit)
{ to_string := λ s, "[chain tactic]" }
instance
tactic.tactic_script_unit_has_to_string
tactic
src/tactic/chain.lean
[ "tactic.ext" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
abstract_if_success (tac : expr → tactic α) (g : expr) : tactic α
do type ← infer_type g, is_lemma ← is_prop type, if is_lemma then -- there's no point making the abstraction, and indeed it's slower tac g else do m ← mk_meta_var type, a ← tac m, do { val ← instantiate_mvars m, guard (val.list_meta_vars = []), c ← new_aux_decl_name, gs ← ...
def
tactic.abstract_if_success
tactic
src/tactic/chain.lean
[ "tactic.ext" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
chain_core {α : Type} [has_to_string (tactic_script α)] (tactics : list (tactic α)) : tactic (list string)
do results ← (get_goals >>= chain_many (first tactics)), when results.empty (fail "`chain` tactic made no progress"), return (results.map to_string)
def
tactic.chain_core
tactic
src/tactic/chain.lean
[ "tactic.ext" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
trace_output (t : tactic α) : tactic α
do tgt ← target, r ← t, name ← decl_name, trace format!"`chain` successfully applied a tactic during elaboration of {name}:", tgt ← pp tgt, trace format!"previous target: {tgt}", trace format!"tactic result: {r}", tgt ← try_core target, tgt ← match tgt with | (some tgt) := pp tgt ...
def
tactic.trace_output
tactic
src/tactic/chain.lean
[ "tactic.ext" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
chain (tactics : list (tactic α)) : tactic (list string)
chain_core (if is_trace_enabled_for `chain then (tactics.map trace_output) else tactics)
def
tactic.chain
tactic
src/tactic/chain.lean
[ "tactic.ext" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_sometimes (u : level) (α nonemp p : expr) : list expr → expr × expr → tactic (expr × expr)
| [] (val, spec) := pure (val, spec) | (e :: ctxt) (val, spec) := do (val, spec) ← mk_sometimes ctxt (val, spec), t ← infer_type e, b ← is_prop t, pure $ if b then let val' := expr.bind_lambda val e in (expr.const ``function.sometimes [level.zero, u] t α nonemp val', expr.const ``function.sometimes...
def
tactic.mk_sometimes
tactic
src/tactic/choose.lean
[ "logic.function.basic", "tactic.core" ]
[]
Given `α : Sort u`, `nonemp : nonempty α`, `p : α → Prop`, a context of local variables `ctxt`, and a pair of an element `val : α` and `spec : p val`, `mk_sometimes u α nonemp p ctx (val, spec)` produces another pair `val', spec'` such that `val'` does not have any free variables from elements of `ctxt` whose types are...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
choose1 (nondep : bool) (h : expr) (data : name) (spec : name) : tactic (expr × option (option expr))
do t ← infer_type h, (ctxt, t) ← whnf t >>= open_pis, t ← whnf t transparency.all, match t with | `(@Exists %%α %%p) := do α_t ← infer_type α, expr.sort u ← whnf α_t transparency.all, (ne_fail, nonemp) ← if nondep then do let ne := expr.const ``nonempty [u] α, nonemp ← try_core (mk_ins...
def
tactic.choose1
tactic
src/tactic/choose.lean
[ "logic.function.basic", "tactic.core" ]
[ "option.guard" ]
Changes `(h : ∀xs, ∃a:α, p a) ⊢ g` to `(d : ∀xs, a) (s : ∀xs, p (d xs)) ⊢ g` and `(h : ∀xs, p xs ∧ q xs) ⊢ g` to `(d : ∀xs, p xs) (s : ∀xs, q xs) ⊢ g`. `choose1` returns a pair of the second local constant it introduces, and the error result (see below). If `nondep` is true and `α` is inhabited, then it will remove th...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
choose (nondep : bool) : expr → list name → opt_param (option (option expr)) none → tactic unit
| h [] _ := fail "expect list of variables" | h [n] (some (some ne)) := do g ← mk_meta_var ne, set_goals [g], -- make a reasonable error state fail "choose: failed to synthesize nonempty instance" | h [n] _ := do cnt ← revert h, intro n, intron (cnt - 1), return () | h (n::ns) ne_fail₁ := do (v, ne_fail₂)...
def
tactic.choose
tactic
src/tactic/choose.lean
[ "logic.function.basic", "tactic.core" ]
[]
Changes `(h : ∀xs, ∃as, p as ∧ q as) ⊢ g` to a list of functions `as`, and a final hypothesis on `p as` and `q as`. If `nondep` is true then the functions will be made to not depend on propositional arguments, when possible. The last argument is an internal recursion variable, indicating whether nondep elimination has...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
choose (nondep : parse (tk "!")?) (first : parse ident) (names : parse ident*) (tgt : parse (tk "using" *> texpr)?) : tactic unit
do tgt ← match tgt with | none := get_local `this | some e := tactic.i_to_expr_strict e end, tactic.choose nondep.is_some tgt (first :: names), try (interactive.simp none none tt [simp_arg_type.expr ``(exists_prop)] [] (loc.ns $ some <$> names)), try (tactic.clear tgt)
def
tactic.interactive.choose
tactic
src/tactic/choose.lean
[ "logic.function.basic", "tactic.core" ]
[ "tactic.choose" ]
`choose a b h h' using hyp` takes an hypothesis `hyp` of the form `∀ (x : X) (y : Y), ∃ (a : A) (b : B), P x y a b ∧ Q x y a b` for some `P Q : X → Y → A → B → Prop` and outputs into context two functions `a : X → Y → A`, `b : X → Y → B` and two assumptions: `h : ∀ (x : X) (y : Y), P x y (a x y) (b x y)` and `h' : ∀ (x...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic.clear' (clear_dependent : bool) (hyps : list expr) : tactic unit
do tgt ← target, -- Check if the target depends on any of the hyps. Doing this (instead of -- letting one of the later tactics fail) lets us give a much more informative -- error message. hyps.mmap' (λ h, do dep ← kdepends_on tgt h, when dep $ fail $ format!"Cannot clear hypothesis {h} since the target depends ...
def
tactic.clear'
tactic
src/tactic/clear.lean
[ "data.bool.basic", "tactic.core" ]
[ "format.intercalate" ]
Clears all the hypotheses in `hyps`. The tactic fails if any of the `hyps` is not a local or if the target depends on any of the `hyps`. It also fails if `hyps` contains duplicates. If there are local hypotheses or definitions, say `H`, which are not in `hyps` but depend on one of the `hyps`, what we do depends on `cl...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear' (p : parse (many ident)) : tactic unit
do hyps ← p.mmap get_local, tactic.clear' false hyps
def
tactic.interactive.clear'
tactic
src/tactic/clear.lean
[ "data.bool.basic", "tactic.core" ]
[ "tactic.clear'" ]
An improved version of the standard `clear` tactic. `clear` is sensitive to the order of its arguments: `clear x y` may fail even though both `x` and `y` could be cleared (if the type of `y` depends on `x`). `clear'` lifts this limitation. ```lean example {α} {β : α → Type} (a : α) (b : β a) : unit := begin try { cl...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_dependent (p : parse (many ident)) : tactic unit
do hyps ← p.mmap get_local, tactic.clear' true hyps
def
tactic.interactive.clear_dependent
tactic
src/tactic/clear.lean
[ "data.bool.basic", "tactic.core" ]
[ "tactic.clear'" ]
A variant of `clear'` which clears not only the given hypotheses, but also any other hypotheses depending on them. ```lean example {α} {β : α → Type} (a : α) (b : β a) : unit := begin try { clear' a }, -- fails since `b` depends on `a` clear_dependent a, -- succeeds, clearing `a` and `b` exact () end ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
guess_degree : expr → tactic expr
| `(has_zero.zero) := pure `(0) | `(has_one.one) := pure `(0) | `(- %%f) := guess_degree f | (app `(⇑C) x) := pure `(0) | `(X) := pure `(1) | `(bit0 %%a) := guess_degree a | `(bit1 %%a) := guess_degree a | `(%%a + %...
def
tactic.compute_degree.guess_degree
tactic
src/tactic/compute_degree.lean
[ "data.polynomial.degree.lemmas" ]
[]
`guess_degree e` assumes that `e` is an expression in a polynomial ring, and makes an attempt at guessing the `nat_degree` of `e`. Heuristics for `guess_degree`: * `0, 1, C a`, guess `0`, * `polynomial.X`, guess `1`, * `bit0/1 f, -f`, guess `guess_degree f`, * `f + g, f - g`, guess `max (guess_degree f) (gu...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
resolve_sum_step : tactic unit
do t ← target >>= instantiate_mvars, `(nat_degree %%tl ≤ %%tr) ← whnf t reducible | fail!("Goal is not of the form `f.nat_degree ≤ d`"), match tl with | `(%%tl1 + %%tl2) := refine ``((nat_degree_add_le_iff_left _ _ _).mpr _) | `(%%tl1 - %%tl2) := refine ``((nat_degree_sub_le_iff_left _).mpr _) | `(%%tl1 * %%tl2) := do ...
def
tactic.compute_degree.resolve_sum_step
tactic
src/tactic/compute_degree.lean
[ "data.polynomial.degree.lemmas" ]
[]
`resolve_sum_step` assumes that the current goal is of the form `f.nat_degree ≤ d`, failing otherwise. It tries to make progress on the goal by progressing into `f` if `f` is * a sum, difference, opposite, product, or a power; * a monomial; * `C a`; * `0, 1` or `bit0 a, bit1 a` (to deal with numerals). The side-goals...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
norm_assum : tactic unit
try `[ norm_num ] >> try assumption
def
tactic.compute_degree.norm_assum
tactic
src/tactic/compute_degree.lean
[ "data.polynomial.degree.lemmas" ]
[]
`norm_assum` simply tries `norm_num` and `assumption`. It is used to try to discharge as many as possible of the side-goals of `compute_degree_le`. Several side-goals are of the form `m ≤ n`, for natural numbers `m, n` or of the form `c ≠ 0`, with `c` a coefficient of the polynomial `f` in question.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
eval_guessing (n : ℕ) : expr → tactic ℕ
| `(%%a + %%b) := (+) <$> eval_guessing a <*> eval_guessing b | `(%%a * %%b) := (*) <$> eval_guessing a <*> eval_guessing b | `(max %%a %%b) := max <$> eval_guessing a <*> eval_guessing b | e := eval_expr' ℕ e <|> pure n
def
tactic.compute_degree.eval_guessing
tactic
src/tactic/compute_degree.lean
[ "data.polynomial.degree.lemmas" ]
[]
`eval_guessing n e` takes a natural number `n` and an expression `e` and gives an estimate for the evaluation of `eval_expr' ℕ e`. It is tailor made for estimating degrees of polynomials. It decomposes `e` recursively as a sequence of additions, multiplications and `max`. On the atoms of the process, `eval_guessing` ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
compute_degree_le_aux : tactic unit
do try $ refine ``(degree_le_nat_degree.trans (with_bot.coe_le_coe.mpr _)), `(nat_degree %%tl ≤ %%tr) ← target | fail "Goal is not of the form\n`f.nat_degree ≤ d` or `f.degree ≤ d`", expected_deg ← guess_degree tl >>= eval_guessing 0, deg_bound ← eval_expr' ℕ tr <|> pure expected_deg, if deg_bound < expected_deg then...
def
tactic.compute_degree.compute_degree_le_aux
tactic
src/tactic/compute_degree.lean
[ "data.polynomial.degree.lemmas" ]
[]
A general description of `compute_degree_le_aux` is in the doc-string of `compute_degree`. The difference between the two is that `compute_degree_le_aux` makes no effort to close side-goals, nor fails if the goal does not change.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
compute_degree_le : tactic unit
focus1 $ do check_target_changes compute_degree_le_aux, try $ any_goals' norm_assum
def
tactic.interactive.compute_degree_le
tactic
src/tactic/compute_degree.lean
[ "data.polynomial.degree.lemmas" ]
[]
`compute_degree_le` tries to solve a goal of the form `f.nat_degree ≤ d` or `f.degree ≤ d`, where `f : R[X]` and `d : ℕ` or `d : with_bot ℕ`. If the given degree `d` is smaller than the one that the tactic computes, then the tactic suggests the degree that it computed. Examples: ```lean open polynomial open_locale p...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_iff_congr_core : tactic unit
applyc ``iff_of_eq
def
tactic.apply_iff_congr_core
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[ "iff_of_eq" ]
Apply the constant `iff_of_eq` to the goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
congr_core' : tactic unit
do tgt ← target, apply_eq_congr_core tgt <|> apply_heq_congr_core <|> apply_iff_congr_core <|> fail "congr tactic failed"
def
tactic.congr_core'
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[]
The main part of the body for the loop in `congr'`. This will try to replace a goal `f x = f y` with `x = y`. Also has support for `==` and `↔`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convert_to_core (r : pexpr) : tactic unit
do tgt ← target, h ← to_expr ``(_ : %%tgt = %%r), rewrite_target h, swap
def
tactic.convert_to_core
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[]
The main function in `convert_to`. Changes the goal to `r` and a proof obligation that the goal is equal to `r`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
by_proof_irrel : tactic unit
do tgt ← target, @expr.const tt n [level.zero] ← pure tgt.get_app_fn, if n = ``eq then `[apply proof_irrel] else if n = ``heq then `[apply proof_irrel_heq] else failed
def
tactic.by_proof_irrel
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[ "proof_irrel_heq" ]
Attempts to prove the goal by proof irrelevance, but avoids unifying universe metavariables to do so.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
congr' : option ℕ → tactic unit
| o := focus1 $ assumption <|> reflexivity transparency.none <|> by_proof_irrel <|> (guard (o ≠ some 0) >> congr_core' >> all_goals' (try (congr' (nat.pred <$> o)))) <|> reflexivity
def
tactic.congr'
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[]
Same as the `congr` tactic, but takes an optional argument which gives the depth of recursive applications. * This is useful when `congr` is too aggressive in breaking down the goal. * For example, given `⊢ f (g (x + y)) = f (g (y + x))`, `congr'` produces the goals `⊢ x = y` and `⊢ y = x`, while `congr' 2` produces ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
congr' (n : parse (with_desc "n" small_nat)?) : parse (tk "with" *> prod.mk <$> rintro_patt_parse_hi* <*> (tk ":" *> small_nat)?)? → tactic unit
| none := tactic.congr' n | (some ⟨p, m⟩) := focus1 (tactic.congr' n >> all_goals' (tactic.ext p.join m $> ()))
def
tactic.interactive.congr'
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[ "tactic.congr'", "tactic.ext" ]
Same as the `congr` tactic, but takes an optional argument which gives the depth of recursive applications. * This is useful when `congr` is too aggressive in breaking down the goal. * For example, given `⊢ f (g (x + y)) = f (g (y + x))`, `congr'` produces the goals `⊢ x = y` and `⊢ y = x`, while `congr' 2` produces ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcongr : parse (list.join <$> rintro_patt_parse_hi*) → tactic unit
| ps := do t ← target, qs ← try_core (tactic.ext ps none), some () ← try_core (tactic.congr' none >> (done <|> do s ← target, guard $ ¬ s =ₐ t)) | skip, done <|> rcongr (qs.get_or_else ps)
def
tactic.interactive.rcongr
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[ "tactic.congr'", "tactic.ext" ]
Repeatedly and apply `congr'` and `ext`, using the given patterns as arguments for `ext`. There are two ways this tactic stops: * `congr'` fails (makes no progress), after having already applied `ext`. * `congr'` canceled out the last usage of `ext`. In this case, the state is reverted to before the `congr'` was app...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convert (sym : parse (with_desc "←" (tk "<-")?)) (r : parse texpr) (n : parse (tk "using" *> small_nat)?) : tactic unit
do tgt ← target, u ← infer_type tgt, r ← i_to_expr ``(%%r : (_ : %%u)), src ← infer_type r, src ← simp_lemmas.mk.dsimplify [] src {fail_if_unchanged := ff}, v ← to_expr (if sym.is_some then ``(%%src = %%tgt) else ``(%%tgt = %%src)) tt ff >>= mk_meta_var, (if sym.is_some then mk_eq_mp v r else mk_eq_mpr v r)...
def
tactic.interactive.convert
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[ "sym", "tactic.congr'" ]
The `exact e` and `refine e` tactics require a term `e` whose type is definitionally equal to the goal. `convert e` is similar to `refine e`, but the type of `e` is not required to exactly match the goal. Instead, new goals are created for differences between the type of `e` and the goal. For example, in the proof stat...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convert_to (r : parse texpr) (n : parse (tk "using" *> small_nat)?) : tactic unit
match n with | none := convert_to_core r >> `[congr' 1] | (some 0) := convert_to_core r | (some o) := convert_to_core r >> tactic.congr' o end
def
tactic.interactive.convert_to
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[ "tactic.congr'" ]
`convert_to g using n` attempts to change the current goal to `g`, but unlike `change`, it will generate equality proof obligations using `congr' n` to resolve discrepancies. `convert_to g` defaults to using `congr' 1`. `convert_to` is similar to `convert`, but `convert_to` takes a type (the desired subgoal) while `co...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ac_change (r : parse texpr) (n : parse (tk "using" *> small_nat)?) : tactic unit
convert_to r n; try ac_refl
def
tactic.interactive.ac_change
tactic
src/tactic/congr.lean
[ "tactic.lint", "tactic.ext" ]
[]
`ac_change g using n` is `convert_to g using n` followed by `ac_refl`. It is useful for rearranging/reassociating e.g. sums: ```lean example (a b c d e f g N : ℕ) : (a + b) + (c + d) + (e + f) + g ≤ N := begin ac_change a + d + e + f + c + g + b ≤ _, -- ⊢ a + d + e + f + c + g + b ≤ N end ``` ## Related tactic: `mo...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
congrm_fun_1 {α ρ} {r : ρ} : α → ρ
λ _, r
def
tactic.congrm_fun_1
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
A generic function with one argument. It is the "function underscore" input to `congrm`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
congrm_fun_2 {α β ρ} {r : ρ} : α → β → ρ
λ _ _, r
def
tactic.congrm_fun_2
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
A generic function with two arguments. It is the "function underscore" input to `congrm`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
congrm_fun_3 {α β γ ρ} {r : ρ} : α → β → γ → ρ
λ _ _ _, r
def
tactic.congrm_fun_3
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
A generic function with three arguments. It is the "function underscore" input to `congrm`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
congrm_fun_4 {α β γ δ ρ} {r : ρ} : α → β → γ → δ → ρ
λ _ _ _ _, r
def
tactic.congrm_fun_4
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
A generic function with four arguments. It is the "function underscore" input to `congrm`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
convert_to_explicit (pat lhs : expr) : tactic expr
if pat.get_app_fn.const_name.to_string.starts_with "tactic.congrm_fun_" then pat.list_explicit_args >>= lhs.replace_explicit_args else return pat
def
tactic.convert_to_explicit
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
Replaces a "function underscore" input to `congrm` into the correct expression, read off from the left-hand-side of the target expression.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
extract_subgoals : list expr → list congr_arg_kind → list expr → tactic (list (expr × expr))
| (_ :: _ :: g :: prf_args) (congr_arg_kind.eq :: kinds) (pat :: pat_args) := (λ rest, (g, pat) :: rest) <$> extract_subgoals prf_args kinds pat_args | (_ :: prf_args) (congr_arg_kind.fixed :: kinds) (_ :: pat_args) := extract_subgoals prf_args kinds pat_args | prf_args ...
def
tactic.extract_subgoals
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
For each element of `list congr_arg_kind` that is `eq`, add a pair `(g, pat)` to the final list. Otherwise, discard an appropriate number of initial terms from each list (possibly none from the first) and repeat. `pat` is the given pattern-piece at the appropriate location, extracted from the last `list expr`. It app...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
equate_with_pattern_core : expr → tactic (list expr) | pat
(applyc ``subsingleton.elim >> pure []) <|> (applyc ``rfl >> pure []) <|> if pat.is_mvar || pat.get_delayed_abstraction_locals.is_some then do try $ applyc ``_root_.propext, get_goals <* set_goals [] else match pat with | expr.app _ _ := do `(%%lhs = %%_) ← target, pat ← convert_to_explicit pat lhs, cl ← mk_s...
def
tactic.equate_with_pattern_core
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
`equate_with_pattern_core pat` solves a single goal of the form `lhs = rhs` (assuming that `lhs` and `rhs` are unifiable with `pat`) by applying congruence lemmas until `pat` is a metavariable. Returns the list of metavariables for the new subgoals at the leafs. Calls `set_goals []` at the end.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
equate_with_pattern (pat : expr) : tactic unit
do congr_subgoals ← solve1 (equate_with_pattern_core pat), gs ← get_goals, set_goals $ congr_subgoals ++ gs
def
tactic.equate_with_pattern
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
`equate_with_pattern pat` solves a single goal of the form `lhs = rhs` (assuming that `lhs` and `rhs` are unifiable with `pat`) by applying congruence lemmas until `pat` is a metavariable. The subgoals for the leafs are prepended to the goals.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
congrm (arg : parse texpr) : tactic unit
do try $ applyc ``_root_.eq.to_iff, `(@eq %%ty _ _) ← target | fail "congrm: goal must be an equality or iff", ta ← to_expr ``((%%arg : %%ty)) tt ff, equate_with_pattern ta
def
tactic.interactive.congrm
tactic
src/tactic/congrm.lean
[ "tactic.interactive" ]
[]
Assume that the goal is of the form `lhs = rhs` or `lhs ↔ rhs`. `congrm e` takes an expression `e` containing placeholders `_` and scans `e, lhs, rhs` in parallel. It matches both `lhs` and `rhs` to the pattern `e`, and produces one goal for each placeholder, stating that the corresponding subexpressions in `lhs` and ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
refl_conv (e : expr) : tactic (expr × expr)
do p ← mk_eq_refl e, return (e, p)
def
tactic.refl_conv
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Reflexivity conversion: given `e` returns `(e, ⊢ e = e)`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
or_refl_conv (tac : expr → tactic (expr × expr)) (e : expr) : tactic (expr × expr)
tac e <|> refl_conv e
def
tactic.or_refl_conv
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Turns a conversion tactic into one that always succeeds, where failure is interpreted as a proof by reflexivity.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
trans_conv (t₁ t₂ : expr → tactic (expr × expr)) (e : expr) : tactic (expr × expr)
(do (e₁, p₁) ← t₁ e, (do (e₂, p₂) ← t₂ e₁, p ← mk_eq_trans p₁ p₂, return (e₂, p)) <|> return (e₁, p₁)) <|> t₂ e
def
tactic.trans_conv
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Transitivity conversion: given two conversions (which take an expression `e` and returns `(e', ⊢ e = e')`), produces another conversion that combines them with transitivity, treating failures as reflexivity conversions.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_nat (α : expr) : ℕ → tactic expr
nat.binary_rec (tactic.mk_mapp ``has_zero.zero [some α, none]) (λ b n tac, if n = 0 then mk_mapp ``has_one.one [some α, none] else do e ← tac, tactic.mk_app (cond b ``bit1 ``bit0) [e])
def
expr.of_nat
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Given an expr `α` representing a type with numeral structure, `of_nat α n` creates the `α`-valued numeral expression corresponding to `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_int (α : expr) : ℤ → tactic expr
| (n : ℕ) := expr.of_nat α n | -[1+ n] := do e ← expr.of_nat α (n+1), tactic.mk_app ``has_neg.neg [e]
def
expr.of_int
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "expr.of_nat" ]
Given an expr `α` representing a type with numeral structure, `of_int α n` creates the `α`-valued numeral expression corresponding to `n`. The output is either a numeral or the negation of a numeral.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
of_list (α : expr) : list expr → tactic expr
| [] := tactic.mk_app ``list.nil [α] | (x :: xs) := do exs ← of_list xs, tactic.mk_app ``list.cons [α, x, exs]
def
expr.of_list
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Convert a list of expressions to an expression denoting the list of those expressions.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_exists_lst (args : list expr) (inner : expr) : tactic expr
args.mfoldr (λarg i:expr, do t ← infer_type arg, sort l ← infer_type t, return $ if arg.occurs i ∨ l ≠ level.zero then (const `Exists [l] : expr) t (i.lambdas [arg]) else (const `and [] : expr) t i) inner
def
expr.mk_exists_lst
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Generates an expression of the form `∃(args), inner`. `args` is assumed to be a list of local constants. When possible, `p ∧ q` is used instead of `∃(_ : p), q`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
traverse {m : Type → Type u} [applicative m] {elab elab' : bool} (f : expr elab → m (expr elab')) : expr elab → m (expr elab')
| (var v) := pure $ var v | (sort l) := pure $ sort l | (const n ls) := pure $ const n ls | (mvar n n' e) := mvar n n' <$> f e | (local_const n n' bi e) := local_const n n' bi <$> f e | (app e₀ e₁) := app <$> f e₀ <*> f e₁ | (lam n bi e₀ e₁) := lam n bi <$> f e₀ <*> f e₁ | (pi n bi e₀ e₁) := pi n bi <$> f e₀ <*...
def
expr.traverse
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "list.traverse" ]
`traverse f e` applies the monadic function `f` to the direct descendants of `e`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mfoldl {α : Type} {m} [monad m] (f : α → expr → m α) : α → expr → m α
| x e := prod.snd <$> (state_t.run (e.traverse $ λ e', (get >>= monad_lift ∘ flip f e' >>= put) $> e') x : m _)
def
expr.mfoldl
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`mfoldl f a e` folds the monadic function `f` over the subterms of the expression `e`, with initial value `a`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
kreplace (e old new : expr) (md := semireducible) (unify := tt) : tactic expr
do e ← kabstract e old md unify, pure $ e.instantiate_var new
def
expr.kreplace
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`kreplace e old new` replaces all occurrences of the expression `old` in `e` with `new`. The occurrences of `old` in `e` are determined using keyed matching with transparency `md`; see `kabstract` for details. If `unify` is true, we may assign metavariables in `e` as we match subterms of `e` against `old`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
contains_sorry_aux (pre : name) : name → tactic bool | nm
do env ← get_env, decl ← get_decl nm, ff ← return decl.value.contains_sorry | return tt, (decl.value.list_names_with_prefix pre).mfold ff $ λ n b, if b then return tt else n.contains_sorry_aux
def
name.contains_sorry_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`pre.contains_sorry_aux nm` checks whether `sorry` occurs in the value of the declaration `nm` or (recusively) in any declarations occurring in the value of `nm` with namespace `pre`. Auxiliary function for `name.contains_sorry`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
contains_sorry (nm : name) : tactic bool
nm.contains_sorry_aux nm
def
name.contains_sorry
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`nm.contains_sorry` checks whether `sorry` occurs in the value of the declaration `nm` or in any declarations `nm._proof_i` (or to be more precise: any declaration in namespace `nm`). See also `expr.contains_sorry`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_state : interaction_monad σ σ
λ state, success state state
def
interaction_monad.get_state
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
set_state (state : σ) : interaction_monad σ unit
λ _, success () state
def
interaction_monad.set_state
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
run_with_state (state : σ) (tac : interaction_monad σ α) : interaction_monad σ α
λ s, match tac state with | success val _ := success val s | exception fn pos _ := exception fn pos s end
def
interaction_monad.run_with_state
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`run_with_state state tac` applies `tac` to the given state `state` and returns the result, subsequently restoring the original state. If `tac` fails, then `run_with_state` does too.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
join' (xs : list format) : format
xs.foldl compose nil
def
format.join'
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`join' [a,b,c]` produces the format object `abc`. It differs from `format.join` by using `format.nil` instead of `""` for the empty list.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
intercalate (x : format) : list format → format
join' ∘ list.intersperse x
def
format.intercalate
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`intercalate x [a, b, c]` produces the format object `a.x.b.x.c`, where `.` represents `format.join`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
soft_break : format
group line
def
format.soft_break
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "group" ]
`soft_break` is similar to `line`. Whereas in `group (x ++ line ++ y ++ line ++ z)` the result either fits on one line or in three, `x ++ soft_break ++ y ++ soft_break ++ z` each line break is decided independently
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
comma_separated {α : Type*} [has_to_format α] : list α → format
| [] := nil | xs := group (nest 1 $ intercalate ("," ++ soft_break) $ xs.map to_fmt)
def
format.comma_separated
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[ "group" ]
Format a list as a comma separated list, without any brackets.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list.to_line_wrap_format {α : Type u} [has_to_format α] (l : list α) : format
bracket "[" "]" (comma_separated l)
def
list.to_line_wrap_format
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
format a `list` by separating elements with `soft_break` instead of `line`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_local_consts_as_local_hyps_aux : list (expr × expr) → list expr → tactic (list (expr × expr))
| mappings [] := return mappings | mappings (var :: rest) := do /- Determine if `var` contains any local variables in the lift `rest`. -/ let is_dependent := var.local_type.fold ff $ λ e n b, if b then b else e ∈ rest, /- If so, then skip it---add it to the end of the variable queue. -/ if is_dependent the...
def
tactic.add_local_consts_as_local_hyps_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Private work function for `add_local_consts_as_local_hyps`: given `mappings : list (expr × expr)` corresponding to pairs `(var, hyp)` of variables and the local hypothesis created as a result and `(var :: rest) : list expr` of more local variables we examine `var` to see if it contains any other variables i...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_local_consts_as_local_hyps (vars : list expr) : tactic (list (expr × expr))
/- The `list.reverse` below is a performance optimisation since the list of available variables reported by the system is often mostly the reverse of the order in which they are dependent. -/ add_local_consts_as_local_hyps_aux [] vars.reverse.dedup
def
tactic.add_local_consts_as_local_hyps
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`add_local_consts_as_local_hyps vars` add the given list `vars` of `expr.local_const`s to the tactic state. This is harder than it sounds, since the list of local constants which we have been passed can have dependencies between their types. For example, suppose we have two local constants `n : ℕ` and `h :...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_expl_pi_arity_aux : expr → tactic nat
| (expr.pi n bi d b) := do m ← mk_fresh_name, let l := expr.local_const m n bi d, new_b ← whnf (expr.instantiate_var b l), r ← get_expl_pi_arity_aux new_b, if bi = binder_info.default then return (r + 1) else return r | e := return 0
def
tactic.get_expl_pi_arity_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_expl_pi_arity (type : expr) : tactic nat
whnf type >>= get_expl_pi_arity_aux
def
tactic.get_expl_pi_arity
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Compute the arity of explicit arguments of `type`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_expl_arity (fn : expr) : tactic nat
infer_type fn >>= get_expl_pi_arity
def
tactic.get_expl_arity
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
Compute the arity of explicit arguments of `fn`'s type.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_app_fn_args_whnf_aux (md : transparency) (unfold_ginductive : bool) : list expr → expr → tactic (expr × list expr)
λ args e, do e ← whnf e md unfold_ginductive, match e with | (expr.app t u) := get_app_fn_args_whnf_aux (u :: args) t | _ := pure (e, args) end
def
tactic.get_app_fn_args_whnf_aux
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_app_fn_args_whnf (e : expr) (md := semireducible) (unfold_ginductive := tt) : tactic (expr × list expr)
get_app_fn_args_whnf_aux md unfold_ginductive [] e
def
tactic.get_app_fn_args_whnf
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
For `e = f x₁ ... xₙ`, `get_app_fn_args_whnf e` returns `(f, [x₁, ..., xₙ])`. `e` is normalised as necessary; for example: ``` get_app_fn_args_whnf `(let f := g x in f y) = (`(g), [`(x), `(y)]) ``` The returned expression is in whnf, but the arguments are generally not.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_app_fn_whnf : expr → opt_param _ semireducible → opt_param _ tt → tactic expr
| e md unfold_ginductive := do e ← whnf e md unfold_ginductive, match e with | (expr.app f _) := get_app_fn_whnf f md unfold_ginductive | _ := pure e end
def
tactic.get_app_fn_whnf
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`get_app_fn_whnf e md unfold_ginductive` is like `expr.get_app_fn e` but `e` is normalised as necessary (with transparency `md`). `unfold_ginductive` controls whether constructors of generalised inductive types are unfolded. The returned expression is in whnf.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_app_fn_const_whnf (e : expr) (md := semireducible) (unfold_ginductive := tt) : tactic name
do f ← get_app_fn_whnf e md unfold_ginductive, match f with | (expr.const n _) := pure n | _ := fail format! "expected a constant (possibly applied to some arguments), but got:\n{e}" end
def
tactic.get_app_fn_const_whnf
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`get_app_fn_const_whnf e md unfold_ginductive` expects that `e = C x₁ ... xₙ`, where `C` is a constant, after normalisation with transparency `md`. If so, the name of `C` is returned. Otherwise the tactic fails. `unfold_ginductive` controls whether constructors of generalised inductive types are unfolded.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_app_args_whnf (e : expr) (md := semireducible) (unfold_ginductive := tt) : tactic (list expr)
prod.snd <$> get_app_fn_args_whnf e md unfold_ginductive
def
tactic.get_app_args_whnf
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`get_app_args_whnf e md unfold_ginductive` is like `expr.get_app_args e` but `e` is normalised as necessary (with transparency `md`). `unfold_ginductive` controls whether constructors of generalised inductive types are unfolded. The returned expressions are not necessarily in whnf.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pis : list expr → expr → tactic expr
| (e@(expr.local_const uniq pp info _) :: es) f := do t ← infer_type e, f' ← pis es f, pure $ expr.pi pp info t (expr.abstract_local f' uniq) | _ f := pure f
def
tactic.pis
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`pis loc_consts f` is used to create a pi expression whose body is `f`. `loc_consts` should be a list of local constants. The function will abstract these local constants from `f` and bind them with pi binders. For example, if `a, b` are local constants with types `Ta, Tb`, ``pis [a, b] `(f a b)`` will return the expr...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
lambdas : list expr → expr → tactic expr
| (e@(expr.local_const uniq pp info _) :: es) f := do t ← infer_type e, f' ← lambdas es f, pure $ expr.lam pp info t (expr.abstract_local f' uniq) | _ f := pure f
def
tactic.lambdas
tactic
src/tactic/core.lean
[ "control.basic", "data.dlist.basic", "meta.expr", "system.io", "tactic.binder_matching", "tactic.interactive_expr", "tactic.lean_core_docs", "tactic.project_dir" ]
[]
`lambdas loc_consts f` is used to create a lambda expression whose body is `f`. `loc_consts` should be a list of local constants. The function will abstract these local constants from `f` and bind them with lambda binders. For example, if `a, b` are local constants with types `Ta, Tb`, ``lambdas [a, b] `(f a b)`` will...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83