Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(group_theory): move order_of into its own file; base costes on …
…left_coset
- Loading branch information
Showing
3 changed files
with
232 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/- | ||
Copyright (c) 2018 Johannes Hölzl. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Johannes Hölzl | ||
-/ | ||
import group_theory.coset | ||
open set function | ||
|
||
variables {α : Type*} {s : set α} {a a₁ a₂ b c: α} | ||
|
||
-- TODO this lemma isn't used anywhere in this file, and should be moved elsewhere. | ||
namespace finset | ||
open finset | ||
|
||
lemma mem_range_iff_mem_finset_range_of_mod_eq [decidable_eq α] {f : ℤ → α} {a : α} {n : ℕ} | ||
(hn : 0 < n) (h : ∀i, f (i % n) = f i) : | ||
a ∈ set.range f ↔ a ∈ (finset.range n).image (λi, f i) := | ||
suffices (∃i, f (i % n) = a) ↔ ∃i, i < n ∧ f ↑i = a, by simpa [h], | ||
have hn' : 0 < (n : ℤ), from int.coe_nat_lt.mpr hn, | ||
iff.intro | ||
(assume ⟨i, hi⟩, | ||
have 0 ≤ i % ↑n, from int.mod_nonneg _ (ne_of_gt hn'), | ||
⟨int.to_nat (i % n), | ||
by rw [←int.coe_nat_lt, int.to_nat_of_nonneg this]; exact ⟨int.mod_lt_of_pos i hn', hi⟩⟩) | ||
(assume ⟨i, hi, ha⟩, | ||
⟨i, by rw [int.mod_eq_of_lt (int.coe_zero_le _) (int.coe_nat_lt_coe_nat_of_lt hi), ha]⟩) | ||
|
||
end finset | ||
|
||
section order_of | ||
variables [group α] [fintype α] [decidable_eq α] | ||
|
||
lemma exists_gpow_eq_one (a : α) : ∃i≠0, a ^ (i:ℤ) = 1 := | ||
have ¬ injective (λi, a ^ i), | ||
from not_injective_int_fintype, | ||
let ⟨i, j, a_eq, ne⟩ := show ∃(i j : ℤ), a ^ i = a ^ j ∧ i ≠ j, | ||
by rw [injective] at this; simpa [classical.not_forall] in | ||
have a ^ (i - j) = 1, | ||
by simp [gpow_add, gpow_neg, a_eq], | ||
⟨i - j, sub_ne_zero.mpr ne, this⟩ | ||
|
||
lemma exists_pow_eq_one (a : α) : ∃i≠0, a ^ i = 1 := | ||
let ⟨i, hi, eq⟩ := exists_gpow_eq_one a in | ||
begin | ||
cases i, | ||
{ exact ⟨i, by simp [int.of_nat_eq_coe, *] at *, eq⟩ }, | ||
{ exact ⟨i + 1, dec_trivial, inv_eq_one.1 eq⟩ } | ||
end | ||
|
||
/-- `order_of a` is the order of the element `a`, i.e. the `n ≥ 1`, s.t. `a ^ n = 1` -/ | ||
def order_of (a : α) : ℕ := nat.find (exists_pow_eq_one a) | ||
|
||
lemma pow_order_of_eq_one (a : α) : a ^ order_of a = 1 := | ||
let ⟨h₁, h₂⟩ := nat.find_spec (exists_pow_eq_one a) in h₂ | ||
|
||
lemma order_of_ne_zero (a : α) : order_of a ≠ 0 := | ||
let ⟨h₁, h₂⟩ := nat.find_spec (exists_pow_eq_one a) in h₁ | ||
|
||
private lemma pow_injective_aux {n m : ℕ} (a : α) (h : n ≤ m) | ||
(hn : n < order_of a) (hm : m < order_of a) (eq : a ^ n = a ^ m) : n = m := | ||
decidable.by_contradiction $ assume ne : n ≠ m, | ||
have h₁ : m - n ≠ 0, by simp [nat.sub_eq_iff_eq_add h, ne.symm], | ||
have h₂ : a ^ (m - n) = 1, by simp [pow_sub _ h, eq], | ||
have le : order_of a ≤ m - n, from nat.find_min' (exists_pow_eq_one a) ⟨h₁, h₂⟩, | ||
have lt : m - n < order_of a, | ||
from (nat.sub_lt_left_iff_lt_add h).mpr $ nat.lt_add_left _ _ _ hm, | ||
lt_irrefl _ (lt_of_le_of_lt le lt) | ||
|
||
lemma pow_injective_of_lt_order_of {n m : ℕ} (a : α) | ||
(hn : n < order_of a) (hm : m < order_of a) (eq : a ^ n = a ^ m) : n = m := | ||
(le_total n m).elim | ||
(assume h, pow_injective_aux a h hn hm eq) | ||
(assume h, (pow_injective_aux a h hm hn eq.symm).symm) | ||
|
||
lemma order_of_le_card_univ : order_of a ≤ fintype.card α := | ||
finset.card_le_of_inj_on ((^) a) | ||
(assume n _, fintype.complete _) | ||
(assume i j, pow_injective_of_lt_order_of a) | ||
|
||
lemma pow_eq_mod_order_of {n : ℕ} : a ^ n = a ^ (n % order_of a) := | ||
calc a ^ n = a ^ (n % order_of a + order_of a * (n / order_of a)) : | ||
by rw [nat.mod_add_div] | ||
... = a ^ (n % order_of a) : | ||
by simp [pow_add, pow_mul, pow_order_of_eq_one] | ||
|
||
lemma gpow_eq_mod_order_of {i : ℤ} : a ^ i = a ^ (i % order_of a) := | ||
calc a ^ i = a ^ (i % order_of a + order_of a * (i / order_of a)) : | ||
by rw [int.mod_add_div] | ||
... = a ^ (i % order_of a) : | ||
by simp [gpow_add, gpow_mul, pow_order_of_eq_one] | ||
|
||
lemma mem_range_gpow_iff_mem_range_order_of {a a' : α} : | ||
a' ∈ range ((^) a : ℤ → α) ↔ a' ∈ (finset.range (order_of a)).image ((^) a : ℕ → α) := | ||
finset.mem_range_iff_mem_finset_range_of_mod_eq | ||
(nat.pos_iff_ne_zero.mpr (order_of_ne_zero a)) | ||
(assume i, gpow_eq_mod_order_of.symm) | ||
|
||
instance decidable_range_gpow : decidable_pred (range ((^) a : ℤ → α)) := | ||
assume a', decidable_of_iff' | ||
(a' ∈ (finset.range (order_of a)).image ((^) a)) | ||
mem_range_gpow_iff_mem_range_order_of | ||
|
||
section | ||
local attribute [instance] set_fintype | ||
|
||
lemma order_eq_card_range_gpow : order_of a = fintype.card (range ((^) a : ℤ → α)) := | ||
begin | ||
refine (finset.card_eq_of_bijective _ _ _ _).symm, | ||
{ exact λn hn, ⟨gpow a n, mem_range_self n⟩ }, | ||
{ exact assume ⟨_, i, rfl⟩ _, | ||
have pos: (0:int) < order_of a, | ||
from int.coe_nat_lt.mpr $ nat.pos_iff_ne_zero.mpr $ order_of_ne_zero a, | ||
have 0 ≤ i % (order_of a), | ||
from int.mod_nonneg _ $ ne_of_gt pos, | ||
⟨int.to_nat (i % order_of a), | ||
by rw [← int.coe_nat_lt, int.to_nat_of_nonneg this]; | ||
exact ⟨int.mod_lt_of_pos _ pos, subtype.eq gpow_eq_mod_order_of.symm⟩⟩ }, | ||
{ intros, exact finset.mem_univ _ }, | ||
{ exact assume i j hi hj eq, pow_injective_of_lt_order_of a hi hj $ by simpa using eq } | ||
end | ||
|
||
section classical | ||
local attribute [instance] classical.prop_decidable | ||
|
||
/- TODO: use cardinal theory, introduce `card : set α → ℕ`, or setup decidability for cosets -/ | ||
lemma order_of_dvd_card_univ : order_of a ∣ fintype.card α := | ||
let ⟨equiv⟩ := (gpowers.is_subgroup a).group_equiv_left_cosets_times_subgroup in | ||
have ft_prod : fintype (left_cosets (gpowers a) × (gpowers a)), | ||
from fintype.of_equiv α equiv, | ||
have ft_s : fintype (gpowers a), | ||
from @fintype.fintype_prod_right _ _ _ ft_prod | ||
⟨⟨(gpowers a), @is_subgroup.subgroup_mem_left_cosets α _ _ (gpowers.is_subgroup a)⟩⟩, | ||
have ft_cosets : fintype (left_cosets (gpowers a)), | ||
from @fintype.fintype_prod_left _ _ _ ft_prod ⟨⟨1, is_submonoid.one_mem (gpowers a)⟩⟩, | ||
have ft : fintype (left_cosets (gpowers a) × (gpowers a)), | ||
from @prod.fintype _ _ ft_cosets ft_s, | ||
have eq₁ : fintype.card α = @fintype.card _ ft_cosets * @fintype.card _ ft_s, | ||
from calc fintype.card α = @fintype.card _ ft_prod : | ||
(@fintype.card_eq _ _ _ ft_prod).2 (gpowers.is_subgroup a).group_equiv_left_cosets_times_subgroup | ||
... = @fintype.card _ (@prod.fintype _ _ ft_cosets ft_s) : | ||
congr_arg (@fintype.card _) $ subsingleton.elim _ _ | ||
... = @fintype.card _ ft_cosets * @fintype.card _ ft_s : | ||
@fintype.card_prod _ _ ft_cosets ft_s, | ||
have eq₂ : order_of a = @fintype.card _ ft_s, | ||
from calc order_of a = _ : order_eq_card_range_gpow | ||
... = _ : congr_arg (@fintype.card _) $ subsingleton.elim _ _, | ||
dvd.intro (@fintype.card (left_cosets (gpowers a)) ft_cosets) $ | ||
by rw [eq₁, eq₂, mul_comm] | ||
|
||
end classical | ||
|
||
end | ||
|
||
end order_of |
Oops, something went wrong.