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 |
|---|---|---|---|---|---|---|---|---|---|---|
simplify_top_down' {α} (a : α) (pre : α → expr → tactic (α × expr × expr))
(e : expr) (cfg : simp_config := {}) : tactic (α × expr × expr) | ext_simplify_core a cfg simp_lemmas.mk (λ _, failed)
(λ a _ _ _ e, do
(new_a, new_e, pr) ← pre a e,
guard (¬ new_e =ₐ e),
return (new_a, new_e, some pr, ff))
(λ _ _ _ _ _, failed)
`eq e | def | norm_cast.simplify_top_down' | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | A local variant on `simplify_top_down`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
derive (e : expr) : tactic (expr × expr) | do
cache ← norm_cast_attr.get_cache,
e ← instantiate_mvars e,
let cfg : simp_config :=
{ zeta := ff,
beta := ff,
eta := ff,
proj := ff,
iota := ff,
iota_eqn := ff,
fail_if_unchanged := ff },
let e0 := e,
-- step 1: pre-processing of numerals
((), e1, pr1) ← simplify_top_down' () ... | def | norm_cast.derive | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | The core simplification routine of `norm_cast`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
derive_push_cast (extra_lems : list simp_arg_type) (e : expr) : tactic (expr × expr) | do (s, _) ← mk_simp_set tt [`push_cast] extra_lems,
(e, prf, _) ← simplify (s.erase [`nat.cast_succ]) [] e
{fail_if_unchanged := ff} `eq tactic.assumption,
return (e, prf) | def | norm_cast.derive_push_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [
"nat.cast_succ"
] | A small variant of `push_cast` suited for non-interactive use.
`derive_push_cast extra_lems e` returns an expression `e'` and a proof that `e = e'`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
aux_mod_cast (e : expr) (include_goal : bool := tt) : tactic expr | match e with
| local_const _ lc _ _ := do
e ← get_local lc,
replace_at derive [e] include_goal,
get_local lc
| e := do
t ← infer_type e,
e ← assertv `this t e,
replace_at derive [e] include_goal,
get_local `this
end | def | tactic.aux_mod_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | `aux_mod_cast e` runs `norm_cast` on `e` and returns the result. If `include_goal` is true, it
also normalizes the goal. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
exact_mod_cast (e : expr) : tactic unit | decorate_error "exact_mod_cast failed:" $ do
new_e ← aux_mod_cast e,
exact new_e | def | tactic.exact_mod_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | `exact_mod_cast e` runs `norm_cast` on the goal and `e`, and tries to use `e` to close the
goal. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
apply_mod_cast (e : expr) : tactic (list (name × expr)) | decorate_error "apply_mod_cast failed:" $ do
new_e ← aux_mod_cast e,
apply new_e | def | tactic.apply_mod_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | `apply_mod_cast e` runs `norm_cast` on the goal and `e`, and tries to apply `e`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
assumption_mod_cast : tactic unit | decorate_error "assumption_mod_cast failed:" $ do
let cfg : simp_config :=
{ fail_if_unchanged := ff,
canonize_instances := ff,
canonize_proofs := ff,
proj := ff },
replace_at derive [] tt,
ctx ← local_context,
ctx.mfirst (λ h, aux_mod_cast h ff >>= tactic.exact) | def | tactic.assumption_mod_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | `assumption_mod_cast` runs `norm_cast` on the goal. For each local hypothesis `h`, it also
normalizes `h` and tries to use that to close the goal. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
norm_cast (loc : parse location) : tactic unit | do
ns ← loc.get_locals,
tt ← replace_at derive ns loc.include_goal | fail "norm_cast failed to simplify",
when loc.include_goal $ try tactic.reflexivity,
when loc.include_goal $ try tactic.triv,
when (¬ ns.empty) $ try tactic.contradiction | def | tactic.interactive.norm_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | Normalize casts at the given locations by moving them "upwards".
As opposed to simp, norm_cast can be used without necessarily closing the goal. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
rw_mod_cast (rs : parse rw_rules) (loc : parse location) : tactic unit | decorate_error "rw_mod_cast failed:" $ do
let cfg_norm : simp_config := {},
let cfg_rw : rewrite_cfg := {},
ns ← loc.get_locals,
monad.mapm' (λ r : rw_rule, do
save_info r.pos,
replace_at derive ns loc.include_goal,
rw ⟨[r], none⟩ loc {}
) rs.rules,
replace_at derive ns loc.include_goal,
skip | def | tactic.interactive.rw_mod_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | Rewrite with the given rules and normalize casts between steps. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
exact_mod_cast (e : parse texpr) : tactic unit | do
e ← i_to_expr e <|> do
{ ty ← target,
e ← i_to_expr_strict ``(%%e : %%ty),
pty ← pp ty, ptgt ← pp e,
fail ("exact_mod_cast failed, expression type not directly " ++
"inferrable. Try:\n\nexact_mod_cast ...\nshow " ++
to_fmt pty ++ ",\nfrom " ++ ptgt : format) },
tactic.exact_mod_cast e | def | tactic.interactive.exact_mod_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [
"tactic.exact_mod_cast"
] | Normalize the goal and the given expression, then close the goal with exact. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
apply_mod_cast (e : parse texpr) : tactic unit | do
e ← i_to_expr_for_apply e,
concat_tags $ tactic.apply_mod_cast e | def | tactic.interactive.apply_mod_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [
"tactic.apply_mod_cast"
] | Normalize the goal and the given expression, then apply the expression to the goal. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
assumption_mod_cast : tactic unit | tactic.assumption_mod_cast | def | tactic.interactive.assumption_mod_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [
"tactic.assumption_mod_cast"
] | Normalize the goal and every expression in the local context, then close the goal with assumption. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
norm_cast : conv unit | replace_lhs derive | def | conv.interactive.norm_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | the converter version of `norm_cast' | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ite_cast {α β} [has_lift_t α β]
{c : Prop} [decidable c] {a b : α} :
↑(ite c a b) = ite c (↑a : β) (↑b : β) | by by_cases h : c; simp [h] | lemma | ite_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
dite_cast {α β} [has_lift_t α β]
{c : Prop} [decidable c] {a : c → α} {b : ¬ c → α} :
↑(dite c a b) = dite c (λ h, (↑(a h) : β)) (λ h, (↑(b h) : β)) | by by_cases h : c; simp [h] | lemma | dite_cast | tactic | src/tactic/norm_cast.lean | [
"tactic.converter.interactive",
"tactic.hint"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin (n : ℕ) (a : fin n) (b : ℕ) | a.1 = b % n | def | tactic.norm_fin.normalize_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | `normalize_fin n a b` means that `a : fin n` is equivalent to `b : ℕ` in the modular sense -
that is, `↑a ≡ b (mod n)`. This is used for translating the algebraic operations: addition,
multiplication, zero and one, which use modulo for reduction. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
normalize_fin_lt (n : ℕ) (a : fin n) (b : ℕ) | a.1 = b | def | tactic.norm_fin.normalize_fin_lt | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | `normalize_fin_lt n a b` means that `a : fin n` is equivalent to `b : ℕ` in the embedding
sense - that is, `↑a = b`. This is used for operations that treat `fin n` as the subset
`{0, ..., n-1}` of `ℕ`. For example, `fin.succ : fin n → fin (n+1)` is thought of as the successor
function, but it does not lift to a map `zm... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
normalize_fin_lt.coe {n} {a : fin n} {b : ℕ} (h : normalize_fin_lt n a b) : ↑a = b | h | theorem | tactic.norm_fin.normalize_fin_lt.coe | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_iff {n : ℕ} [ne_zero n] {a b} :
normalize_fin n a b ↔ a = fin.of_nat' b | iff.symm (fin.eq_iff_veq _ _) | theorem | tactic.norm_fin.normalize_fin_iff | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.eq_iff_veq",
"fin.of_nat'",
"ne_zero"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.mk {n a b n'} (hn : n = n')
(h : normalize_fin n a b) (h2 : b < n') : normalize_fin_lt n a b | h.trans $ nat.mod_eq_of_lt $ by rw hn; exact h2 | theorem | tactic.norm_fin.normalize_fin_lt.mk | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.lt {n a b} (h : normalize_fin_lt n a b) : b < n | by rw ← h.coe; exact a.2 | theorem | tactic.norm_fin.normalize_fin_lt.lt | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.of {n a b} (h : normalize_fin_lt n a b) : normalize_fin n a b | h.trans $ eq.symm $ nat.mod_eq_of_lt h.lt | theorem | tactic.norm_fin.normalize_fin_lt.of | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.zero (n : ℕ) [ne_zero n] :
normalize_fin n 0 0 | by { rw normalize_fin, norm_num } | theorem | tactic.norm_fin.normalize_fin.zero | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"ne_zero"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.zero (n : ℕ) [ne_zero n] : normalize_fin_lt n 0 0 | refl _ | theorem | tactic.norm_fin.normalize_fin_lt.zero | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"ne_zero"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.one (n : ℕ) [ne_zero n] : normalize_fin n 1 1 | refl _ | theorem | tactic.norm_fin.normalize_fin.one | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"ne_zero"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.add {n} {a b : fin n} {a' b' c' : ℕ}
(ha : normalize_fin n a a') (hb : normalize_fin n b b')
(h : a' + b' = c') : normalize_fin n (a + b) c' | by simp only [normalize_fin, ← h] at *; rw [nat.add_mod, ← ha, ← hb, fin.add_def] | theorem | tactic.norm_fin.normalize_fin.add | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"nat.add_mod"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.mul {n} {a b : fin n} {a' b' c' : ℕ}
(ha : normalize_fin n a a') (hb : normalize_fin n b b')
(h : a' * b' = c') : normalize_fin n (a * b) c' | by simp only [normalize_fin, ← h] at *; rw [nat.mul_mod, ← ha, ← hb, fin.mul_def] | theorem | tactic.norm_fin.normalize_fin.mul | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"nat.mul_mod"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.bit0 {n} {a : fin n} {a' : ℕ}
(h : normalize_fin n a a') : normalize_fin n (bit0 a) (bit0 a') | h.add h rfl | theorem | tactic.norm_fin.normalize_fin.bit0 | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.bit1 {n : ℕ} [ne_zero n] {a : fin n} {a' : ℕ}
(h : normalize_fin n a a') : normalize_fin n (bit1 a) (bit1 a') | h.bit0.add (normalize_fin.one _) rfl | theorem | tactic.norm_fin.normalize_fin.bit1 | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"ne_zero"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.succ {n} {a : fin n} {a' b : ℕ}
(h : normalize_fin_lt n a a') (e : a' + 1 = b) : normalize_fin_lt n.succ (fin.succ a) b | by simpa [normalize_fin_lt, ← e] using h | theorem | tactic.norm_fin.normalize_fin_lt.succ | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.cast_lt {n m} {a : fin m} {ha} {a' : ℕ}
(h : normalize_fin_lt m a a') : normalize_fin_lt n (fin.cast_lt a ha) a' | by simpa [normalize_fin_lt] using h | theorem | tactic.norm_fin.normalize_fin_lt.cast_lt | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.cast_lt"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.cast_le {n m} {nm} {a : fin m} {a' : ℕ}
(h : normalize_fin_lt m a a') : normalize_fin_lt n (fin.cast_le nm a) a' | by simpa [normalize_fin_lt] using h | theorem | tactic.norm_fin.normalize_fin_lt.cast_le | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.cast_le"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.cast {n m} {nm} {a : fin m} {a' : ℕ}
(h : normalize_fin_lt m a a') : normalize_fin_lt n (fin.cast nm a) a' | by simpa [normalize_fin_lt] using h | theorem | tactic.norm_fin.normalize_fin_lt.cast | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.cast"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.cast {n m} {nm} {a : fin m} {a' : ℕ}
(h : normalize_fin m a a') : normalize_fin n (fin.cast nm a) a' | by convert ← normalize_fin_lt.cast h | theorem | tactic.norm_fin.normalize_fin.cast | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.cast"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.cast_add {n m} {a : fin n} {a' : ℕ}
(h : normalize_fin_lt n a a') : normalize_fin_lt (n + m) (fin.cast_add m a) a' | by simpa [normalize_fin_lt] using h | theorem | tactic.norm_fin.normalize_fin_lt.cast_add | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.cast_add"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.cast_succ {n} {a : fin n} {a' : ℕ}
(h : normalize_fin_lt n a a') : normalize_fin_lt (n+1) (fin.cast_succ a) a' | normalize_fin_lt.cast_add h | theorem | tactic.norm_fin.normalize_fin_lt.cast_succ | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.cast_succ"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.add_nat {n m m'} (hm : m = m') {a : fin n} {a' b : ℕ}
(h : normalize_fin_lt n a a') (e : a' + m' = b) :
normalize_fin_lt (n+m) (@fin.add_nat n m a) b | by simpa [normalize_fin_lt, ← e, ← hm] using h | theorem | tactic.norm_fin.normalize_fin_lt.add_nat | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.add_nat"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.nat_add {n m n'} (hn : n = n') {a : fin m} {a' b : ℕ}
(h : normalize_fin_lt m a a') (e : n' + a' = b) :
normalize_fin_lt (n+m) (@fin.nat_add n m a) b | by simpa [normalize_fin_lt, ← e, ← hn] using h | theorem | tactic.norm_fin.normalize_fin_lt.nat_add | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"fin.nat_add"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.reduce {n} {a : fin n} {n' a' b k nk : ℕ}
(hn : n = n') (h : normalize_fin n a a') (e1 : n' * k = nk) (e2 : nk + b = a') :
normalize_fin n a b | by rwa [← e2, ← e1, ← hn, normalize_fin, add_comm, nat.add_mul_mod_self_left] at h | theorem | tactic.norm_fin.normalize_fin.reduce | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin_lt.reduce {n} {a : fin n} {n' a' b k nk : ℕ}
(hn : n = n') (h : normalize_fin n a a') (e1 : n' * k = nk) (e2 : nk + b = a') (hl : b < n') :
normalize_fin_lt n a b | normalize_fin_lt.mk hn (h.reduce hn e1 e2) hl | theorem | tactic.norm_fin.normalize_fin_lt.reduce | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.eq {n} {a b : fin n} {c : ℕ}
(ha : normalize_fin n a c) (hb : normalize_fin n b c) : a = b | fin.eq_of_veq $ ha.trans hb.symm | theorem | tactic.norm_fin.normalize_fin.eq | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.lt {n} {a b : fin n} {a' b' : ℕ}
(ha : normalize_fin n a a') (hb : normalize_fin_lt n b b') (h : a' < b') : a < b | by have ha' := normalize_fin_lt.mk rfl ha (h.trans hb.lt); rwa [← hb.coe, ← ha'.coe] at h | theorem | tactic.norm_fin.normalize_fin.lt | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
normalize_fin.le {n} {a b : fin n} {a' b' : ℕ}
(ha : normalize_fin n a a') (hb : normalize_fin_lt n b b') (h : a' ≤ b') : a ≤ b | by have ha' := normalize_fin_lt.mk rfl ha (h.trans_lt hb.lt); rwa [← hb.coe, ← ha'.coe] at h | theorem | tactic.norm_fin.normalize_fin.le | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
eval_fin_m (α : Type) : Type | state_t (instance_cache × option (ℕ × expr × expr)) tactic α | def | tactic.norm_fin.eval_fin_m | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | The monad for the `norm_fin` internal tactics. The state consists of an instance cache for `ℕ`,
and a tuple `(nn, n', p)` where `p` is a proof of `n = n'` and `nn` is `n` evaluated to a natural
number. (`n` itself is implicit.) It is in an `option` because it is lazily initialized - for many
`n` we will never need thi... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin_m.lift {α} (m : tactic α) : eval_fin_m α | ⟨λ ⟨ic, r⟩, do a ← m, pure (a, ic, r)⟩ | def | tactic.norm_fin.eval_fin_m.lift | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Lifts a tactic into the `eval_fin_m` monad. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin_m.lift_ic {α}
(m : instance_cache → tactic (instance_cache × α)) : eval_fin_m α | ⟨λ ⟨ic, r⟩, do (ic, a) ← m ic, pure (a, ic, r)⟩ | def | tactic.norm_fin.eval_fin_m.lift_ic | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Lifts an `instance_cache` tactic into the `eval_fin_m` monad. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin_m.reset {α} (m : eval_fin_m α) : eval_fin_m α | ⟨λ ⟨ic, r⟩, do (a, ic, _) ← m.run ⟨ic, none⟩, pure (a, ic, r)⟩ | def | tactic.norm_fin.eval_fin_m.reset | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Evaluates a monadic action with a fresh `n` cache, and restore the old cache on completion of
the action. This is used when evaluating a tactic in the context of a different `n` than the parent
context. For example if we are evaluating `fin.succ a`, then `a : fin n` and
`fin.succ a : fin (n+1)`, so the parent cache wil... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin_m.eval_n (n : expr) : eval_fin_m (ℕ × expr × expr) | ⟨λ ⟨ic, r⟩, match r with
| none := do
(n', p) ← or_refl_conv norm_num.derive n,
nn ← n'.to_nat,
let np := (nn, n', p),
pure (np, ic, some np)
| some np := pure (np, ic, some np)
end⟩ | def | tactic.norm_fin.eval_fin_m.eval_n | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"norm_num.derive"
] | Given `n`, returns a tuple `(nn, n', p)` where `p` is a proof of `n = n'` and `nn` is `n`
evaluated to a natural number. The result of the evaluation is cached for future references.
Future calls to this function must use the same value of `n`, unless it is in a sub-context
created by `eval_fin_m.reset`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin_m.run {α} (m : eval_fin_m α) : tactic α | do ic ← mk_instance_cache `(ℕ), (a, _) ← state_t.run m (ic, none), pure a | def | tactic.norm_fin.eval_fin_m.run | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Run an `eval_fin_m` action with a new cache and discard the cache after evaluation. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
match_fin_result
| zero (n : expr) (n0 : expr) -- `(0 : fin n)`
| one (n : expr) (n0 : expr) -- `(1 : fin n)`
| add (n a b : expr) -- `(a + b : fin n)`
| mul (n a b : expr) -- `(a * b : fin n)`
| bit0 (n a : expr) -- `(bit0 a : fin n)`
| bit1 (n a : expr) (n0 : expr) -- `(bit1 a :... | inductive | tactic.norm_fin.match_fin_result | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | The expression constructors recognized by the `eval_fin` evaluator. This is used instead of a
direct expr pattern match because expr pattern matches generate very large terms under the
hood so going via an intermediate inductive type like this is more efficient. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
match_fin_coe_fn (a : expr) : expr → option match_fin_result | | `(@fin.cast_le %%n %%m %%h) := some (cast_le n m h a)
| `(@fin.cast %%m %%n %%h) := some (cast n m h a)
| `(@fin.cast_add %%n %%m) := some (cast_add n m a)
| `(@fin.cast_succ %%n) := some (cast_succ n a)
| `(@fin.add_nat %%n %%m) := some (add_nat n m a)
| `(@fin.nat_add %%n %%m) := some (nat_add n m a)
| _ := none | def | tactic.norm_fin.match_fin_coe_fn | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Match a fin expression of the form `(coe_fn f a)` where `f` is some fin function. Several fin
functions are written this way: for example `cast_le : n ≤ m → fin n ↪o fin m` is not actually a
function but rather an order embedding with a coercion to a function. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
match_fin : expr → option match_fin_result | | `(@has_zero.zero ._ (@fin.has_zero_of_ne_zero %%n %%n0)) := some (zero n n0)
| `(@has_one.one ._ (@fin.has_one_of_ne_zero %%n %%n0)) := some (one n n0)
| `(@has_add.add (fin %%n) ._ %%a %%b) := some (add n a b)
| `(@has_mul.mul (fin %%n) ._ %%a %%b) := some (mul n a b)
| `(@_root_.bit0 (fin %%n) ._ %%a) := some (bit0... | def | tactic.norm_fin.match_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Match a fin expression to a `match_fin_result`, for easier pattern matching in the
evaluator. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
reduce_fin' : bool → expr → expr → expr × expr → eval_fin_m (expr × expr) | | lt n a (a', pa) := do
(nn, n', pn) ← eval_fin_m.eval_n n,
na ← expr.to_nat a',
if na < nn then
if lt then do
p ← eval_fin_m.lift_ic (λ ic, prove_lt_nat ic a' n'),
pure (a', `(@normalize_fin_lt.mk).mk_app [n, a, a', n', pn, pa, p])
else pure (a', pa)
else
let nb := na % nn, nk := (na - ... | def | tactic.norm_fin.reduce_fin' | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"expr.to_nat"
] | `reduce_fin lt n a (a', pa)` expects that `pa : normalize_fin n a a'` where `a'`
is a natural numeral, and produces `(b, pb)` where `pb : normalize_fin n a b` if `lt` is false, or
`pb : normalize_fin_lt n a b` if `lt` is true. In either case, `b` will be chosen to be less than
`n`, but if `lt` is true then we also prov... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin_lt' (eval_fin : expr → eval_fin_m (expr × expr)) :
expr → expr → eval_fin_m (expr × expr) | | n a := do
e ← match_fin a,
match e with
| match_fin_result.succ n a := do
(a', pa) ← (eval_fin_lt' n a).reset,
(b, pb) ← eval_fin_m.lift_ic (λ ic, prove_succ' ic a'),
pure (b, `(@normalize_fin_lt.succ).mk_app [n, a, a', b, pa, pb])
| match_fin_result.cast_lt _ m a h := do
(a', pa) ← (eval_fin_... | def | tactic.norm_fin.eval_fin_lt' | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"norm_num.derive"
] | `eval_fin_lt' eval_fin n a` expects that `a : fin n`, and produces `(b, p)` where
`p : normalize_fin_lt n a b`. (It is mutually recursive with `eval_fin` which is why it takes the
function as an argument.) | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_fin_type (a : expr) : tactic expr | do `(fin %%n) ← infer_type a, pure n | def | tactic.norm_fin.get_fin_type | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Get `n` such that `a : fin n`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin : expr → eval_fin_m (expr × expr) | | a := do
m ← match_fin a,
match m with
| match_fin_result.zero n n0 := pure (`(0 : ℕ), `(normalize_fin.zero).mk_app [n, n0])
| match_fin_result.one n n0 := pure (`(1 : ℕ), `(normalize_fin.one).mk_app [n, n0])
| match_fin_result.add n a b := do
(a', pa) ← eval_fin a,
(b', pb) ← eval_fin b,
(c, pc)... | def | tactic.norm_fin.eval_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Given `a : fin n`, `eval_fin a` returns `(b, p)` where `p : normalize_fin n a b`. This function
does no reduction of the numeral `b`; for example `eval_fin (5 + 5 : fin 6)` returns `10`. It works
even if `n` is a variable, for example `eval_fin (5 + 5 : fin (n+1))` also returns `10`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin_lt : expr → expr → eval_fin_m (expr × expr) | eval_fin_lt' eval_fin | def | tactic.norm_fin.eval_fin_lt | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | `eval_fin_lt n a` expects that `a : fin n`, and produces `(b, p)` where
`p : normalize_fin_lt n a b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
reduce_fin (lt : bool) (n a : expr) : eval_fin_m (expr × expr) | eval_fin a >>= reduce_fin' lt n a | def | tactic.norm_fin.reduce_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Given `a : fin n`, `eval_fin ff n a` returns `(b, p)` where `p : normalize_fin n a b`, and
`eval_fin tt n a` returns `p : normalize_fin_lt n a b`. Unlike `eval_fin`, this also does reduction
of the numeral `b`; for example `reduce_fin ff 6 (5 + 5 : fin 6)` returns `4`. As a result, it
fails if `n` is a variable, for ex... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_lt_fin' : expr → expr → expr → expr × expr → expr × expr → eval_fin_m expr | | n a b a' b' := do
(a', pa) ← reduce_fin' ff n a a',
(b', pb) ← reduce_fin' tt n b b',
p ← eval_fin_m.lift_ic (λ ic, prove_lt_nat ic a' b'),
pure (`(@normalize_fin.lt).mk_app [n, a, b, a', b', pa, pb, p]) | def | tactic.norm_fin.prove_lt_fin' | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | If `a b : fin n` and `a'` and `b'` are as returned by `eval_fin`,
then `prove_lt_fin' n a b a' b'` proves `a < b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_le_fin' : expr → expr → expr → expr × expr → expr × expr → eval_fin_m expr | | n a b a' b' := do
(a', pa) ← reduce_fin' ff n a a',
(b', pb) ← reduce_fin' tt n b b',
p ← eval_fin_m.lift_ic (λ ic, prove_le_nat ic a' b'),
pure (`(@normalize_fin.le).mk_app [n, a, b, a', b', pa, pb, p]) | def | tactic.norm_fin.prove_le_fin' | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | If `a b : fin n` and `a'` and `b'` are as returned by `eval_fin`,
then `prove_le_fin' n a b a' b'` proves `a ≤ b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_eq_fin' : expr → expr → expr → expr × expr → expr × expr → eval_fin_m expr | | n a b (a', pa) (b', pb) :=
if a' =ₐ b' then do
pure (`(@normalize_fin.eq).mk_app [n, a, b, a', pa, pb])
else do
(a', pa) ← reduce_fin' ff n a (a', pa),
(b', pb) ← reduce_fin' ff n b (b', pb),
guard (a' =ₐ b'),
pure (`(@normalize_fin.eq).mk_app [n, a, b, a', pa, pb]) | def | tactic.norm_fin.prove_eq_fin' | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | If `a b : fin n` and `a'` and `b'` are as returned by `eval_fin`,
then `prove_eq_fin' n a b a' b'` proves `a = b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_prove_fin
(f : expr → expr → expr → expr × expr → expr × expr → eval_fin_m expr)
(a b : expr) : tactic expr | do n ← get_fin_type a, eval_fin_m.run $ eval_fin a >>= λ a', eval_fin b >>= f n a b a' | def | tactic.norm_fin.eval_prove_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Given a function with the type of `prove_eq_fin'`, evaluates it with the given `a` and `b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_eq_fin : expr → expr → tactic expr | eval_prove_fin prove_eq_fin' | def | tactic.norm_fin.prove_eq_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | If `a b : fin n`, then `prove_eq_fin a b` proves `a = b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_lt_fin : expr → expr → tactic expr | eval_prove_fin prove_lt_fin' | def | tactic.norm_fin.prove_lt_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | If `a b : fin n`, then `prove_lt_fin a b` proves `a < b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_le_fin : expr → expr → tactic expr | eval_prove_fin prove_le_fin' | def | tactic.norm_fin.prove_le_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | If `a b : fin n`, then `prove_le_fin a b` proves `a ≤ b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_fin_numeral (n m : expr) : expr → option (expr × expr) | | a := match match_numeral a with
| zero := some (
expr.app `(@has_zero.zero (fin %%n)) `(@fin.has_zero %%m),
`(normalize_fin.zero).mk_app [n, `(@ne_zero.succ %%m)])
| one := some (
expr.app `(@has_one.one (fin %%n)) `(@fin.has_one %%m),
`(normalize_fin.one).mk_app [n, `(@ne_zero.succ %%m)])
| bit... | def | tactic.norm_fin.mk_fin_numeral | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Given expressions `n` and `m` such that `n` is definitionally equal to `m.succ`, and
a natural numeral `a`, proves `(b, ⊢ normalize_fin n b a)`, where `n` and `m` are both used
in the construction of the numeral `b : fin n`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_rel {α} (a b : expr)
(f : expr → expr × expr → expr × expr → ℕ → ℕ → eval_fin_m α) : tactic α | do n ← get_fin_type a,
eval_fin_m.run $ do
(nn, n', pn) ← eval_fin_m.eval_n n,
(a', pa) ← eval_fin a,
(b', pb) ← eval_fin b,
na ← eval_fin_m.lift a'.to_nat,
nb ← eval_fin_m.lift b'.to_nat,
f n (a', pa) (b', pb) (na % nn) (nb % nn) | def | tactic.norm_fin.eval_rel | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | The common prep work for the cases in `eval_ineq`. Given inputs `a b : fin n`, it calls
`f n a' b' na nb` where `a'` and `b'` are the result of `eval_fin` and `na` and `nb` are
`a' % n` and `b' % n` as natural numbers. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_lt_ge_fin : expr → expr → tactic (expr × bool × expr) | | a b := eval_rel a b $ λ n a' b' na nb,
if na < nb then prod.mk n <$> prod.mk tt <$> prove_lt_fin' n a b a' b'
else prod.mk n <$> prod.mk ff <$> prove_le_fin' n b a b' a' | def | tactic.norm_fin.prove_lt_ge_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Given `a b : fin n`, proves either `(n, tt, p)` where `p : a < b` or
`(n, ff, p)` where `p : b ≤ a`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_eq_ne_fin : expr → expr → tactic (expr × bool × expr) | | a b := eval_rel a b $ λ n a' b' na nb,
if na = nb then prod.mk n <$> prod.mk tt <$> prove_eq_fin' n a b a' b'
else if na < nb then do
p ← prove_lt_fin' n a b a' b',
pure (n, ff, `(@ne_of_lt (fin %%n) _).mk_app [a, b, p])
else do
p ← prove_lt_fin' n b a b' a',
pure (n, ff, `(@ne_of_gt (fin %%n) _... | def | tactic.norm_fin.prove_eq_ne_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Given `a b : fin n`, proves either `(n, tt, p)` where `p : a = b` or
`(n, ff, p)` where `p : a ≠ b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_ineq : expr → tactic (expr × expr) | | `(%%a < %%b) := do
(n, lt, p) ← prove_lt_ge_fin a b,
if lt then true_intro p else false_intro (`(@not_lt_of_ge (fin %%n) _).mk_app [a, b, p])
| `(%%a ≤ %%b) := do
(n, lt, p) ← prove_lt_ge_fin b a,
if lt then false_intro (`(@not_le_of_gt (fin %%n) _).mk_app [a, b, p]) else true_intro p
| `(%%a = %%b) := do
(... | def | tactic.norm_fin.eval_ineq | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | A `norm_num` extension that evaluates equalities and inequalities on the type `fin n`.
```
example : (5 : fin 7) = fin.succ (fin.succ 3) := by norm_num
``` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
as_numeral (n e : expr) : eval_fin_m (option ℕ) | match e.to_nat with
| none := pure none
| some ne := do
(nn, _) ← eval_fin_m.eval_n n,
pure $ if ne < nn then some ne else none
end | def | tactic.norm_fin.as_numeral | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Evaluates `e : fin n` to a natural number less than `n`. Returns `none` if it is not a natural
number or greater than `n`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_fin_num (a : expr) : tactic (expr × expr) | do n ← get_fin_type a,
eval_fin_m.run $ do
as_numeral n a >>= (λ o, guardb o.is_none),
(a', pa) ← eval_fin a,
(a', pa) ← reduce_fin' ff n a (a', pa) <|> pure (a', pa),
(nm + 1, _) ← eval_fin_m.eval_n n | failure,
m' ← eval_fin_m.lift_ic (λ ic, ic.of_nat nm),
n' ← eval_fin_m.lift_ic (λ ic, ic.o... | def | tactic.norm_fin.eval_fin_num | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [] | Given `a : fin n`, returns `(b, ⊢ a = b)` where `b` is a normalized fin numeral. Fails if `a`
is already normalized. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
norm_fin (hs : parse simp_arg_list) : tactic unit | try (simp_top_down tactic.norm_fin.eval_fin_num) >> try (norm_num hs (loc.ns [none])) | def | tactic.interactive.norm_fin | tactic | src/tactic/norm_fin.lean | [
"data.fin.basic",
"tactic.norm_num"
] | [
"tactic.norm_fin.eval_fin_num"
] | Rewrites occurrences of fin expressions to normal form anywhere in the goal.
The `norm_num` extension will only rewrite fin expressions if they appear in equalities and
inequalities. For example if the goal is `P (2 + 2 : fin 3)` then `norm_num` will not do anything
but `norm_fin` will reduce the goal to `P 1`.
(The r... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_bit0 (c : instance_cache) (e : expr) : tactic (instance_cache × expr) | do (c, ai) ← c.get ``has_add,
return (c, (expr.const ``bit0 [c.univ]).mk_app [c.α, ai, e]) | def | tactic.instance_cache.mk_bit0 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | Faster version of `mk_app ``bit0 [e]`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_bit1 (c : instance_cache) (e : expr) : tactic (instance_cache × expr) | do (c, ai) ← c.get ``has_add,
(c, oi) ← c.get ``has_one,
return (c, (expr.const ``bit1 [c.univ]).mk_app [c.α, oi, ai, e]) | def | tactic.instance_cache.mk_bit1 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | Faster version of `mk_app ``bit1 [e]`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
subst_into_add {α} [has_add α] (l r tl tr t)
(prl : (l : α) = tl) (prr : r = tr) (prt : tl + tr = t) : l + r = t | by rw [prl, prr, prt] | lemma | norm_num.subst_into_add | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
subst_into_mul {α} [has_mul α] (l r tl tr t)
(prl : (l : α) = tl) (prr : r = tr) (prt : tl * tr = t) : l * r = t | by rw [prl, prr, prt] | lemma | norm_num.subst_into_mul | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
subst_into_neg {α} [has_neg α] (a ta t : α) (pra : a = ta) (prt : -ta = t) : -a = t | by simp [pra, prt] | lemma | norm_num.subst_into_neg | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
match_numeral_result
| zero | one | bit0 (e : expr) | bit1 (e : expr) | other | inductive | norm_num.match_numeral_result | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | The result type of `match_numeral`, either `0`, `1`, or a top level
decomposition of `bit0 e` or `bit1 e`. The `other` case means it is not a numeral. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
match_numeral : expr → match_numeral_result | | `(bit0 %%e) := match_numeral_result.bit0 e
| `(bit1 %%e) := match_numeral_result.bit1 e
| `(@has_zero.zero _ _) := match_numeral_result.zero
| `(@has_one.one _ _) := match_numeral_result.one
| _ := match_numeral_result.other | def | norm_num.match_numeral | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | Unfold the top level constructor of the numeral expression. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
zero_succ {α} [semiring α] : (0 + 1 : α) = 1 | zero_add _ | theorem | norm_num.zero_succ | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
one_succ {α} [semiring α] : (1 + 1 : α) = 2 | rfl | theorem | norm_num.one_succ | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
bit0_succ {α} [semiring α] (a : α) : bit0 a + 1 = bit1 a | rfl | theorem | norm_num.bit0_succ | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
bit1_succ {α} [semiring α] (a b : α) (h : a + 1 = b) : bit1 a + 1 = bit0 b | h ▸ by simp [bit1, bit0, add_left_comm, add_assoc] | theorem | norm_num.bit1_succ | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
prove_succ : instance_cache → expr → expr → tactic (instance_cache × expr) | | c e r := match match_numeral e with
| zero := c.mk_app ``zero_succ []
| one := c.mk_app ``one_succ []
| bit0 e := c.mk_app ``bit0_succ [e]
| bit1 e := do
let r := r.app_arg,
(c, p) ← prove_succ c e r,
c.mk_app ``bit1_succ [e, r, p]
| _ := failed
end | def | norm_num.prove_succ | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | Given `a`, `b` natural numerals, proves `⊢ a + 1 = b`, assuming that this is provable.
(It may prove garbage instead of failing if `a + 1 = b` is false.) | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prove_succ' (c : instance_cache) (a : expr) : tactic (instance_cache × expr × expr) | do na ← a.to_nat,
(c, b) ← c.of_nat (na + 1),
(c, p) ← prove_succ c a b,
return (c, b, p) | def | norm_num.prove_succ' | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [] | Given `a` natural numeral, returns `(b, ⊢ a + 1 = b)`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
zero_adc {α} [semiring α] (a b : α) (h : a + 1 = b) : 0 + a + 1 = b | by rwa zero_add | theorem | norm_num.zero_adc | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
adc_zero {α} [semiring α] (a b : α) (h : a + 1 = b) : a + 0 + 1 = b | by rwa add_zero | theorem | norm_num.adc_zero | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
one_add {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + a = b | by rwa add_comm | theorem | norm_num.one_add | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_bit0_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit0 b = bit0 c | h ▸ by simp [bit0, add_left_comm, add_assoc] | theorem | norm_num.add_bit0_bit0 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_bit0_bit1 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit1 b = bit1 c | h ▸ by simp [bit0, bit1, add_left_comm, add_assoc] | theorem | norm_num.add_bit0_bit1 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_bit1_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit1 a + bit0 b = bit1 c | h ▸ by simp [bit0, bit1, add_left_comm, add_comm, add_assoc] | theorem | norm_num.add_bit1_bit0 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_bit1_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) : bit1 a + bit1 b = bit0 c | h ▸ by simp [bit0, bit1, add_left_comm, add_comm, add_assoc] | theorem | norm_num.add_bit1_bit1 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
adc_one_one {α} [semiring α] : (1 + 1 + 1 : α) = 3 | rfl | theorem | norm_num.adc_one_one | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
adc_bit0_one {α} [semiring α] (a b : α) (h : a + 1 = b) : bit0 a + 1 + 1 = bit0 b | h ▸ by simp [bit0, add_left_comm, add_assoc] | theorem | norm_num.adc_bit0_one | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
adc_one_bit0 {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + bit0 a + 1 = bit0 b | h ▸ by simp [bit0, add_left_comm, add_assoc] | theorem | norm_num.adc_one_bit0 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
adc_bit1_one {α} [semiring α] (a b : α) (h : a + 1 = b) : bit1 a + 1 + 1 = bit1 b | h ▸ by simp [bit1, bit0, add_left_comm, add_assoc] | theorem | norm_num.adc_bit1_one | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
adc_one_bit1 {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + bit1 a + 1 = bit1 b | h ▸ by simp [bit1, bit0, add_left_comm, add_assoc] | theorem | norm_num.adc_one_bit1 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
adc_bit0_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit0 b + 1 = bit1 c | h ▸ by simp [bit1, bit0, add_left_comm, add_assoc] | theorem | norm_num.adc_bit0_bit0 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
adc_bit1_bit0 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) :
bit1 a + bit0 b + 1 = bit0 c | h ▸ by simp [bit1, bit0, add_left_comm, add_assoc] | theorem | norm_num.adc_bit1_bit0 | tactic | src/tactic/norm_num.lean | [
"data.rat.cast",
"data.rat.meta_defs",
"data.int.lemmas"
] | [
"semiring"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.