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 |
|---|---|---|---|---|---|---|---|---|---|---|
ring2 : conv unit | discharge_eq_lhs tactic.interactive.ring2 | def | conv.interactive.ring2 | tactic | src/tactic/ring2.lean | [
"tactic.ring",
"data.num.lemmas",
"data.tree"
] | [
"tactic.interactive.ring2"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
atom : Type | (value : expr) (index : ℕ) | structure | tactic.ring_exp.atom | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | The `atom` structure is used to represent atomic expressions:
those which `ring_exp` cannot parse any further.
For instance, `a + (a % b)` has `a` and `(a % b)` as atoms.
The `ring_exp_eq` tactic does not normalize the subexpressions in atoms,
but `ring_exp` does if `ring_exp_eq` was not sufficient.
Atoms in fact rep... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eq (a b : atom) : bool | a.index = b.index | def | tactic.ring_exp.atom.eq | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | The `eq` operation on `atom`s works modulo definitional equality,
ignoring their `value`s.
The invariants on `atom` ensure indices are unique per value.
Thus, `eq` indicates equality as long as the `atom`s come from the same context. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
lt (a b : atom) : bool | a.index < b.index | def | tactic.ring_exp.atom.lt | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | We order `atom`s on the order of appearance in the main expression. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
coeff : Type | (value : ℚ) | structure | tactic.ring_exp.coeff | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Coefficients in the expression are stored in a wrapper structure,
allowing for easier modification of the data structures.
The modifications might be caching of the result of `expr.of_rat`,
or using a different meta representation of numerals. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_type : Type
| base : ex_type
| sum : ex_type
| prod : ex_type
| exp : ex_type | inductive | tactic.ring_exp.ex_type | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | The values in `ex_type` are used as parameters to `ex` to control the expression's structure. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
ex_info : Type | (orig : expr) (pretty : expr) (proof : option expr) | structure | tactic.ring_exp.ex_info | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Each `ex` stores information for its normalization proof.
The `orig` expression is the expression that was passed to `eval`.
The `pretty` expression is the normalised form that the `ex` represents.
(I didn't call this something like `norm`, because there are already
too many things called `norm` in mathematics!)
The... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex : ex_type → Type
| zero (info : ex_info) : ex sum
| sum (info : ex_info) : ex prod → ex sum → ex sum
| coeff (info : ex_info) : coeff → ex prod
| prod (info : ex_info) : ex exp → ex prod → ex prod
| var (info : ex_info) : atom → ex base
| sum_b (info : ex_info) : ex sum → ex base
| exp (info : ex_info) : ex ... | inductive | tactic.ring_exp.ex | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | The `ex` type is an abstract representation of an expression with `+`, `*` and `^`.
Those operators are mapped to the `sum`, `prod` and `exp` constructors respectively.
The `zero` constructor is the base case for `ex sum`, e.g. `1 + 2` is represented
by (something along the lines of) `sum 1 (sum 2 zero)`.
The `coeff`... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
ex.info : Π {et : ex_type} (ps : ex et), ex_info | | sum (ex.zero i) := i
| sum (ex.sum i _ _) := i
| prod (ex.coeff i _) := i
| prod (ex.prod i _ _) := i
| base (ex.var i _) := i
| base (ex.sum_b i _) := i
| exp (ex.exp i _ _) := i | def | tactic.ring_exp.ex.info | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Return the proof information associated to the `ex`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex.orig {et : ex_type} (ps : ex et) : expr | ps.info.orig | def | tactic.ring_exp.ex.orig | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Return the original, non-normalized version of this `ex`.
Note that arguments to another `ex` are always "pre-normalized":
their `orig` and `pretty` are equal, and their `proof` is reflexivity. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex.pretty {et : ex_type} (ps : ex et) : expr | ps.info.pretty | def | tactic.ring_exp.ex.pretty | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Return the normalized version of this `ex`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex.proof {et : ex_type} (ps : ex et) : option expr | ps.info.proof | def | tactic.ring_exp.ex.proof | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Return the normalisation proof of the given expression.
If the proof is `refl`, we give `none` instead,
which helps to control the size of proof terms.
To get an actual term, use `ex.proof_term`,
or use `mk_proof` with the correct set of arguments. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_info.set (i : ex_info) (o : option expr) (pf : option expr) : ex_info | {orig := o.get_or_else i.pretty, proof := pf, .. i} | def | tactic.ring_exp.ex_info.set | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Update the `orig` and `proof` fields of the `ex_info`.
Intended for use in `ex.set_info`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex.set_info : Π {et : ex_type} (ps : ex et), option expr → option expr → ex et | | sum (ex.zero i) o pf := ex.zero (i.set o pf)
| sum (ex.sum i p ps) o pf := ex.sum (i.set o pf) p ps
| prod (ex.coeff i x) o pf := ex.coeff (i.set o pf) x
| prod (ex.prod i p ps) o pf := ex.prod (i.set o pf) p ps
| base (ex.var i x) o pf := ex.var (i.set o pf) x
| base (ex.sum_b i ps) o pf :... | def | tactic.ring_exp.ex.set_info | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Update the `ex_info` of the given expression.
We use this to combine intermediate normalisation proofs.
Since `pretty` only depends on the subexpressions,
which do not change, we do not set `pretty`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
coeff_has_repr : has_repr coeff | ⟨λ x, repr x.1⟩ | instance | tactic.ring_exp.coeff_has_repr | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
ex.repr : Π {et : ex_type}, ex et → string | | sum (ex.zero _) := "0"
| sum (ex.sum _ p ps) := ex.repr p ++ " + " ++ ex.repr ps
| prod (ex.coeff _ x) := repr x
| prod (ex.prod _ p ps) := ex.repr p ++ " * " ++ ex.repr ps
| base (ex.var _ x) := repr x
| base (ex.sum_b _ ps) := "(" ++ ex.repr ps ++ ")"
| exp (ex.exp _ p ps) := ex.repr p ++ " ^ " ++ ... | def | tactic.ring_exp.ex.repr | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Convert an `ex` to a `string`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex.eq : Π {et : ex_type}, ex et → ex et → bool | | sum (ex.zero _) (ex.zero _) := tt
| sum (ex.zero _) (ex.sum _ _ _) := ff
| sum (ex.sum _ _ _) (ex.zero _) := ff
| sum (ex.sum _ p ps) (ex.sum _ q qs) := p.eq q && ps.eq qs
| prod (ex.coeff _ x) (ex.coeff _ y) := x = y
| prod (ex.coeff _ _) (ex.prod _ _ _) := ff
| prod (ex.prod _ _... | def | tactic.ring_exp.ex.eq | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Equality test for expressions.
Since equivalence of `atom`s is not the same as equality,
we cannot make a true `(=)` operator for `ex` either. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex.lt : Π {et : ex_type}, ex et → ex et → bool | | sum _ (ex.zero _) := ff
| sum (ex.zero _) _ := tt
| sum (ex.sum _ p ps) (ex.sum _ q qs) := p.lt q || (p.eq q && ps.lt qs)
| prod (ex.coeff _ x) (ex.coeff _ y) := x.1 < y.1
| prod (ex.coeff _ _) _ := tt
| prod _ (ex.coeff _ _) := ff
| p... | def | tactic.ring_exp.ex.lt | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | The ordering on expressions.
As for `ex.eq`, this is a linear order only in one context. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
eval_info | (α : expr) (univ : level)
-- Cache the instances for optimization and consistency
(csr_instance : expr) (ha_instance : expr) (hm_instance : expr) (hp_instance : expr)
-- Optional instances (only required for (-) and (/) respectively)
(ring_instance : option expr) (dr_instance : option expr)
-- Cache common constants.
(... | structure | tactic.ring_exp.eval_info | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Stores the information needed in the `eval` function and its dependencies,
so they can (re)construct expressions.
The `eval_info` structure stores this information for one type,
and the `context` combines the two types, one for bases and one for exponents. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
context | (info_b : eval_info) (info_e : eval_info) (transp : transparency) | structure | tactic.ring_exp.context | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | The `context` contains the full set of information needed for the `eval` function.
This structure has two copies of `eval_info`:
one is for the base (typically some semiring `α`) and another for the exponent (always `ℕ`).
When evaluating an exponent, we put `info_e` in `info_b`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ring_exp_m (α : Type) : Type | reader_t context (state_t (list atom) tactic) α | def | tactic.ring_exp.ring_exp_m | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | The `ring_exp_m` monad is used instead of `tactic` to store the context. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
get_context : ring_exp_m context | reader_t.read | def | tactic.ring_exp.get_context | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Access the instance cache. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
lift {α} (m : tactic α) : ring_exp_m α | reader_t.lift (state_t.lift m) | def | tactic.ring_exp.lift | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Lift an operation in the `tactic` monad to the `ring_exp_m` monad.
This operation will not access the cache. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
in_exponent {α} (mx : ring_exp_m α) : ring_exp_m α | do
ctx ← get_context,
reader_t.lift $ mx.run ⟨ctx.info_e, ctx.info_e, ctx.transp⟩ | def | tactic.ring_exp.in_exponent | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Change the context of the given computation,
so that expressions are evaluated in the exponent ring,
instead of the base ring. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_app_class (f : name) (inst : expr) (args : list expr) : ring_exp_m expr | do
ctx ← get_context,
pure $ (@expr.const tt f [ctx.info_b.univ] ctx.info_b.α inst).mk_app args | def | tactic.ring_exp.mk_app_class | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Specialized version of `mk_app` where the first two arguments are `{α}` `[some_class α]`.
Should be faster because it can use the cached instances. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_app_csr (f : name) (args : list expr) : ring_exp_m expr | do
ctx ← get_context,
mk_app_class f (ctx.info_b.csr_instance) args | def | tactic.ring_exp.mk_app_csr | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Specialized version of `mk_app` where the first two arguments are `{α}` `[comm_semiring α]`.
Should be faster because it can use the cached instances. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_add (args : list expr) : ring_exp_m expr | do
ctx ← get_context,
mk_app_class ``has_add.add ctx.info_b.ha_instance args | def | tactic.ring_exp.mk_add | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Specialized version of `mk_app ``has_add.add`.
Should be faster because it can use the cached instances. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_mul (args : list expr) : ring_exp_m expr | do
ctx ← get_context,
mk_app_class ``has_mul.mul ctx.info_b.hm_instance args | def | tactic.ring_exp.mk_mul | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Specialized version of `mk_app ``has_mul.mul`.
Should be faster because it can use the cached instances. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_pow (args : list expr) : ring_exp_m expr | do
ctx ← get_context,
pure $ (@expr.const tt ``has_pow.pow
[ctx.info_b.univ, ctx.info_e.univ]
ctx.info_b.α ctx.info_e.α
ctx.info_b.hp_instance).mk_app args | def | tactic.ring_exp.mk_pow | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Specialized version of `mk_app ``has_pow.pow`.
Should be faster because it can use the cached instances. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_info.proof_term (ps : ex_info) : ring_exp_m expr | match ps.proof with
| none := lift $ tactic.mk_eq_refl ps.pretty
| (some p) := pure p
end | def | tactic.ring_exp.ex_info.proof_term | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Construct a normalization proof term or return the cached one. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex.proof_term {et : ex_type} (ps : ex et) : ring_exp_m expr | ps.info.proof_term | def | tactic.ring_exp.ex.proof_term | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Construct a normalization proof term or return the cached one. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
none_or_proof_term : list ex_info → ring_exp_m (option (list expr)) | | [] := pure none
| (x :: xs) := do
xs_pfs ← none_or_proof_term xs,
match (x.proof, xs_pfs) with
| (none, none) := pure none
| (some x_pf, none) := do
xs_pfs ← traverse ex_info.proof_term xs,
pure (some (x_pf :: xs_pfs))
| (_, some xs_pfs) := do
x_pf ← x.proof_term,
pure (some (x_pf :: xs_pfs)... | def | tactic.ring_exp.none_or_proof_term | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | If all `ex_info` have trivial proofs, return a trivial proof.
Otherwise, construct all proof terms.
Useful in applications where trivial proofs combine to another trivial proof,
most importantly to pass to `mk_proof_or_refl`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_proof (lem : name) (args : list expr) (hs : list ex_info) : ring_exp_m expr | do
hs' ← traverse ex_info.proof_term hs,
mk_app_csr lem (args ++ hs') | def | tactic.ring_exp.mk_proof | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Use the proof terms as arguments to the given lemma.
If the lemma could reduce to reflexivity, consider using `mk_proof_or_refl.` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mk_proof_or_refl (term : expr) (lem : name) (args : list expr) (hs : list ex_info) :
ring_exp_m expr | do
hs_full ← none_or_proof_term hs,
match hs_full with
| none := lift $ mk_eq_refl term
| (some hs') := mk_app_csr lem (args ++ hs')
end | def | tactic.ring_exp.mk_proof_or_refl | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Use the proof terms as arguments to the given lemma.
Often, we construct a proof term using congruence where reflexivity suffices.
To solve this, the following function tries to get away with reflexivity. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
add_orig {et et'} (ps : ex et) (qs : ex et') : ring_exp_m expr | mk_add [ps.orig, qs.orig] | def | tactic.ring_exp.add_orig | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | A shortcut for adding the original terms of two expressions. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mul_orig {et et'} (ps : ex et) (qs : ex et') : ring_exp_m expr | mk_mul [ps.orig, qs.orig] | def | tactic.ring_exp.mul_orig | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | A shortcut for multiplying the original terms of two expressions. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
pow_orig {et et'} (ps : ex et) (qs : ex et') : ring_exp_m expr | mk_pow [ps.orig, qs.orig] | def | tactic.ring_exp.pow_orig | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | A shortcut for exponentiating the original terms of two expressions. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
sum_congr {p p' ps ps' : α} : p = p' → ps = ps' → p + ps = p' + ps' | by cc | lemma | tactic.ring_exp.sum_congr | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Congruence lemma for constructing `ex.sum`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prod_congr {p p' ps ps' : α} : p = p' → ps = ps' → p * ps = p' * ps' | by cc | lemma | tactic.ring_exp.prod_congr | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Congruence lemma for constructing `ex.prod`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
exp_congr {p p' : α} {ps ps' : ℕ} : p = p' → ps = ps' → p ^ ps = p' ^ ps' | by cc | lemma | tactic.ring_exp.exp_congr | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Congruence lemma for constructing `ex.exp`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_zero : ring_exp_m (ex sum) | do
ctx ← get_context,
pure $ ex.zero ⟨ctx.info_b.zero, ctx.info_b.zero, none⟩ | def | tactic.ring_exp.ex_zero | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Constructs `ex.zero` with the correct arguments. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_sum (p : ex prod) (ps : ex sum) : ring_exp_m (ex sum) | do
pps_o ← add_orig p ps,
pps_p ← mk_add [p.pretty, ps.pretty],
pps_pf ← mk_proof_or_refl pps_p ``sum_congr
[p.orig, p.pretty, ps.orig, ps.pretty]
[p.info, ps.info],
pure (ex.sum ⟨pps_o, pps_p, pps_pf⟩ (p.set_info none none) (ps.set_info none none)) | def | tactic.ring_exp.ex_sum | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Constructs `ex.sum` with the correct arguments. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_coeff (x : rat) : ring_exp_m (ex prod) | do
ctx ← get_context,
x_p ← lift $ expr.of_rat ctx.info_b.α x,
pure (ex.coeff ⟨x_p, x_p, none⟩ ⟨x⟩) | def | tactic.ring_exp.ex_coeff | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"expr.of_rat",
"lift",
"rat"
] | Constructs `ex.coeff` with the correct arguments.
There are more efficient constructors for specific numerals:
if `x = 0`, you should use `ex_zero`; if `x = 1`, use `ex_one`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_one : ring_exp_m (ex prod) | do
ctx ← get_context,
pure $ ex.coeff ⟨ctx.info_b.one, ctx.info_b.one, none⟩ ⟨1⟩ | def | tactic.ring_exp.ex_one | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Constructs `ex.coeff 1` with the correct arguments.
This is a special case for optimization purposes. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_prod (p : ex exp) (ps : ex prod) : ring_exp_m (ex prod) | do
pps_o ← mul_orig p ps,
pps_p ← mk_mul [p.pretty, ps.pretty],
pps_pf ← mk_proof_or_refl pps_p ``prod_congr
[p.orig, p.pretty, ps.orig, ps.pretty]
[p.info, ps.info],
pure (ex.prod ⟨pps_o, pps_p, pps_pf⟩ (p.set_info none none) (ps.set_info none none)) | def | tactic.ring_exp.ex_prod | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Constructs `ex.prod` with the correct arguments. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_var (p : atom) : ring_exp_m (ex base) | pure (ex.var ⟨p.1, p.1, none⟩ p) | def | tactic.ring_exp.ex_var | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Constructs `ex.var` with the correct arguments. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_sum_b (ps : ex sum) : ring_exp_m (ex base) | pure (ex.sum_b ps.info (ps.set_info none none)) | def | tactic.ring_exp.ex_sum_b | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Constructs `ex.sum_b` with the correct arguments. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
ex_exp (p : ex base) (ps : ex prod) : ring_exp_m (ex exp) | do
ctx ← get_context,
pps_o ← pow_orig p ps,
pps_p ← mk_pow [p.pretty, ps.pretty],
pps_pf ← mk_proof_or_refl pps_p ``exp_congr
[p.orig, p.pretty, ps.orig, ps.pretty]
[p.info, ps.info],
pure (ex.exp ⟨pps_o, pps_p, pps_pf⟩ (p.set_info none none) (ps.set_info none none)) | def | tactic.ring_exp.ex_exp | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Constructs `ex.exp` with the correct arguments. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
base_to_exp_pf {p p' : α} : p = p' → p = p' ^ 1 | by simp | lemma | tactic.ring_exp.base_to_exp_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
base_to_exp (p : ex base) : ring_exp_m (ex exp) | do
o ← in_exponent $ ex_one,
ps ← ex_exp p o,
pf ← mk_proof ``base_to_exp_pf [p.orig, p.pretty] [p.info],
pure $ ps.set_info p.orig pf | def | tactic.ring_exp.base_to_exp | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Conversion from `ex base` to `ex exp`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
exp_to_prod_pf {p p' : α} : p = p' → p = p' * 1 | by simp | lemma | tactic.ring_exp.exp_to_prod_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
exp_to_prod (p : ex exp) : ring_exp_m (ex prod) | do
o ← ex_one,
ps ← ex_prod p o,
pf ← mk_proof ``exp_to_prod_pf [p.orig, p.pretty] [p.info],
pure $ ps.set_info p.orig pf | def | tactic.ring_exp.exp_to_prod | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Conversion from `ex exp` to `ex prod`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
prod_to_sum_pf {p p' : α} : p = p' → p = p' + 0 | by simp | lemma | tactic.ring_exp.prod_to_sum_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
prod_to_sum (p : ex prod) : ring_exp_m (ex sum) | do
z ← ex_zero,
ps ← ex_sum p z,
pf ← mk_proof ``prod_to_sum_pf [p.orig, p.pretty] [p.info],
pure $ ps.set_info p.orig pf | def | tactic.ring_exp.prod_to_sum | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Conversion from `ex prod` to `ex sum`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
atom_to_sum_pf (p : α) : p = p ^ 1 * 1 + 0 | by simp | lemma | tactic.ring_exp.atom_to_sum_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
atom_to_sum (p : atom) : ring_exp_m (ex sum) | do
p' ← ex_var p,
o ← in_exponent $ ex_one,
p' ← ex_exp p' o,
o ← ex_one,
p' ← ex_prod p' o,
z ← ex_zero,
p' ← ex_sum p' z,
pf ← mk_proof ``atom_to_sum_pf [p.1] [],
pure $ p'.set_info p.1 pf | def | tactic.ring_exp.atom_to_sum | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | A more efficient conversion from `atom` to `ex sum`.
The result should be the same as `ex_var p >>= base_to_exp >>= exp_to_prod >>= prod_to_sum`,
except we need to calculate less intermediate steps. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
add_coeff (p_p q_p : expr) (p q : coeff) : ring_exp_m (ex prod) | do
ctx ← get_context,
pq_o ← mk_add [p_p, q_p],
(pq_p, pq_pf) ← lift $ norm_num.eval_field pq_o,
pure $ ex.coeff ⟨pq_o, pq_p, pq_pf⟩ ⟨p.1 + q.1⟩ | def | tactic.ring_exp.add_coeff | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift",
"norm_num.eval_field"
] | Compute the sum of two coefficients.
Note that the result might not be a valid expression:
if `p = -q`, then the result should be `ex.zero : ex sum` instead.
The caller must detect when this happens!
The returned value is of the form `ex.coeff _ (p + q)`,
with the proof of `expr.of_rat p + expr.of_rat q = expr.of_rat ... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mul_coeff_pf_one_mul (q : α) : 1 * q = q | one_mul q | lemma | tactic.ring_exp.mul_coeff_pf_one_mul | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"one_mul"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_coeff_pf_mul_one (p : α) : p * 1 = p | mul_one p | lemma | tactic.ring_exp.mul_coeff_pf_mul_one | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"mul_one"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_coeff (p_p q_p : expr) (p q : coeff) : ring_exp_m (ex prod) | match p.1, q.1 with -- Special case to speed up multiplication with 1.
| ⟨1, 1, _, _⟩, _ := do
ctx ← get_context,
pq_o ← mk_mul [p_p, q_p],
pf ← mk_app_csr ``mul_coeff_pf_one_mul [q_p],
pure $ ex.coeff ⟨pq_o, q_p, pf⟩ ⟨q.1⟩
| _, ⟨1, 1, _, _⟩ := do
ctx ← get_context,
pq_o ← mk_mul [p_p, q_p],
pf ← mk_app_c... | def | tactic.ring_exp.mul_coeff | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift",
"norm_num.eval_field"
] | Compute the product of two coefficients.
The returned value is of the form `ex.coeff _ (p * q)`,
with the proof of `expr.of_rat p * expr.of_rat q = expr.of_rat (p * q)`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
rewrite (ps_o : expr) (ps' : ex sum) (pf : expr) : ring_exp_m (ex sum) | do
ps'_pf ← ps'.info.proof_term,
pf ← lift $ mk_eq_trans pf ps'_pf,
pure $ ps'.set_info ps_o pf | def | tactic.ring_exp.rewrite | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Given a proof that the expressions `ps_o` and `ps'.orig` are equal,
show that `ps_o` and `ps'.pretty` are equal.
Useful to deal with aliases in `eval`. For instance, `nat.succ p` can be handled
as an alias of `p + 1` as follows:
```
| ps_o@`(nat.succ %%p_o) := do
ps' ← eval `(%%p_o + 1),
pf ← lift $ mk_app ``nat.s... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
overlap : Type
| none : overlap
| nonzero : ex prod → overlap
| zero : ex sum → overlap | inductive | tactic.ring_exp.overlap | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Represents the way in which two products are equal except coefficient.
This type is used in the function `add_overlap`.
In order to deal with equations of the form `a * 2 + a = 3 * a`,
the `add` function will add up overlapping products,
turning `a * 2 + a` into `a * 3`.
We need to distinguish `a * 2 + a` from `a * 2 ... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_overlap_pf {ps qs pq} (p : α) : ps + qs = pq → p * ps + p * qs = p * pq | λ pq_pf, calc
p * ps + p * qs = p * (ps + qs) : symm (mul_add _ _ _)
... = p * pq : by rw pq_pf | lemma | tactic.ring_exp.add_overlap_pf | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_overlap_pf_zero {ps qs} (p : α) : ps + qs = 0 → p * ps + p * qs = 0 | λ pq_pf, calc
p * ps + p * qs = p * (ps + qs) : symm (mul_add _ _ _)
... = p * 0 : by rw pq_pf
... = 0 : mul_zero _ | lemma | tactic.ring_exp.add_overlap_pf_zero | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"mul_zero"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_overlap : ex prod → ex prod → ring_exp_m overlap | | (ex.coeff x_i x) (ex.coeff y_i y) := do
xy@(ex.coeff _ xy_c) ← add_coeff x_i.pretty y_i.pretty x y
| lift $ fail "internal error: add_coeff should return ex.coeff",
if xy_c.1 = 0
then do
z ← ex_zero,
pure $ overlap.zero (z.set_info xy.orig xy.proof)
else pure $ overlap.nonzero xy
| (ex.prod _ _ _)... | def | tactic.ring_exp.add_overlap | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift"
] | Given arguments `ps`, `qs` of the form `ps' * x` and `ps' * y` respectively
return `ps + qs = ps' * (x + y)` (with `x` and `y` arbitrary coefficients).
For other arguments, return `overlap.none`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
add_pf_z_sum {ps qs qs' : α} : ps = 0 → qs = qs' → ps + qs = qs' | λ ps_pf qs_pf, calc
ps + qs = 0 + qs' : by rw [ps_pf, qs_pf]
... = qs' : zero_add _ | lemma | tactic.ring_exp.add_pf_z_sum | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_pf_sum_z {ps ps' qs : α} : ps = ps' → qs = 0 → ps + qs = ps' | λ ps_pf qs_pf, calc
ps + qs = ps' + 0 : by rw [ps_pf, qs_pf]
... = ps' : add_zero _ | lemma | tactic.ring_exp.add_pf_sum_z | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_pf_sum_overlap {pps p ps qqs q qs pq pqs : α} :
pps = p + ps → qqs = q + qs → p + q = pq → ps + qs = pqs → pps + qqs = pq + pqs | by cc | lemma | tactic.ring_exp.add_pf_sum_overlap | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_pf_sum_overlap_zero {pps p ps qqs q qs pqs : α} :
pps = p + ps → qqs = q + qs → p + q = 0 → ps + qs = pqs → pps + qqs = pqs | λ pps_pf qqs_pf pq_pf pqs_pf, calc
pps + qqs = (p + ps) + (q + qs) : by rw [pps_pf, qqs_pf]
... = (p + q) + (ps + qs) : by cc
... = 0 + pqs : by rw [pq_pf, pqs_pf]
... = pqs : zero_add _ | lemma | tactic.ring_exp.add_pf_sum_overlap_zero | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_pf_sum_lt {pps p ps qqs pqs : α} :
pps = p + ps → ps + qqs = pqs → pps + qqs = p + pqs | by cc | lemma | tactic.ring_exp.add_pf_sum_lt | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add_pf_sum_gt {pps qqs q qs pqs : α} :
qqs = q + qs → pps + qs = pqs → pps + qqs = q + pqs | by cc | lemma | tactic.ring_exp.add_pf_sum_gt | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
add : ex sum → ex sum → ring_exp_m (ex sum) | | ps@(ex.zero ps_i) qs := do
pf ← mk_proof ``add_pf_z_sum [ps.orig, qs.orig, qs.pretty] [ps.info, qs.info],
pqs_o ← add_orig ps qs,
pure $ qs.set_info pqs_o pf
| ps qs@(ex.zero qs_i) := do
pf ← mk_proof ``add_pf_sum_z [ps.orig, ps.pretty, qs.orig] [ps.info, qs.info],
pqs_o ← add_orig ps qs,
pure $ ps.set_in... | def | tactic.ring_exp.add | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Add two expressions.
* `0 + qs = 0`
* `ps + 0 = 0`
* `ps * x + ps * y = ps * (x + y)` (for `x`, `y` coefficients; uses `add_overlap`)
* `(p + ps) + (q + qs) = p + (ps + (q + qs))` (if `p.lt q`)
* `(p + ps) + (q + qs) = q + ((p + ps) + qs)` (if not `p.lt q`) | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mul_pf_c_c {ps ps' qs qs' pq : α} :
ps = ps' → qs = qs' → ps' * qs' = pq → ps * qs = pq | by cc | lemma | tactic.ring_exp.mul_pf_c_c | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_pf_c_prod {ps qqs q qs pqs : α} :
qqs = q * qs → ps * qs = pqs → ps * qqs = q * pqs | by cc | lemma | tactic.ring_exp.mul_pf_c_prod | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_pf_prod_c {pps p ps qs pqs : α} :
pps = p * ps → ps * qs = pqs → pps * qs = p * pqs | by cc | lemma | tactic.ring_exp.mul_pf_prod_c | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_pp_pf_overlap {pps p_b ps qqs qs psqs : α} {p_e q_e : ℕ} :
pps = p_b ^ p_e * ps → qqs = p_b ^ q_e * qs →
p_b ^ (p_e + q_e) * (ps * qs) = psqs → pps * qqs = psqs | λ ps_pf qs_pf psqs_pf, by simp [symm psqs_pf, pow_add, ps_pf, qs_pf]; ac_refl | lemma | tactic.ring_exp.mul_pp_pf_overlap | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"pow_add"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_pp_pf_prod_lt {pps p ps qqs pqs : α} :
pps = p * ps → ps * qqs = pqs → pps * qqs = p * pqs | by cc | lemma | tactic.ring_exp.mul_pp_pf_prod_lt | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_pp_pf_prod_gt {pps qqs q qs pqs : α} :
qqs = q * qs → pps * qs = pqs → pps * qqs = q * pqs | by cc | lemma | tactic.ring_exp.mul_pp_pf_prod_gt | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_pp : ex prod → ex prod → ring_exp_m (ex prod) | | ps@(ex.coeff _ x) qs@(ex.coeff _ y) := do
pq ← mul_coeff ps.pretty qs.pretty x y,
pq_o ← mul_orig ps qs,
pf ← mk_proof_or_refl pq.pretty ``mul_pf_c_c
[ps.orig, ps.pretty, qs.orig, qs.pretty, pq.pretty]
[ps.info, qs.info, pq.info],
pure $ pq.set_info pq_o pf
| ps@(ex.coeff _ x) qqs@(ex.prod _ q qs) := ... | def | tactic.ring_exp.mul_pp | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Multiply two expressions.
* `x * y = (x * y)` (for `x`, `y` coefficients)
* `x * (q * qs) = q * (qs * x)` (for `x` coefficient)
* `(p * ps) * y = p * (ps * y)` (for `y` coefficient)
* `(p_b^p_e * ps) * (p_b^q_e * qs) = p_b^(p_e + q_e) * (ps * qs)`
(if `p_e` and `q_e` are identical except coefficient)
* `(p * ps) *... | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mul_p_pf_zero {ps qs : α} : ps = 0 → ps * qs = 0 | λ ps_pf, by rw [ps_pf, zero_mul] | lemma | tactic.ring_exp.mul_p_pf_zero | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"zero_mul"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_p_pf_sum {pps p ps qs ppsqs : α} : pps = p + ps →
p * qs + ps * qs = ppsqs → pps * qs = ppsqs | λ pps_pf ppsqs_pf, calc
pps * qs = (p + ps) * qs : by rw [pps_pf]
... = p * qs + ps * qs : add_mul _ _ _
... = ppsqs : ppsqs_pf | lemma | tactic.ring_exp.mul_p_pf_sum | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_p : ex sum → ex prod → ring_exp_m (ex sum) | | ps@(ex.zero ps_i) qs := do
z ← ex_zero,
z_o ← mul_orig ps qs,
pf ← mk_proof ``mul_p_pf_zero [ps.orig, qs.orig] [ps.info],
pure $ z.set_info z_o pf
| pps@(ex.sum pps_i p ps) qs := do
pqs ← mul_pp p qs >>= prod_to_sum,
psqs ← mul_p ps qs,
ppsqs ← add pqs psqs,
pps_pf ← pps.proof_term,
ppsqs_o ← mul_or... | def | tactic.ring_exp.mul_p | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Multiply two expressions.
* `0 * qs = 0`
* `(p + ps) * qs = (p * qs) + (ps * qs)` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
mul_pf_zero {ps qs : α} : qs = 0 → ps * qs = 0 | λ qs_pf, by rw [qs_pf, mul_zero] | lemma | tactic.ring_exp.mul_pf_zero | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"mul_zero"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul_pf_sum {ps qqs q qs psqqs : α} : qqs = q + qs → ps * q + ps * qs = psqqs →
ps * qqs = psqqs | λ qs_pf psqqs_pf, calc
ps * qqs = ps * (q + qs) : by rw [qs_pf]
... = ps * q + ps * qs : mul_add _ _ _
... = psqqs : psqqs_pf | lemma | tactic.ring_exp.mul_pf_sum | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
mul : ex sum → ex sum → ring_exp_m (ex sum) | | ps qs@(ex.zero qs_i) := do
z ← ex_zero,
z_o ← mul_orig ps qs,
pf ← mk_proof ``mul_pf_zero [ps.orig, qs.orig] [qs.info],
pure $ z.set_info z_o pf
| ps qqs@(ex.sum qqs_i q qs) := do
psq ← mul_p ps q,
psqs ← mul ps qs,
psqqs ← add psq psqs,
psqqs_o ← mul_orig ps qqs,
pf ← mk_proof ``mul_pf_sum
[ps.... | def | tactic.ring_exp.mul | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Multiply two expressions.
* `ps * 0 = 0`
* `ps * (q + qs) = (ps * q) + (ps * qs)` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
pow_e_pf_exp {pps p : α} {ps qs psqs : ℕ} :
pps = p ^ ps → ps * qs = psqs → pps ^ qs = p ^ psqs | λ pps_pf psqs_pf, calc
pps ^ qs = (p ^ ps) ^ qs : by rw [pps_pf]
... = p ^ (ps * qs) : symm (pow_mul _ _ _)
... = p ^ psqs : by rw [psqs_pf] | lemma | tactic.ring_exp.pow_e_pf_exp | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"pow_mul"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_coeff (p_p q_p : expr) (p q : coeff) : ring_exp_m (ex prod) | do
ctx ← get_context,
pq' ← mk_pow [p_p, q_p],
(pq_p, pq_pf) ← lift $ norm_num.eval_pow pq',
if q.value.denom ≠ 1 then lift $ fail!"Only integer powers are supported, not {q.value}."
else pure $ ex.coeff ⟨pq_p, pq_p, pq_pf⟩ ⟨p.1 ^ q.value.num⟩ | def | tactic.ring_exp.pow_coeff | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"lift",
"norm_num.eval_pow"
] | Compute the exponentiation of two coefficients.
The returned value is of the form `ex.coeff _ (p ^ q)`,
with the proof of `expr.of_rat p ^ expr.of_rat q = expr.of_rat (p ^ q)`. | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
pow_e : ex exp → ex prod → ring_exp_m (ex exp) | | pps@(ex.exp pps_i p ps) qs := do
psqs ← in_exponent $ mul_pp ps qs,
ppsqs ← ex_exp p psqs,
ppsqs_o ← pow_orig pps qs,
pf ← mk_proof ``pow_e_pf_exp
[pps.orig, p.pretty, ps.pretty, qs.orig, psqs.pretty]
[pps.info, psqs.info],
pure $ ppsqs.set_info ppsqs_o pf | def | tactic.ring_exp.pow_e | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"exp"
] | Exponentiate two expressions.
* `(p ^ ps) ^ qs = p ^ (ps * qs)` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
pow_pp_pf_one {ps : α} {qs : ℕ} : ps = 1 → ps ^ qs = 1 | λ ps_pf, by rw [ps_pf, one_pow] | lemma | tactic.ring_exp.pow_pp_pf_one | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"one_pow"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_pf_c_c {ps ps' pq : α} {qs qs' : ℕ} :
ps = ps' → qs = qs' → ps' ^ qs' = pq → ps ^ qs = pq | by cc | lemma | tactic.ring_exp.pow_pf_c_c | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_pp_pf_c {ps ps' pqs : α} {qs qs' : ℕ} :
ps = ps' → qs = qs' → ps' ^ qs' = pqs → ps ^ qs = pqs * 1 | by simp; cc | lemma | tactic.ring_exp.pow_pp_pf_c | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_pp_pf_prod {pps p ps pqs psqs : α} {qs : ℕ} : pps = p * ps →
p ^ qs = pqs → ps ^ qs = psqs → pps ^ qs = pqs * psqs | λ pps_pf pqs_pf psqs_pf, calc
pps ^ qs = (p * ps) ^ qs : by rw [pps_pf]
... = p ^ qs * ps ^ qs : mul_pow _ _ _
... = pqs * psqs : by rw [pqs_pf, psqs_pf] | lemma | tactic.ring_exp.pow_pp_pf_prod | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"mul_pow"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_pp : ex prod → ex prod → ring_exp_m (ex prod) | | ps@(ex.coeff ps_i ⟨⟨1, 1, _, _⟩⟩) qs := do
o ← ex_one,
o_o ← pow_orig ps qs,
pf ← mk_proof ``pow_pp_pf_one [ps.orig, qs.orig] [ps.info],
pure $ o.set_info o_o pf
| ps@(ex.coeff ps_i x) qs@(ex.coeff qs_i y) := do
pq ← pow_coeff ps.pretty qs.pretty x y,
pq_o ← pow_orig ps qs,
pf ← mk_proof_or_refl pq.pret... | def | tactic.ring_exp.pow_pp | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | Exponentiate two expressions.
* `1 ^ qs = 1`
* `x ^ qs = x ^ qs` (for `x` coefficient)
* `(p * ps) ^ qs = p ^ qs + ps ^ qs` | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
pow_p_pf_one {ps ps' : α} {qs : ℕ} : ps = ps' → qs = succ zero → ps ^ qs = ps' | λ ps_pf qs_pf, calc
ps ^ qs = ps' ^ 1 : by rw [ps_pf, qs_pf]
... = ps' : pow_one _ | lemma | tactic.ring_exp.pow_p_pf_one | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"pow_one"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_p_pf_zero {ps : α} {qs qs' : ℕ} : ps = 0 → qs = succ qs' → ps ^ qs = 0 | λ ps_pf qs_pf, calc
ps ^ qs = 0 ^ (succ qs') : by rw [ps_pf, qs_pf]
... = 0 : zero_pow (succ_pos qs') | lemma | tactic.ring_exp.pow_p_pf_zero | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"zero_pow"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_p_pf_succ {ps pqqs : α} {qs qs' : ℕ} :
qs = succ qs' → ps * ps ^ qs' = pqqs → ps ^ qs = pqqs | λ qs_pf pqqs_pf, calc
ps ^ qs = ps ^ succ qs' : by rw [qs_pf]
... = ps * ps ^ qs' : pow_succ _ _
... = pqqs : by rw [pqqs_pf] | lemma | tactic.ring_exp.pow_p_pf_succ | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"pow_succ"
] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_p_pf_singleton {pps p pqs : α} {qs : ℕ} :
pps = p + 0 → p ^ qs = pqs → pps ^ qs = pqs | λ pps_pf pqs_pf, by rw [pps_pf, add_zero, pqs_pf] | lemma | tactic.ring_exp.pow_p_pf_singleton | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_p_pf_cons {ps ps' : α} {qs qs' : ℕ} :
ps = ps' → qs = qs' → ps ^ qs = ps' ^ qs' | by cc | lemma | tactic.ring_exp.pow_p_pf_cons | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [] | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 | |
pow_p : ex sum → ex prod → ring_exp_m (ex sum) | | ps qs@(ex.coeff qs_i ⟨⟨1, 1, _, _⟩⟩) := do
ps_o ← pow_orig ps qs,
pf ← mk_proof ``pow_p_pf_one [ps.orig, ps.pretty, qs.orig] [ps.info, qs.info],
pure $ ps.set_info ps_o pf
| ps@(ex.zero ps_i) qs@(ex.coeff qs_i ⟨⟨succ y, 1, _, _⟩⟩) := do
ctx ← get_context,
z ← ex_zero,
qs_pred ← lift $ expr.of_nat ctx.info... | def | tactic.ring_exp.pow_p | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"expr.of_nat",
"lift"
] | Exponentiate two expressions.
* `ps ^ 1 = ps`
* `0 ^ qs = 0` (note that this is handled *after* `ps ^ 0 = 1`)
* `(p + 0) ^ qs = p ^ qs`
* `ps ^ (qs + 1) = ps * ps ^ qs` (note that this is handled *after* `p + 0 ^ qs = p ^ qs`)
* `ps ^ qs = ps ^ qs` (otherwise) | https://github.com/leanprover-community/mathlib | 65a1391a0106c9204fe45bc73a039f056558cb83 |
pow_pf_zero {ps : α} {qs : ℕ} : qs = 0 → ps ^ qs = 1 | λ qs_pf, calc
ps ^ qs = ps ^ 0 : by rw [qs_pf]
... = 1 : pow_zero _ | lemma | tactic.ring_exp.pow_pf_zero | tactic | src/tactic/ring_exp.lean | [
"tactic.norm_num",
"control.traversable.basic"
] | [
"pow_zero"
] | 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.