Documentation

Time.Fixed

theorem Time.Fixed.ext {precision : Nat} {x : Time.Fixed precision} {y : Time.Fixed precision} (val : x.val = y.val) :
x = y
theorem Time.Fixed.ext_iff {precision : Nat} {x : Time.Fixed precision} {y : Time.Fixed precision} :
x = y x.val = y.val
structure Time.Fixed (precision : Nat) :

fixed-point representation of a fractional number

Instances For
    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
        theorem Time.Fixed.Denominator.lt {precision : Nat} (self : Time.Fixed.Denominator precision) :
        self.val < 10 ^ precision
        instance Time.Fixed.instReprDenominator :
        {precision : Nat} → Repr (Time.Fixed.Denominator precision)
        Equations
        • Time.Fixed.instReprDenominator = { reprPrec := Time.Fixed.reprDenominator✝ }
        instance Time.Fixed.instBEqDenominator :
        {precision : Nat} → BEq (Time.Fixed.Denominator precision)
        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
          theorem Time.Fixed.Parts.lt {precision : Nat} (self : Time.Fixed.Parts precision) :
          self.denominator < 10 ^ precision
          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} → DecidableEq (Time.Fixed.Parts precision)
          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 : Time.Fixed p) (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
              • Time.instLeReflFixed = { le_refl := }
              theorem Time.le_def {p : Nat} (a : Time.Fixed p) (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
              • Time.instLeReflDenominator = { le_refl := }
              Equations
              • f.neg = { val := -f.val }
              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                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 : Nat) (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 : Time.Fixed p) (dt2 : Time.Fixed p) :
                                Equations
                                • dt1.sub dt2 = { val := dt1.val - dt2.val }
                                Instances For
                                  def Time.Fixed.add {p : Nat} (dt1 : Time.Fixed p) (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 : Time.Fixed p) (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 : Time.Fixed p) (b : Time.Fixed p) :
                                    a + b = a.add b
                                    Equations
                                    Instances For
                                      def Time.Fixed.div {p : Nat} (dt1 : Time.Fixed p) (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 : Time.Fixed p) (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 : Time.Fixed p) (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 : Time.Fixed p) (b : Time.Fixed p) :
                                            a % b = a.mod b
                                            @[simp]
                                            theorem Time.Fixed.ofFixed_lt {p : Nat} {a : Time.Fixed p} {b : Time.Fixed p} :
                                            a < b a.val < b.val
                                            @[simp]
                                            theorem Time.Fixed.ofFixed_ne {p : Nat} {a : Time.Fixed p} {b : Time.Fixed p} :
                                            a b a.val b.val
                                            theorem Time.Fixed.ne_of_lt {p : Nat} {a : Time.Fixed p} {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 : Time.Fixed p) (b : Time.Fixed p) :
                                            a % b + a / b * b = a
                                            def Time.Fixed.toMod {p : Nat} (n : Time.Fixed p) (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 : Nat) (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 : Nat) (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