Documentation

Mathlib.Data.UInt

Adds Mathlib specific instances to the UIntX data types. #

The CommRing instances (and the NatCast and IntCast instances from which they is built) are scoped in the UIntX.CommRing namespace, rather than available globally. As a result, the ring tactic will not work on UIntX types without open scoped UIntX.Ring.

This is because the presence of these casting operations contradicts assumptions made by the expression tree elaborator, namely that coercions do not form a cycle.

The UInt version also interferes more with software-verification use-cases, which is reason to be more cautious here.

theorem USize.natCast_def (n : ) :
n = { toBitVec := n }
theorem UInt64.zsmul_def (z : ) (a : UInt64) :
z a = { toBitVec := { toFin := z a.val } }
theorem UInt64.natCast_def (n : ) :
n = { toBitVec := n }
Equations
  • One or more equations did not get rendered due to their size.
theorem UInt32.pow_def (a : UInt32) (n : ) :
a ^ n = { toBitVec := { toFin := a.val ^ n } }
Equations
theorem USize.nsmul_def (n : ) (a : USize) :
n a = { toBitVec := { toFin := n a.val } }

To use this instance, use open scoped UInt32.CommRing.

See the module docstring for an explanation

Equations
Instances For
    theorem UInt16.pow_def (a : UInt16) (n : ) :
    a ^ n = { toBitVec := { toFin := a.val ^ n } }
    Equations
    theorem UInt8.pow_def (a : UInt8) (n : ) :
    a ^ n = { toBitVec := { toFin := a.val ^ n } }
    Equations
    Equations
    theorem UInt16.zsmul_def (z : ) (a : UInt16) :
    z a = { toBitVec := { toFin := z a.val } }

    To use this instance, use open scoped UInt32.CommRing.

    See the module docstring for an explanation

    Equations
    Instances For
      Equations
      Equations
      Equations

      To use this instance, use open scoped UInt32.CommRing.

      See the module docstring for an explanation

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        To use this instance, use open scoped UInt64.CommRing.

        See the module docstring for an explanation

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          Equations
          theorem USize.intCast_def (z : ) :
          z = { toBitVec := z }
          Equations
          • One or more equations did not get rendered due to their size.
          Equations
          Equations

          To use this instance, use open scoped UInt16.CommRing.

          See the module docstring for an explanation

          Equations
          Instances For

            To use this instance, use open scoped UInt64.CommRing.

            See the module docstring for an explanation

            Equations
            Instances For
              theorem UInt16.intCast_def (z : ) :
              z = { toBitVec := z }
              theorem UInt64.intCast_def (z : ) :
              z = { toBitVec := z }
              theorem UInt64.neg_def (a : UInt64) :
              -a = { toBitVec := { toFin := -a.val } }
              theorem UInt32.neg_def (a : UInt32) :
              -a = { toBitVec := { toFin := -a.val } }
              Equations
              • One or more equations did not get rendered due to their size.
              theorem UInt16.nsmul_def (n : ) (a : UInt16) :
              n a = { toBitVec := { toFin := n a.val } }

              To use this instance, use open scoped UInt8.CommRing.

              See the module docstring for an explanation

              Equations
              Instances For
                Equations
                Equations
                theorem UInt8.intCast_def (z : ) :
                z = { toBitVec := z }
                theorem USize.neg_def (a : USize) :
                -a = { toBitVec := { toFin := -a.val } }

                To use this instance, use open scoped USize.CommRing.

                See the module docstring for an explanation

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  Equations
                  • One or more equations did not get rendered due to their size.
                  theorem UInt16.natCast_def (n : ) :
                  n = { toBitVec := n }

                  To use this instance, use open scoped UInt8.CommRing.

                  See the module docstring for an explanation

                  Equations
                  Instances For
                    Equations
                    • One or more equations did not get rendered due to their size.
                    theorem UInt8.natCast_def (n : ) :
                    n = { toBitVec := n }
                    theorem USize.zsmul_def (z : ) (a : USize) :
                    z a = { toBitVec := { toFin := z a.val } }
                    theorem UInt64.pow_def (a : UInt64) (n : ) :
                    a ^ n = { toBitVec := { toFin := a.val ^ n } }
                    theorem UInt16.neg_def (a : UInt16) :
                    -a = { toBitVec := { toFin := -a.val } }
                    theorem USize.pow_def (a : USize) (n : ) :
                    a ^ n = { toBitVec := { toFin := a.val ^ n } }
                    Equations
                    theorem UInt8.neg_def (a : UInt8) :
                    -a = { toBitVec := { toFin := -a.val } }

                    To use this instance, use open scoped UInt8.CommRing.

                    See the module docstring for an explanation

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      Equations

                      To use this instance, use open scoped UInt16.CommRing.

                      See the module docstring for an explanation

                      Equations
                      Instances For

                        To use this instance, use open scoped USize.CommRing.

                        See the module docstring for an explanation

                        Equations
                        Instances For
                          Equations
                          Equations
                          Equations
                          theorem UInt32.intCast_def (z : ) :
                          z = { toBitVec := z }

                          To use this instance, use open scoped UInt64.CommRing.

                          See the module docstring for an explanation

                          Equations
                          Instances For

                            To use this instance, use open scoped UInt16.CommRing.

                            See the module docstring for an explanation

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              theorem UInt32.zsmul_def (z : ) (a : UInt32) :
                              z a = { toBitVec := { toFin := z a.val } }
                              theorem UInt32.nsmul_def (n : ) (a : UInt32) :
                              n a = { toBitVec := { toFin := n a.val } }

                              To use this instance, use open scoped USize.CommRing.

                              See the module docstring for an explanation

                              Equations
                              Instances For
                                theorem UInt64.nsmul_def (n : ) (a : UInt64) :
                                n a = { toBitVec := { toFin := n a.val } }
                                Equations
                                theorem UInt8.zsmul_def (z : ) (a : UInt8) :
                                z a = { toBitVec := { toFin := z a.val } }
                                theorem UInt8.nsmul_def (n : ) (a : UInt8) :
                                n a = { toBitVec := { toFin := n a.val } }
                                Equations
                                theorem UInt32.natCast_def (n : ) :
                                n = { toBitVec := n }
                                Equations

                                Is this an uppercase ASCII letter?

                                Equations
                                Instances For

                                  Is this a lowercase ASCII letter?

                                  Equations
                                  Instances For

                                    Is this an alphabetic ASCII character?

                                    Equations
                                    • c.isASCIIAlpha = (c.isASCIIUpper || c.isASCIILower)
                                    Instances For

                                      Is this an ASCII digit character?

                                      Equations
                                      Instances For

                                        Is this an alphanumeric ASCII character?

                                        Equations
                                        • c.isASCIIAlphanum = (c.isASCIIAlpha || c.isASCIIDigit)
                                        Instances For
                                          @[deprecated UInt8.isASCIIUpper]

                                          Alias of UInt8.isASCIIUpper.


                                          Is this an uppercase ASCII letter?

                                          Equations
                                          Instances For
                                            @[deprecated UInt8.isASCIILower]

                                            Alias of UInt8.isASCIILower.


                                            Is this a lowercase ASCII letter?

                                            Equations
                                            Instances For
                                              @[deprecated UInt8.isASCIIAlpha]

                                              Alias of UInt8.isASCIIAlpha.


                                              Is this an alphabetic ASCII character?

                                              Equations
                                              Instances For
                                                @[deprecated UInt8.isASCIIDigit]

                                                Alias of UInt8.isASCIIDigit.


                                                Is this an ASCII digit character?

                                                Equations
                                                Instances For
                                                  @[deprecated UInt8.isASCIIAlphanum]

                                                  Alias of UInt8.isASCIIAlphanum.


                                                  Is this an alphanumeric ASCII character?

                                                  Equations
                                                  Instances For

                                                    The numbers from 0 to 256 are all valid UTF-8 characters, so we can embed one in the other.

                                                    Equations
                                                    • n.toChar = { val := n.toUInt32, valid := }
                                                    Instances For