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
equiv_rw_hyp (x : name) (e : expr) (cfg : equiv_rw_cfg := {}) : tactic unit
-- We call `dsimp_result` to perform the beta redex introduced by `revert` dsimp_result (do x' ← get_local x, x_ty ← infer_type x', -- Adapt `e` to an equivalence with left-hand-side `x_ty`. e ← equiv_rw_type e x_ty cfg, eq ← to_expr ``(%%x' = equiv.symm %%e (equiv.to_fun %%e %%x')), prf ← to_expr ``((equiv...
def
tactic.equiv_rw_hyp
tactic
src/tactic/equiv_rw.lean
[ "logic.equiv.defs", "tactic.clear", "tactic.simp_result", "tactic.apply", "control.equiv_functor.instances", "logic.equiv.functor" ]
[]
Attempt to replace the hypothesis with name `x` by transporting it along the equivalence in `e : α ≃ β`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
equiv_rw_target (e : expr) (cfg : equiv_rw_cfg := {}) : tactic unit
do t ← target, e ← equiv_rw_type e t cfg, s ← to_expr ``(equiv.inv_fun %%e), tactic.eapply s, skip
def
tactic.equiv_rw_target
tactic
src/tactic/equiv_rw.lean
[ "logic.equiv.defs", "tactic.clear", "tactic.simp_result", "tactic.apply", "control.equiv_functor.instances", "logic.equiv.functor" ]
[]
Rewrite the goal using an equiv `e`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
equiv_rw_hyp_aux (hyp : name) (cfg : equiv_rw_cfg) (permissive : bool := ff) : list expr → itactic
| [] := skip | (e :: t) := do if permissive then equiv_rw_hyp hyp e cfg <|> skip else equiv_rw_hyp hyp e cfg, equiv_rw_hyp_aux t
def
tactic.interactive.equiv_rw_hyp_aux
tactic
src/tactic/equiv_rw.lean
[ "logic.equiv.defs", "tactic.clear", "tactic.simp_result", "tactic.apply", "control.equiv_functor.instances", "logic.equiv.functor" ]
[]
Auxiliary function to call `equiv_rw_hyp` on a `list pexpr` recursively.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
equiv_rw_target_aux (cfg : equiv_rw_cfg) (permissive : bool) : list expr → itactic
| [] := skip | (e :: t) := do if permissive then equiv_rw_target e cfg <|> skip else equiv_rw_target e cfg, equiv_rw_target_aux t
def
tactic.interactive.equiv_rw_target_aux
tactic
src/tactic/equiv_rw.lean
[ "logic.equiv.defs", "tactic.clear", "tactic.simp_result", "tactic.apply", "control.equiv_functor.instances", "logic.equiv.functor" ]
[]
Auxiliary function to call `equiv_rw_target` on a `list pexpr` recursively.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
equiv_rw (l : parse pexpr_list_or_texpr) (locat : parse location) (cfg : equiv_rw_cfg := {}) : itactic
do es ← l.mmap (λ e, to_expr e), match locat with | loc.wildcard := do equiv_rw_target_aux cfg tt es, ctx ← local_context, ctx.mmap (λ e, if e ∈ es then skip else equiv_rw_hyp_aux e.local_pp_name cfg tt es), skip | loc.ns names := do names.mmap (λ hyp', match hyp' with | some hyp := equiv_rw_hyp_aux h...
def
tactic.interactive.equiv_rw
tactic
src/tactic/equiv_rw.lean
[ "logic.equiv.defs", "tactic.clear", "tactic.simp_result", "tactic.apply", "control.equiv_functor.instances", "logic.equiv.functor" ]
[]
`equiv_rw e at h₁ h₂ ⋯`, where each `hᵢ : α` is a hypothesis, and `e : α ≃ β`, will attempt to transport each `hᵢ` along `e`, producing a new hypothesis `hᵢ : β`, with all occurrences of `hᵢ` in other hypotheses and the goal replaced with `e.symm hᵢ`. `equiv_rw e` will attempt to transport the goal along an equivalenc...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
equiv_rw_type (e : parse texpr) (cfg : equiv_rw_cfg := {}) : itactic
do `(%%t ≃ _) ← target | fail "`equiv_rw_type` solves goals of the form `t ≃ _`.", e ← to_expr e, tactic.equiv_rw_type e t cfg >>= tactic.exact
def
tactic.interactive.equiv_rw_type
tactic
src/tactic/equiv_rw.lean
[ "logic.equiv.defs", "tactic.clear", "tactic.simp_result", "tactic.apply", "control.equiv_functor.instances", "logic.equiv.functor" ]
[ "tactic.equiv_rw_type" ]
Solve a goal of the form `t ≃ _`, by constructing an equivalence from `e : α ≃ β`. This is the same equivalence that `equiv_rw` would use to rewrite a term of type `t`. A typical usage might be: ``` have e' : option α ≃ option β := by equiv_rw_type e ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_ctx
(original_decl : declaration) (decl : bool → name → expr → pexpr → tactic unit) (names : list name) (pis_depth : ℕ := 0)
structure
tactic.expand_exists.parse_ctx
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
Data known when parsing pi expressions. `decl`'s arguments are: is_theorem, name, type, value.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_ctx_exists extends parse_ctx
(with_args : expr → expr) (spec_chain : pexpr) (exists_decls : list name := [])
structure
tactic.expand_exists.parse_ctx_exists
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
Data known when parsing exists expressions (after parsing pi expressions). * `with_args` applies pi arguments to a term (eg `id` -> `id #2 #1 #0`). * `spec_chain` takes the form of `classical.some_spec^n (it_exists ...)`, with `n` the depth of `∃` parsed. * `exists_decls` is a list of declarations containing the value...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_ctx_props extends parse_ctx_exists
(project_proof : pexpr → pexpr := id)
structure
tactic.expand_exists.parse_ctx_props
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
Data known when parsing the proposition (after parsing exists and pi expressions). `project_proof` projects a proof of the full proposition (eg `A ∧ B ∧ C`) to a specific proof (eg `B`).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
instantiate_exists_decls (ctx : parse_ctx_exists) (p : expr) : expr
p.instantiate_vars $ ctx.exists_decls.reverse.map (λname, ctx.with_args (const name ctx.original_decl.univ_levels))
def
tactic.expand_exists.instantiate_exists_decls
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
Replaces free variables with their exists declaration. For example, if: ```lean def n_value : ℕ := ... -- generated by `expand_exists` ``` then this function converts `#0` in `#0 = #0` from `∃ n : ℕ, n = n` to `n_value = n_value`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_one_prop (ctx : parse_ctx_props) (p : expr) : tactic unit
do let p : expr := instantiate_exists_decls { ..ctx } p, let val : pexpr := ctx.project_proof ctx.spec_chain, n <- match ctx.names with | [n] := return n | [] := fail "missing name for proposition" | _ := fail "too many names for propositions (are you missing an and?)" end, ctx.decl true n p val
def
tactic.expand_exists.parse_one_prop
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
Parses a proposition and creates the associated specification proof. Does not break down the proposition further.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_props : parse_ctx_props → expr → tactic unit
| ctx (app (app (const "and" []) p) q) := do match ctx.names with | [n] := parse_one_prop ctx (app (app (const `and []) p) q) | (n :: tail) := parse_one_prop { names := [n], project_proof := (λ p, (const `and.left []) p) ∘ ctx.project_proof, ..ctx } p >> parse_props { names := tail, proj...
def
tactic.expand_exists.parse_props
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
Parses a proposition and decides if it should be broken down (eg `P ∧ Q` -> `P` and `Q`) depending on how many `names` are left. Then creates the associated specification proof(s).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_exists : parse_ctx_exists → expr → tactic unit
| ctx (app (app (const "Exists" [lvl]) type) (lam var_name bi var_type body)) := do /- TODO: Is this needed, and/or does this create issues? -/ (if type = var_type then tactic.skip else tactic.fail "exists types should be equal"), ⟨n, names⟩ <- match ctx.names with | (n :: tail) := return (n, tail) | [] := fa...
def
tactic.expand_exists.parse_exists
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
Parses an `∃ a : α, p a`, and creates an associated definition with a value of `α`. When `p α` is not an exists statement, it will call `parse_props`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_pis : parse_ctx → expr → tactic unit
| ctx (pi n bi ty body) := -- When making a declaration, wrap in an equivalent pi expression. let decl := (λ is_theorem name type val, ctx.decl is_theorem name (pi n bi ty type) (lam n bi (to_pexpr ty) val)) in parse_pis { decl := decl, pis_depth := ctx.pis_depth + 1, ..ctx } body | ctx (app (app (const "Exis...
def
tactic.expand_exists.parse_pis
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
Parses a `∀ (a : α), p a`. If `p` is not a pi expression, it will call `parse_exists`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
expand_exists_attr : user_attribute unit (list name)
{ name := "expand_exists", descr := "From a proof that (a) value(s) exist(s) with certain properties, " ++ "constructs (an) instance(s) satisfying those properties.", parser := lean.parser.many lean.parser.ident, after_set := some $ λ decl prio persistent, do d <- get_decl decl, names <- expand_exists_a...
def
tactic.expand_exists_attr
tactic
src/tactic/expand_exists.lean
[ "meta.expr" ]
[]
From a proof that (a) value(s) exist(s) with certain properties, constructs (an) instance(s) satisfying those properties. For instance: ```lean @[expand_exists nat_greater nat_greater_spec] lemma nat_greater_exists (n : ℕ) : ∃ m : ℕ, n < m := ... #check nat_greater -- nat_greater : ℕ → ℕ #check nat_greater_spec ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
status : Type | reg | intro | lam | sintro
inductive
tactic.explode.status
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
thm : Type | expr (e : expr) | name (n : name) | string (s : string)
inductive
tactic.explode.thm
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
A type to distinguish introduction or elimination rules represented as strings from theorems referred to by their names.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
thm.to_string : thm → string
| (thm.expr e) := e.to_string | (thm.name n) := n.to_string | (thm.string s) := s
def
tactic.explode.thm.to_string
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
Turn a thm into a string.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
entry : Type
(expr : expr) (line : nat) (depth : nat) (status : status) (thm : thm) (deps : list nat)
structure
tactic.explode.entry
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pad_right (l : list string) : list string
let n := l.foldl (λ r (s:string), max r s.length) 0 in l.map $ λ s, nat.iterate (λ s, s.push ' ') (n - s.length) s
def
tactic.explode.pad_right
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
entries : Type
mk' :: (s : expr_map entry) (l : list entry)
structure
tactic.explode.entries
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[ "mk'" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
entries.find (es : entries) (e : expr) : option entry
es.s.find e
def
tactic.explode.entries.find
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
entries.size (es : entries) : ℕ
es.s.size
def
tactic.explode.entries.size
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
entries.add : entries → entry → entries
| es@⟨s, l⟩ e := if s.contains e.expr then es else ⟨s.insert e.expr e, e :: l⟩
def
tactic.explode.entries.add
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
entries.head (es : entries) : option entry
es.l.head'
def
tactic.explode.entries.head
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
format_aux : list string → list string → list string → list entry → tactic format
| (line :: lines) (dep :: deps) (thm :: thms) (en :: es) := do fmt ← do { let margin := string.join (list.replicate en.depth " │"), let margin := match en.status with | status.sintro := " ├" ++ margin | status.intro := " │" ++ margin ++ " ┌" | status.reg := " │" ++ margin ++ "" | status....
def
tactic.explode.format_aux
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[ "group", "list.replicate" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
append_dep (filter : expr → tactic unit) (es : entries) (e : expr) (deps : list nat) : tactic (list nat)
do { ei ← es.find e, filter ei.expr, return (ei.line :: deps) } <|> return deps
def
tactic.explode.append_dep
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[ "filter" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
may_be_proof (e : expr) : tactic bool
do expr.sort u ← infer_type e >>= infer_type, return $ bnot u.nonzero
def
tactic.explode.may_be_proof
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
explode_expr (e : expr) (hide_non_prop := tt) : tactic entries
let filter := if hide_non_prop then λ e, may_be_proof e >>= guardb else λ _, skip in tactic.explode.core filter e tt 0 default
def
tactic.explode_expr
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[ "filter" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
explode (n : name) : tactic unit
do const n _ ← resolve_name n | fail "cannot resolve name", d ← get_decl n, v ← match d with | (declaration.defn _ _ _ v _ _) := return v | (declaration.thm _ _ _ v) := return v.get | _ := fail "not a definition" end, t ← pp d.type, explode_expr v <* trace (to_fmt n ++ " : " ++ t) ...
def
tactic.explode
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
explode_cmd (_ : parse $ tk "#explode") : parser unit
do n ← ident, explode n
def
tactic.explode_cmd
tactic
src/tactic/explode.lean
[ "meta.rb_map", "tactic.core" ]
[]
`#explode decl_name` displays a proof term in a line-by-line format somewhat akin to a Fitch-style proof or the Metamath proof style. `#explode_widget decl_name` renders a widget that displays an `#explode` proof. `#explode iff_true_intro` produces ```lean iff_true_intro : ∀ {a : Prop}, a → (a ↔ true) 0│ │ a ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
widget.string_to_html {α} : has_coe string (html α)
⟨λ s, s⟩
instance
widget.string_to_html
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_block_attrs {γ}: sf → tactic (sf × list (attr γ))
| (sf.block i a) := do let s : attr (γ) := style [ ("display", "inline-block"), ("white-space", "pre-wrap"), ("vertical-align", "top") ], (a,rest) ← get_block_attrs a, pure (a, s :: rest) | (sf.highlight c a) := do (a, rest) ← get_block_attrs a, pure (a, (cn c.to_string) :: rest) | a := pure (a,...
def
tactic.explode_widget.get_block_attrs
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Redefine some of the style attributes for better formatting.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
insert_explode {γ} : expr → tactic (list (html (action γ)))
| (expr.const n _) := (do pure $ [h "button" [ cn "pointer ba br3 mr1", on_click (λ _, action.effect $ widget.effect.insert_text ("#explode_widget " ++ n.to_string)), attr.val "title" "explode"] ["💥"]] ) <|> pure [] | e := pure []
def
tactic.explode_widget.insert_explode
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Explode button for subsequent exploding.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
view {γ} (tooltip_component : tc subexpr (action γ)) (click_address : option expr.address) (select_address : option expr.address) : subexpr → sf → tactic (list (html (action γ)))
| ⟨ce, current_address⟩ (sf.tag_expr ea e m) := do let new_address := current_address ++ ea, let select_attrs : list (attr (action γ)) := if some new_address = select_address then [className "highlight"] else [], click_attrs : list (attr (action γ)) ← if some new_address = click_address then do ...
def
tactic.explode_widget.view
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Render a subexpression as a list of html elements.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk {γ} (tooltip : tc subexpr γ) : tc expr γ
let tooltip_comp := component.with_should_update (λ (x y : tactic_state × expr × expr.address), x.2.2 ≠ y.2.2) $ component.map_action (action.on_tooltip_action) tooltip in component.filter_map_action (λ _ (a : γ ⊕ widget.effect), sum.cases_on a some (λ _, none)) $ component.with_effects (λ _ (a : γ ⊕ wid...
def
tactic.explode_widget.mk
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Make an interactive expression.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
implicit_arg_list (tooltip : tc subexpr empty) (e : expr) : tactic $ html empty
do fn ← (mk tooltip) $ expr.get_app_fn e, args ← list.mmap (mk tooltip) $ expr.get_app_args e, pure $ h "div" [] ( (h "span" [className "bg-blue br3 ma1 ph2 white"] [fn]) :: list.map (λ a, h "span" [className "bg-gray br3 ma1 ph2 white"] [a]) args )
def
tactic.explode_widget.implicit_arg_list
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Render the implicit arguments for an expression in fancy, little pills.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
type_tooltip : tc subexpr empty
tc.stateless (λ ⟨e,ea⟩, do y ← tactic.infer_type e, y_comp ← mk type_tooltip y, implicit_args ← implicit_arg_list type_tooltip e, pure [h "div" [style [("minWidth", "12rem")]] [ h "div" [cn "pl1"] [y_comp], h "hr" [] [], implicit_args ] ] )
def
tactic.explode_widget.type_tooltip
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Component for the type tooltip.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
show_type_component : tc expr empty
tc.stateless (λ x, do y ← infer_type x, y_comp ← mk type_tooltip $ y, pure y_comp )
def
tactic.explode_widget.show_type_component
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Component that shows a type.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
show_constant_component : tc expr empty
tc.stateless (λ x, do y_comp ← mk type_tooltip x, pure y_comp )
def
tactic.explode_widget.show_constant_component
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Component that shows a constant.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
lookup_lines : entries → nat → entry
| ⟨_, []⟩ n := ⟨default, 0, 0, status.sintro, thm.string "", []⟩ | ⟨rb, (hd::tl)⟩ n := if hd.line = n then hd else lookup_lines ⟨rb, tl⟩ n
def
tactic.explode_widget.lookup_lines
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Search for an entry that has the specified line number.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
goal_row (e : expr) (show_expr := tt): tactic (list (html empty))
do t ← explode_widget.show_type_component e, return $ [h "td" [cn "ba bg-dark-green tc"] "Goal", h "td" [cn "ba tc"] (if show_expr then [html.of_name e.local_pp_name, " : ", t] else t)]
def
tactic.explode_widget.goal_row
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Render a row that shows a goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
id_row {γ} (l : nat): tactic (list (html γ))
return $ [h "td" [cn "ba bg-dark-green tc"] "ID", h "td" [cn "ba tc"] (to_string l)]
def
tactic.explode_widget.id_row
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Render a row that shows the ID of a goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rule_row : thm → tactic (list (html empty))
| (thm.expr e) := do t ← explode_widget.show_constant_component e, return $ [h "td" [cn "ba bg-dark-green tc"] "Rule", h "td" [cn "ba tc"] t] | t := return $ [h "td" [cn "ba bg-dark-green tc"] "Rule", h "td" [cn "ba tc"] t.to_string]
def
tactic.explode_widget.rule_row
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Render a row that shows the rule or theorem being applied.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
proof_row {γ} (args : list (html γ)): list (html γ)
[h "td" [cn "ba bg-dark-green tc"] "Proofs", h "td" [cn "ba tc"] [h "details" [] $ (h "summary" [attr.style [("color", "orange")]] "Details")::args] ]
def
tactic.explode_widget.proof_row
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Render a row that contains the sub-proofs, i.e., the proofs of the arguments.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assemble_table {γ} (gr ir rr) : list (html γ) → html γ
| [] := h "table" [cn "collapse"] [h "tbody" [] [h "tr" [] gr, h "tr" [] ir, h "tr" [] rr] ] | pr := h "table" [cn "collapse"] [h "tbody" [] [h "tr" [] gr, h "tr" [] ir, h "tr" [] rr, h "tr" [] pr] ]
def
tactic.explode_widget.assemble_table
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Combine the goal row, id row, rule row and proof row to make them a table.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assemble (es : entries): entry → tactic (html empty)
| ⟨e, l, d, status.sintro, t, ref⟩ := do gr ← goal_row e, ir ← id_row l, rr ← rule_row $ thm.string "Assumption", return $ assemble_table gr ir rr [] | ⟨e, l, d, status.intro, t, ref⟩ := do gr ← goal_row e, ir ← id_row l, rr ← rule_row $ thm.string "Assumption", return $ assemble_table gr ir rr [] | ⟨e...
def
tactic.explode_widget.assemble
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Render a table for a given entry.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
explode_component (es : entries) : tactic (html empty)
let concl := lookup_lines es (es.l.length - 1) in assemble es concl
def
tactic.explode_widget.explode_component
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Render a widget from given entries.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
explode_entries (n : name) (hide_non_prop := tt) : tactic entries
do expr.const n _ ← resolve_name n | fail "cannot resolve name", d ← get_decl n, v ← match d with | (declaration.defn _ _ _ v _ _) := return v | (declaration.thm _ _ _ v) := return v.get | _ := fail "not a definition" end, t ← pp d.type, explode_expr v hide_non_prop
def
tactic.explode_widget.explode_entries
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
Explode a theorem and return entries.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
explode_widget_cmd (_ : parse $ tk "#explode_widget") : lean.parser unit
do ⟨li,co⟩ ← cur_pos, n ← ident, es ← explode_entries n, comp ← parser.of_tactic (do html ← explode_component es, c ← pure $ component.stateless (λ _, [html]), pure $ component.ignore_props $ component.ignore_action $ c), save_widget ⟨li, co - "#explode_widget".length - 1⟩ comp, trace "succe...
def
tactic.explode_widget_cmd
tactic
src/tactic/explode_widget.lean
[ "tactic.explode", "tactic.interactive_expr" ]
[]
User command of the explode widget.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
derive_struct_ext_lemma (n : name) : tactic name
do e ← get_env, fs ← e.structure_fields n, d ← get_decl n, n ← resolve_constant n, let r := @expr.const tt n $ d.univ_params.map level.param, (args,_) ← infer_type r >>= open_pis, let args := args.map expr.to_implicit_local_const, let t := r.mk_app args, x ← mk_local_def `x t, y ← mk_local_de...
def
derive_struct_ext_lemma
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[ "expr.mk_and_lst", "expr.to_implicit_local_const" ]
`derive_struct_ext_lemma n` generates two extensionality lemmas based on the equality of all non-propositional projections. On the following: ```lean @[ext] structure foo (α : Type*) := (x y : ℕ) (z : {z // z < x}) (k : α) (h : x < y) ``` `derive_struct_lemma` generates: ```lean lemma foo.ext : ∀ {α : Type u_1} (x ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_ext_subject : expr → tactic name
| (expr.pi n bi d b) := do v ← mk_local' n bi d, b' ← whnf $ b.instantiate_var v, get_ext_subject b' | (expr.app _ e) := do t ← infer_type e >>= instantiate_mvars >>= head_beta, if t.get_app_fn.is_constant then pure $ t.get_app_fn.const_name else if t.is_pi then pure $ name.mk_num...
def
get_ext_subject
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
saturate_fun : name → tactic expr
| (name.mk_numeral 0 name.anonymous) := do v₀ ← mk_mvar, v₁ ← mk_mvar, return $ v₀.imp v₁ | (name.mk_numeral 1 name.anonymous) := do u ← mk_meta_univ, pure $ expr.sort u | n := do e ← resolve_constant n >>= mk_const, a ← get_arity e, e.mk_app <$> (list.iota a).mmap (λ _, mk_mvar)
def
saturate_fun
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
equiv_type_constr (n n' : name) : tactic unit
do e ← saturate_fun n, e' ← saturate_fun n', unify e e' <|> fail format!"{n} and {n'} are not definitionally equal types"
def
equiv_type_constr
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[ "saturate_fun" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hacky_name_reflect : has_reflect name
λ n, `(id %%(expr.const n []) : name)
def
hacky_name_reflect
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext_attr_core : user_attribute (name_map name) name
{ name := `_ext_core, descr := "(internal attribute used by ext)", cache_cfg := { dependencies := [], mk_cache := λ ns, ns.mfoldl (λ m n, do ext_l ← ext_attr_core.get_param_untyped n, pure (m.insert n ext_l.app_arg.const_name)) mk_name_map }, parser := failure }
def
ext_attr_core
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext_lemma_attr_core : user_attribute
{ name := `_ext_lemma_core, descr := "(internal attribute used by ext)", parser := failure }
def
ext_lemma_attr_core
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Private attribute used to tag extensionality lemmas.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_ext_lemmas : tactic (name_map name)
ext_attr_core.get_cache
def
get_ext_lemmas
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Returns the extensionality lemmas in the environment, as a map from structure name to lemma name.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_ext_lemma_names : tactic (list name)
attribute.get_instances ext_lemma_attr_core.name
def
get_ext_lemma_names
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Returns the extensionality lemmas in the environment, as a list of lemma names.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_ext_lemma (constr lem : name) (persistent : bool) : tactic unit
ext_attr_core.set constr lem persistent >> ext_lemma_attr_core.set lem () persistent
def
add_ext_lemma
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Marks `lem` as an extensionality lemma corresponding to type constructor `constr`; if `persistent` is true then this is a global attribute, else local.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
extensional_attribute : user_attribute unit (option name)
{ name := `ext, descr := "lemmas usable by `ext` tactic", parser := optional ident, after_set := some $ λ n _ b, do add ← extensional_attribute.get_param n, e ← get_env, n ← if (e.structure_fields n).is_some then derive_struct_ext_lemma n else pure n, s ← mk_const n >>= infer_type >>= ...
def
extensional_attribute
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[ "add_ext_lemma", "derive_struct_ext_lemma", "equiv_type_constr", "get_ext_subject" ]
Tag lemmas of the form: ```lean @[ext] lemma my_collection.ext (a b : my_collection) (h : ∀ x, a.lookup x = b.lookup y) : a = b := ... ``` The attribute indexes extensionality lemma using the type of the objects (i.e. `my_collection`) which it gets from the statement of the lemma. In some cases, the same lemma c...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext {P : Prop} (a b : plift P) : a = b
begin cases a, cases b, refl end
lemma
plift.ext
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unit.ext {x y : unit} : x = y
by { cases x, cases y, refl, }
lemma
unit.ext
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
punit.ext {x y : punit} : x = y
by { cases x, cases y, refl, }
lemma
punit.ext
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext_state : Type
(patts : list rcases_patt := []) (trace_msg : list string := []) (fuel : option ℕ := none)
structure
tactic.ext_state
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Helper structure for `ext` and `ext1`. `lemmas` keeps track of extensionality lemmas applied so far.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
try_intros_core : state_t ext_state tactic unit
do ⟨patts, trace_msg, fuel⟩ ← get, match patts with | [] := do { es ← state_t.lift intros, when (es.length > 0) $ do let msg := "intros " ++ (" ".intercalate (es.map (λ e, e.local_pp_name.to_string))), modify (λ ⟨patts, trace_msg, fuel⟩, ⟨patts, trace_msg ++ [msg], fuel⟩) } ...
def
tactic.try_intros_core
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Helper function for `try_intros`. Additionally populates the `trace_msg` field of `ext_state`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
try_intros (patts : list rcases_patt) : tactic (list rcases_patt)
let σ := ext_state.mk patts [] none in (ext_state.patts ∘ prod.snd) <$> state_t.run try_intros_core σ
def
tactic.try_intros
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Try to introduce as many arguments as possible, using the given patterns to destruct the introduced variables. Returns the unused patterns.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext1_core (cfg : apply_cfg := {}) : state_t ext_state tactic unit
do ⟨patts, trace_msg, _⟩ ← get, (new_msgs) ← state_t.lift $ focus1 $ do { m ← get_ext_lemmas, tgt ← target, when_tracing `ext $ trace!"[ext] goal: {tgt}", subject ← get_ext_subject tgt, new_trace_msg ← do { rule ← (m.find subject), if is_trace_enabled...
def
tactic.ext1_core
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[ "get_ext_lemma_names", "get_ext_lemmas", "get_ext_subject" ]
Apply one extensionality lemma, and destruct the arguments using the patterns in the ext_state.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext_core (cfg : apply_cfg := {}) : state_t ext_state tactic unit
do acc@⟨_, _, fuel⟩ ← get, match fuel with | (some 0) := pure () | n := do { ext1_core cfg, modify (λ ⟨patts, lemmas, _⟩, ⟨patts, lemmas, nat.pred <$> n⟩), ext_core <|> pure () } end
def
tactic.ext_core
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Apply multiple extensionality lemmas, destructing the arguments using the given patterns.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext1 (xs : list rcases_patt) (cfg : apply_cfg := {}) (trace : bool := ff) : tactic (list rcases_patt)
do ⟨_, σ⟩ ← state_t.run (ext1_core cfg) {patts := xs}, when trace $ tactic.trace $ "Try this: " ++ ", ".intercalate σ.trace_msg, pure σ.patts
def
tactic.ext1
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Apply one extensionality lemma, and destruct the arguments using the given patterns. Returns the unused patterns.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext (xs : list rcases_patt) (fuel : option ℕ) (cfg : apply_cfg := {}) (trace : bool := ff) : tactic (list rcases_patt)
do ⟨_, σ⟩ ← state_t.run (ext_core cfg) {patts := xs, fuel := fuel}, when trace $ tactic.trace $ "Try this: " ++ ", ".intercalate σ.trace_msg, pure σ.patts
def
tactic.ext
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
Apply multiple extensionality lemmas, destructing the arguments using the given patterns. `ext ps (some n)` applies at most `n` extensionality lemmas. Returns the unused patterns.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
interactive.ext1 (trace : parse (tk "?")?) (xs : parse rcases_patt_parse_hi*) : tactic unit
ext1 xs {} trace.is_some $> ()
def
tactic.interactive.ext1
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
`ext1 id` selects and apply one extensionality lemma (with attribute `ext`), using `id`, if provided, to name a local constant introduced by the lemma. If `id` is omitted, the local constant is named automatically, as per `intro`. Placing a `?` after `ext1` (e.g. `ext1? i ⟨a,b⟩ : 3`) will display a sequence of tactic ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
interactive.ext : (parse $ (tk "?")?) → parse rintro_patt_parse_hi* → parse (tk ":" *> small_nat)? → tactic unit
| trace [] (some n) := iterate_range 1 n (ext1 [] {} trace.is_some $> ()) | trace [] none := repeat1 (ext1 [] {} trace.is_some $> ()) | trace xs n := ext xs.join n {} trace.is_some $> ()
def
tactic.interactive.ext
tactic
src/tactic/ext.lean
[ "tactic.rcases", "logic.function.basic" ]
[]
- `ext` applies as many extensionality lemmas as possible; - `ext ids`, with `ids` a list of identifiers, finds extentionality and applies them until it runs out of identifiers in `ids` to name the local constants. - `ext` can also be given an `rcases` pattern in place of an identifier. This will destruct the intro...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
field_simp.ne_zero : tactic unit
do goal ← tactic.target, match goal with | `(%%e ≠ 0) := assumption <|> do n ← e.to_rat, `[norm_num1] | _ := tactic.fail "goal should be of the form `x ≠ 0`" end
def
tactic.field_simp.ne_zero
tactic
src/tactic/field_simp.lean
[ "tactic.interactive", "tactic.norm_num" ]
[]
Try to prove a goal of the form `x ≠ 0` by calling `assumption`, or `norm_num1` if `x` is a numeral.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
field_simp (no_dflt : parse only_flag) (hs : parse simp_arg_list) (attr_names : parse with_ident_list) (locat : parse location) (cfg : simp_config_ext := {discharger := field_simp.ne_zero}) : tactic unit
let attr_names := `field_simps :: attr_names, hs := simp_arg_type.except `one_div :: simp_arg_type.except `mul_eq_zero :: simp_arg_type.except `one_divp :: hs in propagate_tags (simp_core cfg.to_simp_config cfg.discharger no_dflt hs attr_names locat >> skip)
def
tactic.interactive.field_simp
tactic
src/tactic/field_simp.lean
[ "tactic.interactive", "tactic.norm_num" ]
[ "mul_eq_zero", "one_div", "one_divp" ]
The goal of `field_simp` is to reduce an expression in a field to an expression of the form `n / d` where neither `n` nor `d` contains any division symbol, just using the simplifier (with a carefully crafted simpset named `field_simps`) to reduce the number of division symbols whenever possible by iterating the followi...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_subexpr (p : pattern) : expr → tactic (list expr)
| e := prod.snd <$> match_pattern p e <|> match e with | app e₁ e₂ := match_subexpr e₁ <|> match_subexpr e₂ | pi _ _ _ b := mk_fresh_name >>= match_subexpr ∘ b.instantiate_var ∘ mk_local | lam _ _ _ b := mk_fresh_name >>= match_subexpr ∘ b.instantiate_var ∘ mk_local | _ := failed end
def
match_subexpr
tactic
src/tactic/find.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_exact : pexpr → expr → tactic (list expr)
| p e := do (app p₁ p₂) ← pure p | match_expr p e, if pexpr.is_placeholder p₁ then -- `_ p` pattern ~> match `p` recursively do p ← pexpr_to_pattern p₂, match_subexpr p e else match_expr p e
def
match_exact
tactic
src/tactic/find.lean
[ "tactic.core" ]
[ "match_subexpr" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
expr.get_pis : expr → tactic (list expr × expr)
| (pi n bi d b) := do l ← mk_local' n bi d, (pis, b) ← expr.get_pis (b.instantiate_var l), pure (d::pis, b) | e := pure ([], e)
def
expr.get_pis
tactic
src/tactic/find.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pexpr.get_uninst_pis : pexpr → tactic (list pexpr × pexpr)
| (pi n bi d b) := do (pis, b) ← pexpr.get_uninst_pis b, pure (d::pis, b) | e := pure ([], e)
def
pexpr.get_uninst_pis
tactic
src/tactic/find.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_hyps : list pexpr → list expr → list expr → tactic unit
| (p::ps) old_hyps (h::new_hyps) := do some _ ← try_core (match_exact p h) | match_hyps (p::ps) (h::old_hyps) new_hyps, match_hyps ps [] (old_hyps ++ new_hyps) | [] _ _ := skip | (_::_) _ [] := failed
def
match_hyps
tactic
src/tactic/find.lean
[ "tactic.core" ]
[ "match_exact" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_sig (p : pexpr) (e : expr) : tactic unit
do (p_pis, p) ← p.get_uninst_pis, (pis, e) ← e.get_pis, match_exact p e, match_hyps p_pis [] pis
def
match_sig
tactic
src/tactic/find.lean
[ "tactic.core" ]
[ "match_exact", "match_hyps" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
trace_match (pat : pexpr) (ty : expr) (n : name) : tactic unit
try $ do guard ¬ n.is_internal, match_sig pat ty, ty ← pp ty, trace format!"{n}: {ty}"
def
trace_match
tactic
src/tactic/find.lean
[ "tactic.core" ]
[ "match_sig" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_cmd (_ : parse $ tk "#find") : lean.parser unit
do pat ← lean.parser.pexpr 0, env ← get_env, env.mfold () $ λ d _, match d with | declaration.thm n _ ty _ := trace_match pat ty n | declaration.defn n _ ty _ _ _ := trace_match pat ty n | _ := skip end
def
find_cmd
tactic
src/tactic/find.lean
[ "tactic.core" ]
[ "trace_match" ]
The `find` command from `tactic.find` allows to find definitions lemmas using pattern matching on the type. For instance: ```lean import tactic.find run_cmd tactic.skip #find _ + _ = _ + _ #find (_ : ℕ) + _ = _ + _ #find ℕ → ℕ ``` The tactic `library_search` is an alternate way to find lemmas in the library.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
main_declaration_attr : user_attribute
{ name := `main_declaration, descr := "tag essential declarations to help identify unused definitions" }
def
tactic.main_declaration_attr
tactic
src/tactic/find_unused.lean
[ "data.bool.basic", "meta.rb_map", "tactic.core" ]
[]
Attribute `main_declaration` is used to mark declarations that are featured in the current file. Then, the `#list_unused_decls` command can be used to list the declaration present in the file that are not used by the main declarations of the file.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
update_unsed_decls_list : name → name_map declaration → tactic (name_map declaration)
| n m := do d ← get_decl n, if m.contains n then do let m := m.erase n, let ns := d.value.list_constant.union d.type.list_constant, ns.mfold m update_unsed_decls_list else pure m
def
tactic.update_unsed_decls_list
tactic
src/tactic/find_unused.lean
[ "data.bool.basic", "meta.rb_map", "tactic.core" ]
[]
`update_unsed_decls_list n m` removes from the map of unneeded declarations those referenced by declaration named `n` which is considerred to be a main declaration
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
all_unused (fs : list (option string)) : tactic (name_map declaration)
do ds ← get_decls_from fs, ls ← ds.keys.mfilter (succeeds ∘ user_attribute.get_param_untyped main_declaration_attr), ds ← ls.mfoldl (flip update_unsed_decls_list) ds, ds.mfilter $ λ n d, do e ← get_env, return $ !d.is_auto_or_internal e
def
tactic.all_unused
tactic
src/tactic/find_unused.lean
[ "data.bool.basic", "meta.rb_map", "tactic.core" ]
[ "succeeds" ]
In the current file, list all the declaration that are not marked as `@[main_declaration]` and that are not referenced by such declarations
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_file_name (fn : pexpr) : tactic (option string)
some <$> (to_expr fn >>= eval_expr string) <|> fail "expecting: \"src/dir/file-name\"" setup_tactic_parser
def
tactic.parse_file_name
tactic
src/tactic/find_unused.lean
[ "data.bool.basic", "meta.rb_map", "tactic.core" ]
[]
expecting a string literal (e.g. `"src/tactic/find_unused.lean"`)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unused_decls_cmd (_ : parse $ tk "#list_unused_decls") : lean.parser unit
do fs ← pexpr_list, show tactic unit, from do fs ← fs.mmap parse_file_name, ds ← all_unused $ none :: fs, ds.to_list.mmap' $ λ ⟨n,_⟩, trace!"#print {n}"
def
tactic.unused_decls_cmd
tactic
src/tactic/find_unused.lean
[ "data.bool.basic", "meta.rb_map", "tactic.core" ]
[]
The command `#list_unused_decls` lists the declarations that that are not used the main features of the present file. The main features of a file are taken as the declaration tagged with `@[main_declaration]`. A list of files can be given to `#list_unused_decls` as follows: ```lean #list_unused_decls ["src/tactic/cor...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
revert_all
tactic.revert_all
def
tactic.interactive.revert_all
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
whnf_reducible (e : expr) : tactic expr
whnf e reducible
def
auto.whnf_reducible
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_simps : simp_lemmas → list name → tactic simp_lemmas
| s [] := return s | s (n::ns) := do s' ← s.add_simp n, add_simps s' ns
def
auto.add_simps
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
auto_config : Type
(use_simp := tt) (max_ematch_rounds := 20)
structure
auto.auto_config
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[]
Configuration information for the auto tactics. * `(use_simp := tt)`: call the simplifier * `(max_ematch_rounds := 20)`: for the "done" tactic
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
by_contradiction_trick (p : Prop) (h : ∀ f : Prop, (p → f) → f) : p
h p id
theorem
auto.by_contradiction_trick
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
preprocess_goal : tactic unit
do repeat (intro1 >> skip), tgt ← target >>= whnf_reducible, if (¬ (is_false tgt)) then (mk_mapp ``classical.by_contradiction [some tgt]) >>= apply >> intro1 >> skip else skip
def
auto.preprocess_goal
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
not_not_eq : (¬ ¬ p) = p
propext not_not
theorem
auto.not_not_eq
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[ "not_not" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
not_and_eq : (¬ (p ∧ q)) = (¬ p ∨ ¬ q)
propext not_and_distrib
theorem
auto.not_and_eq
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[ "not_and_distrib" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
not_or_eq : (¬ (p ∨ q)) = (¬ p ∧ ¬ q)
propext not_or_distrib
theorem
auto.not_or_eq
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[ "not_or_distrib" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
not_forall_eq : (¬ ∀ x, s x) = (∃ x, ¬ s x)
propext not_forall
theorem
auto.not_forall_eq
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[ "not_forall" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
not_exists_eq : (¬ ∃ x, s x) = (∀ x, ¬ s x)
propext not_exists
theorem
auto.not_exists_eq
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[ "not_exists" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
not_implies_eq : (¬ (p → q)) = (p ∧ ¬ q)
propext not_imp
theorem
auto.not_implies_eq
tactic
src/tactic/finish.lean
[ "tactic.hint" ]
[ "not_imp" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83