Documentation

Complexity.Computability.GenericRAM.Signed

Bounded signed integer RAM #

Signed.model instantiates the generic RAM with the operational choices of LeanTrominoes.ComplexityAbstract.RAM at revision 6d5b36c1 (MIT–ULB CompGeom Group). Values are integers, addresses are naturals, and the configuration is a word width. Every produced, moved, stored, or returned value must fit the signed word range. Address registers must be nonnegative and below 2^w; the current program counter and every continuation label must also be below 2^w.

Arithmetic uses Lean's integer division and remainder, including their total zero-divisor conventions. Each instruction, including halt, costs one. This is the source's signed model, not the unsigned Cslib.WordRAM instance; in particular subtraction is not truncated.

Main definitions #

Main results #

References #

The five arithmetic operations of the original signed RAM.

Instances For

    Integer arithmetic, with Lean's total division and remainder conventions.

    Instances For

      Equality and signed strict comparison.

      Instances For

        Interpret a comparison on signed integers.

        Instances For

          Signed two's-complement range, requiring a positive word width.

          Instances For
            @[instance_reducible]
            instance Cslib.GenericRAM.Signed.instDecidableFits (w : ℕ) (value : ℤ) :
            Decidable (Fits w value)
            theorem Cslib.GenericRAM.Signed.fits_zero {w : ℕ} (positive : 0 < w) :
            Fits w 0

            Zero fits at every positive width.

            theorem Cslib.GenericRAM.Signed.fits_one {w : ℕ} (wide : 2 ≤ w) :
            Fits w 1

            One fits at every width of at least two bits.

            @[reducible, inline]

            The original bounded signed integer RAM, as a generic machine model. All writes and halts check Fits; addresses and control labels use the unsigned range.

            Instances For

              Zero registers and an input length header at address zero, followed by input words. Input placement is a calling convention, not part of the instruction cost.

              Instances For

                Input words and their length header fit the signed range.

                Instances For