I've been trying (but utterly failed) to find literature on how CAS implement factorization of symbolic polynomials. Everything I find relentlessly points back to stuff about rings and polynomials with coefficients over finite fields, which, perhaps I am being naive or missing something, but I haven't found how to apply to the problem mentioned above.
After some frustration, I've ended rolling up my sleeves and coming up with some heuristic algorithm based on the following observation (and quite some bits of trial and error). Consider the expansion of the following expression
$$ \Bigg( \sum^{n}_i{x_i} \Bigg) \times \Bigg( \sum^{m}_j{y_j} \Bigg) = x_0 y_0 + x_1 y_0 \dots + x_n y_m $$
Now I take some random term and divide the entire polynomial against it:
$$ x_0 y_0 + x_1 y_0 \dots + x_n y_m = x_{a} y_{b} ( \frac{x_0 y_0}{x_a y_b} + \frac{x_1 y_0}{x_a y_b} + \dots + \frac{y_q}{y_b} + \dots + \frac{x_p}{x_a} + \cdots + 1 + \dots + \frac{ x_n y_m}{ x_a y_b } ) $$
In this form it is easy to see that there are terms that are of the form $\frac{x_p}{x_a}, \frac{y_q}{y_b}$ (which I call order-1 terms), and the remaining terms that are not of this form can be expressed as factors of two order-1 terms.
So, this suggest that if the terms in a polynomial can be fully classified as 1-terms and products of the 1-terms (call them 2-terms), then it is possible to factorize it. Let's call this algorithm $\mathbf{MF}$
I am ignoring from this discussion the case of polynomials like $ a^2 - b^2$ where the 1-terms are missing, but after one matches all existing terms with $\mathbf{MF}$, it should be possible to apply some additional heuristics to match terms that remain unmatched after applying $\mathbf{MF}$, let's call this $\mathbf{MF*}$.
Now, I've noticed that $\mathbf{MF*}$ mostly seems to work in many cases, but (specially for large polynomials) sometimes the algorithm gets overwhelmed by many "spurious" matches, where some terms happen to be factors of others, but it is merely incidental, and the algorithm quickly has to become more sophisticated to handle these cases.
Is this approach something that is already covered or perhaps solved somewhere without adhoc heuristics? I can't help but suspect that it in fact is, just buried beneath layers of mathematical definitions or theorems in those texts that I have been unable to parse.
Comment to moderators: The question has been closed as "duplicate", however the accepted answer on the claimed duplicate question refers to a book that actually just handles it over to a bunch of theory on factorization of polynomials over finite fields, No attempt is made to explain how or why that is relevant to factorization of multivariate polynomials over integers or rationals. Also I cannot add this as a comment on the linked question.
As a secondary reason why this shouldn't be considered duplicate, is that unlike the claimed duplicate, I am sketching an actually implemented algorithm that works for small enough polynomials, and I would like to perhaps receive some commentary on the algorithm itself and if it is doomed to fail on certain types of polynomials, or it actually reduces to some existing algorithm