from sage.all import PolynomialRing, ZZ

pr = PolynomialRing(ZZ, ('a', 'd', 'X1', 'X2', 'Y1', 'Y2'), 6)
a, d, X1, X2, Y1, Y2 = pr.gens()
k, d2 = 2 * d, 2 * d
T1 = X1 * Y1
T2 = X2 * Y2
Z1, Z2 = 1, 1
formula = {}
A = X1 * X2
formula['A'] = A
B = Y1 * Y2
formula['B'] = B
C = T2
formula['C'] = C
D = T1
formula['D'] = D
E = D + C
formula['E'] = E
t0 = X1 - Y1
formula['t0'] = t0
t1 = X2 + Y2
formula['t1'] = t1
t2 = t0 * t1
formula['t2'] = t2
t3 = t2 + B
formula['t3'] = t3
F = t3 - A
formula['F'] = F
t4 = a * A
formula['t4'] = t4
G = B + t4
formula['G'] = G
H = D - C
formula['H'] = H
X3 = E * F
formula['X3'] = X3
Y3 = G * H
formula['Y3'] = Y3
T3 = E * H
formula['T3'] = T3
Z3 = F * G
formula['Z3'] = Z3
