This is an implementation detail and I'm not sure if this must be fixed. In any case, Rubi seems to make assumptions on Mathematica's internal representation of DownValues of SetDelayed rules.
Description
In Mathematica, DownValues are SetDelayed[lhs, Condition[rhs, cond]] whereas in Mathics, they are SetDelayed[Condition[lhs, cond], rhs] as shown below.
In Mathematica,
In[1]:= f[A_, x_] := x /; x == 2;
In[2]:= DownValues[f] // FullForm
Out[2]//FullForm= {RuleDelayed[HoldPattern[f[Pattern[A,Blank[]],Pattern[x,Blank[]]]],Condition[x,Equal[x,2]]]}
On the other hand, in Mathics:
In[1]:= f[A_, x_] := x /; x == 2;
In[2]:= DownValues[f] // FullForm
Out[2]//FullForm= {RuleDelayed[HoldPattern[Condition[f[Pattern[A, Blank[]], Pattern[x, Blank[]]], Equal[x, 2]]], x]}
How to Reproduce
See above.
Output Given
Out[2]//FullForm= {RuleDelayed[HoldPattern[Condition[f[Pattern[A, Blank[]], Pattern[x, Blank[]]], Equal[x, 2]]], x]}
Expected behavior
The following, if compatibility with Mathematica in this is desired:
Out[2]//FullForm= {RuleDelayed[HoldPattern[f[Pattern[A,Blank[]],Pattern[x,Blank[]]]],Condition[x,Equal[x,2]]]}
Your Environment
Mathics 7.0.1dev0
on CPython 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:27:36) [GCC 13.3.0]
using SymPy 1.13.3, mpmath 1.3.0, numpy 2.1.3, cython Not installed
Workarounds
Conversion Mathics $\leftrightarrow$ Mathematica can be performed using these rules:
dvMathicsToMath = RuleDelayed[Verbatim[HoldPattern][Verbatim[Condition][lhs_,cond_]],rhs_] :> RuleDelayed[HoldPattern[lhs],Condition[rhs,cond]];
dvMathToMathics = RuleDelayed[Verbatim[HoldPattern][lhs_], Verbatim[Condition][rhs_,cond_]] :> RuleDelayed[HoldPattern[Condition[lhs,cond]],rhs];
Priority
Low. Non-blocking.
Additional context
N/A
This is an implementation detail and I'm not sure if this must be fixed. In any case, Rubi seems to make assumptions on Mathematica's internal representation of
DownValuesofSetDelayedrules.Description
In Mathematica,
DownValuesareSetDelayed[lhs, Condition[rhs, cond]]whereas in Mathics, they areSetDelayed[Condition[lhs, cond], rhs]as shown below.In Mathematica,
On the other hand, in Mathics:
How to Reproduce
See above.
Output Given
Expected behavior
The following, if compatibility with Mathematica in this is desired:
Your Environment
Mathics 7.0.1dev0
on CPython 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:27:36) [GCC 13.3.0]
using SymPy 1.13.3, mpmath 1.3.0, numpy 2.1.3, cython Not installed
Workarounds
Conversion Mathics$\leftrightarrow$ Mathematica can be performed using these rules:
Priority
Low. Non-blocking.
Additional context
N/A