Skip to content

Commit

Permalink
Move PolynomialQ to pure ER.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Jul 4, 2017
1 parent bf03b5d commit 4e152ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
14 changes: 0 additions & 14 deletions expreduce/builtin_power.go
Expand Up @@ -262,20 +262,6 @@ func GetPowerDefinitions() (defs []Definition) {
defs = append(defs, Definition{
Name: "PolynomialQ",
Usage: "`PolynomialQ[e, var]` returns True if `e` is a polynomial in `var`.",
//Rules: []Rule{
//{"PolynomialQ[p_Plus,v_]", "AllTrue[List@@p,(PolynomialQ[#,v])&]"},
//// TODO: Should probably assert that the integers are positive.
//{"PolynomialQ[p_*v_^exp_Integer,v_]", "If[FreeQ[p,v]&&Positive[exp],True,False]"},
//{"PolynomialQ[_,v_Integer]", "True"},
//{"PolynomialQ[v_,v_]", "True"},
//{"PolynomialQ[p_*v_,v_]", "If[FreeQ[p,v],True,False]"},
//{"PolynomialQ[p_,v_]", "If[FreeQ[p,v],True,False]"},
//},
Rules: []Rule{
{"PolynomialQ[p_Plus,v_]", "AllTrue[List@@p,(PolynomialQ[#,v])&]"},
{"PolynomialQ[p_.*v_^Optional[exp_Integer],v_]", "If[FreeQ[p,v]&&Positive[exp],True,False]"},
{"PolynomialQ[p_,v_]", "If[FreeQ[p,v],True,False]"},
},
Tests: []TestInstruction{
&SameTest{"True", "PolynomialQ[2x^2-3x+2, x]"},
&SameTest{"True", "PolynomialQ[2x^2, x]"},
Expand Down
6 changes: 6 additions & 0 deletions expreduce/resources/power.er
Expand Up @@ -13,3 +13,9 @@ Expand[a_] := a //. {
genExpand[List @@ s, possibleExponents[n, Length[s]]],
c_*s_Plus :> ((c*#) &) /@ s
};

PolynomialQ[p_Plus, v_] :=
AllTrue[List @@ p, (PolynomialQ[#, v]) &];
PolynomialQ[p_.*v_^Optional[exp_Integer], v_] :=
If[FreeQ[p, v] && Positive[exp], True, False];
PolynomialQ[p_, v_] := If[FreeQ[p, v], True, False];

0 comments on commit 4e152ef

Please sign in to comment.