Skip to content

Add builtin Refine - #1900

Merged
rocky merged 6 commits into
masterfrom
add-Refine
Aug 23, 2026
Merged

Add builtin Refine#1900
rocky merged 6 commits into
masterfrom
add-Refine

Conversation

@rocky

@rocky rocky commented Aug 23, 2026

Copy link
Copy Markdown
Member

Start adding Built-in Function Refine.

To do this, we make use of SymPy's sympy.assumptions.assume.AppliedPredict and conversion from WMA to SymPy for this.
Currently, we handle relational expressions (==, >, etc.) and element domains (Reals, Integers, etc.).

There is much more to do, but this is a start.

We also start allowing "has_form" to accept a Symbol parameter in addition to a string. Over time, I expect a PR to convert from str-argument has-form to Symbol-argument has_form.

Assume and $Assumption have been moved from the generic mathics.builtin.arithmetic to mathics.builtin.assumptions which is where the new Refine lives.

The motivation for this work stems from the fact that Rubi uses and calls Refine.

Some type checking was made more stringent.

@mmatera

mmatera commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Awesome! This has been waiting for a long time...

Move tests already written in ``test.builtin.arithfns.test_assumptions``
to ``test.builtin.assumptions``
@rocky

rocky commented Aug 23, 2026

Copy link
Copy Markdown
Member Author

For reference, there are bugs in SymPy that may be addressed and will help here. See sympy/sympy#30324

What's cool about the PR to fix this, sympy/sympy#30325, is that it is being done in SymPy by improving its SAT solver! Thanks, @tkim601 !

One other thing of interest to me is that while I really like @ad-si Woxi, as best as I can tell, right now it doesn't have access to such a beast yet. It has to do all of the algebraic manipulation inside the Woxi code. Do I have this correct, Adrian? Possibly Woxi can find a similar SAT solver for such purposes?

But it shows the differences in approaches right now. (Possibly over time the two projects will converge).

@rocky
rocky merged commit 75f9d6f into master Aug 23, 2026
18 checks passed
@rocky
rocky deleted the add-Refine branch August 23, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants