POWER_LAWS.bend open laws/TODOs
raw source on the hub · import bend-float64@0.1.3.0/POWER_LAWS.bend as POWER_LAWS
The laws of bend-float64's power (math.bend), at literal inputs: C99's special-case table and the exact answers found before any ball is evaluated. A gate of its own so that each proof file stays within the checker's limit. Gate: ./bend-check POWER_PROOF.bend --verdict
3 imports
import Base import ./float64.bend as F import ./math.bend as M
Laws
law power_table provedin POWER_PROOF.bendsource · line 13 · raw
{[0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{2146959360, 5}, 0x37b36520d19ff23662419c352915aa77/float64.F64{0, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{1072693248, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{2146959360, 5}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{3220176896, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{2146435072, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{1071644672, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{4293918720, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{1073741824, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{4293918720, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{2147483648, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{3221749760, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{2147483648, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{3221225472, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{2147483648, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1074266112, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{2147483648, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1073741824, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{4293918720, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1074266112, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{4293918720, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{3221749760, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{4293918720, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1073741824, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{3221225472, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1071644672, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{3221225472, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1074266112, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.F64{2146435072, 5}, 0x37b36520d19ff23662419c352915aa77/float64.F64{0, 0})] == [0x37b36520d19ff23662419c352915aa77/float64.F64{1072693248, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1072693248, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1072693248, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{2146435072, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{0, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{4293918720, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{2146435072, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{2147483648, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{0, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{4293918720, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{2147483648, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{2146435072, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{4294443008, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{3223322624, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{2146959360, 5}] : List<&2, 0x37b36520d19ff23662419c352915aa77/float64.F64>}Guarantees: C99's table for power: x^0 = 1 even for a quiet NaN x; 1^y = 1 even for a quiet NaN y; (-1)^inf = 1; 0.5^-inf = inf and 2^-inf = +0; (-0)^-3 = -inf, (-0)^-2 = inf, (-0)^3 = -0, (-0)^2 = +0; (-inf)^3 = -inf, (-inf)^-3 = -0, (-inf)^2 = inf; (-2)^0.5 is the default NaN; (-2)^3 = -8; a signalling NaN to the 0 is that NaN quieted, as glibc gives it. Why it matters: power has the largest special-case table of the set, and each entry is a separate decision.
law exact_power provedin POWER_PROOF.bendsource · line 33 · raw
{[0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.from_i32(2), 0x37b36520d19ff23662419c352915aa77/float64.from_i32(10)), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.from_i32(6), 0x37b36520d19ff23662419c352915aa77/float64.from_i32(3)), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.from_i32(3), 0x37b36520d19ff23662419c352915aa77/float64.from_i32(3)), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.from_i32(36), 0x37b36520d19ff23662419c352915aa77/float64.F64{1071644672, 0}), 0x37b36520d19ff23662419c352915aa77/math.power(0x37b36520d19ff23662419c352915aa77/float64.from_i32(2), 0x37b36520d19ff23662419c352915aa77/float64.from_i32(4294966221))] == [0x37b36520d19ff23662419c352915aa77/float64.F64{1083179008, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1080754176, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1077608448, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{1075314688, 0}, 0x37b36520d19ff23662419c352915aa77/float64.F64{0, 0}] : List<&2, 0x37b36520d19ff23662419c352915aa77/float64.F64>}Guarantees: power comes out exact when the answer is: 2^10 = 1024, 6^3 = 216, 3^3 = 27, 36^0.5 = 6 (36 = 3^2 2^2), 2^-1075 = 0 (halfway, to even). Why it matters: an exact or halfway power never settles by refining a ball, so each is found and computed exactly first; without that the evaluation would loop, and a halfway case could round the wrong way.