Assumptions
Whether a step of algebra is valid often depends on what the letters stand for. An assumption says it: x is positive, n is an integer, t lies between 0 and 1. From assumptions the library proves signs, and it only uses a rule when the proof is there.
Stating them
import { assume } from "@ratmath/symbolic";
const A = assume({
x: "positive", // also negative, nonnegative, nonpositive, nonzero, real
n: "integer, >= 1", // several facts, separated by commas
t: "in (0, 1]", // an interval with open or closed ends
u: "> 2", // a comparison with an exact number
w: "0:!w:5", // a Core chain: 0 < w ≤ 5
s: [0, 10], // a closed interval as a pair
});
A Core RationalInterval or Region is accepted as well, so the same object that describes a domain elsewhere in RatMath can be the assumption here. Every function that takes options accepts { assume: … } with either the object above or the plain description.
What follows from them
A.sign("x^2 + x + 1"); // "positive"
A.sign("log(t)"); // "nonpositive" (t ≤ 1)
A.sign("x - u"); // "unknown"
A.range("t*(1 - t)"); // { lo: 0, hi: 1, loClosed: true, hiClosed: false }: a bound, not the exact range
A.proves("u^2 > 4"); // true
A.proves("x < 0"); // false (proven false)
A.proves("x > u"); // null (undecided)
A.proves("integer(n^2 + 3n)"); // true
proves has three answers and only two of them are proofs. null means the library could not decide, which is different from the statement being false.
How a sign is proven
Three methods are tried in turn.
Interval arithmetic with unbounded ends. Each variable has a range such as , and the range of an expression is bounded by combining ranges: , a square is , , of something is positive. Open and closed ends are tracked, which is what separates "positive" from "nonnegative". The bounds of , and the others at finite ends are certified enclosures from analytic.
Factoring. Interval arithmetic sees as , which says nothing. Factored as it is plainly .
Counting real roots. A polynomial in one variable that has no real root in the variable's range cannot change sign there. A Sturm sequence counts the roots exactly, so is proven positive for all real , and is proven positive for .
None of these is complete: a true inequality can come back "unknown". What is guaranteed is the other direction: an answer other than unknown is a theorem.
@ratmath/symbolic and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.