Sorry, it’s not really relevant to your goal, but I have recently made a pack for unit aware computation that is compatible with clpBNR, meaning you can do this:
?- qeval({A == 5000*gram / 2 * gram}). % wrong equation, see below A = 2500.
Here is the original post: Units: a new pack for units and quantities
edit: the correct equation was this:
?- qeval({A == 5000*gram / (2 * gram)}). A = 2500.