Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

feat(tactic/polyrith): solve more problems by testing for membership in the radical #15425

Closed
wants to merge 177 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
688cedb
linear_combination with exponent
robertylewis Jul 16, 2022
23352d9
fix doc string
robertylewis Jul 16, 2022
bd90404
Merge branch 'master' into lc-exponent
robertylewis Jul 22, 2022
0cb3798
change handling of power 1
robertylewis Jul 22, 2022
b721181
feat(order/boolean_algebra): A bounded generalized boolean algebra is…
YaelDillies Jul 22, 2022
26c4a7c
fix(data/json): `rbmap string α` never serializes to `null` (#15622)
eric-wieser Jul 22, 2022
8618fdb
feat(topology/metric_space/isometry): use namespace, add lemmas (#15591)
urkud Jul 22, 2022
6370805
move(order/{boolean_algebra → basic}): move `has_compl` and trivial i…
vihdzp Jul 22, 2022
c751bda
feat(analysis/locally_convex/with_seminorms): in a normed space, von …
ADedecker Jul 22, 2022
b8b4346
feat(data/polynomial/degree/definitions): redefine `polynomial.degree…
adomani Jul 22, 2022
a80d18e
feat(order/upper_lower): Upper closure of a set (#15581)
YaelDillies Jul 23, 2022
8e63004
feat(set_theory/game/nim): make the file `noncomputable theory` (#15367)
vihdzp Jul 23, 2022
5a919a9
feat(ring_theory/noetherian): Finitely generated idempotent ideal is …
erdOne Jul 23, 2022
8f02755
feat(combinatorics/simple_graph/density): Bound on the difference bet…
YaelDillies Jul 23, 2022
d22b20c
feat(order/partition/finpartition): Bound size of a bit of `finpartit…
YaelDillies Jul 23, 2022
5dee850
feat(data/finset/basic): There is exactly one set in empty types (#15…
YaelDillies Jul 23, 2022
d0bf3e4
chore(algebra/lie/direct_sum): remove `direct_sum.lie_algebra_is_inte…
eric-wieser Jul 23, 2022
af2cbcd
refactor(data/set/countable): golf using `_root_.countable`, review A…
urkud Jul 23, 2022
f538c91
refactor(*): rename `nondiscrete_normed_field` (#15625)
j-loreaux Jul 23, 2022
a78156a
fix(*): fix typos I made yesterday (#15627)
urkud Jul 23, 2022
8e24d4f
feat(number_theory/legendre_symbol/add_character): add file introduci…
MichaelStollBayreuth Jul 23, 2022
07ed95f
feat(analysis/inner_product_space/positive): definition and basic fac…
ADedecker Jul 23, 2022
de3de1f
feat(analysis/normed_space/linear_isometry): add defs and lemmas (#15…
urkud Jul 24, 2022
8e4d5ef
chore(scripts): update nolints.txt (#15656)
leanprover-community-bot Jul 24, 2022
a17f46f
feat(data/list/of_fn): lemmas to turn quantifiers over lists to quant…
eric-wieser Jul 24, 2022
a5272f9
feat(set_theory/zfc/basic): `∈` is well-founded on classes (#15544)
vihdzp Jul 24, 2022
abd5519
chore(*): Rename `normed_group` to `normed_add_comm_group` (#15619)
YaelDillies Jul 24, 2022
95ae6f2
refactor(data/{finite,fintype}): move some lemmas to `data.fintype.ba…
urkud Jul 24, 2022
5103c95
feat(linear_algebra/tensor_product): add id_apply and comp_apply for …
kbuzzard Jul 24, 2022
192e8e4
feat(order/bounded_order): an order is either an `order_bot` or a `no…
vihdzp Jul 24, 2022
7de4a19
feat(algebra/periodic): `fract_periodic` (#15660)
jsm28 Jul 24, 2022
69b51a5
feat(representation_theory/Rep): Rep k G ≌ Module (monoid_algebra k G…
kim-em Jul 24, 2022
479e11a
refactor(set_theory/ordinal/basic): `ordinal.min` → `infi` (#14707)
vihdzp Jul 25, 2022
46ca867
feat(analysis/normed_space/lp_space): construct star structures on lp…
JonBannon Jul 25, 2022
21c56ff
chore(algebra/order/sub): Generalize lemmas (#15497)
YaelDillies Jul 25, 2022
815b9f7
chore(algebra/module/basic): use `simp` instead of `norm_num` (#15670)
urkud Jul 25, 2022
38d5ea5
chore(scripts): update nolints.txt (#15674)
leanprover-community-bot Jul 25, 2022
da1b94b
feat(algebraic_geometry/morphisms): Basic framework for classes of mo…
erdOne Jul 25, 2022
8d97330
fix(algebraic_geometry/projective_spectrum/scheme) : fix module doc s…
jjaassoonn Jul 25, 2022
e3d9b53
feat(category_theory/preadditive/*): algebra over endofunctor preaddi…
Julian-Kuelshammer Jul 25, 2022
53cd6f2
feat(*/partition_of_unity): more lemmas based on the partition of uni…
urkud Jul 25, 2022
6c967df
feat(data/matrix/basic): Add `alg_equiv` and `linear_equiv` instances…
linesthatinterlace Jul 25, 2022
07d1850
feat(linear_algebra/annihilating_polynomial): add definition of annih…
twoquarterrican Jul 25, 2022
3822eb2
feat(order/compare): general cleanup (#15665)
vihdzp Jul 25, 2022
fa12011
feat(combinatorics/set_family/kleitman): Kleitman's bound (#14543)
YaelDillies Jul 25, 2022
a193cd7
refactor(measure_theory/function/uniform_integrable): change `uniform…
kex-y Jul 25, 2022
b278a51
feat(data/sign): `left.sign_neg`, `right.sign_neg` (#15652)
jsm28 Jul 25, 2022
d087b26
feat(algebra/lie/of_associative): add `commute.lie_eq` (#15675)
eric-wieser Jul 25, 2022
0f49e14
feat(measure_theory/measure/finite_measure_weak_convergence): Add nor…
kkytola Jul 25, 2022
db6168d
feat(data/set/countable): add `iff` versions of some lemmas (#15671)
urkud Jul 25, 2022
1dd7b30
chore(tactic/fix_reflect_string): delete file (#15537)
hrmacbeth Jul 25, 2022
e2c2654
feat(big_operators/fin): sum over elements of vector equal to `a` equ…
dtumad Jul 26, 2022
b8b642e
chore(scripts): update nolints.txt (#15685)
leanprover-community-bot Jul 26, 2022
a96672d
doc(tactic/compute_degree): fix tactic tags, add examples to docs (#1…
robertylewis Jul 26, 2022
ec474f4
feat(algebra/jordan): Introduce Jordan rings (#11073)
mans0954 Jul 26, 2022
7236c30
refactor(category_theory/*): use simps in the old parts of the librar…
kim-em Jul 26, 2022
7543a9b
chore(algebra/jordan/basic): remove unused imports (#15686)
eric-wieser Jul 26, 2022
60e4d7a
feat(order/filter/*): `filter.pi` is countably generated (#15632)
urkud Jul 26, 2022
0d79d11
feat(topology/metric_space/lipschitz): add several lemmas (#15634)
urkud Jul 26, 2022
e1a7ea9
feat(topology/separation): add `disjoint_nhds_nhds` (#15635)
urkud Jul 26, 2022
f1c31ef
chore(topology/locally_finite): move from `topology.basic` (#15640)
urkud Jul 26, 2022
1690a4e
feat(tooplogy/metric_space/hausdorff_distance): add lemmas about `thi…
urkud Jul 26, 2022
81ab620
feat(topology/basic): add lemmas about `filter.lift' _ closure` (#15653)
urkud Jul 26, 2022
7238f93
feat(order/filter/basic): add `filter.has_basis.bInter_mem` (#15661)
urkud Jul 26, 2022
80862a6
chore(analysis/inner_product_space): golf two proofs (#15679)
mcdoll Jul 26, 2022
6008122
feat(algebraic_topology/fundamental_groupoid): Define simply connecte…
prakol16 Jul 26, 2022
eed4344
feat(category_theory/limits): preserves biproducts if comparison is i…
TwoFX Jul 26, 2022
313a443
feat(probability/moments): mgf/cgf of a sum of independent random var…
RemyDegenne Jul 26, 2022
4918ed1
chore(number_theory/padics/padic_integers): golf the comm_ring instan…
eric-wieser Jul 26, 2022
4a579f0
feat(order/filter/bases): lemmas about bases of product filters (#15630)
urkud Jul 26, 2022
7a83f11
feat(tactic/positivity): a tactic for proving positivity/nonnegativit…
hrmacbeth Jul 26, 2022
aa270c3
feat(measure_theory/function/conditional_expectation): pull-out prope…
RemyDegenne Jul 26, 2022
f34e340
feat(measure_theory/constructions/borel_space): the set of points for…
kex-y Jul 26, 2022
34a1e2c
feat(ring_theory/valuation/valuation_subring): define maximal ideal …
mckoen Jul 26, 2022
55db562
chore(data/set/{function,countable}): extract a lemma from a proof (#…
urkud Jul 26, 2022
cdabf21
feat(set/intervals/monotone): add some monotonicity lemmas (#14896)
kex-y Jul 26, 2022
5d1f9f5
feat(analysis/inner_product/pi_L2): a finite orthonormal family is a …
ADedecker Jul 26, 2022
01889e4
chore(data/list/of_fn): injectivity (#15695)
eric-wieser Jul 26, 2022
28fcd34
chore(topology/sequences): drop local notation `x ⟶ a` (#15696)
urkud Jul 26, 2022
4af0531
feat(analysis/inner_product_space): in finite dimension, hilbert basi…
ADedecker Jul 26, 2022
4787b7f
feat(set_theory/zfc/basic): `inj` lemmas (#15545)
vihdzp Jul 26, 2022
e942d1c
style(analysis/inner_product_space/l2_space): small style improvement…
ADedecker Jul 26, 2022
0b0e823
refactor(algebra/big_operators/basic): Use `to_additive` (#15702)
YaelDillies Jul 27, 2022
57e6cff
chore(scripts): update nolints.txt (#15706)
leanprover-community-bot Jul 27, 2022
1176fe6
refactor(topology/algebra/order/basic): Add antitone versions of sup …
kkytola Jul 27, 2022
ddfc7d3
feat(category_theory): a category with a small detecting set is well-…
TwoFX Jul 27, 2022
34aa539
feat(ring_theory): the Ore localization of a ring (#14348)
javra Jul 27, 2022
36473a4
feat(category_theory): full_of_surjective (#14974)
TwoFX Jul 27, 2022
7e85d90
feat(ring_theory/ring_hom/finite): Finite type is a local property (#…
erdOne Jul 27, 2022
0aa5432
refactor(topology/sheaves): Redefine sheaves in terms of Grothendieck…
erdOne Jul 27, 2022
3eb459b
feat(ring_theory/ring_hom/finite): Finite ring morphisms are stable u…
erdOne Jul 27, 2022
5759bac
feat(ring_theory/tensor_product): A predicate for being the tensor pr…
erdOne Jul 27, 2022
194b2fb
feat(data/sym/card): Prove stars and bars (#11162)
huynhtrankhanh Jul 27, 2022
f1bf211
feat(group_theory/complement): transversal for the transfer homomorph…
tb65536 Jul 27, 2022
2616567
feat(category_theory/preadditive): constructing a semiadditive struct…
TwoFX Jul 27, 2022
9a82b72
feat(linear_algebra/basis): shows the lattice of submodules of a modu…
Michael14071407 Jul 27, 2022
41844de
feat(category_theory/limits/construction): Construct finite limits fr…
erdOne Jul 27, 2022
e47961f
chore(ring_theory/dedekind_domain/ideal): generalize a lemma (#15104)
Paul-Lez Jul 27, 2022
bfa7353
feat(ring_theory): Formally étale/smooth/unramified morphisms are sta…
erdOne Jul 27, 2022
e90cb2d
feat(algebraic_geometry): comap of surjective homomorphism is closed …
samvang Jul 27, 2022
e1a6884
feat(linear_algebra/finite_dimensional): One-dimensional iff principa…
erdOne Jul 27, 2022
0900116
feat(ring_theory/algebraic): `is_algebraic_algebra_map_iff` (#15586)
tb65536 Jul 27, 2022
235c31d
feat(algebraic_topology/dold_kan): construction of idempotent endomor…
joelriou Jul 27, 2022
b1f6b86
feat(analysis/convex/cone): add inner_dual_cone_eq_Inter_inner_dual_c…
apurvnakade Jul 27, 2022
31bab03
feat(data/nat/totient): lemmas `totient_mul_of_prime_of_{not_}dvd` (#…
stuart-presnell Jul 27, 2022
366f262
feat(order/well_founded): typeclasses for well-founded `<` and `>` (#…
vihdzp Jul 27, 2022
8339dff
feat(computability/ackermann): the Ackermann function isn't primitive…
vihdzp Jul 27, 2022
c694f40
feat(linear_algebra): lemmas on associatedness of determinants of lin…
Vierkantor Jul 27, 2022
a9eaeee
doc(field_theory/splitting_field): update code example to reflect cha…
eric-wieser Jul 27, 2022
6db5114
feat(analysis/special_functions/trigonometric/angle): equality of `co…
jsm28 Jul 27, 2022
b39ba3b
chore(analysis/convex/cone): add trivial coercion lemmas (#15713)
eric-wieser Jul 27, 2022
46a1e80
chore(data/polynomial/cancel_leads): golf using `compute_degree_le` (…
adomani Jul 27, 2022
50391ee
feat(category_theory): a characterization of separating objects (#14838)
TwoFX Jul 27, 2022
6f8bcf8
feat(probability/martingale): the discrete stochastic integral of a s…
kex-y Jul 27, 2022
ae48e8c
feat(analysis/special_functions/gaussian): formula for gaussian integ…
sgouezel Jul 27, 2022
39256a6
feat(combinatorics/additive/behrend): Behrend's lower bound on Roth n…
YaelDillies Jul 27, 2022
ee23110
feat(algebraic_geometry/morphisms): Quasi-compact morphisms of scheme…
erdOne Jul 27, 2022
868d1cf
feat(topology/subset_properties): `locally_compact_space` instance fo…
ralvrz Jul 27, 2022
8044813
feat(category_theory/limits/shapes/comm_sq): opposites of is_pullback…
joelriou Jul 28, 2022
39baa56
feat(category_theory): construction of the localized category (#14422)
joelriou Jul 28, 2022
6b64881
chore(topology/algebra/module, analysis/normed_space/linear_isometry)…
ADedecker Jul 28, 2022
79edb6d
chore(category_theory/adjunction): fix a typo (#15720)
TwoFX Jul 28, 2022
13166c6
feat(order/bounded_order): `is_well_order` instances for `with_top` a…
vihdzp Jul 28, 2022
50b43a2
chore(measure_theory/tactic): remove the measurability attribute from…
RemyDegenne Jul 28, 2022
a42a71f
feat(group_theory/finite_abelian): a finitely generated torsion abeli…
Multramate Jul 28, 2022
d6001a4
chore(field_theory/splitting_field): remove unneeded parameter (#15716)
Vierkantor Jul 28, 2022
f90bbe6
feat(test/polyrith): better formatting for generated tests (#15728)
robertylewis Jul 28, 2022
6efbd67
feat(data/pi/algebra): sum_elim lemmas (#15588)
abentkamp Jul 28, 2022
05244cc
feat(algebra/module): sub_mem_sup for modules over rings (#15733)
alexjbest Jul 28, 2022
c04b5a9
feat(data/{pi, prod}): add missing `has_pow` instances for `pi` type …
jjaassoonn Jul 28, 2022
e4c7baa
fix(tactic/polyrith): remove unnecessary 1* from polyrith output (#15…
robertylewis Jul 28, 2022
74ff61b
feat(probability/strong_law): Lp version of the strong law of large n…
kex-y Jul 28, 2022
d6b7aed
feat(analysis/normed_space/compact_operator): definition and basic fa…
ADedecker Jul 28, 2022
049062a
refactor(linear_algebra, analysis/inner_product_space): use `⊤ ≤` ins…
ADedecker Jul 29, 2022
e846e89
feat(linear_algebra/clifford_algebra/even): Universal property and is…
eric-wieser Jul 29, 2022
59e69a2
feat(linear_algebra/matrix): inner prod of matrix (#14794)
abentkamp Jul 29, 2022
dc1a3f4
docs(topology/sets/compacts): fix typo (#15739)
rwbarton Jul 29, 2022
afe51c2
docs(measure_theory/measure/haar): Mention uniqueness in module docst…
rwbarton Jul 29, 2022
b19dc71
feat(data/nat/factorization/basic): golf & move `card_multiples`, pro…
stuart-presnell Jul 29, 2022
1406534
feat(data/finset/pointwise): Singleton arithmetic (#15435)
YaelDillies Jul 29, 2022
4ed946b
feat(algebra/direct_sum/decomposition): add an induction principle fo…
jjaassoonn Jul 29, 2022
7bc35f9
feat(field_theory/intermediate_field): Produce an intermediate field …
tb65536 Jul 29, 2022
dd55a7b
feat(field_theory/adjoin): A compositum of algebraic extensions is al…
tb65536 Jul 29, 2022
0fbd1eb
fix(linear_algebra/prod): add missing `of_dual`s in lemma statements …
eric-wieser Jul 29, 2022
883a3e3
refactor(algebra/homology): better defeqs, less case splitting (#15690)
jcommelin Jul 29, 2022
d529451
feat(group_theory/p_group): Groups of order p^2 are commutative (#8632)
ChrisHughes24 Jul 30, 2022
8af57a7
feat(algebra/big_operators): add lemmas about sum of disjoint multise…
xroblot Jul 30, 2022
dd3fac2
refactor(tactic/lint/type_classes): change inhabited linter to nonemp…
kmill Jul 30, 2022
280d705
feat(algebra/algebra/subalgebra/basic): Swap arguments of `map` and `…
tb65536 Jul 30, 2022
b48983c
chore(logic/function/basic): make `function.injective.decidable_eq` p…
ADedecker Jul 30, 2022
8d9599d
chore(scripts): update nolints.txt (#15776)
leanprover-community-bot Jul 31, 2022
1474c56
feat(ring_theory/ideal/operations): A variant of `finsupp.total` for …
erdOne Jul 31, 2022
29fb82d
feat(number_theory): Bertrand's postulate, slightly different approac…
BoltonBailey Jul 31, 2022
5c1739f
feat(data/nat/factorization/basic): add lemma `prime.factorization_se…
stuart-presnell Jul 31, 2022
0fca9dc
feat(probability/density): probability of event in uniform distributi…
b-mehta Jul 31, 2022
c745704
chore(ring_theory/adjoin_root): remove duplicate namespace (#15775)
ericrbg Jul 31, 2022
4209ebe
feat(order/succ_pred/basic): `a ≤ succ ⊥ ↔ a = ⊥ ∨ a = succ ⊥` and re…
vihdzp Jul 31, 2022
4a529fa
fix(data/polynomial/basic): remove `monomial_fun` to remove diamonds …
ericrbg Aug 1, 2022
7fb60f6
feat(topology/homeomorph): Product of sets is isomorphic to product o…
tb65536 Aug 1, 2022
a03afc0
chore(data/zmod): make `zmod.int_cast_zmod_cast` `@[norm_cast]` (#15753)
Vierkantor Aug 1, 2022
d5b8b40
feat(algebra/order/floor): `fract_one` (#15785)
jsm28 Aug 1, 2022
e5c2fab
feat(geometry/euclidean/oriented_angle): relation to unoriented angle…
jsm28 Aug 1, 2022
58b8f80
feat(order/rel_iso): relation embeddings for `sum.lex` and `prod.lex`…
vihdzp Aug 1, 2022
dab8287
refactor(category_theory): custom structure for full_subcategory (#14…
TwoFX Aug 1, 2022
63971d1
fix(tactic/rcases): support `rcases x with y` renames (#15773)
digama0 Aug 1, 2022
1f1a93e
fix(algebra/monoid_algebra/basic): add `int_cast` to `monoid_algebra`…
ericrbg Aug 1, 2022
cd8620d
implement proper power computation
robertylewis Aug 2, 2022
170d19c
Merge remote-tracking branch 'blessed/master' into polyrith-radical
robertylewis Aug 2, 2022
f5546b0
dead code
robertylewis Aug 2, 2022
41da168
clean up tests
robertylewis Aug 2, 2022
6f18ae9
update syntax to use config object
robertylewis Sep 22, 2022
101bcbd
golf
robertylewis Sep 23, 2022
60c2c35
Merge branch 'lc-exponent' into polyrith-radical
robertylewis Sep 23, 2022
72ef223
update syntax to provide exponent in config object
robertylewis Sep 23, 2022
d00de74
update tests
robertylewis Sep 23, 2022
44cd468
lint
robertylewis Sep 23, 2022
36ca392
Merge branch 'master' into polyrith-radical
robertylewis Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions scripts/polyrith_sage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ def create_query(type: str, n_vars: int, eq_list, goal_type):
""" Create a query to invoke Sage's `MPolynomial_libsingular.lift`. See
https://github.com/sagemath/sage/blob/f8df80820dc7321dc9b18c9644c3b8315999670b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx#L4472-L4518
for a description of this method. """
var_list = ", ".join([f"var{i}" for i in range(n_vars)])
var_list = [f"var{i}" for i in range(n_vars)] + ['aux']
query = f'''
import json
P = PolynomialRing({type_str(type)}, 'var', {n_vars!r})
[{var_list}] = P.gens()
gens = {eq_list}
P = {type_str(type)}{var_list}
[{", ".join(var_list)}] = P.gens()
p = P({goal_type})
gens = {eq_list} + [1 - p*aux]
I = ideal(gens)
coeffs = p.lift(I)
print(json.dumps([polynomial_to_string(c) for c in coeffs]))
coeffs = P(1).lift(I)
power = max(cf.degree(aux) for cf in coeffs)
coeffs = [P(cf.subs(aux = 1/p)*p^power) for cf in coeffs[:int(-1)]]
js = {{'power': power, 'coeffs': [polynomial_to_string(c) for c in coeffs]}}
print(json.dumps(js))
'''
return query

Expand Down
2 changes: 1 addition & 1 deletion src/tactic/linear_combination.lean
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ meta def _root_.tactic.interactive.linear_combination
(input : parse (as_linear_combo ff [] <$> texpr)?)
(_ : parse (tk "with")?)
(config : linear_combination_config := {})
: tactic unit :=
: tactic unit := do
let (h_eqs_names, coeffs) := list.unzip (input.get_or_else []) in
linear_combination h_eqs_names coeffs config

Expand Down
23 changes: 16 additions & 7 deletions src/tactic/polyrith.lean
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,18 @@ meta instance : non_null_json_serializable poly :=
| sum.inr p := pure p
end}

/-- A schema for the data reported by the Sage calculation -/
@[derive [non_null_json_serializable, inhabited]]
structure sage_json_coeffs_and_power :=
(coeffs : list poly)
(power : ℕ)

/-- A schema for success messages from the python script -/
@[derive [non_null_json_serializable, inhabited]]
structure sage_json_success :=
(success : {b : bool // b = tt})
(trace : option string := none)
(data : option (list poly) := none)
(data : option sage_json_coeffs_and_power := none)

/-- A schema for failure messages from the python script -/
@[derive [non_null_json_serializable, inhabited]]
Expand All @@ -316,7 +322,7 @@ structure sage_json_failure :=

/-- Parse the json output from `scripts/polyrith.py` into either an error message, a list of `poly`
objects, or `none` if only trace output was requested. -/
meta def convert_sage_output (j : json) : tactic (option (list poly)) :=
meta def convert_sage_output (j : json) : tactic (option (ℕ × list poly)) :=
do
r : sage_json_success ⊕ sage_json_failure ← decorate_ex "internal json error: "
-- try the error format first, so that if both fail we get the message from the success parser
Expand All @@ -326,7 +332,7 @@ do
fail!"polyrith failed to retrieve a solution from Sage! {f.error_name}: {f.error_value}"
| sum.inl s := do
s.trace.mmap trace,
pure s.data
pure $ s.data.map $ λ sd, (sd.power, sd.coeffs)
end

/-!
Expand Down Expand Up @@ -484,18 +490,21 @@ a call to `linear_combination`.
-/
meta def process_output (eq_names : list expr) (m : list expr) (R : expr) (sage_out : json) :
tactic format := focus1 $ do
some coeffs_as_poly ← convert_sage_output sage_out | fail!"internal error: No output available",
some (power, coeffs_as_poly) ← convert_sage_output sage_out
| fail!"internal error: No output available",
coeffs_as_pexpr ← coeffs_as_poly.mmap (poly.to_pexpr m),
let eq_names_pexpr := eq_names.map to_pexpr,
coeffs_as_expr ← coeffs_as_pexpr.mmap $ λ e, to_expr ``(%%e : %%R),
linear_combo.linear_combination eq_names_pexpr coeffs_as_pexpr,
linear_combo.linear_combination eq_names_pexpr coeffs_as_pexpr {exponent := power},
let components := (eq_names.zip coeffs_as_expr).filter
$ λ pr, bnot $ pr.2.is_app_of `has_zero.zero,
expr_string ← components_to_lc_format components,
let lc_fmt : format := "linear_combination " ++ format.nest 2 (format.group expr_string),
let lc_exp : format := if power = 1 then "" else format!" with {{exponent := {power}}}",
let lc_fmt : format := "linear_combination " ++
format.nest 2 (format.group expr_string ++ lc_exp),
done <|>
fail!"polyrith found the following certificate, but it failed to close the goal:\n{lc_fmt}",
return $ "linear_combination " ++ format.nest 2 (format.group expr_string)
return lc_fmt

/-- Tactic for the special case when no hypotheses are available. -/
meta def no_hypotheses_case : tactic (option format) :=
Expand Down
Loading
Loading