It is hard to make sense of "If the user forced base ring QQ" after the object got created.
How should we know if that keyword was given when looking at the object?
The reason I ask this question is because I do not believe that the usage of the keyword
"base_ring" is "to force the base ring used", but rather to help the constructor to build the
desired object in a specific base ring: the input is converted in that base ring (if possible)
once things are constructed. Then, as Vincent mentioned, and I agree, the base ring
should be kept as long as it is possible.
On the other hand, a user "forcing QQ" can be thought as a peculiar thing to do. Every
rational polyhedron has an integer H-representation, so if one looks at the H-representation,
QQ is not necessary to write the H-representation. The distinction comes from the
V-representation and has consequences on the related objects (Ehrhart quasi-polynomial
vs Ehrhart polynomial and any method that makes use of integer arithmetic...). So, yes
there should be a distinction between the two base rings ZZ and QQ. That said, I believe that internally,
it should always try to take the "simplest" base ring possible. If the user then wants a
different ring, then Sage will give the object back in that one, but may do computations with a
different ring. So now again, does "forcing a base ring" makes sense?
That said, as explained in the tutorial
A clean way to work with polyhedron is to have the objects already be in a common base ring already.
If this is not possible and one gives different types in the input, then it will go on and figure out a
proper base ring. But, since this might take a while, the keyword "base ring" helps in this regards.
So, one should be careful in using this keyword... For example, after #25097 is merged, this will become possible:
sage: sqrt_2s = sqrt(2)
sage: cbrt_2s = 2^(1/3)
sage: P1 = Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]]);P1
Traceback (most recent call last):
...
ValueError: no appropriate backend for computations with Symbolic Ring
sage: P2 = Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]],backend='normaliz');P2
A 1-dimensional polyhedron in (Symbolic Ring)^2 defined as the convex hull of 2 vertices
sage: Polyhedron(vertices = [[sqrt_2s, 0], [0, cbrt_2s]],backend='field')
Traceback (most recent call last):
...
ValueError: the 'field' backend for polyhedron can not be used with non-exact fields
The object P2's base ring is the Symbolic Ring, but the computations are done in the normaliz field accessible with the method `_normaliz_field`.
J-P