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
linter.instance_priority : linter
{ test := instance_priority, no_errors_found := "All instance priorities are good.", errors_found := "DANGEROUS INSTANCE PRIORITIES. The following instances always apply, and therefore should have a priority < 1000. If you don't know what priority to choose, use priority 100. See note [lower instance priority] for ...
def
linter.instance_priority
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "instance_priority", "linter" ]
A linter object for checking instance priorities of instances that always apply. This is in the default linter set.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_nonempty_instance (d : declaration) : tactic (option string)
do tt ← pure d.is_trusted | pure none, ff ← has_attribute' `reducible d.to_name | pure none, ff ← has_attribute' `class d.to_name | pure none, (_, ty) ← open_pis d.type, ty ← whnf ty, if ty = `(Prop) then pure none else do `(Sort _) ← whnf ty | pure none, insts ← attribute.get_instances `instance, insts_tys ← insts.mma...
def
has_nonempty_instance
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "expr.pi_codomain", "unique" ]
Reports declarations of types that do not have an nonemptiness instance. A `nonempty`, `inhabited` or `unique` instance suffices, and we prefer a computable `inhabited` or `unique` instance if possible.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.has_nonempty_instance : linter
{ test := has_nonempty_instance, auto_decls := ff, no_errors_found := "No types have missing nonempty instances.", errors_found := "TYPES ARE MISSING NONEMPTY INSTANCES. The following types should have an associated instance of the class `nonempty`, or if computably possible `inhabited` or `unique`:", is_fast :...
def
linter.has_nonempty_instance
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "has_nonempty_instance", "linter" ]
A linter for missing `nonempty` instances.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
impossible_instance (d : declaration) : tactic (option string)
do tt ← is_instance d.to_name | return none, (binders, _) ← get_pi_binders_nondep d.type, let bad_arguments := binders.filter $ λ nb, nb.2.info ≠ binder_info.inst_implicit, _ :: _ ← return bad_arguments | return none, (λ s, some $ "Impossible to infer " ++ s) <$> print_arguments bad_arguments
def
impossible_instance
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "print_arguments" ]
Checks whether an instance can never be applied.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.impossible_instance : linter
{ test := impossible_instance, auto_decls := tt, no_errors_found := "All instances are applicable.", errors_found := "IMPOSSIBLE INSTANCES FOUND. These instances have an argument that cannot be found during type-class resolution, and " ++ "therefore can never succeed. Either mark the arguments with square bracket...
def
linter.impossible_instance
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "impossible_instance", "linter" ]
A linter object for `impossible_instance`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
incorrect_type_class_argument (d : declaration) : tactic (option string)
do (binders, _) ← get_pi_binders d.type, let instance_arguments := binders.indexes_values $ λ b : binder, b.info = binder_info.inst_implicit, /- the head of the type should either unfold to a class, or be a local constant. A local constant is allowed, because that could be a class when applied to the prop...
def
incorrect_type_class_argument
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "binder", "print_arguments" ]
Checks whether an instance can never be applied.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.incorrect_type_class_argument : linter
{ test := incorrect_type_class_argument, auto_decls := tt, no_errors_found := "All declarations have correct type-class arguments.", errors_found := "INCORRECT TYPE-CLASS ARGUMENTS. Some declarations have non-classes between [square brackets]:" }
def
linter.incorrect_type_class_argument
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "incorrect_type_class_argument", "linter" ]
A linter object for `incorrect_type_class_argument`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
dangerous_instance (d : declaration) : tactic (option string)
do tt ← is_instance d.to_name | return none, (local_constants, target) ← open_pis d.type, let instance_arguments := local_constants.indexes_values $ λ e : expr, e.local_binding_info = binder_info.inst_implicit, let bad_arguments := local_constants.indexes_values $ λ x, !target.has_local_constant x && ...
def
dangerous_instance
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "binder", "print_arguments" ]
Checks whether an instance is dangerous: it creates a new type-class problem with metavariable arguments.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.dangerous_instance : linter
{ test := dangerous_instance, no_errors_found := "No dangerous instances.", errors_found := "DANGEROUS INSTANCES FOUND.\nThese instances are recursive, and create a new " ++ "type-class problem which will have metavariables. Possible solution: remove the instance attribute or make it a local instance instead. Curr...
def
linter.dangerous_instance
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "dangerous_instance", "linter" ]
A linter object for `dangerous_instance`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_nondep_aux : list expr → expr_set → tactic expr_set
| [] r := return r | (h::hs) r := do type ← infer_type h, find_nondep_aux hs $ r.union type.list_local_consts'
def
find_nondep_aux
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[]
Auxilliary definition for `find_nondep`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_nondep : tactic (list expr)
do ctx ← local_context, tgt ← target, lconsts ← find_nondep_aux ctx tgt.list_local_consts', return $ ctx.filter $ λ e, !lconsts.contains e
def
find_nondep
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "find_nondep_aux" ]
Finds all hypotheses that don't occur in the target or other hypotheses.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
fails_quickly (max_steps : ℕ) (d : declaration) : tactic (option string)
retrieve $ do tt ← is_instance d.to_name | return none, let e := d.type, g ← mk_meta_var e, set_goals [g], intros, l@(_::_) ← find_nondep | return none, -- if all arguments occur in the goal, this instance is ok clear l.ilast, reset_instance_cache, state ← read, let state_msg := "\nState:\n" ++ to_s...
def
fails_quickly
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "find_nondep", "retrieve_or_report_error" ]
Tests whether type-class inference search will end quickly on certain unsolvable type-class problems. This is to detect loops or very slow searches, which are problematic (recall that normal type-class search often creates unsolvable subproblems, which have to fail quickly for type-class inference to perform well. We c...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.fails_quickly : linter
{ test := fails_quickly 30000, auto_decls := tt, no_errors_found := "No type-class searches timed out.", errors_found := "TYPE CLASS SEARCHES TIMED OUT. The following instances are part of a loop, or an excessively long search. It is common that the loop occurs in a different class than the one flagged below, but...
def
linter.fails_quickly
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "fails_quickly", "linter" ]
A linter object for `fails_quickly`. We currently set the number of steps in the type-class search pretty high. Some instances take quite some time to fail, and we seem to run against the caching issue in https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/odd.20repeated.20type.20class.20search
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
class_structure (n : name) : tactic (option string)
do is_class ← has_attribute' `class n, if is_class then do env ← get_env, pure $ if env.is_inductive n then none else "is a non-structure or inductive type marked @[class]" else pure none
def
class_structure
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[]
Checks that all uses of the `@[class]` attribute apply to structures or inductive types. This is future-proofing for lean 4, which no longer supports `@[class] def`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.class_structure : linter
{ test := λ d, class_structure d.to_name, auto_decls := tt, no_errors_found := "All classes are structures.", errors_found := "USE OF @[class] def IS DISALLOWED:" }
def
linter.class_structure
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "class_structure", "linter" ]
A linter object for `class_structure`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_coe_variable (d : declaration) : tactic (option string)
do tt ← is_instance d.to_name | return none, `(has_coe %%a %%b) ← return d.type.pi_codomain | return none, if a.is_var then return $ some $ "illegal instance, first argument is variable" else if b.is_var ∧ ¬ b.occurs a then return $ some $ "illegal instance, second argument is variable not occurring in first argume...
def
has_coe_variable
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[]
Tests whether there is no instance of type `has_coe α t` where `α` is a variable, or `has_coe t α` where `α` does not occur in `t`. See note [use has_coe_t].
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.has_coe_variable : linter
{ test := has_coe_variable, auto_decls := tt, no_errors_found := "No invalid `has_coe` instances.", errors_found := "INVALID `has_coe` INSTANCES. Make the following declarations instances of the class `has_coe_t` instead of `has_coe`." }
def
linter.has_coe_variable
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "has_coe_variable", "linter" ]
A linter object for `has_coe_variable`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
inhabited_nonempty (d : declaration) : tactic (option string)
do tt ← is_prop d.type | return none, (binders, _) ← get_pi_binders_nondep d.type, let inhd_binders := binders.filter $ λ pr, pr.2.type.is_app_of `inhabited, if inhd_binders.length = 0 then return none else (λ s, some $ "The following `inhabited` instances should be `nonempty`. " ++ s) <$> print_argum...
def
inhabited_nonempty
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "print_arguments" ]
Checks whether a declaration is prop-valued and takes an `inhabited _` argument that is unused elsewhere in the type. In this case, that argument can be replaced with `nonempty _`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.inhabited_nonempty : linter
{ test := inhabited_nonempty, auto_decls := ff, no_errors_found := "No uses of `inhabited` arguments should be replaced with `nonempty`.", errors_found := "USES OF `inhabited` SHOULD BE REPLACED WITH `nonempty`." }
def
linter.inhabited_nonempty
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "inhabited_nonempty", "linter" ]
A linter object for `inhabited_nonempty`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
decidable_classical (d : declaration) : tactic (option string)
do tt ← is_prop d.type | return none, ff ← pure $ (`decidable).is_prefix_of d.to_name | return none, (binders, _) ← get_pi_binders_nondep d.type, let deceq_binders := binders.filter $ λ pr, pr.2.type.is_app_of `decidable_eq ∨ pr.2.type.is_app_of `decidable_pred ∨ pr.2.type.is_app_of `decidable_rel ∨ ...
def
decidable_classical
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "print_arguments" ]
Checks whether a declaration is `Prop`-valued and takes a `decidable* _` hypothesis that is unused elsewhere in the type. In this case, that hypothesis can be replaced with `classical` in the proof. Theorems in the `decidable` namespace are exempt from the check.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.decidable_classical : linter
{ test := decidable_classical, auto_decls := ff, no_errors_found := "No uses of `decidable` arguments should be replaced with `classical`.", errors_found := "USES OF `decidable` SHOULD BE REPLACED WITH `classical` IN THE PROOF." }
def
linter.decidable_classical
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "decidable_classical", "linter" ]
A linter object for `decidable_classical`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.fintype_finite_fun (d : declaration) : tactic (option string)
do tt ← is_prop d.type | return none, (binders, _) ← get_pi_binders_nondep d.type, let fintype_binders := binders.filter $ λ pr, pr.2.type.is_app_of `fintype, if fintype_binders.length = 0 then return none else (λ s, some $ "The following `fintype` hypotheses should be replaced with `c...
def
linter.fintype_finite_fun
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "fintype", "print_arguments" ]
Checks whether a declaration is `Prop`-valued and takes a `fintype _` hypothesis that is unused elsewhere in the type. In this case, that hypothesis can be replaced with `casesI nonempty_fintype _` in the proof.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.fintype_finite : linter
{ test := linter.fintype_finite_fun, auto_decls := ff, no_errors_found := "No uses of `fintype` arguments should be replaced with `casesI nonempty_fintype _`.", errors_found := "USES OF `fintype` SHOULD BE REPLACED WITH `casesI nonempty_fintype _` IN THE PROOF." }
def
linter.fintype_finite
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "linter", "linter.fintype_finite_fun" ]
A linter object for `fintype` vs `finite`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_coe_to_fun_linter (d : declaration) : tactic (option string)
retrieve $ do tt ← return d.is_trusted | pure none, mk_meta_var d.type >>= set_goals ∘ pure, args ← unfreezing intros, expr.sort _ ← target | pure none, let ty : expr := (expr.const d.to_name d.univ_levels).mk_app args, some coe_fn_inst ← try_core $ to_expr ``(_root_.has_coe_to_fun %%ty _) >>= mk_instance | pure none...
def
has_coe_to_fun_linter
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "succeeds" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.has_coe_to_fun : linter
{ test := has_coe_to_fun_linter, auto_decls := tt, no_errors_found := "has_coe_to_fun is used correctly", errors_found := "INVALID/MISSING `has_coe_to_fun` instances. You should add a `has_coe_to_fun` instance for the following types. See Note [function coercion]." }
def
linter.has_coe_to_fun
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "has_coe_to_fun_linter", "linter" ]
Linter that checks whether `has_coe_to_fun` instances comply with Note [function coercion].
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
check_reducible_non_instances (d : declaration) : tactic (option string)
do tt ← is_instance d.to_name | return none, ff ← is_prop d.type | return none, env ← get_env, -- We only check if the class of the instance contains an `add` or a `mul` field. let cls := d.type.pi_codomain.get_app_fn.const_name, some constrs ← return $ env.structure_fields cls | return none, tt ← return ...
def
check_reducible_non_instances
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[]
Checks whether an instance contains a semireducible non-instance with a class as type in its value. We add some restrictions to get not too many false positives: * We only consider classes with an `add` or `mul` field, since those classes are most likely to occur as a field to another class, and be an extension of an...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linter.check_reducibility : linter
{ test := check_reducible_non_instances, auto_decls := ff, no_errors_found := "All non-instances are reducible.", errors_found := "THE FOLLOWING INSTANCES MIGHT NOT REDUCE. These instances contain one or more declarations that are not instances and are also not marked `@[reducible]`. This means that type-clas...
def
linter.check_reducibility
tactic.lint
src/tactic/lint/type_classes.lean
[ "data.bool.basic", "meta.rb_map", "tactic.lint.basic" ]
[ "check_reducible_non_instances", "linter" ]
A linter that checks whether an instance contains a semireducible non-instance.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_cfg
(unify := ff)
structure
tactic.interactive.mono_cfg
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_selection : Type | left : mono_selection | right : mono_selection | both : mono_selection declare_trace mono.relation
inductive
tactic.interactive.mono_selection
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
compare (e₀ e₁ : expr) : tactic unit
do if opt.unify then do guard (¬ e₀.is_mvar ∧ ¬ e₁.is_mvar), unify e₀ e₁ else is_def_eq e₀ e₁
def
tactic.interactive.compare
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_one_difference : list expr → list expr → tactic (list expr × expr × expr × list expr)
| (x :: xs) (y :: ys) := do c ← try_core (compare x y), if c.is_some then prod.map (cons x) id <$> find_one_difference xs ys else do guard (xs.length = ys.length), mzip_with' compare xs ys, return ([],x,y,xs) | xs ys := fail format!"find_one_difference: {xs}, {ys}"
def
tactic.interactive.find_one_difference
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[ "mzip_with'" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
last_two {α : Type*} (l : list α) : option (α × α)
match l.reverse with | (x₁ :: x₀ :: _) := some (x₀, x₁) | _ := none end
def
tactic.interactive.last_two
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_imp : expr → tactic (expr × expr)
| `(%%e₀ → %%e₁) := do guard (¬ e₁.has_var), return (e₀,e₁) | _ := failed
def
tactic.interactive.match_imp
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
same_operator : expr → expr → bool
| (app e₀ _) (app e₁ _) := let fn₀ := e₀.get_app_fn, fn₁ := e₁.get_app_fn in fn₀.is_constant ∧ fn₀.const_name = fn₁.const_name | (pi _ _ _ _) (pi _ _ _ _) := tt | _ _ := ff
def
tactic.interactive.same_operator
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_operator (e : expr) : option name
guard (¬ e.is_pi) >> pure e.get_app_fn.const_name
def
tactic.interactive.get_operator
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
monotonicity.check_rel (l r : expr) : tactic (option name)
do guard (same_operator l r) <|> do { fail format!"{l} and {r} should be the f x and f y for some f" }, if l.is_pi then pure none else pure r.get_app_fn.const_name
def
tactic.interactive.monotonicity.check_rel
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_key
(with_bot name × with_bot name)
def
tactic.interactive.mono_key
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[ "with_bot" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_key.has_lt : has_lt mono_key
{ lt := prod.lex (<) (<) }
instance
tactic.interactive.mono_key.has_lt
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_head_candidates : ℕ → list expr → expr → tactic mono_key
| 0 _ h := fail!"Cannot find relation in {h}" | (succ n) xs h := do { (rel,l,r) ← if h.is_arrow then pure (none,h.binding_domain,h.binding_body) else guard h.get_app_fn.is_constant >> prod.mk (some h.get_app_fn.const_name) <$> last_two h.get_app_args, prod.mk <$> monotonic...
def
tactic.interactive.mono_head_candidates
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[ "rel" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
monotonicity.check (lm_n : name) : tactic mono_key
do lm ← mk_const lm_n, lm_t ← infer_type lm >>= instantiate_mvars, when_tracing `mono.relation trace!"[mono] Looking for relation in {lm_t}", let s := simp_lemmas.mk, s ← s.add_simp ``monotone, s ← s.add_simp ``strict_mono, lm_t ← s.dsimplify [] lm_t { fail_if_unchanged := ff }, when_tracing `mono....
def
tactic.interactive.monotonicity.check
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[ "monotone", "strict_mono" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
side : lean.parser mono_selection
with_desc "expecting 'left', 'right' or 'both' (default)" $ do some n ← optional ident | pure mono_selection.both, if n = `left then pure $ mono_selection.left else if n = `right then pure $ mono_selection.right else if n = `both then pure $ mono_selection.both else fail format!"invalid argument: {n}, expec...
def
tactic.interactive.side
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[ "side" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
monotonicity.attr : user_attribute (native.rb_lmap mono_key (name)) (option mono_key × mono_selection)
{ name := `mono , descr := "monotonicity of function `f` wrt relations `R₀` and `R₁`: R₀ x y → R₁ (f x) (f y)" , cache_cfg := { dependencies := [], mk_cache := λ ls, do ps ← ls.mmap monotonicity.attr.get_param, let ps := ps.filter_map prod.fst, pure $ (ps.zip ls).foldl (flip $ uncurry ...
def
tactic.interactive.monotonicity.attr
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[ "side" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
filter_instances (e : mono_selection) (ns : list name) : tactic (list name)
ns.mfilter $ λ n, do d ← user_attribute.get_param_untyped monotonicity.attr n, (_,d) ← to_expr ``(id %%d) >>= eval_expr (option mono_key × mono_selection), return (e = d : bool)
def
tactic.interactive.filter_instances
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_monotonicity_lemmas (k : expr) (e : mono_selection) : tactic (list name)
do ns ← monotonicity.attr.get_cache, k' ← if k.is_pi then pure (get_operator k.binding_domain,none) else do { (x₀,x₁) ← last_two k.get_app_args, pure (get_operator x₀,some k.get_app_fn.const_name) }, let ns := ns.find_def [] k', ns' ← filter_instances e ns, if e ≠ mono_sel...
def
tactic.interactive.get_monotonicity_lemmas
tactic.monotonicity
src/tactic/monotonicity/basic.lean
[ "order.with_bot" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_function (elab : bool := tt) | non_assoc : expr elab → list (expr elab) → list (expr elab) → mono_function | assoc : expr elab → option (expr elab) → option (expr elab) → mono_function | assoc_comm : expr elab → expr elab → mono_function
inductive
tactic.interactive.mono_function
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_function.to_tactic_format : mono_function → tactic format
| (mono_function.non_assoc fn xs ys) := do fn' ← pp fn, xs' ← mmap pp xs, ys' ← mmap pp ys, return format!"{fn'} {xs'} _ {ys'}" | (mono_function.assoc fn xs ys) := do fn' ← pp fn, xs' ← pp xs, ys' ← pp ys, return format!"{fn'} {xs'} _ {ys'}" | (mono_function.assoc_comm fn xs) := do fn' ← pp fn, xs...
def
tactic.interactive.mono_function.to_tactic_format
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_to_tactic_format_mono_function : has_to_tactic_format mono_function
{ to_tactic_format := mono_function.to_tactic_format }
instance
tactic.interactive.has_to_tactic_format_mono_function
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ac_mono_ctx' (rel : Type)
(to_rel : rel) (function : mono_function) (left right rel_def : expr)
structure
tactic.interactive.ac_mono_ctx'
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "rel" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ac_mono_ctx
ac_mono_ctx' (option (expr → expr → expr))
def
tactic.interactive.ac_mono_ctx
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ac_mono_ctx_ne
ac_mono_ctx' (expr → expr → expr)
def
tactic.interactive.ac_mono_ctx_ne
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ac_mono_ctx.to_tactic_format (ctx : ac_mono_ctx) : tactic format
do fn ← pp ctx.function, l ← pp ctx.left, r ← pp ctx.right, rel ← pp ctx.rel_def, return format!"{{ function := {fn}\n, left := {l}\n, right := {r}\n, rel_def := {rel} }}"
def
tactic.interactive.ac_mono_ctx.to_tactic_format
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "rel" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_to_tactic_format_mono_ctx : has_to_tactic_format ac_mono_ctx
{ to_tactic_format := ac_mono_ctx.to_tactic_format }
instance
tactic.interactive.has_to_tactic_format_mono_ctx
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
as_goal (e : expr) (tac : tactic unit) : tactic unit
do gs ← get_goals, set_goals [e], tac, set_goals gs
def
tactic.interactive.as_goal
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unify_with_instance (e : expr) : tactic unit
as_goal e $ apply_instance <|> apply_opt_param <|> apply_auto_param <|> tactic.solve_by_elim { lemmas := some asms } <|> reflexivity <|> applyc ``id <|> return ()
def
tactic.interactive.unify_with_instance
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "tactic.solve_by_elim" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_rule_head (p : expr) : list expr → expr → expr → tactic expr
| vs e t := (unify t p >> mmap' unify_with_instance vs.reverse >> instantiate_mvars e) <|> do (expr.pi _ _ d b) ← return t | failed, v ← mk_meta_var d, match_rule_head (v::vs) (expr.app e v) (b.instantiate_var v)
def
tactic.interactive.match_rule_head
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pi_head : expr → tactic expr
| (expr.pi n _ t b) := do v ← mk_meta_var t, pi_head (b.instantiate_var v) | e := return e
def
tactic.interactive.pi_head
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
delete_expr (e : expr) : list expr → tactic (option (list expr))
| [] := return none | (x :: xs) := (compare opt e x >> return (some xs)) <|> (map (cons x) <$> delete_expr xs)
def
tactic.interactive.delete_expr
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_ac' : list expr → list expr → tactic (list expr × list expr × list expr)
| es (x :: xs) := do es' ← delete_expr x es, match es' with | (some es') := do (c,l,r) ← match_ac' es' xs, return (x::c,l,r) | none := do (c,l,r) ← match_ac' es xs, return (c,l,x::r) end | es [] := do return ([],es,[])
def
tactic.interactive.match_ac'
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_ac (l : list expr) (r : list expr) : tactic (list expr × list expr × list expr)
do (s',l',r') ← match_ac' l r, s' ← mmap instantiate_mvars s', l' ← mmap instantiate_mvars l', r' ← mmap instantiate_mvars r', return (s',l',r')
def
tactic.interactive.match_ac
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_prefix : list expr → list expr → tactic (list expr × list expr × list expr)
| (x :: xs) (y :: ys) := (do compare opt x y, prod.map ((::) x) id <$> match_prefix xs ys) <|> return ([],x :: xs,y :: ys) | xs ys := return ([],xs,ys)
def
tactic.interactive.match_prefix
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_assoc (l : list expr) (r : list expr) : tactic (list expr × list expr × list expr × list expr)
do (pre,l₁,r₁) ← match_prefix l r, (suf,l₂,r₂) ← match_prefix (reverse l₁) (reverse r₁), return (pre,reverse l₂,reverse r₂,reverse suf)
def
tactic.interactive.match_assoc
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
`(prefix,left,right,suffix) ← match_assoc unif l r` finds the longest prefix and suffix common to `l` and `r` and returns them along with the differences
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
check_ac : expr → tactic (bool × bool × option (expr × expr × expr) × expr)
| (expr.app (expr.app f x) y) := do t ← infer_type x, a ← try_core $ to_expr ``(is_associative %%t %%f) >>= mk_instance, c ← try_core $ to_expr ``(is_commutative %%t %%f) >>= mk_instance, i ← try_core (do v ← mk_meta_var t, l_inst_p ← to_expr ``(is_left_id %%t %%f %%v), ...
def
tactic.interactive.check_ac
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_assoc_chain' (f : expr) : expr → tactic (dlist expr)
| e := (do (expr.app (expr.app f' x) y) ← return e, is_def_eq f f', (++) <$> parse_assoc_chain' x <*> parse_assoc_chain' y) <|> return (singleton e)
def
tactic.interactive.parse_assoc_chain'
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_assoc_chain (f : expr) : expr → tactic (list expr)
map dlist.to_list ∘ parse_assoc_chain' f
def
tactic.interactive.parse_assoc_chain
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
fold_assoc (op : expr) : option (expr × expr × expr) → list expr → option (expr × list expr)
| _ (x::xs) := some (foldl (expr.app ∘ expr.app op) x xs, []) | none [] := none | (some (l_id,r_id,x₀)) [] := some (x₀,[l_id,r_id])
def
tactic.interactive.fold_assoc
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
fold_assoc1 (op : expr) : list expr → option expr
| (x::xs) := some $ foldl (expr.app ∘ expr.app op) x xs | [] := none
def
tactic.interactive.fold_assoc1
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
same_function_aux : list expr → list expr → expr → expr → tactic (expr × list expr × list expr)
| xs₀ xs₁ (expr.app f₀ a₀) (expr.app f₁ a₁) := same_function_aux (a₀ :: xs₀) (a₁ :: xs₁) f₀ f₁ | xs₀ xs₁ e₀ e₁ := is_def_eq e₀ e₁ >> return (e₀,xs₀,xs₁)
def
tactic.interactive.same_function_aux
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
same_function : expr → expr → tactic (expr × list expr × list expr)
same_function_aux [] []
def
tactic.interactive.same_function
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_ac_mono_function (l r : expr) : tactic (expr × expr × list expr × mono_function)
do (full_f,ls,rs) ← same_function l r, (a,c,i,f) ← check_ac l, if a then if c then do (s,ls,rs) ← monad.join (match_ac <$> parse_assoc_chain f l <*> parse_assoc_chain f r), (l',l_id) ← fold_assoc f i ls, (r',r_id) ← fold_assoc f i rs, s' ← fold_assoc...
def
tactic.interactive.parse_ac_mono_function
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
parse_ac_mono_function' (l r : pexpr)
do l' ← to_expr l, r' ← to_expr r, parse_ac_mono_function l' r'
def
tactic.interactive.parse_ac_mono_function'
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ac_monotonicity_goal : expr → tactic (expr × expr × list expr × ac_mono_ctx)
| `(%%e₀ → %%e₁) := do (l,r,id_rs,f) ← parse_ac_mono_function e₀ e₁, t₀ ← infer_type e₀, t₁ ← infer_type e₁, rel_def ← to_expr ``(λ x₀ x₁, (x₀ : %%t₀) → (x₁ : %%t₁)), return (e₀, e₁, id_rs, { function := f , left := l, right := r , to_rel := some $ expr.pi `x bi...
def
tactic.interactive.ac_monotonicity_goal
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "rel" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bin_op_left (f : expr) : option expr → expr → expr
| none e := e | (some e₀) e₁ := f.mk_app [e₀,e₁]
def
tactic.interactive.bin_op_left
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bin_op (f a b : expr) : expr
f.mk_app [a,b]
def
tactic.interactive.bin_op
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
bin_op_right (f : expr) : expr → option expr → expr
| e none := e | e₀ (some e₁) := f.mk_app [e₀,e₁]
def
tactic.interactive.bin_op_right
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_fun_app : mono_function → expr → expr
| (mono_function.non_assoc f x y) z := f.mk_app (x ++ z :: y) | (mono_function.assoc f x y) z := bin_op_left f x (bin_op_right f z y) | (mono_function.assoc_comm f x) z := f.mk_app [z,x]
def
tactic.interactive.mk_fun_app
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_law /- `assoc (l₀,r₀) (r₁,l₁)` gives first how to find rules to prove x+(y₀+z) R x+(y₁+z); if that fails, helps prove (x+y₀)+z R (x+y₁)+z -/ | assoc : expr × expr → expr × expr → mono_law /- `congr r` gives the rule to prove `x = y → f x = f y` -/ | congr : expr → mono_law | other : expr → mon...
inductive
tactic.interactive.mono_law
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_law.to_tactic_format : mono_law → tactic format
| (mono_law.other e) := do e ← pp e, return format!"other {e}" | (mono_law.congr r) := do e ← pp r, return format!"congr {e}" | (mono_law.assoc (x₀,x₁) (y₀,y₁)) := do x₀ ← pp x₀, x₁ ← pp x₁, y₀ ← pp y₀, y₁ ← pp y₁, return format!"assoc {x₀}; {x₁} | {y₀}; {y₁}"
def
tactic.interactive.mono_law.to_tactic_format
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_to_tactic_format_mono_law : has_to_tactic_format mono_law
{ to_tactic_format := mono_law.to_tactic_format }
instance
tactic.interactive.has_to_tactic_format_mono_law
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_rel (ctx : ac_mono_ctx_ne) (f : expr → expr) : expr
ctx.to_rel (f ctx.left) (f ctx.right)
def
tactic.interactive.mk_rel
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_congr_args (fn : expr) (xs₀ xs₁ : list expr) (l r : expr) : tactic expr
do p ← mk_app `eq [fn.mk_app $ xs₀ ++ l :: xs₁,fn.mk_app $ xs₀ ++ r :: xs₁], prod.snd <$> solve_aux p (do iterate_exactly (xs₁.length) (applyc `congr_fun), applyc `congr_arg)
def
tactic.interactive.mk_congr_args
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_congr_law (ctx : ac_mono_ctx) : tactic expr
match ctx.function with | (mono_function.assoc f x₀ x₁) := if (x₀ <|> x₁).is_some then mk_congr_args f x₀.to_monad x₁.to_monad ctx.left ctx.right else failed | (mono_function.assoc_comm f x₀) := mk_congr_args f [x₀] [] ctx.left ctx.right | (mono_function.non_assoc f x₀ x₁) := mk_congr_args f x₀ x₁ ...
def
tactic.interactive.mk_congr_law
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_pattern (ctx : ac_mono_ctx) : tactic mono_law
match (sequence ctx : option (ac_mono_ctx' _)) with | (some ctx) := match ctx.function with | (mono_function.assoc f (some x) (some y)) := return $ mono_law.assoc ( mk_rel ctx (λ i, bin_op f x (bin_op f i y)) , mk_rel ctx (λ i, bin_op f i y)) ( mk_rel ctx (λ i, bin_op f (bin_op f x i)...
def
tactic.interactive.mk_pattern
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "sequence" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_rule (pat : expr) (r : name) : tactic expr
do r' ← mk_const r, t ← infer_type r', t ← expr.dsimp t { fail_if_unchanged := ff } tt [] [ simp_arg_type.expr ``(monotone), simp_arg_type.expr ``(strict_mono)], match_rule_head pat [] r' t
def
tactic.interactive.match_rule
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "expr.dsimp" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_lemma (pat : expr) : list name → tactic (list expr)
| [] := return [] | (r :: rs) := do (cons <$> match_rule pat r <|> pure id) <*> find_lemma rs
def
tactic.interactive.find_lemma
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_chaining_rules (ls : list name) (x₀ x₁ : expr) : tactic (list expr)
do x' ← to_expr ``(%%x₁ → %%x₀), r₀ ← find_lemma x' ls, r₁ ← find_lemma x₁ ls, return (expr.app <$> r₀ <*> r₁)
def
tactic.interactive.match_chaining_rules
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
find_rule (ls : list name) : mono_law → tactic (list expr)
| (mono_law.assoc (x₀,x₁) (y₀,y₁)) := (match_chaining_rules ls x₀ x₁) <|> (match_chaining_rules ls y₀ y₁) | (mono_law.congr r) := return [r] | (mono_law.other p) := find_lemma p ls
def
tactic.interactive.find_rule
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_rel {α : Sort u} (R : α → α → Sort v) {x y : α} (x' y' : α) (h : R x y) (hx : x = x') (hy : y = y') : R x' y'
by { rw [← hx,← hy], apply h }
def
tactic.interactive.apply_rel
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ac_refine (e : expr) : tactic unit
refine ``(eq.mp _ %%e) ; ac_refl
def
tactic.interactive.ac_refine
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
one_line (e : expr) : tactic format
do lbl ← pp e, asm ← infer_type e >>= pp, return format!"\t{asm}\n"
def
tactic.interactive.one_line
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
side_conditions (e : expr) : tactic format
do let vs := e.list_meta_vars, ts ← mmap one_line vs.tail, let r := e.get_app_fn.const_name, return format!"{r}:\n{format.join ts}"
def
tactic.interactive.side_conditions
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
monotonicity.generalize' (h : name) (v : expr) (x : name) : tactic (expr × expr)
do tgt ← target, t ← infer_type v, tgt' ← do { ⟨tgt', _⟩ ← solve_aux tgt (tactic.generalize v x >> target), to_expr ``(λ y : %%t, Π x, y = x → %%(tgt'.binding_body.lift_vars 0 1)) } <|> to_expr ``(λ y : %%t, Π x, %%v = x → %%tgt), t ← head_beta (tgt' v) >>= assert h, swap, r ← mk_eq_refl v, ...
def
tactic.interactive.monotonicity.generalize'
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
tactic-facing function, similar to `interactive.tactic.generalize` with the exception that meta variables
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hide_meta_vars (tac : list expr → tactic unit) : tactic unit
focus1 $ do tgt ← target >>= instantiate_mvars, tactic.change tgt, ctx ← local_context, let vs := tgt.list_meta_vars, vs' ← mmap (λ v, do h ← get_unused_name `h, x ← get_unused_name `x, prod.snd <$> monotonicity.generalize' h v x) vs, tac ctx; vs'.mmap'...
def
tactic.interactive.hide_meta_vars
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
hide_meta_vars' (tac : itactic) : itactic
hide_meta_vars $ λ _, tac
def
tactic.interactive.hide_meta_vars'
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
solve_mvar (v : expr) (tac : tactic unit) : tactic unit
do gs ← get_goals, set_goals [v], target >>= instantiate_mvars >>= tactic.change, tac, done, set_goals $ gs
def
tactic.interactive.solve_mvar
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list.minimum_on {α β} [linear_order β] (f : α → β) : list α → list α
| [] := [] | (x :: xs) := prod.snd $ xs.foldl (λ ⟨k,a⟩ b, let k' := f b in if k < k' then (k,a) else if k' < k then (k', [b]) else (k,b :: a)) (f x, [x])
def
tactic.interactive.list.minimum_on
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
best_match {β} (xs : list expr) (tac : expr → tactic β) : tactic unit
do t ← target, xs ← xs.mmap (λ x, try_core $ prod.mk x <$> solve_aux t (tac x >> get_goals)), let xs := xs.filter_map id, let r := list.minimum_on (list.length ∘ prod.fst ∘ prod.snd) xs, match r with | [(_,gs,pr)] := tactic.exact pr >> set_goals gs | [] := fail "no good match found" | _ := ...
def
tactic.interactive.best_match
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono_aux (dir : parse side) : tactic unit
do t ← target >>= instantiate_mvars, ns ← get_monotonicity_lemmas t dir, asms ← local_context, rs ← find_lemma asms t ns, focus1 $ () <$ best_match rs (λ law, tactic.refine $ to_pexpr law)
def
tactic.interactive.mono_aux
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "side" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mono (many : parse (tk "*")?) (dir : parse side) (hyps : parse $ tk "with" *> pexpr_list_or_texpr <|> pure []) (simp_rules : parse $ tk "using" *> simp_arg_list <|> pure []) : tactic unit
do hyps ← hyps.mmap (λ p, to_expr p >>= mk_meta_var), hyps.mmap' (λ pr, do h ← get_unused_name `h, note h none pr), when (¬ simp_rules.empty) (simp_core { } failed tt simp_rules [] (loc.ns [none]) >> skip), if many.is_some then repeat $ mono_aux dir else mono_aux dir, gs ← get_goals, set_goals ...
def
tactic.interactive.mono
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "side" ]
- `mono` applies a monotonicity rule. - `mono*` applies monotonicity rules repetitively. - `mono with x ≤ y` or `mono with [0 ≤ x,0 ≤ y]` creates an assertion for the listed propositions. Those help to select the right monotonicity rule. - `mono left` or `mono right` is useful when proving strict orderings: for `x...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
ac_mono_aux (cfg : mono_cfg := { mono_cfg . }) : tactic unit
hide_meta_vars $ λ asms, do try `[simp only [sub_eq_add_neg]], tgt ← target >>= instantiate_mvars, (l,r,id_rs,g) ← ac_monotonicity_goal cfg tgt <|> fail "monotonic context not found", ns ← get_monotonicity_lemmas tgt both, p ← mk_pattern g, rules ← find_rule asms ns p <|> fail "no applicable...
def
tactic.interactive.ac_mono_aux
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[ "tactic.solve_by_elim" ]
transforms a goal of the form `f x ≼ f y` into `x ≤ y` using lemmas marked as `monotonic`. Special care is taken when `f` is the repeated application of an associative operator and if the operator is commutative
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
repeat_until_or_at_most : nat → tactic unit → tactic unit → tactic unit
| 0 t _ := fail "too many applications" | (succ n) t u := u <|> (t >> repeat_until_or_at_most n t u)
def
tactic.interactive.repeat_until_or_at_most
tactic.monotonicity
src/tactic/monotonicity/interactive.lean
[ "control.traversable.derive", "control.traversable.lemmas", "data.dlist", "tactic.monotonicity.basic" ]
[]
(repeat_until_or_at_most n t u): repeat tactic `t` at most n times or until u succeeds
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83