# Proofs of MATH_LAWS.bend. A NaN law holds for every input because each function tests is_nan first: the # hypothesis rewrites that test to its value and the function reduces to its answer. The rest are literal instances # the checker computes. import Base import ./float64.bend as F import ./math.bend as M import ./MATH_LAWS.bend as Laws def Laws.unary_nan(x, h): %Equal.sym(Bool, F.is_nan(x), True{}, h) : {[M.unary(_, M.UExp{}, x), M.unary(_, M.UExp2{}, x), M.unary(_, M.UExpm1{}, x), M.unary(_, M.ULog{}, x), M.unary(_, M.ULog2{}, x), M.unary(_, M.ULog10{}, x), M.unary(_, M.ULog1p{}, x), M.unary(_, M.USin{}, x), M.unary(_, M.UCos{}, x), M.unary(_, M.UTan{}, x), M.unary(_, M.UArcsin{}, x), M.unary(_, M.UArccos{}, x), M.unary(_, M.UArctan{}, x), M.unary(_, M.USinh{}, x), M.unary(_, M.UCosh{}, x), M.unary(_, M.UArcsinh{}, x), M.unary(_, M.UArccosh{}, x), M.unary(_, M.UArctanh{}, x), M.unary(_, M.UCbrt{}, x), M.unary(_, M.UTanh{}, x)] == [F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.quiet(x), F.F64{2146959360, 0}] : List<&2, F.F64>} {==} def Laws.atan2_nan_x(y, x, h): %Equal.sym(Bool, F.is_nan(x), True{}, h) : {M.out(M.atan2_n(_, F.is_nan(y), y, x)) == F.quiet(x) : F.F64} {==} def Laws.atan2_nan_y(y, x, hx, hy): %Equal.sym(Bool, F.is_nan(x), False{}, hx) : {M.out(M.atan2_n(_, F.is_nan(y), y, x)) == F.quiet(y) : F.F64} %Equal.sym(Bool, F.is_nan(y), True{}, hy) : {M.out(M.atan2_n(False{}, _, y, x)) == F.quiet(y) : F.F64} {==} def Laws.special_values(): {==} def Laws.exact_exp_log(): {==} def Laws.exact_hypot(): {==} def Laws.atan2_zeros(): {==}