Documentation

Batteries.Data.Float.Lemmas.Arithmetic

Sign and commutativity lemmas for Float and Float32 #

The lemmas are proved through the logical models Float.Model and Float32.Model.

@[simp]
@[simp]
@[simp]
@[simp]

The bit pattern b with its sign bit flipped.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[simp]
    theorem Float.Model.UnpackedFloat.unpack_pack_neg_unpack {spec : Format} (b : BitVec spec.numBits) :
    unpack spec (pack spec (unpack spec b).neg) = (unpack spec b).neg

    Packing commutes with negation, except on NaN.

    theorem Float.Model.UnpackedFloat.roundWithAccuracy_neg (spec : Format) (s : Sign) (m : Nat) (e : Int) (a : Accuracy) :
    roundWithAccuracy spec (-s) m e a = (roundWithAccuracy spec s m e a).neg
    theorem Float.Model.UnpackedFloat.neg_mul (spec : Format) (u v : UnpackedFloat) :
    mul spec u.neg v = (mul spec u v).neg
    theorem Float.Model.UnpackedFloat.mul_neg (spec : Format) (u v : UnpackedFloat) :
    mul spec u v.neg = (mul spec u v).neg
    theorem Float.Model.UnpackedFloat.neg_div (spec : Format) (u v : UnpackedFloat) :
    div spec u.neg v = (div spec u v).neg
    theorem Float.Model.UnpackedFloat.div_neg (spec : Format) (u v : UnpackedFloat) :
    div spec u v.neg = (div spec u v).neg
    theorem Float.Model.UnpackedFloat.mul_comm (spec : Format) (u v : UnpackedFloat) :
    mul spec u v = mul spec v u
    theorem Float.Model.UnpackedFloat.add_comm (spec : Format) (u v : UnpackedFloat) :
    add spec u v = add spec v u
    theorem Float.Model.UnpackedFloat.fma_comm (spec : Format) (u v w : UnpackedFloat) :
    fma spec u v w = fma spec v u w

    Negation of a packed float.

    @[simp]
    theorem Float.Model.neg_neg (a : Model) :
    - -a = a
    theorem Float.Model.neg_mul (a b : Model) :
    -a * b = -(a * b)
    theorem Float.Model.mul_neg (a b : Model) :
    a * -b = -(a * b)
    theorem Float.Model.neg_div (a b : Model) :
    -a / b = -(a / b)
    theorem Float.Model.div_neg (a b : Model) :
    a / -b = -(a / b)
    theorem Float.Model.mul_comm (a b : Model) :
    a * b = b * a
    theorem Float.Model.add_comm (a b : Model) :
    a + b = b + a
    theorem Float.Model.fma_comm (a b c : Model) :
    a.fma b c = b.fma a c
    @[simp]
    theorem Float.neg_neg (x : Float) :
    - -x = x
    @[simp]
    theorem Float.neg_mul (x y : Float) :
    -x * y = -(x * y)
    @[simp]
    theorem Float.mul_neg (x y : Float) :
    x * -y = -(x * y)
    @[simp]
    theorem Float.neg_div (x y : Float) :
    -x / y = -(x / y)
    @[simp]
    theorem Float.div_neg (x y : Float) :
    x / -y = -(x / y)
    theorem Float.mul_comm (x y : Float) :
    x * y = y * x
    theorem Float.add_comm (x y : Float) :
    x + y = y + x
    theorem Float.fma_comm (x y z : Float) :
    x.fma y z = y.fma x z

    Negation of a packed float.

    @[simp]
    theorem Float32.Model.neg_neg (a : Model) :
    - -a = a
    theorem Float32.Model.neg_mul (a b : Model) :
    -a * b = -(a * b)
    theorem Float32.Model.mul_neg (a b : Model) :
    a * -b = -(a * b)
    theorem Float32.Model.neg_div (a b : Model) :
    -a / b = -(a / b)
    theorem Float32.Model.div_neg (a b : Model) :
    a / -b = -(a / b)
    theorem Float32.Model.mul_comm (a b : Model) :
    a * b = b * a
    theorem Float32.Model.add_comm (a b : Model) :
    a + b = b + a
    theorem Float32.Model.fma_comm (a b c : Model) :
    a.fma b c = b.fma a c
    @[simp]
    theorem Float32.neg_neg (x : Float32) :
    - -x = x
    @[simp]
    theorem Float32.neg_mul (x y : Float32) :
    -x * y = -(x * y)
    @[simp]
    theorem Float32.mul_neg (x y : Float32) :
    x * -y = -(x * y)
    @[simp]
    theorem Float32.neg_div (x y : Float32) :
    -x / y = -(x / y)
    @[simp]
    theorem Float32.div_neg (x y : Float32) :
    x / -y = -(x / y)
    theorem Float32.mul_comm (x y : Float32) :
    x * y = y * x
    theorem Float32.add_comm (x y : Float32) :
    x + y = y + x
    theorem Float32.fma_comm (x y z : Float32) :
    x.fma y z = y.fma x z