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
trace_hooks (n : ℕ) : tactic ((expr → tactic unit) × tactic unit)
if is_trace_enabled_for `solve_by_elim then do g ← target >>= pp, return (on_success g n, on_failure g n) else return (λ _, skip, skip)
def
tactic.solve_by_elim.trace_hooks
tactic
src/tactic/solve_by_elim.lean
[ "tactic.core" ]
[]
A helper function to generate the tactic that print trace messages. This function exists to ensure the target is pretty printed only as necessary.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
solve_by_elim_aux (opt : basic_opt) (original_goals : list expr) (lemmas : list (tactic expr)) (ctx : tactic (list expr)) : ℕ → tactic unit
| n := do -- First, check that progress so far is `accept`able. lock_tactic_state (original_goals.mmap instantiate_mvars >>= opt.accept), -- Then check if we've finished. (done >> solve_by_elim_trace (opt.max_depth - n) "success!") <|> (do -- Otherwise, if there's more time left, (guard (n > 0) <|> ...
def
tactic.solve_by_elim.solve_by_elim_aux
tactic
src/tactic/solve_by_elim.lean
[ "tactic.core" ]
[]
The internal implementation of `solve_by_elim`, with a limiting counter.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
opt extends basic_opt
(backtrack_all_goals : bool := ff) (lemmas : option (list expr) := none) (lemma_thunks : option (list (tactic expr)) := lemmas.map (λ l, l.map return)) (ctx_thunk : tactic (list expr) := local_context)
structure
tactic.solve_by_elim.opt
tactic
src/tactic/solve_by_elim.lean
[ "tactic.core" ]
[]
Arguments for `solve_by_elim`: * By default `solve_by_elim` operates only on the first goal, but with `backtrack_all_goals := true`, it operates on all goals at once, backtracking across goals as needed, and only succeeds if it discharges all goals. * `lemmas` specifies the list of lemmas to use in the backtracki...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
opt.get_lemma_thunks (opt : opt) : tactic (list (tactic expr) × tactic (list expr))
match opt.lemma_thunks with | none := mk_assumption_set ff [] [] | some lemma_thunks := return (lemma_thunks, opt.ctx_thunk) end
def
tactic.solve_by_elim.opt.get_lemma_thunks
tactic
src/tactic/solve_by_elim.lean
[ "tactic.core" ]
[]
If no lemmas have been specified, generate the default set (local hypotheses, along with `rfl`, `trivial`, `congr_arg`, and `congr_fun`).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
solve_by_elim (opt : opt := { }) : tactic unit
do tactic.fail_if_no_goals, (lemmas, ctx_lemmas) ← opt.get_lemma_thunks, (if opt.backtrack_all_goals then id else focus1) $ (do gs ← get_goals, solve_by_elim_aux opt.to_basic_opt gs lemmas ctx_lemmas opt.max_depth <|> fail ("`solve_by_elim` failed.\n" ++ "Try `solve_by_elim { max_depth := N }` f...
def
tactic.solve_by_elim
tactic
src/tactic/solve_by_elim.lean
[ "tactic.core" ]
[]
`solve_by_elim` repeatedly tries `apply`ing a lemma from the list of assumptions (passed via the `opt` argument), recursively operating on any generated subgoals, backtracking as necessary. `solve_by_elim` succeeds only if it discharges the goal. (By default, `solve_by_elim` focuses on the first goal, and only attempt...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_assumption (lemmas : parse pexpr_list?) (opt : apply_any_opt := {}) (tac : tactic unit := skip) : tactic unit
do lemmas ← match lemmas with | none := local_context | some lemmas := lemmas.mmap to_expr end, tactic.apply_any lemmas opt tac
def
tactic.interactive.apply_assumption
tactic
src/tactic/solve_by_elim.lean
[ "tactic.core" ]
[ "tactic.apply_any" ]
`apply_assumption` looks for an assumption of the form `... → ∀ _, ... → head` where `head` matches the current goal. If this fails, `apply_assumption` will call `symmetry` and try again. If this also fails, `apply_assumption` will call `exfalso` and try again, so that if there is an assumption of the form `P → ¬ Q`,...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
solve_by_elim (all_goals : parse $ (tk "*")?) (no_dflt : parse only_flag) (hs : parse simp_arg_list) (attr_names : parse with_ident_list) (opt : solve_by_elim.opt := { }) : tactic unit
do (lemma_thunks, ctx_thunk) ← mk_assumption_set no_dflt hs attr_names, tactic.solve_by_elim { backtrack_all_goals := all_goals.is_some ∨ opt.backtrack_all_goals, lemma_thunks := some lemma_thunks, ctx_thunk := ctx_thunk, ..opt }
def
tactic.interactive.solve_by_elim
tactic
src/tactic/solve_by_elim.lean
[ "tactic.core" ]
[ "tactic.solve_by_elim" ]
`solve_by_elim` calls `apply` on the main goal to find an assumption whose head matches and then repeatedly calls `apply` on the generated subgoals until no subgoals remain, performing at most `max_depth` recursive steps. `solve_by_elim` discharges the current goal or fails. `solve_by_elim` performs back-tracking if ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_if_cond : expr → option expr | e
e.fold none $ λ e _ acc, acc <|> do c ← match e with | `(@ite _ %%c %%_ _ _) := some c | `(@dite _ %%c %%_ _ _) := some c | _ := none end, guard ¬c.has_var, find_if_cond c <|> return c
def
tactic.find_if_cond
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_if_cond_at (at_ : loc) : tactic (option expr)
do lctx ← at_.get_locals, lctx ← lctx.mmap infer_type, tgt ← target, let es := if at_.include_goal then tgt::lctx else lctx, return $ find_if_cond $ es.foldr app default
def
tactic.find_if_cond_at
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
reduce_ifs_at (at_ : loc) : tactic unit
do sls ← get_user_simp_lemmas `split_if_reduction, let cfg : simp_config := { fail_if_unchanged := ff }, let discharger := assumption <|> (applyc `not_not_intro >> assumption), hs ← at_.get_locals, hs.mmap' (λ h, simp_hyp sls [] h cfg discharger >> skip), when at_.include_goal (simp_target sls [] cfg discharger >> skip...
def
tactic.reduce_ifs_at
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
split_if1 (c : expr) (n : name) (at_ : loc) : tactic unit
by_cases c n; reduce_ifs_at at_
def
tactic.split_if1
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_next_name (names : ref (list name)) : tactic name
do ns ← read_ref names, match ns with | [] := get_unused_name `h | n::ns := do write_ref names ns, return n end
def
tactic.get_next_name
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
value_known (c : expr) : tactic bool
do lctx ← local_context, lctx ← lctx.mmap infer_type, return $ c ∈ lctx ∨ `(¬%%c) ∈ lctx
def
tactic.value_known
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
split_ifs_core (at_ : loc) (names : ref (list name)) : list expr → tactic unit | done
do some cond ← find_if_cond_at at_ | fail "no if-then-else expressions to split", let cond := match cond with `(¬%%p) := p | p := p end, if cond ∈ done then skip else do no_split ← value_known cond, if no_split then reduce_ifs_at at_; try (split_ifs_core (cond :: done)) else do n ← get_next_name names, spli...
def
tactic.split_ifs_core
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
split_ifs (names : list name) (at_ : loc := loc.ns [none])
using_new_ref names $ λ names, split_ifs_core at_ names []
def
tactic.split_ifs
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
split_ifs (at_ : parse location) (names : parse with_ident_list) : tactic unit
tactic.split_ifs names at_
def
tactic.interactive.split_ifs
tactic
src/tactic/split_ifs.lean
[ "tactic.hint" ]
[ "tactic.split_ifs" ]
Splits all if-then-else-expressions into multiple goals. Given a goal of the form `g (if p then x else y)`, `split_ifs` will produce two goals: `p ⊢ g x` and `¬p ⊢ g y`. If there are multiple ite-expressions, then `split_ifs` will split them all, starting with a top-most one whose condition does not contain another i...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
loc.to_string_aux : option name → string
| none := "⊢" | (some x) := to_string x
def
loc.to_string_aux
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
loc.to_string : loc → string
| (loc.ns []) := "" | (loc.ns [none]) := "" | (loc.ns ls) := string.join $ list.intersperse " " (" at" :: ls.map loc.to_string_aux) | loc.wildcard := " at *"
def
loc.to_string
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "loc.to_string_aux" ]
pretty print a `loc`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pos.move_left (p : pos) (n : ℕ) : pos
{ line := p.line, column := p.column - n }
def
pos.move_left
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
shift `pos` `n` columns to the left
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
simp_arg_type.has_to_string : has_to_string simp_arg_type
⟨λ a, match a with | simp_arg_type.all_hyps := "*" | (simp_arg_type.except n) := "-" ++ to_string n | (simp_arg_type.expr e) := to_string e | (simp_arg_type.symm_expr e) := "←" ++ to_string e end⟩
instance
tactic.simp_arg_type.has_to_string
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
Turn a `simp_arg_type` into a string.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
struct_inst : lean.parser pexpr
with_desc "cfg" $ do tk "{", ls ← sep_by (skip_info (tk ",")) ( sum.inl <$> (tk ".." *> texpr) <|> sum.inr <$> (prod.mk <$> ident <* tk ":=" <*> texpr)), tk "}", let (srcs,fields) := partition_map id ls, let (names,values) := unzip fields, pure $ pexpr.mk_structure_instance { field_names := na...
def
tactic.struct_inst
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
parse structure instance of the shape `{ field1 := value1, .. , field2 := value2 }`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
struct.to_tactic_format (e : pexpr) : tactic format
do r ← e.get_structure_instance_info, fs ← mzip_with (λ n v, do v ← to_expr v >>= pp, pure $ format!"{n} := {v}" ) r.field_names r.field_values, let ss := r.sources.map (λ s, format!" .. {s}"), let x : format := format.join $ list.intersperse ", " (fs ++ ss), pure format!" {{{x}}}"
def
tactic.struct.to_tactic_format
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "mzip_with" ]
pretty print structure instance
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squeeze_loc_attr : user_attribute unit (option (list (pos × string × list simp_arg_type × string)))
{ name := `_squeeze_loc, parser := fail "this attribute should not be used", descr := "table to accumulate multiple `squeeze_simp` suggestions" }
def
tactic.squeeze_loc_attr
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
Attribute containing a table that accumulates multiple `squeeze_simp` suggestions
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squeeze_loc_attr_carrier
()
def
tactic.squeeze_loc_attr_carrier
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
dummy declaration used as target of `squeeze_loc` attribute
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
render_simp_arg_list : list simp_arg_type → format
| [] := "" | args := (++) " " $ to_line_wrap_format $ args.map to_string
def
tactic.render_simp_arg_list
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
Format a list of arguments for use with `simp` and friends. This omits the list entirely if it is empty. Patch: `pp` was changed to `to_string` because it was getting rid of prefixes that would be necessary for some disambiguations.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_suggestion (p : pos) (pre post : string) (args : list simp_arg_type) (at_pos := ff) : tactic unit
do xs ← squeeze_loc_attr.get_param ``squeeze_loc_attr_carrier, match xs with | none := do let args := render_simp_arg_list args, if at_pos then @scope_trace _ p.line p.column $ λ _, _root_.trace sformat!"{pre}{args}{post}" (pure () : tactic unit) else trace sformat!"{pre}{arg...
def
tactic.mk_suggestion
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
Emit a suggestion to the user. If inside a `squeeze_scope` block, the suggestions emitted through `mk_suggestion` will be aggregated so that every tactic that makes a suggestion can consider multiple execution of the same invocation. If `at_pos` is true, make the suggestion at `p` instead of the current position.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_config : option pexpr → tactic (simp_config_ext × format)
| none := pure ({}, "") | (some cfg) := do e ← to_expr ``(%%cfg : simp_config_ext), fmt ← has_to_tactic_format.to_tactic_format cfg, prod.mk <$> eval_expr simp_config_ext e <*> struct.to_tactic_format cfg
def
tactic.parse_config
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
translate a `pexpr` into a `simp` configuration
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_dsimp_config : option pexpr → tactic (dsimp_config × format)
| none := pure ({}, "") | (some cfg) := do e ← to_expr ``(%%cfg : simp_config_ext), fmt ← has_to_tactic_format.to_tactic_format cfg, prod.mk <$> eval_expr dsimp_config e <*> struct.to_tactic_format cfg
def
tactic.parse_dsimp_config
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
translate a `pexpr` into a `dsimp` configuration
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
same_result (pr : proof_state) (tac : tactic unit) : tactic bool
do s ← get_proof_state_after tac, pure $ some pr = s
def
tactic.same_result
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "get_proof_state_after", "proof_state" ]
`same_result proof tac` runs tactic `tac` and checks if the proof produced by `tac` is equivalent to `proof`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
filter_simp_set_aux (tac : bool → list simp_arg_type → tactic unit) (args : list simp_arg_type) (pr : proof_state) : list simp_arg_type → list simp_arg_type → list simp_arg_type → tactic (list simp_arg_type × list simp_arg_type)
| [] ys ds := pure (ys, ds) | (x :: xs) ys ds := do b ← same_result pr (tac tt (args ++ xs ++ ys)), if b then filter_simp_set_aux xs ys (ds.concat x) else filter_simp_set_aux xs (ys.concat x) ds declare_trace squeeze.deleted
def
tactic.filter_simp_set_aux
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "proof_state" ]
Consumes the first list of `simp` arguments, accumulating required arguments on the second one and unnecessary arguments on the third one.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
filter_simp_set (tac : bool → list simp_arg_type → tactic unit) (user_args simp_args : list simp_arg_type) : tactic (list simp_arg_type)
do some s ← get_proof_state_after (tac ff (user_args ++ simp_args)), (simp_args', _) ← filter_simp_set_aux tac user_args s simp_args [] [], (user_args', ds) ← filter_simp_set_aux tac simp_args' s user_args [] [], when (is_trace_enabled_for `squeeze.deleted = tt ∧ ¬ ds.empty) trace!"deleting provided argu...
def
tactic.filter_simp_set
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "get_proof_state_after" ]
`filter_simp_set g call_simp user_args simp_args` returns `args'` such that, when calling `call_simp tt /- only -/ args'` on the goal `g` (`g` is a meta var) we end up in the same state as if we had called `call_simp ff (user_args ++ simp_args)` and removing any one element of `args'` changes the resulting proof.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
name.to_simp_args (n : name) : simp_arg_type
simp_arg_type.expr $ @expr.local_const ff n n (default) pexpr.mk_placeholder
def
tactic.name.to_simp_args
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
make a `simp_arg_type` that references the name given as an argument
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prepend_root_if_needed (n : name) : tactic name
do x ← resolve_name' n, return $ match x with | expr.macro _ _ := `_root_ ++ n | _ := n end
def
tactic.prepend_root_if_needed
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
If the `name` is (likely) to be overloaded, then prepend a `_root_` on it. The `expr` of an overloaded name is constructed using `expr.macro`; this is how we guess whether it's overloaded.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squeeze_simp_core (slow no_dflt : bool) (args : list simp_arg_type) (tac : Π (no_dflt : bool) (args : list simp_arg_type), tactic unit) (mk_suggestion : list simp_arg_type → tactic unit) : tactic unit
do v ← target >>= mk_meta_var, args ← if slow then do simp_set ← attribute.get_instances `simp, simp_set ← simp_set.mfilter $ has_attribute' `_refl_lemma, simp_set ← simp_set.mmap $ resolve_name' >=> pure ∘ simp_arg_type.expr, pure $ args ++ simp_set else pure args, g ← retrieve $ do { g...
def
tactic.squeeze_simp_core
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "with_local_goals'" ]
tactic combinator to create a `simp`-like tactic that minimizes its argument list. * `slow`: adds all rfl-lemmas from the environment to the initial list (this is a slower but more accurate strategy) * `no_dflt`: did the user use the `only` keyword? * `args`: list of `simp` arguments * `tac`: how...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squeeze_scope (tac : itactic) : tactic unit
do none ← squeeze_loc_attr.get_param ``squeeze_loc_attr_carrier | pure (), squeeze_loc_attr.set ``squeeze_loc_attr_carrier (some []) ff, finally tac $ do some xs ← squeeze_loc_attr.get_param ``squeeze_loc_attr_carrier | fail "invalid state", let m := native.rb_lmap.of_list xs, squeeze_loc_attr.set ...
def
tactic.interactive.squeeze_scope
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "native.rb_lmap.of_list" ]
combinator meant to aggregate the suggestions issued by multiple calls of `squeeze_simp` (due, for instance, to `;`). Can be used as: ```lean example {α β} (xs ys : list α) (f : α → β) : (xs ++ ys.tail).map f = xs.map f ∧ (xs.tail.map f).length = xs.length := begin have : xs = ys, admit, squeeze_scope { split...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squeeze_simp (key : parse cur_pos) (slow_and_accurate : parse (tk "?")?) (use_iota_eqn : parse (tk "!")?) (no_dflt : parse only_flag) (hs : parse simp_arg_list) (attr_names : parse with_ident_list) (locat : parse location) (cfg : parse struct_inst?) : tactic unit
do (cfg',c) ← parse_config cfg, squeeze_simp_core slow_and_accurate.is_some no_dflt hs (λ l_no_dft l_args, simp use_iota_eqn none l_no_dft l_args attr_names locat cfg') (λ args, let use_iota_eqn := if use_iota_eqn.is_some then "!" else "", attrs := if attr_names.empty then "" ...
def
tactic.interactive.squeeze_simp
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "loc.to_string" ]
`squeeze_simp`, `squeeze_simpa` and `squeeze_dsimp` perform the same task with the difference that `squeeze_simp` relates to `simp` while `squeeze_simpa` relates to `simpa` and `squeeze_dsimp` relates to `dsimp`. The following applies to `squeeze_simp`, `squeeze_simpa` and `squeeze_dsimp`. `squeeze_simp` behaves like ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squeeze_simpa (key : parse cur_pos) (slow_and_accurate : parse (tk "?")?) (use_iota_eqn : parse (tk "!")?) (no_dflt : parse only_flag) (hs : parse simp_arg_list) (attr_names : parse with_ident_list) (tgt : parse (tk "using" *> texpr)?) (cfg : parse struct_inst?) : tactic unit
do (cfg',c) ← parse_config cfg, tgt' ← traverse (λ t, do t ← to_expr t >>= pp, pure format!" using {t}") tgt, squeeze_simp_core slow_and_accurate.is_some no_dflt hs (λ l_no_dft l_args, simpa use_iota_eqn none l_no_dft l_args attr_names tgt cfg') (λ args, let use_iota_...
def
tactic.interactive.squeeze_simpa
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[]
see `squeeze_simp`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
squeeze_dsimp (key : parse cur_pos) (slow_and_accurate : parse (tk "?")?) (use_iota_eqn : parse (tk "!")?) (no_dflt : parse only_flag) (hs : parse simp_arg_list) (attr_names : parse with_ident_list) (locat : parse location) (cfg : parse struct_inst?) : tactic unit
do (cfg',c) ← parse_dsimp_config cfg, squeeze_simp_core slow_and_accurate.is_some no_dflt hs (λ l_no_dft l_args, dsimp l_no_dft l_args attr_names locat cfg') (λ args, let use_iota_eqn := if use_iota_eqn.is_some then "!" else "", attrs := if attr_names.empty then "" ...
def
tactic.interactive.squeeze_dsimp
tactic
src/tactic/squeeze.lean
[ "control.traversable.basic", "tactic.simpa" ]
[ "loc.to_string" ]
`squeeze_dsimp` behaves like `dsimp` (including all its arguments) and prints a `dsimp only` invocation to skip the search through the `simp` lemma list. See the doc string of `squeeze_simp` for examples.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_mem_name (sub : name) : name → name
| (mk_string n _) := mk_string (n ++ "_mem") sub | n := n
def
tactic.mk_mem_name
tactic
src/tactic/subtype_instance.lean
[ "tactic.basic" ]
[]
makes the substructure axiom name from field name, by postfacing with `_mem`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
derive_field_subtype : tactic unit
do field ← get_current_field, b ← target >>= is_prop, if b then do `[simp [subtype.ext_iff_val], dsimp [set.coe_eq_subtype]], intros, applyc field; assumption else do s ← find_local ``(set _), `(set %%α) ← infer_type s, e ← mk_const field, expl_arity ← get_expl_arity $ e α, xs ←...
def
tactic.derive_field_subtype
tactic
src/tactic/subtype_instance.lean
[ "tactic.basic" ]
[ "field", "set.coe_eq_subtype", "subtype.ext_iff_val" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
subtype_instance
do t ← target, let cl := t.get_app_fn.const_name, src ← find_ancestors cl t.app_arg, let inst := pexpr.mk_structure_instance { struct := cl, field_values := [], field_names := [], sources := src.map to_pexpr }, refine_struct inst ; derive_field_subtype
def
tactic.interactive.subtype_instance
tactic
src/tactic/subtype_instance.lean
[ "tactic.basic" ]
[]
builds instances for algebraic substructures Example: ```lean variables {α : Type*} [monoid α] {s : set α} class is_submonoid (s : set α) : Prop := (one_mem : (1:α) ∈ s) (mul_mem {a b} : a ∈ s → b ∈ s → a * b ∈ s) instance subtype.monoid {s : set α} [is_submonoid s] : monoid s := by subtype_instance ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
normalize_synonym : name → name
| `gt := `has_lt.lt | `ge := `has_le.le | `monotone := `has_le.le | `not := `false | n := n
def
tactic.suggest.normalize_synonym
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[ "monotone" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
allowed_head_symbols : expr → list name -- We first have a various "customisations": -- Because in `ℕ` `a.succ ≤ b` is definitionally `a < b`, -- we add some special cases to allow looking for `<` lemmas even when the goal has a `≤`. -- Note we only do this in the `ℕ` case, for performance.
| `(@has_le.le ℕ _ (nat.succ _) _) := [`has_le.le, `has_lt.lt] | `(@ge ℕ _ _ (nat.succ _)) := [`has_le.le, `has_lt.lt] | `(@has_le.le ℕ _ 1 _) := [`has_le.le, `has_lt.lt] | `(@ge ℕ _ _ 1) := [`has_le.le, `has_lt.lt] -- These allow `library_search` to search for lemmas of type `¬ a = b` when proving `a ≠ b` -- and vi...
def
tactic.suggest.allowed_head_symbols
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
head_symbol_match | ex | mp | mpr | both
inductive
tactic.suggest.head_symbol_match
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
A declaration can match the head symbol of the current goal in four possible ways: * `ex` : an exact match * `mp` : the declaration returns an `iff`, and the right hand side matches the goal * `mpr` : the declaration returns an `iff`, and the left hand side matches the goal * `both`: the declaration returns an `iff`,...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
head_symbol_match.to_string : head_symbol_match → string
| ex := "exact" | mp := "iff.mp" | mpr := "iff.mpr" | both := "iff.mp and iff.mpr"
def
tactic.suggest.head_symbol_match.to_string
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
a textual representation of a `head_symbol_match`, for trace debugging.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_head_symbol (hs : name_set) : expr → option head_symbol_match
| (expr.pi _ _ _ t) := match_head_symbol t | `(%%a ↔ %%b) := if hs.contains `iff then some ex else match (match_head_symbol a, match_head_symbol b) with | (some ex, some ex) := some both | (some ex, _) := some mpr ...
def
tactic.suggest.match_head_symbol
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
Determine if, and in which way, a given expression matches the specified head symbol.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
decl_data
(d : declaration) (n : name) (m : head_symbol_match) (l : ℕ)
structure
tactic.suggest.decl_data
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
A package of `declaration` metadata, including the way in which its type matches the head symbol which we are searching for.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
process_declaration (hs : name_set) (d : declaration) : option decl_data
let n := d.to_name in if !d.is_trusted || n.is_internal then none else (λ m, ⟨d, n, m, n.length⟩) <$> match_head_symbol hs d.type
def
tactic.suggest.process_declaration
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
library_defs (hs : name_set) : tactic (list decl_data)
do trace_if_enabled `suggest format!"Looking for lemmas with head symbols {hs}.", env ← get_env, let defs := env.decl_filter_map (process_declaration hs), -- Sort by length; people like short proofs let defs := defs.qsort(λ d₁ d₂, d₁.l ≤ d₂.l), trace_if_enabled `suggest format!"Found {defs.length} releva...
def
tactic.suggest.library_defs
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[ "trace_if_enabled" ]
Retrieve all library definitions with a given head symbol.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unpack_iff_both : list decl_data → list decl_data
| [] := [] | (⟨d, n, both, l⟩ :: L) := ⟨d, n, mp, l⟩ :: ⟨d, n, mpr, l⟩ :: unpack_iff_both L | (⟨d, n, m, l⟩ :: L) := ⟨d, n, m, l⟩ :: unpack_iff_both L
def
tactic.suggest.unpack_iff_both
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
We unpack any element of a list of `decl_data` corresponding to an `↔` statement that could apply in both directions into two separate elements. This ensures that both directions can be independently returned by `suggest`, and avoids a problem where the application of one direction prevents the application of the othe...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
suggest_opt extends opt
(compulsory_hyps : list expr := []) (try_this : bool := tt)
structure
tactic.suggest.suggest_opt
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
An extension to the option structure for `solve_by_elim`. * `compulsory_hyps` specifies a list of local hypotheses which must appear in any solution. These are useful for constraining the results from `library_search` and `suggest`. * `try_this` is a flag (default: `tt`) that controls whether a "Try this:"-line shoul...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
suggest_opt.mk_accept (o : suggest_opt) : opt
{ accept := λ gs, o.accept gs >> (guard $ o.compulsory_hyps.all (λ h, gs.any (λ g, g.contains_expr_or_mvar h))), ..o }
def
tactic.suggest.suggest_opt.mk_accept
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
Convert a `suggest_opt` structure to a `opt` structure suitable for `solve_by_elim`, by setting the `accept` parameter to require that all complete solutions use everything in `compulsory_hyps`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_and_solve (close_goals : bool) (opt : suggest_opt := { }) (e : expr) : tactic ℕ
do trace_if_enabled `suggest format!"Trying to apply lemma: {e}", apply e opt.to_apply_cfg, trace_if_enabled `suggest format!"Applied lemma: {e}", ng ← num_goals, -- Phase 1 -- Run `solve_by_elim` on each "safe" goal separately, not worrying about failures. -- (We only attempt the "safe" goals in this way...
def
tactic.suggest.apply_and_solve
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[ "trace_if_enabled" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_declaration (close_goals : bool) (opt : suggest_opt := { }) (d : decl_data) : tactic ℕ
let tac := apply_and_solve close_goals opt in do (e, t) ← decl_mk_const d.d, match d.m with | ex := tac e | mp := do l ← iff_mp_core e t, tac l | mpr := do l ← iff_mpr_core e t, tac l | both := undefined -- we use `unpack_iff_both` to ensure this isn't reachable end
def
tactic.suggest.apply_declaration
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
Apply the declaration `d` (or the forward and backward implications separately, if it is an `iff`), and then attempt to solve the subgoal using `apply_and_solve`. Returns the number of subgoals successfully closed.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
application
(state : tactic_state) (script : string) (decl : option declaration) (num_goals : ℕ) (hyps_used : list expr)
structure
tactic.suggest.application
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
An `application` records the result of a successful application of a library lemma.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_declaration_script (g : expr) (hyps : list expr) (opt : suggest_opt := { }) (d : decl_data) : tactic application
-- (This tactic block is only executed when we evaluate the mllist, -- so we need to do the `focus1` here.) retrieve $ focus1 $ do apply_declaration ff opt d, -- This `instantiate_mvars` is necessary so that we count used hypotheses correctly. g ← instantiate_mvars g, guard $ (opt.compulsory_hyps.all (λ h, h.oc...
def
tactic.apply_declaration_script
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[ "tactic_statement" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
suggest_core' (opt : suggest_opt := { }) : tactic (mllist tactic application)
do g :: _ ← get_goals, hyps ← local_context, -- Check if `solve_by_elim` can solve the goal immediately: (retrieve (do focus1 $ solve_by_elim opt.mk_accept, s ← read, m ← tactic_statement g, -- This `instantiate_mvars` is necessary so that we count used hypotheses correctly. g ← insta...
def
tactic.suggest_core'
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[ "tactic_statement" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
suggest_core (opt : suggest_opt := { }) : mllist tactic application
(mllist.monad_lift (suggest_core' opt)).join
def
tactic.suggest_core
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
The core `suggest` tactic. It attempts to apply a declaration from the library, then solve new goals using `solve_by_elim`. It returns a list of `application`s consisting of fields: * `state`, a tactic state resulting from the successful application of a declaration from the library, * `script`, a string of the form...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
suggest (limit : option ℕ := none) (opt : suggest_opt := { }) : tactic (list application)
do let results := suggest_core opt, -- Get the first n elements of the successful lemmas L ← if h : limit.is_some then results.take (option.get h) else results.force, -- Sort by number of remaining goals, then by number of hypotheses used. return $ L.qsort (λ d₁ d₂, d₁.num_goals < d₂.num_goals ∨ (d₁.num...
def
tactic.suggest
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
See `suggest_core`. Returns a list of at most `limit` `application`s, sorted by number of goals, and then (reverse) number of hypotheses used.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
suggest_scripts (limit : option ℕ := none) (opt : suggest_opt := { }) : tactic (list string)
do L ← suggest limit opt, return $ L.map application.script
def
tactic.suggest_scripts
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
Returns a list of at most `limit` strings, of the form `Try this: exact ...` or `Try this: refine ...`, which make progress on the current goal using a declaration from the library.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
library_search (opt : suggest_opt := { }) : tactic string
(suggest_core opt).mfirst (λ a, do guard (a.num_goals = 0), write a.state, return a.script)
def
tactic.library_search
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
Returns a string of the form `Try this: exact ...`, which closes the current goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
suggest (n : parse (with_desc "n" small_nat)?) (hs : parse simp_arg_list) (attr_names : parse with_ident_list) (use : parse $ (tk "using" *> many ident_) <|> return []) (opt : suggest_opt := { }) : tactic unit
do (lemma_thunks, ctx_thunk) ← mk_assumption_set ff hs attr_names, use ← use.mmap get_local, L ← tactic.suggest_scripts (n.get_or_else 50) { compulsory_hyps := use, lemma_thunks := some lemma_thunks, ctx_thunk := ctx_thunk, ..opt }, if !opt.try_this || is_trace_enabled_for `silence_suggest th...
def
tactic.interactive.suggest
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[ "tactic.suggest_scripts" ]
`suggest` tries to apply suitable theorems/defs from the library, and generates a list of `exact ...` or `refine ...` scripts that could be used at this step. It leaves the tactic state unchanged. It is intended as a complement of the search function in your editor, the `#find` tactic, and `library_search`. `suggest` ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
library_search (semireducible : parse $ optional (tk "!")) (hs : parse simp_arg_list) (attr_names : parse with_ident_list) (use : parse $ (tk "using" *> many ident_) <|> return []) (opt : suggest_opt := { }) : tactic unit
do (lemma_thunks, ctx_thunk) ← mk_assumption_set ff hs attr_names, use ← use.mmap get_local, (tactic.library_search { compulsory_hyps := use, backtrack_all_goals := tt, lemma_thunks := some lemma_thunks, ctx_thunk := ctx_thunk, md := if semireducible.is_some then tactic.t...
def
tactic.interactive.library_search
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[ "tactic.library_search" ]
`library_search` is a tactic to identify existing lemmas in the library. It tries to close the current goal by applying a lemma from the library, then discharging any new goals using `solve_by_elim`. If it succeeds, it prints a trace message `exact ...` which can replace the invocation of `library_search`. Typical us...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
library_search_hole_cmd : hole_command
{ name := "library_search", descr := "Use `library_search` to complete the goal.", action := λ _, do script ← library_search, -- Is there a better API for dropping the 'Try this: exact ' prefix on this string? return [((script.get_rest "Try this: exact ").get_or_else script, "by library_search")] }
def
tactic.library_search_hole_cmd
tactic
src/tactic/suggest.lean
[ "data.bool.basic", "data.mllist", "tactic.solve_by_elim" ]
[]
Invoking the hole command `library_search` ("Use `library_search` to complete the goal") calls the tactic `library_search` to produce a proof term with the type of the hole. Running it on ```lean example : 0 < 1 := {!!} ``` produces ```lean example : 0 < 1 := nat.one_pos ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
swap_arg_parser : lean.parser (name × name)
prod.mk <$> ident <*> (optional (tk "<->" <|> tk "↔") *> ident)
def
tactic.interactive.swap_arg_parser
tactic
src/tactic/swap_var.lean
[ "tactic.interactive" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
swap_args_parser : lean.parser (list (name × name))
(functor.map (λ x, [x]) swap_arg_parser) <|> (tk "[" *> sep_by (tk ",") swap_arg_parser <* tk "]")
def
tactic.interactive.swap_args_parser
tactic
src/tactic/swap_var.lean
[ "tactic.interactive" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
swap_var (renames : parse swap_args_parser) : tactic unit
do renames.mmap' (λ e, do n ← tactic.get_unused_name, -- how to call `interactive.tactic.rename` here? propagate_tags $ tactic.rename_many $ native.rb_map.of_list [(e.1, n), (e.2, e.1)], propagate_tags $ tactic.rename_many $ native.rb_map.of_list [(n, e.2)]), pure ()
def
tactic.interactive.swap_var
tactic
src/tactic/swap_var.lean
[ "tactic.interactive" ]
[]
`swap_var [x y, P ↔ Q]` swaps the names `x` and `y`, `P` and `Q`. Such a swapping can be used as a weak `wlog` if the tactic proofs use the same names. ```lean example (P Q : Prop) (hp : P) (hq : Q) : P ∧ Q := begin split, work_on_goal 1 { swap_var [P Q] }, all_goals { exact ‹P› } end ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
distrib_not : tactic unit
do hs ← local_context, hs.for_each $ λ h, all_goals' $ iterate_at_most' 3 $ do h ← get_local h.local_pp_name, e ← infer_type h, match e with | `(¬ _ = _) := replace h.local_pp_name ``(mt iff.to_eq %%h) | `(_ ≠ _) := replace h.local_pp_name ``(mt iff.to_eq %%h) ...
def
tactic.distrib_not
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
find all assumptions of the shape `¬ (p ∧ q)` or `¬ (p ∨ q)` and replace them using de Morgan's law.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tauto_state
ref $ expr_map (option (expr × expr))
def
tactic.tauto_state
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
modify_ref {α : Type} (r : ref α) (f : α → α)
read_ref r >>= write_ref r ∘ f
def
tactic.modify_ref
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_refl (r : tauto_state) (e : expr) : tactic (expr × expr)
do m ← read_ref r, p ← mk_mapp `rfl [none,e], write_ref r $ m.insert e none, return (e,p)
def
tactic.add_refl
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_symm_proof (r : tauto_state) (e : expr) : tactic (expr × expr)
do env ← get_env, let rel := e.get_app_fn.const_name, some symm ← pure $ environment.symm_for env rel | add_refl r e, (do e' ← mk_meta_var `(Prop), iff_t ← to_expr ``(%%e = %%e'), (_,p) ← solve_aux iff_t (applyc `iff.to_eq ; () <$ split ; applyc symm), e' ← instantiate_mvars ...
def
tactic.add_symm_proof
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[ "rel" ]
If there exists a symmetry lemma that can be applied to the hypothesis `e`, store it.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
add_edge (r : tauto_state) (x y p : expr) : tactic unit
modify_ref r $ λ m, m.insert x (y,p)
def
tactic.add_edge
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
root (r : tauto_state) : expr → tactic (expr × expr) | e
do m ← read_ref r, let record_e : tactic (expr × expr) := match e with | v@(expr.mvar _ _ _) := (do (e,p) ← get_assignment v >>= root, add_edge r v e p, return (e,p)) <|> add_refl r e | _ := add_refl r e end, some e' ← pure $ m.find e | recor...
def
tactic.root
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
Retrieve the root of the hypothesis `e` from the proof forest. If `e` has not been internalized, add it to the proof forest.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
symm_eq (r : tauto_state) : expr → expr → tactic expr | a b
do m ← read_ref r, (a',pa) ← root r a, (b',pb) ← root r b, (unify a' b' >> add_refl r a' *> mk_mapp `rfl [none,a]) <|> do p ← match (a', b') with | (`(¬ %%a₀), `(¬ %%b₀)) := do p ← symm_eq a₀ b₀, p' ← mk_app `congr_arg [`(not),p], add_edge r a' b' p'...
def
tactic.symm_eq
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
Given hypotheses `a` and `b`, build a proof that `a` is equivalent to `b`, applying congruence and recursing into arguments if `a` and `b` are applications of function symbols.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_eq_type (r : tauto_state) : expr → list expr → tactic (expr × expr)
| e [] := failed | e (H :: Hs) := do t ← infer_type H, (prod.mk H <$> symm_eq r e t) <|> find_eq_type e Hs
def
tactic.find_eq_type
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
contra_p_not_p (r : tauto_state) : list expr → list expr → tactic unit
| [] Hs := failed | (H1 :: Rs) Hs := do t ← (extract_opt_auto_param <$> infer_type H1) >>= whnf, (do a ← match_not t, (H2,p) ← find_eq_type r a Hs, H2 ← to_expr ``( (%%p).mpr %%H2 ), tgt ← target, pr ← mk_app `absurd [tgt, H2, H1], tactic.exact pr) <|...
def
tactic.contra_p_not_p
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
contradiction_with (r : tauto_state) : tactic unit
contradiction <|> do tactic.try intro1, ctx ← local_context, contra_p_not_p r ctx ctx
def
tactic.contradiction_with
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
contradiction_symm
using_new_ref (native.rb_map.mk _ _) contradiction_with
def
tactic.contradiction_symm
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assumption_with (r : tauto_state) : tactic unit
do { ctx ← local_context, t ← target, (H,p) ← find_eq_type r t ctx, mk_eq_mpr p H >>= tactic.exact } <|> fail "assumption tactic failed"
def
tactic.assumption_with
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assumption_symm
using_new_ref (native.rb_map.mk _ _) assumption_with
def
tactic.assumption_symm
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tauto_cfg
(classical : bool := ff) (closer : tactic unit := pure ())
structure
tactic.tauto_cfg
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
Configuration options for `tauto`. If `classical` is `tt`, runs `classical` before the rest of `tauto`. `closer` is run on any remaining subgoals left by `tauto_core; basic_tauto_tacs`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tautology (cfg : tauto_cfg := {}) : tactic unit
focus1 $ let basic_tauto_tacs : list (tactic unit) := [reflexivity, solve_by_elim, constructor_matching none [``(_ ∧ _),``(_ ↔ _),``(Exists _),``(true)]], tauto_core (r : tauto_state) : tactic unit := do try (contradiction_with r); try (assumption_with r); repeat...
def
tactic.tautology
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tautology (c : parse $ (tk "!")?) (cfg : tactic.tauto_cfg := {})
tactic.tautology $ { classical := c.is_some, ..cfg }
def
tactic.interactive.tautology
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[ "tactic.tauto_cfg", "tactic.tautology" ]
`tautology` breaks down assumptions of the form `_ ∧ _`, `_ ∨ _`, `_ ↔ _` and `∃ _, _` and splits a goal of the form `_ ∧ _`, `_ ↔ _` or `∃ _, _` until it can be discharged using `reflexivity` or `solve_by_elim`. This is a finishing tactic: it either closes the goal or raises an error. The variant `tautology!` uses the...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tauto (c : parse $ (tk "!")?) (cfg : tactic.tauto_cfg := {}) : tactic unit
tautology c cfg
def
tactic.interactive.tauto
tactic
src/tactic/tauto.lean
[ "tactic.hint" ]
[ "tactic.tauto_cfg" ]
`tauto` breaks down assumptions of the form `_ ∧ _`, `_ ∨ _`, `_ ↔ _` and `∃ _, _` and splits a goal of the form `_ ∧ _`, `_ ↔ _` or `∃ _, _` until it can be discharged using `reflexivity` or `solve_by_elim`. This is a finishing tactic: it either closes the goal or raises an error. The variant `tauto!` uses the law of ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
arrow : Type | right : arrow | left_right : arrow | left : arrow
inductive
tactic.tfae.arrow
tactic
src/tactic/tfae.lean
[ "data.list.tfae", "tactic.scc" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_implication : Π (re : arrow) (e₁ e₂ : expr), pexpr
| arrow.right e₁ e₂ := ``(%%e₁ → %%e₂) | arrow.left_right e₁ e₂ := ``(%%e₁ ↔ %%e₂) | arrow.left e₁ e₂ := ``(%%e₂ → %%e₁)
def
tactic.tfae.mk_implication
tactic
src/tactic/tfae.lean
[ "data.list.tfae", "tactic.scc" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_name : Π (re : arrow) (i₁ i₂ : nat), name
| arrow.right i₁ i₂ := ("tfae_" ++ to_string i₁ ++ "_to_" ++ to_string i₂ : string) | arrow.left_right i₁ i₂ := ("tfae_" ++ to_string i₁ ++ "_iff_" ++ to_string i₂ : string) | arrow.left i₁ i₂ := ("tfae_" ++ to_string i₂ ++ "_to_" ++ to_string i₁ : string)
def
tactic.tfae.mk_name
tactic
src/tactic/tfae.lean
[ "data.list.tfae", "tactic.scc" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_list : expr → option (list expr)
| `([]) := pure [] | `(%%e :: %%es) := (::) e <$> parse_list es | _ := none
def
tactic.interactive.parse_list
tactic
src/tactic/tfae.lean
[ "data.list.tfae", "tactic.scc" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tfae_have (h : parse $ optional ident <* tk ":") (i₁ : parse (with_desc "i" small_nat)) (re : parse (((tk "→" <|> tk "->") *> return arrow.right) <|> ((tk "↔" <|> tk "<->") *> return arrow.left_right) <|> ((tk "←" <|> tk "<-") *> return arrow.left))) (i₂ : parse (with_desc "...
do `(tfae %%l) <- target, l ← parse_list l, e₁ ← list.nth l (i₁ - 1) <|> fail format!"index {i₁} is not between 1 and {l.length}", e₂ ← list.nth l (i₂ - 1) <|> fail format!"index {i₂} is not between 1 and {l.length}", type ← to_expr (tfae.mk_implication re e₁ e₂), let h := h.get_or_else (mk_name...
def
tactic.interactive.tfae_have
tactic
src/tactic/tfae.lean
[ "data.list.tfae", "tactic.scc" ]
[]
In a goal of the form `tfae [a₀, a₁, a₂]`, `tfae_have : i → j` creates the assertion `aᵢ → aⱼ`. The other possible notations are `tfae_have : i ← j` and `tfae_have : i ↔ j`. The user can also provide a label for the assertion, as with `have`: `tfae_have h : i ↔ j`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tfae_finish : tactic unit
applyc ``tfae_nil <|> closure.with_new_closure (λ cl, do impl_graph.mk_scc cl, `(tfae %%l) ← target, l ← parse_list l, (_,r,_) ← cl.root l.head, refine ``(tfae_of_forall %%r _ _), thm ← mk_const ``forall_mem_cons, l.mmap' (λ e, do rewrite_target thm, split, (_,r',p) ← cl.root e, t...
def
tactic.interactive.tfae_finish
tactic
src/tactic/tfae.lean
[ "data.list.tfae", "tactic.scc" ]
[]
Finds all implications and equivalences in the context to prove a goal of the form `tfae [...]`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tidy_attribute : user_attribute
{ name := `tidy, descr := "A tactic that should be called by `tidy`." }
def
tactic.tidy.tidy_attribute
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[]
Tag interactive tactics (locally) with `[tidy]` to add them to the list of default tactics called by `tidy`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
run_tactics : tactic string
do names ← attribute.get_instances `tidy, first (names.map name_to_tactic) <|> fail "no @[tidy] tactics succeeded"
def
tactic.tidy.run_tactics
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[ "name_to_tactic" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ext1_wrapper : tactic string
do ng ← num_goals, ext1 [] {apply_cfg . new_goals := new_goals.all}, ng' ← num_goals, return $ if ng' > ng then "tactic.ext1 [] {new_goals := tactic.new_goals.all}" else "ext1"
def
tactic.tidy.ext1_wrapper
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
default_tactics : list (tactic string)
[ reflexivity >> pure "refl", `[exact dec_trivial] >> pure "exact dec_trivial", propositional_goal >> assumption >> pure "assumption", intros1 >>= λ ns, pure ("intros " ++ (" ".intercalate $ ...
def
tactic.tidy.default_tactics
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
cfg
(trace_result : bool := ff) (trace_result_prefix : string := "Try this: ") (tactics : list (tactic string) := default_tactics) declare_trace tidy
structure
tactic.tidy.cfg
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
core (cfg : cfg := {}) : tactic (list string)
do results ← chain cfg.tactics, when (cfg.trace_result) $ trace (cfg.trace_result_prefix ++ (", ".intercalate results)), return results
def
tactic.tidy.core
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tidy (cfg : tidy.cfg := {})
tactic.tidy.core cfg >> skip
def
tactic.tidy
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[ "tactic.tidy.core" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tidy (trace : parse $ optional (tk "?")) (cfg : tidy.cfg := {})
tactic.tidy { trace_result := trace.is_some, ..cfg }
def
tactic.interactive.tidy
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[ "tactic.tidy" ]
Use a variety of conservative tactics to solve goals. `tidy?` reports back the tactic script it found. As an example ```lean example : ∀ x : unit, x = unit.star := begin tidy? -- Prints the trace message: "Try this: intros x, exact dec_trivial" end ``` The default list of tactics is stored in `tactic.tidy.default_t...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tidy_hole_cmd : hole_command
{ name := "tidy", descr := "Use `tidy` to complete the goal.", action := λ _, do script ← tidy.core, return [("begin " ++ (", ".intercalate script) ++ " end", "by tidy")] }
def
tactic.tidy_hole_cmd
tactic
src/tactic/tidy.lean
[ "tactic.auto_cases", "tactic.chain", "tactic.norm_cast" ]
[]
Invoking the hole command `tidy` ("Use `tidy` to complete the goal") runs the tactic of the same name, replacing the hole with the tactic script `tidy` produces.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83