Documentation

Time.Fixed

structure Time.Fixed (precision : Nat) :

fixed-point representation of a fractional number

Instances For
    theorem Time.Fixed.ext {precision : Nat} {x y : Time.Fixed precision} (val : x.val = y.val) :
    x = y
    instance Time.instReprFixed {precision✝ : Nat} :
    Repr (Time.Fixed precision✝)
    Equations
    • Time.instReprFixed = { reprPrec := Time.reprFixed✝ }
    instance Time.instBEqFixed {precision✝ : Nat} :
    BEq (Time.Fixed precision✝)
    Equations
    • Time.instBEqFixed = { beq := Time.beqFixed✝ }
    instance Time.instDecidableEqFixed {precision✝ : Nat} :
    DecidableEq (Time.Fixed precision✝)
    Equations
    • Time.instDecidableEqFixed = Time.decEqFixed✝
    inductive Time.Sign :
    Instances For
      Equations
      structure Time.Fixed.Denominator (precision : Nat) :

      denominator of Fixed p

      • val : Nat
      • lt : self.val < 10 ^ precision
      Instances For
        instance Time.Fixed.instReprDenominator {precision✝ : Nat} :
        Equations
        • Time.Fixed.instReprDenominator = { reprPrec := Time.Fixed.reprDenominator✝ }
        instance Time.Fixed.instBEqDenominator {precision✝ : Nat} :
        Equations
        • Time.Fixed.instBEqDenominator = { beq := Time.Fixed.beqDenominator✝ }
        Equations
        • Time.Fixed.instDecidableEqDenominator = Time.Fixed.decEqDenominator✝
        structure Time.Fixed.Parts (precision : Nat) :

        parts of Fixed p

        • sign : Time.Sign
        • numerator : Nat
        • denominator : Nat
        • lt : self.denominator < 10 ^ precision
        Instances For
          instance Time.Fixed.instReprParts {precision✝ : Nat} :
          Repr (Time.Fixed.Parts precision✝)
          Equations
          • Time.Fixed.instReprParts = { reprPrec := Time.Fixed.reprParts✝ }
          instance Time.Fixed.instBEqParts {precision✝ : Nat} :
          BEq (Time.Fixed.Parts precision✝)
          Equations
          • Time.Fixed.instBEqParts = { beq := Time.Fixed.beqParts✝ }
          instance Time.Fixed.instDecidableEqParts {precision✝ : Nat} :
          Equations
          • Time.Fixed.instDecidableEqParts = Time.Fixed.decEqParts✝
          Equations
          • Time.Fixed.zero = { val := 0 }
          Instances For
            Equations
            • Time.Fixed.Denominator.zero = { val := 0, lt := }
            Instances For
              Equations
              • Time.instInhabitedFixed = { default := Time.Fixed.zero }
              instance Time.instLTFixed {p : Nat} :
              Equations
              • Time.instLTFixed = { lt := fun (a b : Time.Fixed p) => a.val < b.val }
              theorem Time.lt_def {p : Nat} (a b : Time.Fixed p) :
              (a < b) = (a.val < b.val)
              instance Time.instLEFixed {p : Nat} :
              Equations
              • Time.instLEFixed = { le := fun (a b : Time.Fixed p) => a.val b.val }
              Equations
              • =
              theorem Time.le_def {p : Nat} (a b : Time.Fixed p) :
              (a b) = (a.val b.val)
              Equations
              • Time.instInhabitedDenominator = { default := Time.Fixed.Denominator.zero }
              theorem Time.inhabited_def {p : Nat} :
              default = Time.Fixed.Denominator.zero
              Equations
              Equations
              Equations
              • f.neg = { val := -f.val }
              Instances For
                Equations
                Instances For
                  def Time.Fixed.toFixed {p : Nat} (sign : Time.Sign) (num : Nat) (denom : Time.Fixed.Denominator p) :
                  Equations
                  Instances For
                    Equations
                    • parts.fromParts = Time.Fixed.toFixed parts.sign parts.numerator { val := parts.denominator, lt := }
                    Instances For
                      Equations
                      Instances For

                        remove trailing digits untill n < 10 ^ p

                        Equations
                        Instances For
                          @[irreducible]
                          def Time.Fixed.toDenominator.clip_denom (n p : Nat) (hp : 0 < p) :
                          { n : Nat // n < p }
                          Equations
                          Instances For
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              Equations
                              Instances For
                                Equations
                                • One or more equations did not get rendered due to their size.
                                def Time.Fixed.sub {p : Nat} (dt1 dt2 : Time.Fixed p) :
                                Equations
                                • dt1.sub dt2 = { val := dt1.val - dt2.val }
                                Instances For
                                  def Time.Fixed.add {p : Nat} (dt1 dt2 : Time.Fixed p) :
                                  Equations
                                  • dt1.add dt2 = { val := dt1.val + dt2.val }
                                  Instances For
                                    instance Time.Fixed.instSub {p : Nat} :
                                    Equations
                                    • Time.Fixed.instSub = { sub := Time.Fixed.sub }
                                    theorem Time.Fixed.sub_def {p : Nat} (a b : Time.Fixed p) :
                                    a - b = a.sub b
                                    instance Time.Fixed.instAdd {p : Nat} :
                                    Equations
                                    • Time.Fixed.instAdd = { add := Time.Fixed.add }
                                    theorem Time.Fixed.add_def {p : Nat} (a b : Time.Fixed p) :
                                    a + b = a.add b
                                    Equations
                                    Instances For
                                      def Time.Fixed.div {p : Nat} (dt1 dt2 : Time.Fixed p) :
                                      Equations
                                      • dt1.div dt2 = dt1.val / dt2.val
                                      Instances For
                                        Equations
                                        • Time.Fixed.instHDivInt = { hDiv := Time.Fixed.div }
                                        theorem Time.Fixed.div_def {p : Nat} (a b : Time.Fixed p) :
                                        a / b = a.div b
                                        def Time.Fixed.mul {p : Nat} (a : Int) (f : Time.Fixed p) :
                                        Equations
                                        Instances For
                                          Equations
                                          • Time.Fixed.instHMulInt = { hMul := Time.Fixed.mul }
                                          theorem Time.Fixed.mul_def {p : Nat} (a : Int) (b : Time.Fixed p) :
                                          def Time.Fixed.mod {p : Nat} (dt1 dt2 : Time.Fixed p) :
                                          Equations
                                          • dt1.mod dt2 = { val := dt1.val % dt2.val }
                                          Instances For
                                            instance Time.Fixed.instMod {p : Nat} :
                                            Equations
                                            • Time.Fixed.instMod = { mod := Time.Fixed.mod }
                                            theorem Time.Fixed.mod_def {p : Nat} (a b : Time.Fixed p) :
                                            a % b = a.mod b
                                            @[simp]
                                            theorem Time.Fixed.ofFixed_lt {p : Nat} {a b : Time.Fixed p} :
                                            a < b a.val < b.val
                                            @[simp]
                                            theorem Time.Fixed.ofFixed_ne {p : Nat} {a b : Time.Fixed p} :
                                            a b a.val b.val
                                            theorem Time.Fixed.ne_of_lt {p : Nat} {a b : Time.Fixed p} (h : a < b) :
                                            a b
                                            theorem Time.Fixed.emod_nonneg {p : Nat} (a : Time.Fixed p) {b : Time.Fixed p} (h : b { val := 0 }) :
                                            { val := 0 } a % b
                                            theorem Time.Fixed.emod_lt_of_pos {p : Nat} (a : Time.Fixed p) {b : Time.Fixed p} (h : { val := 0 } < b) :
                                            a % b < b
                                            theorem Time.Fixed.emod_add_ediv {p : Nat} (a b : Time.Fixed p) :
                                            a % b + a / b * b = a
                                            def Time.Fixed.toMod {p : Nat} (n d : Time.Fixed p) (h : Time.Fixed.zero < d) :
                                            { m : Time.Fixed p // Time.Fixed.zero m m < d }

                                            toMod computes n % d : { m : Fixed p // zero ≤ m ∧ m < d }

                                            Equations
                                            • n.toMod d h = n % d,
                                            Instances For
                                              theorem Time.Fixed.zero_lt_toFixed (p m : Nat) (m_denom : Time.Fixed.Denominator p) (h : 0 < m) :
                                              Time.Fixed.zero < Time.Fixed.toFixed Time.Sign.Nonneg m m_denom
                                              theorem Time.Fixed.zero_le_toFixed (p m : Nat) (m_denom : Time.Fixed.Denominator p) (hnm : 0 < m) :
                                              Time.Fixed.zero Time.Fixed.toFixed Time.Sign.Nonneg m m_denom
                                              theorem Time.Fixed.fixed_eq_toParts_fromParts {p : Nat} (f : Time.Fixed p) :
                                              f = f.toParts.fromParts