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 |
|---|---|---|---|---|---|---|---|---|---|---|
pow_pf_sum {ps psqqs : α} {qqs q qs : ℕ} : qqs = q + qs →
ps ^ q * ps ^ qs = psqqs → ps ^ qqs = psqqs | λ qqs_pf psqqs_pf, calc
ps ^ qqs = ps ^ (q + qs) : by rw [qqs_pf]
... = ps ^ q * ps ^ qs : pow_add _ _ _
... = psqqs : psqqs_pf | lemma | tactic.ring_exp.pow_pf_sum | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"pow_add"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow : ex sum → ex sum → ring_exp_m (ex sum) | | ps qs@(ex.zero qs_i) := do
o ← ex_one,
o_o ← pow_orig ps qs,
pf ← mk_proof ``pow_pf_zero [ps.orig, qs.orig] [qs.info],
prod_to_sum $ o.set_info o_o pf
| ps qqs@(ex.sum qqs_i q qs) := do
psq ← pow_p ps q,
psqs ← pow ps qs,
psqqs ← mul psq psqs,
psqqs_o ← pow_orig ps qqs,
pf ← mk_proof ``pow_pf_sum
... | def | tactic.ring_exp.pow | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Exponentiate two expressions.
* `ps ^ 0 = 1`
* `ps ^ (q + qs) = ps ^ q * ps ^ qs` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simple_pf_sum_zero {p p' : α} : p = p' → p + 0 = p' | by simp | lemma | tactic.ring_exp.simple_pf_sum_zero | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
simple_pf_prod_one {p p' : α} : p = p' → p * 1 = p' | by simp | lemma | tactic.ring_exp.simple_pf_prod_one | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
simple_pf_prod_neg_one {α} [ring α] {p p' : α} : p = p' → p * -1 = - p' | by simp | lemma | tactic.ring_exp.simple_pf_prod_neg_one | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"ring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
simple_pf_var_one (p : α) : p ^ 1 = p | by simp | lemma | tactic.ring_exp.simple_pf_var_one | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
simple_pf_exp_one {p p' : α} : p = p' → p ^ 1 = p' | by simp | lemma | tactic.ring_exp.simple_pf_exp_one | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
ex.simple : Π {et : ex_type}, ex et → ring_exp_m (expr × expr) | | sum pps@(ex.sum pps_i p (ex.zero _)) := do
(p_p, p_pf) ← p.simple,
prod.mk p_p <$> mk_app_csr ``simple_pf_sum_zero [p.pretty, p_p, p_pf]
| sum (ex.sum pps_i p ps) := do
(p_p, p_pf) ← p.simple,
(ps_p, ps_pf) ← ps.simple,
prod.mk
<$> mk_add [p_p, ps_p]
<*> mk_app_csr ``sum_congr [p.pretty, p_p, ps.pre... | def | tactic.ring_exp.ex.simple | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp",
"lift"
] | Give a simpler, more human-readable representation of the normalized expression.
Normalized expressions might have the form `a^1 * 1 + 0`,
since the dummy operations reduce special cases in pattern-matching.
Humans prefer to read `a` instead.
This tactic gets rid of the dummy additions, multiplications and exponentiat... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
resolve_atom_aux (a : expr) : list atom → ℕ → ring_exp_m (atom × list atom) | | [] n := let atm : atom := ⟨a, n⟩ in pure (atm, [atm])
| bas@(b :: as) n := do
ctx ← get_context,
(lift $ is_def_eq a b.value ctx.transp >> pure (b , bas)) <|> do
(atm, as') ← resolve_atom_aux as (succ n),
pure (atm, b :: as') | def | tactic.ring_exp.resolve_atom_aux | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Performs a lookup of the atom `a` in the list of known atoms,
or allocates a new one.
If `a` is not definitionally equal to any of the list's entries,
a new atom is appended to the list and returned.
The index of this atom is kept track of in the second inductive argument.
This function is mostly useful in `resolve_a... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
resolve_atom (a : expr) : ring_exp_m atom | do
atoms ← reader_t.lift $ state_t.get,
(atm, atoms') ← resolve_atom_aux a atoms 0,
reader_t.lift $ state_t.put atoms',
pure atm | def | tactic.ring_exp.resolve_atom | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Convert the expression to an atom:
either look up a definitionally equal atom,
or allocate it as a new atom.
You probably want to use `eval_base` if `eval` doesn't work
instead of directly calling `resolve_atom`,
since `eval_base` can also handle numerals. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_base (ps : expr) : ring_exp_m (ex sum) | match ps.to_rat with
| some ⟨0, 1, _, _⟩ := ex_zero
| some x := ex_coeff x >>= prod_to_sum
| none := do
a ← resolve_atom ps,
atom_to_sum a
end | def | tactic.ring_exp.eval_base | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Treat the expression atomically: as a coefficient or atom.
Handles cases where `eval` cannot treat the expression as a known operation
because it is just a number or single variable. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
negate_pf {α} [ring α] {ps ps' : α} : (-1) * ps = ps' → -ps = ps' | by simp | lemma | tactic.ring_exp.negate_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"ring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
negate (ps : ex sum) : ring_exp_m (ex sum) | do
ctx ← get_context,
match ctx.info_b.ring_instance with
| none := lift $ fail "internal error: negate called in semiring"
| (some ring_instance) := do
minus_one ← ex_coeff (-1) >>= prod_to_sum,
ps' ← mul minus_one ps,
ps_pf ← ps'.proof_term,
pf ← mk_app_class ``negate_pf ring_instance [ps.orig... | def | tactic.ring_exp.negate | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Negate an expression by multiplying with `-1`.
Only works if there is a `ring` instance; otherwise it will `fail`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
inverse_pf {α} [division_ring α] {ps ps_u ps_p e' e'' : α} :
ps = ps_u → ps_u = ps_p → ps_p ⁻¹ = e' → e' = e'' → ps ⁻¹ = e'' | by cc | lemma | tactic.ring_exp.inverse_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"division_ring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
inverse (ps : ex sum) : ring_exp_m (ex sum) | do
ctx ← get_context,
dri ← match ctx.info_b.dr_instance with
| none := lift $ fail "division is only supported in a division ring"
| (some dri) := pure dri
end,
(ps_simple, ps_simple_pf) ← ps.simple,
e ← lift $ mk_app ``has_inv.inv [ps_simple],
(e', e_pf) ← lift (norm_num.derive e) <|> ((λ e_pf, (e, e_... | def | tactic.ring_exp.inverse | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift",
"norm_num.derive"
] | Invert an expression by simplifying, applying `has_inv.inv` and treating the result as an atom.
Only works if there is a `division_ring` instance; otherwise it will `fail`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
sub_pf {α} [ring α] {ps qs psqs : α} (h : ps + -qs = psqs) : ps - qs = psqs | by rwa sub_eq_add_neg | lemma | tactic.ring_exp.sub_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"ring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
div_pf {α} [division_ring α] {ps qs psqs : α} (h : ps * qs⁻¹ = psqs) : ps / qs = psqs | by rwa div_eq_mul_inv | lemma | tactic.ring_exp.div_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"div_eq_mul_inv",
"division_ring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
eval : expr → ring_exp_m (ex sum) | | e@`(%%ps + %%qs) := do
ps' ← eval ps,
qs' ← eval qs,
add ps' qs'
| ps_o@`(nat.succ %%p_o) := do
ps' ← eval `(%%p_o + 1),
pf ← lift $ mk_app ``nat.succ_eq_add_one [p_o],
rewrite ps_o ps' pf
| e@`(%%ps - %%qs) := (do
ctx ← get_context,
ri ← match ctx.info_b.ring_instance with
| none := lift $ fail "su... | def | tactic.ring_exp.eval | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Compute a normalized form (of type `ex`) from an expression (of type `expr`).
This is the main driver of the `ring_exp` tactic,
calling out to `add`, `mul`, `pow`, etc. to parse the `expr`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_with_proof (e : expr) : ring_exp_m (ex sum × expr) | do
e' ← eval e,
prod.mk e' <$> e'.proof_term | def | tactic.ring_exp.eval_with_proof | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Run `eval` on the expression and return the result together with normalization proof.
See also `eval_simple` if you want something that behaves like `norm_num`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_simple (e : expr) : ring_exp_m (expr × expr) | do
(complicated, complicated_pf) ← eval_with_proof e,
(simple, simple_pf) ← complicated.simple,
prod.mk simple <$> lift (mk_eq_trans complicated_pf simple_pf) | def | tactic.ring_exp.eval_simple | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Run `eval` on the expression and simplify the result.
Returns a simplified normalized expression, together with an equality proof.
See also `eval_with_proof` if you just want to check the equality of two expressions. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
make_eval_info (α : expr) : tactic eval_info | do
u ← mk_meta_univ,
infer_type α >>= unify (expr.sort (level.succ u)),
u ← get_univ_assignment u,
csr_instance ← mk_app ``comm_semiring [α] >>= mk_instance,
ring_instance ← (some <$> (mk_app ``ring [α] >>= mk_instance) <|> pure none),
dr_instance ← (some <$> (mk_app ``division_ring [α] >>= mk_instance) <|>... | def | tactic.ring_exp.make_eval_info | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"comm_semiring",
"division_ring",
"monoid.has_pow",
"ring"
] | Compute the `eval_info` for a given type `α`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
run_ring_exp {α} (transp : transparency) (e : expr) (mx : ring_exp_m α) : tactic α | do
info_b ← infer_type e >>= make_eval_info,
info_e ← mk_const ``nat >>= make_eval_info,
(λ x : (_ × _), x.1) <$> (state_t.run (reader_t.run mx ⟨info_b, info_e, transp⟩) []) | def | tactic.ring_exp.run_ring_exp | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Use `e` to build the context for running `mx`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
normalize (transp : transparency) (e : expr) : tactic (expr × expr) | do
(_, e', pf') ← ext_simplify_core () {}
simp_lemmas.mk (λ _, failed) (λ _ _ _ _ e, do
(e'', pf) ← run_ring_exp transp e $ eval_simple e,
guard (¬ e'' =ₐ e),
return ((), e'', some pf, ff))
(λ _ _ _ _ _, failed) `eq e,
pure (e', pf') | def | tactic.ring_exp.normalize | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"normalize"
] | Repeatedly apply `eval_simple` on (sub)expressions. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ring_exp_eq (red : parse (tk "!")?) : tactic unit | do
`(eq %%ps %%qs) ← target >>= whnf,
let transp := if red.is_some then semireducible else reducible,
((ps', ps_pf), (qs', qs_pf)) ← run_ring_exp transp ps $
prod.mk <$> eval_with_proof ps <*> eval_with_proof qs,
if ps'.eq qs'
then do
qs_pf_inv ← mk_eq_symm qs_pf,
pf ← mk_eq_trans ps_pf qs_pf_i... | def | tactic.interactive.ring_exp_eq | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Tactic for solving equations of *commutative* (semi)rings,
allowing variables in the exponent.
This version of `ring_exp` fails if the target is not an equality.
The variant `ring_exp_eq!` will use a more aggressive reducibility setting
to determine equality of atoms. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ring_exp (red : parse (tk "!")?) (loc : parse location) : tactic unit | match loc with
| interactive.loc.ns [none] := ring_exp_eq red
| _ := failed
end <|>
do ns ← loc.get_locals,
let transp := if red.is_some then semireducible else reducible,
tt ← tactic.replace_at (normalize transp) ns loc.include_goal
| fail "ring_exp failed to simplify",
when loc.include_goal $ try tact... | def | tactic.interactive.ring_exp | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"normalize",
"tactic.replace_at"
] | Tactic for evaluating expressions in *commutative* (semi)rings, allowing for variables in the
exponent.
This tactic extends `ring`: it should solve every goal that `ring` can solve.
Additionally, it knows how to evaluate expressions with complicated exponents
(where `ring` only understands constant exponents).
The var... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ring_exp (red : parse (lean.parser.tk "!")?) : conv unit | let transp := if red.is_some then semireducible else reducible in
discharge_eq_lhs (ring_exp_eq red)
<|> replace_lhs (normalize transp)
<|> fail "ring_exp failed to simplify" | def | conv.interactive.ring_exp | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"normalize"
] | Normalises expressions in commutative (semi-)rings inside of a `conv` block using the tactic
`ring_exp`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
closure | ref (expr_map (ℕ ⊕ (expr × expr))) | def | tactic.closure | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | `closure` implements a disjoint set data structure using path compression
optimization. For the sake of the scc algorithm, it also stores the preorder
numbering of the equivalence graph of the local assumptions.
The `expr_map` encodes a directed forest by storing for every non-root
node, a reference to its parent and ... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
with_new_closure {α} : (closure → tactic α) → tactic α | using_new_ref (expr_map.mk _) | def | tactic.closure.with_new_closure | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | `with_new_closure f` creates an empty `closure` `c`, executes `f` on `c`, and then deletes `c`,
returning the output of `f`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
to_tactic_format (cl : closure) : tactic format | do m ← read_ref cl,
let l := m.to_list,
fmt ← l.mmap $ λ ⟨x,y⟩, match y with
| sum.inl y := pformat!"{x} ⇐ {y}"
| sum.inr ⟨y,p⟩ := pformat!"({x}, {y}) : {infer_type p}"
end,
pure $ to_fmt fmt | def | tactic.closure.to_tactic_format | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | `to_tactic_format cl` pretty-prints the `closure` `cl` as a list. Assuming `cl` was built by
`dfs_at`, each element corresponds to a node `pᵢ : expr` and is one of the folllowing:
- if `pᵢ` is a root: `"pᵢ ⇐ i"`, where `i` is the preorder number of `pᵢ`,
- otherwise: `"(pᵢ, pⱼ) : P"`, where `P` is `pᵢ ↔ pⱼ`.
Useful for... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
root (cl : closure) : expr → tactic (ℕ × expr × expr) | e | do m ← read_ref cl,
match m.find e with
| none :=
do p ← mk_app ``iff.refl [e],
pure (0,e,p)
| (some (sum.inl n)) :=
do p ← mk_app ``iff.refl [e],
pure (n,e,p)
| (some (sum.inr (e₀,p₀))) :=
do (n,e₁,p₁) ← root e₀,
p ← mk_app ``iff.trans [p₀,p₁],
modify_ref cl $... | def | tactic.closure.root | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | `(n,r,p) ← root cl e` returns `r` the root of the tree that `e` is a part of (which might be
itself) along with `p` a proof of `e ↔ r` and `n`, the preorder numbering of the root. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
merge_intl (cl : closure) (p e₀ p₀ e₁ p₁ : expr) : tactic unit | do p₂ ← mk_app ``iff.symm [p₀],
p ← mk_app ``iff.trans [p₂,p],
p ← mk_app ``iff.trans [p,p₁],
modify_ref cl $ λ m, m.insert e₀ $ sum.inr (e₁,p) | def | tactic.closure.merge_intl | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | (Implementation of `merge`.) | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
merge (cl : closure) (p : expr) : tactic unit | do `(%%e₀ ↔ %%e₁) ← infer_type p >>= instantiate_mvars,
(n₂,e₂,p₂) ← root cl e₀,
(n₃,e₃,p₃) ← root cl e₁,
if e₂ ≠ e₃ then do
if n₂ < n₃ then do p ← mk_app ``iff.symm [p],
cl.merge_intl p e₃ p₃ e₂ p₂
else cl.merge_intl p e₂ p₂ e₃ p₃
else pure () | def | tactic.closure.merge | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | `merge cl p`, with `p` a proof of `e₀ ↔ e₁` for some `e₀` and `e₁`,
merges the trees of `e₀` and `e₁` and keeps the root with the smallest preorder
number as the root. This ensures that, in the depth-first traversal of the graph,
when encountering an edge going into a vertex whose equivalence class includes
a vertex th... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
assign_preorder (cl : closure) (e : expr) : tactic unit | modify_ref cl $ λ m, m.insert e (sum.inl m.size) | def | tactic.closure.assign_preorder | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | Sequentially assign numbers to the nodes of the graph as they are being visited. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_eqv (cl : closure) (e₀ e₁ : expr) : tactic expr | do (_,r,p₀) ← root cl e₀,
(_,r',p₁) ← root cl e₁,
guard (r = r') <|> fail!"{e₀} and {e₁} are not equivalent",
p₁ ← mk_app ``iff.symm [p₁],
mk_app ``iff.trans [p₀,p₁] | def | tactic.closure.prove_eqv | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | `prove_eqv cl e₀ e₁` constructs a proof of equivalence of `e₀` and `e₁` if
they are equivalent. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_impl (cl : closure) (e₀ e₁ : expr) : tactic expr | cl.prove_eqv e₀ e₁ >>= iff_mp | def | tactic.closure.prove_impl | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | `prove_impl cl e₀ e₁` constructs a proof of `e₀ -> e₁` if they are equivalent. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
is_eqv (cl : closure) (e₀ e₁ : expr) : tactic bool | do (_,r,p₀) ← root cl e₀,
(_,r',p₁) ← root cl e₁,
return $ r = r' | def | tactic.closure.is_eqv | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | `is_eqv cl e₀ e₁` checks whether `e₀` and `e₁` are equivalent without building a proof. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
impl_graph | ref (expr_map (list $ expr × expr)) | def | tactic.impl_graph | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [] | mutable graphs between local propositions that imply each other with the proof of implication | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
with_impl_graph {α} : (impl_graph → tactic α) → tactic α | using_new_ref (expr_map.mk (list $ expr × expr)) | def | tactic.with_impl_graph | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [] | `with_impl_graph f` creates an empty `impl_graph` `g`, executes `f` on `g`, and then deletes
`g`, returning the output of `f`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
add_edge (g : impl_graph) : expr → tactic unit | p | do t ← infer_type p,
match t with
| `(%%v₀ → %%v₁) :=
do is_prop v₀ >>= guardb,
is_prop v₁ >>= guardb,
m ← read_ref g,
let xs := (m.find v₀).get_or_else [],
let xs' := (m.find v₁).get_or_else [],
modify_ref g $ λ m, (m.insert v₀ ((v₁,p) :: xs)).insert v₁ xs'
| `(%%v... | def | tactic.impl_graph.add_edge | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [] | `add_edge g p`, with `p` a proof of `v₀ → v₁` or `v₀ ↔ v₁`, adds an edge to the implication
graph `g`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
merge_path (path : list (expr × expr)) (e : expr) : tactic unit | do p₁ ← cl.prove_impl e path.head.fst,
p₂ ← mk_mapp ``id [e],
let path := (e,p₁) :: path,
(_,ls) ← path.mmap_accuml (λ p p',
prod.mk <$> mk_mapp ``implies.trans [none,p'.1,none,p,p'.2] <*> pure p) p₂,
(_,rs) ← path.mmap_accumr (λ p p',
prod.mk <$> mk_mapp ``implies.trans [none,none,none,p.2,p'] <... | def | tactic.impl_graph.merge_path | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"mzip_with",
"path"
] | `merge_path path e`, where `path` and `e` forms a cycle with proofs of implication between
consecutive vertices. The proofs are compiled into proofs of equivalences and added to the closure
structure. `e` and the first vertex of `path` do not have to be the same but they have to be
in the same equivalence class. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
collapse' : list (expr × expr) → list (expr × expr) → expr → tactic unit | | acc [] v := merge_path acc v
| acc ((x,pr) :: xs) v :=
do b ← cl.is_eqv x v,
let acc' := (x,pr)::acc,
if b
then merge_path acc' v
else collapse' acc' xs v | def | tactic.impl_graph.collapse' | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [] | (implementation of `collapse`) | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
collapse : list (expr × expr) → expr → tactic unit | collapse' [] | def | tactic.impl_graph.collapse | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [] | `collapse path v`, where `v` is a vertex that originated the current search
(or a vertex in the same equivalence class as the one that originated the current search).
It or its equivalent should be found in `path`. Since the vertices following `v` in the path
form a cycle with `v`, they can all be added to an equivalen... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
dfs_at :
list (expr × expr) → expr → tactic unit | | vs v :=
do m ← read_ref visit,
(_,v',_) ← cl.root v,
match m.find v' with
| (some tt) :=
pure ()
| (some ff) :=
collapse vs v
| none :=
do cl.assign_preorder v,
modify_ref visit $ λ m, m.insert v ff,
ns ← g.find v,
ns.mmap' $ λ ⟨w,e⟩, dfs_at ((v,e) :: vs) w,... | def | tactic.impl_graph.dfs_at | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [] | Strongly connected component algorithm inspired by Tarjan's and
Dijkstra's scc algorithm. Whereas they return strongly connected
components by enumerating them, this algorithm returns a disjoint set
data structure using path compression. This is a compact
representation that allows us, after the fact, to construct a pr... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_scc (cl : closure) : tactic (expr_map (list (expr × expr))) | with_impl_graph $ λ g,
using_new_ref (expr_map.mk bool) $ λ visit,
do ls ← local_context,
ls.mmap' $ λ l, try (g.add_edge l),
m ← read_ref g,
m.to_list.mmap $ λ ⟨v,_⟩, impl_graph.dfs_at m visit cl [] v,
pure m | def | tactic.impl_graph.mk_scc | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | Use the local assumptions to create a set of equivalence classes. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_eqv_target (cl : closure) : tactic unit | do `(%%p ↔ %%q) ← target >>= whnf,
cl.prove_eqv p q >>= exact | def | tactic.prove_eqv_target | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [
"closure"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
interactive.scc : tactic unit | closure.with_new_closure $ λ cl,
do impl_graph.mk_scc cl,
`(%%p ↔ %%q) ← target,
cl.prove_eqv p q >>= exact | def | tactic.interactive.scc | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [] | `scc` uses the available equivalences and implications to prove
a goal of the form `p ↔ q`.
```lean
example (p q r : Prop) (hpq : p → q) (hqr : q ↔ r) (hrp : r → p) : p ↔ r :=
by scc
``` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
interactive.scc' : tactic unit | closure.with_new_closure $ λ cl,
do m ← impl_graph.mk_scc cl,
let ls := m.to_list.map prod.fst,
let ls' := prod.mk <$> ls <*> ls,
ls'.mmap' $ λ x,
do { h ← get_unused_name `h,
try $ closure.prove_eqv cl x.1 x.2 >>= note h none } | def | tactic.interactive.scc' | tactic | src/tactic/scc.lean | [
"tactic.tauto"
] | [] | Collect all the available equivalences and implications and
add assumptions for every equivalence that can be proven using the
strongly connected components technique. Mostly useful for testing. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
show_term (t : itactic) : itactic | do
g :: _ ← get_goals,
t,
g ← tactic_statement g,
trace g | def | tactic.interactive.show_term | tactic | src/tactic/show_term.lean | [
"tactic.core"
] | [
"tactic_statement"
] | `show_term { tac }` runs the tactic `tac`,
and then prints the term that was constructed.
This is useful for
* constructing term mode proofs from tactic mode proofs, and
* understanding what tactics are doing, and how metavariables are handled.
As an example, in
```
example {P Q R : Prop} (h₁ : Q → P) (h₂ : R) (h₃ : ... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simpa (use_iota_eqn : parse $ (tk "!")?) (trace_lemmas : parse $ (tk "?")?)
(no_dflt : parse only_flag) (hs : parse simp_arg_list) (attr_names : parse with_ident_list)
(tgt : parse (tk "using" *> texpr)?) (cfg : simp_config_ext := {}) : tactic unit | let simp_at lc (close_tac : tactic unit) := focus1 $
simp use_iota_eqn trace_lemmas no_dflt hs attr_names (loc.ns lc)
{fail_if_unchanged := ff, ..cfg} >>
(((close_tac <|> trivial) >> done) <|> fail "simpa failed") in
match tgt with
| none := get_local `this >> simp_at [some `this, none] assumption <|> simp_at [... | def | tactic.interactive.simpa | tactic | src/tactic/simpa.lean | [
"tactic.doc_commands"
] | [] | This is a "finishing" tactic modification of `simp`. It has two forms.
* `simpa [rules, ...] using e` will simplify the goal and the type of
`e` using `rules`, then try to close the goal using `e`.
Simplifying the type of `e` makes it more likely to match the goal
(which has also been simplified). This construc... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
projection_data | (name : name)
(expr : expr)
(proj_nrs : list ℕ)
(is_default : bool)
(is_prefix : bool) | structure | projection_data | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [] | Projection data for a single projection of a structure, consisting of the following fields:
- the name used in the generated `simp` lemmas
- an expression used by simps for the projection. It must be definitionally equal to an original
projection (or a composition of multiple projections).
These expressions can con... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
parsed_projection_data | (orig_name : name) -- name for this projection used in the structure definition
(new_name : name) -- name for this projection used in the generated `simp` lemmas
(is_default : bool)
(is_prefix : bool) | structure | parsed_projection_data | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [] | Temporary projection data parsed from `initialize_simps_projections` before the expression
matching this projection has been found. Only used internally in `simps_get_raw_projections`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
projection_rule | (name × name ⊕ name) × bool | abbreviation | projection_rule | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [] | The type of rules that specify how metadata for projections in changes.
See `initialize_simps_projection`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_str_attr :
user_attribute unit (list name × list projection_data) | { name := `_simps_str,
descr := "An attribute specifying the projection of the given structure.",
parser := failed } | def | simps_str_attr | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"projection_data"
] | The `@[_simps_str]` attribute specifies the preferred projections of the given structure,
used by the `@[simps]` attribute.
- This will usually be tagged by the `@[simps]` tactic.
- You can also generate this with the command `initialize_simps_projections`.
- To change the default value, see Note [custom simps projecti... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
notation_class_attr : user_attribute unit (bool × option name) | { name := `notation_class,
descr := "An attribute specifying that this is a notation class. Used by @[simps].",
parser := prod.mk <$> (option.is_none <$> (tk "*")?) <*> ident? } | def | notation_class_attr | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [] | The `@[notation_class]` attribute specifies that this is a notation class,
and this notation should be used instead of projections by @[simps].
* The first argument `tt` for notation classes and `ff` for classes applied to the structure,
like `has_coe_to_sort` and `has_coe_to_fun`
* The second argument is the... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
projections_info (l : list projection_data) (pref : string) (str : name) : tactic format | do
⟨defaults, nondefaults⟩ ← return $ l.partition_map $
λ s, if s.is_default then inl s else inr s,
to_print ← defaults.mmap $ λ s, to_string <$>
let prefix_str := if s.is_prefix then "(prefix) " else "" in
pformat!"Projection {prefix_str}{s.name}: {s.expr}",
let print2 :=
string.join $ (nondefaul... | def | projections_info | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"projection_data"
] | Returns the projection information of a structure. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_composite_of_projections_aux : Π (str : name) (proj : string) (x : expr)
(pos : list ℕ) (args : list expr), tactic (expr × list ℕ) | str proj x pos args | do
e ← get_env,
projs ← e.structure_fields str,
let proj_info := projs.map_with_index $ λ n p, (λ x, (x, n, p)) <$> proj.get_rest ("_" ++ p.last),
when (proj_info.filter_map id = []) $
fail!"Failed to find constructor {proj.popn 1} in structure {str}.",
(proj_rest, index, proj_nm) ← return (proj_info.filt... | def | get_composite_of_projections_aux | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [] | Auxiliary function of `get_composite_of_projections`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_composite_of_projections (str : name) (proj : string) : tactic (expr × list ℕ) | do
e ← get_env,
str_d ← e.get str,
let str_e : expr := const str str_d.univ_levels,
type ← infer_type str_e,
(type_args, tgt) ← open_pis_whnf type,
let str_ap := str_e.mk_app type_args,
x ← mk_local' `x binder_info.default str_ap,
get_composite_of_projections_aux str ("_" ++ proj) x [] $ type_args ++ [x... | def | get_composite_of_projections | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"get_composite_of_projections_aux"
] | Given a structure `str` and a projection `proj`, that could be multiple nested projections
(separated by `_`), returns an expression that is the composition of these projections and a
list of natural numbers, that are the projection numbers of the applied projections. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_get_raw_projections (e : environment) (str : name) (trace_if_exists : bool := ff)
(rules : list projection_rule := []) (trc := ff) :
tactic (list name × list projection_data) | do
let trc := trc || is_trace_enabled_for `simps.verbose,
has_attr ← has_attribute' `_simps_str str,
if has_attr then do
data ← simps_str_attr.get_param str,
-- We always print the projections when they already exists and are called by
-- `initialize_simps_projections`.
when (trace_if_exists || is... | def | simps_get_raw_projections | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"get_composite_of_projections",
"parsed_projection_data",
"projection_data",
"projection_rule",
"projections_info",
"succeeds"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
simps_parse_rule : parser projection_rule | prod.mk <$>
((λ x y, inl (x, y)) <$> ident <*> (tk "->" >> ident) <|> inr <$> (tk "-" >> ident)) <*>
is_some <$> (tk "as_prefix")? | def | simps_parse_rule | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"projection_rule"
] | Parse a rule for `initialize_simps_projections`. It is either `<name>→<name>` or `-<name>`,
possibly following by `as_prefix`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
initialize_simps_projections_cmd
(_ : parse $ tk "initialize_simps_projections") : parser unit | do
env ← get_env,
trc ← is_some <$> (tk "?")?,
ns ← (prod.mk <$> ident <*> (tk "(" >> sep_by (tk ",") simps_parse_rule <* tk ")")?)*,
ns.mmap' $ λ data, do
nm ← resolve_constant data.1,
simps_get_raw_projections env nm tt (data.2.get_or_else []) trc | def | initialize_simps_projections_cmd | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"simps_get_raw_projections",
"simps_parse_rule"
] | This command specifies custom names and custom projections for the simp attribute `simps_attr`.
* You can specify custom names by writing e.g.
`initialize_simps_projections equiv (to_fun → apply, inv_fun → symm_apply)`.
* See Note [custom simps projection] and the examples below for information how to declare custom
... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_cfg | (attrs := [`simp])
(simp_rhs := ff)
(type_md := transparency.instances)
(rhs_md := transparency.none)
(fully_applied := tt)
(not_recursive := [`prod, `pprod])
(trace := ff)
(add_additive := @none name) | structure | simps_cfg | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [] | Configuration options for the `@[simps]` attribute.
* `attrs` specifies the list of attributes given to the generated lemmas. Default: ``[`simp]``.
The attributes can be either basic attributes, or user attributes without parameters.
There are two attributes which `simps` might add itself:
* If ``[`simp]`... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
as_fn : simps_cfg | {fully_applied := ff} | def | as_fn | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"simps_cfg"
] | A common configuration for `@[simps]`: generate equalities between functions instead equalities
between fully applied expressions. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
lemmas_only : simps_cfg | {attrs := []} | def | lemmas_only | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"simps_cfg"
] | A common configuration for `@[simps]`: don't tag the generated lemmas with `@[simp]`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_get_projection_exprs (e : environment) (tgt : expr)
(rhs : expr) (cfg : simps_cfg) : tactic $ list $ expr × projection_data | do
let params := get_app_args tgt, -- the parameters of the structure
(params.zip $ (get_app_args rhs).take params.length).mmap' (λ ⟨a, b⟩, is_def_eq a b)
<|> fail "unreachable code (1)",
let str := tgt.get_app_fn.const_name,
let rhs_args := (get_app_args rhs).drop params.length, -- the fields of the object... | def | simps_get_projection_exprs | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"projection_data",
"simps_cfg",
"simps_get_raw_projections"
] | Get the projections of a structure used by `@[simps]` applied to the appropriate arguments.
Returns a list of tuples
```
(corresponding right-hand-side, given projection name, projection expression, projection numbers,
used by default, is prefix)
```
(where all fields except the first are packed in a `pro... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_add_projection (nm : name) (type lhs rhs : expr) (args : list expr)
(univs : list name) (cfg : simps_cfg) : tactic (list name) | do
when_tracing `simps.debug trace!
"[simps] > Planning to add the equality\n > {lhs} = ({rhs} : {type})",
lvl ← get_univ_level type,
-- simplify `rhs` if `cfg.simp_rhs` is true
(rhs, prf) ← do { guard cfg.simp_rhs,
rhs' ← rhs.dsimp {fail_if_unchanged := ff},
when_tracing `simps.debug $ when ... | def | simps_add_projection | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"set_attribute",
"simps_cfg",
"succeeds"
] | Add a lemma with `nm` stating that `lhs = rhs`. `type` is the type of both `lhs` and `rhs`,
`args` is the list of local constants occurring, and `univs` is the list of universe variables. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_add_projections : Π (e : environment) (nm : name)
(type lhs rhs : expr) (args : list expr) (univs : list name) (must_be_str : bool)
(cfg : simps_cfg) (todo : list string) (to_apply : list ℕ), tactic (list name) | | e nm type lhs rhs args univs must_be_str cfg todo to_apply := do
-- we don't want to unfold non-reducible definitions (like `set`) to apply more arguments
when_tracing `simps.debug trace!
"[simps] > Type of the expression before normalizing: {type}",
(type_args, tgt) ← open_pis_whnf type cfg.type_md,
when... | def | simps_add_projections | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"simps_add_projection",
"simps_cfg",
"simps_get_projection_exprs",
"to_additive.guess_name"
] | Derive lemmas specifying the projections of the declaration.
If `todo` is non-empty, it will generate exactly the names in `todo`.
`to_apply` is non-empty after a custom projection that is a composition of multiple projections
was just used. In that case we need to apply these projections before we continue chang... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_aux : user_attribute unit (list name) | { name := `_simps_aux,
descr := "An attribute specifying the added simps lemmas.",
parser := failed } | def | simps_aux | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [] | The `@[_simps_aux]` attribute specifies which lemmas are added by `simps`.
This should not be used manually and it only exists for mathport | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_tac (nm : name) (cfg : simps_cfg := {}) (todo : list string := []) (trc := ff) :
tactic unit | do
e ← get_env,
d ← e.get nm,
let lhs : expr := const d.to_name d.univ_levels,
let todo := todo.dedup.map $ λ proj, "_" ++ proj,
let cfg := { trace := cfg.trace || is_trace_enabled_for `simps.verbose || trc, ..cfg },
b ← has_attribute' `to_additive nm,
cfg ← if b then do
{ dict ← to_additive.aux_attr.ge... | def | simps_tac | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"simps_add_projections",
"simps_cfg"
] | `simps_tac` derives `simp` lemmas for all (nested) non-Prop projections of the declaration.
If `todo` is non-empty, it will generate exactly the names in `todo`.
If `short_nm` is true, the generated names will only use the last projection name.
If `trc` is true, trace as if `trace.simps.verbose` is true. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_parser : parser (bool × list string × simps_cfg) | do
/- note: we don't check whether the user has written a nonsense namespace in an argument. -/
prod.mk <$> is_some <$> (tk "?")? <*>
(prod.mk <$> many (name.last <$> ident) <*>
(do some e ← parser.pexpr? | return {}, eval_pexpr simps_cfg e)) | def | simps_parser | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"name.last",
"simps_cfg"
] | The parser for the `@[simps]` attribute. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simps_attr : user_attribute unit (bool × list string × simps_cfg) | { name := `simps,
descr := "Automatically derive lemmas specifying the projections of this declaration.",
parser := simps_parser,
after_set := some $
λ n _ persistent, do
guard persistent <|> fail "`simps` currently cannot be used as a local attribute",
(trc, todo, cfg) ← simps_attr.get_param n,
... | def | simps_attr | tactic | src/tactic/simps.lean | [
"tactic.protected",
"tactic.to_additive"
] | [
"simps_cfg",
"simps_parser",
"simps_tac"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
strip_annotations_from_all_non_local_consts {elab : bool} (e : expr elab)
: expr elab | expr.unsafe_cast $ e.unsafe_cast.replace $ λ e n,
match e.is_annotation with
| some (_, expr.local_const _ _ _ _) := none
| some (_, _) := e.erase_annotations
| _ := none
end | def | tactic.strip_annotations_from_all_non_local_consts | tactic | src/tactic/simp_command.lean | [
"tactic.core"
] | [
"expr.unsafe_cast"
] | Strip all annotations of non local constants in the passed `expr`. (This is required in an
incantation later on in order to make the C++ simplifier happy.) | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simp_arg_type.to_pexpr : simp_arg_type → option pexpr | | sat@(simp_arg_type.expr e) := e
| sat@(simp_arg_type.symm_expr e) := e
| sat := none | def | tactic.simp_arg_type.to_pexpr | tactic | src/tactic/simp_command.lean | [
"tactic.core"
] | [] | `simp_arg_type.to_pexpr` retrieves the `pexpr` underlying the given `simp_arg_type`, if there is
one. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
replace_subexprs_for_simp_arg (e : pexpr) (rules : list (expr × expr)) : pexpr | strip_annotations_from_all_non_local_consts $ pexpr.of_expr $ e.unsafe_cast.replace_subexprs rules | def | tactic.replace_subexprs_for_simp_arg | tactic | src/tactic/simp_command.lean | [
"tactic.core"
] | [] | Incantation which prepares a `pexpr` in a `simp_arg_type` for use by the simplifier after
`expr.replace_subexprs` as been called to replace some of its local variables. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simp_arg_type.replace_subexprs : simp_arg_type → list (expr × expr) → simp_arg_type | | (simp_arg_type.expr e) rules :=
simp_arg_type.expr $ replace_subexprs_for_simp_arg e rules
| (simp_arg_type.symm_expr e) rules :=
simp_arg_type.symm_expr $ replace_subexprs_for_simp_arg e rules
| sat rules := sat
setup_tactic_parser
/- Turn off the messages if the result is exactly `true` with thi... | def | tactic.simp_arg_type.replace_subexprs | tactic | src/tactic/simp_command.lean | [
"tactic.core"
] | [] | `simp_arg_type.replace_subexprs` calls `expr.replace_subexprs` on the underlying `pexpr`, if
there is one, and then prepares the result for use by the simplifier. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simp_cmd (_ : parse $ tk "#simp") : lean.parser unit | do
no_dflt ← only_flag,
hs ← simp_arg_list,
attr_names ← with_ident_list,
o ← optional (tk ":"),
e ← types.texpr,
/- Retrieve the `pexpr`s parsed as part of the simp args, and collate them into a big list. -/
let hs_es := list.join $ hs.map $ option.to_list ∘ simp_arg_type.to_pexpr,
/- Synthesize a `t... | def | tactic.simp_cmd | tactic | src/tactic/simp_command.lean | [
"tactic.core"
] | [
"option.to_list"
] | The basic usage is `#simp e`, where `e` is an expression,
which will print the simplified form of `e`.
You can specify additional simp lemmas as usual for example using
`#simp [f, g] : e`, or `#simp with attr : e`.
(The colon is optional, but helpful for the parser.)
`#simp` understands local variables, so you can us... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
intercept_result {α} (m : expr → tactic expr) (t : tactic α) : tactic α | do
-- Replace the goals with copies.
gs ← get_goals,
gs' ← gs.mmap (λ g, infer_type g >>= mk_meta_var),
set_goals gs',
-- Run the tactic on the copied goals.
a ← t,
-- Run `m` on the produced terms,
(gs.zip gs').mmap (λ ⟨g, g'⟩, do
g' ← instantiate_mvars g',
g'' ← with_local_goals' gs $ m g',
-- and assign to the... | def | tactic.intercept_result | tactic | src/tactic/simp_result.lean | [
"tactic.core"
] | [
"with_local_goals'"
] | `intercept_result m t`
attempts to run a tactic `t`,
intercepts any results `t` assigns to the goals,
and runs `m : expr → tactic expr` on each of the expressions
before assigning the returned values to the original goals.
Because `intercept_result` uses `unsafe.type_context.assign` rather than `unify`,
if the tactic ... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
dsimp_result {α} (t : tactic α)
(cfg : dsimp_config := { fail_if_unchanged := ff }) (no_defaults := ff)
(attr_names : list name := []) (hs : list simp_arg_type := []) : tactic α | intercept_result (λ g,
g.dsimp cfg no_defaults attr_names hs) t | def | tactic.dsimp_result | tactic | src/tactic/simp_result.lean | [
"tactic.core"
] | [] | `dsimp_result t`
attempts to run a tactic `t`,
intercepts any results it assigns to the goals,
and runs `dsimp` on those results
before assigning the simplified values to the original goals. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simp_result {α} (t : tactic α)
(cfg : simp_config := { fail_if_unchanged := ff }) (discharger : tactic unit := failed)
(no_defaults := ff) (attr_names : list name := []) (hs : list simp_arg_type := []) : tactic α | intercept_result (λ g, prod.fst <$>
g.simp cfg discharger no_defaults attr_names hs) t | def | tactic.simp_result | tactic | src/tactic/simp_result.lean | [
"tactic.core"
] | [] | `simp_result t`
attempts to run a tactic `t`,
intercepts any results `t` assigns to the goals,
and runs `simp` on those results
before assigning the simplified values to the original goals. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
dsimp_result
(no_defaults : parse only_flag) (hs : parse simp_arg_list)
(attr_names : parse with_ident_list)
(t : itactic) : itactic | tactic.dsimp_result t { fail_if_unchanged := ff } no_defaults attr_names hs | def | tactic.interactive.dsimp_result | tactic | src/tactic/simp_result.lean | [
"tactic.core"
] | [
"tactic.dsimp_result"
] | `dsimp_result { tac }`
attempts to run a tactic block `tac`,
intercepts any results the tactic block would have assigned to the goals,
and runs `dsimp` on those results
before assigning the simplified values to the original goals.
You can use the usual interactive syntax for `dsimp`, e.g.
`dsimp_result only [a, b, c] ... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simp_result
(no_defaults : parse only_flag) (hs : parse simp_arg_list)
(attr_names : parse with_ident_list)
(t : itactic) : itactic | tactic.simp_result t { fail_if_unchanged := ff } failed no_defaults attr_names hs | def | tactic.interactive.simp_result | tactic | src/tactic/simp_result.lean | [
"tactic.core"
] | [
"tactic.simp_result"
] | `simp_result { tac }`
attempts to run a tactic block `tac`,
intercepts any results the tactic block would have assigned to the goals,
and runs `simp` on those results
before assigning the simplified values to the original goals.
You can use the usual interactive syntax for `simp`, e.g.
`simp_result only [a, b, c] with... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
simp_rw (q : parse rw_rules) (l : parse location) : tactic unit | q.rules.mmap' (λ rule, do
let simp_arg := if rule.symm
then simp_arg_type.symm_expr rule.rule
else simp_arg_type.expr rule.rule,
save_info rule.pos,
simp none none tt [simp_arg] [] l) | def | tactic.interactive.simp_rw | tactic | src/tactic/simp_rw.lean | [
"tactic.core"
] | [] | `simp_rw` functions as a mix of `simp` and `rw`. Like `rw`, it applies each
rewrite rule in the given order, but like `simp` it repeatedly applies these
rules and also under binders like `∀ x, ...`, `∃ x, ...` and `λ x, ...`.
Usage:
- `simp_rw [lemma_1, ..., lemma_n]` will rewrite the goal by applying the
lemmas... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
repeat_with_results {α : Type} (t : tactic α) : tactic (list α) | (do r ← t,
s ← repeat_with_results,
return (r :: s)) <|> return [] | def | tactic.repeat_with_results | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
repeat_count {α : Type} (t : tactic α) : tactic ℕ | do r ← repeat_with_results t,
return r.length | def | tactic.repeat_count | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
slice (a b : ℕ) : conv unit | do repeat $ to_expr ``(category.assoc) >>= λ e, tactic.rewrite_target e {symm:=ff},
iterate_range (a-1) (a-1) (do conv.congr, conv.skip),
k ← repeat_count $ to_expr ``(category.assoc) >>= λ e, tactic.rewrite_target e {symm:=tt},
iterate_range (k+1+a-b) (k+1+a-b) conv.congr,
repeat $ to_expr ``(category.asso... | def | conv.slice | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
slice_lhs (a b : ℕ) (t : conv unit) : tactic unit | do conv.interactive.to_lhs,
slice a b,
t | def | conv.slice_lhs | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
slice_rhs (a b : ℕ) (t : conv unit) : tactic unit | do conv.interactive.to_rhs,
slice a b,
t | def | conv.slice_rhs | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
slice | conv.slice | def | conv.interactive.slice | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [
"conv.slice"
] | `slice` is a conv tactic; if the current focus is a composition of several morphisms,
`slice a b` reassociates as needed, and zooms in on the `a`-th through `b`-th morphisms.
Thus if the current focus is `(a ≫ b) ≫ ((c ≫ d) ≫ e)`, then `slice 2 3` zooms to `b ≫ c`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
conv_target' (c : conv unit) : tactic unit | do t ← target,
(new_t, pr) ← c.convert t,
replace_target new_t pr,
try tactic.triv, try (tactic.reflexivity reducible) | def | tactic.conv_target' | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
slice_lhs (a b : parse small_nat) (t : conv.interactive.itactic) : tactic unit | do conv_target' (conv.interactive.to_lhs >> slice a b >> t) | def | tactic.interactive.slice_lhs | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [] | `slice_lhs a b { tac }` zooms to the left hand side, uses associativity for categorical
composition as needed, zooms in on the `a`-th through `b`-th morphisms, and invokes `tac`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
slice_rhs (a b : parse small_nat) (t : conv.interactive.itactic) : tactic unit | do conv_target' (conv.interactive.to_rhs >> slice a b >> t) | def | tactic.interactive.slice_rhs | tactic | src/tactic/slice.lean | [
"category_theory.category.basic"
] | [] | `slice_rhs a b { tac }` zooms to the right hand side, uses associativity for categorical
composition as needed, zooms in on the `a`-th through `b`-th morphisms, and invokes `tac`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
instance_tree
| node : name → expr → list instance_tree → instance_tree | inductive | tactic.interactive.instance_tree | tactic | src/tactic/slim_check.lean | [
"testing.slim_check.testable",
"data.list.sort"
] | [] | Tree structure representing a `testable` instance. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
summarize_instance : expr → tactic instance_tree | | (lam n bi d b) := do
v ← mk_local' n bi d,
summarize_instance $ b.instantiate_var v
| e@(app f x) := do
`(testable %%p) ← infer_type e,
xs ← e.get_app_args.mmap_filter (try_core ∘ summarize_instance),
pure $ instance_tree.node e.get_app_fn.const_name p xs
| e := do
failed | def | tactic.interactive.summarize_instance | tactic | src/tactic/slim_check.lean | [
"testing.slim_check.testable",
"data.list.sort"
] | [] | Gather information about a `testable` instance. Given
an expression of type `testable ?p`, gather the
name of the `testable` instances that it is built from
and the proposition that they test. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
instance_tree.to_format : instance_tree → tactic format | | (instance_tree.node n p xs) := do
xs ← format.join <$> (xs.mmap $ λ t, flip format.indent 2 <$> instance_tree.to_format t),
ys ← pformat!"testable ({p})",
pformat!"+ {n} :{format.indent ys 2}\n{xs}" | def | tactic.interactive.instance_tree.to_format | tactic | src/tactic/slim_check.lean | [
"testing.slim_check.testable",
"data.list.sort"
] | [] | format a `instance_tree` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
instance_tree.has_to_tactic_format : has_to_tactic_format instance_tree | ⟨ instance_tree.to_format ⟩ | instance | tactic.interactive.instance_tree.has_to_tactic_format | tactic | src/tactic/slim_check.lean | [
"testing.slim_check.testable",
"data.list.sort"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
slim_check (cfg : slim_check_cfg := {}) : tactic unit | do
{ tgt ← retrieve $ tactic.revert_all >> target,
let tgt' := tactic.add_decorations tgt,
let cfg := { cfg with
trace_discarded := cfg.trace_discarded
|| is_trace_enabled_for `slim_check.discarded,
trace_shrink := cfg.trace_shrink
|| ... | def | tactic.interactive.slim_check | tactic | src/tactic/slim_check.lean | [
"testing.slim_check.testable",
"data.list.sort"
] | [] | `slim_check` considers a proof goal and tries to generate examples
that would contradict the statement.
Let's consider the following proof goal.
```lean
xs : list ℕ,
h : ∃ (x : ℕ) (H : x ∈ xs), x < 3
⊢ ∀ (y : ℕ), y ∈ xs → y < 5
```
The local constants will be reverted and an instance will be found for
`testable (∀ (... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_assumption_set (no_dflt : bool) (hs : list simp_arg_type) (attr : list name) :
tactic (list (tactic expr) × tactic (list expr)) | -- We lock the tactic state so that any spurious goals generated during
-- elaboration of pre-expressions are discarded
lock_tactic_state $
do
-- `hs` are expressions specified explicitly,
-- `hex` are exceptions (specified via `solve_by_elim [-h]`) referring to local hypotheses,
-- `gex` are the other exceptions... | def | tactic.solve_by_elim.mk_assumption_set | tactic | src/tactic/solve_by_elim.lean | [
"tactic.core"
] | [] | `mk_assumption_set` builds a collection of lemmas for use in
the backtracking search in `solve_by_elim`.
* By default, it includes all local hypotheses, along with `rfl`, `trivial`, `congr_fun` and
`congr_arg`.
* The flag `no_dflt` removes these.
* The argument `hs` is a list of `simp_arg_type`s,
and can be used t... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
basic_opt extends apply_any_opt | (accept : list expr → tactic unit := λ _, skip)
(pre_apply : tactic unit := skip)
(discharger : tactic unit := failed)
(max_depth : ℕ := 3)
declare_trace solve_by_elim | structure | tactic.solve_by_elim.basic_opt | tactic | src/tactic/solve_by_elim.lean | [
"tactic.core"
] | [] | Configuration options for `solve_by_elim`.
* `accept : list expr → tactic unit` determines whether the current branch should be explored.
At each step, before the lemmas are applied,
`accept` is passed the proof terms for the original goals,
as reported by `get_goals` when `solve_by_elim` started.
These pr... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
solve_by_elim_trace (n : ℕ) (f : format) : tactic unit | trace_if_enabled `solve_by_elim
(format!"[solve_by_elim {(list.replicate (n+1) '.').as_string} " ++ f ++ "]") | def | tactic.solve_by_elim.solve_by_elim_trace | tactic | src/tactic/solve_by_elim.lean | [
"tactic.core"
] | [
"trace_if_enabled"
] | A helper function for trace messages, prepending '....' depending on the current search depth. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
on_success (g : format) (n : ℕ) (e : expr) : tactic unit | do
pp ← pp e,
solve_by_elim_trace n (format!"✅ `{pp}` solves `⊢ {g}`") | def | tactic.solve_by_elim.on_success | tactic | src/tactic/solve_by_elim.lean | [
"tactic.core"
] | [] | A helper function to generate trace messages on successful applications. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
on_failure (g : format) (n : ℕ) : tactic unit | solve_by_elim_trace n (format!"❌ failed to solve `⊢ {g}`") | def | tactic.solve_by_elim.on_failure | tactic | src/tactic/solve_by_elim.lean | [
"tactic.core"
] | [] | A helper function to generate trace messages on unsuccessful applications. | 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.