Hi, I have a proposal for floating point that uses 6 width-4 witness rows. This is on the arithmetic circuit side, and the gates require additional table lookups and range proofs, which also cost exponentiations.
Subject to corrections.
Floating point value e.g. (x_1, x_2, x_3) representing sign, significand and exponent.
For floating point values, range checks:
-
x_1, y_1, z_1 in \{p-1, 1\}
-
x_2, y_2, z_2 in significand range (e.g. 2^{22} \leq x < 2^{23})
-
x_3, y_3, z_3 in exponent range (e.g. -2^{8}+2 \leq x < 2^{8}-1, with negative values -n represented by p-n)
Addition gate: (6 rows)
Wire values: x_1, x_2, x_3, y_1, y_2, y_3, z_1, z_2, z_3, e, r, d, v, v', s_a, s_b, s_c, s_1, s_2, s_3, s_4, s_5, s_6, i. (Total: 23)
Total 6 rows of 4 witness wires each for 1 floating point gate. Max degree (including mul/add selector & 2 (dynamic) branch selectors): 4.
d = x_3-y_3, i (lookup d in table i)
0 < d < 23 (s_1) and
s_3(z_2 = x_2 + v' and z_3 = x_3)
+s_4(2\times z_2 = x_2 + v' and z_3 = x_3 + 1)
+s_5(2\times z_2 = x_2 + v' + 1 and z_3 = x_3 + 1)
+s_6(z_2 = 2\times(x_2 + v') and z_3 = x_3 - 1)
i=1
v' = (y_1 \times x_1) \times v
y_2 = v \times e + r
0\leq r < e
Powers of two table: (d, e=2^d)\in t^*
e=1, r=0 for d=0
Flip x, y for 23 < d < 0 (s_2, i=2).
23 \leq d < 255 (s_a): z_j = x_j, i=3
-255 < d \leq-23 (s_b): z_j = y_j, i=4
d = 0, s_c:
TODO
Require range proofs for d.
Multiplication gate: (3 rows)
Wire values: x_1, x_2, x_3, y_1, y_2, y_3, z_1, z_2, z_3, s_1, r. (Total: 11)
Sign check: x_1 \times y_1 = z_1
Note that 2^{44} \leq x_2 \times y_2 < 2^{46}.
If 2^{45} \leq x_2 \times y_2 < 2^{46} (s_1):
x_2 \times y_2 = z_2 \times 2^{23} + r
0 \leq r < 2^{23}
x_3 + y_3 +1 = z_3
Else 2^{44} \leq x_2 \times y_2 < 2^{45} (1-s_1):
x_2 \times y_2 = z_2 \times 2^{22} + r
0 \leq r < 2^{22}
x_3 + y_3 = z_3
Note that for the multiplication branch, only one of the constraints can be satisfied. Hence, only an additional selector s is needed, while no range checks are needed.
For simplicity, any overflows result in an unsatisfied constraint.