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
list_Sigma
list
def
tactic.list_Sigma
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
A list, with a disjunctive meaning (like a list of inductive constructors, or subgoals)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
list_Pi
list
def
tactic.list_Pi
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
A list, with a conjunctive meaning (like a list of constructor arguments, or hypotheses)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
uncleared_goal
list expr × expr
def
tactic.uncleared_goal
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
A metavariable representing a subgoal, together with a list of local constants to clear.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_patt : Type | one : name → rcases_patt | clear : rcases_patt | explicit : rcases_patt → rcases_patt | typed : rcases_patt → pexpr → rcases_patt | tuple : listΠ rcases_patt → rcases_patt | alts : listΣ rcases_patt → rcases_patt
inductive
tactic.rcases_patt
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
An `rcases` pattern can be one of the following, in a nested combination: * A name like `foo` * The special keyword `rfl` (for pattern matching on equality using `subst`) * A hyphen `-`, which clears the active hypothesis and any dependents. * A type ascription like `pat : ty` (parentheses are optional) * A tuple cons...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
inhabited : inhabited rcases_patt
⟨one `_⟩
instance
tactic.rcases_patt.inhabited
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
name : rcases_patt → option name
| (one `_) := none | (one `rfl) := none | (one n) := some n | (explicit p) := p.name | (typed p _) := p.name | (alts [p]) := p.name | _ := none
def
tactic.rcases_patt.name
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Get the name from a pattern, if provided
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
as_tuple : rcases_patt → bool × listΠ rcases_patt
| (explicit p) := (tt, (as_tuple p).2) | (tuple ps) := (ff, ps) | p := (ff, [p])
def
tactic.rcases_patt.as_tuple
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Interpret an rcases pattern as a tuple, where `p` becomes `⟨p⟩` if `p` is not already a tuple.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
as_alts : rcases_patt → listΣ rcases_patt
| (alts ps) := ps | p := [p]
def
tactic.rcases_patt.as_alts
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Interpret an rcases pattern as an alternation, where non-alternations are treated as one alternative.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tuple' : listΠ rcases_patt → rcases_patt
| [p] := p | ps := tuple ps
def
tactic.rcases_patt.tuple'
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Convert a list of patterns to a tuple pattern, but mapping `[p]` to `p` instead of `⟨p⟩`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
alts' : listΣ rcases_patt → rcases_patt
| [p] := p | ps := alts ps
def
tactic.rcases_patt.alts'
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Convert a list of patterns to an alternation pattern, but mapping `[p]` to `p` instead of a unary alternation `|p`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tuple₁_core : listΠ rcases_patt → listΠ rcases_patt
| [] := [] | [tuple []] := [tuple []] | [tuple ps] := ps | (p :: ps) := p :: tuple₁_core ps
def
tactic.rcases_patt.tuple₁_core
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
This function is used for producing rcases patterns based on a case tree. Suppose that we have a list of patterns `ps` that will match correctly against the branches of the case tree for one constructor. This function will merge tuples at the end of the list, so that `[a, b, ⟨c, d⟩]` becomes `⟨a, b, c, d⟩` instead of `...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
tuple₁ : listΠ rcases_patt → rcases_patt
| [] := default | [one n] := one n | ps := tuple (tuple₁_core ps)
def
tactic.rcases_patt.tuple₁
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
This function is used for producing rcases patterns based on a case tree. This is like `tuple₁_core` but it produces a pattern instead of a tuple pattern list, converting `[n]` to `n` instead of `⟨n⟩` and `[]` to `_`, and otherwise just converting `[a, b, c]` to `⟨a, b, c⟩`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
alts₁_core : listΣ (listΠ rcases_patt) → listΣ rcases_patt
| [] := [] | [[alts ps]] := ps | (p :: ps) := tuple₁ p :: alts₁_core ps
def
tactic.rcases_patt.alts₁_core
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
This function is used for producing rcases patterns based on a case tree. Here we are given the list of patterns to apply to each argument of each constructor after the main case, and must produce a list of alternatives with the same effect. This function calls `tuple₁` to make the individual alternatives, and handles ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
alts₁ : listΣ (listΠ rcases_patt) → rcases_patt
| [[]] := tuple [] | [[alts ps]] := tuple [alts ps] | ps := alts' (alts₁_core ps)
def
tactic.rcases_patt.alts₁
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
This function is used for producing rcases patterns based on a case tree. This is like `alts₁_core`, but it produces a cases pattern directly instead of a list of alternatives. We specially translate the empty alternation to `⟨⟩`, and translate `|(a | b)` to `⟨a | b⟩` (because we don't have any syntax for unary alterna...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_reflect : has_reflect rcases_patt
| (one n) := `(_) | clear := `(_) | (explicit l) := `(explicit).subst (has_reflect l) | (typed l e) := (`(typed).subst (has_reflect l)).subst (reflect e) | (tuple l) := `(λ l, tuple l).subst $ by haveI := has_reflect; exact list.reflect l | (alts l) := `(λ l, alts l).subst $ by haveI := has_reflect; exact list.re...
instance
tactic.rcases_patt.has_reflect
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
format : ∀ bracket : bool, rcases_patt → tactic _root_.format
| _ (one n) := pure $ to_fmt n | _ clear := pure "-" | _ (explicit p) := do f ← format tt p, pure $ "@" ++ f | _ (tuple []) := pure "⟨⟩" | _ (tuple ls) := do fs ← ls.mmap $ format ff, pure $ "⟨" ++ _root_.format.group (_root_.format.nest 1 $ _root_.format.join $ list.intersperse ("," ++ _root_.format.line) fs) ...
def
tactic.rcases_patt.format
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Formats an `rcases` pattern. If the `bracket` argument is true, then it will be printed at high precedence, i.e. it will have parentheses around it if it is not already a tuple or atomic name.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
has_to_tactic_format : has_to_tactic_format rcases_patt
⟨rcases_patt.format ff⟩
instance
tactic.rcases_patt.has_to_tactic_format
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases.process_constructor : bool → list binder_info → listΠ rcases_patt → listΠ name × listΠ rcases_patt
| _ [] ps := ([], []) | explicit (bi::l) ps := if !explicit && (bi ≠ binder_info.default) then let (ns, tl) := rcases.process_constructor explicit l ps in (`_ :: ns, default :: tl) else match l, ps with | [], [] := ([`_], [default]) | [], [p] := ([p.name.get_or_else `_], [p]) --...
def
tactic.rcases.process_constructor
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Takes the number of fields of a single constructor and patterns to match its fields against (not necessarily the same number). The returned lists each contain one element per field of the constructor. The `name` is the name which will be used in the top-level `cases` tactic, and the `rcases_patt` is the pattern which t...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_pi_arity_list_aux : expr → tactic (list binder_info)
| (expr.pi n bi d b) := do m ← mk_fresh_name, let l := expr.local_const m n bi d, new_b ← whnf (expr.instantiate_var b l), r ← get_pi_arity_list_aux new_b, return (bi :: r) | e := return []
def
tactic.get_pi_arity_list_aux
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_pi_arity_list (type : expr) : tactic (list binder_info)
whnf type >>= get_pi_arity_list_aux
def
tactic.get_pi_arity_list
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Compute the arity of the given (Pi-)type
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_arity_list (fn : expr) : tactic (list binder_info)
infer_type fn >>= get_pi_arity_list
def
tactic.get_arity_list
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Compute the arity of the given function
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases.process_constructors (params : nat) : listΣ name → listΣ rcases_patt → tactic (dlist name × listΣ (name × listΠ rcases_patt))
| [] ps := pure (dlist.empty, []) | (c::cs) ps := do l ← mk_const c >>= get_arity_list, let ((explicit, h), t) := (match cs, ps.tail with -- We matched the last constructor against multiple patterns, -- so split off the remaining constructors. This handles matching -- `α ⊕ β ⊕ γ` against `a|b|c`. | [],...
def
tactic.rcases.process_constructors
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Takes a list of constructor names, and an (alternation) list of patterns, and matches each pattern against its constructor. It returns the list of names that will be passed to `cases`, and the list of `(constructor name, patterns)` for each constructor, where `patterns` is the (conjunctive) list of patterns to apply to...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
align {α β} (p : α → β → Prop) [∀ a b, decidable (p a b)] : list α → list β → list (α × β)
| (a::as) (b::bs) := if p a b then (a, b) :: align as bs else align as (b::bs) | _ _ := []
def
tactic.align
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Like `zip`, but only elements satisfying a matching predicate `p` will go in the list, and elements of the first list that fail to match the second list will be skipped.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_local_and_type (e : expr) : tactic (expr × expr)
(do t ← infer_type e, pure (t, e)) <|> (do e ← get_local e.local_pp_name, t ← infer_type e, pure (t, e))
def
tactic.get_local_and_type
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Given a local constant `e`, get its type. *But* if `e` does not exist, go find a hypothesis with the same pretty name as `e` and get it instead. This is needed because we can sometimes lose track of the unique names of hypotheses when they are revert/intro'd by `change` and `cases`. (A better solution would be for thes...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
clear_goals (ugs : list uncleared_goal) : tactic unit
do gs ← ugs.mmap (λ ⟨cs, g⟩, do set_goals [g], cs ← cs.mfoldr (λ c cs, (do (_, c) ← get_local_and_type c, pure (c :: cs)) <|> pure cs) [], clear' tt cs, [g] ← get_goals, pure g), set_goals gs
def
tactic.clear_goals
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Given a list of `uncleared_goal`s, each of which is a goal metavariable and a list of variables to clear, actually perform the clear and set the goals with the result.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases (h : option name) (p : pexpr) (pat : rcases_patt) : tactic unit
do let p := match pat with | rcases_patt.typed _ ty := ``(%%p : %%ty) | _ := p end, e ← match h with | some h := do x ← get_unused_name $ pat.name.get_or_else `this, interactive.generalize h () (p, x), get_local x | none := i_to_expr p end, if e.is_local_constant then match...
def
tactic.rcases
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rcases h e pat` performs case distinction on `e` using `pat` to name the arising new variables and assumptions. If `h` is `some` name, a new assumption `h : e = pat` will relate the expression `e` with the current pattern. See the module comment for the syntax of `pat`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_many (ps : listΠ pexpr) (pat : rcases_patt) : tactic unit
do let (_, pats) := rcases.process_constructor ff (ps.map (λ _, default)) pat.as_tuple.2, pes ← (ps.zip pats).mmap (λ ⟨p, pat⟩, do let p := match pat with | rcases_patt.typed _ ty := ``(%%p : %%ty) | _ := p end, e ← i_to_expr p, if e.is_local_constant then match pat.name with | s...
def
tactic.rcases_many
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rcases_many es pats` performs case distinction on the `es` using `pat` to name the arising new variables and assumptions. See the module comment for the syntax of `pat`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rintro (ids : listΠ rcases_patt) : tactic unit
do l ← ids.mmap (λ id, do e ← intro $ id.name.get_or_else `_, pure (id, e)), focus1 (rcases.continue l >>= clear_goals)
def
tactic.rintro
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rintro pat₁ pat₂ ... patₙ` introduces `n` arguments, then pattern matches on the `patᵢ` using the same syntax as `rcases`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
merge_list {α} (m : α → α → α) : list α → list α → list α
| [] l₂ := l₂ | l₁ [] := l₁ | (a :: l₁) (b :: l₂) := m a b :: merge_list l₁ l₂
def
tactic.merge_list
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Like `zip_with`, but if the lists don't match in length, the excess elements will be put at the end of the result.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_patt.merge : rcases_patt → rcases_patt → rcases_patt
| (rcases_patt.alts p₁) p₂ := rcases_patt.alts (merge_list rcases_patt.merge p₁ p₂.as_alts) | p₁ (rcases_patt.alts p₂) := rcases_patt.alts (merge_list rcases_patt.merge p₁.as_alts p₂) | (rcases_patt.explicit p₁) p₂ := rcases_patt.explicit (p₁.merge p₂) | p₁ (rcases_patt.explicit p₂) := rcases_patt.explicit (p₁.merge p₂...
def
tactic.rcases_patt.merge
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Merge two `rcases` patterns. This is used to underapproximate a case tree by an `rcases` pattern. The two patterns come from cases in two branches, that due to the syntax of `rcases` patterns are forced to overlap. The rule here is that we take only the case splits that are in common between both branches. For example ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_hint (p : pexpr) (depth : nat) : tactic rcases_patt
do e ← i_to_expr p, if e.is_local_constant then focus1 $ do (p, gs) ← rcases_hint_core ff tt depth e, set_goals gs, pure (p.get_or_else default) else do x ← mk_fresh_name, n ← revert_kdependencies e semireducible, tactic.generalize e x <|> (do t ← infer_type e, tactic.a...
def
tactic.rcases_hint
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
* `rcases? e` is like `rcases e with ...`, except it generates `...` by matching on everything it can, and it outputs an `rcases` invocation that should have the same effect. * `rcases? e : n` can be used to control the depth of case splits (especially important for recursive types like `nat`, which can be cased as man...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_hint_many (ps : list pexpr) (depth : nat) : tactic (listΠ rcases_patt)
do es ← ps.mmap (λ p, do e ← i_to_expr p, if e.is_local_constant then pure e else do x ← mk_fresh_name, n ← revert_kdependencies e semireducible, tactic.generalize e x <|> (do t ← infer_type e, tactic.assertv x t e, get_local x >>= tactic.revert, pure ()), ...
def
tactic.rcases_hint_many
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
* `rcases? ⟨e1, e2, e3⟩` is like `rcases ⟨e1, e2, e3⟩ with ...`, except it generates `...` by matching on everything it can, and it outputs an `rcases` invocation that should have the same effect. * `rcases? ⟨e1, e2, e3⟩ : n` can be used to control the depth of case splits (especially important for recursive type...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rintro_hint (depth : nat) : tactic (listΠ rcases_patt)
do l ← intros, focus1 $ do (p, gs) ← rcases_hint.continue ff depth l, set_goals gs, pure p setup_tactic_parser
def
tactic.rintro_hint
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
* `rintro?` is like `rintro ...`, except it generates `...` by introducing and matching on everything it can, and it outputs an `rintro` invocation that should have the same effect. * `rintro? : n` can be used to control the depth of case splits (especially important for recursive types like `nat`, which can be cased a...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_patt_parse_hi
with_desc "patt_hi" rcases_patt_parse_hi'
def
tactic.rcases_patt_parse_hi
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rcases_patt_parse_hi` will parse a high precedence `rcases` pattern, `patt_hi`. This means only tuples and identifiers are allowed; alternations and type ascriptions require `(...)` instead, which switches to `patt`. ```lean patt_hi ::= id | "rfl" | "_" | "@" patt_hi | "⟨" (patt ",")* patt "⟩" | "(" patt ")" ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_patt_parse
with_desc "patt" rcases_patt_parse'
def
tactic.rcases_patt_parse
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rcases_patt_parse` will parse a low precedence `rcases` pattern, `patt`. This consists of a `patt_med` (which deals with alternations), optionally followed by a `: ty` type ascription. The expression `ty` is at `texpr` precedence because it can appear at the end of a tactic, for example in `rcases e with x : ty <|> sk...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_patt_parse_list
with_desc "patt_med" rcases_patt_parse_list'
def
tactic.rcases_patt_parse_list
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rcases_patt_parse_list` will parse an alternation list, `patt_med`, one or more `patt` patterns separated by `|`. It does not parse a `:` at the end, so that `a | b : ty` parses as `(a | b) : ty` where `a | b` is the `patt_med` part. ```lean patt_med ::= (patt_hi "|")* patt_hi ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_parse_depth : parser nat
do o ← (tk ":" *> small_nat)?, pure $ o.get_or_else 5
def
tactic.rcases_parse_depth
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Parse the optional depth argument `(: n)?` of `rcases?` and `rintro?`, with default depth 5.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_args | hint (tgt : pexpr ⊕ list pexpr) (depth : nat) | rcases (name : option name) (tgt : pexpr) (pat : rcases_patt) | rcases_many (tgt : listΠ pexpr) (pat : rcases_patt)
inductive
tactic.rcases_args
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
The arguments to `rcases`, which in fact dispatch to several other tactics. * `rcases? expr (: n)?` or `rcases? ⟨expr, ...⟩ (: n)?` calls `rcases_hint` * `rcases? ⟨expr, ...⟩ (: n)?` calls `rcases_hint_many` * `rcases (h :)? expr (with patt)?` calls `rcases` * `rcases ⟨expr, ...⟩ (with patt)?` calls `rcases_many`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases_parse : parser rcases_args
with_desc "('?' expr (: n)?) | ((h :)? expr (with patt)?)" $ do hint ← (tk "?")?, p ← (sum.inr <$> brackets "⟨" "⟩" (sep_by (tk ",") (parser.pexpr 0))) <|> (sum.inl <$> texpr), match hint with | none := do p ← (do sum.inl (expr.local_const h _ _ _) ← pure p, tk ":" *> (@sum.inl _ (pexpr ⊕ ...
def
tactic.rcases_parse
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Syntax for a `rcases` pattern: * `rcases? expr (: n)?` * `rcases (h :)? expr (with patt_list (: expr)?)?`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rintro_patt_parse_hi
with_desc "rintro_patt_hi" rintro_patt_parse_hi'
def
tactic.rintro_patt_parse_hi
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rintro_patt_parse_hi` will parse a high precedence `rcases` pattern, `rintro_patt_hi` below. This means only tuples and identifiers are allowed; alternations and type ascriptions require `(...)` instead, which switches to `patt`. ```lean rintro_patt_hi ::= patt_hi | "(" rintro_patt ")" ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rintro_patt_parse
with_desc "rintro_patt" $ rintro_patt_parse' tt
def
tactic.rintro_patt_parse
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rintro_patt_parse` will parse a low precedence `rcases` pattern, `rintro_patt` below. This consists of either a sequence of patterns `p1 p2 p3` or an alternation list `p1 | p2 | p3` treated as a single pattern, optionally followed by a `: ty` type ascription, which applies to every pattern in the list. ```lean rintro_...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rintro_patt_parse_low
with_desc "rintro_patt_low" $ rintro_patt_parse' ff
def
tactic.rintro_patt_parse_low
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
`rintro_patt_parse_low` parses `rintro_patt_low`, which is the same as `rintro_patt_parse tt` but it does not permit an unparenthesized alternation list, it must have the form `p1 p2 p3 (: ty)?`. ```lean rintro_patt_low ::= rintro_patt_hi* (":" expr)? ```
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rintro_parse : parser (listΠ rcases_patt ⊕ nat)
with_desc "('?' (: n)?) | patt*" $ (tk "?" >> sum.inr <$> rcases_parse_depth) <|> sum.inl <$> rintro_patt_parse_low
def
tactic.rintro_parse
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Syntax for a `rintro` pattern: `('?' (: n)?) | rintro_patt`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rcases : parse rcases_parse → tactic unit
| (rcases_args.rcases h p ids) := tactic.rcases h p ids | (rcases_args.rcases_many ps ids) := tactic.rcases_many ps ids | (rcases_args.hint p depth) := do (pe, patt) ← match p with | sum.inl p := prod.mk <$> pp p <*> rcases_hint p depth | sum.inr ps := do patts ← rcases_hint_many ps depth, pes ← ps.mmap p...
def
tactic.interactive.rcases
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[ "format.comma_separated", "tactic.rcases", "tactic.rcases_many" ]
`rcases` is a tactic that will perform `cases` recursively, according to a pattern. It is used to destructure hypotheses or expressions composed of inductive types like `h1 : a ∧ b ∧ c ∨ d` or `h2 : ∃ x y, trans_rel R x y`. Usual usage might be `rcases h1 with ⟨ha, hb, hc⟩ | hd` or `rcases h2 with ⟨x, y, _ | ⟨z, hxz, h...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rintro : parse rintro_parse → tactic unit
| (sum.inl []) := intros [] | (sum.inl l) := tactic.rintro l | (sum.inr depth) := do ps ← tactic.rintro_hint depth, fs ← ps.mmap (λ p, do f ← pp $ p.format tt, pure $ format.space ++ format.group f), trace $ ↑"Try this: rintro" ++ format.join fs
def
tactic.interactive.rintro
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[ "tactic.rintro", "tactic.rintro_hint" ]
The `rintro` tactic is a combination of the `intros` tactic with `rcases` to allow for destructuring patterns while introducing variables. See `rcases` for a description of supported patterns. For example, `rintro (a | ⟨b, c⟩) ⟨d, e⟩` will introduce two variables, and then do case splits on both of them producing two s...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rintros
rintro
def
tactic.interactive.rintros
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Alias for `rintro`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
obtain_parse : parser ((option rcases_patt × option pexpr) × option (pexpr ⊕ list pexpr))
with_desc "patt? (: expr)? (:= expr)?" $ do (pat, tp) ← (do pat ← rcases_patt_parse, pure $ match pat with | rcases_patt.typed pat tp := (some pat, some tp) | _ := (some pat, none) end) <|> prod.mk none <$> (tk ":" >> texpr)?, prod.mk (pat, tp) <$> (do tk ":=", (guard tp.is_n...
def
tactic.interactive.obtain_parse
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
Parses `patt? (: expr)? (:= expr)?`, the arguments for `obtain`. (This is almost the same as `rcases_patt_parse`, but it allows the pattern part to be empty.)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
obtain : parse obtain_parse → tactic unit
| ((pat, _), some (sum.inr val)) := tactic.rcases_many val (pat.get_or_else default) | ((pat, none), some (sum.inl val)) := tactic.rcases none val (pat.get_or_else default) | ((pat, some tp), some (sum.inl val)) := tactic.rcases none val $ (pat.get_or_else default).typed tp | ((pat, some tp), none) := do nm ← m...
def
tactic.interactive.obtain
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[ "tactic.rcases", "tactic.rcases_many" ]
The `obtain` tactic is a combination of `have` and `rcases`. See `rcases` for a description of supported patterns. ```lean obtain ⟨patt⟩ : type, { ... } ``` is equivalent to ```lean have h : type, { ... }, rcases h with ⟨patt⟩ ``` The syntax `obtain ⟨patt⟩ : type := proof` is also supported. If `⟨patt⟩` is omitted, ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rsuffices (h : parse obtain_parse) : tactic unit
focus1 $ obtain h >> tactic.rotate 1
def
tactic.interactive.rsuffices
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
The `rsuffices` tactic is an alternative version of `suffices`, that allows the usage of any syntax that would be valid in an `obtain` block. This tactic just calls `obtain` on the expression, and then `rotate 1`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rsufficesI (h : parse obtain_parse) : tactic unit
rsuffices h ; resetI
def
tactic.interactive.rsufficesI
tactic
src/tactic/rcases.lean
[ "data.dlist", "tactic.core", "tactic.clear" ]
[]
The `rsufficesI` tactic is an instance-cache aware version of `rsuffices`; it resets the instance cache on the resulting goals.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
get_cat_inst : expr → tactic expr
| `(@category_struct.comp _ %%struct_inst _ _ _ _ _) := pure struct_inst | _ := failed
def
tactic.get_cat_inst
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[]
From an expression `f ≫ g`, extract the expression representing the category instance.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
prove_reassoc (h : expr) : tactic (expr × expr)
do (vs,t) ← infer_type h >>= open_pis, (lhs,rhs) ← match_eq t, struct_inst ← get_cat_inst lhs <|> get_cat_inst rhs <|> fail "no composition found in statement", `(@quiver.hom _ %%hom_inst %%X %%Y) ← infer_type lhs, C ← infer_type X, X' ← mk_local' `X' binder_info.implicit C, ft ← to_expr ``(@quiver...
def
tactic.prove_reassoc
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[]
(internals for `@[reassoc]`) Given a lemma of the form `∀ ..., f ≫ g = h`, proves a new lemma of the form `h : ∀ ... {W} (k), f ≫ (g ≫ k) = h ≫ k`, and returns the type and proof of this lemma.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
reassoc_axiom (n : name) (n' : name := n.append_suffix "_assoc") : tactic unit
do d ← get_decl n, let ls := d.univ_params.map level.param, let c := @expr.const tt n ls, (t'',pr') ← prove_reassoc c, add_decl $ declaration.thm n' d.univ_params t'' (pure pr'), copy_attribute `simp n n' setup_tactic_parser
def
tactic.reassoc_axiom
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[]
(implementation for `@[reassoc]`) Given a declaration named `n` of the form `∀ ..., f ≫ g = h`, proves a new lemma named `n'` of the form `∀ ... {W} (k), f ≫ (g ≫ k) = h ≫ k`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
reassoc_attr : user_attribute unit (option name)
{ name := `reassoc, descr := "create a companion lemma for associativity-aware rewriting", parser := optional ident, after_set := some (λ n _ _, do some n' ← reassoc_attr.get_param n | reassoc_axiom n (n.append_suffix "_assoc"), reassoc_axiom n $ n.get_prefix ++ n' ) }
def
tactic.reassoc_attr
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[]
The `reassoc` attribute can be applied to a lemma ```lean @[reassoc] lemma some_lemma : foo ≫ bar = baz := ... ``` to produce ```lean lemma some_lemma_assoc {Y : C} (f : X ⟶ Y) : foo ≫ bar ≫ f = baz ≫ f := ... ``` The name of the produced lemma can be specified with `@[reassoc other_lemma_name]`. If `simp` is added...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
reassoc_cmd (_ : parse $ tk "reassoc_axiom") : lean.parser unit
do n ← ident, of_tactic $ do n ← resolve_constant n, reassoc_axiom n
def
tactic.reassoc_cmd
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[]
When declaring a class of categories, the axioms can be reformulated to be more amenable to manipulation in right associated expressions: ```lean class some_class (C : Type) [category C] := (foo : Π X : C, X ⟶ X) (bar : ∀ {X Y : C} (f : X ⟶ Y), foo X ≫ f = f ≫ foo Y) reassoc_axiom some_class.bar ``` The above will p...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
reassoc (del : parse (tk "!")?) (ns : parse ident*) : tactic unit
do ns.mmap' (λ n, do h ← get_local n, (t,pr) ← prove_reassoc h, assertv n t pr, when del.is_some (tactic.clear h) )
def
tactic.interactive.reassoc
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[]
`reassoc h`, for assumption `h : x ≫ y = z`, creates a new assumption `h : ∀ {W} (f : Z ⟶ W), x ≫ y ≫ f = z ≫ f`. `reassoc! h`, does the same but deletes the initial `h` assumption. (You can also add the attribute `@[reassoc]` to lemmas to generate new declarations generalized in this way.)
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
calculated_Prop {α} (β : Prop) (hh : α)
β
def
tactic.calculated_Prop
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
derive_reassoc_proof : tactic unit
do `(calculated_Prop %%v %%h) ← target, (t,pr) ← prove_reassoc h, unify v t, exact pr
def
tactic.derive_reassoc_proof
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
category_theory.reassoc_of {α} (hh : α) {β} (x : tactic.calculated_Prop β hh . tactic.derive_reassoc_proof) : β
x
theorem
category_theory.reassoc_of
tactic
src/tactic/reassoc_axiom.lean
[ "category_theory.category.basic" ]
[ "tactic.calculated_Prop", "tactic.derive_reassoc_proof" ]
With `h : x ≫ y ≫ z = x` (with universal quantifiers tolerated), `reassoc_of h : ∀ {X'} (f : W ⟶ X'), x ≫ y ≫ z ≫ f = x ≫ f`. The type and proof of `reassoc_of h` is generated by `tactic.derive_reassoc_proof` which make `reassoc_of` meta-programming adjacent. It is not called as a tactic but as an expression. The goal...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
expr.rename_var (old new : name) : expr → expr
| (pi n bi t b) := (pi (if n = old then new else n) bi (expr.rename_var t) (expr.rename_var b)) | (lam n bi t b) := (lam (if n = old then new else n) bi (expr.rename_var t) (expr.rename_var b)) | (app t b) := (app (expr.rename_var t) (expr.rename_var b)) | e := e
def
expr.rename_var
tactic
src/tactic/rename_var.lean
[ "tactic.interactive" ]
[]
Rename bound variable `old` to `new` in an `expr`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rename_var_at_goal (old new : name) : tactic unit
do old_tgt ← target, tactic.change (expr.rename_var old new old_tgt)
def
tactic.rename_var_at_goal
tactic
src/tactic/rename_var.lean
[ "tactic.interactive" ]
[ "expr.rename_var" ]
Rename bound variable `old` to `new` in goal
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rename_var_at_hyp (old new : name) (e : expr) : tactic unit
do old_e ← infer_type e, tactic.change_core (expr.rename_var old new old_e) (some e)
def
tactic.rename_var_at_hyp
tactic
src/tactic/rename_var.lean
[ "tactic.interactive" ]
[ "expr.rename_var", "tactic.change_core" ]
Rename bound variable `old` to `new` in assumption `h`
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
rename_var (old : parse ident) (new : parse ident) (l : parse location) : tactic unit
l.apply (rename_var_at_hyp old new) (rename_var_at_goal old new)
def
tactic.interactive.rename_var
tactic
src/tactic/rename_var.lean
[ "tactic.interactive" ]
[]
`rename_var old new` renames all bound variables named `old` to `new` in the goal. `rename_var old new at h` does the same in hypothesis `h`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
replacer_core {α : Type} [reflected _ α] (ntac : name) (eval : ∀ β [reflected _ β], expr → tactic β) : list name → tactic α
| [] := fail ("no implementation defined for " ++ to_string ntac) | (n::ns) := do d ← get_decl n, let t := d.type, tac ← do { mk_const n >>= eval (tactic α) } <|> do { tac ← mk_const n >>= eval (tactic α → tactic α), return (tac (replacer_core ns)) } <|> do { tac ← mk_const n >>= eval (opt...
def
tactic.replacer_core
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
replacer (ntac : name) {α : Type} [reflected _ α] (F : Type → Type) (eF : ∀ β, reflected _ β → reflected _ (F β)) (R : ∀ β, F β → β) : tactic α
attribute.get_instances ntac >>= replacer_core ntac (λ β eβ e, R β <$> @eval_expr' (F β) (eF β eβ) e)
def
tactic.replacer
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_replacer₁ : expr → nat → expr × expr
| (expr.pi n bi d b) i := let (e₁, e₂) := mk_replacer₁ b (i+1) in (expr.pi n bi d e₁, (`(expr.pi n bi d) : expr) e₂) | _ i := (expr.var i, expr.var 0)
def
tactic.mk_replacer₁
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_replacer₂ (ntac : name) (v : expr × expr) : expr → nat → option expr
| (expr.pi n bi d b) i := do b' ← mk_replacer₂ b (i+1), some (expr.lam n bi d b') | `(tactic %%β) i := some $ (expr.const ``replacer []).mk_app [ reflect ntac, β, reflect β, expr.lam `γ binder_info.default `(Type) v.1, expr.lam `γ binder_info.default `(Type) $ expr.lam `eγ binder_info.inst_implici...
def
tactic.mk_replacer₂
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_replacer (ntac : name) (e : expr) : tactic expr
mk_replacer₂ ntac (mk_replacer₁ e 0) e 0
def
tactic.mk_replacer
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
valid_types : expr → list expr
| (expr.pi n bi d b) := expr.pi n bi d <$> valid_types b | `(tactic %%β) := [`(tactic.{0} %%β), `(tactic.{0} %%β → tactic.{0} %%β), `(option (tactic.{0} %%β) → tactic.{0} %%β)] | _ := []
def
tactic.valid_types
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
replacer_attr (ntac : name) : user_attribute
{ name := ntac, descr := "Replaces the definition of `" ++ to_string ntac ++ "`. This should be " ++ "applied to a definition with the type `tactic unit`, which will be " ++ "called whenever `" ++ to_string ntac ++ "` is called. The definition " ++ "can optionally have an argument of type `tactic unit` or " +...
def
tactic.replacer_attr
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
def_replacer (ntac : name) (ty : expr) : tactic unit
let nattr := ntac <.> "attr" in do add_meta_definition nattr [] `(user_attribute) `(replacer_attr %%(reflect ntac)), set_basic_attribute `user_attribute nattr tt, v ← mk_replacer ntac ty, add_meta_definition ntac [] ty v, add_doc_string ntac $ "The `" ++ to_string ntac ++ "` tactic is a \"replaceable\...
def
tactic.def_replacer
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
Define a new replaceable tactic.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
def_replacer_cmd (_ : parse $ tk "def_replacer") : lean.parser unit
do ntac ← ident, ty ← optional (tk ":" *> types.texpr), match ty with | (some p) := do t ← to_expr p, def_replacer ntac t | none := def_replacer ntac `(tactic unit) end
def
tactic.def_replacer_cmd
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
`def_replacer foo` sets up a stub definition `foo : tactic unit`, which can effectively be defined and re-defined later, by tagging definitions with `@[foo]`. - `@[foo] meta def foo_1 : tactic unit := ...` replaces the current definition of `foo`. - `@[foo] meta def foo_2 (old : tactic unit) : tactic unit := ...` repl...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unprime : name → tactic name
| nn@(name.mk_string s n) := let s' := (s.split_on ''').head in if s'.length < s.length then pure (name.mk_string s' n) else fail format!"expecting primed name: {nn}" | n := fail format!"invalid name: {n}"
def
tactic.unprime
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
replaceable_attr : user_attribute
{ name := `replaceable, descr := "make definition replaceable in dependent modules", after_set := some $ λ n' _ _, do { n ← unprime n', d ← get_decl n', «def_replacer» n d.type, (replacer_attr n).set n' () tt } }
def
tactic.replaceable_attr
tactic
src/tactic/replacer.lean
[ "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
restate_axiom (d : declaration) (new_name : name) : tactic unit
do (levels, type, value, reducibility, trusted) ← pure (match d.to_definition with | declaration.defn name levels type value reducibility trusted := (levels, type, value, reducibility, trusted) | _ := undefined end), (s, u) ← mk_simp_set ff [] [], new_type ← (s.dsimplify [] type) <|> pure (type), prop ←...
def
restate_axiom
tactic
src/tactic/restate_axiom.lean
[ "tactic.doc_commands" ]
[]
`restate_axiom` takes a structure field, and makes a new, definitionally simplified copy of it. If the existing field name ends with a `'`, the new field just has the prime removed. Otherwise, we append `_lemma`. The main application is to provide clean versions of structure fields that have been tagged with an auto_pa...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
name_lemma (old : name) (new : option name := none) : tactic name
match new with | none := match old.components.reverse with | last :: most := (do let last := last.to_string, let last := if last.to_list.ilast = ''' then (last.to_list.reverse.drop 1).reverse.as_string else last ++ "_lemm...
def
name_lemma
tactic
src/tactic/restate_axiom.lean
[ "tactic.doc_commands" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
restate_axiom_cmd (_ : parse $ tk "restate_axiom") : lean.parser unit
do from_lemma ← ident, new_name ← optional ident, from_lemma_fully_qualified ← resolve_constant from_lemma, d ← get_decl from_lemma_fully_qualified <|> fail ("declaration " ++ to_string from_lemma ++ " not found"), do { new_name ← name_lemma from_lemma_fully_qualified new_name,
def
restate_axiom_cmd
tactic
src/tactic/restate_axiom.lean
[ "tactic.doc_commands" ]
[ "name_lemma" ]
`restate_axiom` makes a new copy of a structure field, first definitionally simplifying the type. This is useful to remove `auto_param` or `opt_param` from the statement. As an example, we have: ```lean structure A := (x : ℕ) (a' : x = 1 . skip) example (z : A) : z.x = 1 := by rw A.a' -- rewrite tactic failed, lemma ...
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_fn (fn : expr) : expr → tactic (expr × expr)
| (app (app fn' e₀) e₁) := unify fn fn' $> (e₀, e₁) | _ := failed
def
tactic.match_fn
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
fill_args : expr → tactic (expr × list expr)
| (pi n bi d b) := do v ← mk_meta_var d, (r, vs) ← fill_args (b.instantiate_var v), return (r, v::vs) | e := return (e, [])
def
tactic.fill_args
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_assoc_pattern' (fn : expr) : expr → tactic (dlist expr)
| e := (do (e₀, e₁) ← match_fn fn e, (++) <$> mk_assoc_pattern' e₀ <*> mk_assoc_pattern' e₁) <|> pure (dlist.singleton e)
def
tactic.mk_assoc_pattern'
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_assoc_pattern (fn e : expr) : tactic (list expr)
dlist.to_list <$> mk_assoc_pattern' fn e
def
tactic.mk_assoc_pattern
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_assoc (fn : expr) : list expr → tactic expr
| [] := failed | [x] := pure x | (x₀ :: x₁ :: xs) := mk_assoc (fn x₀ x₁ :: xs)
def
tactic.mk_assoc
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
chain_eq_trans : list expr → tactic expr
| [] := to_expr ``(rfl) | [e] := pure e | (e :: es) := chain_eq_trans es >>= mk_eq_trans e
def
tactic.chain_eq_trans
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
unify_prefix : list expr → list expr → tactic unit
| [] _ := pure () | _ [] := failed | (x :: xs) (y :: ys) := unify x y >> unify_prefix xs ys
def
tactic.unify_prefix
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_assoc_pattern' (p : list expr) : list expr → tactic (list expr × list expr) | es
unify_prefix p es $> ([], es.drop p.length) <|> match es with | [] := failed | (x :: xs) := prod.map (cons x) id <$> match_assoc_pattern' xs end
def
tactic.match_assoc_pattern'
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
match_assoc_pattern (fn p e : expr) : tactic (list expr × list expr)
do p' ← mk_assoc_pattern fn p, e' ← mk_assoc_pattern fn e, match_assoc_pattern' p' e'
def
tactic.match_assoc_pattern
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
id_tag.assoc_proof
()
def
tactic.id_tag.assoc_proof
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
Tag for proofs generated by `assoc_rewrite`.
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_eq_proof (fn : expr) (e₀ e₁ : list expr) (p : expr) : tactic (expr × expr × expr)
do (l, r) ← infer_type p >>= match_eq, if e₀.empty ∧ e₁.empty then pure (l, r, p) else do l' ← mk_assoc fn (e₀ ++ [l] ++ e₁), r' ← mk_assoc fn (e₀ ++ [r] ++ e₁), t ← infer_type l', v ← mk_local_def `x t, e ← mk_assoc fn (e₀ ++ [v] ++ e₁), p ← mk_congr_arg (e.lambdas [v]) p, ...
def
tactic.mk_eq_proof
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assoc_root (fn assoc : expr) : expr → tactic (expr × expr) | e
(do (e₀, e₁) ← match_fn fn e, (ea, eb) ← match_fn fn e₁, let e' := fn (fn e₀ ea) eb, p' ← mk_eq_symm (assoc e₀ ea eb), (e'', p'') ← assoc_root e', prod.mk e'' <$> mk_eq_trans p' p'') <|> prod.mk e <$> mk_eq_refl e
def
tactic.assoc_root
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assoc_refl' (fn assoc : expr) : expr → expr → tactic expr
| l r := (is_def_eq l r >> mk_eq_refl l) <|> do (l', l_p) ← assoc_root fn assoc l <|> fail "A", (el₀, el₁) ← match_fn fn l' <|> fail "B", (r', r_p) ← assoc_root fn assoc r <|> fail "C", (er₀, er₁) ← match_fn fn r' <|> fail "D", p₀ ← assoc_refl' el₀ er₀, p₁ ← is_def_eq el₁ er₁ >> mk_eq_refl el₁, f_eq...
def
tactic.assoc_refl'
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assoc_refl (fn : expr) : tactic unit
do (l, r) ← target >>= match_eq, assoc ← mk_mapp ``is_associative.assoc [none, fn, none] <|> fail format!"{fn} is not associative", assoc_refl' fn assoc l r >>= tactic.exact
def
tactic.assoc_refl
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
flatten (fn assoc e : expr) : tactic (expr × expr)
do ls ← mk_assoc_pattern fn e, e' ← mk_assoc fn ls, p ← assoc_refl' fn assoc e e', return (e', p)
def
tactic.flatten
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assoc_rewrite_intl (assoc h e : expr) : tactic (expr × expr)
do t ← infer_type h, (lhs, rhs) ← match_eq t, let fn := lhs.app_fn.app_fn, (l, r) ← match_assoc_pattern fn lhs e, (lhs', rhs', h') ← mk_eq_proof fn l r h, e_p ← assoc_refl' fn assoc e lhs', (rhs'', rhs_p) ← flatten fn assoc rhs', final_p ← chain_eq_trans [e_p, h', rhs_p], return (rhs'', final_p...
def
tactic.assoc_rewrite_intl
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
enum_assoc_subexpr' (fn : expr) : expr → tactic (dlist expr)
| e := dlist.singleton e <$ (match_fn fn e >> guard (¬ e.has_var)) <|> expr.mfoldl (λ es e', (++ es) <$> enum_assoc_subexpr' e') dlist.empty e
def
tactic.enum_assoc_subexpr'
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[ "expr.mfoldl" ]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
enum_assoc_subexpr (fn e : expr) : tactic (list expr)
dlist.to_list <$> enum_assoc_subexpr' fn e
def
tactic.enum_assoc_subexpr
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
mk_assoc_instance (fn : expr) : tactic expr
do t ← mk_mapp ``is_associative [none, fn], inst ← prod.snd <$> solve_aux t assumption <|> (mk_instance t >>= assertv `_inst t) <|> fail format!"{fn} is not associative", mk_mapp ``is_associative.assoc [none, fn, inst]
def
tactic.mk_assoc_instance
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assoc_rewrite (h e : expr) (opt_assoc : option expr := none) : tactic (expr × expr × list expr)
do (t, vs) ← infer_type h >>= fill_args, (lhs, rhs) ← match_eq t, let fn := lhs.app_fn.app_fn, es ← enum_assoc_subexpr fn e, assoc ← match opt_assoc with | none := mk_assoc_instance fn | (some assoc) := pure assoc end, (_, p) ← mfirst (assoc_rewrite_intl assoc $ h.mk_app ...
def
tactic.assoc_rewrite
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assoc_rewrite_target (h : expr) (opt_assoc : option expr := none) : tactic unit
do tgt ← target, (tgt', p, _) ← assoc_rewrite h tgt opt_assoc, replace_target tgt' p
def
tactic.assoc_rewrite_target
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assoc_rewrite_hyp (h hyp : expr) (opt_assoc : option expr := none) : tactic expr
do tgt ← infer_type hyp, (tgt', p, _) ← assoc_rewrite h tgt opt_assoc, replace_hyp hyp tgt' p
def
tactic.assoc_rewrite_hyp
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83
assoc_rw_goal (rs : list rw_rule) : tactic unit
rs.mmap' $ λ r, do save_info r.pos, eq_lemmas ← get_rule_eqn_lemmas r, orelse' (do e ← to_expr' r.rule, assoc_rewrite_target e) (eq_lemmas.mfirst $ λ n, do e ← mk_const n, assoc_rewrite_target e) (eq_lemmas.empty)
def
tactic.interactive.assoc_rw_goal
tactic
src/tactic/rewrite.lean
[ "data.dlist", "tactic.core" ]
[]
https://github.com/leanprover-community/mathlib
65a1391a0106c9204fe45bc73a039f056558cb83