Question: Compared behaviours of type and pat match

Could you explain me why the three forms of patmatch behave identically (which seems natural) but the three forms of type do not.
Is there a way to define the type in type such that this latter returns the same thing for a*f(x)+b, f(x)*a+b, b+a*f(x), b+f(x)*a ?

Z := f(x)*a+b;
t1 = type(Z, `&+`(algebraic, `&*`(algebraic, function)));
t2 = type(Z, `&+`(`&*`(algebraic, function), algebraic));
t3 = type(Z, `&+`(`&*`(function, algebraic), algebraic));

f(x)*a+b

 

t1 = false

 

t2 = false

 

t3 = true

(1)

p1 = patmatch(Z, A::algebraic*f(X::algebraic) + B::algebraic, 'pat');
pat;
p2 = patmatch(Z, B::algebraic + A::algebraic*f(X::algebraic), 'pat');
pat;
p2 = patmatch(Z, B::algebraic + f(X::algebraic)*A::algebraic, 'pat');
pat;

p1 = true

 

[A = a, B = b, X = x]

 

p2 = true

 

[A = a, B = b, X = x]

 

p2 = true

 

[A = a, B = b, X = x]

(2)
 

 

Download type_vs_patmatch.mw

TIA

Please Wait...