Yes, 'elem?' really means that FriCAS can find the integral,
either elementary or not.
FriCAS may use nonelementary function in integral, but should
do so only when there is no elementary expression. So to
check that the integral is elementary you need to check if
FriCAS result is an elementary function. The following
should do this
elem_ker(k) ==
symbolIfCan(k) case Symbol or (
op := operator(k); has?(op, 'elem) or has?(op, '%alg))
elem_expr(ex) == reduce(_and, [elem_ker(k) for k in tower(ex)])
A little explanation: FriCAS expression is a rational function
of kernels. Kernels may be variables, constants, algebraic
expressions or application of functions to arguments. To
check that expression is elementary you need to check that
each kernel contained in it (directly or indirectly) is elementary.
'tower' gives you appropriate list of kerenls. 'elem_ker'
above checks if kernel is elementary looking at 3 possible cases:
'symbolIfCan' checks for variables and constants, 'has?(op, 'elem)'
checks for elementary transcendental functions, 'has?(op, '%alg)'
checks for algebraic expressions.
Note: there are cases which FriCAS currently can not decide,
in such cases intead of returning a result FriCAS throws an
error.
--
Waldek Hebisch