GCD and LCM operations on finsets #
Main definitions #
Finset.gcd- the greatest common denominator of aFinsetof elements of aGCDMonoidFinset.lcm- the least common multiple of aFinsetof elements of aGCDMonoid
Implementation notes #
Many of the proofs use the lemmas gcd_def and lcm_def, which relate Finset.gcd
and Finset.lcm to Multiset.gcd and Multiset.lcm.
TODO: simplify with a tactic and Data.Finset.Lattice
Tags #
finset, gcd
lcm #
def Finset.lcm {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] (s : Finset β) (f : β → α) :
α
Least common multiple of a finite set
Equations
- s.lcm f = Finset.fold lcm 1 f s
Instances For
theorem Finset.lcm_def {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} :
@[simp]
theorem Finset.lcm_empty {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {f : β → α} :
@[simp]
theorem Finset.lcm_dvd_iff {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} {a : α} :
theorem Finset.lcm_dvd {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} {a : α} :
theorem Finset.dvd_lcm {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} {b : β} (hb : b ∈ s) :
@[simp]
theorem Finset.lcm_insert {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} [DecidableEq β] {b : β} :
@[simp]
theorem Finset.lcm_singleton {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {f : β → α} {b : β} :
theorem Finset.normalize_lcm {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} :
theorem Finset.lcm_union {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s₁ s₂ : Finset β} {f : β → α} [DecidableEq β] :
theorem Finset.lcm_congr {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s₁ s₂ : Finset β} {f g : β → α} (hs : s₁ = s₂) (hfg : ∀ a ∈ s₂, f a = g a) :
theorem Finset.lcm_mono_fun {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f g : β → α} (h : ∀ b ∈ s, f b ∣ g b) :
theorem Finset.lcm_mono {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s₁ s₂ : Finset β} {f : β → α} (h : s₁ ⊆ s₂) :
theorem Finset.lcm_image {α : Type u_2} {β : Type u_3} {γ : Type u_4} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {f : β → α} [DecidableEq β] {g : γ → β} (s : Finset γ) :
theorem Finset.lcm_eq_lcm_image {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} [DecidableEq α] :
@[simp]
theorem Finset.lcm_eq_zero_iff {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} [Nontrivial α] :
theorem Finset.lcm_ne_zero_iff {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} [Nontrivial α] :
gcd #
def Finset.gcd {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] (s : Finset β) (f : β → α) :
α
Greatest common divisor of a finite set
Equations
- s.gcd f = Finset.fold gcd 0 f s
Instances For
theorem Finset.gcd_def {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} :
@[simp]
theorem Finset.gcd_empty {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {f : β → α} :
theorem Finset.dvd_gcd_iff {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} {a : α} :
theorem Finset.gcd_dvd {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} {b : β} (hb : b ∈ s) :
theorem Finset.dvd_gcd {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} {a : α} :
theorem Finset.gcd_cons {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} {b : β} (h : b ∉ s) :
@[simp]
theorem Finset.gcd_insert {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} [DecidableEq β] {b : β} :
@[simp]
theorem Finset.gcd_singleton {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {f : β → α} {b : β} :
theorem Finset.normalize_gcd {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} :
theorem Finset.gcd_union {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s₁ s₂ : Finset β} {f : β → α} [DecidableEq β] :
theorem Finset.gcd_congr {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s₁ s₂ : Finset β} {f g : β → α} (hs : s₁ = s₂) (hfg : ∀ a ∈ s₂, f a = g a) :
theorem Finset.gcd_mono_fun {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f g : β → α} (h : ∀ b ∈ s, f b ∣ g b) :
theorem Finset.gcd_mono {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s₁ s₂ : Finset β} {f : β → α} (h : s₁ ⊆ s₂) :
theorem Finset.gcd_image {α : Type u_2} {β : Type u_3} {γ : Type u_4} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {f : β → α} [DecidableEq β] {g : γ → β} (s : Finset γ) :
theorem Finset.gcd_eq_gcd_image {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} [DecidableEq α] :
theorem Finset.gcd_eq_zero_iff {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} :
theorem Finset.gcd_ne_zero_iff {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} :
theorem Finset.gcd_eq_gcd_filter_ne_zero {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} {f : β → α} [DecidablePred fun (x : β) => f x = 0] :
theorem Finset.gcd_mul_left {β : Type u_3} {α : Type u_5} [CommMonoidWithZero α] [StrongNormalizedGCDMonoid α] {s : Finset β} {f : β → α} {a : α} :
theorem Finset.gcd_mul_right {β : Type u_3} {α : Type u_5} [CommMonoidWithZero α] [StrongNormalizedGCDMonoid α] {s : Finset β} {f : β → α} {a : α} :
theorem Finset.gcd_mul_left' {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] (s : Finset β) (f : β → α) (a : α) :
Associated (s.gcd fun (x : β) => a * f x) (a * s.gcd f)
theorem Finset.gcd_mul_right' {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] (s : Finset β) (f : β → α) (a : α) :
Associated (s.gcd fun (x : β) => f x * a) (s.gcd f * a)
theorem Finset.extract_gcd' {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} (f g : β → α) (hs : ∃ x ∈ s, f x ≠ 0) (hg : ∀ b ∈ s, f b = s.gcd f * g b) :
theorem Finset.extract_gcd {α : Type u_2} {β : Type u_3} [CommMonoidWithZero α] [NormalizedGCDMonoid α] {s : Finset β} (f : β → α) (hs : s.Nonempty) :
theorem Finset.gcd_div_eq_one {ι : Type u_1} {α : Type u_2} [CommMonoidWithZero α] [NormalizedGCDMonoid α] [Div α] [MulDivCancelClass α] {f : ι → α} {s : Finset ι} {i : ι} (his : i ∈ s) (hfi : f i ≠ 0) :
Given a nonempty Finset s and a function f from s to ℕ, if d = s.gcd,
then the gcd of (f i) / d is equal to 1.
theorem Finset.gcd_div_id_eq_one {α : Type u_2} [CommMonoidWithZero α] [NormalizedGCDMonoid α] [Div α] [MulDivCancelClass α] {s : Finset α} {a : α} (has : a ∈ s) (ha : a ≠ 0) :
theorem Finset.gcd_eq_of_dvd_sub {α : Type u_2} {β : Type u_3} [CommRing α] [NormalizedGCDMonoid α] {s : Finset β} {f g : β → α} {a : α} (h : ∀ x ∈ s, a ∣ f x - g x) :