By sure this answer could be off topic, but since you tagged SWI-Prolog your question, I will show an extension that have been made available in version 7.1: dicts.
:- module(cuboid, []).
M.cx() := Cx :- Cx is M.x2 - M.x1 .
M.cy() := Cy :- Cy is M.y2 - M.y1 .
M.cz() := Cz :- Cz is M.z2 - M.z1 .
M.volume() := V :- V is M.cx() * M.cy() * M.cz().
M.scale(F) := cuboid{x1:X1, x2:X2, y1:Y1, y2:Y2, z1:Z1, z2:Z2} :-
maplist(mult(F, M), [x1,x2, y1,y2, z1,z2], [X1,X2, Y1,Y2, Z1,Z2]).
mult(F, M, A, V) :- V is M.A * F.
here is an example of use
1 ?- C = cuboid{x1:1, x2:2, y1:1, y2:2, z1:1, z2:2}, writeln(C.volume()).
1
C = cuboid{x1:1, x2:2, y1:1, y2:2, z1:1, z2:2}.
2 ?- S = $C.scale(3), Vs = S.volume().
S = cuboid{x1:3, x2:6, y1:3, y2:6, z1:3, z2:6},
Vs = 27.
I have little clue about spatial relations
or qualitative relations
you are looking for. I imagine that will be a set of spatial relations between two cuboids, like
intersect, is_on_top, is_at_left, etc...
Depending on the applicative domain you are supposed to handle, consider using a constraint library. library(clpr) for reals, library(clpq) for rationals, or library(clpfd) for integers.
This last one is more developed, and actively mantained.