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
sf.of_eformat : eformat → sf
| (tag ⟨ea,e⟩ m) := sf.tag_expr ea e $ sf.of_eformat m | (group m) := sf.block 0 $ sf.of_eformat m | (nest i m) := sf.block i $ sf.of_eformat m | (highlight c m) := sf.highlight c $ sf.of_eformat m | (of_format f) := sf.of_string $ format.to_string f | (compose x y) := sf.compose (sf.of_eformat x) (sf.of_eformat y)
def
widget_override.interactive_expression.sf.of_eformat
tactic
src/tactic/interactive_expr.lean
[]
[ "group" ]
Constructs an `sf` from an `eformat` by forgetting grouping, nesting, etc.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sf.flatten : sf → sf
| (sf.tag_expr ea e m) := (sf.tag_expr ea e $ sf.flatten m) | (sf.compose x y) := match (sf.flatten x), (sf.flatten y) with | (sf.of_string sx), (sf.of_string sy) := sf.of_string (sx ++ sy) | (sf.of_string sx), (sf.compose (sf.of_string sy) z) := sf.compose (sf.of_string (sx ++ sy)) z | (sf.compose x (sf.of_str...
def
widget_override.interactive_expression.sf.flatten
tactic
src/tactic/interactive_expr.lean
[]
[]
Flattens an `sf`, i.e. merges adjacent `of_string` constructors.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
elim_part_apps : sf → expr.address → sf
| (sf.tag_expr ea e m) acc := if ∀ c ∈ ea, c = expr.coord.app_fn then elim_part_apps m (acc ++ ea) else sf.tag_expr (acc ++ ea) e (elim_part_apps m []) | (sf.compose a b) acc := (elim_part_apps a acc).compose (elim_part_apps b acc) | (sf.of_string s) _ := sf.of_string s | (sf.block i a) acc := sf.block i $ ...
def
widget_override.interactive_expression.elim_part_apps
tactic
src/tactic/interactive_expr.lean
[]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sf.elim_part_apps (s : sf) : sf
elim_part_apps s []
def
widget_override.interactive_expression.sf.elim_part_apps
tactic
src/tactic/interactive_expr.lean
[]
[]
Post-process an `sf` object to eliminate tags for partial applications by pushing the `app_fn` as far into the expression as possible. The effect is that clicking on a sub-expression always includes the full argument list in the popup. Consider the expression `id id 0`. We push the `app_fn` for the partial application...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
action (γ : Type) | on_mouse_enter : subexpr → action | on_mouse_leave_all : action | on_click : subexpr → action | on_tooltip_action : γ → action | on_close_tooltip : action | effect : widget.effect → action
inductive
widget_override.interactive_expression.action
tactic
src/tactic/interactive_expr.lean
[]
[]
The actions accepted by an expression widget.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
goto_def_button {γ} : expr → tactic (list (html (action γ)))
| e := (do (expr.const n _) ← pure $ expr.get_app_fn e, env ← tactic.get_env, let file := environment.decl_olean env n, pos ← environment.decl_pos env n, pure $ [h "button" [ cn "pointer ba br3 mr1", on_click (λ _, action.effect $ widget.effect.reveal_position file pos), attr.val "...
def
widget_override.interactive_expression.goto_def_button
tactic
src/tactic/interactive_expr.lean
[]
[]
Render a 'go to definition' button for a given expression. If there is no definition available, then returns an empty list.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_block_attrs {γ}: sf → tactic (sf × list (attr γ))
| (sf.block i a) := do let s : attr (γ) := style [ ("display", "inline-block"), ("padding-left", "1ch"), ("text-indent", "-1ch"), ("white-space", "pre-wrap"), ("vertical-align", "top") ], (a,rest) ← get_block_attrs a, pure (a, s :: rest) | (sf.highlight c a) := do (a, rest) ← get_block_att...
def
widget_override.interactive_expression.get_block_attrs
tactic
src/tactic/interactive_expr.lean
[]
[]
Due to a bug in the webview browser, we have to reduce the number of spans in the expression. To do this, we collect the attributes from `sf.block` and `sf.highlight` after an expression boundary.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
view {γ} (tooltip_component : tc subexpr (action γ)) (click_address : option expr.address) (select_address : option expr.address) : subexpr → sf → tactic (list (html (action γ)))
| ⟨ce, current_address⟩ (sf.tag_expr ea e m) := do let new_address := current_address ++ ea, let select_attrs : list (attr (action γ)) := if some new_address = select_address then [className "highlight"] else [], click_attrs : list (attr (action γ)) ← if some new_address = click_address then do con...
def
widget_override.interactive_expression.view
tactic
src/tactic/interactive_expr.lean
[]
[]
Renders a subexpression as a list of html elements.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk {γ} (tooltip : tc subexpr γ) : tc expr γ
let tooltip_comp := component.with_should_update (λ (x y : tactic_state × expr × expr.address), x.2.2 ≠ y.2.2) $ component.map_action (action.on_tooltip_action) tooltip in component.filter_map_action (λ _ (a : γ ⊕ widget.effect), sum.cases_on a some (λ _, none)) $ component.with_effects (λ _ (a : γ ⊕ widget.eff...
def
widget_override.interactive_expression.mk
tactic
src/tactic/interactive_expr.lean
[]
[]
Make an interactive expression.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
implicit_arg_list (tooltip : tc subexpr empty) (e : expr) : tactic $ html empty
do fn ← (mk tooltip) $ expr.get_app_fn e, args ← list.mmap (mk tooltip) $ expr.get_app_args e, pure $ h "div" [style [("display", "flex"), ("flexWrap", "wrap"), ("alignItems", "baseline")]] ( (h "span" [className "bg-blue br3 ma1 ph2 white"] [fn]) :: list.map (λ a, h "span" [className "bg-gray br3 ma1 p...
def
widget_override.interactive_expression.implicit_arg_list
tactic
src/tactic/interactive_expr.lean
[]
[]
Render the implicit arguments for an expression in fancy, little pills.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
type_tooltip : tc subexpr empty
tc.stateless (λ ⟨e,ea⟩, do y ← tactic.infer_type e, y_comp ← mk type_tooltip y, implicit_args ← implicit_arg_list type_tooltip e, pure [ h "div" [style [ ("minWidth", "8rem"), -- [note]: textIndent is inherited, and we might -- be in an expression here where t...
def
widget_override.interactive_expression.type_tooltip
tactic
src/tactic/interactive_expr.lean
[]
[]
Component for the type tooltip.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
filter_type | none | no_instances | only_props
inductive
widget_override.filter_type
tactic
src/tactic/interactive_expr.lean
[]
[]
Supported tactic state filters.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
filter_local : filter_type → expr → tactic bool
| (filter_type.none) e := pure tt | (filter_type.no_instances) e := do t ← tactic.infer_type e, bnot <$> tactic.is_class t | (filter_type.only_props) e := do t ← tactic.infer_type e, tactic.is_prop t
def
widget_override.filter_local
tactic
src/tactic/interactive_expr.lean
[]
[]
Filters a local constant using the given filter.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
filter_component : component filter_type filter_type
component.stateless (λ lf, [ h "label" [] ["filter: "], select [ ⟨filter_type.none, "0", ["no filter"]⟩, ⟨filter_type.no_instances, "1", ["no instances"]⟩, ⟨filter_type.only_props, "2", ["only props"]⟩ ] lf ] )
def
widget_override.filter_component
tactic
src/tactic/interactive_expr.lean
[]
[]
Component for the filter dropdown.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
html.of_name {α : Type} : name → html α
| n := html.of_string $ name.to_string n
def
widget_override.html.of_name
tactic
src/tactic/interactive_expr.lean
[]
[]
Converts a name into an html element.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
show_type_component : tc expr empty
tc.stateless (λ x, do y ← infer_type x, y_comp ← interactive_expression.mk interactive_expression.type_tooltip $ y, pure y_comp )
def
widget_override.show_type_component
tactic
src/tactic/interactive_expr.lean
[]
[]
Component that shows a type.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
local_collection
(key : string) (locals : list expr) (type : expr) (value : option expr)
structure
widget_override.local_collection
tactic
src/tactic/interactive_expr.lean
[]
[]
A group of local constants in the context that should be rendered as one line.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
to_local_collection (l : expr) : tactic local_collection
tactic.unsafe.type_context.run $ do lctx ← tactic.unsafe.type_context.get_local_context, some ldecl ← pure $ lctx.get_local_decl l.local_uniq_name, pure { key := l.local_uniq_name.repr, locals := [l], type := ldecl.type, value := ldecl.value }
def
widget_override.to_local_collection
tactic
src/tactic/interactive_expr.lean
[]
[]
Converts a single local constant into a (singleton) `local_collection`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
group_local_collection : list local_collection → list local_collection
| (a :: b :: rest) := if a.type = b.type ∧ a.value = b.value then group_local_collection $ { locals := a.locals ++ b.locals, ..a } :: rest else a :: group_local_collection (b :: rest) | ls := ls
def
widget_override.group_local_collection
tactic
src/tactic/interactive_expr.lean
[]
[]
Groups consecutive local collections by type
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_view_goal {γ} (local_c : tc local_collection γ) (target_c : tc expr γ) : tc filter_type γ
tc.stateless $ λ ft, do g@(expr.mvar u_n pp_n y) ← main_goal, t ← get_tag g, let case_tag : list (html γ) := match interactive.case_tag.parse t with | some t := [h "li" [key "_case"] $ [h "span" [cn "goal-case b"] ["case"]] ++ (t.case_names.bind $ λ n, [" ", n])] | none := [] end, ...
def
widget_override.tactic_view_goal
tactic
src/tactic/interactive_expr.lean
[]
[]
Component that displays the main (first) goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_view_action (γ : Type) | out (a:γ): tactic_view_action | filter (f: filter_type): tactic_view_action
inductive
widget_override.tactic_view_action
tactic
src/tactic/interactive_expr.lean
[]
[ "filter" ]
Actions accepted by the `tactic_view_component`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
goals_accomplished_message {α} : html α
h "div" [cn "f5"] ["goals accomplished 🎉"]
def
widget_override.goals_accomplished_message
tactic
src/tactic/interactive_expr.lean
[]
[]
The "goals accomplished 🎉" HTML widget. This can be overridden using: ```lean meta def my_new_msg {α : Type} : widget.html α := "my message" attribute [vm_override my_new_msg] widget_override.goals_accomplished_message ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_view_component {γ} (local_c : tc local_collection γ) (target_c : tc expr γ) : tc unit γ
tc.mk_simple (tactic_view_action γ) (filter_type) (λ _, pure $ filter_type.none) (λ ⟨⟩ ft a, match a with | (tactic_view_action.out a) := pure (ft, some a) | (tactic_view_action.filter ft) := pure (ft, none) end) (λ ⟨⟩ ft, do gs ← get_goals, hs ← gs.mmap (λ g,...
def
widget_override.tactic_view_component
tactic
src/tactic/interactive_expr.lean
[]
[]
Component that displays all goals, together with the `$n goals` message.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_view_term_goal {γ} (local_c : tc local_collection γ) (target_c : tc expr γ) : tc unit γ
tc.stateless $ λ _, do goal ← flip tc.to_html (filter_type.none) $ tactic_view_goal local_c target_c, pure [h "ul" [className "list pl0"] [ h "li" [className "lh-copy"] [h "strong" [cn "goal-goals"] ["expected type:"]], h "li" [className "lh-copy"] [goal]]]
def
widget_override.tactic_view_term_goal
tactic
src/tactic/interactive_expr.lean
[]
[]
Component that displays the term-mode goal.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
show_local_collection_component : tc local_collection empty
tc.stateless (λ lc, do (l::_) ← pure lc.locals, c ← show_type_component l, match lc.value with | some v := do v ← interactive_expression.mk interactive_expression.type_tooltip v, pure [c, " := ", v] | none := pure [c] end)
def
widget_override.show_local_collection_component
tactic
src/tactic/interactive_expr.lean
[]
[]
Component showing a local collection.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_render : tc unit empty
component.ignore_action $ tactic_view_component show_local_collection_component show_type_component
def
widget_override.tactic_render
tactic
src/tactic/interactive_expr.lean
[]
[]
Renders the current tactic state.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tactic_state_widget : component tactic_state empty
tc.to_component tactic_render
def
widget_override.tactic_state_widget
tactic
src/tactic/interactive_expr.lean
[]
[]
Component showing the current tactic state.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
term_goal_widget : component tactic_state empty
(tactic_view_term_goal show_local_collection_component show_type_component).to_component
def
widget_override.term_goal_widget
tactic
src/tactic/interactive_expr.lean
[]
[]
Widget used to display term-proof goals.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
gives_upper_bound (n e : expr) : tactic expr
do t ← infer_type e >>= instantiate_mvars, match t with | `(%%n' < %%b) := do guard (n = n'), b ← b.to_rat, return e | `(%%b > %%n') := do guard (n = n'), b ← b.to_rat, return e | `(%%n' ≤ %%b) := do guard (n = n'), b ← b.to_rat, tn ← infer_type n >>= instantiate_mvars, match tn with...
def
tactic.interval_cases.gives_upper_bound
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
gives_lower_bound (n e : expr) : tactic expr
do t ← infer_type e >>= instantiate_mvars, match t with | `(%%n' ≥ %%b) := do guard (n = n'), b ← b.to_rat, return e | `(%%b ≤ %%n') := do guard (n = n'), b ← b.to_rat, return e | `(%%n' > %%b) := do guard (n = n'), b ← b.to_rat, tn ← infer_type n >>= instantiate_mvars, match tn with...
def
tactic.interval_cases.gives_lower_bound
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
If `e` easily implies `(%%n ≥ %%b)` for some explicit `b`, return that proof.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
combine_upper_bounds : option expr → option expr → tactic (option expr)
| none none := return none | (some prf) none := return $ some prf | none (some prf) := return $ some prf | (some prf₁) (some prf₂) := do option.some <$> to_expr ``(lt_min %%prf₁ %%prf₂)
def
tactic.interval_cases.combine_upper_bounds
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
Combine two upper bounds.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
combine_lower_bounds : option expr → option expr → tactic (option expr)
| none none := return $ none | (some prf) none := return $ some prf | none (some prf) := return $ some prf | (some prf₁) (some prf₂) := do option.some <$> to_expr ``(max_le %%prf₂ %%prf₁)
def
tactic.interval_cases.combine_lower_bounds
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
Combine two lower bounds.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
update_bounds (n : expr) (bounds : option expr × option expr) (e : expr) : tactic (option expr × option expr)
do nlb ← try_core $ gives_lower_bound n e, nub ← try_core $ gives_upper_bound n e, clb ← combine_lower_bounds bounds.1 nlb, cub ← combine_upper_bounds bounds.2 nub, return (clb, cub)
def
tactic.interval_cases.update_bounds
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
Inspect a given expression, using it to update a set of upper and lower bounds on `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
initial_lower_bound (n : expr) : tactic expr
do e ← to_expr ``(@bot_le _ _ _ %%n), t ← infer_type e, match t with | `(%%b ≤ %%n) := do return e | _ := failed end
def
tactic.interval_cases.initial_lower_bound
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
Attempt to find a lower bound for the variable `n`, by evaluating `bot_le n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
initial_upper_bound (n : expr) : tactic expr
do e ← to_expr ``(@le_top _ _ _ %%n), match e with | `(%%n ≤ %%b) := do tn ← infer_type n, e ← match tn with | `(ℕ) := to_expr ``(nat.add_one_le_iff.mpr %%e) | `(ℕ+) := to_expr ``(pnat.add_one_le_iff.mpr %%e) | `(ℤ) := to_expr ``(int.add_one_le_iff.mpr %%e) | _ := failed end, ...
def
tactic.interval_cases.initial_upper_bound
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
Attempt to find an upper bound for the variable `n`, by evaluating `le_top n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_bounds (n : expr) : tactic (expr × expr)
do hl ← try_core (initial_lower_bound n), hu ← try_core (initial_upper_bound n), lc ← local_context, r ← lc.mfoldl (update_bounds n) (hl, hu), match r with | (_, none) := fail "No upper bound located." | (none, _) := fail "No lower bound located." | (some lb_prf, some ub_prf) := return (lb_prf, ub_prf) ...
def
tactic.interval_cases.get_bounds
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
Inspect the local hypotheses for upper and lower bounds on a variable `n`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
set_elems {α} [decidable_eq α] (s : set α) [fintype s] : finset α
(fintype.elems s).image subtype.val
def
tactic.interval_cases.set_elems
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[ "finset", "fintype" ]
The finset of elements of a set `s` for which we have `fintype s`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mem_set_elems {α} [decidable_eq α] (s : set α) [fintype s] {a : α} (h : a ∈ s) : a ∈ set_elems s
finset.mem_image.2 ⟨⟨a, h⟩, fintype.complete _, rfl⟩
lemma
tactic.interval_cases.mem_set_elems
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[ "fintype" ]
Each element of `s` is a member of `set_elems s`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
interval_cases_using (hl hu : expr) (n : option name) : tactic unit
to_expr ``(mem_set_elems (Ico _ _) ⟨%%hl, %%hu⟩) >>= (if hn : n.is_some then note (option.get hn) else note_anon none) >>= fin_cases_at none none setup_tactic_parser
def
tactic.interval_cases_using
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[]
Call `fin_cases` on membership of the finset built from an `Ico` interval corresponding to a lower and an upper bound. Here `hl` should be an expression of the form `a ≤ n`, for some explicit `a`, and `hu` should be of the form `n < b`, for some explicit `b`. By default `interval_cases_using` automatically generates ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
interval_cases (n : parse texpr?) (bounds : parse (tk "using" *> (prod.mk <$> ident <*> ident))?) (lname : parse (tk "with" *> ident)?) : tactic unit
do if h : n.is_some then (do guard bounds.is_none <|> fail "Do not use the `using` keyword if specifying the variable explicitly.", n ← to_expr (option.get h), (hl, hu) ← get_bounds n, tactic.interval_cases_using hl hu lname) else if h' : bounds.is_some then (do [hl, hu] ← [(option.get h')...
def
tactic.interactive.interval_cases
tactic
src/tactic/interval_cases.lean
[ "tactic.fin_cases", "data.fin.interval", "data.int.interval", "data.pnat.interval", "data.pnat.basic" ]
[ "tactic.interval_cases_using" ]
`interval_cases n` searches for upper and lower bounds on a variable `n`, and if bounds are found, splits into separate cases for each possible value of `n`. As an example, in ``` example (n : ℕ) (w₁ : n ≥ 3) (w₂ : n < 5) : n = 3 ∨ n = 4 := begin interval_cases n, all_goals {simp} end ``` after `interval_cases n`,...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
and_kind | and | iff | eq
inductive
tactic.itauto.and_kind
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Different propositional constructors that are variants of "and" for the purposes of the theorem prover.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prop : Type | var : ℕ → prop -- propositional atoms P_i | true : prop -- ⊤ | false : prop -- ⊥ | and' : and_kind → prop → prop → prop -- p ∧ q, p ↔ q, p = q | or : prop → prop → prop -- p ∨ q | imp : prop → prop → prop
inductive
tactic.itauto.prop
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
A reified inductive type for propositional logic.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prop.and : prop → prop → prop
prop.and' and_kind.and
def
tactic.itauto.prop.and
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Constructor for `p ∧ q`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prop.iff : prop → prop → prop
prop.and' and_kind.iff
def
tactic.itauto.prop.iff
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Constructor for `p ↔ q`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prop.eq : prop → prop → prop
prop.and' and_kind.eq
def
tactic.itauto.prop.eq
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Constructor for `p = q`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prop.not (a : prop) : prop
a.imp prop.false
def
tactic.itauto.prop.not
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Constructor for `¬ p`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prop.xor (a b : prop) : prop
(a.and b.not).or (b.and a.not)
def
tactic.itauto.prop.xor
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Constructor for `xor p q`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
and_kind.sides : and_kind → prop → prop → prop × prop
| and_kind.and A B := (A, B) | _ A B := (A.imp B, B.imp A)
def
tactic.itauto.and_kind.sides
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Given the contents of an `and` variant, return the two conjuncts.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prop.to_format : prop → format
| (prop.var i) := format!"v{i}" | prop.true := format!"⊤" | prop.false := format!"⊥" | (prop.and p q) := format!"({p.to_format} ∧ {q.to_format})" | (prop.iff p q) := format!"({p.to_format} ↔ {q.to_format})" | (prop.eq p q) := format!"({p.to_format} = {q.to_format})" | (prop.or p q) := format!"({p.to_format} ∨ {q.to_for...
def
tactic.itauto.prop.to_format
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Debugging printer for propositions.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
and_kind.cmp (p q : and_kind) : ordering
by { cases p; cases q, exacts [eq, lt, lt, gt, eq, lt, gt, gt, eq] }
def
tactic.itauto.and_kind.cmp
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
A comparator for `and_kind`. (There should really be a derive handler for this.)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prop.cmp (p q : prop) : ordering
begin induction p with _ ap _ _ p₁ p₂ _ _ p₁ p₂ _ _ p₁ p₂ _ _ p₁ p₂ generalizing q; cases q, case var var { exact cmp p q }, case true true { exact eq }, case false false { exact eq }, case and' and' : aq q₁ q₂ { exact (ap.cmp aq).or_else ((p₁ q₁).or_else (p₂ q₂)) }, case or or : q₁ q₂ { exact (p₁ q₁).or_el...
def
tactic.itauto.prop.cmp
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
A comparator for propositions. (There should really be a derive handler for this.)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
proof -- ⊢ A, causes failure during reconstruction | «sorry» : proof -- (n: A) ⊢ A | hyp (n : name) : proof -- ⊢ ⊤ | triv : proof -- (p: ⊥) ⊢ A | exfalso' (p : proof) : proof -- (p: (x: A) ⊢ B) ⊢ A → B | intro (x : name) (p : proof) : proof -- ak = and: (p: A ∧ B) ⊢ A -- ak = iff: (p: A ↔ B) ⊢ A → B -- ak = eq: (p: ...
inductive
tactic.itauto.proof
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[ "em" ]
A reified inductive proof type for intuitionistic propositional logic.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
proof.to_format : proof → format
| proof.sorry := "sorry" | (proof.hyp i) := to_fmt i | proof.triv := "triv" | (proof.exfalso' p) := format!"(exfalso {p.to_format})" | (proof.intro x p) := format!"(λ {x}, {p.to_format})" | (proof.and_left _ p) := format!"{p.to_format} .1" | (proof.and_right _ p) := format!"{p.to_format} .2" | (proof.and_intro _ p q) :...
def
tactic.itauto.proof.to_format
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Debugging printer for proof objects.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
proof.exfalso : prop → proof → proof
| prop.false p := p | A p := proof.exfalso' p
def
tactic.itauto.proof.exfalso
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
A variant on `proof.exfalso'` that performs opportunistic simplification.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
proof.or_elim : proof → name → proof → proof → proof
| (proof.em cl p) x q r := proof.decidable_elim cl p x q r | p x q r := proof.or_elim' p x q r
def
tactic.itauto.proof.or_elim
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
A variant on `proof.or_elim` that performs opportunistic simplification.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
proof.app : proof → proof → proof
| (proof.curry ak p) q := proof.curry₂ ak p q | (proof.curry₂ ak p q) r := p.app (q.and_intro ak r) | (proof.or_imp_left p) q := p.app q.or_inl | (proof.or_imp_right p) q := p.app q.or_inr | (proof.imp_imp_simp x p) q := p.app (proof.intro x q) | p q := p.app' q
def
tactic.itauto.proof.app
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
A variant on `proof.app'` that performs opportunistic simplification. (This doesn't do full normalization because we don't want the proof size to blow up.)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
fresh_name : ℕ → name × ℕ
λ n, (mk_simple_name ("h" ++ to_string n), n+1)
def
tactic.itauto.fresh_name
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Get a new name in the pattern `h0, h1, h2, ...`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
context
native.rb_map prop proof
def
tactic.itauto.context
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
The context during proof search is a map from propositions to proof values.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
context.to_format (Γ : context) : format
Γ.fold "" $ λ P p f, P.to_format /- ++ " := " ++ p.to_format -/ ++ ",\n" ++ f
def
tactic.itauto.context.to_format
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Debug printer for the context.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
context.add : prop → proof → context → except (prop → proof) context
| prop.true p Γ := pure Γ | prop.false p Γ := except.error (λ A, proof.exfalso A p) | (prop.and' ak A B) p Γ := do let (A, B) := ak.sides A B, Γ ← Γ.add A (p.and_left ak), Γ.add B (p.and_right ak) | (prop.imp prop.false A) p Γ := pure Γ | (prop.imp prop.true A) p Γ := Γ.add A (p.app proof.triv) | (prop.imp (prop....
def
tactic.itauto.context.add
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Insert a proposition and its proof into the context, as in `have : A := p`. This will eagerly apply all level 1 rules on the spot, which are rules that don't split the goal and are validity preserving: specifically, we drop `⊤` and `A → ⊤` hypotheses, close the goal if we find a `⊥` hypothesis, split all conjunctions, ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
context.with_add (Γ : context) (A : prop) (p : proof) (B : prop) (f : context → prop → ℕ → bool × proof × ℕ) (n : ℕ) : bool × proof × ℕ
match Γ.add A p with | except.ok Γ_A := f Γ_A B n | except.error p := (tt, p B, n) end
def
tactic.itauto.context.with_add
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Add `A` to the context `Γ` with proof `p`. This version of `context.add` takes a continuation and a target proposition `B`, so that in the case that `⊥` is found we can skip the continuation and just prove `B` outright.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
map_proof (f : proof → proof) : bool × proof × ℕ → bool × proof × ℕ
| (b, p, n) := (b, f p, n)
def
tactic.itauto.map_proof
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Map a function over the proof (regardless of whether the proof is successful or not).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
is_ok {α} : bool × α → option α
| (ff, p) := none | (tt, p) := some p
def
tactic.itauto.is_ok
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Convert a value-with-success to an optional value.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
when_ok : bool → (ℕ → bool × proof × ℕ) → ℕ → bool × proof × ℕ
| ff f n := (ff, proof.sorry, n) | tt f n := f n
def
tactic.itauto.when_ok
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Skip the continuation and return a failed proof if the boolean is false.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
search (prove : context → prop → ℕ → bool × proof × ℕ) : context → prop → ℕ → bool × proof × ℕ
| Γ B n := match Γ.find B with | some p := (tt, p, n) | none := let search₁ := Γ.fold none $ λ A p r, match r with | some r := some r | none := match A with | prop.imp A' C := match Γ.find A' with | some q := is_ok $ context.with_add (Γ.erase A) C (p.app q) B prove n | none := matc...
def
tactic.itauto.search
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[ "prove" ]
The search phase, which deals with the level 3 rules, which are rules that are not validity preserving and so require proof search. One obvious one is the or-introduction rule: we prove `A ∨ B` by proving `A` or `B`, and we might have to try one and backtrack. There are two rules dealing with implication in this categ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prove : context → prop → ℕ → bool × proof × ℕ
| Γ prop.true n := (tt, proof.triv, n) | Γ (prop.imp A B) n := let (a, n) := fresh_name n in map_proof (proof.intro a) $ Γ.with_add A (proof.hyp a) B prove n | Γ (prop.and' ak A B) n := let (A, B) := ak.sides A B in let (b, p, n) := prove Γ A n in map_proof (p.and_intro ak) $ when_ok b (prove Γ B) n | Γ B n :...
def
prove
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
The main prover. This receives a context of proven or assumed lemmas and a target proposition, and returns a proof or `none` (with state for the fresh variable generator). The intuitionistic logic rules are separated into three groups: * level 1: No splitting, validity preserving: apply whenever you can. Left rules ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
reify_atom (atoms : ref (buffer expr)) (e : expr) : tactic prop
do vec ← read_ref atoms, o ← try_core $ vec.iterate failure (λ i e' r, r <|> (is_def_eq e e' >> pure i.1)), match o with | none := write_ref atoms (vec.push_back e) $> prop.var vec.size | some i := pure $ prop.var i end
def
reify_atom
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Reifies an atomic or otherwise unrecognized proposition. If it is defeq to a proposition we have already allocated, we reuse it, otherwise we name it with a new index.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
reify (atoms : ref (buffer expr)) : expr → tactic prop
| `(true) := pure prop.true | `(false) := pure prop.false | `(¬ %%a) := prop.not <$> reify a | `(%%a ∧ %%b) := prop.and <$> reify a <*> reify b | `(%%a ∨ %%b) := prop.or <$> reify a <*> reify b | `(%%a ↔ %%b) := prop.iff <$> reify a <*> reify b | `(xor %%a %%b) := prop.xor <$> reify a <*> reify b | `(@eq Prop %%a %%b) ...
def
reify
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[ "reify_atom" ]
Reify an `expr` into a `prop`, allocating anything non-propositional as an atom in the `atoms` list.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
apply_proof : name_map expr → proof → tactic unit
| Γ proof.sorry := fail "itauto failed" | Γ (proof.hyp n) := do e ← Γ.find n, exact e | Γ proof.triv := triv | Γ (proof.exfalso' p) := do t ← mk_mvar, to_expr ``(false.elim %%t) tt ff >>= exact, gs ← get_goals, set_goals (t::gs), apply_proof Γ p | Γ (proof.intro x p) := do e ← intro_core x, apply_proof (Γ.insert x ...
def
apply_proof
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[]
Once we have a proof object, we have to apply it to the goal. (Some of these cases are a bit annoying because `applyc` gets the arguments wrong sometimes so we have to use `to_expr` instead.)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
itauto (use_dec use_classical : bool) (extra_dec : list expr) : tactic unit
using_new_ref mk_buffer $ λ atoms, using_new_ref mk_name_map $ λ hs, do t ← target, t ← mcond (is_prop t) (reify atoms t) (tactic.exfalso $> prop.false), hyps ← local_context, (Γ, decs) ← hyps.mfoldl (λ (Γ : except (prop → proof) context × native.rb_map prop (bool × expr)) h, do e ← infer_type h, ...
def
itauto
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[ "apply_proof", "prove", "reify" ]
A decision procedure for intuitionistic propositional logic. * `use_dec` will add `a ∨ ¬ a` to the context for every decidable atomic proposition `a`. * `use_classical` will allow `a ∨ ¬ a` to be added even if the proposition is not decidable, using classical logic. * `extra_dec` will add `a ∨ ¬ a` to the context fo...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
itauto (classical : parse (tk "!")?) : parse (some <$> pexpr_list <|> tk "*" *> pure none)? → tactic unit
| none := tactic.itauto false classical.is_some [] | (some none) := tactic.itauto true classical.is_some [] | (some (some ls)) := ls.mmap i_to_expr >>= tactic.itauto false classical.is_some
def
interactive.itauto
tactic
src/tactic/itauto.lean
[ "tactic.hint" ]
[ "itauto" ]
A decision procedure for intuitionistic propositional logic. Unlike `finish` and `tauto!` this tactic never uses the law of excluded middle (without the `!` option), and the proof search is tailored for this use case. (`itauto!` will work as a classical SAT solver, but the algorithm is not very good in this situation.)...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
can_lift (α β : Sort*) (coe : out_param $ β → α) (cond : out_param $ α → Prop)
(prf : ∀(x : α), cond x → ∃(y : β), coe y = x)
class
can_lift
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[]
A class specifying that you can lift elements from `α` to `β` assuming `cond` is true. Used by the tactic `lift`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pi.can_lift (ι : Sort*) (α β : ι → Sort*) (coe : Π i, β i → α i) (P : Π i, α i → Prop) [Π i : ι, can_lift (α i) (β i) (coe i) (P i)] : can_lift (Π i : ι, α i) (Π i : ι, β i) (λ f i, coe i (f i)) (λ f, ∀ i, P i (f i))
{ prf := λ f hf, ⟨λ i, classical.some (can_lift.prf (f i) (hf i)), funext $ λ i, classical.some_spec (can_lift.prf (f i) (hf i))⟩ }
instance
pi.can_lift
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[ "can_lift" ]
Enable automatic handling of pi types in `can_lift`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
subtype.exists_pi_extension {ι : Sort*} {α : ι → Sort*} [ne : Π i, nonempty (α i)] {p : ι → Prop} (f : Π i : subtype p, α i) : ∃ g : Π i : ι, α i, (λ i : subtype p, g i) = f
begin tactic.classical, refine ⟨λ i, if hi : p i then f ⟨i, hi⟩ else classical.choice (ne i), funext _⟩, rintro ⟨i, hi⟩, exact dif_pos hi end
lemma
subtype.exists_pi_extension
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[ "tactic.classical" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pi_subtype.can_lift (ι : Sort*) (α : ι → Sort*) [ne : Π i, nonempty (α i)] (p : ι → Prop) : can_lift (Π i : subtype p, α i) (Π i, α i) (λ f i, f i) (λ _, true)
{ prf := λ f _, subtype.exists_pi_extension f }
instance
pi_subtype.can_lift
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[ "can_lift", "subtype.exists_pi_extension" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
pi_subtype.can_lift' (ι : Sort*) (α : Sort*) [ne : nonempty α] (p : ι → Prop) : can_lift (subtype p → α) (ι → α) (λ f i, f i) (λ _, true)
pi_subtype.can_lift ι (λ _, α) p
instance
pi_subtype.can_lift'
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[ "can_lift", "pi_subtype.can_lift" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
subtype.can_lift {α : Sort*} (p : α → Prop) : can_lift α {x // p x} coe p
{ prf := λ a ha, ⟨⟨a, ha⟩, rfl⟩ }
instance
subtype.can_lift
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[ "can_lift" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_lift_prf (h : option pexpr) (e P : expr) : tactic (expr × bool)
do let expected_prf_ty := P.app e, expected_prf_ty ← simp_lemmas.mk.dsimplify [] expected_prf_ty {fail_if_unchanged := ff}, match h with | some h := do e ← decorate_error "lift tactic failed." (i_to_expr ``((%%h : %%expected_prf_ty))), return (e, tt) | none := do prf_nm ← get_unused_name, ...
def
tactic.get_lift_prf
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[]
Construct the proof of `cond x` in the lift tactic. * `e` is the expression being lifted and `h` is the specified proof of `can_lift.cond e`. * `old_tp` and `new_tp` are the arguments to `can_lift` and `inst` is the `can_lift`-instance. * `s` and `to_unfold` contain the information of the simp set used to simplify. ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
lift (p : pexpr) (t : pexpr) (h : option pexpr) (n : list name) : tactic unit
do propositional_goal <|> fail "lift tactic failed. Tactic is only applicable when the target is a proposition.", e ← i_to_expr p, old_tp ← infer_type e, new_tp ← i_to_expr ``(%%t : Sort*), coe ← i_to_expr (``(%%new_tp → %%old_tp)) >>= mk_meta_var, P ← i_to_expr (``(%%old_tp → Prop)) >>= mk_meta_var, ...
def
tactic.lift
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[ "can_lift", "lift" ]
Lift the expression `p` to the type `t`, with proof obligation given by `h`. The list `n` is used for the two newly generated names, and to specify whether `h` should remain in the local context. See the doc string of `tactic.interactive.lift` for more information.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
using_texpr
(tk "using" *> texpr)?
def
tactic.using_texpr
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[]
Parses an optional token "using" followed by a trailing `pexpr`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
to_texpr
(tk "to" *> texpr)
def
tactic.to_texpr
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[]
Parses a token "to" followed by a trailing `pexpr`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
lift (p : parse texpr) (t : parse to_texpr) (h : parse using_texpr) (n : parse with_ident_list) : tactic unit
tactic.lift p t h n
def
tactic.interactive.lift
tactic
src/tactic/lift.lean
[ "tactic.rcases" ]
[ "lift", "tactic.lift" ]
Lift an expression to another type. * Usage: `'lift' expr 'to' expr ('using' expr)? ('with' id (id id?)?)?`. * If `n : ℤ` and `hn : n ≥ 0` then the tactic `lift n to ℕ using hn` creates a new constant of type `ℕ`, also named `n` and replaces all occurrences of the old variable `(n : ℤ)` with `↑n` (where `n` in the ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
left_mul_both_sides {α} [h : has_mul α] {x y : α} (z : α) (h1 : x = y) : z * x = z * y
congr_arg (has_mul.mul z) h1
lemma
linear_combo.left_mul_both_sides
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sum_two_equations {α} [h : has_add α] {x1 y1 x2 y2 : α} (h1 : x1 = y1) (h2: x2 = y2) : x1 + x2 = y1 + y2
congr (congr_arg has_add.add h1) h2
lemma
linear_combo.sum_two_equations
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
left_minus_right {α} [h : add_group α] {x y : α} (h1 : x = y) : x - y = 0
sub_eq_zero.mpr h1
lemma
linear_combo.left_minus_right
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[ "add_group" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
all_on_left_equiv {α} [h : add_group α] (x y : α) : (x = y) = (x - y = 0)
propext (⟨left_minus_right, sub_eq_zero.mp⟩)
lemma
linear_combo.all_on_left_equiv
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[ "add_group" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
replace_eq_expr {α} [h : has_zero α] {x y : α} (h1 : x = 0) (h2 : y = x) : y = 0
by rwa h2
lemma
linear_combo.replace_eq_expr
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
eq_zero_of_sub_eq_zero {α} [add_group α] {x y : α} (h : y = 0) (h2 : x - y = 0) : x = 0
by rwa [h, sub_zero] at h2
lemma
linear_combo.eq_zero_of_sub_eq_zero
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[ "add_group" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linear_combination_config : Type
(normalize : bool := tt) (normalization_tactic : tactic unit := `[ring_nf SOP]) (exponent : ℕ := 1)
structure
linear_combo.linear_combination_config
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[ "normalize" ]
A configuration object for `linear_combination`. `normalize` describes whether or not the normalization step should be used. `normalization_tactic` describes the tactic used for normalization when checking if the weighted sum is equivalent to the goal (when `normalize` is `tt`).
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mul_equality_expr (h_equality : expr) (coeff : pexpr) : tactic expr
do `(%%lhs = %%rhs) ← infer_type h_equality, -- Mark the coefficient as having the same type as the sides of `h_equality` - -- this is necessary in order to use the left_mul_both_sides lemma left_type ← infer_type lhs, coeff_expr ← to_expr ``(%%coeff : %%left_type), mk_app ``left_mul_both_sides [coeff_exp...
def
linear_combo.mul_equality_expr
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
Given that `lhs = rhs`, this tactic returns an `expr` proving that `coeff * lhs = coeff * rhs`. * Input: * `h_equality` : an `expr`, whose type should be an equality between terms of type `α`, where there is an instance of `has_mul α` * `coeff` : a `pexpr`, which should be a value of type `α` * Output: an...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sum_equalities (h_equality1 h_equality2 : expr) : tactic expr
mk_app ``sum_two_equations [h_equality1, h_equality2]
def
linear_combo.sum_equalities
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
Given two hypotheses that `a = b` and `c = d`, this tactic returns an `expr` proving that `a + c = b + d`. * Input: * `h_equality1` : an `expr`, whose type should be an equality between terms of type `α`, where there is an instance of `has_add α` * `h_equality2` : an `expr`, whose type should be an equalit...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
sum_two_hyps_one_mul_helper (h_equality1 h_equality2 : expr) (coeff_for_eq2 : pexpr) : tactic expr
mul_equality_expr h_equality2 coeff_for_eq2 >>= sum_equalities h_equality1
def
linear_combo.sum_two_hyps_one_mul_helper
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
Given that `a = b` and `c = d`, along with a coefficient, this tactic returns an `expr` proving that `a + coeff * c = b + coeff * d`. * Input: * `h_equality1` : an `expr`, whose type should be an equality between terms of type `α`, where there are instances of `has_add α` and `has_mul α` * `h_equality2` : ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
make_sum_of_hyps_helper (expected_tp : expr) : option (tactic expr) → list expr → list pexpr → tactic expr
| none [] [] := to_expr ``(rfl : (0 : %%expected_tp) = 0) | (some tactic_hcombo) [] [] := do tactic_hcombo | none (h_equality :: h_eqs_names) (coeff :: coeffs) := do -- This is the first equa...
def
linear_combo.make_sum_of_hyps_helper
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
Given that `l_sum1 = r_sum1`, `l_h1 = r_h1`, ..., `l_hn = r_hn`, and given coefficients `c_1`, ..., `c_n`, this tactic returns an `expr` proving that `l_sum1 + (c_1 * l_h1) + ... + (c_n * l_hn)` `= r_sum1 + (c_1 * r_h1) + ... + (c_n * r_hn)` * Input: * `expected_tp`: the type of the terms being compared in t...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
make_sum_of_hyps (expected_tp : expr) (h_eqs_names : list expr) (coeffs : list pexpr) : tactic expr
make_sum_of_hyps_helper expected_tp none h_eqs_names coeffs
def
linear_combo.make_sum_of_hyps
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
Given a list of names referencing equalities and a list of pexprs representing coefficients, this tactic proves that a weighted sum of the equalities (where each equation is multiplied by the corresponding coefficient) holds. * Input: * `expected_tp`: the type of the terms being compared in the target equality ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
move_to_left_side (h_equality : expr) : tactic expr
mk_app ``left_minus_right [h_equality]
def
linear_combo.move_to_left_side
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
This tactic proves that the result of moving all the terms in an equality to the left side of the equals sign by subtracting the right side of the equation from the left side holds. In other words, given `lhs = rhs`, this tactic proves that `lhs - rhs = 0`. * Input: * `h_equality` : an `expr`, whose type shou...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
move_target_to_left_side : tactic unit
do -- Move all the terms in the target equality to the left side target ← target, (targ_lhs, targ_rhs) ← match_eq target, target_left_eq ← to_expr ``(%%targ_lhs - %%targ_rhs = 0), mk_app ``all_on_left_equiv [targ_lhs, targ_rhs] >>= replace_target target_left_eq
def
linear_combo.move_target_to_left_side
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
This tactic replaces the target with the result of moving all the terms in the target to the left side of the equals sign by subtracting the right side of the equation from the left side. In other words, when the target is lhs = rhs, this tactic proves that `lhs - rhs = 0` and replaces the target with this new...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
set_goal_to_hleft_sub_tleft (hsum_on_left : expr) : tactic unit
do to_expr ``(eq_zero_of_sub_eq_zero %%hsum_on_left) >>= apply, skip
def
linear_combo.set_goal_to_hleft_sub_tleft
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
This tactic changes the goal to be that the lefthand side of the target minus the lefthand side of the given expression is equal to 0. For example, if `hsum_on_left` is `5*x - 5*y = 0`, and the target is `-5*y + 5*x = 0`, this tactic will change the target to be `-5*y + 5*x - (5*x - 5*y) = 0`. This tactic only ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
raise_goal_to_power : ℕ → tactic unit
| 1 := skip | n := refine ``(@pow_eq_zero _ _ _ _ %%`(n) _)
def
linear_combo.raise_goal_to_power
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
If an exponent `n` is provided, changes the goal from `t = 0` to `t^n = 0`. * Input: * `exponent : ℕ`, the power to raise the goal by. If `1`, this tactic is a no-op. * Output: N/A
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
normalize_if_desired (config : linear_combination_config) : tactic unit
when config.normalize config.normalization_tactic
def
linear_combo.normalize_if_desired
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
This tactic attempts to prove the goal by normalizing the target if the `normalize` field of the given configuration is true. * Input: * `config` : a `linear_combination_config`, which determines the tactic used for normalization if normalization is done * Output: N/A
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
linear_combination (h_eqs_names : list pexpr) (coeffs : list pexpr) (config : linear_combination_config := {}) : tactic unit
do `(@eq %%ext _ _) ← target | fail "linear_combination can only be used to prove equality goals", h_eqs ← h_eqs_names.mmap to_expr, hsum ← make_sum_of_hyps ext h_eqs coeffs, hsum_on_left ← move_to_left_side hsum, move_target_to_left_side, raise_goal_to_power config.exponent, set_goal_to_hleft_sub_tleft h...
def
linear_combo.linear_combination
tactic
src/tactic/linear_combination.lean
[ "tactic.ring" ]
[]
This is a tactic that attempts to simplify the target by creating a linear combination of a list of equalities and subtracting it from the target. (If the `normalize` field of the configuration is set to ff, then the tactic will simply set the user up to prove their target using the linear combination instead o...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83