Documentation

Std.Tactic.Omega.IntList

@[inline, reducible]
abbrev IntList :

A type synonym for List Int, used by omega for dense representation of coefficients.

We define algebraic operations, interpreting List Int as a finitely supported function NatInt.

Equations
Instances For
    def IntList.get (xs : IntList) (i : Nat) :

    Get the i-th element (interpreted as 0 if the list is not long enough).

    Equations
    Instances For
      @[simp]
      theorem IntList.get_nil {i : Nat} :
      IntList.get [] i = 0
      @[simp]
      theorem IntList.get_cons_zero {x : Int} {xs : List Int} :
      IntList.get (x :: xs) 0 = x
      @[simp]
      theorem IntList.get_cons_succ {x : Int} {xs : List Int} {i : Nat} :
      IntList.get (x :: xs) (i + 1) = IntList.get xs i
      theorem IntList.get_map {f : IntInt} {i : Nat} {xs : IntList} (h : f 0 = 0) :
      IntList.get (List.map f xs) i = f (IntList.get xs i)
      theorem IntList.get_of_length_le {i : Nat} {xs : IntList} (h : List.length xs i) :
      IntList.get xs i = 0
      def IntList.set (xs : IntList) (i : Nat) (y : Int) :

      Like List.set, but right-pad with zeroes as necessary first.

      Equations
      Instances For
        @[simp]
        theorem IntList.set_nil_zero {y : Int} :
        IntList.set [] 0 y = [y]
        @[simp]
        theorem IntList.set_nil_succ {i : Nat} {y : Int} :
        IntList.set [] (i + 1) y = 0 :: IntList.set [] i y
        @[simp]
        theorem IntList.set_cons_zero {x : Int} {xs : List Int} {y : Int} :
        IntList.set (x :: xs) 0 y = y :: xs
        @[simp]
        theorem IntList.set_cons_succ {x : Int} {xs : List Int} {i : Nat} {y : Int} :
        IntList.set (x :: xs) (i + 1) y = x :: IntList.set xs i y
        theorem IntList.set_get_eq {xs : IntList} {i : Nat} {y : Int} {j : Nat} :
        IntList.get (IntList.set xs i y) j = if i = j then y else IntList.get xs j
        @[simp]
        theorem IntList.set_get_self {xs : IntList} {i : Nat} {y : Int} :
        @[simp]
        theorem IntList.set_get_of_ne {i : Nat} {j : Nat} {xs : IntList} {y : Int} (h : i j) :

        Returns the leading coefficient, i.e. the first non-zero entry.

        Equations
        Instances For
          def IntList.add (xs : IntList) (ys : IntList) :

          Implementation of + on IntList.

          Equations
          Instances For
            theorem IntList.add_def (xs : IntList) (ys : IntList) :
            xs + ys = List.zipWithAll (fun (x y : Option Int) => Option.getD x 0 + Option.getD y 0) xs ys
            @[simp]
            theorem IntList.add_get (xs : IntList) (ys : IntList) (i : Nat) :
            IntList.get (xs + ys) i = IntList.get xs i + IntList.get ys i
            @[simp]
            theorem IntList.add_nil (xs : IntList) :
            xs + [] = xs
            @[simp]
            theorem IntList.nil_add (xs : IntList) :
            [] + xs = xs
            @[simp]
            theorem IntList.cons_add_cons (x : Int) (xs : IntList) (y : Int) (ys : IntList) :
            x :: xs + y :: ys = (x + y) :: (xs + ys)
            def IntList.mul (xs : IntList) (ys : IntList) :

            Implementation of * on IntList.

            Equations
            Instances For
              theorem IntList.mul_def (xs : IntList) (ys : IntList) :
              xs * ys = List.zipWith (fun (x x_1 : Int) => x * x_1) xs ys
              @[simp]
              theorem IntList.mul_get (xs : IntList) (ys : IntList) (i : Nat) :
              IntList.get (xs * ys) i = IntList.get xs i * IntList.get ys i
              @[simp]
              theorem IntList.mul_nil_left {ys : List Int} :
              [] * ys = []
              @[simp]
              theorem IntList.mul_nil_right {xs : List Int} :
              xs * [] = []
              @[simp]
              theorem IntList.mul_cons₂ {x : Int} {xs : List Int} {y : Int} {ys : List Int} :
              (x :: xs) * (y :: ys) = x * y :: xs * ys

              Implementation of negation on IntList.

              Equations
              Instances For
                theorem IntList.neg_def (xs : IntList) :
                -xs = List.map (fun (x : Int) => -x) xs
                @[simp]
                theorem IntList.neg_get (xs : IntList) (i : Nat) :
                @[simp]
                theorem IntList.neg_nil :
                -[] = []
                @[simp]
                theorem IntList.neg_cons {x : Int} {xs : List Int} :
                -(x :: xs) = -x :: -xs
                def IntList.sub (xs : IntList) (ys : IntList) :

                Implementation of subtraction on IntList.

                Equations
                Instances For
                  theorem IntList.sub_def (xs : IntList) (ys : IntList) :
                  xs - ys = List.zipWithAll (fun (x y : Option Int) => Option.getD x 0 - Option.getD y 0) xs ys
                  def IntList.smul (xs : IntList) (i : Int) :

                  Implementation of scalar multiplication by an integer on IntList.

                  Equations
                  Instances For
                    theorem IntList.smul_def (xs : IntList) (i : Int) :
                    i * xs = List.map (fun (x : Int) => i * x) xs
                    @[simp]
                    theorem IntList.smul_get (xs : IntList) (a : Int) (i : Nat) :
                    IntList.get (a * xs) i = a * IntList.get xs i
                    @[simp]
                    theorem IntList.smul_nil {i : Int} :
                    i * [] = []
                    @[simp]
                    theorem IntList.smul_cons {x : Int} {xs : List Int} {i : Int} :
                    i * (x :: xs) = i * x :: i * xs
                    def IntList.combo (a : Int) (xs : IntList) (b : Int) (ys : IntList) :

                    A linear combination of two IntLists.

                    Equations
                    Instances For
                      theorem IntList.combo_def {a : Int} {b : Int} (xs : IntList) (ys : IntList) :
                      IntList.combo a xs b ys = List.zipWithAll (fun (x y : Option Int) => a * Option.getD x 0 + b * Option.getD y 0) xs ys
                      @[simp]
                      theorem IntList.combo_get {a : Int} {b : Int} (xs : IntList) (ys : IntList) (i : Nat) :
                      IntList.get (IntList.combo a xs b ys) i = a * IntList.get xs i + b * IntList.get ys i
                      theorem IntList.combo_eq_smul_add_smul (a : Int) (xs : IntList) (b : Int) (ys : IntList) :
                      IntList.combo a xs b ys = a * xs + b * ys
                      theorem IntList.mul_comm (xs : IntList) (ys : IntList) :
                      xs * ys = ys * xs
                      @[simp]
                      theorem IntList.neg_neg {xs : IntList} :
                      - -xs = xs
                      theorem IntList.mul_distrib_left (xs : IntList) (ys : IntList) (zs : IntList) :
                      (xs + ys) * zs = xs * zs + ys * zs
                      theorem IntList.mul_neg_left (xs : IntList) (ys : IntList) :
                      -xs * ys = -(xs * ys)
                      theorem IntList.sub_eq_add_neg (xs : IntList) (ys : IntList) :
                      xs - ys = xs + -ys
                      @[simp]
                      theorem IntList.sub_get (xs : IntList) (ys : IntList) (i : Nat) :
                      IntList.get (xs - ys) i = IntList.get xs i - IntList.get ys i
                      @[simp]
                      theorem IntList.mul_smul_left {i : Int} {xs : IntList} {ys : IntList} :
                      i * xs * ys = i * (xs * ys)
                      def IntList.sum (xs : IntList) :

                      The sum of the entries of an IntList.

                      Equations
                      Instances For
                        @[simp]
                        @[simp]
                        theorem IntList.sum_cons {x : Int} {xs : List Int} :
                        @[simp]
                        @[simp]
                        theorem IntList.sum_smul (i : Int) (xs : IntList) :
                        def IntList.dot (xs : IntList) (ys : IntList) :

                        The dot product of two IntLists.

                        Equations
                        Instances For
                          @[simp]
                          theorem IntList.dot_nil_right {xs : IntList} :
                          IntList.dot xs [] = 0
                          @[simp]
                          theorem IntList.dot_cons₂ {x : Int} {xs : List Int} {y : Int} {ys : List Int} :
                          IntList.dot (x :: xs) (y :: ys) = x * y + IntList.dot xs ys
                          theorem IntList.dot_comm (xs : IntList) (ys : IntList) :
                          @[simp]
                          theorem IntList.dot_set_left (xs : IntList) (ys : IntList) (i : Nat) (z : Int) :
                          IntList.dot (IntList.set xs i z) ys = IntList.dot xs ys + (z - IntList.get xs i) * IntList.get ys i
                          @[simp]
                          theorem IntList.dot_set_right (xs : IntList) (ys : IntList) (i : Nat) (z : Int) :
                          IntList.dot xs (IntList.set ys i z) = IntList.dot xs ys + IntList.get xs i * (z - IntList.get ys i)
                          theorem IntList.dot_distrib_left (xs : IntList) (ys : IntList) (zs : IntList) :
                          IntList.dot (xs + ys) zs = IntList.dot xs zs + IntList.dot ys zs
                          @[simp]
                          theorem IntList.dot_neg_left (xs : IntList) (ys : IntList) :
                          @[simp]
                          theorem IntList.dot_smul_left (xs : IntList) (ys : IntList) (i : Int) :
                          IntList.dot (i * xs) ys = i * IntList.dot xs ys
                          theorem IntList.dot_sub_left (xs : IntList) (ys : IntList) (zs : IntList) :
                          IntList.dot (xs - ys) zs = IntList.dot xs zs - IntList.dot ys zs
                          theorem IntList.dot_of_left_zero {xs : IntList} {ys : IntList} (w : ∀ (x : Int), x xsx = 0) :
                          IntList.dot xs ys = 0
                          theorem IntList.dvd_dot_of_dvd_left {xs : IntList} {m : Int} {ys : IntList} (w : ∀ (x : Int), x xsm x) :
                          def IntList.sdiv (xs : IntList) (g : Int) :

                          Division of an IntList by a integer.

                          Equations
                          Instances For
                            @[simp]
                            theorem IntList.sdiv_nil {g : Int} :
                            IntList.sdiv [] g = []
                            @[simp]
                            theorem IntList.sdiv_cons {x : Int} {xs : List Int} {g : Int} :
                            IntList.sdiv (x :: xs) g = x / g :: IntList.sdiv xs g
                            @[simp]
                            theorem IntList.sdiv_get {xs : IntList} {g : Int} {i : Nat} :
                            theorem IntList.mem_sdiv {x : Int} {g : Int} {xs : IntList} (h : x xs) :
                            x / g IntList.sdiv xs g
                            def IntList.gcd (xs : IntList) :

                            The gcd of the absolute values of the entries of an IntList.

                            Equations
                            Instances For
                              @[simp]
                              @[simp]
                              theorem IntList.gcd_cons {x : Int} {xs : List Int} :
                              theorem IntList.gcd_cons_div_left {x : Int} {xs : List Int} :
                              (IntList.gcd (x :: xs)) x
                              theorem IntList.gcd_cons_div_right' {x : Int} {xs : List Int} :
                              (IntList.gcd (x :: xs)) (IntList.gcd xs)
                              theorem IntList.gcd_dvd (xs : IntList) {a : Int} (m : a xs) :
                              (IntList.gcd xs) a
                              theorem IntList.dvd_gcd (xs : IntList) (c : Nat) (w : ∀ {a : Int}, a xsc a) :
                              theorem IntList.gcd_eq_iff (xs : IntList) (g : Nat) :
                              IntList.gcd xs = g (∀ {a : Int}, a xsg a) ∀ (c : Nat), (∀ {a : Int}, a xsc a)c g
                              @[simp]
                              theorem IntList.gcd_eq_zero (xs : IntList) :
                              IntList.gcd xs = 0 ∀ (x : Int), x xsx = 0
                              @[simp]
                              theorem IntList.dot_mod_gcd_left (xs : IntList) (ys : IntList) :
                              IntList.dot xs ys % (IntList.gcd xs) = 0
                              @[simp]
                              theorem IntList.dot_eq_zero_of_left_eq_zero {xs : IntList} {ys : IntList} (h : ∀ (x : Int), x xsx = 0) :
                              IntList.dot xs ys = 0
                              theorem IntList.dot_sdiv_left (xs : IntList) (ys : IntList) {d : Int} (h : d (IntList.gcd xs)) :
                              @[simp]

                              The leading sign in an IntList.

                              Equations
                              Instances For
                                theorem IntList.leadingSign_cons {x : Int} {xs : List Int} :
                                IntList.leadingSign (x :: xs) = if x = 0 then IntList.leadingSign xs else Int.sign x

                                Trim trailing zeroes from a List Int, returning none if none were removed.

                                Equations
                                Instances For

                                  Trailing trailing zeroes from a List Int.

                                  Equations
                                  Instances For
                                    @[simp]
                                    @[inline, reducible]
                                    abbrev IntList.bmod (x : IntList) (m : Nat) :

                                    Apply "balanced mod" to each entry in an IntList.

                                    Equations
                                    Instances For
                                      @[inline, reducible]

                                      The difference between the balanced mod of a dot product, and the dot product with balanced mod applied to each entry of the left factor.

                                      Equations
                                      Instances For