Get the i
-th element (interpreted as 0
if the list is not long enough).
Equations
- Lean.Omega.IntList.get xs i = Option.getD (List.get? xs i) 0
Instances For
@[simp]
theorem
Lean.Omega.IntList.get_cons_zero
{x : Int}
{xs : List Int}
:
Lean.Omega.IntList.get (x :: xs) 0 = x
@[simp]
theorem
Lean.Omega.IntList.get_cons_succ
{x : Int}
{xs : List Int}
{i : Nat}
:
Lean.Omega.IntList.get (x :: xs) (i + 1) = Lean.Omega.IntList.get xs i
theorem
Lean.Omega.IntList.get_map
{f : Int → Int}
{i : Nat}
{xs : Lean.Omega.IntList}
(h : f 0 = 0)
:
Lean.Omega.IntList.get (List.map f xs) i = f (Lean.Omega.IntList.get xs i)
theorem
Lean.Omega.IntList.get_of_length_le
{i : Nat}
{xs : Lean.Omega.IntList}
(h : List.length xs ≤ i)
:
Lean.Omega.IntList.get xs i = 0
Like List.set
, but right-pad with zeroes as necessary first.
Equations
- Lean.Omega.IntList.set [] 0 y = [y]
- Lean.Omega.IntList.set [] (Nat.succ i_2) y = 0 :: Lean.Omega.IntList.set [] i_2 y
- Lean.Omega.IntList.set (head :: xs_2) 0 y = y :: xs_2
- Lean.Omega.IntList.set (x :: xs_2) (Nat.succ i_2) y = x :: Lean.Omega.IntList.set xs_2 i_2 y
Instances For
@[simp]
@[simp]
theorem
Lean.Omega.IntList.set_nil_succ
{i : Nat}
{y : Int}
:
Lean.Omega.IntList.set [] (i + 1) y = 0 :: Lean.Omega.IntList.set [] i y
@[simp]
theorem
Lean.Omega.IntList.set_cons_zero
{x : Int}
{xs : List Int}
{y : Int}
:
Lean.Omega.IntList.set (x :: xs) 0 y = y :: xs
@[simp]
theorem
Lean.Omega.IntList.set_cons_succ
{x : Int}
{xs : List Int}
{i : Nat}
{y : Int}
:
Lean.Omega.IntList.set (x :: xs) (i + 1) y = x :: Lean.Omega.IntList.set xs i y
Returns the leading coefficient, i.e. the first non-zero entry.
Equations
- Lean.Omega.IntList.leading xs = Option.getD (List.find? (fun (x : Int) => !x == 0) xs) 0
Instances For
Implementation of +
on IntList
.
Equations
- Lean.Omega.IntList.add xs ys = List.zipWithAll (fun (x y : Option Int) => Option.getD x 0 + Option.getD y 0) xs ys
Instances For
Equations
theorem
Lean.Omega.IntList.add_def
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
:
xs + ys = List.zipWithAll (fun (x y : Option Int) => Option.getD x 0 + Option.getD y 0) xs ys
@[simp]
theorem
Lean.Omega.IntList.add_get
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
(i : Nat)
:
Lean.Omega.IntList.get (xs + ys) i = Lean.Omega.IntList.get xs i + Lean.Omega.IntList.get ys i
@[simp]
theorem
Lean.Omega.IntList.cons_add_cons
(x : Int)
(xs : Lean.Omega.IntList)
(y : Int)
(ys : Lean.Omega.IntList)
:
Implementation of *
on IntList
.
Equations
- Lean.Omega.IntList.mul xs ys = List.zipWith (fun (x x_1 : Int) => x * x_1) xs ys
Instances For
Equations
theorem
Lean.Omega.IntList.mul_def
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
:
xs * ys = List.zipWith (fun (x x_1 : Int) => x * x_1) xs ys
@[simp]
theorem
Lean.Omega.IntList.mul_get
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
(i : Nat)
:
Lean.Omega.IntList.get (xs * ys) i = Lean.Omega.IntList.get xs i * Lean.Omega.IntList.get ys i
Equations
@[simp]
theorem
Lean.Omega.IntList.neg_get
(xs : Lean.Omega.IntList)
(i : Nat)
:
Lean.Omega.IntList.get (-xs) i = -Lean.Omega.IntList.get xs i
Implementation of subtraction on IntList
.
Equations
- Lean.Omega.IntList.sub xs ys = List.zipWithAll (fun (x y : Option Int) => Option.getD x 0 - Option.getD y 0) xs ys
Instances For
Equations
theorem
Lean.Omega.IntList.sub_def
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
:
xs - ys = List.zipWithAll (fun (x y : Option Int) => Option.getD x 0 - Option.getD y 0) xs ys
Equations
- Lean.Omega.IntList.instHMulIntIntList = { hMul := fun (i : Int) (xs : Lean.Omega.IntList) => Lean.Omega.IntList.smul xs i }
@[simp]
theorem
Lean.Omega.IntList.smul_get
(xs : Lean.Omega.IntList)
(a : Int)
(i : Nat)
:
Lean.Omega.IntList.get (a * xs) i = a * Lean.Omega.IntList.get xs i
def
Lean.Omega.IntList.combo
(a : Int)
(xs : Lean.Omega.IntList)
(b : Int)
(ys : Lean.Omega.IntList)
:
A linear combination of two IntList
s.
Equations
- Lean.Omega.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
Instances For
theorem
Lean.Omega.IntList.combo_eq_smul_add_smul
(a : Int)
(xs : Lean.Omega.IntList)
(b : Int)
(ys : Lean.Omega.IntList)
:
Lean.Omega.IntList.combo a xs b ys = a * xs + b * ys
theorem
Lean.Omega.IntList.mul_distrib_left
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
(zs : Lean.Omega.IntList)
:
@[simp]
theorem
Lean.Omega.IntList.mul_smul_left
{i : Int}
{xs : Lean.Omega.IntList}
{ys : Lean.Omega.IntList}
:
The sum of the entries of an IntList
.
Equations
- Lean.Omega.IntList.sum xs = List.foldr (fun (x x_1 : Int) => x + x_1) 0 xs
Instances For
@[simp]
theorem
Lean.Omega.IntList.sum_cons
{x : Int}
{xs : List Int}
:
Lean.Omega.IntList.sum (x :: xs) = x + Lean.Omega.IntList.sum xs
theorem
Lean.Omega.IntList.sum_add
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
:
Lean.Omega.IntList.sum (xs + ys) = Lean.Omega.IntList.sum xs + Lean.Omega.IntList.sum ys
@[simp]
@[simp]
theorem
Lean.Omega.IntList.sum_smul
(i : Int)
(xs : Lean.Omega.IntList)
:
Lean.Omega.IntList.sum (i * xs) = i * Lean.Omega.IntList.sum xs
The dot product of two IntList
s.
Equations
- Lean.Omega.IntList.dot xs ys = Lean.Omega.IntList.sum (xs * ys)
Instances For
@[simp]
theorem
Lean.Omega.IntList.dot_nil_right
{xs : Lean.Omega.IntList}
:
Lean.Omega.IntList.dot xs [] = 0
@[simp]
theorem
Lean.Omega.IntList.dot_cons₂
{x : Int}
{xs : List Int}
{y : Int}
{ys : List Int}
:
Lean.Omega.IntList.dot (x :: xs) (y :: ys) = x * y + Lean.Omega.IntList.dot xs ys
@[simp]
theorem
Lean.Omega.IntList.dot_set_left
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
(i : Nat)
(z : Int)
:
Lean.Omega.IntList.dot (Lean.Omega.IntList.set xs i z) ys = Lean.Omega.IntList.dot xs ys + (z - Lean.Omega.IntList.get xs i) * Lean.Omega.IntList.get ys i
theorem
Lean.Omega.IntList.dot_distrib_left
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
(zs : Lean.Omega.IntList)
:
Lean.Omega.IntList.dot (xs + ys) zs = Lean.Omega.IntList.dot xs zs + Lean.Omega.IntList.dot ys zs
@[simp]
theorem
Lean.Omega.IntList.dot_neg_left
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
:
Lean.Omega.IntList.dot (-xs) ys = -Lean.Omega.IntList.dot xs ys
@[simp]
theorem
Lean.Omega.IntList.dot_smul_left
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
(i : Int)
:
Lean.Omega.IntList.dot (i * xs) ys = i * Lean.Omega.IntList.dot xs ys
theorem
Lean.Omega.IntList.dot_of_left_zero
{xs : Lean.Omega.IntList}
{ys : Lean.Omega.IntList}
(w : ∀ (x : Int), x ∈ xs → x = 0)
:
Lean.Omega.IntList.dot xs ys = 0
@[simp]
theorem
Lean.Omega.IntList.sdiv_cons
{x : Int}
{xs : List Int}
{g : Int}
:
Lean.Omega.IntList.sdiv (x :: xs) g = x / g :: Lean.Omega.IntList.sdiv xs g
The gcd of the absolute values of the entries of an IntList
.
Equations
- Lean.Omega.IntList.gcd xs = List.foldr (fun (x : Int) (g : Nat) => Nat.gcd (Int.natAbs x) g) 0 xs
Instances For
@[simp]
theorem
Lean.Omega.IntList.gcd_cons
{x : Int}
{xs : List Int}
:
Lean.Omega.IntList.gcd (x :: xs) = Nat.gcd (Int.natAbs x) (Lean.Omega.IntList.gcd xs)
theorem
Lean.Omega.IntList.gcd_cons_div_left
{x : Int}
{xs : List Int}
:
↑(Lean.Omega.IntList.gcd (x :: xs)) ∣ x
theorem
Lean.Omega.IntList.gcd_cons_div_right
{x : Int}
{xs : List Int}
:
Lean.Omega.IntList.gcd (x :: xs) ∣ Lean.Omega.IntList.gcd xs
theorem
Lean.Omega.IntList.gcd_cons_div_right'
{x : Int}
{xs : List Int}
:
↑(Lean.Omega.IntList.gcd (x :: xs)) ∣ ↑(Lean.Omega.IntList.gcd xs)
theorem
Lean.Omega.IntList.gcd_dvd
(xs : Lean.Omega.IntList)
{a : Int}
(m : a ∈ xs)
:
↑(Lean.Omega.IntList.gcd xs) ∣ a
theorem
Lean.Omega.IntList.dvd_gcd
(xs : Lean.Omega.IntList)
(c : Nat)
(w : ∀ {a : Int}, a ∈ xs → ↑c ∣ a)
:
c ∣ Lean.Omega.IntList.gcd xs
@[simp]
@[simp]
theorem
Lean.Omega.IntList.dot_mod_gcd_left
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
:
Lean.Omega.IntList.dot xs ys % ↑(Lean.Omega.IntList.gcd xs) = 0
theorem
Lean.Omega.IntList.gcd_dvd_dot_left
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
:
↑(Lean.Omega.IntList.gcd xs) ∣ Lean.Omega.IntList.dot xs ys
@[simp]
theorem
Lean.Omega.IntList.dot_eq_zero_of_left_eq_zero
{xs : Lean.Omega.IntList}
{ys : Lean.Omega.IntList}
(h : ∀ (x : Int), x ∈ xs → x = 0)
:
Lean.Omega.IntList.dot xs ys = 0
theorem
Lean.Omega.IntList.dot_sdiv_left
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
{d : Int}
(h : d ∣ ↑(Lean.Omega.IntList.gcd xs))
:
Lean.Omega.IntList.dot (Lean.Omega.IntList.sdiv xs d) ys = Lean.Omega.IntList.dot xs ys / d
@[inline, reducible]
abbrev
Lean.Omega.IntList.bmod_dot_sub_dot_bmod
(m : Nat)
(a : Lean.Omega.IntList)
(b : Lean.Omega.IntList)
:
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
theorem
Lean.Omega.IntList.dvd_bmod_dot_sub_dot_bmod
(m : Nat)
(xs : Lean.Omega.IntList)
(ys : Lean.Omega.IntList)
:
↑m ∣ Lean.Omega.IntList.bmod_dot_sub_dot_bmod m xs ys