blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 139 | content_id stringlengths 40 40 | detected_licenses listlengths 0 16 | license_type stringclasses 2
values | repo_name stringlengths 7 55 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 6
values | visit_date int64 1,471B 1,694B | revision_date int64 1,378B 1,694B | committer_date int64 1,378B 1,694B | github_id float64 1.33M 604M ⌀ | star_events_count int64 0 43.5k | fork_events_count int64 0 1.5k | gha_license_id stringclasses 6
values | gha_event_created_at int64 1,402B 1,695B ⌀ | gha_created_at int64 1,359B 1,637B ⌀ | gha_language stringclasses 19
values | src_encoding stringclasses 2
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 1
class | length_bytes int64 3 6.4M | extension stringclasses 4
values | content stringlengths 3 6.12M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b032bbf4d0153515fa1724f3227c8fd525997d99 | e030b0259b777fedcdf73dd966f3f1556d392178 | /library/init/meta/converter.lean | 997180c75e84276d746de4279c1c60c0397bf137 | [
"Apache-2.0"
] | permissive | fgdorais/lean | 17b46a095b70b21fa0790ce74876658dc5faca06 | c3b7c54d7cca7aaa25328f0a5660b6b75fe26055 | refs/heads/master | 1,611,523,590,686 | 1,484,412,902,000 | 1,484,412,902,000 | 38,489,734 | 0 | 0 | null | 1,435,923,380,000 | 1,435,923,379,000 | null | UTF-8 | Lean | false | false | 9,102 | lean | /-
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
Converter monad for building simplifiers.
-/
prelude
import init.meta.tactic init.meta.simp_tactic
import init.meta.congr_lemma init.meta.match_tactic
open tactic
meta structure conv_result (α : Type) :=
(val : α) (rhs : expr) (proof : option expr)
meta def conv (α : Type) : Type :=
name → expr → tactic (conv_result α)
namespace conv
meta def lhs : conv expr :=
λ r e, return ⟨e, e, none⟩
meta def change (new_p : pexpr) : conv unit :=
λ r e, do
new_e ← to_expr new_p,
unify e new_e,
return ⟨(), new_e, none⟩
protected meta def pure {α : Type} : α → conv α :=
λ a r e, return ⟨a, e, none⟩
private meta def join_proofs (r : name) (o₁ o₂ : option expr) : tactic (option expr) :=
match o₁, o₂ with
| none, _ := return o₂
| _, none := return o₁
| some p₁, some p₂ := do
env ← get_env,
match (environment.trans_for env r) with
| (some trans) := do pr ← mk_app trans [p₁, p₂], return $ some pr
| none := fail $ "converter failed, relation '" ++ r^.to_string ++ "' is not transitive"
end
end
protected meta def seq {α β : Type} (c₁ : conv (α → β)) (c₂ : conv α) : conv β :=
λ r e, do
⟨fn, e₁, pr₁⟩ ← c₁ r e,
⟨a, e₂, pr₂⟩ ← c₂ r e₁,
pr ← join_proofs r pr₁ pr₂,
return ⟨fn a, e₂, pr⟩
protected meta def fail {α : Type} : conv α :=
λ r e, failed
protected meta def orelse {α : Type} (c₁ : conv α) (c₂ : conv α) : conv α :=
λ r e, c₁ r e <|> c₂ r e
protected meta def map {α β : Type} (f : α → β) (c : conv α) : conv β :=
λ r e, do
⟨a, e₁, pr⟩ ← c r e,
return ⟨f a, e₁, pr⟩
protected meta def bind {α β : Type} (c₁ : conv α) (c₂ : α → conv β) : conv β :=
λ r e, do
⟨a, e₁, pr₁⟩ ← c₁ r e,
⟨b, e₂, pr₂⟩ ← c₂ a r e₁,
pr ← join_proofs r pr₁ pr₂,
return ⟨b, e₂, pr⟩
meta instance : monad conv :=
{ map := @conv.map,
ret := @conv.pure,
bind := @conv.bind }
meta instance : alternative conv :=
{ map := @conv.map,
pure := @conv.pure,
seq := @conv.seq,
failure := @conv.fail,
orelse := @conv.orelse }
meta def whnf_core (m : transparency) : conv unit :=
λ r e, do n ← whnf_core m e, return ⟨(), n, none⟩
meta def whnf : conv unit :=
conv.whnf_core reducible
meta def dsimp : conv unit :=
λ r e, do s ← simp_lemmas.mk_default, n ← s^.dsimplify e, return ⟨(), n, none⟩
meta def try (c : conv unit) : conv unit :=
c <|> return ()
meta def tryb (c : conv unit) : conv bool :=
(c >> return tt) <|> return ff
meta def trace {α : Type} [has_to_tactic_format α] (a : α) : conv unit :=
λ r e, tactic.trace a >> return ⟨(), e, none⟩
meta def trace_lhs : conv unit :=
lhs >>= trace
meta def apply_lemmas_core (s : simp_lemmas) (prove : tactic unit) : conv unit :=
λ r e, do
(new_e, pr) ← s^.rewrite prove r e,
return ⟨(), new_e, some pr⟩
meta def apply_lemmas (s : simp_lemmas) : conv unit :=
apply_lemmas_core s failed
/- αdapter for using iff-lemmas as eq-lemmas -/
meta def apply_propext_lemmas_core (s : simp_lemmas) (prove : tactic unit) : conv unit :=
λ r e, do
guard (r = `eq),
(new_e, pr) ← s^.rewrite prove `iff e,
new_pr ← mk_app `propext [pr],
return ⟨(), new_e, some new_pr⟩
meta def apply_propext_lemmas (s : simp_lemmas) : conv unit :=
apply_propext_lemmas_core s failed
private meta def mk_refl_proof (r : name) (e : expr) : tactic expr :=
do env ← get_env,
match (environment.refl_for env r) with
| (some refl) := do pr ← mk_app refl [e], return pr
| none := fail $ "converter failed, relation '" ++ r^.to_string ++ "' is not reflexive"
end
meta def to_tactic (c : conv unit) : name → expr → tactic (expr × expr) :=
λ r e, do
⟨u, e₁, o⟩ ← c r e,
match o with
| none := do p ← mk_refl_proof r e, return (e₁, p)
| some p := return (e₁, p)
end
meta def lift_tactic {α : Type} (t : tactic α) : conv α :=
λ r e, do a ← t, return ⟨a, e, none⟩
meta def apply_simp_set (attr_name : name) : conv unit :=
lift_tactic (get_user_simp_lemmas attr_name) >>= apply_lemmas
meta def apply_propext_simp_set (attr_name : name) : conv unit :=
lift_tactic (get_user_simp_lemmas attr_name) >>= apply_propext_lemmas
meta def skip : conv unit :=
return ()
meta def repeat : conv unit → conv unit
| c r lhs :=
(do
⟨_, rhs₁, pr₁⟩ ← c r lhs,
guard (¬ lhs =ₐ rhs₁),
⟨_, rhs₂, pr₂⟩ ← repeat c r rhs₁,
pr ← join_proofs r pr₁ pr₂,
return ⟨(), rhs₂, pr⟩)
<|> return ⟨(), lhs, none⟩
meta def first {α : Type} : list (conv α) → conv α
| [] := conv.fail
| (c::cs) := c <|> first cs
meta def match_pattern (p : pattern) : conv unit :=
λ r e, tactic.match_pattern p e >> return ⟨(), e, none⟩
meta def mk_match_expr (p : pexpr) : tactic (conv unit) :=
do new_p ← pexpr_to_pattern p,
return (λ r e, tactic.match_pattern new_p e >> return ⟨(), e, none⟩)
meta def match_expr (p : pexpr) : conv unit :=
λ r e, do
new_p ← pexpr_to_pattern p,
tactic.match_pattern new_p e >> return ⟨(), e, none⟩
meta def funext (c : conv unit) : conv unit :=
λ r lhs, do
guard (r = `eq),
(expr.lam n bi d b) ← return lhs | failed,
aux_type ← return $ (expr.pi n bi d (expr.const `true [])),
(result, _) ← solve_aux aux_type $ do {
x ← intro1,
c_result ← c r (b^.instantiate_var x),
rhs ← return $ expr.lam n bi d (c_result^.rhs^.abstract x),
match c_result^.proof : _ → tactic (conv_result unit) with
| some pr := do
aux_pr ← return $ expr.lam n bi d (pr^.abstract x),
new_pr ← mk_app `funext [lhs, rhs, aux_pr],
return ⟨(), rhs, some new_pr⟩
| none := return ⟨(), rhs, none⟩
end },
return result
meta def congr_core (c_f c_a : conv unit) : conv unit :=
λ r lhs, do
guard (r = `eq),
(expr.app f a) ← return lhs | failed,
f_type ← infer_type f >>= tactic.whnf,
guard (f_type^.is_arrow),
⟨(), new_f, of⟩ ← try c_f r f,
⟨(), new_a, oa⟩ ← try c_a r a,
rhs ← return $ new_f new_a,
match of, oa with
| none, none :=
return ⟨(), rhs, none⟩
| none, some pr_a := do
pr ← mk_app `congr_arg [a, new_a, f, pr_a],
return ⟨(), new_f new_a, some pr⟩
| some pr_f, none := do
pr ← mk_app `congr_fun [f, new_f, pr_f, a],
return ⟨(), rhs, some pr⟩
| some pr_f, some pr_a := do
pr ← mk_app `congr [f, new_f, a, new_a, pr_f, pr_a],
return ⟨(), rhs, some pr⟩
end
meta def congr (c : conv unit) : conv unit :=
congr_core c c
meta def bottom_up (c : conv unit) : conv unit :=
λ r e, do
s ← simp_lemmas.mk_default,
(a, new_e, pr) ←
ext_simplify_core () default_simplify_config s
(λ u, return u)
(λ a s r p e, failed)
(λ a s r p e, do ⟨u, new_e, pr⟩ ← c r e, return ((), new_e, pr, tt))
r e,
return ⟨(), new_e, some pr⟩
meta def top_down (c : conv unit) : conv unit :=
λ r e, do
s ← simp_lemmas.mk_default,
(a, new_e, pr) ←
ext_simplify_core () default_simplify_config s
(λ u, return u)
(λ a s r p e, do ⟨u, new_e, pr⟩ ← c r e, return ((), new_e, pr, tt))
(λ a s r p e, failed)
r e,
return ⟨(), new_e, some pr⟩
meta def find (c : conv unit) : conv unit :=
λ r e, do
s ← simp_lemmas.mk_default,
(a, new_e, pr) ←
ext_simplify_core () default_simplify_config s
(λ u, return u)
(λ a s r p e,
(do ⟨u, new_e, pr⟩ ← c r e, return ((), new_e, pr, ff))
<|>
return ((), e, none, tt))
(λ a s r p e, failed)
r e,
return ⟨(), new_e, some pr⟩
meta def find_pattern (pat : pattern) (c : conv unit) : conv unit :=
λ r e, do
s ← simp_lemmas.mk_default,
(a, new_e, pr) ←
ext_simplify_core () default_simplify_config s
(λ u, return u)
(λ a s r p e, do
matched ← (tactic.match_pattern pat e >> return tt) <|> return ff,
if matched
then do ⟨u, new_e, pr⟩ ← c r e, return ((), new_e, pr, ff)
else return ((), e, none, tt))
(λ a s r p e, failed)
r e,
return ⟨(), new_e, some pr⟩
meta def findp : pexpr → conv unit → conv unit :=
λ p c r e, do
pat ← pexpr_to_pattern p,
find_pattern pat c r e
meta def conversion (c : conv unit) : tactic unit :=
do (r, lhs, rhs) ← (target_lhs_rhs <|> fail "conversion failed, target is not of the form 'lhs R rhs'"),
(new_lhs, pr) ← to_tactic c r lhs,
(unify new_lhs rhs <|>
do new_lhs_fmt ← pp new_lhs,
rhs_fmt ← pp rhs,
fail (to_fmt "conversion failed, expected" ++
rhs_fmt^.indent 4 ++ format.line ++ "provided" ++
new_lhs_fmt^.indent 4)),
exact pr
end conv
|
37c63a5b495471ed95b32259cf5286de770ac013 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/group_theory/nielsen_schreier.lean | b80da04143b0d6a85d4d2da568cd73ecce021f94 | [
"Apache-2.0"
] | permissive | Vierkantor/mathlib | 0ea59ac32a3a43c93c44d70f441c4ee810ccceca | 83bc3b9ce9b13910b57bda6b56222495ebd31c2f | refs/heads/master | 1,658,323,012,449 | 1,652,256,003,000 | 1,652,256,003,000 | 209,296,341 | 0 | 1 | Apache-2.0 | 1,568,807,655,000 | 1,568,807,655,000 | null | UTF-8 | Lean | false | false | 12,088 | lean | /-
Copyright (c) 2021 David Wärn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Wärn
-/
import category_theory.action
import combinatorics.quiver.arborescence
import combinatorics.quiver.connected_component
import group_theory.is_free_group
/-!
# The Nielsen-Schreier theorem
This file proves that a subgroup of a free group is itself free.
## Main result
- `subgroup_is_free_of_is_free H`: an instance saying that a subgroup of a free group is free.
## Proof overview
The proof is analogous to the proof using covering spaces and fundamental groups of graphs,
but we work directly with groupoids instead of topological spaces. Under this analogy,
- `is_free_groupoid G` corresponds to saying that a space is a graph.
- `End_mul_equiv_subgroup H` plays the role of replacing 'subgroup of fundamental group' with
'fundamental group of covering space'.
- `action_groupoid_is_free G A` corresponds to the fact that a covering of a (single-vertex)
graph is a graph.
- `End_is_free T` corresponds to the fact that, given a spanning tree `T` of a
graph, its fundamental group is free (generated by loops from the complement of the tree).
## Implementation notes
Our definition of `is_free_groupoid` is nonstandard. Normally one would require that functors
`G ⥤ X` to any _groupoid_ `X` are given by graph homomorphisms from the generators, but we only
consider _groups_ `X`. This simplifies the argument since functor equality is complicated in
general, but simple for functors to single object categories.
## References
https://ncatlab.org/nlab/show/Nielsen-Schreier+theorem
## Tags
free group, free groupoid, Nielsen-Schreier
-/
noncomputable theory
open_locale classical
universes v u
open category_theory category_theory.action_category category_theory.single_obj quiver
is_free_group as fgp
/-- `is_free_groupoid.generators G` is a type synonym for `G`. We think of this as
the vertices of the generating quiver of `G` when `G` is free. We can't use `G` directly,
since `G` already has a quiver instance from being a groupoid. -/
@[nolint unused_arguments has_inhabited_instance]
def is_free_groupoid.generators (G) [groupoid G] := G
/-- A groupoid `G` is free when we have the following data:
- a quiver on `is_free_groupoid.generators G` (a type synonym for `G`)
- a function `of` taking a generating arrow to a morphism in `G`
- such that a functor from `G` to any group `X` is uniquely determined
by assigning labels in `X` to the generating arrows.
This definition is nonstandard. Normally one would require that functors `G ⥤ X`
to any _groupoid_ `X` are given by graph homomorphisms from `generators`. -/
class is_free_groupoid (G) [groupoid.{v} G] :=
(quiver_generators : quiver.{v+1} (is_free_groupoid.generators G))
(of : Π {a b : is_free_groupoid.generators G}, (a ⟶ b) → ((show G, from a) ⟶ b))
(unique_lift : ∀ {X : Type v} [group X] (f : labelling (is_free_groupoid.generators G) X),
∃! F : G ⥤ single_obj X, ∀ a b (g : a ⟶ b),
F.map (of g) = f g)
namespace is_free_groupoid
attribute [instance] quiver_generators
/-- Two functors from a free groupoid to a group are equal when they agree on the generating
quiver. -/
@[ext]
lemma ext_functor {G} [groupoid.{v} G] [is_free_groupoid G] {X : Type v} [group X]
(f g : G ⥤ single_obj X)
(h : ∀ a b (e : a ⟶ b), f.map (of e) = g.map (of e)) :
f = g :=
let ⟨_, _, u⟩ := @unique_lift G _ _ X _ (λ (a b : generators G) (e : a ⟶ b), g.map (of e)) in
trans (u _ h) (u _ (λ _ _ _, rfl)).symm
/-- An action groupoid over a free froup is free. More generally, one could show that the groupoid
of elements over a free groupoid is free, but this version is easier to prove and suffices for our
purposes.
Analogous to the fact that a covering space of a graph is a graph. (A free groupoid is like a graph,
and a groupoid of elements is like a covering space.) -/
instance action_groupoid_is_free {G A : Type u} [group G] [is_free_group G] [mul_action G A] :
is_free_groupoid (action_category G A) :=
{ quiver_generators := ⟨λ a b, { e : fgp.generators G // fgp.of e • a.back = b.back }⟩,
of := λ a b e, ⟨fgp.of e, e.property⟩,
unique_lift := begin
introsI X _ f,
let f' : fgp.generators G → (A → X) ⋊[mul_aut_arrow] G :=
λ e, ⟨λ b, @f ⟨(), _⟩ ⟨(), b⟩ ⟨e, smul_inv_smul _ b⟩, fgp.of e⟩,
rcases fgp.unique_lift f' with ⟨F', hF', uF'⟩,
refine ⟨uncurry F' _, _, _⟩,
{ suffices : semidirect_product.right_hom.comp F' = monoid_hom.id _,
{ exact monoid_hom.ext_iff.mp this },
ext,
rw [monoid_hom.comp_apply, hF'],
refl },
{ rintros ⟨⟨⟩, a : A⟩ ⟨⟨⟩, b⟩ ⟨e, h : fgp.of e • a = b⟩,
change (F' (fgp.of _)).left _ = _,
rw hF',
cases (inv_smul_eq_iff.mpr h.symm),
refl },
{ intros E hE,
have : curry E = F',
{ apply uF',
intro e,
ext,
{ convert hE _ _ _, refl },
{ refl } },
apply functor.hext,
{ intro, apply unit.ext },
{ refine action_category.cases _, intros,
simp only [←this, uncurry_map, curry_apply_left, coe_back, hom_of_pair.val] } },
end }
namespace spanning_tree
/- In this section, we suppose we have a free groupoid with a spanning tree for its generating
quiver. The goal is to prove that the vertex group at the root is free. A picture to have in mind
is that we are 'pulling' the endpoints of all the edges of the quiver along the spanning tree to
the root. -/
variables {G : Type u} [groupoid.{u} G] [is_free_groupoid G]
(T : wide_subquiver (symmetrify $ generators G)) [arborescence T]
/-- The root of `T`, except its type is `G` instead of the type synonym `T`. -/
private def root' : G := show T, from root T
/-- A path in the tree gives a hom, by composition. -/
-- this has to be marked noncomputable, see issue #451.
-- It might be nicer to define this in terms of `compose_path`
noncomputable def hom_of_path : Π {a : G}, path (root T) a → (root' T ⟶ a)
| _ path.nil := 𝟙 _
| a (path.cons p f) := hom_of_path p ≫ sum.rec_on f.val (λ e, of e) (λ e, inv (of e))
/-- For every vertex `a`, there is a canonical hom from the root, given by the path in the tree. -/
def tree_hom (a : G) : root' T ⟶ a := hom_of_path T default
/-- Any path to `a` gives `tree_hom T a`, since paths in the tree are unique. -/
lemma tree_hom_eq {a : G} (p : path (root T) a) : tree_hom T a = hom_of_path T p :=
by rw [tree_hom, unique.default_eq]
@[simp] lemma tree_hom_root : tree_hom T (root' T) = 𝟙 _ :=
-- this should just be `tree_hom_eq T path.nil`, but Lean treats `hom_of_path` with suspicion.
trans (tree_hom_eq T path.nil) rfl
/-- Any hom in `G` can be made into a loop, by conjugating with `tree_hom`s. -/
def loop_of_hom {a b : G} (p : a ⟶ b) : End (root' T) :=
tree_hom T a ≫ p ≫ inv (tree_hom T b)
/-- Turning an edge in the spanning tree into a loop gives the indentity loop. -/
lemma loop_of_hom_eq_id {a b : generators G} (e ∈ wide_subquiver_symmetrify T a b) :
loop_of_hom T (of e) = 𝟙 (root' T) :=
begin
rw [loop_of_hom, ←category.assoc, is_iso.comp_inv_eq, category.id_comp],
cases H,
{ rw [tree_hom_eq T (path.cons default ⟨sum.inl e, H⟩), hom_of_path], refl },
{ rw [tree_hom_eq T (path.cons default ⟨sum.inr e, H⟩), hom_of_path],
simp only [is_iso.inv_hom_id, category.comp_id, category.assoc, tree_hom] }
end
/-- Since a hom gives a loop, any homomorphism from the vertex group at the root
extends to a functor on the whole groupoid. -/
@[simps] def functor_of_monoid_hom {X} [monoid X] (f : End (root' T) →* X) :
G ⥤ single_obj X :=
{ obj := λ _, (),
map := λ a b p, f (loop_of_hom T p),
map_id' := begin
intro a,
rw [loop_of_hom, category.id_comp, is_iso.hom_inv_id, ←End.one_def, f.map_one, id_as_one],
end,
map_comp' := begin
intros,
rw [comp_as_mul, ←f.map_mul],
simp only [is_iso.inv_hom_id_assoc, loop_of_hom, End.mul_def, category.assoc]
end }
/-- Given a free groupoid and an arborescence of its generating quiver, the vertex
group at the root is freely generated by loops coming from generating arrows
in the complement of the tree. -/
def End_is_free : is_free_group (End (root' T)) := is_free_group.of_unique_lift
(set.compl (wide_subquiver_equiv_set_total $ wide_subquiver_symmetrify T))
(λ e, loop_of_hom T (of e.val.hom))
begin
introsI X _ f,
let f' : labelling (generators G) X := λ a b e,
if h : e ∈ wide_subquiver_symmetrify T a b then 1
else f ⟨⟨a, b, e⟩, h⟩,
rcases unique_lift f' with ⟨F', hF', uF'⟩,
refine ⟨F'.map_End _, _, _⟩,
{ suffices : ∀ {x y} (q : x ⟶ y), F'.map (loop_of_hom T q) = (F'.map q : X),
{ rintro ⟨⟨a, b, e⟩, h⟩,
rw [functor.map_End_apply, this, hF'],
exact dif_neg h },
intros,
suffices : ∀ {a} (p : path (root' T) a), F'.map (hom_of_path T p) = 1,
{ simp only [this, tree_hom, comp_as_mul, inv_as_inv, loop_of_hom,
inv_one, mul_one, one_mul, functor.map_inv, functor.map_comp] },
intros a p, induction p with b c p e ih,
{ rw [hom_of_path, F'.map_id, id_as_one] },
rw [hom_of_path, F'.map_comp, comp_as_mul, ih, mul_one],
rcases e with ⟨e | e, eT⟩,
{ rw hF', exact dif_pos (or.inl eT) },
{ rw [F'.map_inv, inv_as_inv, inv_eq_one, hF'], exact dif_pos (or.inr eT) } },
{ intros E hE,
ext,
suffices : (functor_of_monoid_hom T E).map x = F'.map x,
{ simpa only [loop_of_hom, functor_of_monoid_hom_map, is_iso.inv_id, tree_hom_root,
category.id_comp, category.comp_id] using this },
congr,
apply uF',
intros a b e,
change E (loop_of_hom T _) = dite _ _ _,
split_ifs,
{ rw [loop_of_hom_eq_id T e h, ←End.one_def, E.map_one] },
{ exact hE ⟨⟨a, b, e⟩, h⟩ } }
end
end spanning_tree
/-- Another name for the identity function `G → G`, to help type checking. -/
private def symgen {G : Type u} [groupoid.{v} G] [is_free_groupoid G] :
G → symmetrify (generators G) := id
/-- If there exists a morphism `a → b` in a free groupoid, then there also exists a zigzag
from `a` to `b` in the generating quiver. -/
lemma path_nonempty_of_hom {G} [groupoid.{u u} G] [is_free_groupoid G] {a b : G} :
nonempty (a ⟶ b) → nonempty (path (symgen a) (symgen b)) :=
begin
rintro ⟨p⟩,
rw [←@weakly_connected_component.eq (generators G), eq_comm,
←free_group.of_injective.eq_iff, ←mul_inv_eq_one],
let X := free_group (weakly_connected_component $ generators G),
let f : G → X := λ g, free_group.of (weakly_connected_component.mk g),
let F : G ⥤ single_obj X := single_obj.difference_functor f,
change F.map p = ((category_theory.functor.const G).obj ()).map p,
congr, ext,
rw [functor.const.obj_map, id_as_one, difference_functor_map, mul_inv_eq_one],
apply congr_arg free_group.of,
apply (weakly_connected_component.eq _ _).mpr,
exact ⟨hom.to_path (sum.inr e)⟩,
end
/-- Given a connected free groupoid, its generating quiver is rooted-connected. -/
instance generators_connected (G) [groupoid.{u u} G] [is_connected G] [is_free_groupoid G]
(r : G) : rooted_connected (symgen r) :=
⟨λ b, path_nonempty_of_hom (category_theory.nonempty_hom_of_connected_groupoid r b)⟩
/-- A vertex group in a free connected groupoid is free. With some work one could drop the
connectedness assumption, by looking at connected components. -/
instance End_is_free_of_connected_free {G} [groupoid G] [is_connected G] [is_free_groupoid G]
(r : G) : is_free_group (End r) :=
spanning_tree.End_is_free $ geodesic_subtree (symgen r)
end is_free_groupoid
/-- The Nielsen-Schreier theorem: a subgroup of a free group is free. -/
instance subgroup_is_free_of_is_free {G : Type u} [group G] [is_free_group G]
(H : subgroup G) : is_free_group H :=
is_free_group.of_mul_equiv (End_mul_equiv_subgroup H)
|
d2a84e2bd6092b6715e455c50a8153773997b974 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/data/fun_like/equiv.lean | 233753fd76c1f2dc9cfeb94b206d035286b7267c | [
"Apache-2.0"
] | permissive | Vierkantor/mathlib | 0ea59ac32a3a43c93c44d70f441c4ee810ccceca | 83bc3b9ce9b13910b57bda6b56222495ebd31c2f | refs/heads/master | 1,658,323,012,449 | 1,652,256,003,000 | 1,652,256,003,000 | 209,296,341 | 0 | 1 | Apache-2.0 | 1,568,807,655,000 | 1,568,807,655,000 | null | UTF-8 | Lean | false | false | 6,880 | lean | /-
Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen
-/
import data.fun_like.embedding
/-!
# Typeclass for a type `F` with an injective map to `A ≃ B`
This typeclass is primarily for use by isomorphisms like `monoid_equiv` and `linear_equiv`.
## Basic usage of `equiv_like`
A typical type of morphisms should be declared as:
```
structure my_iso (A B : Type*) [my_class A] [my_class B]
extends equiv A B :=
(map_op' : ∀ {x y : A}, to_fun (my_class.op x y) = my_class.op (to_fun x) (to_fun y))
namespace my_iso
variables (A B : Type*) [my_class A] [my_class B]
-- This instance is optional if you follow the "Isomorphism class" design below:
instance : equiv_like (my_iso A B) A (λ _, B) :=
{ coe := my_iso.to_equiv.to_fun,
inv := my_iso.to_equiv.inv_fun,
left_inv := my_iso.to_equiv.left_inv,
right_inv := my_iso.to_equiv.right_inv,
coe_injective' := λ f g h, by cases f; cases g; congr' }
/-- Helper instance for when there's too many metavariables to apply `equiv_like.coe` directly. -/
instance : has_coe_to_fun (my_iso A B) := to_fun.to_coe_fn
@[simp] lemma to_fun_eq_coe {f : my_iso A B} : f.to_fun = (f : A → B) := rfl
@[ext] theorem ext {f g : my_iso A B} (h : ∀ x, f x = g x) : f = g := fun_like.ext f g h
/-- Copy of a `my_iso` with a new `to_fun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : my_iso A B) (f' : A → B) (f_inv : B → A) (h : f' = ⇑f) : my_iso A B :=
{ to_fun := f',
inv_fun := f_inv,
left_inv := h.symm ▸ f.left_inv,
right_inv := h.symm ▸ f.right_inv,
map_op' := h.symm ▸ f.map_op' }
end my_iso
```
This file will then provide a `has_coe_to_fun` instance and various
extensionality and simp lemmas.
## Isomorphism classes extending `equiv_like`
The `equiv_like` design provides further benefits if you put in a bit more work.
The first step is to extend `equiv_like` to create a class of those types satisfying
the axioms of your new type of isomorphisms.
Continuing the example above:
```
/-- `my_iso_class F A B` states that `F` is a type of `my_class.op`-preserving morphisms.
You should extend this class when you extend `my_iso`. -/
class my_iso_class (F : Type*) (A B : out_param $ Type*) [my_class A] [my_class B]
extends equiv_like F A (λ _, B), my_hom_class F A B.
-- You can replace `my_iso.equiv_like` with the below instance:
instance : my_iso_class (my_iso A B) A B :=
{ coe := my_iso.to_fun,
inv := my_iso.inv_fun,
left_inv := my_iso.left_inv,
right_inv := my_iso.right_inv,
coe_injective' := λ f g h, by cases f; cases g; congr',
map_op := my_iso.map_op' }
-- [Insert `has_coe_to_fun`, `to_fun_eq_coe`, `ext` and `copy` here]
```
The second step is to add instances of your new `my_iso_class` for all types extending `my_iso`.
Typically, you can just declare a new class analogous to `my_iso_class`:
```
structure cooler_iso (A B : Type*) [cool_class A] [cool_class B]
extends my_iso A B :=
(map_cool' : to_fun cool_class.cool = cool_class.cool)
class cooler_iso_class (F : Type*) (A B : out_param $ Type*) [cool_class A] [cool_class B]
extends my_iso_class F A B :=
(map_cool : ∀ (f : F), f cool_class.cool = cool_class.cool)
@[simp] lemma map_cool {F A B : Type*} [cool_class A] [cool_class B] [cooler_iso_class F A B]
(f : F) : f cool_class.cool = cool_class.cool :=
my_iso_class.map_op
-- You can also replace `my_iso.equiv_like` with the below instance:
instance : cool_iso_class (cool_iso A B) A B :=
{ coe := cool_iso.to_fun,
coe_injective' := λ f g h, by cases f; cases g; congr',
map_op := cool_iso.map_op',
map_cool := cool_iso.map_cool' }
-- [Insert `has_coe_to_fun`, `to_fun_eq_coe`, `ext` and `copy` here]
```
Then any declaration taking a specific type of morphisms as parameter can instead take the
class you just defined:
```
-- Compare with: lemma do_something (f : my_iso A B) : sorry := sorry
lemma do_something {F : Type*} [my_iso_class F A B] (f : F) : sorry := sorry
```
This means anything set up for `my_iso`s will automatically work for `cool_iso_class`es,
and defining `cool_iso_class` only takes a constant amount of effort,
instead of linearly increasing the work per `my_iso`-related declaration.
-/
/-- The class `equiv_like E α β` expresses that terms of type `E` have an
injective coercion to bijections between `α` and `β`.
This typeclass is used in the definition of the homomorphism typeclasses,
such as `zero_equiv_class`, `mul_equiv_class`, `monoid_equiv_class`, ....
-/
class equiv_like (E : Sort*) (α β : out_param Sort*) :=
(coe : E → α → β)
(inv : E → β → α)
(left_inv : ∀ e, function.left_inverse (inv e) (coe e))
(right_inv : ∀ e, function.right_inverse (inv e) (coe e))
-- The `inv` hypothesis makes this easier to prove with `congr'`
(coe_injective' : ∀ e g, coe e = coe g → inv e = inv g → e = g)
namespace equiv_like
variables {E F α β γ : Sort*} [iE : equiv_like E α β] [iF : equiv_like F β γ]
include iE
lemma inv_injective : function.injective (equiv_like.inv : E → (β → α)) :=
λ e g h, coe_injective' e g ((right_inv e).eq_right_inverse (h.symm ▸ left_inv g)) h
@[priority 100]
instance to_embedding_like : embedding_like E α β :=
{ coe := coe,
coe_injective' := λ e g h, coe_injective' e g h
((left_inv e).eq_right_inverse (h.symm ▸ right_inv g)),
injective' := λ e, (left_inv e).injective }
protected lemma injective (e : E) : function.injective e := embedding_like.injective e
protected lemma surjective (e : E) : function.surjective e := (right_inv e).surjective
protected lemma bijective (e : E) : function.bijective (e : α → β) :=
⟨equiv_like.injective e, equiv_like.surjective e⟩
theorem apply_eq_iff_eq (f : E) {x y : α} : f x = f y ↔ x = y := embedding_like.apply_eq_iff_eq f
@[simp] lemma injective_comp (e : E) (f : β → γ) :
function.injective (f ∘ e) ↔ function.injective f :=
function.injective.of_comp_iff' f (equiv_like.bijective e)
@[simp] lemma surjective_comp (e : E) (f : β → γ) :
function.surjective (f ∘ e) ↔ function.surjective f :=
(equiv_like.surjective e).of_comp_iff f
@[simp] lemma bijective_comp (e : E) (f : β → γ) :
function.bijective (f ∘ e) ↔ function.bijective f :=
(equiv_like.bijective e).of_comp_iff f
omit iE
include iF
lemma comp_injective (f : α → β) (e : F) :
function.injective (e ∘ f) ↔ function.injective f :=
embedding_like.comp_injective f e
@[simp] lemma comp_surjective (f : α → β) (e : F) :
function.surjective (e ∘ f) ↔ function.surjective f :=
function.surjective.of_comp_iff' (equiv_like.bijective e) f
@[simp] lemma comp_bijective (f : α → β) (e : F) :
function.bijective (e ∘ f) ↔ function.bijective f :=
(equiv_like.bijective e).of_comp_iff' f
end equiv_like
|
95054fa24418f46d8e675a42594f9e098bd9a4a4 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/ring_theory/witt_vector/truncated.lean | 22a6ad453347cdf7393336abcf977bcb072caae2 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 16,085 | lean | /-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Robert Y. Lewis
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.ring_theory.witt_vector.init_tail
import Mathlib.tactic.equiv_rw
import Mathlib.PostPort
universes u_1 u_2
namespace Mathlib
/-!
# Truncated Witt vectors
The ring of truncated Witt vectors (of length `n`) is a quotient of the ring of Witt vectors.
It retains the first `n` coefficients of each Witt vector.
In this file, we set up the basic quotient API for this ring.
The ring of Witt vectors is the projective limit of all the rings of truncated Witt vectors.
## Main declarations
- `truncated_witt_vector`: the underlying type of the ring of truncated Witt vectors
- `truncated_witt_vector.comm_ring`: the ring structure on truncated Witt vectors
- `witt_vector.truncate`: the quotient homomorphism that truncates a Witt vector,
to obtain a truncated Witt vector
- `truncated_witt_vector.truncate`: the homomorphism that truncates
a truncated Witt vector of length `n` to one of length `m` (for some `m ≤ n`)
- `witt_vector.lift`: the unique ring homomorphism into the ring of Witt vectors
that is compatible with a family of ring homomorphisms to the truncated Witt vectors:
this realizes the ring of Witt vectors as projective limit of the rings of truncated Witt vectors
-/
/--
A truncated Witt vector over `R` is a vector of elements of `R`,
i.e., the first `n` coefficients of a Witt vector.
We will define operations on this type that are compatible with the (untruncated) Witt
vector operations.
`truncated_witt_vector p n R` takes a parameter `p : ℕ` that is not used in the definition.
In practice, this number `p` is assumed to be a prime number,
and under this assumption we construct a ring structure on `truncated_witt_vector p n R`.
(`truncated_witt_vector p₁ n R` and `truncated_witt_vector p₂ n R` are definitionally
equal as types but will have different ring operations.)
-/
def truncated_witt_vector (p : ℕ) (n : ℕ) (R : Type u_1) :=
fin n → R
protected instance truncated_witt_vector.inhabited (p : ℕ) (n : ℕ) (R : Type u_1) [Inhabited R] : Inhabited (truncated_witt_vector p n R) :=
{ default := fun (_x : fin n) => Inhabited.default }
namespace truncated_witt_vector
/-- Create a `truncated_witt_vector` from a vector `x`. -/
def mk (p : ℕ) {n : ℕ} {R : Type u_1} (x : fin n → R) : truncated_witt_vector p n R :=
x
/-- `x.coeff i` is the `i`th entry of `x`. -/
def coeff {p : ℕ} {n : ℕ} {R : Type u_1} (i : fin n) (x : truncated_witt_vector p n R) : R :=
x i
theorem ext {p : ℕ} {n : ℕ} {R : Type u_1} {x : truncated_witt_vector p n R} {y : truncated_witt_vector p n R} (h : ∀ (i : fin n), coeff i x = coeff i y) : x = y :=
funext h
theorem ext_iff {p : ℕ} {n : ℕ} {R : Type u_1} {x : truncated_witt_vector p n R} {y : truncated_witt_vector p n R} : x = y ↔ ∀ (i : fin n), coeff i x = coeff i y :=
{ mp :=
fun (h : x = y) (i : fin n) => eq.mpr (id (Eq._oldrec (Eq.refl (coeff i x = coeff i y)) h)) (Eq.refl (coeff i y)),
mpr := ext }
@[simp] theorem coeff_mk {p : ℕ} {n : ℕ} {R : Type u_1} (x : fin n → R) (i : fin n) : coeff i (mk p x) = x i :=
rfl
@[simp] theorem mk_coeff {p : ℕ} {n : ℕ} {R : Type u_1} (x : truncated_witt_vector p n R) : (mk p fun (i : fin n) => coeff i x) = x := sorry
/--
We can turn a truncated Witt vector `x` into a Witt vector
by setting all coefficients after `x` to be 0.
-/
def out {p : ℕ} {n : ℕ} {R : Type u_1} [comm_ring R] (x : truncated_witt_vector p n R) : witt_vector p R :=
witt_vector.mk p
fun (i : ℕ) => dite (i < n) (fun (h : i < n) => coeff { val := i, property := h } x) fun (h : ¬i < n) => 0
@[simp] theorem coeff_out {p : ℕ} {n : ℕ} {R : Type u_1} [comm_ring R] (x : truncated_witt_vector p n R) (i : fin n) : witt_vector.coeff (out x) ↑i = coeff i x := sorry
theorem out_injective {p : ℕ} {n : ℕ} {R : Type u_1} [comm_ring R] : function.injective out := sorry
end truncated_witt_vector
namespace witt_vector
/-- `truncate_fun n x` uses the first `n` entries of `x` to construct a `truncated_witt_vector`,
which has the same base `p` as `x`.
This function is bundled into a ring homomorphism in `witt_vector.truncate` -/
def truncate_fun {p : ℕ} (n : ℕ) {R : Type u_1} (x : witt_vector p R) : truncated_witt_vector p n R :=
truncated_witt_vector.mk p fun (i : fin n) => coeff x ↑i
@[simp] theorem coeff_truncate_fun {p : ℕ} {n : ℕ} {R : Type u_1} (x : witt_vector p R) (i : fin n) : truncated_witt_vector.coeff i (truncate_fun n x) = coeff x ↑i := sorry
@[simp] theorem out_truncate_fun {p : ℕ} {n : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) : truncated_witt_vector.out (truncate_fun n x) = init n x := sorry
end witt_vector
namespace truncated_witt_vector
@[simp] theorem truncate_fun_out {p : ℕ} {n : ℕ} {R : Type u_1} [comm_ring R] (x : truncated_witt_vector p n R) : witt_vector.truncate_fun n (out x) = x := sorry
protected instance has_zero (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : HasZero (truncated_witt_vector p n R) :=
{ zero := witt_vector.truncate_fun n 0 }
protected instance has_one (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : HasOne (truncated_witt_vector p n R) :=
{ one := witt_vector.truncate_fun n 1 }
protected instance has_add (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : Add (truncated_witt_vector p n R) :=
{ add := fun (x y : truncated_witt_vector p n R) => witt_vector.truncate_fun n (out x + out y) }
protected instance has_mul (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : Mul (truncated_witt_vector p n R) :=
{ mul := fun (x y : truncated_witt_vector p n R) => witt_vector.truncate_fun n (out x * out y) }
protected instance has_neg (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : Neg (truncated_witt_vector p n R) :=
{ neg := fun (x : truncated_witt_vector p n R) => witt_vector.truncate_fun n (-out x) }
@[simp] theorem coeff_zero (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] (i : fin n) : coeff i 0 = 0 :=
id
(eq.mpr (id (Eq._oldrec (Eq.refl (coeff i (witt_vector.truncate_fun n 0) = 0)) (witt_vector.coeff_truncate_fun 0 i)))
(eq.mpr (id (Eq._oldrec (Eq.refl (witt_vector.coeff 0 ↑i = 0)) (witt_vector.zero_coeff p R ↑i))) (Eq.refl 0)))
end truncated_witt_vector
/-- A macro tactic used to prove that `truncate_fun` respects ring operations. -/
namespace witt_vector
theorem truncate_fun_surjective (p : ℕ) (n : ℕ) (R : Type u_1) [comm_ring R] : function.surjective (truncate_fun n) :=
fun (x : truncated_witt_vector p n R) =>
Exists.intro (truncated_witt_vector.out x) (truncated_witt_vector.truncate_fun_out x)
@[simp] theorem truncate_fun_zero (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : truncate_fun n 0 = 0 :=
rfl
@[simp] theorem truncate_fun_one (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : truncate_fun n 1 = 1 :=
rfl
@[simp] theorem truncate_fun_add {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) : truncate_fun n (x + y) = truncate_fun n x + truncate_fun n y := sorry
@[simp] theorem truncate_fun_mul {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) : truncate_fun n (x * y) = truncate_fun n x * truncate_fun n y := sorry
theorem truncate_fun_neg {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] (x : witt_vector p R) : truncate_fun n (-x) = -truncate_fun n x := sorry
end witt_vector
namespace truncated_witt_vector
protected instance comm_ring (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : comm_ring (truncated_witt_vector p n R) :=
function.surjective.comm_ring (witt_vector.truncate_fun n) (witt_vector.truncate_fun_surjective p n R)
(witt_vector.truncate_fun_zero p n R) (witt_vector.truncate_fun_one p n R) (witt_vector.truncate_fun_add n)
(witt_vector.truncate_fun_mul n) (witt_vector.truncate_fun_neg n)
end truncated_witt_vector
namespace witt_vector
/-- `truncate n` is a ring homomorphism that truncates `x` to its first `n` entries
to obtain a `truncated_witt_vector`, which has the same base `p` as `x`. -/
def truncate {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] : witt_vector p R →+* truncated_witt_vector p n R :=
ring_hom.mk (truncate_fun n) (truncate_fun_one p n R) (truncate_fun_mul n) (truncate_fun_zero p n R)
(truncate_fun_add n)
theorem truncate_surjective (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) (R : Type u_1) [comm_ring R] : function.surjective ⇑(truncate n) :=
truncate_fun_surjective p n R
@[simp] theorem coeff_truncate {p : ℕ} [hp : fact (nat.prime p)] {n : ℕ} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (i : fin n) : truncated_witt_vector.coeff i (coe_fn (truncate n) x) = coeff x ↑i :=
coeff_truncate_fun x i
theorem mem_ker_truncate {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] (x : witt_vector p R) : x ∈ ring_hom.ker (truncate n) ↔ ∀ (i : ℕ), i < n → coeff x i = 0 := sorry
@[simp] theorem truncate_mk (p : ℕ) [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] (f : ℕ → R) : coe_fn (truncate n) (mk p f) = truncated_witt_vector.mk p fun (k : fin n) => f ↑k := sorry
end witt_vector
namespace truncated_witt_vector
/--
A ring homomorphism that truncates a truncated Witt vector of length `m` to
a truncated Witt vector of length `n`, for `n ≤ m`.
-/
def truncate {p : ℕ} [hp : fact (nat.prime p)] {n : ℕ} {R : Type u_1} [comm_ring R] {m : ℕ} (hm : n ≤ m) : truncated_witt_vector p m R →+* truncated_witt_vector p n R :=
ring_hom.lift_of_surjective (witt_vector.truncate m) (witt_vector.truncate_surjective p m R) (witt_vector.truncate n)
sorry
@[simp] theorem truncate_comp_witt_vector_truncate {p : ℕ} [hp : fact (nat.prime p)] {n : ℕ} {R : Type u_1} [comm_ring R] {m : ℕ} (hm : n ≤ m) : ring_hom.comp (truncate hm) (witt_vector.truncate m) = witt_vector.truncate n :=
ring_hom.lift_of_surjective_comp (witt_vector.truncate m) (witt_vector.truncate_surjective p m R)
(witt_vector.truncate n) (truncate._proof_1 hm)
@[simp] theorem truncate_witt_vector_truncate {p : ℕ} [hp : fact (nat.prime p)] {n : ℕ} {R : Type u_1} [comm_ring R] {m : ℕ} (hm : n ≤ m) (x : witt_vector p R) : coe_fn (truncate hm) (coe_fn (witt_vector.truncate m) x) = coe_fn (witt_vector.truncate n) x :=
ring_hom.lift_of_surjective_comp_apply (witt_vector.truncate m) (witt_vector.truncate_surjective p m R)
(witt_vector.truncate n) (truncate._proof_1 hm) x
@[simp] theorem truncate_truncate {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] {n₁ : ℕ} {n₂ : ℕ} {n₃ : ℕ} (h1 : n₁ ≤ n₂) (h2 : n₂ ≤ n₃) (x : truncated_witt_vector p n₃ R) : coe_fn (truncate h1) (coe_fn (truncate h2) x) = coe_fn (truncate (has_le.le.trans h1 h2)) x := sorry
@[simp] theorem truncate_comp {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] {n₁ : ℕ} {n₂ : ℕ} {n₃ : ℕ} (h1 : n₁ ≤ n₂) (h2 : n₂ ≤ n₃) : ring_hom.comp (truncate h1) (truncate h2) = truncate (has_le.le.trans h1 h2) := sorry
theorem truncate_surjective {p : ℕ} [hp : fact (nat.prime p)] {n : ℕ} {R : Type u_1} [comm_ring R] {m : ℕ} (hm : n ≤ m) : function.surjective ⇑(truncate hm) := sorry
@[simp] theorem coeff_truncate {p : ℕ} [hp : fact (nat.prime p)] {n : ℕ} {R : Type u_1} [comm_ring R] {m : ℕ} (hm : n ≤ m) (i : fin n) (x : truncated_witt_vector p m R) : coeff i (coe_fn (truncate hm) x) = coeff (coe_fn (fin.cast_le hm) i) x := sorry
protected instance fintype {p : ℕ} {n : ℕ} {R : Type u_1} [fintype R] : fintype (truncated_witt_vector p n R) :=
pi.fintype
theorem card (p : ℕ) (n : ℕ) {R : Type u_1} [fintype R] : fintype.card (truncated_witt_vector p n R) = fintype.card R ^ n := sorry
theorem infi_ker_truncate {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] : (infi fun (i : ℕ) => ring_hom.ker (witt_vector.truncate i)) = ⊥ := sorry
end truncated_witt_vector
namespace witt_vector
/--
Given a family `fₖ : S → truncated_witt_vector p k R` and `s : S`, we produce a Witt vector by
defining the `k`th entry to be the final entry of `fₖ s`.
-/
def lift_fun {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] {S : Type u_2} [semiring S] (f : (k : ℕ) → S →+* truncated_witt_vector p k R) (s : S) : witt_vector p R :=
mk p fun (k : ℕ) => truncated_witt_vector.coeff (fin.last k) (coe_fn (f (k + 1)) s)
@[simp] theorem truncate_lift_fun {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] {S : Type u_2} [semiring S] {f : (k : ℕ) → S →+* truncated_witt_vector p k R} (f_compat : ∀ (k₁ k₂ : ℕ) (hk : k₁ ≤ k₂), ring_hom.comp (truncated_witt_vector.truncate hk) (f k₂) = f k₁) (s : S) : coe_fn (truncate n) (lift_fun f s) = coe_fn (f n) s := sorry
/--
Given compatible ring homs from `S` into `truncated_witt_vector n` for each `n`, we can lift these
to a ring hom `S → 𝕎 R`.
`lift` defines the universal property of `𝕎 R` as the inverse limit of `truncated_witt_vector n`.
-/
def lift {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] {S : Type u_2} [semiring S] (f : (k : ℕ) → S →+* truncated_witt_vector p k R) (f_compat : ∀ (k₁ k₂ : ℕ) (hk : k₁ ≤ k₂), ring_hom.comp (truncated_witt_vector.truncate hk) (f k₂) = f k₁) : S →+* witt_vector p R :=
ring_hom.mk (lift_fun f) sorry sorry sorry sorry
@[simp] theorem truncate_lift {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] {S : Type u_2} [semiring S] {f : (k : ℕ) → S →+* truncated_witt_vector p k R} (f_compat : ∀ (k₁ k₂ : ℕ) (hk : k₁ ≤ k₂), ring_hom.comp (truncated_witt_vector.truncate hk) (f k₂) = f k₁) (s : S) : coe_fn (truncate n) (coe_fn (lift (fun (k₂ : ℕ) => f k₂) f_compat) s) = coe_fn (f n) s :=
truncate_lift_fun n f_compat s
@[simp] theorem truncate_comp_lift {p : ℕ} [hp : fact (nat.prime p)] (n : ℕ) {R : Type u_1} [comm_ring R] {S : Type u_2} [semiring S] {f : (k : ℕ) → S →+* truncated_witt_vector p k R} (f_compat : ∀ (k₁ k₂ : ℕ) (hk : k₁ ≤ k₂), ring_hom.comp (truncated_witt_vector.truncate hk) (f k₂) = f k₁) : ring_hom.comp (truncate n) (lift (fun (k₂ : ℕ) => f k₂) f_compat) = f n := sorry
/-- The uniqueness part of the universal property of `𝕎 R`. -/
theorem lift_unique {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] {S : Type u_2} [semiring S] {f : (k : ℕ) → S →+* truncated_witt_vector p k R} (f_compat : ∀ (k₁ k₂ : ℕ) (hk : k₁ ≤ k₂), ring_hom.comp (truncated_witt_vector.truncate hk) (f k₂) = f k₁) (g : S →+* witt_vector p R) (g_compat : ∀ (k : ℕ), ring_hom.comp (truncate k) g = f k) : lift (fun (k₂ : ℕ) => f k₂) f_compat = g := sorry
/-- The universal property of `𝕎 R` as projective limit of truncated Witt vector rings. -/
@[simp] theorem lift_equiv_symm_apply_coe {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] {S : Type u_2} [semiring S] (g : S →+* witt_vector p R) (k : ℕ) : coe (coe_fn (equiv.symm lift_equiv) g) k = ring_hom.comp (truncate k) g :=
Eq.refl (coe (coe_fn (equiv.symm lift_equiv) g) k)
theorem hom_ext {p : ℕ} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] {S : Type u_2} [semiring S] (g₁ : S →+* witt_vector p R) (g₂ : S →+* witt_vector p R) (h : ∀ (k : ℕ), ring_hom.comp (truncate k) g₁ = ring_hom.comp (truncate k) g₂) : g₁ = g₂ :=
equiv.injective (equiv.symm lift_equiv) (subtype.ext (funext h))
|
83e361299f966ba930eaf51f12adbf9e0c2ea2ed | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/algebra/direct_sum/decomposition.lean | de748982c5c8ce62586922ee75872b0c9e83c7d0 | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 8,378 | lean | /-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser, Jujian Zhang
-/
import algebra.direct_sum.module
import algebra.module.submodule.basic
/-!
# Decompositions of additive monoids, groups, and modules into direct sums
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
## Main definitions
* `direct_sum.decomposition ℳ`: A typeclass to provide a constructive decomposition from
an additive monoid `M` into a family of additive submonoids `ℳ`
* `direct_sum.decompose ℳ`: The canonical equivalence provided by the above typeclass
## Main statements
* `direct_sum.decomposition.is_internal`: The link to `direct_sum.is_internal`.
## Implementation details
As we want to talk about different types of decomposition (additive monoids, modules, rings, ...),
we choose to avoid heavily bundling `direct_sum.decompose`, instead making copies for the
`add_equiv`, `linear_equiv`, etc. This means we have to repeat statements that follow from these
bundled homs, but means we don't have to repeat statements for different types of decomposition.
-/
variables {ι R M σ : Type*}
open_locale direct_sum big_operators
namespace direct_sum
section add_comm_monoid
variables [decidable_eq ι] [add_comm_monoid M]
variables [set_like σ M] [add_submonoid_class σ M] (ℳ : ι → σ)
/-- A decomposition is an equivalence between an additive monoid `M` and a direct sum of additive
submonoids `ℳ i` of that `M`, such that the "recomposition" is canonical. This definition also
works for additive groups and modules.
This is a version of `direct_sum.is_internal` which comes with a constructive inverse to the
canonical "recomposition" rather than just a proof that the "recomposition" is bijective. -/
class decomposition :=
(decompose' : M → ⨁ i, ℳ i)
(left_inv : function.left_inverse (direct_sum.coe_add_monoid_hom ℳ) decompose' )
(right_inv : function.right_inverse (direct_sum.coe_add_monoid_hom ℳ) decompose')
include M
/-- `direct_sum.decomposition` instances, while carrying data, are always equal. -/
instance : subsingleton (decomposition ℳ) :=
⟨λ x y, begin
cases x with x xl xr,
cases y with y yl yr,
congr',
exact function.left_inverse.eq_right_inverse xr yl,
end⟩
variables [decomposition ℳ]
protected lemma decomposition.is_internal : direct_sum.is_internal ℳ :=
⟨decomposition.right_inv.injective, decomposition.left_inv.surjective⟩
/-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as
to a direct sum of components. This is the canonical spelling of the `decompose'` field. -/
def decompose : M ≃ ⨁ i, ℳ i :=
{ to_fun := decomposition.decompose',
inv_fun := direct_sum.coe_add_monoid_hom ℳ,
left_inv := decomposition.left_inv,
right_inv := decomposition.right_inv }
protected lemma decomposition.induction_on {p : M → Prop}
(h_zero : p 0) (h_homogeneous : ∀ {i} (m : ℳ i), p (m : M))
(h_add : ∀ (m m' : M), p m → p m' → p (m + m')) : ∀ m, p m :=
begin
let ℳ' : ι → add_submonoid M :=
λ i, (⟨ℳ i, λ _ _, add_mem_class.add_mem, zero_mem_class.zero_mem _⟩ : add_submonoid M),
haveI t : direct_sum.decomposition ℳ' :=
{ decompose' := direct_sum.decompose ℳ,
left_inv := λ _, (decompose ℳ).left_inv _,
right_inv := λ _, (decompose ℳ).right_inv _, },
have mem : ∀ m, m ∈ supr ℳ' :=
λ m, (direct_sum.is_internal.add_submonoid_supr_eq_top ℳ'
(decomposition.is_internal ℳ')).symm ▸ trivial,
exact λ m, add_submonoid.supr_induction ℳ' (mem m) (λ i m h, h_homogeneous ⟨m, h⟩) h_zero h_add,
end
@[simp] lemma decomposition.decompose'_eq : decomposition.decompose' = decompose ℳ := rfl
@[simp] lemma decompose_symm_of {i : ι} (x : ℳ i) :
(decompose ℳ).symm (direct_sum.of _ i x) = x :=
direct_sum.coe_add_monoid_hom_of ℳ _ _
@[simp] lemma decompose_coe {i : ι} (x : ℳ i) :
decompose ℳ (x : M) = direct_sum.of _ i x :=
by rw [←decompose_symm_of, equiv.apply_symm_apply]
lemma decompose_of_mem {x : M} {i : ι} (hx : x ∈ ℳ i) :
decompose ℳ x = direct_sum.of (λ i, ℳ i) i ⟨x, hx⟩ :=
decompose_coe _ ⟨x, hx⟩
lemma decompose_of_mem_same {x : M} {i : ι} (hx : x ∈ ℳ i) :
(decompose ℳ x i : M) = x :=
by rw [decompose_of_mem _ hx, direct_sum.of_eq_same, subtype.coe_mk]
lemma decompose_of_mem_ne {x : M} {i j : ι} (hx : x ∈ ℳ i) (hij : i ≠ j):
(decompose ℳ x j : M) = 0 :=
by rw [decompose_of_mem _ hx, direct_sum.of_eq_of_ne _ _ _ _ hij,
zero_mem_class.coe_zero]
/-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as
an additive monoid to a direct sum of components. -/
@[simps {fully_applied := ff}]
def decompose_add_equiv : M ≃+ ⨁ i, ℳ i := add_equiv.symm
{ map_add' := map_add (direct_sum.coe_add_monoid_hom ℳ),
..(decompose ℳ).symm }
@[simp] lemma decompose_zero : decompose ℳ (0 : M) = 0 := map_zero (decompose_add_equiv ℳ)
@[simp] lemma decompose_symm_zero : (decompose ℳ).symm 0 = (0 : M) :=
map_zero (decompose_add_equiv ℳ).symm
@[simp] lemma decompose_add (x y : M) : decompose ℳ (x + y) = decompose ℳ x + decompose ℳ y :=
map_add (decompose_add_equiv ℳ) x y
@[simp] lemma decompose_symm_add (x y : ⨁ i, ℳ i) :
(decompose ℳ).symm (x + y) = (decompose ℳ).symm x + (decompose ℳ).symm y :=
map_add (decompose_add_equiv ℳ).symm x y
@[simp] lemma decompose_sum {ι'} (s : finset ι') (f : ι' → M) :
decompose ℳ (∑ i in s, f i) = ∑ i in s, decompose ℳ (f i) :=
map_sum (decompose_add_equiv ℳ) f s
@[simp] lemma decompose_symm_sum {ι'} (s : finset ι') (f : ι' → ⨁ i, ℳ i) :
(decompose ℳ).symm (∑ i in s, f i) = ∑ i in s, (decompose ℳ).symm (f i) :=
map_sum (decompose_add_equiv ℳ).symm f s
lemma sum_support_decompose [Π i (x : ℳ i), decidable (x ≠ 0)] (r : M) :
∑ i in (decompose ℳ r).support, (decompose ℳ r i : M) = r :=
begin
conv_rhs { rw [←(decompose ℳ).symm_apply_apply r,
←sum_support_of (λ i, (ℳ i)) (decompose ℳ r)] },
rw [decompose_symm_sum],
simp_rw decompose_symm_of,
end
end add_comm_monoid
/-- The `-` in the statements below doesn't resolve without this line.
This seems to a be a problem of synthesized vs inferred typeclasses disagreeing. If we replace
the statement of `decompose_neg` with `@eq (⨁ i, ℳ i) (decompose ℳ (-x)) (-decompose ℳ x)`
instead of `decompose ℳ (-x) = -decompose ℳ x`, which forces the typeclasses needed by `⨁ i, ℳ i` to
be found by unification rather than synthesis, then everything works fine without this instance. -/
instance add_comm_group_set_like [add_comm_group M] [set_like σ M] [add_subgroup_class σ M]
(ℳ : ι → σ) : add_comm_group (⨁ i, ℳ i) := by apply_instance
section add_comm_group
variables [decidable_eq ι] [add_comm_group M]
variables [set_like σ M] [add_subgroup_class σ M] (ℳ : ι → σ)
variables [decomposition ℳ]
include M
@[simp] lemma decompose_neg (x : M) : decompose ℳ (-x) = -decompose ℳ x :=
map_neg (decompose_add_equiv ℳ) x
@[simp] lemma decompose_symm_neg (x : ⨁ i, ℳ i) :
(decompose ℳ).symm (-x) = -(decompose ℳ).symm x :=
map_neg (decompose_add_equiv ℳ).symm x
@[simp] lemma decompose_sub (x y : M) : decompose ℳ (x - y) = decompose ℳ x - decompose ℳ y :=
map_sub (decompose_add_equiv ℳ) x y
@[simp] lemma decompose_symm_sub (x y : ⨁ i, ℳ i) :
(decompose ℳ).symm (x - y) = (decompose ℳ).symm x - (decompose ℳ).symm y :=
map_sub (decompose_add_equiv ℳ).symm x y
end add_comm_group
section module
variables [decidable_eq ι] [semiring R] [add_comm_monoid M] [module R M]
variables (ℳ : ι → submodule R M)
variables [decomposition ℳ]
include M
/-- If `M` is graded by `ι` with degree `i` component `ℳ i`, then it is isomorphic as
a module to a direct sum of components. -/
@[simps {fully_applied := ff}]
def decompose_linear_equiv : M ≃ₗ[R] ⨁ i, ℳ i := linear_equiv.symm
{ map_smul' := map_smul (direct_sum.coe_linear_map ℳ),
..(decompose_add_equiv ℳ).symm }
@[simp] lemma decompose_smul (r : R) (x : M) : decompose ℳ (r • x) = r • decompose ℳ x :=
map_smul (decompose_linear_equiv ℳ) r x
end module
end direct_sum
|
de26a150411c2e871631bf2fc8fbac7f09d75423 | 82e44445c70db0f03e30d7be725775f122d72f3e | /src/measure_theory/simple_func_dense.lean | a7252e78f66f4c28c52eab05c2c9a73d2c429dc5 | [
"Apache-2.0"
] | permissive | stjordanis/mathlib | 51e286d19140e3788ef2c470bc7b953e4991f0c9 | 2568d41bca08f5d6bf39d915434c8447e21f42ee | refs/heads/master | 1,631,748,053,501 | 1,627,938,886,000 | 1,627,938,886,000 | 228,728,358 | 0 | 0 | Apache-2.0 | 1,576,630,588,000 | 1,576,630,587,000 | null | UTF-8 | Lean | false | false | 40,637 | lean | /-
Copyright (c) 2019 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov, Heather Macbeth
-/
import measure_theory.l1_space
/-!
# Density of simple functions
Show that each Borel measurable function can be approximated pointwise, and each `Lᵖ` Borel
measurable function can be approximated in `Lᵖ` norm, by a sequence of simple functions.
## Main definitions
* `measure_theory.simple_func.nearest_pt (e : ℕ → α) (N : ℕ) : α →ₛ ℕ`: the `simple_func` sending
each `x : α` to the point `e k` which is the nearest to `x` among `e 0`, ..., `e N`.
* `measure_theory.simple_func.approx_on (f : β → α) (hf : measurable f) (s : set α) (y₀ : α)
(h₀ : y₀ ∈ s) [separable_space s] (n : ℕ) : β →ₛ α` : a simple function that takes values in `s`
and approximates `f`.
* `measure_theory.Lp.simple_func`, the type of `Lp` simple functions
* `coe_to_Lp`, the embedding of `Lp.simple_func E p μ` into `Lp E p μ`
## Main results
* `tendsto_approx_on` (pointwise convergence): If `f x ∈ s`, then the sequence of simple
approximations `measure_theory.simple_func.approx_on f hf s y₀ h₀ n`, evaluated at `x`,
tends to `f x` as `n` tends to `∞`.
* `tendsto_approx_on_univ_Lp` (Lᵖ convergence): If `E` is a `normed_group` and `f` is measurable
and `mem_ℒp` (for `p < ∞`), then the simple functions `simple_func.approx_on f hf s 0 h₀ n` may
be considered as elements of `Lp E p μ`, and they tend in Lᵖ to `f`.
* `Lp.simple_func.dense_embedding`: the embedding `coe_to_Lp` of the `Lp` simple functions into
`Lp` is dense.
* `Lp.simple_func.induction`, `Lp.induction`, `mem_ℒp.induction`, `integrable.induction`: to prove
a predicate for all elements of one of these classes of functions, it suffices to check that it
behaves correctly on simple functions.
## TODO
For `E` finite-dimensional, simple functions `α →ₛ E` are dense in L^∞ -- prove this.
## Notations
* `α →ₛ β` (local notation): the type of simple functions `α → β`.
* `α →₁ₛ[μ] E`: the type of `L1` simple functions `α → β`.
-/
open set function filter topological_space ennreal emetric finset
open_locale classical topological_space ennreal measure_theory big_operators
variables {α β ι E F 𝕜 : Type*}
noncomputable theory
namespace measure_theory
local infixr ` →ₛ `:25 := simple_func
namespace simple_func
/-! ### Pointwise approximation by simple functions -/
section pointwise
variables [measurable_space α] [emetric_space α] [opens_measurable_space α]
/-- `nearest_pt_ind e N x` is the index `k` such that `e k` is the nearest point to `x` among the
points `e 0`, ..., `e N`. If more than one point are at the same distance from `x`, then
`nearest_pt_ind e N x` returns the least of their indexes. -/
noncomputable def nearest_pt_ind (e : ℕ → α) : ℕ → α →ₛ ℕ
| 0 := const α 0
| (N + 1) := piecewise (⋂ k ≤ N, {x | edist (e (N + 1)) x < edist (e k) x})
(measurable_set.Inter $ λ k, measurable_set.Inter_Prop $ λ hk,
measurable_set_lt measurable_edist_right measurable_edist_right)
(const α $ N + 1) (nearest_pt_ind N)
/-- `nearest_pt e N x` is the nearest point to `x` among the points `e 0`, ..., `e N`. If more than
one point are at the same distance from `x`, then `nearest_pt e N x` returns the point with the
least possible index. -/
noncomputable def nearest_pt (e : ℕ → α) (N : ℕ) : α →ₛ α :=
(nearest_pt_ind e N).map e
@[simp] lemma nearest_pt_ind_zero (e : ℕ → α) : nearest_pt_ind e 0 = const α 0 := rfl
@[simp] lemma nearest_pt_zero (e : ℕ → α) : nearest_pt e 0 = const α (e 0) := rfl
lemma nearest_pt_ind_succ (e : ℕ → α) (N : ℕ) (x : α) :
nearest_pt_ind e (N + 1) x =
if ∀ k ≤ N, edist (e (N + 1)) x < edist (e k) x
then N + 1 else nearest_pt_ind e N x :=
by { simp only [nearest_pt_ind, coe_piecewise, set.piecewise], congr, simp }
lemma nearest_pt_ind_le (e : ℕ → α) (N : ℕ) (x : α) : nearest_pt_ind e N x ≤ N :=
begin
induction N with N ihN, { simp },
simp only [nearest_pt_ind_succ],
split_ifs,
exacts [le_rfl, ihN.trans N.le_succ]
end
lemma edist_nearest_pt_le (e : ℕ → α) (x : α) {k N : ℕ} (hk : k ≤ N) :
edist (nearest_pt e N x) x ≤ edist (e k) x :=
begin
induction N with N ihN generalizing k,
{ simp [nonpos_iff_eq_zero.1 hk, le_refl] },
{ simp only [nearest_pt, nearest_pt_ind_succ, map_apply],
split_ifs,
{ rcases hk.eq_or_lt with rfl|hk,
exacts [le_rfl, (h k (nat.lt_succ_iff.1 hk)).le] },
{ push_neg at h,
rcases h with ⟨l, hlN, hxl⟩,
rcases hk.eq_or_lt with rfl|hk,
exacts [(ihN hlN).trans hxl, ihN (nat.lt_succ_iff.1 hk)] } }
end
lemma tendsto_nearest_pt {e : ℕ → α} {x : α} (hx : x ∈ closure (range e)) :
tendsto (λ N, nearest_pt e N x) at_top (𝓝 x) :=
begin
refine (at_top_basis.tendsto_iff nhds_basis_eball).2 (λ ε hε, _),
rcases emetric.mem_closure_iff.1 hx ε hε with ⟨_, ⟨N, rfl⟩, hN⟩,
rw [edist_comm] at hN,
exact ⟨N, trivial, λ n hn, (edist_nearest_pt_le e x hn).trans_lt hN⟩
end
variables [measurable_space β] {f : β → α}
/-- Approximate a measurable function by a sequence of simple functions `F n` such that
`F n x ∈ s`. -/
noncomputable def approx_on (f : β → α) (hf : measurable f) (s : set α) (y₀ : α) (h₀ : y₀ ∈ s)
[separable_space s] (n : ℕ) :
β →ₛ α :=
by haveI : nonempty s := ⟨⟨y₀, h₀⟩⟩;
exact comp (nearest_pt (λ k, nat.cases_on k y₀ (coe ∘ dense_seq s) : ℕ → α) n) f hf
@[simp] lemma approx_on_zero {f : β → α} (hf : measurable f) {s : set α} {y₀ : α} (h₀ : y₀ ∈ s)
[separable_space s] (x : β) :
approx_on f hf s y₀ h₀ 0 x = y₀ :=
rfl
lemma approx_on_mem {f : β → α} (hf : measurable f) {s : set α} {y₀ : α} (h₀ : y₀ ∈ s)
[separable_space s] (n : ℕ) (x : β) :
approx_on f hf s y₀ h₀ n x ∈ s :=
begin
haveI : nonempty s := ⟨⟨y₀, h₀⟩⟩,
suffices : ∀ n, (nat.cases_on n y₀ (coe ∘ dense_seq s) : α) ∈ s, { apply this },
rintro (_|n),
exacts [h₀, subtype.mem _]
end
@[simp] lemma approx_on_comp {γ : Type*} [measurable_space γ] {f : β → α} (hf : measurable f)
{g : γ → β} (hg : measurable g) {s : set α} {y₀ : α} (h₀ : y₀ ∈ s) [separable_space s] (n : ℕ) :
approx_on (f ∘ g) (hf.comp hg) s y₀ h₀ n = (approx_on f hf s y₀ h₀ n).comp g hg :=
rfl
lemma tendsto_approx_on {f : β → α} (hf : measurable f) {s : set α} {y₀ : α} (h₀ : y₀ ∈ s)
[separable_space s] {x : β} (hx : f x ∈ closure s) :
tendsto (λ n, approx_on f hf s y₀ h₀ n x) at_top (𝓝 $ f x) :=
begin
haveI : nonempty s := ⟨⟨y₀, h₀⟩⟩,
rw [← @subtype.range_coe _ s, ← image_univ, ← (dense_range_dense_seq s).closure_eq] at hx,
simp only [approx_on, coe_comp],
refine tendsto_nearest_pt (closure_minimal _ is_closed_closure hx),
simp only [nat.range_cases_on, closure_union, range_comp coe],
exact subset.trans (image_closure_subset_closure_image continuous_subtype_coe)
(subset_union_right _ _)
end
lemma edist_approx_on_le {f : β → α} (hf : measurable f) {s : set α} {y₀ : α} (h₀ : y₀ ∈ s)
[separable_space s] (x : β) (n : ℕ) :
edist (approx_on f hf s y₀ h₀ n x) (f x) ≤ edist y₀ (f x) :=
begin
dsimp only [approx_on, coe_comp, (∘)],
exact edist_nearest_pt_le _ _ (zero_le _)
end
lemma edist_approx_on_y0_le {f : β → α} (hf : measurable f) {s : set α} {y₀ : α} (h₀ : y₀ ∈ s)
[separable_space s] (x : β) (n : ℕ) :
edist y₀ (approx_on f hf s y₀ h₀ n x) ≤ edist y₀ (f x) + edist y₀ (f x) :=
calc edist y₀ (approx_on f hf s y₀ h₀ n x) ≤
edist y₀ (f x) + edist (approx_on f hf s y₀ h₀ n x) (f x) : edist_triangle_right _ _ _
... ≤ edist y₀ (f x) + edist y₀ (f x) : add_le_add_left (edist_approx_on_le hf h₀ x n) _
end pointwise
/-! ### Lp approximation by simple functions -/
section Lp
variables [measurable_space β]
variables [measurable_space E] [normed_group E] {q : ℝ} {p : ℝ≥0∞}
lemma nnnorm_approx_on_le [opens_measurable_space E] {f : β → E} (hf : measurable f)
{s : set E} {y₀ : E} (h₀ : y₀ ∈ s) [separable_space s] (x : β) (n : ℕ) :
∥approx_on f hf s y₀ h₀ n x - f x∥₊ ≤ ∥f x - y₀∥₊ :=
begin
have := edist_approx_on_le hf h₀ x n,
rw edist_comm y₀ at this,
simp only [edist_nndist, nndist_eq_nnnorm] at this,
exact_mod_cast this
end
lemma norm_approx_on_y₀_le [opens_measurable_space E] {f : β → E} (hf : measurable f)
{s : set E} {y₀ : E} (h₀ : y₀ ∈ s) [separable_space s] (x : β) (n : ℕ) :
∥approx_on f hf s y₀ h₀ n x - y₀∥ ≤ ∥f x - y₀∥ + ∥f x - y₀∥ :=
begin
have := edist_approx_on_y0_le hf h₀ x n,
repeat { rw [edist_comm y₀, edist_eq_coe_nnnorm_sub] at this },
exact_mod_cast this,
end
lemma norm_approx_on_zero_le [opens_measurable_space E] {f : β → E} (hf : measurable f)
{s : set E} (h₀ : (0 : E) ∈ s) [separable_space s] (x : β) (n : ℕ) :
∥approx_on f hf s 0 h₀ n x∥ ≤ ∥f x∥ + ∥f x∥ :=
begin
have := edist_approx_on_y0_le hf h₀ x n,
simp [edist_comm (0 : E), edist_eq_coe_nnnorm] at this,
exact_mod_cast this,
end
lemma tendsto_approx_on_Lp_snorm [opens_measurable_space E]
{f : β → E} (hf : measurable f) {s : set E} {y₀ : E} (h₀ : y₀ ∈ s) [separable_space s]
(hp_ne_top : p ≠ ∞) {μ : measure β} (hμ : ∀ᵐ x ∂μ, f x ∈ closure s)
(hi : snorm (λ x, f x - y₀) p μ < ∞) :
tendsto (λ n, snorm (approx_on f hf s y₀ h₀ n - f) p μ) at_top (𝓝 0) :=
begin
by_cases hp_zero : p = 0,
{ simpa only [hp_zero, snorm_exponent_zero] using tendsto_const_nhds },
have hp : 0 < p.to_real := to_real_pos_iff.mpr ⟨bot_lt_iff_ne_bot.mpr hp_zero, hp_ne_top⟩,
suffices : tendsto (λ n, ∫⁻ x, ∥approx_on f hf s y₀ h₀ n x - f x∥₊ ^ p.to_real ∂μ) at_top (𝓝 0),
{ simp only [snorm_eq_lintegral_rpow_nnnorm hp_zero hp_ne_top],
convert continuous_rpow_const.continuous_at.tendsto.comp this;
simp [_root_.inv_pos.mpr hp] },
-- We simply check the conditions of the Dominated Convergence Theorem:
-- (1) The function "`p`-th power of distance between `f` and the approximation" is measurable
have hF_meas : ∀ n, measurable (λ x, (∥approx_on f hf s y₀ h₀ n x - f x∥₊ : ℝ≥0∞) ^ p.to_real),
{ simpa only [← edist_eq_coe_nnnorm_sub] using
λ n, (approx_on f hf s y₀ h₀ n).measurable_bind (λ y x, (edist y (f x)) ^ p.to_real)
(λ y, (measurable_edist_right.comp hf).pow_const p.to_real) },
-- (2) The functions "`p`-th power of distance between `f` and the approximation" are uniformly
-- bounded, at any given point, by `λ x, ∥f x - y₀∥ ^ p.to_real`
have h_bound : ∀ n, (λ x, (∥approx_on f hf s y₀ h₀ n x - f x∥₊ : ℝ≥0∞) ^ p.to_real)
≤ᵐ[μ] (λ x, ∥f x - y₀∥₊ ^ p.to_real),
{ exact λ n, eventually_of_forall
(λ x, rpow_le_rpow (coe_mono (nnnorm_approx_on_le hf h₀ x n)) to_real_nonneg) },
-- (3) The bounding function `λ x, ∥f x - y₀∥ ^ p.to_real` has finite integral
have h_fin : ∫⁻ (a : β), ∥f a - y₀∥₊ ^ p.to_real ∂μ < ⊤,
{ exact lintegral_rpow_nnnorm_lt_top_of_snorm_lt_top hp_zero hp_ne_top hi },
-- (4) The functions "`p`-th power of distance between `f` and the approximation" tend pointwise
-- to zero
have h_lim : ∀ᵐ (a : β) ∂μ,
tendsto (λ n, (∥approx_on f hf s y₀ h₀ n a - f a∥₊ : ℝ≥0∞) ^ p.to_real) at_top (𝓝 0),
{ filter_upwards [hμ],
intros a ha,
have : tendsto (λ n, (approx_on f hf s y₀ h₀ n) a - f a) at_top (𝓝 (f a - f a)),
{ exact (tendsto_approx_on hf h₀ ha).sub tendsto_const_nhds },
convert continuous_rpow_const.continuous_at.tendsto.comp (tendsto_coe.mpr this.nnnorm),
simp [zero_rpow_of_pos hp] },
-- Then we apply the Dominated Convergence Theorem
simpa using tendsto_lintegral_of_dominated_convergence _ hF_meas h_bound h_fin h_lim,
end
lemma mem_ℒp_approx_on [borel_space E]
{f : β → E} {μ : measure β} (fmeas : measurable f) (hf : mem_ℒp f p μ) {s : set E} {y₀ : E}
(h₀ : y₀ ∈ s) [separable_space s] (hi₀ : mem_ℒp (λ x, y₀) p μ) (n : ℕ) :
mem_ℒp (approx_on f fmeas s y₀ h₀ n) p μ :=
begin
refine ⟨(approx_on f fmeas s y₀ h₀ n).ae_measurable, _⟩,
suffices : snorm (λ x, approx_on f fmeas s y₀ h₀ n x - y₀) p μ < ⊤,
{ have : mem_ℒp (λ x, approx_on f fmeas s y₀ h₀ n x - y₀) p μ :=
⟨(approx_on f fmeas s y₀ h₀ n - const β y₀).ae_measurable, this⟩,
convert snorm_add_lt_top this hi₀,
ext x,
simp },
-- We don't necessarily have `mem_ℒp (λ x, f x - y₀) p μ`, because the `ae_measurable` part
-- requires `ae_measurable.add`, which requires second-countability
have hf' : mem_ℒp (λ x, ∥f x - y₀∥) p μ,
{ have h_meas : measurable (λ x, ∥f x - y₀∥),
{ simp only [← dist_eq_norm],
exact (continuous_id.dist continuous_const).measurable.comp fmeas },
refine ⟨h_meas.ae_measurable, _⟩,
rw snorm_norm,
convert snorm_add_lt_top hf hi₀.neg,
ext x,
simp [sub_eq_add_neg] },
have : ∀ᵐ x ∂μ, ∥approx_on f fmeas s y₀ h₀ n x - y₀∥ ≤ ∥(∥f x - y₀∥ + ∥f x - y₀∥)∥,
{ refine eventually_of_forall _,
intros x,
convert norm_approx_on_y₀_le fmeas h₀ x n,
rw [real.norm_eq_abs, abs_of_nonneg],
exact add_nonneg (norm_nonneg _) (norm_nonneg _) },
calc snorm (λ x, approx_on f fmeas s y₀ h₀ n x - y₀) p μ
≤ snorm (λ x, ∥f x - y₀∥ + ∥f x - y₀∥) p μ : snorm_mono_ae this
... < ⊤ : snorm_add_lt_top hf' hf',
end
lemma tendsto_approx_on_univ_Lp_snorm [opens_measurable_space E] [second_countable_topology E]
{f : β → E} (hp_ne_top : p ≠ ∞) {μ : measure β} (fmeas : measurable f) (hf : snorm f p μ < ∞) :
tendsto (λ n, snorm (approx_on f fmeas univ 0 trivial n - f) p μ) at_top (𝓝 0) :=
tendsto_approx_on_Lp_snorm fmeas trivial hp_ne_top (by simp) (by simpa using hf)
lemma mem_ℒp_approx_on_univ [borel_space E] [second_countable_topology E]
{f : β → E} {μ : measure β} (fmeas : measurable f) (hf : mem_ℒp f p μ) (n : ℕ) :
mem_ℒp (approx_on f fmeas univ 0 trivial n) p μ :=
mem_ℒp_approx_on fmeas hf (mem_univ _) zero_mem_ℒp n
lemma tendsto_approx_on_univ_Lp [borel_space E] [second_countable_topology E]
{f : β → E} [hp : fact (1 ≤ p)] (hp_ne_top : p ≠ ∞) {μ : measure β} (fmeas : measurable f)
(hf : mem_ℒp f p μ) :
tendsto (λ n, (mem_ℒp_approx_on_univ fmeas hf n).to_Lp (approx_on f fmeas univ 0 trivial n))
at_top (𝓝 (hf.to_Lp f)) :=
by simp [Lp.tendsto_Lp_iff_tendsto_ℒp'', tendsto_approx_on_univ_Lp_snorm hp_ne_top fmeas hf.2]
end Lp
/-! ### L1 approximation by simple functions -/
section integrable
variables [measurable_space β]
variables [measurable_space E] [normed_group E]
lemma tendsto_approx_on_L1_nnnorm [opens_measurable_space E]
{f : β → E} (hf : measurable f) {s : set E} {y₀ : E} (h₀ : y₀ ∈ s) [separable_space s]
{μ : measure β} (hμ : ∀ᵐ x ∂μ, f x ∈ closure s) (hi : has_finite_integral (λ x, f x - y₀) μ) :
tendsto (λ n, ∫⁻ x, ∥approx_on f hf s y₀ h₀ n x - f x∥₊ ∂μ) at_top (𝓝 0) :=
by simpa [snorm_one_eq_lintegral_nnnorm] using tendsto_approx_on_Lp_snorm hf h₀ one_ne_top hμ
(by simpa [snorm_one_eq_lintegral_nnnorm] using hi)
lemma integrable_approx_on [borel_space E]
{f : β → E} {μ : measure β} (fmeas : measurable f) (hf : integrable f μ)
{s : set E} {y₀ : E} (h₀ : y₀ ∈ s)
[separable_space s] (hi₀ : integrable (λ x, y₀) μ) (n : ℕ) :
integrable (approx_on f fmeas s y₀ h₀ n) μ :=
begin
rw ← mem_ℒp_one_iff_integrable at hf hi₀ ⊢,
exact mem_ℒp_approx_on fmeas hf h₀ hi₀ n,
end
lemma tendsto_approx_on_univ_L1_nnnorm [opens_measurable_space E] [second_countable_topology E]
{f : β → E} {μ : measure β} (fmeas : measurable f) (hf : integrable f μ) :
tendsto (λ n, ∫⁻ x, ∥approx_on f fmeas univ 0 trivial n x - f x∥₊ ∂μ) at_top (𝓝 0) :=
tendsto_approx_on_L1_nnnorm fmeas trivial (by simp) (by simpa using hf.2)
lemma integrable_approx_on_univ [borel_space E] [second_countable_topology E]
{f : β → E} {μ : measure β} (fmeas : measurable f) (hf : integrable f μ) (n : ℕ) :
integrable (approx_on f fmeas univ 0 trivial n) μ :=
integrable_approx_on fmeas hf _ (integrable_zero _ _ _) n
end integrable
section simple_func_properties
variables [measurable_space α]
variables [normed_group E] [measurable_space E] [normed_group F]
variables {μ : measure α} {p : ℝ≥0∞}
/-!
### Properties of simple functions in `Lp` spaces
A simple function `f : α →ₛ E` into a normed group `E` verifies, for a measure `μ`:
- `mem_ℒp f 0 μ` and `mem_ℒp f ∞ μ`, since `f` is a.e.-measurable and bounded,
- for `0 < p < ∞`, `mem_ℒp f p μ ↔ integrable f μ ↔ f.fin_meas_supp μ ↔ ∀ y ≠ 0, μ (f ⁻¹' {y}) < ∞`.
-/
lemma exists_forall_norm_le (f : α →ₛ F) : ∃ C, ∀ x, ∥f x∥ ≤ C :=
exists_forall_le (f.map (λ x, ∥x∥))
lemma mem_ℒp_zero (f : α →ₛ E) (μ : measure α) : mem_ℒp f 0 μ :=
mem_ℒp_zero_iff_ae_measurable.mpr f.ae_measurable
lemma mem_ℒp_top (f : α →ₛ E) (μ : measure α) : mem_ℒp f ∞ μ :=
let ⟨C, hfC⟩ := f.exists_forall_norm_le in
mem_ℒp_top_of_bound f.ae_measurable C $ eventually_of_forall hfC
protected lemma snorm'_eq {p : ℝ} (f : α →ₛ F) (μ : measure α) :
snorm' f p μ = (∑ y in f.range, (nnnorm y : ℝ≥0∞) ^ p * μ (f ⁻¹' {y})) ^ (1/p) :=
have h_map : (λ a, (nnnorm (f a) : ℝ≥0∞) ^ p) = f.map (λ a : F, (nnnorm a : ℝ≥0∞) ^ p), by simp,
by rw [snorm', h_map, lintegral_eq_lintegral, map_lintegral]
lemma measure_preimage_lt_top_of_mem_ℒp (hp_pos : 0 < p) (hp_ne_top : p ≠ ∞) (f : α →ₛ E)
(hf : mem_ℒp f p μ) (y : E) (hy_ne : y ≠ 0) :
μ (f ⁻¹' {y}) < ∞ :=
begin
have hp_pos_real : 0 < p.to_real, from ennreal.to_real_pos_iff.mpr ⟨hp_pos, hp_ne_top⟩,
have hf_snorm := mem_ℒp.snorm_lt_top hf,
rw [snorm_eq_snorm' hp_pos.ne.symm hp_ne_top, f.snorm'_eq,
← @ennreal.lt_rpow_one_div_iff _ _ (1 / p.to_real) (by simp [hp_pos_real]),
@ennreal.top_rpow_of_pos (1 / (1 / p.to_real)) (by simp [hp_pos_real]),
ennreal.sum_lt_top_iff] at hf_snorm,
by_cases hyf : y ∈ f.range,
swap,
{ suffices h_empty : f ⁻¹' {y} = ∅,
by { rw [h_empty, measure_empty], exact ennreal.coe_lt_top, },
ext1 x,
rw [set.mem_preimage, set.mem_singleton_iff, mem_empty_eq, iff_false],
refine λ hxy, hyf _,
rw [mem_range, set.mem_range],
exact ⟨x, hxy⟩, },
specialize hf_snorm y hyf,
rw ennreal.mul_lt_top_iff at hf_snorm,
cases hf_snorm,
{ exact hf_snorm.2, },
cases hf_snorm,
{ refine absurd _ hy_ne,
simpa [hp_pos_real] using hf_snorm, },
{ simp [hf_snorm], },
end
lemma mem_ℒp_of_finite_measure_preimage (p : ℝ≥0∞) {f : α →ₛ E} (hf : ∀ y ≠ 0, μ (f ⁻¹' {y}) < ∞) :
mem_ℒp f p μ :=
begin
by_cases hp0 : p = 0,
{ rw [hp0, mem_ℒp_zero_iff_ae_measurable], exact f.ae_measurable, },
by_cases hp_top : p = ∞,
{ rw hp_top, exact mem_ℒp_top f μ, },
refine ⟨f.ae_measurable, _⟩,
rw [snorm_eq_snorm' hp0 hp_top, f.snorm'_eq],
refine ennreal.rpow_lt_top_of_nonneg (by simp) (ennreal.sum_lt_top_iff.mpr (λ y hy, _)).ne,
by_cases hy0 : y = 0,
{ simp [hy0, ennreal.to_real_pos_iff.mpr ⟨lt_of_le_of_ne (zero_le _) (ne.symm hp0), hp_top⟩], },
{ refine ennreal.mul_lt_top _ (hf y hy0),
exact ennreal.rpow_lt_top_of_nonneg ennreal.to_real_nonneg ennreal.coe_ne_top, },
end
lemma mem_ℒp_iff {f : α →ₛ E} (hp_pos : 0 < p) (hp_ne_top : p ≠ ∞) :
mem_ℒp f p μ ↔ ∀ y ≠ 0, μ (f ⁻¹' {y}) < ∞ :=
⟨λ h, measure_preimage_lt_top_of_mem_ℒp hp_pos hp_ne_top f h,
λ h, mem_ℒp_of_finite_measure_preimage p h⟩
lemma integrable_iff {f : α →ₛ E} : integrable f μ ↔ ∀ y ≠ 0, μ (f ⁻¹' {y}) < ∞ :=
mem_ℒp_one_iff_integrable.symm.trans $ mem_ℒp_iff ennreal.zero_lt_one ennreal.coe_ne_top
lemma mem_ℒp_iff_integrable {f : α →ₛ E} (hp_pos : 0 < p) (hp_ne_top : p ≠ ∞) :
mem_ℒp f p μ ↔ integrable f μ :=
(mem_ℒp_iff hp_pos hp_ne_top).trans integrable_iff.symm
lemma mem_ℒp_iff_fin_meas_supp {f : α →ₛ E} (hp_pos : 0 < p) (hp_ne_top : p ≠ ∞) :
mem_ℒp f p μ ↔ f.fin_meas_supp μ :=
(mem_ℒp_iff hp_pos hp_ne_top).trans fin_meas_supp_iff.symm
lemma integrable_iff_fin_meas_supp {f : α →ₛ E} : integrable f μ ↔ f.fin_meas_supp μ :=
integrable_iff.trans fin_meas_supp_iff.symm
lemma fin_meas_supp.integrable {f : α →ₛ E} (h : f.fin_meas_supp μ) : integrable f μ :=
integrable_iff_fin_meas_supp.2 h
lemma integrable_pair [measurable_space F] {f : α →ₛ E} {g : α →ₛ F} :
integrable f μ → integrable g μ → integrable (pair f g) μ :=
by simpa only [integrable_iff_fin_meas_supp] using fin_meas_supp.pair
lemma mem_ℒp_of_finite_measure (f : α →ₛ E) (p : ℝ≥0∞) (μ : measure α) [finite_measure μ] :
mem_ℒp f p μ :=
let ⟨C, hfC⟩ := f.exists_forall_norm_le in
mem_ℒp.of_bound f.ae_measurable C $ eventually_of_forall hfC
lemma integrable_of_finite_measure [finite_measure μ] (f : α →ₛ E) : integrable f μ :=
mem_ℒp_one_iff_integrable.mp (f.mem_ℒp_of_finite_measure 1 μ)
lemma measure_preimage_lt_top_of_integrable (f : α →ₛ E) (hf : integrable f μ) {x : E}
(hx : x ≠ 0) :
μ (f ⁻¹' {x}) < ∞ :=
integrable_iff.mp hf x hx
lemma measure_lt_top_of_mem_ℒp_indicator (hp_pos : 0 < p) (hp_ne_top : p ≠ ∞) {c : E} (hc : c ≠ 0)
{s : set α} (hs : measurable_set s)
(hcs : mem_ℒp ((const α c).piecewise s hs (const α 0)) p μ) :
μ s < ⊤ :=
begin
have : function.support (const α c) = set.univ := function.support_const hc,
simpa only [mem_ℒp_iff_fin_meas_supp hp_pos hp_ne_top, fin_meas_supp_iff_support,
support_indicator, set.inter_univ, this] using hcs
end
end simple_func_properties
end simple_func
/-! Construction of the space of `Lp` simple functions, and its dense embedding into `Lp`. -/
namespace Lp
open ae_eq_fun
variables
[measurable_space α]
[normed_group E] [second_countable_topology E] [measurable_space E] [borel_space E]
[normed_group F] [second_countable_topology F] [measurable_space F] [borel_space F]
(p : ℝ≥0∞) (μ : measure α)
variables (E)
/-- `Lp.simple_func` is a subspace of Lp consisting of equivalence classes of an integrable simple
function. -/
def simple_func : add_subgroup (Lp E p μ) :=
{ carrier := {f : Lp E p μ | ∃ (s : α →ₛ E), (ae_eq_fun.mk s s.ae_measurable : α →ₘ[μ] E) = f},
zero_mem' := ⟨0, rfl⟩,
add_mem' := λ f g ⟨s, hs⟩ ⟨t, ht⟩, ⟨s + t,
by simp only [←hs, ←ht, mk_add_mk, add_subgroup.coe_add, mk_eq_mk, simple_func.coe_add]⟩,
neg_mem' := λ f ⟨s, hs⟩, ⟨-s,
by simp only [←hs, neg_mk, simple_func.coe_neg, mk_eq_mk, add_subgroup.coe_neg]⟩ }
variables {E p μ}
namespace simple_func
section instances
/-! Simple functions in Lp space form a `normed_space`. -/
@[norm_cast] lemma coe_coe (f : Lp.simple_func E p μ) : ⇑(f : Lp E p μ) = f := rfl
protected lemma eq' {f g : Lp.simple_func E p μ} : (f : α →ₘ[μ] E) = (g : α →ₘ[μ] E) → f = g :=
subtype.eq ∘ subtype.eq
/-! Implementation note: If `Lp.simple_func E p μ` were defined as a `𝕜`-submodule of `Lp E p μ`,
then the next few lemmas, putting a normed `𝕜`-group structure on `Lp.simple_func E p μ`, would be
unnecessary. But instead, `Lp.simple_func E p μ` is defined as an `add_subgroup` of `Lp E p μ`,
which does not permit this (but has the advantage of working when `E` itself is a normed group,
i.e. has no scalar action). -/
variables [normed_field 𝕜] [normed_space 𝕜 E] [measurable_space 𝕜] [opens_measurable_space 𝕜]
/-- If `E` is a normed space, `Lp.simple_func E p μ` is a `has_scalar`. Not declared as an
instance as it is (as of writing) used only in the construction of the Bochner integral. -/
protected def has_scalar : has_scalar 𝕜 (Lp.simple_func E p μ) := ⟨λk f, ⟨k • f,
begin
rcases f with ⟨f, ⟨s, hs⟩⟩,
use k • s,
apply eq.trans (smul_mk k s s.ae_measurable).symm _,
rw hs,
refl,
end ⟩⟩
local attribute [instance] simple_func.has_scalar
@[simp, norm_cast] lemma coe_smul (c : 𝕜) (f : Lp.simple_func E p μ) :
((c • f : Lp.simple_func E p μ) : Lp E p μ) = c • (f : Lp E p μ) := rfl
/-- If `E` is a normed space, `Lp.simple_func E p μ` is a module. Not declared as an
instance as it is (as of writing) used only in the construction of the Bochner integral. -/
protected def module : module 𝕜 (Lp.simple_func E p μ) :=
{ one_smul := λf, by { ext1, exact one_smul _ _ },
mul_smul := λx y f, by { ext1, exact mul_smul _ _ _ },
smul_add := λx f g, by { ext1, exact smul_add _ _ _ },
smul_zero := λx, by { ext1, exact smul_zero _ },
add_smul := λx y f, by { ext1, exact add_smul _ _ _ },
zero_smul := λf, by { ext1, exact zero_smul _ _ } }
local attribute [instance] simple_func.module
/-- If `E` is a normed space, `Lp.simple_func E p μ` is a normed space. Not declared as an
instance as it is (as of writing) used only in the construction of the Bochner integral. -/
protected def normed_space [fact (1 ≤ p)] : normed_space 𝕜 (Lp.simple_func E p μ) :=
⟨ λc f, by { rw [coe_norm_subgroup, coe_norm_subgroup, coe_smul, norm_smul] } ⟩
end instances
local attribute [instance] simple_func.module simple_func.normed_space
section to_Lp
/-- Construct the equivalence class `[f]` of a simple function `f` satisfying `mem_ℒp`. -/
@[reducible] def to_Lp (f : α →ₛ E) (hf : mem_ℒp f p μ) : (Lp.simple_func E p μ) :=
⟨hf.to_Lp f, ⟨f, rfl⟩⟩
lemma to_Lp_eq_to_Lp (f : α →ₛ E) (hf : mem_ℒp f p μ) :
(to_Lp f hf : Lp E p μ) = hf.to_Lp f := rfl
lemma to_Lp_eq_mk (f : α →ₛ E) (hf : mem_ℒp f p μ) :
(to_Lp f hf : α →ₘ[μ] E) = ae_eq_fun.mk f f.ae_measurable := rfl
lemma to_Lp_zero : to_Lp (0 : α →ₛ E) zero_mem_ℒp = (0 : Lp.simple_func E p μ) := rfl
lemma to_Lp_add (f g : α →ₛ E) (hf : mem_ℒp f p μ) (hg : mem_ℒp g p μ) :
to_Lp (f + g) (hf.add hg) = to_Lp f hf + to_Lp g hg := rfl
lemma to_Lp_neg (f : α →ₛ E) (hf : mem_ℒp f p μ) :
to_Lp (-f) hf.neg = -to_Lp f hf := rfl
lemma to_Lp_sub (f g : α →ₛ E) (hf : mem_ℒp f p μ) (hg : mem_ℒp g p μ) :
to_Lp (f - g) (hf.sub hg) = to_Lp f hf - to_Lp g hg :=
by { simp only [sub_eq_add_neg, ← to_Lp_neg, ← to_Lp_add], refl }
variables [normed_field 𝕜] [normed_space 𝕜 E] [measurable_space 𝕜] [opens_measurable_space 𝕜]
lemma to_Lp_smul (f : α →ₛ E) (hf : mem_ℒp f p μ) (c : 𝕜) :
to_Lp (c • f) (hf.const_smul c) = c • to_Lp f hf := rfl
lemma norm_to_Lp [fact (1 ≤ p)] (f : α →ₛ E) (hf : mem_ℒp f p μ) :
∥to_Lp f hf∥ = ennreal.to_real (snorm f p μ) :=
norm_to_Lp f hf
end to_Lp
section to_simple_func
/-- Find a representative of a `Lp.simple_func`. -/
def to_simple_func (f : Lp.simple_func E p μ) : α →ₛ E := classical.some f.2
/-- `(to_simple_func f)` is measurable. -/
@[measurability]
protected lemma measurable (f : Lp.simple_func E p μ) : measurable (to_simple_func f) :=
(to_simple_func f).measurable
@[measurability]
protected lemma ae_measurable (f : Lp.simple_func E p μ) : ae_measurable (to_simple_func f) μ :=
(simple_func.measurable f).ae_measurable
lemma to_simple_func_eq_to_fun (f : Lp.simple_func E p μ) : to_simple_func f =ᵐ[μ] f :=
show ⇑(to_simple_func f) =ᵐ[μ] ⇑(f : α →ₘ[μ] E), by
begin
convert (ae_eq_fun.coe_fn_mk (to_simple_func f) (simple_func.ae_measurable f)).symm using 2,
exact (classical.some_spec f.2).symm,
end
/-- `to_simple_func f` satisfies the predicate `mem_ℒp`. -/
protected lemma mem_ℒp (f : Lp.simple_func E p μ) : mem_ℒp (to_simple_func f) p μ :=
mem_ℒp.ae_eq (to_simple_func_eq_to_fun f).symm $ mem_Lp_iff_mem_ℒp.mp (f : Lp E p μ).2
lemma to_Lp_to_simple_func (f : Lp.simple_func E p μ) :
to_Lp (to_simple_func f) (simple_func.mem_ℒp f) = f :=
simple_func.eq' (classical.some_spec f.2)
lemma to_simple_func_to_Lp (f : α →ₛ E) (hfi : mem_ℒp f p μ) :
to_simple_func (to_Lp f hfi) =ᵐ[μ] f :=
by { rw ← mk_eq_mk, exact classical.some_spec (to_Lp f hfi).2 }
variables (E μ)
lemma zero_to_simple_func : to_simple_func (0 : Lp.simple_func E p μ) =ᵐ[μ] 0 :=
begin
filter_upwards [to_simple_func_eq_to_fun (0 : Lp.simple_func E p μ), Lp.coe_fn_zero E 1 μ],
assume a h₁ h₂,
rwa h₁,
end
variables {E μ}
lemma add_to_simple_func (f g : Lp.simple_func E p μ) :
to_simple_func (f + g) =ᵐ[μ] to_simple_func f + to_simple_func g :=
begin
filter_upwards [to_simple_func_eq_to_fun (f + g), to_simple_func_eq_to_fun f,
to_simple_func_eq_to_fun g, Lp.coe_fn_add (f : Lp E p μ) g],
assume a,
simp only [← coe_coe, add_subgroup.coe_add, pi.add_apply],
iterate 4 { assume h, rw h }
end
lemma neg_to_simple_func (f : Lp.simple_func E p μ) :
to_simple_func (-f) =ᵐ[μ] - to_simple_func f :=
begin
filter_upwards [to_simple_func_eq_to_fun (-f), to_simple_func_eq_to_fun f,
Lp.coe_fn_neg (f : Lp E p μ)],
assume a,
simp only [pi.neg_apply, add_subgroup.coe_neg, ← coe_coe],
repeat { assume h, rw h }
end
lemma sub_to_simple_func (f g : Lp.simple_func E p μ) :
to_simple_func (f - g) =ᵐ[μ] to_simple_func f - to_simple_func g :=
begin
filter_upwards [to_simple_func_eq_to_fun (f - g), to_simple_func_eq_to_fun f,
to_simple_func_eq_to_fun g, Lp.coe_fn_sub (f : Lp E p μ) g],
assume a,
simp only [add_subgroup.coe_sub, pi.sub_apply, ← coe_coe],
repeat { assume h, rw h }
end
variables [normed_field 𝕜] [normed_space 𝕜 E] [measurable_space 𝕜] [opens_measurable_space 𝕜]
lemma smul_to_simple_func (k : 𝕜) (f : Lp.simple_func E p μ) :
to_simple_func (k • f) =ᵐ[μ] k • to_simple_func f :=
begin
filter_upwards [to_simple_func_eq_to_fun (k • f), to_simple_func_eq_to_fun f,
Lp.coe_fn_smul k (f : Lp E p μ)],
assume a,
simp only [pi.smul_apply, coe_smul, ← coe_coe],
repeat { assume h, rw h }
end
lemma norm_to_simple_func [fact (1 ≤ p)] (f : Lp.simple_func E p μ) :
∥f∥ = ennreal.to_real (snorm (to_simple_func f) p μ) :=
by simpa [to_Lp_to_simple_func] using norm_to_Lp (to_simple_func f) (simple_func.mem_ℒp f)
end to_simple_func
section induction
variables (p)
/-- The characteristic function of a finite-measure measurable set `s`, as an `Lp` simple function.
-/
def indicator_const {s : set α} (hs : measurable_set s) (hμs : μ s ≠ ∞) (c : E) :
Lp.simple_func E p μ :=
to_Lp ((simple_func.const _ c).piecewise s hs (simple_func.const _ 0))
(mem_ℒp_indicator_const p hs c (or.inr hμs))
variables {p}
@[simp] lemma coe_indicator_const {s : set α} (hs : measurable_set s) (hμs : μ s ≠ ∞) (c : E) :
(↑(indicator_const p hs hμs c) : Lp E p μ) = indicator_const_Lp p hs hμs c :=
rfl
lemma to_simple_func_indicator_const {s : set α} (hs : measurable_set s) (hμs : μ s ≠ ∞) (c : E) :
to_simple_func (indicator_const p hs hμs c)
=ᵐ[μ] (simple_func.const _ c).piecewise s hs (simple_func.const _ 0) :=
Lp.simple_func.to_simple_func_to_Lp _ _
/-- To prove something for an arbitrary `Lp` simple function, with `0 < p < ∞`, it suffices to show
that the property holds for (multiples of) characteristic functions of finite-measure measurable
sets and is closed under addition (of functions with disjoint support). -/
@[elab_as_eliminator]
protected lemma induction (hp_pos : 0 < p) (hp_ne_top : p ≠ ∞) {P : Lp.simple_func E p μ → Prop}
(h_ind : ∀ (c : E) {s : set α} (hs : measurable_set s) (hμs : μ s < ∞),
P (Lp.simple_func.indicator_const p hs hμs.ne c))
(h_add : ∀ ⦃f g : α →ₛ E⦄, ∀ hf : mem_ℒp f p μ, ∀ hg : mem_ℒp g p μ,
disjoint (support f) (support g) → P (Lp.simple_func.to_Lp f hf) → P (Lp.simple_func.to_Lp g hg)
→ P (Lp.simple_func.to_Lp f hf + Lp.simple_func.to_Lp g hg))
(f : Lp.simple_func E p μ) : P f :=
begin
suffices : ∀ f : α →ₛ E, ∀ hf : mem_ℒp f p μ, P (to_Lp f hf),
{ rw ← to_Lp_to_simple_func f,
apply this }, clear f,
refine simple_func.induction _ _,
{ intros c s hs hf,
by_cases hc : c = 0,
{ convert h_ind 0 measurable_set.empty (by simp) using 1,
ext1,
simp [hc] },
exact h_ind c hs (simple_func.measure_lt_top_of_mem_ℒp_indicator hp_pos hp_ne_top hc hs hf) },
{ intros f g hfg hf hg hfg',
obtain ⟨hf', hg'⟩ : mem_ℒp f p μ ∧ mem_ℒp g p μ,
{ exact (mem_ℒp_add_of_disjoint hfg f.measurable g.measurable).mp hfg' },
exact h_add hf' hg' hfg (hf hf') (hg hg') },
end
end induction
section coe_to_Lp
variables [fact (1 ≤ p)]
protected lemma uniform_continuous :
uniform_continuous (coe : (Lp.simple_func E p μ) → (Lp E p μ)) :=
uniform_continuous_comap
protected lemma uniform_embedding :
uniform_embedding (coe : (Lp.simple_func E p μ) → (Lp E p μ)) :=
uniform_embedding_comap subtype.val_injective
protected lemma uniform_inducing : uniform_inducing (coe : (Lp.simple_func E p μ) → (Lp E p μ)) :=
simple_func.uniform_embedding.to_uniform_inducing
protected lemma dense_embedding (hp_ne_top : p ≠ ∞) :
dense_embedding (coe : (Lp.simple_func E p μ) → (Lp E p μ)) :=
begin
apply simple_func.uniform_embedding.dense_embedding,
assume f,
rw mem_closure_iff_seq_limit,
have hfi' : mem_ℒp f p μ := Lp.mem_ℒp f,
refine ⟨λ n, ↑(to_Lp (simple_func.approx_on f (Lp.measurable f) univ 0 trivial n)
(simple_func.mem_ℒp_approx_on_univ (Lp.measurable f) hfi' n)), λ n, mem_range_self _, _⟩,
convert simple_func.tendsto_approx_on_univ_Lp hp_ne_top (Lp.measurable f) hfi',
rw to_Lp_coe_fn f (Lp.mem_ℒp f)
end
protected lemma dense_inducing (hp_ne_top : p ≠ ∞) :
dense_inducing (coe : (Lp.simple_func E p μ) → (Lp E p μ)) :=
(simple_func.dense_embedding hp_ne_top).to_dense_inducing
protected lemma dense_range (hp_ne_top : p ≠ ∞) :
dense_range (coe : (Lp.simple_func E p μ) → (Lp E p μ)) :=
(simple_func.dense_inducing hp_ne_top).dense
variables [normed_field 𝕜] [normed_space 𝕜 E] [measurable_space 𝕜] [opens_measurable_space 𝕜]
variables (α E 𝕜)
/-- The embedding of Lp simple functions into Lp functions, as a continuous linear map. -/
def coe_to_Lp : (Lp.simple_func E p μ) →L[𝕜] (Lp E p μ) :=
{ map_smul' := λk f, rfl,
cont := Lp.simple_func.uniform_continuous.continuous,
.. add_subgroup.subtype (Lp.simple_func E p μ) }
variables {α E 𝕜}
end coe_to_Lp
end simple_func
end Lp
variables [measurable_space α] [normed_group E] [measurable_space E] [borel_space E]
[second_countable_topology E] {f : α → E} {p : ℝ≥0∞} {μ : measure α}
/-- To prove something for an arbitrary `Lp` function in a second countable Borel normed group, it
suffices to show that
* the property holds for (multiples of) characteristic functions;
* is closed under addition;
* the set of functions in `Lp` for which the property holds is closed.
-/
@[elab_as_eliminator]
lemma Lp.induction [_i : fact (1 ≤ p)] (hp_ne_top : p ≠ ∞) (P : Lp E p μ → Prop)
(h_ind : ∀ (c : E) {s : set α} (hs : measurable_set s) (hμs : μ s < ∞),
P (Lp.simple_func.indicator_const p hs hμs.ne c))
(h_add : ∀ ⦃f g⦄, ∀ hf : mem_ℒp f p μ, ∀ hg : mem_ℒp g p μ, disjoint (support f) (support g) →
P (hf.to_Lp f) → P (hg.to_Lp g) → P ((hf.to_Lp f) + (hg.to_Lp g)))
(h_closed : is_closed {f : Lp E p μ | P f}) :
∀ f : Lp E p μ, P f :=
begin
refine λ f, (Lp.simple_func.dense_range hp_ne_top).induction_on f h_closed _,
refine Lp.simple_func.induction (lt_of_lt_of_le ennreal.zero_lt_one _i.elim) hp_ne_top _ _,
{ exact λ c s, h_ind c },
{ exact λ f g hf hg, h_add hf hg },
end
/-- To prove something for an arbitrary `mem_ℒp` function in a second countable
Borel normed group, it suffices to show that
* the property holds for (multiples of) characteristic functions;
* is closed under addition;
* the set of functions in the `Lᵖ` space for which the property holds is closed.
* the property is closed under the almost-everywhere equal relation.
It is possible to make the hypotheses in the induction steps a bit stronger, and such conditions
can be added once we need them (for example in `h_add` it is only necessary to consider the sum of
a simple function with a multiple of a characteristic function and that the intersection
of their images is a subset of `{0}`).
-/
@[elab_as_eliminator]
lemma mem_ℒp.induction [_i : fact (1 ≤ p)] (hp_ne_top : p ≠ ∞) (P : (α → E) → Prop)
(h_ind : ∀ (c : E) ⦃s⦄, measurable_set s → μ s < ∞ → P (s.indicator (λ _, c)))
(h_add : ∀ ⦃f g : α → E⦄, disjoint (support f) (support g) → mem_ℒp f p μ → mem_ℒp g p μ →
P f → P g → P (f + g))
(h_closed : is_closed {f : Lp E p μ | P f} )
(h_ae : ∀ ⦃f g⦄, f =ᵐ[μ] g → mem_ℒp f p μ → P f → P g) :
∀ ⦃f : α → E⦄ (hf : mem_ℒp f p μ), P f :=
begin
have : ∀ (f : simple_func α E), mem_ℒp f p μ → P f,
{ refine simple_func.induction _ _,
{ intros c s hs h,
by_cases hc : c = 0,
{ subst hc, convert h_ind 0 measurable_set.empty (by simp) using 1, ext, simp [const] },
have hp_pos : 0 < p := lt_of_lt_of_le ennreal.zero_lt_one _i.elim,
exact h_ind c hs (simple_func.measure_lt_top_of_mem_ℒp_indicator hp_pos hp_ne_top hc hs h) },
{ intros f g hfg hf hg int_fg,
rw [simple_func.coe_add, mem_ℒp_add_of_disjoint hfg f.measurable g.measurable] at int_fg,
refine h_add hfg int_fg.1 int_fg.2 (hf int_fg.1) (hg int_fg.2) } },
have : ∀ (f : Lp.simple_func E p μ), P f,
{ intro f,
exact h_ae (Lp.simple_func.to_simple_func_eq_to_fun f) (Lp.simple_func.mem_ℒp f)
(this (Lp.simple_func.to_simple_func f) (Lp.simple_func.mem_ℒp f)) },
have : ∀ (f : Lp E p μ), P f :=
λ f, (Lp.simple_func.dense_range hp_ne_top).induction_on f h_closed this,
exact λ f hf, h_ae hf.coe_fn_to_Lp (Lp.mem_ℒp _) (this (hf.to_Lp f)),
end
section integrable
local attribute [instance] fact_one_le_one_ennreal
notation α ` →₁ₛ[`:25 μ `] ` E := @measure_theory.Lp.simple_func α E _ _ _ _ _ 1 μ
lemma L1.simple_func.to_Lp_one_eq_to_L1 (f : α →ₛ E) (hf : integrable f μ) :
(Lp.simple_func.to_Lp f (mem_ℒp_one_iff_integrable.2 hf) : α →₁[μ] E) = hf.to_L1 f :=
rfl
protected lemma L1.simple_func.integrable (f : α →₁ₛ[μ] E) :
integrable (Lp.simple_func.to_simple_func f) μ :=
by { rw ← mem_ℒp_one_iff_integrable, exact (Lp.simple_func.mem_ℒp f) }
/-- To prove something for an arbitrary integrable function in a second countable
Borel normed group, it suffices to show that
* the property holds for (multiples of) characteristic functions;
* is closed under addition;
* the set of functions in the `L¹` space for which the property holds is closed.
* the property is closed under the almost-everywhere equal relation.
It is possible to make the hypotheses in the induction steps a bit stronger, and such conditions
can be added once we need them (for example in `h_add` it is only necessary to consider the sum of
a simple function with a multiple of a characteristic function and that the intersection
of their images is a subset of `{0}`).
-/
@[elab_as_eliminator]
lemma integrable.induction (P : (α → E) → Prop)
(h_ind : ∀ (c : E) ⦃s⦄, measurable_set s → μ s < ∞ → P (s.indicator (λ _, c)))
(h_add : ∀ ⦃f g : α → E⦄, disjoint (support f) (support g) → integrable f μ → integrable g μ →
P f → P g → P (f + g))
(h_closed : is_closed {f : α →₁[μ] E | P f} )
(h_ae : ∀ ⦃f g⦄, f =ᵐ[μ] g → integrable f μ → P f → P g) :
∀ ⦃f : α → E⦄ (hf : integrable f μ), P f :=
begin
simp only [← mem_ℒp_one_iff_integrable] at *,
exact mem_ℒp.induction one_ne_top P h_ind h_add h_closed h_ae
end
end integrable
end measure_theory
|
279387e0c9723195a8f51d529a92b458af022666 | 5ae26df177f810c5006841e9c73dc56e01b978d7 | /src/data/nat/totient.lean | d0a0e0ec4141e93e468e97fda5654fa33b480a50 | [
"Apache-2.0"
] | permissive | ChrisHughes24/mathlib | 98322577c460bc6b1fe5c21f42ce33ad1c3e5558 | a2a867e827c2a6702beb9efc2b9282bd801d5f9a | refs/heads/master | 1,583,848,251,477 | 1,565,164,247,000 | 1,565,164,247,000 | 129,409,993 | 0 | 1 | Apache-2.0 | 1,565,164,817,000 | 1,523,628,059,000 | Lean | UTF-8 | Lean | false | false | 3,563 | lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import algebra.big_operators data.nat.gcd
open finset
namespace nat
def totient (n : ℕ) : ℕ := ((range n).filter (nat.coprime n)).card
local notation `φ` := totient
lemma totient_le (n : ℕ) : φ n ≤ n :=
calc totient n ≤ (range n).card : card_le_of_subset (filter_subset _)
... = n : card_range _
lemma totient_pos : ∀ {n : ℕ}, 0 < n → 0 < φ n
| 0 := dec_trivial
| 1 := dec_trivial
| (n+2) := λ h, card_pos.2 (mt eq_empty_iff_forall_not_mem.1
(not_forall_of_exists_not ⟨1, not_not.2 $ mem_filter.2 ⟨mem_range.2 dec_trivial, by simp [coprime]⟩⟩))
lemma sum_totient (n : ℕ) : ((range n.succ).filter (∣ n)).sum φ = n :=
if hn0 : n = 0 then by rw hn0; refl
else
calc ((range n.succ).filter (∣ n)).sum φ
= ((range n.succ).filter (∣ n)).sum (λ d, ((range (n / d)).filter (λ m, gcd (n / d) m = 1)).card) :
eq.symm $ sum_bij (λ d _, n / d)
(λ d hd, mem_filter.2 ⟨mem_range.2 $ lt_succ_of_le $ nat.div_le_self _ _,
by conv {to_rhs, rw ← nat.mul_div_cancel' (mem_filter.1 hd).2}; simp⟩)
(λ _ _, rfl)
(λ a b ha hb h,
have ha : a * (n / a) = n, from nat.mul_div_cancel' (mem_filter.1 ha).2,
have (n / a) > 0, from nat.pos_of_ne_zero (λ h, by simp [*, lt_irrefl] at *),
by rw [← nat.mul_right_inj this, ha, h, nat.mul_div_cancel' (mem_filter.1 hb).2])
(λ b hb,
have hb : b < n.succ ∧ b ∣ n, by simpa [-range_succ] using hb,
have hbn : (n / b) ∣ n, from ⟨b, by rw nat.div_mul_cancel hb.2⟩,
have hnb0 : (n / b) ≠ 0, from λ h, by simpa [h, ne.symm hn0] using nat.div_mul_cancel hbn,
⟨n / b, mem_filter.2 ⟨mem_range.2 $ lt_succ_of_le $ nat.div_le_self _ _, hbn⟩,
by rw [← nat.mul_right_inj (nat.pos_of_ne_zero hnb0),
nat.mul_div_cancel' hb.2, nat.div_mul_cancel hbn]⟩)
... = ((range n.succ).filter (∣ n)).sum (λ d, ((range n).filter (λ m, gcd n m = d)).card) :
sum_congr rfl (λ d hd,
have hd : d ∣ n, from (mem_filter.1 hd).2,
have hd0 : 0 < d, from nat.pos_of_ne_zero (λ h, hn0 (eq_zero_of_zero_dvd $ h ▸ hd)),
card_congr (λ m hm, d * m)
(λ m hm, have hm : m < n / d ∧ gcd (n / d) m = 1, by simpa using hm,
mem_filter.2 ⟨mem_range.2 $ nat.mul_div_cancel' hd ▸
(mul_lt_mul_left hd0).2 hm.1,
by rw [← nat.mul_div_cancel' hd, gcd_mul_left, hm.2, mul_one]⟩)
(λ a b ha hb h, (nat.mul_left_inj hd0).1 h)
(λ b hb, have hb : b < n ∧ gcd n b = d, by simpa using hb,
⟨b / d, mem_filter.2 ⟨mem_range.2 ((mul_lt_mul_left (show 0 < d, from hb.2 ▸ hb.2.symm ▸ hd0)).1
(by rw [← hb.2, nat.mul_div_cancel' (gcd_dvd_left _ _),
nat.mul_div_cancel' (gcd_dvd_right _ _)]; exact hb.1)),
hb.2 ▸ coprime_div_gcd_div_gcd (hb.2.symm ▸ hd0)⟩,
hb.2 ▸ nat.mul_div_cancel' (gcd_dvd_right _ _)⟩))
... = ((filter (∣ n) (range n.succ)).bind (λ d, (range n).filter (λ m, gcd n m = d))).card :
(card_bind (by simp [finset.ext]; cc)).symm
... = (range n).card :
congr_arg card (finset.ext.2 (λ m, ⟨by finish,
λ hm, have h : m < n, from mem_range.1 hm,
mem_bind.2 ⟨gcd n m, mem_filter.2 ⟨mem_range.2 (lt_succ_of_le (le_of_dvd (lt_of_le_of_lt (nat.zero_le _) h)
(gcd_dvd_left _ _))), gcd_dvd_left _ _⟩, mem_filter.2 ⟨hm, rfl⟩⟩⟩))
... = n : card_range _
end nat |
b4c8cafa43b3a9a1325a49c429223353efe94070 | a9fe717b93ccfa4b2e64faeb24f96dfefb390240 | /clause.lean | 050464898116a076cb48eaef73b1b87178a5ce80 | [] | no_license | skbaek/omega | ab1f4a6daadfc8c855f14c39d9459ab841527141 | 715e384ed14e8eb177a326700066e7c98269e078 | refs/heads/master | 1,588,000,876,352 | 1,552,645,917,000 | 1,552,645,917,000 | 174,442,914 | 1 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,735 | lean | import .term
@[reducible] def clause := (list term) × (list term)
namespace clause
def weaker : clause → clause → Prop
| ⟨eqs1,les1⟩ ⟨eqs2,les2⟩ := eqs1 ⊆ eqs2 ∧ les1 ⊆ les2
def holds (v) : clause → Prop
| (eqs,les) :=
( (∀ t : term, t ∈ eqs → 0 = term.val v t)
∧ (∀ t : term, t ∈ les → 0 ≤ term.val v t) )
lemma holds_of_weaker {v c1 c2} :
weaker c1 c2 → holds v c2 → holds v c1 :=
begin
intros h1 h2,
cases c1 with eqs1 les1,
cases c2 with eqs2 les2,
constructor,
{ apply list.forall_mem_of_subset h1.left h2.left },
{ apply list.forall_mem_of_subset h1.right h2.right },
end
def sat (c : clause) : Prop :=
∃ v : nat → int, holds v c
lemma sat_of_weaker { c1 c2} :
weaker c1 c2 → sat c2 → sat c1 :=
begin
intros h1 h2, cases h2 with v h2,
refine ⟨v,holds_of_weaker h1 h2⟩,
end
def unsat (c : clause) : Prop := ¬ c.sat
def append (c1 c2 : clause) : clause :=
(c1.fst ++ c2.fst, c1.snd ++ c2.snd)
def holds_append {v c1 c2} :
holds v c1 → holds v c2 → holds v (append c1 c2) :=
begin
intros h1 h2,
cases c1 with eqs1 les1,
cases c2 with eqs2 les2,
cases h1, cases h2,
constructor; rw list.forall_mem_append;
constructor; assumption,
end
end clause
def clauses.sat (ps : list clause) : Prop :=
∃ c ∈ ps, clause.sat c
def clauses.unsat (ps) : Prop := ¬ clauses.sat ps
lemma clauses.unsat_nil : clauses.unsat [] :=
begin intro h1, rcases h1 with ⟨c,h1,h2⟩, cases h1 end
lemma clauses.unsat_cons (p ps) :
clause.unsat p → clauses.unsat ps →
clauses.unsat (p::ps) | h1 h2 h3 :=
begin
simp only [clauses.sat] at h3,
rw list.exists_mem_cons_iff at h3,
cases h3; contradiction,
end
|
791e93a97ac7b573017bff3eae109561e3e64094 | ee8cdbabf07f77e7be63a449b8483ce308d37218 | /lean/src/test/amc12-2001-p21.lean | b9364b16055b7f13671c93db212415808d2b698b | [
"MIT",
"Apache-2.0"
] | permissive | zeta1999/miniF2F | 6d66c75d1c18152e224d07d5eed57624f731d4b7 | c1ba9629559c5273c92ec226894baa0c1ce27861 | refs/heads/main | 1,681,897,460,642 | 1,620,646,361,000 | 1,620,646,361,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 367 | lean | /-
Copyright (c) 2021 OpenAI. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kunhao Zheng
-/
import data.nat.basic
import data.nat.factorial
example (a b c d : ℕ) (h₀ : a*b*c*d = nat.factorial 8) (h₁ : a*b + a + b = 524) (h₂ : b*c + b + c = 146) (h₃ : c*d + c + d = 104) : a - d = 10 :=
begin
sorry
end
|
fea5bc1f728df9cb69cb47c8fa9b5b50897abe35 | 957a80ea22c5abb4f4670b250d55534d9db99108 | /library/init/meta/smt/ematch.lean | b47f81055005748caea3c0caea250972becd78e4 | [
"Apache-2.0"
] | permissive | GaloisInc/lean | aa1e64d604051e602fcf4610061314b9a37ab8cd | f1ec117a24459b59c6ff9e56a1d09d9e9e60a6c0 | refs/heads/master | 1,592,202,909,807 | 1,504,624,387,000 | 1,504,624,387,000 | 75,319,626 | 2 | 1 | Apache-2.0 | 1,539,290,164,000 | 1,480,616,104,000 | C++ | UTF-8 | Lean | false | false | 7,478 | lean | /-
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import init.meta.smt.congruence_closure
import init.meta.attribute init.meta.simp_tactic
import init.meta.interactive_base
open tactic
/-- Heuristic instantiation lemma -/
meta constant hinst_lemma : Type
meta constant hinst_lemmas : Type
/-- `mk_core m e as_simp`, m is used to decide which definitions will be unfolded in patterns.
If as_simp is tt, then this tactic will try to use the left-hand-side of the conclusion
as a pattern. -/
meta constant hinst_lemma.mk_core : transparency → expr → bool → tactic hinst_lemma
meta constant hinst_lemma.mk_from_decl_core : transparency → name → bool → tactic hinst_lemma
meta constant hinst_lemma.pp : hinst_lemma → tactic format
meta constant hinst_lemma.id : hinst_lemma → name
meta instance : has_to_tactic_format hinst_lemma :=
⟨hinst_lemma.pp⟩
meta def hinst_lemma.mk (h : expr) : tactic hinst_lemma :=
hinst_lemma.mk_core reducible h ff
meta def hinst_lemma.mk_from_decl (h : name) : tactic hinst_lemma :=
hinst_lemma.mk_from_decl_core reducible h ff
meta constant hinst_lemmas.mk : hinst_lemmas
meta constant hinst_lemmas.add : hinst_lemmas → hinst_lemma → hinst_lemmas
meta constant hinst_lemmas.fold {α : Type} : hinst_lemmas → α → (hinst_lemma → α → α) → α
meta constant hinst_lemmas.merge : hinst_lemmas → hinst_lemmas → hinst_lemmas
meta def mk_hinst_singleton : hinst_lemma → hinst_lemmas :=
hinst_lemmas.add hinst_lemmas.mk
meta def hinst_lemmas.pp (s : hinst_lemmas) : tactic format :=
let tac := s.fold (return format.nil)
(λ h tac, do
hpp ← h.pp,
r ← tac,
if r.is_nil then return hpp
else return format!"{r},\n{hpp}")
in do
r ← tac,
return $ format.cbrace (format.group r)
meta instance : has_to_tactic_format hinst_lemmas :=
⟨hinst_lemmas.pp⟩
open tactic
private meta def add_lemma (m : transparency) (as_simp : bool) (h : name) (hs : hinst_lemmas) : tactic hinst_lemmas :=
do h ← hinst_lemma.mk_from_decl_core m h as_simp, return $ hs.add h
meta def to_hinst_lemmas_core (m : transparency) : bool → list name → hinst_lemmas → tactic hinst_lemmas
| as_simp [] hs := return hs
| as_simp (n::ns) hs :=
let add n := add_lemma m as_simp n hs >>= to_hinst_lemmas_core as_simp ns
in do
/- First check if n is the name of a function with equational lemmas associated with it -/
eqns ← tactic.get_eqn_lemmas_for tt n,
match eqns with
| [] := do
/- n is not the name of a function definition or it does not have equational lemmas, then check if it is a lemma -/
add n
| _ := do
p ← is_prop_decl n,
if p then add n /- n is a proposition -/
else do
/- Add equational lemmas to resulting hinst_lemmas -/
new_hs ← to_hinst_lemmas_core tt eqns hs,
to_hinst_lemmas_core as_simp ns new_hs
end
meta def mk_hinst_lemma_attr_core (attr_name : name) (as_simp : bool) : command :=
do let t := `(caching_user_attribute hinst_lemmas),
let v := `({name := attr_name,
descr := "hinst_lemma attribute",
after_set := some $ λ n _ _,
to_hinst_lemmas_core reducible as_simp [n] hinst_lemmas.mk >> skip <|>
fail format!"invalid ematch lemma '{n}'",
-- allow unsetting
before_unset := some $ λ _ _, skip,
mk_cache := λ ns, to_hinst_lemmas_core reducible as_simp ns hinst_lemmas.mk,
dependencies := [`reducibility] } : caching_user_attribute hinst_lemmas),
add_decl (declaration.defn attr_name [] t v reducibility_hints.abbrev ff),
attribute.register attr_name
meta def mk_hinst_lemma_attrs_core (as_simp : bool) : list name → command
| [] := skip
| (n::ns) :=
(mk_hinst_lemma_attr_core n as_simp >> mk_hinst_lemma_attrs_core ns)
<|>
(do type ← infer_type (expr.const n []),
let expected := `(caching_user_attribute hinst_lemmas),
(is_def_eq type expected
<|> fail format!"failed to create hinst_lemma attribute '{n}', declaration already exists and has different type."),
mk_hinst_lemma_attrs_core ns)
meta def merge_hinst_lemma_attrs (m : transparency) (as_simp : bool) : list name → hinst_lemmas → tactic hinst_lemmas
| [] hs := return hs
| (attr::attrs) hs := do
ns ← attribute.get_instances attr,
new_hs ← to_hinst_lemmas_core m as_simp ns hs,
merge_hinst_lemma_attrs attrs new_hs
/--
Create a new "cached" attribute (attr_name : caching_user_attribute hinst_lemmas).
It also creates "cached" attributes for each attr_names and simp_attr_names if they have not been defined
yet. Moreover, the hinst_lemmas for attr_name will be the union of the lemmas tagged with
attr_name, attrs_name, and simp_attr_names.
For the ones in simp_attr_names, we use the left-hand-side of the conclusion as the pattern.
-/
meta def mk_hinst_lemma_attr_set (attr_name : name) (attr_names : list name) (simp_attr_names : list name) : command :=
do mk_hinst_lemma_attrs_core ff attr_names,
mk_hinst_lemma_attrs_core tt simp_attr_names,
let t := `(caching_user_attribute hinst_lemmas),
let v := `({name := attr_name,
descr := "hinst_lemma attribute set",
after_set := some $ λ n _ _,
to_hinst_lemmas_core reducible ff [n] hinst_lemmas.mk >> skip <|>
fail format!"invalid ematch lemma '{n}'",
-- allow unsetting
before_unset := some $ λ _ _, skip,
mk_cache := λ ns, do {
hs₁ ← to_hinst_lemmas_core reducible ff ns hinst_lemmas.mk,
hs₂ ← merge_hinst_lemma_attrs reducible ff attr_names hs₁,
merge_hinst_lemma_attrs reducible tt simp_attr_names hs₂},
dependencies := [`reducibility] ++ attr_names ++ simp_attr_names } : caching_user_attribute hinst_lemmas),
add_decl (declaration.defn attr_name [] t v reducibility_hints.abbrev ff),
attribute.register attr_name
meta def get_hinst_lemmas_for_attr (attr_name : name) : tactic hinst_lemmas :=
do
cnst ← return (expr.const attr_name []),
attr ← eval_expr (caching_user_attribute hinst_lemmas) cnst,
caching_user_attribute.get_cache attr
structure ematch_config :=
(max_instances : nat := 10000)
(max_generation : nat := 10)
/- Ematching -/
meta constant ematch_state : Type
meta constant ematch_state.mk : ematch_config → ematch_state
meta constant ematch_state.internalize : ematch_state → expr → tactic ematch_state
namespace tactic
meta constant ematch_core : transparency → cc_state → ematch_state → hinst_lemma → expr → tactic (list (expr × expr) × cc_state × ematch_state)
meta constant ematch_all_core : transparency → cc_state → ematch_state → hinst_lemma → bool → tactic (list (expr × expr) × cc_state × ematch_state)
meta def ematch : cc_state → ematch_state → hinst_lemma → expr → tactic (list (expr × expr) × cc_state × ematch_state) :=
ematch_core reducible
meta def ematch_all : cc_state → ematch_state → hinst_lemma → bool → tactic (list (expr × expr) × cc_state × ematch_state) :=
ematch_all_core reducible
end tactic
|
c13a7880dce169929ca8d749a103e2581a09d49e | d450724ba99f5b50b57d244eb41fef9f6789db81 | /src/mywork/lectures/lecture_14.lean | c3d08d682809f5574ea0ecaf5236119245820719 | [] | no_license | jakekauff/CS2120F21 | 4f009adeb4ce4a148442b562196d66cc6c04530c | e69529ec6f5d47a554291c4241a3d8ec4fe8f5ad | refs/heads/main | 1,693,841,880,030 | 1,637,604,848,000 | 1,637,604,848,000 | 399,946,698 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,577 | lean | /-
Note this this file is called lecture 14,
though today, October, 6, is more than 14
course days in. The reason is that the last
two days were review Q&A in preparation for
the mid-term.
-/
/-
REVIEW INTRODUCTION AND ELIMINATION RULES FOR EXISTS.
-/
/-
LET'S PROVE A THEOREM INVOLVING EXISTS, ALL, AND NEGATION
-/
/-
Is it true that if not everyone likes themselves
then there is someone who doesn't like themself?
-/
/-
Challenge #1: Set up the domain model and then
express the proposition about it. In this case,
the domain model includes people and a binary
likes relation "over" people.
-/
axioms
(Person : Type)
(Likes : Person → Person → Prop)
example :
¬ (∀ p : Person, Likes p p) ↔
∃ p : Person, ¬ Likes p p :=
begin
apply iff.intro,
-- forward
assume h,
have f := classical.em (∃ (p : Person), ¬Likes p p),
cases f,
-- case #1: there IS someone who dislikes themself
assumption,
-- case #2: there IS NOT someone who dislikes themself
-- propose new fact, proof to be constructed in this context
have contra : ∀ (p : Person), Likes p p := _,
-- prove current goal using proposed fact
contradiction,
-- still have to prove supposition
assume p,
-- same trick again!
have g := classical.em (Likes p p),
cases g,
assumption,
have a : ∃ (p : Person), ¬Likes p p := exists.intro p g,
contradiction,
-- backward
assume h,
cases h with p l,
assume a,
have d := a p,
contradiction,
end
theorem not_all_iff_ex_not :
∀ (T : Type) (R : T → T → Prop),
¬ (∀ t : T, R t t) ↔ ∃ t : T, ¬ R t t
:=
begin
end
|
de73d0d66ee61aca11878ba80be6a3ab24acc238 | e953c38599905267210b87fb5d82dcc3e52a4214 | /library/data/real/order.lean | 627b32483287fdb4cc9aeb6358da97f20fec429a | [
"Apache-2.0"
] | permissive | c-cube/lean | 563c1020bff98441c4f8ba60111fef6f6b46e31b | 0fb52a9a139f720be418dafac35104468e293b66 | refs/heads/master | 1,610,753,294,113 | 1,440,451,356,000 | 1,440,499,588,000 | 41,748,334 | 0 | 0 | null | 1,441,122,656,000 | 1,441,122,656,000 | null | UTF-8 | Lean | false | false | 36,329 | lean | /-
Copyright (c) 2015 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Robert Y. Lewis
The real numbers, constructed as equivalence classes of Cauchy sequences of rationals.
This construction follows Bishop and Bridges (1985).
To do:
o Rename things and possibly make theorems private
-/
import data.real.basic data.rat data.nat
open -[coercions] rat
open -[coercions] nat
open eq eq.ops pnat
local notation 0 := rat.of_num 0
local notation 1 := rat.of_num 1
notation 2 := subtype.tag (of_num 2) dec_trivial
----------------------------------------------------------------------------------------------------
namespace s
definition pos (s : seq) := ∃ n : ℕ+, n⁻¹ < (s n)
definition nonneg (s : seq) := ∀ n : ℕ+, -(n⁻¹) ≤ s n
theorem bdd_away_of_pos {s : seq} (Hs : regular s) (H : pos s) :
∃ N : ℕ+, ∀ n : ℕ+, n ≥ N → (s n) ≥ N⁻¹ :=
begin
cases H with [n, Hn],
cases sep_by_inv Hn with [N, HN],
existsi N,
intro m Hm,
have Habs : abs (s m - s n) ≥ s n - s m, by rewrite abs_sub; apply le_abs_self,
have Habs' : s m + abs (s m - s n) ≥ s n, from (iff.mpr (le_add_iff_sub_left_le _ _ _)) Habs,
have HN' : N⁻¹ + N⁻¹ ≤ s n - n⁻¹, begin
apply iff.mpr (le_add_iff_sub_right_le _ _ _),
rewrite [sub_neg_eq_add, add.comm, -add.assoc],
apply le_of_lt HN
end,
rewrite rat.add.comm at Habs',
have Hin : s m ≥ N⁻¹, from calc
s m ≥ s n - abs (s m - s n) : (iff.mp (le_add_iff_sub_left_le _ _ _)) Habs'
... ≥ s n - (m⁻¹ + n⁻¹) : rat.sub_le_sub_left !Hs
... = s n - m⁻¹ - n⁻¹ : by rewrite sub_add_eq_sub_sub
... = s n - n⁻¹ - m⁻¹ : by rewrite [add.assoc, (add.comm (-m⁻¹)), -add.assoc]
... ≥ s n - n⁻¹ - N⁻¹ : rat.sub_le_sub_left (inv_ge_of_le Hm)
... ≥ N⁻¹ + N⁻¹ - N⁻¹ : rat.sub_le_sub_right HN'
... = N⁻¹ : by rewrite rat.add_sub_cancel,
apply Hin
end
theorem pos_of_bdd_away {s : seq} (H : ∃ N : ℕ+, ∀ n : ℕ+, n ≥ N → (s n) ≥ N⁻¹) : pos s :=
begin
cases H with [N, HN],
existsi (N + pone),
apply lt_of_lt_of_le,
apply inv_add_lt_left,
apply HN,
apply pnat.le_of_lt,
apply lt_add_left
end
theorem bdd_within_of_nonneg {s : seq} (Hs : regular s) (H : nonneg s) :
∀ n : ℕ+, ∃ N : ℕ+, ∀ m : ℕ+, m ≥ N → s m ≥ -n⁻¹ :=
begin
intros,
existsi n,
intro m Hm,
apply le.trans,
apply neg_le_neg,
apply inv_ge_of_le,
apply Hm,
apply H
end
theorem nonneg_of_bdd_within {s : seq} (Hs : regular s)
(H : ∀n : ℕ+, ∃ N : ℕ+, ∀ m : ℕ+, m ≥ N → s m ≥ -n⁻¹) : nonneg s :=
begin
rewrite ↑nonneg,
intro k,
apply squeeze_2,
intro ε Hε,
cases H (pceil ((1 + 1) / ε)) with [N, HN],
apply le.trans,
rotate 1,
apply ge_sub_of_abs_sub_le_left,
apply Hs,
apply (max (pceil ((1+1)/ε)) N),
rewrite [↑rat.sub, neg_add, {_ + (-k⁻¹ + _)}add.comm, *add.assoc],
apply rat.add_le_add_left,
apply le.trans,
rotate 1,
apply rat.add_le_add,
rotate 1,
apply HN (max (pceil ((1+1)/ε)) N) !max_right,
rotate_right 1,
apply neg_le_neg,
apply inv_ge_of_le,
apply max_left,
rewrite -neg_add,
apply neg_le_neg,
apply le.trans,
apply rat.add_le_add,
repeat (apply inv_pceil_div;
apply rat.add_pos;
repeat apply zero_lt_one;
apply Hε),
have Hone : 1 = of_num 1, from rfl,
rewrite [Hone, add_halves],
apply le.refl
end
theorem pos_of_pos_equiv {s t : seq} (Hs : regular s) (Heq : s ≡ t) (Hp : pos s) : pos t :=
begin
cases (bdd_away_of_pos Hs Hp) with [N, HN],
existsi 2 * 2 * N,
apply lt_of_lt_of_le,
rotate 1,
apply ge_sub_of_abs_sub_le_right,
apply Heq,
have Hs4 : N⁻¹ ≤ s (2 * 2 * N), from HN _ (!mul_le_mul_left),
apply lt_of_lt_of_le,
rotate 1,
apply iff.mpr !rat.add_le_add_right_iff,
apply Hs4,
rewrite [*pnat.mul.assoc, pnat.add_halves, -(add_halves N), rat.add_sub_cancel],
apply inv_two_mul_lt_inv
end
theorem nonneg_of_nonneg_equiv {s t : seq} (Hs : regular s) (Ht : regular t) (Heq : s ≡ t)
(Hp : nonneg s) : nonneg t :=
begin
apply nonneg_of_bdd_within,
apply Ht,
intros,
cases bdd_within_of_nonneg Hs Hp (2 * 2 * n) with [Ns, HNs],
existsi max Ns (2 * 2 * n),
intro m Hm,
apply le.trans,
rotate 1,
apply ge_sub_of_abs_sub_le_right,
apply Heq,
apply le.trans,
rotate 1,
apply rat.sub_le_sub_right,
apply HNs,
apply pnat.le.trans,
rotate 1,
apply Hm,
rotate_right 1,
apply max_left,
have Hms : m⁻¹ ≤ (2 * 2 * n)⁻¹, begin
apply inv_ge_of_le,
apply pnat.le.trans,
rotate 1,
apply Hm;
apply max_right
end,
have Hms' : m⁻¹ + m⁻¹ ≤ (2 * 2 * n)⁻¹ + (2 * 2 * n)⁻¹, from add_le_add Hms Hms,
apply le.trans,
rotate 1,
apply rat.sub_le_sub_left,
apply Hms',
rewrite [*pnat.mul.assoc, pnat.add_halves, -neg_add, -add_halves n],
apply neg_le_neg,
apply rat.add_le_add_right,
apply inv_two_mul_le_inv
end
definition s_le (a b : seq) := nonneg (sadd b (sneg a))
definition s_lt (a b : seq) := pos (sadd b (sneg a))
theorem zero_nonneg : nonneg zero :=
begin
intros,
apply neg_nonpos_of_nonneg,
apply le_of_lt,
apply inv_pos
end
theorem s_zero_lt_one : s_lt zero one :=
begin
rewrite [↑s_lt, ↑zero, ↑sadd, ↑sneg, ↑one, neg_zero, add_zero, ↑pos],
existsi 2,
apply inv_lt_one_of_gt,
apply one_lt_two
end
theorem le.refl {s : seq} (Hs : regular s) : s_le s s :=
begin
apply nonneg_of_nonneg_equiv,
rotate 2,
apply equiv.symm,
apply neg_s_cancel s Hs,
apply zero_nonneg,
apply zero_is_reg,
apply reg_add_reg Hs (reg_neg_reg Hs)
end
theorem s_nonneg_of_pos {s : seq} (Hs : regular s) (H : pos s) : nonneg s :=
begin
apply nonneg_of_bdd_within,
apply Hs,
intros,
cases bdd_away_of_pos Hs H with [N, HN],
existsi N,
intro m Hm,
apply le.trans,
rotate 1,
apply HN,
apply Hm,
apply le.trans,
rotate 1,
apply le_of_lt,
apply inv_pos,
rewrite -neg_zero,
apply neg_le_neg,
apply le_of_lt,
apply inv_pos
end
theorem s_le_of_s_lt {s t : seq} (Hs : regular s) (Ht : regular t) (H : s_lt s t) : s_le s t :=
begin
rewrite [↑s_le, ↑s_lt at *],
apply s_nonneg_of_pos,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end
theorem s_neg_add_eq_s_add_neg (s t : seq) : sneg (sadd s t) ≡ sadd (sneg s) (sneg t) :=
begin
rewrite [↑equiv, ↑sadd, ↑sneg],
intros,
rewrite [rat.neg_add, sub_self, abs_zero],
apply add_invs_nonneg
end
theorem equiv_cancel_middle {s t u : seq} (Hs : regular s) (Ht : regular t)
(Hu : regular u) : sadd (sadd u t) (sneg (sadd u s)) ≡ sadd t (sneg s) :=
begin
let Hz := zero_is_reg,
apply equiv.trans,
rotate 3,
apply add_well_defined,
rotate 4,
apply s_add_comm,
apply s_neg_add_eq_s_add_neg,
apply equiv.trans,
rotate 3,
apply s_add_assoc,
rotate 2,
apply add_well_defined,
rotate 4,
apply equiv.refl,
apply equiv.trans,
rotate 4,
apply equiv.refl,
rotate_right 1,
apply equiv.trans,
rotate 3,
apply equiv.symm,
apply s_add_assoc,
rotate 2,
apply equiv.trans,
rotate 4,
apply s_zero_add,
rotate_right 1,
apply add_well_defined,
rotate 4,
apply neg_s_cancel,
rotate 1,
apply equiv.refl,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end
theorem add_le_add_of_le_right {s t : seq} (Hs : regular s) (Ht : regular t) (Lst : s_le s t) :
∀ u : seq, regular u → s_le (sadd u s) (sadd u t) :=
begin
intro u Hu,
rewrite [↑s_le at *],
apply nonneg_of_nonneg_equiv,
rotate 2,
apply equiv.symm,
apply equiv_cancel_middle,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end
theorem s_add_lt_add_left {s t : seq} (Hs : regular s) (Ht : regular t) (Hst : s_lt s t) {u : seq}
(Hu : regular u) : s_lt (sadd u s) (sadd u t) :=
begin
rewrite ↑s_lt at *,
apply pos_of_pos_equiv,
rotate 1,
apply equiv.symm,
apply equiv_cancel_middle,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end
theorem add_nonneg_of_nonneg {s t : seq} (Hs : nonneg s) (Ht : nonneg t) : nonneg (sadd s t) :=
begin
intros,
rewrite [-pnat.add_halves, neg_add],
apply add_le_add,
apply Hs,
apply Ht
end
theorem le.trans {s t u : seq} (Hs : regular s) (Ht : regular t) (Hu : regular u) (Lst : s_le s t)
(Ltu : s_le t u) : s_le s u :=
begin
rewrite ↑s_le at *,
let Rz := zero_is_reg,
have Hsum : nonneg (sadd (sadd u (sneg t)) (sadd t (sneg s))),
from add_nonneg_of_nonneg Ltu Lst,
have H' : nonneg (sadd (sadd u (sadd (sneg t) t)) (sneg s)), begin
apply nonneg_of_nonneg_equiv,
rotate 2,
apply add_well_defined,
rotate 4,
apply s_add_assoc,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption),
apply equiv.refl,
apply nonneg_of_nonneg_equiv,
rotate 2,
apply equiv.symm,
apply s_add_assoc,
rotate 2,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end,
have H'' : sadd (sadd u (sadd (sneg t) t)) (sneg s) ≡ sadd u (sneg s), begin
apply add_well_defined,
rotate 4,
apply equiv.trans,
rotate 3,
apply add_well_defined,
rotate 4,
apply equiv.refl,
apply s_neg_cancel,
rotate 1,
apply s_add_zero,
rotate 1,
apply equiv.refl,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end,
apply nonneg_of_nonneg_equiv,
rotate 2,
apply H'',
apply H',
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end
theorem equiv_of_le_of_ge {s t : seq} (Hs : regular s) (Ht : regular t) (Lst : s_le s t)
(Lts : s_le t s) : s ≡ t :=
begin
apply equiv_of_diff_equiv_zero,
rotate 2,
rewrite [↑s_le at *, ↑nonneg at *, ↑equiv, ↑sadd at *, ↑sneg at *],
intros,
rewrite [↑zero, sub_zero],
apply abs_le_of_le_of_neg_le,
apply le_of_neg_le_neg,
rewrite [2 neg_add, neg_neg],
apply rat.le.trans,
apply rat.neg_add_neg_le_neg_of_pos,
apply inv_pos,
rewrite add.comm,
apply Lst,
apply le_of_neg_le_neg,
rewrite [neg_add, neg_neg],
apply rat.le.trans,
apply rat.neg_add_neg_le_neg_of_pos,
apply inv_pos,
apply Lts,
repeat assumption
end
definition sep (s t : seq) := s_lt s t ∨ s_lt t s
local infix `≢` : 50 := sep
theorem le_and_sep_of_lt {s t : seq} (Hs : regular s) (Ht : regular t) (Lst : s_lt s t) :
s_le s t ∧ sep s t :=
begin
apply and.intro,
intros,
cases Lst with [N, HN],
let Rns := reg_neg_reg Hs,
let Rtns := reg_add_reg Ht Rns,
let Habs := ge_sub_of_abs_sub_le_right (Rtns N n),
rewrite [sub_add_eq_sub_sub at Habs],
exact (calc
sadd t (sneg s) n ≥ sadd t (sneg s) N - N⁻¹ - n⁻¹ : Habs
... ≥ 0 - n⁻¹: begin
apply rat.sub_le_sub_right,
apply le_of_lt,
apply (iff.mpr (sub_pos_iff_lt _ _)),
apply HN
end
... = -n⁻¹ : by rewrite zero_sub),
exact or.inl Lst
end
theorem lt_of_le_and_sep {s t : seq} (Hs : regular s) (Ht : regular t) (H : s_le s t ∧ sep s t) :
s_lt s t :=
begin
let Le := and.left H,
cases and.right H with [P, Hlt],
exact P,
rewrite [↑s_le at Le, ↑nonneg at Le, ↑s_lt at Hlt, ↑pos at Hlt],
apply exists.elim Hlt,
intro N HN,
let LeN := Le N,
let HN' := (iff.mpr !neg_lt_neg_iff_lt) HN,
rewrite [↑sadd at HN', ↑sneg at HN', neg_add at HN', neg_neg at HN', add.comm at HN'],
let HN'' := not_le_of_gt HN',
apply absurd LeN HN''
end
theorem lt_iff_le_and_sep {s t : seq} (Hs : regular s) (Ht : regular t) :
s_lt s t ↔ s_le s t ∧ sep s t :=
iff.intro (le_and_sep_of_lt Hs Ht) (lt_of_le_and_sep Hs Ht)
theorem s_neg_zero : sneg zero ≡ zero :=
begin
rewrite ↑[sneg, zero, equiv],
intros,
rewrite [sub_zero, abs_neg, abs_zero],
apply add_invs_nonneg
end
theorem s_sub_zero {s : seq} (Hs : regular s) : sadd s (sneg zero) ≡ s :=
begin
apply equiv.trans,
rotate 3,
apply add_well_defined,
rotate 4,
apply equiv.refl,
apply s_neg_zero,
apply s_add_zero,
repeat (assumption | apply reg_add_reg | apply reg_neg_reg | apply zero_is_reg)
end
theorem s_pos_of_gt_zero {s : seq} (Hs : regular s) (Hgz : s_lt zero s) : pos s :=
begin
rewrite [↑s_lt at *],
apply pos_of_pos_equiv,
rotate 1,
apply s_sub_zero,
repeat (assumption | apply reg_add_reg | apply reg_neg_reg),
apply zero_is_reg
end
theorem s_gt_zero_of_pos {s : seq} (Hs : regular s) (Hp : pos s) : s_lt zero s :=
begin
rewrite ↑s_lt,
apply pos_of_pos_equiv,
rotate 1,
apply equiv.symm,
apply s_sub_zero,
repeat assumption
end
theorem s_nonneg_of_ge_zero {s : seq} (Hs : regular s) (Hgz : s_le zero s) : nonneg s :=
begin
rewrite ↑s_le at *,
apply nonneg_of_nonneg_equiv,
rotate 2,
apply s_sub_zero,
repeat (assumption | apply reg_add_reg | apply reg_neg_reg | apply zero_is_reg)
end
theorem s_ge_zero_of_nonneg {s : seq} (Hs : regular s) (Hn : nonneg s) : s_le zero s :=
begin
rewrite ↑s_le,
apply nonneg_of_nonneg_equiv,
rotate 2,
apply equiv.symm,
apply s_sub_zero,
repeat (assumption | apply reg_add_reg | apply reg_neg_reg | apply zero_is_reg)
end
theorem s_mul_pos_of_pos {s t : seq} (Hs : regular s) (Ht : regular t) (Hps : pos s)
(Hpt : pos t) : pos (smul s t) :=
begin
rewrite [↑pos at *],
cases bdd_away_of_pos Hs Hps with [Ns, HNs],
cases bdd_away_of_pos Ht Hpt with [Nt, HNt],
existsi 2 * max Ns Nt * max Ns Nt,
rewrite ↑smul,
apply lt_of_lt_of_le,
rotate 1,
apply rat.mul_le_mul,
apply HNs,
apply pnat.le.trans,
apply max_left Ns Nt,
rewrite -pnat.mul.assoc,
apply pnat.mul_le_mul_left,
apply HNt,
apply pnat.le.trans,
apply max_right Ns Nt,
rewrite -pnat.mul.assoc,
apply pnat.mul_le_mul_left,
apply le_of_lt,
apply inv_pos,
apply rat.le.trans,
rotate 1,
apply HNs,
apply pnat.le.trans,
apply max_left Ns Nt,
rewrite -pnat.mul.assoc,
apply pnat.mul_le_mul_left,
rewrite inv_mul_eq_mul_inv,
apply rat.mul_lt_mul,
rewrite [inv_mul_eq_mul_inv, -one_mul Ns⁻¹],
apply rat.mul_lt_mul,
apply inv_lt_one_of_gt,
apply dec_trivial,
apply inv_ge_of_le,
apply max_left,
apply inv_pos,
apply le_of_lt zero_lt_one,
apply inv_ge_of_le,
apply max_right,
apply inv_pos,
repeat (apply le_of_lt; apply inv_pos)
end
theorem s_mul_gt_zero_of_gt_zero {s t : seq} (Hs : regular s) (Ht : regular t)
(Hzs : s_lt zero s) (Hzt : s_lt zero t) : s_lt zero (smul s t) :=
s_gt_zero_of_pos
(reg_mul_reg Hs Ht)
(s_mul_pos_of_pos Hs Ht (s_pos_of_gt_zero Hs Hzs) (s_pos_of_gt_zero Ht Hzt))
theorem le_of_lt_or_equiv {s t : seq} (Hs : regular s) (Ht : regular t)
(Hor : (s_lt s t) ∨ (s ≡ t)) : s_le s t :=
or.elim Hor
(begin
intro Hlt,
apply s_le_of_s_lt Hs Ht Hlt
end)
(begin
intro Heq,
rewrite ↑s_le,
apply nonneg_of_nonneg_equiv,
rotate 3,
apply zero_nonneg,
apply zero_is_reg,
apply reg_add_reg Ht (reg_neg_reg Hs),
apply equiv.symm,
apply diff_equiv_zero_of_equiv,
rotate 2,
apply equiv.symm,
apply Heq,
repeat assumption
end)
theorem s_zero_mul {s : seq} : smul s zero ≡ zero :=
begin
rewrite [↑equiv, ↑smul, ↑zero],
intros,
rewrite [mul_zero, sub_zero, abs_zero],
apply add_invs_nonneg
end
theorem s_mul_nonneg_of_pos_of_zero {s t : seq} (Hs : regular s) (Ht : regular t)
(Hps : pos s) (Hpt : zero ≡ t) : nonneg (smul s t) :=
begin
apply nonneg_of_nonneg_equiv,
rotate 2,
apply mul_well_defined,
rotate 4,
apply equiv.refl,
apply Hpt,
apply nonneg_of_nonneg_equiv,
rotate 2,
apply equiv.symm,
apply s_zero_mul,
apply zero_nonneg,
repeat (assumption | apply reg_mul_reg | apply zero_is_reg)
end
theorem s_mul_nonneg_of_nonneg {s t : seq} (Hs : regular s) (Ht : regular t)
(Hps : nonneg s) (Hpt : nonneg t) : nonneg (smul s t) :=
begin
intro n,
rewrite ↑smul,
apply rat.le.by_cases 0 (s (((K₂ s t) * 2) * n)),
intro Hsp,
apply rat.le.by_cases 0 (t (((K₂ s t) * 2) * n)),
intro Htp,
apply rat.le.trans,
rotate 1,
apply rat.mul_nonneg Hsp Htp,
rotate_right 1,
apply le_of_lt,
apply neg_neg_of_pos,
apply inv_pos,
intro Htn,
apply rat.le.trans,
rotate 1,
apply rat.mul_le_mul_of_nonpos_right,
apply rat.le.trans,
apply le_abs_self,
apply canon_2_bound_left s t Hs,
apply Htn,
rotate_right 1,
apply rat.le.trans,
rotate 1,
apply rat.mul_le_mul_of_nonneg_left,
apply Hpt,
apply le_of_lt,
apply rat_of_pnat_is_pos,
rotate 1,
rewrite -neg_mul_eq_mul_neg,
apply neg_le_neg,
rewrite [*pnat.mul.assoc, inv_mul_eq_mul_inv, -mul.assoc, inv_cancel_left, one_mul],
apply inv_ge_of_le,
apply pnat.mul_le_mul_left,
intro Hsn,
apply rat.le.by_cases 0 (t (((K₂ s t) * 2) * n)),
intro Htp,
apply rat.le.trans,
rotate 1,
apply rat.mul_le_mul_of_nonpos_left,
apply rat.le.trans,
apply le_abs_self,
apply canon_2_bound_right s t Ht,
apply Hsn,
rotate_right 1,
apply rat.le.trans,
rotate 1,
apply rat.mul_le_mul_of_nonneg_right,
apply Hps,
apply le_of_lt,
apply rat_of_pnat_is_pos,
rotate 1,
rewrite -neg_mul_eq_neg_mul,
apply neg_le_neg,
rewrite [*pnat.mul.assoc, inv_mul_eq_mul_inv, mul.comm, -mul.assoc, inv_cancel_left, one_mul],
apply inv_ge_of_le,
apply pnat.mul_le_mul_left,
intro Htn,
apply rat.le.trans,
rotate 1,
apply mul_nonneg_of_nonpos_of_nonpos,
apply Hsn,
apply Htn,
apply le_of_lt,
apply neg_neg_of_pos,
apply inv_pos
end
theorem s_mul_ge_zero_of_ge_zero {s t : seq} (Hs : regular s) (Ht : regular t)
(Hzs : s_le zero s) (Hzt : s_le zero t) : s_le zero (smul s t) :=
begin
let Hzs' := s_nonneg_of_ge_zero Hs Hzs,
let Htz' := s_nonneg_of_ge_zero Ht Hzt,
apply s_ge_zero_of_nonneg,
rotate 1,
apply s_mul_nonneg_of_nonneg,
repeat assumption,
apply reg_mul_reg Hs Ht
end
theorem not_lt_self (s : seq) : ¬ s_lt s s :=
begin
intro Hlt,
rewrite [↑s_lt at Hlt, ↑pos at Hlt],
apply exists.elim Hlt,
intro n Hn, esimp at Hn,
rewrite [↑sadd at Hn,↑sneg at Hn, sub_self at Hn],
apply absurd Hn (rat.not_lt_of_ge (rat.le_of_lt !inv_pos))
end
theorem not_sep_self (s : seq) : ¬ s ≢ s :=
begin
intro Hsep,
rewrite ↑sep at Hsep,
let Hsep' := (iff.mp !or_self) Hsep,
apply absurd Hsep' (!not_lt_self)
end
theorem le_well_defined {s t u v : seq} (Hs : regular s) (Ht : regular t) (Hu : regular u)
(Hv : regular v) (Hsu : s ≡ u) (Htv : t ≡ v) : s_le s t ↔ s_le u v :=
iff.intro
(begin
intro Hle,
rewrite [↑s_le at *],
apply nonneg_of_nonneg_equiv,
rotate 2,
apply add_well_defined,
rotate 4,
apply Htv,
apply neg_well_defined,
apply Hsu,
apply Hle,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end)
(begin
intro Hle,
rewrite [↑s_le at *],
apply nonneg_of_nonneg_equiv,
rotate 2,
apply add_well_defined,
rotate 4,
apply equiv.symm, apply Htv,
apply neg_well_defined,
apply equiv.symm, apply Hsu,
apply Hle,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end)
theorem lt_well_defined {s t u v : seq} (Hs : regular s) (Ht : regular t) (Hu : regular u)
(Hv : regular v) (Hsu : s ≡ u) (Htv : t ≡ v) : s_lt s t ↔ s_lt u v :=
iff.intro
(begin
intro Hle,
rewrite [↑s_lt at *],
apply pos_of_pos_equiv,
rotate 1,
apply add_well_defined,
rotate 4,
apply Htv,
apply neg_well_defined,
apply Hsu,
apply Hle,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end)
(begin
intro Hle,
rewrite [↑s_lt at *],
apply pos_of_pos_equiv,
rotate 1,
apply add_well_defined,
rotate 4,
apply equiv.symm, apply Htv,
apply neg_well_defined,
apply equiv.symm, apply Hsu,
apply Hle,
repeat (apply reg_add_reg | apply reg_neg_reg | assumption)
end)
theorem sep_well_defined {s t u v : seq} (Hs : regular s) (Ht : regular t) (Hu : regular u)
(Hv : regular v) (Hsu : s ≡ u) (Htv : t ≡ v) : s ≢ t ↔ u ≢ v :=
begin
rewrite ↑sep,
apply iff.intro,
intro Hor,
apply or.elim Hor,
intro Hlt,
apply or.inl,
apply iff.mp (lt_well_defined Hs Ht Hu Hv Hsu Htv),
assumption,
intro Hlt,
apply or.inr,
apply iff.mp (lt_well_defined Ht Hs Hv Hu Htv Hsu),
assumption,
intro Hor,
apply or.elim Hor,
intro Hlt,
apply or.inl,
apply iff.mpr (lt_well_defined Hs Ht Hu Hv Hsu Htv),
assumption,
intro Hlt,
apply or.inr,
apply iff.mpr (lt_well_defined Ht Hs Hv Hu Htv Hsu),
assumption
end
theorem s_lt_of_lt_of_le {s t u : seq} (Hs : regular s) (Ht : regular t) (Hu : regular u)
(Hst : s_lt s t) (Htu : s_le t u) : s_lt s u :=
begin
let Rtns := reg_add_reg Ht (reg_neg_reg Hs),
let Runt := reg_add_reg Hu (reg_neg_reg Ht),
have Hcan : ∀ m, sadd u (sneg s) m = (sadd t (sneg s)) m + (sadd u (sneg t)) m, begin
intro m,
rewrite [↑sadd, ↑sneg, -sub_eq_sub_add_sub]
end,
rewrite [↑s_lt at *, ↑s_le at *],
cases bdd_away_of_pos Rtns Hst with [Nt, HNt],
cases bdd_within_of_nonneg Runt Htu (2 * Nt) with [Nu, HNu],
apply pos_of_bdd_away,
existsi max (2 * Nt) Nu,
intro n Hn,
rewrite Hcan,
apply rat.le.trans,
rotate 1,
apply rat.add_le_add,
apply HNt,
apply pnat.le.trans,
apply mul_le_mul_left 2,
apply pnat.le.trans,
rotate 1,
apply Hn,
rotate_right 1,
apply max_left,
apply HNu,
apply pnat.le.trans,
rotate 1,
apply Hn,
rotate_right 1,
apply max_right,
rewrite [-add_halves Nt, rat.add_sub_cancel],
apply inv_ge_of_le,
apply max_left
end
theorem s_lt_of_le_of_lt {s t u : seq} (Hs : regular s) (Ht : regular t) (Hu : regular u)
(Hst : s_le s t) (Htu : s_lt t u) : s_lt s u :=
begin
let Rtns := reg_add_reg Ht (reg_neg_reg Hs),
let Runt := reg_add_reg Hu (reg_neg_reg Ht),
have Hcan : ∀ m, sadd u (sneg s) m = (sadd t (sneg s)) m + (sadd u (sneg t)) m, begin
intro m,
rewrite [↑sadd, ↑sneg, -sub_eq_sub_add_sub]
end,
rewrite [↑s_lt at *, ↑s_le at *],
cases bdd_away_of_pos Runt Htu with [Nu, HNu],
cases bdd_within_of_nonneg Rtns Hst (2 * Nu) with [Nt, HNt],
apply pos_of_bdd_away,
existsi max (2 * Nu) Nt,
intro n Hn,
rewrite Hcan,
apply rat.le.trans,
rotate 1,
apply rat.add_le_add,
apply HNt,
apply pnat.le.trans,
rotate 1,
apply Hn,
rotate_right 1,
apply max_right,
apply HNu,
apply pnat.le.trans,
apply mul_le_mul_left 2,
apply pnat.le.trans,
rotate 1,
apply Hn,
rotate_right 1,
apply max_left,
rewrite [-add_halves Nu, neg_add_cancel_left],
apply inv_ge_of_le,
apply max_left
end
theorem le_of_le_reprs {s t : seq} (Hs : regular s) (Ht : regular t)
(Hle : ∀ n : ℕ+, s_le s (const (t n))) : s_le s t :=
by intro m; apply Hle (2 * m) m
theorem le_of_reprs_le {s t : seq} (Hs : regular s) (Ht : regular t)
(Hle : ∀ n : ℕ+, s_le (const (t n)) s) : s_le t s :=
by intro m; apply Hle (2 * m) m
-----------------------------
-- of_rat theorems
theorem const_le_const_of_le {a b : ℚ} (H : a ≤ b) : s_le (const a) (const b) :=
begin
rewrite [↑s_le, ↑nonneg],
intro n,
rewrite [↑sadd, ↑sneg, ↑const],
apply rat.le.trans,
apply rat.neg_nonpos_of_nonneg,
apply rat.le_of_lt,
apply inv_pos,
apply iff.mpr !rat.sub_nonneg_iff_le,
apply H
end
theorem le_of_const_le_const {a b : ℚ} (H : s_le (const a) (const b)) : a ≤ b :=
begin
rewrite [↑s_le at H, ↑nonneg at H, ↑sadd at H, ↑sneg at H, ↑const at H],
apply iff.mp !rat.sub_nonneg_iff_le,
apply nonneg_of_ge_neg_invs _ H
end
theorem nat_inv_lt_rat {a : ℚ} (H : a > 0) : ∃ n : ℕ+, n⁻¹ < a :=
begin
existsi (pceil (1 / (a / (1 + 1)))),
apply lt_of_le_of_lt,
rotate 1,
apply div_two_lt_of_pos H,
rewrite -(@div_div' (a / (1 + 1))),
apply pceil_helper,
rewrite div_div',
apply pnat.le.refl,
apply div_pos_of_pos,
apply pos_div_of_pos_of_pos H dec_trivial
end
theorem const_lt_const_of_lt {a b : ℚ} (H : a < b) : s_lt (const a) (const b) :=
begin
rewrite [↑s_lt, ↑pos, ↑sadd, ↑sneg, ↑const],
apply nat_inv_lt_rat,
apply (iff.mpr !sub_pos_iff_lt H)
end
theorem lt_of_const_lt_const {a b : ℚ} (H : s_lt (const a) (const b)) : a < b :=
begin
rewrite [↑s_lt at H, ↑pos at H, ↑const at H, ↑sadd at H, ↑sneg at H],
cases H with [n, Hn],
apply (iff.mp !sub_pos_iff_lt),
apply lt.trans,
rotate 1,
assumption,
apply pnat.inv_pos
end
theorem s_le_of_le_pointwise {s t : seq} (Hs : regular s) (Ht : s.regular t)
(H : ∀ n : ℕ+, s n ≤ t n) : s_le s t :=
begin
rewrite [↑s_le, ↑nonneg, ↑sadd, ↑sneg],
intros,
apply rat.le.trans,
apply iff.mpr !neg_nonpos_iff_nonneg,
apply le_of_lt,
apply inv_pos,
apply iff.mpr !sub_nonneg_iff_le,
apply H
end
-------- lift to reg_seqs
definition r_lt (s t : reg_seq) := s_lt (reg_seq.sq s) (reg_seq.sq t)
definition r_le (s t : reg_seq) := s_le (reg_seq.sq s) (reg_seq.sq t)
definition r_sep (s t : reg_seq) := sep (reg_seq.sq s) (reg_seq.sq t)
theorem r_le_well_defined (s t u v : reg_seq) (Hsu : requiv s u) (Htv : requiv t v)
: r_le s t = r_le u v :=
propext (le_well_defined (reg_seq.is_reg s) (reg_seq.is_reg t) (reg_seq.is_reg u)
(reg_seq.is_reg v) Hsu Htv)
theorem r_lt_well_defined (s t u v : reg_seq) (Hsu : requiv s u) (Htv : requiv t v)
: r_lt s t = r_lt u v :=
propext (lt_well_defined (reg_seq.is_reg s) (reg_seq.is_reg t) (reg_seq.is_reg u)
(reg_seq.is_reg v) Hsu Htv)
theorem r_sep_well_defined (s t u v : reg_seq) (Hsu : requiv s u) (Htv : requiv t v)
: r_sep s t = r_sep u v :=
propext (sep_well_defined (reg_seq.is_reg s) (reg_seq.is_reg t) (reg_seq.is_reg u)
(reg_seq.is_reg v) Hsu Htv)
theorem r_le.refl (s : reg_seq) : r_le s s := le.refl (reg_seq.is_reg s)
theorem r_le.trans {s t u : reg_seq} (Hst : r_le s t) (Htu : r_le t u) : r_le s u :=
le.trans (reg_seq.is_reg s) (reg_seq.is_reg t) (reg_seq.is_reg u) Hst Htu
theorem r_equiv_of_le_of_ge {s t : reg_seq} (Hs : r_le s t) (Hu : r_le t s) :
requiv s t :=
equiv_of_le_of_ge (reg_seq.is_reg s) (reg_seq.is_reg t) Hs Hu
theorem r_lt_iff_le_and_sep (s t : reg_seq) : r_lt s t ↔ r_le s t ∧ r_sep s t :=
lt_iff_le_and_sep (reg_seq.is_reg s) (reg_seq.is_reg t)
theorem r_add_le_add_of_le_right {s t : reg_seq} (H : r_le s t) (u : reg_seq) :
r_le (u + s) (u + t) :=
add_le_add_of_le_right (reg_seq.is_reg s) (reg_seq.is_reg t) H
(reg_seq.sq u) (reg_seq.is_reg u)
theorem r_add_le_add_of_le_right_var (s t u : reg_seq) (H : r_le s t) :
r_le (u + s) (u + t) := r_add_le_add_of_le_right H u
theorem r_mul_pos_of_pos {s t : reg_seq} (Hs : r_lt r_zero s) (Ht : r_lt r_zero t) :
r_lt r_zero (s * t) :=
s_mul_gt_zero_of_gt_zero (reg_seq.is_reg s) (reg_seq.is_reg t) Hs Ht
theorem r_mul_nonneg_of_nonneg {s t : reg_seq} (Hs : r_le r_zero s) (Ht : r_le r_zero t) :
r_le r_zero (s * t) :=
s_mul_ge_zero_of_ge_zero (reg_seq.is_reg s) (reg_seq.is_reg t) Hs Ht
theorem r_not_lt_self (s : reg_seq) : ¬ r_lt s s :=
not_lt_self (reg_seq.sq s)
theorem r_not_sep_self (s : reg_seq) : ¬ r_sep s s :=
not_sep_self (reg_seq.sq s)
theorem r_le_of_lt {s t : reg_seq} (H : r_lt s t) : r_le s t :=
s_le_of_s_lt (reg_seq.is_reg s) (reg_seq.is_reg t) H
theorem r_lt_of_le_of_lt {s t u : reg_seq} (Hst : r_le s t) (Htu : r_lt t u) : r_lt s u :=
s_lt_of_le_of_lt (reg_seq.is_reg s) (reg_seq.is_reg t) (reg_seq.is_reg u) Hst Htu
theorem r_lt_of_lt_of_le {s t u : reg_seq} (Hst : r_lt s t) (Htu : r_le t u) : r_lt s u :=
s_lt_of_lt_of_le (reg_seq.is_reg s) (reg_seq.is_reg t) (reg_seq.is_reg u) Hst Htu
theorem r_add_lt_add_left (s t : reg_seq) (H : r_lt s t) (u : reg_seq) : r_lt (u + s) (u + t) :=
s_add_lt_add_left (reg_seq.is_reg s) (reg_seq.is_reg t) H (reg_seq.is_reg u)
theorem r_add_lt_add_left_var (s t u : reg_seq) (H : r_lt s t) : r_lt (u + s) (u + t) :=
r_add_lt_add_left s t H u
theorem r_zero_lt_one : r_lt r_zero r_one := s_zero_lt_one
theorem r_le_of_lt_or_eq (s t : reg_seq) (H : r_lt s t ∨ requiv s t) : r_le s t :=
le_of_lt_or_equiv (reg_seq.is_reg s) (reg_seq.is_reg t) H
theorem r_const_le_const_of_le {a b : ℚ} (H : a ≤ b) : r_le (r_const a) (r_const b) :=
const_le_const_of_le H
theorem r_le_of_const_le_const {a b : ℚ} (H : r_le (r_const a) (r_const b)) : a ≤ b :=
le_of_const_le_const H
theorem r_const_lt_const_of_lt {a b : ℚ} (H : a < b) : r_lt (r_const a) (r_const b) :=
const_lt_const_of_lt H
theorem r_lt_of_const_lt_const {a b : ℚ} (H : r_lt (r_const a) (r_const b)) : a < b :=
lt_of_const_lt_const H
theorem r_le_of_le_reprs (s t : reg_seq) (Hle : ∀ n : ℕ+, r_le s (r_const (reg_seq.sq t n))) : r_le s t :=
le_of_le_reprs (reg_seq.is_reg s) (reg_seq.is_reg t) Hle
theorem r_le_of_reprs_le (s t : reg_seq) (Hle : ∀ n : ℕ+, r_le (r_const (reg_seq.sq t n)) s) : r_le t s :=
le_of_reprs_le (reg_seq.is_reg s) (reg_seq.is_reg t) Hle
end s
open real
open [classes] s
namespace real
definition lt (x y : ℝ) := quot.lift_on₂ x y (λ a b, s.r_lt a b) s.r_lt_well_defined
infix [priority real.prio] `<` := lt
definition le (x y : ℝ) := quot.lift_on₂ x y (λ a b, s.r_le a b) s.r_le_well_defined
infix [priority real.prio] `≤` := le
infix [priority real.prio] `<=` := le
definition gt [reducible] (a b : ℝ) := lt b a
definition ge [reducible] (a b : ℝ) := le b a
infix [priority real.prio] >= := real.ge
infix [priority real.prio] ≥ := real.ge
infix [priority real.prio] > := real.gt
definition sep (x y : ℝ) := quot.lift_on₂ x y (λ a b, s.r_sep a b) s.r_sep_well_defined
infix `≢` : 50 := sep
theorem le.refl (x : ℝ) : x ≤ x :=
quot.induction_on x (λ t, s.r_le.refl t)
theorem le.trans (x y z : ℝ) : x ≤ y → y ≤ z → x ≤ z :=
quot.induction_on₃ x y z (λ s t u, s.r_le.trans)
theorem eq_of_le_of_ge (x y : ℝ) : x ≤ y → y ≤ x → x = y :=
quot.induction_on₂ x y (λ s t Hst Hts, quot.sound (s.r_equiv_of_le_of_ge Hst Hts))
theorem lt_iff_le_and_sep (x y : ℝ) : x < y ↔ x ≤ y ∧ x ≢ y :=
quot.induction_on₂ x y (λ s t, s.r_lt_iff_le_and_sep s t)
theorem add_le_add_of_le_right_var (x y z : ℝ) : x ≤ y → z + x ≤ z + y :=
quot.induction_on₃ x y z (λ s t u, s.r_add_le_add_of_le_right_var s t u)
theorem add_le_add_of_le_right (x y : ℝ) : x ≤ y → ∀ z : ℝ, z + x ≤ z + y :=
take H z, add_le_add_of_le_right_var x y z H
theorem mul_gt_zero_of_gt_zero (x y : ℝ) : zero < x → zero < y → zero < x * y :=
quot.induction_on₂ x y (λ s t, s.r_mul_pos_of_pos)
theorem mul_ge_zero_of_ge_zero (x y : ℝ) : zero ≤ x → zero ≤ y → zero ≤ x * y :=
quot.induction_on₂ x y (λ s t, s.r_mul_nonneg_of_nonneg)
theorem not_sep_self (x : ℝ) : ¬ x ≢ x :=
quot.induction_on x (λ s, s.r_not_sep_self s)
theorem not_lt_self (x : ℝ) : ¬ x < x :=
quot.induction_on x (λ s, s.r_not_lt_self s)
theorem le_of_lt {x y : ℝ} : x < y → x ≤ y :=
quot.induction_on₂ x y (λ s t H', s.r_le_of_lt H')
theorem lt_of_le_of_lt {x y z : ℝ} : x ≤ y → y < z → x < z :=
quot.induction_on₃ x y z (λ s t u H H', s.r_lt_of_le_of_lt H H')
theorem lt_of_lt_of_le {x y z : ℝ} : x < y → y ≤ z → x < z :=
quot.induction_on₃ x y z (λ s t u H H', s.r_lt_of_lt_of_le H H')
theorem add_lt_add_left_var (x y z : ℝ) : x < y → z + x < z + y :=
quot.induction_on₃ x y z (λ s t u, s.r_add_lt_add_left_var s t u)
theorem add_lt_add_left (x y : ℝ) : x < y → ∀ z : ℝ, z + x < z + y :=
take H z, add_lt_add_left_var x y z H
theorem zero_lt_one : zero < one := s.r_zero_lt_one
theorem le_of_lt_or_eq (x y : ℝ) : x < y ∨ x = y → x ≤ y :=
(quot.induction_on₂ x y (λ s t H, or.elim H (take H', begin
apply s.r_le_of_lt_or_eq,
apply or.inl H'
end)
(take H', begin
apply s.r_le_of_lt_or_eq,
apply (or.inr (quot.exact H'))
end)))
section migrate_algebra
open [classes] algebra
protected definition ordered_ring [reducible] : algebra.ordered_ring ℝ :=
⦃ algebra.ordered_ring, real.comm_ring,
le_refl := le.refl,
le_trans := le.trans,
mul_pos := mul_gt_zero_of_gt_zero,
mul_nonneg := mul_ge_zero_of_ge_zero,
zero_ne_one := zero_ne_one,
add_le_add_left := add_le_add_of_le_right,
le_antisymm := eq_of_le_of_ge,
lt_irrefl := not_lt_self,
lt_of_le_of_lt := @lt_of_le_of_lt,
lt_of_lt_of_le := @lt_of_lt_of_le,
le_of_lt := @le_of_lt,
add_lt_add_left := add_lt_add_left
⦄
local attribute real.comm_ring [instance]
local attribute real.ordered_ring [instance]
definition sub (a b : ℝ) : ℝ := algebra.sub a b
infix [priority real.prio] - := real.sub
definition dvd (a b : ℝ) : Prop := algebra.dvd a b
notation [priority real.prio] a ∣ b := real.dvd a b
definition pow (a : ℝ) (n : ℕ) : ℝ := algebra.pow a n
notation [priority real.prio] a^n := real.pow a n
definition nmul (n : ℕ) (a : ℝ) : ℝ := algebra.nmul n a
infix [priority real.prio] `⬝` := nmul
definition imul (i : ℤ) (a : ℝ) : ℝ := algebra.imul i a
migrate from algebra with real
replacing has_le.ge → ge, has_lt.gt → gt, sub → sub, dvd → dvd, divide → divide,
pow → pow, nmul → nmul, imul → imul
attribute le.trans lt.trans lt_of_lt_of_le lt_of_le_of_lt ge.trans gt.trans gt_of_gt_of_ge
gt_of_ge_of_gt [trans]
end migrate_algebra
theorem of_rat_le_of_rat_of_le (a b : ℚ) : a ≤ b → of_rat a ≤ of_rat b :=
s.r_const_le_const_of_le
theorem le_of_rat_le_of_rat (a b : ℚ) : of_rat a ≤ of_rat b → a ≤ b :=
s.r_le_of_const_le_const
theorem of_rat_lt_of_rat_of_lt (a b : ℚ) : a < b → of_rat a < of_rat b :=
s.r_const_lt_const_of_lt
theorem lt_of_rat_lt_of_rat (a b : ℚ) : of_rat a < of_rat b → a < b :=
s.r_lt_of_const_lt_const
theorem of_rat_sub (a b : ℚ) : of_rat a - of_rat b = of_rat (a - b) := rfl
open s
theorem le_of_le_reprs (x : ℝ) (t : seq) (Ht : regular t) : (∀ n : ℕ+, x ≤ t n) →
x ≤ quot.mk (reg_seq.mk t Ht) :=
quot.induction_on x (take s Hs,
show s.r_le s (reg_seq.mk t Ht), from
have H' : ∀ n : ℕ+, r_le s (r_const (t n)), from Hs,
by apply r_le_of_le_reprs; apply Hs)
theorem le_of_reprs_le (x : ℝ) (t : seq) (Ht : regular t) : (∀ n : ℕ+, t n ≤ x) →
quot.mk (reg_seq.mk t Ht) ≤ x :=
quot.induction_on x (take s Hs,
show s.r_le (reg_seq.mk t Ht) s, from
have H' : ∀ n : ℕ+, r_le (r_const (t n)) s, from Hs,
by apply r_le_of_reprs_le; apply Hs)
end real
|
c13951ea56b92c63ea3e199caa52a8efe038e2ed | bdb33f8b7ea65f7705fc342a178508e2722eb851 | /data/list/perm.lean | a4a23af96999fb4227930a5c8c08f196f5168f2b | [
"Apache-2.0"
] | permissive | rwbarton/mathlib | 939ae09bf8d6eb1331fc2f7e067d39567e10e33d | c13c5ea701bb1eec057e0a242d9f480a079105e9 | refs/heads/master | 1,584,015,335,862 | 1,524,142,167,000 | 1,524,142,167,000 | 130,614,171 | 0 | 0 | Apache-2.0 | 1,548,902,667,000 | 1,524,437,371,000 | Lean | UTF-8 | Lean | false | false | 34,306 | lean | /-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad, Mario Carneiro
List permutations.
-/
import data.list.basic
namespace list
universe variables uu vv
variables {α : Type uu} {β : Type vv}
/-- `perm l₁ l₂` or `l₁ ~ l₂` asserts that `l₁` and `l₂` are permutations
of each other. This is defined by induction using pairwise swaps. -/
inductive perm : list α → list α → Prop
| nil : perm [] []
| skip : Π (x : α) {l₁ l₂ : list α}, perm l₁ l₂ → perm (x::l₁) (x::l₂)
| swap : Π (x y : α) (l : list α), perm (y::x::l) (x::y::l)
| trans : Π {l₁ l₂ l₃ : list α}, perm l₁ l₂ → perm l₂ l₃ → perm l₁ l₃
open perm
infix ~ := perm
@[refl] protected theorem perm.refl : ∀ (l : list α), l ~ l
| [] := perm.nil
| (x::xs) := skip x (perm.refl xs)
@[symm] protected theorem perm.symm {l₁ l₂ : list α} (p : l₁ ~ l₂) : l₂ ~ l₁ :=
perm.rec_on p
perm.nil
(λ x l₁ l₂ p₁ r₁, skip x r₁)
(λ x y l, swap y x l)
(λ l₁ l₂ l₃ p₁ p₂ r₁ r₂, trans r₂ r₁)
attribute [trans] perm.trans
theorem perm.eqv (α : Type) : equivalence (@perm α) :=
mk_equivalence (@perm α) (@perm.refl α) (@perm.symm α) (@perm.trans α)
instance is_setoid (α : Type) : setoid (list α) :=
setoid.mk (@perm α) (perm.eqv α)
theorem perm_subset {l₁ l₂ : list α} (p : l₁ ~ l₂) : l₁ ⊆ l₂ :=
λ a, perm.rec_on p
(λ h, h)
(λ x l₁ l₂ p₁ r₁ i, or.elim i
(λ ax, by simp [ax])
(λ al₁, or.inr (r₁ al₁)))
(λ x y l ayxl, or.elim ayxl
(λ ay, by simp [ay])
(λ axl, or.elim axl
(λ ax, by simp [ax])
(λ al, or.inr (or.inr al))))
(λ l₁ l₂ l₃ p₁ p₂ r₁ r₂ ainl₁, r₂ (r₁ ainl₁))
theorem mem_of_perm {a : α} {l₁ l₂ : list α} (h : l₁ ~ l₂) : a ∈ l₁ ↔ a ∈ l₂ :=
iff.intro (λ m, perm_subset h m) (λ m, perm_subset h.symm m)
theorem perm_app_left {l₁ l₂ : list α} (t₁ : list α) (p : l₁ ~ l₂) : l₁++t₁ ~ l₂++t₁ :=
perm.rec_on p
(perm.refl ([] ++ t₁))
(λ x l₁ l₂ p₁ r₁, skip x r₁)
(λ x y l, swap x y _)
(λ l₁ l₂ l₃ p₁ p₂ r₁ r₂, trans r₁ r₂)
theorem perm_app_right {t₁ t₂ : list α} : ∀ (l : list α), t₁ ~ t₂ → l++t₁ ~ l++t₂
| [] p := p
| (x::xs) p := skip x (perm_app_right xs p)
theorem perm_app {l₁ l₂ t₁ t₂ : list α} (p₁ : l₁ ~ l₂) (p₂ : t₁ ~ t₂) : l₁++t₁ ~ l₂++t₂ :=
trans (perm_app_left t₁ p₁) (perm_app_right l₂ p₂)
theorem perm_app_cons (a : α) {h₁ h₂ t₁ t₂ : list α}
(p₁ : h₁ ~ h₂) (p₂ : t₁ ~ t₂) : h₁ ++ a::t₁ ~ h₂ ++ a::t₂ :=
perm_app p₁ (skip a p₂)
@[simp] theorem perm_middle {a : α} : ∀ {l₁ l₂ : list α}, l₁++a::l₂ ~ a::(l₁++l₂)
| [] l₂ := perm.refl _
| (b::l₁) l₂ := (skip b (@perm_middle l₁ l₂)).trans (swap a b _)
@[simp] theorem perm_cons_app (a : α) (l : list α) : l ++ [a] ~ a::l :=
by simpa using @perm_middle _ a l []
@[simp] theorem perm_app_comm : ∀ {l₁ l₂ : list α}, (l₁++l₂) ~ (l₂++l₁)
| [] l₂ := by simp
| (a::t) l₂ := (skip a perm_app_comm).trans perm_middle.symm
theorem concat_perm (l : list α) (a : α) : concat l a ~ a :: l :=
by simp
theorem perm_length {l₁ l₂ : list α} (p : l₁ ~ l₂) : length l₁ = length l₂ :=
perm.rec_on p
rfl
(λ x l₁ l₂ p r, by simp[r])
(λ x y l, by simp)
(λ l₁ l₂ l₃ p₁ p₂ r₁ r₂, eq.trans r₁ r₂)
theorem eq_nil_of_perm_nil {l₁ : list α} (p : [] ~ l₁) : l₁ = [] :=
eq_nil_of_length_eq_zero (perm_length p).symm
theorem perm_nil {l₁ : list α} : l₁ ~ [] ↔ l₁ = [] :=
⟨λ p, eq_nil_of_perm_nil p.symm, λ e, e ▸ perm.refl _⟩
theorem not_perm_nil_cons (x : α) (l : list α) : ¬ [] ~ x::l
| p := by injection eq_nil_of_perm_nil p
theorem eq_singleton_of_perm {a b : α} (p : [a] ~ [b]) : a = b :=
by simpa using perm_subset p (by simp)
theorem eq_singleton_of_perm_inv {a : α} {l : list α} (p : [a] ~ l) : l = [a] :=
match l, show 1 = _, from perm_length p, p with
| [a'], rfl, p := by rw [eq_singleton_of_perm p]
end
@[simp] theorem reverse_perm : ∀ (l : list α), reverse l ~ l
| [] := perm.nil
| (a::l) := by rw reverse_cons'; exact
(perm_cons_app _ _).trans (skip a $ reverse_perm l)
theorem perm_cons_app_cons {l l₁ l₂ : list α} (a : α) (p : l ~ l₁++l₂) : a::l ~ l₁++(a::l₂) :=
trans (skip a p) perm_middle.symm
@[simp] theorem perm_repeat {a : α} {n : ℕ} {l : list α} : repeat a n ~ l ↔ repeat a n = l :=
⟨λ p, (eq_repeat.2 $ by exact
⟨by simpa using (perm_length p).symm,
λ b m, eq_of_mem_repeat $ perm_subset p.symm m⟩).symm,
λ h, h ▸ perm.refl _⟩
theorem perm_erase [decidable_eq α] {a : α} {l : list α} (h : a ∈ l) : l ~ a :: l.erase a :=
let ⟨l₁, l₂, _, e₁, e₂⟩ := exists_erase_eq h in
e₂.symm ▸ e₁.symm ▸ perm_middle
@[elab_as_eliminator] theorem perm_induction_on
{P : list α → list α → Prop} {l₁ l₂ : list α} (p : l₁ ~ l₂)
(h₁ : P [] [])
(h₂ : ∀ x l₁ l₂, l₁ ~ l₂ → P l₁ l₂ → P (x::l₁) (x::l₂))
(h₃ : ∀ x y l₁ l₂, l₁ ~ l₂ → P l₁ l₂ → P (y::x::l₁) (x::y::l₂))
(h₄ : ∀ l₁ l₂ l₃, l₁ ~ l₂ → l₂ ~ l₃ → P l₁ l₂ → P l₂ l₃ → P l₁ l₃) :
P l₁ l₂ :=
have P_refl : ∀ l, P l l, from
assume l,
list.rec_on l h₁ (λ x xs ih, h₂ x xs xs (perm.refl xs) ih),
perm.rec_on p h₁ h₂ (λ x y l, h₃ x y l l (perm.refl l) (P_refl l)) h₄
theorem xswap {l₁ l₂ : list α} (x y : α) (p : l₁ ~ l₂) : x::y::l₁ ~ y::x::l₂ :=
(swap y x l₁).trans $ skip y $ skip x p
@[congr] theorem perm_filter_map (f : α → option β) {l₁ l₂ : list α} (p : l₁ ~ l₂) :
filter_map f l₁ ~ filter_map f l₂ :=
begin
induction p with x l₂ l₂' p IH x y l₂ l₂ m₂ r₂ p₁ p₂ IH₁ IH₂,
{ simp },
{ simp [filter_map], cases f x with a; simp [filter_map, IH, skip] },
{ simp [filter_map], cases f x with a; cases f y with b; simp [filter_map, swap] },
{ exact IH₁.trans IH₂ }
end
@[congr] theorem perm_map (f : α → β) {l₁ l₂ : list α} (p : l₁ ~ l₂) :
map f l₁ ~ map f l₂ :=
by rw ← filter_map_eq_map; apply perm_filter_map _ p
theorem perm_pmap {p : α → Prop} (f : Π a, p a → β)
{l₁ l₂ : list α} (p : l₁ ~ l₂) {H₁ H₂} : pmap f l₁ H₁ ~ pmap f l₂ H₂ :=
begin
induction p with x l₂ l₂' p IH x y l₂ l₂ m₂ r₂ p₁ p₂ IH₁ IH₂,
{ simp },
{ simp [IH, skip] },
{ simp [swap] },
{ refine IH₁.trans IH₂,
exact λ a m, H₂ a (perm_subset p₂ m) }
end
theorem perm_filter (p : α → Prop) [decidable_pred p]
{l₁ l₂ : list α} (s : l₁ ~ l₂) : filter p l₁ ~ filter p l₂ :=
by rw ← filter_map_eq_filter; apply perm_filter_map _ s
theorem exists_perm_sublist {l₁ l₂ l₂' : list α}
(s : l₁ <+ l₂) (p : l₂ ~ l₂') : ∃ l₁' ~ l₁, l₁' <+ l₂' :=
begin
induction p with x l₂ l₂' p IH x y l₂ l₂ m₂ r₂ p₁ p₂ IH₁ IH₂ generalizing l₁ s,
{ exact ⟨[], eq_nil_of_sublist_nil s ▸ perm.refl _, nil_sublist _⟩ },
{ cases s with _ _ _ s l₁ _ _ s,
{ exact let ⟨l₁', p', s'⟩ := IH s in ⟨l₁', p', s'.cons _ _ _⟩ },
{ exact let ⟨l₁', p', s'⟩ := IH s in ⟨x::l₁', skip x p', s'.cons2 _ _ _⟩ } },
{ cases s with _ _ _ s l₁ _ _ s; cases s with _ _ _ s l₁ _ _ s,
{ exact ⟨l₁, perm.refl _, (s.cons _ _ _).cons _ _ _⟩ },
{ exact ⟨x::l₁, perm.refl _, (s.cons _ _ _).cons2 _ _ _⟩ },
{ exact ⟨y::l₁, perm.refl _, (s.cons2 _ _ _).cons _ _ _⟩ },
{ exact ⟨x::y::l₁, perm.swap _ _ _, (s.cons2 _ _ _).cons2 _ _ _⟩ } },
{ exact let ⟨m₁, pm, sm⟩ := IH₁ s, ⟨r₁, pr, sr⟩ := IH₂ sm in
⟨r₁, pr.trans pm, sr⟩ }
end
section subperm
/-- `subperm l₁ l₂`, denoted `l₁ <+~ l₂`, means that `l₁` is a sublist of
a permutation of `l₂`. This is an analogue of `l₁ ⊆ l₂` which respects
multiplicities of elements, and is used for the `≤` relation on multisets. -/
def subperm (l₁ l₂ : list α) : Prop := ∃ l ~ l₁, l <+ l₂
infix ` <+~ `:50 := subperm
theorem perm.subperm_left {l l₁ l₂ : list α} (p : l₁ ~ l₂) : l <+~ l₁ ↔ l <+~ l₂ :=
suffices ∀ {l₁ l₂ : list α}, l₁ ~ l₂ → l <+~ l₁ → l <+~ l₂,
from ⟨this p, this p.symm⟩,
λ l₁ l₂ p ⟨u, pu, su⟩,
let ⟨v, pv, sv⟩ := exists_perm_sublist su p in
⟨v, pv.trans pu, sv⟩
theorem perm.subperm_right {l₁ l₂ l : list α} (p : l₁ ~ l₂) : l₁ <+~ l ↔ l₂ <+~ l :=
⟨λ ⟨u, pu, su⟩, ⟨u, pu.trans p, su⟩,
λ ⟨u, pu, su⟩, ⟨u, pu.trans p.symm, su⟩⟩
theorem subperm_of_sublist {l₁ l₂ : list α} (s : l₁ <+ l₂) : l₁ <+~ l₂ :=
⟨l₁, perm.refl _, s⟩
theorem subperm_of_perm {l₁ l₂ : list α} (p : l₁ ~ l₂) : l₁ <+~ l₂ :=
⟨l₂, p.symm, sublist.refl _⟩
theorem subperm.refl (l : list α) : l <+~ l := subperm_of_perm (perm.refl _)
theorem subperm.trans {l₁ l₂ l₃ : list α} : l₁ <+~ l₂ → l₂ <+~ l₃ → l₁ <+~ l₃
| s ⟨l₂', p₂, s₂⟩ :=
let ⟨l₁', p₁, s₁⟩ := p₂.subperm_left.2 s in ⟨l₁', p₁, s₁.trans s₂⟩
theorem length_le_of_subperm {l₁ l₂ : list α} : l₁ <+~ l₂ → length l₁ ≤ length l₂
| ⟨l, p, s⟩ := perm_length p ▸ length_le_of_sublist s
theorem subperm.perm_of_length_le {l₁ l₂ : list α} : l₁ <+~ l₂ → length l₂ ≤ length l₁ → l₁ ~ l₂
| ⟨l, p, s⟩ h :=
suffices l = l₂, from this ▸ p.symm,
eq_of_sublist_of_length_le s $ perm_length p.symm ▸ h
theorem subperm.antisymm {l₁ l₂ : list α} (h₁ : l₁ <+~ l₂) (h₂ : l₂ <+~ l₁) : l₁ ~ l₂ :=
h₁.perm_of_length_le (length_le_of_subperm h₂)
theorem subset_of_subperm {l₁ l₂ : list α} : l₁ <+~ l₂ → l₁ ⊆ l₂
| ⟨l, p, s⟩ := subset.trans (perm_subset p.symm) (subset_of_sublist s)
end subperm
theorem exists_perm_append_of_sublist : ∀ {l₁ l₂ : list α}, l₁ <+ l₂ → ∃ l, l₂ ~ l₁ ++ l
| ._ ._ sublist.slnil := ⟨nil, perm.refl _⟩
| ._ ._ (sublist.cons l₁ l₂ a s) :=
let ⟨l, p⟩ := exists_perm_append_of_sublist s in
⟨a::l, (skip a p).trans perm_middle.symm⟩
| ._ ._ (sublist.cons2 l₁ l₂ a s) :=
let ⟨l, p⟩ := exists_perm_append_of_sublist s in
⟨l, skip a p⟩
theorem perm_countp (p : α → Prop) [decidable_pred p]
{l₁ l₂ : list α} (s : l₁ ~ l₂) : countp p l₁ = countp p l₂ :=
by rw [countp_eq_length_filter, countp_eq_length_filter];
exact perm_length (perm_filter _ s)
theorem countp_le_of_subperm (p : α → Prop) [decidable_pred p]
{l₁ l₂ : list α} : l₁ <+~ l₂ → countp p l₁ ≤ countp p l₂
| ⟨l, p', s⟩ := perm_countp p p' ▸ countp_le_of_sublist s
theorem perm_count [decidable_eq α] {l₁ l₂ : list α}
(p : l₁ ~ l₂) (a) : count a l₁ = count a l₂ :=
perm_countp _ p
theorem count_le_of_subperm [decidable_eq α] {l₁ l₂ : list α}
(s : l₁ <+~ l₂) (a) : count a l₁ ≤ count a l₂ :=
countp_le_of_subperm _ s
theorem foldl_eq_of_perm {f : β → α → β} {l₁ l₂ : list α} (rcomm : right_commutative f) (p : l₁ ~ l₂) :
∀ b, foldl f b l₁ = foldl f b l₂ :=
perm_induction_on p
(λ b, rfl)
(λ x t₁ t₂ p r b, r (f b x))
(λ x y t₁ t₂ p r b, by simp; rw rcomm; exact r (f (f b x) y))
(λ t₁ t₂ t₃ p₁ p₂ r₁ r₂ b, eq.trans (r₁ b) (r₂ b))
theorem foldr_eq_of_perm {f : α → β → β} {l₁ l₂ : list α} (lcomm : left_commutative f) (p : l₁ ~ l₂) :
∀ b, foldr f b l₁ = foldr f b l₂ :=
perm_induction_on p
(λ b, rfl)
(λ x t₁ t₂ p r b, by simp; rw [r b])
(λ x y t₁ t₂ p r b, by simp; rw [lcomm, r b])
(λ t₁ t₂ t₃ p₁ p₂ r₁ r₂ a, eq.trans (r₁ a) (r₂ a))
lemma rec_heq_of_perm {β : list α → Sort*} {f : Πa l, β l → β (a::l)} {b : β []} {l l' : list α}
(hl : perm l l')
(f_congr : ∀{a l l' b b'}, perm l l' → b == b' → f a l b == f a l' b')
(f_swap : ∀{a a' l b}, f a (a'::l) (f a' l b) == f a' (a::l) (f a l b)) :
@list.rec α β b f l == @list.rec α β b f l' :=
begin
induction hl,
case list.perm.nil { refl },
case list.perm.skip : a l l' h ih { exact f_congr h ih },
case list.perm.swap : a a' l { exact f_swap },
case list.perm.trans : l₁ l₂ l₃ h₁ h₂ ih₁ ih₂ { exact heq.trans ih₁ ih₂ }
end
section
variables {op : α → α → α} [is_associative α op] [is_commutative α op]
local notation a * b := op a b
local notation l <*> a := foldl op a l
lemma fold_op_eq_of_perm {l₁ l₂ : list α} {a : α} (h : l₁ ~ l₂) : l₁ <*> a = l₂ <*> a :=
foldl_eq_of_perm (right_comm _ (is_commutative.comm _) (is_associative.assoc _)) h _
end
section comm_monoid
open list
variable [comm_monoid α]
@[to_additive list.sum_eq_of_perm]
lemma prod_eq_of_perm {l₁ l₂ : list α} (h : perm l₁ l₂) : prod l₁ = prod l₂ :=
by induction h; simp [*, mul_left_comm]
@[to_additive list.sum_reverse]
lemma prod_reverse (l : list α) : prod l.reverse = prod l :=
prod_eq_of_perm $ reverse_perm l
end comm_monoid
theorem perm_inv_core {a : α} {l₁ l₂ r₁ r₂ : list α} : l₁++a::r₁ ~ l₂++a::r₂ → l₁++r₁ ~ l₂++r₂ :=
begin
generalize e₁ : l₁++a::r₁ = s₁, generalize e₂ : l₂++a::r₂ = s₂,
intro p, revert l₁ l₂ r₁ r₂ e₁ e₂,
refine perm_induction_on p _ (λ x t₁ t₂ p IH, _) (λ x y t₁ t₂ p IH, _) (λ t₁ t₂ t₃ p₁ p₂ IH₁ IH₂, _);
intros l₁ l₂ r₁ r₂ e₁ e₂,
{ apply (not_mem_nil a).elim, rw ← e₁, simp },
{ cases l₁ with y l₁; cases l₂ with z l₂;
dsimp at e₁ e₂; injections; subst x,
{ substs t₁ t₂, exact p },
{ substs z t₁ t₂, exact p.trans perm_middle },
{ substs y t₁ t₂, exact perm_middle.symm.trans p },
{ substs z t₁ t₂, exact skip y (IH rfl rfl) } },
{ rcases l₁ with _|⟨y, _|⟨z, l₁⟩⟩; rcases l₂ with _|⟨u, _|⟨v, l₂⟩⟩;
dsimp at e₁ e₂; injections; substs x y,
{ substs r₁ r₂, exact skip a p },
{ substs r₁ r₂, exact skip u p },
{ substs r₁ v t₂, exact skip u (p.trans perm_middle) },
{ substs r₁ r₂, exact skip y p },
{ substs r₁ r₂ y u, exact skip a p },
{ substs r₁ u v t₂, exact (skip y $ p.trans perm_middle).trans (swap _ _ _) },
{ substs r₂ z t₁, exact skip y (perm_middle.symm.trans p) },
{ substs r₂ y z t₁, exact (swap _ _ _).trans (skip u $ perm_middle.symm.trans p) },
{ substs u v t₁ t₂, exact (swap _ _ _).trans (skip z $ skip y $ IH rfl rfl) } },
{ substs t₁ t₃,
have : a ∈ t₂ := perm_subset p₁ (by simp),
rcases mem_split this with ⟨l₂, r₂, e₂⟩,
subst t₂, exact (IH₁ rfl rfl).trans (IH₂ rfl rfl) }
end
theorem perm_cons_inv {a : α} {l₁ l₂ : list α} : a::l₁ ~ a::l₂ → l₁ ~ l₂ :=
@perm_inv_core _ _ [] [] _ _
theorem perm_cons (a : α) {l₁ l₂ : list α} : a::l₁ ~ a::l₂ ↔ l₁ ~ l₂ :=
⟨perm_cons_inv, skip a⟩
theorem perm_app_left_iff {l₁ l₂ : list α} : ∀ l, l++l₁ ~ l++l₂ ↔ l₁ ~ l₂
| [] := iff.rfl
| (a::l) := (perm_cons a).trans (perm_app_left_iff l)
theorem perm_app_right_iff {l₁ l₂ : list α} (l) : l₁++l ~ l₂++l ↔ l₁ ~ l₂ :=
⟨λ p, (perm_app_left_iff _).1 $ trans perm_app_comm $ trans p perm_app_comm,
perm_app_left _⟩
theorem subperm_cons (a : α) {l₁ l₂ : list α} : a::l₁ <+~ a::l₂ ↔ l₁ <+~ l₂ :=
⟨λ ⟨l, p, s⟩, begin
cases s with _ _ _ s' u _ _ s',
{ exact (p.subperm_left.2 $ subperm_of_sublist $ sublist_cons _ _).trans
(subperm_of_sublist s') },
{ exact ⟨u, perm_cons_inv p, s'⟩ }
end, λ ⟨l, p, s⟩, ⟨a::l, skip a p, s.cons2 _ _ _⟩⟩
theorem subperm_app_left {l₁ l₂ : list α} : ∀ l, l++l₁ <+~ l++l₂ ↔ l₁ <+~ l₂
| [] := iff.rfl
| (a::l) := (subperm_cons a).trans (subperm_app_left l)
theorem subperm_app_right {l₁ l₂ : list α} (l) : l₁++l <+~ l₂++l ↔ l₁ <+~ l₂ :=
(perm_app_comm.subperm_left.trans perm_app_comm.subperm_right).trans (subperm_app_left l)
theorem subperm.exists_of_length_lt {l₁ l₂ : list α} :
l₁ <+~ l₂ → length l₁ < length l₂ → ∃ a, a :: l₁ <+~ l₂
| ⟨l, p, s⟩ h :=
suffices length l < length l₂ → ∃ (a : α), a :: l <+~ l₂, from
(this $ perm_length p.symm ▸ h).imp (λ a, (skip a p).subperm_right.1),
begin
clear subperm.exists_of_length_lt p h l₁, rename l₂ u,
induction s with l₁ l₂ a s IH _ _ b s IH; intro h,
{ cases h },
{ cases lt_or_eq_of_le (nat.le_of_lt_succ h : length l₁ ≤ length l₂) with h h,
{ exact (IH h).imp (λ a s, s.trans (subperm_of_sublist $ sublist_cons _ _)) },
{ exact ⟨a, eq_of_sublist_of_length_eq s h ▸ subperm.refl _⟩ } },
{ exact (IH $ nat.lt_of_succ_lt_succ h).imp
(λ a s, (swap _ _ _).subperm_right.1 $ (subperm_cons _).2 s) }
end
theorem subperm_of_subset_nodup
{l₁ l₂ : list α} (d : nodup l₁) (H : l₁ ⊆ l₂) : l₁ <+~ l₂ :=
begin
induction d with a l₁' h d IH,
{ exact ⟨nil, perm.nil, nil_sublist _⟩ },
{ cases forall_mem_cons.1 H with H₁ H₂, simp at h,
rcases IH H₂ with ⟨l₂', p, s⟩, clear IH H H₂ l₁,
induction s with r₁ r₂ b s' IH r₁ r₂ b s' IH generalizing l₁',
{ cases H₁ },
{ simp at H₁, cases H₁ with e m,
{ subst b, exact ⟨a::r₁, skip a p, s'.cons2 _ _ _⟩ },
{ exact let ⟨t, p', s'⟩ := IH m d h p in ⟨t, p', s'.cons _ _ _⟩ } },
{ have bm : b ∈ l₁' := (perm_subset p $ mem_cons_self _ _),
have am : a ∈ r₂ := H₁.resolve_left (λ e, h $ e.symm ▸ bm),
rcases mem_split bm with ⟨t₁, t₂, rfl⟩,
have st : t₁ ++ t₂ <+ t₁ ++ b :: t₂ := by simp,
rcases IH am (nodup_of_sublist st d)
(mt (λ x, subset_of_sublist st x) h)
(perm_cons_inv $ p.trans perm_middle) with ⟨t, p', s'⟩,
exact ⟨b::t, (skip b p').trans $
(swap _ _ _).trans (skip a perm_middle.symm), s'.cons2 _ _ _⟩ } }
end
theorem perm_ext {l₁ l₂ : list α} (d₁ : nodup l₁) (d₂ : nodup l₂) : l₁ ~ l₂ ↔ ∀a, a ∈ l₁ ↔ a ∈ l₂ :=
⟨λ p a, mem_of_perm p, λ H, subperm.antisymm
(subperm_of_subset_nodup d₁ (λ a, (H a).1))
(subperm_of_subset_nodup d₂ (λ a, (H a).2))⟩
theorem perm_ext_sublist_nodup {l₁ l₂ l : list α} (d : nodup l)
(s₁ : l₁ <+ l) (s₂ : l₂ <+ l) : l₁ ~ l₂ ↔ l₁ = l₂ :=
⟨λ h, begin
induction s₂ with l₂ l a s₂ IH l₂ l a s₂ IH generalizing l₁,
{ exact eq_nil_of_perm_nil h.symm },
{ simp at d,
cases s₁ with _ _ _ s₁ l₁ _ _ s₁,
{ exact IH d.2 s₁ h },
{ apply d.1.elim,
exact subset_of_subperm ⟨_, h.symm, s₂⟩ (mem_cons_self _ _) } },
{ simp at d,
cases s₁ with _ _ _ s₁ l₁ _ _ s₁,
{ apply d.1.elim,
exact subset_of_subperm ⟨_, h, s₁⟩ (mem_cons_self _ _) },
{ rw IH d.2 s₁ (perm_cons_inv h) } }
end, λ h, by rw h⟩
section
variable [decidable_eq α]
-- attribute [congr]
theorem erase_perm_erase (a : α) {l₁ l₂ : list α} (p : l₁ ~ l₂) :
l₁.erase a ~ l₂.erase a :=
if h₁ : a ∈ l₁ then
have h₂ : a ∈ l₂, from perm_subset p h₁,
perm_cons_inv $ trans (perm_erase h₁).symm $ trans p (perm_erase h₂)
else
have h₂ : a ∉ l₂, from mt (mem_of_perm p).2 h₁,
by rw [erase_of_not_mem h₁, erase_of_not_mem h₂]; exact p
theorem perm_diff_left {l₁ l₂ : list α} (t : list α) (h : l₁ ~ l₂) : l₁.diff t ~ l₂.diff t :=
by induction t generalizing l₁ l₂ h; simp [*, erase_perm_erase]
theorem perm_diff_right (l : list α) {t₁ t₂ : list α} (h : t₁ ~ t₂) : l.diff t₁ = l.diff t₂ :=
by induction h generalizing l; simp [*, erase_perm_erase, erase_comm]
<|> exact (ih_1 _).trans (ih_2 _)
theorem perm_bag_inter_left {l₁ l₂ : list α} (t : list α) (h : l₁ ~ l₂) : l₁.bag_inter t ~ l₂.bag_inter t :=
begin
induction h with x _ _ _ _ x y _ _ _ _ _ _ ih_1 ih_2 generalizing t, {simp},
{ by_cases x ∈ t; simp [*, skip] },
{ by_cases x = y, {simp [h]},
by_cases xt : x ∈ t; by_cases yt : y ∈ t,
{ simp [xt, yt, mem_erase_of_ne h, mem_erase_of_ne (ne.symm h), erase_comm, swap] },
{ simp [xt, yt, mt mem_of_mem_erase, skip] },
{ simp [xt, yt, mt mem_of_mem_erase, skip] },
{ simp [xt, yt] } },
{ exact (ih_1 _).trans (ih_2 _) }
end
theorem perm_bag_inter_right (l : list α) {t₁ t₂ : list α} (p : t₁ ~ t₂) : l.bag_inter t₁ = l.bag_inter t₂ :=
begin
induction l with a l IH generalizing t₁ t₂ p, {simp},
by_cases a ∈ t₁,
{ simp [h, (mem_of_perm p).1 h, IH (erase_perm_erase _ p)] },
{ simp [h, mt (mem_of_perm p).2 h, IH p] }
end
theorem cons_perm_iff_perm_erase {a : α} {l₁ l₂ : list α} : a::l₁ ~ l₂ ↔ a ∈ l₂ ∧ l₁ ~ l₂.erase a :=
⟨λ h, have a ∈ l₂, from perm_subset h (mem_cons_self a l₁),
⟨this, perm_cons_inv $ h.trans $ perm_erase this⟩,
λ ⟨m, h⟩, trans (skip a h) (perm_erase m).symm⟩
theorem perm_iff_count {l₁ l₂ : list α} : l₁ ~ l₂ ↔ ∀ a, count a l₁ = count a l₂ :=
⟨perm_count, λ H, begin
induction l₁ with a l₁ IH generalizing l₂,
{ cases l₂ with b l₂, {refl},
specialize H b, simp at H, contradiction },
{ have : a ∈ l₂ := count_pos.1 (by rw ← H; simp; apply nat.succ_pos),
refine trans (skip a $ IH $ λ b, _) (perm_erase this).symm,
specialize H b,
rw perm_count (perm_erase this) at H,
by_cases b = a; simp [h] at H ⊢; assumption }
end⟩
instance decidable_perm : ∀ (l₁ l₂ : list α), decidable (l₁ ~ l₂)
| [] [] := is_true $ perm.refl _
| [] (b::l₂) := is_false $ λ h, by have := eq_nil_of_perm_nil h; contradiction
| (a::l₁) l₂ := by haveI := decidable_perm l₁ (l₂.erase a);
exact decidable_of_iff' _ cons_perm_iff_perm_erase
-- @[congr]
theorem perm_erase_dup_of_perm {l₁ l₂ : list α} (p : l₁ ~ l₂) :
erase_dup l₁ ~ erase_dup l₂ :=
perm_iff_count.2 $ λ a,
if h : a ∈ l₁
then by simp [nodup_erase_dup, h, perm_subset p h]
else by simp [h, mt (mem_of_perm p).2 h]
-- attribute [congr]
theorem perm_insert (a : α)
{l₁ l₂ : list α} (p : l₁ ~ l₂) : insert a l₁ ~ insert a l₂ :=
if h : a ∈ l₁
then by simpa [h, perm_subset p h] using p
else by simpa [h, mt (mem_of_perm p).2 h] using skip a p
theorem perm_insert_swap (x y : α) (l : list α) :
insert x (insert y l) ~ insert y (insert x l) :=
begin
by_cases xl : x ∈ l; by_cases yl : y ∈ l; simp [xl, yl],
by_cases xy : x = y, { simp [xy] },
simp [not_mem_cons_of_ne_of_not_mem xy xl,
not_mem_cons_of_ne_of_not_mem (ne.symm xy) yl],
constructor
end
theorem perm_union_left {l₁ l₂ : list α} (t₁ : list α) (h : l₁ ~ l₂) : l₁ ∪ t₁ ~ l₂ ∪ t₁ :=
begin
induction h with a _ _ _ ih _ _ _ _ _ _ _ _ ih_1 ih_2; try {simp},
{ exact perm_insert a ih },
{ apply perm_insert_swap },
{ exact ih_1.trans ih_2 }
end
theorem perm_union_right (l : list α) {t₁ t₂ : list α} (h : t₁ ~ t₂) : l ∪ t₁ ~ l ∪ t₂ :=
by induction l; simp [*, perm_insert]
-- @[congr]
theorem perm_union {l₁ l₂ t₁ t₂ : list α} (p₁ : l₁ ~ l₂) (p₂ : t₁ ~ t₂) : l₁ ∪ t₁ ~ l₂ ∪ t₂ :=
trans (perm_union_left t₁ p₁) (perm_union_right l₂ p₂)
theorem perm_inter_left {l₁ l₂ : list α} (t₁ : list α) : l₁ ~ l₂ → l₁ ∩ t₁ ~ l₂ ∩ t₁ :=
perm_filter _
theorem perm_inter_right (l : list α) {t₁ t₂ : list α} (p : t₁ ~ t₂) : l ∩ t₁ = l ∩ t₂ :=
by dsimp [(∩), list.inter]; congr; funext a; rw [mem_of_perm p]
-- @[congr]
theorem perm_inter {l₁ l₂ t₁ t₂ : list α} (p₁ : l₁ ~ l₂) (p₂ : t₁ ~ t₂) : l₁ ∩ t₁ ~ l₂ ∩ t₂ :=
perm_inter_right l₂ p₂ ▸ perm_inter_left t₁ p₁
end
theorem perm_pairwise {R : α → α → Prop} (S : symmetric R) :
∀ {l₁ l₂ : list α} (p : l₁ ~ l₂), pairwise R l₁ ↔ pairwise R l₂ :=
suffices ∀ {l₁ l₂}, l₁ ~ l₂ → pairwise R l₁ → pairwise R l₂, from λ l₁ l₂ p, ⟨this p, this p.symm⟩,
λ l₁ l₂ p d, begin
induction d with a l₁ h d IH generalizing l₂,
{ rw eq_nil_of_perm_nil p, constructor },
{ have : a ∈ l₂ := perm_subset p (mem_cons_self _ _),
rcases mem_split this with ⟨s₂, t₂, rfl⟩,
have p' := perm_cons_inv (p.trans perm_middle),
refine (pairwise_middle S).2 (pairwise_cons.2 ⟨λ b m, _, IH _ p'⟩),
exact h _ (perm_subset p'.symm m) }
end
theorem perm_nodup {l₁ l₂ : list α} : l₁ ~ l₂ → (nodup l₁ ↔ nodup l₂) :=
perm_pairwise $ @ne.symm α
theorem perm_bind_left {l₁ l₂ : list α} (f : α → list β) (p : l₁ ~ l₂) :
l₁.bind f ~ l₂.bind f :=
begin
induction p with a l₁ l₂ p IH a b l l₁ l₂ l₃ p₁ p₂ IH₁ IH₂, {simp},
{ simp, exact perm_app_right _ IH },
{ simp, rw [← append_assoc, ← append_assoc], exact perm_app_left _ perm_app_comm },
{ exact trans IH₁ IH₂ }
end
theorem perm_bind_right (l : list α) {f g : α → list β} (h : ∀ a, f a ~ g a) :
l.bind f ~ l.bind g :=
by induction l with a l IH; simp; exact perm_app (h a) IH
theorem perm_product_left {l₁ l₂ : list α} (t₁ : list β) (p : l₁ ~ l₂) : product l₁ t₁ ~ product l₂ t₁ :=
perm_bind_left _ p
theorem perm_product_right (l : list α) {t₁ t₂ : list β} (p : t₁ ~ t₂) : product l t₁ ~ product l t₂ :=
perm_bind_right _ $ λ a, perm_map _ p
@[congr] theorem perm_product {l₁ l₂ : list α} {t₁ t₂ : list β}
(p₁ : l₁ ~ l₂) (p₂ : t₁ ~ t₂) : product l₁ t₁ ~ product l₂ t₂ :=
trans (perm_product_left t₁ p₁) (perm_product_right l₂ p₂)
theorem sublists_cons_perm_append (a : α) (l : list α) :
sublists (a :: l) ~ sublists l ++ map (cons a) (sublists l) :=
begin
simp [sublists, sublists_aux_cons_cons],
refine skip _ ((skip _ _).trans perm_middle.symm),
induction sublists_aux l cons with b l IH; simp,
exact skip b ((skip _ IH).trans perm_middle.symm)
end
theorem sublists_perm_sublists' : ∀ l : list α, sublists l ~ sublists' l
| [] := perm.refl _
| (a::l) := let IH := sublists_perm_sublists' l in
by rw sublists'_cons; exact
(sublists_cons_perm_append _ _).trans (perm_app IH (perm_map _ IH))
/- enumerating permutations -/
section permutations
theorem permutations_aux2_fst (t : α) (ts : list α) (r : list β) : ∀ (ys : list α) (f : list α → β),
(permutations_aux2 t ts r ys f).1 = ys ++ ts
| [] f := rfl
| (y::ys) f := match _, permutations_aux2_fst ys _ : ∀ o : list α × list β, o.1 = ys ++ ts →
(permutations_aux2._match_1 t y f o).1 = y :: ys ++ ts with
| ⟨_, zs⟩, rfl := rfl
end
@[simp] theorem permutations_aux2_snd_nil (t : α) (ts : list α) (r : list β) (f : list α → β) :
(permutations_aux2 t ts r [] f).2 = r := rfl
@[simp] theorem permutations_aux2_snd_cons (t : α) (ts : list α) (r : list β) (y : α) (ys : list α) (f : list α → β) :
(permutations_aux2 t ts r (y::ys) f).2 = f (t :: y :: ys ++ ts) ::
(permutations_aux2 t ts r ys (λx : list α, f (y::x))).2 :=
match _, permutations_aux2_fst t ts r _ _ : ∀ o : list α × list β, o.1 = ys ++ ts →
(permutations_aux2._match_1 t y f o).2 = f (t :: y :: ys ++ ts) :: o.2 with
| ⟨_, zs⟩, rfl := rfl
end
theorem permutations_aux2_append (t : α) (ts : list α) (r : list β) (ys : list α) (f : list α → β) :
(permutations_aux2 t ts nil ys f).2 ++ r = (permutations_aux2 t ts r ys f).2 :=
by induction ys generalizing f; simp *
theorem mem_permutations_aux2 {t : α} {ts : list α} {ys : list α} {l l' : list α} :
l' ∈ (permutations_aux2 t ts [] ys (append l)).2 ↔
∃ l₁ l₂, l₂ ≠ [] ∧ ys = l₁ ++ l₂ ∧ l' = l ++ l₁ ++ t :: l₂ ++ ts :=
begin
induction ys with y ys ih generalizing l,
{ simpa using λ (l₁ l₂ : list α) (n : ¬ l₂ = []) (e : [] = l₁ ++ l₂),
n.elim (eq_nil_of_sublist_nil $ e.symm ▸ sublist_append_right l₁ l₂) },
{ rw [permutations_aux2_snd_cons, show (λ (x : list α), l ++ y :: x) = append (l ++ [y]),
by funext; simp, mem_cons_iff, ih], split; intro h,
{ rcases h with e | ⟨l₁, l₂, l0, ye, _⟩,
{ subst l', exact ⟨[], y::ys, by simp⟩ },
{ substs l' ys, exact ⟨y::l₁, l₂, l0, by simp⟩ } },
{ rcases h with ⟨_ | ⟨y', l₁⟩, l₂, l0, ye, rfl⟩,
{ simp [ye] },
{ simp at ye, rcases ye with ⟨rfl, rfl⟩,
exact or.inr ⟨l₁, l₂, l0, by simp⟩ } } }
end
theorem mem_permutations_aux2' {t : α} {ts : list α} {ys : list α} {l : list α} :
l ∈ (permutations_aux2 t ts [] ys id).2 ↔
∃ l₁ l₂, l₂ ≠ [] ∧ ys = l₁ ++ l₂ ∧ l = l₁ ++ t :: l₂ ++ ts :=
by rw [show @id (list α) = append nil, by funext; refl]; apply mem_permutations_aux2
theorem length_permutations_aux2 (t : α) (ts : list α) (ys : list α) (f : list α → β) :
length (permutations_aux2 t ts [] ys f).2 = length ys :=
by induction ys generalizing f; simp *
theorem foldr_permutations_aux2 (t : α) (ts : list α) (r L : list (list α)) :
foldr (λy r, (permutations_aux2 t ts r y id).2) r L = L.bind (λ y, (permutations_aux2 t ts [] y id).2) ++ r :=
by induction L with l L ih; [refl, {simp [ih], rw ← permutations_aux2_append}]
theorem mem_foldr_permutations_aux2 {t : α} {ts : list α} {r L : list (list α)} {l' : list α} :
l' ∈ foldr (λy r, (permutations_aux2 t ts r y id).2) r L ↔ l' ∈ r ∨
∃ l₁ l₂, l₁ ++ l₂ ∈ L ∧ l₂ ≠ [] ∧ l' = l₁ ++ t :: l₂ ++ ts :=
have (∃ (a : list α), a ∈ L ∧
∃ (l₁ l₂ : list α), ¬l₂ = nil ∧ a = l₁ ++ l₂ ∧ l' = l₁ ++ t :: (l₂ ++ ts)) ↔
∃ (l₁ l₂ : list α), ¬l₂ = nil ∧ l₁ ++ l₂ ∈ L ∧ l' = l₁ ++ t :: (l₂ ++ ts),
from ⟨λ ⟨a, aL, l₁, l₂, l0, e, h⟩, ⟨l₁, l₂, l0, e ▸ aL, h⟩,
λ ⟨l₁, l₂, l0, aL, h⟩, ⟨_, aL, l₁, l₂, l0, rfl, h⟩⟩,
by rw foldr_permutations_aux2; simp [mem_permutations_aux2', this,
or.comm, or.left_comm, or.assoc, and.comm, and.left_comm, and.assoc]
theorem length_foldr_permutations_aux2 (t : α) (ts : list α) (r L : list (list α)) :
length (foldr (λy r, (permutations_aux2 t ts r y id).2) r L) = sum (map length L) + length r :=
by simp [foldr_permutations_aux2, (∘), length_permutations_aux2]
theorem length_foldr_permutations_aux2' (t : α) (ts : list α) (r L : list (list α))
(n) (H : ∀ l ∈ L, length l = n) :
length (foldr (λy r, (permutations_aux2 t ts r y id).2) r L) = n * length L + length r :=
begin
rw [length_foldr_permutations_aux2, (_ : sum (map length L) = n * length L)],
induction L with l L ih, {simp},
simp [ih (λ l m, H l (mem_cons_of_mem _ m)), H l (mem_cons_self _ _), mul_add]
end
private def meas : (Σ'_:list α, list α) → ℕ × ℕ | ⟨l, i⟩ := (length l + length i, length l)
local infix ` ≺ `:50 := inv_image (prod.lex (<) (<)) meas
theorem perm_of_mem_permutations_aux :
∀ {ts is l : list α}, l ∈ permutations_aux ts is → l ~ ts ++ is :=
begin
refine permutations_aux.rec (by simp) _,
introv IH1 IH2 m,
rw [permutations_aux_cons, permutations, mem_foldr_permutations_aux2] at m,
rcases m with m | ⟨l₁, l₂, m, _, e⟩,
{ exact (IH1 m).trans perm_middle },
{ subst e,
have p : l₁ ++ l₂ ~ is,
{ simp [permutations] at m,
cases m with e m, {simp [e]},
exact is.append_nil ▸ IH2 m },
exact (perm_app_left _ (perm_middle.trans (skip _ p))).trans (skip _ perm_app_comm) }
end
theorem perm_of_mem_permutations {l₁ l₂ : list α}
(h : l₁ ∈ permutations l₂) : l₁ ~ l₂ :=
(eq_or_mem_of_mem_cons h).elim (λ e, e ▸ perm.refl _)
(λ m, append_nil l₂ ▸ perm_of_mem_permutations_aux m)
theorem length_permutations_aux :
∀ ts is : list α, length (permutations_aux ts is) + is.length.fact = (length ts + length is).fact :=
begin
refine permutations_aux.rec (by simp) _,
intros t ts is IH1 IH2,
have IH2 : length (permutations_aux is nil) + 1 = is.length.fact,
{ simpa using IH2 },
simp [-add_comm, nat.fact, nat.add_succ, mul_comm] at IH1,
rw [permutations_aux_cons,
length_foldr_permutations_aux2' _ _ _ _ _
(λ l m, perm_length (perm_of_mem_permutations m)),
permutations, length, length, IH2,
nat.succ_add, nat.fact_succ, mul_comm (nat.succ _), ← IH1,
add_comm (_*_), add_assoc, nat.mul_succ, mul_comm]
end
theorem length_permutations (l : list α) : length (permutations l) = (length l).fact :=
length_permutations_aux l []
theorem mem_permutations_of_perm_lemma {is l : list α}
(H : l ~ [] ++ is → (∃ ts' ~ [], l = ts' ++ is) ∨ l ∈ permutations_aux is [])
: l ~ is → l ∈ permutations is :=
by simpa [permutations, perm_nil] using H
theorem mem_permutations_aux_of_perm :
∀ {ts is l : list α}, l ~ is ++ ts → (∃ is' ~ is, l = is' ++ ts) ∨ l ∈ permutations_aux ts is :=
begin
refine permutations_aux.rec (by simp) _,
intros t ts is IH1 IH2 l p,
rw [permutations_aux_cons, mem_foldr_permutations_aux2],
rcases IH1 (p.trans perm_middle) with ⟨is', p', e⟩ | m,
{ clear p, subst e,
rcases mem_split (perm_subset p'.symm (mem_cons_self _ _)) with ⟨l₁, l₂, e⟩,
subst is',
have p := perm_cons_inv (perm_middle.symm.trans p'),
cases l₂ with a l₂',
{ exact or.inl ⟨l₁, by simpa using p⟩ },
{ exact or.inr (or.inr ⟨l₁, a::l₂',
mem_permutations_of_perm_lemma IH2 p, by simp⟩) } },
{ exact or.inr (or.inl m) }
end
@[simp] theorem mem_permutations (s t : list α) : s ∈ permutations t ↔ s ~ t :=
⟨perm_of_mem_permutations, mem_permutations_of_perm_lemma mem_permutations_aux_of_perm⟩
end permutations
end list
|
dcbed6a96f0e62b8e8109f6a4affc40e54b9d647 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/data/hash_map.lean | 60f9ec9b3f180b93201b78a43b4ad2d2515c423f | [
"Apache-2.0"
] | permissive | Vierkantor/mathlib | 0ea59ac32a3a43c93c44d70f441c4ee810ccceca | 83bc3b9ce9b13910b57bda6b56222495ebd31c2f | refs/heads/master | 1,658,323,012,449 | 1,652,256,003,000 | 1,652,256,003,000 | 209,296,341 | 0 | 1 | Apache-2.0 | 1,568,807,655,000 | 1,568,807,655,000 | null | UTF-8 | Lean | false | false | 29,555 | lean | /-
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Mario Carneiro
-/
import data.array.lemmas
import data.list.join
import data.list.range
import data.pnat.basic
/-!
# Hash maps
Defines a hash map data structure, representing a finite key-value map
with a value type that may depend on the key type. The structure
requires a `nat`-valued hash function to associate keys to buckets.
## Main definitions
* `hash_map`: constructed with `mk_hash_map`.
## Implementation details
A hash map with key type `α` and (dependent) value type `β : α → Type*`
consists of an array of *buckets*, which are lists containing
key/value pairs for that bucket. The hash function is taken modulo `n`
to assign keys to their respective bucket. Because of this, some care
should be put into the hash function to ensure it evenly distributes
keys.
The bucket array is an `array`. These have special VM support for
in-place modification if there is only ever one reference to them. If
one takes special care to never keep references to old versions of a
hash map alive after updating it, then the hash map will be modified
in-place. In this documentation, when we say a hash map is modified
in-place, we are assuming the API is being used in this manner.
When inserting (`hash_map.insert`), if the number of stored pairs (the
*size*) is going to exceed the number of buckets, then a new hash map
is first created with double the number of buckets and everything in
the old hash map is reinserted along with the new key/value pair.
Otherwise, the bucket array is modified in-place. The amortized
running time of inserting $$n$$ elements into a hash map is $$O(n)$$.
When removing (`hash_map.erase`), the hash map is modified in-place.
The implementation does not reduce the number of buckets in the hash
map if the size gets too low.
## Tags
hash map
-/
universes u v w
/-- `bucket_array α β` is the underlying data type for `hash_map α β`,
an array of linked lists of key-value pairs. -/
def bucket_array (α : Type u) (β : α → Type v) (n : ℕ+) :=
array n (list Σ a, β a)
/-- Make a hash_map index from a `nat` hash value and a (positive) buffer size -/
def hash_map.mk_idx (n : ℕ+) (i : nat) : fin n :=
⟨i % n, nat.mod_lt _ n.2⟩
namespace bucket_array
section
parameters {α : Type u} {β : α → Type v} (hash_fn : α → nat)
variables {n : ℕ+} (data : bucket_array α β n)
instance : inhabited (bucket_array α β n) :=
⟨mk_array _ []⟩
/-- Read the bucket corresponding to an element -/
def read (a : α) : list Σ a, β a :=
let bidx := hash_map.mk_idx n (hash_fn a) in
data.read bidx
/-- Write the bucket corresponding to an element -/
def write (a : α) (l : list Σ a, β a) : bucket_array α β n :=
let bidx := hash_map.mk_idx n (hash_fn a) in
data.write bidx l
/-- Modify (read, apply `f`, and write) the bucket corresponding to an element -/
def modify (a : α) (f : list (Σ a, β a) → list (Σ a, β a)) : bucket_array α β n :=
let bidx := hash_map.mk_idx n (hash_fn a) in
array.write data bidx (f (array.read data bidx))
/-- The list of all key-value pairs in the bucket list -/
def as_list : list Σ a, β a := data.to_list.join
theorem mem_as_list {a : Σ a, β a} : a ∈ data.as_list ↔ ∃i, a ∈ array.read data i :=
have (∃ (l : list (Σ (a : α), β a)) (i : fin (n.val)), a ∈ l ∧ array.read data i = l) ↔
∃ (i : fin (n.val)), a ∈ array.read data i,
by rw exists_swap; exact exists_congr (λ i, by simp),
by simp [as_list]; simpa [array.mem.def, and_comm]
/-- Fold a function `f` over the key-value pairs in the bucket list -/
def foldl {δ : Type w} (d : δ) (f : δ → Π a, β a → δ) : δ :=
data.foldl d (λ b d, b.foldl (λ r a, f r a.1 a.2) d)
theorem foldl_eq {δ : Type w} (d : δ) (f : δ → Π a, β a → δ) :
data.foldl d f = data.as_list.foldl (λ r a, f r a.1 a.2) d :=
by rw [foldl, as_list, list.foldl_join, ← array.to_list_foldl]
end
end bucket_array
namespace hash_map
section
parameters {α : Type u} {β : α → Type v} (hash_fn : α → nat)
/-- Insert the pair `⟨a, b⟩` into the correct location in the bucket array
(without checking for duplication) -/
def reinsert_aux {n} (data : bucket_array α β n) (a : α) (b : β a) : bucket_array α β n :=
data.modify hash_fn a (λl, ⟨a, b⟩ :: l)
theorem mk_as_list (n : ℕ+) : bucket_array.as_list (mk_array n [] : bucket_array α β n) = [] :=
list.eq_nil_iff_forall_not_mem.mpr $ λ x m,
let ⟨i, h⟩ := (bucket_array.mem_as_list _).1 m in h
parameter [decidable_eq α]
/-- Search a bucket for a key `a` and return the value -/
def find_aux (a : α) : list (Σ a, β a) → option (β a)
| [] := none
| (⟨a',b⟩::t) := if h : a' = a then some (eq.rec_on h b) else find_aux t
theorem find_aux_iff {a : α} {b : β a} :
Π {l : list Σ a, β a}, (l.map sigma.fst).nodup → (find_aux a l = some b ↔ sigma.mk a b ∈ l)
| [] nd := ⟨λn, by injection n, false.elim⟩
| (⟨a',b'⟩::t) nd := begin
by_cases a' = a,
{ clear find_aux_iff, subst h,
suffices : b' = b ↔ b' = b ∨ sigma.mk a' b ∈ t, {simpa [find_aux, eq_comm]},
refine (or_iff_left_of_imp (λ m, _)).symm,
have : a' ∉ t.map sigma.fst, from nd.not_mem,
exact this.elim (list.mem_map_of_mem sigma.fst m) },
{ have : sigma.mk a b ≠ ⟨a', b'⟩,
{ intro e, injection e with e, exact h e.symm },
simp at nd, simp [find_aux, h, ne.symm h, find_aux_iff, nd] }
end
/-- Returns `tt` if the bucket `l` contains the key `a` -/
def contains_aux (a : α) (l : list Σ a, β a) : bool :=
(find_aux a l).is_some
theorem contains_aux_iff {a : α} {l : list Σ a, β a} (nd : (l.map sigma.fst).nodup) :
contains_aux a l ↔ a ∈ l.map sigma.fst :=
begin
unfold contains_aux,
cases h : find_aux a l with b; simp,
{ assume (b : β a) (m : sigma.mk a b ∈ l),
rw (find_aux_iff nd).2 m at h,
contradiction },
{ show ∃ (b : β a), sigma.mk a b ∈ l,
exact ⟨_, (find_aux_iff nd).1 h⟩ },
end
/-- Modify a bucket to replace a value in the list. Leaves the list
unchanged if the key is not found. -/
def replace_aux (a : α) (b : β a) : list (Σ a, β a) → list (Σ a, β a)
| [] := []
| (⟨a', b'⟩::t) := if a' = a then ⟨a, b⟩::t else ⟨a', b'⟩ :: replace_aux t
/-- Modify a bucket to remove a key, if it exists. -/
def erase_aux (a : α) : list (Σ a, β a) → list (Σ a, β a)
| [] := []
| (⟨a', b'⟩::t) := if a' = a then t else ⟨a', b'⟩ :: erase_aux t
/-- The predicate `valid bkts sz` means that `bkts` satisfies the `hash_map`
invariants: There are exactly `sz` elements in it, every pair is in the
bucket determined by its key and the hash function, and no key appears
multiple times in the list. -/
structure valid {n} (bkts : bucket_array α β n) (sz : nat) : Prop :=
(len : bkts.as_list.length = sz)
(idx : ∀ {i} {a : Σ a, β a}, a ∈ array.read bkts i →
mk_idx n (hash_fn a.1) = i)
(nodup : ∀i, ((array.read bkts i).map sigma.fst).nodup)
theorem valid.idx_enum {n} {bkts : bucket_array α β n} {sz : nat} (v : valid bkts sz)
{i l} (he : (i, l) ∈ bkts.to_list.enum) {a} {b : β a} (hl : sigma.mk a b ∈ l) :
∃ h, mk_idx n (hash_fn a) = ⟨i, h⟩ :=
(array.mem_to_list_enum.mp he).imp (λ h e, by subst e; exact v.idx hl)
theorem valid.idx_enum_1 {n} {bkts : bucket_array α β n} {sz : nat} (v : valid bkts sz)
{i l} (he : (i, l) ∈ bkts.to_list.enum) {a} {b : β a} (hl : sigma.mk a b ∈ l) :
(mk_idx n (hash_fn a)).1 = i :=
let ⟨h, e⟩ := v.idx_enum _ he hl in by rw e; refl
theorem valid.as_list_nodup {n} {bkts : bucket_array α β n} {sz : nat} (v : valid bkts sz) :
(bkts.as_list.map sigma.fst).nodup :=
begin
suffices : (bkts.to_list.map (list.map sigma.fst)).pairwise list.disjoint,
{ suffices : ∀ l, array.mem l bkts → (l.map sigma.fst).nodup,
by simpa [bucket_array.as_list, list.nodup_join, *],
rintros l ⟨i, rfl⟩,
apply v.nodup },
rw [← list.enum_map_snd bkts.to_list, list.pairwise_map, list.pairwise_map],
have : (bkts.to_list.enum.map prod.fst).nodup := by simp [list.nodup_range],
refine list.pairwise.imp_of_mem _ ((list.pairwise_map _).1 this),
rw prod.forall, intros i l₁,
rw prod.forall, intros j l₂ me₁ me₂ ij,
simp [list.disjoint], intros a b ml₁ b' ml₂,
apply ij, rwa [← v.idx_enum_1 _ me₁ ml₁, ← v.idx_enum_1 _ me₂ ml₂]
end
theorem mk_valid (n : ℕ+) : @valid n (mk_array n []) 0 :=
⟨by simp [mk_as_list], λ i a h, by cases h, λ i, list.nodup_nil⟩
theorem valid.find_aux_iff {n} {bkts : bucket_array α β n} {sz : nat} (v : valid bkts sz) {a : α}
{b : β a} :
find_aux a (bkts.read hash_fn a) = some b ↔ sigma.mk a b ∈ bkts.as_list :=
(find_aux_iff (v.nodup _)).trans $
by rw bkts.mem_as_list; exact ⟨λ h, ⟨_, h⟩, λ ⟨i, h⟩, (v.idx h).symm ▸ h⟩
theorem valid.contains_aux_iff {n} {bkts : bucket_array α β n} {sz : nat} (v : valid bkts sz)
(a : α) :
contains_aux a (bkts.read hash_fn a) ↔ a ∈ bkts.as_list.map sigma.fst :=
by simp [contains_aux, option.is_some_iff_exists, v.find_aux_iff hash_fn]
section
parameters {n : ℕ+} {bkts : bucket_array α β n}
{bidx : fin n} {f : list (Σ a, β a) → list (Σ a, β a)}
(u v1 v2 w : list Σ a, β a)
local notation `L` := array.read bkts bidx
private def bkts' : bucket_array α β n := array.write bkts bidx (f L)
variables (hl : L = u ++ v1 ++ w)
(hfl : f L = u ++ v2 ++ w)
include hl hfl
theorem append_of_modify :
∃ u' w', bkts.as_list = u' ++ v1 ++ w' ∧ bkts'.as_list = u' ++ v2 ++ w' :=
begin
unfold bucket_array.as_list,
have h : (bidx : ℕ) < bkts.to_list.length, { simp only [bidx.is_lt, array.to_list_length] },
refine ⟨(bkts.to_list.take bidx).join ++ u, w ++ (bkts.to_list.drop (bidx+1)).join, _, _⟩,
{ conv { to_lhs,
rw [← list.take_append_drop bidx bkts.to_list, list.drop_eq_nth_le_cons h],
simp [hl] }, simp },
{ conv { to_lhs,
rw [bkts', array.write_to_list, list.update_nth_eq_take_cons_drop _ h],
simp [hfl] }, simp }
end
variables (hvnd : (v2.map sigma.fst).nodup)
(hal : ∀ (a : Σ a, β a), a ∈ v2 → mk_idx n (hash_fn a.1) = bidx)
(djuv : (u.map sigma.fst).disjoint (v2.map sigma.fst))
(djwv : (w.map sigma.fst).disjoint (v2.map sigma.fst))
include hvnd hal djuv djwv
theorem valid.modify {sz : ℕ} (v : valid bkts sz) :
v1.length ≤ sz + v2.length ∧ valid bkts' (sz + v2.length - v1.length) :=
begin
rcases append_of_modify u v1 v2 w hl hfl with ⟨u', w', e₁, e₂⟩,
rw [← v.len, e₁],
suffices : valid bkts' (u' ++ v2 ++ w').length,
{ simpa [ge, add_comm, add_left_comm, nat.le_add_right, add_tsub_cancel_left] },
refine ⟨congr_arg _ e₂, λ i a, _, λ i, _⟩,
{ by_cases bidx = i,
{ subst i, rw [bkts', array.read_write, hfl],
have := @valid.idx _ _ _ v bidx a,
simp only [hl, list.mem_append, or_imp_distrib, forall_and_distrib] at this ⊢,
exact ⟨⟨this.1.1, hal _⟩, this.2⟩ },
{ rw [bkts', array.read_write_of_ne _ _ h], apply v.idx } },
{ by_cases bidx = i,
{ subst i, rw [bkts', array.read_write, hfl],
have := @valid.nodup _ _ _ v bidx,
simp [hl, list.nodup_append] at this,
simp [list.nodup_append, this, hvnd, djuv, djwv.symm] },
{ rw [bkts', array.read_write_of_ne _ _ h], apply v.nodup } }
end
end
theorem valid.replace_aux (a : α) (b : β a) : Π (l : list (Σ a, β a)), a ∈ l.map sigma.fst →
∃ (u w : list Σ a, β a) b', l = u ++ [⟨a, b'⟩] ++ w ∧ replace_aux a b l = u ++ [⟨a, b⟩] ++ w
| [] := false.elim
| (⟨a', b'⟩::t) := begin
by_cases e : a' = a,
{ subst a',
suffices : ∃ (u w : list Σ a, β a) (b'' : β a),
(sigma.mk a b') :: t = u ++ ⟨a, b''⟩ :: w ∧
replace_aux a b (⟨a, b'⟩ :: t) = u ++ ⟨a, b⟩ :: w, {simpa},
refine ⟨[], t, b', _⟩, simp [replace_aux] },
{ suffices : ∀ (x : β a) (_ : sigma.mk a x ∈ t), ∃ u w (b'' : β a),
(sigma.mk a' b') :: t = u ++ ⟨a, b''⟩ :: w ∧
(sigma.mk a' b') :: (replace_aux a b t) = u ++ ⟨a, b⟩ :: w,
{ simpa [replace_aux, ne.symm e, e] },
intros x m,
have IH : ∀ (x : β a) (_ : sigma.mk a x ∈ t), ∃ u w (b'' : β a),
t = u ++ ⟨a, b''⟩ :: w ∧ replace_aux a b t = u ++ ⟨a, b⟩ :: w,
{ simpa using valid.replace_aux t },
rcases IH x m with ⟨u, w, b'', hl, hfl⟩,
exact ⟨⟨a', b'⟩ :: u, w, b'', by simp [hl, hfl.symm, ne.symm e]⟩ }
end
theorem valid.replace {n : ℕ+}
{bkts : bucket_array α β n} {sz : ℕ} (a : α) (b : β a)
(Hc : contains_aux a (bkts.read hash_fn a))
(v : valid bkts sz) : valid (bkts.modify hash_fn a (replace_aux a b)) sz :=
begin
have nd := v.nodup (mk_idx n (hash_fn a)),
rcases hash_map.valid.replace_aux a b (array.read bkts (mk_idx n (hash_fn a)))
((contains_aux_iff nd).1 Hc) with ⟨u, w, b', hl, hfl⟩,
simp [hl, list.nodup_append] at nd,
refine (v.modify hash_fn
u [⟨a, b'⟩] [⟨a, b⟩] w hl hfl (list.nodup_singleton _)
(λa' e, by simp at e; rw e)
(λa' e1 e2, _)
(λa' e1 e2, _)).2;
{ revert e1, simp [-sigma.exists] at e2, subst a', simp [nd] }
end
theorem valid.insert {n : ℕ+}
{bkts : bucket_array α β n} {sz : ℕ} (a : α) (b : β a)
(Hnc : ¬ contains_aux a (bkts.read hash_fn a))
(v : valid bkts sz) : valid (reinsert_aux bkts a b) (sz+1) :=
begin
have nd := v.nodup (mk_idx n (hash_fn a)),
refine (v.modify hash_fn
[] [] [⟨a, b⟩] (bkts.read hash_fn a) rfl rfl (list.nodup_singleton _)
(λa' e, by simp at e; rw e)
(λa', false.elim)
(λa' e1 e2, _)).2,
simp [-sigma.exists] at e2, subst a',
exact Hnc ((contains_aux_iff nd).2 e1)
end
theorem valid.erase_aux (a : α) : Π (l : list (Σ a, β a)), a ∈ l.map sigma.fst →
∃ (u w : list Σ a, β a) b, l = u ++ [⟨a, b⟩] ++ w ∧ erase_aux a l = u ++ [] ++ w
| [] := false.elim
| (⟨a', b'⟩::t) := begin
by_cases e : a' = a,
{ subst a',
simpa [erase_aux, and_comm] using show ∃ u w (x : β a),
t = u ++ w ∧ (sigma.mk a b') :: t = u ++ ⟨a, x⟩ :: w,
from ⟨[], t, b', by simp⟩ },
{ simp [erase_aux, e, ne.symm e],
suffices : ∀ (b : β a) (_ : sigma.mk a b ∈ t), ∃ u w (x : β a),
(sigma.mk a' b') :: t = u ++ ⟨a, x⟩ :: w ∧
(sigma.mk a' b') :: (erase_aux a t) = u ++ w,
{ simpa [replace_aux, ne.symm e, e] },
intros b m,
have IH : ∀ (x : β a) (_ : sigma.mk a x ∈ t), ∃ u w (x : β a),
t = u ++ ⟨a, x⟩ :: w ∧ erase_aux a t = u ++ w,
{ simpa using valid.erase_aux t },
rcases IH b m with ⟨u, w, b'', hl, hfl⟩,
exact ⟨⟨a', b'⟩ :: u, w, b'', by simp [hl, hfl.symm]⟩ }
end
theorem valid.erase {n} {bkts : bucket_array α β n} {sz}
(a : α) (Hc : contains_aux a (bkts.read hash_fn a))
(v : valid bkts sz) : valid (bkts.modify hash_fn a (erase_aux a)) (sz-1) :=
begin
have nd := v.nodup (mk_idx n (hash_fn a)),
rcases hash_map.valid.erase_aux a (array.read bkts (mk_idx n (hash_fn a)))
((contains_aux_iff nd).1 Hc) with ⟨u, w, b, hl, hfl⟩,
refine (v.modify hash_fn u [⟨a, b⟩] [] w hl hfl list.nodup_nil _ _ _).2;
simp
end
end
end hash_map
/-- A hash map data structure, representing a finite key-value map
with key type `α` and value type `β` (which may depend on `α`). -/
structure hash_map (α : Type u) [decidable_eq α] (β : α → Type v) :=
(hash_fn : α → nat)
(size : ℕ)
(nbuckets : ℕ+)
(buckets : bucket_array α β nbuckets)
(is_valid : hash_map.valid hash_fn buckets size)
/-- Construct an empty hash map with buffer size `nbuckets` (default 8). -/
def mk_hash_map {α : Type u} [decidable_eq α] {β : α → Type v} (hash_fn : α → nat) (nbuckets := 8) :
hash_map α β :=
let n := if nbuckets = 0 then 8 else nbuckets in
let nz : n > 0 := by abstract { cases nbuckets; simp [if_pos, nat.succ_ne_zero] } in
{ hash_fn := hash_fn,
size := 0,
nbuckets := ⟨n, nz⟩,
buckets := mk_array n [],
is_valid := hash_map.mk_valid _ _ }
namespace hash_map
variables {α : Type u} {β : α → Type v} [decidable_eq α]
/-- Return the value corresponding to a key, or `none` if not found -/
def find (m : hash_map α β) (a : α) : option (β a) :=
find_aux a (m.buckets.read m.hash_fn a)
/-- Return `tt` if the key exists in the map -/
def contains (m : hash_map α β) (a : α) : bool :=
(m.find a).is_some
instance : has_mem α (hash_map α β) := ⟨λa m, m.contains a⟩
/-- Fold a function over the key-value pairs in the map -/
def fold {δ : Type w} (m : hash_map α β) (d : δ) (f : δ → Π a, β a → δ) : δ :=
m.buckets.foldl d f
/-- The list of key-value pairs in the map -/
def entries (m : hash_map α β) : list Σ a, β a :=
m.buckets.as_list
/-- The list of keys in the map -/
def keys (m : hash_map α β) : list α :=
m.entries.map sigma.fst
theorem find_iff (m : hash_map α β) (a : α) (b : β a) :
m.find a = some b ↔ sigma.mk a b ∈ m.entries :=
m.is_valid.find_aux_iff _
theorem contains_iff (m : hash_map α β) (a : α) :
m.contains a ↔ a ∈ m.keys :=
m.is_valid.contains_aux_iff _ _
theorem entries_empty (hash_fn : α → nat) (n) :
(@mk_hash_map α _ β hash_fn n).entries = [] :=
mk_as_list _
theorem keys_empty (hash_fn : α → nat) (n) :
(@mk_hash_map α _ β hash_fn n).keys = [] :=
by dsimp [keys]; rw entries_empty; refl
theorem find_empty (hash_fn : α → nat) (n a) :
(@mk_hash_map α _ β hash_fn n).find a = none :=
by induction h : (@mk_hash_map α _ β hash_fn n).find a; [refl,
{ have := (find_iff _ _ _).1 h, rw entries_empty at this, contradiction }]
theorem not_contains_empty (hash_fn : α → nat) (n a) :
¬ (@mk_hash_map α _ β hash_fn n).contains a :=
by apply bool_iff_false.2; dsimp [contains]; rw [find_empty]; refl
theorem insert_lemma (hash_fn : α → nat) {n n'}
{bkts : bucket_array α β n} {sz} (v : valid hash_fn bkts sz) :
valid hash_fn (bkts.foldl (mk_array _ [] : bucket_array α β n') (reinsert_aux hash_fn)) sz :=
begin
suffices : ∀ (l : list Σ a, β a) (t : bucket_array α β n') sz,
valid hash_fn t sz → ((l ++ t.as_list).map sigma.fst).nodup →
valid hash_fn (l.foldl (λr (a : Σ a, β a), reinsert_aux hash_fn r a.1 a.2) t) (sz + l.length),
{ have p := this bkts.as_list _ _ (mk_valid _ _),
rw [mk_as_list, list.append_nil, zero_add, v.len] at p,
rw bucket_array.foldl_eq,
exact p (v.as_list_nodup _) },
intro l, induction l with c l IH; intros t sz v nd, {exact v},
rw show sz + (c :: l).length = sz + 1 + l.length, by simp [add_comm, add_assoc],
rcases (show (l.map sigma.fst).nodup ∧
((bucket_array.as_list t).map sigma.fst).nodup ∧
c.fst ∉ l.map sigma.fst ∧
c.fst ∉ (bucket_array.as_list t).map sigma.fst ∧
(l.map sigma.fst).disjoint ((bucket_array.as_list t).map sigma.fst),
by simpa [list.nodup_append, not_or_distrib, and_comm, and.left_comm] using nd)
with ⟨nd1, nd2, nm1, nm2, dj⟩,
have v' := v.insert _ _ c.2 (λHc, nm2 $ (v.contains_aux_iff _ c.1).1 Hc),
apply IH _ _ v',
suffices : ∀ ⦃a : α⦄ (b : β a), sigma.mk a b ∈ l →
∀ (b' : β a), sigma.mk a b' ∈ (reinsert_aux hash_fn t c.1 c.2).as_list → false,
{ simpa [list.nodup_append, nd1, v'.as_list_nodup _, list.disjoint] },
intros a b m1 b' m2,
rcases (reinsert_aux hash_fn t c.1 c.2).mem_as_list.1 m2 with ⟨i, im⟩,
have : sigma.mk a b' ∉ array.read t i,
{ intro m3,
have : a ∈ list.map sigma.fst t.as_list :=
list.mem_map_of_mem sigma.fst (t.mem_as_list.2 ⟨_, m3⟩),
exact dj (list.mem_map_of_mem sigma.fst m1) this },
by_cases h : mk_idx n' (hash_fn c.1) = i,
{ subst h,
have e : sigma.mk a b' = ⟨c.1, c.2⟩,
{ simpa [reinsert_aux, bucket_array.modify, array.read_write, this] using im },
injection e with e, subst a,
exact nm1.elim (@list.mem_map_of_mem _ _ sigma.fst _ _ m1) },
{ apply this,
simpa [reinsert_aux, bucket_array.modify, array.read_write_of_ne _ _ h] using im }
end
/-- Insert a key-value pair into the map. (Modifies `m` in-place when applicable) -/
def insert : Π (m : hash_map α β) (a : α) (b : β a), hash_map α β
| ⟨hash_fn, size, n, buckets, v⟩ a b :=
let bkt := buckets.read hash_fn a in
if hc : contains_aux a bkt then
{ hash_fn := hash_fn,
size := size,
nbuckets := n,
buckets := buckets.modify hash_fn a (replace_aux a b),
is_valid := v.replace _ a b hc }
else
let size' := size + 1,
buckets' := buckets.modify hash_fn a (λl, ⟨a, b⟩::l),
valid' := v.insert _ a b hc in
if size' ≤ n then
{ hash_fn := hash_fn,
size := size',
nbuckets := n,
buckets := buckets',
is_valid := valid' }
else
let n' : ℕ+ := ⟨n * 2, mul_pos n.2 dec_trivial⟩,
buckets'' : bucket_array α β n' :=
buckets'.foldl (mk_array _ []) (reinsert_aux hash_fn) in
{ hash_fn := hash_fn,
size := size',
nbuckets := n',
buckets := buckets'',
is_valid := insert_lemma _ valid' }
theorem mem_insert : Π (m : hash_map α β) (a b a' b'),
(sigma.mk a' b' : sigma β) ∈ (m.insert a b).entries ↔
if a = a' then b == b' else sigma.mk a' b' ∈ m.entries
| ⟨hash_fn, size, n, bkts, v⟩ a b a' b' := begin
let bkt := bkts.read hash_fn a,
have nd : (bkt.map sigma.fst).nodup := v.nodup (mk_idx n (hash_fn a)),
have lem : Π (bkts' : bucket_array α β n) (v1 u w)
(hl : bucket_array.as_list bkts = u ++ v1 ++ w)
(hfl : bucket_array.as_list bkts' = u ++ [⟨a, b⟩] ++ w)
(veq : (v1 = [] ∧ ¬ contains_aux a bkt) ∨ ∃b'', v1 = [⟨a, b''⟩]),
sigma.mk a' b' ∈ bkts'.as_list ↔
if a = a' then b == b' else sigma.mk a' b' ∈ bkts.as_list,
{ intros bkts' v1 u w hl hfl veq,
rw [hl, hfl],
by_cases h : a = a',
{ subst a',
suffices : b = b' ∨ sigma.mk a b' ∈ u ∨ sigma.mk a b' ∈ w ↔ b = b',
{ simpa [eq_comm, or.left_comm] },
refine or_iff_left_of_imp (not.elim $ not_or_distrib.2 _),
rcases veq with ⟨rfl, Hnc⟩ | ⟨b'', rfl⟩,
{ have na := (not_iff_not_of_iff $ v.contains_aux_iff _ _).1 Hnc,
simp [hl, not_or_distrib] at na, simp [na] },
{ have nd' := v.as_list_nodup _,
simp [hl, list.nodup_append] at nd', simp [nd'] } },
{ suffices : sigma.mk a' b' ∉ v1, {simp [h, ne.symm h, this]},
rcases veq with ⟨rfl, Hnc⟩ | ⟨b'', rfl⟩; simp [ne.symm h] } },
by_cases Hc : (contains_aux a bkt : Prop),
{ rcases hash_map.valid.replace_aux a b (array.read bkts (mk_idx n (hash_fn a)))
((contains_aux_iff nd).1 Hc) with ⟨u', w', b'', hl', hfl'⟩,
rcases (append_of_modify u' [⟨a, b''⟩] [⟨a, b⟩] w' hl' hfl') with ⟨u, w, hl, hfl⟩,
simpa [insert, @dif_pos (contains_aux a bkt) _ Hc]
using lem _ _ u w hl hfl (or.inr ⟨b'', rfl⟩) },
{ let size' := size + 1,
let bkts' := bkts.modify hash_fn a (λl, ⟨a, b⟩::l),
have mi : sigma.mk a' b' ∈ bkts'.as_list ↔
if a = a' then b == b' else sigma.mk a' b' ∈ bkts.as_list :=
let ⟨u, w, hl, hfl⟩ := append_of_modify [] [] [⟨a, b⟩] _ rfl rfl in
lem bkts' _ u w hl hfl $ or.inl ⟨rfl, Hc⟩,
simp [insert, @dif_neg (contains_aux a bkt) _ Hc],
by_cases h : size' ≤ n,
{ simpa [show size' ≤ n, from h] using mi },
{ let n' : ℕ+ := ⟨n * 2, mul_pos n.2 dec_trivial⟩,
let bkts'' : bucket_array α β n' := bkts'.foldl (mk_array _ []) (reinsert_aux hash_fn),
suffices : sigma.mk a' b' ∈ bkts''.as_list ↔ sigma.mk a' b' ∈ bkts'.as_list.reverse,
{ simpa [show ¬ size' ≤ n, from h, mi] },
rw [show bkts'' = bkts'.as_list.foldl _ _, from bkts'.foldl_eq _ _,
← list.foldr_reverse],
induction bkts'.as_list.reverse with a l IH,
{ simp [mk_as_list] },
{ cases a with a'' b'',
let B := l.foldr (λ (y : sigma β) (x : bucket_array α β n'),
reinsert_aux hash_fn x y.1 y.2) (mk_array n' []),
rcases append_of_modify [] [] [⟨a'', b''⟩] _ rfl rfl with ⟨u, w, hl, hfl⟩,
simp [IH.symm, or.left_comm, show B.as_list = _, from hl,
show (reinsert_aux hash_fn B a'' b'').as_list = _, from hfl] } } }
end
theorem find_insert_eq (m : hash_map α β) (a : α) (b : β a) : (m.insert a b).find a = some b :=
(find_iff (m.insert a b) a b).2 $ (mem_insert m a b a b).2 $ by rw if_pos rfl
theorem find_insert_ne (m : hash_map α β) (a a' : α) (b : β a) (h : a ≠ a') :
(m.insert a b).find a' = m.find a' :=
option.eq_of_eq_some $ λb',
let t := mem_insert m a b a' b' in
(find_iff _ _ _).trans $ iff.trans (by rwa if_neg h at t) (find_iff _ _ _).symm
theorem find_insert (m : hash_map α β) (a' a : α) (b : β a) :
(m.insert a b).find a' = if h : a = a' then some (eq.rec_on h b) else m.find a' :=
if h : a = a' then by rw dif_pos h; exact
match a', h with ._, rfl := find_insert_eq m a b end
else by rw dif_neg h; exact find_insert_ne m a a' b h
/-- Insert a list of key-value pairs into the map. (Modifies `m` in-place when applicable) -/
def insert_all (l : list (Σ a, β a)) (m : hash_map α β) : hash_map α β :=
l.foldl (λ m ⟨a, b⟩, insert m a b) m
/-- Construct a hash map from a list of key-value pairs. -/
def of_list (l : list (Σ a, β a)) (hash_fn) : hash_map α β :=
insert_all l (mk_hash_map hash_fn (2 * l.length))
/-- Remove a key from the map. (Modifies `m` in-place when applicable) -/
def erase (m : hash_map α β) (a : α) : hash_map α β :=
match m with ⟨hash_fn, size, n, buckets, v⟩ :=
if hc : contains_aux a (buckets.read hash_fn a) then
{ hash_fn := hash_fn,
size := size - 1,
nbuckets := n,
buckets := buckets.modify hash_fn a (erase_aux a),
is_valid := v.erase _ a hc }
else m
end
theorem mem_erase : Π (m : hash_map α β) (a a' b'),
(sigma.mk a' b' : sigma β) ∈ (m.erase a).entries ↔
a ≠ a' ∧ sigma.mk a' b' ∈ m.entries
| ⟨hash_fn, size, n, bkts, v⟩ a a' b' := begin
let bkt := bkts.read hash_fn a,
by_cases Hc : (contains_aux a bkt : Prop),
{ let bkts' := bkts.modify hash_fn a (erase_aux a),
suffices : sigma.mk a' b' ∈ bkts'.as_list ↔ a ≠ a' ∧ sigma.mk a' b' ∈ bkts.as_list,
{ simpa [erase, @dif_pos (contains_aux a bkt) _ Hc] },
have nd := v.nodup (mk_idx n (hash_fn a)),
rcases valid.erase_aux a bkt ((contains_aux_iff nd).1 Hc) with ⟨u', w', b, hl', hfl'⟩,
rcases append_of_modify u' [⟨a, b⟩] [] _ hl' hfl' with ⟨u, w, hl, hfl⟩,
suffices : ∀_:sigma.mk a' b' ∈ u ∨ sigma.mk a' b' ∈ w, a ≠ a',
{ have : sigma.mk a' b' ∈ u ∨ sigma.mk a' b' ∈ w ↔ (¬a = a' ∧ a' = a) ∧ b' == b ∨
¬a = a' ∧ (sigma.mk a' b' ∈ u ∨ sigma.mk a' b' ∈ w),
{ simp [eq_comm, not_and_self_iff, and_iff_right_of_imp this] },
simpa [hl, show bkts'.as_list = _, from hfl, and_or_distrib_left,
and_comm, and.left_comm, or.left_comm] },
rintro m rfl, revert m, apply not_or_distrib.2,
have nd' := v.as_list_nodup _,
simp [hl, list.nodup_append] at nd', simp [nd'] },
{ suffices : ∀_:sigma.mk a' b' ∈ bucket_array.as_list bkts, a ≠ a',
{ simp [erase, @dif_neg (contains_aux a bkt) _ Hc, entries, and_iff_right_of_imp this] },
rintro m rfl,
exact Hc ((v.contains_aux_iff _ _).2 (list.mem_map_of_mem sigma.fst m)) }
end
theorem find_erase_eq (m : hash_map α β) (a : α) : (m.erase a).find a = none :=
begin
cases h : (m.erase a).find a with b, {refl},
exact absurd rfl ((mem_erase m a a b).1 ((find_iff (m.erase a) a b).1 h)).left
end
theorem find_erase_ne (m : hash_map α β) (a a' : α) (h : a ≠ a') :
(m.erase a).find a' = m.find a' :=
option.eq_of_eq_some $ λb',
(find_iff _ _ _).trans $ (mem_erase m a a' b').trans $
(and_iff_right h).trans (find_iff _ _ _).symm
theorem find_erase (m : hash_map α β) (a' a : α) :
(m.erase a).find a' = if a = a' then none else m.find a' :=
if h : a = a' then by subst a'; simp [find_erase_eq m a]
else by rw if_neg h; exact find_erase_ne m a a' h
section string
variables [has_to_string α] [∀ a, has_to_string (β a)]
open prod
private def key_data_to_string (a : α) (b : β a) (first : bool) : string :=
(if first then "" else ", ") ++ sformat!"{a} ← {b}"
private def to_string (m : hash_map α β) : string :=
"⟨" ++ (fst (fold m ("", tt) (λ p a b, (fst p ++ key_data_to_string a b (snd p), ff)))) ++ "⟩"
instance : has_to_string (hash_map α β) :=
⟨to_string⟩
end string
section format
open format prod
variables [has_to_format α] [∀ a, has_to_format (β a)]
private meta def format_key_data (a : α) (b : β a) (first : bool) : format :=
(if first then to_fmt "" else to_fmt "," ++ line) ++
to_fmt a ++ space ++ to_fmt "←" ++ space ++ to_fmt b
private meta def to_format (m : hash_map α β) : format :=
group $ to_fmt "⟨" ++
nest 1 (fst (fold m (to_fmt "", tt) (λ p a b, (fst p ++ format_key_data a b (snd p), ff)))) ++
to_fmt "⟩"
meta instance : has_to_format (hash_map α β) :=
⟨to_format⟩
end format
/-- `hash_map` with key type `nat` and value type that may vary. -/
instance {β : ℕ → Type*} : inhabited (hash_map ℕ β) := ⟨mk_hash_map id⟩
end hash_map
|
7dce8813915851fdbede709c2cf4fd20b2ced46c | f313d4982feee650661f61ed73f0cb6635326350 | /Mathlib/Tactic/OpenPrivate.lean | feb5785b64a17c4a03b2e4af70b55a3dfd6d0b34 | [
"Apache-2.0"
] | permissive | shingtaklam1324/mathlib4 | 38c6e172eec1385944db5a70a3b5545c924980ee | 50610c343b7065e8eec056d641f859ceed608e69 | refs/heads/master | 1,683,032,333,313 | 1,621,942,699,000 | 1,621,942,699,000 | 371,130,608 | 0 | 0 | Apache-2.0 | 1,622,053,166,000 | 1,622,053,166,000 | null | UTF-8 | Lean | false | false | 4,740 | lean | /-
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
-/
import Lean.Elab.Command
import Lean.Util.FoldConsts
open Lean Parser.Tactic Elab Command
namespace Lean
def Meta.collectPrivateIn [Monad m] [MonadEnv m] [MonadError m]
(n : Name) (set := NameSet.empty) : m NameSet := do
let c ← getConstInfo n
pure $ Expr.foldConsts c.value! set fun c a =>
if isPrivateName c then a.insert c else a
def Environment.moduleIdxForModule? (env : Environment) (mod : Name) : Option ModuleIdx :=
(env.allImportedModuleNames.indexOf? mod).map fun idx => idx.val
instance : DecidableEq ModuleIdx := instDecidableEqNat
def Environment.declsInModuleIdx (env : Environment) (idx : ModuleIdx) : List Name :=
env.const2ModIdx.fold (fun acc n i => if i = idx then n :: acc else acc) []
namespace Elab.Command
def elabOpenPrivateLike (ids : Array Syntax) (tgts mods : Option (Array Syntax))
(f : (priv full user : Name) → CommandElabM Name) : CommandElabM Unit := do
let mut names := NameSet.empty
for tgt in tgts.getD #[] do
let n ← resolveGlobalConstNoOverload tgt.getId
names ← Meta.collectPrivateIn n names
for mod in mods.getD #[] do
let some modIdx ← (← getEnv).moduleIdxForModule? mod.getId
| throwError "unknown module {mod}"
for declName in (← getEnv).declsInModuleIdx modIdx do
if isPrivateName declName then
names := names.insert declName
let appendNames (msg : String) : String := do
let mut msg := msg
for c in names do
if let some name := privateToUserName? c then
msg := msg ++ s!"{name}\n"
msg
if ids.isEmpty && !names.isEmpty then
logInfo (appendNames "found private declarations:\n")
let mut decls := #[]
for n in ids do
let n := n.getId
let mut found := []
for c in names do
if n.isSuffixOf c then
found := c::found
match found with
| [] => throwError (appendNames s!"'{n}' not found in the provided declarations:\n")
| [c] =>
if let some name := privateToUserName? c then
let new ← f c name n
decls := decls.push (OpenDecl.explicit n new)
else unreachable!
| _ => throwError s!"provided name is ambiguous: found {found.map privateToUserName?}"
modifyScope fun scope => do
let mut openDecls := scope.openDecls
for decl in decls do
openDecls := decl::openDecls
{ scope with openDecls := openDecls }
syntax (name := openPrivate) "open private" ident* ("in" ident*)? ("from" ident*)? : command
/--
The command `open private a b c in foo bar` will look for private definitions named `a`, `b`, `c`
in declarations `foo` and `bar` and open them in the current scope. This does not make the
definitions public, but rather makes them accessible in the current section by the short name `a`
instead of the (unnameable) internal name for the private declaration, something like
`_private.Other.Module.0.Other.Namespace.foo.a`, which cannot be typed directly because of the `0`
name component.
It is also possible to specify the module instead with
`open private a b c from Other.Module`.
-/
@[commandElab openPrivate] def elabOpenPrivate : CommandElab
| `(open private $ids* $[in $tgts*]? $[from $mods*]?) =>
elabOpenPrivateLike ids tgts mods fun c _ _ => c
| _ => throwUnsupportedSyntax
syntax (name := exportPrivate) "export private" ident* ("in" ident*)? ("from" ident*)? : command
/--
The command `export private a b c in foo bar` is similar to `open private`, but instead of opening
them in the current scope it will create public aliases to the private definition. The definition
will exist at exactly the original location and name, as if the `private` keyword was not used
originally.
It will also open the newly created alias definition under the provided short name, like
`open private`.
It is also possible to specify the module instead with
`export private a b c from Other.Module`.
-/
@[commandElab exportPrivate] def elabExportPrivate : CommandElab
| `(export private $ids* $[in $tgts*]? $[from $mods*]?) =>
elabOpenPrivateLike ids tgts mods fun c name _ => do
let cinfo ← getConstInfo c
if (← getEnv).contains name then
throwError s!"'{name}' has already been declared"
let decl := Declaration.defnDecl {
name := name,
levelParams := cinfo.levelParams,
type := cinfo.type,
value := mkConst c (cinfo.levelParams.map mkLevelParam),
hints := ReducibilityHints.abbrev,
safety := if cinfo.isUnsafe then DefinitionSafety.unsafe else DefinitionSafety.safe
}
addDecl decl
compileDecl decl
name
| _ => throwUnsupportedSyntax
end Elab.Command
end Lean
|
77e0e948f8e258e9c239a7767d49f8b7943116ed | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/data/int/parity.lean | a012ad282e206aa5bff477d4e236b2821ce1fa50 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 7,510 | lean | /-
Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Benjamin Davidson
-/
import data.nat.parity
/-!
# Parity of integers
This file contains theorems about the `even` and `odd` predicates on the integers.
## Tags
even, odd
-/
namespace int
variables {m n : ℤ}
@[simp] theorem mod_two_ne_one : ¬ n % 2 = 1 ↔ n % 2 = 0 :=
by cases mod_two_eq_zero_or_one n with h h; simp [h]
local attribute [simp] -- euclidean_domain.mod_eq_zero uses (2 ∣ n) as normal form
theorem mod_two_ne_zero : ¬ n % 2 = 0 ↔ n % 2 = 1 :=
by cases mod_two_eq_zero_or_one n with h h; simp [h]
theorem even_iff : even n ↔ n % 2 = 0 :=
⟨λ ⟨m, hm⟩, by simp [← two_mul, hm], λ h, ⟨n / 2, (mod_add_div n 2).symm.trans
(by simp [← two_mul, h])⟩⟩
theorem odd_iff : odd n ↔ n % 2 = 1 :=
⟨λ ⟨m, hm⟩, by { rw [hm, add_mod], norm_num },
λ h, ⟨n / 2, (mod_add_div n 2).symm.trans (by { rw h, abel })⟩⟩
lemma not_even_iff : ¬ even n ↔ n % 2 = 1 :=
by rw [even_iff, mod_two_ne_zero]
lemma not_odd_iff : ¬ odd n ↔ n % 2 = 0 :=
by rw [odd_iff, mod_two_ne_one]
lemma even_iff_not_odd : even n ↔ ¬ odd n :=
by rw [not_odd_iff, even_iff]
@[simp] lemma odd_iff_not_even : odd n ↔ ¬ even n :=
by rw [not_even_iff, odd_iff]
lemma is_compl_even_odd : is_compl {n : ℤ | even n} {n | odd n} :=
by simp [← set.compl_set_of, is_compl_compl]
lemma even_or_odd (n : ℤ) : even n ∨ odd n :=
or.imp_right odd_iff_not_even.2 $ em $ even n
lemma even_or_odd' (n : ℤ) : ∃ k, n = 2 * k ∨ n = 2 * k + 1 :=
by simpa only [← two_mul, exists_or_distrib, ← odd, ← even] using even_or_odd n
lemma even_xor_odd (n : ℤ) : xor (even n) (odd n) :=
begin
cases even_or_odd n with h,
{ exact or.inl ⟨h, even_iff_not_odd.mp h⟩ },
{ exact or.inr ⟨h, odd_iff_not_even.mp h⟩ },
end
lemma even_xor_odd' (n : ℤ) : ∃ k, xor (n = 2 * k) (n = 2 * k + 1) :=
begin
rcases even_or_odd n with ⟨k, rfl⟩ | ⟨k, rfl⟩;
use k,
{ simpa only [← two_mul, xor, true_and, eq_self_iff_true, not_true, or_false, and_false]
using (succ_ne_self (2*k)).symm },
{ simp only [xor, add_right_eq_self, false_or, eq_self_iff_true, not_true, not_false_iff,
one_ne_zero, and_self] },
end
@[simp] theorem two_dvd_ne_zero : ¬ 2 ∣ n ↔ n % 2 = 1 :=
even_iff_two_dvd.symm.not.trans not_even_iff
instance : decidable_pred (even : ℤ → Prop) := λ n, decidable_of_iff _ even_iff.symm
instance : decidable_pred (odd : ℤ → Prop) := λ n, decidable_of_iff _ odd_iff_not_even.symm
@[simp] theorem not_even_one : ¬ even (1 : ℤ) :=
by rw even_iff; norm_num
@[parity_simps] theorem even_add : even (m + n) ↔ (even m ↔ even n) :=
by cases mod_two_eq_zero_or_one m with h₁ h₁;
cases mod_two_eq_zero_or_one n with h₂ h₂;
simp [even_iff, h₁, h₂, int.add_mod];
norm_num
theorem even_add' : even (m + n) ↔ (odd m ↔ odd n) :=
by rw [even_add, even_iff_not_odd, even_iff_not_odd, not_iff_not]
@[simp] theorem not_even_bit1 (n : ℤ) : ¬ even (bit1 n) :=
by simp [bit1] with parity_simps
lemma two_not_dvd_two_mul_add_one (n : ℤ) : ¬(2 ∣ 2 * n + 1) :=
by { simp [add_mod], refl }
@[parity_simps] theorem even_sub : even (m - n) ↔ (even m ↔ even n) :=
by simp [sub_eq_add_neg] with parity_simps
theorem even_sub' : even (m - n) ↔ (odd m ↔ odd n) :=
by rw [even_sub, even_iff_not_odd, even_iff_not_odd, not_iff_not]
@[parity_simps] theorem even_add_one : even (n + 1) ↔ ¬ even n :=
by simp [even_add]
@[parity_simps] theorem even_mul : even (m * n) ↔ even m ∨ even n :=
by cases mod_two_eq_zero_or_one m with h₁ h₁;
cases mod_two_eq_zero_or_one n with h₂ h₂;
simp [even_iff, h₁, h₂, int.mul_mod];
norm_num
theorem odd_mul : odd (m * n) ↔ odd m ∧ odd n :=
by simp [not_or_distrib] with parity_simps
theorem odd.of_mul_left (h : odd (m * n)) : odd m :=
(odd_mul.mp h).1
theorem odd.of_mul_right (h : odd (m * n)) : odd n :=
(odd_mul.mp h).2
@[parity_simps] theorem even_pow {n : ℕ} : even (m ^ n) ↔ even m ∧ n ≠ 0 :=
by { induction n with n ih; simp [*, even_mul, pow_succ], tauto }
theorem even_pow' {n : ℕ} (h : n ≠ 0) : even (m ^ n) ↔ even m :=
even_pow.trans $ and_iff_left h
@[parity_simps] theorem odd_add : odd (m + n) ↔ (odd m ↔ even n) :=
by rw [odd_iff_not_even, even_add, not_iff, odd_iff_not_even]
theorem odd_add' : odd (m + n) ↔ (odd n ↔ even m) :=
by rw [add_comm, odd_add]
lemma ne_of_odd_add (h : odd (m + n)) : m ≠ n :=
λ hnot, by simpa [hnot] with parity_simps using h
@[parity_simps] theorem odd_sub : odd (m - n) ↔ (odd m ↔ even n) :=
by rw [odd_iff_not_even, even_sub, not_iff, odd_iff_not_even]
theorem odd_sub' : odd (m - n) ↔ (odd n ↔ even m) :=
by rw [odd_iff_not_even, even_sub, not_iff, not_iff_comm, odd_iff_not_even]
lemma even_mul_succ_self (n : ℤ) : even (n * (n + 1)) :=
begin
rw even_mul,
convert n.even_or_odd,
simp with parity_simps
end
@[simp, norm_cast] theorem even_coe_nat (n : ℕ) : even (n : ℤ) ↔ even n :=
by rw_mod_cast [even_iff, nat.even_iff]
@[simp, norm_cast] theorem odd_coe_nat (n : ℕ) : odd (n : ℤ) ↔ odd n :=
by rw [odd_iff_not_even, nat.odd_iff_not_even, even_coe_nat]
@[simp] theorem nat_abs_even : even n.nat_abs ↔ even n :=
by simp [even_iff_two_dvd, dvd_nat_abs, coe_nat_dvd_left.symm]
@[simp] theorem nat_abs_odd : odd n.nat_abs ↔ odd n :=
by rw [odd_iff_not_even, nat.odd_iff_not_even, nat_abs_even]
alias nat_abs_even ↔ _ _root_.even.nat_abs
alias nat_abs_odd ↔ _ _root_.odd.nat_abs
attribute [protected] even.nat_abs odd.nat_abs
lemma four_dvd_add_or_sub_of_odd {a b : ℤ} (ha : odd a) (hb : odd b) : 4 ∣ a + b ∨ 4 ∣ a - b :=
begin
obtain ⟨m, rfl⟩ := ha,
obtain ⟨n, rfl⟩ := hb,
obtain h|h := int.even_or_odd (m + n),
{ right,
rw [int.even_add, ←int.even_sub] at h,
obtain ⟨k, hk⟩ := h,
convert dvd_mul_right 4 k,
rw [eq_add_of_sub_eq hk, mul_add, add_assoc, add_sub_cancel, ← two_mul, ←mul_assoc],
refl },
{ left,
obtain ⟨k, hk⟩ := h,
convert dvd_mul_right 4 (k + 1),
rw [eq_sub_of_add_eq hk, add_right_comm, ←add_sub, mul_add, mul_sub, add_assoc, add_assoc,
sub_add, add_assoc, ←sub_sub (2 * n), sub_self, zero_sub, sub_neg_eq_add, ←mul_assoc,
mul_add],
refl },
end
lemma two_mul_div_two_of_even : even n → 2 * (n / 2) = n :=
λ h, int.mul_div_cancel' (even_iff_two_dvd.mp h)
lemma div_two_mul_two_of_even : even n → n / 2 * 2 = n := --int.div_mul_cancel
λ h, int.div_mul_cancel (even_iff_two_dvd.mp h)
lemma two_mul_div_two_add_one_of_odd : odd n → 2 * (n / 2) + 1 = n :=
by { rintro ⟨c, rfl⟩, rw mul_comm, convert int.div_add_mod' _ _, simpa [int.add_mod] }
lemma div_two_mul_two_add_one_of_odd : odd n → n / 2 * 2 + 1 = n :=
by { rintro ⟨c, rfl⟩, convert int.div_add_mod' _ _, simpa [int.add_mod] }
lemma add_one_div_two_mul_two_of_odd : odd n → 1 + n / 2 * 2 = n :=
by { rintro ⟨c, rfl⟩, rw add_comm, convert int.div_add_mod' _ _, simpa [int.add_mod] }
lemma two_mul_div_two_of_odd (h : odd n) : 2 * (n / 2) = n - 1 :=
eq_sub_of_add_eq (two_mul_div_two_add_one_of_odd h)
-- Here are examples of how `parity_simps` can be used with `int`.
example (m n : ℤ) (h : even m) : ¬ even (n + 3) ↔ even (m^2 + m + n) :=
by simp [*, (dec_trivial : ¬ 2 = 0)] with parity_simps
example : ¬ even (25394535 : ℤ) :=
by simp
end int
|
65d506ed9336652de70f7a073e57c59a13c81d55 | 80cc5bf14c8ea85ff340d1d747a127dcadeb966f | /src/linear_algebra/affine_space/finite_dimensional.lean | a499a38b27d1116f14159685a8e3a43a7c35fe01 | [
"Apache-2.0"
] | permissive | lacker/mathlib | f2439c743c4f8eb413ec589430c82d0f73b2d539 | ddf7563ac69d42cfa4a1bfe41db1fed521bd795f | refs/heads/master | 1,671,948,326,773 | 1,601,479,268,000 | 1,601,479,268,000 | 298,686,743 | 0 | 0 | Apache-2.0 | 1,601,070,794,000 | 1,601,070,794,000 | null | UTF-8 | Lean | false | false | 8,393 | lean | /-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Joseph Myers.
-/
import linear_algebra.affine_space.independent
import linear_algebra.finite_dimensional
noncomputable theory
open_locale big_operators
open_locale classical
/-!
# Finite-dimensional subspaces of affine spaces.
This file provides a few results relating to finite-dimensional
subspaces of affine spaces.
-/
section affine_space'
variables (k : Type*) {V : Type*} {P : Type*} [field k] [add_comm_group V] [module k V]
[affine_space V P]
variables {ι : Type*}
include V
open affine_subspace finite_dimensional
/-- The `vector_span` of a finite set is finite-dimensional. -/
lemma finite_dimensional_vector_span_of_finite {s : set P} (h : set.finite s) :
finite_dimensional k (vector_span k s) :=
span_of_finite k $ vsub_set_finite_of_finite h
/-- The `vector_span` of a family indexed by a `fintype` is
finite-dimensional. -/
instance finite_dimensional_vector_span_of_fintype [fintype ι] (p : ι → P) :
finite_dimensional k (vector_span k (set.range p)) :=
finite_dimensional_vector_span_of_finite k (set.finite_range _)
/-- The `vector_span` of a subset of a family indexed by a `fintype`
is finite-dimensional. -/
instance finite_dimensional_vector_span_image_of_fintype [fintype ι] (p : ι → P)
(s : set ι) : finite_dimensional k (vector_span k (p '' s)) :=
finite_dimensional_vector_span_of_finite k ((set.finite.of_fintype _).image _)
/-- The direction of the affine span of a finite set is
finite-dimensional. -/
lemma finite_dimensional_direction_affine_span_of_finite {s : set P} (h : set.finite s) :
finite_dimensional k (affine_span k s).direction :=
(direction_affine_span k s).symm ▸ finite_dimensional_vector_span_of_finite k h
/-- The direction of the affine span of a family indexed by a
`fintype` is finite-dimensional. -/
instance finite_dimensional_direction_affine_span_of_fintype [fintype ι] (p : ι → P) :
finite_dimensional k (affine_span k (set.range p)).direction :=
finite_dimensional_direction_affine_span_of_finite k (set.finite_range _)
/-- The direction of the affine span of a subset of a family indexed
by a `fintype` is finite-dimensional. -/
instance finite_dimensional_direction_affine_span_image_of_fintype [fintype ι] (p : ι → P)
(s : set ι) : finite_dimensional k (affine_span k (p '' s)).direction :=
finite_dimensional_direction_affine_span_of_finite k ((set.finite.of_fintype _).image _)
variables {k}
/-- The `vector_span` of a finite subset of an affinely independent
family has dimension one less than its cardinality. -/
lemma findim_vector_span_image_finset_of_affine_independent {p : ι → P}
(hi : affine_independent k p) {s : finset ι} {n : ℕ} (hc : finset.card s = n + 1) :
findim k (vector_span k (p '' ↑s)) = n :=
begin
have hi' := affine_independent_of_subset_affine_independent
(affine_independent_set_of_affine_independent hi) (set.image_subset_range p ↑s),
have hc' : fintype.card (p '' ↑s) = n + 1,
{ rwa [set.card_image_of_injective ↑s (injective_of_affine_independent hi), fintype.card_coe] },
have hn : (p '' ↑s).nonempty,
{ simp [hc, ←finset.card_pos] },
rcases hn with ⟨p₁, hp₁⟩,
rw affine_independent_set_iff_linear_independent_vsub k hp₁ at hi',
have hfr : (p '' ↑s \ {p₁}).finite := ((set.finite_mem_finset _).image _).subset
(set.diff_subset _ _),
haveI := hfr.fintype,
have hf : set.finite ((λ (p : P), p -ᵥ p₁) '' (p '' ↑s \ {p₁})) := hfr.image _,
haveI := hf.fintype,
have hc : hf.to_finset.card = n,
{ rw [hf.card_to_finset,
set.card_image_of_injective (p '' ↑s \ {p₁}) (vsub_left_injective _)],
have hd : insert p₁ (p '' ↑s \ {p₁}) = p '' ↑s,
{ rw [set.insert_diff_singleton, set.insert_eq_of_mem hp₁] },
have hc'' : fintype.card ↥(insert p₁ (p '' ↑s \ {p₁})) = n + 1,
{ convert hc' },
rw set.card_insert (p '' ↑s \ {p₁}) (λ h, ((set.mem_diff p₁).2 h).2 rfl) at hc'',
simpa using hc'' },
rw [vector_span_eq_span_vsub_set_right_ne k hp₁, findim_span_set_eq_card _ hi', ←hc],
congr
end
/-- The `vector_span` of a finite affinely independent family has
dimension one less than its cardinality. -/
lemma findim_vector_span_of_affine_independent [fintype ι] {p : ι → P}
(hi : affine_independent k p) {n : ℕ} (hc : fintype.card ι = n + 1) :
findim k (vector_span k (set.range p)) = n :=
begin
rw ←finset.card_univ at hc,
rw [←set.image_univ, ←finset.coe_univ],
exact findim_vector_span_image_finset_of_affine_independent hi hc
end
/-- If the `vector_span` of a finite subset of an affinely independent
family lies in a submodule with dimension one less than its
cardinality, it equals that submodule. -/
lemma vector_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_findim_add_one
{p : ι → P} (hi : affine_independent k p) {s : finset ι} {sm : submodule k V}
[finite_dimensional k sm] (hle : vector_span k (p '' ↑s) ≤ sm)
(hc : finset.card s = findim k sm + 1) : vector_span k (p '' ↑s) = sm :=
eq_of_le_of_findim_eq hle $ findim_vector_span_image_finset_of_affine_independent hi hc
/-- If the `vector_span` of a finite affinely independent
family lies in a submodule with dimension one less than its
cardinality, it equals that submodule. -/
lemma vector_span_eq_of_le_of_affine_independent_of_card_eq_findim_add_one [fintype ι]
{p : ι → P} (hi : affine_independent k p) {sm : submodule k V} [finite_dimensional k sm]
(hle : vector_span k (set.range p) ≤ sm) (hc : fintype.card ι = findim k sm + 1) :
vector_span k (set.range p) = sm :=
eq_of_le_of_findim_eq hle $ findim_vector_span_of_affine_independent hi hc
/-- If the `affine_span` of a finite subset of an affinely independent
family lies in an affine subspace whose direction has dimension one
less than its cardinality, it equals that subspace. -/
lemma affine_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_findim_add_one
{p : ι → P} (hi : affine_independent k p) {s : finset ι} {sp : affine_subspace k P}
[finite_dimensional k sp.direction] (hle : affine_span k (p '' ↑s) ≤ sp)
(hc : finset.card s = findim k sp.direction + 1) : affine_span k (p '' ↑s) = sp :=
begin
have hn : (p '' ↑s).nonempty, { simp [hc, ←finset.card_pos] },
refine eq_of_direction_eq_of_nonempty_of_le _ ((affine_span_nonempty k _).2 hn) hle,
have hd := direction_le hle,
rw direction_affine_span at ⊢ hd,
exact vector_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_findim_add_one hi hd hc
end
/-- If the `affine_span` of a finite affinely independent family lies
in an affine subspace whose direction has dimension one less than its
cardinality, it equals that subspace. -/
lemma affine_span_eq_of_le_of_affine_independent_of_card_eq_findim_add_one [fintype ι]
{p : ι → P} (hi : affine_independent k p) {sp : affine_subspace k P}
[finite_dimensional k sp.direction] (hle : affine_span k (set.range p) ≤ sp)
(hc : fintype.card ι = findim k sp.direction + 1) : affine_span k (set.range p) = sp :=
begin
rw ←finset.card_univ at hc,
rw [←set.image_univ, ←finset.coe_univ] at ⊢ hle,
exact affine_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_findim_add_one hi hle hc
end
/-- The `vector_span` of a finite affinely independent family whose
cardinality is one more than that of the finite-dimensional space is
`⊤`. -/
lemma vector_span_eq_top_of_affine_independent_of_card_eq_findim_add_one [finite_dimensional k V]
[fintype ι] {p : ι → P} (hi : affine_independent k p) (hc : fintype.card ι = findim k V + 1) :
vector_span k (set.range p) = ⊤ :=
eq_top_of_findim_eq $ findim_vector_span_of_affine_independent hi hc
/-- The `affine_span` of a finite affinely independent family whose
cardinality is one more than that of the finite-dimensional space is
`⊤`. -/
lemma affine_span_eq_top_of_affine_independent_of_card_eq_findim_add_one [finite_dimensional k V]
[fintype ι] {p : ι → P} (hi : affine_independent k p) (hc : fintype.card ι = findim k V + 1) :
affine_span k (set.range p) = ⊤ :=
begin
rw [←findim_top, ←direction_top k V P] at hc,
exact affine_span_eq_of_le_of_affine_independent_of_card_eq_findim_add_one hi le_top hc
end
end affine_space'
|
067da1bc59ba044fc614cf7ffb7a5586ff1b739a | 130c49f47783503e462c16b2eff31933442be6ff | /stage0/src/Lean/Server/FileWorker.lean | a4037fb021b3bdf45ef614463612693f27733e45 | [
"Apache-2.0"
] | permissive | Hazel-Brown/lean4 | 8aa5860e282435ffc30dcdfccd34006c59d1d39c | 79e6732fc6bbf5af831b76f310f9c488d44e7a16 | refs/heads/master | 1,689,218,208,951 | 1,629,736,869,000 | 1,629,736,896,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 19,550 | lean | /-
Copyright (c) 2020 Marc Huisinga. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Marc Huisinga, Wojciech Nawrocki
-/
import Init.System.IO
import Std.Data.RBMap
import Lean.Environment
import Lean.Data.Lsp
import Lean.Data.Json.FromToJson
import Lean.Server.Utils
import Lean.Server.Snapshots
import Lean.Server.AsyncList
import Lean.Server.FileWorker.Utils
import Lean.Server.FileWorker.RequestHandling
/-!
For general server architecture, see `README.md`. For details of IPC communication, see `Watchdog.lean`.
This module implements per-file worker processes.
File processing and requests+notifications against a file should be concurrent for two reasons:
- By the LSP standard, requests should be cancellable.
- Since Lean allows arbitrary user code to be executed during elaboration via the tactic framework,
elaboration can be extremely slow and even not halt in some cases. Users should be able to
work with the file while this is happening, e.g. make new changes to the file or send requests.
To achieve these goals, elaboration is executed in a chain of tasks, where each task corresponds to
the elaboration of one command. When the elaboration of one command is done, the next task is spawned.
On didChange notifications, we search for the task in which the change occured. If we stumble across
a task that has not yet finished before finding the task we're looking for, we terminate it
and start the elaboration there, otherwise we start the elaboration at the task where the change occured.
Requests iterate over tasks until they find the command that they need to answer the request.
In order to not block the main thread, this is done in a request task.
If a task that the request task waits for is terminated, a change occured somewhere before the
command that the request is looking for and the request sends a "content changed" error.
-/
namespace Lean.Server.FileWorker
open Lsp
open IO
open Snapshots
open Std (RBMap RBMap.empty)
open JsonRpc
/- Asynchronous snapshot elaboration. -/
section Elab
/-- Elaborates the next command after `parentSnap` and emits diagnostics into `hOut`. -/
private def nextCmdSnap (m : DocumentMeta) (parentSnap : Snapshot) (cancelTk : CancelToken) (hOut : FS.Stream)
: ExceptT ElabTaskError IO Snapshot := do
cancelTk.check
publishProgressAtPos m parentSnap.endPos hOut
let maybeSnap ← compileNextCmd m.text.source parentSnap
-- TODO(MH): check for interrupt with increased precision
cancelTk.check
match maybeSnap with
| Sum.inl snap =>
/- NOTE(MH): This relies on the client discarding old diagnostics upon receiving new ones
while prefering newer versions over old ones. The former is necessary because we do
not explicitly clear older diagnostics, while the latter is necessary because we do
not guarantee that diagnostics are emitted in order. Specifically, it may happen that
we interrupted this elaboration task right at this point and a newer elaboration task
emits diagnostics, after which we emit old diagnostics because we did not yet detect
the interrupt. Explicitly clearing diagnostics is difficult for a similar reason,
because we cannot guarantee that no further diagnostics are emitted after clearing
them. -/
if snap.msgLog.msgs.size > parentSnap.msgLog.msgs.size then
publishMessages m snap.msgLog hOut
snap
| Sum.inr msgLog =>
publishMessages m msgLog hOut
publishProgressDone m hOut
throw ElabTaskError.eof
/-- Elaborates all commands after `initSnap`, emitting the diagnostics into `hOut`. -/
def unfoldCmdSnaps (m : DocumentMeta) (initSnap : Snapshot) (cancelTk : CancelToken) (hOut : FS.Stream)
(initial : Bool) :
IO (AsyncList ElabTaskError Snapshot) := do
if initial && initSnap.msgLog.hasErrors then
-- treat header processing errors as fatal so users aren't swamped with followup errors
AsyncList.nil
else
AsyncList.unfoldAsync (nextCmdSnap m . cancelTk hOut) initSnap
end Elab
-- Pending requests are tracked so they can be cancelled
abbrev PendingRequestMap := RBMap RequestID (Task (Except IO.Error Unit)) compare
structure WorkerContext where
hIn : FS.Stream
hOut : FS.Stream
hLog : FS.Stream
srcSearchPath : SearchPath
structure WorkerState where
doc : EditableDocument
pendingRequests : PendingRequestMap
rpcSesh : RpcSession
abbrev WorkerM := ReaderT WorkerContext <| StateRefT WorkerState IO
/- Worker initialization sequence. -/
section Initialization
/-- Use `leanpkg print-paths` to compile dependencies on the fly and add them to `LEAN_PATH`.
Compilation progress is reported to `hOut` via LSP notifications. Return the search path for
source files. -/
partial def leanpkgSetupSearchPath (leanpkgPath : System.FilePath) (m : DocumentMeta) (imports : Array Import) (hOut : FS.Stream) : IO SearchPath := do
let leanpkgProc ← Process.spawn {
stdin := Process.Stdio.null
stdout := Process.Stdio.piped
stderr := Process.Stdio.piped
cmd := leanpkgPath.toString
args := #["print-paths"] ++ imports.map (toString ·.module)
}
-- progress notification: report latest stderr line
let rec processStderr (acc : String) : IO String := do
let line ← leanpkgProc.stderr.getLine
if line == "" then
return acc
else
publishDiagnostics m #[{ range := ⟨⟨0, 0⟩, ⟨0, 0⟩⟩, severity? := DiagnosticSeverity.information, message := line }] hOut
processStderr (acc ++ line)
let stderr ← IO.asTask (processStderr "") Task.Priority.dedicated
let stdout := String.trim (← leanpkgProc.stdout.readToEnd)
let stderr ← IO.ofExcept stderr.get
if (← leanpkgProc.wait) == 0 then
let leanpkgLines := stdout.split (· == '\n')
-- ignore any output up to the last two lines
-- TODO: leanpkg should instead redirect nested stdout output to stderr
let leanpkgLines := leanpkgLines.drop (leanpkgLines.length - 2)
match leanpkgLines with
| [""] => pure [] -- e.g. no leanpkg.toml
| [leanPath, leanSrcPath] => let sp ← getBuiltinSearchPath
let sp ← addSearchPathFromEnv sp
let sp := System.SearchPath.parse leanPath ++ sp
searchPathRef.set sp
let srcPath := System.SearchPath.parse leanSrcPath
srcPath.mapM realPathNormalized
| _ => throwServerError s!"unexpected output from `leanpkg print-paths`:\n{stdout}\nstderr:\n{stderr}"
else
throwServerError s!"`leanpkg print-paths` failed:\n{stdout}\nstderr:\n{stderr}"
def compileHeader (m : DocumentMeta) (hOut : FS.Stream) : IO (Snapshot × SearchPath) := do
let opts := {} -- TODO
let inputCtx := Parser.mkInputContext m.text.source "<input>"
let (headerStx, headerParserState, msgLog) ← Parser.parseHeader inputCtx
let leanpkgPath ← match (← IO.getEnv "LEAN_SYSROOT") with
| some path => pure <| System.FilePath.mk path / "bin" / "leanpkg"
| _ => pure <| (← appDir) / "leanpkg"
let leanpkgPath := leanpkgPath.withExtension System.FilePath.exeExtension
let mut srcSearchPath := [(← appDir) / ".." / "lib" / "lean" / "src"]
if let some p := (← IO.getEnv "LEAN_SRC_PATH") then
srcSearchPath := srcSearchPath ++ System.SearchPath.parse p
let (headerEnv, msgLog) ← try
-- NOTE: leanpkg does not exist in stage 0 (yet?)
if (← System.FilePath.pathExists leanpkgPath) then
let pkgSearchPath ← leanpkgSetupSearchPath leanpkgPath m (Lean.Elab.headerToImports headerStx).toArray hOut
srcSearchPath := srcSearchPath ++ pkgSearchPath
Elab.processHeader headerStx opts msgLog inputCtx
catch e => -- should be from `leanpkg print-paths`
let msgs := MessageLog.empty.add { fileName := "<ignored>", pos := ⟨0, 0⟩, data := e.toString }
pure (← mkEmptyEnvironment, msgs)
publishMessages m msgLog hOut
let cmdState := Elab.Command.mkState headerEnv msgLog opts
let cmdState := { cmdState with infoState.enabled := true, scopes := [{ header := "", opts := opts }] }
let headerSnap := {
beginPos := 0
stx := headerStx
mpState := headerParserState
cmdState := cmdState
}
return (headerSnap, srcSearchPath)
def initializeWorker (meta : DocumentMeta) (i o e : FS.Stream)
: IO (WorkerContext × WorkerState) := do
/- NOTE(WN): `toFileMap` marks line beginnings as immediately following
"\n", which should be enough to handle both LF and CRLF correctly.
This is because LSP always refers to characters by (line, column),
so if we get the line number correct it shouldn't matter that there
is a CR there. -/
let (headerSnap, srcSearchPath) ← compileHeader meta o
let cancelTk ← CancelToken.new
let cmdSnaps ← unfoldCmdSnaps meta headerSnap cancelTk o (initial := true)
let doc : EditableDocument := ⟨meta, headerSnap, cmdSnaps, cancelTk⟩
return ({
hIn := i
hOut := o
hLog := e
srcSearchPath := srcSearchPath
},
{
doc := doc
pendingRequests := RBMap.empty
rpcSesh := ← RpcSession.new false
})
end Initialization
section Updates
def updatePendingRequests (map : PendingRequestMap → PendingRequestMap) : WorkerM Unit := do
modify fun st => { st with pendingRequests := map st.pendingRequests }
/-- Given the new document and `changePos`, the UTF-8 offset of a change into the pre-change source,
updates editable doc state. -/
def updateDocument (newMeta : DocumentMeta) (changePos : String.Pos) : WorkerM Unit := do
-- The watchdog only restarts the file worker when the syntax tree of the header changes.
-- If e.g. a newline is deleted, it will not restart this file worker, but we still
-- need to reparse the header so that the offsets are correct.
let ctx ← read
let oldDoc := (←get).doc
let newHeaderSnap ← reparseHeader newMeta.text.source oldDoc.headerSnap
if newHeaderSnap.stx != oldDoc.headerSnap.stx then
throwServerError "Internal server error: header changed but worker wasn't restarted."
let ⟨cmdSnaps, e?⟩ ← oldDoc.cmdSnaps.updateFinishedPrefix
match e? with
-- This case should not be possible. only the main task aborts tasks and ensures that aborted tasks
-- do not show up in `snapshots` of an EditableDocument.
| some ElabTaskError.aborted =>
throwServerError "Internal server error: elab task was aborted while still in use."
| some (ElabTaskError.ioError ioError) => throw ioError
| _ => -- No error or EOF
oldDoc.cancelTk.set
-- NOTE(WN): we invalidate eagerly as `endPos` consumes input greedily. To re-elaborate only
-- when really necessary, we could do a whitespace-aware `Syntax` comparison instead.
let mut validSnaps := cmdSnaps.finishedPrefix.takeWhile (fun s => s.endPos < changePos)
if validSnaps.length = 0 then
let cancelTk ← CancelToken.new
let newCmdSnaps ← unfoldCmdSnaps newMeta newHeaderSnap cancelTk ctx.hOut (initial := true)
modify fun st => { st with doc := ⟨newMeta, newHeaderSnap, newCmdSnaps, cancelTk⟩ }
else
/- When at least one valid non-header snap exists, it may happen that a change does not fall
within the syntactic range of that last snap but still modifies it by appending tokens.
We check for this here. We do not currently handle crazy grammars in which an appended
token can merge two or more previous commands into one. To do so would require reparsing
the entire file. -/
let mut lastSnap := validSnaps.getLast!
let preLastSnap :=
if validSnaps.length ≥ 2
then validSnaps.get! (validSnaps.length - 2)
else newHeaderSnap
let newLastStx ← parseNextCmd newMeta.text.source preLastSnap
if newLastStx != lastSnap.stx then
validSnaps ← validSnaps.dropLast
lastSnap ← preLastSnap
let cancelTk ← CancelToken.new
let newSnaps ← unfoldCmdSnaps newMeta lastSnap cancelTk ctx.hOut (initial := false)
let newCmdSnaps := AsyncList.ofList validSnaps ++ newSnaps
modify fun st => { st with doc := ⟨newMeta, newHeaderSnap, newCmdSnaps, cancelTk⟩ }
end Updates
/- Notifications are handled in the main thread. They may change global worker state
such as the current file contents. -/
section NotificationHandling
def handleDidChange (p : DidChangeTextDocumentParams) : WorkerM Unit := do
let docId := p.textDocument
let changes := p.contentChanges
let oldDoc := (←get).doc
let some newVersion ← pure docId.version?
| throwServerError "Expected version number"
if newVersion ≤ oldDoc.meta.version then
-- TODO(WN): This happens on restart sometimes.
IO.eprintln s!"Got outdated version number: {newVersion} ≤ {oldDoc.meta.version}"
else if ¬ changes.isEmpty then
let (newDocText, minStartOff) := foldDocumentChanges changes oldDoc.meta.text
updateDocument ⟨docId.uri, newVersion, newDocText⟩ minStartOff
def handleCancelRequest (p : CancelParams) : WorkerM Unit := do
updatePendingRequests (fun pendingRequests => pendingRequests.erase p.id)
def handleRpcConnect (p : RpcConnectParams) : WorkerM Unit := do
let st ← get
let doc := st.doc
let rpcSesh' ←
if !st.rpcSesh.clientConnected then
-- First client connection.
pure { st.rpcSesh with clientConnected := true }
else
/- Client has restarted. Just setting the state should `dec` the previous session.
Any associated references will then no longer be kept alive for the client. -/
RpcSession.new true
set { st with rpcSesh := rpcSesh' }
(←read).hOut.writeLspNotification
<| { method := "$/lean/rpc/connected"
param := { uri := doc.meta.uri
sessionId := rpcSesh'.sessionId : RpcConnected } }
def handleRpcRelease (p : Lsp.RpcReleaseParams) : WorkerM Unit := do
let st ← get
if p.sessionId ≠ st.rpcSesh.sessionId then
-- TODO(WN): should only print on log-level debug, if we had log-levels
IO.eprintln s!"Trying to release ref '{p.ref}' from outdated RPC session '{p.sessionId}'."
else
discard <| st.rpcSesh.state.modifyGet fun st => st.release p.ref
end NotificationHandling
section MessageHandling
def parseParams (paramType : Type) [FromJson paramType] (params : Json) : WorkerM paramType :=
match fromJson? params with
| Except.ok parsed => pure parsed
| Except.error inner => throwServerError s!"Got param with wrong structure: {params.compress}\n{inner}"
def handleNotification (method : String) (params : Json) : WorkerM Unit := do
let handle := fun paramType [FromJson paramType] (handler : paramType → WorkerM Unit) =>
parseParams paramType params >>= handler
match method with
| "textDocument/didChange" => handle DidChangeTextDocumentParams handleDidChange
| "$/cancelRequest" => handle CancelParams handleCancelRequest
| "$/lean/rpc/connect" => handle RpcConnectParams handleRpcConnect
| "$/lean/rpc/release" => handle RpcReleaseParams handleRpcRelease
| _ => throwServerError s!"Got unsupported notification method: {method}"
def queueRequest (id : RequestID) (requestTask : Task (Except IO.Error Unit))
: WorkerM Unit := do
updatePendingRequests (fun pendingRequests => pendingRequests.insert id requestTask)
def handleRequest (id : RequestID) (method : String) (params : Json)
: WorkerM Unit := do
let ctx ← read
let st ← get
let rc : RequestContext :=
{ rpcSesh := st.rpcSesh
srcSearchPath := ctx.srcSearchPath
doc := st.doc
hLog := ctx.hLog }
let t? ← (ExceptT.run <| handleLspRequest method params rc : IO _)
let t₁ ← match t? with
| Except.error e =>
IO.asTask do
ctx.hOut.writeLspResponseError <| e.toLspResponseError id
| Except.ok t => (IO.mapTask · t) fun
| Except.ok resp =>
ctx.hOut.writeLspResponse ⟨id, resp⟩
| Except.error e =>
ctx.hOut.writeLspResponseError <| e.toLspResponseError id
queueRequest id t₁
end MessageHandling
section MainLoop
partial def mainLoop : WorkerM Unit := do
let ctx ← read
let msg ← ctx.hIn.readLspMessage
let pendingRequests := (←get).pendingRequests
let filterFinishedTasks (acc : PendingRequestMap) (id : RequestID) (task : Task (Except IO.Error Unit))
: WorkerM PendingRequestMap := do
if (←hasFinished task) then
/- Handler tasks are constructed so that the only possible errors here
are failures of writing a response into the stream. -/
if let Except.error e := task.get then
throwServerError s!"Failed responding to request {id}: {e}"
acc.erase id
else acc
let pendingRequests ← pendingRequests.foldM filterFinishedTasks pendingRequests
modify fun st => { st with pendingRequests := pendingRequests }
match msg with
| Message.request id method (some params) =>
handleRequest id method (toJson params)
mainLoop
| Message.notification "exit" none =>
let doc ← (←get).doc
doc.cancelTk.set
return ()
| Message.notification method (some params) =>
handleNotification method (toJson params)
mainLoop
| _ => throwServerError "Got invalid JSON-RPC message"
end MainLoop
def initAndRunWorker (i o e : FS.Stream) : IO UInt32 := do
let i ← maybeTee "fwIn.txt" false i
let o ← maybeTee "fwOut.txt" true o
let _ ← i.readLspRequestAs "initialize" InitializeParams
let ⟨_, param⟩ ← i.readLspNotificationAs "textDocument/didOpen" DidOpenTextDocumentParams
let doc := param.textDocument
let meta : DocumentMeta := ⟨doc.uri, doc.version, doc.text.toFileMap⟩
let e ← e.withPrefix s!"[{param.textDocument.uri}] "
let _ ← IO.setStderr e
try
let (ctx, st) ← initializeWorker meta i o e
let _ ← StateRefT'.run (s := st) <| ReaderT.run (r := ctx) mainLoop
return (0 : UInt32)
catch e =>
IO.eprintln e
publishDiagnostics meta #[{ range := ⟨⟨0, 0⟩, ⟨0, 0⟩⟩, severity? := DiagnosticSeverity.error, message := e.toString }] o
return (1 : UInt32)
@[export lean_server_worker_main]
def workerMain : IO UInt32 := do
let i ← IO.getStdin
let o ← IO.getStdout
let e ← IO.getStderr
try
let seed ← (UInt64.toNat ∘ ByteArray.toUInt64LE!) <$> IO.getRandomBytes 8
IO.setRandSeed seed
let exitCode ← initAndRunWorker i o e
-- HACK: all `Task`s are currently "foreground", i.e. we join on them on main thread exit, but we definitely don't
-- want to do that in the case of the worker processes, which can produce non-terminating tasks evaluating user code
o.flush
e.flush
IO.Process.exit exitCode.toUInt8
catch err =>
e.putStrLn s!"worker initialization error: {err}"
return (1 : UInt32)
end Lean.Server.FileWorker
|
76f06a02374dc70a2306debe7c0d3ddb73b78665 | dd0f5513e11c52db157d2fcc8456d9401a6cd9da | /02_Dependent_Type_Theory.org.23.lean | 33febceb4f8c80fc2df8ff8b34e4208636c6709a | [] | no_license | cjmazey/lean-tutorial | ba559a49f82aa6c5848b9bf17b7389bf7f4ba645 | 381f61c9fcac56d01d959ae0fa6e376f2c4e3b34 | refs/heads/master | 1,610,286,098,832 | 1,447,124,923,000 | 1,447,124,923,000 | 43,082,433 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 246 | lean | /- page 22 -/
import standard
variables (A B C : Type)
definition compose (g : B → C) (f : A → B) (x : A) : C := g (f x)
definition do_twice (h : A → A) (x : A) : A := h (h x)
definition do_thrice (h : A → A) (x : A) : A := h (h (h x))
|
1bf62fded87ef5cf40f73c997832d1e65daaf717 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/combinatorics/simple_graph/density.lean | bf9bf9dfb761b421b337e483a8fb92cfcf1cf5a1 | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 16,280 | lean | /-
Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Bhavik Mehta
-/
import combinatorics.simple_graph.basic
import order.partition.finpartition
import tactic.positivity
/-!
# Edge density
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file defines the number and density of edges of a relation/graph.
## Main declarations
Between two finsets of vertices,
* `rel.interedges`: Finset of edges of a relation.
* `rel.edge_density`: Edge density of a relation.
* `simple_graph.interedges`: Finset of edges of a graph.
* `simple_graph.edge_density`: Edge density of a graph.
-/
open finset
open_locale big_operators
variables {𝕜 ι κ α β : Type*}
/-! ### Density of a relation -/
namespace rel
section asymmetric
variables [linear_ordered_field 𝕜] (r : α → β → Prop) [Π a, decidable_pred (r a)]
{s s₁ s₂ : finset α} {t t₁ t₂ : finset β} {a : α} {b : β} {δ : 𝕜}
/-- Finset of edges of a relation between two finsets of vertices. -/
def interedges (s : finset α) (t : finset β) : finset (α × β) := (s ×ˢ t).filter $ λ e, r e.1 e.2
/-- Edge density of a relation between two finsets of vertices. -/
def edge_density (s : finset α) (t : finset β) : ℚ := (interedges r s t).card / (s.card * t.card)
variables {r}
lemma mem_interedges_iff {x : α × β} : x ∈ interedges r s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ r x.1 x.2 :=
by simp only [interedges, and_assoc, mem_filter, finset.mem_product]
lemma mk_mem_interedges_iff : (a, b) ∈ interedges r s t ↔ a ∈ s ∧ b ∈ t ∧ r a b :=
mem_interedges_iff
@[simp] lemma interedges_empty_left (t : finset β) : interedges r ∅ t = ∅ :=
by rw [interedges, finset.empty_product, filter_empty]
lemma interedges_mono (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) : interedges r s₂ t₂ ⊆ interedges r s₁ t₁ :=
λ x, by { simp_rw mem_interedges_iff, exact λ h, ⟨hs h.1, ht h.2.1, h.2.2⟩ }
variables (r)
lemma card_interedges_add_card_interedges_compl (s : finset α) (t : finset β) :
(interedges r s t).card + (interedges (λ x y, ¬r x y) s t).card = s.card * t.card :=
begin
classical,
rw [←card_product, interedges, interedges, ←card_union_eq, filter_union_filter_neg_eq],
convert disjoint_filter.2 (λ x _, not_not.2),
end
lemma interedges_disjoint_left {s s' : finset α} (hs : disjoint s s') (t : finset β) :
disjoint (interedges r s t) (interedges r s' t) :=
begin
rw finset.disjoint_left at ⊢ hs,
rintro x hx hy,
rw [mem_interedges_iff] at hx hy,
exact hs hx.1 hy.1,
end
lemma interedges_disjoint_right (s : finset α) {t t' : finset β} (ht : disjoint t t') :
disjoint (interedges r s t) (interedges r s t') :=
begin
rw finset.disjoint_left at ⊢ ht,
rintro x hx hy,
rw [mem_interedges_iff] at hx hy,
exact ht hx.2.1 hy.2.1,
end
section decidable_eq
variables [decidable_eq α] [decidable_eq β]
lemma interedges_bUnion_left (s : finset ι) (t : finset β) (f : ι → finset α) :
interedges r (s.bUnion f) t = s.bUnion (λ a, interedges r (f a) t) :=
ext $ λ a, by simp only [mem_bUnion, mem_interedges_iff, exists_and_distrib_right]
lemma interedges_bUnion_right (s : finset α) (t : finset ι) (f : ι → finset β) :
interedges r s (t.bUnion f) = t.bUnion (λ b, interedges r s (f b)) :=
ext $ λ a, by simp only [mem_interedges_iff, mem_bUnion, ←exists_and_distrib_left,
←exists_and_distrib_right]
lemma interedges_bUnion (s : finset ι) (t : finset κ) (f : ι → finset α) (g : κ → finset β) :
interedges r (s.bUnion f) (t.bUnion g) =
(s ×ˢ t).bUnion (λ ab, interedges r (f ab.1) (g ab.2)) :=
by simp_rw [product_bUnion, interedges_bUnion_left, interedges_bUnion_right]
end decidable_eq
lemma card_interedges_le_mul (s : finset α) (t : finset β) :
(interedges r s t).card ≤ s.card * t.card :=
(card_filter_le _ _).trans (card_product _ _).le
lemma edge_density_nonneg (s : finset α) (t : finset β) : 0 ≤ edge_density r s t :=
by { apply div_nonneg; exact_mod_cast nat.zero_le _ }
lemma edge_density_le_one (s : finset α) (t : finset β) : edge_density r s t ≤ 1 :=
div_le_one_of_le (by exact_mod_cast (card_interedges_le_mul _ _ _)) $
by exact_mod_cast (nat.zero_le _)
lemma edge_density_add_edge_density_compl (hs : s.nonempty) (ht : t.nonempty) :
edge_density r s t + edge_density (λ x y, ¬r x y) s t = 1 :=
begin
rw [edge_density, edge_density, div_add_div_same, div_eq_one_iff_eq],
{ exact_mod_cast card_interedges_add_card_interedges_compl r s t },
{ exact_mod_cast (mul_pos hs.card_pos ht.card_pos).ne' }
end
@[simp] lemma edge_density_empty_left (t : finset β) : edge_density r ∅ t = 0 :=
by rw [edge_density, finset.card_empty, nat.cast_zero, zero_mul, div_zero]
@[simp] lemma edge_density_empty_right (s : finset α) : edge_density r s ∅ = 0 :=
by rw [edge_density, finset.card_empty, nat.cast_zero, mul_zero, div_zero]
lemma card_interedges_finpartition_left [decidable_eq α] (P : finpartition s) (t : finset β) :
(interedges r s t).card = ∑ a in P.parts, (interedges r a t).card :=
begin
classical,
simp_rw [←P.bUnion_parts, interedges_bUnion_left, id.def],
rw card_bUnion,
exact λ x hx y hy h, interedges_disjoint_left r (P.disjoint hx hy h) _,
end
lemma card_interedges_finpartition_right [decidable_eq β] (s : finset α) (P : finpartition t) :
(interedges r s t).card = ∑ b in P.parts, (interedges r s b).card :=
begin
classical,
simp_rw [←P.bUnion_parts, interedges_bUnion_right, id],
rw card_bUnion,
exact λ x hx y hy h, interedges_disjoint_right r _ (P.disjoint hx hy h),
end
lemma card_interedges_finpartition [decidable_eq α] [decidable_eq β] (P : finpartition s)
(Q : finpartition t) :
(interedges r s t).card = ∑ ab in P.parts ×ˢ Q.parts, (interedges r ab.1 ab.2).card :=
by simp_rw [card_interedges_finpartition_left _ P, card_interedges_finpartition_right _ _ Q,
sum_product]
lemma mul_edge_density_le_edge_density (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) (hs₂ : s₂.nonempty)
(ht₂ : t₂.nonempty) :
(s₂.card : ℚ)/s₁.card * (t₂.card/t₁.card) * edge_density r s₂ t₂ ≤ edge_density r s₁ t₁ :=
begin
have hst : (s₂.card : ℚ) * t₂.card ≠ 0 := by simp [hs₂.ne_empty, ht₂.ne_empty],
rw [edge_density, edge_density, div_mul_div_comm, mul_comm, div_mul_div_cancel _ hst],
refine div_le_div_of_le (by exact_mod_cast (s₁.card * t₁.card).zero_le) _,
exact_mod_cast card_le_of_subset (interedges_mono hs ht),
end
lemma edge_density_sub_edge_density_le_one_sub_mul (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) (hs₂ : s₂.nonempty)
(ht₂ : t₂.nonempty) :
edge_density r s₂ t₂ - edge_density r s₁ t₁ ≤ 1 - (s₂.card)/s₁.card * (t₂.card/t₁.card) :=
begin
refine (sub_le_sub_left (mul_edge_density_le_edge_density r hs ht hs₂ ht₂) _).trans _,
refine le_trans _ (mul_le_of_le_one_right _ (edge_density_le_one r s₂ t₂)),
{ rw [sub_mul, one_mul] },
refine sub_nonneg_of_le (mul_le_one _ (by positivity) _);
exact div_le_one_of_le (nat.cast_le.2 (card_le_of_subset ‹_›)) (nat.cast_nonneg _),
end
lemma abs_edge_density_sub_edge_density_le_one_sub_mul (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁)
(hs₂ : s₂.nonempty) (ht₂ : t₂.nonempty) :
|edge_density r s₂ t₂ - edge_density r s₁ t₁| ≤ 1 - s₂.card/s₁.card * (t₂.card/t₁.card) :=
begin
have habs : abs (edge_density r s₂ t₂ - edge_density r s₁ t₁) ≤ 1,
{ rw [abs_sub_le_iff, ←sub_zero (1 : ℚ)],
split; exact sub_le_sub (edge_density_le_one r _ _) (edge_density_nonneg r _ _) },
refine abs_sub_le_iff.2 ⟨edge_density_sub_edge_density_le_one_sub_mul r hs ht hs₂ ht₂, _⟩,
rw [←add_sub_cancel (edge_density r s₁ t₁) (edge_density (λ x y, ¬r x y) s₁ t₁),
←add_sub_cancel (edge_density r s₂ t₂) (edge_density (λ x y, ¬r x y) s₂ t₂),
edge_density_add_edge_density_compl _ (hs₂.mono hs) (ht₂.mono ht),
edge_density_add_edge_density_compl _ hs₂ ht₂, sub_sub_sub_cancel_left],
exact edge_density_sub_edge_density_le_one_sub_mul _ hs ht hs₂ ht₂,
end
lemma abs_edge_density_sub_edge_density_le_two_mul_sub_sq (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁)
(hδ₀ : 0 ≤ δ) (hδ₁ : δ < 1) (hs₂ : (1 - δ) * s₁.card ≤ s₂.card)
(ht₂ : (1 - δ) * t₁.card ≤ t₂.card) :
|(edge_density r s₂ t₂ : 𝕜) - edge_density r s₁ t₁| ≤ 2*δ - δ^2 :=
begin
have hδ' : 0 ≤ 2 * δ - δ ^ 2,
{ rw [sub_nonneg, sq],
exact mul_le_mul_of_nonneg_right (hδ₁.le.trans (by norm_num)) hδ₀ },
rw ←sub_pos at hδ₁,
obtain rfl | hs₂' := s₂.eq_empty_or_nonempty,
{ rw [finset.card_empty, nat.cast_zero] at hs₂,
simpa [edge_density, (nonpos_of_mul_nonpos_right hs₂ hδ₁).antisymm (nat.cast_nonneg _)]
using hδ' },
obtain rfl | ht₂' := t₂.eq_empty_or_nonempty,
{ rw [finset.card_empty, nat.cast_zero] at ht₂,
simpa [edge_density, (nonpos_of_mul_nonpos_right ht₂ hδ₁).antisymm (nat.cast_nonneg _)]
using hδ' },
rw [show 2 * δ - δ ^ 2 = 1 - (1 - δ) * (1 - δ), by ring],
norm_cast,
refine (rat.cast_le.2 $
abs_edge_density_sub_edge_density_le_one_sub_mul r hs ht hs₂' ht₂').trans _,
push_cast,
have := hs₂'.mono hs,
have := ht₂'.mono ht,
refine sub_le_sub_left (mul_le_mul ((le_div_iff _).2 hs₂) ((le_div_iff _).2 ht₂) hδ₁.le _) _;
positivity,
end
/-- If `s₂ ⊆ s₁`, `t₂ ⊆ t₁` and they take up all but a `δ`-proportion, then the difference in edge
densities is at most `2 * δ`. -/
lemma abs_edge_density_sub_edge_density_le_two_mul (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) (hδ : 0 ≤ δ)
(hscard : (1 - δ) * s₁.card ≤ s₂.card) (htcard : (1 - δ) * t₁.card ≤ t₂.card) :
|(edge_density r s₂ t₂ : 𝕜) - edge_density r s₁ t₁| ≤ 2 * δ :=
begin
cases lt_or_le δ 1,
{ exact (abs_edge_density_sub_edge_density_le_two_mul_sub_sq r hs ht hδ h hscard htcard).trans
((sub_le_self_iff _).2 $ sq_nonneg δ) },
rw two_mul,
refine (abs_sub _ _).trans (add_le_add (le_trans _ h) (le_trans _ h));
{ rw abs_of_nonneg,
exact_mod_cast edge_density_le_one r _ _,
exact_mod_cast edge_density_nonneg r _ _ }
end
end asymmetric
section symmetric
variables (r : α → α → Prop) [decidable_rel r] {s s₁ s₂ t t₁ t₂ : finset α} {a b : α}
variables {r} (hr : symmetric r)
include hr
@[simp] lemma swap_mem_interedges_iff {x : α × α} :
x.swap ∈ interedges r s t ↔ x ∈ interedges r t s :=
by { rw [mem_interedges_iff, mem_interedges_iff, hr.iff], exact and.left_comm }
lemma mk_mem_interedges_comm : (a, b) ∈ interedges r s t ↔ (b, a) ∈ interedges r t s :=
@swap_mem_interedges_iff _ _ _ _ _ hr (b, a)
lemma card_interedges_comm (s t : finset α) : (interedges r s t).card = (interedges r t s).card :=
finset.card_congr (λ (x : α × α) _, x.swap) (λ x, (swap_mem_interedges_iff hr).2)
(λ _ _ _ _ h, prod.swap_injective h)
(λ x h, ⟨x.swap, (swap_mem_interedges_iff hr).2 h, x.swap_swap⟩)
lemma edge_density_comm (s t : finset α) : edge_density r s t = edge_density r t s :=
by rw [edge_density, mul_comm, card_interedges_comm hr, edge_density]
end symmetric
end rel
open rel
/-! ### Density of a graph -/
namespace simple_graph
variables (G : simple_graph α) [decidable_rel G.adj] {s s₁ s₂ t t₁ t₂ : finset α} {a b : α}
/-- Finset of edges of a relation between two finsets of vertices. -/
def interedges (s t : finset α) : finset (α × α) := interedges G.adj s t
/-- Density of edges of a graph between two finsets of vertices. -/
def edge_density : finset α → finset α → ℚ := edge_density G.adj
lemma interedges_def (s t : finset α) :
G.interedges s t = (s ×ˢ t).filter (λ e, G.adj e.1 e.2) := rfl
lemma edge_density_def (s t : finset α) :
G.edge_density s t = (G.interedges s t).card / (s.card * t.card) := rfl
@[simp] lemma card_interedges_div_card (s t : finset α) :
((G.interedges s t).card : ℚ) / (s.card * t.card) = G.edge_density s t := rfl
lemma mem_interedges_iff {x : α × α} : x ∈ G.interedges s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ G.adj x.1 x.2 :=
mem_interedges_iff
lemma mk_mem_interedges_iff : (a, b) ∈ G.interedges s t ↔ a ∈ s ∧ b ∈ t ∧ G.adj a b :=
mk_mem_interedges_iff
@[simp] lemma interedges_empty_left (t : finset α) : G.interedges ∅ t = ∅ := interedges_empty_left _
lemma interedges_mono : s₂ ⊆ s₁ → t₂ ⊆ t₁ → G.interedges s₂ t₂ ⊆ G.interedges s₁ t₁ :=
interedges_mono
lemma interedges_disjoint_left (hs : disjoint s₁ s₂) (t : finset α) :
disjoint (G.interedges s₁ t) (G.interedges s₂ t) :=
interedges_disjoint_left _ hs _
lemma interedges_disjoint_right (s : finset α) (ht : disjoint t₁ t₂) :
disjoint (G.interedges s t₁) (G.interedges s t₂) :=
interedges_disjoint_right _ _ ht
section decidable_eq
variables [decidable_eq α]
lemma interedges_bUnion_left (s : finset ι) (t : finset α) (f : ι → finset α) :
G.interedges (s.bUnion f) t = s.bUnion (λ a, G.interedges (f a) t) :=
interedges_bUnion_left _ _ _ _
lemma interedges_bUnion_right (s : finset α) (t : finset ι) (f : ι → finset α) :
G.interedges s (t.bUnion f) = t.bUnion (λ b, G.interedges s (f b)) :=
interedges_bUnion_right _ _ _ _
lemma interedges_bUnion (s : finset ι) (t : finset κ) (f : ι → finset α) (g : κ → finset α) :
G.interedges (s.bUnion f) (t.bUnion g) =
(s ×ˢ t).bUnion (λ ab, G.interedges (f ab.1) (g ab.2)) :=
interedges_bUnion _ _ _ _ _
lemma card_interedges_add_card_interedges_compl (h : disjoint s t) :
(G.interedges s t).card + (Gᶜ.interedges s t).card = s.card * t.card :=
begin
rw [←card_product, interedges_def, interedges_def],
have : (s ×ˢ t).filter (λ e , Gᶜ.adj e.1 e.2) = (s ×ˢ t).filter (λ e , ¬ G.adj e.1 e.2),
{ refine filter_congr (λ x hx, _),
rw mem_product at hx,
rw [compl_adj, and_iff_right (h.forall_ne_finset hx.1 hx.2)] },
rw [this, ←card_union_eq, filter_union_filter_neg_eq],
exact disjoint_filter.2 (λ x _, not_not.2),
end
lemma edge_density_add_edge_density_compl (hs : s.nonempty) (ht : t.nonempty) (h : disjoint s t) :
G.edge_density s t + Gᶜ.edge_density s t = 1 :=
begin
rw [edge_density_def, edge_density_def, div_add_div_same, div_eq_one_iff_eq],
{ exact_mod_cast card_interedges_add_card_interedges_compl _ h },
{ positivity }
end
end decidable_eq
lemma card_interedges_le_mul (s t : finset α) : (G.interedges s t).card ≤ s.card * t.card :=
card_interedges_le_mul _ _ _
lemma edge_density_nonneg (s t : finset α) : 0 ≤ G.edge_density s t := edge_density_nonneg _ _ _
lemma edge_density_le_one (s t : finset α) : G.edge_density s t ≤ 1 := edge_density_le_one _ _ _
@[simp] lemma edge_density_empty_left (t : finset α) : G.edge_density ∅ t = 0 :=
edge_density_empty_left _ _
@[simp] lemma edge_density_empty_right (s : finset α) : G.edge_density s ∅ = 0 :=
edge_density_empty_right _ _
@[simp] lemma swap_mem_interedges_iff {x : α × α} :
x.swap ∈ G.interedges s t ↔ x ∈ G.interedges t s :=
swap_mem_interedges_iff G.symm
lemma mk_mem_interedges_comm : (a, b) ∈ G.interedges s t ↔ (b, a) ∈ G.interedges t s :=
mk_mem_interedges_comm G.symm
lemma edge_density_comm (s t : finset α) : G.edge_density s t = G.edge_density t s :=
edge_density_comm G.symm s t
end simple_graph
namespace tactic
open positivity
/-- Extension for the `positivity` tactic: `rel.edge_density` and `simple_graph.edge_density` are
always nonnegative. -/
@[positivity]
meta def positivity_edge_density : expr → tactic strictness
| `(rel.edge_density %%r %%s %%t) := nonnegative <$>
mk_mapp ``rel.edge_density_nonneg [none, none, r, none, s, t]
| `(simple_graph.edge_density %%G %%s %%t) := nonnegative <$>
mk_mapp ``simple_graph.edge_density_nonneg [none, G, none, s, t]
| e := pp e >>= fail ∘ format.bracket "The expression `"
"` isn't of the form `rel.edge_density r s t` nor `simple_graph.edge_density G s t`"
end tactic
|
5daed3f386d63ded85f2a506e8c5b74c038f01b9 | 46125763b4dbf50619e8846a1371029346f4c3db | /src/data/set/intervals/basic.lean | 46112b324b062c53b5aec45059afedbba64f5e9e | [
"Apache-2.0"
] | permissive | thjread/mathlib | a9d97612cedc2c3101060737233df15abcdb9eb1 | 7cffe2520a5518bba19227a107078d83fa725ddc | refs/heads/master | 1,615,637,696,376 | 1,583,953,063,000 | 1,583,953,063,000 | 246,680,271 | 0 | 0 | Apache-2.0 | 1,583,960,875,000 | 1,583,960,875,000 | null | UTF-8 | Lean | false | false | 28,604 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot, Yury Kudryashov
-/
import order.lattice algebra.order_functions algebra.ordered_field tactic.tauto
/-!
# Intervals
In any preorder `α`, we define intervals (which on each side can be either infinite, open, or
closed) using the following naming conventions:
- `i`: infinite
- `o`: open
- `c`: closed
Each interval has the name `I` + letter for left side + letter for right side. For instance,
`Ioc a b` denotes the inverval `(a, b]`.
This file contains these definitions, and basic facts on inclusion, intersection, difference of
intervals (where the precise statements may depend on the properties of the order, in particular
for some statements it should be `linear_order` or `densely_ordered`).
This file also contains statements on lower and upper bounds of intervals.
TODO: This is just the beginning; a lot of rules are missing
-/
universe u
namespace set
open set
section intervals
variables {α : Type u} [preorder α] {a a₁ a₂ b b₁ b₂ x : α}
/-- Left-open right-open interval -/
def Ioo (a b : α) := {x | a < x ∧ x < b}
/-- Left-closed right-open interval -/
def Ico (a b : α) := {x | a ≤ x ∧ x < b}
/-- Left-infinite right-open interval -/
def Iio (a : α) := {x | x < a}
/-- Left-closed right-closed interval -/
def Icc (a b : α) := {x | a ≤ x ∧ x ≤ b}
/-- Left-infinite right-closed interval -/
def Iic (b : α) := {x | x ≤ b}
/-- Left-open right-closed interval -/
def Ioc (a b : α) := {x | a < x ∧ x ≤ b}
/-- Left-closed right-infinite interval -/
def Ici (a : α) := {x | a ≤ x}
/-- Left-open right-infinite interval -/
def Ioi (a : α) := {x | a < x}
@[simp] lemma mem_Ioo : x ∈ Ioo a b ↔ a < x ∧ x < b := iff.rfl
@[simp] lemma mem_Ico : x ∈ Ico a b ↔ a ≤ x ∧ x < b := iff.rfl
@[simp] lemma mem_Iio : x ∈ Iio b ↔ x < b := iff.rfl
@[simp] lemma mem_Icc : x ∈ Icc a b ↔ a ≤ x ∧ x ≤ b := iff.rfl
@[simp] lemma mem_Iic : x ∈ Iic b ↔ x ≤ b := iff.rfl
@[simp] lemma mem_Ioc : x ∈ Ioc a b ↔ a < x ∧ x ≤ b := iff.rfl
@[simp] lemma mem_Ici : x ∈ Ici a ↔ a ≤ x := iff.rfl
@[simp] lemma mem_Ioi : x ∈ Ioi a ↔ a < x := iff.rfl
@[simp] lemma left_mem_Ioo : a ∈ Ioo a b ↔ false := by simp [lt_irrefl]
@[simp] lemma left_mem_Ico : a ∈ Ico a b ↔ a < b := by simp [le_refl]
@[simp] lemma left_mem_Icc : a ∈ Icc a b ↔ a ≤ b := by simp [le_refl]
@[simp] lemma left_mem_Ioc : a ∈ Ioc a b ↔ false := by simp [lt_irrefl]
lemma left_mem_Ici : a ∈ Ici a := by simp
@[simp] lemma right_mem_Ioo : b ∈ Ioo a b ↔ false := by simp [lt_irrefl]
@[simp] lemma right_mem_Ico : b ∈ Ico a b ↔ false := by simp [lt_irrefl]
@[simp] lemma right_mem_Icc : b ∈ Icc a b ↔ a ≤ b := by simp [le_refl]
@[simp] lemma right_mem_Ioc : b ∈ Ioc a b ↔ a < b := by simp [le_refl]
lemma right_mem_Iic : a ∈ Iic a := by simp
@[simp] lemma dual_Ici : @Ici (order_dual α) _ a = @Iic α _ a := rfl
@[simp] lemma dual_Iic : @Iic (order_dual α) _ a = @Ici α _ a := rfl
@[simp] lemma dual_Ioi : @Ioi (order_dual α) _ a = @Iio α _ a := rfl
@[simp] lemma dual_Iio : @Iio (order_dual α) _ a = @Ioi α _ a := rfl
@[simp] lemma dual_Icc : @Icc (order_dual α) _ a b = @Icc α _ b a :=
set.ext $ λ x, and_comm _ _
@[simp] lemma dual_Ioc : @Ioc (order_dual α) _ a b = @Ico α _ b a :=
set.ext $ λ x, and_comm _ _
@[simp] lemma dual_Ico : @Ico (order_dual α) _ a b = @Ioc α _ b a :=
set.ext $ λ x, and_comm _ _
@[simp] lemma dual_Ioo : @Ioo (order_dual α) _ a b = @Ioo α _ b a :=
set.ext $ λ x, and_comm _ _
@[simp] lemma nonempty_Icc : (Icc a b).nonempty ↔ a ≤ b :=
⟨λ ⟨x, hx⟩, le_trans hx.1 hx.2, λ h, ⟨a, left_mem_Icc.2 h⟩⟩
@[simp] lemma nonempty_Ico : (Ico a b).nonempty ↔ a < b :=
⟨λ ⟨x, hx⟩, lt_of_le_of_lt hx.1 hx.2, λ h, ⟨a, left_mem_Ico.2 h⟩⟩
@[simp] lemma nonempty_Ioc : (Ioc a b).nonempty ↔ a < b :=
⟨λ ⟨x, hx⟩, lt_of_lt_of_le hx.1 hx.2, λ h, ⟨b, right_mem_Ioc.2 h⟩⟩
@[simp] lemma nonempty_Ici : (Ici a).nonempty := ⟨a, left_mem_Ici⟩
@[simp] lemma nonempty_Iic : (Iic a).nonempty := ⟨a, right_mem_Iic⟩
@[simp] lemma nonempty_Ioo [densely_ordered α] : (Ioo a b).nonempty ↔ a < b :=
⟨λ ⟨x, ha, hb⟩, lt_trans ha hb, dense⟩
@[simp] lemma nonempty_Ioi [no_top_order α] : (Ioi a).nonempty := no_top a
@[simp] lemma nonempty_Iio [no_bot_order α] : (Iio a).nonempty := no_bot a
@[simp] lemma Ioo_eq_empty (h : b ≤ a) : Ioo a b = ∅ :=
eq_empty_iff_forall_not_mem.2 $ λ x ⟨h₁, h₂⟩, not_le_of_lt (lt_trans h₁ h₂) h
@[simp] lemma Ico_eq_empty (h : b ≤ a) : Ico a b = ∅ :=
eq_empty_iff_forall_not_mem.2 $ λ x ⟨h₁, h₂⟩, not_le_of_lt (lt_of_le_of_lt h₁ h₂) h
@[simp] lemma Icc_eq_empty (h : b < a) : Icc a b = ∅ :=
eq_empty_iff_forall_not_mem.2 $ λ x ⟨h₁, h₂⟩, not_lt_of_le (le_trans h₁ h₂) h
@[simp] lemma Ioc_eq_empty (h : b ≤ a) : Ioc a b = ∅ :=
eq_empty_iff_forall_not_mem.2 $ λ x ⟨h₁, h₂⟩, not_lt_of_le (le_trans h₂ h) h₁
@[simp] lemma Ioo_self (a : α) : Ioo a a = ∅ := Ioo_eq_empty $ le_refl _
@[simp] lemma Ico_self (a : α) : Ico a a = ∅ := Ico_eq_empty $ le_refl _
@[simp] lemma Ioc_self (a : α) : Ioc a a = ∅ := Ioc_eq_empty $ le_refl _
lemma Ici_subset_Ici : Ici a ⊆ Ici b ↔ b ≤ a :=
⟨λ h, h $ left_mem_Ici, λ h x hx, le_trans h hx⟩
lemma Iic_subset_Iic : Iic a ⊆ Iic b ↔ a ≤ b :=
@Ici_subset_Ici (order_dual α) _ _ _
lemma Ici_subset_Ioi : Ici a ⊆ Ioi b ↔ b < a :=
⟨λ h, h left_mem_Ici, λ h x hx, lt_of_lt_of_le h hx⟩
lemma Iic_subset_Iio : Iic a ⊆ Iio b ↔ a < b :=
⟨λ h, h right_mem_Iic, λ h x hx, lt_of_le_of_lt hx h⟩
lemma Ioo_subset_Ioo (h₁ : a₂ ≤ a₁) (h₂ : b₁ ≤ b₂) :
Ioo a₁ b₁ ⊆ Ioo a₂ b₂ :=
λ x ⟨hx₁, hx₂⟩, ⟨lt_of_le_of_lt h₁ hx₁, lt_of_lt_of_le hx₂ h₂⟩
lemma Ioo_subset_Ioo_left (h : a₁ ≤ a₂) : Ioo a₂ b ⊆ Ioo a₁ b :=
Ioo_subset_Ioo h (le_refl _)
lemma Ioo_subset_Ioo_right (h : b₁ ≤ b₂) : Ioo a b₁ ⊆ Ioo a b₂ :=
Ioo_subset_Ioo (le_refl _) h
lemma Ico_subset_Ico (h₁ : a₂ ≤ a₁) (h₂ : b₁ ≤ b₂) :
Ico a₁ b₁ ⊆ Ico a₂ b₂ :=
λ x ⟨hx₁, hx₂⟩, ⟨le_trans h₁ hx₁, lt_of_lt_of_le hx₂ h₂⟩
lemma Ico_subset_Ico_left (h : a₁ ≤ a₂) : Ico a₂ b ⊆ Ico a₁ b :=
Ico_subset_Ico h (le_refl _)
lemma Ico_subset_Ico_right (h : b₁ ≤ b₂) : Ico a b₁ ⊆ Ico a b₂ :=
Ico_subset_Ico (le_refl _) h
lemma Icc_subset_Icc (h₁ : a₂ ≤ a₁) (h₂ : b₁ ≤ b₂) :
Icc a₁ b₁ ⊆ Icc a₂ b₂ :=
λ x ⟨hx₁, hx₂⟩, ⟨le_trans h₁ hx₁, le_trans hx₂ h₂⟩
lemma Icc_subset_Icc_left (h : a₁ ≤ a₂) : Icc a₂ b ⊆ Icc a₁ b :=
Icc_subset_Icc h (le_refl _)
lemma Icc_subset_Icc_right (h : b₁ ≤ b₂) : Icc a b₁ ⊆ Icc a b₂ :=
Icc_subset_Icc (le_refl _) h
lemma Ioc_subset_Ioc (h₁ : a₂ ≤ a₁) (h₂ : b₁ ≤ b₂) :
Ioc a₁ b₁ ⊆ Ioc a₂ b₂ :=
λ x ⟨hx₁, hx₂⟩, ⟨lt_of_le_of_lt h₁ hx₁, le_trans hx₂ h₂⟩
lemma Ioc_subset_Ioc_left (h : a₁ ≤ a₂) : Ioc a₂ b ⊆ Ioc a₁ b :=
Ioc_subset_Ioc h (le_refl _)
lemma Ioc_subset_Ioc_right (h : b₁ ≤ b₂) : Ioc a b₁ ⊆ Ioc a b₂ :=
Ioc_subset_Ioc (le_refl _) h
lemma Ico_subset_Ioo_left (h₁ : a₁ < a₂) : Ico a₂ b ⊆ Ioo a₁ b :=
λ x, and.imp_left $ lt_of_lt_of_le h₁
lemma Icc_subset_Ico_right (h₁ : b₁ < b₂) : Icc a b₁ ⊆ Ico a b₂ :=
λ x, and.imp_right $ λ h₂, lt_of_le_of_lt h₂ h₁
lemma Ioo_subset_Ico_self : Ioo a b ⊆ Ico a b := λ x, and.imp_left le_of_lt
lemma Ioo_subset_Ioc_self : Ioo a b ⊆ Ioc a b := λ x, and.imp_right le_of_lt
lemma Ico_subset_Icc_self : Ico a b ⊆ Icc a b := λ x, and.imp_right le_of_lt
lemma Ioc_subset_Icc_self : Ioc a b ⊆ Icc a b := λ x, and.imp_left le_of_lt
lemma Ioo_subset_Icc_self : Ioo a b ⊆ Icc a b :=
subset.trans Ioo_subset_Ico_self Ico_subset_Icc_self
lemma Ico_subset_Iio_self : Ico a b ⊆ Iio b := λ x, and.right
lemma Ioo_subset_Iio_self : Ioo a b ⊆ Iio b := λ x, and.right
lemma Ioc_subset_Ioi_self : Ioc a b ⊆ Ioi a := λ x, and.left
lemma Ioo_subset_Ioi_self : Ioo a b ⊆ Ioi a := λ x, and.left
lemma Ioi_subset_Ici_self : Ioi a ⊆ Ici a := λx hx, le_of_lt hx
lemma Iio_subset_Iic_self : Iio a ⊆ Iic a := λx hx, le_of_lt hx
lemma Icc_subset_Icc_iff (h₁ : a₁ ≤ b₁) :
Icc a₁ b₁ ⊆ Icc a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ ≤ b₂ :=
⟨λ h, ⟨(h ⟨le_refl _, h₁⟩).1, (h ⟨h₁, le_refl _⟩).2⟩,
λ ⟨h, h'⟩ x ⟨hx, hx'⟩, ⟨le_trans h hx, le_trans hx' h'⟩⟩
lemma Icc_subset_Ioo_iff (h₁ : a₁ ≤ b₁) :
Icc a₁ b₁ ⊆ Ioo a₂ b₂ ↔ a₂ < a₁ ∧ b₁ < b₂ :=
⟨λ h, ⟨(h ⟨le_refl _, h₁⟩).1, (h ⟨h₁, le_refl _⟩).2⟩,
λ ⟨h, h'⟩ x ⟨hx, hx'⟩, ⟨lt_of_lt_of_le h hx, lt_of_le_of_lt hx' h'⟩⟩
lemma Icc_subset_Ico_iff (h₁ : a₁ ≤ b₁) :
Icc a₁ b₁ ⊆ Ico a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ < b₂ :=
⟨λ h, ⟨(h ⟨le_refl _, h₁⟩).1, (h ⟨h₁, le_refl _⟩).2⟩,
λ ⟨h, h'⟩ x ⟨hx, hx'⟩, ⟨le_trans h hx, lt_of_le_of_lt hx' h'⟩⟩
lemma Icc_subset_Ioc_iff (h₁ : a₁ ≤ b₁) :
Icc a₁ b₁ ⊆ Ioc a₂ b₂ ↔ a₂ < a₁ ∧ b₁ ≤ b₂ :=
⟨λ h, ⟨(h ⟨le_refl _, h₁⟩).1, (h ⟨h₁, le_refl _⟩).2⟩,
λ ⟨h, h'⟩ x ⟨hx, hx'⟩, ⟨lt_of_lt_of_le h hx, le_trans hx' h'⟩⟩
lemma Icc_subset_Iio_iff (h₁ : a₁ ≤ b₁) :
Icc a₁ b₁ ⊆ Iio b₂ ↔ b₁ < b₂ :=
⟨λ h, h ⟨h₁, le_refl _⟩, λ h x ⟨hx, hx'⟩, lt_of_le_of_lt hx' h⟩
lemma Icc_subset_Ioi_iff (h₁ : a₁ ≤ b₁) :
Icc a₁ b₁ ⊆ Ioi a₂ ↔ a₂ < a₁ :=
⟨λ h, h ⟨le_refl _, h₁⟩, λ h x ⟨hx, hx'⟩, lt_of_lt_of_le h hx⟩
lemma Icc_subset_Iic_iff (h₁ : a₁ ≤ b₁) :
Icc a₁ b₁ ⊆ Iic b₂ ↔ b₁ ≤ b₂ :=
⟨λ h, h ⟨h₁, le_refl _⟩, λ h x ⟨hx, hx'⟩, le_trans hx' h⟩
lemma Icc_subset_Ici_iff (h₁ : a₁ ≤ b₁) :
Icc a₁ b₁ ⊆ Ici a₂ ↔ a₂ ≤ a₁ :=
⟨λ h, h ⟨le_refl _, h₁⟩, λ h x ⟨hx, hx'⟩, le_trans h hx⟩
/-- If `a ≤ b`, then `(b, +∞) ⊆ (a, +∞)`. In preorders, this is just an implication. If you need
the equivalence in linear orders, use `Ioi_subset_Ioi_iff`. -/
lemma Ioi_subset_Ioi (h : a ≤ b) : Ioi b ⊆ Ioi a :=
λx hx, lt_of_le_of_lt h hx
/-- If `a ≤ b`, then `(b, +∞) ⊆ [a, +∞)`. In preorders, this is just an implication. If you need
the equivalence in dense linear orders, use `Ioi_subset_Ici_iff`. -/
lemma Ioi_subset_Ici (h : a ≤ b) : Ioi b ⊆ Ici a :=
subset.trans (Ioi_subset_Ioi h) Ioi_subset_Ici_self
/-- If `a ≤ b`, then `(-∞, a) ⊆ (-∞, b)`. In preorders, this is just an implication. If you need
the equivalence in linear orders, use `Iio_subset_Iio_iff`. -/
lemma Iio_subset_Iio (h : a ≤ b) : Iio a ⊆ Iio b :=
λx hx, lt_of_lt_of_le hx h
/-- If `a ≤ b`, then `(-∞, a) ⊆ (-∞, b]`. In preorders, this is just an implication. If you need
the equivalence in dense linear orders, use `Iio_subset_Iic_iff`. -/
lemma Iio_subset_Iic (h : a ≤ b) : Iio a ⊆ Iic b :=
subset.trans (Iio_subset_Iio h) Iio_subset_Iic_self
lemma Ici_inter_Iic : Ici a ∩ Iic b = Icc a b := rfl
lemma Ici_inter_Iio : Ici a ∩ Iio b = Ico a b := rfl
lemma Ioi_inter_Iic : Ioi a ∩ Iic b = Ioc a b := rfl
lemma Ioi_inter_Iio : Ioi a ∩ Iio b = Ioo a b := rfl
end intervals
section partial_order
variables {α : Type u} [partial_order α] {a b : α}
@[simp] lemma Icc_self (a : α) : Icc a a = {a} :=
set.ext $ by simp [Icc, le_antisymm_iff, and_comm]
lemma Ico_diff_Ioo_eq_singleton (h : a < b) : Ico a b \ Ioo a b = {a} :=
set.ext $ λ x, begin
simp [not_and'], split,
{ rintro ⟨⟨ax, xb⟩, hne⟩,
exact (eq_or_lt_of_le ax).elim eq.symm (λ h', absurd h' (hne xb)) },
{ rintro rfl, exact ⟨⟨le_refl _, h⟩, λ _, lt_irrefl x⟩ }
end
lemma Ioc_diff_Ioo_eq_singleton (h : a < b) : Ioc a b \ Ioo a b = {b} :=
set.ext $ λ x, begin
simp, split,
{ rintro ⟨⟨ax, xb⟩, hne⟩,
exact (eq_or_lt_of_le xb).elim id (λ h', absurd h' (hne ax)) },
{ rintro rfl, exact ⟨⟨h, le_refl _⟩, λ _, lt_irrefl x⟩ }
end
lemma Icc_diff_Ico_eq_singleton (h : a ≤ b) : Icc a b \ Ico a b = {b} :=
set.ext $ λ x, begin
simp, split,
{ rintro ⟨⟨ax, xb⟩, h⟩,
exact classical.by_contradiction
(λ ne, h ax (lt_of_le_of_ne xb ne)) },
{ rintro rfl, exact ⟨⟨h, le_refl _⟩, λ _, lt_irrefl x⟩ }
end
lemma Icc_diff_Ioc_eq_singleton (h : a ≤ b) : Icc a b \ Ioc a b = {a} :=
set.ext $ λ x, begin
simp [not_and'], split,
{ rintro ⟨⟨ax, xb⟩, h⟩,
exact classical.by_contradiction
(λ hne, h xb (lt_of_le_of_ne ax (ne.symm hne))) },
{ rintro rfl, exact ⟨⟨le_refl _, h⟩, λ _, lt_irrefl x⟩ }
end
end partial_order
section linear_order
variables {α : Type u} [linear_order α] {a a₁ a₂ b b₁ b₂ : α}
lemma compl_Iic : -(Iic a) = Ioi a := ext $ λ _, not_le
lemma compl_Ici : -(Ici a) = Iio a := ext $ λ _, not_le
lemma compl_Iio : -(Iio a) = Ici a := ext $ λ _, not_lt
lemma compl_Ioi : -(Ioi a) = Iic a := ext $ λ _, not_lt
lemma Ioo_eq_empty_iff [densely_ordered α] : Ioo a b = ∅ ↔ b ≤ a :=
⟨λ eq, le_of_not_lt $ λ h,
let ⟨x, h₁, h₂⟩ := dense h in
eq_empty_iff_forall_not_mem.1 eq x ⟨h₁, h₂⟩,
Ioo_eq_empty⟩
lemma Ico_eq_empty_iff : Ico a b = ∅ ↔ b ≤ a :=
⟨λ eq, le_of_not_lt $ λ h, eq_empty_iff_forall_not_mem.1 eq a ⟨le_refl _, h⟩,
Ico_eq_empty⟩
lemma Icc_eq_empty_iff : Icc a b = ∅ ↔ b < a :=
⟨λ eq, lt_of_not_ge $ λ h, eq_empty_iff_forall_not_mem.1 eq a ⟨le_refl _, h⟩,
Icc_eq_empty⟩
lemma Ico_subset_Ico_iff (h₁ : a₁ < b₁) :
Ico a₁ b₁ ⊆ Ico a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ ≤ b₂ :=
⟨λ h, have a₂ ≤ a₁ ∧ a₁ < b₂ := h ⟨le_refl _, h₁⟩,
⟨this.1, le_of_not_lt $ λ h', lt_irrefl b₂ (h ⟨le_of_lt this.2, h'⟩).2⟩,
λ ⟨h₁, h₂⟩, Ico_subset_Ico h₁ h₂⟩
lemma Ioo_subset_Ioo_iff [densely_ordered α] (h₁ : a₁ < b₁) :
Ioo a₁ b₁ ⊆ Ioo a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ ≤ b₂ :=
⟨λ h, begin
rcases dense h₁ with ⟨x, xa, xb⟩,
split; refine le_of_not_lt (λ h', _),
{ have ab := lt_trans (h ⟨xa, xb⟩).1 xb,
exact lt_irrefl _ (h ⟨h', ab⟩).1 },
{ have ab := lt_trans xa (h ⟨xa, xb⟩).2,
exact lt_irrefl _ (h ⟨ab, h'⟩).2 }
end, λ ⟨h₁, h₂⟩, Ioo_subset_Ioo h₁ h₂⟩
lemma Ico_eq_Ico_iff (h : a₁ < b₁ ∨ a₂ < b₂) : Ico a₁ b₁ = Ico a₂ b₂ ↔ a₁ = a₂ ∧ b₁ = b₂ :=
⟨λ e, begin
simp [subset.antisymm_iff] at e, simp [le_antisymm_iff],
cases h; simp [Ico_subset_Ico_iff h] at e;
[ rcases e with ⟨⟨h₁, h₂⟩, e'⟩, rcases e with ⟨e', ⟨h₁, h₂⟩⟩ ];
have := (Ico_subset_Ico_iff (lt_of_le_of_lt h₁ $ lt_of_lt_of_le h h₂)).1 e';
tauto
end, λ ⟨h₁, h₂⟩, by rw [h₁, h₂]⟩
open_locale classical
@[simp] lemma Ioi_subset_Ioi_iff : Ioi b ⊆ Ioi a ↔ a ≤ b :=
begin
refine ⟨λh, _, λh, Ioi_subset_Ioi h⟩,
by_contradiction ba,
exact lt_irrefl _ (h (not_le.mp ba))
end
@[simp] lemma Ioi_subset_Ici_iff [densely_ordered α] : Ioi b ⊆ Ici a ↔ a ≤ b :=
begin
refine ⟨λh, _, λh, Ioi_subset_Ici h⟩,
by_contradiction ba,
obtain ⟨c, bc, ca⟩ : ∃c, b < c ∧ c < a := dense (not_le.mp ba),
exact lt_irrefl _ (lt_of_lt_of_le ca (h bc))
end
@[simp] lemma Iio_subset_Iio_iff : Iio a ⊆ Iio b ↔ a ≤ b :=
begin
refine ⟨λh, _, λh, Iio_subset_Iio h⟩,
by_contradiction ab,
exact lt_irrefl _ (h (not_le.mp ab))
end
@[simp] lemma Iio_subset_Iic_iff [densely_ordered α] : Iio a ⊆ Iic b ↔ a ≤ b :=
begin
refine ⟨λh, _, λh, Iio_subset_Iic h⟩,
by_contradiction ba,
obtain ⟨c, bc, ca⟩ : ∃c, b < c ∧ c < a := dense (not_le.mp ba),
exact lt_irrefl _ (lt_of_lt_of_le bc (h ca))
end
/-! ### Unions of adjacent intervals -/
/-! #### Two infinite intervals -/
@[simp] lemma Iic_union_Ici : Iic a ∪ Ici a = univ := eq_univ_of_forall (λ x, le_total x a)
@[simp] lemma Iio_union_Ici : Iio a ∪ Ici a = univ := eq_univ_of_forall (λ x, lt_or_le x a)
@[simp] lemma Iic_union_Ioi : Iic a ∪ Ioi a = univ := eq_univ_of_forall (λ x, le_or_lt x a)
/-! #### A finite and an infinite interval -/
@[simp] lemma Ioc_union_Ici_eq_Ioi (h : a < b) : Ioc a b ∪ Ici b = Ioi a :=
ext $ λ x, ⟨λ hx, hx.elim and.left (lt_of_lt_of_le h),
λ hx, (le_total x b).elim (λ hxb, or.inl ⟨hx, hxb⟩) (λ hxb, or.inr hxb)⟩
@[simp] lemma Icc_union_Ici_eq_Ioi (h : a ≤ b) : Icc a b ∪ Ici b = Ici a :=
ext $ λ x, ⟨λ hx, hx.elim and.left (le_trans h),
λ hx, (le_total x b).elim (λ hxb, or.inl ⟨hx, hxb⟩) (λ hxb, or.inr hxb)⟩
@[simp] lemma Ioo_union_Ici_eq_Ioi (h : a < b) : Ioo a b ∪ Ici b = Ioi a :=
ext $ λ x, ⟨λ hx, hx.elim and.left (lt_of_lt_of_le h),
λ hx, (lt_or_le x b).elim (λ hxb, or.inl ⟨hx, hxb⟩) (λ hxb, or.inr hxb)⟩
@[simp] lemma Ico_union_Ici_eq_Ioi (h : a ≤ b) : Ico a b ∪ Ici b = Ici a :=
ext $ λ x, ⟨λ hx, hx.elim and.left (le_trans h),
λ hx, (lt_or_le x b).elim (λ hxb, or.inl ⟨hx, hxb⟩) (λ hxb, or.inr hxb)⟩
@[simp] lemma Ioc_union_Ioi_eq_Ioi (h : a ≤ b) : Ioc a b ∪ Ioi b = Ioi a :=
ext $ λ x, ⟨λ hx, hx.elim and.left (lt_of_le_of_lt h),
λ hx, (le_or_lt x b).elim (λ hxb, or.inl ⟨hx, hxb⟩) (λ hxb, or.inr hxb)⟩
@[simp] lemma Icc_union_Ioi_eq_Ioi (h : a ≤ b) : Icc a b ∪ Ioi b = Ici a :=
ext $ λ x, ⟨λ hx, hx.elim and.left (λ hx, le_trans h (le_of_lt hx)),
λ hx, (le_or_lt x b).elim (λ hxb, or.inl ⟨hx, hxb⟩) (λ hxb, or.inr hxb)⟩
/-! #### An infinite and a finite interval -/
@[simp] lemma Iic_union_Icc_eq_Iic (h : a ≤ b) : Iic a ∪ Icc a b = Iic b :=
ext $ λ x, ⟨λ hx, hx.elim (λ hx, le_trans hx h) and.right,
λ hx, (le_total x a).elim (λ hxa, or.inl hxa) (λ hxa, or.inr ⟨hxa, hx⟩)⟩
@[simp] lemma Iic_union_Ico_eq_Iio (h : a < b) : Iic a ∪ Ico a b = Iio b :=
ext $ λ x, ⟨λ hx, hx.elim (λ hx, lt_of_le_of_lt hx h) and.right,
λ hx, (le_total x a).elim (λ hxa, or.inl hxa) (λ hxa, or.inr ⟨hxa, hx⟩)⟩
@[simp] lemma Iio_union_Icc_eq_Iic (h : a ≤ b) : Iio a ∪ Icc a b = Iic b :=
ext $ λ x, ⟨λ hx, hx.elim (λ hx, le_trans (le_of_lt hx) h) and.right,
λ hx, (lt_or_le x a).elim (λ hxa, or.inl hxa) (λ hxa, or.inr ⟨hxa, hx⟩)⟩
@[simp] lemma Iio_union_Ico_eq_Iio (h : a ≤ b) : Iio a ∪ Ico a b = Iio b :=
ext $ λ x, ⟨λ hx, hx.elim (λ hx, lt_of_lt_of_le hx h) and.right,
λ hx, (lt_or_le x a).elim (λ hxa, or.inl hxa) (λ hxa, or.inr ⟨hxa, hx⟩)⟩
@[simp] lemma Iic_union_Ioc_eq_Iic (h : a ≤ b) : Iic a ∪ Ioc a b = Iic b :=
ext $ λ x, ⟨λ hx, hx.elim (λ hx, le_trans hx h) and.right,
λ hx, (le_or_lt x a).elim (λ hxa, or.inl hxa) (λ hxa, or.inr ⟨hxa, hx⟩)⟩
@[simp] lemma Iic_union_Ioo_eq_Iio (h : a < b) : Iic a ∪ Ioo a b = Iio b :=
ext $ λ x, ⟨λ hx, hx.elim (λ hx, lt_of_le_of_lt hx h) and.right,
λ hx, (le_or_lt x a).elim (λ hxa, or.inl hxa) (λ hxa, or.inr ⟨hxa, hx⟩)⟩
/-! #### Two finite intervals with a common point -/
@[simp] lemma Ioc_union_Ico_eq_Ioo {c} (h₁ : a < b) (h₂ : b < c) : Ioc a b ∪ Ico b c = Ioo a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, lt_of_le_of_lt hx.2 h₂⟩) (λ hx, ⟨lt_of_lt_of_le h₁ hx.1, hx.2⟩),
λ hx, (le_total x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Icc_union_Ico_eq_Ico {c} (h₁ : a ≤ b) (h₂ : b < c) : Icc a b ∪ Ico b c = Ico a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, lt_of_le_of_lt hx.2 h₂⟩) (λ hx, ⟨le_trans h₁ hx.1, hx.2⟩),
λ hx, (le_total x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Icc_union_Icc_eq_Icc {c} (h₁ : a ≤ b) (h₂ : b ≤ c) : Icc a b ∪ Icc b c = Icc a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, le_trans hx.2 h₂⟩) (λ hx, ⟨le_trans h₁ hx.1, hx.2⟩),
λ hx, (le_total x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Ioc_union_Icc_eq_Ioc {c} (h₁ : a < b) (h₂ : b ≤ c) : Ioc a b ∪ Icc b c = Ioc a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, le_trans hx.2 h₂⟩) (λ hx, ⟨lt_of_lt_of_le h₁ hx.1, hx.2⟩),
λ hx, (le_total x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
/-! #### Two finite intervals, `I?o` and `Ic?` -/
@[simp] lemma Ioo_union_Ico_eq_Ioo {c} (h₁ : a < b) (h₂ : b ≤ c) : Ioo a b ∪ Ico b c = Ioo a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, lt_of_lt_of_le hx.2 h₂⟩) (λ hx, ⟨lt_of_lt_of_le h₁ hx.1, hx.2⟩),
λ hx, (lt_or_le x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Ico_union_Ico_eq_Ico {c} (h₁ : a ≤ b) (h₂ : b ≤ c) : Ico a b ∪ Ico b c = Ico a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, lt_of_lt_of_le hx.2 h₂⟩) (λ hx, ⟨le_trans h₁ hx.1, hx.2⟩),
λ hx, (lt_or_le x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Ico_union_Icc_eq_Icc {c} (h₁ : a ≤ b) (h₂ : b ≤ c) : Ico a b ∪ Icc b c = Icc a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, le_trans (le_of_lt hx.2) h₂⟩) (λ hx, ⟨le_trans h₁ hx.1, hx.2⟩),
λ hx, (lt_or_le x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Ioo_union_Icc_eq_Ioc {c} (h₁ : a < b) (h₂ : b ≤ c) : Ioo a b ∪ Icc b c = Ioc a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, le_trans (le_of_lt hx.2) h₂⟩) (λ hx, ⟨lt_of_lt_of_le h₁ hx.1, hx.2⟩),
λ hx, (lt_or_le x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
/-! #### Two finite intervals, `I?c` and `Io?` -/
@[simp] lemma Ioc_union_Ioo_eq_Ioo {c} (h₁ : a ≤ b) (h₂ : b < c) : Ioc a b ∪ Ioo b c = Ioo a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, lt_of_le_of_lt hx.2 h₂⟩) (λ hx, ⟨lt_of_le_of_lt h₁ hx.1, hx.2⟩),
λ hx, (le_or_lt x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Icc_union_Ioo_eq_Ico {c} (h₁ : a ≤ b) (h₂ : b < c) : Icc a b ∪ Ioo b c = Ico a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, lt_of_le_of_lt hx.2 h₂⟩) (λ hx, ⟨le_trans h₁ (le_of_lt hx.1), hx.2⟩),
λ hx, (le_or_lt x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Icc_union_Ioc_eq_Icc {c} (h₁ : a ≤ b) (h₂ : b ≤ c) : Icc a b ∪ Ioc b c = Icc a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, le_trans hx.2 h₂⟩) (λ hx, ⟨le_trans h₁ (le_of_lt hx.1), hx.2⟩),
λ hx, (le_or_lt x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
@[simp] lemma Ioc_union_Ioc_eq_Ioc {c} (h₁ : a ≤ b) (h₂ : b ≤ c) : Ioc a b ∪ Ioc b c = Ioc a c :=
ext $ λ x,
⟨λ hx, hx.elim (λ hx, ⟨hx.1, le_trans hx.2 h₂⟩) (λ hx, ⟨lt_of_le_of_lt h₁ hx.1, hx.2⟩),
λ hx, (le_or_lt x b).elim (λ hxb, or.inl ⟨hx.1, hxb⟩) (λ hxb, or.inr ⟨hxb, hx.2⟩)⟩
end linear_order
section lattice
open lattice
section inf
variables {α : Type u} [semilattice_inf α]
@[simp] lemma Iic_inter_Iic {a b : α} : Iic a ∩ Iic b = Iic (a ⊓ b) :=
by { ext x, simp [Iic] }
@[simp] lemma Iio_inter_Iio [is_total α (≤)] {a b : α} : Iio a ∩ Iio b = Iio (a ⊓ b) :=
by { ext x, simp [Iio] }
end inf
section sup
variables {α : Type u} [semilattice_sup α]
@[simp] lemma Ici_inter_Ici {a b : α} : Ici a ∩ Ici b = Ici (a ⊔ b) :=
by { ext x, simp [Ici] }
@[simp] lemma Ioi_inter_Ioi [is_total α (≤)] {a b : α} : Ioi a ∩ Ioi b = Ioi (a ⊔ b) :=
by { ext x, simp [Ioi] }
end sup
section both
variables {α : Type u} [lattice α] [ht : is_total α (≤)] {a b c a₁ a₂ b₁ b₂ : α}
lemma Icc_inter_Icc : Icc a₁ b₁ ∩ Icc a₂ b₂ = Icc (a₁ ⊔ a₂) (b₁ ⊓ b₂) :=
by simp only [Ici_inter_Iic.symm, Ici_inter_Ici.symm, Iic_inter_Iic.symm]; ac_refl
@[simp] lemma Icc_inter_Icc_eq_singleton (hab : a ≤ b) (hbc : b ≤ c) :
Icc a b ∩ Icc b c = {b} :=
begin
rw [Icc_inter_Icc],
convert Icc_self b,
exact sup_of_le_right hab,
exact inf_of_le_left hbc
end
include ht
lemma Ico_inter_Ico : Ico a₁ b₁ ∩ Ico a₂ b₂ = Ico (a₁ ⊔ a₂) (b₁ ⊓ b₂) :=
by simp only [Ici_inter_Iio.symm, Ici_inter_Ici.symm, Iio_inter_Iio.symm]; ac_refl
lemma Ioc_inter_Ioc : Ioc a₁ b₁ ∩ Ioc a₂ b₂ = Ioc (a₁ ⊔ a₂) (b₁ ⊓ b₂) :=
by simp only [Ioi_inter_Iic.symm, Ioi_inter_Ioi.symm, Iic_inter_Iic.symm]; ac_refl
lemma Ioo_inter_Ioo : Ioo a₁ b₁ ∩ Ioo a₂ b₂ = Ioo (a₁ ⊔ a₂) (b₁ ⊓ b₂) :=
by simp only [Ioi_inter_Iio.symm, Ioi_inter_Ioi.symm, Iio_inter_Iio.symm]; ac_refl
end both
end lattice
section decidable_linear_order
variables {α : Type u} [decidable_linear_order α] {a a₁ a₂ b b₁ b₂ : α}
@[simp] lemma Ico_diff_Iio {a b c : α} : Ico a b \ Iio c = Ico (max a c) b :=
set.ext $ by simp [Ico, Iio, iff_def, max_le_iff] {contextual:=tt}
@[simp] lemma Ico_inter_Iio {a b c : α} : Ico a b ∩ Iio c = Ico a (min b c) :=
set.ext $ by simp [Ico, Iio, iff_def, lt_min_iff] {contextual:=tt}
end decidable_linear_order
section ordered_comm_group
variables {α : Type u} [ordered_comm_group α]
lemma image_add_left_Icc (a b c : α) : ((+) a) '' Icc b c = Icc (a + b) (a + c) :=
begin
ext x,
split,
{ rintros ⟨x, hx, rfl⟩,
exact ⟨add_le_add_left hx.1 a, add_le_add_left hx.2 a⟩},
{ intro hx,
refine ⟨-a + x, _, add_neg_cancel_left _ _⟩,
exact ⟨le_neg_add_iff_add_le.2 hx.1, neg_add_le_iff_le_add.2 hx.2⟩ }
end
lemma image_add_right_Icc (a b c : α) : (λ x, x + c) '' Icc a b = Icc (a + c) (b + c) :=
by convert image_add_left_Icc c a b using 1; simp only [add_comm _ c]
lemma image_neg_Iio (r : α) : image (λz, -z) (Iio r) = Ioi (-r) :=
begin
ext z,
apply iff.intro,
{ intros hz,
apply exists.elim hz,
intros z' hz',
rw [←hz'.2],
simp only [mem_Ioi, neg_lt_neg_iff],
exact hz'.1 },
{ intros hz,
simp only [mem_image, mem_Iio],
use -z,
simp [hz],
exact neg_lt.1 hz }
end
lemma image_neg_Iic (r : α) : image (λz, -z) (Iic r) = Ici (-r) :=
begin
apply set.ext,
intros z,
apply iff.intro,
{ intros hz,
apply exists.elim hz,
intros z' hz',
rw [←hz'.2],
simp only [neg_le_neg_iff, mem_Ici],
exact hz'.1 },
{ intros hz,
simp only [mem_image, mem_Iic],
use -z,
simp [hz],
exact neg_le.1 hz }
end
end ordered_comm_group
section decidable_linear_ordered_comm_group
variables {α : Type u} [decidable_linear_ordered_comm_group α]
/-- If we remove a smaller interval from a larger, the result is nonempty -/
lemma nonempty_Ico_sdiff {x dx y dy : α} (h : dy < dx) (hx : 0 < dx) :
nonempty ↥(Ico x (x + dx) \ Ico y (y + dy)) :=
begin
cases lt_or_le x y with h' h',
{ use x, simp* },
{ use max x (x + dy), simp [*, le_refl] }
end
end decidable_linear_ordered_comm_group
section linear_ordered_field
variables {α : Type u} [linear_ordered_field α]
lemma image_mul_right_Icc' (a b : α) {c : α} (h : 0 < c) :
(λ x, x * c) '' Icc a b = Icc (a * c) (b * c) :=
begin
ext x,
split,
{ rintros ⟨x, hx, rfl⟩,
exact ⟨mul_le_mul_of_nonneg_right hx.1 (le_of_lt h),
mul_le_mul_of_nonneg_right hx.2 (le_of_lt h)⟩ },
{ intro hx,
refine ⟨x / c, _, div_mul_cancel x (ne_of_gt h)⟩,
exact ⟨le_div_of_mul_le h hx.1, div_le_of_le_mul h (mul_comm b c ▸ hx.2)⟩ }
end
lemma image_mul_right_Icc {a b c : α} (hab : a ≤ b) (hc : 0 ≤ c) :
(λ x, x * c) '' Icc a b = Icc (a * c) (b * c) :=
begin
cases eq_or_lt_of_le hc,
{ subst c,
simp [(nonempty_Icc.2 hab).image_const] },
exact image_mul_right_Icc' a b ‹0 < c›
end
lemma image_mul_left_Icc' {a : α} (h : 0 < a) (b c : α) :
((*) a) '' Icc b c = Icc (a * b) (a * c) :=
by { convert image_mul_right_Icc' b c h using 1; simp only [mul_comm _ a] }
lemma image_mul_left_Icc {a b c : α} (ha : 0 ≤ a) (hbc : b ≤ c) :
((*) a) '' Icc b c = Icc (a * b) (a * c) :=
by { convert image_mul_right_Icc hbc ha using 1; simp only [mul_comm _ a] }
end linear_ordered_field
end set
|
14441466914c255b5f1a1c8caeeee8c9fdd70fbd | 958488bc7f3c2044206e0358e56d7690b6ae696c | /lean/propext.lean | 3b0d3d44f35d20ae6321fb75adb59a7e6c78f600 | [] | no_license | possientis/Prog | a08eec1c1b121c2fd6c70a8ae89e2fbef952adb4 | d4b3debc37610a88e0dac3ac5914903604fd1d1f | refs/heads/master | 1,692,263,717,723 | 1,691,757,179,000 | 1,691,757,179,000 | 40,361,602 | 3 | 0 | null | 1,679,896,438,000 | 1,438,953,859,000 | Coq | UTF-8 | Lean | false | false | 682 | lean | axiom propext2 {p q : Prop} : (p ↔ q) → p = q
--#check @propext2
--#check @propext
variables p q r s t : Prop
variable P : Prop -> Prop
lemma L1 : (p ↔ q) → ((r ∧ p ∧ s → t) ↔ (r ∧ q ∧ s → t)) :=
begin
intros H,
rewrite (propext2 H)
end
lemma L2 : (p ↔ q) → (P p → P q) :=
begin
intros H1 H2,
rewrite ← (propext2 H1),
assumption
end
-- L2 is equivalent to propext
lemma L3 :
(∀ (p q : Prop), (p ↔ q) → p = q)
↔
(∀ (P : Prop → Prop) (p q:Prop), (p ↔ q) → (P p → P q)) :=
begin
split,
{intros H1 P p q H2 H3, rewrite ← (H1 p q H2), assumption},
{intros H1 p q H2, apply H1 (λ z, p = z) p q H2 rfl}
end
|
63dedead387b043bfff1cffadfef271d3bd29bf3 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/run/empty_match.lean | 51a5a9fe624856bafb13ed27aa5bce02e3e671ba | [
"Apache-2.0"
] | permissive | leanprover-community/lean | 12b87f69d92e614daea8bcc9d4de9a9ace089d0e | cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0 | refs/heads/master | 1,687,508,156,644 | 1,684,951,104,000 | 1,684,951,104,000 | 169,960,991 | 457 | 107 | Apache-2.0 | 1,686,744,372,000 | 1,549,790,268,000 | C++ | UTF-8 | Lean | false | false | 119 | lean | open nat
definition not_lt_zero (a : nat) : ¬ a < 0 :=
assume H : a < 0,
match H with
end
#check _root_.not_lt_zero
|
f93081578b15eff217f5fccd9db71eabfa7575cf | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/algebraic_topology/simplicial_object.lean | 0467fe961b36d1aefb564ed67751af0769a76ba1 | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 24,028 | lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison, Adam Topaz
-/
import algebraic_topology.simplex_category
import category_theory.arrow
import category_theory.limits.functor_category
import category_theory.opposites
/-!
# Simplicial objects in a category.
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
A simplicial object in a category `C` is a `C`-valued presheaf on `simplex_category`.
(Similarly a cosimplicial object is functor `simplex_category ⥤ C`.)
Use the notation `X _[n]` in the `simplicial` locale to obtain the `n`-th term of a
(co)simplicial object `X`, where `n` is a natural number.
-/
open opposite
open category_theory
open category_theory.limits
universes v u v' u'
namespace category_theory
variables (C : Type u) [category.{v} C]
/-- The category of simplicial objects valued in a category `C`.
This is the category of contravariant functors from `simplex_category` to `C`. -/
@[derive category, nolint has_nonempty_instance]
def simplicial_object := simplex_categoryᵒᵖ ⥤ C
namespace simplicial_object
localized "notation (name := simplicial_object.at) X ` _[`:1000 n `]` :=
(X : category_theory.simplicial_object hole!).obj (opposite.op (simplex_category.mk n))"
in simplicial
instance {J : Type v} [small_category J] [has_limits_of_shape J C] :
has_limits_of_shape J (simplicial_object C) := by {dsimp [simplicial_object], apply_instance}
instance [has_limits C] : has_limits (simplicial_object C) := ⟨infer_instance⟩
instance {J : Type v} [small_category J] [has_colimits_of_shape J C] :
has_colimits_of_shape J (simplicial_object C) := by {dsimp [simplicial_object], apply_instance}
instance [has_colimits C] : has_colimits (simplicial_object C) := ⟨infer_instance⟩
variables {C} (X : simplicial_object C)
/-- Face maps for a simplicial object. -/
def δ {n} (i : fin (n+2)) : X _[n+1] ⟶ X _[n] :=
X.map (simplex_category.δ i).op
/-- Degeneracy maps for a simplicial object. -/
def σ {n} (i : fin (n+1)) : X _[n] ⟶ X _[n+1] :=
X.map (simplex_category.σ i).op
/-- Isomorphisms from identities in ℕ. -/
def eq_to_iso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] :=
X.map_iso (eq_to_iso (by rw h))
@[simp] lemma eq_to_iso_refl {n : ℕ} (h : n = n) : X.eq_to_iso h = iso.refl _ :=
by { ext, simp [eq_to_iso], }
/-- The generic case of the first simplicial identity -/
@[reassoc]
lemma δ_comp_δ {n} {i j : fin (n+2)} (H : i ≤ j) :
X.δ j.succ ≫ X.δ i = X.δ i.cast_succ ≫ X.δ j :=
by { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ H] }
@[reassoc]
lemma δ_comp_δ' {n} {i : fin (n+2)} {j : fin (n+3)} (H : i.cast_succ < j) :
X.δ j ≫ X.δ i = X.δ i.cast_succ ≫
X.δ (j.pred (λ hj, by simpa only [hj, fin.not_lt_zero] using H)) :=
by { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ' H] }
@[reassoc]
lemma δ_comp_δ'' {n} {i : fin (n+3)} {j : fin (n+2)} (H : i ≤ j.cast_succ) :
X.δ j.succ ≫ X.δ (i.cast_lt (nat.lt_of_le_of_lt (fin.le_iff_coe_le_coe.mp H) j.is_lt)) =
X.δ i ≫ X.δ j :=
by { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ'' H] }
/-- The special case of the first simplicial identity -/
@[reassoc]
lemma δ_comp_δ_self {n} {i : fin (n+2)} : X.δ i.cast_succ ≫ X.δ i = X.δ i.succ ≫ X.δ i :=
by { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ_self] }
@[reassoc]
lemma δ_comp_δ_self' {n} {j : fin (n+3)} {i : fin (n+2)} (H : j = i.cast_succ) :
X.δ j ≫ X.δ i = X.δ i.succ ≫ X.δ i :=
by { subst H, rw δ_comp_δ_self, }
/-- The second simplicial identity -/
@[reassoc]
lemma δ_comp_σ_of_le {n} {i : fin (n+2)} {j : fin (n+1)} (H : i ≤ j.cast_succ) :
X.σ j.succ ≫ X.δ i.cast_succ = X.δ i ≫ X.σ j :=
by { dsimp [δ, σ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_of_le H] }
/-- The first part of the third simplicial identity -/
@[reassoc]
lemma δ_comp_σ_self {n} {i : fin (n+1)} :
X.σ i ≫ X.δ i.cast_succ = 𝟙 _ :=
begin
dsimp [δ, σ],
simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_self, op_id, X.map_id],
end
@[reassoc]
lemma δ_comp_σ_self' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.cast_succ):
X.σ i ≫ X.δ j = 𝟙 _ := by { subst H, rw δ_comp_σ_self, }
/-- The second part of the third simplicial identity -/
@[reassoc]
lemma δ_comp_σ_succ {n} {i : fin (n+1)} :
X.σ i ≫ X.δ i.succ = 𝟙 _ :=
begin
dsimp [δ, σ],
simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_succ, op_id, X.map_id],
end
@[reassoc]
lemma δ_comp_σ_succ' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.succ) :
X.σ i ≫ X.δ j = 𝟙 _ := by { subst H, rw δ_comp_σ_succ, }
/-- The fourth simplicial identity -/
@[reassoc]
lemma δ_comp_σ_of_gt {n} {i : fin (n+2)} {j : fin (n+1)} (H : j.cast_succ < i) :
X.σ j.cast_succ ≫ X.δ i.succ = X.δ i ≫ X.σ j :=
by { dsimp [δ, σ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_of_gt H] }
@[reassoc]
lemma δ_comp_σ_of_gt' {n} {i : fin (n+3)} {j : fin (n+2)} (H : j.succ < i) :
X.σ j ≫ X.δ i = X.δ (i.pred (λ hi, by simpa only [fin.not_lt_zero, hi] using H)) ≫
X.σ (j.cast_lt ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le
(by simpa only [fin.val_eq_coe, ← fin.coe_succ]
using fin.lt_iff_coe_lt_coe.mp H) i.is_le))) :=
by { dsimp [δ, σ], simpa only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_of_gt' H], }
/-- The fifth simplicial identity -/
@[reassoc]
lemma σ_comp_σ {n} {i j : fin (n+1)} (H : i ≤ j) :
X.σ j ≫ X.σ i.cast_succ = X.σ i ≫ X.σ j.succ :=
by { dsimp [δ, σ], simp only [←X.map_comp, ←op_comp, simplex_category.σ_comp_σ H] }
open_locale simplicial
@[simp, reassoc]
lemma δ_naturality {X' X : simplicial_object C} (f : X ⟶ X') {n : ℕ} (i : fin (n+2)) :
X.δ i ≫ f.app (op [n]) = f.app (op [n+1]) ≫ X'.δ i := f.naturality _
@[simp, reassoc]
lemma σ_naturality {X' X : simplicial_object C} (f : X ⟶ X') {n : ℕ} (i : fin (n+1)) :
X.σ i ≫ f.app (op [n+1]) = f.app (op [n]) ≫ X'.σ i := f.naturality _
variable (C)
/-- Functor composition induces a functor on simplicial objects. -/
@[simps]
def whiskering (D : Type*) [category D] :
(C ⥤ D) ⥤ simplicial_object C ⥤ simplicial_object D :=
whiskering_right _ _ _
/-- Truncated simplicial objects. -/
@[derive category, nolint has_nonempty_instance]
def truncated (n : ℕ) := (simplex_category.truncated n)ᵒᵖ ⥤ C
variable {C}
namespace truncated
instance {n} {J : Type v} [small_category J] [has_limits_of_shape J C] :
has_limits_of_shape J (simplicial_object.truncated C n) := by {dsimp [truncated], apply_instance}
instance {n} [has_limits C] : has_limits (simplicial_object.truncated C n) := ⟨infer_instance⟩
instance {n} {J : Type v} [small_category J] [has_colimits_of_shape J C] :
has_colimits_of_shape J (simplicial_object.truncated C n) :=
by {dsimp [truncated], apply_instance}
instance {n} [has_colimits C] : has_colimits (simplicial_object.truncated C n) := ⟨infer_instance⟩
variable (C)
/-- Functor composition induces a functor on truncated simplicial objects. -/
@[simps]
def whiskering {n} (D : Type*) [category D] :
(C ⥤ D) ⥤ truncated C n ⥤ truncated D n :=
whiskering_right _ _ _
variable {C}
end truncated
section skeleton
/-- The skeleton functor from simplicial objects to truncated simplicial objects. -/
def sk (n : ℕ) : simplicial_object C ⥤ simplicial_object.truncated C n :=
(whiskering_left _ _ _).obj simplex_category.truncated.inclusion.op
end skeleton
variable (C)
/-- The constant simplicial object is the constant functor. -/
abbreviation const : C ⥤ simplicial_object C := category_theory.functor.const _
/-- The category of augmented simplicial objects, defined as a comma category. -/
@[derive category, nolint has_nonempty_instance]
def augmented := comma (𝟭 (simplicial_object C)) (const C)
variable {C}
namespace augmented
/-- Drop the augmentation. -/
@[simps]
def drop : augmented C ⥤ simplicial_object C := comma.fst _ _
/-- The point of the augmentation. -/
@[simps]
def point : augmented C ⥤ C := comma.snd _ _
/-- The functor from augmented objects to arrows. -/
@[simps]
def to_arrow : augmented C ⥤ arrow C :=
{ obj := λ X,
{ left := (drop.obj X) _[0],
right := (point.obj X),
hom := X.hom.app _ },
map := λ X Y η,
{ left := (drop.map η).app _,
right := (point.map η),
w' := begin
dsimp,
rw ← nat_trans.comp_app,
erw η.w,
refl,
end } }
/-- The compatibility of a morphism with the augmentation, on 0-simplices -/
@[reassoc]
lemma w₀ {X Y : augmented C} (f : X ⟶ Y) :
(augmented.drop.map f).app (op (simplex_category.mk 0)) ≫
Y.hom.app (op (simplex_category.mk 0)) =
X.hom.app (op (simplex_category.mk 0)) ≫ augmented.point.map f :=
by convert congr_app f.w (op (simplex_category.mk 0))
variable (C)
/-- Functor composition induces a functor on augmented simplicial objects. -/
@[simp]
def whiskering_obj (D : Type*) [category D] (F : C ⥤ D) :
augmented C ⥤ augmented D :=
{ obj := λ X,
{ left := ((whiskering _ _).obj F).obj (drop.obj X),
right := F.obj (point.obj X),
hom := whisker_right X.hom F ≫ (functor.const_comp _ _ _).hom },
map := λ X Y η,
{ left := whisker_right η.left _,
right := F.map η.right,
w' := begin
ext,
dsimp,
rw [category.comp_id, category.comp_id, ← F.map_comp, ← F.map_comp, ← nat_trans.comp_app],
erw η.w,
refl,
end } }
/-- Functor composition induces a functor on augmented simplicial objects. -/
@[simps]
def whiskering (D : Type u') [category.{v'} D] :
(C ⥤ D) ⥤ augmented C ⥤ augmented D :=
{ obj := whiskering_obj _ _,
map := λ X Y η,
{ app := λ A,
{ left := whisker_left _ η,
right := η.app _,
w' := begin
ext n,
dsimp,
rw [category.comp_id, category.comp_id, η.naturality],
end }, }, }
variable {C}
end augmented
/-- Augment a simplicial object with an object. -/
@[simps]
def augment (X : simplicial_object C) (X₀ : C) (f : X _[0] ⟶ X₀)
(w : ∀ (i : simplex_category) (g₁ g₂ : [0] ⟶ i),
X.map g₁.op ≫ f = X.map g₂.op ≫ f) : simplicial_object.augmented C :=
{ left := X,
right := X₀,
hom :=
{ app := λ i, X.map (simplex_category.const i.unop 0).op ≫ f,
naturality' := begin
intros i j g,
dsimp,
rw ← g.op_unop,
simpa only [← X.map_comp, ← category.assoc, category.comp_id, ← op_comp] using w _ _ _,
end } }
@[simp]
lemma augment_hom_zero (X : simplicial_object C) (X₀ : C) (f : X _[0] ⟶ X₀) (w) :
(X.augment X₀ f w).hom.app (op [0]) = f :=
by { dsimp, rw [simplex_category.hom_zero_zero ([0].const 0), op_id, X.map_id, category.id_comp] }
end simplicial_object
/-- Cosimplicial objects. -/
@[derive category, nolint has_nonempty_instance]
def cosimplicial_object := simplex_category ⥤ C
namespace cosimplicial_object
localized "notation (name := cosimplicial_object.at) X ` _[`:1000 n `]` :=
(X : category_theory.cosimplicial_object hole!).obj (simplex_category.mk n)" in simplicial
instance {J : Type v} [small_category J] [has_limits_of_shape J C] :
has_limits_of_shape J (cosimplicial_object C) := by {dsimp [cosimplicial_object], apply_instance}
instance [has_limits C] : has_limits (cosimplicial_object C) := ⟨infer_instance⟩
instance {J : Type v} [small_category J] [has_colimits_of_shape J C] :
has_colimits_of_shape J (cosimplicial_object C) :=
by {dsimp [cosimplicial_object], apply_instance}
instance [has_colimits C] : has_colimits (cosimplicial_object C) := ⟨infer_instance⟩
variables {C} (X : cosimplicial_object C)
/-- Coface maps for a cosimplicial object. -/
def δ {n} (i : fin (n+2)) : X _[n] ⟶ X _[n+1] :=
X.map (simplex_category.δ i)
/-- Codegeneracy maps for a cosimplicial object. -/
def σ {n} (i : fin (n+1)) : X _[n+1] ⟶ X _[n] :=
X.map (simplex_category.σ i)
/-- Isomorphisms from identities in ℕ. -/
def eq_to_iso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] :=
X.map_iso (eq_to_iso (by rw h))
@[simp] lemma eq_to_iso_refl {n : ℕ} (h : n = n) : X.eq_to_iso h = iso.refl _ :=
by { ext, simp [eq_to_iso], }
/-- The generic case of the first cosimplicial identity -/
@[reassoc]
lemma δ_comp_δ {n} {i j : fin (n+2)} (H : i ≤ j) :
X.δ i ≫ X.δ j.succ = X.δ j ≫ X.δ i.cast_succ :=
by { dsimp [δ], simp only [←X.map_comp, simplex_category.δ_comp_δ H], }
@[reassoc]
lemma δ_comp_δ' {n} {i : fin (n+2)} {j : fin (n+3)} (H : i.cast_succ < j) :
X.δ i ≫ X.δ j = X.δ (j.pred (λ hj, by simpa only [hj, fin.not_lt_zero] using H)) ≫
X.δ i.cast_succ :=
by { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ' H] }
@[reassoc]
lemma δ_comp_δ'' {n} {i : fin (n+3)} {j : fin (n+2)} (H : i ≤ j.cast_succ) :
X.δ (i.cast_lt (nat.lt_of_le_of_lt (fin.le_iff_coe_le_coe.mp H) j.is_lt)) ≫ X.δ j.succ =
X.δ j ≫ X.δ i :=
by { dsimp [δ], simp only [←X.map_comp, ←op_comp, simplex_category.δ_comp_δ'' H] }
/-- The special case of the first cosimplicial identity -/
@[reassoc]
lemma δ_comp_δ_self {n} {i : fin (n+2)} : X.δ i ≫ X.δ i.cast_succ = X.δ i ≫ X.δ i.succ :=
by { dsimp [δ], simp only [←X.map_comp, simplex_category.δ_comp_δ_self] }
@[reassoc]
lemma δ_comp_δ_self' {n} {i : fin (n+2)} {j : fin (n+3)} (H : j = i.cast_succ) :
X.δ i ≫ X.δ j = X.δ i ≫ X.δ i.succ :=
by { subst H, rw δ_comp_δ_self, }
/-- The second cosimplicial identity -/
@[reassoc]
lemma δ_comp_σ_of_le {n} {i : fin (n+2)} {j : fin (n+1)} (H : i ≤ j.cast_succ) :
X.δ i.cast_succ ≫ X.σ j.succ = X.σ j ≫ X.δ i :=
by { dsimp [δ, σ], simp only [←X.map_comp, simplex_category.δ_comp_σ_of_le H] }
/-- The first part of the third cosimplicial identity -/
@[reassoc]
lemma δ_comp_σ_self {n} {i : fin (n+1)} :
X.δ i.cast_succ ≫ X.σ i = 𝟙 _ :=
begin
dsimp [δ, σ],
simp only [←X.map_comp, simplex_category.δ_comp_σ_self, X.map_id],
end
@[reassoc]
lemma δ_comp_σ_self' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.cast_succ) :
X.δ j ≫ X.σ i = 𝟙 _ :=
by { subst H, rw δ_comp_σ_self, }
/-- The second part of the third cosimplicial identity -/
@[reassoc]
lemma δ_comp_σ_succ {n} {i : fin (n+1)} :
X.δ i.succ ≫ X.σ i = 𝟙 _ :=
begin
dsimp [δ, σ],
simp only [←X.map_comp, simplex_category.δ_comp_σ_succ, X.map_id],
end
@[reassoc]
lemma δ_comp_σ_succ' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.succ) :
X.δ j ≫ X.σ i = 𝟙 _ :=
by { subst H, rw δ_comp_σ_succ, }
/-- The fourth cosimplicial identity -/
@[reassoc]
lemma δ_comp_σ_of_gt {n} {i : fin (n+2)} {j : fin (n+1)} (H : j.cast_succ < i) :
X.δ i.succ ≫ X.σ j.cast_succ = X.σ j ≫ X.δ i :=
by { dsimp [δ, σ], simp only [←X.map_comp, simplex_category.δ_comp_σ_of_gt H] }
@[reassoc]
lemma δ_comp_σ_of_gt' {n} {i : fin (n+3)} {j : fin (n+2)} (H : j.succ < i) :
X.δ i ≫ X.σ j = X.σ (j.cast_lt ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le
(by simpa only [fin.val_eq_coe, ← fin.coe_succ]
using fin.lt_iff_coe_lt_coe.mp H) i.is_le))) ≫
X.δ (i.pred (λ hi, by simpa only [fin.not_lt_zero, hi] using H)) :=
by { dsimp [δ, σ], simpa only [←X.map_comp, ←op_comp, simplex_category.δ_comp_σ_of_gt' H], }
/-- The fifth cosimplicial identity -/
@[reassoc]
lemma σ_comp_σ {n} {i j : fin (n+1)} (H : i ≤ j) :
X.σ i.cast_succ ≫ X.σ j = X.σ j.succ ≫ X.σ i :=
by { dsimp [δ, σ], simp only [←X.map_comp, simplex_category.σ_comp_σ H] }
@[simp, reassoc]
lemma δ_naturality {X' X : cosimplicial_object C} (f : X ⟶ X') {n : ℕ} (i : fin (n+2)) :
X.δ i ≫ f.app (simplex_category.mk (n+1)) =
f.app (simplex_category.mk n) ≫ X'.δ i := f.naturality _
@[simp, reassoc]
lemma σ_naturality {X' X : cosimplicial_object C} (f : X ⟶ X') {n : ℕ} (i : fin (n+1)) :
X.σ i ≫ f.app (simplex_category.mk n) =
f.app (simplex_category.mk (n+1)) ≫ X'.σ i := f.naturality _
variable (C)
/-- Functor composition induces a functor on cosimplicial objects. -/
@[simps]
def whiskering (D : Type*) [category D] :
(C ⥤ D) ⥤ cosimplicial_object C ⥤ cosimplicial_object D :=
whiskering_right _ _ _
/-- Truncated cosimplicial objects. -/
@[derive category, nolint has_nonempty_instance]
def truncated (n : ℕ) := simplex_category.truncated n ⥤ C
variable {C}
namespace truncated
instance {n} {J : Type v} [small_category J] [has_limits_of_shape J C] :
has_limits_of_shape J (cosimplicial_object.truncated C n) :=
by {dsimp [truncated], apply_instance}
instance {n} [has_limits C] : has_limits (cosimplicial_object.truncated C n) := ⟨infer_instance⟩
instance {n} {J : Type v} [small_category J] [has_colimits_of_shape J C] :
has_colimits_of_shape J (cosimplicial_object.truncated C n) :=
by {dsimp [truncated], apply_instance}
instance {n} [has_colimits C] : has_colimits (cosimplicial_object.truncated C n) := ⟨infer_instance⟩
variable (C)
/-- Functor composition induces a functor on truncated cosimplicial objects. -/
@[simps]
def whiskering {n} (D : Type*) [category D] :
(C ⥤ D) ⥤ truncated C n ⥤ truncated D n :=
whiskering_right _ _ _
variable {C}
end truncated
section skeleton
/-- The skeleton functor from cosimplicial objects to truncated cosimplicial objects. -/
def sk (n : ℕ) : cosimplicial_object C ⥤ cosimplicial_object.truncated C n :=
(whiskering_left _ _ _).obj simplex_category.truncated.inclusion
end skeleton
variable (C)
/-- The constant cosimplicial object. -/
abbreviation const : C ⥤ cosimplicial_object C := category_theory.functor.const _
/-- Augmented cosimplicial objects. -/
@[derive category, nolint has_nonempty_instance]
def augmented := comma (const C) (𝟭 (cosimplicial_object C))
variable {C}
namespace augmented
/-- Drop the augmentation. -/
@[simps]
def drop : augmented C ⥤ cosimplicial_object C := comma.snd _ _
/-- The point of the augmentation. -/
@[simps]
def point : augmented C ⥤ C := comma.fst _ _
/-- The functor from augmented objects to arrows. -/
@[simps]
def to_arrow : augmented C ⥤ arrow C :=
{ obj := λ X,
{ left := (point.obj X),
right := (drop.obj X) _[0],
hom := X.hom.app _ },
map := λ X Y η,
{ left := (point.map η),
right := (drop.map η).app _,
w' := begin
dsimp,
rw ← nat_trans.comp_app,
erw ← η.w,
refl,
end } }
variable (C)
/-- Functor composition induces a functor on augmented cosimplicial objects. -/
@[simp]
def whiskering_obj (D : Type*) [category D] (F : C ⥤ D) :
augmented C ⥤ augmented D :=
{ obj := λ X,
{ left := F.obj (point.obj X),
right := ((whiskering _ _).obj F).obj (drop.obj X),
hom := (functor.const_comp _ _ _).inv ≫ whisker_right X.hom F },
map := λ X Y η,
{ left := F.map η.left,
right := whisker_right η.right _,
w' := begin
ext,
dsimp,
rw [category.id_comp, category.id_comp, ← F.map_comp, ← F.map_comp, ← nat_trans.comp_app],
erw ← η.w,
refl,
end } }
/-- Functor composition induces a functor on augmented cosimplicial objects. -/
@[simps]
def whiskering (D : Type u') [category.{v'} D] :
(C ⥤ D) ⥤ augmented C ⥤ augmented D :=
{ obj := whiskering_obj _ _,
map := λ X Y η,
{ app := λ A,
{ left := η.app _,
right := whisker_left _ η,
w' := begin
ext n,
dsimp,
rw [category.id_comp, category.id_comp, η.naturality],
end }, }, }
variable {C}
end augmented
open_locale simplicial
/-- Augment a cosimplicial object with an object. -/
@[simps]
def augment (X : cosimplicial_object C) (X₀ : C) (f : X₀ ⟶ X.obj [0])
(w : ∀ (i : simplex_category) (g₁ g₂ : [0] ⟶ i),
f ≫ X.map g₁ = f ≫ X.map g₂) : cosimplicial_object.augmented C :=
{ left := X₀,
right := X,
hom :=
{ app := λ i, f ≫ X.map (simplex_category.const i 0),
naturality' := begin
intros i j g,
dsimp,
simpa [← X.map_comp] using w _ _ _,
end } }
@[simp]
lemma augment_hom_zero (X : cosimplicial_object C) (X₀ : C) (f : X₀ ⟶ X.obj [0]) (w) :
(X.augment X₀ f w).hom.app [0] = f :=
by { dsimp, rw [simplex_category.hom_zero_zero ([0].const 0), X.map_id, category.comp_id] }
end cosimplicial_object
/-- The anti-equivalence between simplicial objects and cosimplicial objects. -/
@[simps]
def simplicial_cosimplicial_equiv : (simplicial_object C)ᵒᵖ ≌ (cosimplicial_object Cᵒᵖ) :=
functor.left_op_right_op_equiv _ _
/-- The anti-equivalence between cosimplicial objects and simplicial objects. -/
@[simps]
def cosimplicial_simplicial_equiv : (cosimplicial_object C)ᵒᵖ ≌ (simplicial_object Cᵒᵖ) :=
functor.op_unop_equiv _ _
variable {C}
/-- Construct an augmented cosimplicial object in the opposite
category from an augmented simplicial object. -/
@[simps]
def simplicial_object.augmented.right_op (X : simplicial_object.augmented C) :
cosimplicial_object.augmented Cᵒᵖ :=
{ left := opposite.op X.right,
right := X.left.right_op,
hom := X.hom.right_op }
/-- Construct an augmented simplicial object from an augmented cosimplicial
object in the opposite category. -/
@[simps]
def cosimplicial_object.augmented.left_op (X : cosimplicial_object.augmented Cᵒᵖ) :
simplicial_object.augmented C :=
{ left := X.right.left_op,
right := X.left.unop,
hom := X.hom.left_op }
/-- Converting an augmented simplicial object to an augmented cosimplicial
object and back is isomorphic to the given object. -/
@[simps]
def simplicial_object.augmented.right_op_left_op_iso (X : simplicial_object.augmented C) :
X.right_op.left_op ≅ X :=
comma.iso_mk X.left.right_op_left_op_iso (eq_to_iso $ by simp) (by tidy)
/-- Converting an augmented cosimplicial object to an augmented simplicial
object and back is isomorphic to the given object. -/
@[simps]
def cosimplicial_object.augmented.left_op_right_op_iso (X : cosimplicial_object.augmented Cᵒᵖ) :
X.left_op.right_op ≅ X :=
comma.iso_mk (eq_to_iso $ by simp) X.right.left_op_right_op_iso (by tidy)
variable (C)
/-- A functorial version of `simplicial_object.augmented.right_op`. -/
@[simps]
def simplicial_to_cosimplicial_augmented :
(simplicial_object.augmented C)ᵒᵖ ⥤ cosimplicial_object.augmented Cᵒᵖ :=
{ obj := λ X, X.unop.right_op,
map := λ X Y f,
{ left := f.unop.right.op,
right := f.unop.left.right_op,
w' := begin
ext x,
dsimp,
simp_rw ← op_comp,
congr' 1,
exact (congr_app f.unop.w (op x)).symm,
end } }
/-- A functorial version of `cosimplicial_object.augmented.left_op`. -/
@[simps]
def cosimplicial_to_simplicial_augmented :
cosimplicial_object.augmented Cᵒᵖ ⥤ (simplicial_object.augmented C)ᵒᵖ :=
{ obj := λ X, opposite.op X.left_op,
map := λ X Y f, quiver.hom.op $
{ left := f.right.left_op,
right := f.left.unop,
w' := begin
ext x,
dsimp,
simp_rw ← unop_comp,
congr' 1,
exact (congr_app f.w x.unop).symm,
end} }
/-- The contravariant categorical equivalence between augmented simplicial
objects and augmented cosimplicial objects in the opposite category. -/
@[simps functor inverse]
def simplicial_cosimplicial_augmented_equiv :
(simplicial_object.augmented C)ᵒᵖ ≌ cosimplicial_object.augmented Cᵒᵖ :=
equivalence.mk
(simplicial_to_cosimplicial_augmented _)
(cosimplicial_to_simplicial_augmented _)
(nat_iso.of_components (λ X, X.unop.right_op_left_op_iso.op) $ λ X Y f,
by { dsimp, rw ←f.op_unop, simp_rw ← op_comp, congr' 1, tidy })
(nat_iso.of_components (λ X, X.left_op_right_op_iso) $ by tidy)
end category_theory
|
99c6cc52afbc802e8708ed8c2f71d2d8205a638c | f2bd3e4fa52fd93f908a6931e81ce3febc0c115e | /.config | 3737124b6ee2d7a54439c8cfe03e0bfdad452abc | [
"MIT"
] | permissive | XDD-Sp/MT1300 | 66fff2e45606db348b1ee04205ae1cd96d801f26 | ae45637a3c907c49ee745e90e0d5d910e3cb3880 | refs/heads/main | 1,693,850,977,035 | 1,634,387,675,000 | 1,634,387,675,000 | 417,819,436 | 0 | 0 | MIT | 1,634,386,755,000 | 1,634,386,754,000 | null | UTF-8 | Lean | false | false | 266,817 | config | # 2021-10-10 ssr plus, passwall
# Automatically generated file; DO NOT EDIT.
# OpenWrt Configuration
#
CONFIG_MODULES=y
CONFIG_HAVE_DOT_CONFIG=y
# CONFIG_TARGET_sunxi is not set
# CONFIG_TARGET_apm821xx is not set
# CONFIG_TARGET_ath25 is not set
# CONFIG_TARGET_ath79 is not set
# CONFIG_TARGET_bcm27xx is not set
# CONFIG_TARGET_bcm53xx is not set
# CONFIG_TARGET_bcm47xx is not set
# CONFIG_TARGET_bcm4908 is not set
# CONFIG_TARGET_bcm63xx is not set
# CONFIG_TARGET_bmips is not set
# CONFIG_TARGET_octeon is not set
# CONFIG_TARGET_gemini is not set
# CONFIG_TARGET_mpc85xx is not set
# CONFIG_TARGET_mxs is not set
# CONFIG_TARGET_lantiq is not set
# CONFIG_TARGET_malta is not set
# CONFIG_TARGET_pistachio is not set
# CONFIG_TARGET_mvebu is not set
# CONFIG_TARGET_kirkwood is not set
# CONFIG_TARGET_mediatek is not set
CONFIG_TARGET_ramips=y
# CONFIG_TARGET_at91 is not set
# CONFIG_TARGET_tegra is not set
# CONFIG_TARGET_layerscape is not set
# CONFIG_TARGET_imx6 is not set
# CONFIG_TARGET_octeontx is not set
# CONFIG_TARGET_oxnas is not set
# CONFIG_TARGET_armvirt is not set
# CONFIG_TARGET_ipq40xx is not set
# CONFIG_TARGET_ipq806x is not set
# CONFIG_TARGET_ipq807x is not set
# CONFIG_TARGET_realtek is not set
# CONFIG_TARGET_rockchip is not set
# CONFIG_TARGET_arc770 is not set
# CONFIG_TARGET_archs38 is not set
# CONFIG_TARGET_omap is not set
# CONFIG_TARGET_uml is not set
# CONFIG_TARGET_zynq is not set
# CONFIG_TARGET_x86 is not set
# CONFIG_TARGET_ramips_mt7620 is not set
CONFIG_TARGET_ramips_mt7621=y
# CONFIG_TARGET_ramips_mt76x8 is not set
# CONFIG_TARGET_ramips_rt288x is not set
# CONFIG_TARGET_ramips_rt305x is not set
# CONFIG_TARGET_ramips_rt3883 is not set
# CONFIG_TARGET_MULTI_PROFILE is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_adslr_g7 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_afoundry_ew1200 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_alfa-network_quad-e4g is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_ampedwireless_ally-r1900k is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_ampedwireless_ally-00x19k is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_asiarf_ap7621-001 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_asiarf_ap7621-nv1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_asus_rt-ac57u is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_asus_rt-ac65p is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_asus_rt-ac85p is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_asus_rt-n56u-b1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_buffalo_wsr-1166dhp is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_buffalo_wsr-2533dhpl is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_buffalo_wsr-600dhp is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_cudy_wr1300 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_cudy_wr2100 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-1960-a1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-2640-a1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-2660-a1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-853-a3 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-853-r1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-860l-b1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-867-a1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-878-a1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-882-a1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dir-882-r1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_d-team_newifi-d2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_d-team_pbr-m1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_edimax_ra21s is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_edimax_re23s is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_edimax_rg21s is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-1167ghbk2-s is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-1167gs2-b is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-1167gst2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-1750gs is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-1750gst2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-1750gsv is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-1900gst is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-2533ghbk-i is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-2533gst is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-2533gst2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_firefly_firewrt is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_gehua_ghl-r-001 is not set
CONFIG_TARGET_ramips_mt7621_DEVICE_glinet_gl-mt1300=y
# CONFIG_TARGET_ramips_mt7621_DEVICE_gnubee_gb-pc1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_gnubee_gb-pc2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_hiwifi_hc5962 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iodata_wn-ax1167gr is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iodata_wn-ax1167gr2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iodata_wn-ax2033gr is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iodata_wn-dx1167r is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iodata_wn-dx1200gr is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iodata_wn-gx300gr is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iodata_wnpr2600g is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iptime_a6ns-m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iptime_a8004t is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_jcg_jhr-ac876m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_jcg_q20 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_jcg_y2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_lenovo_newifi-d1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_e5600 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_ea7300-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_ea7300-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_ea7500-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_ea8100-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_ea8100-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_re6500 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mediatek_ap-mt7621a-v60 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mediatek_mt7621-eval-board is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mikrotik_routerboard-750gr3 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mikrotik_routerboard-760igs is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mikrotik_routerboard-m11g is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mikrotik_routerboard-m33g is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mqmaker_witi is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mtc_wr1201 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_ex6150 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_r6220 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_r6260 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_r6350 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_r6700-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_r6800 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_r6850 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_wac104 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_wac124 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_wndr3700-v5 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netis_wf2881 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_phicomm_k2p is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_planex_vr500 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_samknows_whitebox-v8 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_sercomm_na502 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_storylink_sap-g3200u3 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_telco-electronics_x1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tenbay_t-mb5eu-v01 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_thunder_timecloud is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_totolink_a7000r is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_totolink_x5000r is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_archer-a6-v3 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_archer-c6-v3 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_archer-c6u-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_eap235-wall-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_re350-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_re500-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_re650-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_ubnt_edgerouter-x is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_ubnt_edgerouter-x-sfp is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_ubnt_unifi-6-lite is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_ubnt_unifi-nanohd is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_unielec_u7621-01-16m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_unielec_u7621-06-16m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_unielec_u7621-06-64m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_wavlink_wl-wn531a6 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_wevo_11acnas is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_wevo_w2914ns-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_winstars_ws-wn583a6 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-3g is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-3g-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-3-pro is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-4 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-4a-gigabit is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-ac2100 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-cr660x is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_redmi-router-ac2100 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaoyu_xy-c5 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xzwifi_creativebox-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_youhua_wr1200js is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_youku_yk-l2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_zbtlink_zbt-we1326 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_zbtlink_zbt-we3526 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_zbtlink_zbt-wg2626 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_zbtlink_zbt-wg3526-16m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_zbtlink_zbt-wg3526-32m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_zio_freezio is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_zyxel_nr7101 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_zyxel_wap6805 is not set
CONFIG_HAS_SUBTARGETS=y
CONFIG_HAS_DEVICES=y
CONFIG_TARGET_BOARD="ramips"
CONFIG_TARGET_SUBTARGET="mt7621"
CONFIG_TARGET_PROFILE="DEVICE_glinet_gl-mt1300"
CONFIG_TARGET_ARCH_PACKAGES="mipsel_24kc"
CONFIG_DEFAULT_TARGET_OPTIMIZATION="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc"
CONFIG_CPU_TYPE="24kc"
CONFIG_LINUX_5_4=y
CONFIG_DEFAULT_base-files=y
CONFIG_DEFAULT_block-mount=y
CONFIG_DEFAULT_busybox=y
CONFIG_DEFAULT_coremark=y
CONFIG_DEFAULT_ddns-scripts_aliyun=y
CONFIG_DEFAULT_ddns-scripts_dnspod=y
CONFIG_DEFAULT_default-settings=y
CONFIG_DEFAULT_dnsmasq-full=y
CONFIG_DEFAULT_dropbear=y
CONFIG_DEFAULT_firewall=y
CONFIG_DEFAULT_fstools=y
CONFIG_DEFAULT_iptables=y
CONFIG_DEFAULT_iwinfo=y
CONFIG_DEFAULT_kmod-crypto-hw-eip93=y
CONFIG_DEFAULT_kmod-gpio-button-hotplug=y
CONFIG_DEFAULT_kmod-ipt-raw=y
CONFIG_DEFAULT_kmod-leds-gpio=y
CONFIG_DEFAULT_kmod-mt7615d_dbdc=y
CONFIG_DEFAULT_kmod-nf-nathelper=y
CONFIG_DEFAULT_kmod-nf-nathelper-extra=y
CONFIG_DEFAULT_kmod-usb3=y
CONFIG_DEFAULT_libc=y
CONFIG_DEFAULT_libgcc=y
CONFIG_DEFAULT_libustream-openssl=y
CONFIG_DEFAULT_logd=y
CONFIG_DEFAULT_luci=y
CONFIG_DEFAULT_luci-app-accesscontrol=y
CONFIG_DEFAULT_luci-app-arpbind=y
CONFIG_DEFAULT_luci-app-autoreboot=y
CONFIG_DEFAULT_luci-app-ddns=y
CONFIG_DEFAULT_luci-app-filetransfer=y
CONFIG_DEFAULT_luci-app-nlbwmon=y
CONFIG_DEFAULT_luci-app-ramfree=y
CONFIG_DEFAULT_luci-app-ssr-plus=y
CONFIG_DEFAULT_luci-app-turboacc=y
CONFIG_DEFAULT_luci-app-unblockmusic=y
CONFIG_DEFAULT_luci-app-upnp=y
CONFIG_DEFAULT_luci-app-vlmcsd=y
CONFIG_DEFAULT_luci-app-vsftpd=y
CONFIG_DEFAULT_luci-app-wol=y
CONFIG_DEFAULT_mtd=y
CONFIG_DEFAULT_netifd=y
CONFIG_DEFAULT_opkg=y
CONFIG_DEFAULT_ppp=y
CONFIG_DEFAULT_ppp-mod-pppoe=y
CONFIG_DEFAULT_procd=y
CONFIG_DEFAULT_swconfig=y
CONFIG_DEFAULT_uci=y
CONFIG_DEFAULT_uclient-fetch=y
CONFIG_DEFAULT_urandom-seed=y
CONFIG_HAS_TESTING_KERNEL=y
CONFIG_AUDIO_SUPPORT=y
CONFIG_GPIO_SUPPORT=y
CONFIG_PCI_SUPPORT=y
CONFIG_USB_SUPPORT=y
CONFIG_RTC_SUPPORT=y
CONFIG_USES_DEVICETREE=y
CONFIG_USES_INITRAMFS=y
CONFIG_USES_SQUASHFS=y
CONFIG_USES_MINOR=y
CONFIG_HAS_MIPS16=y
CONFIG_NAND_SUPPORT=y
CONFIG_mipsel=y
CONFIG_ARCH="mipsel"
#
# Target Images
#
CONFIG_TARGET_ROOTFS_INITRAMFS=y
# CONFIG_TARGET_INITRAMFS_COMPRESSION_NONE is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2 is not set
CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA=y
# CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_LZ4 is not set
# CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ is not set
CONFIG_EXTERNAL_CPIO=""
# CONFIG_TARGET_INITRAMFS_FORCE is not set
#
# Root filesystem archives
#
# CONFIG_TARGET_ROOTFS_CPIOGZ is not set
# CONFIG_TARGET_ROOTFS_TARGZ is not set
#
# Root filesystem images
#
# CONFIG_TARGET_ROOTFS_EXT4FS is not set
CONFIG_TARGET_ROOTFS_SQUASHFS=y
CONFIG_TARGET_SQUASHFS_BLOCK_SIZE=1024
CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP=y
CONFIG_TARGET_UBIFS_JOURNAL_SIZE=""
#
# Image Options
#
# end of Target Images
# CONFIG_EXPERIMENTAL is not set
#
# Global build settings
#
# CONFIG_JSON_OVERVIEW_IMAGE_INFO is not set
# CONFIG_ALL_NONSHARED is not set
# CONFIG_ALL_KMODS is not set
# CONFIG_ALL is not set
# CONFIG_BUILDBOT is not set
CONFIG_SIGNED_PACKAGES=y
CONFIG_SIGNATURE_CHECK=y
#
# General build options
#
# CONFIG_TESTING_KERNEL is not set
# CONFIG_DISPLAY_SUPPORT is not set
# CONFIG_BUILD_PATENTED is not set
# CONFIG_BUILD_NLS is not set
CONFIG_SHADOW_PASSWORDS=y
# CONFIG_CLEAN_IPKG is not set
# CONFIG_IPK_FILES_CHECKSUMS is not set
# CONFIG_INCLUDE_CONFIG is not set
# CONFIG_REPRODUCIBLE_DEBUG_INFO is not set
# CONFIG_COLLECT_KERNEL_DEBUG is not set
#
# Kernel build options
#
CONFIG_KERNEL_BUILD_USER=""
CONFIG_KERNEL_BUILD_DOMAIN=""
CONFIG_KERNEL_PRINTK=y
CONFIG_KERNEL_CRASHLOG=y
CONFIG_KERNEL_SWAP=y
# CONFIG_KERNEL_PROC_STRIPPED is not set
CONFIG_KERNEL_DEBUG_FS=y
CONFIG_KERNEL_MIPS_FP_SUPPORT=y
# CONFIG_KERNEL_PERF_EVENTS is not set
# CONFIG_KERNEL_PROFILING is not set
# CONFIG_KERNEL_UBSAN is not set
# CONFIG_KERNEL_KCOV is not set
# CONFIG_KERNEL_TASKSTATS is not set
CONFIG_KERNEL_KALLSYMS=y
# CONFIG_KERNEL_FTRACE is not set
CONFIG_KERNEL_DEBUG_KERNEL=y
CONFIG_KERNEL_DEBUG_INFO=y
# CONFIG_KERNEL_DYNAMIC_DEBUG is not set
# CONFIG_KERNEL_KPROBES is not set
CONFIG_KERNEL_AIO=y
CONFIG_KERNEL_IO_URING=y
CONFIG_KERNEL_FHANDLE=y
CONFIG_KERNEL_FANOTIFY=y
# CONFIG_KERNEL_BLK_DEV_BSG is not set
# CONFIG_KERNEL_HUGETLB_PAGE is not set
CONFIG_KERNEL_MAGIC_SYSRQ=y
# CONFIG_KERNEL_DEBUG_PINCTRL is not set
# CONFIG_KERNEL_DEBUG_GPIO is not set
CONFIG_KERNEL_COREDUMP=y
CONFIG_KERNEL_ELF_CORE=y
# CONFIG_KERNEL_PROVE_LOCKING is not set
# CONFIG_KERNEL_LOCKUP_DETECTOR is not set
# CONFIG_KERNEL_DETECT_HUNG_TASK is not set
# CONFIG_KERNEL_WQ_WATCHDOG is not set
# CONFIG_KERNEL_DEBUG_ATOMIC_SLEEP is not set
# CONFIG_KERNEL_DEBUG_VM is not set
CONFIG_KERNEL_PRINTK_TIME=y
# CONFIG_KERNEL_SLABINFO is not set
# CONFIG_KERNEL_PROC_PAGE_MONITOR is not set
# CONFIG_KERNEL_KEXEC is not set
# CONFIG_USE_RFKILL is not set
# CONFIG_USE_SPARSE is not set
# CONFIG_KERNEL_DEVTMPFS is not set
CONFIG_KERNEL_KEYS=y
# CONFIG_KERNEL_PERSISTENT_KEYRINGS is not set
# CONFIG_KERNEL_KEYS_REQUEST_CACHE is not set
# CONFIG_KERNEL_BIG_KEYS is not set
CONFIG_KERNEL_CGROUPS=y
# CONFIG_KERNEL_CGROUP_DEBUG is not set
CONFIG_KERNEL_FREEZER=y
# CONFIG_KERNEL_CGROUP_FREEZER is not set
# CONFIG_KERNEL_CGROUP_DEVICE is not set
# CONFIG_KERNEL_CGROUP_HUGETLB is not set
CONFIG_KERNEL_CGROUP_PIDS=y
CONFIG_KERNEL_CGROUP_RDMA=y
CONFIG_KERNEL_CGROUP_BPF=y
CONFIG_KERNEL_CPUSETS=y
# CONFIG_KERNEL_PROC_PID_CPUSET is not set
CONFIG_KERNEL_CGROUP_CPUACCT=y
CONFIG_KERNEL_RESOURCE_COUNTERS=y
CONFIG_KERNEL_MM_OWNER=y
CONFIG_KERNEL_MEMCG=y
CONFIG_KERNEL_MEMCG_SWAP=y
# CONFIG_KERNEL_MEMCG_SWAP_ENABLED is not set
CONFIG_KERNEL_MEMCG_KMEM=y
# CONFIG_KERNEL_CGROUP_PERF is not set
CONFIG_KERNEL_CGROUP_SCHED=y
CONFIG_KERNEL_FAIR_GROUP_SCHED=y
CONFIG_KERNEL_CFS_BANDWIDTH=y
CONFIG_KERNEL_RT_GROUP_SCHED=y
CONFIG_KERNEL_BLK_CGROUP=y
# CONFIG_KERNEL_CFQ_GROUP_IOSCHED is not set
CONFIG_KERNEL_BLK_DEV_THROTTLING=y
# CONFIG_KERNEL_BLK_DEV_THROTTLING_LOW is not set
# CONFIG_KERNEL_DEBUG_BLK_CGROUP is not set
# CONFIG_KERNEL_NET_CLS_CGROUP is not set
# CONFIG_KERNEL_CGROUP_NET_CLASSID is not set
# CONFIG_KERNEL_CGROUP_NET_PRIO is not set
CONFIG_KERNEL_NAMESPACES=y
CONFIG_KERNEL_UTS_NS=y
CONFIG_KERNEL_IPC_NS=y
CONFIG_KERNEL_USER_NS=y
CONFIG_KERNEL_PID_NS=y
CONFIG_KERNEL_NET_NS=y
CONFIG_KERNEL_DEVPTS_MULTIPLE_INSTANCES=y
CONFIG_KERNEL_POSIX_MQUEUE=y
CONFIG_KERNEL_SECCOMP_FILTER=y
CONFIG_KERNEL_SECCOMP=y
CONFIG_KERNEL_IP_MROUTE=y
CONFIG_KERNEL_IPV6=y
CONFIG_KERNEL_IPV6_MULTIPLE_TABLES=y
CONFIG_KERNEL_IPV6_SUBTREES=y
CONFIG_KERNEL_IPV6_MROUTE=y
# CONFIG_KERNEL_IPV6_PIMSM_V2 is not set
CONFIG_KERNEL_IPV6_SEG6_LWTUNNEL=y
# CONFIG_KERNEL_LWTUNNEL_BPF is not set
# CONFIG_KERNEL_IP_PNP is not set
#
# Filesystem ACL and attr support options
#
# CONFIG_USE_FS_ACL_ATTR is not set
# CONFIG_KERNEL_FS_POSIX_ACL is not set
# CONFIG_KERNEL_BTRFS_FS_POSIX_ACL is not set
# CONFIG_KERNEL_EXT4_FS_POSIX_ACL is not set
# CONFIG_KERNEL_F2FS_FS_POSIX_ACL is not set
# CONFIG_KERNEL_JFFS2_FS_POSIX_ACL is not set
# CONFIG_KERNEL_TMPFS_POSIX_ACL is not set
# CONFIG_KERNEL_CIFS_ACL is not set
# CONFIG_KERNEL_HFS_FS_POSIX_ACL is not set
# CONFIG_KERNEL_HFSPLUS_FS_POSIX_ACL is not set
# CONFIG_KERNEL_NFS_ACL_SUPPORT is not set
# CONFIG_KERNEL_NFS_V3_ACL_SUPPORT is not set
# CONFIG_KERNEL_NFSD_V2_ACL_SUPPORT is not set
# CONFIG_KERNEL_NFSD_V3_ACL_SUPPORT is not set
# CONFIG_KERNEL_REISER_FS_POSIX_ACL is not set
# CONFIG_KERNEL_XFS_POSIX_ACL is not set
# CONFIG_KERNEL_JFS_POSIX_ACL is not set
# end of Filesystem ACL and attr support options
# CONFIG_KERNEL_DEVMEM is not set
# CONFIG_KERNEL_DEVKMEM is not set
CONFIG_KERNEL_SQUASHFS_FRAGMENT_CACHE_SIZE=3
# CONFIG_KERNEL_SQUASHFS_XATTR is not set
CONFIG_KERNEL_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_KERNEL_CC_OPTIMIZE_FOR_SIZE is not set
# CONFIG_KERNEL_AUDIT is not set
# CONFIG_KERNEL_SECURITY is not set
# CONFIG_KERNEL_SECURITY_NETWORK is not set
# CONFIG_KERNEL_SECURITY_SELINUX is not set
# CONFIG_KERNEL_EXT4_FS_SECURITY is not set
# CONFIG_KERNEL_F2FS_FS_SECURITY is not set
# CONFIG_KERNEL_UBIFS_FS_SECURITY is not set
# CONFIG_KERNEL_JFFS2_FS_SECURITY is not set
# end of Kernel build options
#
# Package build options
#
# CONFIG_DEBUG is not set
CONFIG_IPV6=y
#
# Stripping options
#
# CONFIG_NO_STRIP is not set
# CONFIG_USE_STRIP is not set
CONFIG_USE_SSTRIP=y
CONFIG_SSTRIP_ARGS="-z"
# CONFIG_STRIP_KERNEL_EXPORTS is not set
# CONFIG_USE_MKLIBS is not set
CONFIG_USE_UCLIBCXX=y
# CONFIG_USE_LIBSTDCXX is not set
#
# Hardening build options
#
CONFIG_PKG_CHECK_FORMAT_SECURITY=y
# CONFIG_PKG_ASLR_PIE_NONE is not set
CONFIG_PKG_ASLR_PIE_REGULAR=y
# CONFIG_PKG_ASLR_PIE_ALL is not set
# CONFIG_PKG_CC_STACKPROTECTOR_NONE is not set
CONFIG_PKG_CC_STACKPROTECTOR_REGULAR=y
# CONFIG_PKG_CC_STACKPROTECTOR_STRONG is not set
# CONFIG_KERNEL_CC_STACKPROTECTOR_NONE is not set
CONFIG_KERNEL_CC_STACKPROTECTOR_REGULAR=y
# CONFIG_KERNEL_CC_STACKPROTECTOR_STRONG is not set
CONFIG_KERNEL_STACKPROTECTOR=y
# CONFIG_KERNEL_STACKPROTECTOR_STRONG is not set
# CONFIG_PKG_FORTIFY_SOURCE_NONE is not set
CONFIG_PKG_FORTIFY_SOURCE_1=y
# CONFIG_PKG_FORTIFY_SOURCE_2 is not set
# CONFIG_PKG_RELRO_NONE is not set
# CONFIG_PKG_RELRO_PARTIAL is not set
CONFIG_PKG_RELRO_FULL=y
# CONFIG_SELINUX is not set
# end of Global build settings
# CONFIG_DEVEL is not set
# CONFIG_BROKEN is not set
CONFIG_BINARY_FOLDER=""
CONFIG_DOWNLOAD_FOLDER=""
CONFIG_LOCALMIRROR=""
CONFIG_AUTOREBUILD=y
# CONFIG_AUTOREMOVE is not set
CONFIG_BUILD_SUFFIX=""
CONFIG_TARGET_ROOTFS_DIR=""
# CONFIG_CCACHE is not set
CONFIG_CCACHE_DIR=""
CONFIG_EXTERNAL_KERNEL_TREE=""
CONFIG_KERNEL_GIT_CLONE_URI=""
CONFIG_BUILD_LOG_DIR=""
CONFIG_EXTRA_OPTIMIZATION="-fno-caller-saves -fno-plt"
CONFIG_TARGET_OPTIMIZATION="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc"
CONFIG_SOFT_FLOAT=y
CONFIG_USE_MIPS16=y
# CONFIG_EXTRA_TARGET_ARCH is not set
CONFIG_EXTRA_BINUTILS_CONFIG_OPTIONS=""
CONFIG_EXTRA_GCC_CONFIG_OPTIONS=""
# CONFIG_GCC_DEFAULT_PIE is not set
# CONFIG_GCC_DEFAULT_SSP is not set
# CONFIG_SJLJ_EXCEPTIONS is not set
# CONFIG_INSTALL_GFORTRAN is not set
CONFIG_GDB=y
# CONFIG_GDB_PYTHON is not set
CONFIG_USE_MUSL=y
CONFIG_SSP_SUPPORT=y
CONFIG_BINUTILS_VERSION_2_34=y
CONFIG_BINUTILS_VERSION="2.34"
CONFIG_GCC_VERSION="8.4.0"
# CONFIG_GCC_USE_IREMAP is not set
CONFIG_LIBC="musl"
CONFIG_TARGET_SUFFIX="musl"
# CONFIG_IB is not set
# CONFIG_SDK is not set
# CONFIG_MAKE_TOOLCHAIN is not set
# CONFIG_IMAGEOPT is not set
# CONFIG_PREINITOPT is not set
CONFIG_TARGET_PREINIT_SUPPRESS_STDERR=y
# CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE is not set
CONFIG_TARGET_PREINIT_TIMEOUT=2
# CONFIG_TARGET_PREINIT_SHOW_NETMSG is not set
# CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG is not set
CONFIG_TARGET_PREINIT_IFNAME=""
CONFIG_TARGET_PREINIT_IP="192.168.1.1"
CONFIG_TARGET_PREINIT_NETMASK="255.255.255.0"
CONFIG_TARGET_PREINIT_BROADCAST="192.168.1.255"
# CONFIG_INITOPT is not set
CONFIG_TARGET_INIT_PATH="/usr/sbin:/usr/bin:/sbin:/bin"
CONFIG_TARGET_INIT_ENV=""
CONFIG_TARGET_INIT_CMD="/sbin/init"
CONFIG_TARGET_INIT_SUPPRESS_STDERR=y
# CONFIG_VERSIONOPT is not set
CONFIG_PER_FEED_REPO=y
CONFIG_FEED_packages=y
CONFIG_FEED_luci=y
CONFIG_FEED_routing=y
CONFIG_FEED_telephony=y
#
# Base system
#
# CONFIG_PACKAGE_attendedsysupgrade-common is not set
# CONFIG_PACKAGE_auc is not set
CONFIG_PACKAGE_base-files=y
CONFIG_PACKAGE_block-mount=y
# CONFIG_PACKAGE_blockd is not set
# CONFIG_PACKAGE_bridge is not set
CONFIG_PACKAGE_busybox=y
# CONFIG_BUSYBOX_CUSTOM is not set
CONFIG_BUSYBOX_DEFAULT_HAVE_DOT_CONFIG=y
# CONFIG_BUSYBOX_DEFAULT_DESKTOP is not set
# CONFIG_BUSYBOX_DEFAULT_EXTRA_COMPAT is not set
# CONFIG_BUSYBOX_DEFAULT_FEDORA_COMPAT is not set
CONFIG_BUSYBOX_DEFAULT_INCLUDE_SUSv2=y
CONFIG_BUSYBOX_DEFAULT_LONG_OPTS=y
CONFIG_BUSYBOX_DEFAULT_SHOW_USAGE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VERBOSE_USAGE=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_COMPRESS_USAGE is not set
CONFIG_BUSYBOX_DEFAULT_LFS=y
# CONFIG_BUSYBOX_DEFAULT_PAM is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_DEVPTS=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UTMP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WTMP is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_PIDFILE=y
CONFIG_BUSYBOX_DEFAULT_PID_FILE_PATH="/var/run"
# CONFIG_BUSYBOX_DEFAULT_BUSYBOX is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SHOW_SCRIPT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INSTALLER is not set
# CONFIG_BUSYBOX_DEFAULT_INSTALL_NO_USR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SUID is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SUID_CONFIG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SUID_CONFIG_QUIET is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_PREFER_APPLETS=y
CONFIG_BUSYBOX_DEFAULT_BUSYBOX_EXEC_PATH="/proc/self/exe"
# CONFIG_BUSYBOX_DEFAULT_SELINUX is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CLEAN_UP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SYSLOG_INFO is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_SYSLOG=y
# CONFIG_BUSYBOX_DEFAULT_STATIC is not set
# CONFIG_BUSYBOX_DEFAULT_PIE is not set
# CONFIG_BUSYBOX_DEFAULT_NOMMU is not set
# CONFIG_BUSYBOX_DEFAULT_BUILD_LIBBUSYBOX is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LIBBUSYBOX_STATIC is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INDIVIDUAL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SHARED_BUSYBOX is not set
CONFIG_BUSYBOX_DEFAULT_CROSS_COMPILER_PREFIX=""
CONFIG_BUSYBOX_DEFAULT_SYSROOT=""
CONFIG_BUSYBOX_DEFAULT_EXTRA_CFLAGS=""
CONFIG_BUSYBOX_DEFAULT_EXTRA_LDFLAGS=""
CONFIG_BUSYBOX_DEFAULT_EXTRA_LDLIBS=""
# CONFIG_BUSYBOX_DEFAULT_USE_PORTABLE_CODE is not set
# CONFIG_BUSYBOX_DEFAULT_STACK_OPTIMIZATION_386 is not set
# CONFIG_BUSYBOX_DEFAULT_STATIC_LIBGCC is not set
CONFIG_BUSYBOX_DEFAULT_INSTALL_APPLET_SYMLINKS=y
# CONFIG_BUSYBOX_DEFAULT_INSTALL_APPLET_HARDLINKS is not set
# CONFIG_BUSYBOX_DEFAULT_INSTALL_APPLET_SCRIPT_WRAPPERS is not set
# CONFIG_BUSYBOX_DEFAULT_INSTALL_APPLET_DONT is not set
# CONFIG_BUSYBOX_DEFAULT_INSTALL_SH_APPLET_SYMLINK is not set
# CONFIG_BUSYBOX_DEFAULT_INSTALL_SH_APPLET_HARDLINK is not set
# CONFIG_BUSYBOX_DEFAULT_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set
CONFIG_BUSYBOX_DEFAULT_PREFIX="./_install"
# CONFIG_BUSYBOX_DEFAULT_DEBUG is not set
# CONFIG_BUSYBOX_DEFAULT_DEBUG_PESSIMIZE is not set
# CONFIG_BUSYBOX_DEFAULT_DEBUG_SANITIZE is not set
# CONFIG_BUSYBOX_DEFAULT_UNIT_TEST is not set
# CONFIG_BUSYBOX_DEFAULT_WERROR is not set
# CONFIG_BUSYBOX_DEFAULT_WARN_SIMPLE_MSG is not set
CONFIG_BUSYBOX_DEFAULT_NO_DEBUG_LIB=y
# CONFIG_BUSYBOX_DEFAULT_DMALLOC is not set
# CONFIG_BUSYBOX_DEFAULT_EFENCE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_USE_BSS_TAIL is not set
# CONFIG_BUSYBOX_DEFAULT_FLOAT_DURATION is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_RTMINMAX is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_BUFFERS_USE_MALLOC is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_BUFFERS_GO_ON_STACK=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_BUFFERS_GO_IN_BSS is not set
CONFIG_BUSYBOX_DEFAULT_PASSWORD_MINLEN=6
CONFIG_BUSYBOX_DEFAULT_MD5_SMALL=1
CONFIG_BUSYBOX_DEFAULT_SHA3_SMALL=1
CONFIG_BUSYBOX_DEFAULT_FEATURE_FAST_TOP=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING_MAX_LEN=512
# CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING_VI is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING_HISTORY=256
# CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING_SAVEHISTORY is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING_SAVE_ON_EXIT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_REVERSE_SEARCH is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_TAB_COMPLETION=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_USERNAME_COMPLETION is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING_FANCY_PROMPT=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING_WINCH is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_EDITING_ASK_TERMINAL is not set
# CONFIG_BUSYBOX_DEFAULT_LOCALE_SUPPORT is not set
# CONFIG_BUSYBOX_DEFAULT_UNICODE_SUPPORT is not set
# CONFIG_BUSYBOX_DEFAULT_UNICODE_USING_LOCALE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHECK_UNICODE_IN_ENV is not set
CONFIG_BUSYBOX_DEFAULT_SUBST_WCHAR=0
CONFIG_BUSYBOX_DEFAULT_LAST_SUPPORTED_WCHAR=0
# CONFIG_BUSYBOX_DEFAULT_UNICODE_COMBINING_WCHARS is not set
# CONFIG_BUSYBOX_DEFAULT_UNICODE_WIDE_WCHARS is not set
# CONFIG_BUSYBOX_DEFAULT_UNICODE_BIDI_SUPPORT is not set
# CONFIG_BUSYBOX_DEFAULT_UNICODE_NEUTRAL_TABLE is not set
# CONFIG_BUSYBOX_DEFAULT_UNICODE_PRESERVE_BROKEN is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB=4
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS is not set
CONFIG_BUSYBOX_DEFAULT_MONOTONIC_SYSCALL=y
CONFIG_BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HWIB is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SEAMLESS_XZ is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SEAMLESS_LZMA is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SEAMLESS_BZ2 is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_SEAMLESS_GZ=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SEAMLESS_Z is not set
# CONFIG_BUSYBOX_DEFAULT_AR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_AR_LONG_FILENAMES is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_AR_CREATE is not set
# CONFIG_BUSYBOX_DEFAULT_UNCOMPRESS is not set
CONFIG_BUSYBOX_DEFAULT_GUNZIP=y
CONFIG_BUSYBOX_DEFAULT_ZCAT=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_GUNZIP_LONG_OPTIONS is not set
CONFIG_BUSYBOX_DEFAULT_BUNZIP2=y
CONFIG_BUSYBOX_DEFAULT_BZCAT=y
# CONFIG_BUSYBOX_DEFAULT_UNLZMA is not set
# CONFIG_BUSYBOX_DEFAULT_LZCAT is not set
# CONFIG_BUSYBOX_DEFAULT_LZMA is not set
# CONFIG_BUSYBOX_DEFAULT_UNXZ is not set
# CONFIG_BUSYBOX_DEFAULT_XZCAT is not set
# CONFIG_BUSYBOX_DEFAULT_XZ is not set
# CONFIG_BUSYBOX_DEFAULT_BZIP2 is not set
CONFIG_BUSYBOX_DEFAULT_BZIP2_SMALL=0
CONFIG_BUSYBOX_DEFAULT_FEATURE_BZIP2_DECOMPRESS=y
# CONFIG_BUSYBOX_DEFAULT_CPIO is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CPIO_O is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CPIO_P is not set
# CONFIG_BUSYBOX_DEFAULT_DPKG is not set
# CONFIG_BUSYBOX_DEFAULT_DPKG_DEB is not set
CONFIG_BUSYBOX_DEFAULT_GZIP=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_GZIP_LONG_OPTIONS is not set
CONFIG_BUSYBOX_DEFAULT_GZIP_FAST=0
# CONFIG_BUSYBOX_DEFAULT_FEATURE_GZIP_LEVELS is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_GZIP_DECOMPRESS=y
# CONFIG_BUSYBOX_DEFAULT_LZOP is not set
# CONFIG_BUSYBOX_DEFAULT_UNLZOP is not set
# CONFIG_BUSYBOX_DEFAULT_LZOPCAT is not set
# CONFIG_BUSYBOX_DEFAULT_LZOP_COMPR_HIGH is not set
# CONFIG_BUSYBOX_DEFAULT_RPM is not set
# CONFIG_BUSYBOX_DEFAULT_RPM2CPIO is not set
CONFIG_BUSYBOX_DEFAULT_TAR=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_LONG_OPTIONS is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_CREATE=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_AUTODETECT is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_FROM=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_OLDGNU_COMPATIBILITY is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_OLDSUN_COMPATIBILITY is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_GNU_EXTENSIONS=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_TO_COMMAND is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_UNAME_GNAME is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_NOPRESERVE_TIME is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TAR_SELINUX is not set
# CONFIG_BUSYBOX_DEFAULT_UNZIP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UNZIP_CDF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UNZIP_BZIP2 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UNZIP_LZMA is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UNZIP_XZ is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LZMA_FAST is not set
CONFIG_BUSYBOX_DEFAULT_BASENAME=y
CONFIG_BUSYBOX_DEFAULT_CAT=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CATN is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CATV is not set
CONFIG_BUSYBOX_DEFAULT_CHGRP=y
CONFIG_BUSYBOX_DEFAULT_CHMOD=y
CONFIG_BUSYBOX_DEFAULT_CHOWN=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHOWN_LONG_OPTIONS is not set
CONFIG_BUSYBOX_DEFAULT_CHROOT=y
# CONFIG_BUSYBOX_DEFAULT_CKSUM is not set
# CONFIG_BUSYBOX_DEFAULT_COMM is not set
CONFIG_BUSYBOX_DEFAULT_CP=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CP_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CP_REFLINK is not set
CONFIG_BUSYBOX_DEFAULT_CUT=y
CONFIG_BUSYBOX_DEFAULT_DATE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_DATE_ISOFMT=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DATE_NANO is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DATE_COMPAT is not set
CONFIG_BUSYBOX_DEFAULT_DD=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_DD_SIGNAL_HANDLING=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DD_THIRD_STATUS_LINE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_DD_IBS_OBS=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DD_STATUS is not set
CONFIG_BUSYBOX_DEFAULT_DF=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DF_FANCY is not set
CONFIG_BUSYBOX_DEFAULT_DIRNAME=y
# CONFIG_BUSYBOX_DEFAULT_DOS2UNIX is not set
# CONFIG_BUSYBOX_DEFAULT_UNIX2DOS is not set
CONFIG_BUSYBOX_DEFAULT_DU=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y
CONFIG_BUSYBOX_DEFAULT_ECHO=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FANCY_ECHO=y
CONFIG_BUSYBOX_DEFAULT_ENV=y
# CONFIG_BUSYBOX_DEFAULT_EXPAND is not set
# CONFIG_BUSYBOX_DEFAULT_UNEXPAND is not set
CONFIG_BUSYBOX_DEFAULT_EXPR=y
CONFIG_BUSYBOX_DEFAULT_EXPR_MATH_SUPPORT_64=y
# CONFIG_BUSYBOX_DEFAULT_FACTOR is not set
CONFIG_BUSYBOX_DEFAULT_FALSE=y
# CONFIG_BUSYBOX_DEFAULT_FOLD is not set
CONFIG_BUSYBOX_DEFAULT_HEAD=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FANCY_HEAD=y
# CONFIG_BUSYBOX_DEFAULT_HOSTID is not set
CONFIG_BUSYBOX_DEFAULT_ID=y
# CONFIG_BUSYBOX_DEFAULT_GROUPS is not set
# CONFIG_BUSYBOX_DEFAULT_INSTALL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INSTALL_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_LINK is not set
CONFIG_BUSYBOX_DEFAULT_LN=y
# CONFIG_BUSYBOX_DEFAULT_LOGNAME is not set
CONFIG_BUSYBOX_DEFAULT_LS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_FILETYPES=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_FOLLOWLINKS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_RECURSIVE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_WIDTH=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_SORTFILES=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_TIMESTAMPS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_USERNAME=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_COLOR=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LS_COLOR_IS_DEFAULT=y
CONFIG_BUSYBOX_DEFAULT_MD5SUM=y
# CONFIG_BUSYBOX_DEFAULT_SHA1SUM is not set
CONFIG_BUSYBOX_DEFAULT_SHA256SUM=y
# CONFIG_BUSYBOX_DEFAULT_SHA512SUM is not set
# CONFIG_BUSYBOX_DEFAULT_SHA3SUM is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_MD5_SHA1_SUM_CHECK=y
CONFIG_BUSYBOX_DEFAULT_MKDIR=y
CONFIG_BUSYBOX_DEFAULT_MKFIFO=y
CONFIG_BUSYBOX_DEFAULT_MKNOD=y
CONFIG_BUSYBOX_DEFAULT_MKTEMP=y
CONFIG_BUSYBOX_DEFAULT_MV=y
CONFIG_BUSYBOX_DEFAULT_NICE=y
# CONFIG_BUSYBOX_DEFAULT_NL is not set
# CONFIG_BUSYBOX_DEFAULT_NOHUP is not set
# CONFIG_BUSYBOX_DEFAULT_NPROC is not set
# CONFIG_BUSYBOX_DEFAULT_OD is not set
# CONFIG_BUSYBOX_DEFAULT_PASTE is not set
# CONFIG_BUSYBOX_DEFAULT_PRINTENV is not set
CONFIG_BUSYBOX_DEFAULT_PRINTF=y
CONFIG_BUSYBOX_DEFAULT_PWD=y
CONFIG_BUSYBOX_DEFAULT_READLINK=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_READLINK_FOLLOW=y
# CONFIG_BUSYBOX_DEFAULT_REALPATH is not set
CONFIG_BUSYBOX_DEFAULT_RM=y
CONFIG_BUSYBOX_DEFAULT_RMDIR=y
CONFIG_BUSYBOX_DEFAULT_SEQ=y
# CONFIG_BUSYBOX_DEFAULT_SHRED is not set
# CONFIG_BUSYBOX_DEFAULT_SHUF is not set
CONFIG_BUSYBOX_DEFAULT_SLEEP=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FANCY_SLEEP=y
CONFIG_BUSYBOX_DEFAULT_SORT=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SORT_BIG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SORT_OPTIMIZE_MEMORY is not set
# CONFIG_BUSYBOX_DEFAULT_SPLIT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SPLIT_FANCY is not set
# CONFIG_BUSYBOX_DEFAULT_STAT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_STAT_FORMAT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_STAT_FILESYSTEM is not set
# CONFIG_BUSYBOX_DEFAULT_STTY is not set
# CONFIG_BUSYBOX_DEFAULT_SUM is not set
CONFIG_BUSYBOX_DEFAULT_SYNC=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SYNC_FANCY is not set
CONFIG_BUSYBOX_DEFAULT_FSYNC=y
# CONFIG_BUSYBOX_DEFAULT_TAC is not set
CONFIG_BUSYBOX_DEFAULT_TAIL=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FANCY_TAIL=y
CONFIG_BUSYBOX_DEFAULT_TEE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_TEE_USE_BLOCK_IO=y
CONFIG_BUSYBOX_DEFAULT_TEST=y
CONFIG_BUSYBOX_DEFAULT_TEST1=y
CONFIG_BUSYBOX_DEFAULT_TEST2=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_TEST_64=y
# CONFIG_BUSYBOX_DEFAULT_TIMEOUT is not set
CONFIG_BUSYBOX_DEFAULT_TOUCH=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TOUCH_NODEREF is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_TOUCH_SUSV3=y
CONFIG_BUSYBOX_DEFAULT_TR=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TR_CLASSES is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TR_EQUIV is not set
CONFIG_BUSYBOX_DEFAULT_TRUE=y
# CONFIG_BUSYBOX_DEFAULT_TRUNCATE is not set
# CONFIG_BUSYBOX_DEFAULT_TTY is not set
CONFIG_BUSYBOX_DEFAULT_UNAME=y
CONFIG_BUSYBOX_DEFAULT_UNAME_OSNAME="GNU/Linux"
# CONFIG_BUSYBOX_DEFAULT_BB_ARCH is not set
CONFIG_BUSYBOX_DEFAULT_UNIQ=y
# CONFIG_BUSYBOX_DEFAULT_UNLINK is not set
# CONFIG_BUSYBOX_DEFAULT_USLEEP is not set
# CONFIG_BUSYBOX_DEFAULT_UUDECODE is not set
# CONFIG_BUSYBOX_DEFAULT_BASE32 is not set
# CONFIG_BUSYBOX_DEFAULT_BASE64 is not set
# CONFIG_BUSYBOX_DEFAULT_UUENCODE is not set
CONFIG_BUSYBOX_DEFAULT_WC=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WC_LARGE is not set
# CONFIG_BUSYBOX_DEFAULT_WHO is not set
# CONFIG_BUSYBOX_DEFAULT_W is not set
# CONFIG_BUSYBOX_DEFAULT_USERS is not set
# CONFIG_BUSYBOX_DEFAULT_WHOAMI is not set
CONFIG_BUSYBOX_DEFAULT_YES=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VERBOSE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE=y
# CONFIG_BUSYBOX_DEFAULT_CHVT is not set
CONFIG_BUSYBOX_DEFAULT_CLEAR=y
# CONFIG_BUSYBOX_DEFAULT_DEALLOCVT is not set
# CONFIG_BUSYBOX_DEFAULT_DUMPKMAP is not set
# CONFIG_BUSYBOX_DEFAULT_FGCONSOLE is not set
# CONFIG_BUSYBOX_DEFAULT_KBD_MODE is not set
# CONFIG_BUSYBOX_DEFAULT_LOADFONT is not set
# CONFIG_BUSYBOX_DEFAULT_SETFONT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SETFONT_TEXTUAL_MAP is not set
CONFIG_BUSYBOX_DEFAULT_DEFAULT_SETFONT_DIR=""
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LOADFONT_PSF2 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LOADFONT_RAW is not set
# CONFIG_BUSYBOX_DEFAULT_LOADKMAP is not set
# CONFIG_BUSYBOX_DEFAULT_OPENVT is not set
CONFIG_BUSYBOX_DEFAULT_RESET=y
# CONFIG_BUSYBOX_DEFAULT_RESIZE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_RESIZE_PRINT is not set
# CONFIG_BUSYBOX_DEFAULT_SETCONSOLE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SETCONSOLE_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_SETKEYCODES is not set
# CONFIG_BUSYBOX_DEFAULT_SETLOGCONS is not set
# CONFIG_BUSYBOX_DEFAULT_SHOWKEY is not set
# CONFIG_BUSYBOX_DEFAULT_PIPE_PROGRESS is not set
# CONFIG_BUSYBOX_DEFAULT_RUN_PARTS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_RUN_PARTS_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_RUN_PARTS_FANCY is not set
CONFIG_BUSYBOX_DEFAULT_START_STOP_DAEMON=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_START_STOP_DAEMON_FANCY is not set
CONFIG_BUSYBOX_DEFAULT_WHICH=y
# CONFIG_BUSYBOX_DEFAULT_MINIPS is not set
# CONFIG_BUSYBOX_DEFAULT_NUKE is not set
# CONFIG_BUSYBOX_DEFAULT_RESUME is not set
# CONFIG_BUSYBOX_DEFAULT_RUN_INIT is not set
CONFIG_BUSYBOX_DEFAULT_AWK=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_AWK_LIBM=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_AWK_GNU_EXTENSIONS=y
CONFIG_BUSYBOX_DEFAULT_CMP=y
# CONFIG_BUSYBOX_DEFAULT_DIFF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DIFF_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DIFF_DIR is not set
# CONFIG_BUSYBOX_DEFAULT_ED is not set
# CONFIG_BUSYBOX_DEFAULT_PATCH is not set
CONFIG_BUSYBOX_DEFAULT_SED=y
CONFIG_BUSYBOX_DEFAULT_VI=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_MAX_LEN=1024
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_8BIT is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_COLON=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_YANKMARK=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_SEARCH=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_REGEX_SEARCH is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_USE_SIGNALS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_DOT_CMD=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_READONLY=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_SETOPTS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_SET=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_WIN_RESIZE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_ASK_TERMINAL=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_UNDO is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_UNDO_QUEUE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_VI_UNDO_QUEUE_MAX=0
CONFIG_BUSYBOX_DEFAULT_FEATURE_ALLOW_EXEC=y
CONFIG_BUSYBOX_DEFAULT_FIND=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_PRINT0=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_MTIME=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_MMIN=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_PERM=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_TYPE=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_EXECUTABLE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_XDEV=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_MAXDEPTH=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_NEWER=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_INUM is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_EXEC=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_EXEC_PLUS is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_USER=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_GROUP=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_NOT=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_DEPTH=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_PAREN=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_SIZE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_PRUNE=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_QUIT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_DELETE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_EMPTY is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_PATH=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_REGEX=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_CONTEXT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FIND_LINKS is not set
CONFIG_BUSYBOX_DEFAULT_GREP=y
CONFIG_BUSYBOX_DEFAULT_EGREP=y
CONFIG_BUSYBOX_DEFAULT_FGREP=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_GREP_CONTEXT=y
CONFIG_BUSYBOX_DEFAULT_XARGS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_CONFIRMATION=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_QUOTES=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_TERMOPT=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_REPL_STR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_PARALLEL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_XARGS_SUPPORT_ARGS_FILE is not set
# CONFIG_BUSYBOX_DEFAULT_BOOTCHARTD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_BOOTCHARTD_CONFIG_FILE is not set
CONFIG_BUSYBOX_DEFAULT_HALT=y
CONFIG_BUSYBOX_DEFAULT_POWEROFF=y
CONFIG_BUSYBOX_DEFAULT_REBOOT=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WAIT_FOR_INIT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CALL_TELINIT is not set
CONFIG_BUSYBOX_DEFAULT_TELINIT_PATH=""
# CONFIG_BUSYBOX_DEFAULT_INIT is not set
# CONFIG_BUSYBOX_DEFAULT_LINUXRC is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_USE_INITTAB is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_KILL_REMOVED is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_KILL_DELAY=0
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INIT_SCTTY is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INIT_SYSLOG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INIT_QUIET is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INIT_COREDUMPS is not set
CONFIG_BUSYBOX_DEFAULT_INIT_TERMINAL_TYPE=""
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INIT_MODIFY_CMDLINE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_SHADOWPASSWDS=y
# CONFIG_BUSYBOX_DEFAULT_USE_BB_PWD_GRP is not set
# CONFIG_BUSYBOX_DEFAULT_USE_BB_SHADOW is not set
# CONFIG_BUSYBOX_DEFAULT_USE_BB_CRYPT is not set
# CONFIG_BUSYBOX_DEFAULT_USE_BB_CRYPT_SHA is not set
# CONFIG_BUSYBOX_DEFAULT_ADD_SHELL is not set
# CONFIG_BUSYBOX_DEFAULT_REMOVE_SHELL is not set
# CONFIG_BUSYBOX_DEFAULT_ADDGROUP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_ADDUSER_TO_GROUP is not set
# CONFIG_BUSYBOX_DEFAULT_ADDUSER is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHECK_NAMES is not set
CONFIG_BUSYBOX_DEFAULT_LAST_ID=0
CONFIG_BUSYBOX_DEFAULT_FIRST_SYSTEM_ID=0
CONFIG_BUSYBOX_DEFAULT_LAST_SYSTEM_ID=0
# CONFIG_BUSYBOX_DEFAULT_CHPASSWD is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_DEFAULT_PASSWD_ALGO="md5"
# CONFIG_BUSYBOX_DEFAULT_CRYPTPW is not set
# CONFIG_BUSYBOX_DEFAULT_MKPASSWD is not set
# CONFIG_BUSYBOX_DEFAULT_DELUSER is not set
# CONFIG_BUSYBOX_DEFAULT_DELGROUP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DEL_USER_FROM_GROUP is not set
# CONFIG_BUSYBOX_DEFAULT_GETTY is not set
CONFIG_BUSYBOX_DEFAULT_LOGIN=y
CONFIG_BUSYBOX_DEFAULT_LOGIN_SESSION_AS_CHILD=y
# CONFIG_BUSYBOX_DEFAULT_LOGIN_SCRIPTS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_NOLOGIN is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SECURETTY is not set
CONFIG_BUSYBOX_DEFAULT_PASSWD=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_PASSWD_WEAK_CHECK=y
# CONFIG_BUSYBOX_DEFAULT_SU is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SU_SYSLOG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SU_CHECKS_SHELLS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set
# CONFIG_BUSYBOX_DEFAULT_SULOGIN is not set
# CONFIG_BUSYBOX_DEFAULT_VLOCK is not set
# CONFIG_BUSYBOX_DEFAULT_CHATTR is not set
# CONFIG_BUSYBOX_DEFAULT_FSCK is not set
# CONFIG_BUSYBOX_DEFAULT_LSATTR is not set
# CONFIG_BUSYBOX_DEFAULT_TUNE2FS is not set
# CONFIG_BUSYBOX_DEFAULT_MODPROBE_SMALL is not set
# CONFIG_BUSYBOX_DEFAULT_DEPMOD is not set
# CONFIG_BUSYBOX_DEFAULT_INSMOD is not set
# CONFIG_BUSYBOX_DEFAULT_LSMOD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
# CONFIG_BUSYBOX_DEFAULT_MODINFO is not set
# CONFIG_BUSYBOX_DEFAULT_MODPROBE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MODPROBE_BLACKLIST is not set
# CONFIG_BUSYBOX_DEFAULT_RMMOD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CMDLINE_MODULE_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_2_4_MODULES is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INSMOD_VERSION_CHECKING is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INSMOD_LOADINKMEM is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INSMOD_LOAD_MAP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INSMOD_LOAD_MAP_FULL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHECK_TAINTED_MODULE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INSMOD_TRY_MMAP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MODUTILS_ALIAS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MODUTILS_SYMBOLS is not set
CONFIG_BUSYBOX_DEFAULT_DEFAULT_MODULES_DIR=""
CONFIG_BUSYBOX_DEFAULT_DEFAULT_DEPMOD_FILE=""
# CONFIG_BUSYBOX_DEFAULT_ACPID is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_ACPID_COMPAT is not set
# CONFIG_BUSYBOX_DEFAULT_BLKDISCARD is not set
# CONFIG_BUSYBOX_DEFAULT_BLKID is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_BLKID_TYPE is not set
# CONFIG_BUSYBOX_DEFAULT_BLOCKDEV is not set
# CONFIG_BUSYBOX_DEFAULT_CAL is not set
# CONFIG_BUSYBOX_DEFAULT_CHRT is not set
CONFIG_BUSYBOX_DEFAULT_DMESG=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_DMESG_PRETTY=y
# CONFIG_BUSYBOX_DEFAULT_EJECT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_EJECT_SCSI is not set
# CONFIG_BUSYBOX_DEFAULT_FALLOCATE is not set
# CONFIG_BUSYBOX_DEFAULT_FATATTR is not set
# CONFIG_BUSYBOX_DEFAULT_FBSET is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FBSET_FANCY is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FBSET_READMODE is not set
# CONFIG_BUSYBOX_DEFAULT_FDFORMAT is not set
# CONFIG_BUSYBOX_DEFAULT_FDISK is not set
# CONFIG_BUSYBOX_DEFAULT_FDISK_SUPPORT_LARGE_DISKS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FDISK_WRITABLE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_AIX_LABEL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SGI_LABEL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SUN_LABEL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_OSF_LABEL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_GPT_LABEL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FDISK_ADVANCED is not set
# CONFIG_BUSYBOX_DEFAULT_FINDFS is not set
CONFIG_BUSYBOX_DEFAULT_FLOCK=y
# CONFIG_BUSYBOX_DEFAULT_FDFLUSH is not set
# CONFIG_BUSYBOX_DEFAULT_FREERAMDISK is not set
# CONFIG_BUSYBOX_DEFAULT_FSCK_MINIX is not set
# CONFIG_BUSYBOX_DEFAULT_FSFREEZE is not set
# CONFIG_BUSYBOX_DEFAULT_FSTRIM is not set
# CONFIG_BUSYBOX_DEFAULT_GETOPT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_GETOPT_LONG is not set
CONFIG_BUSYBOX_DEFAULT_HEXDUMP=y
# CONFIG_BUSYBOX_DEFAULT_HD is not set
# CONFIG_BUSYBOX_DEFAULT_XXD is not set
CONFIG_BUSYBOX_DEFAULT_HWCLOCK=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HWCLOCK_ADJTIME_FHS is not set
# CONFIG_BUSYBOX_DEFAULT_IONICE is not set
# CONFIG_BUSYBOX_DEFAULT_IPCRM is not set
# CONFIG_BUSYBOX_DEFAULT_IPCS is not set
# CONFIG_BUSYBOX_DEFAULT_LAST is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LAST_FANCY is not set
# CONFIG_BUSYBOX_DEFAULT_LOSETUP is not set
# CONFIG_BUSYBOX_DEFAULT_LSPCI is not set
# CONFIG_BUSYBOX_DEFAULT_LSUSB is not set
# CONFIG_BUSYBOX_DEFAULT_MDEV is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MDEV_CONF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MDEV_RENAME is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MDEV_RENAME_REGEXP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MDEV_EXEC is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MDEV_LOAD_FIRMWARE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MDEV_DAEMON is not set
# CONFIG_BUSYBOX_DEFAULT_MESG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MESG_ENABLE_ONLY_GROUP is not set
# CONFIG_BUSYBOX_DEFAULT_MKE2FS is not set
# CONFIG_BUSYBOX_DEFAULT_MKFS_EXT2 is not set
# CONFIG_BUSYBOX_DEFAULT_MKFS_MINIX is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MINIX2 is not set
# CONFIG_BUSYBOX_DEFAULT_MKFS_REISER is not set
# CONFIG_BUSYBOX_DEFAULT_MKDOSFS is not set
# CONFIG_BUSYBOX_DEFAULT_MKFS_VFAT is not set
CONFIG_BUSYBOX_DEFAULT_MKSWAP=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MKSWAP_UUID is not set
# CONFIG_BUSYBOX_DEFAULT_MORE is not set
CONFIG_BUSYBOX_DEFAULT_MOUNT=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_FAKE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_VERBOSE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_HELPERS=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_LABEL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_NFS is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_CIFS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_FLAGS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_FSTAB=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_OTHERTAB is not set
# CONFIG_BUSYBOX_DEFAULT_MOUNTPOINT is not set
# CONFIG_BUSYBOX_DEFAULT_NOLOGIN is not set
# CONFIG_BUSYBOX_DEFAULT_NOLOGIN_DEPENDENCIES is not set
# CONFIG_BUSYBOX_DEFAULT_NSENTER is not set
CONFIG_BUSYBOX_DEFAULT_PIVOT_ROOT=y
# CONFIG_BUSYBOX_DEFAULT_RDATE is not set
# CONFIG_BUSYBOX_DEFAULT_RDEV is not set
# CONFIG_BUSYBOX_DEFAULT_READPROFILE is not set
# CONFIG_BUSYBOX_DEFAULT_RENICE is not set
# CONFIG_BUSYBOX_DEFAULT_REV is not set
# CONFIG_BUSYBOX_DEFAULT_RTCWAKE is not set
# CONFIG_BUSYBOX_DEFAULT_SCRIPT is not set
# CONFIG_BUSYBOX_DEFAULT_SCRIPTREPLAY is not set
# CONFIG_BUSYBOX_DEFAULT_SETARCH is not set
# CONFIG_BUSYBOX_DEFAULT_LINUX32 is not set
# CONFIG_BUSYBOX_DEFAULT_LINUX64 is not set
# CONFIG_BUSYBOX_DEFAULT_SETPRIV is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SETPRIV_DUMP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SETPRIV_CAPABILITIES is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SETPRIV_CAPABILITY_NAMES is not set
# CONFIG_BUSYBOX_DEFAULT_SETSID is not set
CONFIG_BUSYBOX_DEFAULT_SWAPON=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_SWAPON_DISCARD=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_SWAPON_PRI=y
CONFIG_BUSYBOX_DEFAULT_SWAPOFF=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SWAPONOFF_LABEL is not set
CONFIG_BUSYBOX_DEFAULT_SWITCH_ROOT=y
# CONFIG_BUSYBOX_DEFAULT_TASKSET is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TASKSET_FANCY is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TASKSET_CPULIST is not set
# CONFIG_BUSYBOX_DEFAULT_UEVENT is not set
CONFIG_BUSYBOX_DEFAULT_UMOUNT=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_UMOUNT_ALL=y
# CONFIG_BUSYBOX_DEFAULT_UNSHARE is not set
# CONFIG_BUSYBOX_DEFAULT_WALL is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_LOOP=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MOUNT_LOOP_CREATE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MTAB_SUPPORT is not set
# CONFIG_BUSYBOX_DEFAULT_VOLUMEID is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_BCACHE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_BTRFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_CRAMFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_EROFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_EXFAT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_EXT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_F2FS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_FAT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_HFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_ISO9660 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_JFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LINUXRAID is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LINUXSWAP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_LUKS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_MINIX is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_NILFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_NTFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_OCFS2 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_REISERFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_ROMFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_SQUASHFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_SYSV is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_UBIFS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_UDF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_VOLUMEID_XFS is not set
# CONFIG_BUSYBOX_DEFAULT_ADJTIMEX is not set
# CONFIG_BUSYBOX_DEFAULT_BBCONFIG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_COMPRESS_BBCONFIG is not set
# CONFIG_BUSYBOX_DEFAULT_BC is not set
# CONFIG_BUSYBOX_DEFAULT_DC is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DC_BIG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DC_LIBM is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_BC_INTERACTIVE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_BC_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_BEEP is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_BEEP_FREQ=0
CONFIG_BUSYBOX_DEFAULT_FEATURE_BEEP_LENGTH_MS=0
# CONFIG_BUSYBOX_DEFAULT_CHAT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHAT_NOFAIL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHAT_TTY_HIFI is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHAT_IMPLICIT_CR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHAT_SWALLOW_OPTS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHAT_SEND_ESCAPES is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHAT_VAR_ABORT_LEN is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CHAT_CLR_ABORT is not set
# CONFIG_BUSYBOX_DEFAULT_CONSPY is not set
CONFIG_BUSYBOX_DEFAULT_CROND=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CROND_D is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CROND_CALL_SENDMAIL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_CROND_SPECIAL_TIMES is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_CROND_DIR="/etc"
CONFIG_BUSYBOX_DEFAULT_CRONTAB=y
# CONFIG_BUSYBOX_DEFAULT_DEVFSD is not set
# CONFIG_BUSYBOX_DEFAULT_DEVFSD_MODLOAD is not set
# CONFIG_BUSYBOX_DEFAULT_DEVFSD_FG_NP is not set
# CONFIG_BUSYBOX_DEFAULT_DEVFSD_VERBOSE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_DEVFS is not set
# CONFIG_BUSYBOX_DEFAULT_DEVMEM is not set
# CONFIG_BUSYBOX_DEFAULT_FBSPLASH is not set
# CONFIG_BUSYBOX_DEFAULT_FLASH_ERASEALL is not set
# CONFIG_BUSYBOX_DEFAULT_FLASH_LOCK is not set
# CONFIG_BUSYBOX_DEFAULT_FLASH_UNLOCK is not set
# CONFIG_BUSYBOX_DEFAULT_FLASHCP is not set
# CONFIG_BUSYBOX_DEFAULT_HDPARM is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HDPARM_GET_IDENTITY is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_SCAN_HWIF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_DRIVE_RESET is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_TRISTATE_HWIF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HDPARM_HDIO_GETSET_DMA is not set
# CONFIG_BUSYBOX_DEFAULT_HEXEDIT is not set
# CONFIG_BUSYBOX_DEFAULT_I2CGET is not set
# CONFIG_BUSYBOX_DEFAULT_I2CSET is not set
# CONFIG_BUSYBOX_DEFAULT_I2CDUMP is not set
# CONFIG_BUSYBOX_DEFAULT_I2CDETECT is not set
# CONFIG_BUSYBOX_DEFAULT_I2CTRANSFER is not set
# CONFIG_BUSYBOX_DEFAULT_INOTIFYD is not set
CONFIG_BUSYBOX_DEFAULT_LESS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_MAXLINES=9999999
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_BRACKETS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_FLAGS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_TRUNCATE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_MARKS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_REGEXP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_WINCH is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_ASK_TERMINAL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_DASHCMD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_LINENUMS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_RAW is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LESS_ENV is not set
CONFIG_BUSYBOX_DEFAULT_LOCK=y
# CONFIG_BUSYBOX_DEFAULT_LSSCSI is not set
# CONFIG_BUSYBOX_DEFAULT_MAKEDEVS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MAKEDEVS_LEAF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_MAKEDEVS_TABLE is not set
# CONFIG_BUSYBOX_DEFAULT_MAN is not set
# CONFIG_BUSYBOX_DEFAULT_MICROCOM is not set
# CONFIG_BUSYBOX_DEFAULT_MIM is not set
# CONFIG_BUSYBOX_DEFAULT_MT is not set
# CONFIG_BUSYBOX_DEFAULT_NANDWRITE is not set
# CONFIG_BUSYBOX_DEFAULT_NANDDUMP is not set
# CONFIG_BUSYBOX_DEFAULT_PARTPROBE is not set
# CONFIG_BUSYBOX_DEFAULT_RAIDAUTORUN is not set
# CONFIG_BUSYBOX_DEFAULT_READAHEAD is not set
# CONFIG_BUSYBOX_DEFAULT_RFKILL is not set
# CONFIG_BUSYBOX_DEFAULT_RUNLEVEL is not set
# CONFIG_BUSYBOX_DEFAULT_RX is not set
# CONFIG_BUSYBOX_DEFAULT_SETFATTR is not set
# CONFIG_BUSYBOX_DEFAULT_SETSERIAL is not set
CONFIG_BUSYBOX_DEFAULT_STRINGS=y
CONFIG_BUSYBOX_DEFAULT_TIME=y
# CONFIG_BUSYBOX_DEFAULT_TS is not set
# CONFIG_BUSYBOX_DEFAULT_TTYSIZE is not set
# CONFIG_BUSYBOX_DEFAULT_UBIATTACH is not set
# CONFIG_BUSYBOX_DEFAULT_UBIDETACH is not set
# CONFIG_BUSYBOX_DEFAULT_UBIMKVOL is not set
# CONFIG_BUSYBOX_DEFAULT_UBIRMVOL is not set
# CONFIG_BUSYBOX_DEFAULT_UBIRSVOL is not set
# CONFIG_BUSYBOX_DEFAULT_UBIUPDATEVOL is not set
# CONFIG_BUSYBOX_DEFAULT_UBIRENAME is not set
# CONFIG_BUSYBOX_DEFAULT_VOLNAME is not set
# CONFIG_BUSYBOX_DEFAULT_WATCHDOG is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_IPV6=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UNIX_LOCAL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_PREFER_IPV4_ADDRESS is not set
CONFIG_BUSYBOX_DEFAULT_VERBOSE_RESOLUTION_ERRORS=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TLS_SHA1 is not set
# CONFIG_BUSYBOX_DEFAULT_ARP is not set
# CONFIG_BUSYBOX_DEFAULT_ARPING is not set
CONFIG_BUSYBOX_DEFAULT_BRCTL=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_BRCTL_FANCY=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_BRCTL_SHOW=y
# CONFIG_BUSYBOX_DEFAULT_DNSD is not set
# CONFIG_BUSYBOX_DEFAULT_ETHER_WAKE is not set
# CONFIG_BUSYBOX_DEFAULT_FTPD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FTPD_WRITE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FTPD_ACCEPT_BROKEN_LIST is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FTPD_AUTHENTICATION is not set
# CONFIG_BUSYBOX_DEFAULT_FTPGET is not set
# CONFIG_BUSYBOX_DEFAULT_FTPPUT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_FTPGETPUT_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_HOSTNAME is not set
# CONFIG_BUSYBOX_DEFAULT_DNSDOMAINNAME is not set
# CONFIG_BUSYBOX_DEFAULT_HTTPD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_RANGES is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_SETUID is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_BASIC_AUTH is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_AUTH_MD5 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_CGI is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_ENCODE_URL_STR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_ERROR_PAGES is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_PROXY is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_GZIP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_ETAG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_LAST_MODIFIED is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_DATE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_HTTPD_ACL_IP is not set
CONFIG_BUSYBOX_DEFAULT_IFCONFIG=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_IFCONFIG_STATUS=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IFCONFIG_SLIP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_IFCONFIG_HW=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_IFCONFIG_BROADCAST_PLUS=y
# CONFIG_BUSYBOX_DEFAULT_IFENSLAVE is not set
# CONFIG_BUSYBOX_DEFAULT_IFPLUGD is not set
# CONFIG_BUSYBOX_DEFAULT_IFUP is not set
# CONFIG_BUSYBOX_DEFAULT_IFDOWN is not set
CONFIG_BUSYBOX_DEFAULT_IFUPDOWN_IFSTATE_PATH=""
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IPV4 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_IPV6 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_MAPPING is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set
# CONFIG_BUSYBOX_DEFAULT_INETD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_INETD_RPC is not set
CONFIG_BUSYBOX_DEFAULT_IP=y
# CONFIG_BUSYBOX_DEFAULT_IPADDR is not set
# CONFIG_BUSYBOX_DEFAULT_IPLINK is not set
# CONFIG_BUSYBOX_DEFAULT_IPROUTE is not set
# CONFIG_BUSYBOX_DEFAULT_IPTUNNEL is not set
# CONFIG_BUSYBOX_DEFAULT_IPRULE is not set
# CONFIG_BUSYBOX_DEFAULT_IPNEIGH is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_IP_ADDRESS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_IP_LINK=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_IP_ROUTE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_IP_ROUTE_DIR="/etc/iproute2"
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IP_TUNNEL is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_IP_RULE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_IP_NEIGH=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IP_RARE_PROTOCOLS is not set
# CONFIG_BUSYBOX_DEFAULT_IPCALC is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IPCALC_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IPCALC_FANCY is not set
# CONFIG_BUSYBOX_DEFAULT_FAKEIDENTD is not set
# CONFIG_BUSYBOX_DEFAULT_NAMEIF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_NAMEIF_EXTENDED is not set
# CONFIG_BUSYBOX_DEFAULT_NBDCLIENT is not set
CONFIG_BUSYBOX_DEFAULT_NC=y
# CONFIG_BUSYBOX_DEFAULT_NETCAT is not set
# CONFIG_BUSYBOX_DEFAULT_NC_SERVER is not set
# CONFIG_BUSYBOX_DEFAULT_NC_EXTRA is not set
# CONFIG_BUSYBOX_DEFAULT_NC_110_COMPAT is not set
CONFIG_BUSYBOX_DEFAULT_NETMSG=y
CONFIG_BUSYBOX_DEFAULT_NETSTAT=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_NETSTAT_WIDE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_NETSTAT_PRG=y
CONFIG_BUSYBOX_DEFAULT_NSLOOKUP=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_NSLOOKUP_BIG=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_NSLOOKUP_LONG_OPTIONS is not set
CONFIG_BUSYBOX_DEFAULT_NTPD=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_NTPD_SERVER=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_NTPD_CONF is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_NTP_AUTH is not set
CONFIG_BUSYBOX_DEFAULT_PING=y
CONFIG_BUSYBOX_DEFAULT_PING6=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_FANCY_PING=y
# CONFIG_BUSYBOX_DEFAULT_PSCAN is not set
CONFIG_BUSYBOX_DEFAULT_ROUTE=y
# CONFIG_BUSYBOX_DEFAULT_SLATTACH is not set
# CONFIG_BUSYBOX_DEFAULT_SSL_CLIENT is not set
# CONFIG_BUSYBOX_DEFAULT_TC is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TC_INGRESS is not set
# CONFIG_BUSYBOX_DEFAULT_TCPSVD is not set
# CONFIG_BUSYBOX_DEFAULT_UDPSVD is not set
# CONFIG_BUSYBOX_DEFAULT_TELNET is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TELNET_TTYPE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TELNET_AUTOLOGIN is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TELNET_WIDTH is not set
# CONFIG_BUSYBOX_DEFAULT_TELNETD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TELNETD_STANDALONE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TELNETD_INETD_WAIT is not set
# CONFIG_BUSYBOX_DEFAULT_TFTP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TFTP_PROGRESS_BAR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TFTP_HPA_COMPAT is not set
# CONFIG_BUSYBOX_DEFAULT_TFTPD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TFTP_GET is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TFTP_PUT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TFTP_BLOCKSIZE is not set
# CONFIG_BUSYBOX_DEFAULT_TFTP_DEBUG is not set
# CONFIG_BUSYBOX_DEFAULT_TLS is not set
CONFIG_BUSYBOX_DEFAULT_TRACEROUTE=y
CONFIG_BUSYBOX_DEFAULT_TRACEROUTE6=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_TRACEROUTE_VERBOSE=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TRACEROUTE_USE_ICMP is not set
# CONFIG_BUSYBOX_DEFAULT_TUNCTL is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TUNCTL_UG is not set
# CONFIG_BUSYBOX_DEFAULT_VCONFIG is not set
# CONFIG_BUSYBOX_DEFAULT_WGET is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WGET_LONG_OPTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WGET_STATUSBAR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WGET_AUTHENTICATION is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WGET_TIMEOUT is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WGET_HTTPS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_WGET_OPENSSL is not set
# CONFIG_BUSYBOX_DEFAULT_WHOIS is not set
# CONFIG_BUSYBOX_DEFAULT_ZCIP is not set
# CONFIG_BUSYBOX_DEFAULT_UDHCPD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCPD_BASE_IP_ON_MAC is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCPD_WRITE_LEASES_EARLY is not set
CONFIG_BUSYBOX_DEFAULT_DHCPD_LEASES_FILE=""
# CONFIG_BUSYBOX_DEFAULT_DUMPLEASES is not set
# CONFIG_BUSYBOX_DEFAULT_DHCPRELAY is not set
CONFIG_BUSYBOX_DEFAULT_UDHCPC=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCPC_ARPING is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCPC_SANITIZEOPT is not set
CONFIG_BUSYBOX_DEFAULT_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
# CONFIG_BUSYBOX_DEFAULT_UDHCPC6 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCPC6_RFC3646 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCPC6_RFC4704 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCPC6_RFC4833 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCPC6_RFC5970 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCP_PORT is not set
CONFIG_BUSYBOX_DEFAULT_UDHCP_DEBUG=0
CONFIG_BUSYBOX_DEFAULT_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCP_RFC3397=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UDHCP_8021Q is not set
CONFIG_BUSYBOX_DEFAULT_IFUPDOWN_UDHCPC_CMD_OPTIONS=""
# CONFIG_BUSYBOX_DEFAULT_LPD is not set
# CONFIG_BUSYBOX_DEFAULT_LPR is not set
# CONFIG_BUSYBOX_DEFAULT_LPQ is not set
# CONFIG_BUSYBOX_DEFAULT_MAKEMIME is not set
# CONFIG_BUSYBOX_DEFAULT_POPMAILDIR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_POPMAILDIR_DELIVERY is not set
# CONFIG_BUSYBOX_DEFAULT_REFORMIME is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_REFORMIME_COMPAT is not set
# CONFIG_BUSYBOX_DEFAULT_SENDMAIL is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET=""
CONFIG_BUSYBOX_DEFAULT_FREE=y
# CONFIG_BUSYBOX_DEFAULT_FUSER is not set
# CONFIG_BUSYBOX_DEFAULT_IOSTAT is not set
CONFIG_BUSYBOX_DEFAULT_KILL=y
CONFIG_BUSYBOX_DEFAULT_KILLALL=y
# CONFIG_BUSYBOX_DEFAULT_KILLALL5 is not set
# CONFIG_BUSYBOX_DEFAULT_LSOF is not set
# CONFIG_BUSYBOX_DEFAULT_MPSTAT is not set
# CONFIG_BUSYBOX_DEFAULT_NMETER is not set
CONFIG_BUSYBOX_DEFAULT_PGREP=y
# CONFIG_BUSYBOX_DEFAULT_PKILL is not set
CONFIG_BUSYBOX_DEFAULT_PIDOF=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_PIDOF_SINGLE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_PIDOF_OMIT is not set
# CONFIG_BUSYBOX_DEFAULT_PMAP is not set
# CONFIG_BUSYBOX_DEFAULT_POWERTOP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_POWERTOP_INTERACTIVE is not set
CONFIG_BUSYBOX_DEFAULT_PS=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_PS_WIDE=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_PS_LONG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_PS_TIME is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_PS_UNUSUAL_SYSTEMS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_PS_ADDITIONAL_COLUMNS is not set
# CONFIG_BUSYBOX_DEFAULT_PSTREE is not set
# CONFIG_BUSYBOX_DEFAULT_PWDX is not set
# CONFIG_BUSYBOX_DEFAULT_SMEMCAP is not set
CONFIG_BUSYBOX_DEFAULT_BB_SYSCTL=y
CONFIG_BUSYBOX_DEFAULT_TOP=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TOP_INTERACTIVE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TOP_SMP_CPU is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TOP_DECIMALS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TOP_SMP_PROCESS is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_TOPMEM is not set
CONFIG_BUSYBOX_DEFAULT_UPTIME=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_UPTIME_UTMP_SUPPORT is not set
# CONFIG_BUSYBOX_DEFAULT_WATCH is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS is not set
# CONFIG_BUSYBOX_DEFAULT_CHPST is not set
# CONFIG_BUSYBOX_DEFAULT_SETUIDGID is not set
# CONFIG_BUSYBOX_DEFAULT_ENVUIDGID is not set
# CONFIG_BUSYBOX_DEFAULT_ENVDIR is not set
# CONFIG_BUSYBOX_DEFAULT_SOFTLIMIT is not set
# CONFIG_BUSYBOX_DEFAULT_RUNSV is not set
# CONFIG_BUSYBOX_DEFAULT_RUNSVDIR is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_RUNSVDIR_LOG is not set
# CONFIG_BUSYBOX_DEFAULT_SV is not set
CONFIG_BUSYBOX_DEFAULT_SV_DEFAULT_SERVICE_DIR=""
# CONFIG_BUSYBOX_DEFAULT_SVC is not set
# CONFIG_BUSYBOX_DEFAULT_SVOK is not set
# CONFIG_BUSYBOX_DEFAULT_SVLOGD is not set
# CONFIG_BUSYBOX_DEFAULT_CHCON is not set
# CONFIG_BUSYBOX_DEFAULT_GETENFORCE is not set
# CONFIG_BUSYBOX_DEFAULT_GETSEBOOL is not set
# CONFIG_BUSYBOX_DEFAULT_LOAD_POLICY is not set
# CONFIG_BUSYBOX_DEFAULT_MATCHPATHCON is not set
# CONFIG_BUSYBOX_DEFAULT_RUNCON is not set
# CONFIG_BUSYBOX_DEFAULT_SELINUXENABLED is not set
# CONFIG_BUSYBOX_DEFAULT_SESTATUS is not set
# CONFIG_BUSYBOX_DEFAULT_SETENFORCE is not set
# CONFIG_BUSYBOX_DEFAULT_SETFILES is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SETFILES_CHECK_OPTION is not set
# CONFIG_BUSYBOX_DEFAULT_RESTORECON is not set
# CONFIG_BUSYBOX_DEFAULT_SETSEBOOL is not set
CONFIG_BUSYBOX_DEFAULT_SH_IS_ASH=y
# CONFIG_BUSYBOX_DEFAULT_SH_IS_HUSH is not set
# CONFIG_BUSYBOX_DEFAULT_SH_IS_NONE is not set
# CONFIG_BUSYBOX_DEFAULT_BASH_IS_ASH is not set
# CONFIG_BUSYBOX_DEFAULT_BASH_IS_HUSH is not set
CONFIG_BUSYBOX_DEFAULT_BASH_IS_NONE=y
CONFIG_BUSYBOX_DEFAULT_SHELL_ASH=y
CONFIG_BUSYBOX_DEFAULT_ASH=y
# CONFIG_BUSYBOX_DEFAULT_ASH_OPTIMIZE_FOR_SIZE is not set
CONFIG_BUSYBOX_DEFAULT_ASH_INTERNAL_GLOB=y
CONFIG_BUSYBOX_DEFAULT_ASH_BASH_COMPAT=y
# CONFIG_BUSYBOX_DEFAULT_ASH_BASH_SOURCE_CURDIR is not set
# CONFIG_BUSYBOX_DEFAULT_ASH_BASH_NOT_FOUND_HOOK is not set
CONFIG_BUSYBOX_DEFAULT_ASH_JOB_CONTROL=y
CONFIG_BUSYBOX_DEFAULT_ASH_ALIAS=y
# CONFIG_BUSYBOX_DEFAULT_ASH_RANDOM_SUPPORT is not set
CONFIG_BUSYBOX_DEFAULT_ASH_EXPAND_PRMT=y
# CONFIG_BUSYBOX_DEFAULT_ASH_IDLE_TIMEOUT is not set
# CONFIG_BUSYBOX_DEFAULT_ASH_MAIL is not set
CONFIG_BUSYBOX_DEFAULT_ASH_ECHO=y
CONFIG_BUSYBOX_DEFAULT_ASH_PRINTF=y
CONFIG_BUSYBOX_DEFAULT_ASH_TEST=y
# CONFIG_BUSYBOX_DEFAULT_ASH_HELP is not set
CONFIG_BUSYBOX_DEFAULT_ASH_GETOPTS=y
CONFIG_BUSYBOX_DEFAULT_ASH_CMDCMD=y
# CONFIG_BUSYBOX_DEFAULT_CTTYHACK is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH is not set
# CONFIG_BUSYBOX_DEFAULT_SHELL_HUSH is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_BASH_COMPAT is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_BRACE_EXPANSION is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_LINENO_VAR is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_BASH_SOURCE_CURDIR is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_INTERACTIVE is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_SAVEHISTORY is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_JOB is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_TICK is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_IF is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_LOOPS is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_CASE is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_FUNCTIONS is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_LOCAL is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_RANDOM_SUPPORT is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_MODE_X is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_ECHO is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_PRINTF is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_TEST is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_HELP is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_EXPORT is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_EXPORT_N is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_READONLY is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_KILL is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_WAIT is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_COMMAND is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_TRAP is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_TYPE is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_TIMES is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_READ is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_SET is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_UNSET is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_ULIMIT is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_UMASK is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_GETOPTS is not set
# CONFIG_BUSYBOX_DEFAULT_HUSH_MEMLEAK is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_MATH=y
CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_MATH_64=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_MATH_BASE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_EXTRA_QUIET is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_STANDALONE is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_NOFORK=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_READ_FRAC is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_HISTFILESIZE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SH_EMBEDDED_SCRIPTS is not set
# CONFIG_BUSYBOX_DEFAULT_KLOGD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_KLOGD_KLOGCTL is not set
CONFIG_BUSYBOX_DEFAULT_LOGGER=y
# CONFIG_BUSYBOX_DEFAULT_LOGREAD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_LOGREAD_REDUCED_LOCKING is not set
# CONFIG_BUSYBOX_DEFAULT_SYSLOGD is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_ROTATE_LOGFILE is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_REMOTE_LOG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SYSLOGD_DUP is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SYSLOGD_CFG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_SYSLOGD_PRECISE_TIMESTAMPS is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_SYSLOGD_READ_BUFFER_SIZE=0
# CONFIG_BUSYBOX_DEFAULT_FEATURE_IPC_SYSLOG is not set
CONFIG_BUSYBOX_DEFAULT_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0
# CONFIG_BUSYBOX_DEFAULT_FEATURE_KMSG_SYSLOG is not set
# CONFIG_PACKAGE_busybox-selinux is not set
CONFIG_PACKAGE_ca-bundle=y
# CONFIG_PACKAGE_ca-certificates is not set
# CONFIG_PACKAGE_dnsmasq is not set
# CONFIG_PACKAGE_dnsmasq-dhcpv6 is not set
CONFIG_PACKAGE_dnsmasq-full=y
CONFIG_PACKAGE_dnsmasq_full_dhcp=y
# CONFIG_PACKAGE_dnsmasq_full_dhcpv6 is not set
# CONFIG_PACKAGE_dnsmasq_full_dnssec is not set
# CONFIG_PACKAGE_dnsmasq_full_auth is not set
CONFIG_PACKAGE_dnsmasq_full_ipset=y
# CONFIG_PACKAGE_dnsmasq_full_conntrack is not set
# CONFIG_PACKAGE_dnsmasq_full_noid is not set
# CONFIG_PACKAGE_dnsmasq_full_broken_rtc is not set
CONFIG_PACKAGE_dnsmasq_full_tftp=y
CONFIG_PACKAGE_dropbear=y
#
# Configuration
#
CONFIG_DROPBEAR_CURVE25519=y
# CONFIG_DROPBEAR_ECC is not set
CONFIG_DROPBEAR_ED25519=y
CONFIG_DROPBEAR_CHACHA20POLY1305=y
# CONFIG_DROPBEAR_ZLIB is not set
CONFIG_DROPBEAR_DBCLIENT=y
CONFIG_DROPBEAR_SCP=y
# CONFIG_DROPBEAR_ASKPASS is not set
# end of Configuration
# CONFIG_PACKAGE_ead is not set
CONFIG_PACKAGE_firewall=y
# CONFIG_PACKAGE_firewall4 is not set
CONFIG_PACKAGE_fstools=y
# CONFIG_FSTOOLS_UBIFS_EXTROOT is not set
# CONFIG_FSTOOLS_OVL_MOUNT_FULL_ACCESS_TIME is not set
# CONFIG_FSTOOLS_OVL_MOUNT_COMPRESS_ZLIB is not set
CONFIG_PACKAGE_fwtool=y
CONFIG_PACKAGE_getrandom=y
CONFIG_PACKAGE_jsonfilter=y
# CONFIG_PACKAGE_libatomic is not set
CONFIG_PACKAGE_libc=y
CONFIG_PACKAGE_libgcc=y
# CONFIG_PACKAGE_libgomp is not set
CONFIG_PACKAGE_libpthread=y
CONFIG_PACKAGE_librt=y
CONFIG_PACKAGE_libstdcpp=y
CONFIG_PACKAGE_logd=y
CONFIG_PACKAGE_mtd=y
CONFIG_PACKAGE_netifd=y
# CONFIG_PACKAGE_nft-qos is not set
# CONFIG_PACKAGE_om-watchdog is not set
CONFIG_PACKAGE_openwrt-keyring=y
CONFIG_PACKAGE_opkg=y
CONFIG_PACKAGE_procd=y
#
# Configuration
#
# CONFIG_PROCD_SHOW_BOOT is not set
# CONFIG_PROCD_ZRAM_TMPFS is not set
# end of Configuration
# CONFIG_PACKAGE_procd-seccomp is not set
# CONFIG_PACKAGE_procd-selinux is not set
# CONFIG_PACKAGE_procd-ujail is not set
# CONFIG_PACKAGE_procd-ujail-console is not set
# CONFIG_PACKAGE_qos-scripts is not set
# CONFIG_PACKAGE_refpolicy is not set
CONFIG_PACKAGE_resolveip=y
CONFIG_PACKAGE_rpcd=y
# CONFIG_PACKAGE_rpcd-mod-file is not set
# CONFIG_PACKAGE_rpcd-mod-iwinfo is not set
# CONFIG_PACKAGE_rpcd-mod-rpcsys is not set
# CONFIG_PACKAGE_selinux-policy is not set
# CONFIG_PACKAGE_snapshot-tool is not set
# CONFIG_PACKAGE_sqm-scripts is not set
# CONFIG_PACKAGE_sqm-scripts-extra is not set
CONFIG_PACKAGE_swconfig=y
CONFIG_PACKAGE_ubox=y
CONFIG_PACKAGE_ubus=y
CONFIG_PACKAGE_ubusd=y
# CONFIG_PACKAGE_ucert is not set
# CONFIG_PACKAGE_ucert-full is not set
CONFIG_PACKAGE_uci=y
CONFIG_PACKAGE_urandom-seed=y
# CONFIG_PACKAGE_urngd is not set
CONFIG_PACKAGE_usign=y
# CONFIG_PACKAGE_uxc is not set
# CONFIG_PACKAGE_wireless-tools is not set
# CONFIG_PACKAGE_zram-swap is not set
# end of Base system
#
# Administration
#
#
# Zabbix
#
# CONFIG_PACKAGE_zabbix-agentd is not set
#
# SSL support
#
# CONFIG_ZABBIX_OPENSSL is not set
# CONFIG_ZABBIX_GNUTLS is not set
CONFIG_ZABBIX_NOSSL=y
# CONFIG_PACKAGE_zabbix-extra-network is not set
# CONFIG_PACKAGE_zabbix-extra-wifi is not set
# CONFIG_PACKAGE_zabbix-get is not set
# CONFIG_PACKAGE_zabbix-proxy is not set
# CONFIG_PACKAGE_zabbix-sender is not set
# CONFIG_PACKAGE_zabbix-server is not set
#
# Database Software
#
# CONFIG_ZABBIX_MYSQL is not set
CONFIG_ZABBIX_POSTGRESQL=y
# CONFIG_PACKAGE_zabbix-server-frontend is not set
# end of Zabbix
#
# openwisp
#
# CONFIG_PACKAGE_openwisp-config-mbedtls is not set
# CONFIG_PACKAGE_openwisp-config-nossl is not set
# CONFIG_PACKAGE_openwisp-config-openssl is not set
# CONFIG_PACKAGE_openwisp-config-wolfssl is not set
# end of openwisp
# CONFIG_PACKAGE_atop is not set
# CONFIG_PACKAGE_backuppc is not set
# CONFIG_PACKAGE_debian-archive-keyring is not set
# CONFIG_PACKAGE_debootstrap is not set
# CONFIG_PACKAGE_gkrellmd is not set
CONFIG_PACKAGE_htop=y
# CONFIG_PACKAGE_ipmitool is not set
# CONFIG_PACKAGE_monit is not set
# CONFIG_PACKAGE_monit-nossl is not set
# CONFIG_PACKAGE_muninlite is not set
# CONFIG_PACKAGE_netatop is not set
CONFIG_PACKAGE_netdata=y
# CONFIG_PACKAGE_nyx is not set
# CONFIG_PACKAGE_schroot is not set
#
# Configuration
#
# CONFIG_SCHROOT_BTRFS is not set
# CONFIG_SCHROOT_LOOPBACK is not set
# CONFIG_SCHROOT_LVM is not set
# CONFIG_SCHROOT_UUID is not set
# end of Configuration
# CONFIG_PACKAGE_sudo is not set
# CONFIG_PACKAGE_syslog-ng is not set
# end of Administration
#
# Boot Loaders
#
# end of Boot Loaders
#
# Development
#
#
# Libraries
#
# CONFIG_PACKAGE_libncurses-dev is not set
# CONFIG_PACKAGE_libxml2-dev is not set
# CONFIG_PACKAGE_zlib-dev is not set
# end of Libraries
# CONFIG_PACKAGE_ar is not set
# CONFIG_PACKAGE_autoconf is not set
# CONFIG_PACKAGE_automake is not set
# CONFIG_PACKAGE_binutils is not set
# CONFIG_PACKAGE_diffutils is not set
# CONFIG_PACKAGE_gcc is not set
# CONFIG_PACKAGE_gdb is not set
# CONFIG_PACKAGE_gdbserver is not set
# CONFIG_PACKAGE_gitlab-runner is not set
# CONFIG_PACKAGE_libtool-bin is not set
# CONFIG_PACKAGE_lpc21isp is not set
# CONFIG_PACKAGE_lttng-tools is not set
# CONFIG_PACKAGE_m4 is not set
# CONFIG_PACKAGE_make is not set
# CONFIG_PACKAGE_meson is not set
# CONFIG_PACKAGE_ninja is not set
# CONFIG_PACKAGE_objdump is not set
# CONFIG_PACKAGE_packr is not set
# CONFIG_PACKAGE_patch is not set
# CONFIG_PACKAGE_pkg-config is not set
# CONFIG_PACKAGE_pkgconf is not set
# CONFIG_PACKAGE_trace-cmd is not set
# CONFIG_PACKAGE_trace-cmd-extra is not set
# CONFIG_PACKAGE_valgrind is not set
# end of Development
#
# Extra packages
#
# CONFIG_PACKAGE_automount is not set
# CONFIG_PACKAGE_autosamba is not set
# CONFIG_PACKAGE_ipv6helper is not set
# CONFIG_PACKAGE_jose is not set
# CONFIG_PACKAGE_k3wifi is not set
# CONFIG_PACKAGE_libjose is not set
# CONFIG_PACKAGE_nginx is not set
# CONFIG_PACKAGE_nginx-mod-luci-ssl is not set
# CONFIG_PACKAGE_nginx-util is not set
# CONFIG_PACKAGE_tang is not set
# end of Extra packages
#
# Firmware
#
#
# ath10k Board-Specific Overrides
#
# end of ath10k Board-Specific Overrides
# CONFIG_PACKAGE_aircard-pcmcia-firmware is not set
# CONFIG_PACKAGE_amdgpu-firmware is not set
# CONFIG_PACKAGE_ar3k-firmware is not set
# CONFIG_PACKAGE_ath10k-board-qca4019 is not set
# CONFIG_PACKAGE_ath10k-board-qca9377 is not set
# CONFIG_PACKAGE_ath10k-board-qca9887 is not set
# CONFIG_PACKAGE_ath10k-board-qca9888 is not set
# CONFIG_PACKAGE_ath10k-board-qca988x is not set
# CONFIG_PACKAGE_ath10k-board-qca9984 is not set
# CONFIG_PACKAGE_ath10k-board-qca99x0 is not set
# CONFIG_PACKAGE_ath10k-firmware-qca4019 is not set
# CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca4019-ct-full-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca4019-ct-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca6174 is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9377 is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9887 is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9887-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9887-ct-full-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9888 is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9888-ct-full-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9888-ct-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca988x is not set
# CONFIG_PACKAGE_ath10k-firmware-qca988x-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca988x-ct-full-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9984 is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9984-ct-full-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9984-ct-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca99x0 is not set
# CONFIG_PACKAGE_ath10k-firmware-qca99x0-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca99x0-ct-full-htt is not set
# CONFIG_PACKAGE_ath10k-firmware-qca99x0-ct-htt is not set
# CONFIG_PACKAGE_ath11k-firmware-ipq6018 is not set
# CONFIG_PACKAGE_ath11k-firmware-ipq8074 is not set
# CONFIG_PACKAGE_ath11k-firmware-qca6390 is not set
# CONFIG_PACKAGE_ath11k-firmware-qcn9074 is not set
# CONFIG_PACKAGE_ath6k-firmware is not set
# CONFIG_PACKAGE_ath9k-htc-firmware is not set
# CONFIG_PACKAGE_b43legacy-firmware is not set
# CONFIG_PACKAGE_bnx2-firmware is not set
# CONFIG_PACKAGE_bnx2x-firmware is not set
# CONFIG_PACKAGE_brcmfmac-firmware-4329-sdio is not set
# CONFIG_PACKAGE_brcmfmac-firmware-43430-sdio-rpi-3b is not set
# CONFIG_PACKAGE_brcmfmac-firmware-43430-sdio-rpi-zero-w is not set
# CONFIG_PACKAGE_brcmfmac-firmware-43430a0-sdio is not set
# CONFIG_PACKAGE_brcmfmac-firmware-43455-sdio-rpi-3b-plus is not set
# CONFIG_PACKAGE_brcmfmac-firmware-43455-sdio-rpi-4b is not set
# CONFIG_PACKAGE_brcmfmac-firmware-43602a1-pcie is not set
# CONFIG_PACKAGE_brcmfmac-firmware-4366b1-pcie is not set
# CONFIG_PACKAGE_brcmfmac-firmware-4366c0-pcie is not set
# CONFIG_PACKAGE_brcmfmac-firmware-usb is not set
# CONFIG_PACKAGE_brcmsmac-firmware is not set
# CONFIG_PACKAGE_carl9170-firmware is not set
# CONFIG_PACKAGE_cypress-firmware-43012-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-43340-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-43362-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-4339-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-43430-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-43455-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-4354-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-4356-pcie is not set
# CONFIG_PACKAGE_cypress-firmware-4356-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-43570-pcie is not set
# CONFIG_PACKAGE_cypress-firmware-4359-pcie is not set
# CONFIG_PACKAGE_cypress-firmware-4359-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-4373-sdio is not set
# CONFIG_PACKAGE_cypress-firmware-4373-usb is not set
# CONFIG_PACKAGE_cypress-firmware-54591-pcie is not set
# CONFIG_PACKAGE_cypress-firmware-89459-pcie is not set
# CONFIG_PACKAGE_e100-firmware is not set
# CONFIG_PACKAGE_edgeport-firmware is not set
# CONFIG_PACKAGE_eip197-mini-firmware is not set
# CONFIG_PACKAGE_ibt-firmware is not set
# CONFIG_PACKAGE_iwl3945-firmware is not set
# CONFIG_PACKAGE_iwl4965-firmware is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl100 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl1000 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl105 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl135 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl2000 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl2030 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl3160 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl3168 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl5000 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl5150 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl6000g2 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl6000g2a is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl6000g2b is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl6050 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl7260 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl7265 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl7265d is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl8260c is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl8265 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl9000 is not set
# CONFIG_PACKAGE_iwlwifi-firmware-iwl9260 is not set
# CONFIG_PACKAGE_jboot-tools is not set
# CONFIG_PACKAGE_libertas-sdio-firmware is not set
# CONFIG_PACKAGE_libertas-spi-firmware is not set
# CONFIG_PACKAGE_libertas-usb-firmware is not set
# CONFIG_PACKAGE_mt7601u-firmware is not set
# CONFIG_PACKAGE_mt7622bt-firmware is not set
# CONFIG_PACKAGE_mwifiex-pcie-firmware is not set
# CONFIG_PACKAGE_mwifiex-sdio-firmware is not set
# CONFIG_PACKAGE_mwl8k-firmware is not set
# CONFIG_PACKAGE_p54-pci-firmware is not set
# CONFIG_PACKAGE_p54-spi-firmware is not set
# CONFIG_PACKAGE_p54-usb-firmware is not set
# CONFIG_PACKAGE_prism54-firmware is not set
# CONFIG_PACKAGE_qtn-firmware is not set
# CONFIG_PACKAGE_qtn-proto is not set
# CONFIG_PACKAGE_qtn-utils is not set
# CONFIG_PACKAGE_r8169-firmware is not set
# CONFIG_PACKAGE_radeon-firmware is not set
# CONFIG_PACKAGE_rs9113-firmware is not set
# CONFIG_PACKAGE_rt2800-pci-firmware is not set
# CONFIG_PACKAGE_rt2800-usb-firmware is not set
# CONFIG_PACKAGE_rt61-pci-firmware is not set
# CONFIG_PACKAGE_rt73-usb-firmware is not set
# CONFIG_PACKAGE_rtl8188eu-firmware is not set
# CONFIG_PACKAGE_rtl8192ce-firmware is not set
# CONFIG_PACKAGE_rtl8192cu-firmware is not set
# CONFIG_PACKAGE_rtl8192de-firmware is not set
# CONFIG_PACKAGE_rtl8192eu-firmware is not set
# CONFIG_PACKAGE_rtl8192se-firmware is not set
# CONFIG_PACKAGE_rtl8192su-firmware is not set
# CONFIG_PACKAGE_rtl8723au-firmware is not set
# CONFIG_PACKAGE_rtl8723bs-firmware is not set
# CONFIG_PACKAGE_rtl8723bu-firmware is not set
# CONFIG_PACKAGE_rtl8821ae-firmware is not set
# CONFIG_PACKAGE_rtl8822be-firmware is not set
# CONFIG_PACKAGE_rtl8822ce-firmware is not set
# CONFIG_PACKAGE_ti-3410-firmware is not set
# CONFIG_PACKAGE_ti-5052-firmware is not set
# CONFIG_PACKAGE_wil6210-firmware is not set
# CONFIG_PACKAGE_wireless-regdb is not set
# CONFIG_PACKAGE_wl12xx-firmware is not set
# CONFIG_PACKAGE_wl18xx-firmware is not set
# end of Firmware
#
# Fonts
#
#
# DejaVu
#
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuMathTeXGyre is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSans is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSans-Bold is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSans-BoldOblique is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSans-ExtraLight is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSans-Oblique is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSansCondensed is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSansCondensed-Bold is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSansCondensed-BoldOblique is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSansCondensed-Oblique is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSansMono is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSansMono-Bold is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSansMono-BoldOblique is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSansMono-Oblique is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSerif is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSerif-Bold is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSerif-BoldItalic is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSerif-Italic is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSerifCondensed is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSerifCondensed-Bold is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSerifCondensed-BoldItalic is not set
# CONFIG_PACKAGE_dejavu-fonts-ttf-DejaVuSerifCondensed-Italic is not set
# end of DejaVu
# end of Fonts
#
# Kernel modules
#
#
# Block Devices
#
# CONFIG_PACKAGE_kmod-aoe is not set
# CONFIG_PACKAGE_kmod-ata-ahci is not set
# CONFIG_PACKAGE_kmod-ata-artop is not set
# CONFIG_PACKAGE_kmod-ata-core is not set
# CONFIG_PACKAGE_kmod-ata-marvell-sata is not set
# CONFIG_PACKAGE_kmod-ata-nvidia-sata is not set
# CONFIG_PACKAGE_kmod-ata-pdc202xx-old is not set
# CONFIG_PACKAGE_kmod-ata-piix is not set
# CONFIG_PACKAGE_kmod-ata-sil is not set
# CONFIG_PACKAGE_kmod-ata-sil24 is not set
# CONFIG_PACKAGE_kmod-ata-via-sata is not set
# CONFIG_PACKAGE_kmod-block2mtd is not set
# CONFIG_PACKAGE_kmod-dax is not set
# CONFIG_PACKAGE_kmod-dm is not set
# CONFIG_PACKAGE_kmod-dm-raid is not set
# CONFIG_PACKAGE_kmod-iosched-bfq is not set
# CONFIG_PACKAGE_kmod-iscsi-initiator is not set
# CONFIG_PACKAGE_kmod-loop is not set
# CONFIG_PACKAGE_kmod-md-mod is not set
# CONFIG_PACKAGE_kmod-nbd is not set
# CONFIG_PACKAGE_kmod-scsi-cdrom is not set
CONFIG_PACKAGE_kmod-scsi-core=y
# CONFIG_PACKAGE_kmod-scsi-generic is not set
# CONFIG_PACKAGE_kmod-scsi-tape is not set
# end of Block Devices
#
# CAN Support
#
# CONFIG_PACKAGE_kmod-can is not set
# end of CAN Support
#
# Cryptographic API modules
#
CONFIG_PACKAGE_kmod-crypto-acompress=y
CONFIG_PACKAGE_kmod-crypto-aead=y
CONFIG_PACKAGE_kmod-crypto-arc4=y
CONFIG_PACKAGE_kmod-crypto-authenc=y
# CONFIG_PACKAGE_kmod-crypto-cbc is not set
CONFIG_PACKAGE_kmod-crypto-ccm=y
CONFIG_PACKAGE_kmod-crypto-cmac=y
CONFIG_PACKAGE_kmod-crypto-crc32c=y
CONFIG_PACKAGE_kmod-crypto-ctr=y
# CONFIG_PACKAGE_kmod-crypto-cts is not set
# CONFIG_PACKAGE_kmod-crypto-deflate is not set
CONFIG_PACKAGE_kmod-crypto-des=y
CONFIG_PACKAGE_kmod-crypto-ecb=y
# CONFIG_PACKAGE_kmod-crypto-ecdh is not set
# CONFIG_PACKAGE_kmod-crypto-echainiv is not set
# CONFIG_PACKAGE_kmod-crypto-fcrypt is not set
# CONFIG_PACKAGE_kmod-crypto-gcm is not set
# CONFIG_PACKAGE_kmod-crypto-gf128 is not set
# CONFIG_PACKAGE_kmod-crypto-ghash is not set
CONFIG_PACKAGE_kmod-crypto-hash=y
CONFIG_PACKAGE_kmod-crypto-hmac=y
CONFIG_PACKAGE_kmod-crypto-hw-eip93=y
# CONFIG_PACKAGE_kmod-crypto-hw-hifn-795x is not set
# CONFIG_PACKAGE_kmod-crypto-hw-padlock is not set
# CONFIG_PACKAGE_kmod-crypto-kpp is not set
CONFIG_PACKAGE_kmod-crypto-manager=y
CONFIG_PACKAGE_kmod-crypto-md4=y
CONFIG_PACKAGE_kmod-crypto-md5=y
# CONFIG_PACKAGE_kmod-crypto-michael-mic is not set
# CONFIG_PACKAGE_kmod-crypto-misc is not set
CONFIG_PACKAGE_kmod-crypto-null=y
# CONFIG_PACKAGE_kmod-crypto-pcbc is not set
# CONFIG_PACKAGE_kmod-crypto-rmd160 is not set
CONFIG_PACKAGE_kmod-crypto-rng=y
CONFIG_PACKAGE_kmod-crypto-seqiv=y
CONFIG_PACKAGE_kmod-crypto-sha1=y
CONFIG_PACKAGE_kmod-crypto-sha256=y
CONFIG_PACKAGE_kmod-crypto-sha512=y
# CONFIG_PACKAGE_kmod-crypto-test is not set
CONFIG_PACKAGE_kmod-crypto-user=y
# CONFIG_PACKAGE_kmod-crypto-xcbc is not set
# CONFIG_PACKAGE_kmod-crypto-xts is not set
CONFIG_PACKAGE_kmod-cryptodev=y
# end of Cryptographic API modules
#
# Filesystems
#
# CONFIG_PACKAGE_kmod-fs-afs is not set
# CONFIG_PACKAGE_kmod-fs-antfs is not set
# CONFIG_PACKAGE_kmod-fs-autofs4 is not set
CONFIG_PACKAGE_kmod-fs-btrfs=y
CONFIG_PACKAGE_kmod-fs-cifs=y
# CONFIG_PACKAGE_kmod-fs-configfs is not set
# CONFIG_PACKAGE_kmod-fs-cramfs is not set
CONFIG_PACKAGE_kmod-fs-exfat=y
# CONFIG_PACKAGE_kmod-fs-exportfs is not set
CONFIG_PACKAGE_kmod-fs-ext4=y
# CONFIG_PACKAGE_kmod-fs-f2fs is not set
# CONFIG_PACKAGE_kmod-fs-fscache is not set
# CONFIG_PACKAGE_kmod-fs-hfs is not set
# CONFIG_PACKAGE_kmod-fs-hfsplus is not set
# CONFIG_PACKAGE_kmod-fs-isofs is not set
# CONFIG_PACKAGE_kmod-fs-jfs is not set
# CONFIG_PACKAGE_kmod-fs-ksmbd is not set
# CONFIG_PACKAGE_kmod-fs-minix is not set
# CONFIG_PACKAGE_kmod-fs-msdos is not set
# CONFIG_PACKAGE_kmod-fs-nfs is not set
# CONFIG_PACKAGE_kmod-fs-nfs-common is not set
# CONFIG_PACKAGE_kmod-fs-nfs-common-rpcsec is not set
# CONFIG_PACKAGE_kmod-fs-nfs-v3 is not set
# CONFIG_PACKAGE_kmod-fs-nfs-v4 is not set
# CONFIG_PACKAGE_kmod-fs-nfsd is not set
CONFIG_PACKAGE_kmod-fs-ntfs=y
# CONFIG_PACKAGE_kmod-fs-ntfs3 is not set
# CONFIG_PACKAGE_kmod-fs-reiserfs is not set
# CONFIG_PACKAGE_kmod-fs-squashfs is not set
# CONFIG_PACKAGE_kmod-fs-udf is not set
# CONFIG_PACKAGE_kmod-fs-vfat is not set
# CONFIG_PACKAGE_kmod-fs-xfs is not set
# CONFIG_PACKAGE_kmod-fuse is not set
# end of Filesystems
#
# FireWire support
#
# CONFIG_PACKAGE_kmod-firewire is not set
# end of FireWire support
#
# Hardware Monitoring Support
#
# CONFIG_PACKAGE_kmod-gl-mifi-mcu is not set
# CONFIG_PACKAGE_kmod-hwmon-ad7418 is not set
# CONFIG_PACKAGE_kmod-hwmon-adcxx is not set
# CONFIG_PACKAGE_kmod-hwmon-ads1015 is not set
# CONFIG_PACKAGE_kmod-hwmon-adt7410 is not set
# CONFIG_PACKAGE_kmod-hwmon-adt7475 is not set
# CONFIG_PACKAGE_kmod-hwmon-core is not set
# CONFIG_PACKAGE_kmod-hwmon-dme1737 is not set
# CONFIG_PACKAGE_kmod-hwmon-drivetemp is not set
# CONFIG_PACKAGE_kmod-hwmon-emc2305 is not set
# CONFIG_PACKAGE_kmod-hwmon-gpiofan is not set
# CONFIG_PACKAGE_kmod-hwmon-ina209 is not set
# CONFIG_PACKAGE_kmod-hwmon-ina2xx is not set
# CONFIG_PACKAGE_kmod-hwmon-it87 is not set
# CONFIG_PACKAGE_kmod-hwmon-lm63 is not set
# CONFIG_PACKAGE_kmod-hwmon-lm75 is not set
# CONFIG_PACKAGE_kmod-hwmon-lm77 is not set
# CONFIG_PACKAGE_kmod-hwmon-lm85 is not set
# CONFIG_PACKAGE_kmod-hwmon-lm90 is not set
# CONFIG_PACKAGE_kmod-hwmon-lm92 is not set
# CONFIG_PACKAGE_kmod-hwmon-lm95241 is not set
# CONFIG_PACKAGE_kmod-hwmon-ltc4151 is not set
# CONFIG_PACKAGE_kmod-hwmon-mcp3021 is not set
# CONFIG_PACKAGE_kmod-hwmon-pwmfan is not set
# CONFIG_PACKAGE_kmod-hwmon-sch5627 is not set
# CONFIG_PACKAGE_kmod-hwmon-sht21 is not set
# CONFIG_PACKAGE_kmod-hwmon-tmp102 is not set
# CONFIG_PACKAGE_kmod-hwmon-tmp103 is not set
# CONFIG_PACKAGE_kmod-hwmon-tmp421 is not set
# CONFIG_PACKAGE_kmod-hwmon-vid is not set
# CONFIG_PACKAGE_kmod-hwmon-w83793 is not set
# CONFIG_PACKAGE_kmod-pmbus-core is not set
# CONFIG_PACKAGE_kmod-pmbus-zl6100 is not set
# end of Hardware Monitoring Support
#
# I2C support
#
# CONFIG_PACKAGE_kmod-i2c-algo-bit is not set
# CONFIG_PACKAGE_kmod-i2c-algo-pca is not set
# CONFIG_PACKAGE_kmod-i2c-algo-pcf is not set
# CONFIG_PACKAGE_kmod-i2c-core is not set
# CONFIG_PACKAGE_kmod-i2c-designware-pci is not set
# CONFIG_PACKAGE_kmod-i2c-gpio is not set
# CONFIG_PACKAGE_kmod-i2c-mux is not set
# CONFIG_PACKAGE_kmod-i2c-mux-gpio is not set
# CONFIG_PACKAGE_kmod-i2c-mux-pca9541 is not set
# CONFIG_PACKAGE_kmod-i2c-mux-pca954x is not set
# CONFIG_PACKAGE_kmod-i2c-pxa is not set
# CONFIG_PACKAGE_kmod-i2c-smbus is not set
# CONFIG_PACKAGE_kmod-i2c-tiny-usb is not set
# end of I2C support
#
# Industrial I/O Modules
#
# CONFIG_PACKAGE_kmod-iio-ad799x is not set
# CONFIG_PACKAGE_kmod-iio-am2315 is not set
# CONFIG_PACKAGE_kmod-iio-bh1750 is not set
# CONFIG_PACKAGE_kmod-iio-bme680 is not set
# CONFIG_PACKAGE_kmod-iio-bme680-i2c is not set
# CONFIG_PACKAGE_kmod-iio-bme680-spi is not set
# CONFIG_PACKAGE_kmod-iio-bmp280 is not set
# CONFIG_PACKAGE_kmod-iio-bmp280-i2c is not set
# CONFIG_PACKAGE_kmod-iio-bmp280-spi is not set
# CONFIG_PACKAGE_kmod-iio-ccs811 is not set
# CONFIG_PACKAGE_kmod-iio-core is not set
# CONFIG_PACKAGE_kmod-iio-dht11 is not set
# CONFIG_PACKAGE_kmod-iio-fxas21002c is not set
# CONFIG_PACKAGE_kmod-iio-fxas21002c-i2c is not set
# CONFIG_PACKAGE_kmod-iio-fxas21002c-spi is not set
# CONFIG_PACKAGE_kmod-iio-fxos8700 is not set
# CONFIG_PACKAGE_kmod-iio-fxos8700-i2c is not set
# CONFIG_PACKAGE_kmod-iio-fxos8700-spi is not set
# CONFIG_PACKAGE_kmod-iio-hmc5843 is not set
# CONFIG_PACKAGE_kmod-iio-htu21 is not set
# CONFIG_PACKAGE_kmod-iio-kfifo-buf is not set
# CONFIG_PACKAGE_kmod-iio-lsm6dsx is not set
# CONFIG_PACKAGE_kmod-iio-lsm6dsx-i2c is not set
# CONFIG_PACKAGE_kmod-iio-lsm6dsx-spi is not set
# CONFIG_PACKAGE_kmod-iio-si7020 is not set
# CONFIG_PACKAGE_kmod-iio-sps30 is not set
# CONFIG_PACKAGE_kmod-iio-st_accel is not set
# CONFIG_PACKAGE_kmod-iio-st_accel-i2c is not set
# CONFIG_PACKAGE_kmod-iio-st_accel-spi is not set
# CONFIG_PACKAGE_kmod-iio-tsl4531 is not set
# CONFIG_PACKAGE_kmod-industrialio-triggered-buffer is not set
# end of Industrial I/O Modules
#
# Input modules
#
# CONFIG_PACKAGE_kmod-hid is not set
# CONFIG_PACKAGE_kmod-hid-generic is not set
# CONFIG_PACKAGE_kmod-input-core is not set
# CONFIG_PACKAGE_kmod-input-evdev is not set
# CONFIG_PACKAGE_kmod-input-gpio-encoder is not set
# CONFIG_PACKAGE_kmod-input-gpio-keys is not set
# CONFIG_PACKAGE_kmod-input-gpio-keys-polled is not set
# CONFIG_PACKAGE_kmod-input-joydev is not set
# CONFIG_PACKAGE_kmod-input-matrixkmap is not set
# CONFIG_PACKAGE_kmod-input-polldev is not set
# CONFIG_PACKAGE_kmod-input-touchscreen-ads7846 is not set
# CONFIG_PACKAGE_kmod-input-uinput is not set
# end of Input modules
#
# LED modules
#
# CONFIG_PACKAGE_kmod-input-leds is not set
CONFIG_PACKAGE_kmod-leds-gpio=y
# CONFIG_PACKAGE_kmod-leds-pca963x is not set
# CONFIG_PACKAGE_kmod-leds-uleds is not set
# CONFIG_PACKAGE_kmod-ledtrig-activity is not set
# CONFIG_PACKAGE_kmod-ledtrig-audio is not set
# CONFIG_PACKAGE_kmod-ledtrig-gpio is not set
# CONFIG_PACKAGE_kmod-ledtrig-oneshot is not set
# CONFIG_PACKAGE_kmod-ledtrig-transient is not set
# end of LED modules
#
# Libraries
#
CONFIG_PACKAGE_kmod-asn1-decoder=y
# CONFIG_PACKAGE_kmod-lib-cordic is not set
CONFIG_PACKAGE_kmod-lib-crc-ccitt=y
# CONFIG_PACKAGE_kmod-lib-crc-itu-t is not set
CONFIG_PACKAGE_kmod-lib-crc16=y
CONFIG_PACKAGE_kmod-lib-crc32c=y
# CONFIG_PACKAGE_kmod-lib-crc7 is not set
# CONFIG_PACKAGE_kmod-lib-crc8 is not set
# CONFIG_PACKAGE_kmod-lib-lz4 is not set
CONFIG_PACKAGE_kmod-lib-lzo=y
CONFIG_PACKAGE_kmod-lib-raid6=y
CONFIG_PACKAGE_kmod-lib-textsearch=y
CONFIG_PACKAGE_kmod-lib-xor=y
CONFIG_PACKAGE_kmod-lib-zlib-deflate=y
CONFIG_PACKAGE_kmod-lib-zlib-inflate=y
CONFIG_PACKAGE_kmod-lib-zstd=y
# end of Libraries
#
# Native Language Support
#
CONFIG_PACKAGE_kmod-nls-base=y
# CONFIG_PACKAGE_kmod-nls-cp1250 is not set
# CONFIG_PACKAGE_kmod-nls-cp1251 is not set
# CONFIG_PACKAGE_kmod-nls-cp437 is not set
# CONFIG_PACKAGE_kmod-nls-cp775 is not set
# CONFIG_PACKAGE_kmod-nls-cp850 is not set
# CONFIG_PACKAGE_kmod-nls-cp852 is not set
# CONFIG_PACKAGE_kmod-nls-cp862 is not set
# CONFIG_PACKAGE_kmod-nls-cp864 is not set
# CONFIG_PACKAGE_kmod-nls-cp866 is not set
# CONFIG_PACKAGE_kmod-nls-cp932 is not set
# CONFIG_PACKAGE_kmod-nls-cp936 is not set
# CONFIG_PACKAGE_kmod-nls-cp950 is not set
# CONFIG_PACKAGE_kmod-nls-iso8859-1 is not set
# CONFIG_PACKAGE_kmod-nls-iso8859-13 is not set
# CONFIG_PACKAGE_kmod-nls-iso8859-15 is not set
# CONFIG_PACKAGE_kmod-nls-iso8859-2 is not set
# CONFIG_PACKAGE_kmod-nls-iso8859-6 is not set
# CONFIG_PACKAGE_kmod-nls-iso8859-8 is not set
# CONFIG_PACKAGE_kmod-nls-koi8r is not set
CONFIG_PACKAGE_kmod-nls-utf8=y
# end of Native Language Support
#
# Netfilter Extensions
#
# CONFIG_PACKAGE_kmod-arptables is not set
# CONFIG_PACKAGE_kmod-br-netfilter is not set
# CONFIG_PACKAGE_kmod-ebtables is not set
# CONFIG_PACKAGE_kmod-ebtables-ipv4 is not set
# CONFIG_PACKAGE_kmod-ebtables-ipv6 is not set
# CONFIG_PACKAGE_kmod-ebtables-watchers is not set
CONFIG_PACKAGE_kmod-ip6tables=y
# CONFIG_PACKAGE_kmod-ip6tables-extra is not set
# CONFIG_PACKAGE_kmod-ipt-account is not set
# CONFIG_PACKAGE_kmod-ipt-chaos is not set
# CONFIG_PACKAGE_kmod-ipt-checksum is not set
# CONFIG_PACKAGE_kmod-ipt-cluster is not set
# CONFIG_PACKAGE_kmod-ipt-clusterip is not set
# CONFIG_PACKAGE_kmod-ipt-compat-xtables is not set
# CONFIG_PACKAGE_kmod-ipt-condition is not set
CONFIG_PACKAGE_kmod-ipt-conntrack=y
# CONFIG_PACKAGE_kmod-ipt-conntrack-extra is not set
# CONFIG_PACKAGE_kmod-ipt-conntrack-label is not set
CONFIG_PACKAGE_kmod-ipt-core=y
# CONFIG_PACKAGE_kmod-ipt-debug is not set
# CONFIG_PACKAGE_kmod-ipt-delude is not set
# CONFIG_PACKAGE_kmod-ipt-dhcpmac is not set
# CONFIG_PACKAGE_kmod-ipt-dnetmap is not set
# CONFIG_PACKAGE_kmod-ipt-extra is not set
# CONFIG_PACKAGE_kmod-ipt-filter is not set
CONFIG_PACKAGE_kmod-ipt-fullconenat=y
# CONFIG_PACKAGE_kmod-ipt-fuzzy is not set
# CONFIG_PACKAGE_kmod-ipt-geoip is not set
# CONFIG_PACKAGE_kmod-ipt-hashlimit is not set
# CONFIG_PACKAGE_kmod-ipt-iface is not set
# CONFIG_PACKAGE_kmod-ipt-ipmark is not set
# CONFIG_PACKAGE_kmod-ipt-ipopt is not set
# CONFIG_PACKAGE_kmod-ipt-ipp2p is not set
# CONFIG_PACKAGE_kmod-ipt-iprange is not set
# CONFIG_PACKAGE_kmod-ipt-ipsec is not set
CONFIG_PACKAGE_kmod-ipt-ipset=y
# CONFIG_PACKAGE_kmod-ipt-ipv4options is not set
# CONFIG_PACKAGE_kmod-ipt-led is not set
# CONFIG_PACKAGE_kmod-ipt-length2 is not set
# CONFIG_PACKAGE_kmod-ipt-logmark is not set
# CONFIG_PACKAGE_kmod-ipt-lscan is not set
# CONFIG_PACKAGE_kmod-ipt-lua is not set
CONFIG_PACKAGE_kmod-ipt-nat=y
# CONFIG_PACKAGE_kmod-ipt-nat-extra is not set
# CONFIG_PACKAGE_kmod-ipt-nat6 is not set
# CONFIG_PACKAGE_kmod-ipt-nathelper-rtsp is not set
# CONFIG_PACKAGE_kmod-ipt-nflog is not set
# CONFIG_PACKAGE_kmod-ipt-nfqueue is not set
CONFIG_PACKAGE_kmod-ipt-offload=y
# CONFIG_PACKAGE_kmod-ipt-physdev is not set
# CONFIG_PACKAGE_kmod-ipt-proto is not set
# CONFIG_PACKAGE_kmod-ipt-psd is not set
# CONFIG_PACKAGE_kmod-ipt-quota2 is not set
CONFIG_PACKAGE_kmod-ipt-raw=y
# CONFIG_PACKAGE_kmod-ipt-raw6 is not set
# CONFIG_PACKAGE_kmod-ipt-rpfilter is not set
# CONFIG_PACKAGE_kmod-ipt-rtpengine is not set
# CONFIG_PACKAGE_kmod-ipt-sysrq is not set
# CONFIG_PACKAGE_kmod-ipt-tarpit is not set
# CONFIG_PACKAGE_kmod-ipt-tee is not set
CONFIG_PACKAGE_kmod-ipt-tproxy=y
# CONFIG_PACKAGE_kmod-ipt-u32 is not set
# CONFIG_PACKAGE_kmod-ipt-ulog is not set
# CONFIG_PACKAGE_kmod-netatop is not set
CONFIG_PACKAGE_kmod-nf-conntrack=y
# CONFIG_PACKAGE_kmod-nf-conntrack-netlink is not set
CONFIG_PACKAGE_kmod-nf-conntrack6=y
CONFIG_PACKAGE_kmod-nf-flow=y
CONFIG_PACKAGE_kmod-nf-ipt=y
CONFIG_PACKAGE_kmod-nf-ipt6=y
# CONFIG_PACKAGE_kmod-nf-ipvs is not set
CONFIG_PACKAGE_kmod-nf-nat=y
# CONFIG_PACKAGE_kmod-nf-nat6 is not set
CONFIG_PACKAGE_kmod-nf-nathelper=y
CONFIG_PACKAGE_kmod-nf-nathelper-extra=y
CONFIG_PACKAGE_kmod-nf-reject=y
CONFIG_PACKAGE_kmod-nf-reject6=y
CONFIG_PACKAGE_kmod-nfnetlink=y
# CONFIG_PACKAGE_kmod-nfnetlink-log is not set
# CONFIG_PACKAGE_kmod-nfnetlink-queue is not set
# CONFIG_PACKAGE_kmod-nft-arp is not set
# CONFIG_PACKAGE_kmod-nft-bridge is not set
# CONFIG_PACKAGE_kmod-nft-core is not set
# CONFIG_PACKAGE_kmod-nft-fib is not set
# CONFIG_PACKAGE_kmod-nft-nat is not set
# CONFIG_PACKAGE_kmod-nft-nat6 is not set
# CONFIG_PACKAGE_kmod-nft-netdev is not set
# CONFIG_PACKAGE_kmod-nft-offload is not set
# CONFIG_PACKAGE_kmod-nft-queue is not set
# end of Netfilter Extensions
#
# Network Devices
#
# CONFIG_PACKAGE_kmod-3c59x is not set
# CONFIG_PACKAGE_kmod-8139cp is not set
# CONFIG_PACKAGE_kmod-8139too is not set
# CONFIG_PACKAGE_kmod-alx is not set
# CONFIG_PACKAGE_kmod-atl1 is not set
# CONFIG_PACKAGE_kmod-atl1c is not set
# CONFIG_PACKAGE_kmod-atl1e is not set
# CONFIG_PACKAGE_kmod-atl2 is not set
# CONFIG_PACKAGE_kmod-b44 is not set
# CONFIG_PACKAGE_kmod-be2net is not set
# CONFIG_PACKAGE_kmod-bnx2 is not set
# CONFIG_PACKAGE_kmod-bnx2x is not set
# CONFIG_PACKAGE_kmod-dm9000 is not set
# CONFIG_PACKAGE_kmod-dummy is not set
# CONFIG_PACKAGE_kmod-e100 is not set
# CONFIG_PACKAGE_kmod-e1000 is not set
# CONFIG_PACKAGE_kmod-et131x is not set
# CONFIG_PACKAGE_kmod-ethoc is not set
# CONFIG_PACKAGE_kmod-forcedeth is not set
# CONFIG_PACKAGE_kmod-hfcmulti is not set
# CONFIG_PACKAGE_kmod-hfcpci is not set
# CONFIG_PACKAGE_kmod-i40e is not set
# CONFIG_PACKAGE_kmod-iavf is not set
# CONFIG_PACKAGE_kmod-ifb is not set
# CONFIG_PACKAGE_kmod-igb is not set
# CONFIG_PACKAGE_kmod-igc is not set
# CONFIG_PACKAGE_kmod-ipvlan is not set
# CONFIG_PACKAGE_kmod-ixgbe is not set
# CONFIG_PACKAGE_kmod-ixgbevf is not set
# CONFIG_PACKAGE_kmod-libphy is not set
CONFIG_PACKAGE_kmod-macvlan=y
# CONFIG_PACKAGE_kmod-mdio-gpio is not set
# CONFIG_PACKAGE_kmod-mii is not set
# CONFIG_PACKAGE_kmod-mlx4-core is not set
# CONFIG_PACKAGE_kmod-mlx5-core is not set
# CONFIG_PACKAGE_kmod-natsemi is not set
# CONFIG_PACKAGE_kmod-ne2k-pci is not set
# CONFIG_PACKAGE_kmod-niu is not set
# CONFIG_PACKAGE_kmod-of-mdio is not set
# CONFIG_PACKAGE_kmod-pcnet32 is not set
# CONFIG_PACKAGE_kmod-phy-bcm84881 is not set
# CONFIG_PACKAGE_kmod-phy-broadcom is not set
# CONFIG_PACKAGE_kmod-phy-realtek is not set
# CONFIG_PACKAGE_kmod-phylink is not set
# CONFIG_PACKAGE_kmod-qlcnic is not set
# CONFIG_PACKAGE_kmod-r6040 is not set
# CONFIG_PACKAGE_kmod-r8125 is not set
# CONFIG_PACKAGE_kmod-r8168 is not set
# CONFIG_PACKAGE_kmod-r8169 is not set
# CONFIG_PACKAGE_kmod-sfc is not set
# CONFIG_PACKAGE_kmod-sfc-falcon is not set
# CONFIG_PACKAGE_kmod-sfp is not set
# CONFIG_PACKAGE_kmod-siit is not set
# CONFIG_PACKAGE_kmod-sis190 is not set
# CONFIG_PACKAGE_kmod-sis900 is not set
# CONFIG_PACKAGE_kmod-skge is not set
# CONFIG_PACKAGE_kmod-sky2 is not set
# CONFIG_PACKAGE_kmod-solos-pci is not set
# CONFIG_PACKAGE_kmod-spi-ks8995 is not set
# CONFIG_PACKAGE_kmod-swconfig is not set
# CONFIG_PACKAGE_kmod-switch-bcm53xx is not set
# CONFIG_PACKAGE_kmod-switch-bcm53xx-mdio is not set
# CONFIG_PACKAGE_kmod-switch-ip17xx is not set
# CONFIG_PACKAGE_kmod-switch-rtl8306 is not set
# CONFIG_PACKAGE_kmod-switch-rtl8366-smi is not set
# CONFIG_PACKAGE_kmod-switch-rtl8366rb is not set
# CONFIG_PACKAGE_kmod-switch-rtl8366s is not set
# CONFIG_PACKAGE_kmod-switch-rtl8367b is not set
# CONFIG_PACKAGE_kmod-tg3 is not set
# CONFIG_PACKAGE_kmod-tulip is not set
# CONFIG_PACKAGE_kmod-via-rhine is not set
# CONFIG_PACKAGE_kmod-via-velocity is not set
# CONFIG_PACKAGE_kmod-vmxnet3 is not set
# end of Network Devices
#
# Network Support
#
# CONFIG_PACKAGE_kmod-atm is not set
# CONFIG_PACKAGE_kmod-ax25 is not set
# CONFIG_PACKAGE_kmod-batman-adv is not set
# CONFIG_PACKAGE_kmod-bonding is not set
# CONFIG_PACKAGE_kmod-bpf-test is not set
# CONFIG_PACKAGE_kmod-dnsresolver is not set
# CONFIG_PACKAGE_kmod-fast-classifier is not set
# CONFIG_PACKAGE_kmod-fast-classifier-noload is not set
# CONFIG_PACKAGE_kmod-fou is not set
# CONFIG_PACKAGE_kmod-fou6 is not set
# CONFIG_PACKAGE_kmod-geneve is not set
# CONFIG_PACKAGE_kmod-gre is not set
# CONFIG_PACKAGE_kmod-gre6 is not set
# CONFIG_PACKAGE_kmod-ip6-tunnel is not set
# CONFIG_PACKAGE_kmod-ipip is not set
# CONFIG_PACKAGE_kmod-ipsec is not set
# CONFIG_PACKAGE_kmod-iptunnel6 is not set
# CONFIG_PACKAGE_kmod-isdn4linux is not set
# CONFIG_PACKAGE_kmod-jool is not set
# CONFIG_PACKAGE_kmod-l2tp is not set
# CONFIG_PACKAGE_kmod-l2tp-eth is not set
# CONFIG_PACKAGE_kmod-l2tp-ip is not set
# CONFIG_PACKAGE_kmod-macremapper is not set
# CONFIG_PACKAGE_kmod-macsec is not set
# CONFIG_PACKAGE_kmod-misdn is not set
# CONFIG_PACKAGE_kmod-mpls is not set
# CONFIG_PACKAGE_kmod-nat46 is not set
# CONFIG_PACKAGE_kmod-netem is not set
# CONFIG_PACKAGE_kmod-netlink-diag is not set
# CONFIG_PACKAGE_kmod-nlmon is not set
# CONFIG_PACKAGE_kmod-nsh is not set
# CONFIG_PACKAGE_kmod-openvswitch is not set
# CONFIG_PACKAGE_kmod-openvswitch-geneve is not set
# CONFIG_PACKAGE_kmod-openvswitch-gre is not set
# CONFIG_PACKAGE_kmod-openvswitch-vxlan is not set
# CONFIG_PACKAGE_kmod-pf-ring is not set
# CONFIG_PACKAGE_kmod-pktgen is not set
CONFIG_PACKAGE_kmod-ppp=y
CONFIG_PACKAGE_kmod-mppe=y
# CONFIG_PACKAGE_kmod-ppp-synctty is not set
# CONFIG_PACKAGE_kmod-pppoa is not set
CONFIG_PACKAGE_kmod-pppoe=y
# CONFIG_PACKAGE_kmod-pppol2tp is not set
CONFIG_PACKAGE_kmod-pppox=y
# CONFIG_PACKAGE_kmod-pptp is not set
# CONFIG_PACKAGE_kmod-qca-nss-ecm-noload is not set
# CONFIG_PACKAGE_kmod-qca-nss-ecm-premium is not set
# CONFIG_PACKAGE_kmod-qca-nss-ecm-premium-noload is not set
# CONFIG_PACKAGE_kmod-qca-nss-ecm-standard is not set
# CONFIG_PACKAGE_kmod-sched is not set
# CONFIG_PACKAGE_kmod-sched-act-vlan is not set
# CONFIG_PACKAGE_kmod-sched-bpf is not set
# CONFIG_PACKAGE_kmod-sched-cake is not set
# CONFIG_PACKAGE_kmod-sched-connmark is not set
# CONFIG_PACKAGE_kmod-sched-core is not set
# CONFIG_PACKAGE_kmod-sched-ctinfo is not set
# CONFIG_PACKAGE_kmod-sched-flower is not set
# CONFIG_PACKAGE_kmod-sched-ipset is not set
# CONFIG_PACKAGE_kmod-sched-mqprio is not set
# CONFIG_PACKAGE_kmod-sctp is not set
# CONFIG_PACKAGE_kmod-shortcut-fe is not set
# CONFIG_PACKAGE_kmod-shortcut-fe-cm is not set
# CONFIG_PACKAGE_kmod-sit is not set
CONFIG_PACKAGE_kmod-slhc=y
# CONFIG_PACKAGE_kmod-slip is not set
CONFIG_PACKAGE_kmod-tcp-bbr=y
# CONFIG_PACKAGE_kmod-tcp-hybla is not set
# CONFIG_PACKAGE_kmod-trelay is not set
CONFIG_PACKAGE_kmod-tun=y
# CONFIG_PACKAGE_kmod-veth is not set
# CONFIG_PACKAGE_kmod-vxlan is not set
# CONFIG_PACKAGE_kmod-wireguard is not set
# end of Network Support
#
# Other modules
#
# CONFIG_PACKAGE_kmod-6lowpan is not set
# CONFIG_PACKAGE_kmod-ath3k is not set
# CONFIG_PACKAGE_kmod-bcma is not set
# CONFIG_PACKAGE_kmod-bluetooth is not set
# CONFIG_PACKAGE_kmod-bluetooth-6lowpan is not set
# CONFIG_PACKAGE_kmod-btmrvl is not set
# CONFIG_PACKAGE_kmod-button-hotplug is not set
# CONFIG_PACKAGE_kmod-dma-ralink is not set
# CONFIG_PACKAGE_kmod-echo is not set
# CONFIG_PACKAGE_kmod-eeprom-93cx6 is not set
# CONFIG_PACKAGE_kmod-eeprom-at24 is not set
# CONFIG_PACKAGE_kmod-eeprom-at25 is not set
# CONFIG_PACKAGE_kmod-gpio-beeper is not set
CONFIG_PACKAGE_kmod-gpio-button-hotplug=y
# CONFIG_PACKAGE_kmod-gpio-dev is not set
# CONFIG_PACKAGE_kmod-gpio-mcp23s08 is not set
# CONFIG_PACKAGE_kmod-gpio-nxp-74hc164 is not set
# CONFIG_PACKAGE_kmod-gpio-pca953x is not set
# CONFIG_PACKAGE_kmod-gpio-pcf857x is not set
# CONFIG_PACKAGE_kmod-hsdma-mtk is not set
# CONFIG_PACKAGE_kmod-ikconfig is not set
# CONFIG_PACKAGE_kmod-it87-wdt is not set
# CONFIG_PACKAGE_kmod-itco-wdt is not set
# CONFIG_PACKAGE_kmod-keys-encrypted is not set
# CONFIG_PACKAGE_kmod-keys-trusted is not set
# CONFIG_PACKAGE_kmod-lp is not set
# CONFIG_PACKAGE_kmod-mmc is not set
# CONFIG_PACKAGE_kmod-mtd-rw is not set
# CONFIG_PACKAGE_kmod-mtdoops is not set
# CONFIG_PACKAGE_kmod-mtdram is not set
# CONFIG_PACKAGE_kmod-mtdtests is not set
# CONFIG_PACKAGE_kmod-parport-pc is not set
# CONFIG_PACKAGE_kmod-ppdev is not set
# CONFIG_PACKAGE_kmod-pps is not set
# CONFIG_PACKAGE_kmod-pps-gpio is not set
# CONFIG_PACKAGE_kmod-pps-ldisc is not set
# CONFIG_PACKAGE_kmod-ptp is not set
# CONFIG_PACKAGE_kmod-random-core is not set
# CONFIG_PACKAGE_kmod-rtc-ds1307 is not set
# CONFIG_PACKAGE_kmod-rtc-ds1374 is not set
# CONFIG_PACKAGE_kmod-rtc-ds1672 is not set
# CONFIG_PACKAGE_kmod-rtc-em3027 is not set
# CONFIG_PACKAGE_kmod-rtc-isl1208 is not set
# CONFIG_PACKAGE_kmod-rtc-pcf2123 is not set
# CONFIG_PACKAGE_kmod-rtc-pcf2127 is not set
# CONFIG_PACKAGE_kmod-rtc-pcf8563 is not set
# CONFIG_PACKAGE_kmod-rtc-pt7c4338 is not set
# CONFIG_PACKAGE_kmod-rtc-rs5c372a is not set
# CONFIG_PACKAGE_kmod-rtc-rx8025 is not set
# CONFIG_PACKAGE_kmod-rtc-s35390a is not set
# CONFIG_PACKAGE_kmod-sdhci is not set
# CONFIG_PACKAGE_kmod-sdhci-mt7620 is not set
# CONFIG_PACKAGE_kmod-serial-8250 is not set
# CONFIG_PACKAGE_kmod-serial-8250-exar is not set
# CONFIG_PACKAGE_kmod-softdog is not set
# CONFIG_PACKAGE_kmod-ssb is not set
# CONFIG_PACKAGE_kmod-tpm is not set
# CONFIG_PACKAGE_kmod-tpm-i2c-atmel is not set
# CONFIG_PACKAGE_kmod-tpm-i2c-infineon is not set
# CONFIG_PACKAGE_kmod-w83627hf-wdt is not set
# CONFIG_PACKAGE_kmod-zram is not set
# end of Other modules
#
# PCMCIA support
#
# end of PCMCIA support
#
# SPI Support
#
# CONFIG_PACKAGE_kmod-mmc-spi is not set
# CONFIG_PACKAGE_kmod-spi-bitbang is not set
# CONFIG_PACKAGE_kmod-spi-dev is not set
# CONFIG_PACKAGE_kmod-spi-gpio is not set
# end of SPI Support
#
# Sound Support
#
# CONFIG_PACKAGE_kmod-sound-core is not set
# end of Sound Support
#
# USB Support
#
# CONFIG_PACKAGE_kmod-chaoskey is not set
# CONFIG_PACKAGE_kmod-usb-acm is not set
# CONFIG_PACKAGE_kmod-usb-atm is not set
# CONFIG_PACKAGE_kmod-usb-cm109 is not set
CONFIG_PACKAGE_kmod-usb-core=y
# CONFIG_PACKAGE_kmod-usb-dwc2 is not set
# CONFIG_PACKAGE_kmod-usb-dwc3 is not set
CONFIG_PACKAGE_kmod-usb-ehci=y
# CONFIG_PACKAGE_kmod-usb-hid is not set
# CONFIG_PACKAGE_kmod-usb-hid-cp2112 is not set
# CONFIG_PACKAGE_kmod-usb-ledtrig-usbport is not set
# CONFIG_PACKAGE_kmod-usb-net is not set
# CONFIG_PACKAGE_kmod-usb-net-aqc111 is not set
# CONFIG_PACKAGE_kmod-usb-net-asix is not set
# CONFIG_PACKAGE_kmod-usb-net-asix-ax88179 is not set
# CONFIG_PACKAGE_kmod-usb-net-cdc-eem is not set
# CONFIG_PACKAGE_kmod-usb-net-cdc-ether is not set
# CONFIG_PACKAGE_kmod-usb-net-cdc-mbim is not set
# CONFIG_PACKAGE_kmod-usb-net-cdc-ncm is not set
# CONFIG_PACKAGE_kmod-usb-net-cdc-subset is not set
# CONFIG_PACKAGE_kmod-usb-net-dm9601-ether is not set
# CONFIG_PACKAGE_kmod-usb-net-hso is not set
# CONFIG_PACKAGE_kmod-usb-net-huawei-cdc-ncm is not set
# CONFIG_PACKAGE_kmod-usb-net-ipheth is not set
# CONFIG_PACKAGE_kmod-usb-net-kalmia is not set
# CONFIG_PACKAGE_kmod-usb-net-kaweth is not set
# CONFIG_PACKAGE_kmod-usb-net-mcs7830 is not set
# CONFIG_PACKAGE_kmod-usb-net-pegasus is not set
# CONFIG_PACKAGE_kmod-usb-net-pl is not set
# CONFIG_PACKAGE_kmod-usb-net-qmi-wwan is not set
# CONFIG_PACKAGE_kmod-usb-net-rndis is not set
# CONFIG_PACKAGE_kmod-usb-net-rtl8150 is not set
# CONFIG_PACKAGE_kmod-usb-net-rtl8152 is not set
# CONFIG_PACKAGE_kmod-usb-net-rtl8152-vendor is not set
# CONFIG_PACKAGE_kmod-usb-net-sierrawireless is not set
# CONFIG_PACKAGE_kmod-usb-net-smsc95xx is not set
# CONFIG_PACKAGE_kmod-usb-net-sr9700 is not set
# CONFIG_PACKAGE_kmod-usb-ohci is not set
# CONFIG_PACKAGE_kmod-usb-ohci-pci is not set
# CONFIG_PACKAGE_kmod-usb-printer is not set
# CONFIG_PACKAGE_kmod-usb-serial is not set
# CONFIG_PACKAGE_kmod-usb-serial-ark3116 is not set
# CONFIG_PACKAGE_kmod-usb-serial-belkin is not set
# CONFIG_PACKAGE_kmod-usb-serial-ch341 is not set
# CONFIG_PACKAGE_kmod-usb-serial-cp210x is not set
# CONFIG_PACKAGE_kmod-usb-serial-cypress-m8 is not set
# CONFIG_PACKAGE_kmod-usb-serial-edgeport is not set
# CONFIG_PACKAGE_kmod-usb-serial-ftdi is not set
# CONFIG_PACKAGE_kmod-usb-serial-garmin is not set
# CONFIG_PACKAGE_kmod-usb-serial-ipw is not set
# CONFIG_PACKAGE_kmod-usb-serial-keyspan is not set
# CONFIG_PACKAGE_kmod-usb-serial-mct is not set
# CONFIG_PACKAGE_kmod-usb-serial-mos7720 is not set
# CONFIG_PACKAGE_kmod-usb-serial-mos7840 is not set
# CONFIG_PACKAGE_kmod-usb-serial-option is not set
# CONFIG_PACKAGE_kmod-usb-serial-oti6858 is not set
# CONFIG_PACKAGE_kmod-usb-serial-pl2303 is not set
# CONFIG_PACKAGE_kmod-usb-serial-qualcomm is not set
# CONFIG_PACKAGE_kmod-usb-serial-sierrawireless is not set
# CONFIG_PACKAGE_kmod-usb-serial-simple is not set
# CONFIG_PACKAGE_kmod-usb-serial-ti-usb is not set
# CONFIG_PACKAGE_kmod-usb-serial-visor is not set
CONFIG_PACKAGE_kmod-usb-storage=y
CONFIG_PACKAGE_kmod-usb-storage-extras=y
# CONFIG_PACKAGE_kmod-usb-storage-uas is not set
# CONFIG_PACKAGE_kmod-usb-uhci is not set
# CONFIG_PACKAGE_kmod-usb-wdm is not set
CONFIG_PACKAGE_kmod-usb-xhci-hcd=y
CONFIG_PACKAGE_kmod-usb-xhci-mtk=y
# CONFIG_PACKAGE_kmod-usb-yealink is not set
CONFIG_PACKAGE_kmod-usb2=y
# CONFIG_PACKAGE_kmod-usb2-pci is not set
CONFIG_PACKAGE_kmod-usb3=y
# CONFIG_PACKAGE_kmod-usbip is not set
# CONFIG_PACKAGE_kmod-usbip-client is not set
# CONFIG_PACKAGE_kmod-usbip-server is not set
# CONFIG_PACKAGE_kmod-usbmon is not set
# end of USB Support
#
# Video Support
#
# CONFIG_PACKAGE_kmod-multimedia-input is not set
# CONFIG_PACKAGE_kmod-video-core is not set
# end of Video Support
#
# Virtualization
#
# end of Virtualization
#
# Voice over IP
#
# CONFIG_PACKAGE_kmod-dahdi is not set
# end of Voice over IP
#
# W1 support
#
# CONFIG_PACKAGE_kmod-w1 is not set
# end of W1 support
#
# WPAN 802.15.4 Support
#
# CONFIG_PACKAGE_kmod-at86rf230 is not set
# CONFIG_PACKAGE_kmod-atusb is not set
# CONFIG_PACKAGE_kmod-ca8210 is not set
# CONFIG_PACKAGE_kmod-cc2520 is not set
# CONFIG_PACKAGE_kmod-fakelb is not set
# CONFIG_PACKAGE_kmod-ieee802154 is not set
# CONFIG_PACKAGE_kmod-ieee802154-6lowpan is not set
# CONFIG_PACKAGE_kmod-mac802154 is not set
# CONFIG_PACKAGE_kmod-mrf24j40 is not set
# end of WPAN 802.15.4 Support
#
# Wireless Drivers
#
# CONFIG_PACKAGE_kmod-acx-mac80211 is not set
# CONFIG_PACKAGE_kmod-adm8211 is not set
# CONFIG_PACKAGE_kmod-ar5523 is not set
# CONFIG_PACKAGE_kmod-ath is not set
# CONFIG_PACKAGE_kmod-ath10k is not set
# CONFIG_PACKAGE_kmod-ath10k-ct is not set
# CONFIG_PACKAGE_kmod-ath10k-ct-smallbuffers is not set
# CONFIG_PACKAGE_kmod-ath11k is not set
# CONFIG_PACKAGE_kmod-ath5k is not set
# CONFIG_PACKAGE_kmod-ath6kl-sdio is not set
# CONFIG_PACKAGE_kmod-ath6kl-usb is not set
# CONFIG_PACKAGE_kmod-ath9k is not set
# CONFIG_PACKAGE_kmod-ath9k-htc is not set
# CONFIG_PACKAGE_kmod-b43 is not set
# CONFIG_PACKAGE_kmod-b43legacy is not set
# CONFIG_PACKAGE_kmod-brcmfmac is not set
# CONFIG_PACKAGE_kmod-brcmsmac is not set
# CONFIG_PACKAGE_kmod-brcmutil is not set
# CONFIG_PACKAGE_kmod-carl9170 is not set
# CONFIG_PACKAGE_kmod-cfg80211 is not set
# CONFIG_PACKAGE_kmod-hermes is not set
# CONFIG_PACKAGE_kmod-hermes-pci is not set
# CONFIG_PACKAGE_kmod-hermes-plx is not set
# CONFIG_PACKAGE_kmod-ipw2100 is not set
# CONFIG_PACKAGE_kmod-ipw2200 is not set
# CONFIG_PACKAGE_kmod-iwl-legacy is not set
# CONFIG_PACKAGE_kmod-iwl3945 is not set
# CONFIG_PACKAGE_kmod-iwl4965 is not set
# CONFIG_PACKAGE_kmod-iwlwifi is not set
# CONFIG_PACKAGE_kmod-lib80211 is not set
# CONFIG_PACKAGE_kmod-libertas-sdio is not set
# CONFIG_PACKAGE_kmod-libertas-spi is not set
# CONFIG_PACKAGE_kmod-libertas-usb is not set
# CONFIG_PACKAGE_kmod-libipw is not set
# CONFIG_PACKAGE_kmod-mac80211 is not set
# CONFIG_PACKAGE_kmod-mac80211-hwsim is not set
# CONFIG_PACKAGE_kmod-mt76 is not set
# CONFIG_PACKAGE_kmod-mt7601u is not set
# CONFIG_PACKAGE_kmod-mt7603 is not set
# CONFIG_PACKAGE_kmod-mt7603e is not set
# CONFIG_PACKAGE_kmod-mt7615-firmware is not set
CONFIG_PACKAGE_kmod-mt7615d=y
CONFIG_MTK_SUPPORT_OPENWRT=y
CONFIG_MTK_WIFI_DRIVER=y
CONFIG_MTK_FIRST_IF_MT7615E=y
# CONFIG_MTK_FIRST_IF_MT7622 is not set
# CONFIG_MTK_FIRST_IF_MT7626 is not set
# CONFIG_MTK_FIRST_IF_NONE is not set
# CONFIG_MTK_SECOND_IF_NONE is not set
CONFIG_MTK_SECOND_IF_MT7615E=y
CONFIG_MTK_THIRD_IF_NONE=y
# CONFIG_MTK_THIRD_IF_MT7615E is not set
CONFIG_MTK_RT_FIRST_CARD=7615
CONFIG_MTK_RT_SECOND_CARD=7615
CONFIG_MTK_RT_FIRST_IF_RF_OFFSET=0xc0000
CONFIG_MTK_RT_SECOND_IF_RF_OFFSET=0xc8000
CONFIG_MTK_MT_WIFI=y
CONFIG_MTK_MT_WIFI_PATH="mt_wifi"
#
# WiFi Generic Feature Options
#
CONFIG_MTK_FIRST_IF_EEPROM_FLASH=y
# CONFIG_MTK_FIRST_IF_EEPROM_PROM is not set
# CONFIG_MTK_FIRST_IF_EEPROM_EFUSE is not set
CONFIG_MTK_RT_FIRST_CARD_EEPROM="flash"
CONFIG_MTK_SECOND_IF_EEPROM_FLASH=y
# CONFIG_MTK_SECOND_IF_EEPROM_PROM is not set
# CONFIG_MTK_SECOND_IF_EEPROM_EFUSE is not set
CONFIG_MTK_RT_SECOND_CARD_EEPROM="flash"
CONFIG_MTK_MULTI_INF_SUPPORT=y
CONFIG_MTK_WIFI_BASIC_FUNC=y
CONFIG_MTK_DOT11_N_SUPPORT=y
CONFIG_MTK_DOT11_VHT_AC=y
CONFIG_MTK_G_BAND_256QAM_SUPPORT=y
CONFIG_MTK_BRCM_256QAM_SUPPORT=y
CONFIG_MTK_VHT_TXBF_2G_EPIGRAM_IE_SUPPORT=y
CONFIG_MTK_TPC_SUPPORT=y
CONFIG_MTK_ICAP_SUPPORT=y
CONFIG_MTK_SPECTRUM_SUPPORT=y
CONFIG_MTK_BACKGROUND_SCAN_SUPPORT=y
CONFIG_MTK_SMART_CARRIER_SENSE_SUPPORT=y
CONFIG_MTK_MT_DFS_SUPPORT=y
CONFIG_MTK_HDR_TRANS_TX_SUPPORT=y
CONFIG_MTK_HDR_TRANS_RX_SUPPORT=y
CONFIG_MTK_DBDC_MODE=y
CONFIG_MTK_MULTI_PROFILE_SUPPORT=y
CONFIG_MTK_WSC_INCLUDED=y
CONFIG_MTK_WSC_V2_SUPPORT=y
CONFIG_MTK_DOT11W_PMF_SUPPORT=y
CONFIG_MTK_TXBF_SUPPORT=y
# CONFIG_MTK_FAST_NAT_SUPPORT is not set
# CONFIG_MTK_FTM_SUPPORT is not set
CONFIG_MTK_IGMP_SNOOP_SUPPORT=y
CONFIG_MTK_RTMP_FLASH_SUPPORT=y
CONFIG_MTK_PRE_CAL_TRX_SET1_SUPPORT=y
CONFIG_MTK_RLM_CAL_CACHE_SUPPORT=y
CONFIG_MTK_PRE_CAL_TRX_SET2_SUPPORT=y
# CONFIG_MTK_RF_LOCKDOWN_SUPPORT is not set
# CONFIG_MTK_LINK_TEST_SUPPORT is not set
CONFIG_MTK_ATE_SUPPORT=y
# CONFIG_MTK_PASSPOINT_R2 is not set
# CONFIG_MTK_MBO_SUPPORT is not set
CONFIG_MTK_UAPSD=y
CONFIG_MTK_TCP_RACK_SUPPORT=y
CONFIG_MTK_RED_SUPPORT=y
# CONFIG_MTK_FDB_SUPPORT is not set
CONFIG_MTK_FIRST_IF_IPAILNA=y
# CONFIG_MTK_FIRST_IF_IPAELNA is not set
# CONFIG_MTK_FIRST_IF_EPAELNA is not set
CONFIG_MTK_SECOND_IF_IPAILNA=y
# CONFIG_MTK_SECOND_IF_IPAELNA is not set
# CONFIG_MTK_SECOND_IF_EPAELNA is not set
# CONFIG_MTK_RLT_MAC is not set
# CONFIG_MTK_RTMP_MAC is not set
# end of WiFi Generic Feature Options
#
# WiFi Operation Modes
#
CONFIG_MTK_WIFI_MODE_AP=y
# CONFIG_MTK_WIFI_MODE_STA is not set
# CONFIG_MTK_WIFI_MODE_BOTH is not set
CONFIG_MTK_MT_AP_SUPPORT=y
CONFIG_MTK_WDS_SUPPORT=y
CONFIG_MTK_MBSS_SUPPORT=y
CONFIG_MTK_APCLI_SUPPORT=y
# CONFIG_MTK_APCLI_CERT_SUPPORT is not set
CONFIG_MTK_MAC_REPEATER_SUPPORT=y
# CONFIG_MTK_MWDS is not set
CONFIG_MTK_MUMIMO_SUPPORT=y
CONFIG_MTK_MU_RA_SUPPORT=y
# CONFIG_MTK_DOT11R_FT_SUPPORT is not set
# CONFIG_MTK_DOT11K_RRM_SUPPORT is not set
# CONFIG_MTK_CFG80211_SUPPORT is not set
# CONFIG_MTK_DSCP_PRI_SUPPORT is not set
# CONFIG_MTK_CON_WPS_SUPPORT is not set
CONFIG_MTK_MCAST_RATE_SPECIFIC=y
CONFIG_MTK_VOW_SUPPORT=y
CONFIG_MTK_BAND_STEERING=y
CONFIG_MTK_LED_CONTROL_SUPPORT=y
# CONFIG_MTK_WLAN_HOOK is not set
# CONFIG_MTK_RADIUS_ACCOUNTING_SUPPORT is not set
# CONFIG_MTK_GREENAP_SUPPORT is not set
CONFIG_MTK_PCIE_ASPM_DYM_CTRL_SUPPORT=y
# CONFIG_MTK_COEX_SUPPORT is not set
# CONFIG_MTK_EASY_SETUP_SUPPORT is not set
# CONFIG_MTK_EVENT_NOTIFIER_SUPPORT is not set
# CONFIG_MTK_AIR_MONITOR is not set
# CONFIG_MTK_WNM_SUPPORT is not set
# CONFIG_MTK_INTERWORKING is not set
CONFIG_MTK_LINUX_NET_TXQ_SUPPORT=y
# end of WiFi Operation Modes
CONFIG_MTK_WIFI_MT_MAC=y
CONFIG_MTK_MT_MAC=y
# CONFIG_MTK_CHIP_MT7603E is not set
CONFIG_MTK_CHIP_MT7615E=y
# CONFIG_MTK_CHIP_MT7622 is not set
# CONFIG_MTK_CHIP_MT7663E is not set
# CONFIG_MTK_CHIP_MT7626 is not set
CONFIG_PACKAGE_kmod-mt7615d_dbdc=y
# CONFIG_PACKAGE_kmod-mt7615e is not set
# CONFIG_PACKAGE_kmod-mt7663-firmware-ap is not set
# CONFIG_PACKAGE_kmod-mt7663-firmware-sta is not set
# CONFIG_PACKAGE_kmod-mt7663s is not set
# CONFIG_PACKAGE_kmod-mt7663u is not set
# CONFIG_PACKAGE_kmod-mt76x0e is not set
# CONFIG_PACKAGE_kmod-mt76x0u is not set
# CONFIG_PACKAGE_kmod-mt76x2 is not set
# CONFIG_PACKAGE_kmod-mt76x2e is not set
# CONFIG_PACKAGE_kmod-mt76x2u is not set
# CONFIG_PACKAGE_kmod-mt7915e is not set
# CONFIG_PACKAGE_kmod-mt7921e is not set
# CONFIG_PACKAGE_kmod-mwifiex-pcie is not set
# CONFIG_PACKAGE_kmod-mwifiex-sdio is not set
# CONFIG_PACKAGE_kmod-mwl8k is not set
# CONFIG_PACKAGE_kmod-net-prism54 is not set
# CONFIG_PACKAGE_kmod-net-rtl8192su is not set
# CONFIG_PACKAGE_kmod-owl-loader is not set
# CONFIG_PACKAGE_kmod-p54-common is not set
# CONFIG_PACKAGE_kmod-p54-pci is not set
# CONFIG_PACKAGE_kmod-p54-usb is not set
# CONFIG_PACKAGE_kmod-qtn-pcie2 is not set
# CONFIG_PACKAGE_kmod-rsi91x is not set
# CONFIG_PACKAGE_kmod-rsi91x-sdio is not set
# CONFIG_PACKAGE_kmod-rsi91x-usb is not set
# CONFIG_PACKAGE_kmod-rt2400-pci is not set
# CONFIG_PACKAGE_kmod-rt2500-pci is not set
# CONFIG_PACKAGE_kmod-rt2500-usb is not set
# CONFIG_PACKAGE_kmod-rt2800-pci is not set
# CONFIG_PACKAGE_kmod-rt2800-usb is not set
# CONFIG_PACKAGE_kmod-rt2x00-lib is not set
# CONFIG_PACKAGE_kmod-rt61-pci is not set
# CONFIG_PACKAGE_kmod-rt73-usb is not set
# CONFIG_PACKAGE_kmod-rtl8180 is not set
# CONFIG_PACKAGE_kmod-rtl8187 is not set
# CONFIG_PACKAGE_kmod-rtl8192ce is not set
# CONFIG_PACKAGE_kmod-rtl8192cu is not set
# CONFIG_PACKAGE_kmod-rtl8192de is not set
# CONFIG_PACKAGE_kmod-rtl8192se is not set
# CONFIG_PACKAGE_kmod-rtl8723bs is not set
# CONFIG_PACKAGE_kmod-rtl8812au-ct is not set
# CONFIG_PACKAGE_kmod-rtl8821ae is not set
# CONFIG_PACKAGE_kmod-rtl8xxxu is not set
# CONFIG_PACKAGE_kmod-rtw88 is not set
# CONFIG_PACKAGE_kmod-wil6210 is not set
# CONFIG_PACKAGE_kmod-wl12xx is not set
# CONFIG_PACKAGE_kmod-wl18xx is not set
# CONFIG_PACKAGE_kmod-wlcore is not set
# CONFIG_PACKAGE_kmod-zd1211rw is not set
# end of Wireless Drivers
# end of Kernel modules
#
# Languages
#
#
# Erlang
#
# CONFIG_PACKAGE_erlang is not set
# CONFIG_PACKAGE_erlang-asn1 is not set
# CONFIG_PACKAGE_erlang-compiler is not set
# CONFIG_PACKAGE_erlang-crypto is not set
# CONFIG_PACKAGE_erlang-erl-interface is not set
# CONFIG_PACKAGE_erlang-hipe is not set
# CONFIG_PACKAGE_erlang-inets is not set
# CONFIG_PACKAGE_erlang-mnesia is not set
# CONFIG_PACKAGE_erlang-os_mon is not set
# CONFIG_PACKAGE_erlang-public-key is not set
# CONFIG_PACKAGE_erlang-reltool is not set
# CONFIG_PACKAGE_erlang-runtime-tools is not set
# CONFIG_PACKAGE_erlang-snmp is not set
# CONFIG_PACKAGE_erlang-ssh is not set
# CONFIG_PACKAGE_erlang-ssl is not set
# CONFIG_PACKAGE_erlang-syntax-tools is not set
# CONFIG_PACKAGE_erlang-tools is not set
# CONFIG_PACKAGE_erlang-xmerl is not set
# end of Erlang
#
# Go
#
# CONFIG_PACKAGE_golang is not set
#
# Configuration
#
CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT=""
CONFIG_GOLANG_BUILD_CACHE_DIR=""
# CONFIG_GOLANG_MOD_CACHE_WORLD_READABLE is not set
# end of Configuration
# CONFIG_PACKAGE_golang-doc is not set
# CONFIG_PACKAGE_golang-github-jedisct1-dnscrypt-proxy2-dev is not set
# CONFIG_PACKAGE_golang-github-nextdns-nextdns-dev is not set
# CONFIG_PACKAGE_golang-gitlab-yawning-obfs4-dev is not set
# CONFIG_PACKAGE_golang-src is not set
# CONFIG_PACKAGE_golang-torproject-tor-fw-helper-dev is not set
# end of Go
#
# Lua
#
# CONFIG_PACKAGE_dkjson is not set
# CONFIG_PACKAGE_json4lua is not set
# CONFIG_PACKAGE_ldbus is not set
CONFIG_PACKAGE_libiwinfo-lua=y
# CONFIG_PACKAGE_linotify is not set
# CONFIG_PACKAGE_lpeg is not set
# CONFIG_PACKAGE_lsqlite3 is not set
CONFIG_PACKAGE_lua=y
# CONFIG_PACKAGE_lua-argparse is not set
# CONFIG_PACKAGE_lua-bencode is not set
# CONFIG_PACKAGE_lua-bit32 is not set
# CONFIG_PACKAGE_lua-cjson is not set
# CONFIG_PACKAGE_lua-copas is not set
# CONFIG_PACKAGE_lua-coxpcall is not set
# CONFIG_PACKAGE_lua-ev is not set
# CONFIG_PACKAGE_lua-examples is not set
# CONFIG_PACKAGE_lua-libmodbus is not set
# CONFIG_PACKAGE_lua-lzlib is not set
# CONFIG_PACKAGE_lua-md5 is not set
# CONFIG_PACKAGE_lua-mobdebug is not set
# CONFIG_PACKAGE_lua-mosquitto is not set
# CONFIG_PACKAGE_lua-openssl is not set
# CONFIG_PACKAGE_lua-penlight is not set
# CONFIG_PACKAGE_lua-rings is not set
# CONFIG_PACKAGE_lua-rs232 is not set
# CONFIG_PACKAGE_lua-sha2 is not set
# CONFIG_PACKAGE_lua-wsapi-base is not set
# CONFIG_PACKAGE_lua-wsapi-xavante is not set
# CONFIG_PACKAGE_lua-xavante is not set
# CONFIG_PACKAGE_lua5.3 is not set
# CONFIG_PACKAGE_luabitop is not set
# CONFIG_PACKAGE_luac is not set
# CONFIG_PACKAGE_luac5.3 is not set
# CONFIG_PACKAGE_luaexpat is not set
# CONFIG_PACKAGE_luafilesystem is not set
# CONFIG_PACKAGE_luajit is not set
# CONFIG_PACKAGE_lualanes is not set
# CONFIG_PACKAGE_luaposix is not set
# CONFIG_PACKAGE_luarocks is not set
# CONFIG_PACKAGE_luasec is not set
# CONFIG_PACKAGE_luasoap is not set
# CONFIG_PACKAGE_luasocket is not set
# CONFIG_PACKAGE_luasocket5.3 is not set
# CONFIG_PACKAGE_luasql-mysql is not set
# CONFIG_PACKAGE_luasql-pgsql is not set
# CONFIG_PACKAGE_luasql-sqlite3 is not set
# CONFIG_PACKAGE_luasrcdiet is not set
# CONFIG_PACKAGE_luci-lib-fs is not set
# CONFIG_PACKAGE_luv is not set
# CONFIG_PACKAGE_lyaml is not set
# CONFIG_PACKAGE_lzmq is not set
# CONFIG_PACKAGE_uuid is not set
# end of Lua
#
# Node.js
#
# CONFIG_PACKAGE_node is not set
# CONFIG_PACKAGE_node-arduino-firmata is not set
# CONFIG_PACKAGE_node-cylon is not set
# CONFIG_PACKAGE_node-cylon-firmata is not set
# CONFIG_PACKAGE_node-cylon-gpio is not set
# CONFIG_PACKAGE_node-cylon-i2c is not set
# CONFIG_PACKAGE_node-hid is not set
# CONFIG_PACKAGE_node-homebridge is not set
# CONFIG_PACKAGE_node-javascript-obfuscator is not set
# CONFIG_PACKAGE_node-npm is not set
# CONFIG_PACKAGE_node-serialport is not set
# CONFIG_PACKAGE_node-serialport-bindings is not set
# end of Node.js
#
# PHP7
#
# CONFIG_PACKAGE_php7 is not set
# end of PHP7
#
# PHP8
#
# CONFIG_PACKAGE_php8 is not set
# end of PHP8
#
# Perl
#
# CONFIG_PACKAGE_perl is not set
# end of Perl
#
# Python
#
# CONFIG_PACKAGE_libpython3 is not set
# CONFIG_PACKAGE_micropython is not set
# CONFIG_PACKAGE_micropython-lib is not set
# CONFIG_PACKAGE_python-pip-conf is not set
# CONFIG_PACKAGE_python3 is not set
# CONFIG_PACKAGE_python3-aiohttp is not set
# CONFIG_PACKAGE_python3-aiohttp-cors is not set
# CONFIG_PACKAGE_python3-apipkg is not set
# CONFIG_PACKAGE_python3-apparmor is not set
# CONFIG_PACKAGE_python3-appdirs is not set
# CONFIG_PACKAGE_python3-asgiref is not set
# CONFIG_PACKAGE_python3-asn1crypto is not set
# CONFIG_PACKAGE_python3-astral is not set
# CONFIG_PACKAGE_python3-async-timeout is not set
# CONFIG_PACKAGE_python3-asyncio is not set
# CONFIG_PACKAGE_python3-atomicwrites is not set
# CONFIG_PACKAGE_python3-attrs is not set
# CONFIG_PACKAGE_python3-augeas is not set
# CONFIG_PACKAGE_python3-automat is not set
# CONFIG_PACKAGE_python3-awscli is not set
# CONFIG_PACKAGE_python3-babel is not set
# CONFIG_PACKAGE_python3-base is not set
# CONFIG_PACKAGE_python3-bcrypt is not set
# CONFIG_PACKAGE_python3-bidict is not set
# CONFIG_PACKAGE_python3-boto3 is not set
# CONFIG_PACKAGE_python3-botocore is not set
# CONFIG_PACKAGE_python3-bottle is not set
# CONFIG_PACKAGE_python3-cached-property is not set
# CONFIG_PACKAGE_python3-cachelib is not set
# CONFIG_PACKAGE_python3-cachetools is not set
# CONFIG_PACKAGE_python3-certifi is not set
# CONFIG_PACKAGE_python3-cffi is not set
# CONFIG_PACKAGE_python3-cgi is not set
# CONFIG_PACKAGE_python3-cgitb is not set
# CONFIG_PACKAGE_python3-chardet is not set
# CONFIG_PACKAGE_python3-ciso8601 is not set
# CONFIG_PACKAGE_python3-click is not set
# CONFIG_PACKAGE_python3-click-log is not set
# CONFIG_PACKAGE_python3-codecs is not set
# CONFIG_PACKAGE_python3-colorama is not set
# CONFIG_PACKAGE_python3-constantly is not set
# CONFIG_PACKAGE_python3-contextlib2 is not set
# CONFIG_PACKAGE_python3-cryptodome is not set
# CONFIG_PACKAGE_python3-cryptodomex is not set
# CONFIG_PACKAGE_python3-cryptography is not set
# CONFIG_PACKAGE_python3-ctypes is not set
# CONFIG_PACKAGE_python3-curl is not set
# CONFIG_PACKAGE_python3-dateutil is not set
# CONFIG_PACKAGE_python3-dbm is not set
# CONFIG_PACKAGE_python3-decimal is not set
# CONFIG_PACKAGE_python3-decorator is not set
# CONFIG_PACKAGE_python3-defusedxml is not set
# CONFIG_PACKAGE_python3-dev is not set
# CONFIG_PACKAGE_python3-distro is not set
# CONFIG_PACKAGE_python3-distutils is not set
# CONFIG_PACKAGE_python3-django is not set
# CONFIG_PACKAGE_python3-django-appconf is not set
# CONFIG_PACKAGE_python3-django-compressor is not set
# CONFIG_PACKAGE_python3-django-cors-headers is not set
# CONFIG_PACKAGE_python3-django-etesync-journal is not set
# CONFIG_PACKAGE_python3-django-formtools is not set
# CONFIG_PACKAGE_python3-django-jsonfield is not set
# CONFIG_PACKAGE_python3-django-jsonfield2 is not set
# CONFIG_PACKAGE_python3-django-picklefield is not set
# CONFIG_PACKAGE_python3-django-postoffice is not set
# CONFIG_PACKAGE_python3-django-ranged-response is not set
# CONFIG_PACKAGE_python3-django-restframework is not set
# CONFIG_PACKAGE_python3-django-restframework39 is not set
# CONFIG_PACKAGE_python3-django-simple-captcha is not set
# CONFIG_PACKAGE_python3-django-statici18n is not set
# CONFIG_PACKAGE_python3-django-webpack-loader is not set
# CONFIG_PACKAGE_python3-django1 is not set
# CONFIG_PACKAGE_python3-dns is not set
# CONFIG_PACKAGE_python3-docker is not set
# CONFIG_PACKAGE_python3-dockerpty is not set
# CONFIG_PACKAGE_python3-docopt is not set
# CONFIG_PACKAGE_python3-docutils is not set
# CONFIG_PACKAGE_python3-dotenv is not set
# CONFIG_PACKAGE_python3-drf-nested-routers is not set
# CONFIG_PACKAGE_python3-email is not set
# CONFIG_PACKAGE_python3-engineio is not set
# CONFIG_PACKAGE_python3-et_xmlfile is not set
# CONFIG_PACKAGE_python3-evdev is not set
# CONFIG_PACKAGE_python3-eventlet is not set
# CONFIG_PACKAGE_python3-execnet is not set
# CONFIG_PACKAGE_python3-flask is not set
# CONFIG_PACKAGE_python3-flask-babel is not set
# CONFIG_PACKAGE_python3-flask-httpauth is not set
# CONFIG_PACKAGE_python3-flask-login is not set
# CONFIG_PACKAGE_python3-flask-seasurf is not set
# CONFIG_PACKAGE_python3-flask-session is not set
# CONFIG_PACKAGE_python3-flask-socketio is not set
# CONFIG_PACKAGE_python3-flup is not set
# CONFIG_PACKAGE_python3-gdbm is not set
# CONFIG_PACKAGE_python3-gmpy2 is not set
# CONFIG_PACKAGE_python3-gnupg is not set
# CONFIG_PACKAGE_python3-gpiod is not set
# CONFIG_PACKAGE_python3-greenlet is not set
# CONFIG_PACKAGE_python3-hyperlink is not set
# CONFIG_PACKAGE_python3-idna is not set
# CONFIG_PACKAGE_python3-ifaddr is not set
# CONFIG_PACKAGE_python3-incremental is not set
# CONFIG_PACKAGE_python3-influxdb is not set
# CONFIG_PACKAGE_python3-iniconfig is not set
# CONFIG_PACKAGE_python3-intelhex is not set
# CONFIG_PACKAGE_python3-itsdangerous is not set
# CONFIG_PACKAGE_python3-jdcal is not set
# CONFIG_PACKAGE_python3-jinja2 is not set
# CONFIG_PACKAGE_python3-jmespath is not set
# CONFIG_PACKAGE_python3-jsonpath-ng is not set
# CONFIG_PACKAGE_python3-jsonschema is not set
# CONFIG_PACKAGE_python3-lib2to3 is not set
# CONFIG_PACKAGE_python3-libmodbus is not set
# CONFIG_PACKAGE_python3-libselinux is not set
# CONFIG_PACKAGE_python3-libsemanage is not set
# CONFIG_PACKAGE_python3-light is not set
#
# Configuration
#
# CONFIG_PYTHON3_BLUETOOTH_SUPPORT is not set
# CONFIG_PYTHON3_HOST_PIP_CACHE_WORLD_READABLE is not set
# end of Configuration
# CONFIG_PACKAGE_python3-logging is not set
# CONFIG_PACKAGE_python3-lxml is not set
# CONFIG_PACKAGE_python3-lzma is not set
# CONFIG_PACKAGE_python3-markdown is not set
# CONFIG_PACKAGE_python3-markupsafe is not set
# CONFIG_PACKAGE_python3-maxminddb is not set
# CONFIG_PACKAGE_python3-more-itertools is not set
# CONFIG_PACKAGE_python3-msgpack is not set
# CONFIG_PACKAGE_python3-multidict is not set
# CONFIG_PACKAGE_python3-multiprocessing is not set
# CONFIG_PACKAGE_python3-ncurses is not set
# CONFIG_PACKAGE_python3-netdisco is not set
# CONFIG_PACKAGE_python3-netifaces is not set
# CONFIG_PACKAGE_python3-networkx is not set
# CONFIG_PACKAGE_python3-newt is not set
# CONFIG_PACKAGE_python3-oauthlib is not set
# CONFIG_PACKAGE_python3-openpyxl is not set
# CONFIG_PACKAGE_python3-openssl is not set
# CONFIG_PACKAGE_python3-packaging is not set
# CONFIG_PACKAGE_python3-paho-mqtt is not set
# CONFIG_PACKAGE_python3-paramiko is not set
# CONFIG_PACKAGE_python3-parsley is not set
# CONFIG_PACKAGE_python3-passlib is not set
# CONFIG_PACKAGE_python3-pillow is not set
# CONFIG_PACKAGE_python3-pip is not set
# CONFIG_PACKAGE_python3-pkg-resources is not set
# CONFIG_PACKAGE_python3-pluggy is not set
# CONFIG_PACKAGE_python3-ply is not set
# CONFIG_PACKAGE_python3-psutil is not set
# CONFIG_PACKAGE_python3-psycopg2 is not set
# CONFIG_PACKAGE_python3-py is not set
# CONFIG_PACKAGE_python3-pyasn1 is not set
# CONFIG_PACKAGE_python3-pyasn1-modules is not set
# CONFIG_PACKAGE_python3-pycparser is not set
# CONFIG_PACKAGE_python3-pydoc is not set
# CONFIG_PACKAGE_python3-pyjwt is not set
# CONFIG_PACKAGE_python3-pymysql is not set
# CONFIG_PACKAGE_python3-pynacl is not set
# CONFIG_PACKAGE_python3-pyodbc is not set
# CONFIG_PACKAGE_python3-pyopenssl is not set
# CONFIG_PACKAGE_python3-pyotp is not set
# CONFIG_PACKAGE_python3-pyparsing is not set
# CONFIG_PACKAGE_python3-pyroute2 is not set
# CONFIG_PACKAGE_python3-pyrsistent is not set
# CONFIG_PACKAGE_python3-pyserial is not set
# CONFIG_PACKAGE_python3-pysocks is not set
# CONFIG_PACKAGE_python3-pytest is not set
# CONFIG_PACKAGE_python3-pytest-forked is not set
# CONFIG_PACKAGE_python3-pytest-xdist is not set
# CONFIG_PACKAGE_python3-pytz is not set
# CONFIG_PACKAGE_python3-qrcode is not set
# CONFIG_PACKAGE_python3-rcssmin is not set
# CONFIG_PACKAGE_python3-readline is not set
# CONFIG_PACKAGE_python3-requests is not set
# CONFIG_PACKAGE_python3-requests-oauthlib is not set
# CONFIG_PACKAGE_python3-rsa is not set
# CONFIG_PACKAGE_python3-ruamel-yaml is not set
# CONFIG_PACKAGE_python3-s3transfer is not set
# CONFIG_PACKAGE_python3-schedule is not set
# CONFIG_PACKAGE_python3-schema is not set
# CONFIG_PACKAGE_python3-seafile-ccnet is not set
# CONFIG_PACKAGE_python3-seafile-server is not set
# CONFIG_PACKAGE_python3-searpc is not set
# CONFIG_PACKAGE_python3-sentry-sdk is not set
# CONFIG_PACKAGE_python3-sepolgen is not set
# CONFIG_PACKAGE_python3-sepolicy is not set
# CONFIG_PACKAGE_python3-service-identity is not set
# CONFIG_PACKAGE_python3-setuptools is not set
# CONFIG_PACKAGE_python3-simplejson is not set
# CONFIG_PACKAGE_python3-six is not set
# CONFIG_PACKAGE_python3-slugify is not set
# CONFIG_PACKAGE_python3-smbus is not set
# CONFIG_PACKAGE_python3-socketio is not set
# CONFIG_PACKAGE_python3-speedtest-cli is not set
# CONFIG_PACKAGE_python3-sqlalchemy is not set
# CONFIG_PACKAGE_python3-sqlite3 is not set
# CONFIG_PACKAGE_python3-sqlparse is not set
# CONFIG_PACKAGE_python3-stem is not set
# CONFIG_PACKAGE_python3-sysrepo is not set
# CONFIG_PACKAGE_python3-text-unidecode is not set
# CONFIG_PACKAGE_python3-texttable is not set
# CONFIG_PACKAGE_python3-toml is not set
# CONFIG_PACKAGE_python3-tornado is not set
# CONFIG_PACKAGE_python3-twisted is not set
# CONFIG_PACKAGE_python3-typing-extensions is not set
# CONFIG_PACKAGE_python3-ubus is not set
# CONFIG_PACKAGE_python3-uci is not set
# CONFIG_PACKAGE_python3-unidecode is not set
# CONFIG_PACKAGE_python3-unittest is not set
# CONFIG_PACKAGE_python3-urllib is not set
# CONFIG_PACKAGE_python3-urllib3 is not set
# CONFIG_PACKAGE_python3-vobject is not set
# CONFIG_PACKAGE_python3-voluptuous is not set
# CONFIG_PACKAGE_python3-voluptuous-serialize is not set
# CONFIG_PACKAGE_python3-wcwidth is not set
# CONFIG_PACKAGE_python3-websocket-client is not set
# CONFIG_PACKAGE_python3-werkzeug is not set
# CONFIG_PACKAGE_python3-xml is not set
# CONFIG_PACKAGE_python3-xmltodict is not set
# CONFIG_PACKAGE_python3-yaml is not set
# CONFIG_PACKAGE_python3-yarl is not set
# CONFIG_PACKAGE_python3-zeroconf is not set
# CONFIG_PACKAGE_python3-zipp is not set
# CONFIG_PACKAGE_python3-zope-interface is not set
# end of Python
#
# Ruby
#
# CONFIG_PACKAGE_ruby is not set
# end of Ruby
#
# Tcl
#
# CONFIG_PACKAGE_tcl is not set
# end of Tcl
# CONFIG_PACKAGE_chicken-scheme-full is not set
# CONFIG_PACKAGE_chicken-scheme-interpreter is not set
# CONFIG_PACKAGE_slsh is not set
# end of Languages
#
# Libraries
#
#
# Compression
#
# CONFIG_PACKAGE_libbz2 is not set
# CONFIG_PACKAGE_liblz4 is not set
# CONFIG_PACKAGE_liblzma is not set
# CONFIG_PACKAGE_libunrar is not set
# CONFIG_PACKAGE_libzip-gnutls is not set
# CONFIG_PACKAGE_libzip-mbedtls is not set
# CONFIG_PACKAGE_libzip-nossl is not set
# CONFIG_PACKAGE_libzip-openssl is not set
# CONFIG_PACKAGE_libzstd is not set
# end of Compression
#
# Database
#
# CONFIG_PACKAGE_libmariadb is not set
# CONFIG_PACKAGE_libpq is not set
# CONFIG_PACKAGE_libpqxx is not set
# CONFIG_PACKAGE_libsqlite3 is not set
# CONFIG_PACKAGE_pgsqlodbc is not set
# CONFIG_PACKAGE_psqlodbca is not set
# CONFIG_PACKAGE_psqlodbcw is not set
# CONFIG_PACKAGE_redis-cli is not set
# CONFIG_PACKAGE_redis-server is not set
# CONFIG_PACKAGE_redis-utils is not set
# CONFIG_PACKAGE_tdb is not set
# CONFIG_PACKAGE_unixodbc is not set
# end of Database
#
# Filesystem
#
# CONFIG_PACKAGE_libacl is not set
CONFIG_PACKAGE_libattr=y
# CONFIG_PACKAGE_libfuse is not set
# CONFIG_PACKAGE_libfuse3 is not set
# CONFIG_PACKAGE_libow is not set
# CONFIG_PACKAGE_libow-capi is not set
# CONFIG_PACKAGE_libsysfs is not set
# end of Filesystem
#
# Firewall
#
# CONFIG_PACKAGE_libfko is not set
CONFIG_PACKAGE_libip4tc=y
CONFIG_PACKAGE_libip6tc=y
CONFIG_PACKAGE_libxtables=y
# CONFIG_PACKAGE_libxtables-nft is not set
# end of Firewall
#
# Instant Messaging
#
# CONFIG_PACKAGE_quasselc is not set
# end of Instant Messaging
#
# IoT
#
# CONFIG_PACKAGE_libmraa is not set
# CONFIG_PACKAGE_libmraa-python3 is not set
# CONFIG_PACKAGE_libupm is not set
# CONFIG_PACKAGE_libupm-a110x is not set
# CONFIG_PACKAGE_libupm-a110x-python3 is not set
# CONFIG_PACKAGE_libupm-abp is not set
# CONFIG_PACKAGE_libupm-abp-python3 is not set
# CONFIG_PACKAGE_libupm-ad8232 is not set
# CONFIG_PACKAGE_libupm-ad8232-python3 is not set
# CONFIG_PACKAGE_libupm-adafruitms1438 is not set
# CONFIG_PACKAGE_libupm-adafruitms1438-python3 is not set
# CONFIG_PACKAGE_libupm-adafruitss is not set
# CONFIG_PACKAGE_libupm-adafruitss-python3 is not set
# CONFIG_PACKAGE_libupm-adc121c021 is not set
# CONFIG_PACKAGE_libupm-adc121c021-python3 is not set
# CONFIG_PACKAGE_libupm-adis16448 is not set
# CONFIG_PACKAGE_libupm-adis16448-python3 is not set
# CONFIG_PACKAGE_libupm-ads1x15 is not set
# CONFIG_PACKAGE_libupm-ads1x15-python3 is not set
# CONFIG_PACKAGE_libupm-adxl335 is not set
# CONFIG_PACKAGE_libupm-adxl335-python3 is not set
# CONFIG_PACKAGE_libupm-adxl345 is not set
# CONFIG_PACKAGE_libupm-adxl345-python3 is not set
# CONFIG_PACKAGE_libupm-adxrs610 is not set
# CONFIG_PACKAGE_libupm-adxrs610-python3 is not set
# CONFIG_PACKAGE_libupm-am2315 is not set
# CONFIG_PACKAGE_libupm-am2315-python3 is not set
# CONFIG_PACKAGE_libupm-apa102 is not set
# CONFIG_PACKAGE_libupm-apa102-python3 is not set
# CONFIG_PACKAGE_libupm-apds9002 is not set
# CONFIG_PACKAGE_libupm-apds9002-python3 is not set
# CONFIG_PACKAGE_libupm-apds9930 is not set
# CONFIG_PACKAGE_libupm-apds9930-python3 is not set
# CONFIG_PACKAGE_libupm-at42qt1070 is not set
# CONFIG_PACKAGE_libupm-at42qt1070-python3 is not set
# CONFIG_PACKAGE_libupm-bh1749 is not set
# CONFIG_PACKAGE_libupm-bh1749-python3 is not set
# CONFIG_PACKAGE_libupm-bh1750 is not set
# CONFIG_PACKAGE_libupm-bh1750-python3 is not set
# CONFIG_PACKAGE_libupm-bh1792 is not set
# CONFIG_PACKAGE_libupm-bh1792-python3 is not set
# CONFIG_PACKAGE_libupm-biss0001 is not set
# CONFIG_PACKAGE_libupm-biss0001-python3 is not set
# CONFIG_PACKAGE_libupm-bma220 is not set
# CONFIG_PACKAGE_libupm-bma220-python3 is not set
# CONFIG_PACKAGE_libupm-bma250e is not set
# CONFIG_PACKAGE_libupm-bma250e-python3 is not set
# CONFIG_PACKAGE_libupm-bmg160 is not set
# CONFIG_PACKAGE_libupm-bmg160-python3 is not set
# CONFIG_PACKAGE_libupm-bmi160 is not set
# CONFIG_PACKAGE_libupm-bmi160-python3 is not set
# CONFIG_PACKAGE_libupm-bmm150 is not set
# CONFIG_PACKAGE_libupm-bmm150-python3 is not set
# CONFIG_PACKAGE_libupm-bmp280 is not set
# CONFIG_PACKAGE_libupm-bmp280-python3 is not set
# CONFIG_PACKAGE_libupm-bmpx8x is not set
# CONFIG_PACKAGE_libupm-bmpx8x-python3 is not set
# CONFIG_PACKAGE_libupm-bmx055 is not set
# CONFIG_PACKAGE_libupm-bmx055-python3 is not set
# CONFIG_PACKAGE_libupm-bno055 is not set
# CONFIG_PACKAGE_libupm-bno055-python3 is not set
# CONFIG_PACKAGE_libupm-button is not set
# CONFIG_PACKAGE_libupm-button-python3 is not set
# CONFIG_PACKAGE_libupm-buzzer is not set
# CONFIG_PACKAGE_libupm-buzzer-python3 is not set
# CONFIG_PACKAGE_libupm-cjq4435 is not set
# CONFIG_PACKAGE_libupm-cjq4435-python3 is not set
# CONFIG_PACKAGE_libupm-collision is not set
# CONFIG_PACKAGE_libupm-collision-python3 is not set
# CONFIG_PACKAGE_libupm-curieimu is not set
# CONFIG_PACKAGE_libupm-curieimu-python3 is not set
# CONFIG_PACKAGE_libupm-cwlsxxa is not set
# CONFIG_PACKAGE_libupm-cwlsxxa-python3 is not set
# CONFIG_PACKAGE_libupm-dfrec is not set
# CONFIG_PACKAGE_libupm-dfrec-python3 is not set
# CONFIG_PACKAGE_libupm-dfrorp is not set
# CONFIG_PACKAGE_libupm-dfrorp-python3 is not set
# CONFIG_PACKAGE_libupm-dfrph is not set
# CONFIG_PACKAGE_libupm-dfrph-python3 is not set
# CONFIG_PACKAGE_libupm-ds1307 is not set
# CONFIG_PACKAGE_libupm-ds1307-python3 is not set
# CONFIG_PACKAGE_libupm-ds1808lc is not set
# CONFIG_PACKAGE_libupm-ds1808lc-python3 is not set
# CONFIG_PACKAGE_libupm-ds18b20 is not set
# CONFIG_PACKAGE_libupm-ds18b20-python3 is not set
# CONFIG_PACKAGE_libupm-ds2413 is not set
# CONFIG_PACKAGE_libupm-ds2413-python3 is not set
# CONFIG_PACKAGE_libupm-ecezo is not set
# CONFIG_PACKAGE_libupm-ecezo-python3 is not set
# CONFIG_PACKAGE_libupm-ecs1030 is not set
# CONFIG_PACKAGE_libupm-ecs1030-python3 is not set
# CONFIG_PACKAGE_libupm-ehr is not set
# CONFIG_PACKAGE_libupm-ehr-python3 is not set
# CONFIG_PACKAGE_libupm-eldriver is not set
# CONFIG_PACKAGE_libupm-eldriver-python3 is not set
# CONFIG_PACKAGE_libupm-electromagnet is not set
# CONFIG_PACKAGE_libupm-electromagnet-python3 is not set
# CONFIG_PACKAGE_libupm-emg is not set
# CONFIG_PACKAGE_libupm-emg-python3 is not set
# CONFIG_PACKAGE_libupm-enc03r is not set
# CONFIG_PACKAGE_libupm-enc03r-python3 is not set
# CONFIG_PACKAGE_libupm-flex is not set
# CONFIG_PACKAGE_libupm-flex-python3 is not set
# CONFIG_PACKAGE_libupm-gas is not set
# CONFIG_PACKAGE_libupm-gas-python3 is not set
# CONFIG_PACKAGE_libupm-gp2y0a is not set
# CONFIG_PACKAGE_libupm-gp2y0a-python3 is not set
# CONFIG_PACKAGE_libupm-gprs is not set
# CONFIG_PACKAGE_libupm-gprs-python3 is not set
# CONFIG_PACKAGE_libupm-gsr is not set
# CONFIG_PACKAGE_libupm-gsr-python3 is not set
# CONFIG_PACKAGE_libupm-guvas12d is not set
# CONFIG_PACKAGE_libupm-guvas12d-python3 is not set
# CONFIG_PACKAGE_libupm-h3lis331dl is not set
# CONFIG_PACKAGE_libupm-h3lis331dl-python3 is not set
# CONFIG_PACKAGE_libupm-h803x is not set
# CONFIG_PACKAGE_libupm-h803x-python3 is not set
# CONFIG_PACKAGE_libupm-hcsr04 is not set
# CONFIG_PACKAGE_libupm-hcsr04-python3 is not set
# CONFIG_PACKAGE_libupm-hdc1000 is not set
# CONFIG_PACKAGE_libupm-hdc1000-python3 is not set
# CONFIG_PACKAGE_libupm-hdxxvxta is not set
# CONFIG_PACKAGE_libupm-hdxxvxta-python3 is not set
# CONFIG_PACKAGE_libupm-hka5 is not set
# CONFIG_PACKAGE_libupm-hka5-python3 is not set
# CONFIG_PACKAGE_libupm-hlg150h is not set
# CONFIG_PACKAGE_libupm-hlg150h-python3 is not set
# CONFIG_PACKAGE_libupm-hm11 is not set
# CONFIG_PACKAGE_libupm-hm11-python3 is not set
# CONFIG_PACKAGE_libupm-hmc5883l is not set
# CONFIG_PACKAGE_libupm-hmc5883l-python3 is not set
# CONFIG_PACKAGE_libupm-hmtrp is not set
# CONFIG_PACKAGE_libupm-hmtrp-python3 is not set
# CONFIG_PACKAGE_libupm-hp20x is not set
# CONFIG_PACKAGE_libupm-hp20x-python3 is not set
# CONFIG_PACKAGE_libupm-ht9170 is not set
# CONFIG_PACKAGE_libupm-ht9170-python3 is not set
# CONFIG_PACKAGE_libupm-htu21d is not set
# CONFIG_PACKAGE_libupm-htu21d-python3 is not set
# CONFIG_PACKAGE_libupm-hwxpxx is not set
# CONFIG_PACKAGE_libupm-hwxpxx-python3 is not set
# CONFIG_PACKAGE_libupm-hx711 is not set
# CONFIG_PACKAGE_libupm-hx711-python3 is not set
# CONFIG_PACKAGE_libupm-ili9341 is not set
# CONFIG_PACKAGE_libupm-ili9341-python3 is not set
# CONFIG_PACKAGE_libupm-ims is not set
# CONFIG_PACKAGE_libupm-ims-python3 is not set
# CONFIG_PACKAGE_libupm-ina132 is not set
# CONFIG_PACKAGE_libupm-ina132-python3 is not set
# CONFIG_PACKAGE_libupm-interfaces is not set
# CONFIG_PACKAGE_libupm-interfaces-python3 is not set
# CONFIG_PACKAGE_libupm-isd1820 is not set
# CONFIG_PACKAGE_libupm-isd1820-python3 is not set
# CONFIG_PACKAGE_libupm-itg3200 is not set
# CONFIG_PACKAGE_libupm-itg3200-python3 is not set
# CONFIG_PACKAGE_libupm-jhd1313m1 is not set
# CONFIG_PACKAGE_libupm-jhd1313m1-python3 is not set
# CONFIG_PACKAGE_libupm-joystick12 is not set
# CONFIG_PACKAGE_libupm-joystick12-python3 is not set
# CONFIG_PACKAGE_libupm-kx122 is not set
# CONFIG_PACKAGE_libupm-kx122-python3 is not set
# CONFIG_PACKAGE_libupm-kxcjk1013 is not set
# CONFIG_PACKAGE_libupm-kxcjk1013-python3 is not set
# CONFIG_PACKAGE_libupm-kxtj3 is not set
# CONFIG_PACKAGE_libupm-kxtj3-python3 is not set
# CONFIG_PACKAGE_libupm-l298 is not set
# CONFIG_PACKAGE_libupm-l298-python3 is not set
# CONFIG_PACKAGE_libupm-l3gd20 is not set
# CONFIG_PACKAGE_libupm-l3gd20-python3 is not set
# CONFIG_PACKAGE_libupm-lcd is not set
# CONFIG_PACKAGE_libupm-lcd-python3 is not set
# CONFIG_PACKAGE_libupm-lcdks is not set
# CONFIG_PACKAGE_libupm-lcdks-python3 is not set
# CONFIG_PACKAGE_libupm-lcm1602 is not set
# CONFIG_PACKAGE_libupm-lcm1602-python3 is not set
# CONFIG_PACKAGE_libupm-ldt0028 is not set
# CONFIG_PACKAGE_libupm-ldt0028-python3 is not set
# CONFIG_PACKAGE_libupm-led is not set
# CONFIG_PACKAGE_libupm-led-python3 is not set
# CONFIG_PACKAGE_libupm-lidarlitev3 is not set
# CONFIG_PACKAGE_libupm-lidarlitev3-python3 is not set
# CONFIG_PACKAGE_libupm-light is not set
# CONFIG_PACKAGE_libupm-light-python3 is not set
# CONFIG_PACKAGE_libupm-linefinder is not set
# CONFIG_PACKAGE_libupm-linefinder-python3 is not set
# CONFIG_PACKAGE_libupm-lis2ds12 is not set
# CONFIG_PACKAGE_libupm-lis2ds12-python3 is not set
# CONFIG_PACKAGE_libupm-lis3dh is not set
# CONFIG_PACKAGE_libupm-lis3dh-python3 is not set
# CONFIG_PACKAGE_libupm-lm35 is not set
# CONFIG_PACKAGE_libupm-lm35-python3 is not set
# CONFIG_PACKAGE_libupm-lol is not set
# CONFIG_PACKAGE_libupm-lol-python3 is not set
# CONFIG_PACKAGE_libupm-loudness is not set
# CONFIG_PACKAGE_libupm-loudness-python3 is not set
# CONFIG_PACKAGE_libupm-lp8860 is not set
# CONFIG_PACKAGE_libupm-lp8860-python3 is not set
# CONFIG_PACKAGE_libupm-lpd8806 is not set
# CONFIG_PACKAGE_libupm-lpd8806-python3 is not set
# CONFIG_PACKAGE_libupm-lsm303agr is not set
# CONFIG_PACKAGE_libupm-lsm303agr-python3 is not set
# CONFIG_PACKAGE_libupm-lsm303d is not set
# CONFIG_PACKAGE_libupm-lsm303d-python3 is not set
# CONFIG_PACKAGE_libupm-lsm303dlh is not set
# CONFIG_PACKAGE_libupm-lsm303dlh-python3 is not set
# CONFIG_PACKAGE_libupm-lsm6ds3h is not set
# CONFIG_PACKAGE_libupm-lsm6ds3h-python3 is not set
# CONFIG_PACKAGE_libupm-lsm6dsl is not set
# CONFIG_PACKAGE_libupm-lsm6dsl-python3 is not set
# CONFIG_PACKAGE_libupm-lsm9ds0 is not set
# CONFIG_PACKAGE_libupm-lsm9ds0-python3 is not set
# CONFIG_PACKAGE_libupm-m24lr64e is not set
# CONFIG_PACKAGE_libupm-m24lr64e-python3 is not set
# CONFIG_PACKAGE_libupm-mag3110 is not set
# CONFIG_PACKAGE_libupm-mag3110-python3 is not set
# CONFIG_PACKAGE_libupm-max30100 is not set
# CONFIG_PACKAGE_libupm-max30100-python3 is not set
# CONFIG_PACKAGE_libupm-max31723 is not set
# CONFIG_PACKAGE_libupm-max31723-python3 is not set
# CONFIG_PACKAGE_libupm-max31855 is not set
# CONFIG_PACKAGE_libupm-max31855-python3 is not set
# CONFIG_PACKAGE_libupm-max44000 is not set
# CONFIG_PACKAGE_libupm-max44000-python3 is not set
# CONFIG_PACKAGE_libupm-max44009 is not set
# CONFIG_PACKAGE_libupm-max44009-python3 is not set
# CONFIG_PACKAGE_libupm-max5487 is not set
# CONFIG_PACKAGE_libupm-max5487-python3 is not set
# CONFIG_PACKAGE_libupm-maxds3231m is not set
# CONFIG_PACKAGE_libupm-maxds3231m-python3 is not set
# CONFIG_PACKAGE_libupm-maxsonarez is not set
# CONFIG_PACKAGE_libupm-maxsonarez-python3 is not set
# CONFIG_PACKAGE_libupm-mb704x is not set
# CONFIG_PACKAGE_libupm-mb704x-python3 is not set
# CONFIG_PACKAGE_libupm-mcp2515 is not set
# CONFIG_PACKAGE_libupm-mcp2515-python3 is not set
# CONFIG_PACKAGE_libupm-mcp9808 is not set
# CONFIG_PACKAGE_libupm-mcp9808-python3 is not set
# CONFIG_PACKAGE_libupm-md is not set
# CONFIG_PACKAGE_libupm-md-python3 is not set
# CONFIG_PACKAGE_libupm-mg811 is not set
# CONFIG_PACKAGE_libupm-mg811-python3 is not set
# CONFIG_PACKAGE_libupm-mhz16 is not set
# CONFIG_PACKAGE_libupm-mhz16-python3 is not set
# CONFIG_PACKAGE_libupm-mic is not set
# CONFIG_PACKAGE_libupm-mic-python3 is not set
# CONFIG_PACKAGE_libupm-micsv89 is not set
# CONFIG_PACKAGE_libupm-micsv89-python3 is not set
# CONFIG_PACKAGE_libupm-mlx90614 is not set
# CONFIG_PACKAGE_libupm-mlx90614-python3 is not set
# CONFIG_PACKAGE_libupm-mma7361 is not set
# CONFIG_PACKAGE_libupm-mma7361-python3 is not set
# CONFIG_PACKAGE_libupm-mma7455 is not set
# CONFIG_PACKAGE_libupm-mma7455-python3 is not set
# CONFIG_PACKAGE_libupm-mma7660 is not set
# CONFIG_PACKAGE_libupm-mma7660-python3 is not set
# CONFIG_PACKAGE_libupm-mma8x5x is not set
# CONFIG_PACKAGE_libupm-mma8x5x-python3 is not set
# CONFIG_PACKAGE_libupm-mmc35240 is not set
# CONFIG_PACKAGE_libupm-mmc35240-python3 is not set
# CONFIG_PACKAGE_libupm-moisture is not set
# CONFIG_PACKAGE_libupm-moisture-python3 is not set
# CONFIG_PACKAGE_libupm-mpl3115a2 is not set
# CONFIG_PACKAGE_libupm-mpl3115a2-python3 is not set
# CONFIG_PACKAGE_libupm-mpr121 is not set
# CONFIG_PACKAGE_libupm-mpr121-python3 is not set
# CONFIG_PACKAGE_libupm-mpu9150 is not set
# CONFIG_PACKAGE_libupm-mpu9150-python3 is not set
# CONFIG_PACKAGE_libupm-mq303a is not set
# CONFIG_PACKAGE_libupm-mq303a-python3 is not set
# CONFIG_PACKAGE_libupm-ms5611 is not set
# CONFIG_PACKAGE_libupm-ms5611-python3 is not set
# CONFIG_PACKAGE_libupm-ms5803 is not set
# CONFIG_PACKAGE_libupm-ms5803-python3 is not set
# CONFIG_PACKAGE_libupm-my9221 is not set
# CONFIG_PACKAGE_libupm-my9221-python3 is not set
# CONFIG_PACKAGE_libupm-nlgpio16 is not set
# CONFIG_PACKAGE_libupm-nlgpio16-python3 is not set
# CONFIG_PACKAGE_libupm-nmea_gps is not set
# CONFIG_PACKAGE_libupm-nmea_gps-python3 is not set
# CONFIG_PACKAGE_libupm-nrf24l01 is not set
# CONFIG_PACKAGE_libupm-nrf24l01-python3 is not set
# CONFIG_PACKAGE_libupm-nrf8001 is not set
# CONFIG_PACKAGE_libupm-nrf8001-python3 is not set
# CONFIG_PACKAGE_libupm-nunchuck is not set
# CONFIG_PACKAGE_libupm-nunchuck-python3 is not set
# CONFIG_PACKAGE_libupm-o2 is not set
# CONFIG_PACKAGE_libupm-o2-python3 is not set
# CONFIG_PACKAGE_libupm-otp538u is not set
# CONFIG_PACKAGE_libupm-otp538u-python3 is not set
# CONFIG_PACKAGE_libupm-ozw is not set
# CONFIG_PACKAGE_libupm-ozw-python3 is not set
# CONFIG_PACKAGE_libupm-p9813 is not set
# CONFIG_PACKAGE_libupm-p9813-python3 is not set
# CONFIG_PACKAGE_libupm-pca9685 is not set
# CONFIG_PACKAGE_libupm-pca9685-python3 is not set
# CONFIG_PACKAGE_libupm-pn532 is not set
# CONFIG_PACKAGE_libupm-pn532-python3 is not set
# CONFIG_PACKAGE_libupm-ppd42ns is not set
# CONFIG_PACKAGE_libupm-ppd42ns-python3 is not set
# CONFIG_PACKAGE_libupm-pulsensor is not set
# CONFIG_PACKAGE_libupm-pulsensor-python3 is not set
# CONFIG_PACKAGE_libupm-relay is not set
# CONFIG_PACKAGE_libupm-relay-python3 is not set
# CONFIG_PACKAGE_libupm-rf22 is not set
# CONFIG_PACKAGE_libupm-rf22-python3 is not set
# CONFIG_PACKAGE_libupm-rfr359f is not set
# CONFIG_PACKAGE_libupm-rfr359f-python3 is not set
# CONFIG_PACKAGE_libupm-rgbringcoder is not set
# CONFIG_PACKAGE_libupm-rgbringcoder-python3 is not set
# CONFIG_PACKAGE_libupm-rhusb is not set
# CONFIG_PACKAGE_libupm-rhusb-python3 is not set
# CONFIG_PACKAGE_libupm-rn2903 is not set
# CONFIG_PACKAGE_libupm-rn2903-python3 is not set
# CONFIG_PACKAGE_libupm-rotary is not set
# CONFIG_PACKAGE_libupm-rotary-python3 is not set
# CONFIG_PACKAGE_libupm-rotaryencoder is not set
# CONFIG_PACKAGE_libupm-rotaryencoder-python3 is not set
# CONFIG_PACKAGE_libupm-rpr220 is not set
# CONFIG_PACKAGE_libupm-rpr220-python3 is not set
# CONFIG_PACKAGE_libupm-rsc is not set
# CONFIG_PACKAGE_libupm-rsc-python3 is not set
# CONFIG_PACKAGE_libupm-scam is not set
# CONFIG_PACKAGE_libupm-scam-python3 is not set
# CONFIG_PACKAGE_libupm-sensortemplate is not set
# CONFIG_PACKAGE_libupm-sensortemplate-python3 is not set
# CONFIG_PACKAGE_libupm-servo is not set
# CONFIG_PACKAGE_libupm-servo-python3 is not set
# CONFIG_PACKAGE_libupm-sht1x is not set
# CONFIG_PACKAGE_libupm-sht1x-python3 is not set
# CONFIG_PACKAGE_libupm-si1132 is not set
# CONFIG_PACKAGE_libupm-si1132-python3 is not set
# CONFIG_PACKAGE_libupm-si114x is not set
# CONFIG_PACKAGE_libupm-si114x-python3 is not set
# CONFIG_PACKAGE_libupm-si7005 is not set
# CONFIG_PACKAGE_libupm-si7005-python3 is not set
# CONFIG_PACKAGE_libupm-slide is not set
# CONFIG_PACKAGE_libupm-slide-python3 is not set
# CONFIG_PACKAGE_libupm-sm130 is not set
# CONFIG_PACKAGE_libupm-sm130-python3 is not set
# CONFIG_PACKAGE_libupm-smartdrive is not set
# CONFIG_PACKAGE_libupm-smartdrive-python3 is not set
# CONFIG_PACKAGE_libupm-speaker is not set
# CONFIG_PACKAGE_libupm-speaker-python3 is not set
# CONFIG_PACKAGE_libupm-ssd1351 is not set
# CONFIG_PACKAGE_libupm-ssd1351-python3 is not set
# CONFIG_PACKAGE_libupm-st7735 is not set
# CONFIG_PACKAGE_libupm-st7735-python3 is not set
# CONFIG_PACKAGE_libupm-stepmotor is not set
# CONFIG_PACKAGE_libupm-stepmotor-python3 is not set
# CONFIG_PACKAGE_libupm-sx1276 is not set
# CONFIG_PACKAGE_libupm-sx1276-python3 is not set
# CONFIG_PACKAGE_libupm-sx6119 is not set
# CONFIG_PACKAGE_libupm-sx6119-python3 is not set
# CONFIG_PACKAGE_libupm-t3311 is not set
# CONFIG_PACKAGE_libupm-t3311-python3 is not set
# CONFIG_PACKAGE_libupm-t6713 is not set
# CONFIG_PACKAGE_libupm-t6713-python3 is not set
# CONFIG_PACKAGE_libupm-ta12200 is not set
# CONFIG_PACKAGE_libupm-ta12200-python3 is not set
# CONFIG_PACKAGE_libupm-tca9548a is not set
# CONFIG_PACKAGE_libupm-tca9548a-python3 is not set
# CONFIG_PACKAGE_libupm-tcs3414cs is not set
# CONFIG_PACKAGE_libupm-tcs3414cs-python3 is not set
# CONFIG_PACKAGE_libupm-tcs37727 is not set
# CONFIG_PACKAGE_libupm-tcs37727-python3 is not set
# CONFIG_PACKAGE_libupm-teams is not set
# CONFIG_PACKAGE_libupm-teams-python3 is not set
# CONFIG_PACKAGE_libupm-temperature is not set
# CONFIG_PACKAGE_libupm-temperature-python3 is not set
# CONFIG_PACKAGE_libupm-tex00 is not set
# CONFIG_PACKAGE_libupm-tex00-python3 is not set
# CONFIG_PACKAGE_libupm-th02 is not set
# CONFIG_PACKAGE_libupm-th02-python3 is not set
# CONFIG_PACKAGE_libupm-tm1637 is not set
# CONFIG_PACKAGE_libupm-tm1637-python3 is not set
# CONFIG_PACKAGE_libupm-tmp006 is not set
# CONFIG_PACKAGE_libupm-tmp006-python3 is not set
# CONFIG_PACKAGE_libupm-tsl2561 is not set
# CONFIG_PACKAGE_libupm-tsl2561-python3 is not set
# CONFIG_PACKAGE_libupm-ttp223 is not set
# CONFIG_PACKAGE_libupm-ttp223-python3 is not set
# CONFIG_PACKAGE_libupm-uartat is not set
# CONFIG_PACKAGE_libupm-uartat-python3 is not set
# CONFIG_PACKAGE_libupm-uln200xa is not set
# CONFIG_PACKAGE_libupm-uln200xa-python3 is not set
# CONFIG_PACKAGE_libupm-ultrasonic is not set
# CONFIG_PACKAGE_libupm-ultrasonic-python3 is not set
# CONFIG_PACKAGE_libupm-urm37 is not set
# CONFIG_PACKAGE_libupm-urm37-python3 is not set
# CONFIG_PACKAGE_libupm-utilities is not set
# CONFIG_PACKAGE_libupm-utilities-python3 is not set
# CONFIG_PACKAGE_libupm-vcap is not set
# CONFIG_PACKAGE_libupm-vcap-python3 is not set
# CONFIG_PACKAGE_libupm-vdiv is not set
# CONFIG_PACKAGE_libupm-vdiv-python3 is not set
# CONFIG_PACKAGE_libupm-veml6070 is not set
# CONFIG_PACKAGE_libupm-veml6070-python3 is not set
# CONFIG_PACKAGE_libupm-water is not set
# CONFIG_PACKAGE_libupm-water-python3 is not set
# CONFIG_PACKAGE_libupm-waterlevel is not set
# CONFIG_PACKAGE_libupm-waterlevel-python3 is not set
# CONFIG_PACKAGE_libupm-wfs is not set
# CONFIG_PACKAGE_libupm-wfs-python3 is not set
# CONFIG_PACKAGE_libupm-wheelencoder is not set
# CONFIG_PACKAGE_libupm-wheelencoder-python3 is not set
# CONFIG_PACKAGE_libupm-wt5001 is not set
# CONFIG_PACKAGE_libupm-wt5001-python3 is not set
# CONFIG_PACKAGE_libupm-xbee is not set
# CONFIG_PACKAGE_libupm-xbee-python3 is not set
# CONFIG_PACKAGE_libupm-yg1006 is not set
# CONFIG_PACKAGE_libupm-yg1006-python3 is not set
# CONFIG_PACKAGE_libupm-zfm20 is not set
# CONFIG_PACKAGE_libupm-zfm20-python3 is not set
# end of IoT
#
# Languages
#
# CONFIG_PACKAGE_libyaml is not set
# end of Languages
#
# LibElektra
#
# CONFIG_PACKAGE_libelektra-boost is not set
# CONFIG_PACKAGE_libelektra-core is not set
# CONFIG_PACKAGE_libelektra-cpp is not set
# CONFIG_PACKAGE_libelektra-crypto is not set
# CONFIG_PACKAGE_libelektra-curlget is not set
# CONFIG_PACKAGE_libelektra-dbus is not set
# CONFIG_PACKAGE_libelektra-extra is not set
# CONFIG_PACKAGE_libelektra-lua is not set
# CONFIG_PACKAGE_libelektra-plugins is not set
# CONFIG_PACKAGE_libelektra-python3 is not set
# CONFIG_PACKAGE_libelektra-resolvers is not set
# CONFIG_PACKAGE_libelektra-xerces is not set
# CONFIG_PACKAGE_libelektra-xml is not set
# CONFIG_PACKAGE_libelektra-yajl is not set
# CONFIG_PACKAGE_libelektra-yamlcpp is not set
# CONFIG_PACKAGE_libelektra-zmq is not set
# end of LibElektra
#
# Networking
#
# CONFIG_PACKAGE_libdcwproto is not set
# CONFIG_PACKAGE_libdcwsocket is not set
# CONFIG_PACKAGE_libsctp is not set
# CONFIG_PACKAGE_libuhttpd-mbedtls is not set
# CONFIG_PACKAGE_libuhttpd-nossl is not set
# CONFIG_PACKAGE_libuhttpd-openssl is not set
# CONFIG_PACKAGE_libuhttpd-wolfssl is not set
# CONFIG_PACKAGE_libulfius-gnutls is not set
# CONFIG_PACKAGE_libulfius-nossl is not set
# CONFIG_PACKAGE_libunbound is not set
# CONFIG_PACKAGE_libuwsc-mbedtls is not set
# CONFIG_PACKAGE_libuwsc-nossl is not set
# CONFIG_PACKAGE_libuwsc-openssl is not set
# CONFIG_PACKAGE_libuwsc-wolfssl is not set
# end of Networking
#
# Qt5
#
# CONFIG_PACKAGE_qt5-core is not set
# CONFIG_PACKAGE_qt5-network is not set
# CONFIG_PACKAGE_qt5-sql is not set
# CONFIG_PACKAGE_qt5-xml is not set
# CONFIG_PACKAGE_qtbase is not set
CONFIG_QT5_INCLUDE_ATOMIC=y
#
# Select Qtbase Libraries
#
#
# Qtbase Libraries
#
# end of Select Qtbase Libraries
# end of Qt5
#
# SSL
#
# CONFIG_PACKAGE_libgnutls is not set
# CONFIG_PACKAGE_libgnutls-dane is not set
CONFIG_PACKAGE_libmbedtls=y
# CONFIG_LIBMBEDTLS_DEBUG_C is not set
# CONFIG_LIBMBEDTLS_HKDF_C is not set
# CONFIG_PACKAGE_libnss is not set
CONFIG_PACKAGE_libopenssl=y
#
# Build Options
#
CONFIG_OPENSSL_OPTIMIZE_SPEED=y
CONFIG_OPENSSL_WITH_ASM=y
CONFIG_OPENSSL_WITH_DEPRECATED=y
# CONFIG_OPENSSL_NO_DEPRECATED is not set
CONFIG_OPENSSL_WITH_ERROR_MESSAGES=y
#
# Protocol Support
#
CONFIG_OPENSSL_WITH_TLS13=y
# CONFIG_OPENSSL_WITH_DTLS is not set
# CONFIG_OPENSSL_WITH_NPN is not set
CONFIG_OPENSSL_WITH_SRP=y
CONFIG_OPENSSL_WITH_CMS=y
#
# Algorithm Selection
#
# CONFIG_OPENSSL_WITH_EC2M is not set
CONFIG_OPENSSL_WITH_CHACHA_POLY1305=y
CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM=y
CONFIG_OPENSSL_WITH_PSK=y
#
# Less commonly used build options
#
# CONFIG_OPENSSL_WITH_ARIA is not set
# CONFIG_OPENSSL_WITH_CAMELLIA is not set
# CONFIG_OPENSSL_WITH_IDEA is not set
# CONFIG_OPENSSL_WITH_SEED is not set
# CONFIG_OPENSSL_WITH_SM234 is not set
# CONFIG_OPENSSL_WITH_BLAKE2 is not set
# CONFIG_OPENSSL_WITH_MDC2 is not set
# CONFIG_OPENSSL_WITH_WHIRLPOOL is not set
# CONFIG_OPENSSL_WITH_COMPRESSION is not set
# CONFIG_OPENSSL_WITH_RFC3779 is not set
#
# Engine/Hardware Support
#
CONFIG_OPENSSL_ENGINE=y
CONFIG_OPENSSL_ENGINE_BUILTIN=y
CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG=y
CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO=y
CONFIG_PACKAGE_libopenssl-conf=y
# CONFIG_PACKAGE_libopenssl-devcrypto is not set
# CONFIG_PACKAGE_libopenssl-gost_engine is not set
# CONFIG_PACKAGE_libpolarssl is not set
# CONFIG_PACKAGE_libwolfssl is not set
# end of SSL
#
# Sound
#
# CONFIG_PACKAGE_alsa-ucm-conf is not set
# CONFIG_PACKAGE_liblo is not set
# end of Sound
#
# Telephony
#
# CONFIG_PACKAGE_bcg729 is not set
# CONFIG_PACKAGE_dahdi-tools-libtonezone is not set
# CONFIG_PACKAGE_gsmlib is not set
# CONFIG_PACKAGE_libctb is not set
# CONFIG_PACKAGE_libfreetdm is not set
# CONFIG_PACKAGE_libiksemel is not set
# CONFIG_PACKAGE_libks is not set
# CONFIG_PACKAGE_libosip2 is not set
# CONFIG_PACKAGE_libpj is not set
# CONFIG_PACKAGE_libpjlib-util is not set
# CONFIG_PACKAGE_libpjmedia is not set
# CONFIG_PACKAGE_libpjnath is not set
# CONFIG_PACKAGE_libpjsip is not set
# CONFIG_PACKAGE_libpjsip-simple is not set
# CONFIG_PACKAGE_libpjsip-ua is not set
# CONFIG_PACKAGE_libpjsua is not set
# CONFIG_PACKAGE_libpjsua2 is not set
# CONFIG_PACKAGE_libre is not set
# CONFIG_PACKAGE_librem is not set
# CONFIG_PACKAGE_libspandsp is not set
# CONFIG_PACKAGE_libspandsp3 is not set
# CONFIG_PACKAGE_libsrtp2 is not set
# CONFIG_PACKAGE_signalwire-client-c is not set
# CONFIG_PACKAGE_sofia-sip is not set
# end of Telephony
#
# libimobiledevice
#
# CONFIG_PACKAGE_libimobiledevice is not set
# CONFIG_PACKAGE_libirecovery is not set
# CONFIG_PACKAGE_libplist is not set
# CONFIG_PACKAGE_libusbmuxd is not set
# end of libimobiledevice
# CONFIG_PACKAGE_acsccid is not set
# CONFIG_PACKAGE_alsa-lib is not set
# CONFIG_PACKAGE_argp-standalone is not set
# CONFIG_PACKAGE_bind-libs is not set
# CONFIG_PACKAGE_bluez-libs is not set
CONFIG_PACKAGE_boost=y
# CONFIG_boost-context-exclude is not set
# CONFIG_boost-coroutine-exclude is not set
# CONFIG_boost-fiber-exclude is not set
#
# Select Boost Options
#
#
# Boost compilation options.
#
# CONFIG_boost-compile-visibility-global is not set
# CONFIG_boost-compile-visibility-protected is not set
CONFIG_boost-compile-visibility-hidden=y
# CONFIG_boost-shared-libs is not set
# CONFIG_boost-static-libs is not set
CONFIG_boost-static-and-shared-libs=y
CONFIG_boost-runtime-shared=y
CONFIG_boost-variant-release=y
# CONFIG_boost-variant-debug is not set
# CONFIG_boost-variant-profile is not set
# CONFIG_boost-use-name-tags is not set
# end of Select Boost Options
#
# Select Boost libraries
#
#
# Libraries
#
# CONFIG_boost-libs-all is not set
# CONFIG_boost-test-pkg is not set
# CONFIG_boost-graph-parallel is not set
# CONFIG_PACKAGE_boost-atomic is not set
# CONFIG_PACKAGE_boost-chrono is not set
# CONFIG_PACKAGE_boost-container is not set
# CONFIG_PACKAGE_boost-context is not set
# CONFIG_PACKAGE_boost-contract is not set
# CONFIG_PACKAGE_boost-coroutine is not set
# CONFIG_PACKAGE_boost-date_time is not set
# CONFIG_PACKAGE_boost-fiber is not set
# CONFIG_PACKAGE_boost-filesystem is not set
# CONFIG_PACKAGE_boost-graph is not set
# CONFIG_PACKAGE_boost-iostreams is not set
# CONFIG_PACKAGE_boost-json is not set
# CONFIG_PACKAGE_boost-locale is not set
# CONFIG_PACKAGE_boost-log is not set
# CONFIG_PACKAGE_boost-math is not set
# CONFIG_PACKAGE_boost-nowide is not set
CONFIG_PACKAGE_boost-program_options=y
# CONFIG_PACKAGE_boost-python3 is not set
# CONFIG_PACKAGE_boost-random is not set
# CONFIG_PACKAGE_boost-regex is not set
# CONFIG_PACKAGE_boost-serialization is not set
# CONFIG_PACKAGE_boost-wserialization is not set
# CONFIG_PACKAGE_boost-stacktrace is not set
CONFIG_PACKAGE_boost-system=y
# CONFIG_PACKAGE_boost-thread is not set
# CONFIG_PACKAGE_boost-timer is not set
# CONFIG_PACKAGE_boost-type_erasure is not set
# CONFIG_PACKAGE_boost-wave is not set
# end of Select Boost libraries
# CONFIG_PACKAGE_cJSON is not set
# CONFIG_PACKAGE_ccid is not set
# CONFIG_PACKAGE_check is not set
# CONFIG_PACKAGE_confuse is not set
# CONFIG_PACKAGE_czmq is not set
# CONFIG_PACKAGE_dtndht is not set
# CONFIG_PACKAGE_getdns is not set
# CONFIG_PACKAGE_giflib is not set
# CONFIG_PACKAGE_glib2 is not set
# CONFIG_PACKAGE_google-authenticator-libpam is not set
# CONFIG_PACKAGE_hidapi is not set
# CONFIG_PACKAGE_ibrcommon is not set
# CONFIG_PACKAGE_ibrdtn is not set
# CONFIG_PACKAGE_icu is not set
# CONFIG_PACKAGE_icu-data-tools is not set
# CONFIG_PACKAGE_icu-full-data is not set
# CONFIG_PACKAGE_jansson is not set
# CONFIG_PACKAGE_json-glib is not set
# CONFIG_PACKAGE_jsoncpp is not set
# CONFIG_PACKAGE_knot-libs is not set
# CONFIG_PACKAGE_knot-libzscanner is not set
# CONFIG_PACKAGE_libaio is not set
# CONFIG_PACKAGE_libantlr3c is not set
# CONFIG_PACKAGE_libao is not set
# CONFIG_PACKAGE_libapparmor is not set
# CONFIG_PACKAGE_libapr is not set
# CONFIG_PACKAGE_libaprutil is not set
# CONFIG_PACKAGE_libarchive is not set
# CONFIG_PACKAGE_libarchive-noopenssl is not set
# CONFIG_PACKAGE_libasm is not set
# CONFIG_PACKAGE_libassuan is not set
# CONFIG_PACKAGE_libatasmart is not set
# CONFIG_PACKAGE_libaudit is not set
# CONFIG_PACKAGE_libauparse is not set
# CONFIG_PACKAGE_libavahi-client is not set
# CONFIG_PACKAGE_libavahi-compat-libdnssd is not set
# CONFIG_PACKAGE_libavahi-dbus-support is not set
# CONFIG_PACKAGE_libavahi-nodbus-support is not set
# CONFIG_PACKAGE_libbfd is not set
CONFIG_PACKAGE_libblkid=y
CONFIG_PACKAGE_libblobmsg-json=y
CONFIG_PACKAGE_libbpf=y
# CONFIG_PACKAGE_libbsd is not set
CONFIG_PACKAGE_libcap=y
# CONFIG_PACKAGE_libcap-bin is not set
# CONFIG_PACKAGE_libcap-ng is not set
# CONFIG_PACKAGE_libcares is not set
# CONFIG_PACKAGE_libcbor is not set
# CONFIG_PACKAGE_libcgroup is not set
# CONFIG_PACKAGE_libcharset is not set
# CONFIG_PACKAGE_libcoap is not set
CONFIG_PACKAGE_libcomerr=y
# CONFIG_PACKAGE_libconfig is not set
# CONFIG_PACKAGE_libcryptopp is not set
# CONFIG_PACKAGE_libctf is not set
CONFIG_PACKAGE_libcurl=y
#
# SSL support
#
# CONFIG_LIBCURL_MBEDTLS is not set
# CONFIG_LIBCURL_WOLFSSL is not set
CONFIG_LIBCURL_OPENSSL=y
# CONFIG_LIBCURL_GNUTLS is not set
# CONFIG_LIBCURL_NOSSL is not set
#
# Supported protocols
#
# CONFIG_LIBCURL_DICT is not set
CONFIG_LIBCURL_FILE=y
CONFIG_LIBCURL_FTP=y
# CONFIG_LIBCURL_GOPHER is not set
CONFIG_LIBCURL_HTTP=y
CONFIG_LIBCURL_COOKIES=y
# CONFIG_LIBCURL_IMAP is not set
# CONFIG_LIBCURL_LDAP is not set
# CONFIG_LIBCURL_POP3 is not set
# CONFIG_LIBCURL_RTSP is not set
# CONFIG_LIBCURL_SSH2 is not set
CONFIG_LIBCURL_NO_SMB="!"
# CONFIG_LIBCURL_SMTP is not set
# CONFIG_LIBCURL_TELNET is not set
# CONFIG_LIBCURL_TFTP is not set
# CONFIG_LIBCURL_NGHTTP2 is not set
#
# Miscellaneous
#
CONFIG_LIBCURL_PROXY=y
# CONFIG_LIBCURL_CRYPTO_AUTH is not set
# CONFIG_LIBCURL_TLS_SRP is not set
# CONFIG_LIBCURL_LIBIDN2 is not set
# CONFIG_LIBCURL_THREADED_RESOLVER is not set
# CONFIG_LIBCURL_ZLIB is not set
# CONFIG_LIBCURL_ZSTD is not set
# CONFIG_LIBCURL_UNIX_SOCKETS is not set
# CONFIG_LIBCURL_LIBCURL_OPTION is not set
# CONFIG_LIBCURL_VERBOSE is not set
# CONFIG_PACKAGE_libdaemon is not set
# CONFIG_PACKAGE_libdaq is not set
# CONFIG_PACKAGE_libdaq3 is not set
# CONFIG_PACKAGE_libdb47 is not set
# CONFIG_PACKAGE_libdb47xx is not set
# CONFIG_PACKAGE_libdbi is not set
# CONFIG_PACKAGE_libdbus is not set
# CONFIG_PACKAGE_libdevmapper is not set
# CONFIG_PACKAGE_libdevmapper-selinux is not set
# CONFIG_PACKAGE_libdmapsharing is not set
# CONFIG_PACKAGE_libdnet is not set
# CONFIG_PACKAGE_libdouble-conversion is not set
# CONFIG_PACKAGE_libdrm is not set
# CONFIG_PACKAGE_libdw is not set
# CONFIG_PACKAGE_libecdsautil is not set
# CONFIG_PACKAGE_libedit is not set
CONFIG_PACKAGE_libelf=y
# CONFIG_PACKAGE_libesmtp is not set
# CONFIG_PACKAGE_libestr is not set
CONFIG_PACKAGE_libev=y
CONFIG_PACKAGE_libevdev=y
# CONFIG_PACKAGE_libevent2 is not set
# CONFIG_PACKAGE_libevent2-core is not set
# CONFIG_PACKAGE_libevent2-extra is not set
# CONFIG_PACKAGE_libevent2-openssl is not set
# CONFIG_PACKAGE_libevent2-pthreads is not set
# CONFIG_PACKAGE_libexif is not set
# CONFIG_PACKAGE_libexpat is not set
# CONFIG_PACKAGE_libexslt is not set
CONFIG_PACKAGE_libext2fs=y
# CONFIG_PACKAGE_libextractor is not set
# CONFIG_PACKAGE_libf2fs is not set
# CONFIG_PACKAGE_libf2fs-selinux is not set
# CONFIG_PACKAGE_libfaad2 is not set
# CONFIG_PACKAGE_libfastjson is not set
# CONFIG_PACKAGE_libfdisk is not set
# CONFIG_PACKAGE_libfdt is not set
# CONFIG_PACKAGE_libffi is not set
# CONFIG_PACKAGE_libffmpeg-audio-dec is not set
# CONFIG_PACKAGE_libffmpeg-custom is not set
# CONFIG_PACKAGE_libffmpeg-full is not set
# CONFIG_PACKAGE_libffmpeg-mini is not set
# CONFIG_PACKAGE_libfido2 is not set
# CONFIG_PACKAGE_libflac is not set
# CONFIG_PACKAGE_libfmt is not set
# CONFIG_PACKAGE_libfreetype is not set
# CONFIG_PACKAGE_libfstrm is not set
# CONFIG_PACKAGE_libftdi is not set
# CONFIG_PACKAGE_libftdi1 is not set
# CONFIG_PACKAGE_libgabe is not set
# CONFIG_PACKAGE_libgcrypt is not set
# CONFIG_PACKAGE_libgd is not set
# CONFIG_PACKAGE_libgd-full is not set
# CONFIG_PACKAGE_libgdbm is not set
# CONFIG_PACKAGE_libgee is not set
# CONFIG_PACKAGE_libgmp is not set
# CONFIG_PACKAGE_libgnurl is not set
# CONFIG_PACKAGE_libgpg-error is not set
# CONFIG_PACKAGE_libgpgme is not set
# CONFIG_PACKAGE_libgpgmepp is not set
# CONFIG_PACKAGE_libgphoto2 is not set
# CONFIG_PACKAGE_libgpiod is not set
# CONFIG_PACKAGE_libgps is not set
# CONFIG_PACKAGE_libh2o is not set
# CONFIG_PACKAGE_libh2o-evloop is not set
# CONFIG_PACKAGE_libhamlib is not set
# CONFIG_PACKAGE_libhavege is not set
# CONFIG_PACKAGE_libhiredis is not set
# CONFIG_PACKAGE_libhttp-parser is not set
# CONFIG_PACKAGE_libhwloc is not set
# CONFIG_PACKAGE_libi2c is not set
# CONFIG_PACKAGE_libical is not set
# CONFIG_PACKAGE_libiconv is not set
# CONFIG_PACKAGE_libiconv-full is not set
# CONFIG_PACKAGE_libid3tag is not set
# CONFIG_PACKAGE_libidn is not set
# CONFIG_PACKAGE_libidn2 is not set
# CONFIG_PACKAGE_libiio is not set
# CONFIG_PACKAGE_libinotifytools is not set
# CONFIG_PACKAGE_libinput is not set
# CONFIG_PACKAGE_libintl is not set
# CONFIG_PACKAGE_libintl-full is not set
# CONFIG_PACKAGE_libipfs-http-client is not set
# CONFIG_PACKAGE_libiw is not set
CONFIG_PACKAGE_libiwinfo=y
# CONFIG_PACKAGE_libjpeg-turbo is not set
CONFIG_PACKAGE_libjson-c=y
# CONFIG_PACKAGE_libkeyutils is not set
# CONFIG_PACKAGE_libkmod is not set
# CONFIG_PACKAGE_libksba is not set
# CONFIG_PACKAGE_libldns is not set
# CONFIG_PACKAGE_libleptonica is not set
# CONFIG_PACKAGE_libloragw is not set
# CONFIG_PACKAGE_libltdl is not set
CONFIG_PACKAGE_liblua=y
# CONFIG_PACKAGE_liblua5.3 is not set
CONFIG_PACKAGE_liblzo=y
# CONFIG_PACKAGE_libmad is not set
# CONFIG_PACKAGE_libmagic is not set
# CONFIG_PACKAGE_libmaxminddb is not set
# CONFIG_PACKAGE_libmbim is not set
# CONFIG_PACKAGE_libmcrypt is not set
# CONFIG_PACKAGE_libmicrohttpd-no-ssl is not set
# CONFIG_PACKAGE_libmicrohttpd-ssl is not set
# CONFIG_PACKAGE_libmilter-sendmail is not set
CONFIG_PACKAGE_libminiupnpc=y
# CONFIG_PACKAGE_libmms is not set
CONFIG_PACKAGE_libmnl=y
# CONFIG_PACKAGE_libmodbus is not set
# CONFIG_PACKAGE_libmosquitto-nossl is not set
# CONFIG_PACKAGE_libmosquitto-ssl is not set
CONFIG_PACKAGE_libmount=y
# CONFIG_PACKAGE_libmpdclient is not set
# CONFIG_PACKAGE_libmpeg2 is not set
# CONFIG_PACKAGE_libmpg123 is not set
CONFIG_PACKAGE_libnatpmp=y
CONFIG_PACKAGE_libncurses=y
# CONFIG_PACKAGE_libndpi is not set
# CONFIG_PACKAGE_libneon is not set
# CONFIG_PACKAGE_libnet-1.2.x is not set
# CONFIG_PACKAGE_libnetconf2 is not set
# CONFIG_PACKAGE_libnetfilter-acct is not set
# CONFIG_PACKAGE_libnetfilter-conntrack is not set
# CONFIG_PACKAGE_libnetfilter-cthelper is not set
# CONFIG_PACKAGE_libnetfilter-cttimeout is not set
# CONFIG_PACKAGE_libnetfilter-log is not set
# CONFIG_PACKAGE_libnetfilter-queue is not set
# CONFIG_PACKAGE_libnetsnmp is not set
# CONFIG_PACKAGE_libnettle is not set
# CONFIG_PACKAGE_libnewt is not set
# CONFIG_PACKAGE_libnfnetlink is not set
# CONFIG_PACKAGE_libnftnl is not set
# CONFIG_PACKAGE_libnghttp2 is not set
# CONFIG_PACKAGE_libnl is not set
# CONFIG_PACKAGE_libnl-core is not set
# CONFIG_PACKAGE_libnl-genl is not set
# CONFIG_PACKAGE_libnl-nf is not set
# CONFIG_PACKAGE_libnl-route is not set
CONFIG_PACKAGE_libnl-tiny=y
# CONFIG_PACKAGE_libnopoll is not set
# CONFIG_PACKAGE_libnpth is not set
# CONFIG_PACKAGE_libnpupnp is not set
# CONFIG_PACKAGE_libogg is not set
# CONFIG_PACKAGE_liboil is not set
# CONFIG_PACKAGE_libopcodes is not set
# CONFIG_PACKAGE_libopendkim is not set
# CONFIG_PACKAGE_libopenobex is not set
# CONFIG_PACKAGE_libopensc is not set
# CONFIG_PACKAGE_libopenzwave is not set
# CONFIG_PACKAGE_liboping is not set
# CONFIG_PACKAGE_libopus is not set
# CONFIG_PACKAGE_libopusenc is not set
# CONFIG_PACKAGE_libopusfile is not set
# CONFIG_PACKAGE_liborcania is not set
# CONFIG_PACKAGE_libout123 is not set
# CONFIG_PACKAGE_libowipcalc is not set
# CONFIG_PACKAGE_libp11 is not set
# CONFIG_PACKAGE_libpagekite is not set
# CONFIG_PACKAGE_libpam is not set
# CONFIG_PACKAGE_libpbc is not set
# CONFIG_PACKAGE_libpcap is not set
# CONFIG_PACKAGE_libpci is not set
# CONFIG_PACKAGE_libpciaccess is not set
CONFIG_PACKAGE_libpcre=y
# CONFIG_PCRE_JIT_ENABLED is not set
# CONFIG_PACKAGE_libpcre16 is not set
# CONFIG_PACKAGE_libpcre2 is not set
# CONFIG_PACKAGE_libpcre2-16 is not set
# CONFIG_PACKAGE_libpcre2-32 is not set
# CONFIG_PACKAGE_libpcre32 is not set
# CONFIG_PACKAGE_libpcsclite is not set
# CONFIG_PACKAGE_libpfring is not set
# CONFIG_PACKAGE_libpkcs11-spy is not set
# CONFIG_PACKAGE_libpkgconf is not set
# CONFIG_PACKAGE_libpng is not set
# CONFIG_PACKAGE_libpopt is not set
# CONFIG_PACKAGE_libpri is not set
# CONFIG_PACKAGE_libprotobuf-c is not set
# CONFIG_PACKAGE_libpsl is not set
# CONFIG_PACKAGE_libqmi is not set
# CONFIG_PACKAGE_libqrencode is not set
# CONFIG_PACKAGE_libqrtr-glib is not set
# CONFIG_PACKAGE_libradcli is not set
# CONFIG_PACKAGE_libradiotap is not set
CONFIG_PACKAGE_libreadline=y
# CONFIG_PACKAGE_libredblack is not set
# CONFIG_PACKAGE_librouteros is not set
# CONFIG_PACKAGE_libroxml is not set
# CONFIG_PACKAGE_librrd1 is not set
# CONFIG_PACKAGE_librtlsdr is not set
# CONFIG_PACKAGE_libruby is not set
# CONFIG_PACKAGE_libsamplerate is not set
# CONFIG_PACKAGE_libsane is not set
# CONFIG_PACKAGE_libsasl2 is not set
# CONFIG_PACKAGE_libsearpc is not set
# CONFIG_PACKAGE_libseccomp is not set
# CONFIG_PACKAGE_libselinux is not set
# CONFIG_PACKAGE_libsemanage is not set
# CONFIG_PACKAGE_libsensors is not set
# CONFIG_PACKAGE_libsepol is not set
# CONFIG_PACKAGE_libshout is not set
# CONFIG_PACKAGE_libshout-full is not set
# CONFIG_PACKAGE_libshout-nossl is not set
# CONFIG_PACKAGE_libsispmctl is not set
# CONFIG_PACKAGE_libslang2 is not set
# CONFIG_PACKAGE_libslang2-mod-base64 is not set
# CONFIG_PACKAGE_libslang2-mod-chksum is not set
# CONFIG_PACKAGE_libslang2-mod-csv is not set
# CONFIG_PACKAGE_libslang2-mod-fcntl is not set
# CONFIG_PACKAGE_libslang2-mod-fork is not set
# CONFIG_PACKAGE_libslang2-mod-histogram is not set
# CONFIG_PACKAGE_libslang2-mod-iconv is not set
# CONFIG_PACKAGE_libslang2-mod-json is not set
# CONFIG_PACKAGE_libslang2-mod-onig is not set
# CONFIG_PACKAGE_libslang2-mod-pcre is not set
# CONFIG_PACKAGE_libslang2-mod-png is not set
# CONFIG_PACKAGE_libslang2-mod-rand is not set
# CONFIG_PACKAGE_libslang2-mod-select is not set
# CONFIG_PACKAGE_libslang2-mod-slsmg is not set
# CONFIG_PACKAGE_libslang2-mod-socket is not set
# CONFIG_PACKAGE_libslang2-mod-stats is not set
# CONFIG_PACKAGE_libslang2-mod-sysconf is not set
# CONFIG_PACKAGE_libslang2-mod-termios is not set
# CONFIG_PACKAGE_libslang2-mod-varray is not set
# CONFIG_PACKAGE_libslang2-mod-zlib is not set
# CONFIG_PACKAGE_libslang2-modules is not set
CONFIG_PACKAGE_libsmartcols=y
# CONFIG_PACKAGE_libsndfile is not set
# CONFIG_PACKAGE_libsoc is not set
# CONFIG_PACKAGE_libsocks is not set
CONFIG_PACKAGE_libsodium=y
#
# Configuration
#
CONFIG_LIBSODIUM_MINIMAL=y
# end of Configuration
# CONFIG_PACKAGE_libsoup is not set
# CONFIG_PACKAGE_libsoxr is not set
# CONFIG_PACKAGE_libspeex is not set
# CONFIG_PACKAGE_libspeexdsp is not set
# CONFIG_PACKAGE_libspice-server is not set
CONFIG_PACKAGE_libss=y
# CONFIG_PACKAGE_libssh is not set
# CONFIG_PACKAGE_libssh2 is not set
# CONFIG_PACKAGE_libstoken is not set
# CONFIG_PACKAGE_libstrophe is not set
# CONFIG_PACKAGE_libsyn123 is not set
# CONFIG_PACKAGE_libsysrepo is not set
# CONFIG_PACKAGE_libtalloc is not set
# CONFIG_PACKAGE_libtasn1 is not set
# CONFIG_PACKAGE_libtheora is not set
# CONFIG_PACKAGE_libtiff is not set
# CONFIG_PACKAGE_libtins is not set
CONFIG_PACKAGE_libtirpc=y
# CONFIG_PACKAGE_libtorrent-rasterbar is not set
CONFIG_PACKAGE_libubox=y
# CONFIG_PACKAGE_libubox-lua is not set
CONFIG_PACKAGE_libubus=y
CONFIG_PACKAGE_libubus-lua=y
CONFIG_PACKAGE_libuci=y
CONFIG_PACKAGE_libuci-lua=y
# CONFIG_PACKAGE_libuci2 is not set
CONFIG_PACKAGE_libuclient=y
CONFIG_PACKAGE_libudev-zero=y
CONFIG_PACKAGE_libudns=y
# CONFIG_PACKAGE_libuecc is not set
# CONFIG_PACKAGE_libugpio is not set
# CONFIG_PACKAGE_libunistring is not set
# CONFIG_PACKAGE_libunwind is not set
# CONFIG_PACKAGE_libupnp is not set
# CONFIG_PACKAGE_libupnpp is not set
# CONFIG_PACKAGE_liburcu is not set
# CONFIG_PACKAGE_liburing is not set
CONFIG_PACKAGE_libusb-1.0=y
# CONFIG_PACKAGE_libusb-compat is not set
# CONFIG_PACKAGE_libustream-mbedtls is not set
CONFIG_PACKAGE_libustream-openssl=y
# CONFIG_PACKAGE_libustream-wolfssl is not set
CONFIG_PACKAGE_libuuid=y
CONFIG_PACKAGE_libuv=y
# CONFIG_PACKAGE_libuwifi is not set
# CONFIG_PACKAGE_libv4l is not set
# CONFIG_PACKAGE_libvorbis is not set
# CONFIG_PACKAGE_libvorbisidec is not set
# CONFIG_PACKAGE_libvpx is not set
# CONFIG_PACKAGE_libwebp is not set
CONFIG_PACKAGE_libwebsockets-full=y
# CONFIG_PACKAGE_libwebsockets-mbedtls is not set
# CONFIG_PACKAGE_libwebsockets-openssl is not set
# CONFIG_PACKAGE_libwrap is not set
# CONFIG_PACKAGE_libwxbase is not set
# CONFIG_PACKAGE_libxerces-c is not set
# CONFIG_PACKAGE_libxerces-c-samples is not set
# CONFIG_PACKAGE_libxml2 is not set
# CONFIG_PACKAGE_libxslt is not set
# CONFIG_PACKAGE_libyaml-cpp is not set
# CONFIG_PACKAGE_libyang is not set
# CONFIG_PACKAGE_libyang-cpp is not set
# CONFIG_PACKAGE_libyubikey is not set
# CONFIG_PACKAGE_libzmq-curve is not set
# CONFIG_PACKAGE_libzmq-nc is not set
# CONFIG_PACKAGE_linux-atm is not set
# CONFIG_PACKAGE_lmdb is not set
# CONFIG_PACKAGE_log4cplus is not set
# CONFIG_PACKAGE_loudmouth is not set
# CONFIG_PACKAGE_lttng-ust is not set
# CONFIG_PACKAGE_minizip is not set
# CONFIG_PACKAGE_msgpack-c is not set
# CONFIG_PACKAGE_mtdev is not set
# CONFIG_PACKAGE_musl-fts is not set
# CONFIG_PACKAGE_mxml is not set
# CONFIG_PACKAGE_nspr is not set
# CONFIG_PACKAGE_oniguruma is not set
# CONFIG_PACKAGE_open-isns is not set
# CONFIG_PACKAGE_openpgm is not set
# CONFIG_PACKAGE_p11-kit is not set
# CONFIG_PACKAGE_pixman is not set
# CONFIG_PACKAGE_poco is not set
# CONFIG_PACKAGE_poco-all is not set
# CONFIG_PACKAGE_protobuf is not set
# CONFIG_PACKAGE_protobuf-lite is not set
# CONFIG_PACKAGE_pthsem is not set
# CONFIG_PACKAGE_rblibtorrent is not set
# CONFIG_PACKAGE_re2 is not set
CONFIG_PACKAGE_rpcd-mod-rrdns=y
# CONFIG_PACKAGE_sbc is not set
# CONFIG_PACKAGE_serdisplib is not set
# CONFIG_PACKAGE_taglib is not set
CONFIG_PACKAGE_terminfo=y
# CONFIG_PACKAGE_tinycdb is not set
# CONFIG_PACKAGE_uclibcxx is not set
# CONFIG_PACKAGE_uw-imap is not set
# CONFIG_PACKAGE_xmlrpc-c is not set
# CONFIG_PACKAGE_xmlrpc-c-client is not set
# CONFIG_PACKAGE_xmlrpc-c-server is not set
# CONFIG_PACKAGE_yajl is not set
# CONFIG_PACKAGE_yubico-pam is not set
CONFIG_PACKAGE_zlib=y
#
# Configuration
#
CONFIG_ZLIB_OPTIMIZE_SPEED=y
# end of Configuration
# end of Libraries
#
# LuCI
#
#
# 1. Collections
#
CONFIG_PACKAGE_luci=y
# CONFIG_PACKAGE_luci-nginx is not set
# CONFIG_PACKAGE_luci-ssl-nginx is not set
# CONFIG_PACKAGE_luci-ssl-openssl is not set
# end of 1. Collections
#
# 2. Modules
#
CONFIG_PACKAGE_luci-base=y
# CONFIG_LUCI_SRCDIET is not set
#
# Translations
#
# CONFIG_LUCI_LANG_hu is not set
# CONFIG_LUCI_LANG_pt is not set
# CONFIG_LUCI_LANG_no is not set
# CONFIG_LUCI_LANG_sk is not set
# CONFIG_LUCI_LANG_el is not set
# CONFIG_LUCI_LANG_uk is not set
# CONFIG_LUCI_LANG_ru is not set
# CONFIG_LUCI_LANG_vi is not set
# CONFIG_LUCI_LANG_de is not set
# CONFIG_LUCI_LANG_ro is not set
# CONFIG_LUCI_LANG_ms is not set
# CONFIG_LUCI_LANG_pl is not set
CONFIG_LUCI_LANG_zh-cn=y
# CONFIG_LUCI_LANG_ko is not set
# CONFIG_LUCI_LANG_he is not set
# CONFIG_LUCI_LANG_zh-tw is not set
# CONFIG_LUCI_LANG_tr is not set
# CONFIG_LUCI_LANG_sv is not set
# CONFIG_LUCI_LANG_ja is not set
# CONFIG_LUCI_LANG_pt-br is not set
# CONFIG_LUCI_LANG_ca is not set
# CONFIG_LUCI_LANG_en is not set
# CONFIG_LUCI_LANG_es is not set
# CONFIG_LUCI_LANG_cs is not set
# CONFIG_LUCI_LANG_fr is not set
# CONFIG_LUCI_LANG_it is not set
# end of Translations
CONFIG_PACKAGE_luci-compat=y
CONFIG_PACKAGE_luci-mod-admin-full=y
# CONFIG_PACKAGE_luci-mod-failsafe is not set
# CONFIG_PACKAGE_luci-mod-rpc is not set
# CONFIG_PACKAGE_luci-newapi is not set
# end of 2. Modules
#
# 3. Applications
#
CONFIG_PACKAGE_luci-app-accesscontrol=y
# CONFIG_PACKAGE_luci-app-adblock is not set
CONFIG_PACKAGE_luci-app-adbyby-plus=y
# CONFIG_PACKAGE_luci-app-advanced-reboot is not set
# CONFIG_PACKAGE_luci-app-ahcp is not set
# CONFIG_PACKAGE_luci-app-airplay2 is not set
# CONFIG_PACKAGE_luci-app-amule is not set
# CONFIG_PACKAGE_luci-app-aria2 is not set
# CONFIG_PACKAGE_luci-app-arpbind is not set
# CONFIG_PACKAGE_luci-app-asterisk is not set
# CONFIG_PACKAGE_luci-app-attendedsysupgrade is not set
CONFIG_PACKAGE_luci-app-autoreboot=y
# CONFIG_PACKAGE_luci-app-baidupcs-web is not set
# CONFIG_PACKAGE_luci-app-bcp38 is not set
# CONFIG_PACKAGE_luci-app-bird1-ipv4 is not set
# CONFIG_PACKAGE_luci-app-bird1-ipv6 is not set
# CONFIG_PACKAGE_luci-app-bmx6 is not set
CONFIG_PACKAGE_luci-app-cifs-mount=y
# CONFIG_PACKAGE_luci-app-cifsd is not set
# CONFIG_PACKAGE_luci-app-cjdns is not set
# CONFIG_PACKAGE_luci-app-clamav is not set
# CONFIG_PACKAGE_luci-app-commands is not set
# CONFIG_PACKAGE_luci-app-control-timewol is not set
# CONFIG_PACKAGE_luci-app-control-webrestriction is not set
# CONFIG_PACKAGE_luci-app-control-weburl is not set
# CONFIG_PACKAGE_luci-app-cshark is not set
CONFIG_PACKAGE_luci-app-ddns=y
# CONFIG_PACKAGE_luci-app-diag-core is not set
CONFIG_PACKAGE_luci-app-diskman=y
CONFIG_PACKAGE_luci-app-diskman_INCLUDE_btrfs_progs=y
CONFIG_PACKAGE_luci-app-diskman_INCLUDE_lsblk=y
# CONFIG_PACKAGE_luci-app-diskman_INCLUDE_mdadm is not set
# CONFIG_PACKAGE_luci-app-dnscrypt-proxy is not set
# CONFIG_PACKAGE_luci-app-dnsforwarder is not set
# CONFIG_PACKAGE_luci-app-docker is not set
# CONFIG_PACKAGE_luci-app-dump1090 is not set
# CONFIG_PACKAGE_luci-app-dynapoint is not set
# CONFIG_PACKAGE_luci-app-e2guardian is not set
# CONFIG_PACKAGE_luci-app-easymesh is not set
# CONFIG_PACKAGE_luci-app-familycloud is not set
# CONFIG_PACKAGE_luci-app-fileassistant is not set
# CONFIG_PACKAGE_luci-app-filebrowser is not set
# CONFIG_PACKAGE_luci-app-filetransfer is not set
CONFIG_PACKAGE_luci-app-firewall=y
# CONFIG_PACKAGE_luci-app-frpc is not set
# CONFIG_PACKAGE_luci-app-frps is not set
# CONFIG_PACKAGE_luci-app-fwknopd is not set
# CONFIG_PACKAGE_luci-app-guest-wifi is not set
# CONFIG_PACKAGE_luci-app-haproxy-tcp is not set
# CONFIG_PACKAGE_luci-app-hd-idle is not set
# CONFIG_PACKAGE_luci-app-hnet is not set
# CONFIG_PACKAGE_luci-app-https-dns-proxy is not set
# CONFIG_PACKAGE_luci-app-ipsec-server is not set
# CONFIG_PACKAGE_luci-app-ipsec-vpnd is not set
# CONFIG_PACKAGE_luci-app-jd-dailybonus is not set
# CONFIG_PACKAGE_luci-app-kodexplorer is not set
# CONFIG_PACKAGE_luci-app-lxc is not set
# CONFIG_PACKAGE_luci-app-minidlna is not set
# CONFIG_PACKAGE_luci-app-mjpg-streamer is not set
# CONFIG_PACKAGE_luci-app-music-remote-center is not set
# CONFIG_PACKAGE_luci-app-mwan3 is not set
# CONFIG_PACKAGE_luci-app-mwan3helper is not set
# CONFIG_PACKAGE_luci-app-n2n_v2 is not set
CONFIG_PACKAGE_luci-app-netdata=y
# CONFIG_PACKAGE_luci-app-nfs is not set
# CONFIG_PACKAGE_luci-app-nft-qos is not set
# CONFIG_PACKAGE_luci-app-nginx-pingos is not set
# CONFIG_PACKAGE_luci-app-nlbwmon is not set
# CONFIG_PACKAGE_luci-app-noddos is not set
# CONFIG_PACKAGE_luci-app-nps is not set
# CONFIG_PACKAGE_luci-app-ntpc is not set
# CONFIG_PACKAGE_luci-app-ocserv is not set
# CONFIG_PACKAGE_luci-app-olsr is not set
# CONFIG_PACKAGE_luci-app-olsr-services is not set
# CONFIG_PACKAGE_luci-app-olsr-viz is not set
# CONFIG_PACKAGE_luci-app-openclash is not set
# CONFIG_PACKAGE_luci-app-openvpn is not set
# CONFIG_PACKAGE_luci-app-openvpn-server is not set
# CONFIG_PACKAGE_luci-app-p910nd is not set
# CONFIG_PACKAGE_luci-app-pagekitec is not set
CONFIG_PACKAGE_luci-app-passwall=y
#
# Configuration
#
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Brook is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ChinaDNS_NG=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Dns2socks=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Haproxy is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Hysteria is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Kcptun is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_NaiveProxy is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_PDNSD=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Libev_Client=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Libev_Server is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Rust_Client is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR_Libev_Client=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR_Libev_Server is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Simple_Obfs=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_GO is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_Plus=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_V2ray is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_V2ray_Plugin is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray=y
# end of Configuration
# CONFIG_PACKAGE_luci-app-polipo is not set
# CONFIG_PACKAGE_luci-app-pppoe-relay is not set
# CONFIG_PACKAGE_luci-app-pppoe-server is not set
# CONFIG_PACKAGE_luci-app-pptp-server is not set
# CONFIG_PACKAGE_luci-app-privoxy is not set
# CONFIG_PACKAGE_luci-app-ps3netsrv is not set
# CONFIG_PACKAGE_luci-app-pushbot is not set
# CONFIG_PACKAGE_luci-app-qbittorrent is not set
CONFIG_PACKAGE_luci-app-qbittorrent_dynamic=y
# CONFIG_PACKAGE_luci-app-qos is not set
# CONFIG_PACKAGE_luci-app-radicale is not set
CONFIG_PACKAGE_luci-app-ramfree=y
# CONFIG_PACKAGE_luci-app-rclone is not set
# CONFIG_PACKAGE_luci-app-rclone_INCLUDE_rclone-webui is not set
# CONFIG_PACKAGE_luci-app-rclone_INCLUDE_rclone-ng is not set
# CONFIG_PACKAGE_luci-app-rclone_INCLUDE_fuse-utils is not set
# CONFIG_PACKAGE_luci-app-rp-pppoe-server is not set
CONFIG_PACKAGE_luci-app-samba=y
# CONFIG_PACKAGE_luci-app-samba4 is not set
# CONFIG_PACKAGE_luci-app-shadowsocks-libev is not set
# CONFIG_PACKAGE_luci-app-shairplay is not set
# CONFIG_PACKAGE_luci-app-siitwizard is not set
# CONFIG_PACKAGE_luci-app-simple-adblock is not set
# CONFIG_PACKAGE_luci-app-socat is not set
# CONFIG_PACKAGE_luci-app-softethervpn is not set
# CONFIG_PACKAGE_luci-app-splash is not set
# CONFIG_PACKAGE_luci-app-sqm is not set
# CONFIG_PACKAGE_luci-app-squid is not set
# CONFIG_PACKAGE_luci-app-ssr-mudb-server is not set
CONFIG_PACKAGE_luci-app-ssr-plus=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Kcptun is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_NaiveProxy is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Redsocks2 is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Libev_Client is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Libev_Server is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Rust_Client is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Rust_Server is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Libev_Client=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Libev_Server is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Simple_Obfs is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Trojan is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_V2ray_Plugin is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Xray=y
# CONFIG_PACKAGE_luci-app-ssrserver-python is not set
# CONFIG_PACKAGE_luci-app-statistics is not set
# CONFIG_PACKAGE_luci-app-syncdial is not set
# CONFIG_PACKAGE_luci-app-syncthing is not set
# CONFIG_PACKAGE_luci-app-timecontrol is not set
# CONFIG_PACKAGE_luci-app-tinyproxy is not set
# CONFIG_PACKAGE_luci-app-transmission is not set
# CONFIG_PACKAGE_luci-app-travelmate is not set
CONFIG_PACKAGE_luci-app-ttyd=y
CONFIG_PACKAGE_luci-app-turboacc=y
CONFIG_PACKAGE_TURBOACC_INCLUDE_OFFLOADING=y
# CONFIG_PACKAGE_TURBOACC_INCLUDE_SHORTCUT_FE is not set
CONFIG_PACKAGE_TURBOACC_INCLUDE_BBR_CCA=y
# CONFIG_PACKAGE_TURBOACC_INCLUDE_DNSFORWARDER is not set
# CONFIG_PACKAGE_TURBOACC_INCLUDE_DNSPROXY is not set
# CONFIG_PACKAGE_luci-app-udpxy is not set
# CONFIG_PACKAGE_luci-app-uhttpd is not set
# CONFIG_PACKAGE_luci-app-unblockmusic is not set
# CONFIG_PACKAGE_luci-app-unblockmusic_INCLUDE_UnblockNeteaseMusic_Go is not set
# CONFIG_PACKAGE_luci-app-unblockmusic_INCLUDE_UnblockNeteaseMusic_NodeJS is not set
# CONFIG_PACKAGE_luci-app-unbound is not set
CONFIG_PACKAGE_luci-app-upnp=y
# CONFIG_PACKAGE_luci-app-usb-printer is not set
# CONFIG_PACKAGE_luci-app-uugamebooster is not set
# CONFIG_PACKAGE_luci-app-v2ray-server is not set
# CONFIG_PACKAGE_luci-app-verysync is not set
CONFIG_PACKAGE_luci-app-vlmcsd=y
# CONFIG_PACKAGE_luci-app-vnstat is not set
# CONFIG_PACKAGE_luci-app-vpnbypass is not set
# CONFIG_PACKAGE_luci-app-vsftpd is not set
# CONFIG_PACKAGE_luci-app-watchcat is not set
# CONFIG_PACKAGE_luci-app-webadmin is not set
# CONFIG_PACKAGE_luci-app-wifischedule is not set
# CONFIG_PACKAGE_luci-app-wireguard is not set
# CONFIG_PACKAGE_luci-app-wol is not set
# CONFIG_PACKAGE_luci-app-wrtbwmon is not set
# CONFIG_PACKAGE_luci-app-xlnetacc is not set
CONFIG_PACKAGE_luci-app-zerotier=y
# end of 3. Applications
#
# 4. Themes
#
# CONFIG_PACKAGE_luci-theme-argon is not set
CONFIG_PACKAGE_luci-theme-bootstrap=y
# CONFIG_PACKAGE_luci-theme-material is not set
# CONFIG_PACKAGE_luci-theme-netgear is not set
# end of 4. Themes
#
# 5. Protocols
#
# CONFIG_PACKAGE_luci-proto-3g is not set
# CONFIG_PACKAGE_luci-proto-bonding is not set
# CONFIG_PACKAGE_luci-proto-ipip is not set
# CONFIG_PACKAGE_luci-proto-ipv6 is not set
# CONFIG_PACKAGE_luci-proto-ncm is not set
# CONFIG_PACKAGE_luci-proto-openconnect is not set
CONFIG_PACKAGE_luci-proto-ppp=y
# CONFIG_PACKAGE_luci-proto-qmi is not set
# CONFIG_PACKAGE_luci-proto-relay is not set
# CONFIG_PACKAGE_luci-proto-vpnc is not set
# CONFIG_PACKAGE_luci-proto-wireguard is not set
# end of 5. Protocols
#
# 6. Libraries
#
# CONFIG_PACKAGE_luci-lib-dracula is not set
# CONFIG_PACKAGE_luci-lib-httpclient is not set
# CONFIG_PACKAGE_luci-lib-httpprotoutils is not set
CONFIG_PACKAGE_luci-lib-ip=y
# CONFIG_PACKAGE_luci-lib-iptparser is not set
# CONFIG_PACKAGE_luci-lib-jquery-1-4 is not set
# CONFIG_PACKAGE_luci-lib-json is not set
CONFIG_PACKAGE_luci-lib-jsonc=y
# CONFIG_PACKAGE_luci-lib-luaneightbl is not set
CONFIG_PACKAGE_luci-lib-nixio=y
# CONFIG_PACKAGE_luci-lib-nixio_notls is not set
# CONFIG_PACKAGE_luci-lib-nixio_axtls is not set
# CONFIG_PACKAGE_luci-lib-nixio_cyassl is not set
CONFIG_PACKAGE_luci-lib-nixio_openssl=y
# CONFIG_PACKAGE_luci-lib-px5g is not set
# end of 6. Libraries
CONFIG_PACKAGE_default-settings=y
CONFIG_PACKAGE_luci-i18n-accesscontrol-zh-cn=y
CONFIG_PACKAGE_luci-i18n-adbyby-plus-zh-cn=y
CONFIG_PACKAGE_luci-i18n-autoreboot-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-base-ca is not set
# CONFIG_PACKAGE_luci-i18n-base-cs is not set
# CONFIG_PACKAGE_luci-i18n-base-de is not set
# CONFIG_PACKAGE_luci-i18n-base-el is not set
# CONFIG_PACKAGE_luci-i18n-base-en is not set
# CONFIG_PACKAGE_luci-i18n-base-es is not set
# CONFIG_PACKAGE_luci-i18n-base-fr is not set
# CONFIG_PACKAGE_luci-i18n-base-he is not set
# CONFIG_PACKAGE_luci-i18n-base-hu is not set
# CONFIG_PACKAGE_luci-i18n-base-it is not set
# CONFIG_PACKAGE_luci-i18n-base-ja is not set
# CONFIG_PACKAGE_luci-i18n-base-ko is not set
# CONFIG_PACKAGE_luci-i18n-base-ms is not set
# CONFIG_PACKAGE_luci-i18n-base-no is not set
# CONFIG_PACKAGE_luci-i18n-base-pl is not set
# CONFIG_PACKAGE_luci-i18n-base-pt is not set
# CONFIG_PACKAGE_luci-i18n-base-pt-br is not set
# CONFIG_PACKAGE_luci-i18n-base-ro is not set
# CONFIG_PACKAGE_luci-i18n-base-ru is not set
# CONFIG_PACKAGE_luci-i18n-base-sk is not set
# CONFIG_PACKAGE_luci-i18n-base-sv is not set
# CONFIG_PACKAGE_luci-i18n-base-tr is not set
# CONFIG_PACKAGE_luci-i18n-base-uk is not set
# CONFIG_PACKAGE_luci-i18n-base-vi is not set
CONFIG_PACKAGE_luci-i18n-base-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-base-zh-tw is not set
CONFIG_PACKAGE_luci-i18n-cifs-mount-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-ddns-bg is not set
# CONFIG_PACKAGE_luci-i18n-ddns-ca is not set
# CONFIG_PACKAGE_luci-i18n-ddns-cs is not set
# CONFIG_PACKAGE_luci-i18n-ddns-de is not set
# CONFIG_PACKAGE_luci-i18n-ddns-el is not set
# CONFIG_PACKAGE_luci-i18n-ddns-en is not set
# CONFIG_PACKAGE_luci-i18n-ddns-es is not set
# CONFIG_PACKAGE_luci-i18n-ddns-fr is not set
# CONFIG_PACKAGE_luci-i18n-ddns-he is not set
# CONFIG_PACKAGE_luci-i18n-ddns-hi is not set
# CONFIG_PACKAGE_luci-i18n-ddns-hu is not set
# CONFIG_PACKAGE_luci-i18n-ddns-it is not set
# CONFIG_PACKAGE_luci-i18n-ddns-ja is not set
# CONFIG_PACKAGE_luci-i18n-ddns-ko is not set
# CONFIG_PACKAGE_luci-i18n-ddns-mr is not set
# CONFIG_PACKAGE_luci-i18n-ddns-ms is not set
# CONFIG_PACKAGE_luci-i18n-ddns-no is not set
# CONFIG_PACKAGE_luci-i18n-ddns-pl is not set
# CONFIG_PACKAGE_luci-i18n-ddns-pt is not set
# CONFIG_PACKAGE_luci-i18n-ddns-pt-br is not set
# CONFIG_PACKAGE_luci-i18n-ddns-ro is not set
# CONFIG_PACKAGE_luci-i18n-ddns-ru is not set
# CONFIG_PACKAGE_luci-i18n-ddns-sk is not set
# CONFIG_PACKAGE_luci-i18n-ddns-sv is not set
# CONFIG_PACKAGE_luci-i18n-ddns-tr is not set
# CONFIG_PACKAGE_luci-i18n-ddns-uk is not set
# CONFIG_PACKAGE_luci-i18n-ddns-vi is not set
CONFIG_PACKAGE_luci-i18n-ddns-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-ddns-zh-tw is not set
# CONFIG_PACKAGE_luci-i18n-firewall-ca is not set
# CONFIG_PACKAGE_luci-i18n-firewall-cs is not set
# CONFIG_PACKAGE_luci-i18n-firewall-de is not set
# CONFIG_PACKAGE_luci-i18n-firewall-el is not set
# CONFIG_PACKAGE_luci-i18n-firewall-en is not set
# CONFIG_PACKAGE_luci-i18n-firewall-es is not set
# CONFIG_PACKAGE_luci-i18n-firewall-fr is not set
# CONFIG_PACKAGE_luci-i18n-firewall-he is not set
# CONFIG_PACKAGE_luci-i18n-firewall-hu is not set
# CONFIG_PACKAGE_luci-i18n-firewall-it is not set
# CONFIG_PACKAGE_luci-i18n-firewall-ja is not set
# CONFIG_PACKAGE_luci-i18n-firewall-ko is not set
# CONFIG_PACKAGE_luci-i18n-firewall-ms is not set
# CONFIG_PACKAGE_luci-i18n-firewall-no is not set
# CONFIG_PACKAGE_luci-i18n-firewall-pl is not set
# CONFIG_PACKAGE_luci-i18n-firewall-pt is not set
# CONFIG_PACKAGE_luci-i18n-firewall-pt-br is not set
# CONFIG_PACKAGE_luci-i18n-firewall-ro is not set
# CONFIG_PACKAGE_luci-i18n-firewall-ru is not set
# CONFIG_PACKAGE_luci-i18n-firewall-sk is not set
# CONFIG_PACKAGE_luci-i18n-firewall-sv is not set
# CONFIG_PACKAGE_luci-i18n-firewall-tr is not set
# CONFIG_PACKAGE_luci-i18n-firewall-uk is not set
# CONFIG_PACKAGE_luci-i18n-firewall-vi is not set
CONFIG_PACKAGE_luci-i18n-firewall-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-firewall-zh-tw is not set
CONFIG_PACKAGE_luci-i18n-netdata-zh-cn=y
CONFIG_PACKAGE_luci-i18n-passwall-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-passwall-zh_Hans is not set
CONFIG_PACKAGE_luci-i18n-ramfree-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-samba-ca is not set
# CONFIG_PACKAGE_luci-i18n-samba-cs is not set
# CONFIG_PACKAGE_luci-i18n-samba-de is not set
# CONFIG_PACKAGE_luci-i18n-samba-el is not set
# CONFIG_PACKAGE_luci-i18n-samba-en is not set
# CONFIG_PACKAGE_luci-i18n-samba-es is not set
# CONFIG_PACKAGE_luci-i18n-samba-fr is not set
# CONFIG_PACKAGE_luci-i18n-samba-he is not set
# CONFIG_PACKAGE_luci-i18n-samba-hu is not set
# CONFIG_PACKAGE_luci-i18n-samba-it is not set
# CONFIG_PACKAGE_luci-i18n-samba-ja is not set
# CONFIG_PACKAGE_luci-i18n-samba-ms is not set
# CONFIG_PACKAGE_luci-i18n-samba-no is not set
# CONFIG_PACKAGE_luci-i18n-samba-pl is not set
# CONFIG_PACKAGE_luci-i18n-samba-pt is not set
# CONFIG_PACKAGE_luci-i18n-samba-pt-br is not set
# CONFIG_PACKAGE_luci-i18n-samba-ro is not set
# CONFIG_PACKAGE_luci-i18n-samba-ru is not set
# CONFIG_PACKAGE_luci-i18n-samba-sk is not set
# CONFIG_PACKAGE_luci-i18n-samba-sv is not set
# CONFIG_PACKAGE_luci-i18n-samba-tr is not set
# CONFIG_PACKAGE_luci-i18n-samba-uk is not set
# CONFIG_PACKAGE_luci-i18n-samba-vi is not set
CONFIG_PACKAGE_luci-i18n-samba-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-samba-zh-tw is not set
CONFIG_PACKAGE_luci-i18n-ssr-plus-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-ssr-plus-zh_Hans is not set
CONFIG_PACKAGE_luci-i18n-ttyd-zh-cn=y
CONFIG_PACKAGE_luci-i18n-turboacc-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-upnp-ca is not set
# CONFIG_PACKAGE_luci-i18n-upnp-cs is not set
# CONFIG_PACKAGE_luci-i18n-upnp-de is not set
# CONFIG_PACKAGE_luci-i18n-upnp-el is not set
# CONFIG_PACKAGE_luci-i18n-upnp-en is not set
# CONFIG_PACKAGE_luci-i18n-upnp-es is not set
# CONFIG_PACKAGE_luci-i18n-upnp-fr is not set
# CONFIG_PACKAGE_luci-i18n-upnp-he is not set
# CONFIG_PACKAGE_luci-i18n-upnp-hu is not set
# CONFIG_PACKAGE_luci-i18n-upnp-it is not set
# CONFIG_PACKAGE_luci-i18n-upnp-ja is not set
# CONFIG_PACKAGE_luci-i18n-upnp-ms is not set
# CONFIG_PACKAGE_luci-i18n-upnp-no is not set
# CONFIG_PACKAGE_luci-i18n-upnp-pl is not set
# CONFIG_PACKAGE_luci-i18n-upnp-pt is not set
# CONFIG_PACKAGE_luci-i18n-upnp-pt-br is not set
# CONFIG_PACKAGE_luci-i18n-upnp-ro is not set
# CONFIG_PACKAGE_luci-i18n-upnp-ru is not set
# CONFIG_PACKAGE_luci-i18n-upnp-sk is not set
# CONFIG_PACKAGE_luci-i18n-upnp-sv is not set
# CONFIG_PACKAGE_luci-i18n-upnp-tr is not set
# CONFIG_PACKAGE_luci-i18n-upnp-uk is not set
# CONFIG_PACKAGE_luci-i18n-upnp-vi is not set
CONFIG_PACKAGE_luci-i18n-upnp-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-upnp-zh-tw is not set
CONFIG_PACKAGE_luci-i18n-vlmcsd-zh-cn=y
CONFIG_PACKAGE_luci-i18n-zerotier-zh-cn=y
# end of LuCI
#
# Mail
#
# CONFIG_PACKAGE_alpine is not set
# CONFIG_PACKAGE_bogofilter is not set
# CONFIG_PACKAGE_dovecot is not set
# CONFIG_PACKAGE_dovecot-pigeonhole is not set
# CONFIG_PACKAGE_dovecot-utils is not set
# CONFIG_PACKAGE_emailrelay is not set
# CONFIG_PACKAGE_exim is not set
# CONFIG_PACKAGE_exim-gnutls is not set
# CONFIG_PACKAGE_exim-ldap is not set
# CONFIG_PACKAGE_exim-openssl is not set
# CONFIG_PACKAGE_fdm is not set
# CONFIG_PACKAGE_greyfix is not set
# CONFIG_PACKAGE_mailsend is not set
# CONFIG_PACKAGE_mailsend-nossl is not set
# CONFIG_PACKAGE_msmtp is not set
# CONFIG_PACKAGE_msmtp-mta is not set
# CONFIG_PACKAGE_msmtp-nossl is not set
# CONFIG_PACKAGE_msmtp-queue is not set
# CONFIG_PACKAGE_mutt is not set
# CONFIG_PACKAGE_nail is not set
# CONFIG_PACKAGE_opendkim is not set
# CONFIG_PACKAGE_opendkim-tools is not set
# CONFIG_PACKAGE_postfix is not set
#
# Select postfix build options
#
CONFIG_POSTFIX_TLS=y
CONFIG_POSTFIX_SASL=y
CONFIG_POSTFIX_LDAP=y
# CONFIG_POSTFIX_DB is not set
CONFIG_POSTFIX_CDB=y
CONFIG_POSTFIX_SQLITE=y
# CONFIG_POSTFIX_MYSQL is not set
# CONFIG_POSTFIX_PGSQL is not set
CONFIG_POSTFIX_PCRE=y
# CONFIG_POSTFIX_EAI is not set
# end of Select postfix build options
# CONFIG_PACKAGE_spamc is not set
# CONFIG_PACKAGE_spamc-ssl is not set
# end of Mail
#
# Multimedia
#
#
# Streaming
#
# CONFIG_PACKAGE_oggfwd is not set
# end of Streaming
# CONFIG_PACKAGE_UnblockNeteaseMusic is not set
# CONFIG_PACKAGE_UnblockNeteaseMusic-Go is not set
# CONFIG_UNBLOCKNETEASEMUSIC_GO_COMPRESS_GOPROXY is not set
CONFIG_UNBLOCKNETEASEMUSIC_GO_COMPRESS_UPX=y
# CONFIG_PACKAGE_ffmpeg is not set
# CONFIG_PACKAGE_ffprobe is not set
# CONFIG_PACKAGE_fswebcam is not set
# CONFIG_PACKAGE_gerbera is not set
# CONFIG_PACKAGE_gmediarender is not set
# CONFIG_PACKAGE_gphoto2 is not set
# CONFIG_PACKAGE_graphicsmagick is not set
# CONFIG_PACKAGE_grilo is not set
# CONFIG_PACKAGE_grilo-plugins is not set
# CONFIG_PACKAGE_gst1-libav is not set
# CONFIG_PACKAGE_gstreamer1-libs is not set
# CONFIG_PACKAGE_gstreamer1-plugins-bad is not set
# CONFIG_PACKAGE_gstreamer1-plugins-base is not set
# CONFIG_PACKAGE_gstreamer1-plugins-good is not set
# CONFIG_PACKAGE_gstreamer1-plugins-ugly is not set
# CONFIG_PACKAGE_gstreamer1-utils is not set
# CONFIG_PACKAGE_icecast is not set
# CONFIG_PACKAGE_imagemagick is not set
# CONFIG_PACKAGE_lcdgrilo is not set
# CONFIG_PACKAGE_minidlna is not set
# CONFIG_PACKAGE_minisatip is not set
# CONFIG_PACKAGE_mjpg-streamer is not set
# CONFIG_PACKAGE_motion is not set
# CONFIG_PACKAGE_tvheadend is not set
# CONFIG_PACKAGE_v4l2rtspserver is not set
# CONFIG_PACKAGE_vips is not set
# CONFIG_PACKAGE_xupnpd is not set
# CONFIG_PACKAGE_youtube-dl is not set
# end of Multimedia
#
# Network
#
#
# BitTorrent
#
# CONFIG_PACKAGE_mktorrent is not set
# CONFIG_PACKAGE_opentracker is not set
# CONFIG_PACKAGE_opentracker6 is not set
# CONFIG_PACKAGE_qbittorrent is not set
# CONFIG_PACKAGE_rtorrent is not set
# CONFIG_PACKAGE_rtorrent-rpc is not set
# CONFIG_PACKAGE_transmission-cli-openssl is not set
# CONFIG_PACKAGE_transmission-daemon-openssl is not set
# CONFIG_PACKAGE_transmission-remote-openssl is not set
# CONFIG_PACKAGE_transmission-web is not set
# CONFIG_PACKAGE_transmission-web-control is not set
# end of BitTorrent
#
# Captive Portals
#
# CONFIG_PACKAGE_apfree-wifidog is not set
# CONFIG_PACKAGE_coova-chilli is not set
# CONFIG_PACKAGE_nodogsplash is not set
# CONFIG_PACKAGE_opennds is not set
# CONFIG_PACKAGE_wifidog is not set
# CONFIG_PACKAGE_wifidog-tls is not set
# end of Captive Portals
#
# Cloud Manager
#
# CONFIG_PACKAGE_rclone-ng is not set
# CONFIG_PACKAGE_rclone-webui-react is not set
# end of Cloud Manager
#
# Dial-in/up
#
# CONFIG_PACKAGE_rp-pppoe-common is not set
# CONFIG_PACKAGE_rp-pppoe-relay is not set
# CONFIG_PACKAGE_rp-pppoe-server is not set
# end of Dial-in/up
#
# Download Manager
#
# CONFIG_PACKAGE_ariang is not set
# CONFIG_PACKAGE_ariang-nginx is not set
# CONFIG_PACKAGE_leech is not set
# CONFIG_PACKAGE_webui-aria2 is not set
# end of Download Manager
#
# File Transfer
#
# CONFIG_PACKAGE_aria2 is not set
# CONFIG_PACKAGE_atftp is not set
# CONFIG_PACKAGE_atftpd is not set
CONFIG_PACKAGE_curl=y
# CONFIG_PACKAGE_gnurl is not set
# CONFIG_PACKAGE_lftp is not set
# CONFIG_PACKAGE_ps3netsrv is not set
# CONFIG_PACKAGE_rosy-file-server is not set
# CONFIG_PACKAGE_rsync is not set
# CONFIG_PACKAGE_rsyncd is not set
# CONFIG_PACKAGE_vsftpd is not set
# CONFIG_PACKAGE_vsftpd-alt is not set
# CONFIG_PACKAGE_vsftpd-tls is not set
# CONFIG_PACKAGE_wget-nossl is not set
CONFIG_PACKAGE_wget-ssl=y
# end of File Transfer
#
# Filesystem
#
# CONFIG_PACKAGE_davfs2 is not set
# CONFIG_PACKAGE_ksmbd-avahi-service is not set
# CONFIG_PACKAGE_ksmbd-server is not set
# CONFIG_PACKAGE_ksmbd-utils is not set
# CONFIG_PACKAGE_netatalk is not set
# CONFIG_PACKAGE_nfs-kernel-server is not set
# CONFIG_PACKAGE_owftpd is not set
# CONFIG_PACKAGE_owhttpd is not set
# CONFIG_PACKAGE_owserver is not set
# CONFIG_PACKAGE_sshfs is not set
# end of Filesystem
#
# Firewall
#
# CONFIG_PACKAGE_arptables is not set
# CONFIG_PACKAGE_conntrack is not set
# CONFIG_PACKAGE_conntrackd is not set
# CONFIG_PACKAGE_ebtables is not set
# CONFIG_PACKAGE_fwknop is not set
# CONFIG_PACKAGE_fwknopd is not set
# CONFIG_PACKAGE_ip6tables is not set
CONFIG_PACKAGE_iptables=y
# CONFIG_IPTABLES_CONNLABEL is not set
# CONFIG_IPTABLES_NFTABLES is not set
# CONFIG_PACKAGE_iptables-mod-account is not set
# CONFIG_PACKAGE_iptables-mod-chaos is not set
# CONFIG_PACKAGE_iptables-mod-checksum is not set
# CONFIG_PACKAGE_iptables-mod-cluster is not set
# CONFIG_PACKAGE_iptables-mod-clusterip is not set
# CONFIG_PACKAGE_iptables-mod-condition is not set
# CONFIG_PACKAGE_iptables-mod-conntrack-extra is not set
# CONFIG_PACKAGE_iptables-mod-delude is not set
# CONFIG_PACKAGE_iptables-mod-dhcpmac is not set
# CONFIG_PACKAGE_iptables-mod-dnetmap is not set
# CONFIG_PACKAGE_iptables-mod-extra is not set
# CONFIG_PACKAGE_iptables-mod-filter is not set
CONFIG_PACKAGE_iptables-mod-fullconenat=y
# CONFIG_PACKAGE_iptables-mod-fuzzy is not set
# CONFIG_PACKAGE_iptables-mod-geoip is not set
# CONFIG_PACKAGE_iptables-mod-hashlimit is not set
# CONFIG_PACKAGE_iptables-mod-iface is not set
# CONFIG_PACKAGE_iptables-mod-ipmark is not set
# CONFIG_PACKAGE_iptables-mod-ipopt is not set
# CONFIG_PACKAGE_iptables-mod-ipp2p is not set
# CONFIG_PACKAGE_iptables-mod-iprange is not set
# CONFIG_PACKAGE_iptables-mod-ipsec is not set
# CONFIG_PACKAGE_iptables-mod-ipv4options is not set
# CONFIG_PACKAGE_iptables-mod-led is not set
# CONFIG_PACKAGE_iptables-mod-length2 is not set
# CONFIG_PACKAGE_iptables-mod-logmark is not set
# CONFIG_PACKAGE_iptables-mod-lscan is not set
# CONFIG_PACKAGE_iptables-mod-lua is not set
# CONFIG_PACKAGE_iptables-mod-nat-extra is not set
# CONFIG_PACKAGE_iptables-mod-nflog is not set
# CONFIG_PACKAGE_iptables-mod-nfqueue is not set
# CONFIG_PACKAGE_iptables-mod-physdev is not set
# CONFIG_PACKAGE_iptables-mod-proto is not set
# CONFIG_PACKAGE_iptables-mod-psd is not set
# CONFIG_PACKAGE_iptables-mod-quota2 is not set
# CONFIG_PACKAGE_iptables-mod-rpfilter is not set
# CONFIG_PACKAGE_iptables-mod-rtpengine is not set
# CONFIG_PACKAGE_iptables-mod-sysrq is not set
# CONFIG_PACKAGE_iptables-mod-tarpit is not set
# CONFIG_PACKAGE_iptables-mod-tee is not set
CONFIG_PACKAGE_iptables-mod-tproxy=y
# CONFIG_PACKAGE_iptables-mod-trace is not set
# CONFIG_PACKAGE_iptables-mod-u32 is not set
# CONFIG_PACKAGE_iptables-mod-ulog is not set
# CONFIG_PACKAGE_iptaccount is not set
# CONFIG_PACKAGE_iptgeoip is not set
#
# Select iptgeoip options
#
# CONFIG_IPTGEOIP_PRESERVE is not set
# end of Select iptgeoip options
# CONFIG_PACKAGE_miniupnpc is not set
CONFIG_PACKAGE_miniupnpd=y
# CONFIG_MINIUPNPD_IGDv2 is not set
# CONFIG_PACKAGE_natpmpc is not set
# CONFIG_PACKAGE_nftables-json is not set
# CONFIG_PACKAGE_nftables-nojson is not set
# CONFIG_PACKAGE_shorewall is not set
# CONFIG_PACKAGE_shorewall-core is not set
# CONFIG_PACKAGE_shorewall-lite is not set
# CONFIG_PACKAGE_shorewall6 is not set
# CONFIG_PACKAGE_shorewall6-lite is not set
# CONFIG_PACKAGE_snort is not set
# CONFIG_PACKAGE_snort3 is not set
# end of Firewall
#
# Firewall Tunnel
#
# CONFIG_PACKAGE_iodine is not set
# CONFIG_PACKAGE_iodined is not set
# end of Firewall Tunnel
#
# FreeRADIUS (version 3)
#
# CONFIG_PACKAGE_freeradius3 is not set
# CONFIG_PACKAGE_freeradius3-common is not set
# CONFIG_PACKAGE_freeradius3-utils is not set
# end of FreeRADIUS (version 3)
#
# IP Addresses and Names
#
# CONFIG_PACKAGE_aggregate is not set
# CONFIG_PACKAGE_announce is not set
# CONFIG_PACKAGE_avahi-autoipd is not set
# CONFIG_PACKAGE_avahi-daemon-service-http is not set
# CONFIG_PACKAGE_avahi-daemon-service-ssh is not set
# CONFIG_PACKAGE_avahi-dbus-daemon is not set
# CONFIG_PACKAGE_avahi-dnsconfd is not set
# CONFIG_PACKAGE_avahi-nodbus-daemon is not set
# CONFIG_PACKAGE_avahi-utils is not set
# CONFIG_PACKAGE_bind-check is not set
# CONFIG_PACKAGE_bind-client is not set
# CONFIG_PACKAGE_bind-dig is not set
# CONFIG_PACKAGE_bind-dnssec is not set
# CONFIG_PACKAGE_bind-host is not set
# CONFIG_PACKAGE_bind-nslookup is not set
# CONFIG_PACKAGE_bind-rndc is not set
# CONFIG_PACKAGE_bind-server is not set
# CONFIG_PACKAGE_bind-tools is not set
CONFIG_PACKAGE_ddns-scripts=y
CONFIG_PACKAGE_ddns-scripts_aliyun=y
# CONFIG_PACKAGE_ddns-scripts_cloudflare.com-v4 is not set
CONFIG_PACKAGE_ddns-scripts_dnspod=y
# CONFIG_PACKAGE_ddns-scripts_freedns_42_pl is not set
# CONFIG_PACKAGE_ddns-scripts_godaddy.com-v1 is not set
# CONFIG_PACKAGE_ddns-scripts_no-ip_com is not set
# CONFIG_PACKAGE_ddns-scripts_nsupdate is not set
# CONFIG_PACKAGE_ddns-scripts_route53-v1 is not set
# CONFIG_PACKAGE_dhcp-forwarder is not set
CONFIG_PACKAGE_dns2socks=y
# CONFIG_PACKAGE_dnscrypt-proxy is not set
# CONFIG_PACKAGE_dnscrypt-proxy-resolvers is not set
# CONFIG_PACKAGE_dnsdist is not set
# CONFIG_PACKAGE_dnsproxy is not set
# CONFIG_DNSPROXY_COMPRESS_GOPROXY is not set
CONFIG_DNSPROXY_COMPRESS_UPX=y
# CONFIG_PACKAGE_drill is not set
# CONFIG_PACKAGE_hostip is not set
# CONFIG_PACKAGE_idn is not set
# CONFIG_PACKAGE_idn2 is not set
# CONFIG_PACKAGE_inadyn is not set
# CONFIG_PACKAGE_isc-dhcp-client-ipv4 is not set
# CONFIG_PACKAGE_isc-dhcp-client-ipv6 is not set
# CONFIG_PACKAGE_isc-dhcp-omshell-ipv4 is not set
# CONFIG_PACKAGE_isc-dhcp-omshell-ipv6 is not set
# CONFIG_PACKAGE_isc-dhcp-relay-ipv4 is not set
# CONFIG_PACKAGE_isc-dhcp-relay-ipv6 is not set
# CONFIG_PACKAGE_isc-dhcp-server-ipv4 is not set
# CONFIG_PACKAGE_isc-dhcp-server-ipv6 is not set
# CONFIG_PACKAGE_kadnode is not set
# CONFIG_PACKAGE_kea-admin is not set
# CONFIG_PACKAGE_kea-ctrl is not set
# CONFIG_PACKAGE_kea-dhcp-ddns is not set
# CONFIG_PACKAGE_kea-dhcp4 is not set
# CONFIG_PACKAGE_kea-dhcp6 is not set
# CONFIG_PACKAGE_kea-lfc is not set
# CONFIG_PACKAGE_kea-libs is not set
# CONFIG_PACKAGE_kea-perfdhcp is not set
# CONFIG_PACKAGE_kea-shell is not set
# CONFIG_PACKAGE_knot is not set
# CONFIG_PACKAGE_knot-dig is not set
# CONFIG_PACKAGE_knot-host is not set
# CONFIG_PACKAGE_knot-keymgr is not set
# CONFIG_PACKAGE_knot-nsupdate is not set
# CONFIG_PACKAGE_knot-resolver is not set
#
# Configuration
#
# CONFIG_PACKAGE_knot-resolver_dnstap is not set
# end of Configuration
# CONFIG_PACKAGE_knot-tests is not set
# CONFIG_PACKAGE_knot-zonecheck is not set
# CONFIG_PACKAGE_ldns-examples is not set
# CONFIG_PACKAGE_mdns-utils is not set
# CONFIG_PACKAGE_mdnsd is not set
# CONFIG_PACKAGE_mdnsresponder is not set
# CONFIG_PACKAGE_nsd is not set
# CONFIG_PACKAGE_nsd-control is not set
# CONFIG_PACKAGE_nsd-control-setup is not set
# CONFIG_PACKAGE_nsd-nossl is not set
# CONFIG_PACKAGE_ohybridproxy is not set
# CONFIG_PACKAGE_overture is not set
# CONFIG_PACKAGE_pdns is not set
# CONFIG_PACKAGE_pdns-ixfrdist is not set
# CONFIG_PACKAGE_pdns-recursor is not set
# CONFIG_PACKAGE_pdns-tools is not set
# CONFIG_PACKAGE_stubby is not set
# CONFIG_PACKAGE_tor-hs is not set
# CONFIG_PACKAGE_torsocks is not set
# CONFIG_PACKAGE_unbound-anchor is not set
# CONFIG_PACKAGE_unbound-checkconf is not set
# CONFIG_PACKAGE_unbound-control is not set
# CONFIG_PACKAGE_unbound-control-setup is not set
# CONFIG_PACKAGE_unbound-daemon is not set
# CONFIG_PACKAGE_unbound-host is not set
# CONFIG_PACKAGE_wsdd2 is not set
# CONFIG_PACKAGE_zonestitcher is not set
# end of IP Addresses and Names
#
# Instant Messaging
#
# CONFIG_PACKAGE_bitlbee is not set
# CONFIG_PACKAGE_irssi is not set
# CONFIG_PACKAGE_ngircd is not set
# CONFIG_PACKAGE_ngircd-nossl is not set
# CONFIG_PACKAGE_prosody is not set
# CONFIG_PACKAGE_quassel-irssi is not set
# CONFIG_PACKAGE_umurmur-mbedtls is not set
# CONFIG_PACKAGE_umurmur-openssl is not set
# CONFIG_PACKAGE_znc is not set
# end of Instant Messaging
#
# Linux ATM tools
#
# CONFIG_PACKAGE_atm-aread is not set
# CONFIG_PACKAGE_atm-atmaddr is not set
# CONFIG_PACKAGE_atm-atmdiag is not set
# CONFIG_PACKAGE_atm-atmdump is not set
# CONFIG_PACKAGE_atm-atmloop is not set
# CONFIG_PACKAGE_atm-atmsigd is not set
# CONFIG_PACKAGE_atm-atmswitch is not set
# CONFIG_PACKAGE_atm-atmtcp is not set
# CONFIG_PACKAGE_atm-awrite is not set
# CONFIG_PACKAGE_atm-bus is not set
# CONFIG_PACKAGE_atm-debug-tools is not set
# CONFIG_PACKAGE_atm-diagnostics is not set
# CONFIG_PACKAGE_atm-esi is not set
# CONFIG_PACKAGE_atm-ilmid is not set
# CONFIG_PACKAGE_atm-ilmidiag is not set
# CONFIG_PACKAGE_atm-lecs is not set
# CONFIG_PACKAGE_atm-les is not set
# CONFIG_PACKAGE_atm-mpcd is not set
# CONFIG_PACKAGE_atm-saaldump is not set
# CONFIG_PACKAGE_atm-sonetdiag is not set
# CONFIG_PACKAGE_atm-svc_recv is not set
# CONFIG_PACKAGE_atm-svc_send is not set
# CONFIG_PACKAGE_atm-tools is not set
# CONFIG_PACKAGE_atm-ttcp_atm is not set
# CONFIG_PACKAGE_atm-zeppelin is not set
# CONFIG_PACKAGE_br2684ctl is not set
# end of Linux ATM tools
#
# LoRaWAN
#
# CONFIG_PACKAGE_libloragw-tests is not set
# CONFIG_PACKAGE_libloragw-utils is not set
# end of LoRaWAN
#
# NMAP Suite
#
# CONFIG_PACKAGE_ncat is not set
# CONFIG_PACKAGE_ncat-full is not set
# CONFIG_PACKAGE_ncat-ssl is not set
# CONFIG_PACKAGE_ndiff is not set
# CONFIG_PACKAGE_nmap is not set
# CONFIG_PACKAGE_nmap-full is not set
# CONFIG_PACKAGE_nmap-ssl is not set
# CONFIG_PACKAGE_nping is not set
# CONFIG_PACKAGE_nping-ssl is not set
# end of NMAP Suite
#
# NTRIP
#
# CONFIG_PACKAGE_ntripcaster is not set
# CONFIG_PACKAGE_ntripclient is not set
# CONFIG_PACKAGE_ntripserver is not set
# end of NTRIP
#
# OLSR.org network framework
#
# CONFIG_PACKAGE_oonf-dlep-proxy is not set
# CONFIG_PACKAGE_oonf-dlep-radio is not set
# CONFIG_PACKAGE_oonf-init-scripts is not set
# CONFIG_PACKAGE_oonf-olsrd2 is not set
# end of OLSR.org network framework
#
# Open vSwitch
#
# CONFIG_PACKAGE_openvswitch is not set
# CONFIG_PACKAGE_openvswitch-ovn-host is not set
# CONFIG_PACKAGE_openvswitch-ovn-north is not set
# CONFIG_PACKAGE_openvswitch-python3 is not set
# CONFIG_PACKAGE_ovsd is not set
# end of Open vSwitch
#
# OpenLDAP
#
# CONFIG_PACKAGE_libopenldap is not set
CONFIG_OPENLDAP_DEBUG=y
# CONFIG_OPENLDAP_CRYPT is not set
# CONFIG_OPENLDAP_MONITOR is not set
# CONFIG_OPENLDAP_DB47 is not set
# CONFIG_OPENLDAP_ICU is not set
# CONFIG_PACKAGE_openldap-server is not set
# CONFIG_PACKAGE_openldap-utils is not set
# end of OpenLDAP
#
# P2P
#
# CONFIG_PACKAGE_amule is not set
# CONFIG_AMULE_CRYPTOPP_STATIC_LINKING is not set
# CONFIG_PACKAGE_antileech is not set
# end of P2P
#
# Printing
#
# CONFIG_PACKAGE_p910nd is not set
# end of Printing
#
# Project V
#
# CONFIG_PACKAGE_v2ray-plugin is not set
# CONFIG_v2ray-plugin_INCLUDE_GOPROXY is not set
# end of Project V
#
# Routing and Redirection
#
# CONFIG_PACKAGE_babel-pinger is not set
# CONFIG_PACKAGE_babeld is not set
# CONFIG_PACKAGE_batmand is not set
# CONFIG_PACKAGE_bcp38 is not set
# CONFIG_PACKAGE_bfdd is not set
# CONFIG_PACKAGE_bird1-ipv4 is not set
# CONFIG_PACKAGE_bird1-ipv4-uci is not set
# CONFIG_PACKAGE_bird1-ipv6 is not set
# CONFIG_PACKAGE_bird1-ipv6-uci is not set
# CONFIG_PACKAGE_bird1c-ipv4 is not set
# CONFIG_PACKAGE_bird1c-ipv6 is not set
# CONFIG_PACKAGE_bird1cl-ipv4 is not set
# CONFIG_PACKAGE_bird1cl-ipv6 is not set
# CONFIG_PACKAGE_bird2 is not set
# CONFIG_PACKAGE_bird2c is not set
# CONFIG_PACKAGE_bird2cl is not set
# CONFIG_PACKAGE_bmx6 is not set
# CONFIG_PACKAGE_bmx7 is not set
# CONFIG_PACKAGE_cjdns is not set
# CONFIG_PACKAGE_cjdns-tests is not set
# CONFIG_PACKAGE_dcstad is not set
# CONFIG_PACKAGE_dcwapd is not set
# CONFIG_PACKAGE_devlink is not set
# CONFIG_PACKAGE_frr is not set
# CONFIG_PACKAGE_genl is not set
# CONFIG_PACKAGE_igmpproxy is not set
# CONFIG_PACKAGE_ip-bridge is not set
CONFIG_PACKAGE_ip-full=y
# CONFIG_PACKAGE_ip-tiny is not set
# CONFIG_PACKAGE_lldpd is not set
# CONFIG_PACKAGE_mcproxy is not set
# CONFIG_PACKAGE_mrmctl is not set
# CONFIG_PACKAGE_mwan3 is not set
# CONFIG_PACKAGE_nstat is not set
# CONFIG_PACKAGE_olsrd is not set
# CONFIG_PACKAGE_prince is not set
# CONFIG_PACKAGE_quagga is not set
# CONFIG_PACKAGE_rdma is not set
# CONFIG_PACKAGE_relayd is not set
# CONFIG_PACKAGE_smcroute is not set
# CONFIG_PACKAGE_ss is not set
# CONFIG_PACKAGE_sslh is not set
# CONFIG_PACKAGE_tc-full is not set
# CONFIG_PACKAGE_tc-mod-iptables is not set
# CONFIG_PACKAGE_tc-tiny is not set
# CONFIG_PACKAGE_tcpproxy is not set
# CONFIG_PACKAGE_udp-broadcast-relay-redux is not set
# CONFIG_PACKAGE_vis is not set
# CONFIG_PACKAGE_yggdrasil is not set
# end of Routing and Redirection
#
# SSH
#
# CONFIG_PACKAGE_autossh is not set
# CONFIG_PACKAGE_openssh-client is not set
# CONFIG_PACKAGE_openssh-client-utils is not set
# CONFIG_PACKAGE_openssh-keygen is not set
# CONFIG_PACKAGE_openssh-moduli is not set
# CONFIG_PACKAGE_openssh-server is not set
# CONFIG_PACKAGE_openssh-server-pam is not set
# CONFIG_PACKAGE_openssh-sftp-avahi-service is not set
# CONFIG_PACKAGE_openssh-sftp-client is not set
# CONFIG_PACKAGE_openssh-sftp-server is not set
# CONFIG_PACKAGE_sshtunnel is not set
# CONFIG_PACKAGE_tmate is not set
# end of SSH
#
# THC-IPv6 attack and analyzing toolkit
#
# CONFIG_PACKAGE_thc-ipv6-address6 is not set
# CONFIG_PACKAGE_thc-ipv6-alive6 is not set
# CONFIG_PACKAGE_thc-ipv6-covert-send6 is not set
# CONFIG_PACKAGE_thc-ipv6-covert-send6d is not set
# CONFIG_PACKAGE_thc-ipv6-denial6 is not set
# CONFIG_PACKAGE_thc-ipv6-detect-new-ip6 is not set
# CONFIG_PACKAGE_thc-ipv6-detect-sniffer6 is not set
# CONFIG_PACKAGE_thc-ipv6-dnsdict6 is not set
# CONFIG_PACKAGE_thc-ipv6-dnsrevenum6 is not set
# CONFIG_PACKAGE_thc-ipv6-dos-new-ip6 is not set
# CONFIG_PACKAGE_thc-ipv6-dump-router6 is not set
# CONFIG_PACKAGE_thc-ipv6-exploit6 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-advertise6 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-dhcps6 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-dns6d is not set
# CONFIG_PACKAGE_thc-ipv6-fake-dnsupdate6 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-mipv6 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-mld26 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-mld6 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-mldrouter6 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-router26 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-router6 is not set
# CONFIG_PACKAGE_thc-ipv6-fake-solicitate6 is not set
# CONFIG_PACKAGE_thc-ipv6-flood-advertise6 is not set
# CONFIG_PACKAGE_thc-ipv6-flood-dhcpc6 is not set
# CONFIG_PACKAGE_thc-ipv6-flood-mld26 is not set
# CONFIG_PACKAGE_thc-ipv6-flood-mld6 is not set
# CONFIG_PACKAGE_thc-ipv6-flood-mldrouter6 is not set
# CONFIG_PACKAGE_thc-ipv6-flood-router26 is not set
# CONFIG_PACKAGE_thc-ipv6-flood-router6 is not set
# CONFIG_PACKAGE_thc-ipv6-flood-solicitate6 is not set
# CONFIG_PACKAGE_thc-ipv6-fragmentation6 is not set
# CONFIG_PACKAGE_thc-ipv6-fuzz-dhcpc6 is not set
# CONFIG_PACKAGE_thc-ipv6-fuzz-dhcps6 is not set
# CONFIG_PACKAGE_thc-ipv6-fuzz-ip6 is not set
# CONFIG_PACKAGE_thc-ipv6-implementation6 is not set
# CONFIG_PACKAGE_thc-ipv6-implementation6d is not set
# CONFIG_PACKAGE_thc-ipv6-inverse-lookup6 is not set
# CONFIG_PACKAGE_thc-ipv6-kill-router6 is not set
# CONFIG_PACKAGE_thc-ipv6-ndpexhaust6 is not set
# CONFIG_PACKAGE_thc-ipv6-node-query6 is not set
# CONFIG_PACKAGE_thc-ipv6-parasite6 is not set
# CONFIG_PACKAGE_thc-ipv6-passive-discovery6 is not set
# CONFIG_PACKAGE_thc-ipv6-randicmp6 is not set
# CONFIG_PACKAGE_thc-ipv6-redir6 is not set
# CONFIG_PACKAGE_thc-ipv6-rsmurf6 is not set
# CONFIG_PACKAGE_thc-ipv6-sendpees6 is not set
# CONFIG_PACKAGE_thc-ipv6-sendpeesmp6 is not set
# CONFIG_PACKAGE_thc-ipv6-smurf6 is not set
# CONFIG_PACKAGE_thc-ipv6-thcping6 is not set
# CONFIG_PACKAGE_thc-ipv6-toobig6 is not set
# CONFIG_PACKAGE_thc-ipv6-trace6 is not set
# end of THC-IPv6 attack and analyzing toolkit
#
# Tcpreplay
#
# CONFIG_PACKAGE_tcpbridge is not set
# CONFIG_PACKAGE_tcpcapinfo is not set
# CONFIG_PACKAGE_tcpliveplay is not set
# CONFIG_PACKAGE_tcpprep is not set
# CONFIG_PACKAGE_tcpreplay is not set
# CONFIG_PACKAGE_tcpreplay-all is not set
# CONFIG_PACKAGE_tcpreplay-edit is not set
# CONFIG_PACKAGE_tcprewrite is not set
# end of Tcpreplay
#
# Telephony
#
# CONFIG_PACKAGE_asterisk is not set
# CONFIG_PACKAGE_baresip is not set
# CONFIG_PACKAGE_freeswitch is not set
# CONFIG_PACKAGE_kamailio is not set
# CONFIG_PACKAGE_miax is not set
# CONFIG_PACKAGE_pcapsipdump is not set
# CONFIG_PACKAGE_restund is not set
# CONFIG_PACKAGE_rtpengine is not set
# CONFIG_PACKAGE_rtpengine-no-transcode is not set
# CONFIG_PACKAGE_rtpengine-recording is not set
# CONFIG_PACKAGE_rtpproxy is not set
# CONFIG_PACKAGE_sipp is not set
# CONFIG_PACKAGE_siproxd is not set
# CONFIG_PACKAGE_yate is not set
# end of Telephony
#
# Telephony Lantiq
#
# end of Telephony Lantiq
#
# Time Synchronization
#
# CONFIG_PACKAGE_chrony is not set
# CONFIG_PACKAGE_chrony-nts is not set
# CONFIG_PACKAGE_htpdate is not set
# CONFIG_PACKAGE_linuxptp is not set
# CONFIG_PACKAGE_ntp-keygen is not set
# CONFIG_PACKAGE_ntp-utils is not set
# CONFIG_PACKAGE_ntpclient is not set
# CONFIG_PACKAGE_ntpd is not set
# CONFIG_PACKAGE_ntpdate is not set
# end of Time Synchronization
#
# VPN
#
# CONFIG_PACKAGE_chaosvpn is not set
# CONFIG_PACKAGE_eoip is not set
# CONFIG_PACKAGE_fastd is not set
# CONFIG_PACKAGE_libreswan is not set
# CONFIG_PACKAGE_n2n-edge is not set
# CONFIG_PACKAGE_n2n-supernode is not set
# CONFIG_PACKAGE_ocserv is not set
# CONFIG_PACKAGE_openconnect is not set
# CONFIG_PACKAGE_openfortivpn is not set
# CONFIG_PACKAGE_openvpn-easy-rsa is not set
# CONFIG_PACKAGE_openvpn-mbedtls is not set
# CONFIG_PACKAGE_openvpn-openssl is not set
# CONFIG_PACKAGE_openvpn-wolfssl is not set
# CONFIG_PACKAGE_pptpd is not set
# CONFIG_PACKAGE_softethervpn-base is not set
# CONFIG_PACKAGE_softethervpn-bridge is not set
# CONFIG_PACKAGE_softethervpn-client is not set
# CONFIG_PACKAGE_softethervpn-server is not set
# CONFIG_PACKAGE_softethervpn5-bridge is not set
# CONFIG_PACKAGE_softethervpn5-client is not set
# CONFIG_PACKAGE_softethervpn5-server is not set
# CONFIG_PACKAGE_sstp-client is not set
# CONFIG_PACKAGE_strongswan is not set
# CONFIG_PACKAGE_tailscale is not set
# CONFIG_PACKAGE_tailscaled is not set
# CONFIG_PACKAGE_tinc is not set
# CONFIG_PACKAGE_uanytun is not set
# CONFIG_PACKAGE_uanytun-nettle is not set
# CONFIG_PACKAGE_uanytun-nocrypt is not set
# CONFIG_PACKAGE_uanytun-sslcrypt is not set
# CONFIG_PACKAGE_vpnc is not set
# CONFIG_PACKAGE_vpnc-scripts is not set
# CONFIG_PACKAGE_wireguard-tools is not set
# CONFIG_PACKAGE_xl2tpd is not set
CONFIG_PACKAGE_zerotier=y
#
# Configuration
#
# CONFIG_ZEROTIER_ENABLE_DEBUG is not set
# CONFIG_ZEROTIER_ENABLE_SELFTEST is not set
# end of Configuration
# end of VPN
#
# Version Control Systems
#
# CONFIG_PACKAGE_git is not set
# CONFIG_PACKAGE_git-http is not set
# CONFIG_PACKAGE_subversion-client is not set
# CONFIG_PACKAGE_subversion-libs is not set
# CONFIG_PACKAGE_subversion-server is not set
# end of Version Control Systems
#
# WWAN
#
# CONFIG_PACKAGE_adb-enablemodem is not set
# CONFIG_PACKAGE_comgt is not set
# CONFIG_PACKAGE_comgt-directip is not set
# CONFIG_PACKAGE_comgt-ncm is not set
# CONFIG_PACKAGE_umbim is not set
# CONFIG_PACKAGE_uqmi is not set
# end of WWAN
#
# Web Servers/Proxies
#
# CONFIG_PACKAGE_apache is not set
# CONFIG_PACKAGE_brook is not set
# CONFIG_BROOK_COMPRESS_GOPROXY is not set
CONFIG_BROOK_COMPRESS_UPX=y
# CONFIG_PACKAGE_cgi-io is not set
# CONFIG_PACKAGE_clamav is not set
# CONFIG_PACKAGE_e2guardian is not set
# CONFIG_PACKAGE_etebase is not set
# CONFIG_PACKAGE_freshclam is not set
# CONFIG_PACKAGE_frpc is not set
# CONFIG_PACKAGE_frps is not set
# CONFIG_PACKAGE_gateway-go is not set
# CONFIG_PACKAGE_gunicorn3 is not set
# CONFIG_PACKAGE_haproxy is not set
# CONFIG_PACKAGE_haproxy-nossl is not set
# CONFIG_PACKAGE_hysteria is not set
# CONFIG_PACKAGE_kcptun-client is not set
# CONFIG_PACKAGE_kcptun-config is not set
# CONFIG_PACKAGE_kcptun-server is not set
# CONFIG_PACKAGE_lighttpd is not set
CONFIG_PACKAGE_microsocks=y
# CONFIG_PACKAGE_naiveproxy is not set
# CONFIG_PACKAGE_nginx-all-module is not set
# CONFIG_PACKAGE_nginx-mod-luci is not set
# CONFIG_PACKAGE_nginx-ssl is not set
# CONFIG_PACKAGE_nginx-ssl-util is not set
# CONFIG_PACKAGE_nginx-ssl-util-nopcre is not set
CONFIG_PACKAGE_pdnsd-alt=y
# CONFIG_PACKAGE_polipo is not set
# CONFIG_PACKAGE_privoxy is not set
# CONFIG_PACKAGE_python3-gunicorn is not set
# CONFIG_PACKAGE_radicale is not set
# CONFIG_PACKAGE_radicale2 is not set
# CONFIG_PACKAGE_radicale2-examples is not set
# CONFIG_PACKAGE_redsocks2 is not set
# CONFIG_PACKAGE_shadowsocks-libev-config is not set
CONFIG_PACKAGE_shadowsocks-libev-ss-local=y
CONFIG_PACKAGE_shadowsocks-libev-ss-redir=y
# CONFIG_PACKAGE_shadowsocks-libev-ss-rules is not set
# CONFIG_PACKAGE_shadowsocks-libev-ss-server is not set
# CONFIG_PACKAGE_shadowsocks-libev-ss-tunnel is not set
# CONFIG_PACKAGE_shadowsocks-rust-sslocal is not set
# CONFIG_PACKAGE_shadowsocks-rust-ssmanager is not set
# CONFIG_PACKAGE_shadowsocks-rust-ssserver is not set
# CONFIG_PACKAGE_shadowsocks-rust-ssurl is not set
CONFIG_PACKAGE_shadowsocksr-libev-ssr-check=y
CONFIG_PACKAGE_shadowsocksr-libev-ssr-local=y
# CONFIG_PACKAGE_shadowsocksr-libev-ssr-nat is not set
CONFIG_PACKAGE_shadowsocksr-libev-ssr-redir=y
# CONFIG_PACKAGE_shadowsocksr-libev-ssr-server is not set
# CONFIG_PACKAGE_sockd is not set
# CONFIG_PACKAGE_socksify is not set
# CONFIG_PACKAGE_spawn-fcgi is not set
# CONFIG_PACKAGE_squid is not set
# CONFIG_PACKAGE_srelay is not set
# CONFIG_PACKAGE_tinyproxy is not set
# CONFIG_PACKAGE_trojan-go is not set
CONFIG_PACKAGE_uhttpd=y
# CONFIG_PACKAGE_uhttpd-mod-lua is not set
CONFIG_PACKAGE_uhttpd-mod-ubus=y
# CONFIG_PACKAGE_uwsgi is not set
# end of Web Servers/Proxies
#
# Wireless
#
# CONFIG_PACKAGE_aircrack-ng is not set
# CONFIG_PACKAGE_airmon-ng is not set
# CONFIG_PACKAGE_dynapoint is not set
# CONFIG_PACKAGE_hcxdumptool is not set
# CONFIG_PACKAGE_hcxtools is not set
# CONFIG_PACKAGE_horst is not set
# CONFIG_PACKAGE_mt_wifi is not set
# CONFIG_PACKAGE_pixiewps is not set
# CONFIG_PACKAGE_reaver is not set
# CONFIG_PACKAGE_wavemon is not set
# CONFIG_PACKAGE_wifischedule is not set
# end of Wireless
#
# WirelessAPD
#
# CONFIG_PACKAGE_eapol-test is not set
# CONFIG_PACKAGE_eapol-test-openssl is not set
# CONFIG_PACKAGE_eapol-test-wolfssl is not set
# CONFIG_PACKAGE_hostapd is not set
# CONFIG_PACKAGE_hostapd-basic is not set
# CONFIG_PACKAGE_hostapd-basic-openssl is not set
# CONFIG_PACKAGE_hostapd-basic-wolfssl is not set
# CONFIG_PACKAGE_hostapd-common is not set
# CONFIG_PACKAGE_hostapd-mini is not set
# CONFIG_PACKAGE_hostapd-openssl is not set
# CONFIG_PACKAGE_hostapd-wolfssl is not set
# CONFIG_PACKAGE_hs20-client is not set
# CONFIG_PACKAGE_hs20-common is not set
# CONFIG_PACKAGE_hs20-server is not set
# CONFIG_PACKAGE_wpa-supplicant is not set
# CONFIG_WPA_WOLFSSL is not set
# CONFIG_DRIVER_WEXT_SUPPORT is not set
CONFIG_DRIVER_11N_SUPPORT=y
CONFIG_DRIVER_11AC_SUPPORT=y
# CONFIG_DRIVER_11AX_SUPPORT is not set
# CONFIG_WPA_ENABLE_WEP is not set
# CONFIG_PACKAGE_wpa-supplicant-basic is not set
# CONFIG_PACKAGE_wpa-supplicant-mini is not set
# CONFIG_PACKAGE_wpa-supplicant-openssl is not set
# CONFIG_PACKAGE_wpa-supplicant-wolfssl is not set
# CONFIG_PACKAGE_wpad is not set
# CONFIG_PACKAGE_wpad-basic is not set
# CONFIG_PACKAGE_wpad-basic-openssl is not set
# CONFIG_PACKAGE_wpad-basic-wolfssl is not set
# CONFIG_PACKAGE_wpad-mini is not set
# CONFIG_PACKAGE_wpad-openssl is not set
# CONFIG_PACKAGE_wpad-wolfssl is not set
# end of WirelessAPD
#
# arp-scan
#
# CONFIG_PACKAGE_arp-scan is not set
# CONFIG_PACKAGE_arp-scan-database is not set
# end of arp-scan
# CONFIG_PACKAGE_464xlat is not set
# CONFIG_PACKAGE_6in4 is not set
# CONFIG_PACKAGE_6rd is not set
# CONFIG_PACKAGE_6to4 is not set
# CONFIG_PACKAGE_UDPspeeder is not set
# CONFIG_PACKAGE_acme is not set
# CONFIG_PACKAGE_acme-dnsapi is not set
# CONFIG_PACKAGE_adblock is not set
CONFIG_PACKAGE_adbyby=y
# CONFIG_PACKAGE_addrwatch is not set
# CONFIG_PACKAGE_adguardhome is not set
# CONFIG_PACKAGE_ahcpd is not set
# CONFIG_PACKAGE_alfred is not set
# CONFIG_PACKAGE_apcupsd is not set
# CONFIG_PACKAGE_apcupsd-cgi is not set
# CONFIG_PACKAGE_apinger is not set
# CONFIG_PACKAGE_atlas-probe is not set
# CONFIG_PACKAGE_atlas-sw-probe is not set
# CONFIG_PACKAGE_atlas-sw-probe-rpc is not set
# CONFIG_PACKAGE_baidupcs-web is not set
# CONFIG_BAIDUPCS_WEB_COMPRESS_GOPROXY is not set
CONFIG_BAIDUPCS_WEB_COMPRESS_UPX=y
# CONFIG_PACKAGE_banip is not set
# CONFIG_PACKAGE_batctl-default is not set
# CONFIG_PACKAGE_batctl-full is not set
# CONFIG_PACKAGE_batctl-tiny is not set
# CONFIG_PACKAGE_beanstalkd is not set
# CONFIG_PACKAGE_bmon is not set
# CONFIG_PACKAGE_boinc is not set
# CONFIG_PACKAGE_bpftool-full is not set
# CONFIG_PACKAGE_bpftool-minimal is not set
# CONFIG_PACKAGE_bwm-ng is not set
# CONFIG_PACKAGE_bwping is not set
# CONFIG_PACKAGE_chat is not set
CONFIG_PACKAGE_chinadns-ng=y
# CONFIG_PACKAGE_cifsmount is not set
# CONFIG_PACKAGE_coap-server is not set
# CONFIG_PACKAGE_conserver is not set
# CONFIG_PACKAGE_cshark is not set
# CONFIG_PACKAGE_daemonlogger is not set
# CONFIG_PACKAGE_darkstat is not set
# CONFIG_PACKAGE_dawn is not set
# CONFIG_PACKAGE_dhcpcd is not set
# CONFIG_PACKAGE_dmapd is not set
# CONFIG_PACKAGE_dnscrypt-proxy2 is not set
# CONFIG_PACKAGE_dnsforwarder is not set
# CONFIG_PACKAGE_dnstap is not set
# CONFIG_PACKAGE_dnstop is not set
# CONFIG_PACKAGE_ds-lite is not set
# CONFIG_PACKAGE_dsmboot is not set
# CONFIG_PACKAGE_esniper is not set
# CONFIG_PACKAGE_etherwake is not set
# CONFIG_PACKAGE_etherwake-nfqueue is not set
# CONFIG_PACKAGE_ethtool is not set
# CONFIG_PACKAGE_ethtool-full is not set
# CONFIG_PACKAGE_fakeidentd is not set
# CONFIG_PACKAGE_fakepop is not set
# CONFIG_PACKAGE_family-dns is not set
# CONFIG_PACKAGE_foolsm is not set
# CONFIG_PACKAGE_fping is not set
# CONFIG_PACKAGE_generate-ipv6-address is not set
# CONFIG_PACKAGE_geth is not set
# CONFIG_PACKAGE_git-lfs is not set
# CONFIG_PACKAGE_gnunet is not set
# CONFIG_PACKAGE_gre is not set
# CONFIG_PACKAGE_hnet-full is not set
# CONFIG_PACKAGE_hnet-full-l2tp is not set
# CONFIG_PACKAGE_hnet-full-secure is not set
# CONFIG_PACKAGE_hnetd-nossl is not set
# CONFIG_PACKAGE_hnetd-openssl is not set
# CONFIG_PACKAGE_httping is not set
# CONFIG_PACKAGE_httping-nossl is not set
# CONFIG_PACKAGE_https-dns-proxy is not set
# CONFIG_PACKAGE_i2pd is not set
# CONFIG_PACKAGE_ibrdtn-tools is not set
# CONFIG_PACKAGE_ibrdtnd is not set
# CONFIG_PACKAGE_ifstat is not set
# CONFIG_PACKAGE_iftop is not set
# CONFIG_PACKAGE_iiod is not set
# CONFIG_PACKAGE_iperf is not set
# CONFIG_PACKAGE_iperf3 is not set
# CONFIG_PACKAGE_iperf3-ssl is not set
# CONFIG_PACKAGE_ipip is not set
CONFIG_PACKAGE_ipset=y
# CONFIG_PACKAGE_ipset-dns is not set
CONFIG_PACKAGE_ipt2socks=y
# CONFIG_PACKAGE_iptraf-ng is not set
# CONFIG_PACKAGE_iputils-arping is not set
# CONFIG_PACKAGE_iputils-clockdiff is not set
# CONFIG_PACKAGE_iputils-ping is not set
# CONFIG_PACKAGE_iputils-tftpd is not set
# CONFIG_PACKAGE_iputils-tracepath is not set
# CONFIG_PACKAGE_ipvsadm is not set
# CONFIG_PACKAGE_irtt is not set
# CONFIG_PACKAGE_iw is not set
# CONFIG_PACKAGE_iw-full is not set
# CONFIG_PACKAGE_jool-tools is not set
# CONFIG_PACKAGE_keepalived is not set
# CONFIG_PACKAGE_knxd is not set
# CONFIG_PACKAGE_kplex is not set
# CONFIG_PACKAGE_krb5-client is not set
# CONFIG_PACKAGE_krb5-libs is not set
# CONFIG_PACKAGE_krb5-server is not set
# CONFIG_PACKAGE_krb5-server-extras is not set
CONFIG_PACKAGE_libipset=y
# CONFIG_PACKAGE_libndp is not set
# CONFIG_PACKAGE_linknx is not set
# CONFIG_PACKAGE_lynx is not set
# CONFIG_PACKAGE_mac-telnet-client is not set
# CONFIG_PACKAGE_mac-telnet-discover is not set
# CONFIG_PACKAGE_mac-telnet-ping is not set
# CONFIG_PACKAGE_mac-telnet-server is not set
# CONFIG_PACKAGE_map is not set
# CONFIG_PACKAGE_mbusd is not set
# CONFIG_PACKAGE_memcached is not set
# CONFIG_PACKAGE_mentohust is not set
# CONFIG_PACKAGE_mii-tool is not set
# CONFIG_PACKAGE_mikrotik-btest is not set
# CONFIG_PACKAGE_mini_snmpd is not set
# CONFIG_PACKAGE_minimalist-pcproxy is not set
# CONFIG_PACKAGE_miredo is not set
# CONFIG_PACKAGE_modemmanager is not set
# CONFIG_PACKAGE_mosquitto-client-nossl is not set
# CONFIG_PACKAGE_mosquitto-client-ssl is not set
# CONFIG_PACKAGE_mosquitto-nossl is not set
# CONFIG_PACKAGE_mosquitto-ssl is not set
# CONFIG_PACKAGE_mrd6 is not set
# CONFIG_PACKAGE_mstpd is not set
# CONFIG_PACKAGE_mtk_apcli is not set
# CONFIG_PACKAGE_mtr is not set
# CONFIG_PACKAGE_nbd is not set
# CONFIG_PACKAGE_nbd-server is not set
# CONFIG_PACKAGE_ncp is not set
# CONFIG_PACKAGE_ndppd is not set
# CONFIG_PACKAGE_ndptool is not set
# CONFIG_PACKAGE_nebula is not set
# CONFIG_PACKAGE_nebula-cert is not set
# CONFIG_PACKAGE_net-tools-route is not set
# CONFIG_PACKAGE_netcat is not set
# CONFIG_PACKAGE_netdiscover is not set
# CONFIG_PACKAGE_netifyd is not set
# CONFIG_PACKAGE_netperf is not set
# CONFIG_PACKAGE_netsniff-ng is not set
# CONFIG_PACKAGE_netstinky is not set
# CONFIG_PACKAGE_nextdns is not set
# CONFIG_PACKAGE_nfdump is not set
# CONFIG_PACKAGE_nlbwmon is not set
# CONFIG_PACKAGE_noddos is not set
# CONFIG_PACKAGE_noping is not set
# CONFIG_PACKAGE_npc is not set
# CONFIG_PACKAGE_nut is not set
# CONFIG_PACKAGE_obfs4proxy is not set
# CONFIG_PACKAGE_odhcp6c is not set
# CONFIG_PACKAGE_odhcpd is not set
# CONFIG_PACKAGE_odhcpd-ipv6only is not set
# CONFIG_PACKAGE_ola is not set
# CONFIG_PACKAGE_omcproxy is not set
# CONFIG_PACKAGE_onionshare-cli is not set
# CONFIG_PACKAGE_ooniprobe is not set
# CONFIG_PACKAGE_oor is not set
# CONFIG_PACKAGE_open-iscsi is not set
# CONFIG_PACKAGE_oping is not set
# CONFIG_PACKAGE_ostiary is not set
# CONFIG_PACKAGE_pagekitec is not set
# CONFIG_PACKAGE_pen is not set
# CONFIG_PACKAGE_phantap is not set
# CONFIG_PACKAGE_pimbd is not set
# CONFIG_PACKAGE_pingcheck is not set
# CONFIG_PACKAGE_port-mirroring is not set
CONFIG_PACKAGE_ppp=y
# CONFIG_PACKAGE_ppp-mod-passwordfd is not set
# CONFIG_PACKAGE_ppp-mod-pppoa is not set
CONFIG_PACKAGE_ppp-mod-pppoe=y
# CONFIG_PACKAGE_ppp-mod-pppol2tp is not set
# CONFIG_PACKAGE_ppp-mod-pptp is not set
# CONFIG_PACKAGE_ppp-mod-radius is not set
# CONFIG_PACKAGE_ppp-multilink is not set
# CONFIG_PACKAGE_pppdump is not set
# CONFIG_PACKAGE_pppoe-discovery is not set
# CONFIG_PACKAGE_pppossh is not set
# CONFIG_PACKAGE_pppstats is not set
# CONFIG_PACKAGE_proto-bonding is not set
# CONFIG_PACKAGE_proxychains-ng is not set
# CONFIG_PACKAGE_ptunnel-ng is not set
# CONFIG_PACKAGE_radsecproxy is not set
# CONFIG_PACKAGE_ratched is not set
# CONFIG_PACKAGE_ratechecker is not set
# CONFIG_PACKAGE_redsocks is not set
# CONFIG_PACKAGE_remserial is not set
# CONFIG_PACKAGE_restic-rest-server is not set
# CONFIG_PACKAGE_rpcapd is not set
# CONFIG_PACKAGE_rpcbind is not set
# CONFIG_PACKAGE_rssileds is not set
# CONFIG_PACKAGE_rsyslog is not set
# CONFIG_PACKAGE_safe-search is not set
# CONFIG_PACKAGE_samba36-client is not set
# CONFIG_PACKAGE_samba36-net is not set
CONFIG_PACKAGE_samba36-server=y
CONFIG_PACKAGE_SAMBA_MAX_DEBUG_LEVEL=-1
# CONFIG_PACKAGE_samba4-admin is not set
# CONFIG_PACKAGE_samba4-client is not set
# CONFIG_PACKAGE_samba4-libs is not set
# CONFIG_PACKAGE_samba4-server is not set
# CONFIG_PACKAGE_samba4-utils is not set
# CONFIG_PACKAGE_samplicator is not set
# CONFIG_PACKAGE_scapy is not set
# CONFIG_PACKAGE_sctp-tools is not set
# CONFIG_PACKAGE_seafile-ccnet is not set
# CONFIG_PACKAGE_seafile-seahub is not set
# CONFIG_PACKAGE_seafile-server is not set
# CONFIG_PACKAGE_seafile-server-fuse is not set
# CONFIG_PACKAGE_ser2net is not set
# CONFIG_PACKAGE_simple-adblock is not set
CONFIG_PACKAGE_simple-obfs=y
# CONFIG_PACKAGE_simple-obfs-server is not set
#
# Simple-obfs Compile Configuration
#
# CONFIG_SIMPLE_OBFS_STATIC_LINK is not set
# end of Simple-obfs Compile Configuration
# CONFIG_PACKAGE_smartdns is not set
# CONFIG_PACKAGE_smbinfo is not set
# CONFIG_PACKAGE_snmp-mibs is not set
# CONFIG_PACKAGE_snmp-utils is not set
# CONFIG_PACKAGE_snmpd is not set
# CONFIG_PACKAGE_snmptrapd is not set
# CONFIG_PACKAGE_socat is not set
# CONFIG_PACKAGE_softflowd is not set
# CONFIG_PACKAGE_soloscli is not set
# CONFIG_PACKAGE_speedtest-netperf is not set
# CONFIG_PACKAGE_spoofer is not set
# CONFIG_PACKAGE_ssocks is not set
# CONFIG_PACKAGE_ssocksd is not set
# CONFIG_PACKAGE_static-neighbor-reports is not set
# CONFIG_PACKAGE_stunnel is not set
# CONFIG_PACKAGE_switchdev-poller is not set
# CONFIG_PACKAGE_tac_plus is not set
# CONFIG_PACKAGE_tac_plus-pam is not set
# CONFIG_PACKAGE_tayga is not set
# CONFIG_PACKAGE_tcpdump is not set
# CONFIG_PACKAGE_tcpdump-mini is not set
CONFIG_PACKAGE_tcping=y
# CONFIG_PACKAGE_tcpping is not set
# CONFIG_PACKAGE_tgt is not set
# CONFIG_PACKAGE_tmate-ssh-server is not set
# CONFIG_PACKAGE_tor is not set
# CONFIG_PACKAGE_tor-basic is not set
# CONFIG_PACKAGE_tor-fw-helper is not set
# CONFIG_PACKAGE_trafficshaper is not set
# CONFIG_PACKAGE_travelmate is not set
# CONFIG_PACKAGE_trojan is not set
CONFIG_PACKAGE_trojan-plus=y
# CONFIG_PACKAGE_u2pnpd is not set
# CONFIG_PACKAGE_uacme is not set
CONFIG_PACKAGE_uclient-fetch=y
# CONFIG_PACKAGE_udptunnel is not set
# CONFIG_PACKAGE_udpxy is not set
# CONFIG_PACKAGE_ulogd is not set
# CONFIG_PACKAGE_umdns is not set
# CONFIG_PACKAGE_usbip is not set
# CONFIG_PACKAGE_uugamebooster is not set
# CONFIG_PACKAGE_v2ray-core is not set
# CONFIG_PACKAGE_vallumd is not set
# CONFIG_PACKAGE_verysync is not set
CONFIG_PACKAGE_vlmcsd=y
# CONFIG_PACKAGE_vncrepeater is not set
# CONFIG_PACKAGE_vnstat is not set
# CONFIG_PACKAGE_vnstat2 is not set
# CONFIG_PACKAGE_vpn-policy-routing is not set
# CONFIG_PACKAGE_vpnbypass is not set
# CONFIG_PACKAGE_vti is not set
# CONFIG_PACKAGE_vxlan is not set
# CONFIG_PACKAGE_wakeonlan is not set
# CONFIG_PACKAGE_wg-installer-client is not set
# CONFIG_PACKAGE_wg-installer-server is not set
# CONFIG_PACKAGE_wol is not set
# CONFIG_PACKAGE_wpan-tools is not set
# CONFIG_PACKAGE_wwan is not set
# CONFIG_PACKAGE_xinetd is not set
CONFIG_PACKAGE_xray-core=y
#
# Xray-core Configuration
#
# CONFIG_XRAY_CORE_COMPRESS_GOPROXY is not set
CONFIG_XRAY_CORE_COMPRESS_UPX=y
# end of Xray-core Configuration
# CONFIG_PACKAGE_xray-example is not set
# CONFIG_PACKAGE_xray-geodata is not set
# CONFIG_PACKAGE_xray-plugin is not set
# CONFIG_XRAY_PLUGIN_PROVIDE_V2RAY_PLUGIN is not set
# CONFIG_XRAY_PLUGIN_COMPRESS_GOPROXY is not set
CONFIG_XRAY_PLUGIN_COMPRESS_UPX=y
# end of Network
#
# Sound
#
# CONFIG_PACKAGE_alsa-utils is not set
# CONFIG_PACKAGE_alsa-utils-seq is not set
# CONFIG_PACKAGE_alsa-utils-tests is not set
# CONFIG_PACKAGE_aserver is not set
# CONFIG_PACKAGE_espeak is not set
# CONFIG_PACKAGE_faad2 is not set
# CONFIG_PACKAGE_fdk-aac is not set
# CONFIG_PACKAGE_forked-daapd is not set
# CONFIG_PACKAGE_ices is not set
# CONFIG_PACKAGE_lame is not set
# CONFIG_PACKAGE_lame-lib is not set
# CONFIG_PACKAGE_liblo-utils is not set
# CONFIG_PACKAGE_madplay is not set
# CONFIG_PACKAGE_moc is not set
# CONFIG_PACKAGE_mpc is not set
# CONFIG_PACKAGE_mpd-avahi-service is not set
# CONFIG_PACKAGE_mpd-full is not set
# CONFIG_PACKAGE_mpd-mini is not set
# CONFIG_PACKAGE_mpg123 is not set
# CONFIG_PACKAGE_opus-tools is not set
# CONFIG_PACKAGE_pianod is not set
# CONFIG_PACKAGE_pianod-client is not set
# CONFIG_PACKAGE_portaudio is not set
# CONFIG_PACKAGE_pulseaudio-daemon is not set
# CONFIG_PACKAGE_pulseaudio-daemon-avahi is not set
# CONFIG_PACKAGE_shairplay is not set
# CONFIG_PACKAGE_shairport-sync-mbedtls is not set
# CONFIG_PACKAGE_shairport-sync-mini is not set
# CONFIG_PACKAGE_shairport-sync-openssl is not set
# CONFIG_PACKAGE_shine is not set
# CONFIG_PACKAGE_sox is not set
# CONFIG_PACKAGE_squeezelite-full is not set
# CONFIG_PACKAGE_squeezelite-mini is not set
# CONFIG_PACKAGE_svox is not set
# CONFIG_PACKAGE_upmpdcli is not set
# end of Sound
#
# Utilities
#
#
# AppArmor
#
# CONFIG_PACKAGE_apparmor-profiles is not set
# CONFIG_PACKAGE_apparmor-utils is not set
# end of AppArmor
#
# BigClown
#
# CONFIG_PACKAGE_bigclown-control-tool is not set
# CONFIG_PACKAGE_bigclown-firmware-tool is not set
# CONFIG_PACKAGE_bigclown-gateway is not set
# CONFIG_PACKAGE_bigclown-mqtt2influxdb is not set
# end of BigClown
#
# Boot Loaders
#
# CONFIG_PACKAGE_fconfig is not set
# CONFIG_PACKAGE_uboot-envtools is not set
# end of Boot Loaders
#
# Compression
#
# CONFIG_PACKAGE_bsdtar is not set
# CONFIG_PACKAGE_bsdtar-noopenssl is not set
# CONFIG_PACKAGE_bzip2 is not set
# CONFIG_PACKAGE_gzip is not set
# CONFIG_PACKAGE_lz4 is not set
# CONFIG_PACKAGE_pigz is not set
# CONFIG_PACKAGE_unrar is not set
CONFIG_PACKAGE_unzip=y
# CONFIG_PACKAGE_xz-utils is not set
# CONFIG_PACKAGE_zipcmp is not set
# CONFIG_PACKAGE_zipmerge is not set
# CONFIG_PACKAGE_ziptool is not set
# CONFIG_PACKAGE_zstd is not set
# end of Compression
#
# Database
#
# CONFIG_PACKAGE_mariadb-common is not set
# CONFIG_PACKAGE_pgsql-cli is not set
# CONFIG_PACKAGE_pgsql-cli-extra is not set
# CONFIG_PACKAGE_pgsql-server is not set
# CONFIG_PACKAGE_rrdcgi1 is not set
# CONFIG_PACKAGE_rrdtool1 is not set
# CONFIG_PACKAGE_sqlite3-cli is not set
# CONFIG_PACKAGE_unixodbc-tools is not set
# end of Database
#
# Disc
#
# CONFIG_PACKAGE_autopart is not set
# CONFIG_PACKAGE_blkdiscard is not set
CONFIG_PACKAGE_blkid=y
# CONFIG_PACKAGE_blockdev is not set
# CONFIG_PACKAGE_cfdisk is not set
# CONFIG_PACKAGE_cgdisk is not set
# CONFIG_PACKAGE_eject is not set
# CONFIG_PACKAGE_fdisk is not set
# CONFIG_PACKAGE_findfs is not set
# CONFIG_PACKAGE_fio is not set
# CONFIG_PACKAGE_fixparts is not set
# CONFIG_PACKAGE_gdisk is not set
# CONFIG_PACKAGE_hd-idle is not set
# CONFIG_PACKAGE_hdparm is not set
CONFIG_PACKAGE_lsblk=y
# CONFIG_PACKAGE_lvm2 is not set
# CONFIG_PACKAGE_lvm2-selinux is not set
# CONFIG_PACKAGE_mdadm is not set
# CONFIG_PACKAGE_mtools is not set
CONFIG_PACKAGE_parted=y
#
# Configuration
#
CONFIG_PARTED_READLINE=y
# CONFIG_PARTED_LVM2 is not set
# end of Configuration
# CONFIG_PACKAGE_partx-utils is not set
# CONFIG_PACKAGE_sfdisk is not set
# CONFIG_PACKAGE_sgdisk is not set
# CONFIG_PACKAGE_uvol is not set
# CONFIG_PACKAGE_wipefs is not set
# end of Disc
#
# Editors
#
# CONFIG_PACKAGE_joe is not set
# CONFIG_PACKAGE_joe-extras is not set
# CONFIG_PACKAGE_jupp is not set
# CONFIG_PACKAGE_mg is not set
# CONFIG_PACKAGE_nano is not set
# CONFIG_PACKAGE_vim is not set
# CONFIG_PACKAGE_vim-full is not set
# CONFIG_PACKAGE_vim-fuller is not set
# CONFIG_PACKAGE_vim-help is not set
# CONFIG_PACKAGE_vim-runtime is not set
# CONFIG_PACKAGE_zile is not set
# end of Editors
#
# Encryption
#
# CONFIG_PACKAGE_ccrypt is not set
# CONFIG_PACKAGE_certtool is not set
# CONFIG_PACKAGE_cryptsetup is not set
# CONFIG_PACKAGE_gnupg is not set
# CONFIG_PACKAGE_gnupg2 is not set
# CONFIG_PACKAGE_gnupg2-dirmngr is not set
# CONFIG_PACKAGE_gnutls-utils is not set
# CONFIG_PACKAGE_gpgv is not set
# CONFIG_PACKAGE_gpgv2 is not set
# CONFIG_PACKAGE_keyctl is not set
# CONFIG_PACKAGE_keyutils is not set
# CONFIG_PACKAGE_px5g-mbedtls is not set
# CONFIG_PACKAGE_px5g-standalone is not set
# CONFIG_PACKAGE_px5g-wolfssl is not set
# CONFIG_PACKAGE_stoken is not set
# end of Encryption
#
# Filesystem
#
# CONFIG_PACKAGE_acl is not set
# CONFIG_PACKAGE_antfs-mount is not set
# CONFIG_PACKAGE_attr is not set
# CONFIG_PACKAGE_badblocks is not set
CONFIG_PACKAGE_btrfs-progs=y
# CONFIG_BTRFS_PROGS_ZSTD is not set
# CONFIG_PACKAGE_chattr is not set
# CONFIG_PACKAGE_debugfs is not set
# CONFIG_PACKAGE_dosfstools is not set
# CONFIG_PACKAGE_dumpe2fs is not set
# CONFIG_PACKAGE_e2freefrag is not set
CONFIG_PACKAGE_e2fsprogs=y
# CONFIG_PACKAGE_e4crypt is not set
# CONFIG_PACKAGE_exfat-fsck is not set
# CONFIG_PACKAGE_exfat-mkfs is not set
# CONFIG_PACKAGE_f2fs-tools is not set
# CONFIG_PACKAGE_f2fs-tools-selinux is not set
# CONFIG_PACKAGE_f2fsck is not set
# CONFIG_PACKAGE_f2fsck-selinux is not set
# CONFIG_PACKAGE_filefrag is not set
# CONFIG_PACKAGE_fstrim is not set
# CONFIG_PACKAGE_fuse-utils is not set
# CONFIG_PACKAGE_fuse3-utils is not set
# CONFIG_PACKAGE_hfsfsck is not set
# CONFIG_PACKAGE_lsattr is not set
# CONFIG_PACKAGE_mkf2fs is not set
# CONFIG_PACKAGE_mkf2fs-selinux is not set
# CONFIG_PACKAGE_mkhfs is not set
# CONFIG_PACKAGE_ncdu is not set
# CONFIG_PACKAGE_nfs-utils is not set
# CONFIG_PACKAGE_nfs-utils-libs is not set
# CONFIG_PACKAGE_ntfs-3g is not set
# CONFIG_PACKAGE_ntfs-3g-low is not set
# CONFIG_PACKAGE_ntfs-3g-utils is not set
# CONFIG_PACKAGE_ntfs3-mount is not set
# CONFIG_PACKAGE_owfs is not set
# CONFIG_PACKAGE_owshell is not set
# CONFIG_PACKAGE_resize2fs is not set
# CONFIG_PACKAGE_squashfs-tools-mksquashfs is not set
# CONFIG_PACKAGE_squashfs-tools-unsquashfs is not set
# CONFIG_PACKAGE_swap-utils is not set
# CONFIG_PACKAGE_sysfsutils is not set
# CONFIG_PACKAGE_tune2fs is not set
# CONFIG_PACKAGE_xfs-admin is not set
# CONFIG_PACKAGE_xfs-fsck is not set
# CONFIG_PACKAGE_xfs-growfs is not set
# CONFIG_PACKAGE_xfs-mkfs is not set
# end of Filesystem
#
# Image Manipulation
#
# CONFIG_PACKAGE_libjpeg-turbo-utils is not set
# CONFIG_PACKAGE_tiff-utils is not set
# end of Image Manipulation
#
# Microcontroller programming
#
# CONFIG_PACKAGE_avrdude is not set
# CONFIG_PACKAGE_dfu-programmer is not set
# CONFIG_PACKAGE_stm32flash is not set
# end of Microcontroller programming
#
# RTKLIB Suite
#
# CONFIG_PACKAGE_convbin is not set
# CONFIG_PACKAGE_pos2kml is not set
# CONFIG_PACKAGE_rnx2rtkp is not set
# CONFIG_PACKAGE_rtkrcv is not set
# CONFIG_PACKAGE_str2str is not set
# end of RTKLIB Suite
#
# Shells
#
# CONFIG_PACKAGE_bash is not set
# CONFIG_PACKAGE_fish is not set
# CONFIG_PACKAGE_klish is not set
# CONFIG_PACKAGE_mksh is not set
# CONFIG_PACKAGE_tcsh is not set
# CONFIG_PACKAGE_zsh is not set
# end of Shells
#
# Telephony
#
# CONFIG_PACKAGE_dahdi-cfg is not set
# CONFIG_PACKAGE_dahdi-monitor is not set
# CONFIG_PACKAGE_gsm-utils is not set
# CONFIG_PACKAGE_sipgrep is not set
# CONFIG_PACKAGE_sngrep is not set
# end of Telephony
#
# Terminal
#
# CONFIG_PACKAGE_agetty is not set
# CONFIG_PACKAGE_dvtm is not set
# CONFIG_PACKAGE_minicom is not set
# CONFIG_PACKAGE_picocom is not set
# CONFIG_PACKAGE_rtty-mbedtls is not set
# CONFIG_PACKAGE_rtty-nossl is not set
# CONFIG_PACKAGE_rtty-openssl is not set
# CONFIG_PACKAGE_rtty-wolfssl is not set
# CONFIG_PACKAGE_screen is not set
# CONFIG_PACKAGE_script-utils is not set
# CONFIG_PACKAGE_serialconsole is not set
# CONFIG_PACKAGE_setterm is not set
# CONFIG_PACKAGE_tio is not set
# CONFIG_PACKAGE_tmux is not set
CONFIG_PACKAGE_ttyd=y
# CONFIG_PACKAGE_wall is not set
# end of Terminal
#
# Virtualization
#
# end of Virtualization
#
# Zoneinfo
#
# CONFIG_PACKAGE_zoneinfo-africa is not set
# CONFIG_PACKAGE_zoneinfo-all is not set
# CONFIG_PACKAGE_zoneinfo-asia is not set
# CONFIG_PACKAGE_zoneinfo-atlantic is not set
# CONFIG_PACKAGE_zoneinfo-australia-nz is not set
# CONFIG_PACKAGE_zoneinfo-core is not set
# CONFIG_PACKAGE_zoneinfo-europe is not set
# CONFIG_PACKAGE_zoneinfo-india is not set
# CONFIG_PACKAGE_zoneinfo-northamerica is not set
# CONFIG_PACKAGE_zoneinfo-pacific is not set
# CONFIG_PACKAGE_zoneinfo-poles is not set
# CONFIG_PACKAGE_zoneinfo-simple is not set
# CONFIG_PACKAGE_zoneinfo-southamerica is not set
# end of Zoneinfo
#
# libimobiledevice
#
# CONFIG_PACKAGE_idevicerestore is not set
# CONFIG_PACKAGE_irecovery is not set
# CONFIG_PACKAGE_libimobiledevice-utils is not set
# CONFIG_PACKAGE_libusbmuxd-utils is not set
# CONFIG_PACKAGE_plistutil is not set
# CONFIG_PACKAGE_usbmuxd is not set
# end of libimobiledevice
#
# libselinux tools
#
# CONFIG_PACKAGE_libselinux-avcstat is not set
# CONFIG_PACKAGE_libselinux-compute_av is not set
# CONFIG_PACKAGE_libselinux-compute_create is not set
# CONFIG_PACKAGE_libselinux-compute_member is not set
# CONFIG_PACKAGE_libselinux-compute_relabel is not set
# CONFIG_PACKAGE_libselinux-getconlist is not set
# CONFIG_PACKAGE_libselinux-getdefaultcon is not set
# CONFIG_PACKAGE_libselinux-getenforce is not set
# CONFIG_PACKAGE_libselinux-getfilecon is not set
# CONFIG_PACKAGE_libselinux-getpidcon is not set
# CONFIG_PACKAGE_libselinux-getsebool is not set
# CONFIG_PACKAGE_libselinux-getseuser is not set
# CONFIG_PACKAGE_libselinux-matchpathcon is not set
# CONFIG_PACKAGE_libselinux-policyvers is not set
# CONFIG_PACKAGE_libselinux-sefcontext_compile is not set
# CONFIG_PACKAGE_libselinux-selabel_digest is not set
# CONFIG_PACKAGE_libselinux-selabel_get_digests_all_partial_matches is not set
# CONFIG_PACKAGE_libselinux-selabel_lookup is not set
# CONFIG_PACKAGE_libselinux-selabel_lookup_best_match is not set
# CONFIG_PACKAGE_libselinux-selabel_partial_match is not set
# CONFIG_PACKAGE_libselinux-selinux_check_access is not set
# CONFIG_PACKAGE_libselinux-selinux_check_securetty_context is not set
# CONFIG_PACKAGE_libselinux-selinuxenabled is not set
# CONFIG_PACKAGE_libselinux-selinuxexeccon is not set
# CONFIG_PACKAGE_libselinux-setenforce is not set
# CONFIG_PACKAGE_libselinux-setfilecon is not set
# CONFIG_PACKAGE_libselinux-togglesebool is not set
# CONFIG_PACKAGE_libselinux-validatetrans is not set
# end of libselinux tools
# CONFIG_PACKAGE_ack is not set
# CONFIG_PACKAGE_acpid is not set
# CONFIG_PACKAGE_adb is not set
# CONFIG_PACKAGE_ap51-flash is not set
# CONFIG_PACKAGE_apk is not set
# CONFIG_PACKAGE_at is not set
# CONFIG_PACKAGE_atheepmgr is not set
# CONFIG_PACKAGE_audit is not set
# CONFIG_PACKAGE_audit-utils is not set
# CONFIG_PACKAGE_augeas is not set
# CONFIG_PACKAGE_augeas-lenses is not set
# CONFIG_PACKAGE_augeas-lenses-tests is not set
# CONFIG_PACKAGE_bandwidthd is not set
# CONFIG_PACKAGE_bandwidthd-pgsql is not set
# CONFIG_PACKAGE_bandwidthd-php is not set
# CONFIG_PACKAGE_bandwidthd-sqlite is not set
# CONFIG_PACKAGE_banhostlist is not set
# CONFIG_PACKAGE_bc is not set
# CONFIG_PACKAGE_bluelog is not set
# CONFIG_PACKAGE_bluez-daemon is not set
# CONFIG_PACKAGE_bluez-utils is not set
# CONFIG_PACKAGE_bluez-utils-extra is not set
# CONFIG_PACKAGE_bluld is not set
# CONFIG_PACKAGE_bonniexx is not set
# CONFIG_PACKAGE_bottlerocket is not set
# CONFIG_PACKAGE_bsdiff is not set
# CONFIG_PACKAGE_bspatch is not set
# CONFIG_PACKAGE_byobu is not set
# CONFIG_PACKAGE_byobu-utils is not set
# CONFIG_PACKAGE_cache-domains-mbedtls is not set
# CONFIG_PACKAGE_cache-domains-openssl is not set
# CONFIG_PACKAGE_cache-domains-wolfssl is not set
# CONFIG_PACKAGE_cal is not set
# CONFIG_PACKAGE_canutils is not set
# CONFIG_PACKAGE_cgroup-tools is not set
# CONFIG_PACKAGE_cgroupfs-mount is not set
# CONFIG_PACKAGE_checkpolicy is not set
# CONFIG_PACKAGE_checksec is not set
# CONFIG_PACKAGE_checksec_automator is not set
# CONFIG_PACKAGE_chkcon is not set
# CONFIG_PACKAGE_cmdpad is not set
# CONFIG_PACKAGE_cni is not set
# CONFIG_PACKAGE_cni-plugins is not set
# CONFIG_PACKAGE_cni-plugins-nft is not set
# CONFIG_PACKAGE_coap-client is not set
# CONFIG_PACKAGE_collectd is not set
# CONFIG_PACKAGE_conmon is not set
# CONFIG_PACKAGE_containerd is not set
CONFIG_PACKAGE_coremark=y
CONFIG_COREMARK_OPTIMIZE_O3=y
CONFIG_COREMARK_ENABLE_MULTITHREADING=y
CONFIG_COREMARK_NUMBER_OF_THREADS=16
CONFIG_PACKAGE_coreutils=y
# CONFIG_PACKAGE_coreutils-b2sum is not set
# CONFIG_PACKAGE_coreutils-base32 is not set
CONFIG_PACKAGE_coreutils-base64=y
# CONFIG_PACKAGE_coreutils-basename is not set
# CONFIG_PACKAGE_coreutils-basenc is not set
# CONFIG_PACKAGE_coreutils-cat is not set
# CONFIG_PACKAGE_coreutils-chcon is not set
# CONFIG_PACKAGE_coreutils-chgrp is not set
# CONFIG_PACKAGE_coreutils-chmod is not set
# CONFIG_PACKAGE_coreutils-chown is not set
# CONFIG_PACKAGE_coreutils-chroot is not set
# CONFIG_PACKAGE_coreutils-cksum is not set
# CONFIG_PACKAGE_coreutils-comm is not set
# CONFIG_PACKAGE_coreutils-cp is not set
# CONFIG_PACKAGE_coreutils-csplit is not set
# CONFIG_PACKAGE_coreutils-cut is not set
# CONFIG_PACKAGE_coreutils-date is not set
# CONFIG_PACKAGE_coreutils-dd is not set
# CONFIG_PACKAGE_coreutils-df is not set
# CONFIG_PACKAGE_coreutils-dir is not set
# CONFIG_PACKAGE_coreutils-dircolors is not set
# CONFIG_PACKAGE_coreutils-dirname is not set
# CONFIG_PACKAGE_coreutils-du is not set
# CONFIG_PACKAGE_coreutils-echo is not set
# CONFIG_PACKAGE_coreutils-env is not set
# CONFIG_PACKAGE_coreutils-expand is not set
# CONFIG_PACKAGE_coreutils-expr is not set
# CONFIG_PACKAGE_coreutils-factor is not set
# CONFIG_PACKAGE_coreutils-false is not set
# CONFIG_PACKAGE_coreutils-fmt is not set
# CONFIG_PACKAGE_coreutils-fold is not set
# CONFIG_PACKAGE_coreutils-groups is not set
# CONFIG_PACKAGE_coreutils-head is not set
# CONFIG_PACKAGE_coreutils-hostid is not set
# CONFIG_PACKAGE_coreutils-id is not set
# CONFIG_PACKAGE_coreutils-install is not set
# CONFIG_PACKAGE_coreutils-join is not set
# CONFIG_PACKAGE_coreutils-kill is not set
# CONFIG_PACKAGE_coreutils-link is not set
# CONFIG_PACKAGE_coreutils-ln is not set
# CONFIG_PACKAGE_coreutils-logname is not set
# CONFIG_PACKAGE_coreutils-ls is not set
# CONFIG_PACKAGE_coreutils-md5sum is not set
# CONFIG_PACKAGE_coreutils-mkdir is not set
# CONFIG_PACKAGE_coreutils-mkfifo is not set
# CONFIG_PACKAGE_coreutils-mknod is not set
# CONFIG_PACKAGE_coreutils-mktemp is not set
# CONFIG_PACKAGE_coreutils-mv is not set
# CONFIG_PACKAGE_coreutils-nice is not set
# CONFIG_PACKAGE_coreutils-nl is not set
CONFIG_PACKAGE_coreutils-nohup=y
# CONFIG_PACKAGE_coreutils-nproc is not set
# CONFIG_PACKAGE_coreutils-numfmt is not set
# CONFIG_PACKAGE_coreutils-od is not set
# CONFIG_PACKAGE_coreutils-paste is not set
# CONFIG_PACKAGE_coreutils-pathchk is not set
# CONFIG_PACKAGE_coreutils-pinky is not set
# CONFIG_PACKAGE_coreutils-pr is not set
# CONFIG_PACKAGE_coreutils-printenv is not set
# CONFIG_PACKAGE_coreutils-printf is not set
# CONFIG_PACKAGE_coreutils-ptx is not set
# CONFIG_PACKAGE_coreutils-pwd is not set
# CONFIG_PACKAGE_coreutils-readlink is not set
# CONFIG_PACKAGE_coreutils-realpath is not set
# CONFIG_PACKAGE_coreutils-rm is not set
# CONFIG_PACKAGE_coreutils-rmdir is not set
# CONFIG_PACKAGE_coreutils-runcon is not set
# CONFIG_PACKAGE_coreutils-seq is not set
# CONFIG_PACKAGE_coreutils-sha1sum is not set
# CONFIG_PACKAGE_coreutils-sha224sum is not set
# CONFIG_PACKAGE_coreutils-sha256sum is not set
# CONFIG_PACKAGE_coreutils-sha384sum is not set
# CONFIG_PACKAGE_coreutils-sha512sum is not set
# CONFIG_PACKAGE_coreutils-shred is not set
# CONFIG_PACKAGE_coreutils-shuf is not set
# CONFIG_PACKAGE_coreutils-sleep is not set
# CONFIG_PACKAGE_coreutils-sort is not set
# CONFIG_PACKAGE_coreutils-split is not set
# CONFIG_PACKAGE_coreutils-stat is not set
# CONFIG_PACKAGE_coreutils-stdbuf is not set
# CONFIG_PACKAGE_coreutils-stty is not set
# CONFIG_PACKAGE_coreutils-sum is not set
# CONFIG_PACKAGE_coreutils-sync is not set
# CONFIG_PACKAGE_coreutils-tac is not set
# CONFIG_PACKAGE_coreutils-tail is not set
# CONFIG_PACKAGE_coreutils-tee is not set
# CONFIG_PACKAGE_coreutils-test is not set
# CONFIG_PACKAGE_coreutils-timeout is not set
# CONFIG_PACKAGE_coreutils-touch is not set
# CONFIG_PACKAGE_coreutils-tr is not set
# CONFIG_PACKAGE_coreutils-true is not set
# CONFIG_PACKAGE_coreutils-truncate is not set
# CONFIG_PACKAGE_coreutils-tsort is not set
# CONFIG_PACKAGE_coreutils-tty is not set
# CONFIG_PACKAGE_coreutils-uname is not set
# CONFIG_PACKAGE_coreutils-unexpand is not set
# CONFIG_PACKAGE_coreutils-uniq is not set
# CONFIG_PACKAGE_coreutils-unlink is not set
# CONFIG_PACKAGE_coreutils-uptime is not set
# CONFIG_PACKAGE_coreutils-users is not set
# CONFIG_PACKAGE_coreutils-vdir is not set
# CONFIG_PACKAGE_coreutils-wc is not set
# CONFIG_PACKAGE_coreutils-who is not set
# CONFIG_PACKAGE_coreutils-whoami is not set
# CONFIG_PACKAGE_coreutils-yes is not set
# CONFIG_PACKAGE_crconf is not set
# CONFIG_PACKAGE_crelay is not set
# CONFIG_PACKAGE_crun is not set
# CONFIG_PACKAGE_csstidy is not set
# CONFIG_PACKAGE_ct-bugcheck is not set
# CONFIG_PACKAGE_ctop is not set
# CONFIG_PACKAGE_dbus is not set
# CONFIG_PACKAGE_dbus-utils is not set
# CONFIG_PACKAGE_device-observatory is not set
# CONFIG_PACKAGE_dfu-util is not set
# CONFIG_PACKAGE_digitemp is not set
# CONFIG_PACKAGE_digitemp-usb is not set
# CONFIG_PACKAGE_dmesg is not set
# CONFIG_PACKAGE_docker is not set
# CONFIG_PACKAGE_docker-compose is not set
# CONFIG_PACKAGE_dockerd is not set
# CONFIG_PACKAGE_dropbearconvert is not set
# CONFIG_PACKAGE_dtc is not set
# CONFIG_PACKAGE_dumb-init is not set
# CONFIG_PACKAGE_dump1090 is not set
# CONFIG_PACKAGE_ecdsautils is not set
# CONFIG_PACKAGE_elektra-kdb is not set
# CONFIG_PACKAGE_evtest is not set
# CONFIG_PACKAGE_extract is not set
# CONFIG_PACKAGE_fdt-utils is not set
# CONFIG_PACKAGE_file is not set
# CONFIG_PACKAGE_findutils is not set
# CONFIG_PACKAGE_findutils-find is not set
# CONFIG_PACKAGE_findutils-locate is not set
# CONFIG_PACKAGE_findutils-xargs is not set
# CONFIG_PACKAGE_flashrom is not set
# CONFIG_PACKAGE_flashrom-pci is not set
# CONFIG_PACKAGE_flashrom-spi is not set
# CONFIG_PACKAGE_flashrom-usb is not set
# CONFIG_PACKAGE_flent-tools is not set
# CONFIG_PACKAGE_flock is not set
# CONFIG_PACKAGE_fritz-caldata is not set
# CONFIG_PACKAGE_fritz-tffs is not set
# CONFIG_PACKAGE_fritz-tffs-nand is not set
# CONFIG_PACKAGE_ftdi_eeprom is not set
# CONFIG_PACKAGE_gammu is not set
# CONFIG_PACKAGE_gawk is not set
# CONFIG_PACKAGE_gddrescue is not set
# CONFIG_PACKAGE_getopt is not set
# CONFIG_PACKAGE_giflib-utils is not set
# CONFIG_PACKAGE_gkermit is not set
# CONFIG_PACKAGE_gnuplot is not set
# CONFIG_PACKAGE_gpioctl-sysfs is not set
# CONFIG_PACKAGE_gpiod-tools is not set
# CONFIG_PACKAGE_gpsd is not set
# CONFIG_PACKAGE_gpsd-clients is not set
# CONFIG_PACKAGE_gpsd-utils is not set
# CONFIG_PACKAGE_grep is not set
# CONFIG_PACKAGE_hamlib is not set
# CONFIG_PACKAGE_haserl is not set
# CONFIG_PACKAGE_hashdeep is not set
# CONFIG_PACKAGE_haveged is not set
# CONFIG_PACKAGE_hplip-common is not set
# CONFIG_PACKAGE_hplip-sane is not set
# CONFIG_PACKAGE_hub-ctrl is not set
# CONFIG_PACKAGE_hwclock is not set
# CONFIG_PACKAGE_hwinfo is not set
# CONFIG_PACKAGE_hwloc-utils is not set
# CONFIG_PACKAGE_i2c-tools is not set
# CONFIG_PACKAGE_iconv is not set
# CONFIG_PACKAGE_iio-utils is not set
# CONFIG_PACKAGE_inotifywait is not set
# CONFIG_PACKAGE_inotifywatch is not set
# CONFIG_PACKAGE_io is not set
# CONFIG_PACKAGE_ipfs-http-client-tests is not set
# CONFIG_PACKAGE_irqbalance is not set
# CONFIG_PACKAGE_iwcap is not set
CONFIG_PACKAGE_iwinfo=y
# CONFIG_PACKAGE_jq is not set
CONFIG_PACKAGE_jshn=y
# CONFIG_PACKAGE_kmod is not set
# CONFIG_PACKAGE_lcd4linux-custom is not set
# CONFIG_PACKAGE_lcdproc-clients is not set
# CONFIG_PACKAGE_lcdproc-drivers is not set
# CONFIG_PACKAGE_lcdproc-server is not set
# CONFIG_PACKAGE_less is not set
# CONFIG_PACKAGE_less-wide is not set
CONFIG_PACKAGE_libjson-script=y
# CONFIG_PACKAGE_libnetwork is not set
# CONFIG_PACKAGE_libxml2-utils is not set
# CONFIG_PACKAGE_lm-sensors is not set
# CONFIG_PACKAGE_lm-sensors-detect is not set
# CONFIG_PACKAGE_logger is not set
# CONFIG_PACKAGE_logrotate is not set
# CONFIG_PACKAGE_look is not set
# CONFIG_PACKAGE_losetup is not set
# CONFIG_PACKAGE_lrzsz is not set
# CONFIG_PACKAGE_lscpu is not set
CONFIG_PACKAGE_lsof=y
# CONFIG_PACKAGE_lxc is not set
CONFIG_PACKAGE_maccalc=y
# CONFIG_PACKAGE_macchanger is not set
# CONFIG_PACKAGE_mandoc is not set
# CONFIG_PACKAGE_mbedtls-util is not set
# CONFIG_PACKAGE_mbim-utils is not set
# CONFIG_PACKAGE_mbtools is not set
# CONFIG_PACKAGE_mc is not set
# CONFIG_PACKAGE_mcookie is not set
# CONFIG_PACKAGE_micrond is not set
# CONFIG_PACKAGE_mmc-utils is not set
# CONFIG_PACKAGE_more is not set
# CONFIG_PACKAGE_moreutils is not set
# CONFIG_PACKAGE_mosh-client is not set
# CONFIG_PACKAGE_mosh-server is not set
# CONFIG_PACKAGE_mount-utils is not set
# CONFIG_PACKAGE_mpack is not set
# CONFIG_PACKAGE_mt-st is not set
# CONFIG_PACKAGE_namei is not set
# CONFIG_PACKAGE_nand-utils is not set
# CONFIG_PACKAGE_naywatch is not set
# CONFIG_PACKAGE_netopeer2-cli is not set
# CONFIG_PACKAGE_netopeer2-server is not set
# CONFIG_PACKAGE_netwhere is not set
# CONFIG_PACKAGE_nnn is not set
# CONFIG_PACKAGE_nsenter is not set
# CONFIG_PACKAGE_nss-utils is not set
# CONFIG_PACKAGE_oath-toolkit is not set
# CONFIG_PACKAGE_oci-runtime-tool is not set
# CONFIG_PACKAGE_open-plc-utils is not set
# CONFIG_PACKAGE_open2300 is not set
# CONFIG_PACKAGE_openobex is not set
# CONFIG_PACKAGE_openobex-apps is not set
# CONFIG_PACKAGE_openocd is not set
# CONFIG_PACKAGE_opensc-utils is not set
CONFIG_PACKAGE_openssl-util=y
# CONFIG_PACKAGE_openzwave is not set
# CONFIG_PACKAGE_openzwave-config is not set
# CONFIG_PACKAGE_owipcalc is not set
# CONFIG_PACKAGE_pciids is not set
# CONFIG_PACKAGE_pciutils is not set
# CONFIG_PACKAGE_pcsc-tools is not set
# CONFIG_PACKAGE_pcscd is not set
# CONFIG_PACKAGE_podman is not set
# CONFIG_PACKAGE_podman-selinux is not set
# CONFIG_PACKAGE_policycoreutils is not set
# CONFIG_PACKAGE_powertop is not set
# CONFIG_PACKAGE_pps-tools is not set
# CONFIG_PACKAGE_prlimit is not set
# CONFIG_PACKAGE_procps-ng is not set
# CONFIG_PACKAGE_progress is not set
# CONFIG_PACKAGE_prometheus is not set
# CONFIG_PACKAGE_prometheus-node-exporter-lua is not set
# CONFIG_PACKAGE_prometheus-statsd-exporter is not set
# CONFIG_PACKAGE_pservice is not set
# CONFIG_PACKAGE_psmisc is not set
# CONFIG_PACKAGE_pv is not set
# CONFIG_PACKAGE_qmi-utils is not set
# CONFIG_PACKAGE_qrencode is not set
# CONFIG_PACKAGE_quota is not set
# CONFIG_PACKAGE_ravpower-mcu is not set
# CONFIG_PACKAGE_rclone is not set
# CONFIG_PACKAGE_readsb is not set
# CONFIG_PACKAGE_relayctl is not set
# CONFIG_PACKAGE_rename is not set
# CONFIG_PACKAGE_restic is not set
# CONFIG_PACKAGE_rng-tools is not set
# CONFIG_PACKAGE_rtl-ais is not set
# CONFIG_PACKAGE_rtl-sdr is not set
# CONFIG_PACKAGE_rtl_433 is not set
# CONFIG_PACKAGE_runc is not set
# CONFIG_PACKAGE_sane-backends is not set
# CONFIG_PACKAGE_sane-daemon is not set
# CONFIG_PACKAGE_sane-frontends is not set
# CONFIG_PACKAGE_secilc is not set
# CONFIG_PACKAGE_sed is not set
# CONFIG_PACKAGE_selinux-audit2allow is not set
# CONFIG_PACKAGE_selinux-chcat is not set
# CONFIG_PACKAGE_selinux-semanage is not set
# CONFIG_PACKAGE_semodule-utils is not set
# CONFIG_PACKAGE_serdisplib-tools is not set
# CONFIG_PACKAGE_setools is not set
# CONFIG_PACKAGE_setserial is not set
# CONFIG_PACKAGE_shadow-utils is not set
CONFIG_PACKAGE_shellsync=y
# CONFIG_PACKAGE_sipcalc is not set
# CONFIG_PACKAGE_sispmctl is not set
# CONFIG_PACKAGE_slide-switch is not set
# CONFIG_PACKAGE_smartd is not set
# CONFIG_PACKAGE_smartd-mail is not set
CONFIG_PACKAGE_smartmontools=y
# CONFIG_PACKAGE_smartmontools-drivedb is not set
# CONFIG_PACKAGE_smstools3 is not set
# CONFIG_PACKAGE_sockread is not set
# CONFIG_PACKAGE_spi-tools is not set
# CONFIG_PACKAGE_spidev-test is not set
# CONFIG_PACKAGE_ssdeep is not set
# CONFIG_PACKAGE_sshpass is not set
# CONFIG_PACKAGE_strace is not set
CONFIG_STRACE_NONE=y
# CONFIG_STRACE_LIBDW is not set
# CONFIG_STRACE_LIBUNWIND is not set
# CONFIG_PACKAGE_stress is not set
# CONFIG_PACKAGE_stress-ng is not set
# CONFIG_PACKAGE_sumo is not set
# CONFIG_PACKAGE_syncthing is not set
# CONFIG_PACKAGE_sysrepo is not set
# CONFIG_PACKAGE_sysrepocfg is not set
# CONFIG_PACKAGE_sysrepoctl is not set
# CONFIG_PACKAGE_sysstat is not set
# CONFIG_PACKAGE_tar is not set
# CONFIG_PACKAGE_taskwarrior is not set
# CONFIG_PACKAGE_telldus-core is not set
# CONFIG_PACKAGE_temperusb is not set
# CONFIG_PACKAGE_tesseract is not set
# CONFIG_PACKAGE_tini is not set
# CONFIG_PACKAGE_tracertools is not set
# CONFIG_PACKAGE_tree is not set
# CONFIG_PACKAGE_triggerhappy is not set
CONFIG_PACKAGE_ubi-utils=y
# CONFIG_PACKAGE_ucode is not set
# CONFIG_PACKAGE_udns-dnsget is not set
# CONFIG_PACKAGE_udns-ex-rdns is not set
# CONFIG_PACKAGE_udns-rblcheck is not set
# CONFIG_PACKAGE_ugps is not set
# CONFIG_PACKAGE_uhubctl is not set
# CONFIG_PACKAGE_uledd is not set
# CONFIG_PACKAGE_unshare is not set
# CONFIG_PACKAGE_usb-modeswitch is not set
CONFIG_PACKAGE_usbids=y
CONFIG_PACKAGE_usbutils=y
# CONFIG_PACKAGE_uuidd is not set
# CONFIG_PACKAGE_uuidgen is not set
# CONFIG_PACKAGE_uvcdynctrl is not set
# CONFIG_PACKAGE_v4l-utils is not set
# CONFIG_PACKAGE_view1090 is not set
# CONFIG_PACKAGE_viewadsb is not set
# CONFIG_PACKAGE_watchcat is not set
# CONFIG_PACKAGE_whereis is not set
# CONFIG_PACKAGE_which is not set
# CONFIG_PACKAGE_whiptail is not set
# CONFIG_PACKAGE_whois is not set
# CONFIG_PACKAGE_wifitoggle is not set
# CONFIG_PACKAGE_wipe is not set
# CONFIG_PACKAGE_xsltproc is not set
# CONFIG_PACKAGE_xxd is not set
# CONFIG_PACKAGE_yanglint is not set
# CONFIG_PACKAGE_yara is not set
# CONFIG_PACKAGE_ykclient is not set
# CONFIG_PACKAGE_ykpers is not set
# CONFIG_PACKAGE_yq is not set
# end of Utilities
#
# Xorg
#
#
# Font-Utils
#
# CONFIG_PACKAGE_fontconfig is not set
# end of Font-Utils
# end of Xorg
CONFIG_OVERRIDE_PKGS="kcptun"
|
66be7264a8937d34025b746681df8fc82610cbf5 | 77c5b91fae1b966ddd1db969ba37b6f0e4901e88 | /src/analysis/normed_space/banach.lean | 103f1d2a63720ac40c51bfbcf1601d782feed318 | [
"Apache-2.0"
] | permissive | dexmagic/mathlib | ff48eefc56e2412429b31d4fddd41a976eb287ce | 7a5d15a955a92a90e1d398b2281916b9c41270b2 | refs/heads/master | 1,693,481,322,046 | 1,633,360,193,000 | 1,633,360,193,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 17,079 | lean | /-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import topology.metric_space.baire
import analysis.normed_space.operator_norm
/-!
# Banach open mapping theorem
This file contains the Banach open mapping theorem, i.e., the fact that a bijective
bounded linear map between Banach spaces has a bounded inverse.
-/
open function metric set filter finset
open_locale classical topological_space big_operators nnreal
variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]
{E : Type*} [normed_group E] [normed_space 𝕜 E]
{F : Type*} [normed_group F] [normed_space 𝕜 F]
(f : E →L[𝕜] F)
include 𝕜
namespace continuous_linear_map
/-- A (possibly nonlinear) right inverse to a continuous linear map, which doesn't have to be
linear itself but which satisfies a bound `∥inverse x∥ ≤ C * ∥x∥`. A surjective continuous linear
map doesn't always have a continuous linear right inverse, but it always has a nonlinear inverse
in this sense, by Banach's open mapping theorem. -/
structure nonlinear_right_inverse :=
(to_fun : F → E)
(nnnorm : ℝ≥0)
(bound' : ∀ y, ∥to_fun y∥ ≤ nnnorm * ∥y∥)
(right_inv' : ∀ y, f (to_fun y) = y)
instance : has_coe_to_fun (nonlinear_right_inverse f) := ⟨_, λ fsymm, fsymm.to_fun⟩
@[simp] lemma nonlinear_right_inverse.right_inv {f : E →L[𝕜] F} (fsymm : nonlinear_right_inverse f)
(y : F) : f (fsymm y) = y :=
fsymm.right_inv' y
lemma nonlinear_right_inverse.bound {f : E →L[𝕜] F} (fsymm : nonlinear_right_inverse f) (y : F) :
∥fsymm y∥ ≤ fsymm.nnnorm * ∥y∥ :=
fsymm.bound' y
end continuous_linear_map
/-- Given a continuous linear equivalence, the inverse is in particular an instance of
`nonlinear_right_inverse` (which turns out to be linear). -/
noncomputable def continuous_linear_equiv.to_nonlinear_right_inverse (f : E ≃L[𝕜] F) :
continuous_linear_map.nonlinear_right_inverse (f : E →L[𝕜] F) :=
{ to_fun := f.inv_fun,
nnnorm := nnnorm (f.symm : F →L[𝕜] E),
bound' := λ y, continuous_linear_map.le_op_norm (f.symm : F →L[𝕜] E) _,
right_inv' := f.apply_symm_apply }
noncomputable instance (f : E ≃L[𝕜] F) :
inhabited (continuous_linear_map.nonlinear_right_inverse (f : E →L[𝕜] F)) :=
⟨f.to_nonlinear_right_inverse⟩
/-! ### Proof of the Banach open mapping theorem -/
variable [complete_space F]
/--
First step of the proof of the Banach open mapping theorem (using completeness of `F`):
by Baire's theorem, there exists a ball in `E` whose image closure has nonempty interior.
Rescaling everything, it follows that any `y ∈ F` is arbitrarily well approached by
images of elements of norm at most `C * ∥y∥`.
For further use, we will only need such an element whose image
is within distance `∥y∥/2` of `y`, to apply an iterative process. -/
lemma exists_approx_preimage_norm_le (surj : surjective f) :
∃C ≥ 0, ∀y, ∃x, dist (f x) y ≤ 1/2 * ∥y∥ ∧ ∥x∥ ≤ C * ∥y∥ :=
begin
have A : (⋃n:ℕ, closure (f '' (ball 0 n))) = univ,
{ refine subset.antisymm (subset_univ _) (λy hy, _),
rcases surj y with ⟨x, hx⟩,
rcases exists_nat_gt (∥x∥) with ⟨n, hn⟩,
refine mem_Union.2 ⟨n, subset_closure _⟩,
refine (mem_image _ _ _).2 ⟨x, ⟨_, hx⟩⟩,
rwa [mem_ball, dist_eq_norm, sub_zero] },
have : ∃ (n : ℕ) x, x ∈ interior (closure (f '' (ball 0 n))) :=
nonempty_interior_of_Union_of_closed (λn, is_closed_closure) A,
simp only [mem_interior_iff_mem_nhds, metric.mem_nhds_iff] at this,
rcases this with ⟨n, a, ε, ⟨εpos, H⟩⟩,
rcases normed_field.exists_one_lt_norm 𝕜 with ⟨c, hc⟩,
refine ⟨(ε/2)⁻¹ * ∥c∥ * 2 * n, _, λy, _⟩,
{ refine mul_nonneg (mul_nonneg (mul_nonneg _ (norm_nonneg _)) (by norm_num)) _,
exacts [inv_nonneg.2 (div_nonneg (le_of_lt εpos) (by norm_num)), n.cast_nonneg] },
{ by_cases hy : y = 0,
{ use 0, simp [hy] },
{ rcases rescale_to_shell hc (half_pos εpos) hy with ⟨d, hd, ydlt, leyd, dinv⟩,
let δ := ∥d∥ * ∥y∥/4,
have δpos : 0 < δ :=
div_pos (mul_pos (norm_pos_iff.2 hd) (norm_pos_iff.2 hy)) (by norm_num),
have : a + d • y ∈ ball a ε,
by simp [dist_eq_norm, lt_of_le_of_lt ydlt.le (half_lt_self εpos)],
rcases metric.mem_closure_iff.1 (H this) _ δpos with ⟨z₁, z₁im, h₁⟩,
rcases (mem_image _ _ _).1 z₁im with ⟨x₁, hx₁, xz₁⟩,
rw ← xz₁ at h₁,
rw [mem_ball, dist_eq_norm, sub_zero] at hx₁,
have : a ∈ ball a ε, by { simp, exact εpos },
rcases metric.mem_closure_iff.1 (H this) _ δpos with ⟨z₂, z₂im, h₂⟩,
rcases (mem_image _ _ _).1 z₂im with ⟨x₂, hx₂, xz₂⟩,
rw ← xz₂ at h₂,
rw [mem_ball, dist_eq_norm, sub_zero] at hx₂,
let x := x₁ - x₂,
have I : ∥f x - d • y∥ ≤ 2 * δ := calc
∥f x - d • y∥ = ∥f x₁ - (a + d • y) - (f x₂ - a)∥ :
by { congr' 1, simp only [x, f.map_sub], abel }
... ≤ ∥f x₁ - (a + d • y)∥ + ∥f x₂ - a∥ :
norm_sub_le _ _
... ≤ δ + δ : begin
apply add_le_add,
{ rw [← dist_eq_norm, dist_comm], exact le_of_lt h₁ },
{ rw [← dist_eq_norm, dist_comm], exact le_of_lt h₂ }
end
... = 2 * δ : (two_mul _).symm,
have J : ∥f (d⁻¹ • x) - y∥ ≤ 1/2 * ∥y∥ := calc
∥f (d⁻¹ • x) - y∥ = ∥d⁻¹ • f x - (d⁻¹ * d) • y∥ :
by rwa [f.map_smul _, inv_mul_cancel, one_smul]
... = ∥d⁻¹ • (f x - d • y)∥ : by rw [mul_smul, smul_sub]
... = ∥d∥⁻¹ * ∥f x - d • y∥ : by rw [norm_smul, normed_field.norm_inv]
... ≤ ∥d∥⁻¹ * (2 * δ) : begin
apply mul_le_mul_of_nonneg_left I,
rw inv_nonneg,
exact norm_nonneg _
end
... = (∥d∥⁻¹ * ∥d∥) * ∥y∥ /2 : by { simp only [δ], ring }
... = ∥y∥/2 : by { rw [inv_mul_cancel, one_mul], simp [norm_eq_zero, hd] }
... = (1/2) * ∥y∥ : by ring,
rw ← dist_eq_norm at J,
have K : ∥d⁻¹ • x∥ ≤ (ε / 2)⁻¹ * ∥c∥ * 2 * ↑n * ∥y∥ := calc
∥d⁻¹ • x∥ = ∥d∥⁻¹ * ∥x₁ - x₂∥ : by rw [norm_smul, normed_field.norm_inv]
... ≤ ((ε / 2)⁻¹ * ∥c∥ * ∥y∥) * (n + n) : begin
refine mul_le_mul dinv _ (norm_nonneg _) _,
{ exact le_trans (norm_sub_le _ _) (add_le_add (le_of_lt hx₁) (le_of_lt hx₂)) },
{ apply mul_nonneg (mul_nonneg _ (norm_nonneg _)) (norm_nonneg _),
exact inv_nonneg.2 (le_of_lt (half_pos εpos)) }
end
... = (ε / 2)⁻¹ * ∥c∥ * 2 * ↑n * ∥y∥ : by ring,
exact ⟨d⁻¹ • x, J, K⟩ } },
end
variable [complete_space E]
/-- The Banach open mapping theorem: if a bounded linear map between Banach spaces is onto, then
any point has a preimage with controlled norm. -/
theorem exists_preimage_norm_le (surj : surjective f) :
∃C > 0, ∀y, ∃x, f x = y ∧ ∥x∥ ≤ C * ∥y∥ :=
begin
obtain ⟨C, C0, hC⟩ := exists_approx_preimage_norm_le f surj,
/- Second step of the proof: starting from `y`, we want an exact preimage of `y`. Let `g y` be
the approximate preimage of `y` given by the first step, and `h y = y - f(g y)` the part that
has no preimage yet. We will iterate this process, taking the approximate preimage of `h y`,
leaving only `h^2 y` without preimage yet, and so on. Let `u n` be the approximate preimage
of `h^n y`. Then `u` is a converging series, and by design the sum of the series is a
preimage of `y`. This uses completeness of `E`. -/
choose g hg using hC,
let h := λy, y - f (g y),
have hle : ∀y, ∥h y∥ ≤ (1/2) * ∥y∥,
{ assume y,
rw [← dist_eq_norm, dist_comm],
exact (hg y).1 },
refine ⟨2 * C + 1, by linarith, λy, _⟩,
have hnle : ∀n:ℕ, ∥(h^[n]) y∥ ≤ (1/2)^n * ∥y∥,
{ assume n,
induction n with n IH,
{ simp only [one_div, nat.nat_zero_eq_zero, one_mul, iterate_zero_apply,
pow_zero] },
{ rw [iterate_succ'],
apply le_trans (hle _) _,
rw [pow_succ, mul_assoc],
apply mul_le_mul_of_nonneg_left IH,
norm_num } },
let u := λn, g((h^[n]) y),
have ule : ∀n, ∥u n∥ ≤ (1/2)^n * (C * ∥y∥),
{ assume n,
apply le_trans (hg _).2 _,
calc C * ∥(h^[n]) y∥ ≤ C * ((1/2)^n * ∥y∥) : mul_le_mul_of_nonneg_left (hnle n) C0
... = (1 / 2) ^ n * (C * ∥y∥) : by ring },
have sNu : summable (λn, ∥u n∥),
{ refine summable_of_nonneg_of_le (λn, norm_nonneg _) ule _,
exact summable.mul_right _ (summable_geometric_of_lt_1 (by norm_num) (by norm_num)) },
have su : summable u := summable_of_summable_norm sNu,
let x := tsum u,
have x_ineq : ∥x∥ ≤ (2 * C + 1) * ∥y∥ := calc
∥x∥ ≤ ∑'n, ∥u n∥ : norm_tsum_le_tsum_norm sNu
... ≤ ∑'n, (1/2)^n * (C * ∥y∥) :
tsum_le_tsum ule sNu (summable.mul_right _ summable_geometric_two)
... = (∑'n, (1/2)^n) * (C * ∥y∥) : tsum_mul_right
... = 2 * C * ∥y∥ : by rw [tsum_geometric_two, mul_assoc]
... ≤ 2 * C * ∥y∥ + ∥y∥ : le_add_of_nonneg_right (norm_nonneg y)
... = (2 * C + 1) * ∥y∥ : by ring,
have fsumeq : ∀n:ℕ, f (∑ i in range n, u i) = y - (h^[n]) y,
{ assume n,
induction n with n IH,
{ simp [f.map_zero] },
{ rw [sum_range_succ, f.map_add, IH, iterate_succ', sub_add] } },
have : tendsto (λn, ∑ i in range n, u i) at_top (𝓝 x) :=
su.has_sum.tendsto_sum_nat,
have L₁ : tendsto (λn, f (∑ i in range n, u i)) at_top (𝓝 (f x)) :=
(f.continuous.tendsto _).comp this,
simp only [fsumeq] at L₁,
have L₂ : tendsto (λn, y - (h^[n]) y) at_top (𝓝 (y - 0)),
{ refine tendsto_const_nhds.sub _,
rw tendsto_iff_norm_tendsto_zero,
simp only [sub_zero],
refine squeeze_zero (λ_, norm_nonneg _) hnle _,
rw [← zero_mul ∥y∥],
refine (tendsto_pow_at_top_nhds_0_of_lt_1 _ _).mul tendsto_const_nhds; norm_num },
have feq : f x = y - 0 := tendsto_nhds_unique L₁ L₂,
rw sub_zero at feq,
exact ⟨x, feq, x_ineq⟩
end
/-- The Banach open mapping theorem: a surjective bounded linear map between Banach spaces is
open. -/
theorem open_mapping (surj : surjective f) : is_open_map f :=
begin
assume s hs,
rcases exists_preimage_norm_le f surj with ⟨C, Cpos, hC⟩,
refine is_open_iff.2 (λy yfs, _),
rcases mem_image_iff_bex.1 yfs with ⟨x, xs, fxy⟩,
rcases is_open_iff.1 hs x xs with ⟨ε, εpos, hε⟩,
refine ⟨ε/C, div_pos εpos Cpos, λz hz, _⟩,
rcases hC (z-y) with ⟨w, wim, wnorm⟩,
have : f (x + w) = z, by { rw [f.map_add, wim, fxy, add_sub_cancel'_right] },
rw ← this,
have : x + w ∈ ball x ε := calc
dist (x+w) x = ∥w∥ : by { rw dist_eq_norm, simp }
... ≤ C * ∥z - y∥ : wnorm
... < C * (ε/C) : begin
apply mul_lt_mul_of_pos_left _ Cpos,
rwa [mem_ball, dist_eq_norm] at hz,
end
... = ε : mul_div_cancel' _ (ne_of_gt Cpos),
exact set.mem_image_of_mem _ (hε this)
end
/-! ### Applications of the Banach open mapping theorem -/
namespace continuous_linear_map
lemma exists_nonlinear_right_inverse_of_surjective (f : E →L[𝕜] F) (hsurj : f.range = ⊤) :
∃ (fsymm : nonlinear_right_inverse f), 0 < fsymm.nnnorm :=
begin
choose C hC fsymm h using exists_preimage_norm_le _ (linear_map.range_eq_top.mp hsurj),
use { to_fun := fsymm,
nnnorm := ⟨C, hC.lt.le⟩,
bound' := λ y, (h y).2,
right_inv' := λ y, (h y).1 },
exact hC
end
/-- A surjective continuous linear map between Banach spaces admits a (possibly nonlinear)
controlled right inverse. In general, it is not possible to ensure that such a right inverse
is linear (take for instance the map from `E` to `E/F` where `F` is a closed subspace of `E`
without a closed complement. Then it doesn't have a continuous linear right inverse.) -/
@[irreducible] noncomputable def nonlinear_right_inverse_of_surjective
(f : E →L[𝕜] F) (hsurj : f.range = ⊤) : nonlinear_right_inverse f :=
classical.some (exists_nonlinear_right_inverse_of_surjective f hsurj)
lemma nonlinear_right_inverse_of_surjective_nnnorm_pos (f : E →L[𝕜] F) (hsurj : f.range = ⊤) :
0 < (nonlinear_right_inverse_of_surjective f hsurj).nnnorm :=
begin
rw nonlinear_right_inverse_of_surjective,
exact classical.some_spec (exists_nonlinear_right_inverse_of_surjective f hsurj)
end
end continuous_linear_map
namespace linear_equiv
/-- If a bounded linear map is a bijection, then its inverse is also a bounded linear map. -/
@[continuity]
theorem continuous_symm (e : E ≃ₗ[𝕜] F) (h : continuous e) :
continuous e.symm :=
begin
rw continuous_def,
intros s hs,
rw [← e.image_eq_preimage],
rw [← e.coe_coe] at h ⊢,
exact open_mapping ⟨↑e, h⟩ e.surjective s hs
end
/-- Associating to a linear equivalence between Banach spaces a continuous linear equivalence when
the direct map is continuous, thanks to the Banach open mapping theorem that ensures that the
inverse map is also continuous. -/
def to_continuous_linear_equiv_of_continuous (e : E ≃ₗ[𝕜] F) (h : continuous e) :
E ≃L[𝕜] F :=
{ continuous_to_fun := h,
continuous_inv_fun := e.continuous_symm h,
..e }
@[simp] lemma coe_fn_to_continuous_linear_equiv_of_continuous (e : E ≃ₗ[𝕜] F) (h : continuous e) :
⇑(e.to_continuous_linear_equiv_of_continuous h) = e := rfl
@[simp] lemma coe_fn_to_continuous_linear_equiv_of_continuous_symm (e : E ≃ₗ[𝕜] F)
(h : continuous e) :
⇑(e.to_continuous_linear_equiv_of_continuous h).symm = e.symm := rfl
end linear_equiv
namespace continuous_linear_equiv
/-- Convert a bijective continuous linear map `f : E →L[𝕜] F` between two Banach spaces
to a continuous linear equivalence. -/
noncomputable def of_bijective (f : E →L[𝕜] F) (hinj : f.ker = ⊥) (hsurj : f.range = ⊤) :
E ≃L[𝕜] F :=
(linear_equiv.of_bijective ↑f (linear_map.ker_eq_bot.mp hinj) (linear_map.range_eq_top.mp hsurj))
.to_continuous_linear_equiv_of_continuous f.continuous
@[simp] lemma coe_fn_of_bijective (f : E →L[𝕜] F) (hinj : f.ker = ⊥) (hsurj : f.range = ⊤) :
⇑(of_bijective f hinj hsurj) = f := rfl
lemma coe_of_bijective (f : E →L[𝕜] F) (hinj : f.ker = ⊥) (hsurj : f.range = ⊤) :
↑(of_bijective f hinj hsurj) = f := by { ext, refl }
@[simp] lemma of_bijective_symm_apply_apply (f : E →L[𝕜] F) (hinj : f.ker = ⊥)
(hsurj : f.range = ⊤) (x : E) :
(of_bijective f hinj hsurj).symm (f x) = x :=
(of_bijective f hinj hsurj).symm_apply_apply x
@[simp] lemma of_bijective_apply_symm_apply (f : E →L[𝕜] F) (hinj : f.ker = ⊥)
(hsurj : f.range = ⊤) (y : F) :
f ((of_bijective f hinj hsurj).symm y) = y :=
(of_bijective f hinj hsurj).apply_symm_apply y
end continuous_linear_equiv
namespace continuous_linear_map
/-- Intermediate definition used to show
`continuous_linear_map.closed_complemented_range_of_is_compl_of_ker_eq_bot`.
This is `f.coprod G.subtypeL` as an `continuous_linear_equiv`. -/
noncomputable def coprod_subtypeL_equiv_of_is_compl
(f : E →L[𝕜] F) {G : submodule 𝕜 F}
(h : is_compl f.range G) [complete_space G] (hker : f.ker = ⊥) : (E × G) ≃L[𝕜] F :=
continuous_linear_equiv.of_bijective (f.coprod G.subtypeL)
(begin
rw ker_coprod_of_disjoint_range,
{ rw [hker, submodule.ker_subtypeL, submodule.prod_bot] },
{ rw submodule.range_subtypeL,
exact h.disjoint }
end)
(by simp only [range_coprod, h.sup_eq_top, submodule.range_subtypeL])
lemma range_eq_map_coprod_subtypeL_equiv_of_is_compl
(f : E →L[𝕜] F) {G : submodule 𝕜 F}
(h : is_compl f.range G) [complete_space G] (hker : f.ker = ⊥) :
f.range = ((⊤ : submodule 𝕜 E).prod (⊥ : submodule 𝕜 G)).map
(f.coprod_subtypeL_equiv_of_is_compl h hker : E × G →ₗ[𝕜] F) :=
by rw [coprod_subtypeL_equiv_of_is_compl, _root_.coe_coe, continuous_linear_equiv.coe_of_bijective,
coe_coprod, linear_map.coprod_map_prod, submodule.map_bot, sup_bot_eq, submodule.map_top,
range]
/- TODO: remove the assumption `f.ker = ⊥` in the next lemma, by using the map induced by `f` on
`E / f.ker`, once we have quotient normed spaces. -/
lemma closed_complemented_range_of_is_compl_of_ker_eq_bot (f : E →L[𝕜] F) (G : submodule 𝕜 F)
(h : is_compl f.range G) (hG : is_closed (G : set F)) (hker : f.ker = ⊥) :
is_closed (f.range : set F) :=
begin
haveI : complete_space G := complete_space_coe_iff_is_complete.2 hG.is_complete,
let g := coprod_subtypeL_equiv_of_is_compl f h hker,
rw congr_arg coe (range_eq_map_coprod_subtypeL_equiv_of_is_compl f h hker ),
apply g.to_homeomorph.is_closed_image.2,
exact is_closed_univ.prod is_closed_singleton,
end
end continuous_linear_map
|
ecbea6cf316104f37798df278e18d29b5a26ebf7 | 19cc34575500ee2e3d4586c15544632aa07a8e66 | /src/ring_theory/witt_vector/structure_polynomial.lean | 51863dfdbb23d0a3b83056873c6ab35b5a8e673e | [
"Apache-2.0"
] | permissive | LibertasSpZ/mathlib | b9fcd46625eb940611adb5e719a4b554138dade6 | 33f7870a49d7cc06d2f3036e22543e6ec5046e68 | refs/heads/master | 1,672,066,539,347 | 1,602,429,158,000 | 1,602,429,158,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 12,673 | lean | /-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Robert Y. Lewis
-/
import data.matrix.notation
import field_theory.mv_polynomial
import field_theory.finite.polynomial
import number_theory.basic
import ring_theory.witt_vector.witt_polynomial
/-!
# Witt structure polynomials
In this file we prove the main theorem that makes the whole theory of Witt vectors work.
Briefly, consider a polynomial `Φ : mv_polynomial idx ℤ` over the integers,
with polynomials variables indexed by an arbitrary type `idx`.
Then there exists a unique family of polynomials `φ : ℕ → mv_polynomial (idx × ℕ) Φ`
such that for all `n : ℕ` we have (`witt_structure_int_exists_unique`)
```
bind₁ φ (witt_polynomial p ℤ n) = bind₁ (λ i, (rename (prod.mk i) (witt_polynomial p ℤ n))) Φ
```
In other words: evaluating the `n`-th Witt polynomial on the family `φ`
is the same as evaluating `Φ` on the (appropriately renamed) `n`-th Witt polynomials.
N.b.: As far as we know, these polynomials do not have a name in the literature,
so we have decided to call them the “Witt structure polynomials”. See `witt_structure_int`.
## Special cases
With the main result of this file in place, we apply it to certain special polynomials.
For example, by taking `Φ = X tt + X ff` resp. `Φ = X tt * X ff`
we obtain families of polynomials `witt_add` resp. `witt_mul`
(with type `ℕ → mv_polynomial (bool × ℕ) ℤ`) that will be used in later files to define the
addition and multiplication on the ring of Witt vectors.
## Outline of the proof
The proof of `witt_structure_int_exists_unique` is rather technical, and takes up most of this file.
We start by proving the analogous version for polynomials with rational coefficients,
instead of integer coefficients.
In this case, the solution is rather easy,
since the Witt polynomials form a faithful change of coordinates
in the polynomial ring `mv_polynomial ℕ ℚ`.
We therefore obtain a family of polynomials `witt_structure_rat Φ`
for every `Φ : mv_polynomial idx ℚ`.
If `Φ` has integer coefficients, then the polynomials `witt_structure_rat Φ n` do so as well.
Proving this claim is the essential core of this file, and culminates in
`map_witt_structure_int`, which proves that upon mapping the coefficients of `witt_structure_int Φ n`
from the integers to the rationals, one obtains `witt_structure_rat Φ n`.
Ultimately, the proof of `map_witt_structure_int` relies on
```
dvd_sub_pow_of_dvd_sub {R : Type*} [comm_ring R] {p : ℕ} {a b : R} :
(p : R) ∣ a - b → ∀ (k : ℕ), (p : R) ^ (k + 1) ∣ a ^ p ^ k - b ^ p ^ k
```
## Main results
* `witt_structure_rat Φ`: the family of polynomials `ℕ → mv_polynomial (idx × ℕ) ℚ`
associated with `Φ : mv_polynomial idx ℚ` and satisfying the property explained above.
* `witt_structure_rat_prop`: the proof that `witt_structure_rat` indeed satisfies the property.
* `witt_structure_int Φ`: the family of polynomials `ℕ → mv_polynomial (idx × ℕ) ℤ`
associated with `Φ : mv_polynomial idx ℤ` and satisfying the property explained above.
* `map_witt_structure_int`: the proof that the integral polynomials `with_structure_int Φ`
are equal to `witt_structure_rat Φ` when mapped to polynomials with rational coefficients.
-/
open mv_polynomial
open set
open finset (range)
open finsupp (single)
-- This lemma reduces a bundled morphism to a "mere" function,
-- and consequently the simplifier cannot use a lot of powerful simp-lemmas.
-- We disable this locally, and probably it should be disabled globally in mathlib.
local attribute [-simp] coe_eval₂_hom
variables {p : ℕ} {R : Type*} {idx : Type*} [comm_ring R]
open_locale witt
open_locale big_operators
section p_prime
variables (p) [hp : fact p.prime]
include hp
/-- `witt_structure_rat Φ` is a family of polynomials `ℕ → mv_polynomial (idx × ℕ) ℚ`
that are uniquely characterised by the property that
`bind₁ (witt_structure_rat p Φ) (witt_polynomial p ℚ n) = bind₁ (λ i, (rename (prod.mk i) (witt_polynomial p ℚ n))) Φ`.
In other words: evaluating the `n`-th Witt polynomial on the family `witt_structure_rat Φ`
is the same as evaluating `Φ` on the (appropriately renamed) `n`-th Witt polynomials.
See `witt_structure_rat_prop` for this property,
and `witt_structure_rat_exists_unique` for the fact that `witt_structure_rat`
gives the unique family of polynomials with this property.
These polynomials turn out to have integral coefficients,
but it requires some effort to show this.
See `witt_structure_int` for the version with integral coefficients,
and `map_witt_structure_int` for the fact that it is equal to `witt_structure_rat`
when mapped to polynomials over the rationals. -/
noncomputable def witt_structure_rat (Φ : mv_polynomial idx ℚ) (n : ℕ) :
mv_polynomial (idx × ℕ) ℚ :=
bind₁ (λ k, bind₁ (λ i, rename (prod.mk i) (W_ ℚ k)) Φ) (X_in_terms_of_W p ℚ n)
theorem witt_structure_rat_prop (Φ : mv_polynomial idx ℚ) (n : ℕ) :
bind₁ (witt_structure_rat p Φ) (W_ ℚ n) =
bind₁ (λ i, (rename (prod.mk i) (W_ ℚ n))) Φ :=
calc bind₁ (witt_structure_rat p Φ) (W_ ℚ n)
= bind₁ (λ k, bind₁ (λ i, (rename (prod.mk i)) (W_ ℚ k)) Φ) (bind₁ (X_in_terms_of_W p ℚ) (W_ ℚ n)) :
by { rw bind₁_bind₁, apply eval₂_hom_congr (ring_hom.ext_rat _ _) rfl rfl }
... = bind₁ (λ i, (rename (prod.mk i) (W_ ℚ n))) Φ :
by rw [bind₁_X_in_terms_of_W_witt_polynomial p _ n, bind₁_X_right]
theorem witt_structure_rat_exists_unique (Φ : mv_polynomial idx ℚ) :
∃! (φ : ℕ → mv_polynomial (idx × ℕ) ℚ),
∀ (n : ℕ), bind₁ φ (W_ ℚ n) = bind₁ (λ i, (rename (prod.mk i) (W_ ℚ n))) Φ :=
begin
refine ⟨witt_structure_rat p Φ, _, _⟩,
{ intro n, apply witt_structure_rat_prop },
{ intros φ H,
funext n,
rw show φ n = bind₁ φ (bind₁ (W_ ℚ) (X_in_terms_of_W p ℚ n)),
{ rw [bind₁_witt_polynomial_X_in_terms_of_W p, bind₁_X_right] },
rw [bind₁_bind₁],
exact eval₂_hom_congr (ring_hom.ext_rat _ _) (funext H) rfl },
end
lemma witt_structure_rat_rec_aux (Φ : mv_polynomial idx ℚ) (n : ℕ) :
witt_structure_rat p Φ n * C (p ^ n : ℚ) =
bind₁ (λ b, rename (λ i, (b, i)) (W_ ℚ n)) Φ -
∑ i in range n, C (p ^ i : ℚ) * (witt_structure_rat p Φ i) ^ p ^ (n - i) :=
begin
have := X_in_terms_of_W_aux p ℚ n,
replace := congr_arg (bind₁ (λ k : ℕ, bind₁ (λ i, rename (prod.mk i) (W_ ℚ k)) Φ)) this,
rw [alg_hom.map_mul, bind₁_C_right] at this,
convert this, clear this,
conv_rhs { simp only [alg_hom.map_sub, bind₁_X_right] },
rw sub_right_inj,
simp only [alg_hom.map_sum, alg_hom.map_mul, bind₁_C_right, alg_hom.map_pow],
refl
end
/-- Write `witt_structure_rat p φ n` in terms of `witt_structure_rat p φ i` for `i < n`. -/
lemma witt_structure_rat_rec (Φ : mv_polynomial idx ℚ) (n : ℕ) :
(witt_structure_rat p Φ n) = C (1 / p ^ n : ℚ) *
(bind₁ (λ b, (rename (λ i, (b, i)) (W_ ℚ n))) Φ -
∑ i in range n, C (p ^ i : ℚ) * (witt_structure_rat p Φ i) ^ p ^ (n - i)) :=
begin
calc witt_structure_rat p Φ n
= C (1 / p ^ n : ℚ) * (witt_structure_rat p Φ n * C (p ^ n : ℚ)) : _
... = _ : by rw witt_structure_rat_rec_aux,
rw [mul_left_comm, ← C_mul, div_mul_cancel, C_1, mul_one],
exact pow_ne_zero _ (nat.cast_ne_zero.2 $ ne_of_gt (nat.prime.pos ‹_›)),
end
/-- `witt_structure_int Φ` is a family of polynomials `ℕ → mv_polynomial (idx × ℕ) ℚ`
that are uniquely characterised by the property that
`bind₁ (witt_structure_int p Φ) (witt_polynomial p ℚ n) = bind₁ (λ i, (rename (prod.mk i) (witt_polynomial p ℚ n))) Φ`.
In other words: evaluating the `n`-th Witt polynomial on the family `witt_structure_int Φ`
is the same as evaluating `Φ` on the (appropriately renamed) `n`-th Witt polynomials.
See `witt_structure_int_prop` for this property,
and `witt_structure_int_exists_unique` for the fact that `witt_structure_int`
gives the unique family of polynomials with this property. -/
noncomputable def witt_structure_int (Φ : mv_polynomial idx ℤ) (n : ℕ) : mv_polynomial (idx × ℕ) ℤ :=
finsupp.map_range rat.num (rat.coe_int_num 0)
(witt_structure_rat p (map (int.cast_ring_hom ℚ) Φ) n)
variable {p}
lemma bind₁_rename_expand_witt_polynomial (Φ : mv_polynomial idx ℤ) (n : ℕ)
(IH : ∀ m : ℕ, m < (n + 1) →
map (int.cast_ring_hom ℚ) (witt_structure_int p Φ m) =
witt_structure_rat p (map (int.cast_ring_hom ℚ) Φ) m) :
bind₁ (λ b, rename (λ i, (b, i)) (expand p (W_ ℤ n))) Φ =
bind₁ (λ i, expand p (witt_structure_int p Φ i)) (W_ ℤ n) :=
begin
apply mv_polynomial.map_injective (int.cast_ring_hom ℚ) int.cast_injective,
simp only [map_bind₁, map_rename, map_expand, rename_expand, map_witt_polynomial],
have key := (witt_structure_rat_prop p (map (int.cast_ring_hom ℚ) Φ) n).symm,
apply_fun expand p at key,
simp only [expand_bind₁] at key,
rw key, clear key,
apply eval₂_hom_congr' rfl _ rfl,
rintro i hi -,
rw [witt_polynomial_vars, finset.mem_range] at hi,
simp only [IH i hi],
end
lemma C_p_pow_dvd_bind₁_rename_witt_polynomial_sub_sum (Φ : mv_polynomial idx ℤ) (n : ℕ)
(IH : ∀ m : ℕ, m < n →
map (int.cast_ring_hom ℚ) (witt_structure_int p Φ m) =
witt_structure_rat p (map (int.cast_ring_hom ℚ) Φ) m) :
C ↑(p ^ n) ∣
(bind₁ (λ (b : idx), rename (λ i, (b, i)) (witt_polynomial p ℤ n)) Φ -
∑ i in range n, C (↑p ^ i) * witt_structure_int p Φ i ^ p ^ (n - i)) :=
begin
cases n,
{ simp only [is_unit_one, int.coe_nat_zero, int.coe_nat_succ, zero_add, pow_zero, C_1, is_unit.dvd] },
-- prepare a useful equation for rewriting
have key := bind₁_rename_expand_witt_polynomial Φ n IH,
apply_fun (map (int.cast_ring_hom (zmod (p ^ (n + 1))))) at key,
conv_lhs at key { simp only [map_bind₁, map_rename, map_expand, map_witt_polynomial] },
-- clean up and massage
rw [nat.succ_eq_add_one, C_dvd_iff_zmod, ring_hom.map_sub, sub_eq_zero, map_bind₁],
simp only [map_rename, map_witt_polynomial, witt_polynomial_zmod_self],
rw key, clear key IH,
rw [bind₁, aeval_witt_polynomial, ring_hom.map_sum, ring_hom.map_sum, finset.sum_congr rfl],
intros k hk,
rw finset.mem_range at hk,
simp only [← sub_eq_zero, ← ring_hom.map_sub, ← C_dvd_iff_zmod, C_eq_coe_nat, ← mul_sub,
← int.nat_cast_eq_coe_nat, ← nat.cast_pow],
rw show p ^ (n + 1) = p ^ k * p ^ (n - k + 1),
{ rw ← pow_add, congr' 1, omega },
rw [nat.cast_mul, nat.cast_pow, nat.cast_pow],
apply mul_dvd_mul_left,
rw show p ^ (n + 1 - k) = p * p ^ (n - k),
{ rw ← pow_succ, congr' 1, omega },
rw [pow_mul],
-- the machine!
apply dvd_sub_pow_of_dvd_sub,
rw [← C_eq_coe_nat, int.nat_cast_eq_coe_nat, C_dvd_iff_zmod, ring_hom.map_sub,
sub_eq_zero, map_expand, ring_hom.map_pow, mv_polynomial.expand_zmod],
end
variables (p)
@[simp] lemma map_witt_structure_int (Φ : mv_polynomial idx ℤ) (n : ℕ) :
map (int.cast_ring_hom ℚ) (witt_structure_int p Φ n) =
witt_structure_rat p (map (int.cast_ring_hom ℚ) Φ) n :=
begin
apply nat.strong_induction_on n, clear n,
intros n IH,
rw [witt_structure_int, map_map_range_eq_iff, int.coe_cast_ring_hom],
intro c,
rw [witt_structure_rat_rec, coeff_C_mul, mul_comm, mul_div_assoc', mul_one],
have sum_induction_steps : map (int.cast_ring_hom ℚ)
(∑ i in range n, C (p ^ i : ℤ) *
(witt_structure_int p Φ i) ^ p ^ (n - i)) =
∑ i in range n, C (p ^ i : ℚ) *
(witt_structure_rat p (map (int.cast_ring_hom ℚ) Φ) i) ^ p ^ (n - i),
{ rw [ring_hom.map_sum],
apply finset.sum_congr rfl,
intros i hi,
rw finset.mem_range at hi,
simp only [IH i hi, ring_hom.map_mul, ring_hom.map_pow, map_C],
refl },
simp only [← sum_induction_steps, ← map_witt_polynomial p (int.cast_ring_hom ℚ),
← map_rename, ← map_bind₁, ← ring_hom.map_sub, coeff_map],
rw show (p : ℚ)^n = ((p^n : ℕ) : ℤ), by norm_cast,
rw [← rat.denom_eq_one_iff, ring_hom.eq_int_cast, rat.denom_div_cast_eq_one_iff],
swap, { exact_mod_cast pow_ne_zero n hp.ne_zero },
revert c, rw [← C_dvd_iff_dvd_coeff],
exact C_p_pow_dvd_bind₁_rename_witt_polynomial_sub_sum Φ n IH,
end
/-
TODO: in a follow-up PR, we deduce `witt_structure_int_prop` from `witt_structure_rat_prop`
using `map_witt_structure_int` (easy, 5 lines) and some other properties.
-/
end p_prime
|
f2e80c2b283e7f00f6f104daf61f9e97587b845a | 7c2dd01406c42053207061adb11703dc7ce0b5e5 | /src/solutions/01_equality_rewriting.lean | fe3d9847fad923381953fd1aa0968cd156fc2cdb | [
"Apache-2.0"
] | permissive | leanprover-community/tutorials | 50ec79564cbf2ad1afd1ac43d8ee3c592c2883a8 | 79a6872a755c4ae0c2aca57e1adfdac38b1d8bb1 | refs/heads/master | 1,687,466,144,386 | 1,672,061,276,000 | 1,672,061,276,000 | 189,169,918 | 186 | 81 | Apache-2.0 | 1,686,350,300,000 | 1,559,113,678,000 | Lean | UTF-8 | Lean | false | false | 5,718 | lean | import data.real.basic
/-
One of the earliest kind of proofs one encounters while learning mathematics is proving by
a calculation. It may not sound like a proof, but this is actually using lemmas expressing
properties of operations on numbers. It also uses the fundamental property of equality: if two
mathematical objects A and B are equal then, in any statement involving A, one can replace A
by B. This operation is called rewriting, and the Lean "tactic" for this is `rw`.
In the following exercises, we will use the following two lemmas:
mul_assoc a b c : a * b * c = a * (b * c)
mul_comm a b : a*b = b*a
Hence the command
rw mul_assoc a b c,
will replace a*b*c by a*(b*c) in the current goal.
In order to replace backward, we use
rw ← mul_assoc a b c,
replacing a*(b*c) by a*b*c in the current goal.
Of course we don't want to constantly invoke those lemmas, and we will eventually introduce
more powerful solutions.
-/
-- Uncomment the following line if you want to see parentheses around subexpressions.
-- set_option pp.parens true
example (a b c : ℝ) : (a * b) * c = b * (a * c) :=
begin
rw mul_comm a b,
rw mul_assoc b a c,
end
-- 0001
example (a b c : ℝ) : (c * b) * a = b * (a * c) :=
begin
-- sorry
rw mul_comm c b,
rw mul_assoc b c a,
rw mul_comm c a,
-- sorry
end
-- 0002
example (a b c : ℝ) : a * (b * c) = b * (a * c) :=
begin
-- sorry
rw ← mul_assoc a b c,
rw mul_comm a b,
rw mul_assoc b a c,
-- sorry
end
/-
Now let's return to the preceding example to experiment with what happens
if we don't give arguments to mul_assoc or mul_comm.
For instance, you can start the next proof with
rw ← mul_assoc,
Try to figure out what happens.
-/
-- 0003
example (a b c : ℝ) : a * (b * c) = b * (a * c) :=
begin
-- sorry
rw ← mul_assoc,
-- "rw mul_comm," doesn't do what we want.
rw mul_comm a b,
rw mul_assoc,
-- sorry
end
/-
We can also perform rewriting in an assumption of the local context, using for instance
rw mul_comm a b at hyp,
in order to replace a*b by b*a in assumption hyp.
The next example will use a third lemma:
two_mul a : 2*a = a + a
Also we use the `exact` tactic, which allows to provide a direct proof term.
-/
example (a b c d : ℝ) (hyp : c = d*a + b) (hyp' : b = a*d) : c = 2*a*d :=
begin
rw hyp' at hyp,
rw mul_comm d a at hyp,
rw ← two_mul (a*d) at hyp,
rw ← mul_assoc 2 a d at hyp,
exact hyp, -- Our assumption hyp is now exactly what we have to prove
end
/-
And the next one can use:
sub_self x : x - x = 0
-/
-- 0004
example (a b c d : ℝ) (hyp : c = b*a - d) (hyp' : d = a*b) : c = 0 :=
begin
-- sorry
rw hyp' at hyp,
rw mul_comm b a at hyp,
rw sub_self (a*b) at hyp,
exact hyp,
-- sorry
end
/-
What is written in the two preceding example is very far away from what we would write on
paper. Let's now see how to get a more natural layout.
Inside each pair of curly braces below, the goal is to prove equality with the preceding line.
-/
example (a b c d : ℝ) (hyp : c = d*a + b) (hyp' : b = a*d) : c = 2*a*d :=
begin
calc c = d*a + b : by { rw hyp }
... = d*a + a*d : by { rw hyp' }
... = a*d + a*d : by { rw mul_comm d a }
... = 2*(a*d) : by { rw two_mul }
... = 2*a*d : by { rw mul_assoc },
end
/-
Let's note there is no comma at the end of each line of calculation. `calc` is really one
command, and the comma comes only after it's fully done.
From a practical point of view, when writing such a proof, it is convenient to:
* pause the tactic state view update in VScode by clicking the Pause icon button
in the top right corner of the Lean Goal buffer
* write the full calculation, ending each line with ": by {}"
* resume tactic state update by clicking the Play icon button and fill in proofs between
curly braces.
Let's return to the other example using this method.
-/
-- 0005
example (a b c d : ℝ) (hyp : c = b*a - d) (hyp' : d = a*b) : c = 0 :=
begin
-- sorry
calc c = b*a - d : by { rw hyp }
... = b*a - a*b : by { rw hyp' }
... = a*b - a*b : by { rw mul_comm a b }
... = 0 : by { rw sub_self (a*b) },
-- sorry
end
/-
The preceding proofs have exhausted our supply of "mul_comm" patience. Now it's time
to get the computer to work harder. The `ring` tactic will prove any goal that follows by
applying only the axioms of commutative (semi-)rings, in particular commutativity and
associativity of addition and multiplication, as well as distributivity.
We also note that curly braces are not necessary when we write a single tactic proof, so
let's get rid of them.
-/
example (a b c d : ℝ) (hyp : c = d*a + b) (hyp' : b = a*d) : c = 2*a*d :=
begin
calc c = d*a + b : by rw hyp
... = d*a + a*d : by rw hyp'
... = 2*a*d : by ring,
end
/-
Of course we can use `ring` outside of `calc`. Let's do the next one in one line.
-/
-- 0006
example (a b c : ℝ) : a * (b * c) = b * (a * c) :=
begin
-- sorry
ring,
-- sorry
end
/-
This is too much fun. Let's do it again.
-/
-- 0007
example (a b : ℝ) : (a + b) + a = 2*a + b :=
begin
-- sorry
ring,
-- sorry
end
/-
Maybe this is cheating. Let's try to do the next computation without ring.
We could use:
pow_two x : x^2 = x*x
mul_sub a b c : a*(b-c) = a*b - a*c
add_mul a b c : (a+b)*c = a*c + b*c
add_sub a b c : a + (b - c) = (a + b) - c
sub_sub a b c : a - b - c = a - (b + c)
add_zero a : a + 0 = a
-/
-- 0008
example (a b : ℝ) : (a + b)*(a - b) = a^2 - b^2 :=
begin
-- sorry
rw pow_two a,
rw pow_two b,
rw mul_sub (a+b) a b,
rw add_mul a b a,
rw add_mul a b b,
rw mul_comm b a,
rw ← sub_sub,
rw ← add_sub,
rw sub_self,
rw add_zero,
-- sorry
end
/- Let's stick to ring in the end. -/
|
9b742d4a33f5627f1ae10c02dadf1d0436dbbc52 | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/number_theory/kummer_dedekind.lean | 789eb779ba26447fd8a890fe57218441659e658f | [
"Apache-2.0"
] | permissive | jcommelin/mathlib | d8456447c36c176e14d96d9e76f39841f69d2d9b | ee8279351a2e434c2852345c51b728d22af5a156 | refs/heads/master | 1,664,782,136,488 | 1,663,638,983,000 | 1,663,638,983,000 | 132,563,656 | 0 | 0 | Apache-2.0 | 1,663,599,929,000 | 1,525,760,539,000 | Lean | UTF-8 | Lean | false | false | 8,343 | lean | /-
Copyright (c) 2021 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Paul Lezeau
-/
import ring_theory.adjoin_root
import ring_theory.dedekind_domain.ideal
import ring_theory.algebra_tower
/-!
# Kummer-Dedekind theorem
This file proves the monogenic version of the Kummer-Dedekind theorem on the splitting of prime
ideals in an extension of the ring of integers. This states that if `I` is a prime ideal of
Dedekind domain `R` and `S = R[α]` for some `α` that is integral over `R` with minimal polynomial
`f`, then the prime factorisations of `I * S` and `f mod I` have the same shape, i.e. they have the
same number of prime factors, and each prime factors of `I * S` can be paired with a prime factor
of `f mod I` in a way that ensures multiplicities match (in fact, this pairing can be made explicit
with a formula).
## Main definitions
* `normalized_factors_map_equiv_normalized_factors_min_poly_mk` : The bijection in the
Kummer-Dedekind theorem. This is the pairing between the prime factors of `I * S` and the prime
factors of `f mod I`.
## Main results
* `normalized_factors_ideal_map_eq_normalized_factors_min_poly_mk_map` : The Kummer-Dedekind
theorem.
* `ideal.irreducible_map_of_irreducible_minpoly` : `I.map (algebra_map R S)` is irreducible if
`(map I^.quotient.mk (minpoly R pb.gen))` is irreducible, where `pb` is a power basis of `S`
over `R`.
## TODO
* Define the conductor ideal and prove the Kummer-Dedekind theorem in full generality.
* Prove the converse of `ideal.irreducible_map_of_irreducible_minpoly`.
* Prove that `normalized_factors_map_equiv_normalized_factors_min_poly_mk` can be expressed as
`normalized_factors_map_equiv_normalized_factors_min_poly_mk g = ⟨I, G(α)⟩` for `g` a prime
factor of `f mod I` and `G` a lift of `g` to `R[X]`.
## References
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
kummer, dedekind, kummer dedekind, dedekind-kummer, dedekind kummer
-/
namespace kummer_dedekind
open_locale big_operators polynomial classical
open ideal polynomial double_quot unique_factorization_monoid
variables {R : Type*} [comm_ring R]
variables {S : Type*} [comm_ring S] [is_domain S] [is_dedekind_domain S] [algebra R S]
variables (pb : power_basis R S) {I : ideal R}
local attribute [instance] ideal.quotient.field
variables [is_domain R]
/-- The first half of the **Kummer-Dedekind Theorem** in the monogenic case, stating that the prime
factors of `I*S` are in bijection with those of the minimal polynomial of the generator of `S`
over `R`, taken `mod I`.-/
noncomputable def normalized_factors_map_equiv_normalized_factors_min_poly_mk (hI : is_maximal I)
(hI' : I ≠ ⊥) : {J : ideal S | J ∈ normalized_factors (I.map (algebra_map R S) )} ≃
{d : (R ⧸ I)[X] | d ∈ normalized_factors (map I^.quotient.mk (minpoly R pb.gen)) } :=
((normalized_factors_equiv_of_quot_equiv ↑(pb.quotient_equiv_quotient_minpoly_map I)
--show that `I * S` ≠ ⊥
(show I.map (algebra_map R S) ≠ ⊥,
by rwa [ne.def, map_eq_bot_iff_of_injective pb.basis.algebra_map_injective, ← ne.def])
--show that the ideal spanned by `(minpoly R pb.gen) mod I` is non-zero
(by {by_contra, exact (show (map I^.quotient.mk (minpoly R pb.gen) ≠ 0), from
polynomial.map_monic_ne_zero (minpoly.monic pb.is_integral_gen))
(span_singleton_eq_bot.mp h) } )).trans
(normalized_factors_equiv_span_normalized_factors
(show (map I^.quotient.mk (minpoly R pb.gen)) ≠ 0, from
polynomial.map_monic_ne_zero (minpoly.monic pb.is_integral_gen))).symm)
/-- The second half of the **Kummer-Dedekind Theorem** in the monogenic case, stating that the
bijection `factors_equiv'` defined in the first half preserves multiplicities. -/
theorem multiplicity_factors_map_eq_multiplicity (hI : is_maximal I) (hI' : I ≠ ⊥) {J : ideal S}
(hJ : J ∈ normalized_factors (I.map (algebra_map R S))) :
multiplicity J (I.map (algebra_map R S)) =
multiplicity ↑(normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI' ⟨J, hJ⟩)
(map I^.quotient.mk (minpoly R pb.gen)) :=
by rw [normalized_factors_map_equiv_normalized_factors_min_poly_mk, equiv.coe_trans,
function.comp_app,
multiplicity_normalized_factors_equiv_span_normalized_factors_symm_eq_multiplicity,
normalized_factors_equiv_of_quot_equiv_multiplicity_eq_multiplicity]
/-- The **Kummer-Dedekind Theorem**. -/
theorem normalized_factors_ideal_map_eq_normalized_factors_min_poly_mk_map (hI : is_maximal I)
(hI' : I ≠ ⊥) : normalized_factors (I.map (algebra_map R S)) = multiset.map
(λ f, ((normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI').symm f : ideal S))
(normalized_factors (polynomial.map I^.quotient.mk (minpoly R pb.gen))).attach :=
begin
ext J,
-- WLOG, assume J is a normalized factor
by_cases hJ : J ∈ normalized_factors (I.map (algebra_map R S)), swap,
{ rw [multiset.count_eq_zero.mpr hJ, eq_comm, multiset.count_eq_zero, multiset.mem_map],
simp only [multiset.mem_attach, true_and, not_exists],
rintros J' rfl,
exact hJ
((normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI').symm J').prop },
-- Then we just have to compare the multiplicities, which we already proved are equal.
have := multiplicity_factors_map_eq_multiplicity pb hI hI' hJ,
rw [multiplicity_eq_count_normalized_factors, multiplicity_eq_count_normalized_factors,
unique_factorization_monoid.normalize_normalized_factor _ hJ,
unique_factorization_monoid.normalize_normalized_factor,
part_enat.coe_inj]
at this,
refine this.trans _,
-- Get rid of the `map` by applying the equiv to both sides.
generalize hJ' : (normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI')
⟨J, hJ⟩ = J',
have : ((normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI').symm
J' : ideal S) = J,
{ rw [← hJ', equiv.symm_apply_apply _ _, subtype.coe_mk] },
subst this,
-- Get rid of the `attach` by applying the subtype `coe` to both sides.
rw [multiset.count_map_eq_count' (λ f,
((normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI').symm f
: ideal S)),
multiset.attach_count_eq_count_coe],
{ exact subtype.coe_injective.comp (equiv.injective _) },
{ exact (normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI' _).prop },
{ exact irreducible_of_normalized_factor _
(normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI' _).prop },
{ exact polynomial.map_monic_ne_zero (minpoly.monic pb.is_integral_gen) },
{ exact irreducible_of_normalized_factor _ hJ },
{ rwa [← bot_eq_zero, ne.def, map_eq_bot_iff_of_injective pb.basis.algebra_map_injective] },
end
theorem ideal.irreducible_map_of_irreducible_minpoly (hI : is_maximal I) (hI' : I ≠ ⊥)
(hf : irreducible (map I^.quotient.mk (minpoly R pb.gen))) :
irreducible (I.map (algebra_map R S)) :=
begin
have mem_norm_factors : normalize (map I^.quotient.mk (minpoly R pb.gen)) ∈ normalized_factors
(map I^.quotient.mk (minpoly R pb.gen)) := by simp [normalized_factors_irreducible hf],
suffices : ∃ x, normalized_factors (I.map (algebra_map R S)) = {x},
{ obtain ⟨x, hx⟩ := this,
have h := normalized_factors_prod (show I.map (algebra_map R S) ≠ 0, by
rwa [← bot_eq_zero, ne.def, map_eq_bot_iff_of_injective pb.basis.algebra_map_injective]),
rw [associated_iff_eq, hx, multiset.prod_singleton] at h,
rw ← h,
exact irreducible_of_normalized_factor x
(show x ∈ normalized_factors (I.map (algebra_map R S)), by simp [hx]) },
rw normalized_factors_ideal_map_eq_normalized_factors_min_poly_mk_map pb hI hI',
use ((normalized_factors_map_equiv_normalized_factors_min_poly_mk pb hI hI').symm
⟨normalize (map I^.quotient.mk (minpoly R pb.gen)), mem_norm_factors⟩ : ideal S),
rw multiset.map_eq_singleton,
use ⟨normalize (map I^.quotient.mk (minpoly R pb.gen)), mem_norm_factors⟩,
refine ⟨_, rfl⟩,
apply multiset.map_injective subtype.coe_injective,
rw [multiset.attach_map_coe, multiset.map_singleton, subtype.coe_mk],
exact normalized_factors_irreducible hf
end
end kummer_dedekind
|
f442e0d95bd8a27f3374407c9725eafc249b3449 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/algebra/field/opposite.lean | bb6e07c2a8747d0552ae645eed3c5622fa1b66ab | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 2,115 | lean | /-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import algebra.field.defs
import algebra.ring.opposite
import data.int.cast.lemmas
/-!
# Field structure on the multiplicative/additive opposite
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
-/
variables (α : Type*)
namespace mul_opposite
@[to_additive] instance [has_rat_cast α] : has_rat_cast αᵐᵒᵖ := ⟨λ n, op n⟩
variables {α}
@[simp, norm_cast, to_additive]
lemma op_rat_cast [has_rat_cast α] (q : ℚ) : op (q : α) = q := rfl
@[simp, norm_cast, to_additive]
lemma unop_rat_cast [has_rat_cast α] (q : ℚ) : unop (q : αᵐᵒᵖ) = q := rfl
variables (α)
instance [division_semiring α] : division_semiring αᵐᵒᵖ :=
{ .. mul_opposite.group_with_zero α, .. mul_opposite.semiring α }
instance [division_ring α] : division_ring αᵐᵒᵖ :=
{ rat_cast := λ q, op q,
rat_cast_mk := λ a b hb h, by { rw [rat.cast_def, op_div, op_nat_cast, op_int_cast],
exact int.commute_cast _ _ },
..mul_opposite.division_semiring α, ..mul_opposite.ring α }
instance [semifield α] : semifield αᵐᵒᵖ :=
{ .. mul_opposite.division_semiring α, .. mul_opposite.comm_semiring α }
instance [field α] : field αᵐᵒᵖ :=
{ .. mul_opposite.division_ring α, .. mul_opposite.comm_ring α }
end mul_opposite
namespace add_opposite
instance [division_semiring α] : division_semiring αᵃᵒᵖ :=
{ ..add_opposite.group_with_zero α, ..add_opposite.semiring α }
instance [division_ring α] : division_ring αᵃᵒᵖ :=
{ rat_cast_mk := λ a b hb h, by rw ←div_eq_mul_inv; exact congr_arg op (rat.cast_def _),
..add_opposite.ring α, ..add_opposite.group_with_zero α, ..add_opposite.has_rat_cast α }
instance [semifield α] : semifield αᵃᵒᵖ :=
{ ..add_opposite.division_semiring α, ..add_opposite.comm_semiring α }
instance [field α] : field αᵃᵒᵖ :=
{ ..add_opposite.division_ring α, ..add_opposite.comm_ring α }
end add_opposite
|
891fe08ae09c2d18b869e102f2a606993aa6b6ea | 432d948a4d3d242fdfb44b81c9e1b1baacd58617 | /src/algebra/group/pi.lean | 6dab665c91e740178b9d5efd7a5bd7c6ad5fdb29 | [
"Apache-2.0"
] | permissive | JLimperg/aesop3 | 306cc6570c556568897ed2e508c8869667252e8a | a4a116f650cc7403428e72bd2e2c4cda300fe03f | refs/heads/master | 1,682,884,916,368 | 1,620,320,033,000 | 1,620,320,033,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 9,124 | lean | /-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon, Patrick Massot
-/
import data.pi
import data.set.function
import tactic.pi_instances
import algebra.group.hom_instances
/-!
# Pi instances for groups and monoids
This file defines instances for group, monoid, semigroup and related structures on Pi types.
-/
universes u v w
variable {I : Type u} -- The indexing type
variable {f : I → Type v} -- The family of types already equipped with instances
variables (x y : Π i, f i) (i : I)
namespace pi
@[to_additive]
instance semigroup [∀ i, semigroup $ f i] : semigroup (Π i : I, f i) :=
by refine_struct { mul := (*), .. }; tactic.pi_instance_derive_field
instance semigroup_with_zero [∀ i, semigroup_with_zero $ f i] :
semigroup_with_zero (Π i : I, f i) :=
by refine_struct { zero := (0 : Π i, f i), mul := (*), .. }; tactic.pi_instance_derive_field
@[to_additive]
instance comm_semigroup [∀ i, comm_semigroup $ f i] : comm_semigroup (Π i : I, f i) :=
by refine_struct { mul := (*), .. }; tactic.pi_instance_derive_field
@[to_additive]
instance mul_one_class [∀ i, mul_one_class $ f i] : mul_one_class (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), .. }; tactic.pi_instance_derive_field
@[to_additive]
instance monoid [∀ i, monoid $ f i] : monoid (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), npow := λ n x i, npow n (x i) };
tactic.pi_instance_derive_field
@[simp]
lemma pow_apply [∀ i, monoid $ f i] (n : ℕ) : (x^n) i = (x i)^n :=
begin
induction n with n ih,
{ simp, },
{ simp [pow_succ, ih], },
end
@[to_additive]
instance comm_monoid [∀ i, comm_monoid $ f i] : comm_monoid (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), npow := λ n x i, npow n (x i) };
tactic.pi_instance_derive_field
@[to_additive]
instance div_inv_monoid [∀ i, div_inv_monoid $ f i] :
div_inv_monoid (Π i : I, f i) :=
{ div_eq_mul_inv := λ x y, funext (λ i, div_eq_mul_inv (x i) (y i)),
.. pi.monoid, .. pi.has_div, .. pi.has_inv }
@[to_additive]
instance group [∀ i, group $ f i] : group (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), inv := has_inv.inv, div := has_div.div,
npow := λ n x i, npow n (x i), gpow := λ n x i, gpow n (x i) }; tactic.pi_instance_derive_field
@[to_additive]
instance comm_group [∀ i, comm_group $ f i] : comm_group (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), inv := has_inv.inv, div := has_div.div,
npow := λ n x i, npow n (x i), gpow := λ n x i, gpow n (x i) }; tactic.pi_instance_derive_field
@[to_additive add_left_cancel_semigroup]
instance left_cancel_semigroup [∀ i, left_cancel_semigroup $ f i] :
left_cancel_semigroup (Π i : I, f i) :=
by refine_struct { mul := (*) }; tactic.pi_instance_derive_field
@[to_additive add_right_cancel_semigroup]
instance right_cancel_semigroup [∀ i, right_cancel_semigroup $ f i] :
right_cancel_semigroup (Π i : I, f i) :=
by refine_struct { mul := (*) }; tactic.pi_instance_derive_field
@[to_additive add_left_cancel_monoid]
instance left_cancel_monoid [∀ i, left_cancel_monoid $ f i] :
left_cancel_monoid (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), npow := λ n x i, npow n (x i) };
tactic.pi_instance_derive_field
@[to_additive add_right_cancel_monoid]
instance right_cancel_monoid [∀ i, right_cancel_monoid $ f i] :
right_cancel_monoid (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), npow := λ n x i, npow n (x i), .. };
tactic.pi_instance_derive_field
@[to_additive add_cancel_monoid]
instance cancel_monoid [∀ i, cancel_monoid $ f i] :
cancel_monoid (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), npow := λ n x i, npow n (x i) };
tactic.pi_instance_derive_field
@[to_additive add_cancel_comm_monoid]
instance cancel_comm_monoid [∀ i, cancel_comm_monoid $ f i] :
cancel_comm_monoid (Π i : I, f i) :=
by refine_struct { one := (1 : Π i, f i), mul := (*), npow := λ n x i, npow n (x i) };
tactic.pi_instance_derive_field
instance mul_zero_class [∀ i, mul_zero_class $ f i] :
mul_zero_class (Π i : I, f i) :=
by refine_struct { zero := (0 : Π i, f i), mul := (*), .. }; tactic.pi_instance_derive_field
instance mul_zero_one_class [∀ i, mul_zero_one_class $ f i] :
mul_zero_one_class (Π i : I, f i) :=
by refine_struct { zero := (0 : Π i, f i), one := (1 : Π i, f i), mul := (*), .. };
tactic.pi_instance_derive_field
instance monoid_with_zero [∀ i, monoid_with_zero $ f i] :
monoid_with_zero (Π i : I, f i) :=
by refine_struct { zero := (0 : Π i, f i), one := (1 : Π i, f i), mul := (*),
npow := λ n x i, npow n (x i) }; tactic.pi_instance_derive_field
instance comm_monoid_with_zero [∀ i, comm_monoid_with_zero $ f i] :
comm_monoid_with_zero (Π i : I, f i) :=
by refine_struct { zero := (0 : Π i, f i), one := (1 : Π i, f i), mul := (*),
npow := λ n x i, npow n (x i) }; tactic.pi_instance_derive_field
section instance_lemmas
open function
variables {α β γ : Type*}
@[simp, to_additive] lemma const_one [has_one β] : const α (1 : β) = 1 := rfl
@[simp, to_additive] lemma comp_one [has_one β] {f : β → γ} : f ∘ 1 = const α (f 1) := rfl
@[simp, to_additive] lemma one_comp [has_one γ] {f : α → β} : (1 : β → γ) ∘ f = 1 := rfl
end instance_lemmas
end pi
section monoid_hom
variables (f) [Π i, mul_one_class (f i)]
/-- Evaluation of functions into an indexed collection of monoids at a point is a monoid
homomorphism. -/
@[to_additive "Evaluation of functions into an indexed collection of additive monoids at a point
is an additive monoid homomorphism."]
def monoid_hom.apply (i : I) : (Π i, f i) →* f i :=
{ to_fun := λ g, g i,
map_one' := rfl,
map_mul' := λ x y, rfl, }
@[simp, to_additive]
lemma monoid_hom.apply_apply (i : I) (g : Π i, f i) :
(monoid_hom.apply f i) g = g i := rfl
/-- Coercion of a `monoid_hom` into a function is itself a `monoid_hom`.
See also `monoid_hom.eval`. -/
@[to_additive "Coercion of an `add_monoid_hom` into a function is itself a `add_monoid_hom`.
See also `add_monoid_hom.eval`. ", simps]
def monoid_hom.coe_fn (α β : Type*) [mul_one_class α] [comm_monoid β] : (α →* β) →* (α → β) :=
{ to_fun := λ g, g,
map_one' := rfl,
map_mul' := λ x y, rfl, }
end monoid_hom
section single
variables [decidable_eq I]
open pi
variables (f)
/-- The zero-preserving homomorphism including a single value
into a dependent family of values, as functions supported at a point.
This is the `zero_hom` version of `pi.single`. -/
@[simps] def zero_hom.single [Π i, has_zero $ f i] (i : I) : zero_hom (f i) (Π i, f i) :=
{ to_fun := single i,
map_zero' := single_zero i }
/-- The additive monoid homomorphism including a single additive monoid
into a dependent family of additive monoids, as functions supported at a point.
This is the `add_monoid_hom` version of `pi.single`. -/
@[simps] def add_monoid_hom.single [Π i, add_zero_class $ f i] (i : I) : f i →+ Π i, f i :=
{ to_fun := single i,
map_add' := single_op₂ (λ _, (+)) (λ _, zero_add _) _,
.. (zero_hom.single f i) }
/-- The multiplicative homomorphism including a single `mul_zero_class`
into a dependent family of `mul_zero_class`es, as functions supported at a point.
This is the `mul_hom` version of `pi.single`. -/
@[simps] def mul_hom.single [Π i, mul_zero_class $ f i] (i : I) : mul_hom (f i) (Π i, f i) :=
{ to_fun := single i,
map_mul' := single_op₂ (λ _, (*)) (λ _, zero_mul _) _, }
variables {f}
lemma pi.single_add [Π i, add_zero_class $ f i] (i : I) (x y : f i) :
single i (x + y) = single i x + single i y :=
(add_monoid_hom.single f i).map_add x y
lemma pi.single_neg [Π i, add_group $ f i] (i : I) (x : f i) :
single i (-x) = -single i x :=
(add_monoid_hom.single f i).map_neg x
lemma pi.single_sub [Π i, add_group $ f i] (i : I) (x y : f i) :
single i (x - y) = single i x - single i y :=
(add_monoid_hom.single f i).map_sub x y
lemma pi.single_mul [Π i, mul_zero_class $ f i] (i : I) (x y : f i) :
single i (x * y) = single i x * single i y :=
(mul_hom.single f i).map_mul x y
end single
section piecewise
@[to_additive]
lemma set.piecewise_mul [Π i, has_mul (f i)] (s : set I) [Π i, decidable (i ∈ s)]
(f₁ f₂ g₁ g₂ : Π i, f i) :
s.piecewise (f₁ * f₂) (g₁ * g₂) = s.piecewise f₁ g₁ * s.piecewise f₂ g₂ :=
s.piecewise_op₂ _ _ _ _ (λ _, (*))
@[to_additive]
lemma pi.piecewise_inv [Π i, has_inv (f i)] (s : set I) [Π i, decidable (i ∈ s)]
(f₁ g₁ : Π i, f i) :
s.piecewise (f₁⁻¹) (g₁⁻¹) = (s.piecewise f₁ g₁)⁻¹ :=
s.piecewise_op f₁ g₁ (λ _ x, x⁻¹)
@[to_additive]
lemma pi.piecewise_div [Π i, has_div (f i)] (s : set I) [Π i, decidable (i ∈ s)]
(f₁ f₂ g₁ g₂ : Π i, f i) :
s.piecewise (f₁ / f₂) (g₁ / g₂) = s.piecewise f₁ g₁ / s.piecewise f₂ g₂ :=
s.piecewise_op₂ _ _ _ _ (λ _, (/))
end piecewise
|
d5cc1f90906ed76e044a48806d33f7fe1c071896 | 9dd3f3912f7321eb58ee9aa8f21778ad6221f87c | /tests/lean/error_pos.lean | 9b01dda21a20b1df45f392823d39ce8db69f53f7 | [
"Apache-2.0"
] | permissive | bre7k30/lean | de893411bcfa7b3c5572e61b9e1c52951b310aa4 | 5a924699d076dab1bd5af23a8f910b433e598d7a | refs/heads/master | 1,610,900,145,817 | 1,488,006,845,000 | 1,488,006,845,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 488 | lean | example (A : Type) (B : A → Type) (b : B) : true :=
trivial
example : ∀ (A : Type) (B : A → Type) (b : B), true :=
begin
intros, trivial
end
check λ (A : Type) (B : A → Type) (b : B), true
check λ (A : Type) (B : A → Type), B → true
check λ (A : Type) (B : A → Type) b, (b : B)
example {A : Type} {B : Type} {a₁ a₂ : B} {b₁ b₂ : A → B} : a₁ = a₂ → (∀ x, b₁ x = b₂ x) → (let x : A := a₁ in b₁ x) = (let x : A := a₂ in b₂ x) :=
sorry
|
832915814fe86c2e39e4db647268193dd4ae3907 | 55c7fc2bf55d496ace18cd6f3376e12bb14c8cc5 | /src/topology/metric_space/hausdorff_distance.lean | bcf14501d29fc81f162b06bd8f53a5cac05e0ac9 | [
"Apache-2.0"
] | permissive | dupuisf/mathlib | 62de4ec6544bf3b79086afd27b6529acfaf2c1bb | 8582b06b0a5d06c33ee07d0bdf7c646cae22cf36 | refs/heads/master | 1,669,494,854,016 | 1,595,692,409,000 | 1,595,692,409,000 | 272,046,630 | 0 | 0 | Apache-2.0 | 1,592,066,143,000 | 1,592,066,142,000 | null | UTF-8 | Lean | false | false | 32,345 | lean | /-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Sébastien Gouëzel
-/
import topology.metric_space.isometry
import topology.instances.ennreal
/-!
# Hausdorff distance
The Hausdorff distance on subsets of a metric (or emetric) space.
Given two subsets `s` and `t` of a metric space, their Hausdorff distance is the smallest `d`
such that any point `s` is within `d` of a point in `t`, and conversely. This quantity
is often infinite (think of `s` bounded and `t` unbounded), and therefore better
expressed in the setting of emetric spaces.
## Main definitions
This files introduces:
* `inf_edist x s`, the infimum edistance of a point `x` to a set `s` in an emetric space
* `Hausdorff_edist s t`, the Hausdorff edistance of two sets in an emetric space
* Versions of these notions on metric spaces, called respectively `inf_dist` and
`Hausdorff_dist`.
-/
noncomputable theory
open_locale classical
universes u v w
open classical set function topological_space filter
namespace emetric
section inf_edist
open_locale ennreal
variables {α : Type u} {β : Type v} [emetric_space α] [emetric_space β] {x y : α} {s t : set α} {Φ : α → β}
/-- The minimal edistance of a point to a set -/
def inf_edist (x : α) (s : set α) : ennreal := Inf ((edist x) '' s)
@[simp] lemma inf_edist_empty : inf_edist x ∅ = ∞ :=
by unfold inf_edist; simp
/-- The edist to a union is the minimum of the edists -/
@[simp] lemma inf_edist_union : inf_edist x (s ∪ t) = inf_edist x s ⊓ inf_edist x t :=
by simp [inf_edist, image_union, Inf_union]
/-- The edist to a singleton is the edistance to the single point of this singleton -/
@[simp] lemma inf_edist_singleton : inf_edist x {y} = edist x y :=
by simp [inf_edist]
/-- The edist to a set is bounded above by the edist to any of its points -/
lemma inf_edist_le_edist_of_mem (h : y ∈ s) : inf_edist x s ≤ edist x y :=
Inf_le ((mem_image _ _ _).2 ⟨y, h, by refl⟩)
/-- If a point `x` belongs to `s`, then its edist to `s` vanishes -/
lemma inf_edist_zero_of_mem (h : x ∈ s) : inf_edist x s = 0 :=
le_zero_iff_eq.1 $ @edist_self _ _ x ▸ inf_edist_le_edist_of_mem h
/-- The edist is monotonous with respect to inclusion -/
lemma inf_edist_le_inf_edist_of_subset (h : s ⊆ t) : inf_edist x t ≤ inf_edist x s :=
Inf_le_Inf (image_subset _ h)
/-- If the edist to a set is `< r`, there exists a point in the set at edistance `< r` -/
lemma exists_edist_lt_of_inf_edist_lt {r : ennreal} (h : inf_edist x s < r) :
∃y∈s, edist x y < r :=
let ⟨t, ⟨ht, tr⟩⟩ := Inf_lt_iff.1 h in
let ⟨y, ⟨ys, hy⟩⟩ := (mem_image _ _ _).1 ht in
⟨y, ys, by rwa ← hy at tr⟩
/-- The edist of `x` to `s` is bounded by the sum of the edist of `y` to `s` and
the edist from `x` to `y` -/
lemma inf_edist_le_inf_edist_add_edist : inf_edist x s ≤ inf_edist y s + edist x y :=
begin
have : ∀z ∈ s, Inf (edist x '' s) ≤ edist y z + edist x y := λz hz, calc
Inf (edist x '' s) ≤ edist x z :
Inf_le ((mem_image _ _ _).2 ⟨z, hz, by refl⟩)
... ≤ edist x y + edist y z : edist_triangle _ _ _
... = edist y z + edist x y : add_comm _ _,
have : (λz, z + edist x y) (Inf (edist y '' s)) = Inf ((λz, z + edist x y) '' (edist y '' s)),
{ refine map_Inf_of_continuous_at_of_monotone _ _ (by simp),
{ exact continuous_at_id.add continuous_at_const },
{ assume a b h, simp, apply add_le_add_right h _ }},
simp only [inf_edist] at this,
rw [inf_edist, inf_edist, this, ← image_comp],
simpa only [and_imp, function.comp_app, le_Inf_iff, exists_imp_distrib, ball_image_iff]
end
/-- The edist to a set depends continuously on the point -/
lemma continuous_inf_edist : continuous (λx, inf_edist x s) :=
continuous_of_le_add_edist 1 (by simp) $
by simp only [one_mul, inf_edist_le_inf_edist_add_edist, forall_2_true_iff]
/-- The edist to a set and to its closure coincide -/
lemma inf_edist_closure : inf_edist x (closure s) = inf_edist x s :=
begin
refine le_antisymm (inf_edist_le_inf_edist_of_subset subset_closure) _,
refine ennreal.le_of_forall_epsilon_le (λε εpos h, _),
have εpos' : (0 : ennreal) < ε := by simpa,
have : inf_edist x (closure s) < inf_edist x (closure s) + ε/2 :=
ennreal.lt_add_right h (ennreal.half_pos εpos'),
rcases exists_edist_lt_of_inf_edist_lt this with ⟨y, ycs, hy⟩,
-- y : α, ycs : y ∈ closure s, hy : edist x y < inf_edist x (closure s) + ↑ε / 2
rcases emetric.mem_closure_iff.1 ycs (ε/2) (ennreal.half_pos εpos') with ⟨z, zs, dyz⟩,
-- z : α, zs : z ∈ s, dyz : edist y z < ↑ε / 2
calc inf_edist x s ≤ edist x z : inf_edist_le_edist_of_mem zs
... ≤ edist x y + edist y z : edist_triangle _ _ _
... ≤ (inf_edist x (closure s) + ε / 2) + (ε/2) : add_le_add (le_of_lt hy) (le_of_lt dyz)
... = inf_edist x (closure s) + ↑ε : by rw [add_assoc, ennreal.add_halves]
end
/-- A point belongs to the closure of `s` iff its infimum edistance to this set vanishes -/
lemma mem_closure_iff_inf_edist_zero : x ∈ closure s ↔ inf_edist x s = 0 :=
⟨λh, by rw ← inf_edist_closure; exact inf_edist_zero_of_mem h,
λh, emetric.mem_closure_iff.2 $ λε εpos, exists_edist_lt_of_inf_edist_lt (by rwa h)⟩
/-- Given a closed set `s`, a point belongs to `s` iff its infimum edistance to this set vanishes -/
lemma mem_iff_ind_edist_zero_of_closed (h : is_closed s) : x ∈ s ↔ inf_edist x s = 0 :=
begin
convert ← mem_closure_iff_inf_edist_zero,
exact h.closure_eq
end
/-- The infimum edistance is invariant under isometries -/
lemma inf_edist_image (hΦ : isometry Φ) :
inf_edist (Φ x) (Φ '' t) = inf_edist x t :=
begin
simp only [inf_edist],
apply congr_arg,
ext b, split,
{ assume hb,
rcases (mem_image _ _ _).1 hb with ⟨y, ⟨hy, hy'⟩⟩,
rcases (mem_image _ _ _).1 hy with ⟨z, ⟨hz, hz'⟩⟩,
rw [← hy', ← hz', hΦ x z],
exact mem_image_of_mem _ hz },
{ assume hb,
rcases (mem_image _ _ _).1 hb with ⟨y, ⟨hy, hy'⟩⟩,
rw [← hy', ← hΦ x y],
exact mem_image_of_mem _ (mem_image_of_mem _ hy) }
end
end inf_edist --section
/-- The Hausdorff edistance between two sets is the smallest `r` such that each set
is contained in the `r`-neighborhood of the other one -/
def Hausdorff_edist {α : Type u} [emetric_space α] (s t : set α) : ennreal :=
Sup ((λx, inf_edist x t) '' s) ⊔ Sup ((λx, inf_edist x s) '' t)
lemma Hausdorff_edist_def {α : Type u} [emetric_space α] (s t : set α) :
Hausdorff_edist s t = Sup ((λx, inf_edist x t) '' s) ⊔ Sup ((λx, inf_edist x s) '' t) := rfl
attribute [irreducible] Hausdorff_edist
section Hausdorff_edist
open_locale ennreal
variables {α : Type u} {β : Type v} [emetric_space α] [emetric_space β]
{x y : α} {s t u : set α} {Φ : α → β}
/-- The Hausdorff edistance of a set to itself vanishes -/
@[simp] lemma Hausdorff_edist_self : Hausdorff_edist s s = 0 :=
begin
erw [Hausdorff_edist_def, sup_idem, ← le_bot_iff],
apply Sup_le _,
simp [le_bot_iff, inf_edist_zero_of_mem, le_refl] {contextual := tt},
end
/-- The Haudorff edistances of `s` to `t` and of `t` to `s` coincide -/
lemma Hausdorff_edist_comm : Hausdorff_edist s t = Hausdorff_edist t s :=
by unfold Hausdorff_edist; apply sup_comm
/-- Bounding the Hausdorff edistance by bounding the edistance of any point
in each set to the other set -/
lemma Hausdorff_edist_le_of_inf_edist {r : ennreal}
(H1 : ∀x ∈ s, inf_edist x t ≤ r) (H2 : ∀x ∈ t, inf_edist x s ≤ r) :
Hausdorff_edist s t ≤ r :=
begin
simp only [Hausdorff_edist, -mem_image, set.ball_image_iff, Sup_le_iff, sup_le_iff],
exact ⟨H1, H2⟩
end
/-- Bounding the Hausdorff edistance by exhibiting, for any point in each set,
another point in the other set at controlled distance -/
lemma Hausdorff_edist_le_of_mem_edist {r : ennreal}
(H1 : ∀x ∈ s, ∃y ∈ t, edist x y ≤ r) (H2 : ∀x ∈ t, ∃y ∈ s, edist x y ≤ r) :
Hausdorff_edist s t ≤ r :=
begin
refine Hausdorff_edist_le_of_inf_edist _ _,
{ assume x xs,
rcases H1 x xs with ⟨y, yt, hy⟩,
exact le_trans (inf_edist_le_edist_of_mem yt) hy },
{ assume x xt,
rcases H2 x xt with ⟨y, ys, hy⟩,
exact le_trans (inf_edist_le_edist_of_mem ys) hy }
end
/-- The distance to a set is controlled by the Hausdorff distance -/
lemma inf_edist_le_Hausdorff_edist_of_mem (h : x ∈ s) : inf_edist x t ≤ Hausdorff_edist s t :=
begin
rw Hausdorff_edist_def,
refine le_trans (le_Sup _) le_sup_left,
exact mem_image_of_mem _ h
end
/-- If the Hausdorff distance is `<r`, then any point in one of the sets has
a corresponding point at distance `<r` in the other set -/
lemma exists_edist_lt_of_Hausdorff_edist_lt {r : ennreal} (h : x ∈ s) (H : Hausdorff_edist s t < r) :
∃y∈t, edist x y < r :=
exists_edist_lt_of_inf_edist_lt $ calc
inf_edist x t ≤ Sup ((λx, inf_edist x t) '' s) : le_Sup (mem_image_of_mem _ h)
... ≤ Sup ((λx, inf_edist x t) '' s) ⊔ Sup ((λx, inf_edist x s) '' t) : le_sup_left
... < r : by rwa Hausdorff_edist_def at H
/-- The distance from `x` to `s`or `t` is controlled in terms of the Hausdorff distance
between `s` and `t` -/
lemma inf_edist_le_inf_edist_add_Hausdorff_edist :
inf_edist x t ≤ inf_edist x s + Hausdorff_edist s t :=
ennreal.le_of_forall_epsilon_le $ λε εpos h, begin
have εpos' : (0 : ennreal) < ε := by simpa,
have : inf_edist x s < inf_edist x s + ε/2 :=
ennreal.lt_add_right (ennreal.add_lt_top.1 h).1 (ennreal.half_pos εpos'),
rcases exists_edist_lt_of_inf_edist_lt this with ⟨y, ys, dxy⟩,
-- y : α, ys : y ∈ s, dxy : edist x y < inf_edist x s + ↑ε / 2
have : Hausdorff_edist s t < Hausdorff_edist s t + ε/2 :=
ennreal.lt_add_right (ennreal.add_lt_top.1 h).2 (ennreal.half_pos εpos'),
rcases exists_edist_lt_of_Hausdorff_edist_lt ys this with ⟨z, zt, dyz⟩,
-- z : α, zt : z ∈ t, dyz : edist y z < Hausdorff_edist s t + ↑ε / 2
calc inf_edist x t ≤ edist x z : inf_edist_le_edist_of_mem zt
... ≤ edist x y + edist y z : edist_triangle _ _ _
... ≤ (inf_edist x s + ε/2) + (Hausdorff_edist s t + ε/2) : add_le_add (le_of_lt dxy) (le_of_lt dyz)
... = inf_edist x s + Hausdorff_edist s t + ε : by simp [ennreal.add_halves, add_comm, add_left_comm]
end
/-- The Hausdorff edistance is invariant under eisometries -/
lemma Hausdorff_edist_image (h : isometry Φ) :
Hausdorff_edist (Φ '' s) (Φ '' t) = Hausdorff_edist s t :=
begin
unfold Hausdorff_edist,
congr,
{ ext b,
split,
{ assume hb,
rcases (mem_image _ _ _ ).1 hb with ⟨y, ⟨hy, hy'⟩⟩,
rcases (mem_image _ _ _ ).1 hy with ⟨z, ⟨hz, hz'⟩⟩,
rw [← hy', ← hz', inf_edist_image h],
exact mem_image_of_mem _ hz },
{ assume hb,
rcases (mem_image _ _ _ ).1 hb with ⟨y, ⟨hy, hy'⟩⟩,
rw [← hy', ← inf_edist_image h],
exact mem_image_of_mem _ (mem_image_of_mem _ hy) }},
{ ext b,
split,
{ assume hb,
rcases (mem_image _ _ _ ).1 hb with ⟨y, ⟨hy, hy'⟩⟩,
rcases (mem_image _ _ _ ).1 hy with ⟨z, ⟨hz, hz'⟩⟩,
rw [← hy', ← hz', inf_edist_image h],
exact mem_image_of_mem _ hz },
{ assume hb,
rcases (mem_image _ _ _ ).1 hb with ⟨y, ⟨hy, hy'⟩⟩,
rw [← hy', ← inf_edist_image h],
exact mem_image_of_mem _ (mem_image_of_mem _ hy) }}
end
/-- The Hausdorff distance is controlled by the diameter of the union -/
lemma Hausdorff_edist_le_ediam (hs : s.nonempty) (ht : t.nonempty) : Hausdorff_edist s t ≤ diam (s ∪ t) :=
begin
rcases hs with ⟨x, xs⟩,
rcases ht with ⟨y, yt⟩,
refine Hausdorff_edist_le_of_mem_edist _ _,
{ exact λz hz, ⟨y, yt, edist_le_diam_of_mem (subset_union_left _ _ hz) (subset_union_right _ _ yt)⟩ },
{ exact λz hz, ⟨x, xs, edist_le_diam_of_mem (subset_union_right _ _ hz) (subset_union_left _ _ xs)⟩ }
end
/-- The Hausdorff distance satisfies the triangular inequality -/
lemma Hausdorff_edist_triangle : Hausdorff_edist s u ≤ Hausdorff_edist s t + Hausdorff_edist t u :=
begin
rw Hausdorff_edist_def,
simp only [and_imp, set.mem_image, Sup_le_iff, exists_imp_distrib,
sup_le_iff, -mem_image, set.ball_image_iff],
split,
show ∀x ∈ s, inf_edist x u ≤ Hausdorff_edist s t + Hausdorff_edist t u, from λx xs, calc
inf_edist x u ≤ inf_edist x t + Hausdorff_edist t u : inf_edist_le_inf_edist_add_Hausdorff_edist
... ≤ Hausdorff_edist s t + Hausdorff_edist t u :
add_le_add_right (inf_edist_le_Hausdorff_edist_of_mem xs) _,
show ∀x ∈ u, inf_edist x s ≤ Hausdorff_edist s t + Hausdorff_edist t u, from λx xu, calc
inf_edist x s ≤ inf_edist x t + Hausdorff_edist t s : inf_edist_le_inf_edist_add_Hausdorff_edist
... ≤ Hausdorff_edist u t + Hausdorff_edist t s :
add_le_add_right (inf_edist_le_Hausdorff_edist_of_mem xu) _
... = Hausdorff_edist s t + Hausdorff_edist t u : by simp [Hausdorff_edist_comm, add_comm]
end
/-- The Hausdorff edistance between a set and its closure vanishes -/
@[simp, priority 1100]
lemma Hausdorff_edist_self_closure : Hausdorff_edist s (closure s) = 0 :=
begin
erw ← le_bot_iff,
simp only [Hausdorff_edist, inf_edist_closure, -le_zero_iff_eq, and_imp,
set.mem_image, Sup_le_iff, exists_imp_distrib, sup_le_iff,
set.ball_image_iff, ennreal.bot_eq_zero, -mem_image],
simp only [inf_edist_zero_of_mem, mem_closure_iff_inf_edist_zero, le_refl, and_self,
forall_true_iff] {contextual := tt}
end
/-- Replacing a set by its closure does not change the Hausdorff edistance. -/
@[simp] lemma Hausdorff_edist_closure₁ : Hausdorff_edist (closure s) t = Hausdorff_edist s t :=
begin
refine le_antisymm _ _,
{ calc _ ≤ Hausdorff_edist (closure s) s + Hausdorff_edist s t : Hausdorff_edist_triangle
... = Hausdorff_edist s t : by simp [Hausdorff_edist_comm] },
{ calc _ ≤ Hausdorff_edist s (closure s) + Hausdorff_edist (closure s) t : Hausdorff_edist_triangle
... = Hausdorff_edist (closure s) t : by simp }
end
/-- Replacing a set by its closure does not change the Hausdorff edistance. -/
@[simp] lemma Hausdorff_edist_closure₂ : Hausdorff_edist s (closure t) = Hausdorff_edist s t :=
by simp [@Hausdorff_edist_comm _ _ s _]
/-- The Hausdorff edistance between sets or their closures is the same -/
@[simp] lemma Hausdorff_edist_closure : Hausdorff_edist (closure s) (closure t) = Hausdorff_edist s t :=
by simp
/-- Two sets are at zero Hausdorff edistance if and only if they have the same closure -/
lemma Hausdorff_edist_zero_iff_closure_eq_closure : Hausdorff_edist s t = 0 ↔ closure s = closure t :=
⟨begin
assume h,
refine subset.antisymm _ _,
{ have : s ⊆ closure t := λx xs, mem_closure_iff_inf_edist_zero.2 $ begin
erw ← le_bot_iff,
have := @inf_edist_le_Hausdorff_edist_of_mem _ _ _ _ t xs,
rwa h at this,
end,
by rw ← @closure_closure _ _ t; exact closure_mono this },
{ have : t ⊆ closure s := λx xt, mem_closure_iff_inf_edist_zero.2 $ begin
erw ← le_bot_iff,
have := @inf_edist_le_Hausdorff_edist_of_mem _ _ _ _ s xt,
rw Hausdorff_edist_comm at h,
rwa h at this,
end,
by rw ← @closure_closure _ _ s; exact closure_mono this }
end,
λh, by rw [← Hausdorff_edist_closure, h, Hausdorff_edist_self]⟩
/-- Two closed sets are at zero Hausdorff edistance if and only if they coincide -/
lemma Hausdorff_edist_zero_iff_eq_of_closed (hs : is_closed s) (ht : is_closed t) :
Hausdorff_edist s t = 0 ↔ s = t :=
by rw [Hausdorff_edist_zero_iff_closure_eq_closure, hs.closure_eq,
ht.closure_eq]
/-- The Haudorff edistance to the empty set is infinite -/
lemma Hausdorff_edist_empty (ne : s.nonempty) : Hausdorff_edist s ∅ = ∞ :=
begin
rcases ne with ⟨x, xs⟩,
have : inf_edist x ∅ ≤ Hausdorff_edist s ∅ := inf_edist_le_Hausdorff_edist_of_mem xs,
simpa using this,
end
/-- If a set is at finite Hausdorff edistance of a nonempty set, it is nonempty -/
lemma nonempty_of_Hausdorff_edist_ne_top (hs : s.nonempty) (fin : Hausdorff_edist s t ≠ ⊤) :
t.nonempty :=
t.eq_empty_or_nonempty.elim (λ ht, (fin $ ht.symm ▸ Hausdorff_edist_empty hs).elim) id
lemma empty_or_nonempty_of_Hausdorff_edist_ne_top (fin : Hausdorff_edist s t ≠ ⊤) :
s = ∅ ∧ t = ∅ ∨ s.nonempty ∧ t.nonempty :=
begin
cases s.eq_empty_or_nonempty with hs hs,
{ cases t.eq_empty_or_nonempty with ht ht,
{ exact or.inl ⟨hs, ht⟩ },
{ rw Hausdorff_edist_comm at fin,
exact or.inr ⟨nonempty_of_Hausdorff_edist_ne_top ht fin, ht⟩ } },
{ exact or.inr ⟨hs, nonempty_of_Hausdorff_edist_ne_top hs fin⟩ }
end
end Hausdorff_edist -- section
end emetric --namespace
/-Now, we turn to the same notions in metric spaces. To avoid the difficulties related to
Inf and Sup on ℝ (which is only conditionnally complete), we use the notions in ennreal formulated
in terms of the edistance, and coerce them to ℝ. Then their properties follow readily from the
corresponding properties in ennreal, modulo some tedious rewriting of inequalities from one to the
other -/
namespace metric
section
variables {α : Type u} {β : Type v} [metric_space α] [metric_space β] {s t u : set α} {x y : α} {Φ : α → β}
open emetric
/-- The minimal distance of a point to a set -/
def inf_dist (x : α) (s : set α) : ℝ := ennreal.to_real (inf_edist x s)
/-- the minimal distance is always nonnegative -/
lemma inf_dist_nonneg : 0 ≤ inf_dist x s := by simp [inf_dist]
/-- the minimal distance to the empty set is 0 (if you want to have the more reasonable
value ∞ instead, use `inf_edist`, which takes values in ennreal) -/
@[simp] lemma inf_dist_empty : inf_dist x ∅ = 0 :=
by simp [inf_dist]
/-- In a metric space, the minimal edistance to a nonempty set is finite -/
lemma inf_edist_ne_top (h : s.nonempty) : inf_edist x s ≠ ⊤ :=
begin
rcases h with ⟨y, hy⟩,
apply lt_top_iff_ne_top.1,
calc inf_edist x s ≤ edist x y : inf_edist_le_edist_of_mem hy
... < ⊤ : lt_top_iff_ne_top.2 (edist_ne_top _ _)
end
/-- The minimal distance of a point to a set containing it vanishes -/
lemma inf_dist_zero_of_mem (h : x ∈ s) : inf_dist x s = 0 :=
by simp [inf_edist_zero_of_mem h, inf_dist]
/-- The minimal distance to a singleton is the distance to the unique point in this singleton -/
@[simp] lemma inf_dist_singleton : inf_dist x {y} = dist x y :=
by simp [inf_dist, inf_edist, dist_edist]
/-- The minimal distance to a set is bounded by the distance to any point in this set -/
lemma inf_dist_le_dist_of_mem (h : y ∈ s) : inf_dist x s ≤ dist x y :=
begin
rw [dist_edist, inf_dist, ennreal.to_real_le_to_real (inf_edist_ne_top ⟨_, h⟩) (edist_ne_top _ _)],
exact inf_edist_le_edist_of_mem h
end
/-- The minimal distance is monotonous with respect to inclusion -/
lemma inf_dist_le_inf_dist_of_subset (h : s ⊆ t) (hs : s.nonempty) :
inf_dist x t ≤ inf_dist x s :=
begin
have ht : t.nonempty := hs.mono h,
rw [inf_dist, inf_dist, ennreal.to_real_le_to_real (inf_edist_ne_top ht) (inf_edist_ne_top hs)],
exact inf_edist_le_inf_edist_of_subset h
end
/-- If the minimal distance to a set is `<r`, there exists a point in this set at distance `<r` -/
lemma exists_dist_lt_of_inf_dist_lt {r : real} (h : inf_dist x s < r) (hs : s.nonempty) :
∃y∈s, dist x y < r :=
begin
have rpos : 0 < r := lt_of_le_of_lt inf_dist_nonneg h,
have : inf_edist x s < ennreal.of_real r,
{ rwa [inf_dist, ← ennreal.to_real_of_real (le_of_lt rpos), ennreal.to_real_lt_to_real (inf_edist_ne_top hs)] at h,
simp },
rcases exists_edist_lt_of_inf_edist_lt this with ⟨y, ys, hy⟩,
rw [edist_dist, ennreal.of_real_lt_of_real_iff rpos] at hy,
exact ⟨y, ys, hy⟩,
end
/-- The minimal distance from `x` to `s` is bounded by the distance from `y` to `s`, modulo
the distance between `x` and `y` -/
lemma inf_dist_le_inf_dist_add_dist : inf_dist x s ≤ inf_dist y s + dist x y :=
begin
cases s.eq_empty_or_nonempty with hs hs,
{ by simp [hs, dist_nonneg] },
{ rw [inf_dist, inf_dist, dist_edist, ← ennreal.to_real_add (inf_edist_ne_top hs) (edist_ne_top _ _),
ennreal.to_real_le_to_real (inf_edist_ne_top hs)],
{ apply inf_edist_le_inf_edist_add_edist },
{ simp [ennreal.add_eq_top, inf_edist_ne_top hs, edist_ne_top] }}
end
variable (s)
/-- The minimal distance to a set is Lipschitz in point with constant 1 -/
lemma lipschitz_inf_dist_pt : lipschitz_with 1 (λx, inf_dist x s) :=
lipschitz_with.of_le_add $ λ x y, inf_dist_le_inf_dist_add_dist
/-- The minimal distance to a set is uniformly continuous in point -/
lemma uniform_continuous_inf_dist_pt :
uniform_continuous (λx, inf_dist x s) :=
(lipschitz_inf_dist_pt s).uniform_continuous
/-- The minimal distance to a set is continuous in point -/
lemma continuous_inf_dist_pt : continuous (λx, inf_dist x s) :=
(uniform_continuous_inf_dist_pt s).continuous
variable {s}
/-- The minimal distance to a set and its closure coincide -/
lemma inf_dist_eq_closure : inf_dist x (closure s) = inf_dist x s :=
by simp [inf_dist, inf_edist_closure]
/-- A point belongs to the closure of `s` iff its infimum distance to this set vanishes -/
lemma mem_closure_iff_inf_dist_zero (h : s.nonempty) : x ∈ closure s ↔ inf_dist x s = 0 :=
by simp [mem_closure_iff_inf_edist_zero, inf_dist, ennreal.to_real_eq_zero_iff, inf_edist_ne_top h]
/-- Given a closed set `s`, a point belongs to `s` iff its infimum distance to this set vanishes -/
lemma mem_iff_inf_dist_zero_of_closed (h : is_closed s) (hs : s.nonempty) :
x ∈ s ↔ inf_dist x s = 0 :=
begin
have := @mem_closure_iff_inf_dist_zero _ _ s x hs,
rwa h.closure_eq at this
end
/-- The infimum distance is invariant under isometries -/
lemma inf_dist_image (hΦ : isometry Φ) :
inf_dist (Φ x) (Φ '' t) = inf_dist x t :=
by simp [inf_dist, inf_edist_image hΦ]
/-- The Hausdorff distance between two sets is the smallest nonnegative `r` such that each set is
included in the `r`-neighborhood of the other. If there is no such `r`, it is defined to
be `0`, arbitrarily -/
def Hausdorff_dist (s t : set α) : ℝ := ennreal.to_real (Hausdorff_edist s t)
/-- The Hausdorff distance is nonnegative -/
lemma Hausdorff_dist_nonneg : 0 ≤ Hausdorff_dist s t :=
by simp [Hausdorff_dist]
/-- If two sets are nonempty and bounded in a metric space, they are at finite Hausdorff edistance -/
lemma Hausdorff_edist_ne_top_of_nonempty_of_bounded (hs : s.nonempty) (ht : t.nonempty)
(bs : bounded s) (bt : bounded t) : Hausdorff_edist s t ≠ ⊤ :=
begin
rcases hs with ⟨cs, hcs⟩,
rcases ht with ⟨ct, hct⟩,
rcases (bounded_iff_subset_ball ct).1 bs with ⟨rs, hrs⟩,
rcases (bounded_iff_subset_ball cs).1 bt with ⟨rt, hrt⟩,
have : Hausdorff_edist s t ≤ ennreal.of_real (max rs rt),
{ apply Hausdorff_edist_le_of_mem_edist,
{ assume x xs,
existsi [ct, hct],
have : dist x ct ≤ max rs rt := le_trans (hrs xs) (le_max_left _ _),
rwa [edist_dist, ennreal.of_real_le_of_real_iff],
exact le_trans dist_nonneg this },
{ assume x xt,
existsi [cs, hcs],
have : dist x cs ≤ max rs rt := le_trans (hrt xt) (le_max_right _ _),
rwa [edist_dist, ennreal.of_real_le_of_real_iff],
exact le_trans dist_nonneg this }},
exact ennreal.lt_top_iff_ne_top.1 (lt_of_le_of_lt this (by simp [lt_top_iff_ne_top]))
end
/-- The Hausdorff distance between a set and itself is zero -/
@[simp] lemma Hausdorff_dist_self_zero : Hausdorff_dist s s = 0 :=
by simp [Hausdorff_dist]
/-- The Hausdorff distance from `s` to `t` and from `t` to `s` coincide -/
lemma Hausdorff_dist_comm : Hausdorff_dist s t = Hausdorff_dist t s :=
by simp [Hausdorff_dist, Hausdorff_edist_comm]
/-- The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable
value ∞ instead, use `Hausdorff_edist`, which takes values in ennreal) -/
@[simp] lemma Hausdorff_dist_empty : Hausdorff_dist s ∅ = 0 :=
begin
cases s.eq_empty_or_nonempty with h h,
{ simp [h] },
{ simp [Hausdorff_dist, Hausdorff_edist_empty h] }
end
/-- The Hausdorff distance to the empty set vanishes (if you want to have the more reasonable
value ∞ instead, use `Hausdorff_edist`, which takes values in ennreal) -/
@[simp] lemma Hausdorff_dist_empty' : Hausdorff_dist ∅ s = 0 :=
by simp [Hausdorff_dist_comm]
/-- Bounding the Hausdorff distance by bounding the distance of any point
in each set to the other set -/
lemma Hausdorff_dist_le_of_inf_dist {r : ℝ} (hr : r ≥ 0)
(H1 : ∀x ∈ s, inf_dist x t ≤ r) (H2 : ∀x ∈ t, inf_dist x s ≤ r) :
Hausdorff_dist s t ≤ r :=
begin
by_cases h1 : Hausdorff_edist s t = ⊤,
by rwa [Hausdorff_dist, h1, ennreal.top_to_real],
cases s.eq_empty_or_nonempty with hs hs,
by rwa [hs, Hausdorff_dist_empty'],
cases t.eq_empty_or_nonempty with ht ht,
by rwa [ht, Hausdorff_dist_empty],
have : Hausdorff_edist s t ≤ ennreal.of_real r,
{ apply Hausdorff_edist_le_of_inf_edist _ _,
{ assume x hx,
have I := H1 x hx,
rwa [inf_dist, ← ennreal.to_real_of_real hr,
ennreal.to_real_le_to_real (inf_edist_ne_top ht) ennreal.of_real_ne_top] at I },
{ assume x hx,
have I := H2 x hx,
rwa [inf_dist, ← ennreal.to_real_of_real hr,
ennreal.to_real_le_to_real (inf_edist_ne_top hs) ennreal.of_real_ne_top] at I }},
rwa [Hausdorff_dist, ← ennreal.to_real_of_real hr,
ennreal.to_real_le_to_real h1 ennreal.of_real_ne_top]
end
/-- Bounding the Hausdorff distance by exhibiting, for any point in each set,
another point in the other set at controlled distance -/
lemma Hausdorff_dist_le_of_mem_dist {r : ℝ} (hr : 0 ≤ r)
(H1 : ∀x ∈ s, ∃y ∈ t, dist x y ≤ r) (H2 : ∀x ∈ t, ∃y ∈ s, dist x y ≤ r) :
Hausdorff_dist s t ≤ r :=
begin
apply Hausdorff_dist_le_of_inf_dist hr,
{ assume x xs,
rcases H1 x xs with ⟨y, yt, hy⟩,
exact le_trans (inf_dist_le_dist_of_mem yt) hy },
{ assume x xt,
rcases H2 x xt with ⟨y, ys, hy⟩,
exact le_trans (inf_dist_le_dist_of_mem ys) hy }
end
/-- The Hausdorff distance is controlled by the diameter of the union -/
lemma Hausdorff_dist_le_diam (hs : s.nonempty) (bs : bounded s) (ht : t.nonempty) (bt : bounded t) :
Hausdorff_dist s t ≤ diam (s ∪ t) :=
begin
rcases hs with ⟨x, xs⟩,
rcases ht with ⟨y, yt⟩,
refine Hausdorff_dist_le_of_mem_dist diam_nonneg _ _,
{ exact λz hz, ⟨y, yt, dist_le_diam_of_mem (bounded_union.2 ⟨bs, bt⟩)
(subset_union_left _ _ hz) (subset_union_right _ _ yt)⟩ },
{ exact λz hz, ⟨x, xs, dist_le_diam_of_mem (bounded_union.2 ⟨bs, bt⟩)
(subset_union_right _ _ hz) (subset_union_left _ _ xs)⟩ }
end
/-- The distance to a set is controlled by the Hausdorff distance -/
lemma inf_dist_le_Hausdorff_dist_of_mem (hx : x ∈ s) (fin : Hausdorff_edist s t ≠ ⊤) :
inf_dist x t ≤ Hausdorff_dist s t :=
begin
have ht : t.nonempty := nonempty_of_Hausdorff_edist_ne_top ⟨x, hx⟩ fin,
rw [Hausdorff_dist, inf_dist, ennreal.to_real_le_to_real (inf_edist_ne_top ht) fin],
exact inf_edist_le_Hausdorff_edist_of_mem hx
end
/-- If the Hausdorff distance is `<r`, then any point in one of the sets is at distance
`<r` of a point in the other set -/
lemma exists_dist_lt_of_Hausdorff_dist_lt {r : ℝ} (h : x ∈ s) (H : Hausdorff_dist s t < r)
(fin : Hausdorff_edist s t ≠ ⊤) : ∃y∈t, dist x y < r :=
begin
have r0 : 0 < r := lt_of_le_of_lt (Hausdorff_dist_nonneg) H,
have : Hausdorff_edist s t < ennreal.of_real r,
by rwa [Hausdorff_dist, ← ennreal.to_real_of_real (le_of_lt r0),
ennreal.to_real_lt_to_real fin (ennreal.of_real_ne_top)] at H,
rcases exists_edist_lt_of_Hausdorff_edist_lt h this with ⟨y, hy, yr⟩,
rw [edist_dist, ennreal.of_real_lt_of_real_iff r0] at yr,
exact ⟨y, hy, yr⟩
end
/-- If the Hausdorff distance is `<r`, then any point in one of the sets is at distance
`<r` of a point in the other set -/
lemma exists_dist_lt_of_Hausdorff_dist_lt' {r : ℝ} (h : y ∈ t) (H : Hausdorff_dist s t < r)
(fin : Hausdorff_edist s t ≠ ⊤) : ∃x∈s, dist x y < r :=
begin
rw Hausdorff_dist_comm at H,
rw Hausdorff_edist_comm at fin,
simpa [dist_comm] using exists_dist_lt_of_Hausdorff_dist_lt h H fin
end
/-- The infimum distance to `s` and `t` are the same, up to the Hausdorff distance
between `s` and `t` -/
lemma inf_dist_le_inf_dist_add_Hausdorff_dist (fin : Hausdorff_edist s t ≠ ⊤) :
inf_dist x t ≤ inf_dist x s + Hausdorff_dist s t :=
begin
rcases empty_or_nonempty_of_Hausdorff_edist_ne_top fin with ⟨hs,ht⟩|⟨hs,ht⟩,
{ simp only [hs, ht, Hausdorff_dist_empty, inf_dist_empty, zero_add] },
rw [inf_dist, inf_dist, Hausdorff_dist, ← ennreal.to_real_add (inf_edist_ne_top hs) fin,
ennreal.to_real_le_to_real (inf_edist_ne_top ht)],
{ exact inf_edist_le_inf_edist_add_Hausdorff_edist },
{ exact ennreal.add_ne_top.2 ⟨inf_edist_ne_top hs, fin⟩ }
end
/-- The Hausdorff distance is invariant under isometries -/
lemma Hausdorff_dist_image (h : isometry Φ) :
Hausdorff_dist (Φ '' s) (Φ '' t) = Hausdorff_dist s t :=
by simp [Hausdorff_dist, Hausdorff_edist_image h]
/-- The Hausdorff distance satisfies the triangular inequality -/
lemma Hausdorff_dist_triangle (fin : Hausdorff_edist s t ≠ ⊤) :
Hausdorff_dist s u ≤ Hausdorff_dist s t + Hausdorff_dist t u :=
begin
by_cases Hausdorff_edist s u = ⊤,
{ calc Hausdorff_dist s u = 0 + 0 : by simp [Hausdorff_dist, h]
... ≤ Hausdorff_dist s t + Hausdorff_dist t u :
add_le_add (Hausdorff_dist_nonneg) (Hausdorff_dist_nonneg) },
{ have Dtu : Hausdorff_edist t u < ⊤ := calc
Hausdorff_edist t u ≤ Hausdorff_edist t s + Hausdorff_edist s u : Hausdorff_edist_triangle
... = Hausdorff_edist s t + Hausdorff_edist s u : by simp [Hausdorff_edist_comm]
... < ⊤ : by simp [ennreal.add_lt_top]; simp [ennreal.lt_top_iff_ne_top, h, fin],
rw [Hausdorff_dist, Hausdorff_dist, Hausdorff_dist,
← ennreal.to_real_add fin (lt_top_iff_ne_top.1 Dtu), ennreal.to_real_le_to_real h],
{ exact Hausdorff_edist_triangle },
{ simp [ennreal.add_eq_top, lt_top_iff_ne_top.1 Dtu, fin] }}
end
/-- The Hausdorff distance satisfies the triangular inequality -/
lemma Hausdorff_dist_triangle' (fin : Hausdorff_edist t u ≠ ⊤) :
Hausdorff_dist s u ≤ Hausdorff_dist s t + Hausdorff_dist t u :=
begin
rw Hausdorff_edist_comm at fin,
have I : Hausdorff_dist u s ≤ Hausdorff_dist u t + Hausdorff_dist t s := Hausdorff_dist_triangle fin,
simpa [add_comm, Hausdorff_dist_comm] using I
end
/-- The Hausdorff distance between a set and its closure vanish -/
@[simp, priority 1100]
lemma Hausdorff_dist_self_closure : Hausdorff_dist s (closure s) = 0 :=
by simp [Hausdorff_dist]
/-- Replacing a set by its closure does not change the Hausdorff distance. -/
@[simp] lemma Hausdorff_dist_closure₁ : Hausdorff_dist (closure s) t = Hausdorff_dist s t :=
by simp [Hausdorff_dist]
/-- Replacing a set by its closure does not change the Hausdorff distance. -/
@[simp] lemma Hausdorff_dist_closure₂ : Hausdorff_dist s (closure t) = Hausdorff_dist s t :=
by simp [Hausdorff_dist]
/-- The Hausdorff distance between two sets and their closures coincide -/
@[simp] lemma Hausdorff_dist_closure : Hausdorff_dist (closure s) (closure t) = Hausdorff_dist s t :=
by simp [Hausdorff_dist]
/-- Two sets are at zero Hausdorff distance if and only if they have the same closures -/
lemma Hausdorff_dist_zero_iff_closure_eq_closure (fin : Hausdorff_edist s t ≠ ⊤) :
Hausdorff_dist s t = 0 ↔ closure s = closure t :=
by simp [Hausdorff_edist_zero_iff_closure_eq_closure.symm, Hausdorff_dist,
ennreal.to_real_eq_zero_iff, fin]
/-- Two closed sets are at zero Hausdorff distance if and only if they coincide -/
lemma Hausdorff_dist_zero_iff_eq_of_closed (hs : is_closed s) (ht : is_closed t)
(fin : Hausdorff_edist s t ≠ ⊤) : Hausdorff_dist s t = 0 ↔ s = t :=
by simp [(Hausdorff_edist_zero_iff_eq_of_closed hs ht).symm, Hausdorff_dist,
ennreal.to_real_eq_zero_iff, fin]
end --section
end metric --namespace
|
4c029bf8b25c98bf1a5ee815e6824ec5420be394 | 618003631150032a5676f229d13a079ac875ff77 | /src/tactic/omega/clause.lean | e54a872118b0d699cc217dcd022ce05f71f0a1f1 | [
"Apache-2.0"
] | permissive | awainverse/mathlib | 939b68c8486df66cfda64d327ad3d9165248c777 | ea76bd8f3ca0a8bf0a166a06a475b10663dec44a | refs/heads/master | 1,659,592,962,036 | 1,590,987,592,000 | 1,590,987,592,000 | 268,436,019 | 1 | 0 | Apache-2.0 | 1,590,990,500,000 | 1,590,990,500,000 | null | UTF-8 | Lean | false | false | 1,997 | lean | /- Copyright (c) 2019 Seul Baek. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Seul Baek
Definition of linear constrain clauses. -/
import tactic.omega.term
namespace omega
/-- (([t₁,...tₘ],[s₁,...,sₙ]) : clause) encodes the constraints
0 = ⟦t₁⟧ ∧ ... ∧ 0 = ⟦tₘ⟧ ∧ 0 ≤ ⟦s₁⟧ ∧ ... ∧ 0 ≤ ⟦sₙ⟧, where
⟦t⟧ is the value of (t : term). -/
@[reducible] def clause := (list term) × (list term)
namespace clause
/-- holds v c := clause c holds under valuation v -/
def holds (v : nat → int) : clause → Prop
| (eqs,les) :=
( (∀ t : term, t ∈ eqs → 0 = term.val v t)
∧ (∀ t : term, t ∈ les → 0 ≤ term.val v t) )
/-- sat c := there exists a valuation v under which c holds -/
def sat (c : clause) : Prop :=
∃ v : nat → int, holds v c
/-- unsat c := there is no valuation v under which c holds -/
def unsat (c : clause) : Prop := ¬ c.sat
/-- append two clauses by elementwise appending -/
def append (c1 c2 : clause) : clause :=
(c1.fst ++ c2.fst, c1.snd ++ c2.snd)
lemma holds_append {v : nat → int} {c1 c2 : clause} :
holds v c1 → holds v c2 → holds v (append c1 c2) :=
begin
intros h1 h2,
cases c1 with eqs1 les1,
cases c2 with eqs2 les2,
cases h1, cases h2,
constructor; rw list.forall_mem_append;
constructor; assumption,
end
end clause
/-- There exists a satisfiable clause c in argument -/
def clauses.sat (cs : list clause) : Prop :=
∃ c ∈ cs, clause.sat c
/-- There is no satisfiable clause c in argument -/
def clauses.unsat (cs : list clause) : Prop := ¬ clauses.sat cs
lemma clauses.unsat_nil : clauses.unsat [] :=
begin intro h1, rcases h1 with ⟨c,h1,h2⟩, cases h1 end
lemma clauses.unsat_cons (c : clause) (cs : list clause) :
clause.unsat c → clauses.unsat cs →
clauses.unsat (c::cs) | h1 h2 h3 :=
begin
unfold clauses.sat at h3,
rw list.exists_mem_cons_iff at h3,
cases h3; contradiction,
end
end omega
|
f32c590316a9c948089e7a20ffb12ffbd79adccf | c777c32c8e484e195053731103c5e52af26a25d1 | /src/analysis/special_functions/trigonometric/angle.lean | 422c30266f8b2eaf2770d98155a479afcd3b8332 | [
"Apache-2.0"
] | permissive | kbuzzard/mathlib | 2ff9e85dfe2a46f4b291927f983afec17e946eb8 | 58537299e922f9c77df76cb613910914a479c1f7 | refs/heads/master | 1,685,313,702,744 | 1,683,974,212,000 | 1,683,974,212,000 | 128,185,277 | 1 | 0 | null | 1,522,920,600,000 | 1,522,920,600,000 | null | UTF-8 | Lean | false | false | 35,669 | lean | /-
Copyright (c) 2019 Calle Sönne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Calle Sönne
-/
import analysis.special_functions.trigonometric.basic
import analysis.normed.group.add_circle
import algebra.char_zero.quotient
import topology.instances.sign
/-!
# The type of angles
In this file we define `real.angle` to be the quotient group `ℝ/2πℤ` and prove a few simple lemmas
about trigonometric functions and angles.
-/
open_locale real
noncomputable theory
namespace real
/-- The type of angles -/
@[derive [normed_add_comm_group, inhabited, has_coe_t ℝ]]
def angle : Type := add_circle (2 * π)
namespace angle
instance : circular_order real.angle :=
@add_circle.circular_order _ _ _ _ _ ⟨by norm_num [pi_pos]⟩ _
@[continuity] lemma continuous_coe : continuous (coe : ℝ → angle) :=
continuous_quotient_mk
/-- Coercion `ℝ → angle` as an additive homomorphism. -/
def coe_hom : ℝ →+ angle := quotient_add_group.mk' _
@[simp] lemma coe_coe_hom : (coe_hom : ℝ → angle) = coe := rfl
/-- An induction principle to deduce results for `angle` from those for `ℝ`, used with
`induction θ using real.angle.induction_on`. -/
@[elab_as_eliminator]
protected lemma induction_on {p : angle → Prop} (θ : angle) (h : ∀ x : ℝ, p x) : p θ :=
quotient.induction_on' θ h
@[simp] lemma coe_zero : ↑(0 : ℝ) = (0 : angle) := rfl
@[simp] lemma coe_add (x y : ℝ) : ↑(x + y : ℝ) = (↑x + ↑y : angle) := rfl
@[simp] lemma coe_neg (x : ℝ) : ↑(-x : ℝ) = -(↑x : angle) := rfl
@[simp] lemma coe_sub (x y : ℝ) : ↑(x - y : ℝ) = (↑x - ↑y : angle) := rfl
lemma coe_nsmul (n : ℕ) (x : ℝ) : ↑(n • x : ℝ) = (n • ↑x : angle) := rfl
lemma coe_zsmul (z : ℤ) (x : ℝ) : ↑(z • x : ℝ) = (z • ↑x : angle) := rfl
@[simp, norm_cast] lemma coe_nat_mul_eq_nsmul (x : ℝ) (n : ℕ) :
↑((n : ℝ) * x) = n • (↑x : angle) :=
by simpa only [nsmul_eq_mul] using coe_hom.map_nsmul x n
@[simp, norm_cast] lemma coe_int_mul_eq_zsmul (x : ℝ) (n : ℤ) :
↑((n : ℝ) * x : ℝ) = n • (↑x : angle) :=
by simpa only [zsmul_eq_mul] using coe_hom.map_zsmul x n
lemma angle_eq_iff_two_pi_dvd_sub {ψ θ : ℝ} : (θ : angle) = ψ ↔ ∃ k : ℤ, θ - ψ = 2 * π * k :=
by simp only [quotient_add_group.eq, add_subgroup.zmultiples_eq_closure,
add_subgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm]
@[simp] lemma coe_two_pi : ↑(2 * π : ℝ) = (0 : angle) :=
angle_eq_iff_two_pi_dvd_sub.2 ⟨1, by rw [sub_zero, int.cast_one, mul_one]⟩
@[simp] lemma neg_coe_pi : -(π : angle) = π :=
begin
rw [←coe_neg, angle_eq_iff_two_pi_dvd_sub],
use -1,
simp [two_mul, sub_eq_add_neg]
end
@[simp] lemma two_nsmul_coe_div_two (θ : ℝ) : (2 : ℕ) • (↑(θ / 2) : angle) = θ :=
by rw [←coe_nsmul, two_nsmul, add_halves]
@[simp] lemma two_zsmul_coe_div_two (θ : ℝ) : (2 : ℤ) • (↑(θ / 2) : angle) = θ :=
by rw [←coe_zsmul, two_zsmul, add_halves]
@[simp] lemma two_nsmul_neg_pi_div_two : (2 : ℕ) • (↑(-π / 2) : angle) = π :=
by rw [two_nsmul_coe_div_two, coe_neg, neg_coe_pi]
@[simp] lemma two_zsmul_neg_pi_div_two : (2 : ℤ) • (↑(-π / 2) : angle) = π :=
by rw [two_zsmul, ←two_nsmul, two_nsmul_neg_pi_div_two]
lemma sub_coe_pi_eq_add_coe_pi (θ : angle) : θ - π = θ + π :=
by rw [sub_eq_add_neg, neg_coe_pi]
@[simp] lemma two_nsmul_coe_pi : (2 : ℕ) • (π : angle) = 0 :=
by simp [←coe_nat_mul_eq_nsmul]
@[simp] lemma two_zsmul_coe_pi : (2 : ℤ) • (π : angle) = 0 :=
by simp [←coe_int_mul_eq_zsmul]
@[simp] lemma coe_pi_add_coe_pi : (π : real.angle) + π = 0 :=
by rw [←two_nsmul, two_nsmul_coe_pi]
lemma zsmul_eq_iff {ψ θ : angle} {z : ℤ} (hz : z ≠ 0) :
z • ψ = z • θ ↔ (∃ k : fin z.nat_abs, ψ = θ + (k : ℕ) • (2 * π / z : ℝ)) :=
quotient_add_group.zmultiples_zsmul_eq_zsmul_iff hz
lemma nsmul_eq_iff {ψ θ : angle} {n : ℕ} (hz : n ≠ 0) :
n • ψ = n • θ ↔ (∃ k : fin n, ψ = θ + (k : ℕ) • (2 * π / n : ℝ)) :=
quotient_add_group.zmultiples_nsmul_eq_nsmul_iff hz
lemma two_zsmul_eq_iff {ψ θ : angle} : (2 : ℤ) • ψ = (2 : ℤ) • θ ↔ (ψ = θ ∨ ψ = θ + π) :=
by rw [zsmul_eq_iff two_ne_zero, int.nat_abs_bit0, int.nat_abs_one,
fin.exists_fin_two, fin.coe_zero, fin.coe_one, zero_smul, add_zero, one_smul,
int.cast_two, mul_div_cancel_left (_ : ℝ) two_ne_zero]
lemma two_nsmul_eq_iff {ψ θ : angle} : (2 : ℕ) • ψ = (2 : ℕ) • θ ↔ (ψ = θ ∨ ψ = θ + π) :=
by simp_rw [←coe_nat_zsmul, int.coe_nat_bit0, int.coe_nat_one, two_zsmul_eq_iff]
lemma two_nsmul_eq_zero_iff {θ : angle} : (2 : ℕ) • θ = 0 ↔ (θ = 0 ∨ θ = π) :=
by convert two_nsmul_eq_iff; simp
lemma two_nsmul_ne_zero_iff {θ : angle} : (2 : ℕ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π :=
by rw [←not_or_distrib, ←two_nsmul_eq_zero_iff]
lemma two_zsmul_eq_zero_iff {θ : angle} : (2 : ℤ) • θ = 0 ↔ (θ = 0 ∨ θ = π) :=
by simp_rw [two_zsmul, ←two_nsmul, two_nsmul_eq_zero_iff]
lemma two_zsmul_ne_zero_iff {θ : angle} : (2 : ℤ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π :=
by rw [←not_or_distrib, ←two_zsmul_eq_zero_iff]
lemma eq_neg_self_iff {θ : angle} : θ = -θ ↔ θ = 0 ∨ θ = π :=
by rw [←add_eq_zero_iff_eq_neg, ←two_nsmul, two_nsmul_eq_zero_iff]
lemma ne_neg_self_iff {θ : angle} : θ ≠ -θ ↔ θ ≠ 0 ∧ θ ≠ π :=
by rw [←not_or_distrib, ←eq_neg_self_iff.not]
lemma neg_eq_self_iff {θ : angle} : -θ = θ ↔ θ = 0 ∨ θ = π :=
by rw [eq_comm, eq_neg_self_iff]
lemma neg_ne_self_iff {θ : angle} : -θ ≠ θ ↔ θ ≠ 0 ∧ θ ≠ π :=
by rw [←not_or_distrib, ←neg_eq_self_iff.not]
lemma two_nsmul_eq_pi_iff {θ : angle} : (2 : ℕ) • θ = π ↔ (θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ)) :=
begin
have h : (π : angle) = (2 : ℕ) • (π / 2 : ℝ), { rw [two_nsmul, ←coe_add, add_halves] },
nth_rewrite 0 h,
rw [two_nsmul_eq_iff],
congr',
rw [add_comm, ←coe_add, ←sub_eq_zero, ←coe_sub, add_sub_assoc, neg_div, sub_neg_eq_add,
add_halves, ←two_mul, coe_two_pi]
end
lemma two_zsmul_eq_pi_iff {θ : angle} : (2 : ℤ) • θ = π ↔ (θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ)) :=
by rw [two_zsmul, ←two_nsmul, two_nsmul_eq_pi_iff]
theorem cos_eq_iff_coe_eq_or_eq_neg {θ ψ : ℝ} :
cos θ = cos ψ ↔ (θ : angle) = ψ ∨ (θ : angle) = -ψ :=
begin
split,
{ intro Hcos,
rw [← sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero,
eq_false_intro (two_ne_zero' ℝ), false_or, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos,
rcases Hcos with ⟨n, hn⟩ | ⟨n, hn⟩,
{ right,
rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), ← sub_eq_iff_eq_add] at hn,
rw [← hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc,
coe_int_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero] },
{ left,
rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), eq_sub_iff_add_eq] at hn,
rw [← hn, coe_add, mul_assoc,
coe_int_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero, zero_add] }, },
{ rw [angle_eq_iff_two_pi_dvd_sub, ← coe_neg, angle_eq_iff_two_pi_dvd_sub],
rintro (⟨k, H⟩ | ⟨k, H⟩),
rw [← sub_eq_zero, cos_sub_cos, H, mul_assoc 2 π k,
mul_div_cancel_left _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero],
rw [← sub_eq_zero, cos_sub_cos, ← sub_neg_eq_add, H, mul_assoc 2 π k,
mul_div_cancel_left _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero,
zero_mul] }
end
theorem sin_eq_iff_coe_eq_or_add_eq_pi {θ ψ : ℝ} :
sin θ = sin ψ ↔ (θ : angle) = ψ ∨ (θ : angle) + ψ = π :=
begin
split,
{ intro Hsin, rw [← cos_pi_div_two_sub, ← cos_pi_div_two_sub] at Hsin,
cases cos_eq_iff_coe_eq_or_eq_neg.mp Hsin with h h,
{ left, rw [coe_sub, coe_sub] at h, exact sub_right_inj.1 h },
right, rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub,
sub_add_eq_add_sub, ← coe_add, add_halves, sub_sub, sub_eq_zero] at h,
exact h.symm },
{ rw [angle_eq_iff_two_pi_dvd_sub, ←eq_sub_iff_add_eq, ←coe_sub, angle_eq_iff_two_pi_dvd_sub],
rintro (⟨k, H⟩ | ⟨k, H⟩),
rw [← sub_eq_zero, sin_sub_sin, H, mul_assoc 2 π k,
mul_div_cancel_left _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero,
zero_mul],
have H' : θ + ψ = (2 * k) * π + π := by rwa [←sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add,
mul_assoc, mul_comm π _, ←mul_assoc] at H,
rw [← sub_eq_zero, sin_sub_sin, H', add_div, mul_assoc 2 _ π,
mul_div_cancel_left _ (two_ne_zero' ℝ), cos_add_pi_div_two, sin_int_mul_pi, neg_zero,
mul_zero] }
end
theorem cos_sin_inj {θ ψ : ℝ} (Hcos : cos θ = cos ψ) (Hsin : sin θ = sin ψ) : (θ : angle) = ψ :=
begin
cases cos_eq_iff_coe_eq_or_eq_neg.mp Hcos with hc hc, { exact hc },
cases sin_eq_iff_coe_eq_or_add_eq_pi.mp Hsin with hs hs, { exact hs },
rw [eq_neg_iff_add_eq_zero, hs] at hc,
obtain ⟨n, hn⟩ : ∃ n, n • _ = _ := quotient_add_group.left_rel_apply.mp (quotient.exact' hc),
rw [← neg_one_mul, add_zero, ← sub_eq_zero, zsmul_eq_mul, ← mul_assoc, ← sub_mul,
mul_eq_zero, eq_false_intro (ne_of_gt pi_pos), or_false, sub_neg_eq_add,
← int.cast_zero, ← int.cast_one, ← int.cast_bit0, ← int.cast_mul, ← int.cast_add,
int.cast_inj] at hn,
have : (n * 2 + 1) % (2:ℤ) = 0 % (2:ℤ) := congr_arg (%(2:ℤ)) hn,
rw [add_comm, int.add_mul_mod_self] at this,
exact absurd this one_ne_zero
end
/-- The sine of a `real.angle`. -/
def sin (θ : angle) : ℝ := sin_periodic.lift θ
@[simp] lemma sin_coe (x : ℝ) : sin (x : angle) = real.sin x :=
rfl
@[continuity] lemma continuous_sin : continuous sin :=
real.continuous_sin.quotient_lift_on' _
/-- The cosine of a `real.angle`. -/
def cos (θ : angle) : ℝ := cos_periodic.lift θ
@[simp] lemma cos_coe (x : ℝ) : cos (x : angle) = real.cos x :=
rfl
@[continuity] lemma continuous_cos : continuous cos :=
real.continuous_cos.quotient_lift_on' _
lemma cos_eq_real_cos_iff_eq_or_eq_neg {θ : angle} {ψ : ℝ} : cos θ = real.cos ψ ↔ θ = ψ ∨ θ = -ψ :=
begin
induction θ using real.angle.induction_on,
exact cos_eq_iff_coe_eq_or_eq_neg
end
lemma cos_eq_iff_eq_or_eq_neg {θ ψ : angle} : cos θ = cos ψ ↔ θ = ψ ∨ θ = -ψ :=
begin
induction ψ using real.angle.induction_on,
exact cos_eq_real_cos_iff_eq_or_eq_neg
end
lemma sin_eq_real_sin_iff_eq_or_add_eq_pi {θ : angle} {ψ : ℝ} :
sin θ = real.sin ψ ↔ θ = ψ ∨ θ + ψ = π :=
begin
induction θ using real.angle.induction_on,
exact sin_eq_iff_coe_eq_or_add_eq_pi
end
lemma sin_eq_iff_eq_or_add_eq_pi {θ ψ : angle} : sin θ = sin ψ ↔ θ = ψ ∨ θ + ψ = π :=
begin
induction ψ using real.angle.induction_on,
exact sin_eq_real_sin_iff_eq_or_add_eq_pi
end
@[simp] lemma sin_zero : sin (0 : angle) = 0 :=
by rw [←coe_zero, sin_coe, real.sin_zero]
@[simp] lemma sin_coe_pi : sin (π : angle) = 0 :=
by rw [sin_coe, real.sin_pi]
lemma sin_eq_zero_iff {θ : angle} : sin θ = 0 ↔ θ = 0 ∨ θ = π :=
begin
nth_rewrite 0 ←sin_zero,
rw sin_eq_iff_eq_or_add_eq_pi,
simp
end
lemma sin_ne_zero_iff {θ : angle} : sin θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π :=
by rw [←not_or_distrib, ←sin_eq_zero_iff]
@[simp] lemma sin_neg (θ : angle) : sin (-θ) = -sin θ :=
begin
induction θ using real.angle.induction_on,
exact real.sin_neg _
end
lemma sin_antiperiodic : function.antiperiodic sin (π : angle) :=
begin
intro θ,
induction θ using real.angle.induction_on,
exact real.sin_antiperiodic θ
end
@[simp] lemma sin_add_pi (θ : angle) : sin (θ + π) = -sin θ :=
sin_antiperiodic θ
@[simp] lemma sin_sub_pi (θ : angle) : sin (θ - π) = -sin θ :=
sin_antiperiodic.sub_eq θ
@[simp] lemma cos_zero : cos (0 : angle) = 1 :=
by rw [←coe_zero, cos_coe, real.cos_zero]
@[simp] lemma cos_coe_pi : cos (π : angle) = -1 :=
by rw [cos_coe, real.cos_pi]
@[simp] lemma cos_neg (θ : angle) : cos (-θ) = cos θ :=
begin
induction θ using real.angle.induction_on,
exact real.cos_neg _
end
lemma cos_antiperiodic : function.antiperiodic cos (π : angle) :=
begin
intro θ,
induction θ using real.angle.induction_on,
exact real.cos_antiperiodic θ
end
@[simp] lemma cos_add_pi (θ : angle) : cos (θ + π) = -cos θ :=
cos_antiperiodic θ
@[simp] lemma cos_sub_pi (θ : angle) : cos (θ - π) = -cos θ :=
cos_antiperiodic.sub_eq θ
lemma cos_eq_zero_iff {θ : angle} : cos θ = 0 ↔ (θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ)) :=
by rw [← cos_pi_div_two, ← cos_coe, cos_eq_iff_eq_or_eq_neg, ← coe_neg, ← neg_div]
lemma sin_add (θ₁ θ₂ : real.angle) : sin (θ₁ + θ₂) = sin θ₁ * cos θ₂ + cos θ₁ * sin θ₂ :=
begin
induction θ₁ using real.angle.induction_on,
induction θ₂ using real.angle.induction_on,
exact real.sin_add θ₁ θ₂
end
lemma cos_add (θ₁ θ₂ : real.angle) : cos (θ₁ + θ₂) = cos θ₁ * cos θ₂ - sin θ₁ * sin θ₂ :=
begin
induction θ₂ using real.angle.induction_on,
induction θ₁ using real.angle.induction_on,
exact real.cos_add θ₁ θ₂,
end
@[simp] lemma cos_sq_add_sin_sq (θ : real.angle) : cos θ ^ 2 + sin θ ^ 2 = 1 :=
begin
induction θ using real.angle.induction_on,
exact real.cos_sq_add_sin_sq θ,
end
lemma sin_add_pi_div_two (θ : angle) : sin (θ + ↑(π / 2)) = cos θ :=
begin
induction θ using real.angle.induction_on,
exact sin_add_pi_div_two _
end
lemma sin_sub_pi_div_two (θ : angle) : sin (θ - ↑(π / 2)) = -cos θ :=
begin
induction θ using real.angle.induction_on,
exact sin_sub_pi_div_two _
end
lemma sin_pi_div_two_sub (θ : angle) : sin (↑(π / 2) - θ) = cos θ :=
begin
induction θ using real.angle.induction_on,
exact sin_pi_div_two_sub _
end
lemma cos_add_pi_div_two (θ : angle) : cos (θ + ↑(π / 2)) = -sin θ :=
begin
induction θ using real.angle.induction_on,
exact cos_add_pi_div_two _
end
lemma cos_sub_pi_div_two (θ : angle) : cos (θ - ↑(π / 2)) = sin θ :=
begin
induction θ using real.angle.induction_on,
exact cos_sub_pi_div_two _
end
lemma cos_pi_div_two_sub (θ : angle) : cos (↑(π / 2) - θ) = sin θ :=
begin
induction θ using real.angle.induction_on,
exact cos_pi_div_two_sub _
end
lemma abs_sin_eq_of_two_nsmul_eq {θ ψ : angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) :
|sin θ| = |sin ψ| :=
begin
rw two_nsmul_eq_iff at h,
rcases h with rfl | rfl,
{ refl },
{ rw [sin_add_pi, abs_neg] }
end
lemma abs_sin_eq_of_two_zsmul_eq {θ ψ : angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) :
|sin θ| = |sin ψ| :=
begin
simp_rw [two_zsmul, ←two_nsmul] at h,
exact abs_sin_eq_of_two_nsmul_eq h
end
lemma abs_cos_eq_of_two_nsmul_eq {θ ψ : angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) :
|cos θ| = |cos ψ| :=
begin
rw two_nsmul_eq_iff at h,
rcases h with rfl | rfl,
{ refl },
{ rw [cos_add_pi, abs_neg] }
end
lemma abs_cos_eq_of_two_zsmul_eq {θ ψ : angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) :
|cos θ| = |cos ψ| :=
begin
simp_rw [two_zsmul, ←two_nsmul] at h,
exact abs_cos_eq_of_two_nsmul_eq h
end
@[simp] lemma coe_to_Ico_mod (θ ψ : ℝ) : ↑(to_Ico_mod two_pi_pos ψ θ) = (θ : angle) :=
begin
rw angle_eq_iff_two_pi_dvd_sub,
refine ⟨-to_Ico_div two_pi_pos ψ θ, _⟩,
rw [to_Ico_mod_sub_self, zsmul_eq_mul, mul_comm]
end
@[simp] lemma coe_to_Ioc_mod (θ ψ : ℝ) : ↑(to_Ioc_mod two_pi_pos ψ θ) = (θ : angle) :=
begin
rw angle_eq_iff_two_pi_dvd_sub,
refine ⟨-to_Ioc_div two_pi_pos ψ θ, _⟩,
rw [to_Ioc_mod_sub_self, zsmul_eq_mul, mul_comm]
end
/-- Convert a `real.angle` to a real number in the interval `Ioc (-π) π`. -/
def to_real (θ : angle) : ℝ :=
(to_Ioc_mod_periodic two_pi_pos (-π)).lift θ
lemma to_real_coe (θ : ℝ) : (θ : angle).to_real = to_Ioc_mod two_pi_pos (-π) θ := rfl
lemma to_real_coe_eq_self_iff {θ : ℝ} : (θ : angle).to_real = θ ↔ -π < θ ∧ θ ≤ π :=
begin
rw [to_real_coe, to_Ioc_mod_eq_self two_pi_pos],
ring_nf
end
lemma to_real_coe_eq_self_iff_mem_Ioc {θ : ℝ} : (θ : angle).to_real = θ ↔ θ ∈ set.Ioc (-π) π :=
by rw [to_real_coe_eq_self_iff, ←set.mem_Ioc]
lemma to_real_injective : function.injective to_real :=
begin
intros θ ψ h,
induction θ using real.angle.induction_on,
induction ψ using real.angle.induction_on,
simpa [to_real_coe, to_Ioc_mod_eq_to_Ioc_mod, zsmul_eq_mul, mul_comm _ (2 * π),
←angle_eq_iff_two_pi_dvd_sub, eq_comm] using h,
end
@[simp] lemma to_real_inj {θ ψ : angle} : θ.to_real = ψ.to_real ↔ θ = ψ :=
to_real_injective.eq_iff
@[simp] lemma coe_to_real (θ : angle): (θ.to_real : angle) = θ :=
begin
induction θ using real.angle.induction_on,
exact coe_to_Ioc_mod _ _
end
lemma neg_pi_lt_to_real (θ : angle) : -π < θ.to_real :=
begin
induction θ using real.angle.induction_on,
exact left_lt_to_Ioc_mod _ _ _
end
lemma to_real_le_pi (θ : angle) : θ.to_real ≤ π :=
begin
induction θ using real.angle.induction_on,
convert to_Ioc_mod_le_right two_pi_pos _ _,
ring
end
lemma abs_to_real_le_pi (θ : angle) : |θ.to_real| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_to_real _).le, to_real_le_pi _⟩
lemma to_real_mem_Ioc (θ : angle) : θ.to_real ∈ set.Ioc (-π) π :=
⟨neg_pi_lt_to_real _, to_real_le_pi _⟩
@[simp] lemma to_Ioc_mod_to_real (θ : angle): to_Ioc_mod two_pi_pos (-π) θ.to_real = θ.to_real :=
begin
induction θ using real.angle.induction_on,
rw to_real_coe,
exact to_Ioc_mod_to_Ioc_mod _ _ _ _
end
@[simp] lemma to_real_zero : (0 : angle).to_real = 0 :=
begin
rw [←coe_zero, to_real_coe_eq_self_iff],
exact ⟨(left.neg_neg_iff.2 real.pi_pos), real.pi_pos.le⟩
end
@[simp] lemma to_real_eq_zero_iff {θ : angle} : θ.to_real = 0 ↔ θ = 0 :=
begin
nth_rewrite 0 ←to_real_zero,
exact to_real_inj
end
@[simp] lemma to_real_pi : (π : angle).to_real = π :=
begin
rw [to_real_coe_eq_self_iff],
exact ⟨left.neg_lt_self real.pi_pos, le_refl _⟩
end
@[simp] lemma to_real_eq_pi_iff {θ : angle} : θ.to_real = π ↔ θ = π :=
by rw [← to_real_inj, to_real_pi]
lemma pi_ne_zero : (π : angle) ≠ 0 :=
begin
rw [←to_real_injective.ne_iff, to_real_pi, to_real_zero],
exact pi_ne_zero
end
@[simp] lemma to_real_pi_div_two : ((π / 2 : ℝ) : angle).to_real = π / 2 :=
to_real_coe_eq_self_iff.2 $ by split; linarith [pi_pos]
@[simp] lemma to_real_eq_pi_div_two_iff {θ : angle} : θ.to_real = π / 2 ↔ θ = (π / 2 : ℝ) :=
by rw [← to_real_inj, to_real_pi_div_two]
@[simp] lemma to_real_neg_pi_div_two : ((-π / 2 : ℝ) : angle).to_real = -π / 2 :=
to_real_coe_eq_self_iff.2 $ by split; linarith [pi_pos]
@[simp] lemma to_real_eq_neg_pi_div_two_iff {θ : angle} : θ.to_real = -π / 2 ↔ θ = (-π / 2 : ℝ) :=
by rw [← to_real_inj, to_real_neg_pi_div_two]
lemma pi_div_two_ne_zero : ((π / 2 : ℝ) : angle) ≠ 0 :=
begin
rw [←to_real_injective.ne_iff, to_real_pi_div_two, to_real_zero],
exact div_ne_zero real.pi_ne_zero two_ne_zero
end
lemma neg_pi_div_two_ne_zero : ((-π / 2 : ℝ) : angle) ≠ 0 :=
begin
rw [←to_real_injective.ne_iff, to_real_neg_pi_div_two, to_real_zero],
exact div_ne_zero (neg_ne_zero.2 real.pi_ne_zero) two_ne_zero
end
lemma abs_to_real_coe_eq_self_iff {θ : ℝ} : |(θ : angle).to_real| = θ ↔ 0 ≤ θ ∧ θ ≤ π :=
⟨λ h, h ▸ ⟨abs_nonneg _, abs_to_real_le_pi _⟩, λ h,
(to_real_coe_eq_self_iff.2 ⟨(left.neg_neg_iff.2 real.pi_pos).trans_le h.1, h.2⟩).symm ▸
abs_eq_self.2 h.1⟩
lemma abs_to_real_neg_coe_eq_self_iff {θ : ℝ} : |(-θ : angle).to_real| = θ ↔ 0 ≤ θ ∧ θ ≤ π :=
begin
refine ⟨λ h, h ▸ ⟨abs_nonneg _, abs_to_real_le_pi _⟩, λ h, _⟩,
by_cases hnegpi : θ = π, { simp [hnegpi, real.pi_pos.le] },
rw [←coe_neg, to_real_coe_eq_self_iff.2 ⟨neg_lt_neg (lt_of_le_of_ne h.2 hnegpi),
(neg_nonpos.2 h.1).trans real.pi_pos.le⟩, abs_neg,
abs_eq_self.2 h.1]
end
lemma abs_to_real_eq_pi_div_two_iff {θ : angle} :
|θ.to_real| = π / 2 ↔ (θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ)) :=
by rw [abs_eq (div_nonneg real.pi_pos.le two_pos.le), ←neg_div, to_real_eq_pi_div_two_iff,
to_real_eq_neg_pi_div_two_iff]
lemma nsmul_to_real_eq_mul {n : ℕ} (h : n ≠ 0) {θ : angle} :
(n • θ).to_real = n * θ.to_real ↔ θ.to_real ∈ set.Ioc (-π / n) (π / n) :=
begin
nth_rewrite 0 ←coe_to_real θ,
have h' : 0 < (n : ℝ), { exact_mod_cast nat.pos_of_ne_zero h },
rw [←coe_nsmul, nsmul_eq_mul, to_real_coe_eq_self_iff, set.mem_Ioc, div_lt_iff' h',
le_div_iff' h']
end
lemma two_nsmul_to_real_eq_two_mul {θ : angle} :
((2 : ℕ) • θ).to_real = 2 * θ.to_real ↔ θ.to_real ∈ set.Ioc (-π / 2) (π / 2) :=
by exact_mod_cast nsmul_to_real_eq_mul two_ne_zero
lemma two_zsmul_to_real_eq_two_mul {θ : angle} :
((2 : ℤ) • θ).to_real = 2 * θ.to_real ↔ θ.to_real ∈ set.Ioc (-π / 2) (π / 2) :=
by rw [two_zsmul, ←two_nsmul, two_nsmul_to_real_eq_two_mul]
lemma to_real_coe_eq_self_sub_two_mul_int_mul_pi_iff {θ : ℝ} {k : ℤ} :
(θ : angle).to_real = θ - 2 * k * π ↔ θ ∈ set.Ioc ((2 * k - 1 : ℝ) * π) ((2 * k + 1) * π) :=
begin
rw [←sub_zero (θ : angle), ←zsmul_zero k, ←coe_two_pi, ←coe_zsmul, ←coe_sub,
zsmul_eq_mul, ←mul_assoc, mul_comm (k : ℝ), to_real_coe_eq_self_iff, set.mem_Ioc],
exact ⟨λ h, ⟨by linarith, by linarith⟩, λ h, ⟨by linarith, by linarith⟩⟩
end
lemma to_real_coe_eq_self_sub_two_pi_iff {θ : ℝ} :
(θ : angle).to_real = θ - 2 * π ↔ θ ∈ set.Ioc π (3 * π) :=
by { convert @to_real_coe_eq_self_sub_two_mul_int_mul_pi_iff θ 1; norm_num }
lemma to_real_coe_eq_self_add_two_pi_iff {θ : ℝ} :
(θ : angle).to_real = θ + 2 * π ↔ θ ∈ set.Ioc (-3 * π) (-π) :=
by { convert @to_real_coe_eq_self_sub_two_mul_int_mul_pi_iff θ (-1); norm_num }
lemma two_nsmul_to_real_eq_two_mul_sub_two_pi {θ : angle} :
((2 : ℕ) • θ).to_real = 2 * θ.to_real - 2 * π ↔ π / 2 < θ.to_real :=
begin
nth_rewrite 0 ←coe_to_real θ,
rw [←coe_nsmul, two_nsmul, ←two_mul, to_real_coe_eq_self_sub_two_pi_iff, set.mem_Ioc],
exact ⟨λ h, by linarith,
λ h, ⟨(div_lt_iff' (zero_lt_two' ℝ)).1 h, by linarith [pi_pos, to_real_le_pi θ]⟩⟩
end
lemma two_zsmul_to_real_eq_two_mul_sub_two_pi {θ : angle} :
((2 : ℤ) • θ).to_real = 2 * θ.to_real - 2 * π ↔ π / 2 < θ.to_real :=
by rw [two_zsmul, ←two_nsmul, two_nsmul_to_real_eq_two_mul_sub_two_pi]
lemma two_nsmul_to_real_eq_two_mul_add_two_pi {θ : angle} :
((2 : ℕ) • θ).to_real = 2 * θ.to_real + 2 * π ↔ θ.to_real ≤ -π / 2 :=
begin
nth_rewrite 0 ←coe_to_real θ,
rw [←coe_nsmul, two_nsmul, ←two_mul, to_real_coe_eq_self_add_two_pi_iff, set.mem_Ioc],
refine ⟨λ h, by linarith,
λ h, ⟨by linarith [pi_pos, neg_pi_lt_to_real θ], (le_div_iff' (zero_lt_two' ℝ)).1 h⟩⟩
end
lemma two_zsmul_to_real_eq_two_mul_add_two_pi {θ : angle} :
((2 : ℤ) • θ).to_real = 2 * θ.to_real + 2 * π ↔ θ.to_real ≤ -π / 2 :=
by rw [two_zsmul, ←two_nsmul, two_nsmul_to_real_eq_two_mul_add_two_pi]
@[simp] lemma sin_to_real (θ : angle) : real.sin θ.to_real = sin θ :=
by conv_rhs { rw [← coe_to_real θ, sin_coe] }
@[simp] lemma cos_to_real (θ : angle) : real.cos θ.to_real = cos θ :=
by conv_rhs { rw [← coe_to_real θ, cos_coe] }
lemma cos_nonneg_iff_abs_to_real_le_pi_div_two {θ : angle} : 0 ≤ cos θ ↔ |θ.to_real| ≤ π / 2 :=
begin
nth_rewrite 0 ←coe_to_real θ,
rw [abs_le, cos_coe],
refine ⟨λ h, _, cos_nonneg_of_mem_Icc⟩,
by_contra hn,
rw [not_and_distrib, not_le, not_le] at hn,
refine (not_lt.2 h) _,
rcases hn with hn | hn,
{ rw ←real.cos_neg,
refine cos_neg_of_pi_div_two_lt_of_lt (by linarith) _,
linarith [neg_pi_lt_to_real θ] },
{ refine cos_neg_of_pi_div_two_lt_of_lt hn _,
linarith [to_real_le_pi θ] }
end
lemma cos_pos_iff_abs_to_real_lt_pi_div_two {θ : angle} : 0 < cos θ ↔ |θ.to_real| < π / 2 :=
begin
rw [lt_iff_le_and_ne, lt_iff_le_and_ne, cos_nonneg_iff_abs_to_real_le_pi_div_two,
←and_congr_right],
rintro -,
rw [ne.def, ne.def, not_iff_not, @eq_comm ℝ 0, abs_to_real_eq_pi_div_two_iff, cos_eq_zero_iff]
end
lemma cos_neg_iff_pi_div_two_lt_abs_to_real {θ : angle} : cos θ < 0 ↔ π / 2 < |θ.to_real| :=
by rw [←not_le, ←not_le, not_iff_not, cos_nonneg_iff_abs_to_real_le_pi_div_two]
lemma abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi {θ ψ : angle}
(h : (2 : ℕ) • θ + (2 : ℕ) • ψ = π) : |cos θ| = |sin ψ| :=
begin
rw [←eq_sub_iff_add_eq, ←two_nsmul_coe_div_two, ←nsmul_sub, two_nsmul_eq_iff] at h,
rcases h with rfl | rfl;
simp [cos_pi_div_two_sub]
end
lemma abs_cos_eq_abs_sin_of_two_zsmul_add_two_zsmul_eq_pi {θ ψ : angle}
(h : (2 : ℤ) • θ + (2 : ℤ) • ψ = π) : |cos θ| = |sin ψ| :=
begin
simp_rw [two_zsmul, ←two_nsmul] at h,
exact abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi h
end
/-- The tangent of a `real.angle`. -/
def tan (θ : angle) : ℝ := sin θ / cos θ
lemma tan_eq_sin_div_cos (θ : angle) : tan θ = sin θ / cos θ := rfl
@[simp] lemma tan_coe (x : ℝ) : tan (x : angle) = real.tan x :=
by rw [tan, sin_coe, cos_coe, real.tan_eq_sin_div_cos]
@[simp] lemma tan_zero : tan (0 : angle) = 0 :=
by rw [←coe_zero, tan_coe, real.tan_zero]
@[simp] lemma tan_coe_pi : tan (π : angle) = 0 :=
by rw [tan_eq_sin_div_cos, sin_coe_pi, zero_div]
lemma tan_periodic : function.periodic tan (π : angle) :=
begin
intro θ,
induction θ using real.angle.induction_on,
rw [←coe_add, tan_coe, tan_coe],
exact real.tan_periodic θ
end
@[simp] lemma tan_add_pi (θ : angle) : tan (θ + π) = tan θ :=
tan_periodic θ
@[simp] lemma tan_sub_pi (θ : angle) : tan (θ - π) = tan θ :=
tan_periodic.sub_eq θ
@[simp] lemma tan_to_real (θ : angle) : real.tan θ.to_real = tan θ :=
by conv_rhs { rw [←coe_to_real θ, tan_coe] }
lemma tan_eq_of_two_nsmul_eq {θ ψ : angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) : tan θ = tan ψ :=
begin
rw two_nsmul_eq_iff at h,
rcases h with rfl | rfl,
{ refl },
{ exact tan_add_pi _ }
end
lemma tan_eq_of_two_zsmul_eq {θ ψ : angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) : tan θ = tan ψ :=
begin
simp_rw [two_zsmul, ←two_nsmul] at h,
exact tan_eq_of_two_nsmul_eq h
end
lemma tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi {θ ψ : angle}
(h : (2 : ℕ) • θ + (2 : ℕ) • ψ = π) : tan ψ = (tan θ)⁻¹ :=
begin
induction θ using real.angle.induction_on,
induction ψ using real.angle.induction_on,
rw [←smul_add, ←coe_add, ←coe_nsmul, two_nsmul, ←two_mul, angle_eq_iff_two_pi_dvd_sub] at h,
rcases h with ⟨k, h⟩,
rw [sub_eq_iff_eq_add, ←mul_inv_cancel_left₀ two_ne_zero π, mul_assoc, ←mul_add,
mul_right_inj' (two_ne_zero' ℝ), ←eq_sub_iff_add_eq',
mul_inv_cancel_left₀ two_ne_zero π, inv_mul_eq_div, mul_comm] at h,
rw [tan_coe, tan_coe, ←tan_pi_div_two_sub, h, add_sub_assoc, add_comm],
exact real.tan_periodic.int_mul _ _
end
lemma tan_eq_inv_of_two_zsmul_add_two_zsmul_eq_pi {θ ψ : angle}
(h : (2 : ℤ) • θ + (2 : ℤ) • ψ = π) : tan ψ = (tan θ)⁻¹ :=
begin
simp_rw [two_zsmul, ←two_nsmul] at h,
exact tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi h
end
/-- The sign of a `real.angle` is `0` if the angle is `0` or `π`, `1` if the angle is strictly
between `0` and `π` and `-1` is the angle is strictly between `-π` and `0`. It is defined as the
sign of the sine of the angle. -/
def sign (θ : angle) : sign_type := sign (sin θ)
@[simp] lemma sign_zero : (0 : angle).sign = 0 :=
by rw [sign, sin_zero, sign_zero]
@[simp] lemma sign_coe_pi : (π : angle).sign = 0 :=
by rw [sign, sin_coe_pi, _root_.sign_zero]
@[simp] lemma sign_neg (θ : angle) : (-θ).sign = - θ.sign :=
by simp_rw [sign, sin_neg, left.sign_neg]
lemma sign_antiperiodic : function.antiperiodic sign (π : angle) :=
λ θ, by rw [sign, sign, sin_add_pi, left.sign_neg]
@[simp] lemma sign_add_pi (θ : angle) : (θ + π).sign = -θ.sign :=
sign_antiperiodic θ
@[simp] lemma sign_pi_add (θ : angle) : ((π : angle) + θ).sign = -θ.sign :=
by rw [add_comm, sign_add_pi]
@[simp] lemma sign_sub_pi (θ : angle) : (θ - π).sign = -θ.sign :=
sign_antiperiodic.sub_eq θ
@[simp] lemma sign_pi_sub (θ : angle) : ((π : angle) - θ).sign = θ.sign :=
by simp [sign_antiperiodic.sub_eq']
lemma sign_eq_zero_iff {θ : angle} : θ.sign = 0 ↔ θ = 0 ∨ θ = π :=
by rw [sign, sign_eq_zero_iff, sin_eq_zero_iff]
lemma sign_ne_zero_iff {θ : angle} : θ.sign ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π :=
by rw [←not_or_distrib, ←sign_eq_zero_iff]
lemma to_real_neg_iff_sign_neg {θ : angle} : θ.to_real < 0 ↔ θ.sign = -1 :=
begin
rw [sign, ←sin_to_real, sign_eq_neg_one_iff],
rcases lt_trichotomy θ.to_real 0 with (h|h|h),
{ exact ⟨λ _, real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_to_real θ), λ _, h⟩ },
{ simp [h] },
{ exact ⟨λ hn, false.elim (h.asymm hn),
λ hn, false.elim (hn.not_le (sin_nonneg_of_nonneg_of_le_pi h.le (to_real_le_pi θ)))⟩ }
end
lemma to_real_nonneg_iff_sign_nonneg {θ : angle} : 0 ≤ θ.to_real ↔ 0 ≤ θ.sign :=
begin
rcases lt_trichotomy θ.to_real 0 with (h|h|h),
{ refine ⟨λ hn, false.elim (h.not_le hn), λ hn, _⟩,
rw [to_real_neg_iff_sign_neg.1 h] at hn,
exact false.elim (hn.not_lt dec_trivial) },
{ simp [h, sign, ←sin_to_real] },
{ refine ⟨λ _, _, λ _, h.le⟩,
rw [sign, ←sin_to_real, sign_nonneg_iff],
exact sin_nonneg_of_nonneg_of_le_pi h.le (to_real_le_pi θ) }
end
@[simp] lemma sign_to_real {θ : angle} (h : θ ≠ π) : _root_.sign θ.to_real = θ.sign :=
begin
rcases lt_trichotomy θ.to_real 0 with (ht|ht|ht),
{ simp [ht, to_real_neg_iff_sign_neg.1 ht] },
{ simp [sign, ht, ←sin_to_real] },
{ rw [sign, ←sin_to_real, sign_pos ht,
sign_pos (sin_pos_of_pos_of_lt_pi ht
((to_real_le_pi θ).lt_of_ne (to_real_eq_pi_iff.not.2 h)))] }
end
lemma coe_abs_to_real_of_sign_nonneg {θ : angle} (h : 0 ≤ θ.sign) : ↑|θ.to_real| = θ :=
by rw [abs_eq_self.2 (to_real_nonneg_iff_sign_nonneg.2 h), coe_to_real]
lemma neg_coe_abs_to_real_of_sign_nonpos {θ : angle} (h : θ.sign ≤ 0) : -↑|θ.to_real| = θ :=
begin
rw sign_type.nonpos_iff at h,
rcases h with h|h,
{ rw [abs_of_neg (to_real_neg_iff_sign_neg.2 h), coe_neg, neg_neg, coe_to_real] },
{ rw sign_eq_zero_iff at h,
rcases h with rfl|rfl;
simp [abs_of_pos real.pi_pos] }
end
lemma eq_iff_sign_eq_and_abs_to_real_eq {θ ψ : angle} :
θ = ψ ↔ θ.sign = ψ.sign ∧ |θ.to_real| = |ψ.to_real| :=
begin
refine ⟨_, λ h, _⟩, { rintro rfl, exact ⟨rfl, rfl⟩ },
rcases h with ⟨hs, hr⟩,
rw abs_eq_abs at hr,
rcases hr with (hr|hr),
{ exact to_real_injective hr },
{ by_cases h : θ = π,
{ rw [h, to_real_pi, ← neg_eq_iff_eq_neg] at hr,
exact false.elim ((neg_pi_lt_to_real ψ).ne hr) },
{ by_cases h' : ψ = π,
{ rw [h', to_real_pi] at hr,
exact false.elim ((neg_pi_lt_to_real θ).ne hr.symm) },
{ rw [←sign_to_real h, ←sign_to_real h', hr, left.sign_neg, sign_type.neg_eq_self_iff,
_root_.sign_eq_zero_iff, to_real_eq_zero_iff] at hs,
rw [hs, to_real_zero, neg_zero, to_real_eq_zero_iff] at hr,
rw [hr, hs] } } }
end
lemma eq_iff_abs_to_real_eq_of_sign_eq {θ ψ : angle} (h : θ.sign = ψ.sign) :
θ = ψ ↔ |θ.to_real| = |ψ.to_real| :=
by simpa [h] using @eq_iff_sign_eq_and_abs_to_real_eq θ ψ
@[simp] lemma sign_coe_pi_div_two : (↑(π / 2) : angle).sign = 1 :=
by rw [sign, sin_coe, sin_pi_div_two, sign_one]
@[simp] lemma sign_coe_neg_pi_div_two : (↑(-π / 2) : angle).sign = -1 :=
by rw [sign, sin_coe, neg_div, real.sin_neg, sin_pi_div_two, left.sign_neg, sign_one]
lemma sign_coe_nonneg_of_nonneg_of_le_pi {θ : ℝ} (h0 : 0 ≤ θ) (hpi : θ ≤ π) :
0 ≤ (θ : angle).sign :=
begin
rw [sign, sign_nonneg_iff],
exact sin_nonneg_of_nonneg_of_le_pi h0 hpi
end
lemma sign_neg_coe_nonpos_of_nonneg_of_le_pi {θ : ℝ} (h0 : 0 ≤ θ) (hpi : θ ≤ π) :
(-θ : angle).sign ≤ 0 :=
begin
rw [sign, sign_nonpos_iff, sin_neg, left.neg_nonpos_iff],
exact sin_nonneg_of_nonneg_of_le_pi h0 hpi
end
lemma sign_two_nsmul_eq_sign_iff {θ : angle} :
((2 : ℕ) • θ).sign = θ.sign ↔ (θ = π ∨ |θ.to_real| < π / 2) :=
begin
by_cases hpi : θ = π, { simp [hpi] },
rw or_iff_right hpi,
refine ⟨λ h, _, λ h, _⟩,
{ by_contra hle,
rw [not_lt, le_abs, le_neg] at hle,
have hpi' : θ.to_real ≠ π, { simpa using hpi },
rcases hle with hle | hle; rcases hle.eq_or_lt with heq | hlt,
{ rw [←coe_to_real θ, ←heq] at h, simpa using h },
{ rw [←sign_to_real hpi, sign_pos (pi_div_two_pos.trans hlt),
←sign_to_real, two_nsmul_to_real_eq_two_mul_sub_two_pi.2 hlt, _root_.sign_neg] at h,
{ simpa using h },
{ rw ←mul_sub,
exact mul_neg_of_pos_of_neg two_pos (sub_neg.2 ((to_real_le_pi _).lt_of_ne hpi')) },
{ intro he, simpa [he] using h } },
{ rw [←coe_to_real θ, heq] at h, simpa using h },
{ rw [←sign_to_real hpi,
_root_.sign_neg (hlt.trans (left.neg_neg_iff.2 pi_div_two_pos)),
←sign_to_real] at h, swap, { intro he, simpa [he] using h },
rw ←neg_div at hlt,
rw [two_nsmul_to_real_eq_two_mul_add_two_pi.2 hlt.le, sign_pos] at h,
{ simpa using h },
{ linarith [neg_pi_lt_to_real θ] } } },
{ have hpi' : (2 : ℕ) • θ ≠ π,
{ rw [ne.def, two_nsmul_eq_pi_iff, not_or_distrib],
split,
{ rintro rfl, simpa [pi_pos, div_pos, abs_of_pos] using h },
{ rintro rfl,
rw [to_real_neg_pi_div_two] at h,
simpa [pi_pos, div_pos, neg_div, abs_of_pos] using h } },
rw [abs_lt, ←neg_div] at h,
rw [←sign_to_real hpi, ←sign_to_real hpi', two_nsmul_to_real_eq_two_mul.2 ⟨h.1, h.2.le⟩,
sign_mul, sign_pos (zero_lt_two' ℝ), one_mul] }
end
lemma sign_two_zsmul_eq_sign_iff {θ : angle} :
((2 : ℤ) • θ).sign = θ.sign ↔ (θ = π ∨ |θ.to_real| < π / 2) :=
by rw [two_zsmul, ←two_nsmul, sign_two_nsmul_eq_sign_iff]
lemma continuous_at_sign {θ : angle} (h0 : θ ≠ 0) (hpi : θ ≠ π) : continuous_at sign θ :=
(continuous_at_sign_of_ne_zero (sin_ne_zero_iff.2 ⟨h0, hpi⟩)).comp continuous_sin.continuous_at
lemma _root_.continuous_on.angle_sign_comp {α : Type*} [topological_space α] {f : α → angle}
{s : set α} (hf : continuous_on f s) (hs : ∀ z ∈ s, f z ≠ 0 ∧ f z ≠ π) :
continuous_on (sign ∘ f) s :=
begin
refine (continuous_at.continuous_on (λ θ hθ, _)).comp hf (set.maps_to_image f s),
obtain ⟨z, hz, rfl⟩ := hθ,
exact continuous_at_sign (hs _ hz).1 (hs _ hz).2
end
/-- Suppose a function to angles is continuous on a connected set and never takes the values `0`
or `π` on that set. Then the values of the function on that set all have the same sign. -/
lemma sign_eq_of_continuous_on {α : Type*} [topological_space α] {f : α → angle} {s : set α}
{x y : α} (hc : is_connected s) (hf : continuous_on f s) (hs : ∀ z ∈ s, f z ≠ 0 ∧ f z ≠ π)
(hx : x ∈ s) (hy : y ∈ s) : (f y).sign = (f x).sign :=
(hc.image _ (hf.angle_sign_comp hs)).is_preconnected.subsingleton
(set.mem_image_of_mem _ hy) (set.mem_image_of_mem _ hx)
end angle
end real
|
16ab1d171c8d1d2e5cbf71ff710e2a9a9e38eece | 6e41ee3ac9b96e8980a16295cc21f131e731884f | /tests/lean/slow/nat_bug2.lean | 883f3b33a5091c560488e0e08bfa5d0eefcf22cf | [
"Apache-2.0"
] | permissive | EgbertRijke/lean | 3426cfa0e5b3d35d12fc3fd7318b35574cb67dc3 | 4f2e0c6d7fc9274d953cfa1c37ab2f3e799ab183 | refs/heads/master | 1,610,834,871,476 | 1,422,159,801,000 | 1,422,159,801,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 49,288 | lean | ----------------------------------------------------------------------------------------------------
-- Copyright (c) 2014 Floris van Doorn. All rights reserved.
-- Released under Apache 2.0 license as described in the file LICENSE.
-- Author: Floris van Doorn
----------------------------------------------------------------------------------------------------
import logic algebra.binary
open tactic binary eq.ops eq
open decidable
namespace experiment
definition refl := @eq.refl
definition and_intro := @and.intro
definition or_intro_left := @or.intro_left
definition or_intro_right := @or.intro_right
inductive nat : Type :=
zero : nat,
succ : nat → nat
namespace nat
notation `ℕ`:max := nat
definition plus (x y : ℕ) : ℕ
:= nat.rec x (λ n r, succ r) y
definition to_nat [coercion] (n : num) : ℕ
:= num.rec zero (λ n, pos_num.rec (succ zero) (λ n r, plus r (plus r (succ zero))) (λ n r, plus r r) n) n
namespace helper_tactics
definition apply_refl := apply @refl
tactic_hint apply_refl
end helper_tactics
open helper_tactics
theorem nat_rec_zero {P : ℕ → Type} (x : P 0) (f : ∀m, P m → P (succ m)) : nat.rec x f 0 = x
theorem nat_rec_succ {P : ℕ → Type} (x : P 0) (f : ∀m, P m → P (succ m)) (n : ℕ) : nat.rec x f (succ n) = f n (nat.rec x f n)
-------------------------------------------------- succ pred
theorem succ_ne_zero (n : ℕ) : succ n ≠ 0
:= assume H : succ n = 0,
have H2 : true = false, from
let f := (nat.rec false (fun a b, true)) in
calc true = f (succ n) : _
... = f 0 : {H}
... = false : _,
absurd H2 true_ne_false
definition pred (n : ℕ) := nat.rec 0 (fun m x, m) n
theorem pred_zero : pred 0 = 0
theorem pred_succ (n : ℕ) : pred (succ n) = n
theorem zero_or_succ (n : ℕ) : n = 0 ∨ n = succ (pred n)
:= induction_on n
(or.intro_left _ (refl 0))
(take m IH, or.intro_right _
(show succ m = succ (pred (succ m)), from congr_arg succ (pred_succ m⁻¹)))
theorem zero_or_succ2 (n : ℕ) : n = 0 ∨ ∃k, n = succ k
:= or_of_or_of_imp_of_imp (zero_or_succ n) (assume H, H) (assume H : n = succ (pred n), exists.intro (pred n) H)
theorem case {P : ℕ → Prop} (n : ℕ) (H1: P 0) (H2 : ∀m, P (succ m)) : P n
:= induction_on n H1 (take m IH, H2 m)
theorem discriminate {B : Prop} {n : ℕ} (H1: n = 0 → B) (H2 : ∀m, n = succ m → B) : B
:= or.elim (zero_or_succ n)
(take H3 : n = 0, H1 H3)
(take H3 : n = succ (pred n), H2 (pred n) H3)
theorem succ_inj {n m : ℕ} (H : succ n = succ m) : n = m
:= calc
n = pred (succ n) : pred_succ n⁻¹
... = pred (succ m) : {H}
... = m : pred_succ m
theorem succ_ne_self (n : ℕ) : succ n ≠ n
:= induction_on n
(take H : 1 = 0,
have ne : 1 ≠ 0, from succ_ne_zero 0,
absurd H ne)
(take k IH H, IH (succ_inj H))
theorem decidable_eq [instance] (n m : ℕ) : decidable (n = m)
:= have general : ∀n, decidable (n = m), from
rec_on m
(take n,
rec_on n
(inl (refl 0))
(λ m iH, inr (succ_ne_zero m)))
(λ (m' : ℕ) (iH1 : ∀n, decidable (n = m')),
take n, rec_on n
(inr (ne.symm (succ_ne_zero m')))
(λ (n' : ℕ) (iH2 : decidable (n' = succ m')),
have d1 : decidable (n' = m'), from iH1 n',
decidable.rec_on d1
(assume Heq : n' = m', inl (congr_arg succ Heq))
(assume Hne : n' ≠ m',
have H1 : succ n' ≠ succ m', from
assume Heq, absurd (succ_inj Heq) Hne,
inr H1))),
general n
theorem two_step_induction_on {P : ℕ → Prop} (a : ℕ) (H1 : P 0) (H2 : P 1)
(H3 : ∀ (n : ℕ) (IH1 : P n) (IH2 : P (succ n)), P (succ (succ n))) : P a
:= have stronger : P a ∧ P (succ a), from
induction_on a
(and_intro H1 H2)
(take k IH,
have IH1 : P k, from and.elim_left IH,
have IH2 : P (succ k), from and.elim_right IH,
and_intro IH2 (H3 k IH1 IH2)),
and.elim_left stronger
theorem sub_induction {P : ℕ → ℕ → Prop} (n m : ℕ) (H1 : ∀m, P 0 m)
(H2 : ∀n, P (succ n) 0) (H3 : ∀n m, P n m → P (succ n) (succ m)) : P n m
:= have general : ∀m, P n m, from induction_on n
(take m : ℕ, H1 m)
(take k : ℕ,
assume IH : ∀m, P k m,
take m : ℕ,
discriminate
(assume Hm : m = 0,
Hm⁻¹ ▸ (H2 k))
(take l : ℕ,
assume Hm : m = succ l,
Hm⁻¹ ▸ (H3 k l (IH l)))),
general m
-------------------------------------------------- add
definition add (x y : ℕ) : ℕ := plus x y
infixl `+` := add
theorem add_zero (n : ℕ) : n + 0 = n
theorem add_succ (n m : ℕ) : n + succ m = succ (n + m)
---------- comm, assoc
theorem zero_add (n : ℕ) : 0 + n = n
:= induction_on n
(add_zero 0)
(take m IH, show 0 + succ m = succ m, from
calc
0 + succ m = succ (0 + m) : add_succ _ _
... = succ m : {IH})
theorem succ_add (n m : ℕ) : (succ n) + m = succ (n + m)
:= induction_on m
(calc
succ n + 0 = succ n : add_zero (succ n)
... = succ (n + 0) : {symm (add_zero n)})
(take k IH,
calc
succ n + succ k = succ (succ n + k) : add_succ _ _
... = succ (succ (n + k)) : {IH}
... = succ (n + succ k) : {symm (add_succ _ _)})
theorem add_comm (n m : ℕ) : n + m = m + n
:= induction_on m
(trans (add_zero _) (symm (zero_add _)))
(take k IH,
calc
n + succ k = succ (n+k) : add_succ _ _
... = succ (k + n) : {IH}
... = succ k + n : symm (succ_add _ _))
theorem succ_add_eq_add_succ (n m : ℕ) : succ n + m = n + succ m
:= calc
succ n + m = succ (n + m) : succ_add n m
... = n +succ m : symm (add_succ n m)
theorem add_comm_succ (n m : ℕ) : n + succ m = m + succ n
:= calc
n + succ m = succ n + m : symm (succ_add_eq_add_succ n m)
... = m + succ n : add_comm (succ n) m
theorem add_assoc (n m k : ℕ) : (n + m) + k = n + (m + k)
:= induction_on k
(calc
(n + m) + 0 = n + m : add_zero _
... = n + (m + 0) : {symm (add_zero m)})
(take l IH,
calc
(n + m) + succ l = succ ((n + m) + l) : add_succ _ _
... = succ (n + (m + l)) : {IH}
... = n + succ (m + l) : symm (add_succ _ _)
... = n + (m + succ l) : {symm (add_succ _ _)})
theorem add_left_comm (n m k : ℕ) : n + (m + k) = m + (n + k)
:= left_comm add_comm add_assoc n m k
theorem add_right_comm (n m k : ℕ) : n + m + k = n + k + m
:= right_comm add_comm add_assoc n m k
---------- inversion
theorem add_cancel_left {n m k : ℕ} : n + m = n + k → m = k
:=
induction_on n
(take H : 0 + m = 0 + k,
calc
m = 0 + m : symm (zero_add m)
... = 0 + k : H
... = k : zero_add k)
(take (n : ℕ) (IH : n + m = n + k → m = k) (H : succ n + m = succ n + k),
have H2 : succ (n + m) = succ (n + k),
from calc
succ (n + m) = succ n + m : symm (succ_add n m)
... = succ n + k : H
... = succ (n + k) : succ_add n k,
have H3 : n + m = n + k, from succ_inj H2,
IH H3)
--rename to and_cancel_right
theorem add_cancel_right {n m k : ℕ} (H : n + m = k + m) : n = k
:=
have H2 : m + n = m + k,
from calc
m + n = n + m : add_comm m n
... = k + m : H
... = m + k : add_comm k m,
add_cancel_left H2
theorem eq_zero_of_add_eq_zero_right {n m : ℕ} : n + m = 0 → n = 0
:=
induction_on n
(take (H : 0 + m = 0), refl 0)
(take k IH,
assume (H : succ k + m = 0),
absurd
(show succ (k + m) = 0, from
calc
succ (k + m) = succ k + m : symm (succ_add k m)
... = 0 : H)
(succ_ne_zero (k + m)))
theorem add_eq_zero_right {n m : ℕ} (H : n + m = 0) : m = 0
:= eq_zero_of_add_eq_zero_right (trans (add_comm m n) H)
theorem add_eq_zero {n m : ℕ} (H : n + m = 0) : n = 0 ∧ m = 0
:= and_intro (eq_zero_of_add_eq_zero_right H) (add_eq_zero_right H)
-- add_eq_self below
---------- misc
theorem add_one (n:ℕ) : n + 1 = succ n
:=
calc
n + 1 = succ (n + 0) : add_succ _ _
... = succ n : {add_zero _}
theorem add_one_left (n:ℕ) : 1 + n = succ n
:=
calc
1 + n = succ (0 + n) : succ_add _ _
... = succ n : {zero_add _}
--the following theorem has a terrible name, but since the name is not a substring or superstring of another name, it is at least easy to globally replace it
theorem induction_plus_one {P : ℕ → Prop} (a : ℕ) (H1 : P 0)
(H2 : ∀ (n : ℕ) (IH : P n), P (n + 1)) : P a
:= nat.rec H1 (take n IH, (add_one n) ▸ (H2 n IH)) a
-------------------------------------------------- mul
definition mul (n m : ℕ) := nat.rec 0 (fun m x, x + n) m
infixl `*` := mul
theorem mul_zero_right (n:ℕ) : n * 0 = 0
theorem mul_succ_right (n m:ℕ) : n * succ m = n * m + n
set_option unifier.max_steps 100000
---------- comm, distr, assoc, identity
theorem mul_zero_left (n:ℕ) : 0 * n = 0
:= induction_on n
(mul_zero_right 0)
(take m IH,
calc
0 * succ m = 0 * m + 0 : mul_succ_right _ _
... = 0 * m : add_zero _
... = 0 : IH)
theorem mul_succ_left (n m:ℕ) : (succ n) * m = (n * m) + m
:= induction_on m
(calc
succ n * 0 = 0 : mul_zero_right _
... = n * 0 : symm (mul_zero_right _)
... = n * 0 + 0 : symm (add_zero _))
(take k IH,
calc
succ n * succ k = (succ n * k) + succ n : mul_succ_right _ _
... = (n * k) + k + succ n : { IH }
... = (n * k) + (k + succ n) : add_assoc _ _ _
... = (n * k) + (n + succ k) : {add_comm_succ _ _}
... = (n * k) + n + succ k : symm (add_assoc _ _ _)
... = (n * succ k) + succ k : {symm (mul_succ_right n k)})
theorem mul_comm (n m:ℕ) : n * m = m * n
:= induction_on m
(trans (mul_zero_right _) (symm (mul_zero_left _)))
(take k IH,
calc
n * succ k = n * k + n : mul_succ_right _ _
... = k * n + n : {IH}
... = (succ k) * n : symm (mul_succ_left _ _))
theorem mul_add_distr_left (n m k : ℕ) : (n + m) * k = n * k + m * k
:= induction_on k
(calc
(n + m) * 0 = 0 : mul_zero_right _
... = 0 + 0 : symm (add_zero _)
... = n * 0 + 0 : refl _
... = n * 0 + m * 0 : refl _)
(take l IH, calc
(n + m) * succ l = (n + m) * l + (n + m) : mul_succ_right _ _
... = n * l + m * l + (n + m) : {IH}
... = n * l + m * l + n + m : symm (add_assoc _ _ _)
... = n * l + n + m * l + m : {add_right_comm _ _ _}
... = n * l + n + (m * l + m) : add_assoc _ _ _
... = n * succ l + (m * l + m) : {symm (mul_succ_right _ _)}
... = n * succ l + m * succ l : {symm (mul_succ_right _ _)})
theorem mul_add_distr_right (n m k : ℕ) : n * (m + k) = n * m + n * k
:= calc
n * (m + k) = (m + k) * n : mul_comm _ _
... = m * n + k * n : mul_add_distr_left _ _ _
... = n * m + k * n : {mul_comm _ _}
... = n * m + n * k : {mul_comm _ _}
theorem mul_assoc (n m k:ℕ) : (n * m) * k = n * (m * k)
:= induction_on k
(calc
(n * m) * 0 = 0 : mul_zero_right _
... = n * 0 : symm (mul_zero_right _)
... = n * (m * 0) : {symm (mul_zero_right _)})
(take l IH,
calc
(n * m) * succ l = (n * m) * l + n * m : mul_succ_right _ _
... = n * (m * l) + n * m : {IH}
... = n * (m * l + m) : symm (mul_add_distr_right _ _ _)
... = n * (m * succ l) : {symm (mul_succ_right _ _)})
theorem mul_comm_left (n m k : ℕ) : n * (m * k) = m * (n * k)
:= left_comm mul_comm mul_assoc n m k
theorem mul_comm_right (n m k : ℕ) : n * m * k = n * k * m
:= right_comm mul_comm mul_assoc n m k
theorem mul_one_right (n : ℕ) : n * 1 = n
:= calc
n * 1 = n * 0 + n : mul_succ_right n 0
... = 0 + n : {mul_zero_right n}
... = n : zero_add n
theorem mul_one_left (n : ℕ) : 1 * n = n
:= calc
1 * n = n * 1 : mul_comm _ _
... = n : mul_one_right n
---------- inversion
theorem mul_eq_zero {n m : ℕ} (H : n * m = 0) : n = 0 ∨ m = 0
:=
discriminate
(take Hn : n = 0, or_intro_left _ Hn)
(take (k : ℕ),
assume (Hk : n = succ k),
discriminate
(take (Hm : m = 0), or_intro_right _ Hm)
(take (l : ℕ),
assume (Hl : m = succ l),
have Heq : succ (k * succ l + l) = n * m, from
symm (calc
n * m = n * succ l : { Hl }
... = succ k * succ l : { Hk }
... = k * succ l + succ l : mul_succ_left _ _
... = succ (k * succ l + l) : add_succ _ _),
absurd (trans Heq H) (succ_ne_zero _)))
-- see more under "positivity" below
-------------------------------------------------- le
definition le (n m:ℕ) : Prop := ∃k, n + k = m
infix `<=` := le
infix `≤` := le
theorem le_intro {n m k : ℕ} (H : n + k = m) : n ≤ m
:= exists.intro k H
theorem le_elim {n m : ℕ} (H : n ≤ m) : ∃ k, n + k = m
:= H
---------- partial order (totality is part of lt)
theorem le_intro2 (n m : ℕ) : n ≤ n + m
:= le_intro (refl (n + m))
theorem le_refl (n : ℕ) : n ≤ n
:= le_intro (add_zero n)
theorem zero_le (n : ℕ) : 0 ≤ n
:= le_intro (zero_add n)
theorem le_zero {n : ℕ} (H : n ≤ 0) : n = 0
:=
obtain (k : ℕ) (Hk : n + k = 0), from le_elim H,
eq_zero_of_add_eq_zero_right Hk
theorem not_succ_zero_le (n : ℕ) : ¬ succ n ≤ 0
:= assume H : succ n ≤ 0,
have H2 : succ n = 0, from le_zero H,
absurd H2 (succ_ne_zero n)
theorem le_zero_inv {n : ℕ} (H : n ≤ 0) : n = 0
:= obtain (k : ℕ) (Hk : n + k = 0), from le_elim H,
eq_zero_of_add_eq_zero_right Hk
theorem le_trans {n m k : ℕ} (H1 : n ≤ m) (H2 : m ≤ k) : n ≤ k
:= obtain (l1 : ℕ) (Hl1 : n + l1 = m), from le_elim H1,
obtain (l2 : ℕ) (Hl2 : m + l2 = k), from le_elim H2,
le_intro
(calc
n + (l1 + l2) = n + l1 + l2 : symm (add_assoc n l1 l2)
... = m + l2 : { Hl1 }
... = k : Hl2)
theorem le_antisym {n m : ℕ} (H1 : n ≤ m) (H2 : m ≤ n) : n = m
:= obtain (k : ℕ) (Hk : n + k = m), from (le_elim H1),
obtain (l : ℕ) (Hl : m + l = n), from (le_elim H2),
have L1 : k + l = 0, from
add_cancel_left
(calc
n + (k + l) = n + k + l : { symm (add_assoc n k l) }
... = m + l : { Hk }
... = n : Hl
... = n + 0 : symm (add_zero n)),
have L2 : k = 0, from eq_zero_of_add_eq_zero_right L1,
calc
n = n + 0 : symm (add_zero n)
... = n + k : { symm L2 }
... = m : Hk
---------- interaction with add
theorem add_le_left {n m : ℕ} (H : n ≤ m) (k : ℕ) : k + n ≤ k + m
:= obtain (l : ℕ) (Hl : n + l = m), from (le_elim H),
le_intro
(calc
k + n + l = k + (n + l) : add_assoc k n l
... = k + m : { Hl })
theorem add_le_right {n m : ℕ} (H : n ≤ m) (k : ℕ) : n + k ≤ m + k
:= (add_comm k m) ▸ (add_comm k n) ▸ (add_le_left H k)
theorem add_le {n m k l : ℕ} (H1 : n ≤ k) (H2 : m ≤ l) : n + m ≤ k + l
:= le_trans (add_le_right H1 m) (add_le_left H2 k)
theorem add_le_left_inv {n m k : ℕ} (H : k + n ≤ k + m) : n ≤ m
:=
obtain (l : ℕ) (Hl : k + n + l = k + m), from (le_elim H),
le_intro (add_cancel_left
(calc
k + (n + l) = k + n + l : symm (add_assoc k n l)
... = k + m : Hl))
theorem add_le_right_inv {n m k : ℕ} (H : n + k ≤ m + k) : n ≤ m
:= add_le_left_inv (add_comm m k ▸ add_comm n k ▸ H)
---------- interaction with succ and pred
theorem succ_le {n m : ℕ} (H : n ≤ m) : succ n ≤ succ m
:= add_one m ▸ add_one n ▸ add_le_right H 1
theorem succ_le_cancel {n m : ℕ} (H : succ n ≤ succ m) : n ≤ m
:= add_le_right_inv (add_one m⁻¹ ▸ add_one n⁻¹ ▸ H)
theorem self_le_succ (n : ℕ) : n ≤ succ n
:= le_intro (add_one n)
theorem le_imp_le_succ {n m : ℕ} (H : n ≤ m) : n ≤ succ m
:= le_trans H (self_le_succ m)
theorem succ_le_left_or {n m : ℕ} (H : n ≤ m) : succ n ≤ m ∨ n = m
:= obtain (k : ℕ) (Hk : n + k = m), from (le_elim H),
discriminate
(assume H3 : k = 0,
have Heq : n = m,
from calc
n = n + 0 : (add_zero n)⁻¹
... = n + k : {H3⁻¹}
... = m : Hk,
or_intro_right _ Heq)
(take l:ℕ,
assume H3 : k = succ l,
have Hlt : succ n ≤ m, from
(le_intro
(calc
succ n + l = n + succ l : succ_add_eq_add_succ n l
... = n + k : {H3⁻¹}
... = m : Hk)),
or_intro_left _ Hlt)
theorem succ_le_left {n m : ℕ} (H1 : n ≤ m) (H2 : n ≠ m) : succ n ≤ m
:= or_resolve_left (succ_le_left_or H1) H2
theorem succ_le_right_inv {n m : ℕ} (H : n ≤ succ m) : n ≤ m ∨ n = succ m
:= or_of_or_of_imp_of_imp (succ_le_left_or H)
(take H2 : succ n ≤ succ m, show n ≤ m, from succ_le_cancel H2)
(take H2 : n = succ m, H2)
theorem succ_le_left_inv {n m : ℕ} (H : succ n ≤ m) : n ≤ m ∧ n ≠ m
:= obtain (k : ℕ) (H2 : succ n + k = m), from (le_elim H),
and_intro
(have H3 : n + succ k = m,
from calc
n + succ k = succ n + k : symm (succ_add_eq_add_succ n k)
... = m : H2,
show n ≤ m, from le_intro H3)
(assume H3 : n = m,
have H4 : succ n ≤ n, from subst (symm H3) H,
have H5 : succ n = n, from le_antisym H4 (self_le_succ n),
show false, from absurd H5 (succ_ne_self n))
theorem le_pred_self (n : ℕ) : pred n ≤ n
:= case n
(subst (symm pred_zero) (le_refl 0))
(take k : ℕ, subst (symm (pred_succ k)) (self_le_succ k))
theorem pred_le {n m : ℕ} (H : n ≤ m) : pred n ≤ pred m
:= discriminate
(take Hn : n = 0,
have H2 : pred n = 0,
from calc
pred n = pred 0 : {Hn}
... = 0 : pred_zero,
subst (symm H2) (zero_le (pred m)))
(take k : ℕ,
assume Hn : n = succ k,
obtain (l : ℕ) (Hl : n + l = m), from le_elim H,
have H2 : pred n + l = pred m,
from calc
pred n + l = pred (succ k) + l : {Hn}
... = k + l : {pred_succ k}
... = pred (succ (k + l)) : symm (pred_succ (k + l))
... = pred (succ k + l) : {symm (succ_add k l)}
... = pred (n + l) : {symm Hn}
... = pred m : {Hl},
le_intro H2)
theorem pred_le_left_inv {n m : ℕ} (H : pred n ≤ m) : n ≤ m ∨ n = succ m
:= discriminate
(take Hn : n = 0,
or_intro_left _ (subst (symm Hn) (zero_le m)))
(take k : ℕ,
assume Hn : n = succ k,
have H2 : pred n = k,
from calc
pred n = pred (succ k) : {Hn}
... = k : pred_succ k,
have H3 : k ≤ m, from subst H2 H,
have H4 : succ k ≤ m ∨ k = m, from succ_le_left_or H3,
show n ≤ m ∨ n = succ m, from
or_of_or_of_imp_of_imp H4
(take H5 : succ k ≤ m, show n ≤ m, from subst (symm Hn) H5)
(take H5 : k = m, show n = succ m, from subst H5 Hn))
-- ### interaction with successor and predecessor
theorem le_imp_succ_le_or_eq {n m : ℕ} (H : n ≤ m) : succ n ≤ m ∨ n = m
:=
obtain (k : ℕ) (Hk : n + k = m), from (le_elim H),
discriminate
(assume H3 : k = 0,
have Heq : n = m,
from calc
n = n + 0 : symm (add_zero n)
... = n + k : {symm H3}
... = m : Hk,
or_intro_right _ Heq)
(take l : nat,
assume H3 : k = succ l,
have Hlt : succ n ≤ m, from
(le_intro
(calc
succ n + l = n + succ l : succ_add_eq_add_succ n l
... = n + k : {symm H3}
... = m : Hk)),
or_intro_left _ Hlt)
theorem le_ne_imp_succ_le {n m : ℕ} (H1 : n ≤ m) (H2 : n ≠ m) : succ n ≤ m
:= or_resolve_left (le_imp_succ_le_or_eq H1) H2
theorem succ_le_imp_le_and_ne {n m : ℕ} (H : succ n ≤ m) : n ≤ m ∧ n ≠ m
:=
and_intro
(le_trans (self_le_succ n) H)
(assume H2 : n = m,
have H3 : succ n ≤ n, from subst (symm H2) H,
have H4 : succ n = n, from le_antisym H3 (self_le_succ n),
show false, from absurd H4 (succ_ne_self n))
theorem pred_le_self (n : ℕ) : pred n ≤ n
:=
case n
(subst (symm pred_zero) (le_refl 0))
(take k : nat, subst (symm (pred_succ k)) (self_le_succ k))
theorem pred_le_imp_le_or_eq {n m : ℕ} (H : pred n ≤ m) : n ≤ m ∨ n = succ m
:=
discriminate
(take Hn : n = 0,
or_intro_left _ (subst (symm Hn) (zero_le m)))
(take k : nat,
assume Hn : n = succ k,
have H2 : pred n = k,
from calc
pred n = pred (succ k) : {Hn}
... = k : pred_succ k,
have H3 : k ≤ m, from subst H2 H,
have H4 : succ k ≤ m ∨ k = m, from le_imp_succ_le_or_eq H3,
show n ≤ m ∨ n = succ m, from
or_of_or_of_imp_of_imp H4
(take H5 : succ k ≤ m, show n ≤ m, from subst (symm Hn) H5)
(take H5 : k = m, show n = succ m, from subst H5 Hn))
---------- interaction with mul
theorem mul_le_left {n m : ℕ} (H : n ≤ m) (k : ℕ) : k * n ≤ k * m
:=
obtain (l : ℕ) (Hl : n + l = m), from (le_elim H),
induction_on k
(have H2 : 0 * n = 0 * m,
from calc
0 * n = 0 : mul_zero_left n
... = 0 * m : symm (mul_zero_left m),
show 0 * n ≤ 0 * m, from subst H2 (le_refl (0 * n)))
(take (l : ℕ),
assume IH : l * n ≤ l * m,
have H2 : l * n + n ≤ l * m + m, from add_le IH H,
have H3 : succ l * n ≤ l * m + m, from subst (symm (mul_succ_left l n)) H2,
show succ l * n ≤ succ l * m, from subst (symm (mul_succ_left l m)) H3)
theorem mul_le_right {n m : ℕ} (H : n ≤ m) (k : ℕ) : n * k ≤ m * k
:= mul_comm k m ▸ mul_comm k n ▸ (mul_le_left H k)
theorem mul_le {n m k l : ℕ} (H1 : n ≤ k) (H2 : m ≤ l) : n * m ≤ k * l
:= le_trans (mul_le_right H1 m) (mul_le_left H2 k)
-- mul_le_[left|right]_inv below
-------------------------------------------------- lt
definition lt (n m : ℕ) := succ n ≤ m
infix `<` := lt
theorem lt_intro {n m k : ℕ} (H : succ n + k = m) : n < m
:= le_intro H
theorem lt_elim {n m : ℕ} (H : n < m) : ∃ k, succ n + k = m
:= le_elim H
theorem lt_intro2 (n m : ℕ) : n < n + succ m
:= lt_intro (succ_add_eq_add_succ n m)
-------------------------------------------------- ge, gt
definition ge (n m : ℕ) := m ≤ n
infix `>=` := ge
infix `≥` := ge
definition gt (n m : ℕ) := m < n
infix `>` := gt
---------- basic facts
theorem lt_ne {n m : ℕ} (H : n < m) : n ≠ m
:= and.elim_right (succ_le_left_inv H)
theorem lt_irrefl (n : ℕ) : ¬ n < n
:= assume H : n < n, absurd (refl n) (lt_ne H)
theorem lt_zero (n : ℕ) : 0 < succ n
:= succ_le (zero_le n)
theorem lt_zero_inv (n : ℕ) : ¬ n < 0
:= assume H : n < 0,
have H2 : succ n = 0, from le_zero_inv H,
absurd H2 (succ_ne_zero n)
theorem lt_positive {n m : ℕ} (H : n < m) : ∃k, m = succ k
:= discriminate
(take (Hm : m = 0), absurd (subst Hm H) (lt_zero_inv n))
(take (l : ℕ) (Hm : m = succ l), exists.intro l Hm)
---------- interaction with le
theorem lt_imp_le_succ {n m : ℕ} (H : n < m) : succ n ≤ m
:= H
theorem le_succ_imp_lt {n m : ℕ} (H : succ n ≤ m) : n < m
:= H
theorem self_lt_succ (n : ℕ) : n < succ n
:= le_refl (succ n)
theorem lt_imp_le {n m : ℕ} (H : n < m) : n ≤ m
:= and.elim_left (succ_le_imp_le_and_ne H)
theorem le_imp_lt_or_eq {n m : ℕ} (H : n ≤ m) : n < m ∨ n = m
:= le_imp_succ_le_or_eq H
theorem le_ne_imp_lt {n m : ℕ} (H1 : n ≤ m) (H2 : n ≠ m) : n < m
:= le_ne_imp_succ_le H1 H2
theorem le_imp_lt_succ {n m : ℕ} (H : n ≤ m) : n < succ m
:= succ_le H
theorem lt_succ_imp_le {n m : ℕ} (H : n < succ m) : n ≤ m
:= succ_le_cancel H
---------- trans, antisym
theorem lt_le_trans {n m k : ℕ} (H1 : n < m) (H2 : m ≤ k) : n < k
:= le_trans H1 H2
theorem le_lt_trans {n m k : ℕ} (H1 : n ≤ m) (H2 : m < k) : n < k
:= le_trans (succ_le H1) H2
theorem lt_trans {n m k : ℕ} (H1 : n < m) (H2 : m < k) : n < k
:= lt_le_trans H1 (lt_imp_le H2)
theorem le_imp_not_gt {n m : ℕ} (H : n ≤ m) : ¬ n > m
:= assume H2 : m < n, absurd (le_lt_trans H H2) (lt_irrefl n)
theorem lt_imp_not_ge {n m : ℕ} (H : n < m) : ¬ n ≥ m
:= assume H2 : m ≤ n, absurd (lt_le_trans H H2) (lt_irrefl n)
theorem lt_antisym {n m : ℕ} (H : n < m) : ¬ m < n
:= le_imp_not_gt (lt_imp_le H)
---------- interaction with add
theorem add_lt_left {n m : ℕ} (H : n < m) (k : ℕ) : k + n < k + m
:= add_succ k n ▸ add_le_left H k
theorem add_lt_right {n m : ℕ} (H : n < m) (k : ℕ) : n + k < m + k
:= add_comm k m ▸ add_comm k n ▸ add_lt_left H k
theorem add_le_lt {n m k l : ℕ} (H1 : n ≤ k) (H2 : m < l) : n + m < k + l
:= le_lt_trans (add_le_right H1 m) (add_lt_left H2 k)
theorem add_lt_le {n m k l : ℕ} (H1 : n < k) (H2 : m ≤ l) : n + m < k + l
:= lt_le_trans (add_lt_right H1 m) (add_le_left H2 k)
theorem add_lt {n m k l : ℕ} (H1 : n < k) (H2 : m < l) : n + m < k + l
:= add_lt_le H1 (lt_imp_le H2)
theorem add_lt_left_inv {n m k : ℕ} (H : k + n < k + m) : n < m
:= add_le_left_inv (add_succ k n⁻¹ ▸ H)
theorem add_lt_right_inv {n m k : ℕ} (H : n + k < m + k) : n < m
:= add_lt_left_inv (add_comm m k ▸ add_comm n k ▸ H)
---------- interaction with succ (see also the interaction with le)
theorem succ_lt {n m : ℕ} (H : n < m) : succ n < succ m
:= add_one m ▸ add_one n ▸ add_lt_right H 1
theorem succ_lt_inv {n m : ℕ} (H : succ n < succ m) : n < m
:= add_lt_right_inv (add_one m⁻¹ ▸ add_one n⁻¹ ▸ H)
theorem lt_self_succ (n : ℕ) : n < succ n
:= le_refl (succ n)
theorem succ_lt_right {n m : ℕ} (H : n < m) : n < succ m
:= lt_trans H (lt_self_succ m)
---------- totality of lt and le
theorem le_or_lt (n m : ℕ) : n ≤ m ∨ m < n
:= induction_on n
(or_intro_left _ (zero_le m))
(take (k : ℕ),
assume IH : k ≤ m ∨ m < k,
or.elim IH
(assume H : k ≤ m,
obtain (l : ℕ) (Hl : k + l = m), from le_elim H,
discriminate
(assume H2 : l = 0,
have H3 : m = k,
from calc
m = k + l : symm Hl
... = k + 0 : {H2}
... = k : add_zero k,
have H4 : m < succ k, from subst H3 (lt_self_succ m),
or_intro_right _ H4)
(take l2 : ℕ,
assume H2 : l = succ l2,
have H3 : succ k + l2 = m,
from calc
succ k + l2 = k + succ l2 : succ_add_eq_add_succ k l2
... = k + l : {symm H2}
... = m : Hl,
or_intro_left _ (le_intro H3)))
(assume H : m < k, or_intro_right _ (succ_lt_right H)))
theorem trichotomy_alt (n m : ℕ) : (n < m ∨ n = m) ∨ m < n
:= or_of_or_of_imp_of_imp (le_or_lt n m) (assume H : n ≤ m, le_imp_lt_or_eq H) (assume H : m < n, H)
theorem trichotomy (n m : ℕ) : n < m ∨ n = m ∨ m < n
:= iff.elim_left or.assoc (trichotomy_alt n m)
theorem le_total (n m : ℕ) : n ≤ m ∨ m ≤ n
:= or_of_or_of_imp_of_imp (le_or_lt n m) (assume H : n ≤ m, H) (assume H : m < n, lt_imp_le H)
-- interaction with mul under "positivity"
theorem strong_induction_on {P : ℕ → Prop} (n : ℕ) (IH : ∀n, (∀m, m < n → P m) → P n) : P n
:= have stronger : ∀k, k ≤ n → P k, from
induction_on n
(take (k : ℕ),
assume H : k ≤ 0,
have H2 : k = 0, from le_zero_inv H,
have H3 : ∀m, m < k → P m, from
(take m : ℕ,
assume H4 : m < k,
have H5 : m < 0, from subst H2 H4,
absurd H5 (lt_zero_inv m)),
show P k, from IH k H3)
(take l : ℕ,
assume IHl : ∀k, k ≤ l → P k,
take k : ℕ,
assume H : k ≤ succ l,
or.elim (succ_le_right_inv H)
(assume H2 : k ≤ l, show P k, from IHl k H2)
(assume H2 : k = succ l,
have H3 : ∀m, m < k → P m, from
(take m : ℕ,
assume H4 : m < k,
have H5 : m ≤ l, from lt_succ_imp_le (subst H2 H4),
show P m, from IHl m H5),
show P k, from IH k H3)),
stronger n (le_refl n)
theorem case_strong_induction_on {P : ℕ → Prop} (a : ℕ) (H0 : P 0) (Hind : ∀(n : ℕ), (∀m, m ≤ n → P m) → P (succ n)) : P a
:= strong_induction_on a
(take n, case n
(assume H : (∀m, m < 0 → P m), H0)
(take n, assume H : (∀m, m < succ n → P m),
Hind n (take m, assume H1 : m ≤ n, H m (le_imp_lt_succ H1))))
theorem add_eq_self {n m : ℕ} (H : n + m = n) : m = 0
:= discriminate
(take Hm : m = 0, Hm)
(take k : ℕ,
assume Hm : m = succ k,
have H2 : succ n + k = n,
from calc
succ n + k = n + succ k : succ_add_eq_add_succ n k
... = n + m : {symm Hm}
... = n : H,
have H3 : n < n, from lt_intro H2,
have H4 : n ≠ n, from lt_ne H3,
absurd (refl n) H4)
-------------------------------------------------- positivity
-- we use " _ > 0" as canonical way of denoting that a number is positive
---------- basic
theorem zero_or_positive (n : ℕ) : n = 0 ∨ n > 0
:= or_of_or_of_imp_of_imp (or.swap (le_imp_lt_or_eq (zero_le n))) (take H : 0 = n, symm H) (take H : n > 0, H)
theorem succ_positive {n m : ℕ} (H : n = succ m) : n > 0
:= subst (symm H) (lt_zero m)
theorem ne_zero_positive {n : ℕ} (H : n ≠ 0) : n > 0
:= or.elim (zero_or_positive n) (take H2 : n = 0, absurd H2 H) (take H2 : n > 0, H2)
theorem pos_imp_eq_succ {n : ℕ} (H : n > 0) : ∃l, n = succ l
:= discriminate
(take H2, absurd (subst H2 H) (lt_irrefl 0))
(take l Hl, exists.intro l Hl)
theorem add_positive_right (n : ℕ) {k : ℕ} (H : k > 0) : n + k > n
:= obtain (l : ℕ) (Hl : k = succ l), from pos_imp_eq_succ H,
subst (symm Hl) (lt_intro2 n l)
theorem add_positive_left (n : ℕ) {k : ℕ} (H : k > 0) : k + n > n
:= subst (add_comm n k) (add_positive_right n H)
-- Positivity
-- ---------
--
-- Writing "t > 0" is the preferred way to assert that a natural number is positive.
-- ### basic
-- See also succ_pos.
theorem succ_pos (n : ℕ) : 0 < succ n
:= succ_le (zero_le n)
theorem case_zero_pos {P : ℕ → Prop} (y : ℕ) (H0 : P 0) (H1 : ∀y, y > 0 → P y) : P y
:= case y H0 (take y', H1 _ (succ_pos _))
theorem succ_imp_pos {n m : ℕ} (H : n = succ m) : n > 0
:= subst (symm H) (succ_pos m)
theorem add_pos_right (n : ℕ) {k : ℕ} (H : k > 0) : n + k > n
:= subst (add_zero n) (add_lt_left H n)
theorem add_pos_left (n : ℕ) {k : ℕ} (H : k > 0) : k + n > n
:= subst (add_comm n k) (add_pos_right n H)
---------- mul
theorem mul_positive {n m : ℕ} (Hn : n > 0) (Hm : m > 0) : n * m > 0
:= obtain (k : ℕ) (Hk : n = succ k), from pos_imp_eq_succ Hn,
obtain (l : ℕ) (Hl : m = succ l), from pos_imp_eq_succ Hm,
succ_positive (calc
n * m = succ k * m : {Hk}
... = succ k * succ l : {Hl}
... = succ k * l + succ k : mul_succ_right (succ k) l
... = succ (succ k * l + k) : add_succ _ _)
theorem mul_positive_inv_left {n m : ℕ} (H : n * m > 0) : n > 0
:= discriminate
(assume H2 : n = 0,
have H3 : n * m = 0,
from calc
n * m = 0 * m : {H2}
... = 0 : mul_zero_left m,
have H4 : 0 > 0, from subst H3 H,
absurd H4 (lt_irrefl 0))
(take l : ℕ,
assume Hl : n = succ l,
subst (symm Hl) (lt_zero l))
theorem mul_positive_inv_right {n m : ℕ} (H : n * m > 0) : m > 0
:= mul_positive_inv_left (subst (mul_comm n m) H)
theorem mul_left_inj {n m k : ℕ} (Hn : n > 0) (H : n * m = n * k) : m = k
:=
have general : ∀m, n * m = n * k → m = k, from
induction_on k
(take m:ℕ,
assume H : n * m = n * 0,
have H2 : n * m = 0,
from calc
n * m = n * 0 : H
... = 0 : mul_zero_right n,
have H3 : n = 0 ∨ m = 0, from mul_eq_zero H2,
or_resolve_right H3 (ne.symm (lt_ne Hn)))
(take (l : ℕ),
assume (IH : ∀ m, n * m = n * l → m = l),
take (m : ℕ),
assume (H : n * m = n * succ l),
have H2 : n * succ l > 0, from mul_positive Hn (lt_zero l),
have H3 : m > 0, from mul_positive_inv_right (subst (symm H) H2),
obtain (l2:ℕ) (Hm : m = succ l2), from pos_imp_eq_succ H3,
have H4 : n * l2 + n = n * l + n,
from calc
n * l2 + n = n * succ l2 : symm (mul_succ_right n l2)
... = n * m : {symm Hm}
... = n * succ l : H
... = n * l + n : mul_succ_right n l,
have H5 : n * l2 = n * l, from add_cancel_right H4,
calc
m = succ l2 : Hm
... = succ l : {IH l2 H5}),
general m H
theorem mul_right_inj {n m k : ℕ} (Hm : m > 0) (H : n * m = k * m) : n = k
:= mul_left_inj Hm (subst (mul_comm k m) (subst (mul_comm n m) H))
-- mul_eq_one below
---------- interaction of mul with le and lt
theorem mul_lt_left {n m k : ℕ} (Hk : k > 0) (H : n < m) : k * n < k * m
:=
have H2 : k * n < k * n + k, from add_positive_right (k * n) Hk,
have H3 : k * n + k ≤ k * m, from subst (mul_succ_right k n) (mul_le_left H k),
lt_le_trans H2 H3
theorem mul_lt_right {n m k : ℕ} (Hk : k > 0) (H : n < m) : n * k < m * k
:= subst (mul_comm k m) (subst (mul_comm k n) (mul_lt_left Hk H))
theorem mul_le_lt {n m k l : ℕ} (Hk : k > 0) (H1 : n ≤ k) (H2 : m < l) : n * m < k * l
:= le_lt_trans (mul_le_right H1 m) (mul_lt_left Hk H2)
theorem mul_lt_le {n m k l : ℕ} (Hl : l > 0) (H1 : n < k) (H2 : m ≤ l) : n * m < k * l
:= le_lt_trans (mul_le_left H2 n) (mul_lt_right Hl H1)
theorem mul_lt {n m k l : ℕ} (H1 : n < k) (H2 : m < l) : n * m < k * l
:=
have H3 : n * m ≤ k * m, from mul_le_right (lt_imp_le H1) m,
have H4 : k * m < k * l, from mul_lt_left (le_lt_trans (zero_le n) H1) H2,
le_lt_trans H3 H4
theorem mul_lt_left_inv {n m k : ℕ} (H : k * n < k * m) : n < m
:=
have general : ∀ m, k * n < k * m → n < m, from
induction_on n
(take m : ℕ,
assume H2 : k * 0 < k * m,
have H3 : 0 < k * m, from mul_zero_right k ▸ H2,
show 0 < m, from mul_positive_inv_right H3)
(take l : ℕ,
assume IH : ∀ m, k * l < k * m → l < m,
take m : ℕ,
assume H2 : k * succ l < k * m,
have H3 : 0 < k * m, from le_lt_trans (zero_le _) H2,
have H4 : 0 < m, from mul_positive_inv_right H3,
obtain (l2 : ℕ) (Hl2 : m = succ l2), from pos_imp_eq_succ H4,
have H5 : k * l + k < k * m, from mul_succ_right k l ▸ H2,
have H6 : k * l + k < k * succ l2, from Hl2 ▸ H5,
have H7 : k * l + k < k * l2 + k, from mul_succ_right k l2 ▸ H6,
have H8 : k * l < k * l2, from add_lt_right_inv H7,
have H9 : l < l2, from IH l2 H8,
have H10 : succ l < succ l2, from succ_lt H9,
show succ l < m, from Hl2⁻¹ ▸ H10),
general m H
theorem mul_lt_right_inv {n m k : ℕ} (H : n * k < m * k) : n < m
:= mul_lt_left_inv (mul_comm m k ▸ mul_comm n k ▸ H)
theorem mul_le_left_inv {n m k : ℕ} (H : succ k * n ≤ succ k * m) : n ≤ m
:=
have H2 : succ k * n < succ k * m + succ k, from le_lt_trans H (lt_intro2 _ _),
have H3 : succ k * n < succ k * succ m, from subst (symm (mul_succ_right (succ k) m)) H2,
have H4 : n < succ m, from mul_lt_left_inv H3,
show n ≤ m, from lt_succ_imp_le H4
theorem mul_le_right_inv {n m k : ℕ} (H : n * succ m ≤ k * succ m) : n ≤ k
:= mul_le_left_inv (subst (mul_comm k (succ m)) (subst (mul_comm n (succ m)) H))
theorem mul_eq_one_left {n m : ℕ} (H : n * m = 1) : n = 1
:=
have H2 : n * m > 0, from subst (symm H) (lt_zero 0),
have H3 : n > 0, from mul_positive_inv_left H2,
have H4 : m > 0, from mul_positive_inv_right H2,
or.elim (le_or_lt n 1)
(assume H5 : n ≤ 1,
show n = 1, from le_antisym H5 H3)
(assume H5 : n > 1,
have H6 : n * m ≥ 2 * 1, from mul_le H5 H4,
have H7 : 1 ≥ 2, from subst (mul_one_right 2) (subst H H6),
absurd (self_lt_succ 1) (le_imp_not_gt H7))
theorem mul_eq_one_right {n m : ℕ} (H : n * m = 1) : m = 1
:= mul_eq_one_left (subst (mul_comm n m) H)
theorem mul_eq_one {n m : ℕ} (H : n * m = 1) : n = 1 ∧ m = 1
:= and_intro (mul_eq_one_left H) (mul_eq_one_right H)
-------------------------------------------------- sub
definition sub (n m : ℕ) : ℕ := nat.rec n (fun m x, pred x) m
infixl `-` := sub
theorem sub_zero_right (n : ℕ) : n - 0 = n
theorem sub_succ_right (n m : ℕ) : n - succ m = pred (n - m)
theorem sub_zero_left (n : ℕ) : 0 - n = 0
:= induction_on n (sub_zero_right 0)
(take k : ℕ,
assume IH : 0 - k = 0,
calc
0 - succ k = pred (0 - k) : sub_succ_right 0 k
... = pred 0 : {IH}
... = 0 : pred_zero)
theorem sub_succ_succ (n m : ℕ) : succ n - succ m = n - m
:= induction_on m
(calc
succ n - 1 = pred (succ n - 0) : sub_succ_right (succ n) 0
... = pred (succ n) : {sub_zero_right (succ n)}
... = n : pred_succ n
... = n - 0 : symm (sub_zero_right n))
(take k : ℕ,
assume IH : succ n - succ k = n - k,
calc
succ n - succ (succ k) = pred (succ n - succ k) : sub_succ_right (succ n) (succ k)
... = pred (n - k) : {IH}
... = n - succ k : symm (sub_succ_right n k))
theorem sub_one (n : ℕ) : n - 1 = pred n
:= calc
n - 1 = pred (n - 0) : sub_succ_right n 0
... = pred n : {sub_zero_right n}
theorem sub_self (n : ℕ) : n - n = 0
:= induction_on n (sub_zero_right 0) (take k IH, trans (sub_succ_succ k k) IH)
theorem sub_add_add_right (n m k : ℕ) : (n + k) - (m + k) = n - m
:= induction_on k
(calc
(n + 0) - (m + 0) = n - (m + 0) : {add_zero _}
... = n - m : {add_zero _})
(take l : ℕ,
assume IH : (n + l) - (m + l) = n - m,
calc
(n + succ l) - (m + succ l) = succ (n + l) - (m + succ l) : {add_succ _ _}
... = succ (n + l) - succ (m + l) : {add_succ _ _}
... = (n + l) - (m + l) : sub_succ_succ _ _
... = n - m : IH)
theorem sub_add_add_left (n m k : ℕ) : (k + n) - (k + m) = n - m
:= subst (add_comm m k) (subst (add_comm n k) (sub_add_add_right n m k))
theorem sub_add_left (n m : ℕ) : n + m - m = n
:= induction_on m
(subst (symm (add_zero n)) (sub_zero_right n))
(take k : ℕ,
assume IH : n + k - k = n,
calc
n + succ k - succ k = succ (n + k) - succ k : {add_succ n k}
... = n + k - k : sub_succ_succ _ _
... = n : IH)
theorem sub_sub (n m k : ℕ) : n - m - k = n - (m + k)
:= induction_on k
(calc
n - m - 0 = n - m : sub_zero_right _
... = n - (m + 0) : {symm (add_zero m)})
(take l : ℕ,
assume IH : n - m - l = n - (m + l),
calc
n - m - succ l = pred (n - m - l) : sub_succ_right (n - m) l
... = pred (n - (m + l)) : {IH}
... = n - succ (m + l) : symm (sub_succ_right n (m + l))
... = n - (m + succ l) : {symm (add_succ m l)})
theorem succ_sub_sub (n m k : ℕ) : succ n - m - succ k = n - m - k
:= calc
succ n - m - succ k = succ n - (m + succ k) : sub_sub _ _ _
... = succ n - succ (m + k) : {add_succ m k}
... = n - (m + k) : sub_succ_succ _ _
... = n - m - k : symm (sub_sub n m k)
theorem sub_add_right_eq_zero (n m : ℕ) : n - (n + m) = 0
:= calc
n - (n + m) = n - n - m : symm (sub_sub n n m)
... = 0 - m : {sub_self n}
... = 0 : sub_zero_left m
theorem sub_comm (m n k : ℕ) : m - n - k = m - k - n
:= calc
m - n - k = m - (n + k) : sub_sub m n k
... = m - (k + n) : {add_comm n k}
... = m - k - n : symm (sub_sub m k n)
theorem succ_sub_one (n : ℕ) : succ n - 1 = n
:= sub_succ_succ n 0 ⬝ sub_zero_right n
---------- mul
theorem mul_pred_left (n m : ℕ) : pred n * m = n * m - m
:= induction_on n
(calc
pred 0 * m = 0 * m : {pred_zero}
... = 0 : mul_zero_left _
... = 0 - m : symm (sub_zero_left m)
... = 0 * m - m : {symm (mul_zero_left m)})
(take k : ℕ,
assume IH : pred k * m = k * m - m,
calc
pred (succ k) * m = k * m : {pred_succ k}
... = k * m + m - m : symm (sub_add_left _ _)
... = succ k * m - m : {symm (mul_succ_left k m)})
theorem mul_pred_right (n m : ℕ) : n * pred m = n * m - n
:= calc n * pred m = pred m * n : mul_comm _ _
... = m * n - n : mul_pred_left m n
... = n * m - n : {mul_comm m n}
theorem mul_sub_distr_left (n m k : ℕ) : (n - m) * k = n * k - m * k
:= induction_on m
(calc
(n - 0) * k = n * k : {sub_zero_right n}
... = n * k - 0 : symm (sub_zero_right _)
... = n * k - 0 * k : {symm (mul_zero_left _)})
(take l : ℕ,
assume IH : (n - l) * k = n * k - l * k,
calc
(n - succ l) * k = pred (n - l) * k : {sub_succ_right n l}
... = (n - l) * k - k : mul_pred_left _ _
... = n * k - l * k - k : {IH}
... = n * k - (l * k + k) : sub_sub _ _ _
... = n * k - (succ l * k) : {symm (mul_succ_left l k)})
theorem mul_sub_distr_right (n m k : ℕ) : n * (m - k) = n * m - n * k
:= calc
n * (m - k) = (m - k) * n : mul_comm _ _
... = m * n - k * n : mul_sub_distr_left _ _ _
... = n * m - k * n : {mul_comm _ _}
... = n * m - n * k : {mul_comm _ _}
-------------------------------------------------- max, min, iteration, maybe: sub, div
theorem succ_sub {m n : ℕ} : m ≥ n → succ m - n = succ (m - n)
:= sub_induction n m
(take k,
assume H : 0 ≤ k,
calc
succ k - 0 = succ k : sub_zero_right (succ k)
... = succ (k - 0) : {symm (sub_zero_right k)})
(take k,
assume H : succ k ≤ 0,
absurd H (not_succ_zero_le k))
(take k l,
assume IH : k ≤ l → succ l - k = succ (l - k),
take H : succ k ≤ succ l,
calc
succ (succ l) - succ k = succ l - k : sub_succ_succ (succ l) k
... = succ (l - k) : IH (succ_le_cancel H)
... = succ (succ l - succ k) : {symm (sub_succ_succ l k)})
theorem le_imp_sub_eq_zero {n m : ℕ} (H : n ≤ m) : n - m = 0
:= obtain (k : ℕ) (Hk : n + k = m), from le_elim H, subst Hk (sub_add_right_eq_zero n k)
theorem add_sub_le {n m : ℕ} : n ≤ m → n + (m - n) = m
:= sub_induction n m
(take k,
assume H : 0 ≤ k,
calc
0 + (k - 0) = k - 0 : zero_add (k - 0)
... = k : sub_zero_right k)
(take k, assume H : succ k ≤ 0, absurd H (not_succ_zero_le k))
(take k l,
assume IH : k ≤ l → k + (l - k) = l,
take H : succ k ≤ succ l,
calc
succ k + (succ l - succ k) = succ k + (l - k) : {sub_succ_succ l k}
... = succ (k + (l - k)) : succ_add k (l - k)
... = succ l : {IH (succ_le_cancel H)})
theorem add_sub_ge_left {n m : ℕ} : n ≥ m → n - m + m = n
:= subst (add_comm m (n - m)) add_sub_le
theorem add_sub_ge {n m : ℕ} (H : n ≥ m) : n + (m - n) = n
:= calc
n + (m - n) = n + 0 : {le_imp_sub_eq_zero H}
... = n : add_zero n
theorem add_sub_le_left {n m : ℕ} : n ≤ m → n - m + m = m
:= subst (add_comm m (n - m)) add_sub_ge
theorem le_add_sub_left (n m : ℕ) : n ≤ n + (m - n)
:= or.elim (le_total n m)
(assume H : n ≤ m, subst (symm (add_sub_le H)) H)
(assume H : m ≤ n, subst (symm (add_sub_ge H)) (le_refl n))
theorem le_add_sub_right (n m : ℕ) : m ≤ n + (m - n)
:= or.elim (le_total n m)
(assume H : n ≤ m, subst (symm (add_sub_le H)) (le_refl m))
(assume H : m ≤ n, subst (symm (add_sub_ge H)) H)
theorem sub_split {P : ℕ → Prop} {n m : ℕ} (H1 : n ≤ m → P 0) (H2 : ∀k, m + k = n -> P k)
: P (n - m)
:= or.elim (le_total n m)
(assume H3 : n ≤ m, subst (symm (le_imp_sub_eq_zero H3)) (H1 H3))
(assume H3 : m ≤ n, H2 (n - m) (add_sub_le H3))
theorem sub_le_self (n m : ℕ) : n - m ≤ n
:=
sub_split
(assume H : n ≤ m, zero_le n)
(take k : ℕ, assume H : m + k = n, le_intro (subst (add_comm m k) H))
theorem le_elim_sub (n m : ℕ) (H : n ≤ m) : ∃k, m - k = n
:=
obtain (k : ℕ) (Hk : n + k = m), from le_elim H,
exists.intro k
(calc
m - k = n + k - k : {symm Hk}
... = n : sub_add_left n k)
theorem add_sub_assoc {m k : ℕ} (H : k ≤ m) (n : ℕ) : n + m - k = n + (m - k)
:= have l1 : k ≤ m → n + m - k = n + (m - k), from
sub_induction k m
(take m : ℕ,
assume H : 0 ≤ m,
calc
n + m - 0 = n + m : sub_zero_right (n + m)
... = n + (m - 0) : {symm (sub_zero_right m)})
(take k : ℕ, assume H : succ k ≤ 0, absurd H (not_succ_zero_le k))
(take k m,
assume IH : k ≤ m → n + m - k = n + (m - k),
take H : succ k ≤ succ m,
calc
n + succ m - succ k = succ (n + m) - succ k : {add_succ n m}
... = n + m - k : sub_succ_succ (n + m) k
... = n + (m - k) : IH (succ_le_cancel H)
... = n + (succ m - succ k) : {symm (sub_succ_succ m k)}),
l1 H
theorem sub_eq_zero_imp_le {n m : ℕ} : n - m = 0 → n ≤ m
:= sub_split
(assume H1 : n ≤ m, assume H2 : 0 = 0, H1)
(take k : ℕ,
assume H1 : m + k = n,
assume H2 : k = 0,
have H3 : n = m, from subst (add_zero m) (subst H2 (symm H1)),
subst H3 (le_refl n))
theorem sub_sub_split {P : ℕ → ℕ → Prop} {n m : ℕ} (H1 : ∀k, n = m + k -> P k 0)
(H2 : ∀k, m = n + k → P 0 k) : P (n - m) (m - n)
:= or.elim (le_total n m)
(assume H3 : n ≤ m,
le_imp_sub_eq_zero H3⁻¹ ▸ (H2 (m - n) (add_sub_le H3⁻¹)))
(assume H3 : m ≤ n,
le_imp_sub_eq_zero H3⁻¹ ▸ (H1 (n - m) (add_sub_le H3⁻¹)))
theorem sub_intro {n m k : ℕ} (H : n + m = k) : k - n = m
:= have H2 : k - n + n = m + n, from
calc
k - n + n = k : add_sub_ge_left (le_intro H)
... = n + m : symm H
... = m + n : add_comm n m,
add_cancel_right H2
theorem sub_lt {x y : ℕ} (xpos : x > 0) (ypos : y > 0) : x - y < x
:= obtain (x' : ℕ) (xeq : x = succ x'), from pos_imp_eq_succ xpos,
obtain (y' : ℕ) (yeq : y = succ y'), from pos_imp_eq_succ ypos,
have xsuby_eq : x - y = x' - y', from
calc
x - y = succ x' - y : {xeq}
... = succ x' - succ y' : {yeq}
... = x' - y' : sub_succ_succ _ _,
have H1 : x' - y' ≤ x', from sub_le_self _ _,
have H2 : x' < succ x', from self_lt_succ _,
show x - y < x, from xeq⁻¹ ▸ xsuby_eq⁻¹ ▸ le_lt_trans H1 H2
-- Max, min, iteration, and absolute difference
-- --------------------------------------------
definition max (n m : ℕ) : ℕ := n + (m - n)
definition min (n m : ℕ) : ℕ := m - (m - n)
theorem max_le {n m : ℕ} (H : n ≤ m) : n + (m - n) = m := add_sub_le H
theorem max_ge {n m : ℕ} (H : n ≥ m) : n + (m - n) = n := add_sub_ge H
theorem left_le_max (n m : ℕ) : n ≤ n + (m - n) := le_add_sub_left n m
theorem right_le_max (n m : ℕ) : m ≤ max n m := le_add_sub_right n m
-- ### absolute difference
-- This section is still incomplete
definition dist (n m : ℕ) := (n - m) + (m - n)
theorem dist_comm (n m : ℕ) : dist n m = dist m n
:= add_comm (n - m) (m - n)
theorem dist_eq_zero {n m : ℕ} (H : dist n m = 0) : n = m
:=
have H2 : n - m = 0, from eq_zero_of_add_eq_zero_right H,
have H3 : n ≤ m, from sub_eq_zero_imp_le H2,
have H4 : m - n = 0, from add_eq_zero_right H,
have H5 : m ≤ n, from sub_eq_zero_imp_le H4,
le_antisym H3 H5
theorem dist_le {n m : ℕ} (H : n ≤ m) : dist n m = m - n
:= calc
dist n m = (n - m) + (m - n) : refl _
... = 0 + (m - n) : {le_imp_sub_eq_zero H}
... = m - n : zero_add (m - n)
theorem dist_ge {n m : ℕ} (H : n ≥ m) : dist n m = n - m
:= subst (dist_comm m n) (dist_le H)
theorem dist_zero_right (n : ℕ) : dist n 0 = n
:= trans (dist_ge (zero_le n)) (sub_zero_right n)
theorem dist_zero_left (n : ℕ) : dist 0 n = n
:= trans (dist_le (zero_le n)) (sub_zero_right n)
theorem dist_intro {n m k : ℕ} (H : n + m = k) : dist k n = m
:= calc
dist k n = k - n : dist_ge (le_intro H)
... = m : sub_intro H
theorem dist_add_right (n k m : ℕ) : dist (n + k) (m + k) = dist n m
:=
calc
dist (n + k) (m + k) = ((n+k) - (m+k)) + ((m+k)-(n+k)) : refl _
... = (n - m) + ((m + k) - (n + k)) : {sub_add_add_right _ _ _}
... = (n - m) + (m - n) : {sub_add_add_right _ _ _}
theorem dist_add_left (k n m : ℕ) : dist (k + n) (k + m) = dist n m
:= subst (add_comm m k) (subst (add_comm n k) (dist_add_right n k m))
theorem dist_ge_add_right {n m : ℕ} (H : n ≥ m) : dist n m + m = n
:= calc
dist n m + m = n - m + m : {dist_ge H}
... = n : add_sub_ge_left H
theorem dist_eq_intro {n m k l : ℕ} (H : n + m = k + l) : dist n k = dist l m
:= calc
dist n k = dist (n + m) (k + m) : symm (dist_add_right n m k)
... = dist (k + l) (k + m) : {H}
... = dist l m : dist_add_left k l m
end nat
end experiment
|
82ae6f3b4ae96a9992e6c750197b4cd1edd4a0a7 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/ring_theory/ideal/prod.lean | 96485fbc8535e4b45a99b3fabd6461f77b2e9c55 | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 6,131 | lean | /-
Copyright (c) 2020 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import ring_theory.ideal.operations
/-!
# Ideals in product rings
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
For commutative rings `R` and `S` and ideals `I ≤ R`, `J ≤ S`, we define `ideal.prod I J` as the
product `I × J`, viewed as an ideal of `R × S`. In `ideal_prod_eq` we show that every ideal of
`R × S` is of this form. Furthermore, we show that every prime ideal of `R × S` is of the form
`p × S` or `R × p`, where `p` is a prime ideal.
-/
universes u v
variables {R : Type u} {S : Type v} [ring R] [ring S] (I I' : ideal R) (J J' : ideal S)
namespace ideal
/-- `I × J` as an ideal of `R × S`. -/
def prod : ideal (R × S) :=
{ carrier := { x | x.fst ∈ I ∧ x.snd ∈ J },
zero_mem' := by simp,
add_mem' :=
begin
rintros ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨ha₁, ha₂⟩ ⟨hb₁, hb₂⟩,
exact ⟨I.add_mem ha₁ hb₁, J.add_mem ha₂ hb₂⟩
end,
smul_mem' :=
begin
rintros ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ⟨hb₁, hb₂⟩,
exact ⟨I.mul_mem_left _ hb₁, J.mul_mem_left _ hb₂⟩,
end }
@[simp] lemma mem_prod {r : R} {s : S} : (⟨r, s⟩ : R × S) ∈ prod I J ↔ r ∈ I ∧ s ∈ J := iff.rfl
@[simp] lemma prod_top_top : prod (⊤ : ideal R) (⊤ : ideal S) = ⊤ := ideal.ext $ by simp
/-- Every ideal of the product ring is of the form `I × J`, where `I` and `J` can be explicitly
given as the image under the projection maps. -/
theorem ideal_prod_eq (I : ideal (R × S)) :
I = ideal.prod (map (ring_hom.fst R S) I) (map (ring_hom.snd R S) I) :=
begin
apply ideal.ext,
rintro ⟨r, s⟩,
rw [mem_prod, mem_map_iff_of_surjective (ring_hom.fst R S) prod.fst_surjective,
mem_map_iff_of_surjective (ring_hom.snd R S) prod.snd_surjective],
refine ⟨λ h, ⟨⟨_, ⟨h, rfl⟩⟩, ⟨_, ⟨h, rfl⟩⟩⟩, _⟩,
rintro ⟨⟨⟨r, s'⟩, ⟨h₁, rfl⟩⟩, ⟨⟨r', s⟩, ⟨h₂, rfl⟩⟩⟩,
simpa using I.add_mem (I.mul_mem_left (1, 0) h₁) (I.mul_mem_left (0, 1) h₂),
end
@[simp] lemma map_fst_prod (I : ideal R) (J : ideal S) : map (ring_hom.fst R S) (prod I J) = I :=
begin
ext,
rw mem_map_iff_of_surjective (ring_hom.fst R S) prod.fst_surjective,
exact ⟨by { rintro ⟨x, ⟨h, rfl⟩⟩, exact h.1 }, λ h, ⟨⟨x, 0⟩, ⟨⟨h, ideal.zero_mem _⟩, rfl⟩⟩⟩
end
@[simp] lemma map_snd_prod (I : ideal R) (J : ideal S) : map (ring_hom.snd R S) (prod I J) = J :=
begin
ext,
rw mem_map_iff_of_surjective (ring_hom.snd R S) prod.snd_surjective,
exact ⟨by { rintro ⟨x, ⟨h, rfl⟩⟩, exact h.2 }, λ h, ⟨⟨0, x⟩, ⟨⟨ideal.zero_mem _, h⟩, rfl⟩⟩⟩
end
@[simp] lemma map_prod_comm_prod :
map ((ring_equiv.prod_comm : R × S ≃+* S × R) : R × S →+* S × R) (prod I J) = prod J I :=
begin
refine trans (ideal_prod_eq _) _,
simp [map_map],
end
/-- Ideals of `R × S` are in one-to-one correspondence with pairs of ideals of `R` and ideals of
`S`. -/
def ideal_prod_equiv : ideal (R × S) ≃ ideal R × ideal S :=
{ to_fun := λ I, ⟨map (ring_hom.fst R S) I, map (ring_hom.snd R S) I⟩,
inv_fun := λ I, prod I.1 I.2,
left_inv := λ I, (ideal_prod_eq I).symm,
right_inv := λ ⟨I, J⟩, by simp }
@[simp] lemma ideal_prod_equiv_symm_apply (I : ideal R) (J : ideal S) :
ideal_prod_equiv.symm ⟨I, J⟩ = prod I J := rfl
lemma prod.ext_iff {I I' : ideal R} {J J' : ideal S} : prod I J = prod I' J' ↔ I = I' ∧ J = J' :=
by simp only [←ideal_prod_equiv_symm_apply, ideal_prod_equiv.symm.injective.eq_iff, prod.mk.inj_iff]
lemma is_prime_of_is_prime_prod_top {I : ideal R} (h : (ideal.prod I (⊤ : ideal S)).is_prime) :
I.is_prime :=
begin
split,
{ unfreezingI { contrapose! h },
simp [is_prime_iff, h] },
{ intros x y hxy,
have : (⟨x, 1⟩ : R × S) * ⟨y, 1⟩ ∈ prod I ⊤,
{ rw [prod.mk_mul_mk, mul_one, mem_prod],
exact ⟨hxy, trivial⟩ },
simpa using h.mem_or_mem this }
end
lemma is_prime_of_is_prime_prod_top' {I : ideal S} (h : (ideal.prod (⊤ : ideal R) I).is_prime) :
I.is_prime :=
begin
apply @is_prime_of_is_prime_prod_top _ R,
rw ←map_prod_comm_prod,
exact map_is_prime_of_equiv _
end
lemma is_prime_ideal_prod_top {I : ideal R} [h : I.is_prime] : (prod I (⊤ : ideal S)).is_prime :=
begin
split,
{ unfreezingI { rcases h with ⟨h, -⟩, contrapose! h },
rw [←prod_top_top, prod.ext_iff] at h,
exact h.1 },
rintros ⟨r₁, s₁⟩ ⟨r₂, s₂⟩ ⟨h₁, h₂⟩,
cases h.mem_or_mem h₁ with h h,
{ exact or.inl ⟨h, trivial⟩ },
{ exact or.inr ⟨h, trivial⟩ }
end
lemma is_prime_ideal_prod_top' {I : ideal S} [h : I.is_prime] : (prod (⊤ : ideal R) I).is_prime :=
begin
rw ←map_prod_comm_prod,
apply map_is_prime_of_equiv _,
exact is_prime_ideal_prod_top,
end
lemma ideal_prod_prime_aux {I : ideal R} {J : ideal S} : (ideal.prod I J).is_prime →
I = ⊤ ∨ J = ⊤ :=
begin
contrapose!,
simp only [ne_top_iff_one, is_prime_iff, not_and, not_forall, not_or_distrib],
exact λ ⟨hI, hJ⟩ hIJ, ⟨⟨0, 1⟩, ⟨1, 0⟩, by simp, by simp [hJ], by simp [hI]⟩
end
/-- Classification of prime ideals in product rings: the prime ideals of `R × S` are precisely the
ideals of the form `p × S` or `R × p`, where `p` is a prime ideal of `R` or `S`. -/
theorem ideal_prod_prime (I : ideal (R × S)) : I.is_prime ↔
((∃ p : ideal R, p.is_prime ∧ I = ideal.prod p ⊤) ∨
(∃ p : ideal S, p.is_prime ∧ I = ideal.prod ⊤ p)) :=
begin
split,
{ rw ideal_prod_eq I,
introsI hI,
rcases ideal_prod_prime_aux hI with (h|h),
{ right,
rw h at hI ⊢,
exact ⟨_, ⟨is_prime_of_is_prime_prod_top' hI, rfl⟩⟩ },
{ left,
rw h at hI ⊢,
exact ⟨_, ⟨is_prime_of_is_prime_prod_top hI, rfl⟩⟩ } },
{ rintro (⟨p, ⟨h, rfl⟩⟩|⟨p, ⟨h, rfl⟩⟩),
{ exactI is_prime_ideal_prod_top },
{ exactI is_prime_ideal_prod_top' } }
end
end ideal
|
07d6ac3d1649d18ed10f51db62ccd3bc51418667 | 0d7f5899c0475f9e105a439896d9377f80c0d7c3 | /src/fron_ualg.lean | f27303eeb50f470bd5ad1351eb7a46f8700e17a3 | [] | no_license | adamtopaz/UnivAlg | 127038f320e68cdf3efcd0c084c9af02fdb8da3d | 2458d47a6e4fd0525e3a25b07cb7dd518ac173ef | refs/heads/master | 1,670,320,985,286 | 1,597,350,882,000 | 1,597,350,882,000 | 280,585,500 | 4 | 0 | null | 1,597,350,883,000 | 1,595,048,527,000 | Lean | UTF-8 | Lean | false | false | 1,190 | lean | import .lang
import .forget
import .free_ralg
import .fron_ralg
import .add_rules
import .ualg
namespace rules_hom
variables {L0 : lang} {R0 : rules L0} {L1 : lang} {R1 : rules L1}
variables (ι : R0 →# R1)
variables (A : Type*) [ualg R0 A]
include ι
def fron := R1.add (ι.lhom.fron A)
namespace fron
instance : has_app L1 (ι.fron A) := rules.add.has_app R1 _
instance : compat ι.lhom (ι.fron A) := ι.lhom.forget_along _
def univ : A →$[L0] (ι.fron A) :=
(lang_hom.fron.univ ι.lhom A).comp
((rules.add.univ R1 (ι.lhom.fron A)).drop ι.lhom)
variable {A}
def lift {B : Type*} [ualg R1 B] [compat ι.lhom B] (f : A →$[L0] B) :
ι.fron A →$[L1] B :=
rules.add.lift R1 $
lang_hom.fron.lift _ f
theorem univ_comp_lift {B : Type*} [ualg R1 B] [compat ι.lhom B] (f : A →$[L0] B) :
(univ ι A).comp ((lift ι f).drop ι.lhom) = f := by {ext, refl}
theorem lift_unique {B : Type*} [ualg R1 B] [compat ι.lhom B] (f : A →$[L0] B)
(g : ι.fron A →$[L1] B) : (univ ι A).comp (g.drop ι.lhom) = f → g = lift ι f :=
begin
intro hyp,
apply rules.add.lift_unique,
apply lang_hom.fron.lift_unique,
assumption,
end
end fron
end rules_hom |
baa9f4e8502e48e71568b37eac281f192c28172b | 38ee9024fb5974f555fb578fcf5a5a7b71e669b5 | /Mathlib/Mathport/Syntax.lean | 9be04c5d0420f3e2424c14a5c11820f29531014d | [
"Apache-2.0"
] | permissive | denayd/mathlib4 | 750e0dcd106554640a1ac701e51517501a574715 | 7f40a5c514066801ab3c6d431e9f405baa9b9c58 | refs/heads/master | 1,693,743,991,894 | 1,636,618,048,000 | 1,636,618,048,000 | 373,926,241 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 34,483 | lean | /-
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Lean.Elab.Command
import Lean.Elab.Quotation
import Mathlib.Tactic.Core
import Mathlib.Tactic.Ext
import Mathlib.Tactic.Find
import Mathlib.Tactic.LibrarySearch
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Ring
import Mathlib.Tactic.ShowTerm
import Mathlib.Tactic.SolveByElim
-- To fix upstream:
-- * bracketedExplicitBinders doesn't support optional types
namespace Lean
namespace Parser.Term
@[termParser default+1] def Command.quot : Parser :=
leading_parser "`(command|" >> incQuotDepth commandParser >> ")"
end Parser.Term
namespace Elab.Term
open Lean Elab Term Quotation in
@[termElab Command.quot] def elabCommandQuot : TermElab := adaptExpander stxQuot.expand
end Elab.Term
namespace Parser.Command
syntax (name := include) "include " ident+ : command
syntax (name := omit) "omit " ident+ : command
syntax (name := parameter) "parameter " bracketedBinder+ : command
syntax (name := noncomputableTheory) (docComment)? "noncomputable " "theory" : command
syntax (name := runCmd) "run_cmd " doSeq : command
syntax bindersItem := "(" "..." ")"
syntax identScope := ":" "(" "scoped " ident " => " term ")"
syntax notation3Item := strLit <|> bindersItem <|> (ident (identScope)?)
macro ak:Term.attrKind "notation3 "
prec:optPrecedence name:optNamedName prio:optNamedPrio
lits:((ppSpace notation3Item)+) " => " val:term : command => do
let args ← lits.getArgs.mapM fun lit =>
let k := lit[0].getKind
if k == strLitKind then `(macroArg| $(lit[0]):strLit)
else if k == ``bindersItem then withFreshMacroScope `(macroArg| bi:explicitBinders)
else withFreshMacroScope `(macroArg| $(lit[0]):ident:term)
`(command| $ak:attrKind macro
$[$(prec.getOptional?):precedence]?
$[$(name.getOptional?):namedName]?
$[$(prio.getOptional?):namedPrio]?
$(args[0]):macroArg $[$(args[1:].toArray):macroArg]* : term =>
`(sorry))
end Parser.Command
namespace Elab.Command
@[commandElab Parser.Command.include]
def elabIncludeCmd : CommandElab := fun _ => pure ()
@[commandElab Parser.Command.omit]
def elabOmitCmd : CommandElab := fun _ => pure ()
open Meta in
unsafe def elabRunCmdUnsafe : CommandElab := fun stx => do
let e ← `((do $(stx[1]) : CoreM Unit))
let n := `_runCmd
runTermElabM (some n) fun _ => do
let e ← Term.elabTerm e (← Term.elabTerm (← `(CoreM Unit)) none)
Term.synthesizeSyntheticMVarsNoPostponing
let e ← withLocalDeclD `env (mkConst ``Lean.Environment) fun env =>
withLocalDeclD `opts (mkConst ``Lean.Options) fun opts => do
let e ← mkAppM ``Lean.runMetaEval #[env, opts, e]
mkLambdaFVars #[env, opts] e
let env ← getEnv
let opts ← getOptions
let act ← try
let type ← inferType e
let decl := Declaration.defnDecl {
name := n
levelParams := []
type := type
value := e
hints := ReducibilityHints.opaque
safety := DefinitionSafety.unsafe }
Term.ensureNoUnassignedMVars decl
addAndCompile decl
evalConst (Environment → Options → IO (String × Except IO.Error Environment)) n
finally setEnv env
match (← act env opts).2 with
| Except.error e => throwError e.toString
| Except.ok env => do setEnv env; pure ()
-- TODO(Mario): Why is the extra indirection needed?
@[implementedBy elabRunCmdUnsafe] constant elabRunCmd' : CommandElab
@[commandElab runCmd] def elabRunCmd : CommandElab := elabRunCmd'
-- open private declareSyntaxCatQuotParser in elabDeclareSyntaxCat
private def declareSyntaxCatQuotParser (catName : Name) : CommandElabM Unit := do
if let Name.str _ suffix _ := catName then
let quotSymbol := "`(" ++ suffix ++ "|"
let name := catName ++ `quot
-- TODO(Sebastian): this might confuse the pretty printer, but it lets us reuse the elaborator
let kind := ``Lean.Parser.Term.quot
let cmd ← `(
@[termParser] def $(mkIdent name) : Lean.ParserDescr :=
Lean.ParserDescr.node $(quote kind) $(quote Lean.Parser.maxPrec)
(Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol $(quote quotSymbol))
(Lean.ParserDescr.binary `andthen
(Lean.ParserDescr.unary `incQuotDepth (Lean.ParserDescr.cat $(quote catName) 0))
(Lean.ParserDescr.symbol ")"))))
elabCommand cmd
end Elab.Command
namespace Parser.Term
-- syntax:lead (name := noMatch) "match " matchDiscr,* " with" "." : term
syntax (name := noFun) "fun" "." : term
syntax "{" term,* "}" : term
syntax "{ " ident (" : " term)? " | " term " }" : term
syntax "{ " ident " ∈ " term " | " term " }" : term
syntax (priority := low) "{" term " | " bracketedBinder+ " }" : term
syntax "quote " term : term
syntax "pquote " term : term
syntax "ppquote " term : term
syntax "%%" term : term
end Term
namespace Tactic
syntax tactic " <;> " "[" tactic,* "]" : tactic
syntax "runTac " doSeq : tactic
end Tactic
namespace Tactic
syntax (name := propagateTags) "propagateTags " tacticSeq : tactic
syntax (name := introv) "introv" (ppSpace binderIdent)* : tactic
syntax renameArg := ident " => " ident
syntax (name := rename') "rename'" (ppSpace renameArg),+ : tactic
syntax (name := fapply) "fapply " term : tactic
syntax (name := eapply) "eapply " term : tactic
syntax (name := applyWith) "apply " term " with " term : tactic
syntax (name := mapply) "mapply " term : tactic
macro "assumption'" : tactic => `(all_goals assumption)
syntax (name := exacts) "exacts" " [" term,* "]" : tactic
syntax (name := toExpr') "toExpr' " term : tactic
syntax (name := rwa) "rwa " rwRuleSeq (ppSpace location)? : tactic
syntax (name := withCases) "withCases " tacticSeq : tactic
syntax (name := induction') "induction' " casesTarget,+ (" using " ident)?
(" with " (colGt binderIdent)+)? (" generalizing " (colGt ident)+)? : tactic
syntax caseArg := binderIdent,+ (" :" (ppSpace (ident <|> "_"))+)?
syntax (name := case') "case' " (("[" caseArg,* "]") <|> caseArg) " => " tacticSeq : tactic
syntax "destruct " term : tactic
syntax (name := cases') "cases' " casesTarget,+ (" using " ident)?
(" with " (colGt binderIdent)+)? : tactic
syntax (name := casesM) "casesM" "*"? ppSpace term,* : tactic
syntax (name := casesType) "casesType" "*"? ppSpace ident* : tactic
syntax (name := casesType!) "casesType!" "*"? ppSpace ident* : tactic
syntax (name := «sorry») "sorry" : tactic
syntax (name := iterate) "iterate" (num)? ppSpace tacticSeq : tactic
syntax (name := repeat') "repeat' " tacticSeq : tactic
syntax (name := abstract) "abstract" (ppSpace ident)? ppSpace tacticSeq : tactic
syntax (name := have'') "have " Term.haveIdLhs : tactic
syntax (name := let'') "let " Term.haveIdLhs : tactic
syntax (name := suffices') "suffices " Term.haveIdLhs : tactic
syntax (name := trace) "trace " term : tactic
syntax (name := existsi) "exists " term,* : tactic
syntax (name := eConstructor) "econstructor" : tactic
syntax (name := left) "left" : tactic
syntax (name := right) "right" : tactic
syntax (name := constructorM) "constructorM" "*"? ppSpace term,* : tactic
syntax (name := exFalso) "exFalso" : tactic
syntax (name := injections') "injections" (" with " (colGt (ident <|> "_"))+)? : tactic
syntax (name := simp') "simp'" "*"? (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := simpIntro) "simpIntro" (" (" &"config" " := " term ")")?
(ppSpace (colGt (ident <|> "_")))* (&" only")? (" [" simpArg,* "]")? (" with " ident+)? : tactic
syntax (name := dsimp) "dsimp" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := symm) "symm" : tactic
syntax (name := trans) "trans" (ppSpace (colGt term))? : tactic
syntax (name := acRfl) "acRfl" : tactic
syntax (name := cc) "cc" : tactic
syntax (name := substVars) "substVars" : tactic
syntax (name := dUnfold) "dunfold" (" (" &"config" " := " term ")")?
(ppSpace (colGt ident))* (ppSpace location)? : tactic
syntax (name := delta') "delta'" (colGt ident)* (ppSpace location)? : tactic
syntax (name := unfoldProjs) "unfoldProjs" (" (" &"config" " := " term ")")?
(ppSpace location)? : tactic
syntax (name := unfold) "unfold" (" (" &"config" " := " term ")")?
(ppSpace (colGt ident))* (ppSpace location)? : tactic
syntax (name := unfold1) "unfold1" (" (" &"config" " := " term ")")?
(ppSpace (colGt ident))* (ppSpace location)? : tactic
syntax (name := inferOptParam) "inferOptParam" : tactic
syntax (name := inferAutoParam) "inferAutoParam" : tactic
syntax (name := guardExprEq) "guardExpr " term:51 " =ₐ " term : tactic -- alpha equality
syntax (name := guardTarget) "guardTarget" " =ₐ " term : tactic -- alpha equality
-- Moved to Mathlib.Tactic.Basic
-- syntax (name := guardHyp) "guardHyp " ident
-- ((" : " <|> " :ₐ ") term)? ((" := " <|> " :=ₐ ") term)? : tactic
-- Moved to Mathlib.Tactic.Basic
-- syntax (name := matchTarget) "matchTarget " term : tactic
-- There is already a `byCases` tactic in core (in `src/init/classical.lean`)
-- so for now we add a primed version to support the optional identifier,
-- and available `decidable` instances.
syntax (name := byCases') "byCases' " atomic(ident " : ")? term : tactic
syntax (name := byContra) "byContra " (colGt ident)? : tactic
syntax (name := typeCheck) "typeCheck " term : tactic
syntax (name := rsimp) "rsimp" : tactic
syntax (name := compVal) "compVal" : tactic
syntax (name := async) "async " tacticSeq : tactic
namespace Conv
macro "try " t:convSeq : conv => `(first | $t | skip)
syntax "runConv " doSeq : conv
open Tactic (simpArg rwRuleSeq)
syntax (name := traceLHS) "traceLHS" : conv
syntax (name := toLHS) "toLHS" : conv
syntax (name := toRHS) "toRHS" : conv
syntax (name := find) "find " term " => " tacticSeq : conv
syntax (name := «for») "for " term:max " [" num,* "]" " => " tacticSeq : conv
syntax (name := dsimp) "dsimp" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? : conv
syntax (name := simp') "simp" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? : conv
syntax (name := guardLHS) "guardLHS " " =ₐ " term : conv
syntax (name := rw) "rw " rwRuleSeq : conv
end Conv
syntax (name := unfreezingI) "unfreezingI " tacticSeq : tactic
syntax (name := resetI) "resetI" : tactic
syntax (name := substI) "substI " term : tactic
syntax (name := casesI) "casesI " casesTarget,+ (" using " ident)?
(" with " (colGt binderIdent)+)? : tactic
syntax (name := introI) "introI" (colGt (ident <|> "_"))* : tactic
syntax (name := introsI) "introsI" (colGt (ident <|> "_"))* : tactic
syntax (name := haveI) "haveI " Term.haveDecl : tactic
syntax (name := haveI') "haveI " Term.haveIdLhs : tactic
syntax (name := letI) "letI " Term.letDecl : tactic
syntax (name := letI') "letI " Term.haveIdLhs : tactic
syntax (name := exactI) "exactI " term : tactic
syntax (name := rcases?) "rcases?" casesTarget,* (" : " num)? : tactic
syntax (name := rcases) "rcases" casesTarget,* (" with " rcasesPat)? : tactic
syntax (name := obtain) "obtain" (ppSpace rcasesPatMed)? (" : " term)? (" := " term,+)? : tactic
syntax (name := rintro?) "rintro?" (" : " num)? : tactic
syntax (name := rintro) "rintro" (ppSpace rintroPat)* (" : " term)? : tactic
syntax (name := ext1) "ext1" (ppSpace rcasesPat)* : tactic
syntax (name := ext1?) "ext1?" (ppSpace rcasesPat)* : tactic
-- The current implementation of `ext` in mathlib4 does not support `rcasesPat`,
-- and will need to be updated.
syntax (name := ext) "ext" (ppSpace rcasesPat)* (" : " num)? : tactic
syntax (name := ext?) "ext?" (ppSpace rcasesPat)* (" : " num)? : tactic
syntax (name := apply') "apply' " term : tactic
syntax (name := fapply') "fapply' " term : tactic
syntax (name := eapply') "eapply' " term : tactic
syntax (name := applyWith') "applyWith' " ("(" &"config" " := " term ")")? term : tactic
syntax (name := mapply') "mapply' " term : tactic
syntax (name := rfl') "rfl'" : tactic
syntax (name := symm') "symm'" (ppSpace location)? : tactic
syntax (name := trans') "trans'" (ppSpace term)? : tactic
syntax (name := fsplit) "fsplit" : tactic
syntax (name := injectionsAndClear) "injectionsAndClear" : tactic
syntax (name := fconstructor) "fconstructor" : tactic
syntax (name := tryFor) "tryFor " term:max tacticSeq : tactic
syntax (name := substs) "substs" (ppSpace ident)* : tactic
syntax (name := unfoldCoes) "unfoldCoes" (ppSpace location)? : tactic
syntax (name := unfoldWf) "unfoldWf" : tactic
syntax (name := unfoldAux) "unfoldAux" : tactic
syntax (name := recover) "recover" : tactic
syntax (name := «continue») "continue " tacticSeq : tactic
syntax (name := workOnGoal) "workOnGoal " num ppSpace tacticSeq : tactic
syntax (name := swap) "swap" (ppSpace num)? : tactic
syntax (name := rotate) "rotate" (ppSpace num)? : tactic
syntax (name := clear_) "clear_" : tactic
syntax (name := replace) "replace " Term.haveDecl : tactic
syntax (name := replace') "replace " Term.haveIdLhs : tactic
syntax (name := classical) "classical" : tactic
syntax (name := generalizeHyp) "generalize " atomic(ident " : ")? term:51 " = " ident
ppSpace location : tactic
syntax (name := clean) "clean " term : tactic
syntax (name := refineStruct) "refineStruct " term : tactic
syntax (name := matchHyp) "matchHyp " ("(" &"m" " := " term ") ")? ident " : " term : tactic
-- Moved to Mathlib.Tactic.Basic
-- syntax (name := guardExprStrict) "guardExpr " term:51 " == " term : tactic -- syntactic equality
-- Moved to Mathlib.Tactic.Basic
-- syntax (name := guardTargetStrict) "guardTarget" " == " term : tactic -- syntactic equality
syntax (name := guardHypNums) "guardHypNums " num : tactic
syntax (name := guardTags) "guardTags" (ppSpace ident)* : tactic
syntax (name := guardProofTerm) "guardProofTerm " tactic:51 " => " term : tactic
syntax (name := failIfSuccess?) "failIfSuccess? " str ppSpace tacticSeq : tactic
syntax (name := field) "field " ident " => " tacticSeq : tactic
syntax (name := haveField) "haveField" : tactic
syntax (name := applyField) "applyField" : tactic
syntax (name := applyRules) "applyRules" (" (" &"config" " := " term ")")?
" [" term,* "]" (ppSpace num)? : tactic
syntax (name := hGeneralize) "hGeneralize " atomic(binderIdent " : ")? term:51 " = " ident
(" with " binderIdent)? : tactic
syntax (name := hGeneralize!) "hGeneralize! " atomic(binderIdent " : ")? term:51 " = " ident
(" with " binderIdent)? : tactic
syntax (name := guardExprEq') "guardExpr " term:51 " = " term : tactic -- definitional equality
syntax (name := guardTarget') "guardTarget" " = " term : tactic -- definitional equality
syntax (name := triv) "triv" : tactic
syntax (name := use) "use " term,+ : tactic
syntax (name := clearAuxDecl) "clearAuxDecl" : tactic
syntax (name := set) "set " ident (" : " term)? " := " term (" with " "←"? ident)? : tactic
syntax (name := set!) "set! " ident (" : " term)? " := " term (" with " "←"? ident)? : tactic
syntax (name := clearExcept) "clear " "*" " - " ident* : tactic
syntax (name := extractGoal) "extractGoal" (ppSpace ident)?
(" with" (ppSpace (colGt ident))*)? : tactic
syntax (name := extractGoal!) "extractGoal!" (ppSpace ident)?
(" with" (ppSpace (colGt ident))*)? : tactic
syntax (name := inhabit) "inhabit " atomic(ident " : ")? term : tactic
syntax (name := revertDeps) "revertDeps" (ppSpace (colGt ident))* : tactic
syntax (name := revertAfter) "revertAfter " ident : tactic
syntax (name := revertTargetDeps) "revertTargetDeps" : tactic
syntax (name := clearValue) "clearValue" (ppSpace (colGt ident))* : tactic
syntax (name := applyAssumption) "applyAssumption" : tactic
-- Moved to Mathlib.Tactic.SolveByElim
-- syntax (name := solveByElim) "solveByElim" "*"? (" (" &"config" " := " term ")")?
-- (&" only")? (" [" simpArg,* "]")? (" with " (colGt ident)+)? : tactic
syntax (name := hint) "hint" : tactic
syntax (name := clear!) "clear!" (ppSpace ident)* : tactic
syntax (name := choose) "choose" (ppSpace ident)+ (" using " term)? : tactic
syntax (name := choose!) "choose!" (ppSpace ident)+ (" using " term)? : tactic
syntax (name := convLHS) "convLHS" (" at " ident)? (" in " term)? " => " Conv.convSeq : tactic
syntax (name := convRHS) "convRHS" (" at " ident)? (" in " term)? " => " Conv.convSeq : tactic
syntax (name := congr) "congr" (ppSpace (colGt num))?
(" with " (colGt rcasesPat)* (" : " num)?)? : tactic
syntax (name := rcongr) "rcongr" (ppSpace (colGt rcasesPat))* : tactic
syntax (name := convert) "convert " "← "? term (" using " num)? : tactic
syntax (name := convertTo) "convertTo " term (" using " num)? : tactic
syntax (name := acChange) "acChange " term (" using " num)? : tactic
syntax (name := decide!) "decide!" : tactic
syntax (name := deltaInstance) "deltaInstance" (ppSpace ident)* : tactic
syntax (name := elide) "elide " num (ppSpace location)? : tactic
syntax (name := unelide) "unelide" (ppSpace location)? : tactic
syntax (name := clarify) "clarify" (" (" &"config" " := " term ")")?
(" [" Parser.Tactic.simpArg,* "]")? (" using " term,+)? : tactic
syntax (name := safe) "safe" (" (" &"config" " := " term ")")?
(" [" Parser.Tactic.simpArg,* "]")? (" using " term,+)? : tactic
syntax (name := finish) "finish" (" (" &"config" " := " term ")")?
(" [" Parser.Tactic.simpArg,* "]")? (" using " term,+)? : tactic
syntax generalizesArg := (ident " : ")? term:51 " = " ident
syntax (name := generalizes) "generalizes " "[" generalizesArg,* "]" : tactic
syntax (name := generalizeProofs) "generalizeProofs"
(ppSpace (colGt binderIdent))* (ppSpace location)? : tactic
syntax (name := itauto) "itauto" : tactic
syntax (name := lift) "lift " term " to " term
(" using " term)? (" with " binderIdent+)? : tactic
syntax (name := pushCast) "pushCast"
(" [" Parser.Tactic.simpArg,* "]")? (ppSpace location)? : tactic
syntax (name := normCast) "normCast" (ppSpace location)? : tactic
syntax (name := rwModCast) "rwModCast " rwRuleSeq (ppSpace location)? : tactic
syntax (name := exactModCast) "exactModCast " term : tactic
syntax (name := applyModCast) "applyModCast " term : tactic
syntax (name := assumptionModCast) "assumptionModCast" : tactic
syntax (name := obviously) "obviously" : tactic
syntax (name := prettyCases) "prettyCases" : tactic
syntax (name := pushNeg) "pushNeg" (ppSpace location)? : tactic
syntax (name := contrapose) "contrapose" (ppSpace ident (" with " ident)?)? : tactic
syntax (name := contrapose!) "contrapose!" (ppSpace ident (" with " ident)?)? : tactic
syntax (name := renameVar) "renameVar " ident " → " ident (ppSpace location)? : tactic
syntax (name := assocRw) "assocRw " rwRuleSeq (ppSpace location)? : tactic
-- Moved to Mathlib.Tactic.ShowTerm
-- syntax (name := showTerm) "showTerm " tacticSeq : tactic
syntax (name := simpRw) "simpRw " rwRuleSeq (ppSpace location)? : tactic
syntax (name := dsimpResult) "dsimpResult " (&"only ")? ("[" Tactic.simpArg,* "]")?
(" with " ident+)? " => " tacticSeq : tactic
syntax (name := simpResult) "simpResult " (&"only ")? ("[" Tactic.simpArg,* "]")?
(" with " ident+)? " => " tacticSeq : tactic
syntax (name := simpa) "simpa" (" (" &"config" " := " term ")")? (&" only")?
(" [" Tactic.simpArg,* "]")? (" with " (colGt ident)+)? (" using " term)? : tactic
syntax (name := simpa!) "simpa!" (" (" &"config" " := " term ")")? (&" only")?
(" [" Tactic.simpArg,* "]")? (" with " (colGt ident)+)? (" using " term)? : tactic
syntax (name := simpa?) "simpa?" (" (" &"config" " := " term ")")? (&" only")?
(" [" Tactic.simpArg,* "]")? (" with " (colGt ident)+)? (" using " term)? : tactic
syntax (name := simpa!?) "simpa!?" (" (" &"config" " := " term ")")? (&" only")?
(" [" Tactic.simpArg,* "]")? (" with " (colGt ident)+)? (" using " term)? : tactic
syntax (name := splitIfs) "splitIfs" (ppSpace location)? (" with " binderIdent+)? : tactic
syntax (name := squeezeScope) "squeezeScope " tacticSeq : tactic
syntax (name := squeezeSimp) "squeezeSimp" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := squeezeSimp?) "squeezeSimp?" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := squeezeSimp!) "squeezeSimp!" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := squeezeSimp?!) "squeezeSimp?!" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := squeezeSimpa) "squeezeSimpa" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (" using " term)? : tactic
syntax (name := squeezeSimpa?) "squeezeSimpa?" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (" using " term)? : tactic
syntax (name := squeezeSimpa!) "squeezeSimpa!" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (" using " term)? : tactic
syntax (name := squeezeSimpa?!) "squeezeSimpa?!" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (" using " term)? : tactic
syntax (name := squeezeDSimp) "squeezeDSimp" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := squeezeDSimp?) "squeezeDSimp?" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := squeezeDSimp!) "squeezeDSimp!" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := squeezeDSimp?!) "squeezeDSimp?!" (" (" &"config" " := " term ")")? (&" only")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := suggest) "suggest" (" (" &"config" " := " term ")")? (ppSpace num)?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (" using " (colGt ident)+)? : tactic
-- Moved to Mathlib.Tactic.LibrarySearch
-- syntax (name := librarySearch) "librarySearch" (" (" &"config" " := " term ")")?
-- (" [" simpArg,* "]")? (" with " (colGt ident)+)? (" using " (colGt ident)+)? : tactic
syntax (name := librarySearch!) "librarySearch!" (" (" &"config" " := " term ")")?
(" [" simpArg,* "]")? (" with " (colGt ident)+)? (" using " (colGt ident)+)? : tactic
syntax (name := tauto) "tauto" (" (" &"config" " := " term ")")? : tactic
syntax (name := tauto!) "tauto!" (" (" &"config" " := " term ")")? : tactic
syntax (name := truncCases) "truncCases " term (" with " (colGt binderIdent)+)? : tactic
syntax (name := normNum1) "normNum1" (ppSpace location)? : tactic
-- Moved to Mathlib.Tactic.NormNum
-- syntax (name := normNum) "normNum" (" [" simpArg,* "]")? (ppSpace location)? : tactic
syntax (name := applyNormed) "applyNormed " term : tactic
syntax (name := abel1) "abel1" : tactic
syntax (name := abel) "abel" (ppSpace (&"raw" <|> &"term"))? (ppSpace location)? : tactic
syntax (name := abel!) "abel!" (ppSpace (&"raw" <|> &"term"))? (ppSpace location)? : tactic
syntax (name := ring1) "ring1" : tactic
syntax (name := ring1!) "ring1!" : tactic
syntax ringMode := &"SOP" <|> &"raw" <|> &"horner"
syntax (name := ringNF) "ringNF" (ppSpace ringMode)? (ppSpace location)? : tactic
syntax (name := ringNF!) "ringNF!" (ppSpace ringMode)? (ppSpace location)? : tactic
-- Moved to Mathlib.Tactic.Ring
-- syntax (name := ring) "ring" : tactic
syntax (name := ring!) "ring!" : tactic
syntax (name := ringExpEq) "ringExpEq" : tactic
syntax (name := ringExpEq!) "ringExpEq!" : tactic
syntax (name := ringExp) "ringExp" (ppSpace location)? : tactic
syntax (name := ringExp!) "ringExp!" (ppSpace location)? : tactic
syntax (name := noncommRing) "noncommRing" : tactic
syntax (name := linarith) "linarith" (" (" &"config" " := " term ")")?
(&" only")? (" [" term,* "]")? : tactic
syntax (name := linarith!) "linarith!" (" (" &"config" " := " term ")")?
(&" only")? (" [" term,* "]")? : tactic
syntax (name := nlinarith) "nlinarith" (" (" &"config" " := " term ")")?
(&" only")? (" [" term,* "]")? : tactic
syntax (name := nlinarith!) "nlinarith!" (" (" &"config" " := " term ")")?
(&" only")? (" [" term,* "]")? : tactic
syntax (name := omega) "omega" (&" manual")? (&" nat" <|> &" int")? : tactic
syntax (name := tfaeHave) "tfaeHave " (ident " : ")? num (" → " <|> " ↔ " <|> " ← ") num : tactic
syntax (name := tfaeFinish) "tfaeFinish" : tactic
syntax mono.side := &"left" <|> &"right" <|> &"both"
syntax (name := mono) "mono" "*"? (ppSpace mono.side)?
(" with " (colGt term),+)? (" using " (colGt simpArg),+)? : tactic
syntax (name := acMono) "acMono" ("*" <|> ("^" num))?
(" (" &"config" " := " term ")")? ((" : " term) <|> (" := " term))? : tactic
syntax (name := applyFun) "applyFun " term (ppSpace location)? (" using " term)? : tactic
syntax (name := finCases) "finCases " ("*" <|> (term,+)) (" with " term)? : tactic
syntax (name := intervalCases) "intervalCases" (ppSpace (colGt term))?
(" using " term ", " term)? (" with " ident)? : tactic
syntax (name := reassoc) "reassoc" (ppSpace (colGt ident))* : tactic
syntax (name := reassoc!) "reassoc!" (ppSpace (colGt ident))* : tactic
syntax (name := deriveReassocProof) "deriveReassocProof" : tactic
syntax (name := sliceLHS) "sliceLHS " num num " => " Conv.convSeq : tactic
syntax (name := sliceRHS) "sliceRHS " num num " => " Conv.convSeq : tactic
syntax (name := subtypeInstance) "subtypeInstance" : tactic
syntax (name := group) "group" (ppSpace location)? : tactic
syntax (name := cancelDenoms) "cancelDenoms" (ppSpace location)? : tactic
syntax (name := zify) "zify" (" [" simpArg,* "]")? (ppSpace location)? : tactic
syntax (name := transport) "transport" (ppSpace term)? " using " term : tactic
syntax (name := unfoldCases) "unfoldCases " tacticSeq : tactic
syntax (name := fieldSimp) "fieldSimp" (" (" &"config" " := " term ")")? (&" only")?
(" [" Tactic.simpArg,* "]")? (" with " (colGt ident)+)? (ppSpace location)? : tactic
syntax (name := equivRw) "equivRw " ("(" &"config" " := " term ") ")?
term (ppSpace location)? : tactic
syntax (name := equivRwType) "equivRwType " ("(" &"config" " := " term ") ")? term : tactic
syntax (name := nthRw) "nthRw " num rwRuleSeq (ppSpace location)? : tactic
syntax (name := nthRwLHS) "nthRwLHS " num rwRuleSeq (ppSpace location)? : tactic
syntax (name := nthRwRHS) "nthRwRHS " num rwRuleSeq (ppSpace location)? : tactic
syntax (name := rwSearch) "rwSearch " ("(" &"config" " := " term ") ")? rwRuleSeq : tactic
syntax (name := rwSearch?) "rwSearch? " ("(" &"config" " := " term ") ")? rwRuleSeq : tactic
syntax (name := piInstanceDeriveField) "piInstanceDeriveField" : tactic
syntax (name := piInstance) "piInstance" : tactic
syntax (name := tidy) "tidy" (" (" &"config" " := " term ")")? : tactic
syntax (name := tidy?) "tidy?" (" (" &"config" " := " term ")")? : tactic
syntax (name := wlog) "wlog" (" (" &"discharger" " := " term ")")?
(ppSpace (colGt ident))? (" : " term)? (" := " term)? (" using " (ident*),+)? : tactic
syntax (name := elementwise) "elementwise" (ppSpace (colGt ident))* : tactic
syntax (name := elementwise!) "elementwise!" (ppSpace (colGt ident))* : tactic
syntax (name := deriveElementwiseProof) "deriveElementwiseProof" : tactic
syntax (name := mkDecorations) "mkDecorations" : tactic
syntax (name := nontriviality) "nontriviality"
(ppSpace (colGt term))? (" using " simpArg,+)? : tactic
syntax (name := filterUpwards) "filterUpwards" " [" term,* "]" (ppSpace (colGt term))? : tactic
syntax (name := isBounded_default) "isBounded_default" : tactic
syntax (name := opInduction) "opInduction" (ppSpace (colGt term))? : tactic
syntax (name := mvBisim) "mvBisim" (ppSpace (colGt term))? (" with " binderIdent+)? : tactic
syntax (name := continuity) "continuity" (" (" &"config" " := " term ")")? : tactic
syntax (name := continuity!) "continuity!" (" (" &"config" " := " term ")")? : tactic
syntax (name := continuity?) "continuity?" (" (" &"config" " := " term ")")? : tactic
syntax (name := continuity!?) "continuity!?" (" (" &"config" " := " term ")")? : tactic
syntax (name := unitInterval) "unitInterval" : tactic
syntax (name := mfldSetTac) "mfldSetTac" : tactic
syntax (name := measurability) "measurability" (" (" &"config" " := " term ")")? : tactic
syntax (name := measurability!) "measurability!" (" (" &"config" " := " term ")")? : tactic
syntax (name := measurability?) "measurability?" (" (" &"config" " := " term ")")? : tactic
syntax (name := measurability!?) "measurability!?" (" (" &"config" " := " term ")")? : tactic
syntax (name := padicIndexSimp) "padicIndexSimp" " [" term,* "]" (ppSpace location)? : tactic
syntax (name := uniqueDiffWithinAt_Ici_Iic_univ) "uniqueDiffWithinAt_Ici_Iic_univ" : tactic
syntax (name := ghostFunTac) "ghostFunTac " term ", " term : tactic
syntax (name := ghostCalc) "ghostCalc" (ppSpace binderIdent)* : tactic
syntax (name := initRing) "initRing" (" using " term)? : tactic
syntax (name := ghostSimp) "ghostSimp" (" [" simpArg,* "]")? : tactic
syntax (name := wittTruncateFunTac) "wittTruncateFunTac" : tactic
namespace Conv
syntax (name := convConv) "conv" " => " Conv.convSeq : conv
syntax (name := erw) "erw " rwRuleSeq : conv
syntax (name := applyCongr) "applyCongr" (ppSpace (colGt term))? : conv
syntax (name := guardTarget) "guardTarget" " =ₐ " term : conv
syntax (name := normCast) "normCast" : conv
syntax (name := normNum1) "normNum1" : conv
syntax (name := normNum) "normNum" (" [" simpArg,* "]")? : conv
syntax (name := ringNF) "ringNF" (ppSpace ringMode)? : conv
syntax (name := ringNF!) "ringNF!" (ppSpace ringMode)? : conv
syntax (name := ring) "ring" : conv
syntax (name := ring!) "ring!" : conv
syntax (name := ringExp) "ringExp" : conv
syntax (name := ringExp!) "ringExp!" : conv
syntax (name := slice) "slice " num num : conv
end Conv
end Tactic
namespace Attr
syntax (name := intro) "intro" : attr
syntax (name := intro!) "intro!" : attr
syntax (name := nolint) "nolint" (ppSpace ident)* : attr
syntax (name := ext) "ext" (ppSpace ident)? : attr
syntax (name := higherOrder) "higherOrder" (ppSpace ident)? : attr
syntax (name := interactive) "interactive" : attr
syntax (name := mkIff) "mkIff" (ppSpace ident)? : attr
syntax (name := normCast) "normCast" (ppSpace (&"elim" <|> &"move" <|> &"squash"))? : attr
syntax (name := protectProj) "protectProj" (&" without" (ppSpace ident)+)? : attr
syntax (name := notationClass) "notationClass" "*"? (ppSpace ident)? : attr
syntax (name := simps) "simps" (" (" &"config" " := " term ")")? (ppSpace ident)* : attr
syntax (name := simps?) "simps?" (" (" &"config" " := " term ")")? (ppSpace ident)* : attr
syntax (name := mono) "mono" (ppSpace Tactic.mono.side)? : attr
syntax (name := reassoc) "reassoc" (ppSpace ident)? : attr
syntax (name := ancestor) "ancestor" (ppSpace ident)* : attr
syntax (name := elementwise) "elementwise" (ppSpace ident)? : attr
syntax (name := toAdditiveIgnoreArgs) "toAdditiveIgnoreArgs" num* : attr
syntax (name := toAdditiveReorder) "toAdditiveReorder" num* : attr
syntax (name := toAdditive) "toAdditive" (ppSpace ident)? (ppSpace str)? : attr
syntax (name := toAdditive!) "toAdditive!" (ppSpace ident)? (ppSpace str)? : attr
syntax (name := toAdditive?) "toAdditive?" (ppSpace ident)? (ppSpace str)? : attr
syntax (name := toAdditive!?) "toAdditive!?" (ppSpace ident)? (ppSpace str)? : attr
end Attr
namespace Command
namespace Lint
syntax verbosity := "-" <|> "+"
syntax opts := (verbosity "*"?) <|> ("*"? (verbosity)?)
syntax args := opts " only"? ident*
end Lint
syntax (name := lint) "#lint" Lint.args : command
syntax (name := lintMathlib) "#lint_mathlib" Lint.args : command
syntax (name := lintAll) "#lint_all" Lint.args : command
syntax (name := listLinters) "#list_linters" : command
syntax (name := copyDocString) "copy_doc_string " ident " → " ident* : command
syntax (name := libraryNote) docComment "library_note " str : command
syntax (name := addTacticDoc) (docComment)? "add_tactic_doc " term : command
syntax (name := addDeclDoc) docComment "add_decl_doc " ident : command
syntax (name := setupTacticParser) "setup_tactic_parser" : command
-- Note that Mathlib.Tactic.OpenPrivate provides an alternative,
-- which we should later switch to using.
syntax (name := importPrivate) "import_private " ident (" from " ident)? : command
syntax (name := mkSimpAttribute) "mk_simp_attribute " ident
(" from" (ppSpace ident)+)? (" := " str)? : command
syntax (name := addHintTactic) "add_hint_tactic " tactic : command
syntax (name := alias) "alias " ident " ← " ident* : command
syntax (name := aliasLR) "alias " ident " ↔ " (".." <|> (binderIdent binderIdent)) : command
syntax (name := explode) "#explode " ident : command
-- Moved to Mathlib.Tactic.Find
-- syntax (name := find) "#find " term : command
syntax (name := open_locale) "open_locale" (ppSpace ident)* : command
syntax (name := localized) "localized " "[" ident "] " command : command
syntax (name := listUnusedDecls) "#list_unused_decls" : command
syntax (name := mkIffOfInductiveProp) "mk_iff_of_inductive_prop" ident ident : command
syntax (name := defReplacer) "def_replacer " ident Term.optType : command
syntax (name := restateAxiom) "restate_axiom " ident (ppSpace ident)? : command
syntax (name := simp) "#simp" (&" only")? (" [" Tactic.simpArg,* "]")?
(" with " ident+)? " :"? ppSpace term : command
syntax simpsRule.rename := ident " → " ident
syntax simpsRule.erase := "-" ident
syntax simpsRule := (simpsRule.rename <|> simpsRule.erase) &" as_prefix"?
syntax simpsProj := ident (" (" simpsRule,+ ")")?
syntax (name := initializeSimpsProjections) "initialize_simps_projections"
(ppSpace simpsProj)* : command
syntax (name := initializeSimpsProjections?) "initialize_simps_projections?"
(ppSpace simpsProj)* : command
syntax (name := «where») "#where" : command
syntax (name := reassoc_axiom) "reassoc_axiom " ident : command
syntax (name := sample) "#sample " term : command
end Command
|
34a8aefffab9bfe5dec3b1d3eab6751fb922626a | dc253be9829b840f15d96d986e0c13520b085033 | /algebra/tensor.hlean | eeb15e8ea2f962fa90f4d867fff9711ca9af7623 | [
"Apache-2.0"
] | permissive | cmu-phil/Spectral | 4ce68e5c1ef2a812ffda5260e9f09f41b85ae0ea | 3b078f5f1de251637decf04bd3fc8aa01930a6b3 | refs/heads/master | 1,685,119,195,535 | 1,684,169,772,000 | 1,684,169,772,000 | 46,450,197 | 42 | 13 | null | 1,505,516,767,000 | 1,447,883,921,000 | Lean | UTF-8 | Lean | false | false | 1,268 | hlean | /-
Copyright (c) 2015 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Egbert Rijke
Tensor group
-/
import .free_abelian_group
open eq algebra is_trunc sigma sigma.ops prod trunc function equiv
namespace group
variables {G G' : Group} {g g' h h' k : G} {A B : AbGroup}
/- Tensor group (WIP) -/
/- namespace tensor_group
variables {A B}
local abbreviation ι := @free_ab_group_inclusion
inductive tensor_rel_type : free_ab_group (Set_of_Group A ×t Set_of_Group B) → Type :=
| mul_left : Π(a₁ a₂ : A) (b : B), tensor_rel_type (ι (a₁, b) * ι (a₂, b) * (ι (a₁ * a₂, b))⁻¹)
| mul_right : Π(a : A) (b₁ b₂ : B), tensor_rel_type (ι (a, b₁) * ι (a, b₂) * (ι (a, b₁ * b₂))⁻¹)
open tensor_rel_type
definition tensor_rel' (x : free_ab_group (Set_of_Group A ×t Set_of_Group B)) : Prop :=
∥ tensor_rel_type x ∥
definition tensor_group_rel (A B : AbGroup)
: normal_subgroup_rel (free_ab_group (Set_of_Group A ×t Set_of_Group B)) :=
sorry /- relation generated by tensor_rel'-/
definition tensor_group [constructor] : AbGroup :=
quotient_ab_group (tensor_group_rel A B)
end tensor_group-/
end group
|
a604925d471cc7e9daac10bac1f1a744e109f3c1 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/data/fin/tuple/basic.lean | 8deaf3f06fa08cb58ddd23482d887eb272a65ed8 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 27,779 | lean | /-
Copyright (c) 2019 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Yury Kudryashov, Sébastien Gouëzel, Chris Hughes
-/
import data.fin.basic
import data.pi.lex
import data.set.intervals.basic
/-!
# Operation on tuples
We interpret maps `Π i : fin n, α i` as `n`-tuples of elements of possibly varying type `α i`,
`(α 0, …, α (n-1))`. A particular case is `fin n → α` of elements with all the same type.
In this case when `α i` is a constant map, then tuples are isomorphic (but not definitionally equal)
to `vector`s.
We define the following operations:
* `fin.tail` : the tail of an `n+1` tuple, i.e., its last `n` entries;
* `fin.cons` : adding an element at the beginning of an `n`-tuple, to get an `n+1`-tuple;
* `fin.init` : the beginning of an `n+1` tuple, i.e., its first `n` entries;
* `fin.snoc` : adding an element at the end of an `n`-tuple, to get an `n+1`-tuple. The name `snoc`
comes from `cons` (i.e., adding an element to the left of a tuple) read in reverse order.
* `fin.insert_nth` : insert an element to a tuple at a given position.
* `fin.find p` : returns the first index `n` where `p n` is satisfied, and `none` if it is never
satisfied.
-/
universes u v
namespace fin
variables {m n : ℕ}
open function
section tuple
/-- There is exactly one tuple of size zero. -/
example (α : fin 0 → Sort u) : unique (Π i : fin 0, α i) :=
by apply_instance
@[simp] lemma tuple0_le {α : Π i : fin 0, Type*} [Π i, preorder (α i)] (f g : Π i, α i) : f ≤ g :=
fin_zero_elim
variables {α : fin (n+1) → Type u} (x : α 0) (q : Πi, α i) (p : Π(i : fin n), α (i.succ))
(i : fin n) (y : α i.succ) (z : α 0)
/-- The tail of an `n+1` tuple, i.e., its last `n` entries. -/
def tail (q : Πi, α i) : (Π(i : fin n), α (i.succ)) := λ i, q i.succ
lemma tail_def {n : ℕ} {α : fin (n+1) → Type*} {q : Π i, α i} :
tail (λ k : fin (n+1), q k) = (λ k : fin n, q k.succ) := rfl
/-- Adding an element at the beginning of an `n`-tuple, to get an `n+1`-tuple. -/
def cons (x : α 0) (p : Π(i : fin n), α (i.succ)) : Πi, α i :=
λ j, fin.cases x p j
@[simp] lemma tail_cons : tail (cons x p) = p :=
by simp [tail, cons]
@[simp] lemma cons_succ : cons x p i.succ = p i :=
by simp [cons]
@[simp] lemma cons_zero : cons x p 0 = x :=
by simp [cons]
/-- Updating a tuple and adding an element at the beginning commute. -/
@[simp] lemma cons_update : cons x (update p i y) = update (cons x p) i.succ y :=
begin
ext j,
by_cases h : j = 0,
{ rw h, simp [ne.symm (succ_ne_zero i)] },
{ let j' := pred j h,
have : j'.succ = j := succ_pred j h,
rw [← this, cons_succ],
by_cases h' : j' = i,
{ rw h', simp },
{ have : j'.succ ≠ i.succ, by rwa [ne.def, succ_inj],
rw [update_noteq h', update_noteq this, cons_succ] } }
end
/-- As a binary function, `fin.cons` is injective. -/
lemma cons_injective2 : function.injective2 (@cons n α) :=
λ x₀ y₀ x y h, ⟨congr_fun h 0, funext $ λ i, by simpa using congr_fun h (fin.succ i)⟩
@[simp] lemma cons_eq_cons {x₀ y₀ : α 0} {x y : Π i : fin n, α (i.succ)} :
cons x₀ x = cons y₀ y ↔ x₀ = y₀ ∧ x = y :=
cons_injective2.eq_iff
lemma cons_left_injective (x : Π i : fin n, α (i.succ)) : function.injective (λ x₀, cons x₀ x) :=
cons_injective2.left _
lemma cons_right_injective (x₀ : α 0) : function.injective (cons x₀) :=
cons_injective2.right _
/-- Adding an element at the beginning of a tuple and then updating it amounts to adding it
directly. -/
lemma update_cons_zero : update (cons x p) 0 z = cons z p :=
begin
ext j,
by_cases h : j = 0,
{ rw h, simp },
{ simp only [h, update_noteq, ne.def, not_false_iff],
let j' := pred j h,
have : j'.succ = j := succ_pred j h,
rw [← this, cons_succ, cons_succ] }
end
/-- Concatenating the first element of a tuple with its tail gives back the original tuple -/
@[simp] lemma cons_self_tail : cons (q 0) (tail q) = q :=
begin
ext j,
by_cases h : j = 0,
{ rw h, simp },
{ let j' := pred j h,
have : j'.succ = j := succ_pred j h,
rw [← this, tail, cons_succ] }
end
/-- Recurse on an `n+1`-tuple by splitting it into a single element and an `n`-tuple. -/
@[elab_as_eliminator]
def cons_induction {P : (Π i : fin n.succ, α i) → Sort v}
(h : ∀ x₀ x, P (fin.cons x₀ x)) (x : (Π i : fin n.succ, α i)) : P x :=
_root_.cast (by rw cons_self_tail) $ h (x 0) (tail x)
@[simp] lemma cons_induction_cons {P : (Π i : fin n.succ, α i) → Sort v}
(h : Π x₀ x, P (fin.cons x₀ x)) (x₀ : α 0) (x : Π i : fin n, α i.succ) :
@cons_induction _ _ _ h (cons x₀ x) = h x₀ x :=
begin
rw [cons_induction, cast_eq],
congr',
exact tail_cons _ _
end
@[simp] lemma forall_fin_zero_pi {α : fin 0 → Sort*} {P : (Π i, α i) → Prop} :
(∀ x, P x) ↔ P fin_zero_elim :=
⟨λ h, h _, λ h x, subsingleton.elim fin_zero_elim x ▸ h⟩
@[simp] lemma exists_fin_zero_pi {α : fin 0 → Sort*} {P : (Π i, α i) → Prop} :
(∃ x, P x) ↔ P fin_zero_elim :=
⟨λ ⟨x, h⟩, subsingleton.elim x fin_zero_elim ▸ h, λ h, ⟨_, h⟩⟩
lemma forall_fin_succ_pi {P : (Π i, α i) → Prop} :
(∀ x, P x) ↔ (∀ a v, P (fin.cons a v)) :=
⟨λ h a v, h (fin.cons a v), cons_induction⟩
lemma exists_fin_succ_pi {P : (Π i, α i) → Prop} :
(∃ x, P x) ↔ (∃ a v, P (fin.cons a v)) :=
⟨λ ⟨x, h⟩, ⟨x 0, tail x, (cons_self_tail x).symm ▸ h⟩, λ ⟨a, v, h⟩, ⟨_, h⟩⟩
/-- Updating the first element of a tuple does not change the tail. -/
@[simp] lemma tail_update_zero : tail (update q 0 z) = tail q :=
by { ext j, simp [tail, fin.succ_ne_zero] }
/-- Updating a nonzero element and taking the tail commute. -/
@[simp] lemma tail_update_succ :
tail (update q i.succ y) = update (tail q) i y :=
begin
ext j,
by_cases h : j = i,
{ rw h, simp [tail] },
{ simp [tail, (fin.succ_injective n).ne h, h] }
end
lemma comp_cons {α : Type*} {β : Type*} (g : α → β) (y : α) (q : fin n → α) :
g ∘ (cons y q) = cons (g y) (g ∘ q) :=
begin
ext j,
by_cases h : j = 0,
{ rw h, refl },
{ let j' := pred j h,
have : j'.succ = j := succ_pred j h,
rw [← this, cons_succ, comp_app, cons_succ] }
end
lemma comp_tail {α : Type*} {β : Type*} (g : α → β) (q : fin n.succ → α) :
g ∘ (tail q) = tail (g ∘ q) :=
by { ext j, simp [tail] }
lemma le_cons [Π i, preorder (α i)] {x : α 0} {q : Π i, α i} {p : Π i : fin n, α i.succ} :
q ≤ cons x p ↔ q 0 ≤ x ∧ tail q ≤ p :=
forall_fin_succ.trans $ and_congr iff.rfl $ forall_congr $ λ j, by simp [tail]
lemma cons_le [Π i, preorder (α i)] {x : α 0} {q : Π i, α i} {p : Π i : fin n, α i.succ} :
cons x p ≤ q ↔ x ≤ q 0 ∧ p ≤ tail q :=
@le_cons _ (λ i, (α i)ᵒᵈ) _ x q p
lemma cons_le_cons [Π i, preorder (α i)] {x₀ y₀ : α 0} {x y : Π i : fin n, α (i.succ)} :
cons x₀ x ≤ cons y₀ y ↔ x₀ ≤ y₀ ∧ x ≤ y :=
forall_fin_succ.trans $ and_congr_right' $ by simp only [cons_succ, pi.le_def]
lemma pi_lex_lt_cons_cons {x₀ y₀ : α 0} {x y : Π i : fin n, α (i.succ)}
(s : Π {i : fin n.succ}, α i → α i → Prop) :
pi.lex (<) @s (fin.cons x₀ x) (fin.cons y₀ y) ↔
s x₀ y₀ ∨ x₀ = y₀ ∧ pi.lex (<) (λ i : fin n, @s i.succ) x y :=
begin
simp_rw [pi.lex, fin.exists_fin_succ, fin.cons_succ, fin.cons_zero, fin.forall_fin_succ],
simp [and_assoc, exists_and_distrib_left],
end
lemma range_fin_succ {α} (f : fin (n + 1) → α) :
set.range f = insert (f 0) (set.range (fin.tail f)) :=
set.ext $ λ y, exists_fin_succ.trans $ eq_comm.or iff.rfl
@[simp] lemma range_cons {α : Type*} {n : ℕ} (x : α) (b : fin n → α) :
set.range (fin.cons x b : fin n.succ → α) = insert x (set.range b) :=
by rw [range_fin_succ, cons_zero, tail_cons]
/-- `fin.append ho u v` appends two vectors of lengths `m` and `n` to produce
one of length `o = m + n`. `ho` provides control of definitional equality
for the vector length. -/
def append {α : Type*} {o : ℕ} (ho : o = m + n) (u : fin m → α) (v : fin n → α) : fin o → α :=
λ i, if h : (i : ℕ) < m
then u ⟨i, h⟩
else v ⟨(i : ℕ) - m, (tsub_lt_iff_left (le_of_not_lt h)).2 (ho ▸ i.property)⟩
@[simp] lemma fin_append_apply_zero {α : Type*} {o : ℕ} (ho : (o + 1) = (m + 1) + n)
(u : fin (m + 1) → α) (v : fin n → α) :
fin.append ho u v 0 = u 0 := rfl
end tuple
section tuple_right
/-! In the previous section, we have discussed inserting or removing elements on the left of a
tuple. In this section, we do the same on the right. A difference is that `fin (n+1)` is constructed
inductively from `fin n` starting from the left, not from the right. This implies that Lean needs
more help to realize that elements belong to the right types, i.e., we need to insert casts at
several places. -/
variables {α : fin (n+1) → Type u} (x : α (last n)) (q : Πi, α i) (p : Π(i : fin n), α i.cast_succ)
(i : fin n) (y : α i.cast_succ) (z : α (last n))
/-- The beginning of an `n+1` tuple, i.e., its first `n` entries -/
def init (q : Πi, α i) (i : fin n) : α i.cast_succ :=
q i.cast_succ
lemma init_def {n : ℕ} {α : fin (n+1) → Type*} {q : Π i, α i} :
init (λ k : fin (n+1), q k) = (λ k : fin n, q k.cast_succ) := rfl
/-- Adding an element at the end of an `n`-tuple, to get an `n+1`-tuple. The name `snoc` comes from
`cons` (i.e., adding an element to the left of a tuple) read in reverse order. -/
def snoc (p : Π(i : fin n), α i.cast_succ) (x : α (last n)) (i : fin (n+1)) : α i :=
if h : i.val < n
then _root_.cast (by rw fin.cast_succ_cast_lt i h) (p (cast_lt i h))
else _root_.cast (by rw eq_last_of_not_lt h) x
@[simp] lemma init_snoc : init (snoc p x) = p :=
begin
ext i,
have h' := fin.cast_lt_cast_succ i i.is_lt,
simp [init, snoc, i.is_lt, h'],
convert cast_eq rfl (p i)
end
@[simp] lemma snoc_cast_succ : snoc p x i.cast_succ = p i :=
begin
have : i.cast_succ.val < n := i.is_lt,
have h' := fin.cast_lt_cast_succ i i.is_lt,
simp [snoc, this, h'],
convert cast_eq rfl (p i)
end
@[simp] lemma snoc_comp_cast_succ {n : ℕ} {α : Sort*} {a : α} {f : fin n → α} :
(snoc f a : fin (n + 1) → α) ∘ cast_succ = f :=
funext (λ i, by rw [function.comp_app, snoc_cast_succ])
@[simp] lemma snoc_last : snoc p x (last n) = x :=
by { simp [snoc] }
@[simp] lemma snoc_comp_nat_add {n m : ℕ} {α : Sort*} (f : fin (m + n) → α) (a : α) :
(snoc f a : fin _ → α) ∘ (nat_add m : fin (n + 1) → fin (m + n + 1)) = snoc (f ∘ nat_add m) a :=
begin
ext i,
refine fin.last_cases _ (λ i, _) i,
{ simp only [function.comp_app],
rw [snoc_last, nat_add_last, snoc_last] },
{ simp only [function.comp_app],
rw [snoc_cast_succ, nat_add_cast_succ, snoc_cast_succ] }
end
@[simp] lemma snoc_cast_add {α : fin (n + m + 1) → Type*}
(f : Π i : fin (n + m), α (cast_succ i)) (a : α (last (n + m)))
(i : fin n) :
(snoc f a) (cast_add (m + 1) i) = f (cast_add m i) :=
dif_pos _
@[simp] lemma snoc_comp_cast_add {n m : ℕ} {α : Sort*} (f : fin (n + m) → α) (a : α) :
(snoc f a : fin _ → α) ∘ cast_add (m + 1) = f ∘ cast_add m :=
funext (snoc_cast_add f a)
/-- Updating a tuple and adding an element at the end commute. -/
@[simp] lemma snoc_update : snoc (update p i y) x = update (snoc p x) i.cast_succ y :=
begin
ext j,
by_cases h : j.val < n,
{ simp only [snoc, h, dif_pos],
by_cases h' : j = cast_succ i,
{ have C1 : α i.cast_succ = α j, by rw h',
have E1 : update (snoc p x) i.cast_succ y j = _root_.cast C1 y,
{ have : update (snoc p x) j (_root_.cast C1 y) j = _root_.cast C1 y, by simp,
convert this,
{ exact h'.symm },
{ exact heq_of_cast_eq (congr_arg α (eq.symm h')) rfl } },
have C2 : α i.cast_succ = α (cast_succ (cast_lt j h)),
by rw [cast_succ_cast_lt, h'],
have E2 : update p i y (cast_lt j h) = _root_.cast C2 y,
{ have : update p (cast_lt j h) (_root_.cast C2 y) (cast_lt j h) = _root_.cast C2 y,
by simp,
convert this,
{ simp [h, h'] },
{ exact heq_of_cast_eq C2 rfl } },
rw [E1, E2],
exact eq_rec_compose _ _ _ },
{ have : ¬(cast_lt j h = i),
by { assume E, apply h', rw [← E, cast_succ_cast_lt] },
simp [h', this, snoc, h] } },
{ rw eq_last_of_not_lt h,
simp [ne.symm (ne_of_lt (cast_succ_lt_last i))] }
end
/-- Adding an element at the beginning of a tuple and then updating it amounts to adding it
directly. -/
lemma update_snoc_last : update (snoc p x) (last n) z = snoc p z :=
begin
ext j,
by_cases h : j.val < n,
{ have : j ≠ last n := ne_of_lt h,
simp [h, update_noteq, this, snoc] },
{ rw eq_last_of_not_lt h,
simp }
end
/-- Concatenating the first element of a tuple with its tail gives back the original tuple -/
@[simp] lemma snoc_init_self : snoc (init q) (q (last n)) = q :=
begin
ext j,
by_cases h : j.val < n,
{ have : j ≠ last n := ne_of_lt h,
simp [h, update_noteq, this, snoc, init, cast_succ_cast_lt],
have A : cast_succ (cast_lt j h) = j := cast_succ_cast_lt _ _,
rw ← cast_eq rfl (q j),
congr' 1; rw A },
{ rw eq_last_of_not_lt h,
simp }
end
/-- Updating the last element of a tuple does not change the beginning. -/
@[simp] lemma init_update_last : init (update q (last n) z) = init q :=
by { ext j, simp [init, ne_of_lt, cast_succ_lt_last] }
/-- Updating an element and taking the beginning commute. -/
@[simp] lemma init_update_cast_succ :
init (update q i.cast_succ y) = update (init q) i y :=
begin
ext j,
by_cases h : j = i,
{ rw h, simp [init] },
{ simp [init, h] }
end
/-- `tail` and `init` commute. We state this lemma in a non-dependent setting, as otherwise it
would involve a cast to convince Lean that the two types are equal, making it harder to use. -/
lemma tail_init_eq_init_tail {β : Type*} (q : fin (n+2) → β) :
tail (init q) = init (tail q) :=
by { ext i, simp [tail, init, cast_succ_fin_succ] }
/-- `cons` and `snoc` commute. We state this lemma in a non-dependent setting, as otherwise it
would involve a cast to convince Lean that the two types are equal, making it harder to use. -/
lemma cons_snoc_eq_snoc_cons {β : Type*} (a : β) (q : fin n → β) (b : β) :
@cons n.succ (λ i, β) a (snoc q b) = snoc (cons a q) b :=
begin
ext i,
by_cases h : i = 0,
{ rw h, refl },
set j := pred i h with ji,
have : i = j.succ, by rw [ji, succ_pred],
rw [this, cons_succ],
by_cases h' : j.val < n,
{ set k := cast_lt j h' with jk,
have : j = k.cast_succ, by rw [jk, cast_succ_cast_lt],
rw [this, ← cast_succ_fin_succ],
simp },
rw [eq_last_of_not_lt h', succ_last],
simp
end
lemma comp_snoc {α : Type*} {β : Type*} (g : α → β) (q : fin n → α) (y : α) :
g ∘ (snoc q y) = snoc (g ∘ q) (g y) :=
begin
ext j,
by_cases h : j.val < n,
{ have : j ≠ last n := ne_of_lt h,
simp [h, this, snoc, cast_succ_cast_lt] },
{ rw eq_last_of_not_lt h,
simp }
end
lemma comp_init {α : Type*} {β : Type*} (g : α → β) (q : fin n.succ → α) :
g ∘ (init q) = init (g ∘ q) :=
by { ext j, simp [init] }
end tuple_right
section insert_nth
variables {α : fin (n+1) → Type u} {β : Type v}
/-- Define a function on `fin (n + 1)` from a value on `i : fin (n + 1)` and values on each
`fin.succ_above i j`, `j : fin n`. This version is elaborated as eliminator and works for
propositions, see also `fin.insert_nth` for a version without an `@[elab_as_eliminator]`
attribute. -/
@[elab_as_eliminator]
def succ_above_cases {α : fin (n + 1) → Sort u} (i : fin (n + 1)) (x : α i)
(p : Π j : fin n, α (i.succ_above j)) (j : fin (n + 1)) : α j :=
if hj : j = i then eq.rec x hj.symm
else if hlt : j < i then eq.rec_on (succ_above_cast_lt hlt) (p _)
else eq.rec_on (succ_above_pred $ (ne.lt_or_lt hj).resolve_left hlt) (p _)
lemma forall_iff_succ_above {p : fin (n + 1) → Prop} (i : fin (n + 1)) :
(∀ j, p j) ↔ p i ∧ ∀ j, p (i.succ_above j) :=
⟨λ h, ⟨h _, λ j, h _⟩, λ h, succ_above_cases i h.1 h.2⟩
/-- Insert an element into a tuple at a given position. For `i = 0` see `fin.cons`,
for `i = fin.last n` see `fin.snoc`. See also `fin.succ_above_cases` for a version elaborated
as an eliminator. -/
def insert_nth (i : fin (n + 1)) (x : α i) (p : Π j : fin n, α (i.succ_above j)) (j : fin (n + 1)) :
α j :=
succ_above_cases i x p j
@[simp] lemma insert_nth_apply_same (i : fin (n + 1)) (x : α i) (p : Π j, α (i.succ_above j)) :
insert_nth i x p i = x :=
by simp [insert_nth, succ_above_cases]
@[simp] lemma insert_nth_apply_succ_above (i : fin (n + 1)) (x : α i) (p : Π j, α (i.succ_above j))
(j : fin n) :
insert_nth i x p (i.succ_above j) = p j :=
begin
simp only [insert_nth, succ_above_cases, dif_neg (succ_above_ne _ _)],
by_cases hlt : j.cast_succ < i,
{ rw [dif_pos ((succ_above_lt_iff _ _).2 hlt)],
apply eq_of_heq ((eq_rec_heq _ _).trans _),
rw [cast_lt_succ_above hlt] },
{ rw [dif_neg (mt (succ_above_lt_iff _ _).1 hlt)],
apply eq_of_heq ((eq_rec_heq _ _).trans _),
rw [pred_succ_above (le_of_not_lt hlt)] }
end
@[simp] lemma succ_above_cases_eq_insert_nth :
@succ_above_cases.{u + 1} = @insert_nth.{u} := rfl
@[simp] lemma insert_nth_comp_succ_above (i : fin (n + 1)) (x : β) (p : fin n → β) :
insert_nth i x p ∘ i.succ_above = p :=
funext $ insert_nth_apply_succ_above i x p
lemma insert_nth_eq_iff {i : fin (n + 1)} {x : α i} {p : Π j, α (i.succ_above j)} {q : Π j, α j} :
i.insert_nth x p = q ↔ q i = x ∧ p = (λ j, q (i.succ_above j)) :=
by simp [funext_iff, forall_iff_succ_above i, eq_comm]
lemma eq_insert_nth_iff {i : fin (n + 1)} {x : α i} {p : Π j, α (i.succ_above j)} {q : Π j, α j} :
q = i.insert_nth x p ↔ q i = x ∧ p = (λ j, q (i.succ_above j)) :=
eq_comm.trans insert_nth_eq_iff
lemma insert_nth_apply_below {i j : fin (n + 1)} (h : j < i) (x : α i)
(p : Π k, α (i.succ_above k)) :
i.insert_nth x p j = eq.rec_on (succ_above_cast_lt h) (p $ j.cast_lt _) :=
by rw [insert_nth, succ_above_cases, dif_neg h.ne, dif_pos h]
lemma insert_nth_apply_above {i j : fin (n + 1)} (h : i < j) (x : α i)
(p : Π k, α (i.succ_above k)) :
i.insert_nth x p j = eq.rec_on (succ_above_pred h) (p $ j.pred _) :=
by rw [insert_nth, succ_above_cases, dif_neg h.ne', dif_neg h.not_lt]
lemma insert_nth_zero (x : α 0) (p : Π j : fin n, α (succ_above 0 j)) :
insert_nth 0 x p = cons x (λ j, _root_.cast (congr_arg α (congr_fun succ_above_zero j)) (p j)) :=
begin
refine insert_nth_eq_iff.2 ⟨by simp, _⟩,
ext j,
convert (cons_succ _ _ _).symm
end
@[simp] lemma insert_nth_zero' (x : β) (p : fin n → β) :
@insert_nth _ (λ _, β) 0 x p = cons x p :=
by simp [insert_nth_zero]
lemma insert_nth_last (x : α (last n)) (p : Π j : fin n, α ((last n).succ_above j)) :
insert_nth (last n) x p =
snoc (λ j, _root_.cast (congr_arg α (succ_above_last_apply j)) (p j)) x :=
begin
refine insert_nth_eq_iff.2 ⟨by simp, _⟩,
ext j,
apply eq_of_heq,
transitivity snoc (λ j, _root_.cast (congr_arg α (succ_above_last_apply j)) (p j)) x j.cast_succ,
{ rw [snoc_cast_succ], exact (cast_heq _ _).symm },
{ apply congr_arg_heq,
rw [succ_above_last] }
end
@[simp] lemma insert_nth_last' (x : β) (p : fin n → β) :
@insert_nth _ (λ _, β) (last n) x p = snoc p x :=
by simp [insert_nth_last]
@[simp] lemma insert_nth_zero_right [Π j, has_zero (α j)] (i : fin (n + 1)) (x : α i) :
i.insert_nth x 0 = pi.single i x :=
insert_nth_eq_iff.2 $ by simp [succ_above_ne, pi.zero_def]
lemma insert_nth_binop (op : Π j, α j → α j → α j) (i : fin (n + 1))
(x y : α i) (p q : Π j, α (i.succ_above j)) :
i.insert_nth (op i x y) (λ j, op _ (p j) (q j)) =
λ j, op j (i.insert_nth x p j) (i.insert_nth y q j) :=
insert_nth_eq_iff.2 $ by simp
@[simp] lemma insert_nth_mul [Π j, has_mul (α j)] (i : fin (n + 1))
(x y : α i) (p q : Π j, α (i.succ_above j)) :
i.insert_nth (x * y) (p * q) = i.insert_nth x p * i.insert_nth y q :=
insert_nth_binop (λ _, (*)) i x y p q
@[simp] lemma insert_nth_add [Π j, has_add (α j)] (i : fin (n + 1))
(x y : α i) (p q : Π j, α (i.succ_above j)) :
i.insert_nth (x + y) (p + q) = i.insert_nth x p + i.insert_nth y q :=
insert_nth_binop (λ _, (+)) i x y p q
@[simp] lemma insert_nth_div [Π j, has_div (α j)] (i : fin (n + 1))
(x y : α i) (p q : Π j, α (i.succ_above j)) :
i.insert_nth (x / y) (p / q) = i.insert_nth x p / i.insert_nth y q :=
insert_nth_binop (λ _, (/)) i x y p q
@[simp] lemma insert_nth_sub [Π j, has_sub (α j)] (i : fin (n + 1))
(x y : α i) (p q : Π j, α (i.succ_above j)) :
i.insert_nth (x - y) (p - q) = i.insert_nth x p - i.insert_nth y q :=
insert_nth_binop (λ _, has_sub.sub) i x y p q
@[simp] lemma insert_nth_sub_same [Π j, add_group (α j)] (i : fin (n + 1))
(x y : α i) (p : Π j, α (i.succ_above j)) :
i.insert_nth x p - i.insert_nth y p = pi.single i (x - y) :=
by simp_rw [← insert_nth_sub, ← insert_nth_zero_right, pi.sub_def, sub_self, pi.zero_def]
variables [Π i, preorder (α i)]
lemma insert_nth_le_iff {i : fin (n + 1)} {x : α i} {p : Π j, α (i.succ_above j)} {q : Π j, α j} :
i.insert_nth x p ≤ q ↔ x ≤ q i ∧ p ≤ (λ j, q (i.succ_above j)) :=
by simp [pi.le_def, forall_iff_succ_above i]
lemma le_insert_nth_iff {i : fin (n + 1)} {x : α i} {p : Π j, α (i.succ_above j)} {q : Π j, α j} :
q ≤ i.insert_nth x p ↔ q i ≤ x ∧ (λ j, q (i.succ_above j)) ≤ p :=
by simp [pi.le_def, forall_iff_succ_above i]
open set
lemma insert_nth_mem_Icc {i : fin (n + 1)} {x : α i} {p : Π j, α (i.succ_above j)}
{q₁ q₂ : Π j, α j} :
i.insert_nth x p ∈ Icc q₁ q₂ ↔
x ∈ Icc (q₁ i) (q₂ i) ∧ p ∈ Icc (λ j, q₁ (i.succ_above j)) (λ j, q₂ (i.succ_above j)) :=
by simp only [mem_Icc, insert_nth_le_iff, le_insert_nth_iff, and.assoc, and.left_comm]
lemma preimage_insert_nth_Icc_of_mem {i : fin (n + 1)} {x : α i} {q₁ q₂ : Π j, α j}
(hx : x ∈ Icc (q₁ i) (q₂ i)) :
i.insert_nth x ⁻¹' (Icc q₁ q₂) = Icc (λ j, q₁ (i.succ_above j)) (λ j, q₂ (i.succ_above j)) :=
set.ext $ λ p, by simp only [mem_preimage, insert_nth_mem_Icc, hx, true_and]
lemma preimage_insert_nth_Icc_of_not_mem {i : fin (n + 1)} {x : α i} {q₁ q₂ : Π j, α j}
(hx : x ∉ Icc (q₁ i) (q₂ i)) :
i.insert_nth x ⁻¹' (Icc q₁ q₂) = ∅ :=
set.ext $ λ p, by simp only [mem_preimage, insert_nth_mem_Icc, hx, false_and, mem_empty_iff_false]
end insert_nth
section find
/-- `find p` returns the first index `n` where `p n` is satisfied, and `none` if it is never
satisfied. -/
def find : Π {n : ℕ} (p : fin n → Prop) [decidable_pred p], option (fin n)
| 0 p _ := none
| (n+1) p _ := by resetI; exact option.cases_on
(@find n (λ i, p (i.cast_lt (nat.lt_succ_of_lt i.2))) _)
(if h : p (fin.last n) then some (fin.last n) else none)
(λ i, some (i.cast_lt (nat.lt_succ_of_lt i.2)))
/-- If `find p = some i`, then `p i` holds -/
lemma find_spec : Π {n : ℕ} (p : fin n → Prop) [decidable_pred p] {i : fin n}
(hi : i ∈ by exactI fin.find p), p i
| 0 p I i hi := option.no_confusion hi
| (n+1) p I i hi := begin
dsimp [find] at hi,
resetI,
cases h : find (λ i : fin n, (p (i.cast_lt (nat.lt_succ_of_lt i.2)))) with j,
{ rw h at hi,
dsimp at hi,
split_ifs at hi with hl hl,
{ exact hi ▸ hl },
{ exact hi.elim } },
{ rw h at hi,
rw [← option.some_inj.1 hi],
exact find_spec _ h }
end
/-- `find p` does not return `none` if and only if `p i` holds at some index `i`. -/
lemma is_some_find_iff : Π {n : ℕ} {p : fin n → Prop} [decidable_pred p],
by exactI (find p).is_some ↔ ∃ i, p i
| 0 p _ := iff_of_false (λ h, bool.no_confusion h) (λ ⟨i, _⟩, fin_zero_elim i)
| (n+1) p _ := ⟨λ h, begin
rw [option.is_some_iff_exists] at h,
cases h with i hi,
exactI ⟨i, find_spec _ hi⟩
end, λ ⟨⟨i, hin⟩, hi⟩,
begin
resetI,
dsimp [find],
cases h : find (λ i : fin n, (p (i.cast_lt (nat.lt_succ_of_lt i.2)))) with j,
{ split_ifs with hl hl,
{ exact option.is_some_some },
{ have := (@is_some_find_iff n (λ x, p (x.cast_lt (nat.lt_succ_of_lt x.2))) _).2
⟨⟨i, lt_of_le_of_ne (nat.le_of_lt_succ hin)
(λ h, by clear_aux_decl; cases h; exact hl hi)⟩, hi⟩,
rw h at this,
exact this } },
{ simp }
end⟩
/-- `find p` returns `none` if and only if `p i` never holds. -/
lemma find_eq_none_iff {n : ℕ} {p : fin n → Prop} [decidable_pred p] :
find p = none ↔ ∀ i, ¬ p i :=
by rw [← not_exists, ← is_some_find_iff]; cases (find p); simp
/-- If `find p` returns `some i`, then `p j` does not hold for `j < i`, i.e., `i` is minimal among
the indices where `p` holds. -/
lemma find_min : Π {n : ℕ} {p : fin n → Prop} [decidable_pred p] {i : fin n}
(hi : i ∈ by exactI fin.find p) {j : fin n} (hj : j < i), ¬ p j
| 0 p _ i hi j hj hpj := option.no_confusion hi
| (n+1) p _ i hi ⟨j, hjn⟩ hj hpj := begin
resetI,
dsimp [find] at hi,
cases h : find (λ i : fin n, (p (i.cast_lt (nat.lt_succ_of_lt i.2)))) with k,
{ rw [h] at hi,
split_ifs at hi with hl hl,
{ subst hi,
rw [find_eq_none_iff] at h,
exact h ⟨j, hj⟩ hpj },
{ exact hi.elim } },
{ rw h at hi,
dsimp at hi,
obtain rfl := option.some_inj.1 hi,
exact find_min h (show (⟨j, lt_trans hj k.2⟩ : fin n) < k, from hj) hpj }
end
lemma find_min' {p : fin n → Prop} [decidable_pred p] {i : fin n}
(h : i ∈ fin.find p) {j : fin n} (hj : p j) : i ≤ j :=
le_of_not_gt (λ hij, find_min h hij hj)
lemma nat_find_mem_find {p : fin n → Prop} [decidable_pred p]
(h : ∃ i, ∃ hin : i < n, p ⟨i, hin⟩) :
(⟨nat.find h, (nat.find_spec h).fst⟩ : fin n) ∈ find p :=
let ⟨i, hin, hi⟩ := h in
begin
cases hf : find p with f,
{ rw [find_eq_none_iff] at hf,
exact (hf ⟨i, hin⟩ hi).elim },
{ refine option.some_inj.2 (le_antisymm _ _),
{ exact find_min' hf (nat.find_spec h).snd },
{ exact nat.find_min' _ ⟨f.2, by convert find_spec p hf;
exact fin.eta _ _⟩ } }
end
lemma mem_find_iff {p : fin n → Prop} [decidable_pred p] {i : fin n} :
i ∈ fin.find p ↔ p i ∧ ∀ j, p j → i ≤ j :=
⟨λ hi, ⟨find_spec _ hi, λ _, find_min' hi⟩,
begin
rintros ⟨hpi, hj⟩,
cases hfp : fin.find p,
{ rw [find_eq_none_iff] at hfp,
exact (hfp _ hpi).elim },
{ exact option.some_inj.2 (le_antisymm (find_min' hfp hpi) (hj _ (find_spec _ hfp))) }
end⟩
lemma find_eq_some_iff {p : fin n → Prop} [decidable_pred p] {i : fin n} :
fin.find p = some i ↔ p i ∧ ∀ j, p j → i ≤ j :=
mem_find_iff
lemma mem_find_of_unique {p : fin n → Prop} [decidable_pred p]
(h : ∀ i j, p i → p j → i = j) {i : fin n} (hi : p i) : i ∈ fin.find p :=
mem_find_iff.2 ⟨hi, λ j hj, le_of_eq $ h i j hi hj⟩
end find
/-- To show two sigma pairs of tuples agree, it to show the second elements are related via
`fin.cast`. -/
lemma sigma_eq_of_eq_comp_cast {α : Type*} :
∀ {a b : Σ ii, fin ii → α} (h : a.fst = b.fst), a.snd = b.snd ∘ fin.cast h → a = b
| ⟨ai, a⟩ ⟨bi, b⟩ hi h :=
begin
dsimp only at hi,
subst hi,
simpa using h,
end
/-- `fin.sigma_eq_of_eq_comp_cast` as an `iff`. -/
lemma sigma_eq_iff_eq_comp_cast {α : Type*} {a b : Σ ii, fin ii → α} :
a = b ↔ ∃ (h : a.fst = b.fst), a.snd = b.snd ∘ fin.cast h :=
⟨λ h, h ▸ ⟨rfl, funext $ fin.rec $ by exact λ i hi, rfl⟩,
λ ⟨h, h'⟩, sigma_eq_of_eq_comp_cast _ h'⟩
end fin
|
a36e74755c2f84c9246f7a42e925f3a13ecf1b07 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/group_theory/submonoid/default_auto.lean | 07492864a93ccd4665cbdfd0eb64a04315afd47c | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 164 | lean | import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.group_theory.submonoid.membership
import Mathlib.PostPort
namespace Mathlib
end Mathlib |
0b044d32a4ba3dc3de9d73454bb637b6a2730cd6 | 649957717d58c43b5d8d200da34bf374293fe739 | /src/topology/algebra/group.lean | a4d0d7b00037d3ab0f4d2fdf3f1038f18cce9ba7 | [
"Apache-2.0"
] | permissive | Vtec234/mathlib | b50c7b21edea438df7497e5ed6a45f61527f0370 | fb1848bbbfce46152f58e219dc0712f3289d2b20 | refs/heads/master | 1,592,463,095,113 | 1,562,737,749,000 | 1,562,737,749,000 | 196,202,858 | 0 | 0 | Apache-2.0 | 1,562,762,338,000 | 1,562,762,337,000 | null | UTF-8 | Lean | false | false | 14,131 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot
Theory of topological groups.
-/
import data.equiv.algebra
import group_theory.quotient_group
import topology.algebra.monoid topology.order
open classical set lattice filter topological_space
local attribute [instance] classical.prop_decidable
universes u v w
variables {α : Type u} {β : Type v} {γ : Type w}
section topological_group
/-- A topological group is a group in which the multiplication and inversion operations are
continuous. -/
class topological_group (α : Type*) [topological_space α] [group α]
extends topological_monoid α : Prop :=
(continuous_inv : continuous (λa:α, a⁻¹))
/-- A topological (additive) group is a group in which the addition and negation operations are
continuous. -/
class topological_add_group (α : Type u) [topological_space α] [add_group α]
extends topological_add_monoid α : Prop :=
(continuous_neg : continuous (λa:α, -a))
attribute [to_additive topological_add_group] topological_group
attribute [to_additive topological_add_group.mk] topological_group.mk
attribute [to_additive topological_add_group.continuous_neg] topological_group.continuous_inv
attribute [to_additive topological_add_group.to_topological_add_monoid] topological_group.to_topological_monoid
variables [topological_space α] [group α]
@[to_additive continuous_neg']
lemma continuous_inv' [topological_group α] : continuous (λx:α, x⁻¹) :=
topological_group.continuous_inv α
@[to_additive continuous_neg]
lemma continuous_inv [topological_group α] [topological_space β] {f : β → α}
(hf : continuous f) : continuous (λx, (f x)⁻¹) :=
continuous_inv'.comp hf
@[to_additive continuous_on.neg]
lemma continuous_on.inv [topological_group α] [topological_space β] {f : β → α} {s : set β}
(hf : continuous_on f s) : continuous_on (λx, (f x)⁻¹) s :=
continuous_inv'.comp_continuous_on hf
@[to_additive tendsto_neg]
lemma tendsto_inv [topological_group α] {f : β → α} {x : filter β} {a : α}
(hf : tendsto f x (nhds a)) : tendsto (λx, (f x)⁻¹) x (nhds a⁻¹) :=
tendsto.comp (continuous_iff_continuous_at.mp (topological_group.continuous_inv α) a) hf
@[to_additive prod.topological_add_group]
instance [topological_group α] [topological_space β] [group β] [topological_group β] :
topological_group (α × β) :=
{ continuous_inv := continuous.prod_mk (continuous_inv continuous_fst) (continuous_inv continuous_snd) }
attribute [instance] prod.topological_add_group
protected def homeomorph.mul_left [topological_group α] (a : α) : α ≃ₜ α :=
{ continuous_to_fun := continuous_mul continuous_const continuous_id,
continuous_inv_fun := continuous_mul continuous_const continuous_id,
.. equiv.mul_left a }
attribute [to_additive homeomorph.add_left._proof_1] homeomorph.mul_left._proof_1
attribute [to_additive homeomorph.add_left._proof_2] homeomorph.mul_left._proof_2
attribute [to_additive homeomorph.add_left._proof_3] homeomorph.mul_left._proof_3
attribute [to_additive homeomorph.add_left._proof_4] homeomorph.mul_left._proof_4
attribute [to_additive homeomorph.add_left] homeomorph.mul_left
@[to_additive is_open_map_add_left]
lemma is_open_map_mul_left [topological_group α] (a : α) : is_open_map (λ x, a * x) :=
(homeomorph.mul_left a).is_open_map
protected def homeomorph.mul_right
{α : Type*} [topological_space α] [group α] [topological_group α] (a : α) :
α ≃ₜ α :=
{ continuous_to_fun := continuous_mul continuous_id continuous_const,
continuous_inv_fun := continuous_mul continuous_id continuous_const,
.. equiv.mul_right a }
attribute [to_additive homeomorph.add_right._proof_1] homeomorph.mul_right._proof_1
attribute [to_additive homeomorph.add_right._proof_2] homeomorph.mul_right._proof_2
attribute [to_additive homeomorph.add_right._proof_3] homeomorph.mul_right._proof_3
attribute [to_additive homeomorph.add_right._proof_4] homeomorph.mul_right._proof_4
attribute [to_additive homeomorph.add_right] homeomorph.mul_right
@[to_additive is_open_map_add_right]
lemma is_open_map_mul_right [topological_group α] (a : α) : is_open_map (λ x, x * a) :=
(homeomorph.mul_right a).is_open_map
protected def homeomorph.inv (α : Type*) [topological_space α] [group α] [topological_group α] :
α ≃ₜ α :=
{ continuous_to_fun := continuous_inv',
continuous_inv_fun := continuous_inv',
.. equiv.inv α }
attribute [to_additive homeomorph.neg._proof_1] homeomorph.inv._proof_1
attribute [to_additive homeomorph.neg._proof_2] homeomorph.inv._proof_2
attribute [to_additive homeomorph.neg] homeomorph.inv
@[to_additive exists_nhds_half]
lemma exists_nhds_split [topological_group α] {s : set α} (hs : s ∈ nhds (1 : α)) :
∃ V ∈ nhds (1 : α), ∀ v w ∈ V, v * w ∈ s :=
begin
have : ((λa:α×α, a.1 * a.2) ⁻¹' s) ∈ nhds ((1, 1) : α × α) :=
tendsto_mul' (by simpa using hs),
rw nhds_prod_eq at this,
rcases mem_prod_iff.1 this with ⟨V₁, H₁, V₂, H₂, H⟩,
exact ⟨V₁ ∩ V₂, inter_mem_sets H₁ H₂, assume v w ⟨hv, _⟩ ⟨_, hw⟩, @H (v, w) ⟨hv, hw⟩⟩
end
@[to_additive exists_nhds_half_neg]
lemma exists_nhds_split_inv [topological_group α] {s : set α} (hs : s ∈ nhds (1 : α)) :
∃ V ∈ nhds (1 : α), ∀ v w ∈ V, v * w⁻¹ ∈ s :=
begin
have : tendsto (λa:α×α, a.1 * (a.2)⁻¹) ((nhds (1:α)).prod (nhds (1:α))) (nhds 1),
{ simpa using tendsto_mul (@tendsto_fst α α (nhds 1) (nhds 1)) (tendsto_inv tendsto_snd) },
have : ((λa:α×α, a.1 * (a.2)⁻¹) ⁻¹' s) ∈ (nhds (1:α)).prod (nhds (1:α)) :=
this (by simpa using hs),
rcases mem_prod_iff.1 this with ⟨V₁, H₁, V₂, H₂, H⟩,
exact ⟨V₁ ∩ V₂, inter_mem_sets H₁ H₂, assume v w ⟨hv, _⟩ ⟨_, hw⟩, @H (v, w) ⟨hv, hw⟩⟩
end
@[to_additive exists_nhds_quarter]
lemma exists_nhds_split4 [topological_group α] {u : set α} (hu : u ∈ nhds (1 : α)) :
∃ V ∈ nhds (1 : α), ∀ {v w s t}, v ∈ V → w ∈ V → s ∈ V → t ∈ V → v * w * s * t ∈ u :=
begin
rcases exists_nhds_split hu with ⟨W, W_nhd, h⟩,
rcases exists_nhds_split W_nhd with ⟨V, V_nhd, h'⟩,
existsi [V, V_nhd],
intros v w s t v_in w_in s_in t_in,
simpa [mul_assoc] using h _ _ (h' v w v_in w_in) (h' s t s_in t_in)
end
section
variable (α)
@[to_additive nhds_zero_symm]
lemma nhds_one_symm [topological_group α] : comap (λr:α, r⁻¹) (nhds (1 : α)) = nhds (1 : α) :=
begin
have lim : tendsto (λr:α, r⁻¹) (nhds 1) (nhds 1),
{ simpa using tendsto_inv (@tendsto_id α (nhds 1)) },
refine comap_eq_of_inverse _ _ lim lim,
{ funext x, simp },
end
end
@[to_additive nhds_translation_add_neg]
lemma nhds_translation_mul_inv [topological_group α] (x : α) :
comap (λy:α, y * x⁻¹) (nhds 1) = nhds x :=
begin
refine comap_eq_of_inverse (λy:α, y * x) _ _ _,
{ funext x; simp },
{ suffices : tendsto (λy:α, y * x⁻¹) (nhds x) (nhds (x * x⁻¹)), { simpa },
exact tendsto_mul tendsto_id tendsto_const_nhds },
{ suffices : tendsto (λy:α, y * x) (nhds 1) (nhds (1 * x)), { simpa },
exact tendsto_mul tendsto_id tendsto_const_nhds }
end
@[to_additive topological_add_group.ext]
lemma topological_group.ext {G : Type*} [group G] {t t' : topological_space G}
(tg : @topological_group G t _) (tg' : @topological_group G t' _)
(h : @nhds G t 1 = @nhds G t' 1) : t = t' :=
eq_of_nhds_eq_nhds $ λ x, by
rw [← @nhds_translation_mul_inv G t _ _ x , ← @nhds_translation_mul_inv G t' _ _ x , ← h]
end topological_group
section quotient_topological_group
variables [topological_space α] [group α] [topological_group α] (N : set α) [normal_subgroup N]
@[to_additive quotient_add_group.quotient.topological_space]
instance : topological_space (quotient_group.quotient N) :=
by dunfold quotient_group.quotient; apply_instance
attribute [instance] quotient_add_group.quotient.topological_space
open quotient_group
@[to_additive quotient_add_group_saturate]
lemma quotient_group_saturate (s : set α) :
(coe : α → quotient N) ⁻¹' ((coe : α → quotient N) '' s) = (⋃ x : N, (λ y, y*x.1) '' s) :=
begin
ext x,
simp only [mem_preimage, mem_image, mem_Union, quotient_group.eq],
split,
{ exact assume ⟨a, a_in, h⟩, ⟨⟨_, h⟩, a, a_in, mul_inv_cancel_left _ _⟩ },
{ exact assume ⟨⟨i, hi⟩, a, ha, eq⟩,
⟨a, ha, by simp only [eq.symm, (mul_assoc _ _ _).symm, inv_mul_cancel_left, hi]⟩ }
end
@[to_additive quotient_add_group.open_coe]
lemma quotient_group.open_coe : is_open_map (coe : α → quotient N) :=
begin
intros s s_op,
change is_open ((coe : α → quotient N) ⁻¹' (coe '' s)),
rw quotient_group_saturate N s,
apply is_open_Union,
rintro ⟨n, _⟩,
exact is_open_map_mul_right n s s_op
end
@[to_additive topological_add_group_quotient]
instance topological_group_quotient : topological_group (quotient N) :=
{ continuous_mul := begin
have cont : continuous ((coe : α → quotient N) ∘ (λ (p : α × α), p.fst * p.snd)) :=
continuous_quot_mk.comp continuous_mul',
have quot : quotient_map (λ p : α × α, ((p.1:quotient N), (p.2:quotient N))),
{ apply is_open_map.to_quotient_map,
{ exact is_open_map.prod (quotient_group.open_coe N) (quotient_group.open_coe N) },
{ apply continuous.prod_mk,
{ exact continuous_quot_mk.comp continuous_fst },
{ exact continuous_quot_mk.comp continuous_snd } },
{ rintro ⟨⟨x⟩, ⟨y⟩⟩,
exact ⟨(x, y), rfl⟩ } },
exact (quotient_map.continuous_iff quot).2 cont,
end,
continuous_inv := begin
apply continuous_quotient_lift,
change continuous ((coe : α → quotient N) ∘ (λ (a : α), a⁻¹)),
exact continuous_quot_mk.comp continuous_inv'
end }
attribute [instance] topological_add_group_quotient
end quotient_topological_group
section topological_add_group
variables [topological_space α] [add_group α]
lemma continuous_sub [topological_add_group α] [topological_space β] {f : β → α} {g : β → α}
(hf : continuous f) (hg : continuous g) : continuous (λx, f x - g x) :=
by simp; exact continuous_add hf (continuous_neg hg)
lemma continuous_sub' [topological_add_group α] : continuous (λp:α×α, p.1 - p.2) :=
continuous_sub continuous_fst continuous_snd
lemma continuous_on.sub [topological_add_group α] [topological_space β] {f : β → α} {g : β → α} {s : set β}
(hf : continuous_on f s) (hg : continuous_on g s) : continuous_on (λx, f x - g x) s :=
continuous_sub'.comp_continuous_on (hf.prod hg)
lemma tendsto_sub [topological_add_group α] {f : β → α} {g : β → α} {x : filter β} {a b : α}
(hf : tendsto f x (nhds a)) (hg : tendsto g x (nhds b)) : tendsto (λx, f x - g x) x (nhds (a - b)) :=
by simp; exact tendsto_add hf (tendsto_neg hg)
lemma nhds_translation [topological_add_group α] (x : α) : comap (λy:α, y - x) (nhds 0) = nhds x :=
nhds_translation_add_neg x
end topological_add_group
/-- additive group with a neighbourhood around 0.
Only used to construct a topology and uniform space.
This is currently only available for commutative groups, but it can be extended to
non-commutative groups too.
-/
class add_group_with_zero_nhd (α : Type u) extends add_comm_group α :=
(Z : filter α)
(zero_Z {} : pure 0 ≤ Z)
(sub_Z {} : tendsto (λp:α×α, p.1 - p.2) (Z.prod Z) Z)
namespace add_group_with_zero_nhd
variables (α) [add_group_with_zero_nhd α]
local notation `Z` := add_group_with_zero_nhd.Z
instance : topological_space α :=
topological_space.mk_of_nhds $ λa, map (λx, x + a) (Z α)
variables {α}
lemma neg_Z : tendsto (λa:α, - a) (Z α) (Z α) :=
have tendsto (λa, (0:α)) (Z α) (Z α),
by refine le_trans (assume h, _) zero_Z; simp [univ_mem_sets'] {contextual := tt},
have tendsto (λa:α, 0 - a) (Z α) (Z α), from
sub_Z.comp (tendsto.prod_mk this tendsto_id),
by simpa
lemma add_Z : tendsto (λp:α×α, p.1 + p.2) ((Z α).prod (Z α)) (Z α) :=
suffices tendsto (λp:α×α, p.1 - -p.2) ((Z α).prod (Z α)) (Z α),
by simpa,
sub_Z.comp (tendsto.prod_mk tendsto_fst (neg_Z.comp tendsto_snd))
lemma exists_Z_half {s : set α} (hs : s ∈ Z α) : ∃ V ∈ Z α, ∀ v w ∈ V, v + w ∈ s :=
begin
have : ((λa:α×α, a.1 + a.2) ⁻¹' s) ∈ (Z α).prod (Z α) := add_Z (by simpa using hs),
rcases mem_prod_iff.1 this with ⟨V₁, H₁, V₂, H₂, H⟩,
exact ⟨V₁ ∩ V₂, inter_mem_sets H₁ H₂, assume v w ⟨hv, _⟩ ⟨_, hw⟩, @H (v, w) ⟨hv, hw⟩⟩
end
lemma nhds_eq (a : α) : nhds a = map (λx, x + a) (Z α) :=
topological_space.nhds_mk_of_nhds _ _
(assume a, calc pure a = map (λx, x + a) (pure 0) : by simp
... ≤ _ : map_mono zero_Z)
(assume b s hs,
let ⟨t, ht, eqt⟩ := exists_Z_half hs in
have t0 : (0:α) ∈ t, by simpa using zero_Z ht,
begin
refine ⟨(λx:α, x + b) '' t, image_mem_map ht, _, _⟩,
{ refine set.image_subset_iff.2 (assume b hbt, _),
simpa using eqt 0 b t0 hbt },
{ rintros _ ⟨c, hb, rfl⟩,
refine (Z α).sets_of_superset ht (assume x hxt, _),
simpa using eqt _ _ hxt hb }
end)
lemma nhds_zero_eq_Z : nhds 0 = Z α := by simp [nhds_eq]; exact filter.map_id
instance : topological_add_monoid α :=
⟨ continuous_iff_continuous_at.2 $ assume ⟨a, b⟩,
begin
rw [continuous_at, nhds_prod_eq, nhds_eq, nhds_eq, nhds_eq, filter.prod_map_map_eq,
tendsto_map'_iff],
suffices : tendsto ((λx:α, (a + b) + x) ∘ (λp:α×α,p.1 + p.2)) (filter.prod (Z α) (Z α))
(map (λx:α, (a + b) + x) (Z α)),
{ simpa [(∘)] },
exact tendsto_map.comp add_Z
end⟩
instance : topological_add_group α :=
⟨continuous_iff_continuous_at.2 $ assume a,
begin
rw [continuous_at, nhds_eq, nhds_eq, tendsto_map'_iff],
suffices : tendsto ((λx:α, x - a) ∘ (λx:α, -x)) (Z α) (map (λx:α, x - a) (Z α)),
{ simpa [(∘)] },
exact tendsto_map.comp neg_Z
end⟩
end add_group_with_zero_nhd
|
7e87aef800fc3fc30f3052ac2256cec6893cdde4 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/data/pequiv.lean | ea1cf4cd9b40dc8183b1f05ac133a37c3753d311 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 14,090 | lean | /-
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import data.set.basic
/-!
# Partial Equivalences
In this file, we define partial equivalences `pequiv`, which are a bijection between a subset of `α`
and a subset of `β`. Notationally, a `pequiv` is denoted by "`≃.`" (note that the full stop is part
of the notation). The way we store these internally is with two functions `f : α → option β` and
the reverse function `g : β → option α`, with the condition that if `f a` is `option.some b`,
then `g b` is `option.some a`.
## Main results
- `pequiv.of_set`: creates a `pequiv` from a set `s`,
which sends an element to itself if it is in `s`.
- `pequiv.single`: given two elements `a : α` and `b : β`, create a `pequiv` that sends them to
each other, and ignores all other elements.
- `pequiv.injective_of_forall_ne_is_some`/`injective_of_forall_is_some`: If the domain of a `pequiv`
is all of `α` (except possibly one point), its `to_fun` is injective.
## Canonical order
`pequiv` is canonically ordered by inclusion; that is, if a function `f` defined on a subset `s`
is equal to `g` on that subset, but `g` is also defined on a larger set, then `f ≤ g`. We also have
a definition of `⊥`, which is the empty `pequiv` (sends all to `none`), which in the end gives us a
`semilattice_inf` with an `order_bot` instance.
## Tags
pequiv, partial equivalence
-/
universes u v w x
/-- A `pequiv` is a partial equivalence, a representation of a bijection between a subset
of `α` and a subset of `β`. See also `local_equiv` for a version that requires `to_fun` and
`inv_fun` to be globally defined functions and has `source` and `target` sets as extra fields. -/
structure pequiv (α : Type u) (β : Type v) :=
(to_fun : α → option β)
(inv_fun : β → option α)
(inv : ∀ (a : α) (b : β), a ∈ inv_fun b ↔ b ∈ to_fun a)
infixr ` ≃. `:25 := pequiv
namespace pequiv
variables {α : Type u} {β : Type v} {γ : Type w} {δ : Type x}
open function option
instance : has_coe_to_fun (α ≃. β) (λ _, α → option β) := ⟨to_fun⟩
@[simp] lemma coe_mk_apply (f₁ : α → option β) (f₂ : β → option α) (h) (x : α) :
(pequiv.mk f₁ f₂ h : α → option β) x = f₁ x := rfl
@[ext] lemma ext : ∀ {f g : α ≃. β} (h : ∀ x, f x = g x), f = g
| ⟨f₁, f₂, hf⟩ ⟨g₁, g₂, hg⟩ h :=
have h : f₁ = g₁, from funext h,
have ∀ b, f₂ b = g₂ b,
begin
subst h,
assume b,
have hf := λ a, hf a b,
have hg := λ a, hg a b,
cases h : g₂ b with a,
{ simp only [h, option.not_mem_none, false_iff] at hg,
simp only [hg, iff_false] at hf,
rwa [option.eq_none_iff_forall_not_mem] },
{ rw [← option.mem_def, hf, ← hg, h, option.mem_def] }
end,
by simp [*, funext_iff]
lemma ext_iff {f g : α ≃. β} : f = g ↔ ∀ x, f x = g x :=
⟨congr_fun ∘ congr_arg _, ext⟩
/-- The identity map as a partial equivalence. -/
@[refl] protected def refl (α : Type*) : α ≃. α :=
{ to_fun := some,
inv_fun := some,
inv := λ _ _, eq_comm }
/-- The inverse partial equivalence. -/
@[symm] protected def symm (f : α ≃. β) : β ≃. α :=
{ to_fun := f.2,
inv_fun := f.1,
inv := λ _ _, (f.inv _ _).symm }
lemma mem_iff_mem (f : α ≃. β) : ∀ {a : α} {b : β}, a ∈ f.symm b ↔ b ∈ f a := f.3
lemma eq_some_iff (f : α ≃. β) : ∀ {a : α} {b : β}, f.symm b = some a ↔ f a = some b := f.3
/-- Composition of partial equivalences `f : α ≃. β` and `g : β ≃. γ`. -/
@[trans] protected def trans (f : α ≃. β) (g : β ≃. γ) : α ≃. γ :=
{ to_fun := λ a, (f a).bind g,
inv_fun := λ a, (g.symm a).bind f.symm,
inv := λ a b, by simp [*, and.comm, eq_some_iff f, eq_some_iff g] at * }
@[simp] lemma refl_apply (a : α) : pequiv.refl α a = some a := rfl
@[simp] lemma symm_refl : (pequiv.refl α).symm = pequiv.refl α := rfl
@[simp] lemma symm_symm (f : α ≃. β) : f.symm.symm = f := by cases f; refl
lemma symm_injective : function.injective (@pequiv.symm α β) :=
left_inverse.injective symm_symm
lemma trans_assoc (f : α ≃. β) (g : β ≃. γ) (h : γ ≃. δ) :
(f.trans g).trans h = f.trans (g.trans h) :=
ext (λ _, option.bind_assoc _ _ _)
lemma mem_trans (f : α ≃. β) (g : β ≃. γ) (a : α) (c : γ) :
c ∈ f.trans g a ↔ ∃ b, b ∈ f a ∧ c ∈ g b := option.bind_eq_some'
lemma trans_eq_some (f : α ≃. β) (g : β ≃. γ) (a : α) (c : γ) :
f.trans g a = some c ↔ ∃ b, f a = some b ∧ g b = some c := option.bind_eq_some'
lemma trans_eq_none (f : α ≃. β) (g : β ≃. γ) (a : α) :
f.trans g a = none ↔ (∀ b c, b ∉ f a ∨ c ∉ g b) :=
begin
simp only [eq_none_iff_forall_not_mem, mem_trans, imp_iff_not_or.symm],
push_neg, tauto
end
@[simp] lemma refl_trans (f : α ≃. β) : (pequiv.refl α).trans f = f :=
by ext; dsimp [pequiv.trans]; refl
@[simp] lemma trans_refl (f : α ≃. β) : f.trans (pequiv.refl β) = f :=
by ext; dsimp [pequiv.trans]; simp
protected lemma inj (f : α ≃. β) {a₁ a₂ : α} {b : β} (h₁ : b ∈ f a₁) (h₂ : b ∈ f a₂) : a₁ = a₂ :=
by rw ← mem_iff_mem at *; cases h : f.symm b; simp * at *
/-- If the domain of a `pequiv` is `α` except a point, its forward direction is injective. -/
lemma injective_of_forall_ne_is_some (f : α ≃. β) (a₂ : α)
(h : ∀ (a₁ : α), a₁ ≠ a₂ → is_some (f a₁)) : injective f :=
has_left_inverse.injective
⟨λ b, option.rec_on b a₂ (λ b', option.rec_on (f.symm b') a₂ id),
λ x, begin
classical,
cases hfx : f x,
{ have : x = a₂, from not_imp_comm.1 (h x) (hfx.symm ▸ by simp), simp [this] },
{ dsimp only, rw [(eq_some_iff f).2 hfx], refl }
end⟩
/-- If the domain of a `pequiv` is all of `α`, its forward direction is injective. -/
lemma injective_of_forall_is_some {f : α ≃. β}
(h : ∀ (a : α), is_some (f a)) : injective f :=
(classical.em (nonempty α)).elim
(λ hn, injective_of_forall_ne_is_some f (classical.choice hn)
(λ a _, h a))
(λ hn x, (hn ⟨x⟩).elim)
section of_set
variables (s : set α) [decidable_pred (∈ s)]
/-- Creates a `pequiv` that is the identity on `s`, and `none` outside of it. -/
def of_set (s : set α) [decidable_pred (∈ s)] : α ≃. α :=
{ to_fun := λ a, if a ∈ s then some a else none,
inv_fun := λ a, if a ∈ s then some a else none,
inv := λ a b, by
{ split_ifs with hb ha ha,
{ simp [eq_comm] },
{ simp [ne_of_mem_of_not_mem hb ha] },
{ simp [ne_of_mem_of_not_mem ha hb] },
{ simp } } }
lemma mem_of_set_self_iff {s : set α} [decidable_pred (∈ s)] {a : α} : a ∈ of_set s a ↔ a ∈ s :=
by dsimp [of_set]; split_ifs; simp *
lemma mem_of_set_iff {s : set α} [decidable_pred (∈ s)] {a b : α} :
a ∈ of_set s b ↔ a = b ∧ a ∈ s :=
begin
dsimp [of_set],
split_ifs,
{ simp only [iff_self_and, eq_comm],
rintro rfl,
exact h, },
{ simp only [false_iff, not_and],
rintro rfl,
exact h, }
end
@[simp] lemma of_set_eq_some_iff {s : set α} {h : decidable_pred (∈ s)} {a b : α} :
of_set s b = some a ↔ a = b ∧ a ∈ s := mem_of_set_iff
@[simp] lemma of_set_eq_some_self_iff {s : set α} {h : decidable_pred (∈ s)} {a : α} :
of_set s a = some a ↔ a ∈ s := mem_of_set_self_iff
@[simp] lemma of_set_symm : (of_set s).symm = of_set s := rfl
@[simp] lemma of_set_univ : of_set set.univ = pequiv.refl α := rfl
@[simp] lemma of_set_eq_refl {s : set α} [decidable_pred (∈ s)] :
of_set s = pequiv.refl α ↔ s = set.univ :=
⟨λ h, begin
rw [set.eq_univ_iff_forall],
intro,
rw [← mem_of_set_self_iff, h],
exact rfl
end, λ h, by simp only [← of_set_univ, h]⟩
end of_set
lemma symm_trans_rev (f : α ≃. β) (g : β ≃. γ) : (f.trans g).symm = g.symm.trans f.symm := rfl
lemma self_trans_symm (f : α ≃. β) : f.trans f.symm = of_set {a | (f a).is_some} :=
begin
ext,
dsimp [pequiv.trans],
simp only [eq_some_iff f, option.is_some_iff_exists, option.mem_def, bind_eq_some',
of_set_eq_some_iff],
split,
{ rintros ⟨b, hb₁, hb₂⟩,
exact ⟨pequiv.inj _ hb₂ hb₁, b, hb₂⟩ },
{ simp {contextual := tt} }
end
lemma symm_trans_self (f : α ≃. β) : f.symm.trans f = of_set {b | (f.symm b).is_some} :=
symm_injective $ by simp [symm_trans_rev, self_trans_symm, -symm_symm]
lemma trans_symm_eq_iff_forall_is_some {f : α ≃. β} :
f.trans f.symm = pequiv.refl α ↔ ∀ a, is_some (f a) :=
by rw [self_trans_symm, of_set_eq_refl, set.eq_univ_iff_forall]; refl
instance : has_bot (α ≃. β) :=
⟨{ to_fun := λ _, none,
inv_fun := λ _, none,
inv := by simp }⟩
instance : inhabited (α ≃. β) := ⟨⊥⟩
@[simp] lemma bot_apply (a : α) : (⊥ : α ≃. β) a = none := rfl
@[simp] lemma symm_bot : (⊥ : α ≃. β).symm = ⊥ := rfl
@[simp] lemma trans_bot (f : α ≃. β) : f.trans (⊥ : β ≃. γ) = ⊥ :=
by ext; dsimp [pequiv.trans]; simp
@[simp] lemma bot_trans (f : β ≃. γ) : (⊥ : α ≃. β).trans f = ⊥ :=
by ext; dsimp [pequiv.trans]; simp
lemma is_some_symm_get (f : α ≃. β) {a : α} (h : is_some (f a)) :
is_some (f.symm (option.get h)) :=
is_some_iff_exists.2 ⟨a, by rw [f.eq_some_iff, some_get]⟩
section single
variables [decidable_eq α] [decidable_eq β] [decidable_eq γ]
/-- Create a `pequiv` which sends `a` to `b` and `b` to `a`, but is otherwise `none`. -/
def single (a : α) (b : β) : α ≃. β :=
{ to_fun := λ x, if x = a then some b else none,
inv_fun := λ x, if x = b then some a else none,
inv := λ _ _, by simp; split_ifs; cc }
lemma mem_single (a : α) (b : β) : b ∈ single a b a := if_pos rfl
lemma mem_single_iff (a₁ a₂ : α) (b₁ b₂ : β) : b₁ ∈ single a₂ b₂ a₁ ↔ a₁ = a₂ ∧ b₁ = b₂ :=
by dsimp [single]; split_ifs; simp [*, eq_comm]
@[simp] lemma symm_single (a : α) (b : β) : (single a b).symm = single b a := rfl
@[simp] lemma single_apply (a : α) (b : β) : single a b a = some b := if_pos rfl
lemma single_apply_of_ne {a₁ a₂ : α} (h : a₁ ≠ a₂) (b : β) : single a₁ b a₂ = none := if_neg h.symm
lemma single_trans_of_mem (a : α) {b : β} {c : γ} {f : β ≃. γ} (h : c ∈ f b) :
(single a b).trans f = single a c :=
begin
ext,
dsimp [single, pequiv.trans],
split_ifs; simp * at *
end
lemma trans_single_of_mem {a : α} {b : β} (c : γ) {f : α ≃. β} (h : b ∈ f a) :
f.trans (single b c) = single a c :=
symm_injective $ single_trans_of_mem _ ((mem_iff_mem f).2 h)
@[simp]
lemma single_trans_single (a : α) (b : β) (c : γ) : (single a b).trans (single b c) = single a c :=
single_trans_of_mem _ (mem_single _ _)
@[simp] lemma single_subsingleton_eq_refl [subsingleton α] (a b : α) : single a b = pequiv.refl α :=
begin
ext i j,
dsimp [single],
rw [if_pos (subsingleton.elim i a), subsingleton.elim i j, subsingleton.elim b j]
end
lemma trans_single_of_eq_none {b : β} (c : γ) {f : δ ≃. β} (h : f.symm b = none) :
f.trans (single b c) = ⊥ :=
begin
ext,
simp only [eq_none_iff_forall_not_mem, option.mem_def, f.eq_some_iff] at h,
dsimp [pequiv.trans, single],
simp,
intros,
split_ifs;
simp * at *
end
lemma single_trans_of_eq_none (a : α) {b : β} {f : β ≃. δ} (h : f b = none) :
(single a b).trans f = ⊥ :=
symm_injective $ trans_single_of_eq_none _ h
lemma single_trans_single_of_ne {b₁ b₂ : β} (h : b₁ ≠ b₂) (a : α) (c : γ) :
(single a b₁).trans (single b₂ c) = ⊥ :=
single_trans_of_eq_none _ (single_apply_of_ne h.symm _)
end single
section order
instance : partial_order (α ≃. β) :=
{ le := λ f g, ∀ (a : α) (b : β), b ∈ f a → b ∈ g a,
le_refl := λ _ _ _, id,
le_trans := λ f g h fg gh a b, (gh a b) ∘ (fg a b),
le_antisymm := λ f g fg gf, ext begin
assume a,
cases h : g a with b,
{ exact eq_none_iff_forall_not_mem.2
(λ b hb, option.not_mem_none b $ h ▸ fg a b hb) },
{ exact gf _ _ h }
end }
lemma le_def {f g : α ≃. β} : f ≤ g ↔ (∀ (a : α) (b : β), b ∈ f a → b ∈ g a) := iff.rfl
instance : order_bot (α ≃. β) :=
{ bot_le := λ _ _ _ h, (not_mem_none _ h).elim,
..pequiv.has_bot }
instance [decidable_eq α] [decidable_eq β] : semilattice_inf (α ≃. β) :=
{ inf := λ f g,
{ to_fun := λ a, if f a = g a then f a else none,
inv_fun := λ b, if f.symm b = g.symm b then f.symm b else none,
inv := λ a b, begin
have hf := @mem_iff_mem _ _ f a b,
have hg := @mem_iff_mem _ _ g a b, -- `split_ifs; finish` closes this goal from here
split_ifs with h1 h2 h2; try { simp [hf] },
{ contrapose! h2,
rw h2,
rw [←h1,hf,h2] at hg,
simp only [mem_def, true_iff, eq_self_iff_true] at hg,
rw [hg] },
{ contrapose! h1,
rw h1 at *,
rw ←h2 at hg,
simp only [mem_def, eq_self_iff_true, iff_true] at hf hg,
rw [hf,hg] },
end },
inf_le_left := λ _ _ _ _, by simp; split_ifs; cc,
inf_le_right := λ _ _ _ _, by simp; split_ifs; cc,
le_inf := λ f g h fg gh a b, begin
intro H,
have hf := fg a b H,
have hg := gh a b H,
simp only [option.mem_def, pequiv.coe_mk_apply],
split_ifs with h1, { exact hf }, { exact h1 (hf.trans hg.symm) },
end,
..pequiv.partial_order }
end order
end pequiv
namespace equiv
variables {α : Type*} {β : Type*} {γ : Type*}
/-- Turns an `equiv` into a `pequiv` of the whole type. -/
def to_pequiv (f : α ≃ β) : α ≃. β :=
{ to_fun := some ∘ f,
inv_fun := some ∘ f.symm,
inv := by simp [equiv.eq_symm_apply, eq_comm] }
@[simp] lemma to_pequiv_refl : (equiv.refl α).to_pequiv = pequiv.refl α := rfl
lemma to_pequiv_trans (f : α ≃ β) (g : β ≃ γ) : (f.trans g).to_pequiv =
f.to_pequiv.trans g.to_pequiv := rfl
lemma to_pequiv_symm (f : α ≃ β) : f.symm.to_pequiv = f.to_pequiv.symm := rfl
lemma to_pequiv_apply (f : α ≃ β) (x : α) : f.to_pequiv x = some (f x) := rfl
end equiv
|
70bc511762df2d577ae50f6f21f0d157ae299819 | 947b78d97130d56365ae2ec264df196ce769371a | /stage0/src/Lean/Parser/Syntax.lean | 321968a12053fc9edfe9fb296072ed1be581e6c0 | [
"Apache-2.0"
] | permissive | shyamalschandra/lean4 | 27044812be8698f0c79147615b1d5090b9f4b037 | 6e7a883b21eaf62831e8111b251dc9b18f40e604 | refs/heads/master | 1,671,417,126,371 | 1,601,859,995,000 | 1,601,860,020,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 5,452 | lean | /-
Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Sebastian Ullrich
-/
import Lean.Parser.Command
import Lean.Parser.Tactic
namespace Lean
namespace Parser
@[init] def regBuiltinSyntaxParserAttr : IO Unit :=
let leadingIdentAsSymbol := true;
registerBuiltinParserAttribute `builtinSyntaxParser `stx leadingIdentAsSymbol
@[init] def regSyntaxParserAttribute : IO Unit :=
registerBuiltinDynamicParserAttribute `stxParser `stx
@[inline] def syntaxParser (rbp : Nat := 0) : Parser :=
categoryParser `stx rbp
-- TODO: `max` is a bad precedence name. Find a new one.
def maxSymbol := parser! nonReservedSymbol "max" true
def precedenceLit : Parser := numLit <|> maxSymbol
def «precedence» := parser! ":" >> precedenceLit
def optPrecedence := optional (try «precedence»)
namespace Syntax
@[builtinSyntaxParser] def paren := parser! "(" >> many1 syntaxParser >> ")"
@[builtinSyntaxParser] def cat := parser! ident >> optPrecedence
@[builtinSyntaxParser] def atom := parser! strLit
@[builtinSyntaxParser] def num := parser! nonReservedSymbol "num"
@[builtinSyntaxParser] def str := parser! nonReservedSymbol "str"
@[builtinSyntaxParser] def char := parser! nonReservedSymbol "char"
@[builtinSyntaxParser] def ident := parser! nonReservedSymbol "ident"
@[builtinSyntaxParser] def try := parser! nonReservedSymbol "try " >> syntaxParser maxPrec
@[builtinSyntaxParser] def lookahead := parser! nonReservedSymbol "lookahead " >> syntaxParser maxPrec
@[builtinSyntaxParser] def sepBy := parser! nonReservedSymbol "sepBy " >> syntaxParser maxPrec >> syntaxParser maxPrec
@[builtinSyntaxParser] def sepBy1 := parser! nonReservedSymbol "sepBy1 " >> syntaxParser maxPrec >> syntaxParser maxPrec
@[builtinSyntaxParser] def notFollowedBy := parser! nonReservedSymbol "notFollowedBy " >> syntaxParser maxPrec
@[builtinSyntaxParser] def optional := tparser! "?"
@[builtinSyntaxParser] def many := tparser! "*"
@[builtinSyntaxParser] def many1 := tparser! "+"
@[builtinSyntaxParser] def orelse := tparser!:2 " <|> " >> syntaxParser 1
end Syntax
namespace Term
@[builtinTermParser] def stx.quot : Parser := parser! "`(stx|" >> toggleInsideQuot syntaxParser >> ")"
end Term
namespace Command
def «prefix» := parser! "prefix"
def «infix» := parser! "infix"
def «infixl» := parser! "infixl"
def «infixr» := parser! "infixr"
def «postfix» := parser! "postfix"
def mixfixKind := «prefix» <|> «infix» <|> «infixl» <|> «infixr» <|> «postfix»
-- TODO: after we remove old frontend
-- * remove " := "
-- * remove quotedSymbol and unquotedSymbol alternative
@[builtinCommandParser] def «mixfix» := parser! mixfixKind >> optPrecedence >> (strLit <|> quotedSymbol <|> unquotedSymbol) >> (darrow <|> " := ") >> termParser
-- TODO: remove
@[builtinCommandParser] def «reserve» := parser! "reserve " >> mixfixKind >> quotedSymbol >> optPrecedence
def identPrec := parser! ident >> optPrecedence
def optKind : Parser := optional ("[" >> ident >> "]")
def notationItem := withAntiquot (mkAntiquot "notationItem" `Lean.Parser.Command.notationItem) (strLit <|> quotedSymbol <|> identPrec)
-- TODO: remove " := " after old frontend is gone
@[builtinCommandParser] def «notation» := parser! "notation" >> optPrecedence >> many notationItem >> (" := " <|> darrow) >> termParser
@[builtinCommandParser] def «macro_rules» := parser! "macro_rules" >> optKind >> Term.matchAlts
def parserKind := parser! ident
def parserPrio := parser! numLit
def parserKindPrio := parser! try (ident >> ", ") >> numLit
def optKindPrio : Parser := optional ("[" >> (parserKindPrio <|> parserKind <|> parserPrio) >> "]")
@[builtinCommandParser] def «syntax» := parser! "syntax " >> optPrecedence >> optKindPrio >> many1 syntaxParser >> " : " >> ident
@[builtinCommandParser] def syntaxAbbrev := parser! "syntax " >> ident >> " := " >> many1 syntaxParser
@[builtinCommandParser] def syntaxCat := parser! "declare_syntax_cat " >> ident
def macroArgSimple := parser! ident >> checkNoWsBefore "no space before ':'" >> ":" >> syntaxParser maxPrec
def macroArg := try strLit <|> try macroArgSimple
def macroHead := macroArg <|> try ident
def macroTailTactic : Parser := try (" : " >> identEq "tactic") >> darrow >> ("`(" >> toggleInsideQuot Tactic.seq1Unbox >> ")" <|> termParser)
def macroTailCommand : Parser := try (" : " >> identEq "command") >> darrow >> ("`(" >> toggleInsideQuot (many1Unbox commandParser) >> ")" <|> termParser)
def macroTailDefault : Parser := try (" : " >> ident) >> darrow >> (("`(" >> toggleInsideQuot (categoryParserOfStack 2) >> ")") <|> termParser)
def macroTail := macroTailTactic <|> macroTailCommand <|> macroTailDefault
@[builtinCommandParser] def «macro» := parser! "macro " >> optPrecedence >> macroHead >> many macroArg >> macroTail
@[builtinCommandParser] def «elab_rules» := parser! "elab_rules" >> optKind >> optional (" : " >> ident) >> Term.matchAlts
def elabHead := macroHead
def elabArg := macroArg
def elabTail := try (" : " >> ident >> optional (" <= " >> ident)) >> darrow >> termParser
@[builtinCommandParser] def «elab» := parser! "elab " >> optPrecedence >> elabHead >> many elabArg >> elabTail
end Command
end Parser
end Lean
|
23c6b081be7bc8d6771e1c2c92b5297f8dad81ce | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/analysis/specific_limits/normed.lean | 47c7d7a5d578aab9bd84e734eb3f26546dac5c48 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 30,228 | lean | /-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker, Sébastien Gouëzel, Yury G. Kudryashov, Dylan MacKenzie, Patrick Massot
-/
import algebra.order.field.basic
import analysis.asymptotics.asymptotics
import analysis.specific_limits.basic
/-!
# A collection of specific limit computations
This file contains important specific limit computations in (semi-)normed groups/rings/spaces, as
as well as such computations in `ℝ` when the natural proof passes through a fact about normed
spaces.
-/
noncomputable theory
open classical set function filter finset metric asymptotics
open_locale classical topological_space nat big_operators uniformity nnreal ennreal
variables {α : Type*} {β : Type*} {ι : Type*}
lemma tendsto_norm_at_top_at_top : tendsto (norm : ℝ → ℝ) at_top at_top :=
tendsto_abs_at_top_at_top
lemma summable_of_absolute_convergence_real {f : ℕ → ℝ} :
(∃r, tendsto (λn, (∑ i in range n, |f i|)) at_top (𝓝 r)) → summable f
| ⟨r, hr⟩ :=
begin
refine summable_of_summable_norm ⟨r, (has_sum_iff_tendsto_nat_of_nonneg _ _).2 _⟩,
exact assume i, norm_nonneg _,
simpa only using hr
end
/-! ### Powers -/
lemma tendsto_norm_zero' {𝕜 : Type*} [normed_add_comm_group 𝕜] :
tendsto (norm : 𝕜 → ℝ) (𝓝[≠] 0) (𝓝[>] 0) :=
tendsto_norm_zero.inf $ tendsto_principal_principal.2 $ λ x hx, norm_pos_iff.2 hx
namespace normed_field
lemma tendsto_norm_inverse_nhds_within_0_at_top {𝕜 : Type*} [normed_field 𝕜] :
tendsto (λ x:𝕜, ‖x⁻¹‖) (𝓝[≠] 0) at_top :=
(tendsto_inv_zero_at_top.comp tendsto_norm_zero').congr $ λ x, (norm_inv x).symm
lemma tendsto_norm_zpow_nhds_within_0_at_top {𝕜 : Type*} [normed_field 𝕜] {m : ℤ}
(hm : m < 0) :
tendsto (λ x : 𝕜, ‖x ^ m‖) (𝓝[≠] 0) at_top :=
begin
rcases neg_surjective m with ⟨m, rfl⟩,
rw neg_lt_zero at hm, lift m to ℕ using hm.le, rw int.coe_nat_pos at hm,
simp only [norm_pow, zpow_neg, zpow_coe_nat, ← inv_pow],
exact (tendsto_pow_at_top hm.ne').comp normed_field.tendsto_norm_inverse_nhds_within_0_at_top
end
/-- The (scalar) product of a sequence that tends to zero with a bounded one also tends to zero. -/
lemma tendsto_zero_smul_of_tendsto_zero_of_bounded {ι 𝕜 𝔸 : Type*} [normed_field 𝕜]
[normed_add_comm_group 𝔸] [normed_space 𝕜 𝔸] {l : filter ι} {ε : ι → 𝕜} {f : ι → 𝔸}
(hε : tendsto ε l (𝓝 0)) (hf : filter.is_bounded_under (≤) l (norm ∘ f)) :
tendsto (ε • f) l (𝓝 0) :=
begin
rw ← is_o_one_iff 𝕜 at hε ⊢,
simpa using is_o.smul_is_O hε (hf.is_O_const (one_ne_zero : (1 : 𝕜) ≠ 0))
end
@[simp] lemma continuous_at_zpow {𝕜 : Type*} [nontrivially_normed_field 𝕜] {m : ℤ} {x : 𝕜} :
continuous_at (λ x, x ^ m) x ↔ x ≠ 0 ∨ 0 ≤ m :=
begin
refine ⟨_, continuous_at_zpow₀ _ _⟩,
contrapose!, rintro ⟨rfl, hm⟩ hc,
exact not_tendsto_at_top_of_tendsto_nhds (hc.tendsto.mono_left nhds_within_le_nhds).norm
(tendsto_norm_zpow_nhds_within_0_at_top hm)
end
@[simp] lemma continuous_at_inv {𝕜 : Type*} [nontrivially_normed_field 𝕜] {x : 𝕜} :
continuous_at has_inv.inv x ↔ x ≠ 0 :=
by simpa [(zero_lt_one' ℤ).not_le] using @continuous_at_zpow _ _ (-1) x
end normed_field
lemma is_o_pow_pow_of_lt_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ < r₂) :
(λ n : ℕ, r₁ ^ n) =o[at_top] (λ n, r₂ ^ n) :=
have H : 0 < r₂ := h₁.trans_lt h₂,
is_o_of_tendsto (λ n hn, false.elim $ H.ne' $ pow_eq_zero hn) $
(tendsto_pow_at_top_nhds_0_of_lt_1 (div_nonneg h₁ (h₁.trans h₂.le)) ((div_lt_one H).2 h₂)).congr
(λ n, div_pow _ _ _)
lemma is_O_pow_pow_of_le_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ ≤ r₂) :
(λ n : ℕ, r₁ ^ n) =O[at_top] (λ n, r₂ ^ n) :=
h₂.eq_or_lt.elim (λ h, h ▸ is_O_refl _ _) (λ h, (is_o_pow_pow_of_lt_left h₁ h).is_O)
lemma is_o_pow_pow_of_abs_lt_left {r₁ r₂ : ℝ} (h : |r₁| < |r₂|) :
(λ n : ℕ, r₁ ^ n) =o[at_top] (λ n, r₂ ^ n) :=
begin
refine (is_o.of_norm_left _).of_norm_right,
exact (is_o_pow_pow_of_lt_left (abs_nonneg r₁) h).congr (pow_abs r₁) (pow_abs r₂)
end
/-- Various statements equivalent to the fact that `f n` grows exponentially slower than `R ^ n`.
* 0: $f n = o(a ^ n)$ for some $-R < a < R$;
* 1: $f n = o(a ^ n)$ for some $0 < a < R$;
* 2: $f n = O(a ^ n)$ for some $-R < a < R$;
* 3: $f n = O(a ^ n)$ for some $0 < a < R$;
* 4: there exist `a < R` and `C` such that one of `C` and `R` is positive and $|f n| ≤ Ca^n$
for all `n`;
* 5: there exists `0 < a < R` and a positive `C` such that $|f n| ≤ Ca^n$ for all `n`;
* 6: there exists `a < R` such that $|f n| ≤ a ^ n$ for sufficiently large `n`;
* 7: there exists `0 < a < R` such that $|f n| ≤ a ^ n$ for sufficiently large `n`.
NB: For backwards compatibility, if you add more items to the list, please append them at the end of
the list. -/
lemma tfae_exists_lt_is_o_pow (f : ℕ → ℝ) (R : ℝ) :
tfae [∃ a ∈ Ioo (-R) R, f =o[at_top] pow a,
∃ a ∈ Ioo 0 R, f =o[at_top] (pow a),
∃ a ∈ Ioo (-R) R, f =O[at_top] pow a,
∃ a ∈ Ioo 0 R, f =O[at_top] pow a,
∃ (a < R) C (h₀ : 0 < C ∨ 0 < R), ∀ n, |f n| ≤ C * a ^ n,
∃ (a ∈ Ioo 0 R) (C > 0), ∀ n, |f n| ≤ C * a ^ n,
∃ a < R, ∀ᶠ n in at_top, |f n| ≤ a ^ n,
∃ a ∈ Ioo 0 R, ∀ᶠ n in at_top, |f n| ≤ a ^ n] :=
begin
have A : Ico 0 R ⊆ Ioo (-R) R,
from λ x hx, ⟨(neg_lt_zero.2 (hx.1.trans_lt hx.2)).trans_le hx.1, hx.2⟩,
have B : Ioo 0 R ⊆ Ioo (-R) R := subset.trans Ioo_subset_Ico_self A,
-- First we prove that 1-4 are equivalent using 2 → 3 → 4, 1 → 3, and 2 → 1
tfae_have : 1 → 3, from λ ⟨a, ha, H⟩, ⟨a, ha, H.is_O⟩,
tfae_have : 2 → 1, from λ ⟨a, ha, H⟩, ⟨a, B ha, H⟩,
tfae_have : 3 → 2,
{ rintro ⟨a, ha, H⟩,
rcases exists_between (abs_lt.2 ha) with ⟨b, hab, hbR⟩,
exact ⟨b, ⟨(abs_nonneg a).trans_lt hab, hbR⟩,
H.trans_is_o (is_o_pow_pow_of_abs_lt_left (hab.trans_le (le_abs_self b)))⟩ },
tfae_have : 2 → 4, from λ ⟨a, ha, H⟩, ⟨a, ha, H.is_O⟩,
tfae_have : 4 → 3, from λ ⟨a, ha, H⟩, ⟨a, B ha, H⟩,
-- Add 5 and 6 using 4 → 6 → 5 → 3
tfae_have : 4 → 6,
{ rintro ⟨a, ha, H⟩,
rcases bound_of_is_O_nat_at_top H with ⟨C, hC₀, hC⟩,
refine ⟨a, ha, C, hC₀, λ n, _⟩,
simpa only [real.norm_eq_abs, abs_pow, abs_of_nonneg ha.1.le]
using hC (pow_ne_zero n ha.1.ne') },
tfae_have : 6 → 5, from λ ⟨a, ha, C, H₀, H⟩, ⟨a, ha.2, C, or.inl H₀, H⟩,
tfae_have : 5 → 3,
{ rintro ⟨a, ha, C, h₀, H⟩,
rcases sign_cases_of_C_mul_pow_nonneg (λ n, (abs_nonneg _).trans (H n)) with rfl | ⟨hC₀, ha₀⟩,
{ obtain rfl : f = 0, by { ext n, simpa using H n },
simp only [lt_irrefl, false_or] at h₀,
exact ⟨0, ⟨neg_lt_zero.2 h₀, h₀⟩, is_O_zero _ _⟩ },
exact ⟨a, A ⟨ha₀, ha⟩,
is_O_of_le' _ (λ n, (H n).trans $ mul_le_mul_of_nonneg_left (le_abs_self _) hC₀.le)⟩ },
-- Add 7 and 8 using 2 → 8 → 7 → 3
tfae_have : 2 → 8,
{ rintro ⟨a, ha, H⟩,
refine ⟨a, ha, (H.def zero_lt_one).mono (λ n hn, _)⟩,
rwa [real.norm_eq_abs, real.norm_eq_abs, one_mul, abs_pow, abs_of_pos ha.1] at hn },
tfae_have : 8 → 7, from λ ⟨a, ha, H⟩, ⟨a, ha.2, H⟩,
tfae_have : 7 → 3,
{ rintro ⟨a, ha, H⟩,
have : 0 ≤ a, from nonneg_of_eventually_pow_nonneg (H.mono $ λ n, (abs_nonneg _).trans),
refine ⟨a, A ⟨this, ha⟩, is_O.of_bound 1 _⟩,
simpa only [real.norm_eq_abs, one_mul, abs_pow, abs_of_nonneg this] },
tfae_finish
end
/-- For any natural `k` and a real `r > 1` we have `n ^ k = o(r ^ n)` as `n → ∞`. -/
lemma is_o_pow_const_const_pow_of_one_lt {R : Type*} [normed_ring R] (k : ℕ) {r : ℝ} (hr : 1 < r) :
(λ n, n ^ k : ℕ → R) =o[at_top] (λ n, r ^ n) :=
begin
have : tendsto (λ x : ℝ, x ^ k) (𝓝[>] 1) (𝓝 1),
from ((continuous_id.pow k).tendsto' (1 : ℝ) 1 (one_pow _)).mono_left inf_le_left,
obtain ⟨r' : ℝ, hr' : r' ^ k < r, h1 : 1 < r'⟩ :=
((this.eventually (gt_mem_nhds hr)).and self_mem_nhds_within).exists,
have h0 : 0 ≤ r' := zero_le_one.trans h1.le,
suffices : (λ n, n ^ k : ℕ → R) =O[at_top] (λ n : ℕ, (r' ^ k) ^ n),
from this.trans_is_o (is_o_pow_pow_of_lt_left (pow_nonneg h0 _) hr'),
conv in ((r' ^ _) ^ _) { rw [← pow_mul, mul_comm, pow_mul] },
suffices : ∀ n : ℕ, ‖(n : R)‖ ≤ (r' - 1)⁻¹ * ‖(1 : R)‖ * ‖r' ^ n‖,
from (is_O_of_le' _ this).pow _,
intro n, rw mul_right_comm,
refine n.norm_cast_le.trans (mul_le_mul_of_nonneg_right _ (norm_nonneg _)),
simpa [div_eq_inv_mul, real.norm_eq_abs, abs_of_nonneg h0] using n.cast_le_pow_div_sub h1
end
/-- For a real `r > 1` we have `n = o(r ^ n)` as `n → ∞`. -/
lemma is_o_coe_const_pow_of_one_lt {R : Type*} [normed_ring R] {r : ℝ} (hr : 1 < r) :
(coe : ℕ → R) =o[at_top] (λ n, r ^ n) :=
by simpa only [pow_one] using @is_o_pow_const_const_pow_of_one_lt R _ 1 _ hr
/-- If `‖r₁‖ < r₂`, then for any naturak `k` we have `n ^ k r₁ ^ n = o (r₂ ^ n)` as `n → ∞`. -/
lemma is_o_pow_const_mul_const_pow_const_pow_of_norm_lt {R : Type*} [normed_ring R] (k : ℕ)
{r₁ : R} {r₂ : ℝ} (h : ‖r₁‖ < r₂) :
(λ n, n ^ k * r₁ ^ n : ℕ → R) =o[at_top] (λ n, r₂ ^ n) :=
begin
by_cases h0 : r₁ = 0,
{ refine (is_o_zero _ _).congr' (mem_at_top_sets.2 $ ⟨1, λ n hn, _⟩) eventually_eq.rfl,
simp [zero_pow (zero_lt_one.trans_le hn), h0] },
rw [← ne.def, ← norm_pos_iff] at h0,
have A : (λ n, n ^ k : ℕ → R) =o[at_top] (λ n, (r₂ / ‖r₁‖) ^ n),
from is_o_pow_const_const_pow_of_one_lt k ((one_lt_div h0).2 h),
suffices : (λ n, r₁ ^ n) =O[at_top] (λ n, ‖r₁‖ ^ n),
by simpa [div_mul_cancel _ (pow_pos h0 _).ne'] using A.mul_is_O this,
exact is_O.of_bound 1 (by simpa using eventually_norm_pow_le r₁)
end
lemma tendsto_pow_const_div_const_pow_of_one_lt (k : ℕ) {r : ℝ} (hr : 1 < r) :
tendsto (λ n, n ^ k / r ^ n : ℕ → ℝ) at_top (𝓝 0) :=
(is_o_pow_const_const_pow_of_one_lt k hr).tendsto_div_nhds_zero
/-- If `|r| < 1`, then `n ^ k r ^ n` tends to zero for any natural `k`. -/
lemma tendsto_pow_const_mul_const_pow_of_abs_lt_one (k : ℕ) {r : ℝ} (hr : |r| < 1) :
tendsto (λ n, n ^ k * r ^ n : ℕ → ℝ) at_top (𝓝 0) :=
begin
by_cases h0 : r = 0,
{ exact tendsto_const_nhds.congr'
(mem_at_top_sets.2 ⟨1, λ n hn, by simp [zero_lt_one.trans_le hn, h0]⟩) },
have hr' : 1 < (|r|)⁻¹, from one_lt_inv (abs_pos.2 h0) hr,
rw tendsto_zero_iff_norm_tendsto_zero,
simpa [div_eq_mul_inv] using tendsto_pow_const_div_const_pow_of_one_lt k hr'
end
/-- If `0 ≤ r < 1`, then `n ^ k r ^ n` tends to zero for any natural `k`.
This is a specialized version of `tendsto_pow_const_mul_const_pow_of_abs_lt_one`, singled out
for ease of application. -/
lemma tendsto_pow_const_mul_const_pow_of_lt_one (k : ℕ) {r : ℝ} (hr : 0 ≤ r) (h'r : r < 1) :
tendsto (λ n, n ^ k * r ^ n : ℕ → ℝ) at_top (𝓝 0) :=
tendsto_pow_const_mul_const_pow_of_abs_lt_one k (abs_lt.2 ⟨neg_one_lt_zero.trans_le hr, h'r⟩)
/-- If `|r| < 1`, then `n * r ^ n` tends to zero. -/
lemma tendsto_self_mul_const_pow_of_abs_lt_one {r : ℝ} (hr : |r| < 1) :
tendsto (λ n, n * r ^ n : ℕ → ℝ) at_top (𝓝 0) :=
by simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_abs_lt_one 1 hr
/-- If `0 ≤ r < 1`, then `n * r ^ n` tends to zero. This is a specialized version of
`tendsto_self_mul_const_pow_of_abs_lt_one`, singled out for ease of application. -/
lemma tendsto_self_mul_const_pow_of_lt_one {r : ℝ} (hr : 0 ≤ r) (h'r : r < 1) :
tendsto (λ n, n * r ^ n : ℕ → ℝ) at_top (𝓝 0) :=
by simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_lt_one 1 hr h'r
/-- In a normed ring, the powers of an element x with `‖x‖ < 1` tend to zero. -/
lemma tendsto_pow_at_top_nhds_0_of_norm_lt_1 {R : Type*} [normed_ring R] {x : R}
(h : ‖x‖ < 1) : tendsto (λ (n : ℕ), x ^ n) at_top (𝓝 0) :=
begin
apply squeeze_zero_norm' (eventually_norm_pow_le x),
exact tendsto_pow_at_top_nhds_0_of_lt_1 (norm_nonneg _) h,
end
lemma tendsto_pow_at_top_nhds_0_of_abs_lt_1 {r : ℝ} (h : |r| < 1) :
tendsto (λn:ℕ, r^n) at_top (𝓝 0) :=
tendsto_pow_at_top_nhds_0_of_norm_lt_1 h
/-! ### Geometric series-/
section geometric
variables {K : Type*} [normed_field K] {ξ : K}
lemma has_sum_geometric_of_norm_lt_1 (h : ‖ξ‖ < 1) : has_sum (λn:ℕ, ξ ^ n) (1 - ξ)⁻¹ :=
begin
have xi_ne_one : ξ ≠ 1, by { contrapose! h, simp [h] },
have A : tendsto (λn, (ξ ^ n - 1) * (ξ - 1)⁻¹) at_top (𝓝 ((0 - 1) * (ξ - 1)⁻¹)),
from ((tendsto_pow_at_top_nhds_0_of_norm_lt_1 h).sub tendsto_const_nhds).mul tendsto_const_nhds,
rw [has_sum_iff_tendsto_nat_of_summable_norm],
{ simpa [geom_sum_eq, xi_ne_one, neg_inv, div_eq_mul_inv] using A },
{ simp [norm_pow, summable_geometric_of_lt_1 (norm_nonneg _) h] }
end
lemma summable_geometric_of_norm_lt_1 (h : ‖ξ‖ < 1) : summable (λn:ℕ, ξ ^ n) :=
⟨_, has_sum_geometric_of_norm_lt_1 h⟩
lemma tsum_geometric_of_norm_lt_1 (h : ‖ξ‖ < 1) : ∑'n:ℕ, ξ ^ n = (1 - ξ)⁻¹ :=
(has_sum_geometric_of_norm_lt_1 h).tsum_eq
lemma has_sum_geometric_of_abs_lt_1 {r : ℝ} (h : |r| < 1) : has_sum (λn:ℕ, r ^ n) (1 - r)⁻¹ :=
has_sum_geometric_of_norm_lt_1 h
lemma summable_geometric_of_abs_lt_1 {r : ℝ} (h : |r| < 1) : summable (λn:ℕ, r ^ n) :=
summable_geometric_of_norm_lt_1 h
lemma tsum_geometric_of_abs_lt_1 {r : ℝ} (h : |r| < 1) : ∑'n:ℕ, r ^ n = (1 - r)⁻¹ :=
tsum_geometric_of_norm_lt_1 h
/-- A geometric series in a normed field is summable iff the norm of the common ratio is less than
one. -/
@[simp] lemma summable_geometric_iff_norm_lt_1 : summable (λ n : ℕ, ξ ^ n) ↔ ‖ξ‖ < 1 :=
begin
refine ⟨λ h, _, summable_geometric_of_norm_lt_1⟩,
obtain ⟨k : ℕ, hk : dist (ξ ^ k) 0 < 1⟩ :=
(h.tendsto_cofinite_zero.eventually (ball_mem_nhds _ zero_lt_one)).exists,
simp only [norm_pow, dist_zero_right] at hk,
rw [← one_pow k] at hk,
exact lt_of_pow_lt_pow _ zero_le_one hk
end
end geometric
section mul_geometric
lemma summable_norm_pow_mul_geometric_of_norm_lt_1 {R : Type*} [normed_ring R]
(k : ℕ) {r : R} (hr : ‖r‖ < 1) : summable (λ n : ℕ, ‖(n ^ k * r ^ n : R)‖) :=
begin
rcases exists_between hr with ⟨r', hrr', h⟩,
exact summable_of_is_O_nat (summable_geometric_of_lt_1 ((norm_nonneg _).trans hrr'.le) h)
(is_o_pow_const_mul_const_pow_const_pow_of_norm_lt _ hrr').is_O.norm_left
end
lemma summable_pow_mul_geometric_of_norm_lt_1 {R : Type*} [normed_ring R] [complete_space R]
(k : ℕ) {r : R} (hr : ‖r‖ < 1) : summable (λ n, n ^ k * r ^ n : ℕ → R) :=
summable_of_summable_norm $ summable_norm_pow_mul_geometric_of_norm_lt_1 _ hr
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `has_sum` version. -/
lemma has_sum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [normed_field 𝕜] [complete_space 𝕜]
{r : 𝕜} (hr : ‖r‖ < 1) : has_sum (λ n, n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) :=
begin
have A : summable (λ n, n * r ^ n : ℕ → 𝕜),
by simpa using summable_pow_mul_geometric_of_norm_lt_1 1 hr,
have B : has_sum (pow r : ℕ → 𝕜) (1 - r)⁻¹, from has_sum_geometric_of_norm_lt_1 hr,
refine A.has_sum_iff.2 _,
have hr' : r ≠ 1, by { rintro rfl, simpa [lt_irrefl] using hr },
set s : 𝕜 := ∑' n : ℕ, n * r ^ n,
calc s = (1 - r) * s / (1 - r) : (mul_div_cancel_left _ (sub_ne_zero.2 hr'.symm)).symm
... = (s - r * s) / (1 - r) : by rw [sub_mul, one_mul]
... = ((0 : ℕ) * r ^ 0 + (∑' n : ℕ, (n + 1 : ℕ) * r ^ (n + 1)) - r * s) / (1 - r) :
by rw ← tsum_eq_zero_add A
... = (r * (∑' n : ℕ, (n + 1) * r ^ n) - r * s) / (1 - r) :
by simp [pow_succ, mul_left_comm _ r, tsum_mul_left]
... = r / (1 - r) ^ 2 :
by simp [add_mul, tsum_add A B.summable, mul_add, B.tsum_eq, ← div_eq_mul_inv, sq,
div_div]
end
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`. -/
lemma tsum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [normed_field 𝕜] [complete_space 𝕜]
{r : 𝕜} (hr : ‖r‖ < 1) :
(∑' n : ℕ, n * r ^ n : 𝕜) = (r / (1 - r) ^ 2) :=
(has_sum_coe_mul_geometric_of_norm_lt_1 hr).tsum_eq
end mul_geometric
section summable_le_geometric
variables [seminormed_add_comm_group α] {r C : ℝ} {f : ℕ → α}
lemma seminormed_add_comm_group.cauchy_seq_of_le_geometric {C : ℝ} {r : ℝ} (hr : r < 1)
{u : ℕ → α} (h : ∀ n, ‖u n - u (n + 1)‖ ≤ C*r^n) : cauchy_seq u :=
cauchy_seq_of_le_geometric r C hr (by simpa [dist_eq_norm] using h)
lemma dist_partial_sum_le_of_le_geometric (hf : ∀n, ‖f n‖ ≤ C * r^n) (n : ℕ) :
dist (∑ i in range n, f i) (∑ i in range (n+1), f i) ≤ C * r ^ n :=
begin
rw [sum_range_succ, dist_eq_norm, ← norm_neg, neg_sub, add_sub_cancel'],
exact hf n,
end
/-- If `‖f n‖ ≤ C * r ^ n` for all `n : ℕ` and some `r < 1`, then the partial sums of `f` form a
Cauchy sequence. This lemma does not assume `0 ≤ r` or `0 ≤ C`. -/
lemma cauchy_seq_finset_of_geometric_bound (hr : r < 1) (hf : ∀n, ‖f n‖ ≤ C * r^n) :
cauchy_seq (λ s : finset (ℕ), ∑ x in s, f x) :=
cauchy_seq_finset_of_norm_bounded _
(aux_has_sum_of_le_geometric hr (dist_partial_sum_le_of_le_geometric hf)).summable hf
/-- If `‖f n‖ ≤ C * r ^ n` for all `n : ℕ` and some `r < 1`, then the partial sums of `f` are within
distance `C * r ^ n / (1 - r)` of the sum of the series. This lemma does not assume `0 ≤ r` or
`0 ≤ C`. -/
lemma norm_sub_le_of_geometric_bound_of_has_sum (hr : r < 1) (hf : ∀n, ‖f n‖ ≤ C * r^n)
{a : α} (ha : has_sum f a) (n : ℕ) :
‖(∑ x in finset.range n, f x) - a‖ ≤ (C * r ^ n) / (1 - r) :=
begin
rw ← dist_eq_norm,
apply dist_le_of_le_geometric_of_tendsto r C hr (dist_partial_sum_le_of_le_geometric hf),
exact ha.tendsto_sum_nat
end
@[simp] lemma dist_partial_sum (u : ℕ → α) (n : ℕ) :
dist (∑ k in range (n + 1), u k) (∑ k in range n, u k) = ‖u n‖ :=
by simp [dist_eq_norm, sum_range_succ]
@[simp] lemma dist_partial_sum' (u : ℕ → α) (n : ℕ) :
dist (∑ k in range n, u k) (∑ k in range (n+1), u k) = ‖u n‖ :=
by simp [dist_eq_norm', sum_range_succ]
lemma cauchy_series_of_le_geometric {C : ℝ} {u : ℕ → α}
{r : ℝ} (hr : r < 1) (h : ∀ n, ‖u n‖ ≤ C*r^n) : cauchy_seq (λ n, ∑ k in range n, u k) :=
cauchy_seq_of_le_geometric r C hr (by simp [h])
lemma normed_add_comm_group.cauchy_series_of_le_geometric' {C : ℝ} {u : ℕ → α} {r : ℝ} (hr : r < 1)
(h : ∀ n, ‖u n‖ ≤ C*r^n) : cauchy_seq (λ n, ∑ k in range (n + 1), u k) :=
(cauchy_series_of_le_geometric hr h).comp_tendsto $ tendsto_add_at_top_nat 1
lemma normed_add_comm_group.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
(hr₀ : 0 < r) (hr₁ : r < 1)
(h : ∀ n ≥ N, ‖u n‖ ≤ C*r^n) : cauchy_seq (λ n, ∑ k in range (n + 1), u k) :=
begin
set v : ℕ → α := λ n, if n < N then 0 else u n,
have hC : 0 ≤ C,
from (zero_le_mul_right $ pow_pos hr₀ N).mp ((norm_nonneg _).trans $ h N $ le_refl N),
have : ∀ n ≥ N, u n = v n,
{ intros n hn,
simp [v, hn, if_neg (not_lt.mpr hn)] },
refine cauchy_seq_sum_of_eventually_eq this (normed_add_comm_group.cauchy_series_of_le_geometric'
hr₁ _),
{ exact C },
intro n,
dsimp [v],
split_ifs with H H,
{ rw norm_zero,
exact mul_nonneg hC (pow_nonneg hr₀.le _) },
{ push_neg at H,
exact h _ H }
end
end summable_le_geometric
section normed_ring_geometric
variables {R : Type*} [normed_ring R] [complete_space R]
open normed_space
/-- A geometric series in a complete normed ring is summable.
Proved above (same name, different namespace) for not-necessarily-complete normed fields. -/
lemma normed_ring.summable_geometric_of_norm_lt_1
(x : R) (h : ‖x‖ < 1) : summable (λ (n:ℕ), x ^ n) :=
begin
have h1 : summable (λ (n:ℕ), ‖x‖ ^ n) := summable_geometric_of_lt_1 (norm_nonneg _) h,
refine summable_of_norm_bounded_eventually _ h1 _,
rw nat.cofinite_eq_at_top,
exact eventually_norm_pow_le x,
end
/-- Bound for the sum of a geometric series in a normed ring. This formula does not assume that the
normed ring satisfies the axiom `‖1‖ = 1`. -/
lemma normed_ring.tsum_geometric_of_norm_lt_1
(x : R) (h : ‖x‖ < 1) : ‖∑' n:ℕ, x ^ n‖ ≤ ‖(1:R)‖ - 1 + (1 - ‖x‖)⁻¹ :=
begin
rw tsum_eq_zero_add (normed_ring.summable_geometric_of_norm_lt_1 x h),
simp only [pow_zero],
refine le_trans (norm_add_le _ _) _,
have : ‖∑' b : ℕ, (λ n, x ^ (n + 1)) b‖ ≤ (1 - ‖x‖)⁻¹ - 1,
{ refine tsum_of_norm_bounded _ (λ b, norm_pow_le' _ (nat.succ_pos b)),
convert (has_sum_nat_add_iff' 1).mpr (has_sum_geometric_of_lt_1 (norm_nonneg x) h),
simp },
linarith
end
lemma geom_series_mul_neg (x : R) (h : ‖x‖ < 1) :
(∑' i:ℕ, x ^ i) * (1 - x) = 1 :=
begin
have := ((normed_ring.summable_geometric_of_norm_lt_1 x h).has_sum.mul_right (1 - x)),
refine tendsto_nhds_unique this.tendsto_sum_nat _,
have : tendsto (λ (n : ℕ), 1 - x ^ n) at_top (𝓝 1),
{ simpa using tendsto_const_nhds.sub (tendsto_pow_at_top_nhds_0_of_norm_lt_1 h) },
convert ← this,
ext n,
rw [←geom_sum_mul_neg, finset.sum_mul],
end
lemma mul_neg_geom_series (x : R) (h : ‖x‖ < 1) :
(1 - x) * ∑' i:ℕ, x ^ i = 1 :=
begin
have := (normed_ring.summable_geometric_of_norm_lt_1 x h).has_sum.mul_left (1 - x),
refine tendsto_nhds_unique this.tendsto_sum_nat _,
have : tendsto (λ (n : ℕ), 1 - x ^ n) at_top (nhds 1),
{ simpa using tendsto_const_nhds.sub
(tendsto_pow_at_top_nhds_0_of_norm_lt_1 h) },
convert ← this,
ext n,
rw [←mul_neg_geom_sum, finset.mul_sum]
end
end normed_ring_geometric
/-! ### Summability tests based on comparison with geometric series -/
lemma summable_of_ratio_norm_eventually_le {α : Type*} [seminormed_add_comm_group α]
[complete_space α] {f : ℕ → α} {r : ℝ} (hr₁ : r < 1)
(h : ∀ᶠ n in at_top, ‖f (n+1)‖ ≤ r * ‖f n‖) : summable f :=
begin
by_cases hr₀ : 0 ≤ r,
{ rw eventually_at_top at h,
rcases h with ⟨N, hN⟩,
rw ← @summable_nat_add_iff α _ _ _ _ N,
refine summable_of_norm_bounded (λ n, ‖f N‖ * r^n)
(summable.mul_left _ $ summable_geometric_of_lt_1 hr₀ hr₁) (λ n, _),
conv_rhs {rw [mul_comm, ← zero_add N]},
refine le_geom hr₀ n (λ i _, _),
convert hN (i + N) (N.le_add_left i) using 3,
ac_refl },
{ push_neg at hr₀,
refine summable_of_norm_bounded_eventually 0 summable_zero _,
rw nat.cofinite_eq_at_top,
filter_upwards [h] with _ hn,
by_contra' h,
exact not_lt.mpr (norm_nonneg _) (lt_of_le_of_lt hn $ mul_neg_of_neg_of_pos hr₀ h), },
end
lemma summable_of_ratio_test_tendsto_lt_one {α : Type*} [normed_add_comm_group α] [complete_space α]
{f : ℕ → α} {l : ℝ} (hl₁ : l < 1) (hf : ∀ᶠ n in at_top, f n ≠ 0)
(h : tendsto (λ n, ‖f (n+1)‖/‖f n‖) at_top (𝓝 l)) : summable f :=
begin
rcases exists_between hl₁ with ⟨r, hr₀, hr₁⟩,
refine summable_of_ratio_norm_eventually_le hr₁ _,
filter_upwards [eventually_le_of_tendsto_lt hr₀ h, hf] with _ _ h₁,
rwa ← div_le_iff (norm_pos_iff.mpr h₁),
end
lemma not_summable_of_ratio_norm_eventually_ge {α : Type*} [seminormed_add_comm_group α]
{f : ℕ → α} {r : ℝ} (hr : 1 < r) (hf : ∃ᶠ n in at_top, ‖f n‖ ≠ 0)
(h : ∀ᶠ n in at_top, r * ‖f n‖ ≤ ‖f (n+1)‖) : ¬ summable f :=
begin
rw eventually_at_top at h,
rcases h with ⟨N₀, hN₀⟩,
rw frequently_at_top at hf,
rcases hf N₀ with ⟨N, hNN₀ : N₀ ≤ N, hN⟩,
rw ← @summable_nat_add_iff α _ _ _ _ N,
refine mt summable.tendsto_at_top_zero
(λ h', not_tendsto_at_top_of_tendsto_nhds (tendsto_norm_zero.comp h') _),
convert tendsto_at_top_of_geom_le _ hr _,
{ refine lt_of_le_of_ne (norm_nonneg _) _,
intro h'',
specialize hN₀ N hNN₀,
simp only [comp_app, zero_add] at h'',
exact hN h''.symm },
{ intro i,
dsimp only [comp_app],
convert (hN₀ (i + N) (hNN₀.trans (N.le_add_left i))) using 3,
ac_refl }
end
lemma not_summable_of_ratio_test_tendsto_gt_one {α : Type*} [seminormed_add_comm_group α]
{f : ℕ → α} {l : ℝ} (hl : 1 < l)
(h : tendsto (λ n, ‖f (n+1)‖/‖f n‖) at_top (𝓝 l)) : ¬ summable f :=
begin
have key : ∀ᶠ n in at_top, ‖f n‖ ≠ 0,
{ filter_upwards [eventually_ge_of_tendsto_gt hl h] with _ hn hc,
rw [hc, div_zero] at hn,
linarith },
rcases exists_between hl with ⟨r, hr₀, hr₁⟩,
refine not_summable_of_ratio_norm_eventually_ge hr₀ key.frequently _,
filter_upwards [eventually_ge_of_tendsto_gt hr₁ h, key] with _ _ h₁,
rwa ← le_div_iff (lt_of_le_of_ne (norm_nonneg _) h₁.symm)
end
section
/-! ### Dirichlet and alternating series tests -/
variables {E : Type*} [normed_add_comm_group E] [normed_space ℝ E]
variables {b : ℝ} {f : ℕ → ℝ} {z : ℕ → E}
/-- **Dirichlet's Test** for monotone sequences. -/
theorem monotone.cauchy_seq_series_mul_of_tendsto_zero_of_bounded
(hfa : monotone f) (hf0 : tendsto f at_top (𝓝 0)) (hgb : ∀ n, ‖∑ i in range n, z i‖ ≤ b) :
cauchy_seq (λ n, ∑ i in range (n + 1), (f i) • z i) :=
begin
simp_rw [finset.sum_range_by_parts _ _ (nat.succ _), sub_eq_add_neg,
nat.succ_sub_succ_eq_sub, tsub_zero],
apply (normed_field.tendsto_zero_smul_of_tendsto_zero_of_bounded hf0
⟨b, eventually_map.mpr $ eventually_of_forall $ λ n, hgb $ n+1⟩).cauchy_seq.add,
refine (cauchy_seq_range_of_norm_bounded _ _ (λ n, _ : ∀ n, _ ≤ b * |f(n+1) - f(n)|)).neg,
{ simp_rw [abs_of_nonneg (sub_nonneg_of_le (hfa (nat.le_succ _))), ← mul_sum],
apply real.uniform_continuous_const_mul.comp_cauchy_seq,
simp_rw [sum_range_sub, sub_eq_add_neg],
exact (tendsto.cauchy_seq hf0).add_const },
{ rw [norm_smul, mul_comm],
exact mul_le_mul_of_nonneg_right (hgb _) (abs_nonneg _) },
end
/-- **Dirichlet's test** for antitone sequences. -/
theorem antitone.cauchy_seq_series_mul_of_tendsto_zero_of_bounded
(hfa : antitone f) (hf0 : tendsto f at_top (𝓝 0)) (hzb : ∀ n, ‖∑ i in range n, z i‖ ≤ b) :
cauchy_seq (λ n, ∑ i in range (n+1), (f i) • z i) :=
begin
have hfa': monotone (λ n, -f n) := λ _ _ hab, neg_le_neg $ hfa hab,
have hf0': tendsto (λ n, -f n) at_top (𝓝 0) := by { convert hf0.neg, norm_num },
convert (hfa'.cauchy_seq_series_mul_of_tendsto_zero_of_bounded hf0' hzb).neg,
funext,
simp
end
lemma norm_sum_neg_one_pow_le (n : ℕ) : ‖∑ i in range n, (-1 : ℝ) ^ i‖ ≤ 1 :=
by { rw [neg_one_geom_sum], split_ifs; norm_num }
/-- The **alternating series test** for monotone sequences.
See also `tendsto_alternating_series_of_monotone_tendsto_zero`. -/
theorem monotone.cauchy_seq_alternating_series_of_tendsto_zero
(hfa : monotone f) (hf0 : tendsto f at_top (𝓝 0)) :
cauchy_seq (λ n, ∑ i in range (n+1), (-1) ^ i * f i) :=
begin
simp_rw [mul_comm],
exact hfa.cauchy_seq_series_mul_of_tendsto_zero_of_bounded hf0 norm_sum_neg_one_pow_le
end
/-- The **alternating series test** for monotone sequences. -/
theorem monotone.tendsto_alternating_series_of_tendsto_zero
(hfa : monotone f) (hf0 : tendsto f at_top (𝓝 0)) :
∃ l, tendsto (λ n, ∑ i in range (n+1), (-1) ^ i * f i) at_top (𝓝 l) :=
cauchy_seq_tendsto_of_complete $ hfa.cauchy_seq_alternating_series_of_tendsto_zero hf0
/-- The **alternating series test** for antitone sequences.
See also `tendsto_alternating_series_of_antitone_tendsto_zero`. -/
theorem antitone.cauchy_seq_alternating_series_of_tendsto_zero
(hfa : antitone f) (hf0 : tendsto f at_top (𝓝 0)) :
cauchy_seq (λ n, ∑ i in range (n+1), (-1) ^ i * f i) :=
begin
simp_rw [mul_comm],
exact
hfa.cauchy_seq_series_mul_of_tendsto_zero_of_bounded hf0 norm_sum_neg_one_pow_le
end
/-- The **alternating series test** for antitone sequences. -/
theorem antitone.tendsto_alternating_series_of_tendsto_zero
(hfa : antitone f) (hf0 : tendsto f at_top (𝓝 0)) :
∃ l, tendsto (λ n, ∑ i in range (n+1), (-1) ^ i * f i) at_top (𝓝 l) :=
cauchy_seq_tendsto_of_complete $ hfa.cauchy_seq_alternating_series_of_tendsto_zero hf0
end
/-!
### Factorial
-/
/-- The series `∑' n, x ^ n / n!` is summable of any `x : ℝ`. See also `exp_series_div_summable`
for a version that also works in `ℂ`, and `exp_series_summable'` for a version that works in
any normed algebra over `ℝ` or `ℂ`. -/
lemma real.summable_pow_div_factorial (x : ℝ) :
summable (λ n, x ^ n / n! : ℕ → ℝ) :=
begin
-- We start with trivial extimates
have A : (0 : ℝ) < ⌊‖x‖⌋₊ + 1, from zero_lt_one.trans_le (by simp),
have B : ‖x‖ / (⌊‖x‖⌋₊ + 1) < 1, from (div_lt_one A).2 (nat.lt_floor_add_one _),
-- Then we apply the ratio test. The estimate works for `n ≥ ⌊‖x‖⌋₊`.
suffices : ∀ n ≥ ⌊‖x‖⌋₊, ‖x ^ (n + 1) / (n + 1)!‖ ≤ ‖x‖ / (⌊‖x‖⌋₊ + 1) * ‖x ^ n / ↑n!‖,
from summable_of_ratio_norm_eventually_le B (eventually_at_top.2 ⟨⌊‖x‖⌋₊, this⟩),
-- Finally, we prove the upper estimate
intros n hn,
calc ‖x ^ (n + 1) / (n + 1)!‖ = (‖x‖ / (n + 1)) * ‖x ^ n / n!‖ :
by rw [pow_succ, nat.factorial_succ, nat.cast_mul, ← div_mul_div_comm,
norm_mul, norm_div, real.norm_coe_nat, nat.cast_succ]
... ≤ (‖x‖ / (⌊‖x‖⌋₊ + 1)) * ‖x ^ n / n!‖ :
by mono* with [0 ≤ ‖x ^ n / n!‖, 0 ≤ ‖x‖]; apply norm_nonneg
end
lemma real.tendsto_pow_div_factorial_at_top (x : ℝ) :
tendsto (λ n, x ^ n / n! : ℕ → ℝ) at_top (𝓝 0) :=
(real.summable_pow_div_factorial x).tendsto_at_top_zero
|
6adc2bc36625da982410cd1761928953cee2f570 | 4c630d016e43ace8c5f476a5070a471130c8a411 | /group_theory/order_of_element.lean | 3fa91cdb8825d9ac1b2e80ff4bd4946ebe43c894 | [
"Apache-2.0"
] | permissive | ngamt/mathlib | 9a510c391694dc43eec969914e2a0e20b272d172 | 58909bd424209739a2214961eefaa012fb8a18d2 | refs/heads/master | 1,585,942,993,674 | 1,540,739,585,000 | 1,540,916,815,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 11,428 | lean | /-
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 data.set.finite 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, nat.pos_of_ne_zero (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_pos (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, from nat.pos_of_ne_zero (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_gpowers_iff_mem_range_order_of {a a' : α} :
a' ∈ gpowers a ↔ a' ∈ (finset.range (order_of a)).image ((^) a : ℕ → α) :=
finset.mem_range_iff_mem_finset_range_of_mod_eq
(order_of_pos a)
(assume i, gpow_eq_mod_order_of.symm)
instance decidable_gpowers : decidable_pred (gpowers a) :=
assume a', decidable_of_iff'
(a' ∈ (finset.range (order_of a)).image ((^) a))
mem_gpowers_iff_mem_range_order_of
lemma order_of_dvd_of_pow_eq_one {n : ℕ} (h : a ^ n = 1) : order_of a ∣ n :=
by_contradiction
(λ h₁, nat.find_min _ (show n % order_of a < order_of a,
from nat.mod_lt _ (order_of_pos _))
⟨nat.pos_of_ne_zero (mt nat.dvd_of_mod_eq_zero h₁), by rwa ← pow_eq_mod_order_of⟩)
lemma order_of_le_of_pow_eq_one {n : ℕ} (hn : 0 < n) (h : a ^ n = 1) : order_of a ≤ n :=
nat.find_min' (exists_pow_eq_one a) ⟨hn, h⟩
lemma sum_card_order_of_eq_card_pow_eq_one {n : ℕ} (hn : 0 < n) :
((finset.range n.succ).filter (∣ n)).sum (λ m, (finset.univ.filter (λ a : α, order_of a = m)).card)
= (finset.univ.filter (λ a : α, a ^ n = 1)).card :=
calc ((finset.range n.succ).filter (∣ n)).sum (λ m, (finset.univ.filter (λ a : α, order_of a = m)).card)
= _ : (finset.card_bind (by simp [finset.ext]; cc)).symm
... = _ : congr_arg finset.card (finset.ext.2 (begin
assume a,
suffices : order_of a ≤ n ∧ order_of a ∣ n ↔ a ^ n = 1,
{ simpa [-finset.range_succ, nat.lt_succ_iff], },
exact ⟨λ h, let ⟨m, hm⟩ := h.2 in by rw [hm, pow_mul, pow_order_of_eq_one, _root_.one_pow],
λ h, ⟨order_of_le_of_pow_eq_one hn h, order_of_dvd_of_pow_eq_one h⟩⟩
end))
section
local attribute [instance] set_fintype
lemma order_eq_card_gpowers : order_of a = fintype.card (gpowers a) :=
begin
refine (finset.card_eq_of_bijective _ _ _ _).symm,
{ exact λn hn, ⟨gpow a n, ⟨n, rfl⟩⟩ },
{ exact assume ⟨_, i, rfl⟩ _,
have pos: (0:int) < order_of a,
from int.coe_nat_lt.mpr $ order_of_pos 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
open quotient_group
/- TODO: use cardinal theory, introduce `card : set α → ℕ`, or setup decidability for cosets -/
lemma order_of_dvd_card_univ : order_of a ∣ fintype.card α :=
have ft_prod : fintype (quotient (gpowers a) × (gpowers a)),
from fintype.of_equiv α (gpowers.is_subgroup a).group_equiv_quotient_times_subgroup,
have ft_s : fintype (gpowers a),
from @fintype.fintype_prod_right _ _ _ ft_prod _,
have ft_cosets : fintype (quotient (gpowers a)),
from @fintype.fintype_prod_left _ _ _ ft_prod ⟨⟨1, is_submonoid.one_mem (gpowers a)⟩⟩,
have ft : fintype (quotient (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_congr _ _ _ ft_prod (gpowers.is_subgroup a).group_equiv_quotient_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_gpowers
... = _ : congr_arg (@fintype.card _) $ subsingleton.elim _ _,
dvd.intro (@fintype.card (quotient (gpowers a)) ft_cosets) $
by rw [eq₁, eq₂, mul_comm]
end classical
@[simp] lemma pow_card_eq_one (a : α) : a ^ fintype.card α = 1 :=
let ⟨m, hm⟩ := @order_of_dvd_card_univ _ a _ _ _ in
by simp [hm, pow_mul, pow_order_of_eq_one]
lemma powers_eq_gpowers (a : α) : powers a = gpowers a :=
set.ext (λ x, ⟨λ ⟨n, hn⟩, ⟨n, by simp * at *⟩,
λ ⟨i, hi⟩, ⟨(i % order_of a).nat_abs,
by rwa [← gpow_coe_nat, int.nat_abs_of_nonneg (int.mod_nonneg _
(int.coe_nat_ne_zero_iff_pos.2 (order_of_pos _))), ← gpow_eq_mod_order_of]⟩⟩)
end
end order_of
section cyclic
local attribute [instance] set_fintype
class is_cyclic (α : Type*) [group α] : Prop :=
(exists_generator : ∃ g : α, ∀ x, x ∈ gpowers g)
lemma is_cyclic_of_order_of_eq_card [group α] [fintype α] [decidable_eq α]
(x : α) (hx : order_of x = fintype.card α) : is_cyclic α :=
⟨⟨x, set.eq_univ_iff_forall.1 $ set.eq_of_subset_of_card_le
(set.subset_univ _)
(by rw [fintype.card_congr (equiv.set.univ α), ← hx, order_eq_card_gpowers])⟩⟩
lemma order_of_eq_card_of_forall_mem_gppowers [group α] [fintype α] [decidable_eq α]
{g : α} (hx : ∀ x, x ∈ gpowers g) : order_of g = fintype.card α :=
by rw [← fintype.card_congr (equiv.set.univ α), order_eq_card_gpowers];
simp [hx]; congr
instance [group α] : is_cyclic (is_subgroup.trivial α) :=
⟨⟨(1 : is_subgroup.trivial α), λ x, ⟨0, subtype.eq $ eq.symm (is_subgroup.mem_trivial.1 x.2)⟩⟩⟩
instance is_subgroup.is_cyclic [group α] [is_cyclic α] (H : set α) [is_subgroup H] : is_cyclic H :=
by haveI := classical.prop_decidable; exact
let ⟨g, hg⟩ := is_cyclic.exists_generator α in
if hx : ∃ (x : α), x ∈ H ∧ x ≠ (1 : α) then
let ⟨x, hx₁, hx₂⟩ := hx in
let ⟨k, hk⟩ := hg x in
have hex : ∃ n : ℕ, 0 < n ∧ g ^ n ∈ H,
from ⟨k.nat_abs, nat.pos_of_ne_zero
(λ h, hx₂ $ by rw [← hk, int.eq_zero_of_nat_abs_eq_zero h, gpow_zero]),
match k, hk with
| (k : ℕ), hk := by rw [int.nat_abs_of_nat, ← gpow_coe_nat, hk]; exact hx₁
| -[1+ k], hk := by rw [int.nat_abs_of_neg_succ_of_nat,
← is_subgroup.inv_mem_iff H]; simp * at *
end⟩,
⟨⟨⟨g ^ nat.find hex, (nat.find_spec hex).2⟩,
λ ⟨x, hx⟩, let ⟨k, hk⟩ := hg x in
have hk₁ : g ^ ((nat.find hex : ℤ) * (k / nat.find hex)) ∈ gpowers (g ^ nat.find hex),
from ⟨k / nat.find hex, eq.symm $ gpow_mul _ _ _⟩,
have hk₂ : g ^ ((nat.find hex : ℤ) * (k / nat.find hex)) ∈ H,
by rw gpow_mul; exact is_subgroup.gpow_mem (nat.find_spec hex).2,
have hk₃ : g ^ (k % nat.find hex) ∈ H,
from (is_subgroup.mul_mem_cancel_left H hk₂).1 $
by rw [← gpow_add, int.mod_add_div, hk]; exact hx,
have hk₄ : k % nat.find hex = (k % nat.find hex).nat_abs,
by rw int.nat_abs_of_nonneg (int.mod_nonneg _
(int.coe_nat_ne_zero_iff_pos.2 (nat.find_spec hex).1)),
have hk₅ : g ^ (k % nat.find hex ).nat_abs ∈ H,
by rwa [← gpow_coe_nat, ← hk₄],
have hk₆ : (k % (nat.find hex : ℤ)).nat_abs = 0,
from by_contradiction (λ h,
nat.find_min hex (int.coe_nat_lt.1 $ by rw [← hk₄];
exact int.mod_lt_of_pos _ (int.coe_nat_pos.2 (nat.find_spec hex).1))
⟨nat.pos_of_ne_zero h, hk₅⟩),
⟨k / (nat.find hex : ℤ), subtype.coe_ext.2 begin
suffices : g ^ ((nat.find hex : ℤ) * (k / nat.find hex)) = x,
{ simpa [gpow_mul] },
rw [int.mul_div_cancel' (int.dvd_of_mod_eq_zero (int.eq_zero_of_nat_abs_eq_zero hk₆)), hk]
end⟩⟩⟩
else
have H = is_subgroup.trivial α,
from set.ext $ λ x, ⟨λ h, by simp at *; tauto,
λ h, by rw [is_subgroup.mem_trivial.1 h]; exact is_submonoid.one_mem _⟩,
by clear _let_match; subst this; apply_instance
end cyclic |
d74f6d5ebf994f560d8b785b38202991d66f66cf | fa02ed5a3c9c0adee3c26887a16855e7841c668b | /src/category_theory/monoidal/of_chosen_finite_products.lean | 5a9b0c48a66886025d717c9e3e231804bbacfd0a | [
"Apache-2.0"
] | permissive | jjgarzella/mathlib | 96a345378c4e0bf26cf604aed84f90329e4896a2 | 395d8716c3ad03747059d482090e2bb97db612c8 | refs/heads/master | 1,686,480,124,379 | 1,625,163,323,000 | 1,625,163,323,000 | 281,190,421 | 2 | 0 | Apache-2.0 | 1,595,268,170,000 | 1,595,268,169,000 | null | UTF-8 | Lean | false | false | 15,905 | lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Simon Hudon
-/
import category_theory.monoidal.braided
import category_theory.limits.shapes.binary_products
import category_theory.limits.shapes.terminal
import category_theory.pempty
/-!
# The monoidal structure on a category with chosen finite products.
This is a variant of the development in `category_theory.monoidal.of_has_finite_products`,
which uses specified choices of the terminal object and binary product,
enabling the construction of a cartesian category with specific definitions of the tensor unit
and tensor product.
(Because the construction in `category_theory.monoidal.of_has_finite_products` uses `has_limit`
classes, the actual definitions there are opaque behind `classical.choice`.)
We use this in `category_theory.monoidal.types` to construct the monoidal category of types
so that the tensor product is the usual cartesian product of types.
For now we only do the construction from products, and not from coproducts,
which seems less often useful.
-/
universes v u
noncomputable theory
namespace category_theory
variables (C : Type u) [category.{v} C] {X Y : C}
namespace limits
section
variables {C}
/-- Swap the two sides of a `binary_fan`. -/
def binary_fan.swap {P Q : C} (t : binary_fan P Q) : binary_fan Q P :=
binary_fan.mk t.snd t.fst
@[simp] lemma binary_fan.swap_fst {P Q : C} (t : binary_fan P Q) : t.swap.fst = t.snd := rfl
@[simp] lemma binary_fan.swap_snd {P Q : C} (t : binary_fan P Q) : t.swap.snd = t.fst := rfl
/--
If a cone `t` over `P Q` is a limit cone, then `t.swap` is a limit cone over `Q P`.
-/
@[simps]
def is_limit.swap_binary_fan {P Q : C} {t : binary_fan P Q} (I : is_limit t) : is_limit t.swap :=
{ lift := λ s, I.lift (binary_fan.swap s),
fac' := λ s, by { rintro ⟨⟩; simp, },
uniq' := λ s m w,
begin
have h := I.uniq (binary_fan.swap s) m,
rw h,
intro j,
specialize w j.swap,
cases j; exact w,
end }
/--
Construct `has_binary_product Q P` from `has_binary_product P Q`.
This can't be an instance, as it would cause a loop in typeclass search.
-/
lemma has_binary_product.swap (P Q : C) [has_binary_product P Q] : has_binary_product Q P :=
has_limit.mk ⟨binary_fan.swap (limit.cone (pair P Q)), (limit.is_limit (pair P Q)).swap_binary_fan⟩
/--
Given a limit cone over `X` and `Y`, and another limit cone over `Y` and `X`, we can construct
an isomorphism between the cone points. Relative to some fixed choice of limits cones for every
pair, these isomorphisms constitute a braiding.
-/
def binary_fan.braiding {X Y : C}
{s : binary_fan X Y} (P : is_limit s) {t : binary_fan Y X} (Q : is_limit t) :
s.X ≅ t.X :=
is_limit.cone_point_unique_up_to_iso P Q.swap_binary_fan
/--
Given binary fans `sXY` over `X Y`, and `sYZ` over `Y Z`, and `s` over `sXY.X Z`,
if `sYZ` is a limit cone we can construct a binary fan over `X sYZ.X`.
This is an ingredient of building the associator for a cartesian category.
-/
def binary_fan.assoc {X Y Z : C}
{sXY : binary_fan X Y} {sYZ : binary_fan Y Z} (Q : is_limit sYZ) (s : binary_fan sXY.X Z) :
binary_fan X sYZ.X :=
binary_fan.mk (s.fst ≫ sXY.fst) (Q.lift (binary_fan.mk (s.fst ≫ sXY.snd) s.snd))
@[simp] lemma binary_fan.assoc_fst {X Y Z : C}
{sXY : binary_fan X Y} {sYZ : binary_fan Y Z} (Q : is_limit sYZ) (s : binary_fan sXY.X Z) :
(s.assoc Q).fst = s.fst ≫ sXY.fst := rfl
@[simp] lemma binary_fan.assoc_snd {X Y Z : C}
{sXY : binary_fan X Y} {sYZ : binary_fan Y Z} (Q : is_limit sYZ) (s : binary_fan sXY.X Z) :
(s.assoc Q).snd = Q.lift (binary_fan.mk (s.fst ≫ sXY.snd) s.snd) := rfl
/--
Given binary fans `sXY` over `X Y`, and `sYZ` over `Y Z`, and `s` over `X sYZ.X`,
if `sYZ` is a limit cone we can construct a binary fan over `sXY.X Z`.
This is an ingredient of building the associator for a cartesian category.
-/
def binary_fan.assoc_inv {X Y Z : C}
{sXY : binary_fan X Y} (P : is_limit sXY) {sYZ : binary_fan Y Z} (s : binary_fan X sYZ.X) :
binary_fan sXY.X Z :=
binary_fan.mk (P.lift (binary_fan.mk s.fst (s.snd ≫ sYZ.fst))) (s.snd ≫ sYZ.snd)
@[simp] lemma binary_fan.assoc_inv_fst {X Y Z : C}
{sXY : binary_fan X Y} (P : is_limit sXY) {sYZ : binary_fan Y Z} (s : binary_fan X sYZ.X) :
(s.assoc_inv P).fst = P.lift (binary_fan.mk s.fst (s.snd ≫ sYZ.fst)) := rfl
@[simp] lemma binary_fan.assoc_inv_snd {X Y Z : C}
{sXY : binary_fan X Y} (P : is_limit sXY) {sYZ : binary_fan Y Z} (s : binary_fan X sYZ.X) :
(s.assoc_inv P).snd = s.snd ≫ sYZ.snd := rfl
/--
If all the binary fans involved a limit cones, `binary_fan.assoc` produces another limit cone.
-/
@[simps]
def is_limit.assoc {X Y Z : C}
{sXY : binary_fan X Y} (P : is_limit sXY) {sYZ : binary_fan Y Z} (Q : is_limit sYZ)
{s : binary_fan sXY.X Z} (R : is_limit s) : is_limit (s.assoc Q) :=
{ lift := λ t, R.lift (binary_fan.assoc_inv P t),
fac' := λ t,
begin
rintro ⟨⟩; simp,
apply Q.hom_ext,
rintro ⟨⟩; simp,
end,
uniq' := λ t m w,
begin
have h := R.uniq (binary_fan.assoc_inv P t) m,
rw h,
rintro ⟨⟩; simp,
apply P.hom_ext,
rintro ⟨⟩; simp,
{ exact w walking_pair.left, },
{ specialize w walking_pair.right,
simp at w,
rw [←w], simp, },
{ specialize w walking_pair.right,
simp at w,
rw [←w], simp, },
end, }
/--
Given two pairs of limit cones corresponding to the parenthesisations of `X × Y × Z`,
we obtain an isomorphism between the cone points.
-/
@[reducible]
def binary_fan.associator {X Y Z : C}
{sXY : binary_fan X Y} (P : is_limit sXY) {sYZ : binary_fan Y Z} (Q : is_limit sYZ)
{s : binary_fan sXY.X Z} (R : is_limit s) {t : binary_fan X sYZ.X} (S : is_limit t) :
s.X ≅ t.X :=
is_limit.cone_point_unique_up_to_iso (is_limit.assoc P Q R) S
/--
Given a fixed family of limit data for every pair `X Y`, we obtain an associator.
-/
@[reducible]
def binary_fan.associator_of_limit_cone
(L : Π X Y : C, limit_cone (pair X Y)) (X Y Z : C) :
(L (L X Y).cone.X Z).cone.X ≅ (L X (L Y Z).cone.X).cone.X :=
binary_fan.associator
(L X Y).is_limit (L Y Z).is_limit
(L (L X Y).cone.X Z).is_limit (L X (L Y Z).cone.X).is_limit
/--
Construct a left unitor from specified limit cones.
-/
@[simps]
def binary_fan.left_unitor
{X : C} {s : cone (functor.empty C)} (P : is_limit s) {t : binary_fan s.X X} (Q : is_limit t) :
t.X ≅ X :=
{ hom := t.snd,
inv := Q.lift (binary_fan.mk (P.lift { X := X, π := { app := pempty.rec _ } }) (𝟙 X) ),
hom_inv_id' := by { apply Q.hom_ext, rintro ⟨⟩, { apply P.hom_ext, rintro ⟨⟩, }, { simp, }, }, }
/--
Construct a right unitor from specified limit cones.
-/
@[simps]
def binary_fan.right_unitor
{X : C} {s : cone (functor.empty C)} (P : is_limit s) {t : binary_fan X s.X} (Q : is_limit t) :
t.X ≅ X :=
{ hom := t.fst,
inv := Q.lift (binary_fan.mk (𝟙 X) (P.lift { X := X, π := { app := pempty.rec _ } })),
hom_inv_id' := by { apply Q.hom_ext, rintro ⟨⟩, { simp, }, { apply P.hom_ext, rintro ⟨⟩, }, }, }
end
end limits
open category_theory.limits
section
local attribute [tidy] tactic.case_bash
variables {C}
variables (𝒯 : limit_cone (functor.empty C))
variables (ℬ : Π (X Y : C), limit_cone (pair X Y))
namespace monoidal_of_chosen_finite_products
/-- Implementation of the tensor product for `monoidal_of_chosen_finite_products`. -/
@[reducible]
def tensor_obj (X Y : C) : C := (ℬ X Y).cone.X
/-- Implementation of the tensor product of morphisms for `monoidal_of_chosen_finite_products`. -/
@[reducible]
def tensor_hom {W X Y Z : C} (f : W ⟶ X) (g : Y ⟶ Z) : tensor_obj ℬ W Y ⟶ tensor_obj ℬ X Z :=
(binary_fan.is_limit.lift' (ℬ X Z).is_limit
((ℬ W Y).cone.π.app walking_pair.left ≫ f)
(((ℬ W Y).cone.π.app walking_pair.right : (ℬ W Y).cone.X ⟶ Y) ≫ g)).val
lemma tensor_id (X₁ X₂ : C) : tensor_hom ℬ (𝟙 X₁) (𝟙 X₂) = 𝟙 (tensor_obj ℬ X₁ X₂) :=
begin
apply is_limit.hom_ext (ℬ _ _).is_limit, rintro ⟨⟩;
{ dsimp [tensor_hom], simp, },
end
lemma tensor_comp {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : C}
(f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) :
tensor_hom ℬ (f₁ ≫ g₁) (f₂ ≫ g₂) =
tensor_hom ℬ f₁ f₂ ≫ tensor_hom ℬ g₁ g₂ :=
begin
apply is_limit.hom_ext (ℬ _ _).is_limit, rintro ⟨⟩;
{ dsimp [tensor_hom], simp, },
end
lemma pentagon (W X Y Z : C) :
tensor_hom ℬ (binary_fan.associator_of_limit_cone ℬ W X Y).hom (𝟙 Z) ≫
(binary_fan.associator_of_limit_cone ℬ W (tensor_obj ℬ X Y) Z).hom ≫
tensor_hom ℬ (𝟙 W) (binary_fan.associator_of_limit_cone ℬ X Y Z).hom =
(binary_fan.associator_of_limit_cone ℬ (tensor_obj ℬ W X) Y Z).hom ≫
(binary_fan.associator_of_limit_cone ℬ W X (tensor_obj ℬ Y Z)).hom :=
begin
dsimp [tensor_hom],
apply is_limit.hom_ext (ℬ _ _).is_limit, rintro ⟨⟩,
{ simp, },
{ apply is_limit.hom_ext (ℬ _ _).is_limit, rintro ⟨⟩,
{ simp, },
apply is_limit.hom_ext (ℬ _ _).is_limit, rintro ⟨⟩,
{ simp, },
{ simp, }, }
end
lemma triangle (X Y : C) :
(binary_fan.associator_of_limit_cone ℬ X 𝒯.cone.X Y).hom ≫
tensor_hom ℬ (𝟙 X) (binary_fan.left_unitor 𝒯.is_limit (ℬ 𝒯.cone.X Y).is_limit).hom =
tensor_hom ℬ (binary_fan.right_unitor 𝒯.is_limit (ℬ X 𝒯.cone.X).is_limit).hom (𝟙 Y) :=
begin
dsimp [tensor_hom],
apply is_limit.hom_ext (ℬ _ _).is_limit, rintro ⟨⟩; simp,
end
lemma left_unitor_naturality {X₁ X₂ : C} (f : X₁ ⟶ X₂) :
tensor_hom ℬ (𝟙 𝒯.cone.X) f ≫ (binary_fan.left_unitor 𝒯.is_limit (ℬ 𝒯.cone.X X₂).is_limit).hom =
(binary_fan.left_unitor 𝒯.is_limit (ℬ 𝒯.cone.X X₁).is_limit).hom ≫ f :=
begin
dsimp [tensor_hom],
simp,
end
lemma right_unitor_naturality {X₁ X₂ : C} (f : X₁ ⟶ X₂) :
tensor_hom ℬ f (𝟙 𝒯.cone.X) ≫
(binary_fan.right_unitor 𝒯.is_limit (ℬ X₂ 𝒯.cone.X).is_limit).hom =
(binary_fan.right_unitor 𝒯.is_limit (ℬ X₁ 𝒯.cone.X).is_limit).hom ≫ f :=
begin
dsimp [tensor_hom],
simp,
end
lemma associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (f₃ : X₃ ⟶ Y₃) :
tensor_hom ℬ (tensor_hom ℬ f₁ f₂) f₃ ≫ (binary_fan.associator_of_limit_cone ℬ Y₁ Y₂ Y₃).hom =
(binary_fan.associator_of_limit_cone ℬ X₁ X₂ X₃).hom ≫
tensor_hom ℬ f₁ (tensor_hom ℬ f₂ f₃) :=
begin
dsimp [tensor_hom],
apply is_limit.hom_ext (ℬ _ _).is_limit, rintro ⟨⟩,
{ simp, },
{ apply is_limit.hom_ext (ℬ _ _).is_limit, rintro ⟨⟩,
{ simp, },
{ simp, }, },
end
end monoidal_of_chosen_finite_products
open monoidal_of_chosen_finite_products
/-- A category with a terminal object and binary products has a natural monoidal structure. -/
def monoidal_of_chosen_finite_products :
monoidal_category C :=
{ tensor_unit := 𝒯.cone.X,
tensor_obj := λ X Y, tensor_obj ℬ X Y,
tensor_hom := λ _ _ _ _ f g, tensor_hom ℬ f g,
tensor_id' := tensor_id ℬ,
tensor_comp' := λ _ _ _ _ _ _ f₁ f₂ g₁ g₂, tensor_comp ℬ f₁ f₂ g₁ g₂,
associator := λ X Y Z, binary_fan.associator_of_limit_cone ℬ X Y Z,
left_unitor := λ X, binary_fan.left_unitor (𝒯.is_limit) (ℬ 𝒯.cone.X X).is_limit,
right_unitor := λ X, binary_fan.right_unitor (𝒯.is_limit) (ℬ X 𝒯.cone.X).is_limit,
pentagon' := pentagon ℬ,
triangle' := triangle 𝒯 ℬ,
left_unitor_naturality' := λ _ _ f, left_unitor_naturality 𝒯 ℬ f,
right_unitor_naturality' := λ _ _ f, right_unitor_naturality 𝒯 ℬ f,
associator_naturality' := λ _ _ _ _ _ _ f₁ f₂ f₃, associator_naturality ℬ f₁ f₂ f₃, }
namespace monoidal_of_chosen_finite_products
open monoidal_category
/--
A type synonym for `C` carrying a monoidal category structure corresponding to
a fixed choice of limit data for the empty functor, and for `pair X Y` for every `X Y : C`.
This is an implementation detail for `symmetric_of_chosen_finite_products`.
-/
@[derive category, nolint unused_arguments has_inhabited_instance]
def monoidal_of_chosen_finite_products_synonym
(𝒯 : limit_cone (functor.empty C)) (ℬ : Π (X Y : C), limit_cone (pair X Y)):= C
instance : monoidal_category (monoidal_of_chosen_finite_products_synonym 𝒯 ℬ) :=
monoidal_of_chosen_finite_products 𝒯 ℬ
lemma braiding_naturality {X X' Y Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') :
(tensor_hom ℬ f g) ≫ (limits.binary_fan.braiding (ℬ Y Y').is_limit (ℬ Y' Y).is_limit).hom =
(limits.binary_fan.braiding (ℬ X X').is_limit (ℬ X' X).is_limit).hom ≫ (tensor_hom ℬ g f) :=
begin
dsimp [tensor_hom, limits.binary_fan.braiding],
apply (ℬ _ _).is_limit.hom_ext, rintro ⟨⟩;
{ dsimp [limits.is_limit.cone_point_unique_up_to_iso], simp, },
end
lemma hexagon_forward (X Y Z : C) :
(binary_fan.associator_of_limit_cone ℬ X Y Z).hom ≫
(limits.binary_fan.braiding
(ℬ X (tensor_obj ℬ Y Z)).is_limit
(ℬ (tensor_obj ℬ Y Z) X).is_limit).hom ≫
(binary_fan.associator_of_limit_cone ℬ Y Z X).hom =
(tensor_hom ℬ (limits.binary_fan.braiding (ℬ X Y).is_limit (ℬ Y X).is_limit).hom (𝟙 Z)) ≫
(binary_fan.associator_of_limit_cone ℬ Y X Z).hom ≫
(tensor_hom ℬ (𝟙 Y) (limits.binary_fan.braiding (ℬ X Z).is_limit (ℬ Z X).is_limit).hom) :=
begin
dsimp [tensor_hom, limits.binary_fan.braiding],
apply (ℬ _ _).is_limit.hom_ext, rintro ⟨⟩,
{ dsimp [limits.is_limit.cone_point_unique_up_to_iso], simp, },
{ apply (ℬ _ _).is_limit.hom_ext, rintro ⟨⟩;
{ dsimp [limits.is_limit.cone_point_unique_up_to_iso], simp, }, }
end
lemma hexagon_reverse (X Y Z : C) :
(binary_fan.associator_of_limit_cone ℬ X Y Z).inv ≫
(limits.binary_fan.braiding
(ℬ (tensor_obj ℬ X Y) Z).is_limit
(ℬ Z (tensor_obj ℬ X Y)).is_limit).hom ≫
(binary_fan.associator_of_limit_cone ℬ Z X Y).inv =
(tensor_hom ℬ (𝟙 X) (limits.binary_fan.braiding (ℬ Y Z).is_limit (ℬ Z Y).is_limit).hom) ≫
(binary_fan.associator_of_limit_cone ℬ X Z Y).inv ≫
(tensor_hom ℬ (limits.binary_fan.braiding (ℬ X Z).is_limit (ℬ Z X).is_limit).hom (𝟙 Y)) :=
begin
dsimp [tensor_hom, limits.binary_fan.braiding],
apply (ℬ _ _).is_limit.hom_ext, rintro ⟨⟩,
{ apply (ℬ _ _).is_limit.hom_ext, rintro ⟨⟩;
{ dsimp [binary_fan.associator_of_limit_cone, binary_fan.associator,
limits.is_limit.cone_point_unique_up_to_iso],
simp, }, },
{ dsimp [binary_fan.associator_of_limit_cone, binary_fan.associator,
limits.is_limit.cone_point_unique_up_to_iso],
simp, },
end
lemma symmetry (X Y : C) :
(limits.binary_fan.braiding (ℬ X Y).is_limit (ℬ Y X).is_limit).hom ≫
(limits.binary_fan.braiding (ℬ Y X).is_limit (ℬ X Y).is_limit).hom =
𝟙 (tensor_obj ℬ X Y) :=
begin
dsimp [tensor_hom, limits.binary_fan.braiding],
apply (ℬ _ _).is_limit.hom_ext, rintro ⟨⟩;
{ dsimp [limits.is_limit.cone_point_unique_up_to_iso], simp, },
end
end monoidal_of_chosen_finite_products
open monoidal_of_chosen_finite_products
/--
The monoidal structure coming from finite products is symmetric.
-/
def symmetric_of_chosen_finite_products :
symmetric_category (monoidal_of_chosen_finite_products_synonym 𝒯 ℬ) :=
{ braiding := λ X Y, limits.binary_fan.braiding (ℬ _ _).is_limit (ℬ _ _).is_limit,
braiding_naturality' := λ X X' Y Y' f g, braiding_naturality ℬ f g,
hexagon_forward' := λ X Y Z, hexagon_forward ℬ X Y Z,
hexagon_reverse' := λ X Y Z, hexagon_reverse ℬ X Y Z,
symmetry' := λ X Y, symmetry ℬ X Y, }
end
end category_theory
|
fd5c667f9df9877b893c32995edbad197280c952 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/topology/separation.lean | a5bc09e356b2f04219fcb764e1b03ae3fa4cb3ae | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 93,002 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import topology.subset_properties
import topology.connected
import topology.nhds_set
import topology.inseparable
/-!
# Separation properties of topological spaces.
This file defines the predicate `separated_nhds`, and common separation axioms
(under the Kolmogorov classification).
## Main definitions
* `separated_nhds`: Two `set`s are separated by neighbourhoods if they are contained in disjoint
open sets.
* `t0_space`: A T₀/Kolmogorov space is a space where, for every two points `x ≠ y`,
there is an open set that contains one, but not the other.
* `t1_space`: A T₁/Fréchet space is a space where every singleton set is closed.
This is equivalent to, for every pair `x ≠ y`, there existing an open set containing `x`
but not `y` (`t1_space_iff_exists_open` shows that these conditions are equivalent.)
* `t2_space`: A T₂/Hausdorff space is a space where, for every two points `x ≠ y`,
there is two disjoint open sets, one containing `x`, and the other `y`.
* `t2_5_space`: A T₂.₅/Urysohn space is a space where, for every two points `x ≠ y`,
there is two open sets, one containing `x`, and the other `y`, whose closures are disjoint.
* `t3_space`: A T₃ space, is one where given any closed `C` and `x ∉ C`,
there is disjoint open sets containing `x` and `C` respectively. In `mathlib`, T₃ implies T₂.₅.
* `normal_space`: A T₄ space (sometimes referred to as normal, but authors vary on
whether this includes T₂; `mathlib` does), is one where given two disjoint closed sets,
we can find two open sets that separate them. In `mathlib`, T₄ implies T₃.
* `t5_space`: A T₅ space, also known as a *completely normal Hausdorff space*
## Main results
### T₀ spaces
* `is_closed.exists_closed_singleton` Given a closed set `S` in a compact T₀ space,
there is some `x ∈ S` such that `{x}` is closed.
* `exists_open_singleton_of_open_finset` Given an open `finset` `S` in a T₀ space,
there is some `x ∈ S` such that `{x}` is open.
### T₁ spaces
* `is_closed_map_const`: The constant map is a closed map.
* `discrete_of_t1_of_finite`: A finite T₁ space must have the discrete topology.
### T₂ spaces
* `t2_iff_nhds`: A space is T₂ iff the neighbourhoods of distinct points generate the bottom filter.
* `t2_iff_is_closed_diagonal`: A space is T₂ iff the `diagonal` of `α` (that is, the set of all
points of the form `(a, a) : α × α`) is closed under the product topology.
* `finset_disjoint_finset_opens_of_t2`: Any two disjoint finsets are `separated_nhds`.
* Most topological constructions preserve Hausdorffness;
these results are part of the typeclass inference system (e.g. `embedding.t2_space`)
* `set.eq_on.closure`: If two functions are equal on some set `s`, they are equal on its closure.
* `is_compact.is_closed`: All compact sets are closed.
* `locally_compact_of_compact_nhds`: If every point has a compact neighbourhood,
then the space is locally compact.
* `totally_separated_space_of_t1_of_basis_clopen`: If `α` has a clopen basis, then
it is a `totally_separated_space`.
* `loc_compact_t2_tot_disc_iff_tot_sep`: A locally compact T₂ space is totally disconnected iff
it is totally separated.
If the space is also compact:
* `normal_of_compact_t2`: A compact T₂ space is a `normal_space`.
* `connected_components_eq_Inter_clopen`: The connected component of a point
is the intersection of all its clopen neighbourhoods.
* `compact_t2_tot_disc_iff_tot_sep`: Being a `totally_disconnected_space`
is equivalent to being a `totally_separated_space`.
* `connected_components.t2`: `connected_components α` is T₂ for `α` T₂ and compact.
### T₃ spaces
* `disjoint_nested_nhds`: Given two points `x ≠ y`, we can find neighbourhoods `x ∈ V₁ ⊆ U₁` and
`y ∈ V₂ ⊆ U₂`, with the `Vₖ` closed and the `Uₖ` open, such that the `Uₖ` are disjoint.
## References
https://en.wikipedia.org/wiki/Separation_axiom
-/
open function set filter topological_space
open_locale topological_space filter classical
universes u v
variables {α : Type u} {β : Type v} [topological_space α]
section separation
/--
`separated_nhds` is a predicate on pairs of sub`set`s of a topological space. It holds if the two
sub`set`s are contained in disjoint open sets.
-/
def separated_nhds : set α → set α → Prop :=
λ (s t : set α), ∃ U V : (set α), (is_open U) ∧ is_open V ∧
(s ⊆ U) ∧ (t ⊆ V) ∧ disjoint U V
lemma separated_nhds_iff_disjoint {s t : set α} :
separated_nhds s t ↔ disjoint (𝓝ˢ s) (𝓝ˢ t) :=
by simp only [(has_basis_nhds_set s).disjoint_iff (has_basis_nhds_set t), separated_nhds,
exists_prop, ← exists_and_distrib_left, and.assoc, and.comm, and.left_comm]
namespace separated_nhds
variables {s s₁ s₂ t t₁ t₂ u : set α}
@[symm] lemma symm : separated_nhds s t → separated_nhds t s :=
λ ⟨U, V, oU, oV, aU, bV, UV⟩, ⟨V, U, oV, oU, bV, aU, disjoint.symm UV⟩
lemma comm (s t : set α) : separated_nhds s t ↔ separated_nhds t s := ⟨symm, symm⟩
lemma preimage [topological_space β] {f : α → β} {s t : set β} (h : separated_nhds s t)
(hf : continuous f) : separated_nhds (f ⁻¹' s) (f ⁻¹' t) :=
let ⟨U, V, oU, oV, sU, tV, UV⟩ := h in
⟨f ⁻¹' U, f ⁻¹' V, oU.preimage hf, oV.preimage hf, preimage_mono sU, preimage_mono tV,
UV.preimage f⟩
protected lemma disjoint (h : separated_nhds s t) : disjoint s t :=
let ⟨U, V, hU, hV, hsU, htV, hd⟩ := h in hd.mono hsU htV
lemma disjoint_closure_left (h : separated_nhds s t) : disjoint (closure s) t :=
let ⟨U, V, hU, hV, hsU, htV, hd⟩ := h
in (hd.closure_left hV).mono (closure_mono hsU) htV
lemma disjoint_closure_right (h : separated_nhds s t) : disjoint s (closure t) :=
h.symm.disjoint_closure_left.symm
lemma empty_right (s : set α) : separated_nhds s ∅ :=
⟨_, _, is_open_univ, is_open_empty, λ a h, mem_univ a, λ a h, by cases h, disjoint_empty _⟩
lemma empty_left (s : set α) : separated_nhds ∅ s :=
(empty_right _).symm
lemma mono (h : separated_nhds s₂ t₂) (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : separated_nhds s₁ t₁ :=
let ⟨U, V, hU, hV, hsU, htV, hd⟩ := h in ⟨U, V, hU, hV, hs.trans hsU, ht.trans htV, hd⟩
lemma union_left : separated_nhds s u → separated_nhds t u → separated_nhds (s ∪ t) u :=
by simpa only [separated_nhds_iff_disjoint, nhds_set_union, disjoint_sup_left] using and.intro
lemma union_right (ht : separated_nhds s t) (hu : separated_nhds s u) :
separated_nhds s (t ∪ u) :=
(ht.symm.union_left hu.symm).symm
end separated_nhds
/-- A T₀ space, also known as a Kolmogorov space, is a topological space such that for every pair
`x ≠ y`, there is an open set containing one but not the other. We formulate the definition in terms
of the `inseparable` relation. -/
class t0_space (α : Type u) [topological_space α] : Prop :=
(t0 : ∀ ⦃x y : α⦄, inseparable x y → x = y)
lemma t0_space_iff_inseparable (α : Type u) [topological_space α] :
t0_space α ↔ ∀ (x y : α), inseparable x y → x = y :=
⟨λ ⟨h⟩, h, λ h, ⟨h⟩⟩
lemma t0_space_iff_not_inseparable (α : Type u) [topological_space α] :
t0_space α ↔ ∀ (x y : α), x ≠ y → ¬inseparable x y :=
by simp only [t0_space_iff_inseparable, ne.def, not_imp_not]
lemma inseparable.eq [t0_space α] {x y : α} (h : inseparable x y) : x = y :=
t0_space.t0 h
lemma t0_space_iff_nhds_injective (α : Type u) [topological_space α] :
t0_space α ↔ injective (𝓝 : α → filter α) :=
t0_space_iff_inseparable α
lemma nhds_injective [t0_space α] : injective (𝓝 : α → filter α) :=
(t0_space_iff_nhds_injective α).1 ‹_›
lemma inseparable_iff_eq [t0_space α] {x y : α} : inseparable x y ↔ x = y :=
nhds_injective.eq_iff
@[simp] lemma nhds_eq_nhds_iff [t0_space α] {a b : α} : 𝓝 a = 𝓝 b ↔ a = b :=
nhds_injective.eq_iff
@[simp] lemma inseparable_eq_eq [t0_space α] : inseparable = @eq α :=
funext₂ $ λ x y, propext inseparable_iff_eq
lemma t0_space_iff_exists_is_open_xor_mem (α : Type u) [topological_space α] :
t0_space α ↔ ∀ x y, x ≠ y → ∃ U:set α, is_open U ∧ (xor (x ∈ U) (y ∈ U)) :=
by simp only [t0_space_iff_not_inseparable, xor_iff_not_iff, not_forall, exists_prop,
inseparable_iff_forall_open]
lemma exists_is_open_xor_mem [t0_space α] {x y : α} (h : x ≠ y) :
∃ U : set α, is_open U ∧ xor (x ∈ U) (y ∈ U) :=
(t0_space_iff_exists_is_open_xor_mem α).1 ‹_› x y h
/-- Specialization forms a partial order on a t0 topological space. -/
def specialization_order (α : Type*) [topological_space α] [t0_space α] : partial_order α :=
{ .. specialization_preorder α,
.. partial_order.lift (order_dual.to_dual ∘ 𝓝) nhds_injective }
instance : t0_space (separation_quotient α) :=
⟨λ x' y', quotient.induction_on₂' x' y' $
λ x y h, separation_quotient.mk_eq_mk.2 $ separation_quotient.inducing_mk.inseparable_iff.1 h⟩
theorem minimal_nonempty_closed_subsingleton [t0_space α] {s : set α} (hs : is_closed s)
(hmin : ∀ t ⊆ s, t.nonempty → is_closed t → t = s) :
s.subsingleton :=
begin
refine λ x hx y hy, of_not_not (λ hxy, _),
rcases exists_is_open_xor_mem hxy with ⟨U, hUo, hU⟩,
wlog h : x ∈ U ∧ y ∉ U := hU using [x y, y x], cases h with hxU hyU,
have : s \ U = s := hmin (s \ U) (diff_subset _ _) ⟨y, hy, hyU⟩ (hs.sdiff hUo),
exact (this.symm.subset hx).2 hxU
end
theorem minimal_nonempty_closed_eq_singleton [t0_space α] {s : set α} (hs : is_closed s)
(hne : s.nonempty) (hmin : ∀ t ⊆ s, t.nonempty → is_closed t → t = s) :
∃ x, s = {x} :=
exists_eq_singleton_iff_nonempty_subsingleton.2 ⟨hne, minimal_nonempty_closed_subsingleton hs hmin⟩
/-- Given a closed set `S` in a compact T₀ space,
there is some `x ∈ S` such that `{x}` is closed. -/
theorem is_closed.exists_closed_singleton {α : Type*} [topological_space α]
[t0_space α] [compact_space α] {S : set α} (hS : is_closed S) (hne : S.nonempty) :
∃ (x : α), x ∈ S ∧ is_closed ({x} : set α) :=
begin
obtain ⟨V, Vsub, Vne, Vcls, hV⟩ := hS.exists_minimal_nonempty_closed_subset hne,
rcases minimal_nonempty_closed_eq_singleton Vcls Vne hV with ⟨x, rfl⟩,
exact ⟨x, Vsub (mem_singleton x), Vcls⟩
end
theorem minimal_nonempty_open_subsingleton [t0_space α] {s : set α} (hs : is_open s)
(hmin : ∀ t ⊆ s, t.nonempty → is_open t → t = s) :
s.subsingleton :=
begin
refine λ x hx y hy, of_not_not (λ hxy, _),
rcases exists_is_open_xor_mem hxy with ⟨U, hUo, hU⟩,
wlog h : x ∈ U ∧ y ∉ U := hU using [x y, y x], cases h with hxU hyU,
have : s ∩ U = s := hmin (s ∩ U) (inter_subset_left _ _) ⟨x, hx, hxU⟩ (hs.inter hUo),
exact hyU (this.symm.subset hy).2
end
theorem minimal_nonempty_open_eq_singleton [t0_space α] {s : set α} (hs : is_open s)
(hne : s.nonempty) (hmin : ∀ t ⊆ s, t.nonempty → is_open t → t = s) :
∃ x, s = {x} :=
exists_eq_singleton_iff_nonempty_subsingleton.2 ⟨hne, minimal_nonempty_open_subsingleton hs hmin⟩
/-- Given an open finite set `S` in a T₀ space, there is some `x ∈ S` such that `{x}` is open. -/
theorem exists_open_singleton_of_open_finite [t0_space α] {s : set α} (hfin : s.finite)
(hne : s.nonempty) (ho : is_open s) :
∃ x ∈ s, is_open ({x} : set α) :=
begin
lift s to finset α using hfin,
induction s using finset.strong_induction_on with s ihs,
rcases em (∃ t ⊂ s, t.nonempty ∧ is_open (t : set α)) with ⟨t, hts, htne, hto⟩|ht,
{ rcases ihs t hts htne hto with ⟨x, hxt, hxo⟩,
exact ⟨x, hts.1 hxt, hxo⟩ },
{ rcases minimal_nonempty_open_eq_singleton ho hne _ with ⟨x, hx⟩,
{ exact ⟨x, hx.symm ▸ rfl, hx ▸ ho⟩ },
refine λ t hts htne hto, of_not_not (λ hts', ht _),
lift t to finset α using s.finite_to_set.subset hts,
exact ⟨t, ssubset_iff_subset_ne.2 ⟨hts, mt finset.coe_inj.2 hts'⟩, htne, hto⟩ }
end
theorem exists_open_singleton_of_fintype [t0_space α] [finite α] [nonempty α] :
∃ x : α, is_open ({x} : set α) :=
let ⟨x, _, h⟩ := exists_open_singleton_of_open_finite (set.to_finite _) univ_nonempty
is_open_univ in ⟨x, h⟩
lemma t0_space_of_injective_of_continuous [topological_space β] {f : α → β}
(hf : function.injective f) (hf' : continuous f) [t0_space β] : t0_space α :=
⟨λ x y h, hf $ (h.map hf').eq⟩
protected lemma embedding.t0_space [topological_space β] [t0_space β] {f : α → β}
(hf : embedding f) : t0_space α :=
t0_space_of_injective_of_continuous hf.inj hf.continuous
instance subtype.t0_space [t0_space α] {p : α → Prop} : t0_space (subtype p) :=
embedding_subtype_coe.t0_space
theorem t0_space_iff_or_not_mem_closure (α : Type u) [topological_space α] :
t0_space α ↔ (∀ a b : α, a ≠ b → (a ∉ closure ({b} : set α) ∨ b ∉ closure ({a} : set α))) :=
by simp only [t0_space_iff_not_inseparable, inseparable_iff_mem_closure, not_and_distrib]
instance [topological_space β] [t0_space α] [t0_space β] : t0_space (α × β) :=
⟨λ x y h, prod.ext (h.map continuous_fst).eq (h.map continuous_snd).eq⟩
instance {ι : Type*} {π : ι → Type*} [Π i, topological_space (π i)] [Π i, t0_space (π i)] :
t0_space (Π i, π i) :=
⟨λ x y h, funext $ λ i, (h.map (continuous_apply i)).eq⟩
lemma t0_space.of_cover (h : ∀ x y, inseparable x y → ∃ s : set α, x ∈ s ∧ y ∈ s ∧ t0_space s) :
t0_space α :=
begin
refine ⟨λ x y hxy, _⟩,
rcases h x y hxy with ⟨s, hxs, hys, hs⟩, resetI,
lift x to s using hxs, lift y to s using hys,
rw ← subtype_inseparable_iff at hxy,
exact congr_arg coe hxy.eq
end
lemma t0_space.of_open_cover (h : ∀ x, ∃ s : set α, x ∈ s ∧ is_open s ∧ t0_space s) : t0_space α :=
t0_space.of_cover $ λ x y hxy,
let ⟨s, hxs, hso, hs⟩ := h x in ⟨s, hxs, (hxy.mem_open_iff hso).1 hxs, hs⟩
/-- A T₁ space, also known as a Fréchet space, is a topological space
where every singleton set is closed. Equivalently, for every pair
`x ≠ y`, there is an open set containing `x` and not `y`. -/
class t1_space (α : Type u) [topological_space α] : Prop :=
(t1 : ∀x, is_closed ({x} : set α))
lemma is_closed_singleton [t1_space α] {x : α} : is_closed ({x} : set α) :=
t1_space.t1 x
lemma is_open_compl_singleton [t1_space α] {x : α} : is_open ({x}ᶜ : set α) :=
is_closed_singleton.is_open_compl
lemma is_open_ne [t1_space α] {x : α} : is_open {y | y ≠ x} :=
is_open_compl_singleton
@[to_additive]
lemma continuous.is_open_mul_support [t1_space α] [has_one α] [topological_space β]
{f : β → α} (hf : continuous f) : is_open (mul_support f) :=
is_open_ne.preimage hf
lemma ne.nhds_within_compl_singleton [t1_space α] {x y : α} (h : x ≠ y) :
𝓝[{y}ᶜ] x = 𝓝 x :=
is_open_ne.nhds_within_eq h
lemma ne.nhds_within_diff_singleton [t1_space α] {x y : α} (h : x ≠ y) (s : set α) :
𝓝[s \ {y}] x = 𝓝[s] x :=
begin
rw [diff_eq, inter_comm, nhds_within_inter_of_mem],
exact mem_nhds_within_of_mem_nhds (is_open_ne.mem_nhds h)
end
lemma is_open_set_of_eventually_nhds_within [t1_space α] {p : α → Prop} :
is_open {x | ∀ᶠ y in 𝓝[≠] x, p y} :=
begin
refine is_open_iff_mem_nhds.mpr (λ a ha, _),
filter_upwards [eventually_nhds_nhds_within.mpr ha] with b hb,
by_cases a = b,
{ subst h, exact hb },
{ rw (ne.symm h).nhds_within_compl_singleton at hb,
exact hb.filter_mono nhds_within_le_nhds }
end
protected lemma set.finite.is_closed [t1_space α] {s : set α} (hs : set.finite s) :
is_closed s :=
begin
rw ← bUnion_of_singleton s,
exact is_closed_bUnion hs (λ i hi, is_closed_singleton)
end
lemma topological_space.is_topological_basis.exists_mem_of_ne
[t1_space α] {b : set (set α)} (hb : is_topological_basis b) {x y : α} (h : x ≠ y) :
∃ a ∈ b, x ∈ a ∧ y ∉ a :=
begin
rcases hb.is_open_iff.1 is_open_ne x h with ⟨a, ab, xa, ha⟩,
exact ⟨a, ab, xa, λ h, ha h rfl⟩,
end
lemma filter.coclosed_compact_le_cofinite [t1_space α] :
filter.coclosed_compact α ≤ filter.cofinite :=
λ s hs, compl_compl s ▸ hs.is_compact.compl_mem_coclosed_compact_of_is_closed hs.is_closed
variable (α)
/-- In a `t1_space`, relatively compact sets form a bornology. Its cobounded filter is
`filter.coclosed_compact`. See also `bornology.in_compact` the bornology of sets contained
in a compact set. -/
def bornology.relatively_compact [t1_space α] : bornology α :=
{ cobounded := filter.coclosed_compact α,
le_cofinite := filter.coclosed_compact_le_cofinite }
variable {α}
lemma bornology.relatively_compact.is_bounded_iff [t1_space α] {s : set α} :
@bornology.is_bounded _ (bornology.relatively_compact α) s ↔ is_compact (closure s) :=
begin
change sᶜ ∈ filter.coclosed_compact α ↔ _,
rw filter.mem_coclosed_compact,
split,
{ rintros ⟨t, ht₁, ht₂, hst⟩,
rw compl_subset_compl at hst,
exact is_compact_of_is_closed_subset ht₂ is_closed_closure (closure_minimal hst ht₁) },
{ intros h,
exact ⟨closure s, is_closed_closure, h, compl_subset_compl.mpr subset_closure⟩ }
end
protected lemma finset.is_closed [t1_space α] (s : finset α) : is_closed (s : set α) :=
s.finite_to_set.is_closed
lemma t1_space_tfae (α : Type u) [topological_space α] :
tfae [t1_space α,
∀ x, is_closed ({x} : set α),
∀ x, is_open ({x}ᶜ : set α),
continuous (@cofinite_topology.of α),
∀ ⦃x y : α⦄, x ≠ y → {y}ᶜ ∈ 𝓝 x,
∀ ⦃x y : α⦄, x ≠ y → ∃ s ∈ 𝓝 x, y ∉ s,
∀ ⦃x y : α⦄, x ≠ y → ∃ (U : set α) (hU : is_open U), x ∈ U ∧ y ∉ U,
∀ ⦃x y : α⦄, x ≠ y → disjoint (𝓝 x) (pure y),
∀ ⦃x y : α⦄, x ≠ y → disjoint (pure x) (𝓝 y),
∀ ⦃x y : α⦄, x ⤳ y → x = y] :=
begin
tfae_have : 1 ↔ 2, from ⟨λ h, h.1, λ h, ⟨h⟩⟩,
tfae_have : 2 ↔ 3, by simp only [is_open_compl_iff],
tfae_have : 5 ↔ 3,
{ refine forall_swap.trans _,
simp only [is_open_iff_mem_nhds, mem_compl_iff, mem_singleton_iff] },
tfae_have : 5 ↔ 6,
by simp only [← subset_compl_singleton_iff, exists_mem_subset_iff],
tfae_have : 5 ↔ 7,
by simp only [(nhds_basis_opens _).mem_iff, subset_compl_singleton_iff, exists_prop, and.assoc,
and.left_comm],
tfae_have : 5 ↔ 8,
by simp only [← principal_singleton, disjoint_principal_right],
tfae_have : 8 ↔ 9, from forall_swap.trans (by simp only [disjoint.comm, ne_comm]),
tfae_have : 1 → 4,
{ simp only [continuous_def, cofinite_topology.is_open_iff'],
rintro H s (rfl|hs),
exacts [is_open_empty, compl_compl s ▸ (@set.finite.is_closed _ _ H _ hs).is_open_compl] },
tfae_have : 4 → 2,
from λ h x, (cofinite_topology.is_closed_iff.2 $ or.inr (finite_singleton _)).preimage h,
tfae_have : 2 ↔ 10,
{ simp only [← closure_subset_iff_is_closed, specializes_iff_mem_closure, subset_def,
mem_singleton_iff, eq_comm] },
tfae_finish
end
lemma t1_space_iff_continuous_cofinite_of {α : Type*} [topological_space α] :
t1_space α ↔ continuous (@cofinite_topology.of α) :=
(t1_space_tfae α).out 0 3
lemma cofinite_topology.continuous_of [t1_space α] : continuous (@cofinite_topology.of α) :=
t1_space_iff_continuous_cofinite_of.mp ‹_›
lemma t1_space_iff_exists_open : t1_space α ↔
∀ (x y), x ≠ y → (∃ (U : set α) (hU : is_open U), x ∈ U ∧ y ∉ U) :=
(t1_space_tfae α).out 0 6
lemma t1_space_iff_disjoint_pure_nhds : t1_space α ↔ ∀ ⦃x y : α⦄, x ≠ y → disjoint (pure x) (𝓝 y) :=
(t1_space_tfae α).out 0 8
lemma t1_space_iff_disjoint_nhds_pure : t1_space α ↔ ∀ ⦃x y : α⦄, x ≠ y → disjoint (𝓝 x) (pure y) :=
(t1_space_tfae α).out 0 7
lemma t1_space_iff_specializes_imp_eq : t1_space α ↔ ∀ ⦃x y : α⦄, x ⤳ y → x = y :=
(t1_space_tfae α).out 0 9
lemma disjoint_pure_nhds [t1_space α] {x y : α} (h : x ≠ y) : disjoint (pure x) (𝓝 y) :=
t1_space_iff_disjoint_pure_nhds.mp ‹_› h
lemma disjoint_nhds_pure [t1_space α] {x y : α} (h : x ≠ y) : disjoint (𝓝 x) (pure y) :=
t1_space_iff_disjoint_nhds_pure.mp ‹_› h
lemma specializes.eq [t1_space α] {x y : α} (h : x ⤳ y) : x = y :=
t1_space_iff_specializes_imp_eq.1 ‹_› h
lemma specializes_iff_eq [t1_space α] {x y : α} : x ⤳ y ↔ x = y :=
⟨specializes.eq, λ h, h ▸ specializes_rfl⟩
@[simp] lemma specializes_eq_eq [t1_space α] : (⤳) = @eq α :=
funext₂ $ λ x y, propext specializes_iff_eq
@[simp] lemma pure_le_nhds_iff [t1_space α] {a b : α} : pure a ≤ 𝓝 b ↔ a = b :=
specializes_iff_pure.symm.trans specializes_iff_eq
@[simp] lemma nhds_le_nhds_iff [t1_space α] {a b : α} : 𝓝 a ≤ 𝓝 b ↔ a = b :=
specializes_iff_eq
instance {α : Type*} : t1_space (cofinite_topology α) :=
t1_space_iff_continuous_cofinite_of.mpr continuous_id
lemma t1_space_antitone {α : Type*} : antitone (@t1_space α) :=
begin
simp only [antitone, t1_space_iff_continuous_cofinite_of, continuous_iff_le_induced],
exact λ t₁ t₂ h, h.trans
end
lemma continuous_within_at_update_of_ne [t1_space α] [decidable_eq α] [topological_space β]
{f : α → β} {s : set α} {x y : α} {z : β} (hne : y ≠ x) :
continuous_within_at (function.update f x z) s y ↔ continuous_within_at f s y :=
eventually_eq.congr_continuous_within_at
(mem_nhds_within_of_mem_nhds $ mem_of_superset (is_open_ne.mem_nhds hne) $
λ y' hy', function.update_noteq hy' _ _)
(function.update_noteq hne _ _)
lemma continuous_at_update_of_ne [t1_space α] [decidable_eq α] [topological_space β]
{f : α → β} {x y : α} {z : β} (hne : y ≠ x) :
continuous_at (function.update f x z) y ↔ continuous_at f y :=
by simp only [← continuous_within_at_univ, continuous_within_at_update_of_ne hne]
lemma continuous_on_update_iff [t1_space α] [decidable_eq α] [topological_space β]
{f : α → β} {s : set α} {x : α} {y : β} :
continuous_on (function.update f x y) s ↔
continuous_on f (s \ {x}) ∧ (x ∈ s → tendsto f (𝓝[s \ {x}] x) (𝓝 y)) :=
begin
rw [continuous_on, ← and_forall_ne x, and_comm],
refine and_congr ⟨λ H z hz, _, λ H z hzx hzs, _⟩ (forall_congr $ λ hxs, _),
{ specialize H z hz.2 hz.1,
rw continuous_within_at_update_of_ne hz.2 at H,
exact H.mono (diff_subset _ _) },
{ rw continuous_within_at_update_of_ne hzx,
refine (H z ⟨hzs, hzx⟩).mono_of_mem (inter_mem_nhds_within _ _),
exact is_open_ne.mem_nhds hzx },
{ exact continuous_within_at_update_same }
end
lemma t1_space_of_injective_of_continuous [topological_space β] {f : α → β}
(hf : function.injective f) (hf' : continuous f) [t1_space β] : t1_space α :=
t1_space_iff_specializes_imp_eq.2 $ λ x y h, hf (h.map hf').eq
protected lemma embedding.t1_space [topological_space β] [t1_space β] {f : α → β}
(hf : embedding f) : t1_space α :=
t1_space_of_injective_of_continuous hf.inj hf.continuous
instance subtype.t1_space {α : Type u} [topological_space α] [t1_space α] {p : α → Prop} :
t1_space (subtype p) :=
embedding_subtype_coe.t1_space
instance [topological_space β] [t1_space α] [t1_space β] : t1_space (α × β) :=
⟨λ ⟨a, b⟩, @singleton_prod_singleton _ _ a b ▸ is_closed_singleton.prod is_closed_singleton⟩
instance {ι : Type*} {π : ι → Type*} [Π i, topological_space (π i)] [Π i, t1_space (π i)] :
t1_space (Π i, π i) :=
⟨λ f, univ_pi_singleton f ▸ is_closed_set_pi (λ i hi, is_closed_singleton)⟩
@[priority 100] -- see Note [lower instance priority]
instance t1_space.t0_space [t1_space α] : t0_space α := ⟨λ x y h, h.specializes.eq⟩
@[simp] lemma compl_singleton_mem_nhds_iff [t1_space α] {x y : α} : {x}ᶜ ∈ 𝓝 y ↔ y ≠ x :=
is_open_compl_singleton.mem_nhds_iff
lemma compl_singleton_mem_nhds [t1_space α] {x y : α} (h : y ≠ x) : {x}ᶜ ∈ 𝓝 y :=
compl_singleton_mem_nhds_iff.mpr h
@[simp] lemma closure_singleton [t1_space α] {a : α} :
closure ({a} : set α) = {a} :=
is_closed_singleton.closure_eq
lemma set.subsingleton.closure [t1_space α] {s : set α} (hs : s.subsingleton) :
(closure s).subsingleton :=
hs.induction_on (by simp) $ λ x, by simp
@[simp] lemma subsingleton_closure [t1_space α] {s : set α} :
(closure s).subsingleton ↔ s.subsingleton :=
⟨λ h, h.anti subset_closure, λ h, h.closure⟩
lemma is_closed_map_const {α β} [topological_space α] [topological_space β] [t1_space β] {y : β} :
is_closed_map (function.const α y) :=
is_closed_map.of_nonempty $ λ s hs h2s, by simp_rw [h2s.image_const, is_closed_singleton]
lemma nhds_within_insert_of_ne [t1_space α] {x y : α} {s : set α} (hxy : x ≠ y) :
𝓝[insert y s] x = 𝓝[s] x :=
begin
refine le_antisymm (λ t ht, _) (nhds_within_mono x $ subset_insert y s),
obtain ⟨o, ho, hxo, host⟩ := mem_nhds_within.mp ht,
refine mem_nhds_within.mpr ⟨o \ {y}, ho.sdiff is_closed_singleton, ⟨hxo, hxy⟩, _⟩,
rw [inter_insert_of_not_mem $ not_mem_diff_of_mem (mem_singleton y)],
exact (inter_subset_inter (diff_subset _ _) subset.rfl).trans host
end
/-- If `t` is a subset of `s`, except for one point,
then `insert x s` is a neighborhood of `x` within `t`. -/
lemma insert_mem_nhds_within_of_subset_insert [t1_space α] {x y : α} {s t : set α}
(hu : t ⊆ insert y s) :
insert x s ∈ 𝓝[t] x :=
begin
rcases eq_or_ne x y with rfl|h,
{ exact mem_of_superset self_mem_nhds_within hu },
refine nhds_within_mono x hu _,
rw [nhds_within_insert_of_ne h],
exact mem_of_superset self_mem_nhds_within (subset_insert x s)
end
lemma bInter_basis_nhds [t1_space α] {ι : Sort*} {p : ι → Prop} {s : ι → set α} {x : α}
(h : (𝓝 x).has_basis p s) : (⋂ i (h : p i), s i) = {x} :=
begin
simp only [eq_singleton_iff_unique_mem, mem_Inter],
refine ⟨λ i hi, mem_of_mem_nhds $ h.mem_of_mem hi, λ y hy, _⟩,
contrapose! hy,
rcases h.mem_iff.1 (compl_singleton_mem_nhds hy.symm) with ⟨i, hi, hsub⟩,
exact ⟨i, hi, λ h, hsub h rfl⟩
end
@[simp] lemma compl_singleton_mem_nhds_set_iff [t1_space α] {x : α} {s : set α} :
{x}ᶜ ∈ 𝓝ˢ s ↔ x ∉ s :=
by rwa [is_open_compl_singleton.mem_nhds_set, subset_compl_singleton_iff]
@[simp] lemma nhds_set_le_iff [t1_space α] {s t : set α} : 𝓝ˢ s ≤ 𝓝ˢ t ↔ s ⊆ t :=
begin
refine ⟨_, λ h, monotone_nhds_set h⟩,
simp_rw [filter.le_def], intros h x hx,
specialize h {x}ᶜ,
simp_rw [compl_singleton_mem_nhds_set_iff] at h,
by_contra hxt,
exact h hxt hx,
end
@[simp] lemma nhds_set_inj_iff [t1_space α] {s t : set α} : 𝓝ˢ s = 𝓝ˢ t ↔ s = t :=
by { simp_rw [le_antisymm_iff], exact and_congr nhds_set_le_iff nhds_set_le_iff }
lemma injective_nhds_set [t1_space α] : function.injective (𝓝ˢ : set α → filter α) :=
λ s t hst, nhds_set_inj_iff.mp hst
lemma strict_mono_nhds_set [t1_space α] : strict_mono (𝓝ˢ : set α → filter α) :=
monotone_nhds_set.strict_mono_of_injective injective_nhds_set
@[simp] lemma nhds_le_nhds_set_iff [t1_space α] {s : set α} {x : α} : 𝓝 x ≤ 𝓝ˢ s ↔ x ∈ s :=
by rw [← nhds_set_singleton, nhds_set_le_iff, singleton_subset_iff]
/-- Removing a non-isolated point from a dense set, one still obtains a dense set. -/
lemma dense.diff_singleton [t1_space α] {s : set α} (hs : dense s) (x : α) [ne_bot (𝓝[≠] x)] :
dense (s \ {x}) :=
hs.inter_of_open_right (dense_compl_singleton x) is_open_compl_singleton
/-- Removing a finset from a dense set in a space without isolated points, one still
obtains a dense set. -/
lemma dense.diff_finset [t1_space α] [∀ (x : α), ne_bot (𝓝[≠] x)]
{s : set α} (hs : dense s) (t : finset α) :
dense (s \ t) :=
begin
induction t using finset.induction_on with x s hxs ih hd,
{ simpa using hs },
{ rw [finset.coe_insert, ← union_singleton, ← diff_diff],
exact ih.diff_singleton _, }
end
/-- Removing a finite set from a dense set in a space without isolated points, one still
obtains a dense set. -/
lemma dense.diff_finite [t1_space α] [∀ (x : α), ne_bot (𝓝[≠] x)]
{s : set α} (hs : dense s) {t : set α} (ht : t.finite) :
dense (s \ t) :=
begin
convert hs.diff_finset ht.to_finset,
exact (finite.coe_to_finset _).symm,
end
/-- If a function to a `t1_space` tends to some limit `b` at some point `a`, then necessarily
`b = f a`. -/
lemma eq_of_tendsto_nhds [topological_space β] [t1_space β] {f : α → β} {a : α} {b : β}
(h : tendsto f (𝓝 a) (𝓝 b)) : f a = b :=
by_contra $ assume (hfa : f a ≠ b),
have fact₁ : {f a}ᶜ ∈ 𝓝 b := compl_singleton_mem_nhds hfa.symm,
have fact₂ : tendsto f (pure a) (𝓝 b) := h.comp (tendsto_id'.2 $ pure_le_nhds a),
fact₂ fact₁ (eq.refl $ f a)
lemma filter.tendsto.eventually_ne [topological_space β] [t1_space β] {α : Type*} {g : α → β}
{l : filter α} {b₁ b₂ : β} (hg : tendsto g l (𝓝 b₁)) (hb : b₁ ≠ b₂) :
∀ᶠ z in l, g z ≠ b₂ :=
hg.eventually (is_open_compl_singleton.eventually_mem hb)
lemma continuous_at.eventually_ne [topological_space β] [t1_space β] {g : α → β}
{a : α} {b : β} (hg1 : continuous_at g a) (hg2 : g a ≠ b) :
∀ᶠ z in 𝓝 a, g z ≠ b :=
hg1.tendsto.eventually_ne hg2
/-- To prove a function to a `t1_space` is continuous at some point `a`, it suffices to prove that
`f` admits *some* limit at `a`. -/
lemma continuous_at_of_tendsto_nhds [topological_space β] [t1_space β] {f : α → β} {a : α} {b : β}
(h : tendsto f (𝓝 a) (𝓝 b)) : continuous_at f a :=
show tendsto f (𝓝 a) (𝓝 $ f a), by rwa eq_of_tendsto_nhds h
lemma tendsto_const_nhds_iff [t1_space α] {l : filter α} [ne_bot l] {c d : α} :
tendsto (λ x, c) l (𝓝 d) ↔ c = d :=
by simp_rw [tendsto, filter.map_const, pure_le_nhds_iff]
/-- If the punctured neighborhoods of a point form a nontrivial filter, then any neighborhood is
infinite. -/
lemma infinite_of_mem_nhds {α} [topological_space α] [t1_space α] (x : α) [hx : ne_bot (𝓝[≠] x)]
{s : set α} (hs : s ∈ 𝓝 x) : set.infinite s :=
begin
intro hsf,
have A : {x} ⊆ s, by simp only [singleton_subset_iff, mem_of_mem_nhds hs],
have B : is_closed (s \ {x}) := (hsf.subset (diff_subset _ _)).is_closed,
have C : (s \ {x})ᶜ ∈ 𝓝 x, from B.is_open_compl.mem_nhds (λ h, h.2 rfl),
have D : {x} ∈ 𝓝 x, by simpa only [← diff_eq, diff_diff_cancel_left A] using inter_mem hs C,
rwa [← mem_interior_iff_mem_nhds, interior_singleton] at D
end
lemma discrete_of_t1_of_finite {X : Type*} [topological_space X] [t1_space X] [finite X] :
discrete_topology X :=
begin
apply singletons_open_iff_discrete.mp,
intros x,
rw [← is_closed_compl_iff],
exact (set.to_finite _).is_closed
end
lemma preconnected_space.trivial_of_discrete [preconnected_space α] [discrete_topology α] :
subsingleton α :=
begin
rw ←not_nontrivial_iff_subsingleton,
rintro ⟨x, y, hxy⟩,
rw [ne.def, ←mem_singleton_iff, (is_clopen_discrete _).eq_univ $ singleton_nonempty y] at hxy,
exact hxy (mem_univ x)
end
lemma is_preconnected.infinite_of_nontrivial [t1_space α] {s : set α} (h : is_preconnected s)
(hs : s.nontrivial) : s.infinite :=
begin
refine mt (λ hf, (subsingleton_coe s).mp _) (not_subsingleton_iff.mpr hs),
haveI := @discrete_of_t1_of_finite s _ _ hf.to_subtype,
exact @preconnected_space.trivial_of_discrete _ _ (subtype.preconnected_space h) _
end
lemma connected_space.infinite [connected_space α] [nontrivial α] [t1_space α] : infinite α :=
infinite_univ_iff.mp $ is_preconnected_univ.infinite_of_nontrivial nontrivial_univ
lemma singleton_mem_nhds_within_of_mem_discrete {s : set α} [discrete_topology s]
{x : α} (hx : x ∈ s) :
{x} ∈ 𝓝[s] x :=
begin
have : ({⟨x, hx⟩} : set s) ∈ 𝓝 (⟨x, hx⟩ : s), by simp [nhds_discrete],
simpa only [nhds_within_eq_map_subtype_coe hx, image_singleton]
using @image_mem_map _ _ _ (coe : s → α) _ this
end
/-- The neighbourhoods filter of `x` within `s`, under the discrete topology, is equal to
the pure `x` filter (which is the principal filter at the singleton `{x}`.) -/
lemma nhds_within_of_mem_discrete {s : set α} [discrete_topology s] {x : α} (hx : x ∈ s) :
𝓝[s] x = pure x :=
le_antisymm (le_pure_iff.2 $ singleton_mem_nhds_within_of_mem_discrete hx) (pure_le_nhds_within hx)
lemma filter.has_basis.exists_inter_eq_singleton_of_mem_discrete
{ι : Type*} {p : ι → Prop} {t : ι → set α} {s : set α} [discrete_topology s] {x : α}
(hb : (𝓝 x).has_basis p t) (hx : x ∈ s) :
∃ i (hi : p i), t i ∩ s = {x} :=
begin
rcases (nhds_within_has_basis hb s).mem_iff.1 (singleton_mem_nhds_within_of_mem_discrete hx)
with ⟨i, hi, hix⟩,
exact ⟨i, hi, subset.antisymm hix $ singleton_subset_iff.2
⟨mem_of_mem_nhds $ hb.mem_of_mem hi, hx⟩⟩
end
/-- A point `x` in a discrete subset `s` of a topological space admits a neighbourhood
that only meets `s` at `x`. -/
lemma nhds_inter_eq_singleton_of_mem_discrete {s : set α} [discrete_topology s]
{x : α} (hx : x ∈ s) :
∃ U ∈ 𝓝 x, U ∩ s = {x} :=
by simpa using (𝓝 x).basis_sets.exists_inter_eq_singleton_of_mem_discrete hx
/-- For point `x` in a discrete subset `s` of a topological space, there is a set `U`
such that
1. `U` is a punctured neighborhood of `x` (ie. `U ∪ {x}` is a neighbourhood of `x`),
2. `U` is disjoint from `s`.
-/
lemma disjoint_nhds_within_of_mem_discrete {s : set α} [discrete_topology s] {x : α} (hx : x ∈ s) :
∃ U ∈ 𝓝[≠] x, disjoint U s :=
let ⟨V, h, h'⟩ := nhds_inter_eq_singleton_of_mem_discrete hx in
⟨{x}ᶜ ∩ V, inter_mem_nhds_within _ h,
(disjoint_iff_inter_eq_empty.mpr (by { rw [inter_assoc, h', compl_inter_self] }))⟩
/-- Let `X` be a topological space and let `s, t ⊆ X` be two subsets. If there is an inclusion
`t ⊆ s`, then the topological space structure on `t` induced by `X` is the same as the one
obtained by the induced topological space structure on `s`. -/
lemma topological_space.subset_trans {X : Type*} [tX : topological_space X]
{s t : set X} (ts : t ⊆ s) :
(subtype.topological_space : topological_space t) =
(subtype.topological_space : topological_space s).induced (set.inclusion ts) :=
begin
change tX.induced ((coe : s → X) ∘ (set.inclusion ts)) =
topological_space.induced (set.inclusion ts) (tX.induced _),
rw ← induced_compose,
end
/-- The topology pulled-back under an inclusion `f : X → Y` from the discrete topology (`⊥`) is the
discrete topology.
This version does not assume the choice of a topology on either the source `X`
nor the target `Y` of the inclusion `f`. -/
lemma induced_bot {X Y : Type*} {f : X → Y} (hf : function.injective f) :
topological_space.induced f ⊥ = ⊥ :=
eq_of_nhds_eq_nhds (by simp [nhds_induced, ← set.image_singleton, hf.preimage_image, nhds_bot])
/-- The topology induced under an inclusion `f : X → Y` from the discrete topological space `Y`
is the discrete topology on `X`. -/
lemma discrete_topology_induced {X Y : Type*} [tY : topological_space Y] [discrete_topology Y]
{f : X → Y} (hf : function.injective f) : @discrete_topology X (topological_space.induced f tY) :=
by apply discrete_topology.mk; by rw [discrete_topology.eq_bot Y, induced_bot hf]
lemma embedding.discrete_topology {X Y : Type*} [topological_space X] [tY : topological_space Y]
[discrete_topology Y] {f : X → Y} (hf : embedding f) : discrete_topology X :=
⟨by rw [hf.induced, discrete_topology.eq_bot Y, induced_bot hf.inj]⟩
/-- Let `s, t ⊆ X` be two subsets of a topological space `X`. If `t ⊆ s` and the topology induced
by `X`on `s` is discrete, then also the topology induces on `t` is discrete. -/
lemma discrete_topology.of_subset {X : Type*} [topological_space X] {s t : set X}
(ds : discrete_topology s) (ts : t ⊆ s) :
discrete_topology t :=
begin
rw [topological_space.subset_trans ts, ds.eq_bot],
exact {eq_bot := induced_bot (set.inclusion_injective ts)}
end
/-- A T₂ space, also known as a Hausdorff space, is one in which for every
`x ≠ y` there exists disjoint open sets around `x` and `y`. This is
the most widely used of the separation axioms. -/
@[mk_iff] class t2_space (α : Type u) [topological_space α] : Prop :=
(t2 : ∀ x y, x ≠ y → ∃ u v : set α, is_open u ∧ is_open v ∧ x ∈ u ∧ y ∈ v ∧ disjoint u v)
/-- Two different points can be separated by open sets. -/
lemma t2_separation [t2_space α] {x y : α} (h : x ≠ y) :
∃ u v : set α, is_open u ∧ is_open v ∧ x ∈ u ∧ y ∈ v ∧ disjoint u v :=
t2_space.t2 x y h
lemma t2_space_iff_disjoint_nhds : t2_space α ↔ ∀ x y : α, x ≠ y → disjoint (𝓝 x) (𝓝 y) :=
begin
refine (t2_space_iff α).trans (forall₃_congr $ λ x y hne, _),
simp only [(nhds_basis_opens x).disjoint_iff (nhds_basis_opens y), exists_prop,
← exists_and_distrib_left, and.assoc, and_comm, and.left_comm]
end
@[simp] lemma disjoint_nhds_nhds [t2_space α] {x y : α} : disjoint (𝓝 x) (𝓝 y) ↔ x ≠ y :=
⟨λ hd he, by simpa [he, nhds_ne_bot.ne] using hd, t2_space_iff_disjoint_nhds.mp ‹_› x y⟩
lemma pairwise_disjoint_nhds [t2_space α] : pairwise (disjoint on (𝓝 : α → filter α)) :=
λ x y, disjoint_nhds_nhds.2
protected lemma set.pairwise_disjoint_nhds [t2_space α] (s : set α) : s.pairwise_disjoint 𝓝 :=
pairwise_disjoint_nhds.set_pairwise s
/-- Points of a finite set can be separated by open sets from each other. -/
lemma set.finite.t2_separation [t2_space α] {s : set α} (hs : s.finite) :
∃ U : α → set α, (∀ x, x ∈ U x ∧ is_open (U x)) ∧ s.pairwise_disjoint U :=
s.pairwise_disjoint_nhds.exists_mem_filter_basis hs nhds_basis_opens
lemma is_open_set_of_disjoint_nhds_nhds :
is_open {p : α × α | disjoint (𝓝 p.1) (𝓝 p.2)} :=
begin
simp only [is_open_iff_mem_nhds, prod.forall, mem_set_of_eq],
intros x y h,
obtain ⟨U, hU, V, hV, hd⟩ := ((nhds_basis_opens x).disjoint_iff (nhds_basis_opens y)).mp h,
exact mem_nhds_prod_iff.mpr ⟨U, hU.2.mem_nhds hU.1, V, hV.2.mem_nhds hV.1,
λ ⟨x', y'⟩ ⟨hx', hy'⟩, disjoint_of_disjoint_of_mem hd (hU.2.mem_nhds hx') (hV.2.mem_nhds hy')⟩
end
@[priority 100] -- see Note [lower instance priority]
instance t2_space.t1_space [t2_space α] : t1_space α :=
t1_space_iff_disjoint_pure_nhds.mpr $ λ x y hne, (disjoint_nhds_nhds.2 hne).mono_left $
pure_le_nhds _
/-- A space is T₂ iff the neighbourhoods of distinct points generate the bottom filter. -/
lemma t2_iff_nhds : t2_space α ↔ ∀ {x y : α}, ne_bot (𝓝 x ⊓ 𝓝 y) → x = y :=
by simp only [t2_space_iff_disjoint_nhds, disjoint_iff, ne_bot_iff, ne.def, not_imp_comm]
lemma eq_of_nhds_ne_bot [t2_space α] {x y : α} (h : ne_bot (𝓝 x ⊓ 𝓝 y)) : x = y :=
t2_iff_nhds.mp ‹_› h
lemma t2_space_iff_nhds : t2_space α ↔ ∀ {x y : α}, x ≠ y → ∃ (U ∈ 𝓝 x) (V ∈ 𝓝 y), disjoint U V :=
by simp only [t2_space_iff_disjoint_nhds, filter.disjoint_iff]
lemma t2_separation_nhds [t2_space α] {x y : α} (h : x ≠ y) :
∃ u v, u ∈ 𝓝 x ∧ v ∈ 𝓝 y ∧ disjoint u v :=
let ⟨u, v, open_u, open_v, x_in, y_in, huv⟩ := t2_separation h in
⟨u, v, open_u.mem_nhds x_in, open_v.mem_nhds y_in, huv⟩
lemma t2_separation_compact_nhds [locally_compact_space α] [t2_space α] {x y : α} (h : x ≠ y) :
∃ u v, u ∈ 𝓝 x ∧ v ∈ 𝓝 y ∧ is_compact u ∧ is_compact v ∧ disjoint u v :=
by simpa only [exists_prop, ← exists_and_distrib_left, and_comm, and.assoc, and.left_comm]
using ((compact_basis_nhds x).disjoint_iff (compact_basis_nhds y)).1 (disjoint_nhds_nhds.2 h)
lemma t2_iff_ultrafilter :
t2_space α ↔ ∀ {x y : α} (f : ultrafilter α), ↑f ≤ 𝓝 x → ↑f ≤ 𝓝 y → x = y :=
t2_iff_nhds.trans $ by simp only [←exists_ultrafilter_iff, and_imp, le_inf_iff, exists_imp_distrib]
lemma t2_iff_is_closed_diagonal : t2_space α ↔ is_closed (diagonal α) :=
by simp only [t2_space_iff_disjoint_nhds, ← is_open_compl_iff, is_open_iff_mem_nhds, prod.forall,
nhds_prod_eq, compl_diagonal_mem_prod, mem_compl_iff, mem_diagonal_iff]
lemma is_closed_diagonal [t2_space α] : is_closed (diagonal α) :=
t2_iff_is_closed_diagonal.mp ‹_›
section separated
open separated_nhds finset
lemma finset_disjoint_finset_opens_of_t2 [t2_space α] :
∀ (s t : finset α), disjoint s t → separated_nhds (s : set α) t :=
begin
refine induction_on_union _ (λ a b hi d, (hi d.symm).symm) (λ a d, empty_right a) (λ a b ab, _) _,
{ obtain ⟨U, V, oU, oV, aU, bV, UV⟩ := t2_separation (finset.disjoint_singleton.1 ab),
refine ⟨U, V, oU, oV, _, _, UV⟩;
exact singleton_subset_set_iff.mpr ‹_› },
{ intros a b c ac bc d,
apply_mod_cast union_left (ac (disjoint_of_subset_left (a.subset_union_left b) d)) (bc _),
exact disjoint_of_subset_left (a.subset_union_right b) d },
end
lemma point_disjoint_finset_opens_of_t2 [t2_space α] {x : α} {s : finset α} (h : x ∉ s) :
separated_nhds ({x} : set α) s :=
by exact_mod_cast finset_disjoint_finset_opens_of_t2 {x} s (finset.disjoint_singleton_left.mpr h)
end separated
lemma tendsto_nhds_unique [t2_space α] {f : β → α} {l : filter β} {a b : α}
[ne_bot l] (ha : tendsto f l (𝓝 a)) (hb : tendsto f l (𝓝 b)) : a = b :=
eq_of_nhds_ne_bot $ ne_bot_of_le $ le_inf ha hb
lemma tendsto_nhds_unique' [t2_space α] {f : β → α} {l : filter β} {a b : α}
(hl : ne_bot l) (ha : tendsto f l (𝓝 a)) (hb : tendsto f l (𝓝 b)) : a = b :=
eq_of_nhds_ne_bot $ ne_bot_of_le $ le_inf ha hb
lemma tendsto_nhds_unique_of_eventually_eq [t2_space α] {f g : β → α} {l : filter β} {a b : α}
[ne_bot l] (ha : tendsto f l (𝓝 a)) (hb : tendsto g l (𝓝 b)) (hfg : f =ᶠ[l] g) :
a = b :=
tendsto_nhds_unique (ha.congr' hfg) hb
lemma tendsto_nhds_unique_of_frequently_eq [t2_space α] {f g : β → α} {l : filter β} {a b : α}
(ha : tendsto f l (𝓝 a)) (hb : tendsto g l (𝓝 b)) (hfg : ∃ᶠ x in l, f x = g x) :
a = b :=
have ∃ᶠ z : α × α in 𝓝 (a, b), z.1 = z.2 := (ha.prod_mk_nhds hb).frequently hfg,
not_not.1 $ λ hne, this (is_closed_diagonal.is_open_compl.mem_nhds hne)
/-- A T₂.₅ space, also known as a Urysohn space, is a topological space
where for every pair `x ≠ y`, there are two open sets, with the intersection of closures
empty, one containing `x` and the other `y` . -/
class t2_5_space (α : Type u) [topological_space α]: Prop :=
(t2_5 : ∀ ⦃x y : α⦄ (h : x ≠ y), disjoint ((𝓝 x).lift' closure) ((𝓝 y).lift' closure))
@[simp] lemma disjoint_lift'_closure_nhds [t2_5_space α] {x y : α} :
disjoint ((𝓝 x).lift' closure) ((𝓝 y).lift' closure) ↔ x ≠ y :=
⟨λ h hxy, by simpa [hxy, nhds_ne_bot.ne] using h, λ h, t2_5_space.t2_5 h⟩
@[priority 100] -- see Note [lower instance priority]
instance t2_5_space.t2_space [t2_5_space α] : t2_space α :=
t2_space_iff_disjoint_nhds.2 $
λ x y hne, (disjoint_lift'_closure_nhds.2 hne).mono (le_lift'_closure _) (le_lift'_closure _)
lemma exists_nhds_disjoint_closure [t2_5_space α] {x y : α} (h : x ≠ y) :
∃ (s ∈ 𝓝 x) (t ∈ 𝓝 y), disjoint (closure s) (closure t) :=
((𝓝 x).basis_sets.lift'_closure.disjoint_iff (𝓝 y).basis_sets.lift'_closure).1 $
disjoint_lift'_closure_nhds.2 h
lemma exists_open_nhds_disjoint_closure [t2_5_space α] {x y : α} (h : x ≠ y) :
∃ u : set α, x ∈ u ∧ is_open u ∧ ∃ v : set α, y ∈ v ∧ is_open v ∧
disjoint (closure u) (closure v) :=
by simpa only [exists_prop, and.assoc] using ((nhds_basis_opens x).lift'_closure.disjoint_iff
(nhds_basis_opens y).lift'_closure).1 (disjoint_lift'_closure_nhds.2 h)
section lim
variables [t2_space α] {f : filter α}
/-!
### Properties of `Lim` and `lim`
In this section we use explicit `nonempty α` instances for `Lim` and `lim`. This way the lemmas
are useful without a `nonempty α` instance.
-/
lemma Lim_eq {a : α} [ne_bot f] (h : f ≤ 𝓝 a) :
@Lim _ _ ⟨a⟩ f = a :=
tendsto_nhds_unique (le_nhds_Lim ⟨a, h⟩) h
lemma Lim_eq_iff [ne_bot f] (h : ∃ (a : α), f ≤ nhds a) {a} : @Lim _ _ ⟨a⟩ f = a ↔ f ≤ 𝓝 a :=
⟨λ c, c ▸ le_nhds_Lim h, Lim_eq⟩
lemma ultrafilter.Lim_eq_iff_le_nhds [compact_space α] {x : α} {F : ultrafilter α} :
F.Lim = x ↔ ↑F ≤ 𝓝 x :=
⟨λ h, h ▸ F.le_nhds_Lim, Lim_eq⟩
lemma is_open_iff_ultrafilter' [compact_space α] (U : set α) :
is_open U ↔ (∀ F : ultrafilter α, F.Lim ∈ U → U ∈ F.1) :=
begin
rw is_open_iff_ultrafilter,
refine ⟨λ h F hF, h F.Lim hF F F.le_nhds_Lim, _⟩,
intros cond x hx f h,
rw [← (ultrafilter.Lim_eq_iff_le_nhds.2 h)] at hx,
exact cond _ hx
end
lemma filter.tendsto.lim_eq {a : α} {f : filter β} [ne_bot f] {g : β → α} (h : tendsto g f (𝓝 a)) :
@lim _ _ _ ⟨a⟩ f g = a :=
Lim_eq h
lemma filter.lim_eq_iff {f : filter β} [ne_bot f] {g : β → α} (h : ∃ a, tendsto g f (𝓝 a)) {a} :
@lim _ _ _ ⟨a⟩ f g = a ↔ tendsto g f (𝓝 a) :=
⟨λ c, c ▸ tendsto_nhds_lim h, filter.tendsto.lim_eq⟩
lemma continuous.lim_eq [topological_space β] {f : β → α} (h : continuous f) (a : β) :
@lim _ _ _ ⟨f a⟩ (𝓝 a) f = f a :=
(h.tendsto a).lim_eq
@[simp] lemma Lim_nhds (a : α) : @Lim _ _ ⟨a⟩ (𝓝 a) = a :=
Lim_eq le_rfl
@[simp] lemma lim_nhds_id (a : α) : @lim _ _ _ ⟨a⟩ (𝓝 a) id = a :=
Lim_nhds a
@[simp] lemma Lim_nhds_within {a : α} {s : set α} (h : a ∈ closure s) :
@Lim _ _ ⟨a⟩ (𝓝[s] a) = a :=
by haveI : ne_bot (𝓝[s] a) := mem_closure_iff_cluster_pt.1 h;
exact Lim_eq inf_le_left
@[simp] lemma lim_nhds_within_id {a : α} {s : set α} (h : a ∈ closure s) :
@lim _ _ _ ⟨a⟩ (𝓝[s] a) id = a :=
Lim_nhds_within h
end lim
/-!
### `t2_space` constructions
We use two lemmas to prove that various standard constructions generate Hausdorff spaces from
Hausdorff spaces:
* `separated_by_continuous` says that two points `x y : α` can be separated by open neighborhoods
provided that there exists a continuous map `f : α → β` with a Hausdorff codomain such that
`f x ≠ f y`. We use this lemma to prove that topological spaces defined using `induced` are
Hausdorff spaces.
* `separated_by_open_embedding` says that for an open embedding `f : α → β` of a Hausdorff space
`α`, the images of two distinct points `x y : α`, `x ≠ y` can be separated by open neighborhoods.
We use this lemma to prove that topological spaces defined using `coinduced` are Hausdorff spaces.
-/
@[priority 100] -- see Note [lower instance priority]
instance discrete_topology.to_t2_space {α : Type*} [topological_space α] [discrete_topology α] :
t2_space α :=
⟨λ x y h, ⟨{x}, {y}, is_open_discrete _, is_open_discrete _, rfl, rfl, disjoint_singleton.2 h⟩⟩
lemma separated_by_continuous {α : Type*} {β : Type*}
[topological_space α] [topological_space β] [t2_space β]
{f : α → β} (hf : continuous f) {x y : α} (h : f x ≠ f y) :
∃u v : set α, is_open u ∧ is_open v ∧ x ∈ u ∧ y ∈ v ∧ disjoint u v :=
let ⟨u, v, uo, vo, xu, yv, uv⟩ := t2_separation h in
⟨f ⁻¹' u, f ⁻¹' v, uo.preimage hf, vo.preimage hf, xu, yv, uv.preimage _⟩
lemma separated_by_open_embedding {α β : Type*} [topological_space α] [topological_space β]
[t2_space α] {f : α → β} (hf : open_embedding f) {x y : α} (h : x ≠ y) :
∃ u v : set β, is_open u ∧ is_open v ∧ f x ∈ u ∧ f y ∈ v ∧ disjoint u v :=
let ⟨u, v, uo, vo, xu, yv, uv⟩ := t2_separation h in
⟨f '' u, f '' v, hf.is_open_map _ uo, hf.is_open_map _ vo,
mem_image_of_mem _ xu, mem_image_of_mem _ yv, disjoint_image_of_injective hf.inj uv⟩
instance {α : Type*} {p : α → Prop} [t : topological_space α] [t2_space α] : t2_space (subtype p) :=
⟨assume x y h, separated_by_continuous continuous_subtype_val (mt subtype.eq h)⟩
instance {α : Type*} {β : Type*} [t₁ : topological_space α] [t2_space α]
[t₂ : topological_space β] [t2_space β] : t2_space (α × β) :=
⟨assume ⟨x₁,x₂⟩ ⟨y₁,y₂⟩ h,
or.elim (not_and_distrib.mp (mt prod.ext_iff.mpr h))
(λ h₁, separated_by_continuous continuous_fst h₁)
(λ h₂, separated_by_continuous continuous_snd h₂)⟩
lemma embedding.t2_space [topological_space β] [t2_space β] {f : α → β} (hf : embedding f) :
t2_space α :=
⟨λ x y h, separated_by_continuous hf.continuous (hf.inj.ne h)⟩
instance {α : Type*} {β : Type*} [t₁ : topological_space α] [t2_space α]
[t₂ : topological_space β] [t2_space β] : t2_space (α ⊕ β) :=
begin
constructor,
rintros (x|x) (y|y) h,
{ replace h : x ≠ y := λ c, (c.subst h) rfl,
exact separated_by_open_embedding open_embedding_inl h },
{ exact ⟨_, _, is_open_range_inl, is_open_range_inr, ⟨x, rfl⟩, ⟨y, rfl⟩,
is_compl_range_inl_range_inr.disjoint⟩ },
{ exact ⟨_, _, is_open_range_inr, is_open_range_inl, ⟨x, rfl⟩, ⟨y, rfl⟩,
is_compl_range_inl_range_inr.disjoint.symm⟩ },
{ replace h : x ≠ y := λ c, (c.subst h) rfl,
exact separated_by_open_embedding open_embedding_inr h }
end
instance Pi.t2_space {α : Type*} {β : α → Type v} [t₂ : Πa, topological_space (β a)]
[∀a, t2_space (β a)] :
t2_space (Πa, β a) :=
⟨assume x y h,
let ⟨i, hi⟩ := not_forall.mp (mt funext h) in
separated_by_continuous (continuous_apply i) hi⟩
instance sigma.t2_space {ι : Type*} {α : ι → Type*} [Πi, topological_space (α i)]
[∀a, t2_space (α a)] :
t2_space (Σi, α i) :=
begin
constructor,
rintros ⟨i, x⟩ ⟨j, y⟩ neq,
rcases em (i = j) with (rfl|h),
{ replace neq : x ≠ y := λ c, (c.subst neq) rfl,
exact separated_by_open_embedding open_embedding_sigma_mk neq },
{ exact ⟨_, _, is_open_range_sigma_mk, is_open_range_sigma_mk, ⟨x, rfl⟩, ⟨y, rfl⟩,
set.disjoint_left.mpr $ by tidy⟩ }
end
variables {γ : Type*} [topological_space β] [topological_space γ]
lemma is_closed_eq [t2_space α] {f g : β → α}
(hf : continuous f) (hg : continuous g) : is_closed {x:β | f x = g x} :=
continuous_iff_is_closed.mp (hf.prod_mk hg) _ is_closed_diagonal
lemma is_open_ne_fun [t2_space α] {f g : β → α}
(hf : continuous f) (hg : continuous g) : is_open {x:β | f x ≠ g x} :=
is_open_compl_iff.mpr $ is_closed_eq hf hg
/-- If two continuous maps are equal on `s`, then they are equal on the closure of `s`. See also
`set.eq_on.of_subset_closure` for a more general version. -/
lemma set.eq_on.closure [t2_space α] {s : set β} {f g : β → α} (h : eq_on f g s)
(hf : continuous f) (hg : continuous g) :
eq_on f g (closure s) :=
closure_minimal h (is_closed_eq hf hg)
/-- If two continuous functions are equal on a dense set, then they are equal. -/
lemma continuous.ext_on [t2_space α] {s : set β} (hs : dense s) {f g : β → α}
(hf : continuous f) (hg : continuous g) (h : eq_on f g s) :
f = g :=
funext $ λ x, h.closure hf hg (hs x)
lemma eq_on_closure₂' [t2_space α] {s : set β} {t : set γ} {f g : β → γ → α}
(h : ∀ (x ∈ s) (y ∈ t), f x y = g x y)
(hf₁ : ∀ x, continuous (f x)) (hf₂ : ∀ y, continuous (λ x, f x y))
(hg₁ : ∀ x, continuous (g x)) (hg₂ : ∀ y, continuous (λ x, g x y)) :
∀ (x ∈ closure s) (y ∈ closure t), f x y = g x y :=
suffices closure s ⊆ ⋂ y ∈ closure t, {x | f x y = g x y}, by simpa only [subset_def, mem_Inter],
closure_minimal (λ x hx, mem_Inter₂.2 $ set.eq_on.closure (h x hx) (hf₁ _) (hg₁ _)) $
is_closed_bInter $ λ y hy, is_closed_eq (hf₂ _) (hg₂ _)
lemma eq_on_closure₂ [t2_space α] {s : set β} {t : set γ} {f g : β → γ → α}
(h : ∀ (x ∈ s) (y ∈ t), f x y = g x y)
(hf : continuous (uncurry f)) (hg : continuous (uncurry g)) :
∀ (x ∈ closure s) (y ∈ closure t), f x y = g x y :=
eq_on_closure₂' h (λ x, continuous_uncurry_left x hf) (λ x, continuous_uncurry_right x hf)
(λ y, continuous_uncurry_left y hg) (λ y, continuous_uncurry_right y hg)
/-- If `f x = g x` for all `x ∈ s` and `f`, `g` are continuous on `t`, `s ⊆ t ⊆ closure s`, then
`f x = g x` for all `x ∈ t`. See also `set.eq_on.closure`. -/
lemma set.eq_on.of_subset_closure [t2_space α] {s t : set β} {f g : β → α} (h : eq_on f g s)
(hf : continuous_on f t) (hg : continuous_on g t) (hst : s ⊆ t) (hts : t ⊆ closure s) :
eq_on f g t :=
begin
intros x hx,
haveI : (𝓝[s] x).ne_bot, from mem_closure_iff_cluster_pt.mp (hts hx),
exact tendsto_nhds_unique_of_eventually_eq ((hf x hx).mono_left $ nhds_within_mono _ hst)
((hg x hx).mono_left $ nhds_within_mono _ hst) (h.eventually_eq_of_mem self_mem_nhds_within)
end
lemma function.left_inverse.closed_range [t2_space α] {f : α → β} {g : β → α}
(h : function.left_inverse f g) (hf : continuous f) (hg : continuous g) :
is_closed (range g) :=
have eq_on (g ∘ f) id (closure $ range g),
from h.right_inv_on_range.eq_on.closure (hg.comp hf) continuous_id,
is_closed_of_closure_subset $ λ x hx,
calc x = g (f x) : (this hx).symm
... ∈ _ : mem_range_self _
lemma function.left_inverse.closed_embedding [t2_space α] {f : α → β} {g : β → α}
(h : function.left_inverse f g) (hf : continuous f) (hg : continuous g) :
closed_embedding g :=
⟨h.embedding hf hg, h.closed_range hf hg⟩
lemma is_compact_is_compact_separated [t2_space α] {s t : set α}
(hs : is_compact s) (ht : is_compact t) (hst : disjoint s t) :
separated_nhds s t :=
by simp only [separated_nhds, prod_subset_compl_diagonal_iff_disjoint.symm] at ⊢ hst;
exact generalized_tube_lemma hs ht is_closed_diagonal.is_open_compl hst
/-- In a `t2_space`, every compact set is closed. -/
lemma is_compact.is_closed [t2_space α] {s : set α} (hs : is_compact s) : is_closed s :=
is_open_compl_iff.1 $ is_open_iff_forall_mem_open.mpr $ assume x hx,
let ⟨u, v, uo, vo, su, xv, uv⟩ :=
is_compact_is_compact_separated hs is_compact_singleton (disjoint_singleton_right.2 hx) in
⟨v, (uv.mono_left $ show s ≤ u, from su).subset_compl_left, vo, by simpa using xv⟩
@[simp] lemma filter.coclosed_compact_eq_cocompact [t2_space α] :
coclosed_compact α = cocompact α :=
by simp [coclosed_compact, cocompact, infi_and', and_iff_right_of_imp is_compact.is_closed]
@[simp] lemma bornology.relatively_compact_eq_in_compact [t2_space α] :
bornology.relatively_compact α = bornology.in_compact α :=
by rw bornology.ext_iff; exact filter.coclosed_compact_eq_cocompact
/-- If `V : ι → set α` is a decreasing family of compact sets then any neighborhood of
`⋂ i, V i` contains some `V i`. This is a version of `exists_subset_nhd_of_compact'` where we
don't need to assume each `V i` closed because it follows from compactness since `α` is
assumed to be Hausdorff. -/
lemma exists_subset_nhds_of_is_compact [t2_space α] {ι : Type*} [nonempty ι] {V : ι → set α}
(hV : directed (⊇) V) (hV_cpct : ∀ i, is_compact (V i)) {U : set α}
(hU : ∀ x ∈ ⋂ i, V i, U ∈ 𝓝 x) : ∃ i, V i ⊆ U :=
exists_subset_nhds_of_is_compact' hV hV_cpct (λ i, (hV_cpct i).is_closed) hU
lemma compact_exhaustion.is_closed [t2_space α] (K : compact_exhaustion α) (n : ℕ) :
is_closed (K n) :=
(K.is_compact n).is_closed
lemma is_compact.inter [t2_space α] {s t : set α} (hs : is_compact s) (ht : is_compact t) :
is_compact (s ∩ t) :=
hs.inter_right $ ht.is_closed
lemma is_compact_closure_of_subset_compact [t2_space α] {s t : set α}
(ht : is_compact t) (h : s ⊆ t) : is_compact (closure s) :=
is_compact_of_is_closed_subset ht is_closed_closure (closure_minimal h ht.is_closed)
@[simp]
lemma exists_compact_superset_iff [t2_space α] {s : set α} :
(∃ K, is_compact K ∧ s ⊆ K) ↔ is_compact (closure s) :=
⟨λ ⟨K, hK, hsK⟩, is_compact_closure_of_subset_compact hK hsK, λ h, ⟨closure s, h, subset_closure⟩⟩
lemma image_closure_of_is_compact [t2_space β]
{s : set α} (hs : is_compact (closure s)) {f : α → β} (hf : continuous_on f (closure s)) :
f '' closure s = closure (f '' s) :=
subset.antisymm hf.image_closure $ closure_minimal (image_subset f subset_closure)
(hs.image_of_continuous_on hf).is_closed
/-- If a compact set is covered by two open sets, then we can cover it by two compact subsets. -/
lemma is_compact.binary_compact_cover [t2_space α] {K U V : set α} (hK : is_compact K)
(hU : is_open U) (hV : is_open V) (h2K : K ⊆ U ∪ V) :
∃ K₁ K₂ : set α, is_compact K₁ ∧ is_compact K₂ ∧ K₁ ⊆ U ∧ K₂ ⊆ V ∧ K = K₁ ∪ K₂ :=
begin
obtain ⟨O₁, O₂, h1O₁, h1O₂, h2O₁, h2O₂, hO⟩ :=
is_compact_is_compact_separated (hK.diff hU) (hK.diff hV)
(by rwa [disjoint_iff_inter_eq_empty, diff_inter_diff, diff_eq_empty]),
exact ⟨_, _, hK.diff h1O₁, hK.diff h1O₂, by rwa [diff_subset_comm], by rwa [diff_subset_comm],
by rw [← diff_inter, hO.inter_eq, diff_empty]⟩
end
lemma continuous.is_closed_map [compact_space α] [t2_space β] {f : α → β} (h : continuous f) :
is_closed_map f :=
λ s hs, (hs.is_compact.image h).is_closed
lemma continuous.closed_embedding [compact_space α] [t2_space β] {f : α → β} (h : continuous f)
(hf : function.injective f) : closed_embedding f :=
closed_embedding_of_continuous_injective_closed h hf h.is_closed_map
section
open finset function
/-- For every finite open cover `Uᵢ` of a compact set, there exists a compact cover `Kᵢ ⊆ Uᵢ`. -/
lemma is_compact.finite_compact_cover [t2_space α] {s : set α} (hs : is_compact s)
{ι} (t : finset ι) (U : ι → set α) (hU : ∀ i ∈ t, is_open (U i)) (hsC : s ⊆ ⋃ i ∈ t, U i) :
∃ K : ι → set α, (∀ i, is_compact (K i)) ∧ (∀i, K i ⊆ U i) ∧ s = ⋃ i ∈ t, K i :=
begin
classical,
induction t using finset.induction with x t hx ih generalizing U hU s hs hsC,
{ refine ⟨λ _, ∅, λ i, is_compact_empty, λ i, empty_subset _, _⟩,
simpa only [subset_empty_iff, Union_false, Union_empty] using hsC },
simp only [finset.set_bUnion_insert] at hsC,
simp only [finset.mem_insert] at hU,
have hU' : ∀ i ∈ t, is_open (U i) := λ i hi, hU i (or.inr hi),
rcases hs.binary_compact_cover (hU x (or.inl rfl)) (is_open_bUnion hU') hsC
with ⟨K₁, K₂, h1K₁, h1K₂, h2K₁, h2K₂, hK⟩,
rcases ih U hU' h1K₂ h2K₂ with ⟨K, h1K, h2K, h3K⟩,
refine ⟨update K x K₁, _, _, _⟩,
{ intros i, by_cases hi : i = x,
{ simp only [update_same, hi, h1K₁] },
{ rw [← ne.def] at hi, simp only [update_noteq hi, h1K] }},
{ intros i, by_cases hi : i = x,
{ simp only [update_same, hi, h2K₁] },
{ rw [← ne.def] at hi, simp only [update_noteq hi, h2K] }},
{ simp only [set_bUnion_insert_update _ hx, hK, h3K] }
end
end
lemma locally_compact_of_compact_nhds [t2_space α] (h : ∀ x : α, ∃ s, s ∈ 𝓝 x ∧ is_compact s) :
locally_compact_space α :=
⟨assume x n hn,
let ⟨u, un, uo, xu⟩ := mem_nhds_iff.mp hn in
let ⟨k, kx, kc⟩ := h x in
-- K is compact but not necessarily contained in N.
-- K \ U is again compact and doesn't contain x, so
-- we may find open sets V, W separating x from K \ U.
-- Then K \ W is a compact neighborhood of x contained in U.
let ⟨v, w, vo, wo, xv, kuw, vw⟩ :=
is_compact_is_compact_separated is_compact_singleton (kc.diff uo)
(disjoint_singleton_left.2 $ λ h, h.2 xu) in
have wn : wᶜ ∈ 𝓝 x, from
mem_nhds_iff.mpr ⟨v, vw.subset_compl_right, vo, singleton_subset_iff.mp xv⟩,
⟨k \ w,
filter.inter_mem kx wn,
subset.trans (diff_subset_comm.mp kuw) un,
kc.diff wo⟩⟩
@[priority 100] -- see Note [lower instance priority]
instance locally_compact_of_compact [t2_space α] [compact_space α] : locally_compact_space α :=
locally_compact_of_compact_nhds (assume x, ⟨univ, is_open_univ.mem_nhds trivial, is_compact_univ⟩)
/-- In a locally compact T₂ space, every point has an open neighborhood with compact closure -/
lemma exists_open_with_compact_closure [locally_compact_space α] [t2_space α] (x : α) :
∃ (U : set α), is_open U ∧ x ∈ U ∧ is_compact (closure U) :=
begin
rcases exists_compact_mem_nhds x with ⟨K, hKc, hxK⟩,
rcases mem_nhds_iff.1 hxK with ⟨t, h1t, h2t, h3t⟩,
exact ⟨t, h2t, h3t, is_compact_closure_of_subset_compact hKc h1t⟩
end
/--
In a locally compact T₂ space, every compact set has an open neighborhood with compact closure.
-/
lemma exists_open_superset_and_is_compact_closure [locally_compact_space α] [t2_space α]
{K : set α} (hK : is_compact K) : ∃ V, is_open V ∧ K ⊆ V ∧ is_compact (closure V) :=
begin
rcases exists_compact_superset hK with ⟨K', hK', hKK'⟩,
refine ⟨interior K', is_open_interior, hKK',
is_compact_closure_of_subset_compact hK' interior_subset⟩,
end
/--
In a locally compact T₂ space, given a compact set `K` inside an open set `U`, we can find a
open set `V` between these sets with compact closure: `K ⊆ V` and the closure of `V` is inside `U`.
-/
lemma exists_open_between_and_is_compact_closure [locally_compact_space α] [t2_space α]
{K U : set α} (hK : is_compact K) (hU : is_open U) (hKU : K ⊆ U) :
∃ V, is_open V ∧ K ⊆ V ∧ closure V ⊆ U ∧ is_compact (closure V) :=
begin
rcases exists_compact_between hK hU hKU with ⟨V, hV, hKV, hVU⟩,
exact ⟨interior V, is_open_interior, hKV,
(closure_minimal interior_subset hV.is_closed).trans hVU,
is_compact_closure_of_subset_compact hV interior_subset⟩,
end
lemma is_preirreducible_iff_subsingleton [t2_space α] {S : set α} :
is_preirreducible S ↔ S.subsingleton :=
begin
refine ⟨λ h x hx y hy, _, set.subsingleton.is_preirreducible⟩,
by_contradiction e,
obtain ⟨U, V, hU, hV, hxU, hyV, h'⟩ := t2_separation e,
exact ((h U V hU hV ⟨x, hx, hxU⟩ ⟨y, hy, hyV⟩).mono $ inter_subset_right _ _).not_disjoint h',
end
alias is_preirreducible_iff_subsingleton ↔ is_preirreducible.subsingleton _
attribute [protected] is_preirreducible.subsingleton
lemma is_irreducible_iff_singleton [t2_space α] {S : set α} :
is_irreducible S ↔ ∃ x, S = {x} :=
by rw [is_irreducible, is_preirreducible_iff_subsingleton,
exists_eq_singleton_iff_nonempty_subsingleton]
/-- There does not exist a nontrivial preirreducible T₂ space. -/
lemma not_preirreducible_nontrivial_t2 (α) [topological_space α] [preirreducible_space α]
[nontrivial α] [t2_space α] : false :=
(preirreducible_space.is_preirreducible_univ α).subsingleton.not_nontrivial nontrivial_univ
end separation
section regular_space
/-- A topological space is called a *regular space* if for any closed set `s` and `a ∉ s`, there
exist disjoint open sets `U ⊇ s` and `V ∋ a`. We formulate this condition in terms of `disjoint`ness
of filters `𝓝ˢ s` and `𝓝 a`. -/
@[mk_iff] class regular_space (X : Type u) [topological_space X] : Prop :=
(regular : ∀ {s : set X} {a}, is_closed s → a ∉ s → disjoint (𝓝ˢ s) (𝓝 a))
lemma regular_space_tfae (X : Type u) [topological_space X] :
tfae [regular_space X,
∀ (s : set X) (a ∉ closure s), disjoint (𝓝ˢ s) (𝓝 a),
∀ (a : X) (s : set X), disjoint (𝓝ˢ s) (𝓝 a) ↔ a ∉ closure s,
∀ (a : X) (s ∈ 𝓝 a), ∃ t ∈ 𝓝 a, is_closed t ∧ t ⊆ s,
∀ a : X, (𝓝 a).lift' closure ≤ 𝓝 a,
∀ a : X, (𝓝 a).lift' closure = 𝓝 a] :=
begin
tfae_have : 1 ↔ 5,
{ rw [regular_space_iff, (@compl_surjective (set X) _).forall, forall_swap],
simp only [is_closed_compl_iff, mem_compl_iff, not_not, @and_comm (_ ∈ _),
(nhds_basis_opens _).lift'_closure.le_basis_iff (nhds_basis_opens _), and_imp,
(nhds_basis_opens _).disjoint_iff_right, exists_prop, ← subset_interior_iff_mem_nhds_set,
interior_compl, compl_subset_compl] },
tfae_have : 5 → 6, from λ h a, (h a).antisymm (𝓝 _).le_lift'_closure,
tfae_have : 6 → 4,
{ intros H a s hs,
rw [← H] at hs,
rcases (𝓝 a).basis_sets.lift'_closure.mem_iff.mp hs with ⟨U, hU, hUs⟩,
exact ⟨closure U, mem_of_superset hU subset_closure, is_closed_closure, hUs⟩ },
tfae_have : 4 → 2,
{ intros H s a ha,
have ha' : sᶜ ∈ 𝓝 a, by rwa [← mem_interior_iff_mem_nhds, interior_compl],
rcases H _ _ ha' with ⟨U, hU, hUc, hUs⟩,
refine disjoint_of_disjoint_of_mem disjoint_compl_left _ hU,
rwa [← subset_interior_iff_mem_nhds_set, hUc.is_open_compl.interior_eq, subset_compl_comm] },
tfae_have : 2 → 3,
{ refine λ H a s, ⟨λ hd has, mem_closure_iff_nhds_ne_bot.mp has _, H s a⟩,
exact (hd.symm.mono_right $ @principal_le_nhds_set _ _ s).eq_bot },
tfae_have : 3 → 1, from λ H, ⟨λ s a hs ha, (H _ _).mpr $ hs.closure_eq.symm ▸ ha⟩,
tfae_finish
end
lemma regular_space.of_lift'_closure (h : ∀ a : α, (𝓝 a).lift' closure = 𝓝 a) : regular_space α :=
iff.mpr ((regular_space_tfae α).out 0 5) h
lemma regular_space.of_basis {ι : α → Sort*} {p : Π a, ι a → Prop} {s : Π a, ι a → set α}
(h₁ : ∀ a, (𝓝 a).has_basis (p a) (s a)) (h₂ : ∀ a i, p a i → is_closed (s a i)) :
regular_space α :=
regular_space.of_lift'_closure $ λ a, (h₁ a).lift'_closure_eq_self (h₂ a)
lemma regular_space.of_exists_mem_nhds_is_closed_subset
(h : ∀ (a : α) (s ∈ 𝓝 a), ∃ t ∈ 𝓝 a, is_closed t ∧ t ⊆ s) : regular_space α :=
iff.mpr ((regular_space_tfae α).out 0 3) h
variables [regular_space α] {a : α} {s : set α}
lemma disjoint_nhds_set_nhds : disjoint (𝓝ˢ s) (𝓝 a) ↔ a ∉ closure s :=
iff.mp ((regular_space_tfae α).out 0 2) ‹_› _ _
lemma disjoint_nhds_nhds_set : disjoint (𝓝 a) (𝓝ˢ s) ↔ a ∉ closure s :=
disjoint.comm.trans disjoint_nhds_set_nhds
lemma exists_mem_nhds_is_closed_subset {a : α} {s : set α} (h : s ∈ 𝓝 a) :
∃ t ∈ 𝓝 a, is_closed t ∧ t ⊆ s :=
iff.mp ((regular_space_tfae α).out 0 3) ‹_› _ _ h
lemma closed_nhds_basis (a : α) : (𝓝 a).has_basis (λ s : set α, s ∈ 𝓝 a ∧ is_closed s) id :=
has_basis_self.2 (λ _, exists_mem_nhds_is_closed_subset)
lemma lift'_nhds_closure (a : α) : (𝓝 a).lift' closure = 𝓝 a :=
(closed_nhds_basis a).lift'_closure_eq_self (λ s hs, hs.2)
lemma filter.has_basis.nhds_closure {ι : Sort*} {a : α} {p : ι → Prop} {s : ι → set α}
(h : (𝓝 a).has_basis p s) : (𝓝 a).has_basis p (λ i, closure (s i)) :=
lift'_nhds_closure a ▸ h.lift'_closure
lemma has_basis_nhds_closure (a : α) : (𝓝 a).has_basis (λ s, s ∈ 𝓝 a) closure :=
(𝓝 a).basis_sets.nhds_closure
lemma has_basis_opens_closure (a : α) : (𝓝 a).has_basis (λ s, a ∈ s ∧ is_open s) closure :=
(nhds_basis_opens a).nhds_closure
lemma topological_space.is_topological_basis.nhds_basis_closure
{B : set (set α)} (hB : topological_space.is_topological_basis B) (a : α) :
(𝓝 a).has_basis (λ s : set α, a ∈ s ∧ s ∈ B) closure :=
by simpa only [and_comm] using hB.nhds_has_basis.nhds_closure
lemma topological_space.is_topological_basis.exists_closure_subset
{B : set (set α)} (hB : topological_space.is_topological_basis B) {a : α} {s : set α}
(h : s ∈ 𝓝 a) :
∃ t ∈ B, a ∈ t ∧ closure t ⊆ s :=
by simpa only [exists_prop, and.assoc] using hB.nhds_has_basis.nhds_closure.mem_iff.mp h
lemma disjoint_nhds_nhds_iff_not_specializes {a b : α} :
disjoint (𝓝 a) (𝓝 b) ↔ ¬a ⤳ b :=
by rw [← nhds_set_singleton, disjoint_nhds_set_nhds, specializes_iff_mem_closure]
lemma specializes_comm {a b : α} : a ⤳ b ↔ b ⤳ a :=
by simp only [← disjoint_nhds_nhds_iff_not_specializes.not_left, disjoint.comm]
alias specializes_comm ↔ specializes.symm _
lemma specializes_iff_inseparable {a b : α} : a ⤳ b ↔ inseparable a b :=
⟨λ h, h.antisymm h.symm, le_of_eq⟩
lemma is_closed_set_of_specializes : is_closed {p : α × α | p.1 ⤳ p.2} :=
by simp only [← is_open_compl_iff, compl_set_of, ← disjoint_nhds_nhds_iff_not_specializes,
is_open_set_of_disjoint_nhds_nhds]
lemma is_closed_set_of_inseparable : is_closed {p : α × α | inseparable p.1 p.2} :=
by simp only [← specializes_iff_inseparable, is_closed_set_of_specializes]
protected lemma inducing.regular_space [topological_space β] {f : β → α} (hf : inducing f) :
regular_space β :=
regular_space.of_basis (λ b, by { rw [hf.nhds_eq_comap b], exact (closed_nhds_basis _).comap _ }) $
λ b s hs, hs.2.preimage hf.continuous
lemma regular_space_induced (f : β → α) : @regular_space β (induced f ‹_›) :=
by { letI := induced f ‹_›, exact inducing.regular_space ⟨rfl⟩ }
lemma regular_space_Inf {X} {T : set (topological_space X)} (h : ∀ t ∈ T, @regular_space X t) :
@regular_space X (Inf T) :=
begin
letI := Inf T,
have : ∀ a, (𝓝 a).has_basis
(λ If : Σ I : set T, I → set X,
If.1.finite ∧ ∀ i : If.1, If.2 i ∈ @nhds X i a ∧ @is_closed X i (If.2 i))
(λ If, ⋂ i : If.1, If.snd i),
{ intro a,
rw [nhds_Inf, ← infi_subtype''],
exact has_basis_infi (λ t : T, @closed_nhds_basis X t (h t t.2) a) },
refine regular_space.of_basis this (λ a If hIf, is_closed_Inter $ λ i, _),
exact (hIf.2 i).2.mono (Inf_le (i : T).2)
end
lemma regular_space_infi {ι X} {t : ι → topological_space X} (h : ∀ i, @regular_space X (t i)) :
@regular_space X (infi t) :=
regular_space_Inf $ forall_range_iff.mpr h
lemma regular_space.inf {X} {t₁ t₂ : topological_space X} (h₁ : @regular_space X t₁)
(h₂ : @regular_space X t₂) : @regular_space X (t₁ ⊓ t₂) :=
by { rw [inf_eq_infi], exact regular_space_infi (bool.forall_bool.2 ⟨h₂, h₁⟩) }
instance {p : α → Prop} : regular_space (subtype p) :=
embedding_subtype_coe.to_inducing.regular_space
instance [topological_space β] [regular_space β] : regular_space (α × β) :=
(regular_space_induced prod.fst).inf (regular_space_induced prod.snd)
instance {ι : Type*} {π : ι → Type*} [Π i, topological_space (π i)] [∀ i, regular_space (π i)] :
regular_space (Π i, π i) :=
regular_space_infi $ λ i, regular_space_induced _
end regular_space
section t3
/-- A T₃ space is a T₀ space which is a regular space. Any T₃ space is a T₁ space, a T₂ space, and
a T₂.₅ space. -/
class t3_space (α : Type u) [topological_space α] extends t0_space α, regular_space α : Prop
@[priority 100] -- see Note [lower instance priority]
instance t3_space.t2_5_space [t3_space α] : t2_5_space α :=
begin
refine ⟨λ x y hne, _⟩,
rw [lift'_nhds_closure, lift'_nhds_closure],
have : x ∉ closure {y} ∨ y ∉ closure {x},
from (t0_space_iff_or_not_mem_closure α).mp infer_instance x y hne,
wlog H : x ∉ closure {y} := this using [x y, y x] tactic.skip,
{ rwa [← disjoint_nhds_nhds_set, nhds_set_singleton] at H },
{ exact λ h, (this h.symm).symm }
end
protected lemma embedding.t3_space [topological_space β] [t3_space β] {f : α → β}
(hf : embedding f) : t3_space α :=
{ to_t0_space := hf.t0_space,
to_regular_space := hf.to_inducing.regular_space }
instance subtype.t3_space [t3_space α] {p : α → Prop} : t3_space (subtype p) :=
embedding_subtype_coe.t3_space
instance [topological_space β] [t3_space α] [t3_space β] : t3_space (α × β) := ⟨⟩
instance {ι : Type*} {π : ι → Type*} [Π i, topological_space (π i)] [Π i, t3_space (π i)] :
t3_space (Π i, π i) := ⟨⟩
/-- Given two points `x ≠ y`, we can find neighbourhoods `x ∈ V₁ ⊆ U₁` and `y ∈ V₂ ⊆ U₂`,
with the `Vₖ` closed and the `Uₖ` open, such that the `Uₖ` are disjoint. -/
lemma disjoint_nested_nhds [t3_space α] {x y : α} (h : x ≠ y) :
∃ (U₁ V₁ ∈ 𝓝 x) (U₂ V₂ ∈ 𝓝 y), is_closed V₁ ∧ is_closed V₂ ∧ is_open U₁ ∧ is_open U₂ ∧
V₁ ⊆ U₁ ∧ V₂ ⊆ U₂ ∧ disjoint U₁ U₂ :=
begin
rcases t2_separation h with ⟨U₁, U₂, U₁_op, U₂_op, x_in, y_in, H⟩,
rcases exists_mem_nhds_is_closed_subset (U₁_op.mem_nhds x_in) with ⟨V₁, V₁_in, V₁_closed, h₁⟩,
rcases exists_mem_nhds_is_closed_subset (U₂_op.mem_nhds y_in) with ⟨V₂, V₂_in, V₂_closed, h₂⟩,
exact ⟨U₁, mem_of_superset V₁_in h₁, V₁, V₁_in, U₂, mem_of_superset V₂_in h₂, V₂, V₂_in,
V₁_closed, V₂_closed, U₁_op, U₂_op, h₁, h₂, H⟩
end
open separation_quotient
/-- The `separation_quotient` of a regular space is a T₃ space. -/
instance [regular_space α] : t3_space (separation_quotient α) :=
{ regular := λ s, surjective_mk.forall.2 $ λ a hs ha,
by { rw [← disjoint_comap_iff surjective_mk, comap_mk_nhds_mk, comap_mk_nhds_set],
exact regular_space.regular (hs.preimage continuous_mk) ha } }
end t3
section normality
/-- A T₄ space, also known as a normal space (although this condition sometimes
omits T₂), is one in which for every pair of disjoint closed sets `C` and `D`,
there exist disjoint open sets containing `C` and `D` respectively. -/
class normal_space (α : Type u) [topological_space α] extends t1_space α : Prop :=
(normal : ∀ s t : set α, is_closed s → is_closed t → disjoint s t → separated_nhds s t)
theorem normal_separation [normal_space α] {s t : set α}
(H1 : is_closed s) (H2 : is_closed t) (H3 : disjoint s t) :
separated_nhds s t :=
normal_space.normal s t H1 H2 H3
theorem normal_exists_closure_subset [normal_space α] {s t : set α} (hs : is_closed s)
(ht : is_open t) (hst : s ⊆ t) :
∃ u, is_open u ∧ s ⊆ u ∧ closure u ⊆ t :=
begin
have : disjoint s tᶜ, from set.disjoint_left.mpr (λ x hxs hxt, hxt (hst hxs)),
rcases normal_separation hs (is_closed_compl_iff.2 ht) this
with ⟨s', t', hs', ht', hss', htt', hs't'⟩,
refine ⟨s', hs', hss',
subset.trans (closure_minimal _ (is_closed_compl_iff.2 ht')) (compl_subset_comm.1 htt')⟩,
exact λ x hxs hxt, hs't'.le_bot ⟨hxs, hxt⟩
end
@[priority 100] -- see Note [lower instance priority]
instance normal_space.t3_space [normal_space α] : t3_space α :=
{ regular := λ s x hs hxs, let ⟨u, v, hu, hv, hsu, hxv, huv⟩ :=
normal_separation hs is_closed_singleton (disjoint_singleton_right.mpr hxs) in
disjoint_of_disjoint_of_mem huv (hu.mem_nhds_set.2 hsu) (hv.mem_nhds $ hxv rfl) }
-- We can't make this an instance because it could cause an instance loop.
lemma normal_of_compact_t2 [compact_space α] [t2_space α] : normal_space α :=
⟨λ s t hs ht, is_compact_is_compact_separated hs.is_compact ht.is_compact⟩
protected lemma closed_embedding.normal_space [topological_space β] [normal_space β] {f : α → β}
(hf : closed_embedding f) : normal_space α :=
{ to_t1_space := hf.to_embedding.t1_space,
normal :=
begin
intros s t hs ht hst,
have H : separated_nhds (f '' s) (f '' t),
from normal_space.normal (f '' s) (f '' t) (hf.is_closed_map s hs) (hf.is_closed_map t ht)
(disjoint_image_of_injective hf.inj hst),
exact (H.preimage hf.continuous).mono (subset_preimage_image _ _) (subset_preimage_image _ _)
end }
namespace separation_quotient
/-- The `separation_quotient` of a normal space is a T₄ space. We don't have separate typeclasses
for normal spaces (without T₁ assumption) and T₄ spaces, so we use the same class for assumption
and for conclusion.
One can prove this using a homeomorphism between `α` and `separation_quotient α`. We give an
alternative proof that works without assuming that `α` is a T₁ space. -/
instance [normal_space α] : normal_space (separation_quotient α) :=
{ normal := λ s t hs ht hd, separated_nhds_iff_disjoint.2 $
begin
rw [← disjoint_comap_iff surjective_mk, comap_mk_nhds_set, comap_mk_nhds_set],
exact separated_nhds_iff_disjoint.1 (normal_separation (hs.preimage continuous_mk)
(ht.preimage continuous_mk) (hd.preimage mk))
end }
end separation_quotient
variable (α)
/-- A T₃ topological space with second countable topology is a normal space.
This lemma is not an instance to avoid a loop. -/
lemma normal_space_of_t3_second_countable [second_countable_topology α] [t3_space α] :
normal_space α :=
begin
have key : ∀ {s t : set α}, is_closed t → disjoint s t →
∃ U : set (countable_basis α), (s ⊆ ⋃ u ∈ U, ↑u) ∧
(∀ u ∈ U, disjoint (closure ↑u) t) ∧
∀ n : ℕ, is_closed (⋃ (u ∈ U) (h : encodable.encode u ≤ n), closure (u : set α)),
{ intros s t hc hd,
rw disjoint_left at hd,
have : ∀ x ∈ s, ∃ U ∈ countable_basis α, x ∈ U ∧ disjoint (closure U) t,
{ intros x hx,
rcases (is_basis_countable_basis α).exists_closure_subset (hc.is_open_compl.mem_nhds (hd hx))
with ⟨u, hu, hxu, hut⟩,
exact ⟨u, hu, hxu, disjoint_left.2 hut⟩ },
choose! U hu hxu hd,
set V : s → countable_basis α := maps_to.restrict _ _ _ hu,
refine ⟨range V, _, forall_range_iff.2 $ subtype.forall.2 hd, λ n, _⟩,
{ rw bUnion_range,
exact λ x hx, mem_Union.2 ⟨⟨x, hx⟩, hxu x hx⟩ },
{ simp only [← supr_eq_Union, supr_and'],
exact is_closed_bUnion (((finite_le_nat n).preimage_embedding (encodable.encode' _)).subset $
inter_subset_right _ _) (λ u hu, is_closed_closure) } },
refine ⟨λ s t hs ht hd, _⟩,
rcases key ht hd with ⟨U, hsU, hUd, hUc⟩,
rcases key hs hd.symm with ⟨V, htV, hVd, hVc⟩,
refine ⟨⋃ u ∈ U, ↑u \ ⋃ (v ∈ V) (hv : encodable.encode v ≤ encodable.encode u), closure ↑v,
⋃ v ∈ V, ↑v \ ⋃ (u ∈ U) (hu : encodable.encode u ≤ encodable.encode v), closure ↑u,
is_open_bUnion $ λ u hu, (is_open_of_mem_countable_basis u.2).sdiff (hVc _),
is_open_bUnion $ λ v hv, (is_open_of_mem_countable_basis v.2).sdiff (hUc _),
λ x hx, _, λ x hx, _, _⟩,
{ rcases mem_Union₂.1 (hsU hx) with ⟨u, huU, hxu⟩,
refine mem_bUnion huU ⟨hxu, _⟩,
simp only [mem_Union],
rintro ⟨v, hvV, -, hxv⟩,
exact (hVd v hvV).le_bot ⟨hxv, hx⟩ },
{ rcases mem_Union₂.1 (htV hx) with ⟨v, hvV, hxv⟩,
refine mem_bUnion hvV ⟨hxv, _⟩,
simp only [mem_Union],
rintro ⟨u, huU, -, hxu⟩,
exact (hUd u huU).le_bot ⟨hxu, hx⟩ },
{ simp only [disjoint_left, mem_Union, mem_diff, not_exists, not_and, not_forall, not_not],
rintro a ⟨u, huU, hau, haV⟩ v hvV hav,
cases le_total (encodable.encode u) (encodable.encode v) with hle hle,
exacts [⟨u, huU, hle, subset_closure hau⟩, (haV _ hvV hle $ subset_closure hav).elim] }
end
end normality
section completely_normal
/-- A topological space `α` is a *completely normal Hausdorff space* if each subspace `s : set α` is
a normal Hausdorff space. Equivalently, `α` is a `T₁` space and for any two sets `s`, `t` such that
`closure s` is disjoint with `t` and `s` is disjoint with `closure t`, there exist disjoint
neighbourhoods of `s` and `t`. -/
class t5_space (α : Type u) [topological_space α] extends t1_space α : Prop :=
(completely_normal : ∀ ⦃s t : set α⦄, disjoint (closure s) t → disjoint s (closure t) →
disjoint (𝓝ˢ s) (𝓝ˢ t))
export t5_space (completely_normal)
lemma embedding.t5_space [topological_space β] [t5_space β] {e : α → β} (he : embedding e) :
t5_space α :=
begin
haveI := he.t1_space,
refine ⟨λ s t hd₁ hd₂, _⟩,
simp only [he.to_inducing.nhds_set_eq_comap],
refine disjoint_comap (completely_normal _ _),
{ rwa [← subset_compl_iff_disjoint_left, image_subset_iff, preimage_compl,
← he.closure_eq_preimage_closure_image, subset_compl_iff_disjoint_left] },
{ rwa [← subset_compl_iff_disjoint_right, image_subset_iff, preimage_compl,
← he.closure_eq_preimage_closure_image, subset_compl_iff_disjoint_right] }
end
/-- A subspace of a `T₅` space is a `T₅` space. -/
instance [t5_space α] {p : α → Prop} : t5_space {x // p x} := embedding_subtype_coe.t5_space
/-- A `T₅` space is a `T₄` space. -/
@[priority 100] -- see Note [lower instance priority]
instance t5_space.to_normal_space [t5_space α] : normal_space α :=
⟨λ s t hs ht hd, separated_nhds_iff_disjoint.2 $
completely_normal (by rwa [hs.closure_eq]) (by rwa [ht.closure_eq])⟩
open separation_quotient
/-- The `separation_quotient` of a completely normal space is a T₅ space. We don't have separate
typeclasses for completely normal spaces (without T₁ assumption) and T₅ spaces, so we use the same
class for assumption and for conclusion.
One can prove this using a homeomorphism between `α` and `separation_quotient α`. We give an
alternative proof that works without assuming that `α` is a T₁ space. -/
instance [t5_space α] : t5_space (separation_quotient α) :=
{ completely_normal := λ s t hd₁ hd₂,
begin
rw [← disjoint_comap_iff surjective_mk, comap_mk_nhds_set, comap_mk_nhds_set],
apply t5_space.completely_normal; rw [← preimage_mk_closure],
exacts [hd₁.preimage mk, hd₂.preimage mk]
end }
end completely_normal
/-- In a compact t2 space, the connected component of a point equals the intersection of all
its clopen neighbourhoods. -/
lemma connected_component_eq_Inter_clopen [t2_space α] [compact_space α] (x : α) :
connected_component x = ⋂ Z : {Z : set α // is_clopen Z ∧ x ∈ Z}, Z :=
begin
apply eq_of_subset_of_subset connected_component_subset_Inter_clopen,
-- Reduce to showing that the clopen intersection is connected.
refine is_preconnected.subset_connected_component _ (mem_Inter.2 (λ Z, Z.2.2)),
-- We do this by showing that any disjoint cover by two closed sets implies
-- that one of these closed sets must contain our whole thing.
-- To reduce to the case where the cover is disjoint on all of `α` we need that `s` is closed
have hs : @is_closed α _ (⋂ (Z : {Z : set α // is_clopen Z ∧ x ∈ Z}), Z) :=
is_closed_Inter (λ Z, Z.2.1.2),
rw (is_preconnected_iff_subset_of_fully_disjoint_closed hs),
intros a b ha hb hab ab_disj,
haveI := @normal_of_compact_t2 α _ _ _,
-- Since our space is normal, we get two larger disjoint open sets containing the disjoint
-- closed sets. If we can show that our intersection is a subset of any of these we can then
-- "descend" this to show that it is a subset of either a or b.
rcases normal_separation ha hb ab_disj with ⟨u, v, hu, hv, hau, hbv, huv⟩,
-- If we can find a clopen set around x, contained in u ∪ v, we get a disjoint decomposition
-- Z = Z ∩ u ∪ Z ∩ v of clopen sets. The intersection of all clopen neighbourhoods will then lie
-- in whichever of u or v x lies in and hence will be a subset of either a or b.
rsuffices ⟨Z, H⟩ : ∃ (Z : set α), is_clopen Z ∧ x ∈ Z ∧ Z ⊆ u ∪ v,
{ have H1 := is_clopen_inter_of_disjoint_cover_clopen H.1 H.2.2 hu hv huv,
rw [union_comm] at H,
have H2 := is_clopen_inter_of_disjoint_cover_clopen H.1 H.2.2 hv hu huv.symm,
by_cases (x ∈ u),
-- The x ∈ u case.
{ left,
suffices : (⋂ (Z : {Z : set α // is_clopen Z ∧ x ∈ Z}), ↑Z) ⊆ u,
{ replace hab : (⋂ (Z : {Z // is_clopen Z ∧ x ∈ Z}), ↑Z) ≤ a ∪ b := hab,
replace this : (⋂ (Z : {Z // is_clopen Z ∧ x ∈ Z}), ↑Z) ≤ u := this,
exact disjoint.left_le_of_le_sup_right hab (huv.mono this hbv) },
{ apply subset.trans _ (inter_subset_right Z u),
apply Inter_subset (λ Z : {Z : set α // is_clopen Z ∧ x ∈ Z}, ↑Z)
⟨Z ∩ u, H1, mem_inter H.2.1 h⟩ } },
-- If x ∉ u, we get x ∈ v since x ∈ u ∪ v. The rest is then like the x ∈ u case.
have h1 : x ∈ v,
{ cases (mem_union x u v).1 (mem_of_subset_of_mem (subset.trans hab
(union_subset_union hau hbv)) (mem_Inter.2 (λ i, i.2.2))) with h1 h1,
{ exfalso, exact h h1},
{ exact h1} },
right,
suffices : (⋂ (Z : {Z : set α // is_clopen Z ∧ x ∈ Z}), ↑Z) ⊆ v,
{ replace this : (⋂ (Z : {Z // is_clopen Z ∧ x ∈ Z}), ↑Z) ≤ v := this,
exact (huv.symm.mono this hau).left_le_of_le_sup_left hab },
{ apply subset.trans _ (inter_subset_right Z v),
apply Inter_subset (λ Z : {Z : set α // is_clopen Z ∧ x ∈ Z}, ↑Z)
⟨Z ∩ v, H2, mem_inter H.2.1 h1⟩ } },
-- Now we find the required Z. We utilize the fact that X \ u ∪ v will be compact,
-- so there must be some finite intersection of clopen neighbourhoods of X disjoint to it,
-- but a finite intersection of clopen sets is clopen so we let this be our Z.
have H1 := (hu.union hv).is_closed_compl.is_compact.inter_Inter_nonempty
(λ Z : {Z : set α // is_clopen Z ∧ x ∈ Z}, Z) (λ Z, Z.2.1.2),
rw [←not_disjoint_iff_nonempty_inter, imp_not_comm, not_forall] at H1,
cases H1 (disjoint_compl_left_iff_subset.2 $ hab.trans $ union_subset_union hau hbv) with Zi H2,
refine ⟨(⋂ (U ∈ Zi), subtype.val U), _, _, _⟩,
{ exact is_clopen_bInter_finset (λ Z hZ, Z.2.1) },
{ exact mem_Inter₂.2 (λ Z hZ, Z.2.2) },
{ rwa [←disjoint_compl_left_iff_subset, disjoint_iff_inter_eq_empty, ←not_nonempty_iff_eq_empty] }
end
section profinite
/-- A T1 space with a clopen basis is totally separated. -/
lemma totally_separated_space_of_t1_of_basis_clopen [t1_space α]
(h : is_topological_basis {s : set α | is_clopen s}) :
totally_separated_space α :=
begin
constructor,
rintros x - y - hxy,
rcases h.mem_nhds_iff.mp (is_open_ne.mem_nhds hxy) with ⟨U, hU, hxU, hyU⟩,
exact ⟨U, Uᶜ, hU.is_open, hU.compl.is_open, hxU, λ h, hyU h rfl,
(union_compl_self U).superset, disjoint_compl_right⟩
end
variables [t2_space α] [compact_space α]
/-- A compact Hausdorff space is totally disconnected if and only if it is totally separated, this
is also true for locally compact spaces. -/
theorem compact_t2_tot_disc_iff_tot_sep :
totally_disconnected_space α ↔ totally_separated_space α :=
begin
split,
{ intro h, constructor,
rintros x - y -,
contrapose!,
intros hyp,
suffices : x ∈ connected_component y,
by simpa [totally_disconnected_space_iff_connected_component_singleton.1 h y,
mem_singleton_iff],
rw [connected_component_eq_Inter_clopen, mem_Inter],
rintro ⟨w : set α, hw : is_clopen w, hy : y ∈ w⟩,
by_contra hx,
exact hyp wᶜ w hw.2.is_open_compl hw.1 hx hy (@is_compl_compl _ w _).symm.codisjoint.top_le
disjoint_compl_left },
apply totally_separated_space.totally_disconnected_space,
end
variables [totally_disconnected_space α]
lemma nhds_basis_clopen (x : α) : (𝓝 x).has_basis (λ s : set α, x ∈ s ∧ is_clopen s) id :=
⟨λ U, begin
split,
{ have : connected_component x = {x},
from totally_disconnected_space_iff_connected_component_singleton.mp ‹_› x,
rw connected_component_eq_Inter_clopen at this,
intros hU,
let N := {Z // is_clopen Z ∧ x ∈ Z},
rsuffices ⟨⟨s, hs, hs'⟩, hs''⟩ : ∃ Z : N, Z.val ⊆ U,
{ exact ⟨s, ⟨hs', hs⟩, hs''⟩ },
haveI : nonempty N := ⟨⟨univ, is_clopen_univ, mem_univ x⟩⟩,
have hNcl : ∀ Z : N, is_closed Z.val := (λ Z, Z.property.1.2),
have hdir : directed superset (λ Z : N, Z.val),
{ rintros ⟨s, hs, hxs⟩ ⟨t, ht, hxt⟩,
exact ⟨⟨s ∩ t, hs.inter ht, ⟨hxs, hxt⟩⟩, inter_subset_left s t, inter_subset_right s t⟩ },
have h_nhd: ∀ y ∈ (⋂ Z : N, Z.val), U ∈ 𝓝 y,
{ intros y y_in,
erw [this, mem_singleton_iff] at y_in,
rwa y_in },
exact exists_subset_nhds_of_compact_space hdir hNcl h_nhd },
{ rintro ⟨V, ⟨hxV, V_op, -⟩, hUV : V ⊆ U⟩,
rw mem_nhds_iff,
exact ⟨V, hUV, V_op, hxV⟩ }
end⟩
lemma is_topological_basis_clopen : is_topological_basis {s : set α | is_clopen s} :=
begin
apply is_topological_basis_of_open_of_nhds (λ U (hU : is_clopen U), hU.1),
intros x U hxU U_op,
have : U ∈ 𝓝 x,
from is_open.mem_nhds U_op hxU,
rcases (nhds_basis_clopen x).mem_iff.mp this with ⟨V, ⟨hxV, hV⟩, hVU : V ⊆ U⟩,
use V,
tauto
end
/-- Every member of an open set in a compact Hausdorff totally disconnected space
is contained in a clopen set contained in the open set. -/
lemma compact_exists_clopen_in_open {x : α} {U : set α} (is_open : is_open U) (memU : x ∈ U) :
∃ (V : set α) (hV : is_clopen V), x ∈ V ∧ V ⊆ U :=
(is_topological_basis.mem_nhds_iff is_topological_basis_clopen).1 (is_open.mem_nhds memU)
end profinite
section locally_compact
variables {H : Type*} [topological_space H] [locally_compact_space H] [t2_space H]
/-- A locally compact Hausdorff totally disconnected space has a basis with clopen elements. -/
lemma loc_compact_Haus_tot_disc_of_zero_dim [totally_disconnected_space H] :
is_topological_basis {s : set H | is_clopen s} :=
begin
refine is_topological_basis_of_open_of_nhds (λ u hu, hu.1) _,
rintros x U memU hU,
obtain ⟨s, comp, xs, sU⟩ := exists_compact_subset hU memU,
obtain ⟨t, h, ht, xt⟩ := mem_interior.1 xs,
let u : set s := (coe : s → H)⁻¹' (interior s),
have u_open_in_s : is_open u := is_open_interior.preimage continuous_subtype_coe,
let X : s := ⟨x, h xt⟩,
have Xu : X ∈ u := xs,
haveI : compact_space s := is_compact_iff_compact_space.1 comp,
obtain ⟨V : set s, clopen_in_s, Vx, V_sub⟩ := compact_exists_clopen_in_open u_open_in_s Xu,
have V_clopen : is_clopen ((coe : s → H) '' V),
{ refine ⟨_, (comp.is_closed.closed_embedding_subtype_coe.closed_iff_image_closed).1
clopen_in_s.2⟩,
let v : set u := (coe : u → s)⁻¹' V,
have : (coe : u → H) = (coe : s → H) ∘ (coe : u → s) := rfl,
have f0 : embedding (coe : u → H) := embedding_subtype_coe.comp embedding_subtype_coe,
have f1 : open_embedding (coe : u → H),
{ refine ⟨f0, _⟩,
{ have : set.range (coe : u → H) = interior s,
{ rw [this, set.range_comp, subtype.range_coe, subtype.image_preimage_coe],
apply set.inter_eq_self_of_subset_left interior_subset, },
rw this,
apply is_open_interior } },
have f2 : is_open v := clopen_in_s.1.preimage continuous_subtype_coe,
have f3 : (coe : s → H) '' V = (coe : u → H) '' v,
{ rw [this, image_comp coe coe, subtype.image_preimage_coe,
inter_eq_self_of_subset_left V_sub] },
rw f3,
apply f1.is_open_map v f2 },
refine ⟨coe '' V, V_clopen, by simp [Vx, h xt], _⟩,
transitivity s,
{ simp },
assumption
end
/-- A locally compact Hausdorff space is totally disconnected
if and only if it is totally separated. -/
theorem loc_compact_t2_tot_disc_iff_tot_sep :
totally_disconnected_space H ↔ totally_separated_space H :=
begin
split,
{ introI h,
exact totally_separated_space_of_t1_of_basis_clopen loc_compact_Haus_tot_disc_of_zero_dim },
apply totally_separated_space.totally_disconnected_space,
end
end locally_compact
/-- `connected_components α` is Hausdorff when `α` is Hausdorff and compact -/
instance connected_components.t2 [t2_space α] [compact_space α] :
t2_space (connected_components α) :=
begin
-- Proof follows that of: https://stacks.math.columbia.edu/tag/0900
-- Fix 2 distinct connected components, with points a and b
refine ⟨connected_components.surjective_coe.forall₂.2 $ λ a b ne, _⟩,
rw connected_components.coe_ne_coe at ne,
have h := connected_component_disjoint ne,
-- write ↑b as the intersection of all clopen subsets containing it
rw [connected_component_eq_Inter_clopen b, disjoint_iff_inter_eq_empty] at h,
-- Now we show that this can be reduced to some clopen containing `↑b` being disjoint to `↑a`
obtain ⟨U, V, hU, ha, hb, rfl⟩ : ∃ (U : set α) (V : set (connected_components α)), is_clopen U ∧
connected_component a ∩ U = ∅ ∧ connected_component b ⊆ U ∧ coe ⁻¹' V = U,
{ cases is_closed_connected_component.is_compact.elim_finite_subfamily_closed _ _ h with fin_a ha,
swap, { exact λ Z, Z.2.1.2 },
-- This clopen and its complement will separate the connected components of `a` and `b`
set U : set α := (⋂ (i : {Z // is_clopen Z ∧ b ∈ Z}) (H : i ∈ fin_a), i),
have hU : is_clopen U := is_clopen_bInter_finset (λ i j, i.2.1),
exact ⟨U, coe '' U, hU, ha, subset_Inter₂ (λ Z _, Z.2.1.connected_component_subset Z.2.2),
(connected_components_preimage_image U).symm ▸ hU.bUnion_connected_component_eq⟩ },
rw connected_components.quotient_map_coe.is_clopen_preimage at hU,
refine ⟨Vᶜ, V, hU.compl.is_open, hU.is_open, _, hb mem_connected_component, disjoint_compl_left⟩,
exact λ h, flip set.nonempty.ne_empty ha ⟨a, mem_connected_component, h⟩,
end
|
6e497e3478822b79e01566afd5646c258be0305f | c09f5945267fd905e23a77be83d9a78580e04a4a | /src/topology/algebra/group.lean | 07c16c51b71211b9dba71f2c9595a725bb87b556 | [
"Apache-2.0"
] | permissive | OHIHIYA20/mathlib | 023a6df35355b5b6eb931c404f7dd7535dccfa89 | 1ec0a1f49db97d45e8666a3bf33217ff79ca1d87 | refs/heads/master | 1,587,964,529,965 | 1,551,819,319,000 | 1,551,819,319,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 13,374 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot
Theory of topological groups.
-/
import data.equiv.algebra
import group_theory.quotient_group
import topology.algebra.monoid
open classical set lattice filter topological_space
local attribute [instance] classical.prop_decidable
universes u v w
variables {α : Type u} {β : Type v} {γ : Type w}
section topological_group
/-- A topological group is a group in which the multiplication and inversion operations are
continuous. -/
class topological_group (α : Type*) [topological_space α] [group α]
extends topological_monoid α : Prop :=
(continuous_inv : continuous (λa:α, a⁻¹))
/-- A topological (additive) group is a group in which the addition and negation operations are
continuous. -/
class topological_add_group (α : Type u) [topological_space α] [add_group α]
extends topological_add_monoid α : Prop :=
(continuous_neg : continuous (λa:α, -a))
attribute [to_additive topological_add_group] topological_group
attribute [to_additive topological_add_group.mk] topological_group.mk
attribute [to_additive topological_add_group.continuous_neg] topological_group.continuous_inv
attribute [to_additive topological_add_group.to_topological_add_monoid] topological_group.to_topological_monoid
variables [topological_space α] [group α]
@[to_additive continuous_neg']
lemma continuous_inv' [topological_group α] : continuous (λx:α, x⁻¹) :=
topological_group.continuous_inv α
@[to_additive continuous_neg]
lemma continuous_inv [topological_group α] [topological_space β] {f : β → α}
(hf : continuous f) : continuous (λx, (f x)⁻¹) :=
hf.comp continuous_inv'
@[to_additive tendsto_neg]
lemma tendsto_inv [topological_group α] {f : β → α} {x : filter β} {a : α}
(hf : tendsto f x (nhds a)) : tendsto (λx, (f x)⁻¹) x (nhds a⁻¹) :=
hf.comp (continuous_iff_continuous_at.mp (topological_group.continuous_inv α) a)
@[to_additive prod.topological_add_group]
instance [topological_group α] [topological_space β] [group β] [topological_group β] :
topological_group (α × β) :=
{ continuous_inv := continuous.prod_mk (continuous_inv continuous_fst) (continuous_inv continuous_snd) }
attribute [instance] prod.topological_add_group
protected def homeomorph.mul_left [topological_group α] (a : α) : α ≃ₜ α :=
{ continuous_to_fun := continuous_mul continuous_const continuous_id,
continuous_inv_fun := continuous_mul continuous_const continuous_id,
.. equiv.mul_left a }
attribute [to_additive homeomorph.add_left._proof_1] homeomorph.mul_left._proof_1
attribute [to_additive homeomorph.add_left._proof_2] homeomorph.mul_left._proof_2
attribute [to_additive homeomorph.add_left._proof_3] homeomorph.mul_left._proof_3
attribute [to_additive homeomorph.add_left._proof_4] homeomorph.mul_left._proof_4
attribute [to_additive homeomorph.add_left] homeomorph.mul_left
@[to_additive is_open_map_add_left]
lemma is_open_map_mul_left [topological_group α] (a : α) : is_open_map (λ x, a * x) :=
(homeomorph.mul_left a).is_open_map
protected def homeomorph.mul_right
{α : Type*} [topological_space α] [group α] [topological_group α] (a : α) :
α ≃ₜ α :=
{ continuous_to_fun := continuous_mul continuous_id continuous_const,
continuous_inv_fun := continuous_mul continuous_id continuous_const,
.. equiv.mul_right a }
attribute [to_additive homeomorph.add_right._proof_1] homeomorph.mul_right._proof_1
attribute [to_additive homeomorph.add_right._proof_2] homeomorph.mul_right._proof_2
attribute [to_additive homeomorph.add_right._proof_3] homeomorph.mul_right._proof_3
attribute [to_additive homeomorph.add_right._proof_4] homeomorph.mul_right._proof_4
attribute [to_additive homeomorph.add_right] homeomorph.mul_right
@[to_additive is_open_map_add_right]
lemma is_open_map_mul_right [topological_group α] (a : α) : is_open_map (λ x, x * a) :=
(homeomorph.mul_right a).is_open_map
protected def homeomorph.inv (α : Type*) [topological_space α] [group α] [topological_group α] :
α ≃ₜ α :=
{ continuous_to_fun := continuous_inv',
continuous_inv_fun := continuous_inv',
.. equiv.inv α }
attribute [to_additive homeomorph.neg._proof_1] homeomorph.inv._proof_1
attribute [to_additive homeomorph.neg._proof_2] homeomorph.inv._proof_2
attribute [to_additive homeomorph.neg] homeomorph.inv
@[to_additive exists_nhds_half]
lemma exists_nhds_split [topological_group α] {s : set α} (hs : s ∈ (nhds (1 : α)).sets) :
∃ V ∈ (nhds (1 : α)).sets, ∀ v w ∈ V, v * w ∈ s :=
begin
have : ((λa:α×α, a.1 * a.2) ⁻¹' s) ∈ (nhds ((1, 1) : α × α)).sets :=
tendsto_mul' (by simpa using hs),
rw nhds_prod_eq at this,
rcases mem_prod_iff.1 this with ⟨V₁, H₁, V₂, H₂, H⟩,
exact ⟨V₁ ∩ V₂, inter_mem_sets H₁ H₂, assume v w ⟨hv, _⟩ ⟨_, hw⟩, @H (v, w) ⟨hv, hw⟩⟩
end
@[to_additive exists_nhds_half_neg]
lemma exists_nhds_split_inv [topological_group α] {s : set α} (hs : s ∈ (nhds (1 : α)).sets) :
∃ V ∈ (nhds (1 : α)).sets, ∀ v w ∈ V, v * w⁻¹ ∈ s :=
begin
have : tendsto (λa:α×α, a.1 * (a.2)⁻¹) ((nhds (1:α)).prod (nhds (1:α))) (nhds 1),
{ simpa using tendsto_mul (@tendsto_fst α α (nhds 1) (nhds 1)) (tendsto_inv tendsto_snd) },
have : ((λa:α×α, a.1 * (a.2)⁻¹) ⁻¹' s) ∈ ((nhds (1:α)).prod (nhds (1:α))).sets :=
this (by simpa using hs),
rcases mem_prod_iff.1 this with ⟨V₁, H₁, V₂, H₂, H⟩,
exact ⟨V₁ ∩ V₂, inter_mem_sets H₁ H₂, assume v w ⟨hv, _⟩ ⟨_, hw⟩, @H (v, w) ⟨hv, hw⟩⟩
end
@[to_additive exists_nhds_quarter]
lemma exists_nhds_split4 [topological_group α] {u : set α} (hu : u ∈ (nhds (1 : α)).sets) :
∃ V ∈ (nhds (1 : α)).sets, ∀ {v w s t}, v ∈ V → w ∈ V → s ∈ V → t ∈ V → v * w * s * t ∈ u :=
begin
rcases exists_nhds_split hu with ⟨W, W_nhd, h⟩,
rcases exists_nhds_split W_nhd with ⟨V, V_nhd, h'⟩,
existsi [V, V_nhd],
intros v w s t v_in w_in s_in t_in,
simpa [mul_assoc] using h _ _ (h' v w v_in w_in) (h' s t s_in t_in)
end
section
variable (α)
@[to_additive nhds_zero_symm]
lemma nhds_one_symm [topological_group α] : comap (λr:α, r⁻¹) (nhds (1 : α)) = nhds (1 : α) :=
begin
have lim : tendsto (λr:α, r⁻¹) (nhds 1) (nhds 1),
{ simpa using tendsto_inv (@tendsto_id α (nhds 1)) },
refine comap_eq_of_inverse _ _ lim lim,
{ funext x, simp },
end
end
@[to_additive nhds_translation_add_neg]
lemma nhds_translation_mul_inv [topological_group α] (x : α) :
comap (λy:α, y * x⁻¹) (nhds 1) = nhds x :=
begin
refine comap_eq_of_inverse (λy:α, y * x) _ _ _,
{ funext x; simp },
{ suffices : tendsto (λy:α, y * x⁻¹) (nhds x) (nhds (x * x⁻¹)), { simpa },
exact tendsto_mul tendsto_id tendsto_const_nhds },
{ suffices : tendsto (λy:α, y * x) (nhds 1) (nhds (1 * x)), { simpa },
exact tendsto_mul tendsto_id tendsto_const_nhds }
end
end topological_group
section quotient_topological_group
variables [topological_space α] [group α] [topological_group α] (N : set α) [normal_subgroup N]
@[to_additive quotient_add_group.quotient.topological_space]
instance : topological_space (quotient_group.quotient N) :=
by dunfold quotient_group.quotient; apply_instance
attribute [instance] quotient_add_group.quotient.topological_space
open quotient_group
@[to_additive quotient_add_group_saturate]
lemma quotient_group_saturate (s : set α) :
(coe : α → quotient N) ⁻¹' ((coe : α → quotient N) '' s) = (⋃ x : N, (λ y, y*x.1) '' s) :=
begin
ext x,
simp only [mem_preimage_eq, mem_image, mem_Union, quotient_group.eq],
split,
{ exact assume ⟨a, a_in, h⟩, ⟨⟨_, h⟩, a, a_in, mul_inv_cancel_left _ _⟩ },
{ exact assume ⟨⟨i, hi⟩, a, ha, eq⟩,
⟨a, ha, by simp only [eq.symm, (mul_assoc _ _ _).symm, inv_mul_cancel_left, hi]⟩ }
end
@[to_additive quotient_add_group.open_coe]
lemma quotient_group.open_coe : is_open_map (coe : α → quotient N) :=
begin
intros s s_op,
change is_open ((coe : α → quotient N) ⁻¹' (coe '' s)),
rw quotient_group_saturate N s,
apply is_open_Union,
rintro ⟨n, _⟩,
exact is_open_map_mul_right n s s_op
end
@[to_additive topological_add_group_quotient]
instance topological_group_quotient : topological_group (quotient N) :=
{ continuous_mul := begin
have cont : continuous ((coe : α → quotient N) ∘ (λ (p : α × α), p.fst * p.snd)) :=
continuous.comp continuous_mul' continuous_quot_mk,
have quot : quotient_map (λ p : α × α, ((p.1:quotient N), (p.2:quotient N))),
{ apply is_open_map.to_quotient_map,
{ exact is_open_map.prod (quotient_group.open_coe N) (quotient_group.open_coe N) },
{ apply continuous.prod_mk,
{ exact continuous.comp continuous_fst continuous_quot_mk },
{ exact continuous.comp continuous_snd continuous_quot_mk } },
{ rintro ⟨⟨x⟩, ⟨y⟩⟩,
exact ⟨(x, y), rfl⟩ } },
exact (quotient_map.continuous_iff quot).2 cont,
end,
continuous_inv := begin
apply continuous_quotient_lift,
change continuous ((coe : α → quotient N) ∘ (λ (a : α), a⁻¹)),
exact continuous.comp continuous_inv' continuous_quot_mk
end }
attribute [instance] topological_add_group_quotient
end quotient_topological_group
section topological_add_group
variables [topological_space α] [add_group α]
lemma continuous_sub [topological_add_group α] [topological_space β] {f : β → α} {g : β → α}
(hf : continuous f) (hg : continuous g) : continuous (λx, f x - g x) :=
by simp; exact continuous_add hf (continuous_neg hg)
lemma continuous_sub' [topological_add_group α] : continuous (λp:α×α, p.1 - p.2) :=
continuous_sub continuous_fst continuous_snd
lemma tendsto_sub [topological_add_group α] {f : β → α} {g : β → α} {x : filter β} {a b : α}
(hf : tendsto f x (nhds a)) (hg : tendsto g x (nhds b)) : tendsto (λx, f x - g x) x (nhds (a - b)) :=
by simp; exact tendsto_add hf (tendsto_neg hg)
lemma nhds_translation [topological_add_group α] (x : α) : comap (λy:α, y - x) (nhds 0) = nhds x :=
nhds_translation_add_neg x
end topological_add_group
/-- additive group with a neighbourhood around 0.
Only used to construct a topology and uniform space.
This is currently only available for commutative groups, but it can be extended to
non-commutative groups too.
-/
class add_group_with_zero_nhd (α : Type u) extends add_comm_group α :=
(Z : filter α)
(zero_Z {} : pure 0 ≤ Z)
(sub_Z {} : tendsto (λp:α×α, p.1 - p.2) (Z.prod Z) Z)
namespace add_group_with_zero_nhd
variables (α) [add_group_with_zero_nhd α]
local notation `Z` := add_group_with_zero_nhd.Z
instance : topological_space α :=
topological_space.mk_of_nhds $ λa, map (λx, x + a) (Z α)
variables {α}
lemma neg_Z : tendsto (λa:α, - a) (Z α) (Z α) :=
have tendsto (λa, (0:α)) (Z α) (Z α),
by refine le_trans (assume h, _) zero_Z; simp [univ_mem_sets'] {contextual := tt},
have tendsto (λa:α, 0 - a) (Z α) (Z α), from
(tendsto.prod_mk this tendsto_id).comp sub_Z,
by simpa
lemma add_Z : tendsto (λp:α×α, p.1 + p.2) ((Z α).prod (Z α)) (Z α) :=
suffices tendsto (λp:α×α, p.1 - -p.2) ((Z α).prod (Z α)) (Z α),
by simpa,
(tendsto.prod_mk tendsto_fst (tendsto_snd.comp neg_Z)).comp sub_Z
lemma exists_Z_half {s : set α} (hs : s ∈ (Z α).sets) : ∃ V ∈ (Z α).sets, ∀ v w ∈ V, v + w ∈ s :=
begin
have : ((λa:α×α, a.1 + a.2) ⁻¹' s) ∈ ((Z α).prod (Z α)).sets := add_Z (by simpa using hs),
rcases mem_prod_iff.1 this with ⟨V₁, H₁, V₂, H₂, H⟩,
exact ⟨V₁ ∩ V₂, inter_mem_sets H₁ H₂, assume v w ⟨hv, _⟩ ⟨_, hw⟩, @H (v, w) ⟨hv, hw⟩⟩
end
lemma nhds_eq (a : α) : nhds a = map (λx, x + a) (Z α) :=
topological_space.nhds_mk_of_nhds _ _
(assume a, calc pure a = map (λx, x + a) (pure 0) : by simp
... ≤ _ : map_mono zero_Z)
(assume b s hs,
let ⟨t, ht, eqt⟩ := exists_Z_half hs in
have t0 : (0:α) ∈ t, by simpa using zero_Z ht,
begin
refine ⟨(λx:α, x + b) '' t, image_mem_map ht, _, _⟩,
{ refine set.image_subset_iff.2 (assume b hbt, _),
simpa using eqt 0 b t0 hbt },
{ rintros _ ⟨c, hb, rfl⟩,
refine (Z α).sets_of_superset ht (assume x hxt, _),
simpa using eqt _ _ hxt hb }
end)
lemma nhds_zero_eq_Z : nhds 0 = Z α := by simp [nhds_eq]; exact filter.map_id
instance : topological_add_monoid α :=
⟨ continuous_iff_continuous_at.2 $ assume ⟨a, b⟩,
begin
rw [continuous_at, nhds_prod_eq, nhds_eq, nhds_eq, nhds_eq, filter.prod_map_map_eq,
tendsto_map'_iff],
suffices : tendsto ((λx:α, (a + b) + x) ∘ (λp:α×α,p.1 + p.2)) (filter.prod (Z α) (Z α))
(map (λx:α, (a + b) + x) (Z α)),
{ simpa [(∘)] },
exact add_Z.comp tendsto_map
end⟩
instance : topological_add_group α :=
⟨continuous_iff_continuous_at.2 $ assume a,
begin
rw [continuous_at, nhds_eq, nhds_eq, tendsto_map'_iff],
suffices : tendsto ((λx:α, x - a) ∘ (λx:α, -x)) (Z α) (map (λx:α, x - a) (Z α)),
{ simpa [(∘)] },
exact neg_Z.comp tendsto_map
end⟩
end add_group_with_zero_nhd
|
09eee3f0a11cde668b0c253d3d5979515f0c2987 | bbecf0f1968d1fba4124103e4f6b55251d08e9c4 | /counterexamples/phillips.lean | 0dab408f4b4878a959f3ba723a7a174ee1541659 | [
"Apache-2.0"
] | permissive | waynemunro/mathlib | e3fd4ff49f4cb43d4a8ded59d17be407bc5ee552 | 065a70810b5480d584033f7bbf8e0409480c2118 | refs/heads/master | 1,693,417,182,397 | 1,634,644,781,000 | 1,634,644,781,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 28,534 | lean | /-
Copyright (c) 2021 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import analysis.normed_space.hahn_banach
import measure_theory.measure.lebesgue
/-!
# A counterexample on Pettis integrability
There are several theories of integration for functions taking values in Banach spaces. Bochner
integration, requiring approximation by simple functions, is the analogue of the one-dimensional
theory. It is very well behaved, but only works for functions with second-countable range.
For functions `f` taking values in a larger Banach space `B`, one can define the Dunford integral
as follows. Assume that, for all continuous linear functional `φ`, the function `φ ∘ f` is
measurable (we say that `f` is weakly measurable, or scalarly measurable) and integrable.
Then `φ ↦ ∫ φ ∘ f` is continuous (by the closed graph theorem), and therefore defines an element
of the bidual `B**`. This is the Dunford integral of `f`.
This Dunford integral is not usable in practice as it does not belong to the right space. Let us
say that a function is Pettis integrable if its Dunford integral belongs to the canonical image of
`B` in `B**`. In this case, we define the Pettis integral as the Dunford integral inside `B`.
This integral is very general, but not really usable to do analysis. This file illustrates this,
by giving an example of a function with nice properties but which is *not* Pettis-integrable.
This function:
- is defined from `[0, 1]` to a complete Banach space;
- is weakly measurable;
- has norm everywhere bounded by `1` (in particular, its norm is integrable);
- and yet it is not Pettis-integrable with respect to Lebesgue measure.
This construction is due to [Ralph S. Phillips, *Integration in a convex linear
topological space*][phillips1940], in Example 10.8. It requires the continuum hypothesis. The
example is the following.
Under the continuum hypothesis, one can find a subset of `ℝ²` which,
along each vertical line, only misses a countable set of points, while it is countable along each
horizontal line. This is due to Sierpinski, and formalized in `sierpinski_pathological_family`.
(In fact, Sierpinski proves that the existence of such a set is equivalent to the continuum
hypothesis).
Let `B` be the set of all bounded functions on `ℝ` (we are really talking about everywhere defined
functions here). Define `f : ℝ → B` by taking `f x` to be the characteristic function of the
vertical slice at position `x` of Sierpinski's set. It is our counterexample.
To show that it is weakly measurable, we should consider `φ ∘ f` where `φ` is an arbitrary
continuous linear form on `B`. There is no reasonable classification of such linear forms (they can
be very wild). But if one restricts such a linear form to characteristic functions, one gets a
finitely additive signed "measure". Such a "measure" can be decomposed into a discrete part
(supported on a countable set) and a continuous part (giving zero mass to countable sets).
For all but countably many points, `f x` will not intersect the discrete support of `φ` thanks to
the definition of the Sierpinski set. This implies that `φ ∘ f` is constant outside of a countable
set, and equal to the total mass of the continuous part of `φ` there. In particular, it is
measurable (and its integral is the total mass of the continuous part of `φ`).
Assume that `f` has a Pettis integral `g`. For all continuous linear form `φ`, then `φ g` should
be the total mass of the continuous part of `φ`. Taking for `φ` the evaluation at the point `x`
(which has no continuous part), one gets `g x = 0`. Take then for `φ` the Lebesgue integral on
`[0, 1]` (or rather an arbitrary extension of Lebesgue integration to all bounded functions,
thanks to Hahn-Banach). Then `φ g` should be the total mass of the continuous part of `φ`,
which is `1`. This contradicts the fact that `g = 0`, and concludes the proof that `f` has no
Pettis integral.
## Implementation notes
The space of all bounded functions is defined as the space of all bounded continuous functions
on a discrete copy of the original type, as mathlib only contains the space of all bounded
continuous functions (which is the useful one).
-/
universe u
variables {α : Type u}
open set bounded_continuous_function measure_theory
open cardinal (aleph)
open_locale cardinal bounded_continuous_function
noncomputable theory
/-- A copy of a type, endowed with the discrete topology -/
def discrete_copy (α : Type u) : Type u := α
instance : topological_space (discrete_copy α) := ⊥
instance : discrete_topology (discrete_copy α) := ⟨rfl⟩
instance [inhabited α] : inhabited (discrete_copy α) := ⟨id default α⟩
namespace phillips_1940
/-!
### Extending the integral
Thanks to Hahn-Banach, one can define a (non-canonical) continuous linear functional on the space
of all bounded functions, coinciding with the integral on the integrable ones.
-/
/-- The subspace of integrable functions in the space of all bounded functions on a type.
This is a technical device, used to apply Hahn-Banach theorem to construct an extension of the
integral to all bounded functions. -/
def bounded_integrable_functions [measurable_space α] (μ : measure α) :
subspace ℝ (discrete_copy α →ᵇ ℝ) :=
{ carrier := {f | integrable f μ},
zero_mem' := integrable_zero _ _ _,
add_mem' := λ f g hf hg, integrable.add hf hg,
smul_mem' := λ c f hf, integrable.smul c hf }
/-- The integral, as a continuous linear map on the subspace of integrable functions in the space
of all bounded functions on a type. This is a technical device, that we will extend through
Hahn-Banach. -/
def bounded_integrable_functions_integral_clm [measurable_space α]
(μ : measure α) [is_finite_measure μ] : bounded_integrable_functions μ →L[ℝ] ℝ :=
linear_map.mk_continuous
{ to_fun := λ f, ∫ x, f x ∂μ,
map_add' := λ f g, integral_add f.2 g.2,
map_smul' := λ c f, integral_smul _ _ }
(μ univ).to_real
begin
assume f,
rw mul_comm,
apply norm_integral_le_of_norm_le_const,
apply filter.eventually_of_forall,
assume x,
exact bounded_continuous_function.norm_coe_le_norm f x,
end
/-- Given a measure, there exists a continuous linear form on the space of all bounded functions
(not necessarily measurable) that coincides with the integral on bounded measurable functions. -/
lemma exists_linear_extension_to_bounded_functions
[measurable_space α] (μ : measure α) [is_finite_measure μ] :
∃ φ : (discrete_copy α →ᵇ ℝ) →L[ℝ] ℝ, ∀ (f : discrete_copy α →ᵇ ℝ),
integrable f μ → φ f = ∫ x, f x ∂μ :=
begin
rcases exists_extension_norm_eq _ (bounded_integrable_functions_integral_clm μ) with ⟨φ, hφ⟩,
exact ⟨φ, λ f hf, hφ.1 ⟨f, hf⟩⟩,
end
/-- An arbitrary extension of the integral to all bounded functions, as a continuous linear map.
It is not at all canonical, and constructed using Hahn-Banach. -/
def _root_.measure_theory.measure.extension_to_bounded_functions
[measurable_space α] (μ : measure α) [is_finite_measure μ] : (discrete_copy α →ᵇ ℝ) →L[ℝ] ℝ :=
(exists_linear_extension_to_bounded_functions μ).some
lemma extension_to_bounded_functions_apply [measurable_space α] (μ : measure α)
[is_finite_measure μ] (f : discrete_copy α →ᵇ ℝ) (hf : integrable f μ) :
μ.extension_to_bounded_functions f = ∫ x, f x ∂μ :=
(exists_linear_extension_to_bounded_functions μ).some_spec f hf
/-!
### Additive measures on the space of all sets
We define bounded finitely additive signed measures on the space of all subsets of a type `α`,
and show that such an object can be split into a discrete part and a continuous part.
-/
/-- A bounded signed finitely additive measure defined on *all* subsets of a type. -/
structure bounded_additive_measure (α : Type u) :=
(to_fun : set α → ℝ)
(additive' : ∀ s t, disjoint s t → to_fun (s ∪ t) = to_fun s + to_fun t)
(exists_bound : ∃ (C : ℝ), ∀ s, |to_fun s| ≤ C)
instance : inhabited (bounded_additive_measure α) :=
⟨{ to_fun := λ s, 0,
additive' := λ s t hst, by simp,
exists_bound := ⟨0, λ s, by simp⟩ }⟩
instance : has_coe_to_fun (bounded_additive_measure α) := ⟨_, λ f, f.to_fun⟩
namespace bounded_additive_measure
/-- A constant bounding the mass of any set for `f`. -/
def C (f : bounded_additive_measure α) := f.exists_bound.some
lemma additive (f : bounded_additive_measure α) (s t : set α)
(h : disjoint s t) : f (s ∪ t) = f s + f t :=
f.additive' s t h
lemma abs_le_bound (f : bounded_additive_measure α) (s : set α) :
|f s| ≤ f.C :=
f.exists_bound.some_spec s
lemma le_bound (f : bounded_additive_measure α) (s : set α) :
f s ≤ f.C :=
le_trans (le_abs_self _) (f.abs_le_bound s)
@[simp] lemma empty (f : bounded_additive_measure α) : f ∅ = 0 :=
begin
have : (∅ : set α) = ∅ ∪ ∅, by simp only [empty_union],
apply_fun f at this,
rwa [f.additive _ _ (empty_disjoint _), self_eq_add_left] at this,
end
instance : has_neg (bounded_additive_measure α) :=
⟨λ f,
{ to_fun := λ s, - f s,
additive' := λ s t hst, by simp only [f.additive s t hst, add_comm, neg_add_rev],
exists_bound := ⟨f.C, λ s, by simp [f.abs_le_bound]⟩ }⟩
@[simp] lemma neg_apply (f : bounded_additive_measure α) (s : set α) : (-f) s = - (f s) := rfl
/-- Restricting a bounded additive measure to a subset still gives a bounded additive measure. -/
def restrict (f : bounded_additive_measure α) (t : set α) : bounded_additive_measure α :=
{ to_fun := λ s, f (t ∩ s),
additive' := λ s s' h, begin
rw [← f.additive (t ∩ s) (t ∩ s'), inter_union_distrib_left],
exact h.mono (inter_subset_right _ _) (inter_subset_right _ _),
end,
exists_bound := ⟨f.C, λ s, f.abs_le_bound _⟩ }
@[simp] lemma restrict_apply (f : bounded_additive_measure α) (s t : set α) :
f.restrict s t = f (s ∩ t) := rfl
/-- There is a maximal countable set of positive measure, in the sense that any countable set
not intersecting it has nonpositive measure. Auxiliary lemma to prove `exists_discrete_support`. -/
lemma exists_discrete_support_nonpos (f : bounded_additive_measure α) :
∃ (s : set α), countable s ∧ (∀ t, countable t → f (t \ s) ≤ 0) :=
begin
/- The idea of the proof is to construct the desired set inductively, adding at each step a
countable set with close to maximal measure among those points that have not already been chosen.
Doing this countably many steps will be enough. Indeed, otherwise, a remaining set would have
positive measure `ε`. This means that at each step the set we have added also had a large measure,
say at least `ε / 2`. After `n` steps, the set we have constructed has therefore measure at least
`n * ε / 2`. This is a contradiction since the measures have to remain uniformly bounded.
We argue from the start by contradiction, as this means that our inductive construction will
never be stuck, so we won't have to consider this case separately.
-/
by_contra h,
push_neg at h,
-- We will formulate things in terms of the type of countable subsets of `α`, as this is more
-- convenient to formalize the inductive construction.
let A : set (set α) := {t | countable t},
let empty : A := ⟨∅, countable_empty⟩,
haveI : nonempty A := ⟨empty⟩,
-- given a countable set `s`, one can find a set `t` in its complement with measure close to
-- maximal.
have : ∀ (s : A), ∃ (t : A), (∀ (u : A), f (u \ s) ≤ 2 * f (t \ s)),
{ assume s,
have B : bdd_above (range (λ (u : A), f (u \ s))),
{ refine ⟨f.C, λ x hx, _⟩,
rcases hx with ⟨u, hu⟩,
rw ← hu,
exact f.le_bound _ },
let S := supr (λ (t : A), f (t \ s)),
have S_pos : 0 < S,
{ rcases h s.1 s.2 with ⟨t, t_count, ht⟩,
apply ht.trans_le,
let t' : A := ⟨t, t_count⟩,
change f (t' \ s) ≤ S,
exact le_csupr B t' },
rcases exists_lt_of_lt_csupr (half_lt_self S_pos) with ⟨t, ht⟩,
refine ⟨t, λ u, _⟩,
calc f (u \ s) ≤ S : le_csupr B _
... = 2 * (S / 2) : by ring
... ≤ 2 * f (t \ s) : mul_le_mul_of_nonneg_left ht.le (by norm_num) },
choose! F hF using this,
-- iterate the above construction, by adding at each step a set with measure close to maximal in
-- the complement of already chosen points. This is the set `s n` at step `n`.
let G : A → A := λ u, ⟨u ∪ F u, u.2.union (F u).2⟩,
let s : ℕ → A := λ n, G^[n] empty,
-- We will get a contradiction from the fact that there is a countable set `u` with positive
-- measure in the complement of `⋃ n, s n`.
rcases h (⋃ n, s n) (countable_Union (λ n, (s n).2)) with ⟨t, t_count, ht⟩,
let u : A := ⟨t \ ⋃ n, s n, t_count.mono (diff_subset _ _)⟩,
set ε := f u with hε,
have ε_pos : 0 < ε := ht,
have I1 : ∀ n, ε / 2 ≤ f (s (n+1) \ s n),
{ assume n,
rw [div_le_iff' (show (0 : ℝ) < 2, by norm_num), hε],
convert hF (s n) u using 3,
{ dsimp [u],
ext x,
simp only [not_exists, mem_Union, mem_diff],
tauto },
{ simp only [s, function.iterate_succ', subtype.coe_mk, union_diff_left] } },
have I2 : ∀ (n : ℕ), (n : ℝ) * (ε / 2) ≤ f (s n),
{ assume n,
induction n with n IH,
{ simp only [s, bounded_additive_measure.empty, id.def, nat.cast_zero, zero_mul,
function.iterate_zero, subtype.coe_mk], },
{ have : (s (n+1) : set α) = (s (n+1) \ s n) ∪ s n,
by simp only [s, function.iterate_succ', union_comm, union_diff_self, subtype.coe_mk,
union_diff_left],
rw [nat.succ_eq_add_one, this, f.additive],
swap, { rw disjoint.comm, apply disjoint_diff },
calc ((n + 1) : ℝ) * (ε / 2) = ε / 2 + n * (ε / 2) : by ring
... ≤ f ((s (n + 1)) \ (s n)) + f (s n) : add_le_add (I1 n) IH } },
rcases exists_nat_gt (f.C / (ε / 2)) with ⟨n, hn⟩,
have : (n : ℝ) ≤ f.C / (ε / 2),
by { rw le_div_iff (half_pos ε_pos), exact (I2 n).trans (f.le_bound _) },
exact lt_irrefl _ (this.trans_lt hn),
end
lemma exists_discrete_support (f : bounded_additive_measure α) :
∃ (s : set α), countable s ∧ (∀ t, countable t → f (t \ s) = 0) :=
begin
rcases f.exists_discrete_support_nonpos with ⟨s₁, s₁_count, h₁⟩,
rcases (-f).exists_discrete_support_nonpos with ⟨s₂, s₂_count, h₂⟩,
refine ⟨s₁ ∪ s₂, s₁_count.union s₂_count, λ t ht, le_antisymm _ _⟩,
{ have : t \ (s₁ ∪ s₂) = (t \ (s₁ ∪ s₂)) \ s₁,
by rw [diff_diff, union_comm, union_assoc, union_self],
rw this,
exact h₁ _ (ht.mono (diff_subset _ _)) },
{ have : t \ (s₁ ∪ s₂) = (t \ (s₁ ∪ s₂)) \ s₂,
by rw [diff_diff, union_assoc, union_self],
rw this,
simp only [neg_nonpos, neg_apply] at h₂,
exact h₂ _ (ht.mono (diff_subset _ _)) },
end
/-- A countable set outside of which the measure gives zero mass to countable sets. We are not
claiming this set is unique, but we make an arbitrary choice of such a set. -/
def discrete_support (f : bounded_additive_measure α) : set α :=
(exists_discrete_support f).some
lemma countable_discrete_support (f : bounded_additive_measure α) :
countable f.discrete_support :=
(exists_discrete_support f).some_spec.1
lemma apply_countable (f : bounded_additive_measure α) (t : set α) (ht : countable t) :
f (t \ f.discrete_support) = 0 :=
(exists_discrete_support f).some_spec.2 t ht
/-- The discrete part of a bounded additive measure, obtained by restricting the measure to its
countable support. -/
def discrete_part (f : bounded_additive_measure α) : bounded_additive_measure α :=
f.restrict f.discrete_support
/-- The continuous part of a bounded additive measure, giving zero measure to every countable
set. -/
def continuous_part (f : bounded_additive_measure α) : bounded_additive_measure α :=
f.restrict (univ \ f.discrete_support)
lemma eq_add_parts (f : bounded_additive_measure α) (s : set α) :
f s = f.discrete_part s + f.continuous_part s :=
begin
simp only [discrete_part, continuous_part, restrict_apply],
rw [← f.additive, ← inter_distrib_right],
{ simp only [union_univ, union_diff_self, univ_inter] },
{ have : disjoint f.discrete_support (univ \ f.discrete_support) := disjoint_diff,
exact this.mono (inter_subset_left _ _) (inter_subset_left _ _) }
end
lemma discrete_part_apply (f : bounded_additive_measure α) (s : set α) :
f.discrete_part s = f (f.discrete_support ∩ s) := rfl
lemma continuous_part_apply_eq_zero_of_countable (f : bounded_additive_measure α)
(s : set α) (hs : countable s) : f.continuous_part s = 0 :=
begin
simp [continuous_part],
convert f.apply_countable s hs using 2,
ext x,
simp [and_comm]
end
lemma continuous_part_apply_diff (f : bounded_additive_measure α)
(s t : set α) (hs : countable s) : f.continuous_part (t \ s) = f.continuous_part t :=
begin
conv_rhs { rw ← diff_union_inter t s },
rw [additive, self_eq_add_right],
{ exact continuous_part_apply_eq_zero_of_countable _ _ (hs.mono (inter_subset_right _ _)) },
{ exact disjoint.mono_right (inter_subset_right _ _) (disjoint.comm.1 disjoint_diff) },
end
end bounded_additive_measure
open bounded_additive_measure
section
/-!
### Relationship between continuous functionals and finitely additive measures.
-/
lemma norm_indicator_le_one (s : set α) (x : α) :
∥(indicator s (1 : α → ℝ)) x∥ ≤ 1 :=
by { simp only [indicator, pi.one_apply], split_ifs; norm_num }
/-- A functional in the dual space of bounded functions gives rise to a bounded additive measure,
by applying the functional to the indicator functions. -/
def _root_.continuous_linear_map.to_bounded_additive_measure
[topological_space α] [discrete_topology α]
(f : (α →ᵇ ℝ) →L[ℝ] ℝ) : bounded_additive_measure α :=
{ to_fun := λ s, f (of_normed_group_discrete (indicator s 1) 1 (norm_indicator_le_one s)),
additive' := λ s t hst,
begin
have : of_normed_group_discrete (indicator (s ∪ t) 1) 1 (norm_indicator_le_one (s ∪ t))
= of_normed_group_discrete (indicator s 1) 1 (norm_indicator_le_one s)
+ of_normed_group_discrete (indicator t 1) 1 (norm_indicator_le_one t),
by { ext x, simp [indicator_union_of_disjoint hst], },
rw [this, f.map_add],
end,
exists_bound := ⟨∥f∥, λ s, begin
have I : ∥of_normed_group_discrete (indicator s 1) 1 (norm_indicator_le_one s)∥ ≤ 1,
by apply norm_of_normed_group_le _ zero_le_one,
apply le_trans (f.le_op_norm _),
simpa using mul_le_mul_of_nonneg_left I (norm_nonneg f),
end⟩ }
@[simp] lemma continuous_part_eval_clm_eq_zero [topological_space α] [discrete_topology α]
(s : set α) (x : α) :
(eval_clm ℝ x).to_bounded_additive_measure.continuous_part s = 0 :=
let f := (eval_clm ℝ x).to_bounded_additive_measure in calc
f.continuous_part s
= f.continuous_part (s \ {x}) : (continuous_part_apply_diff _ _ _ (countable_singleton x)).symm
... = f ((univ \ f.discrete_support) ∩ (s \ {x})) : rfl
... = indicator ((univ \ f.discrete_support) ∩ (s \ {x})) 1 x : rfl
... = 0 : by simp
lemma to_functions_to_measure [measurable_space α] (μ : measure α) [is_finite_measure μ]
(s : set α) (hs : measurable_set s) :
μ.extension_to_bounded_functions.to_bounded_additive_measure s = (μ s).to_real :=
begin
change μ.extension_to_bounded_functions
(of_normed_group_discrete (indicator s (λ x, 1)) 1 (norm_indicator_le_one s)) = (μ s).to_real,
rw extension_to_bounded_functions_apply,
{ change ∫ x, s.indicator (λ y, (1 : ℝ)) x ∂μ = _,
simp [integral_indicator hs] },
{ change integrable (indicator s 1) μ,
have : integrable (λ x, (1 : ℝ)) μ := integrable_const (1 : ℝ),
apply this.mono' (measurable.indicator (@measurable_const _ _ _ _ (1 : ℝ)) hs).ae_measurable,
apply filter.eventually_of_forall,
exact norm_indicator_le_one _ }
end
lemma to_functions_to_measure_continuous_part [measurable_space α] [measurable_singleton_class α]
(μ : measure α) [is_finite_measure μ] [has_no_atoms μ]
(s : set α) (hs : measurable_set s) :
μ.extension_to_bounded_functions.to_bounded_additive_measure.continuous_part s = (μ s).to_real :=
begin
let f := μ.extension_to_bounded_functions.to_bounded_additive_measure,
change f ((univ \ f.discrete_support) ∩ s) = (μ s).to_real,
rw to_functions_to_measure, swap,
{ exact measurable_set.inter
(measurable_set.univ.diff (countable.measurable_set f.countable_discrete_support)) hs },
congr' 1,
rw [inter_comm, ← inter_diff_assoc, inter_univ],
exact measure_diff_null (f.countable_discrete_support.measure_zero _)
end
end
/-!
### A set in `ℝ²` large along verticals, small along horizontals
We construct a subset of `ℝ²`, given as a family of sets, which is large along verticals (i.e.,
it only misses a countable set along each vertical) but small along horizontals (it is countable
along horizontals). Such a set can not be measurable as it would contradict Fubini theorem.
We need the continuum hypothesis to construct it.
-/
theorem sierpinski_pathological_family (Hcont : #ℝ = aleph 1) :
∃ (f : ℝ → set ℝ), (∀ x, countable (univ \ f x)) ∧ (∀ y, countable {x | y ∈ f x}) :=
begin
rcases cardinal.ord_eq ℝ with ⟨r, hr, H⟩,
resetI,
refine ⟨λ x, {y | r x y}, λ x, _, λ y, _⟩,
{ have : univ \ {y | r x y} = {y | r y x} ∪ {x},
{ ext y,
simp only [true_and, mem_univ, mem_set_of_eq, mem_insert_iff, union_singleton, mem_diff],
rcases trichotomous_of r x y with h|rfl|h,
{ simp only [h, not_or_distrib, false_iff, not_true],
split,
{ rintros rfl, exact irrefl_of r y h },
{ exact asymm h } },
{ simp only [true_or, eq_self_iff_true, iff_true], exact irrefl x },
{ simp only [h, iff_true, or_true], exact asymm h } },
rw this,
apply countable.union _ (countable_singleton _),
rw [cardinal.countable_iff_lt_aleph_one, ← Hcont],
exact cardinal.card_typein_lt r x H },
{ rw [cardinal.countable_iff_lt_aleph_one, ← Hcont],
exact cardinal.card_typein_lt r y H }
end
/-- A family of sets in `ℝ` which only miss countably many points, but such that any point is
contained in only countably many of them. -/
def spf (Hcont : #ℝ = aleph 1) (x : ℝ) : set ℝ :=
(sierpinski_pathological_family Hcont).some x
lemma countable_compl_spf (Hcont : #ℝ = aleph 1) (x : ℝ) : countable (univ \ spf Hcont x) :=
(sierpinski_pathological_family Hcont).some_spec.1 x
lemma countable_spf_mem (Hcont : #ℝ = aleph 1) (y : ℝ) : countable {x | y ∈ spf Hcont x} :=
(sierpinski_pathological_family Hcont).some_spec.2 y
/-!
### A counterexample for the Pettis integral
We construct a function `f` from `[0,1]` to a complete Banach space `B`, which is weakly measurable
(i.e., for any continuous linear form `φ` on `B` the function `φ ∘ f` is measurable), bounded in
norm (i.e., for all `x`, one has `∥f x∥ ≤ 1`), and still `f` has no Pettis integral.
This construction, due to Phillips, requires the continuum hypothesis. We will take for `B` the
space of all bounded functions on `ℝ`, with the supremum norm (no measure here, we are really
talking of everywhere defined functions). And `f x` will be the characteristic function of a set
which is large (it has countable complement), as in the Sierpinski pathological family.
-/
/-- A family of bounded functions `f_x` from `ℝ` (seen with the discrete topology) to `ℝ` (in fact
taking values in `{0, 1}`), indexed by a real parameter `x`, corresponding to the characteristic
functions of the different fibers of the Sierpinski pathological family -/
def f (Hcont : #ℝ = aleph 1) (x : ℝ) : (discrete_copy ℝ →ᵇ ℝ) :=
of_normed_group_discrete (indicator (spf Hcont x) 1) 1 (norm_indicator_le_one _)
lemma apply_f_eq_continuous_part (Hcont : #ℝ = aleph 1)
(φ : (discrete_copy ℝ →ᵇ ℝ) →L[ℝ] ℝ) (x : ℝ)
(hx : φ.to_bounded_additive_measure.discrete_support ∩ spf Hcont x = ∅) :
φ (f Hcont x) = φ.to_bounded_additive_measure.continuous_part univ :=
begin
set ψ := φ.to_bounded_additive_measure with hψ,
have : φ (f Hcont x) = ψ (spf Hcont x) := rfl,
have U : univ = spf Hcont x ∪ (univ \ spf Hcont x), by simp only [union_univ, union_diff_self],
rw [this, eq_add_parts, discrete_part_apply, hx, ψ.empty, zero_add, U,
ψ.continuous_part.additive _ _ (disjoint_diff),
ψ.continuous_part_apply_eq_zero_of_countable _ (countable_compl_spf Hcont x), add_zero],
end
lemma countable_ne (Hcont : #ℝ = aleph 1) (φ : (discrete_copy ℝ →ᵇ ℝ) →L[ℝ] ℝ) :
countable {x | φ.to_bounded_additive_measure.continuous_part univ ≠ φ (f Hcont x)} :=
begin
have A : {x | φ.to_bounded_additive_measure.continuous_part univ ≠ φ (f Hcont x)}
⊆ {x | φ.to_bounded_additive_measure.discrete_support ∩ spf Hcont x ≠ ∅},
{ assume x hx,
contrapose! hx,
simp only [not_not, mem_set_of_eq] at hx,
simp [apply_f_eq_continuous_part Hcont φ x hx], },
have B : {x | φ.to_bounded_additive_measure.discrete_support ∩ spf Hcont x ≠ ∅}
⊆ ⋃ y ∈ φ.to_bounded_additive_measure.discrete_support, {x | y ∈ spf Hcont x},
{ assume x hx,
dsimp at hx,
rw [← ne.def, ne_empty_iff_nonempty] at hx,
simp only [exists_prop, mem_Union, mem_set_of_eq],
exact hx },
apply countable.mono (subset.trans A B),
exact countable.bUnion (countable_discrete_support _) (λ a ha, countable_spf_mem Hcont a),
end
lemma comp_ae_eq_const (Hcont : #ℝ = aleph 1) (φ : (discrete_copy ℝ →ᵇ ℝ) →L[ℝ] ℝ) :
∀ᵐ x ∂(volume.restrict (Icc (0 : ℝ) 1)),
φ.to_bounded_additive_measure.continuous_part univ = φ (f Hcont x) :=
begin
apply ae_restrict_of_ae,
refine measure_mono_null _ ((countable_ne Hcont φ).measure_zero _),
assume x,
simp only [imp_self, mem_set_of_eq, mem_compl_eq],
end
lemma integrable_comp (Hcont : #ℝ = aleph 1) (φ : (discrete_copy ℝ →ᵇ ℝ) →L[ℝ] ℝ) :
integrable_on (λ x, φ (f Hcont x)) (Icc 0 1) :=
begin
have : integrable_on (λ x, φ.to_bounded_additive_measure.continuous_part univ) (Icc (0 : ℝ) 1)
volume, by simp [integrable_on_const],
apply integrable.congr this (comp_ae_eq_const Hcont φ),
end
lemma integral_comp (Hcont : #ℝ = aleph 1) (φ : (discrete_copy ℝ →ᵇ ℝ) →L[ℝ] ℝ) :
∫ x in Icc 0 1, φ (f Hcont x) = φ.to_bounded_additive_measure.continuous_part univ :=
begin
rw ← integral_congr_ae (comp_ae_eq_const Hcont φ),
simp,
end
/-!
The next few statements show that the function `f Hcont : ℝ → (discrete_copy ℝ →ᵇ ℝ)` takes its
values in a complete space, is scalarly measurable, is everywhere bounded by `1`, and still has
no Pettis integral.
-/
example : complete_space (discrete_copy ℝ →ᵇ ℝ) := by apply_instance
/-- The function `f Hcont : ℝ → (discrete_copy ℝ →ᵇ ℝ)` is scalarly measurable. -/
lemma measurable_comp (Hcont : #ℝ = aleph 1) (φ : (discrete_copy ℝ →ᵇ ℝ) →L[ℝ] ℝ) :
measurable (λ x, φ (f Hcont x)) :=
begin
have : measurable (λ x, φ.to_bounded_additive_measure.continuous_part univ) := measurable_const,
refine this.measurable_of_countable_ne _,
exact countable_ne Hcont φ,
end
/-- The function `f Hcont : ℝ → (discrete_copy ℝ →ᵇ ℝ)` is uniformly bounded by `1` in norm. -/
lemma norm_bound (Hcont : #ℝ = aleph 1) (x : ℝ) : ∥f Hcont x∥ ≤ 1 :=
norm_of_normed_group_le _ zero_le_one _
/-- The function `f Hcont : ℝ → (discrete_copy ℝ →ᵇ ℝ)` has no Pettis integral. -/
theorem no_pettis_integral (Hcont : #ℝ = aleph 1) :
¬ ∃ (g : discrete_copy ℝ →ᵇ ℝ),
∀ (φ : (discrete_copy ℝ →ᵇ ℝ) →L[ℝ] ℝ), ∫ x in Icc 0 1, φ (f Hcont x) = φ g :=
begin
rintros ⟨g, h⟩,
simp only [integral_comp] at h,
have : g = 0,
{ ext x,
have : g x = eval_clm ℝ x g := rfl,
rw [this, ← h],
simp },
simp only [this, continuous_linear_map.map_zero] at h,
specialize h (volume.restrict (Icc (0 : ℝ) 1)).extension_to_bounded_functions,
simp_rw [to_functions_to_measure_continuous_part _ _ measurable_set.univ] at h,
simpa using h,
end
end phillips_1940
|
9ebc3a1ede44d7604c9a18c2a6c8378ff93d7a22 | d7189ea2ef694124821b033e533f18905b5e87ef | /galois/bitvec/rotate.lean | a847ca164ed5b88a85fb81a351076e5525b534b2 | [
"Apache-2.0"
] | permissive | digama0/lean-protocol-support | eaa7e6f8b8e0d5bbfff1f7f52bfb79a3b11b0f59 | cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda | refs/heads/master | 1,625,421,450,627 | 1,506,035,462,000 | 1,506,035,462,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 226 | lean | import data.bitvec
import galois.vector.rotate
namespace bitvec
variables {n : ℕ}
definition rol : bitvec n → ℕ → bitvec n := vector.rol
definition ror : bitvec n → ℕ → bitvec n := vector.ror
end bitvec
|
6125557962f6bf09ad25d68493403cd7399b2c77 | 19cc34575500ee2e3d4586c15544632aa07a8e66 | /src/data/complex/exponential.lean | f940b5148ce2644dafe6dd4862e4810fa7591787 | [
"Apache-2.0"
] | permissive | LibertasSpZ/mathlib | b9fcd46625eb940611adb5e719a4b554138dade6 | 33f7870a49d7cc06d2f3036e22543e6ec5046e68 | refs/heads/master | 1,672,066,539,347 | 1,602,429,158,000 | 1,602,429,158,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 51,110 | lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir
-/
import algebra.geom_sum
import data.nat.choose.sum
import data.complex.basic
/-!
# Exponential, trigonometric and hyperbolic trigonometric functions
This file contains the definitions of the real and complex exponential, sine, cosine, tangent,
hyperbolic sine, hypebolic cosine, and hyperbolic tangent functions.
-/
local notation `abs'` := _root_.abs
open is_absolute_value
open_locale classical big_operators nat
section
open real is_absolute_value finset
lemma forall_ge_le_of_forall_le_succ {α : Type*} [preorder α] (f : ℕ → α) {m : ℕ}
(h : ∀ n ≥ m, f n.succ ≤ f n) : ∀ {l}, ∀ k ≥ m, k ≤ l → f l ≤ f k :=
begin
assume l k hkm hkl,
generalize hp : l - k = p,
have : l = k + p := add_comm p k ▸ (nat.sub_eq_iff_eq_add hkl).1 hp,
subst this,
clear hkl hp,
induction p with p ih,
{ simp },
{ exact le_trans (h _ (le_trans hkm (nat.le_add_right _ _))) ih }
end
section
variables {α : Type*} {β : Type*} [ring β]
[discrete_linear_ordered_field α] [archimedean α] {abv : β → α} [is_absolute_value abv]
lemma is_cau_of_decreasing_bounded (f : ℕ → α) {a : α} {m : ℕ} (ham : ∀ n ≥ m, abs (f n) ≤ a)
(hnm : ∀ n ≥ m, f n.succ ≤ f n) : is_cau_seq abs f :=
λ ε ε0,
let ⟨k, hk⟩ := archimedean.arch a ε0 in
have h : ∃ l, ∀ n ≥ m, a - l •ℕ ε < f n :=
⟨k + k + 1, λ n hnm, lt_of_lt_of_le
(show a - (k + (k + 1)) •ℕ ε < -abs (f n),
from lt_neg.1 $ lt_of_le_of_lt (ham n hnm) (begin
rw [neg_sub, lt_sub_iff_add_lt, add_nsmul],
exact add_lt_add_of_le_of_lt hk (lt_of_le_of_lt hk
(lt_add_of_pos_left _ ε0)),
end))
(neg_le.2 $ (abs_neg (f n)) ▸ le_abs_self _)⟩,
let l := nat.find h in
have hl : ∀ (n : ℕ), n ≥ m → f n > a - l •ℕ ε := nat.find_spec h,
have hl0 : l ≠ 0 := λ hl0, not_lt_of_ge (ham m (le_refl _))
(lt_of_lt_of_le (by have := hl m (le_refl m); simpa [hl0] using this) (le_abs_self (f m))),
begin
cases not_forall.1
(nat.find_min h (nat.pred_lt hl0)) with i hi,
rw [not_imp, not_lt] at hi,
existsi i,
assume j hj,
have hfij : f j ≤ f i := forall_ge_le_of_forall_le_succ f hnm _ hi.1 hj,
rw [abs_of_nonpos (sub_nonpos.2 hfij), neg_sub, sub_lt_iff_lt_add'],
exact calc f i ≤ a - (nat.pred l) •ℕ ε : hi.2
... = a - l •ℕ ε + ε :
by conv {to_rhs, rw [← nat.succ_pred_eq_of_pos (nat.pos_of_ne_zero hl0), succ_nsmul',
sub_add, add_sub_cancel] }
... < f j + ε : add_lt_add_right (hl j (le_trans hi.1 hj)) _
end
lemma is_cau_of_mono_bounded (f : ℕ → α) {a : α} {m : ℕ} (ham : ∀ n ≥ m, abs (f n) ≤ a)
(hnm : ∀ n ≥ m, f n ≤ f n.succ) : is_cau_seq abs f :=
begin
refine @eq.rec_on (ℕ → α) _ (is_cau_seq abs) _ _
(-⟨_, @is_cau_of_decreasing_bounded _ _ _ (λ n, -f n) a m (by simpa) (by simpa)⟩ :
cau_seq α abs).2,
ext,
exact neg_neg _
end
end
section no_archimedean
variables {α : Type*} {β : Type*} [ring β]
[discrete_linear_ordered_field α] {abv : β → α} [is_absolute_value abv]
lemma is_cau_series_of_abv_le_cau {f : ℕ → β} {g : ℕ → α} (n : ℕ) :
(∀ m, n ≤ m → abv (f m) ≤ g m) →
is_cau_seq abs (λ n, ∑ i in range n, g i) →
is_cau_seq abv (λ n, ∑ i in range n, f i) :=
begin
assume hm hg ε ε0,
cases hg (ε / 2) (div_pos ε0 (by norm_num)) with i hi,
existsi max n i,
assume j ji,
have hi₁ := hi j (le_trans (le_max_right n i) ji),
have hi₂ := hi (max n i) (le_max_right n i),
have sub_le := abs_sub_le (∑ k in range j, g k) (∑ k in range i, g k)
(∑ k in range (max n i), g k),
have := add_lt_add hi₁ hi₂,
rw [abs_sub (∑ k in range (max n i), g k), add_halves ε] at this,
refine lt_of_le_of_lt (le_trans (le_trans _ (le_abs_self _)) sub_le) this,
generalize hk : j - max n i = k,
clear this hi₂ hi₁ hi ε0 ε hg sub_le,
rw nat.sub_eq_iff_eq_add ji at hk,
rw hk,
clear hk ji j,
induction k with k' hi,
{ simp [abv_zero abv] },
{ dsimp at *,
simp only [nat.succ_add, sum_range_succ, sub_eq_add_neg, add_assoc],
refine le_trans (abv_add _ _ _) _,
exact add_le_add (hm _ (le_add_of_nonneg_of_le (nat.zero_le _) (le_max_left _ _))) hi },
end
lemma is_cau_series_of_abv_cau {f : ℕ → β} : is_cau_seq abs (λ m, ∑ n in range m, abv (f n)) →
is_cau_seq abv (λ m, ∑ n in range m, f n) :=
is_cau_series_of_abv_le_cau 0 (λ n h, le_refl _)
end no_archimedean
section
variables {α : Type*} {β : Type*} [ring β]
[discrete_linear_ordered_field α] [archimedean α] {abv : β → α} [is_absolute_value abv]
lemma is_cau_geo_series {β : Type*} [field β] {abv : β → α} [is_absolute_value abv]
(x : β) (hx1 : abv x < 1) : is_cau_seq abv (λ n, ∑ m in range n, x ^ m) :=
have hx1' : abv x ≠ 1 := λ h, by simpa [h, lt_irrefl] using hx1,
is_cau_series_of_abv_cau
begin
simp only [abv_pow abv] {eta := ff},
have : (λ (m : ℕ), ∑ n in range m, (abv x) ^ n) =
λ m, geom_series (abv x) m := rfl,
simp only [this, geom_sum hx1'] {eta := ff},
conv in (_ / _) { rw [← neg_div_neg_eq, neg_sub, neg_sub] },
refine @is_cau_of_mono_bounded _ _ _ _ ((1 : α) / (1 - abv x)) 0 _ _,
{ assume n hn,
rw abs_of_nonneg,
refine div_le_div_of_le (le_of_lt $ sub_pos.2 hx1)
(sub_le_self _ (abv_pow abv x n ▸ abv_nonneg _ _)),
refine div_nonneg (sub_nonneg.2 _) (sub_nonneg.2 $ le_of_lt hx1),
clear hn,
induction n with n ih,
{ simp },
{ rw [pow_succ, ← one_mul (1 : α)],
refine mul_le_mul (le_of_lt hx1) ih (abv_pow abv x n ▸ abv_nonneg _ _) (by norm_num) } },
{ assume n hn,
refine div_le_div_of_le (le_of_lt $ sub_pos.2 hx1) (sub_le_sub_left _ _),
rw [← one_mul (_ ^ n), pow_succ],
exact mul_le_mul_of_nonneg_right (le_of_lt hx1) (pow_nonneg (abv_nonneg _ _) _) }
end
lemma is_cau_geo_series_const (a : α) {x : α} (hx1 : abs x < 1) :
is_cau_seq abs (λ m, ∑ n in range m, a * x ^ n) :=
have is_cau_seq abs (λ m, a * ∑ n in range m, x ^ n) :=
(cau_seq.const abs a * ⟨_, is_cau_geo_series x hx1⟩).2,
by simpa only [mul_sum]
lemma series_ratio_test {f : ℕ → β} (n : ℕ) (r : α)
(hr0 : 0 ≤ r) (hr1 : r < 1) (h : ∀ m, n ≤ m → abv (f m.succ) ≤ r * abv (f m)) :
is_cau_seq abv (λ m, ∑ n in range m, f n) :=
have har1 : abs r < 1, by rwa abs_of_nonneg hr0,
begin
refine is_cau_series_of_abv_le_cau n.succ _ (is_cau_geo_series_const (abv (f n.succ) * r⁻¹ ^ n.succ) har1),
assume m hmn,
cases classical.em (r = 0) with r_zero r_ne_zero,
{ have m_pos := lt_of_lt_of_le (nat.succ_pos n) hmn,
have := h m.pred (nat.le_of_succ_le_succ (by rwa [nat.succ_pred_eq_of_pos m_pos])),
simpa [r_zero, nat.succ_pred_eq_of_pos m_pos, pow_succ] },
generalize hk : m - n.succ = k,
have r_pos : 0 < r := lt_of_le_of_ne hr0 (ne.symm r_ne_zero),
replace hk : m = k + n.succ := (nat.sub_eq_iff_eq_add hmn).1 hk,
induction k with k ih generalizing m n,
{ rw [hk, zero_add, mul_right_comm, inv_pow' _ _, ← div_eq_mul_inv, mul_div_cancel],
exact (ne_of_lt (pow_pos r_pos _)).symm },
{ have kn : k + n.succ ≥ n.succ, by rw ← zero_add n.succ; exact add_le_add (zero_le _) (by simp),
rw [hk, nat.succ_add, pow_succ' r, ← mul_assoc],
exact le_trans (by rw mul_comm; exact h _ (nat.le_of_succ_le kn))
(mul_le_mul_of_nonneg_right (ih (k + n.succ) n h kn rfl) hr0) }
end
lemma sum_range_diag_flip {α : Type*} [add_comm_monoid α] (n : ℕ) (f : ℕ → ℕ → α) :
∑ m in range n, ∑ k in range (m + 1), f k (m - k) =
∑ m in range n, ∑ k in range (n - m), f m k :=
have h₁ : ∑ a in (range n).sigma (range ∘ nat.succ), f (a.2) (a.1 - a.2) =
∑ m in range n, ∑ k in range (m + 1), f k (m - k) := sum_sigma,
have h₂ : ∑ a in (range n).sigma (λ m, range (n - m)), f (a.1) (a.2) =
∑ m in range n, ∑ k in range (n - m), f m k := sum_sigma,
h₁ ▸ h₂ ▸ sum_bij
(λ a _, ⟨a.2, a.1 - a.2⟩)
(λ a ha, have h₁ : a.1 < n := mem_range.1 (mem_sigma.1 ha).1,
have h₂ : a.2 < nat.succ a.1 := mem_range.1 (mem_sigma.1 ha).2,
mem_sigma.2 ⟨mem_range.2 (lt_of_lt_of_le h₂ h₁),
mem_range.2 ((nat.sub_lt_sub_right_iff (nat.le_of_lt_succ h₂)).2 h₁)⟩)
(λ _ _, rfl)
(λ ⟨a₁, a₂⟩ ⟨b₁, b₂⟩ ha hb h,
have ha : a₁ < n ∧ a₂ ≤ a₁ :=
⟨mem_range.1 (mem_sigma.1 ha).1, nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 ha).2)⟩,
have hb : b₁ < n ∧ b₂ ≤ b₁ :=
⟨mem_range.1 (mem_sigma.1 hb).1, nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 hb).2)⟩,
have h : a₂ = b₂ ∧ _ := sigma.mk.inj h,
have h' : a₁ = b₁ - b₂ + a₂ := (nat.sub_eq_iff_eq_add ha.2).1 (eq_of_heq h.2),
sigma.mk.inj_iff.2
⟨nat.sub_add_cancel hb.2 ▸ h'.symm ▸ h.1 ▸ rfl,
(heq_of_eq h.1)⟩)
(λ ⟨a₁, a₂⟩ ha,
have ha : a₁ < n ∧ a₂ < n - a₁ :=
⟨mem_range.1 (mem_sigma.1 ha).1, (mem_range.1 (mem_sigma.1 ha).2)⟩,
⟨⟨a₂ + a₁, a₁⟩, ⟨mem_sigma.2 ⟨mem_range.2 (nat.lt_sub_right_iff_add_lt.1 ha.2),
mem_range.2 (nat.lt_succ_of_le (nat.le_add_left _ _))⟩,
sigma.mk.inj_iff.2 ⟨rfl, heq_of_eq (nat.add_sub_cancel _ _).symm⟩⟩⟩)
lemma sum_range_sub_sum_range {α : Type*} [add_comm_group α] {f : ℕ → α}
{n m : ℕ} (hnm : n ≤ m) : ∑ k in range m, f k - ∑ k in range n, f k =
∑ k in (range m).filter (λ k, n ≤ k), f k :=
begin
rw [← sum_sdiff (@filter_subset _ (λ k, n ≤ k) _ (range m)),
sub_eq_iff_eq_add, ← eq_sub_iff_add_eq, add_sub_cancel'],
refine finset.sum_congr
(finset.ext $ λ a, ⟨λ h, by simp at *; finish,
λ h, have ham : a < m := lt_of_lt_of_le (mem_range.1 h) hnm,
by simp * at *⟩)
(λ _ _, rfl),
end
end
section no_archimedean
variables {α : Type*} {β : Type*} [ring β]
[discrete_linear_ordered_field α] {abv : β → α} [is_absolute_value abv]
lemma abv_sum_le_sum_abv {γ : Type*} (f : γ → β) (s : finset γ) :
abv (∑ k in s, f k) ≤ ∑ k in s, abv (f k) :=
by haveI := classical.dec_eq γ; exact
finset.induction_on s (by simp [abv_zero abv])
(λ a s has ih, by rw [sum_insert has, sum_insert has];
exact le_trans (abv_add abv _ _) (add_le_add_left ih _))
lemma cauchy_product {a b : ℕ → β}
(ha : is_cau_seq abs (λ m, ∑ n in range m, abv (a n)))
(hb : is_cau_seq abv (λ m, ∑ n in range m, b n)) (ε : α) (ε0 : 0 < ε) :
∃ i : ℕ, ∀ j ≥ i, abv ((∑ k in range j, a k) * (∑ k in range j, b k) -
∑ n in range j, ∑ m in range (n + 1), a m * b (n - m)) < ε :=
let ⟨Q, hQ⟩ := cau_seq.bounded ⟨_, hb⟩ in
let ⟨P, hP⟩ := cau_seq.bounded ⟨_, ha⟩ in
have hP0 : 0 < P, from lt_of_le_of_lt (abs_nonneg _) (hP 0),
have hPε0 : 0 < ε / (2 * P),
from div_pos ε0 (mul_pos (show (2 : α) > 0, from by norm_num) hP0),
let ⟨N, hN⟩ := cau_seq.cauchy₂ ⟨_, hb⟩ hPε0 in
have hQε0 : 0 < ε / (4 * Q),
from div_pos ε0 (mul_pos (show (0 : α) < 4, by norm_num)
(lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))),
let ⟨M, hM⟩ := cau_seq.cauchy₂ ⟨_, ha⟩ hQε0 in
⟨2 * (max N M + 1), λ K hK,
have h₁ : ∑ m in range K, ∑ k in range (m + 1), a k * b (m - k) =
∑ m in range K, ∑ n in range (K - m), a m * b n,
by simpa using sum_range_diag_flip K (λ m n, a m * b n),
have h₂ : (λ i, ∑ k in range (K - i), a i * b k) = (λ i, a i * ∑ k in range (K - i), b k),
by simp [finset.mul_sum],
have h₃ : ∑ i in range K, a i * ∑ k in range (K - i), b k =
∑ i in range K, a i * (∑ k in range (K - i), b k - ∑ k in range K, b k)
+ ∑ i in range K, a i * ∑ k in range K, b k,
by rw ← sum_add_distrib; simp [(mul_add _ _ _).symm],
have two_mul_two : (4 : α) = 2 * 2, by norm_num,
have hQ0 : Q ≠ 0, from λ h, by simpa [h, lt_irrefl] using hQε0,
have h2Q0 : 2 * Q ≠ 0, from mul_ne_zero two_ne_zero hQ0,
have hε : ε / (2 * P) * P + ε / (4 * Q) * (2 * Q) = ε,
by rw [← div_div_eq_div_mul, div_mul_cancel _ (ne.symm (ne_of_lt hP0)),
two_mul_two, mul_assoc, ← div_div_eq_div_mul, div_mul_cancel _ h2Q0, add_halves],
have hNMK : max N M + 1 < K,
from lt_of_lt_of_le (by rw two_mul; exact lt_add_of_pos_left _ (nat.succ_pos _)) hK,
have hKN : N < K,
from calc N ≤ max N M : le_max_left _ _
... < max N M + 1 : nat.lt_succ_self _
... < K : hNMK,
have hsumlesum : ∑ i in range (max N M + 1), abv (a i) *
abv (∑ k in range (K - i), b k - ∑ k in range K, b k) ≤
∑ i in range (max N M + 1), abv (a i) * (ε / (2 * P)),
from sum_le_sum (λ m hmJ, mul_le_mul_of_nonneg_left
(le_of_lt (hN (K - m) K
(nat.le_sub_left_of_add_le (le_trans
(by rw two_mul; exact add_le_add (le_of_lt (mem_range.1 hmJ))
(le_trans (le_max_left _ _) (le_of_lt (lt_add_one _)))) hK))
(le_of_lt hKN))) (abv_nonneg abv _)),
have hsumltP : ∑ n in range (max N M + 1), abv (a n) < P :=
calc ∑ n in range (max N M + 1), abv (a n)
= abs (∑ n in range (max N M + 1), abv (a n)) :
eq.symm (abs_of_nonneg (sum_nonneg (λ x h, abv_nonneg abv (a x))))
... < P : hP (max N M + 1),
begin
rw [h₁, h₂, h₃, sum_mul, ← sub_sub, sub_right_comm, sub_self, zero_sub, abv_neg abv],
refine lt_of_le_of_lt (abv_sum_le_sum_abv _ _) _,
suffices : ∑ i in range (max N M + 1),
abv (a i) * abv (∑ k in range (K - i), b k - ∑ k in range K, b k) +
(∑ i in range K, abv (a i) * abv (∑ k in range (K - i), b k - ∑ k in range K, b k) -
∑ i in range (max N M + 1), abv (a i) * abv (∑ k in range (K - i), b k - ∑ k in range K, b k)) <
ε / (2 * P) * P + ε / (4 * Q) * (2 * Q),
{ rw hε at this, simpa [abv_mul abv] },
refine add_lt_add (lt_of_le_of_lt hsumlesum
(by rw [← sum_mul, mul_comm]; exact (mul_lt_mul_left hPε0).mpr hsumltP)) _,
rw sum_range_sub_sum_range (le_of_lt hNMK),
exact calc ∑ i in (range K).filter (λ k, max N M + 1 ≤ k),
abv (a i) * abv (∑ k in range (K - i), b k - ∑ k in range K, b k)
≤ ∑ i in (range K).filter (λ k, max N M + 1 ≤ k), abv (a i) * (2 * Q) :
sum_le_sum (λ n hn, begin
refine mul_le_mul_of_nonneg_left _ (abv_nonneg _ _),
rw sub_eq_add_neg,
refine le_trans (abv_add _ _ _) _,
rw [two_mul, abv_neg abv],
exact add_le_add (le_of_lt (hQ _)) (le_of_lt (hQ _)),
end)
... < ε / (4 * Q) * (2 * Q) :
by rw [← sum_mul, ← sum_range_sub_sum_range (le_of_lt hNMK)];
refine (mul_lt_mul_right $ by rw two_mul;
exact add_pos (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))
(lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))).2
(lt_of_le_of_lt (le_abs_self _)
(hM _ _ (le_trans (nat.le_succ_of_le (le_max_right _ _)) (le_of_lt hNMK))
(nat.le_succ_of_le (le_max_right _ _))))
end⟩
end no_archimedean
end
open finset
open cau_seq
namespace complex
lemma is_cau_abs_exp (z : ℂ) : is_cau_seq _root_.abs
(λ n, ∑ m in range n, abs (z ^ m / m!)) :=
let ⟨n, hn⟩ := exists_nat_gt (abs z) in
have hn0 : (0 : ℝ) < n, from lt_of_le_of_lt (abs_nonneg _) hn,
series_ratio_test n (complex.abs z / n) (div_nonneg (complex.abs_nonneg _) (le_of_lt hn0))
(by rwa [div_lt_iff hn0, one_mul])
(λ m hm,
by rw [abs_abs, abs_abs, nat.factorial_succ, pow_succ,
mul_comm m.succ, nat.cast_mul, ← div_div_eq_div_mul, mul_div_assoc,
mul_div_right_comm, abs_mul, abs_div, abs_cast_nat];
exact mul_le_mul_of_nonneg_right
(div_le_div_of_le_left (abs_nonneg _) hn0
(nat.cast_le.2 (le_trans hm (nat.le_succ _)))) (abs_nonneg _))
noncomputable theory
lemma is_cau_exp (z : ℂ) :
is_cau_seq abs (λ n, ∑ m in range n, z ^ m / m!) :=
is_cau_series_of_abv_cau (is_cau_abs_exp z)
/-- The Cauchy sequence consisting of partial sums of the Taylor series of
the complex exponential function -/
@[pp_nodot] def exp' (z : ℂ) :
cau_seq ℂ complex.abs :=
⟨λ n, ∑ m in range n, z ^ m / m!, is_cau_exp z⟩
/-- The complex exponential function, defined via its Taylor series -/
@[pp_nodot] def exp (z : ℂ) : ℂ := lim (exp' z)
/-- The complex sine function, defined via `exp` -/
@[pp_nodot] def sin (z : ℂ) : ℂ := ((exp (-z * I) - exp (z * I)) * I) / 2
/-- The complex cosine function, defined via `exp` -/
@[pp_nodot] def cos (z : ℂ) : ℂ := (exp (z * I) + exp (-z * I)) / 2
/-- The complex tangent function, defined as `sin z / cos z` -/
@[pp_nodot] def tan (z : ℂ) : ℂ := sin z / cos z
/-- The complex hyperbolic sine function, defined via `exp` -/
@[pp_nodot] def sinh (z : ℂ) : ℂ := (exp z - exp (-z)) / 2
/-- The complex hyperbolic cosine function, defined via `exp` -/
@[pp_nodot] def cosh (z : ℂ) : ℂ := (exp z + exp (-z)) / 2
/-- The complex hyperbolic tangent function, defined as `sinh z / cosh z` -/
@[pp_nodot] def tanh (z : ℂ) : ℂ := sinh z / cosh z
end complex
namespace real
open complex
/-- The real exponential function, defined as the real part of the complex exponential -/
@[pp_nodot] def exp (x : ℝ) : ℝ := (exp x).re
/-- The real sine function, defined as the real part of the complex sine -/
@[pp_nodot] def sin (x : ℝ) : ℝ := (sin x).re
/-- The real cosine function, defined as the real part of the complex cosine -/
@[pp_nodot] def cos (x : ℝ) : ℝ := (cos x).re
/-- The real tangent function, defined as the real part of the complex tangent -/
@[pp_nodot] def tan (x : ℝ) : ℝ := (tan x).re
/-- The real hypebolic sine function, defined as the real part of the complex hyperbolic sine -/
@[pp_nodot] def sinh (x : ℝ) : ℝ := (sinh x).re
/-- The real hypebolic cosine function, defined as the real part of the complex hyperbolic cosine -/
@[pp_nodot] def cosh (x : ℝ) : ℝ := (cosh x).re
/-- The real hypebolic tangent function, defined as the real part of
the complex hyperbolic tangent -/
@[pp_nodot] def tanh (x : ℝ) : ℝ := (tanh x).re
end real
namespace complex
variables (x y : ℂ)
@[simp] lemma exp_zero : exp 0 = 1 :=
lim_eq_of_equiv_const $
λ ε ε0, ⟨1, λ j hj, begin
convert ε0,
cases j,
{ exact absurd hj (not_le_of_gt zero_lt_one) },
{ dsimp [exp'],
induction j with j ih,
{ dsimp [exp']; simp },
{ rw ← ih dec_trivial,
simp only [sum_range_succ, pow_succ],
simp } }
end⟩
lemma exp_add : exp (x + y) = exp x * exp y :=
show lim (⟨_, is_cau_exp (x + y)⟩ : cau_seq ℂ abs) =
lim (show cau_seq ℂ abs, from ⟨_, is_cau_exp x⟩)
* lim (show cau_seq ℂ abs, from ⟨_, is_cau_exp y⟩),
from
have hj : ∀ j : ℕ, ∑ m in range j, (x + y) ^ m / m! =
∑ i in range j, ∑ k in range (i + 1), x ^ k / k! * (y ^ (i - k) / (i - k)!),
from assume j,
finset.sum_congr rfl (λ m hm, begin
rw [add_pow, div_eq_mul_inv, sum_mul],
refine finset.sum_congr rfl (λ i hi, _),
have h₁ : (m.choose i : ℂ) ≠ 0 := nat.cast_ne_zero.2
(nat.pos_iff_ne_zero.1 (nat.choose_pos (nat.le_of_lt_succ (mem_range.1 hi)))),
have h₂ := nat.choose_mul_factorial_mul_factorial (nat.le_of_lt_succ $ finset.mem_range.1 hi),
rw [← h₂, nat.cast_mul, nat.cast_mul, mul_inv', mul_inv'],
simp only [mul_left_comm (m.choose i : ℂ), mul_assoc, mul_left_comm (m.choose i : ℂ)⁻¹,
mul_comm (m.choose i : ℂ)],
rw inv_mul_cancel h₁,
simp [div_eq_mul_inv, mul_comm, mul_assoc, mul_left_comm]
end),
by rw lim_mul_lim;
exact eq.symm (lim_eq_lim_of_equiv (by dsimp; simp only [hj];
exact cauchy_product (is_cau_abs_exp x) (is_cau_exp y)))
attribute [irreducible] complex.exp
lemma exp_list_sum (l : list ℂ) : exp l.sum = (l.map exp).prod :=
@monoid_hom.map_list_prod (multiplicative ℂ) ℂ _ _ ⟨exp, exp_zero, exp_add⟩ l
lemma exp_multiset_sum (s : multiset ℂ) : exp s.sum = (s.map exp).prod :=
@monoid_hom.map_multiset_prod (multiplicative ℂ) ℂ _ _ ⟨exp, exp_zero, exp_add⟩ s
lemma exp_sum {α : Type*} (s : finset α) (f : α → ℂ) : exp (∑ x in s, f x) = ∏ x in s, exp (f x) :=
@monoid_hom.map_prod α (multiplicative ℂ) ℂ _ _ ⟨exp, exp_zero, exp_add⟩ f s
lemma exp_nat_mul (x : ℂ) : ∀ n : ℕ, exp(n*x) = (exp x)^n
| 0 := by rw [nat.cast_zero, zero_mul, exp_zero, pow_zero]
| (nat.succ n) := by rw [pow_succ', nat.cast_add_one, add_mul, exp_add, ←exp_nat_mul, one_mul]
lemma exp_ne_zero : exp x ≠ 0 :=
λ h, zero_ne_one $ by rw [← exp_zero, ← add_neg_self x, exp_add, h]; simp
lemma exp_neg : exp (-x) = (exp x)⁻¹ :=
by rw [← mul_right_inj' (exp_ne_zero x), ← exp_add];
simp [mul_inv_cancel (exp_ne_zero x)]
lemma exp_sub : exp (x - y) = exp x / exp y :=
by simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv]
@[simp] lemma exp_conj : exp (conj x) = conj (exp x) :=
begin
dsimp [exp],
rw [← lim_conj],
refine congr_arg lim (cau_seq.ext (λ _, _)),
dsimp [exp', function.comp, cau_seq_conj],
rw conj.map_sum,
refine sum_congr rfl (λ n hn, _),
rw [conj.map_div, conj.map_pow, ← of_real_nat_cast, conj_of_real]
end
@[simp] lemma of_real_exp_of_real_re (x : ℝ) : ((exp x).re : ℂ) = exp x :=
eq_conj_iff_re.1 $ by rw [← exp_conj, conj_of_real]
@[simp, norm_cast] lemma of_real_exp (x : ℝ) : (real.exp x : ℂ) = exp x :=
of_real_exp_of_real_re _
@[simp] lemma exp_of_real_im (x : ℝ) : (exp x).im = 0 :=
by rw [← of_real_exp_of_real_re, of_real_im]
lemma exp_of_real_re (x : ℝ) : (exp x).re = real.exp x := rfl
lemma two_sinh : 2 * sinh x = exp x - exp (-x) :=
mul_div_cancel' _ two_ne_zero'
lemma two_cosh : 2 * cosh x = exp x + exp (-x) :=
mul_div_cancel' _ two_ne_zero'
@[simp] lemma sinh_zero : sinh 0 = 0 := by simp [sinh]
@[simp] lemma sinh_neg : sinh (-x) = -sinh x :=
by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul]
private lemma sinh_add_aux {a b c d : ℂ} :
(a - b) * (c + d) + (a + b) * (c - d) = 2 * (a * c - b * d) := by ring
lemma sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y :=
begin
rw [← mul_right_inj' (@two_ne_zero' ℂ _ _ _), two_sinh,
exp_add, neg_add, exp_add, eq_comm,
mul_add, ← mul_assoc, two_sinh, mul_left_comm, two_sinh,
← mul_right_inj' (@two_ne_zero' ℂ _ _ _), mul_add,
mul_left_comm, two_cosh, ← mul_assoc, two_cosh],
exact sinh_add_aux
end
@[simp] lemma cosh_zero : cosh 0 = 1 := by simp [cosh]
@[simp] lemma cosh_neg : cosh (-x) = cosh x :=
by simp [add_comm, cosh, exp_neg]
private lemma cosh_add_aux {a b c d : ℂ} :
(a + b) * (c + d) + (a - b) * (c - d) = 2 * (a * c + b * d) := by ring
lemma cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y :=
begin
rw [← mul_right_inj' (@two_ne_zero' ℂ _ _ _), two_cosh,
exp_add, neg_add, exp_add, eq_comm,
mul_add, ← mul_assoc, two_cosh, ← mul_assoc, two_sinh,
← mul_right_inj' (@two_ne_zero' ℂ _ _ _), mul_add,
mul_left_comm, two_cosh, mul_left_comm, two_sinh],
exact cosh_add_aux
end
lemma sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y :=
by simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg]
lemma cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y :=
by simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg]
lemma sinh_conj : sinh (conj x) = conj (sinh x) :=
by rw [sinh, ← conj.map_neg, exp_conj, exp_conj, ← conj.map_sub, sinh, conj.map_div, conj_bit0, conj.map_one]
@[simp] lemma of_real_sinh_of_real_re (x : ℝ) : ((sinh x).re : ℂ) = sinh x :=
eq_conj_iff_re.1 $ by rw [← sinh_conj, conj_of_real]
@[simp, norm_cast] lemma of_real_sinh (x : ℝ) : (real.sinh x : ℂ) = sinh x :=
of_real_sinh_of_real_re _
@[simp] lemma sinh_of_real_im (x : ℝ) : (sinh x).im = 0 :=
by rw [← of_real_sinh_of_real_re, of_real_im]
lemma sinh_of_real_re (x : ℝ) : (sinh x).re = real.sinh x := rfl
lemma cosh_conj : cosh (conj x) = conj (cosh x) :=
begin
rw [cosh, ← conj.map_neg, exp_conj, exp_conj, ← conj.map_add, cosh, conj.map_div,
conj_bit0, conj.map_one]
end
@[simp] lemma of_real_cosh_of_real_re (x : ℝ) : ((cosh x).re : ℂ) = cosh x :=
eq_conj_iff_re.1 $ by rw [← cosh_conj, conj_of_real]
@[simp, norm_cast] lemma of_real_cosh (x : ℝ) : (real.cosh x : ℂ) = cosh x :=
of_real_cosh_of_real_re _
@[simp] lemma cosh_of_real_im (x : ℝ) : (cosh x).im = 0 :=
by rw [← of_real_cosh_of_real_re, of_real_im]
lemma cosh_of_real_re (x : ℝ) : (cosh x).re = real.cosh x := rfl
lemma tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x := rfl
@[simp] lemma tanh_zero : tanh 0 = 0 := by simp [tanh]
@[simp] lemma tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div]
lemma tanh_conj : tanh (conj x) = conj (tanh x) :=
by rw [tanh, sinh_conj, cosh_conj, ← conj.map_div, tanh]
@[simp] lemma of_real_tanh_of_real_re (x : ℝ) : ((tanh x).re : ℂ) = tanh x :=
eq_conj_iff_re.1 $ by rw [← tanh_conj, conj_of_real]
@[simp, norm_cast] lemma of_real_tanh (x : ℝ) : (real.tanh x : ℂ) = tanh x :=
of_real_tanh_of_real_re _
@[simp] lemma tanh_of_real_im (x : ℝ) : (tanh x).im = 0 :=
by rw [← of_real_tanh_of_real_re, of_real_im]
lemma tanh_of_real_re (x : ℝ) : (tanh x).re = real.tanh x := rfl
lemma cosh_add_sinh : cosh x + sinh x = exp x :=
by rw [← mul_right_inj' (@two_ne_zero' ℂ _ _ _), mul_add,
two_cosh, two_sinh, add_add_sub_cancel, two_mul]
lemma sinh_add_cosh : sinh x + cosh x = exp x :=
by rw [add_comm, cosh_add_sinh]
lemma cosh_sub_sinh : cosh x - sinh x = exp (-x) :=
by rw [← mul_right_inj' (@two_ne_zero' ℂ _ _ _), mul_sub,
two_cosh, two_sinh, add_sub_sub_cancel, two_mul]
lemma cosh_sq_sub_sinh_sq : cosh x ^ 2 - sinh x ^ 2 = 1 :=
by rw [sq_sub_sq, cosh_add_sinh, cosh_sub_sinh, ← exp_add, add_neg_self, exp_zero]
@[simp] lemma sin_zero : sin 0 = 0 := by simp [sin]
@[simp] lemma sin_neg : sin (-x) = -sin x :=
by simp [sin, sub_eq_add_neg, exp_neg, (neg_div _ _).symm, add_mul]
lemma two_sin : 2 * sin x = (exp (-x * I) - exp (x * I)) * I :=
mul_div_cancel' _ two_ne_zero'
lemma two_cos : 2 * cos x = exp (x * I) + exp (-x * I) :=
mul_div_cancel' _ two_ne_zero'
lemma sinh_mul_I : sinh (x * I) = sin x * I :=
by rw [← mul_right_inj' (@two_ne_zero' ℂ _ _ _), two_sinh,
← mul_assoc, two_sin, mul_assoc, I_mul_I, mul_neg_one,
neg_sub, neg_mul_eq_neg_mul]
lemma cosh_mul_I : cosh (x * I) = cos x :=
by rw [← mul_right_inj' (@two_ne_zero' ℂ _ _ _), two_cosh,
two_cos, neg_mul_eq_neg_mul]
lemma sin_add : sin (x + y) = sin x * cos y + cos x * sin y :=
by rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I,
add_mul, add_mul, mul_right_comm, ← sinh_mul_I,
mul_assoc, ← sinh_mul_I, ← cosh_mul_I, ← cosh_mul_I, sinh_add]
@[simp] lemma cos_zero : cos 0 = 1 := by simp [cos]
@[simp] lemma cos_neg : cos (-x) = cos x :=
by simp [cos, sub_eq_add_neg, exp_neg, add_comm]
private lemma cos_add_aux {a b c d : ℂ} :
(a + b) * (c + d) - (b - a) * (d - c) * (-1) =
2 * (a * c + b * d) := by ring
lemma cos_add : cos (x + y) = cos x * cos y - sin x * sin y :=
by rw [← cosh_mul_I, add_mul, cosh_add, cosh_mul_I, cosh_mul_I,
sinh_mul_I, sinh_mul_I, mul_mul_mul_comm, I_mul_I,
mul_neg_one, sub_eq_add_neg]
lemma sin_sub : sin (x - y) = sin x * cos y - cos x * sin y :=
by simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg]
lemma cos_sub : cos (x - y) = cos x * cos y + sin x * sin y :=
by simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg]
lemma sin_conj : sin (conj x) = conj (sin x) :=
by rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I,
← conj_neg_I, ← conj.map_mul, ← conj.map_mul, sinh_conj,
mul_neg_eq_neg_mul_symm, sinh_neg, sinh_mul_I, mul_neg_eq_neg_mul_symm]
@[simp] lemma of_real_sin_of_real_re (x : ℝ) : ((sin x).re : ℂ) = sin x :=
eq_conj_iff_re.1 $ by rw [← sin_conj, conj_of_real]
@[simp, norm_cast] lemma of_real_sin (x : ℝ) : (real.sin x : ℂ) = sin x :=
of_real_sin_of_real_re _
@[simp] lemma sin_of_real_im (x : ℝ) : (sin x).im = 0 :=
by rw [← of_real_sin_of_real_re, of_real_im]
lemma sin_of_real_re (x : ℝ) : (sin x).re = real.sin x := rfl
lemma cos_conj : cos (conj x) = conj (cos x) :=
by rw [← cosh_mul_I, ← conj_neg_I, ← conj.map_mul, ← cosh_mul_I,
cosh_conj, mul_neg_eq_neg_mul_symm, cosh_neg]
@[simp] lemma of_real_cos_of_real_re (x : ℝ) : ((cos x).re : ℂ) = cos x :=
eq_conj_iff_re.1 $ by rw [← cos_conj, conj_of_real]
@[simp, norm_cast] lemma of_real_cos (x : ℝ) : (real.cos x : ℂ) = cos x :=
of_real_cos_of_real_re _
@[simp] lemma cos_of_real_im (x : ℝ) : (cos x).im = 0 :=
by rw [← of_real_cos_of_real_re, of_real_im]
lemma cos_of_real_re (x : ℝ) : (cos x).re = real.cos x := rfl
@[simp] lemma tan_zero : tan 0 = 0 := by simp [tan]
lemma tan_eq_sin_div_cos : tan x = sin x / cos x := rfl
@[simp] lemma tan_neg : tan (-x) = -tan x := by simp [tan, neg_div]
lemma tan_conj : tan (conj x) = conj (tan x) :=
by rw [tan, sin_conj, cos_conj, ← conj.map_div, tan]
@[simp] lemma of_real_tan_of_real_re (x : ℝ) : ((tan x).re : ℂ) = tan x :=
eq_conj_iff_re.1 $ by rw [← tan_conj, conj_of_real]
@[simp, norm_cast] lemma of_real_tan (x : ℝ) : (real.tan x : ℂ) = tan x :=
of_real_tan_of_real_re _
@[simp] lemma tan_of_real_im (x : ℝ) : (tan x).im = 0 :=
by rw [← of_real_tan_of_real_re, of_real_im]
lemma tan_of_real_re (x : ℝ) : (tan x).re = real.tan x := rfl
lemma cos_add_sin_I : cos x + sin x * I = exp (x * I) :=
by rw [← cosh_add_sinh, sinh_mul_I, cosh_mul_I]
lemma cos_sub_sin_I : cos x - sin x * I = exp (-x * I) :=
by rw [← neg_mul_eq_neg_mul, ← cosh_sub_sinh, sinh_mul_I, cosh_mul_I]
lemma sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 :=
eq.trans
(by rw [cosh_mul_I, sinh_mul_I, mul_pow, I_sq, mul_neg_one, sub_neg_eq_add, add_comm])
(cosh_sq_sub_sinh_sq (x * I))
lemma cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 :=
by rw [two_mul, cos_add, ← pow_two, ← pow_two]
lemma cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 :=
by rw [cos_two_mul', eq_sub_iff_add_eq.2 (sin_sq_add_cos_sq x),
← sub_add, sub_add_eq_add_sub, two_mul]
lemma sin_two_mul : sin (2 * x) = 2 * sin x * cos x :=
by rw [two_mul, sin_add, two_mul, add_mul, mul_comm]
lemma cos_square : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 :=
by simp [cos_two_mul, div_add_div_same, mul_div_cancel_left, two_ne_zero', -one_div]
lemma sin_square : sin x ^ 2 = 1 - cos x ^ 2 :=
by { rw [←sin_sq_add_cos_sq x], simp }
lemma exp_mul_I : exp (x * I) = cos x + sin x * I :=
(cos_add_sin_I _).symm
lemma exp_add_mul_I : exp (x + y * I) = exp x * (cos y + sin y * I) :=
by rw [exp_add, exp_mul_I]
lemma exp_eq_exp_re_mul_sin_add_cos : exp x = exp x.re * (cos x.im + sin x.im * I) :=
by rw [← exp_add_mul_I, re_add_im]
/-- De Moivre's formula -/
theorem cos_add_sin_mul_I_pow (n : ℕ) (z : ℂ) : (cos z + sin z * I) ^ n = cos (↑n * z) + sin (↑n * z) * I :=
begin
rw [← exp_mul_I, ← exp_mul_I],
induction n with n ih,
{ rw [pow_zero, nat.cast_zero, zero_mul, zero_mul, exp_zero] },
{ rw [pow_succ', ih, nat.cast_succ, add_mul, add_mul, one_mul, exp_add] }
end
end complex
namespace real
open complex
variables (x y : ℝ)
@[simp] lemma exp_zero : exp 0 = 1 :=
by simp [real.exp]
lemma exp_add : exp (x + y) = exp x * exp y :=
by simp [exp_add, exp]
lemma exp_list_sum (l : list ℝ) : exp l.sum = (l.map exp).prod :=
@monoid_hom.map_list_prod (multiplicative ℝ) ℝ _ _ ⟨exp, exp_zero, exp_add⟩ l
lemma exp_multiset_sum (s : multiset ℝ) : exp s.sum = (s.map exp).prod :=
@monoid_hom.map_multiset_prod (multiplicative ℝ) ℝ _ _ ⟨exp, exp_zero, exp_add⟩ s
lemma exp_sum {α : Type*} (s : finset α) (f : α → ℝ) : exp (∑ x in s, f x) = ∏ x in s, exp (f x) :=
@monoid_hom.map_prod α (multiplicative ℝ) ℝ _ _ ⟨exp, exp_zero, exp_add⟩ f s
lemma exp_nat_mul (x : ℝ) : ∀ n : ℕ, exp(n*x) = (exp x)^n
| 0 := by rw [nat.cast_zero, zero_mul, exp_zero, pow_zero]
| (nat.succ n) := by rw [pow_succ', nat.cast_add_one, add_mul, exp_add, ←exp_nat_mul, one_mul]
lemma exp_ne_zero : exp x ≠ 0 :=
λ h, exp_ne_zero x $ by rw [exp, ← of_real_inj] at h; simp * at *
lemma exp_neg : exp (-x) = (exp x)⁻¹ :=
by rw [← of_real_inj, exp, of_real_exp_of_real_re, of_real_neg, exp_neg,
of_real_inv, of_real_exp]
lemma exp_sub : exp (x - y) = exp x / exp y :=
by simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv]
@[simp] lemma sin_zero : sin 0 = 0 := by simp [sin]
@[simp] lemma sin_neg : sin (-x) = -sin x :=
by simp [sin, exp_neg, (neg_div _ _).symm, add_mul]
lemma sin_add : sin (x + y) = sin x * cos y + cos x * sin y :=
by rw [← of_real_inj]; simp [sin, sin_add]
@[simp] lemma cos_zero : cos 0 = 1 := by simp [cos]
@[simp] lemma cos_neg : cos (-x) = cos x :=
by simp [cos, exp_neg]
lemma cos_add : cos (x + y) = cos x * cos y - sin x * sin y :=
by rw ← of_real_inj; simp [cos, cos_add]
lemma sin_sub : sin (x - y) = sin x * cos y - cos x * sin y :=
by simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg]
lemma cos_sub : cos (x - y) = cos x * cos y + sin x * sin y :=
by simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg]
lemma tan_eq_sin_div_cos : tan x = sin x / cos x :=
if h : complex.cos x = 0 then by simp [sin, cos, tan, *, complex.tan, div_eq_mul_inv] at *
else
by rw [sin, cos, tan, complex.tan, ← of_real_inj, div_eq_mul_inv, mul_re];
simp [norm_sq, (div_div_eq_div_mul _ _ _).symm, div_self h]; refl
@[simp] lemma tan_zero : tan 0 = 0 := by simp [tan]
@[simp] lemma tan_neg : tan (-x) = -tan x := by simp [tan, neg_div]
lemma sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 :=
of_real_inj.1 $ by simpa using sin_sq_add_cos_sq x
lemma sin_sq_le_one : sin x ^ 2 ≤ 1 :=
by rw ← sin_sq_add_cos_sq x; exact le_add_of_nonneg_right (pow_two_nonneg _)
lemma cos_sq_le_one : cos x ^ 2 ≤ 1 :=
by rw ← sin_sq_add_cos_sq x; exact le_add_of_nonneg_left (pow_two_nonneg _)
lemma abs_sin_le_one : abs' (sin x) ≤ 1 :=
(mul_self_le_mul_self_iff (_root_.abs_nonneg (sin x)) (by exact zero_le_one)).2 $
by rw [← _root_.abs_mul, abs_mul_self, mul_one, ← pow_two];
apply sin_sq_le_one
lemma abs_cos_le_one : abs' (cos x) ≤ 1 :=
(mul_self_le_mul_self_iff (_root_.abs_nonneg (cos x)) (by exact zero_le_one)).2 $
by rw [← _root_.abs_mul, abs_mul_self, mul_one, ← pow_two];
apply cos_sq_le_one
lemma sin_le_one : sin x ≤ 1 :=
(abs_le.1 (abs_sin_le_one _)).2
lemma cos_le_one : cos x ≤ 1 :=
(abs_le.1 (abs_cos_le_one _)).2
lemma neg_one_le_sin : -1 ≤ sin x :=
(abs_le.1 (abs_sin_le_one _)).1
lemma neg_one_le_cos : -1 ≤ cos x :=
(abs_le.1 (abs_cos_le_one _)).1
lemma cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 :=
by rw ← of_real_inj; simp [cos_two_mul]
lemma sin_two_mul : sin (2 * x) = 2 * sin x * cos x :=
by rw ← of_real_inj; simp [sin_two_mul]
lemma cos_square : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 :=
of_real_inj.1 $ by simpa using cos_square x
lemma sin_square : sin x ^ 2 = 1 - cos x ^ 2 :=
eq_sub_iff_add_eq.2 $ sin_sq_add_cos_sq _
/-- The definition of `sinh` in terms of `exp`. -/
lemma sinh_eq (x : ℝ) : sinh x = (exp x - exp (-x)) / 2 :=
eq_div_of_mul_eq two_ne_zero $ by rw [sinh, exp, exp, complex.of_real_neg, complex.sinh, mul_two,
← complex.add_re, ← mul_two, div_mul_cancel _ (two_ne_zero' : (2 : ℂ) ≠ 0), complex.sub_re]
@[simp] lemma sinh_zero : sinh 0 = 0 := by simp [sinh]
@[simp] lemma sinh_neg : sinh (-x) = -sinh x :=
by simp [sinh, exp_neg, (neg_div _ _).symm, add_mul]
lemma sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y :=
by rw ← of_real_inj; simp [sinh_add]
/-- The definition of `cosh` in terms of `exp`. -/
lemma cosh_eq (x : ℝ) : cosh x = (exp x + exp (-x)) / 2 :=
eq_div_of_mul_eq two_ne_zero $ by rw [cosh, exp, exp, complex.of_real_neg, complex.cosh, mul_two,
← complex.add_re, ← mul_two, div_mul_cancel _ (two_ne_zero' : (2 : ℂ) ≠ 0), complex.add_re]
@[simp] lemma cosh_zero : cosh 0 = 1 := by simp [cosh]
@[simp] lemma cosh_neg : cosh (-x) = cosh x :=
by simp [cosh, exp_neg]
lemma cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y :=
by rw ← of_real_inj; simp [cosh, cosh_add]
lemma sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y :=
by simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg]
lemma cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y :=
by simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg]
lemma cosh_sq_sub_sinh_sq (x : ℝ) : cosh x ^ 2 - sinh x ^ 2 = 1 :=
begin
rw [sinh, cosh],
have := congr_arg complex.re (complex.cosh_sq_sub_sinh_sq x),
rw [pow_two, pow_two] at this,
change (⟨_, _⟩ : ℂ).re - (⟨_, _⟩ : ℂ).re = 1 at this,
rw [complex.cosh_of_real_im x, complex.sinh_of_real_im x, mul_zero, sub_zero, sub_zero] at this,
rwa [pow_two, pow_two],
end
lemma tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x :=
of_real_inj.1 $ by simp [tanh_eq_sinh_div_cosh]
@[simp] lemma tanh_zero : tanh 0 = 0 := by simp [tanh]
@[simp] lemma tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div]
open is_absolute_value
/- TODO make this private and prove ∀ x -/
lemma add_one_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : x + 1 ≤ exp x :=
calc x + 1 ≤ lim (⟨(λ n : ℕ, ((exp' x) n).re), is_cau_seq_re (exp' x)⟩ : cau_seq ℝ abs') :
le_lim (cau_seq.le_of_exists ⟨2,
λ j hj, show x + (1 : ℝ) ≤ (∑ m in range j, (x ^ m / m! : ℂ)).re,
from have h₁ : (((λ m : ℕ, (x ^ m / m! : ℂ)) ∘ nat.succ) 0).re = x, by simp,
have h₂ : ((x : ℂ) ^ 0 / 0!).re = 1, by simp,
begin
rw [← nat.sub_add_cancel hj, sum_range_succ', sum_range_succ',
add_re, add_re, h₁, h₂, add_assoc,
← @sum_hom _ _ _ _ _ _ _ complex.re
(is_add_group_hom.to_is_add_monoid_hom _)],
refine le_add_of_nonneg_of_le (sum_nonneg (λ m hm, _)) (le_refl _),
rw [← of_real_pow, ← of_real_nat_cast, ← of_real_div, of_real_re],
exact div_nonneg (pow_nonneg hx _) (nat.cast_nonneg _),
end⟩)
... = exp x : by rw [exp, complex.exp, ← cau_seq_re, lim_re]
lemma one_le_exp {x : ℝ} (hx : 0 ≤ x) : 1 ≤ exp x :=
by linarith [add_one_le_exp_of_nonneg hx]
lemma exp_pos (x : ℝ) : 0 < exp x :=
(le_total 0 x).elim (lt_of_lt_of_le zero_lt_one ∘ one_le_exp)
(λ h, by rw [← neg_neg x, real.exp_neg];
exact inv_pos.2 (lt_of_lt_of_le zero_lt_one (one_le_exp (neg_nonneg.2 h))))
@[simp] lemma abs_exp (x : ℝ) : abs' (exp x) = exp x :=
abs_of_pos (exp_pos _)
lemma exp_strict_mono : strict_mono exp :=
λ x y h, by rw [← sub_add_cancel y x, real.exp_add];
exact (lt_mul_iff_one_lt_left (exp_pos _)).2
(lt_of_lt_of_le (by linarith) (add_one_le_exp_of_nonneg (by linarith)))
@[mono] lemma exp_monotone : ∀ {x y : ℝ}, x ≤ y → exp x ≤ exp y := exp_strict_mono.monotone
lemma exp_lt_exp {x y : ℝ} : exp x < exp y ↔ x < y := exp_strict_mono.lt_iff_lt
lemma exp_le_exp {x y : ℝ} : exp x ≤ exp y ↔ x ≤ y := exp_strict_mono.le_iff_le
lemma exp_injective : function.injective exp := exp_strict_mono.injective
@[simp] lemma exp_eq_one_iff : exp x = 1 ↔ x = 0 :=
by rw [← exp_zero, exp_injective.eq_iff]
@[simp] lemma one_lt_exp_iff {x : ℝ} : 1 < exp x ↔ 0 < x :=
by rw [← exp_zero, exp_lt_exp]
@[simp] lemma exp_lt_one_iff {x : ℝ} : exp x < 1 ↔ x < 0 :=
by rw [← exp_zero, exp_lt_exp]
@[simp] lemma exp_le_one_iff {x : ℝ} : exp x ≤ 1 ↔ x ≤ 0 :=
exp_zero ▸ exp_le_exp
@[simp] lemma one_le_exp_iff {x : ℝ} : 1 ≤ exp x ↔ 0 ≤ x :=
exp_zero ▸ exp_le_exp
/-- `real.cosh` is always positive -/
lemma cosh_pos (x : ℝ) : 0 < real.cosh x :=
(cosh_eq x).symm ▸ half_pos (add_pos (exp_pos x) (exp_pos (-x)))
end real
namespace complex
lemma sum_div_factorial_le {α : Type*} [discrete_linear_ordered_field α] (n j : ℕ) (hn : 0 < n) :
∑ m in filter (λ k, n ≤ k) (range j), (1 / m! : α) ≤ n.succ * (n! * n)⁻¹ :=
calc ∑ m in filter (λ k, n ≤ k) (range j), (1 / m! : α)
= ∑ m in range (j - n), 1 / (m + n)! :
sum_bij (λ m _, m - n)
(λ m hm, mem_range.2 $ (nat.sub_lt_sub_right_iff (by simp at hm; tauto)).2
(by simp at hm; tauto))
(λ m hm, by rw nat.sub_add_cancel; simp at *; tauto)
(λ a₁ a₂ ha₁ ha₂ h,
by rwa [nat.sub_eq_iff_eq_add, ← nat.sub_add_comm, eq_comm, nat.sub_eq_iff_eq_add, add_left_inj, eq_comm] at h;
simp at *; tauto)
(λ b hb, ⟨b + n, mem_filter.2 ⟨mem_range.2 $ nat.add_lt_of_lt_sub_right (mem_range.1 hb), nat.le_add_left _ _⟩,
by rw nat.add_sub_cancel⟩)
... ≤ ∑ m in range (j - n), (n! * n.succ ^ m)⁻¹ :
begin
refine sum_le_sum (assume m n, _),
rw [one_div, inv_le_inv],
{ rw [← nat.cast_pow, ← nat.cast_mul, nat.cast_le, add_comm],
exact nat.factorial_mul_pow_le_factorial },
{ exact nat.cast_pos.2 (nat.factorial_pos _) },
{ exact mul_pos (nat.cast_pos.2 (nat.factorial_pos _))
(pow_pos (nat.cast_pos.2 (nat.succ_pos _)) _) },
end
... = n!⁻¹ * ∑ m in range (j - n), n.succ⁻¹ ^ m :
by simp [mul_inv', mul_sum.symm, sum_mul.symm, -nat.factorial_succ, mul_comm, inv_pow']
... = (n.succ - n.succ * n.succ⁻¹ ^ (j - n)) / (n! * n) :
have h₁ : (n.succ : α) ≠ 1, from @nat.cast_one α _ _ ▸ mt nat.cast_inj.1
(mt nat.succ.inj (nat.pos_iff_ne_zero.1 hn)),
have h₂ : (n.succ : α) ≠ 0, from nat.cast_ne_zero.2 (nat.succ_ne_zero _),
have h₃ : (n! * n : α) ≠ 0,
from mul_ne_zero (nat.cast_ne_zero.2 (nat.pos_iff_ne_zero.1 (nat.factorial_pos _)))
(nat.cast_ne_zero.2 (nat.pos_iff_ne_zero.1 hn)),
have h₄ : (n.succ - 1 : α) = n, by simp,
by rw [← geom_series_def, geom_sum_inv h₁ h₂, eq_div_iff_mul_eq h₃,
mul_comm _ (n! * n : α), ← mul_assoc (n!⁻¹ : α), ← mul_inv_rev', h₄,
← mul_assoc (n! * n : α), mul_comm (n : α) n!, mul_inv_cancel h₃];
simp [mul_add, add_mul, mul_assoc, mul_comm]
... ≤ n.succ / (n! * n) :
begin
refine iff.mpr (div_le_div_right (mul_pos _ _)) _,
exact nat.cast_pos.2 (nat.factorial_pos _),
exact nat.cast_pos.2 hn,
exact sub_le_self _
(mul_nonneg (nat.cast_nonneg _) (pow_nonneg (inv_nonneg.2 (nat.cast_nonneg _)) _))
end
lemma exp_bound {x : ℂ} (hx : abs x ≤ 1) {n : ℕ} (hn : 0 < n) :
abs (exp x - ∑ m in range n, x ^ m / m!) ≤ abs x ^ n * (n.succ * (n! * n)⁻¹) :=
begin
rw [← lim_const (∑ m in range n, _), exp, sub_eq_add_neg, ← lim_neg, lim_add, ← lim_abs],
refine lim_le (cau_seq.le_of_exists ⟨n, λ j hj, _⟩),
show abs (∑ m in range j, x ^ m / m! - ∑ m in range n, x ^ m / m!)
≤ abs x ^ n * (n.succ * (n! * n)⁻¹),
rw sum_range_sub_sum_range hj,
exact calc abs (∑ m in (range j).filter (λ k, n ≤ k), (x ^ m / m! : ℂ))
= abs (∑ m in (range j).filter (λ k, n ≤ k), (x ^ n * (x ^ (m - n) / m!) : ℂ)) :
congr_arg abs (sum_congr rfl (λ m hm, by rw [← mul_div_assoc, ← pow_add, nat.add_sub_cancel']; simp at hm; tauto))
... ≤ ∑ m in filter (λ k, n ≤ k) (range j), abs (x ^ n * (_ / m!)) : abv_sum_le_sum_abv _ _
... ≤ ∑ m in filter (λ k, n ≤ k) (range j), abs x ^ n * (1 / m!) :
begin
refine sum_le_sum (λ m hm, _),
rw [abs_mul, abv_pow abs, abs_div, abs_cast_nat],
refine mul_le_mul_of_nonneg_left ((div_le_div_right _).2 _) _,
exact nat.cast_pos.2 (nat.factorial_pos _),
rw abv_pow abs,
exact (pow_le_one _ (abs_nonneg _) hx),
exact pow_nonneg (abs_nonneg _) _
end
... = abs x ^ n * (∑ m in (range j).filter (λ k, n ≤ k), (1 / m! : ℝ)) :
by simp [abs_mul, abv_pow abs, abs_div, mul_sum.symm]
... ≤ abs x ^ n * (n.succ * (n! * n)⁻¹) :
mul_le_mul_of_nonneg_left (sum_div_factorial_le _ _ hn) (pow_nonneg (abs_nonneg _) _)
end
lemma abs_exp_sub_one_le {x : ℂ} (hx : abs x ≤ 1) :
abs (exp x - 1) ≤ 2 * abs x :=
calc abs (exp x - 1) = abs (exp x - ∑ m in range 1, x ^ m / m!) :
by simp [sum_range_succ]
... ≤ abs x ^ 1 * ((nat.succ 1) * (1! * (1 : ℕ))⁻¹) :
exp_bound hx dec_trivial
... = 2 * abs x : by simp [two_mul, mul_two, mul_add, mul_comm]
lemma abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) :
abs (exp x - 1 - x) ≤ (abs x)^2 :=
calc abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m!) :
by simp [sub_eq_add_neg, sum_range_succ, add_assoc]
... ≤ (abs x)^2 * (nat.succ 2 * (2! * (2 : ℕ))⁻¹) :
exp_bound hx dec_trivial
... ≤ (abs x)^2 * 1 :
mul_le_mul_of_nonneg_left (by norm_num) (pow_two_nonneg (abs x))
... = (abs x)^2 :
by rw [mul_one]
end complex
namespace real
open complex finset
lemma cos_bound {x : ℝ} (hx : abs' x ≤ 1) :
abs' (cos x - (1 - x ^ 2 / 2)) ≤ abs' x ^ 4 * (5 / 96) :=
calc abs' (cos x - (1 - x ^ 2 / 2)) = abs (complex.cos x - (1 - x ^ 2 / 2)) :
by rw ← abs_of_real; simp [of_real_bit0, of_real_one, of_real_inv]
... = abs ((complex.exp (x * I) + complex.exp (-x * I) - (2 - x ^ 2)) / 2) :
by simp [complex.cos, sub_div, add_div, neg_div, div_self (@two_ne_zero' ℂ _ _ _)]
... = abs (((complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m!) +
((complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m!))) / 2) :
congr_arg abs (congr_arg (λ x : ℂ, x / 2) begin
simp only [sum_range_succ],
simp [pow_succ],
apply complex.ext; simp [div_eq_mul_inv, norm_sq]; ring
end)
... ≤ abs ((complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m!) / 2) +
abs ((complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m!) / 2) :
by rw add_div; exact abs_add _ _
... = (abs ((complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m!)) / 2 +
abs ((complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m!)) / 2) :
by simp [complex.abs_div]
... ≤ ((complex.abs (x * I) ^ 4 * (nat.succ 4 * (4! * (4 : ℕ))⁻¹)) / 2 +
(complex.abs (-x * I) ^ 4 * (nat.succ 4 * (4! * (4 : ℕ))⁻¹)) / 2) :
add_le_add ((div_le_div_right (by norm_num)).2 (exp_bound (by simpa) dec_trivial))
((div_le_div_right (by norm_num)).2 (exp_bound (by simpa) dec_trivial))
... ≤ abs' x ^ 4 * (5 / 96) : by norm_num; simp [mul_assoc, mul_comm, mul_left_comm, mul_div_assoc]
lemma sin_bound {x : ℝ} (hx : abs' x ≤ 1) :
abs' (sin x - (x - x ^ 3 / 6)) ≤ abs' x ^ 4 * (5 / 96) :=
calc abs' (sin x - (x - x ^ 3 / 6)) = abs (complex.sin x - (x - x ^ 3 / 6)) :
by rw ← abs_of_real; simp [of_real_bit0, of_real_one, of_real_inv]
... = abs (((complex.exp (-x * I) - complex.exp (x * I)) * I - (2 * x - x ^ 3 / 3)) / 2) :
by simp [complex.sin, sub_div, add_div, neg_div, mul_div_cancel_left _ (@two_ne_zero' ℂ _ _ _),
div_div_eq_div_mul, show (3 : ℂ) * 2 = 6, by norm_num]
... = abs ((((complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m!) -
(complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m!)) * I) / 2) :
congr_arg abs (congr_arg (λ x : ℂ, x / 2) begin
simp only [sum_range_succ],
simp [pow_succ],
apply complex.ext; simp [div_eq_mul_inv, norm_sq]; ring
end)
... ≤ abs ((complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m!) * I / 2) +
abs (-((complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m!) * I) / 2) :
by rw [sub_mul, sub_eq_add_neg, add_div]; exact abs_add _ _
... = (abs ((complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m!)) / 2 +
abs ((complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m!)) / 2) :
by simp [add_comm, complex.abs_div, complex.abs_mul]
... ≤ ((complex.abs (x * I) ^ 4 * (nat.succ 4 * (4! * (4 : ℕ))⁻¹)) / 2 +
(complex.abs (-x * I) ^ 4 * (nat.succ 4 * (4! * (4 : ℕ))⁻¹)) / 2) :
add_le_add ((div_le_div_right (by norm_num)).2 (exp_bound (by simpa) dec_trivial))
((div_le_div_right (by norm_num)).2 (exp_bound (by simpa) dec_trivial))
... ≤ abs' x ^ 4 * (5 / 96) : by norm_num; simp [mul_assoc, mul_comm, mul_left_comm, mul_div_assoc]
lemma cos_pos_of_le_one {x : ℝ} (hx : abs' x ≤ 1) : 0 < cos x :=
calc 0 < (1 - x ^ 2 / 2) - abs' x ^ 4 * (5 / 96) :
sub_pos.2 $ lt_sub_iff_add_lt.2
(calc abs' x ^ 4 * (5 / 96) + x ^ 2 / 2
≤ 1 * (5 / 96) + 1 / 2 :
add_le_add
(mul_le_mul_of_nonneg_right (pow_le_one _ (abs_nonneg _) hx) (by norm_num))
((div_le_div_right (by norm_num)).2 (by rw [pow_two, ← abs_mul_self, _root_.abs_mul];
exact mul_le_one hx (abs_nonneg _) hx))
... < 1 : by norm_num)
... ≤ cos x : sub_le.1 (abs_sub_le_iff.1 (cos_bound hx)).2
lemma sin_pos_of_pos_of_le_one {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 1) : 0 < sin x :=
calc 0 < x - x ^ 3 / 6 - abs' x ^ 4 * (5 / 96) :
sub_pos.2 $ lt_sub_iff_add_lt.2
(calc abs' x ^ 4 * (5 / 96) + x ^ 3 / 6
≤ x * (5 / 96) + x / 6 :
add_le_add
(mul_le_mul_of_nonneg_right
(calc abs' x ^ 4 ≤ abs' x ^ 1 : pow_le_pow_of_le_one (abs_nonneg _)
(by rwa _root_.abs_of_nonneg (le_of_lt hx0))
dec_trivial
... = x : by simp [_root_.abs_of_nonneg (le_of_lt (hx0))]) (by norm_num))
((div_le_div_right (by norm_num)).2
(calc x ^ 3 ≤ x ^ 1 : pow_le_pow_of_le_one (le_of_lt hx0) hx dec_trivial
... = x : pow_one _))
... < x : by linarith)
... ≤ sin x : sub_le.1 (abs_sub_le_iff.1 (sin_bound
(by rwa [_root_.abs_of_nonneg (le_of_lt hx0)]))).2
lemma sin_pos_of_pos_of_le_two {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 2) : 0 < sin x :=
have x / 2 ≤ 1, from (div_le_iff (by norm_num)).mpr (by simpa),
calc 0 < 2 * sin (x / 2) * cos (x / 2) :
mul_pos (mul_pos (by norm_num) (sin_pos_of_pos_of_le_one (half_pos hx0) this))
(cos_pos_of_le_one (by rwa [_root_.abs_of_nonneg (le_of_lt (half_pos hx0))]))
... = sin x : by rw [← sin_two_mul, two_mul, add_halves]
lemma cos_one_le : cos 1 ≤ 2 / 3 :=
calc cos 1 ≤ abs' (1 : ℝ) ^ 4 * (5 / 96) + (1 - 1 ^ 2 / 2) :
sub_le_iff_le_add.1 (abs_sub_le_iff.1 (cos_bound (by simp))).1
... ≤ 2 / 3 : by norm_num
lemma cos_one_pos : 0 < cos 1 := cos_pos_of_le_one (by simp)
lemma cos_two_neg : cos 2 < 0 :=
calc cos 2 = cos (2 * 1) : congr_arg cos (mul_one _).symm
... = _ : real.cos_two_mul 1
... ≤ 2 * (2 / 3) ^ 2 - 1 :
sub_le_sub_right (mul_le_mul_of_nonneg_left
(by rw [pow_two, pow_two]; exact
mul_self_le_mul_self (le_of_lt cos_one_pos)
cos_one_le)
(by norm_num)) _
... < 0 : by norm_num
end real
namespace complex
lemma abs_cos_add_sin_mul_I (x : ℝ) : abs (cos x + sin x * I) = 1 :=
have _ := real.sin_sq_add_cos_sq x,
by simp [add_comm, abs, norm_sq, pow_two, *, sin_of_real_re, cos_of_real_re, mul_re] at *
lemma abs_exp_eq_iff_re_eq {x y : ℂ} : abs (exp x) = abs (exp y) ↔ x.re = y.re :=
by rw [exp_eq_exp_re_mul_sin_add_cos, exp_eq_exp_re_mul_sin_add_cos y,
abs_mul, abs_mul, abs_cos_add_sin_mul_I, abs_cos_add_sin_mul_I,
← of_real_exp, ← of_real_exp, abs_of_nonneg (le_of_lt (real.exp_pos _)),
abs_of_nonneg (le_of_lt (real.exp_pos _)), mul_one, mul_one];
exact ⟨λ h, real.exp_injective h, congr_arg _⟩
@[simp] lemma abs_exp_of_real (x : ℝ) : abs (exp x) = real.exp x :=
by rw [← of_real_exp]; exact abs_of_nonneg (le_of_lt (real.exp_pos _))
end complex
|
56fd3522a9a4a2401b60288c7e84fd8a5178e8b2 | ae1e94c332e17c7dc7051ce976d5a9eebe7ab8a5 | /tests/lean/run/listDecEq.lean | 060978784e517a3cebeae889293e50faf6ba8eae | [
"Apache-2.0"
] | permissive | dupuisf/lean4 | d082d13b01243e1de29ae680eefb476961221eef | 6a39c65bd28eb0e28c3870188f348c8914502718 | refs/heads/master | 1,676,948,755,391 | 1,610,665,114,000 | 1,610,665,114,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 788 | lean | #lang lean4
-- List decidable equality using `withPtrEqDecEq`
def listDecEqAux {α} [s : DecidableEq α] : ∀ (as bs : List α), Decidable (as = bs)
| [], [] => isTrue rfl
| [], b::bs => isFalse $ fun h => List.noConfusion h
| a::as, [] => isFalse $ fun h => List.noConfusion h
| a::as, b::bs =>
match s a b with
| isTrue h₁ =>
match withPtrEqDecEq as bs (fun _ => listDecEqAux as bs) with
| isTrue h₂ => isTrue $ h₁ ▸ h₂ ▸ rfl
| isFalse h₂ => isFalse $ fun h => List.noConfusion h $ fun _ h₃ => absurd h₃ h₂
| isFalse h₁ => isFalse $ fun h => List.noConfusion h $ fun h₂ _ => absurd h₂ h₁
instance List.optimizedDecEq {α} [DecidableEq α] : DecidableEq (List α) :=
fun a b => withPtrEqDecEq a b (fun _ => listDecEqAux a b)
|
7a86e69d2908767469c4ba7d4afe48b30c5f203f | e00ea76a720126cf9f6d732ad6216b5b824d20a7 | /docs/tutorial/category_theory/intro.lean | 238c8926aaa7f13f23603611828765b0ca73408e | [
"Apache-2.0"
] | permissive | vaibhavkarve/mathlib | a574aaf68c0a431a47fa82ce0637f0f769826bfe | 17f8340912468f49bdc30acdb9a9fa02eeb0473a | refs/heads/master | 1,621,263,802,637 | 1,585,399,588,000 | 1,585,399,588,000 | 250,833,447 | 0 | 0 | Apache-2.0 | 1,585,410,341,000 | 1,585,410,341,000 | null | UTF-8 | Lean | false | false | 11,638 | lean | import category_theory.functor_category -- this transitively imports
-- category_theory.category
-- category_theory.functor
-- category_theory.natural_transformation
/-!
# An introduction to category theory in Lean
This is an introduction to the basic usage of category theory (in the mathematical sense) in Lean.
We cover how the basic theory of categories, functors and natural transformations is set up in Lean.
Most of the below is not hard to read off from the files `category_theory/category.lean`,
`category_theory/functor.lean` and `category_theory/natural_transformation.lean`.
First a word of warning. In `mathlib`, in the `/src` directory, there is a subdirectory called
`category`. This is *not* where categories, in the sense of mathematics, are defined; it's for use
by computer scientists. The directory we will be concerned with here is the `category_theory`
subdirectory.
## Overview
A category is a collection of objects, and a collection of morphisms (also known as arrows) between
the objects. The objects and morphisms have some extra structure and satisfy some axioms -- see the
[definition on Wikipedia](https://en.wikipedia.org/wiki/Category_%28mathematics%29#Definition) for
details.
One important thing to note is that a morphism in an abstract category may not be an actual function
between two types. In particular, there is new notation `⟶` , typed as `\h` or `\hom` in VS Code,
for a morphism. Nevertheless, in most of the "concrete" categories like `Top` and `Ab`, it is still
possible to write `f x` when `x : X` and `f : X ⟶ Y` is a morphism, as there is an automatic
coercion from morphisms to functions. (If the coercion doesn't fire automatically, sometimes it is
necessary to write `(f : X → Y) x`.)
In some fonts the `⟶` morphism arrow can be virtually indistinguishable from the standard function
arrow `→` . You may want to install the [Deja Vu Sans Mono](https://dejavu-fonts.github.io/) and put
that at the beginning of the `Font Family` setting in VSCode, to get a nice readable font with
excellent unicode coverage.
Another point of confusion can be universe issues. Following Lean's conventions for universe
polymorphism, the objects of a category might live in one universe `u` and the morphisms in another
universe `v`. Note that in many categories showing up in "set-theoretic mathematics", the morphisms
between two objects often form a set, but the objects themselves may or may not form a set. In Lean
this corresponds to the two possibilities `u=v` and `u=v+1`, known as `small_category` and
`large_category` respectively. In order to avoid proving the same statements for both small and
large categories, we usually stick to the general polymorphic situation with `u` and `v` independent
universes, and we do this below.
## Getting started with categories
The structure of a category on a type `C` in Lean is done using typeclasses; terms of `C` then
correspond to objects in the category. The convention in the category theory library is to use
universes prefixed with `u` (e.g. `u`, `u₁`, `u₂`) for the objects, and universes prefixed with `v`
for morphisms. Thus we have `C : Type u`, and if `X : C` and `Y : C` then morphisms `X ⟶ Y : Type v`
(note the non-standard arrow).
We set this up as follows:
-/
open category_theory
section category
universes v u -- the order matters (see below)
variables (C : Type u) [𝒞 : category.{v} C]
include 𝒞
variables {W X Y Z : C}
variables (f : W ⟶ X) (g : X ⟶ Y) (h : Y ⟶ Z)
/-!
This says "let `C` be a category, let `W`, `X`, `Y`, `Z` be objects of `C`, and let `f : W ⟶ X`, `g
: X ⟶ Y` and `h : Y ⟶ Z` be morphisms in `C` (with the specified source and targets)".
Note two unusual things. Firstly, the typeclass `category C` is explicitly named as `𝒞` (in
contrast to group theory, where one would just write `[group G]` rather than `[h : group G]`).
Secondly, we have to explicitly tell Lean the universe where the morphisms live (by writing
`category.{v} C`), because Lean cannot guess from knowing `C` alone.
The order in which universes are introduced at the top of the file matters: we put the universes for
morphisms first (typically `v`, `v₁` and so on), and then universes for objects (typically `u`, `u₁`
and so on). This ensures that in any new definition we make the universe variables for morphisms
come first, so that they can be explicitly specified while still allowing the universe levels of the
objects to be inferred automatically.
The reason that the typeclass is given an explicit name `𝒞` (typeset `\McC`) is that one often has
to write `include 𝒞` in code to ensure that Lean includes the typeclass in theorems and
definitions. (Lean is not willing to guess the universe level of morphisms, so sometimes won't
automatically include the `[category.{v} C]` variable.) One can use `omit 𝒞` again (or appropriate
scoping constructs) to make sure it isn't included in declarations where it isn't needed.
## Basic notation
In categories one has morphisms between objects, such as the identity morphism from an object to
itself. One can compose morphisms, and there are standard facts about the composition of a morphism
with the identity morphism, and the fact that morphism composition is associative. In Lean all of
this looks like the following:
-/
-- The identity morphism from `X` to `X` (remember that this is the `\h` arrow):
example : X ⟶ X := 𝟙 X -- type `𝟙` as `\bb1`
-- Function composition `h ∘ g`, a morphism from `X` to `Z`:
example : X ⟶ Z := g ≫ h
/-
Note in particular the order! The "maps on the right" convention was chosen; `g ≫ h` means "`g` then
`h`". Type `≫` with `\gg` in VS Code. Here are the theorems which ensure that we have a category.
-/
open category_theory.category
example : 𝟙 X ≫ g = g := id_comp C g
example : g ≫ 𝟙 Y = g := comp_id C g
example : (f ≫ g) ≫ h = f ≫ (g ≫ h) := assoc C f g h
example : (f ≫ g) ≫ h = f ≫ g ≫ h := assoc C f g h -- note \gg is right associative
-- All four examples above can also be proved with `simp`.
-- Monomorphisms and epimorphisms are predicates on morphisms and are implemented as typeclasses.
variables (f' : W ⟶ X) (h' : Y ⟶ Z)
example [mono g] : f ≫ g = f' ≫ g → f = f' := mono.right_cancellation f f'
example [epi g] : g ≫ h = g ≫ h' → h = h' := epi.left_cancellation h h'
end category -- end of section
/-!
## Getting started with functors
A functor is a map between categories. It is implemented as a structure. The notation for a functor
from `C` to `D` is `C ⥤ D`. Type `\func` in VS Code for the symbol. Here we demonstrate how to
evaluate functors on objects and on morphisms, how to show functors preserve the identity morphism
and composition of morphisms, how to compose functors, and show the notation `𝟭` for the identity
functor.
-/
section functor
universes v₁ v₂ v₃ u₁ u₂ u₃ -- recall we put morphism universes (`vᵢ`) before object universes (`uᵢ`)
variables (C : Type u₁) [𝒞 : category.{v₁} C]
variables (D : Type u₂) [𝒟 : category.{v₂} D]
variables (E : Type u₃) [ℰ : category.{v₃} E]
include 𝒞 𝒟 ℰ
variables {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z)
-- functors
variables (F : C ⥤ D) (G : D ⥤ E)
example : D := F.obj X -- functor F on objects
example : F.obj Y ⟶ F.obj Z := F.map g -- functor F on morphisms
-- A functor sends identity objects to identity objects
example : F.map (𝟙 X) = 𝟙 (F.obj X) := F.map_id X
-- and preserves compositions
example : F.map (f ≫ g) = (F.map f) ≫ (F.map g) := F.map_comp f g
-- The identity functor is `𝟭`, currently apparently untypesettable in Lean!
example : C ⥤ C := 𝟭 C
-- The identity functor is (definitionally) the identity on objects and morphisms:
example : (𝟭 C).obj X = X := category_theory.functor.id_obj X
example : (𝟭 C).map f = f := category_theory.functor.id_map f
-- Composition of functors; note order:
example : C ⥤ E := F ⋙ G -- typeset with `\ggg`
-- Composition of the identity either way does nothing:
example : F ⋙ 𝟭 D = F := F.comp_id
example : 𝟭 C ⋙ F = F := F.id_comp
-- Composition of functors definitionally does the right thing on objects and morphisms:
example : (F ⋙ G).obj X = G.obj (F.obj X) := F.comp_obj G X -- or rfl
example : (F ⋙ G).map f = G.map (F.map f) := rfl -- or F.comp_map G X Y f
end functor -- end of section
/-!
One can also check that associativity of composition of functors is definitionally true,
although we've observed that relying on this can result in slow proofs. (One should
rather use the natural isomorphisms provided in `src/category_theory/whiskering.lean`.)
## Getting started with natural transformations
A natural transformation is a morphism between functors. If `F` and `G` are functors from `C` to `D`
then a natural transformation is a map `F X ⟶ G X` for each object `X : C` plus the theorem that if
`f : X ⟶ Y` is a morphism then the two routes from `F X` to `G Y` are the same. One might imagine
that this is now another layer of notation, but fortunately the `category_theory.functor_category`
import gives the type of functors from `C` to `D` a category structure, which means that we can just
use morphism notation for natural transformations.
-/
section nat_trans
universes v₁ v₂ u₁ u₂
variables {C : Type u₁} [𝒞 : category.{v₁} C] {D : Type u₂} [𝒟 : category.{v₂} D]
include 𝒞 𝒟
variables (X Y : C)
variable (f : X ⟶ Y)
variables (F G H : C ⥤ D)
variables (α : F ⟶ G) (β : G ⟶ H) -- natural transformations (note it's the usual `\hom` arrow here)
-- Composition of natural transformations is just composition of morphisms:
example : F ⟶ H := α ≫ β
-- Applying natural transformation to an object:
example (X : C) : F.obj X ⟶ G.obj X := α.app X
/- The diagram coming from g and α
F(f)
F X ---> F Y
| |
|α(X) |α(Y)
v v
G X ---> G Y
G(f)
commutes.
-/
example : F.map f ≫ α.app Y = (α.app X) ≫ G.map f := α.naturality f
end nat_trans -- section
/-!
## Debugging universe problems
Unfortunately, dealing with universe polymorphism is an intrinsic problem in the category theory
library.
A very common problem is Lean complaining that it can't find an instance of `category X`, when you
can see right there in the hypotheses a `category X`! What's going on? Nearly always this is because
the universe level of the morphisms has not been specified explicitly, so in fact Lean is looking
for a `category.{? u} X` instance, while it has available a `category.{v u} X` instance. (The object
universe level is unambiguous, because this can be inferred from `X`.) You can determine if this is
a problem by using `set_option pp.universes true`. The reason this causes a problem is that Lean 3
is not willing to specialise a universe metavariable in order to solve a typeclass search.
Typically, you solve this problem by working out how to tell Lean which universe you want the
morphisms to live in, usually by adding a `.{v}` to the end of some identifier. As an example, in
```
instance coe_to_Top : has_coe (PresheafedSpace.{v} C) Top :=
{ coe := λ X, X.to_Top }
```
(taken from `src/algebraic_geometry/presheafed_space.lean`), if you remove the `.{v}` you get a
typeclass resolution error.
-/
/-!
## What next?
There are several lean files in the [category theory docs directory of
mathlib](https://github.com/leanprover-community/mathlib/tree/master/docs/tutorial/category_theory)
which give further examples of using the category theory library in Lean.
-/
|
62d1c87863b1fd5a16c9ea634a1dca93200ae9c4 | 31f556cdeb9239ffc2fad8f905e33987ff4feab9 | /stage0/src/Lean/Elab/Tactic/Unfold.lean | 69ea96a5889e5125f2a1a7de12f19a6e39a2a033 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | tobiasgrosser/lean4 | ce0fd9cca0feba1100656679bf41f0bffdbabb71 | ebdbdc10436a4d9d6b66acf78aae7a23f5bd073f | refs/heads/master | 1,673,103,412,948 | 1,664,930,501,000 | 1,664,930,501,000 | 186,870,185 | 0 | 0 | Apache-2.0 | 1,665,129,237,000 | 1,557,939,901,000 | Lean | UTF-8 | Lean | false | false | 1,091 | lean | /-
Copyright (c) 2022 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Lean.Meta.Tactic.Unfold
import Lean.Elab.Tactic.Basic
import Lean.Elab.Tactic.Location
namespace Lean.Elab.Tactic
open Meta
def unfoldLocalDecl (declName : Name) (fvarId : FVarId) : TacticM Unit := do
replaceMainGoal [← Meta.unfoldLocalDecl (← getMainGoal) fvarId declName]
def unfoldTarget (declName : Name) : TacticM Unit := do
replaceMainGoal [← Meta.unfoldTarget (← getMainGoal) declName]
/-- "unfold " ident+ (location)? -/
@[builtinTactic Lean.Parser.Tactic.unfold] def evalUnfold : Tactic := fun stx => do
let loc := expandOptLocation stx[2]
for declNameId in stx[1].getArgs do
go declNameId loc
where
go (declNameId : Syntax) (loc : Location) : TacticM Unit := do
let declName ← resolveGlobalConstNoOverloadWithInfo declNameId
withLocation loc (unfoldLocalDecl declName) (unfoldTarget declName) (throwTacticEx `unfold · m!"did not unfold '{declName}'")
end Lean.Elab.Tactic
|
d10aedee6454dada6a2a45b2479edd31c0324ad7 | 94e33a31faa76775069b071adea97e86e218a8ee | /src/geometry/manifold/algebra/smooth_functions.lean | b4cdbb28b834193245aabd89798e6870c6b80f40 | [
"Apache-2.0"
] | permissive | urkud/mathlib | eab80095e1b9f1513bfb7f25b4fa82fa4fd02989 | 6379d39e6b5b279df9715f8011369a301b634e41 | refs/heads/master | 1,658,425,342,662 | 1,658,078,703,000 | 1,658,078,703,000 | 186,910,338 | 0 | 0 | Apache-2.0 | 1,568,512,083,000 | 1,557,958,709,000 | Lean | UTF-8 | Lean | false | false | 10,233 | lean | /-
Copyright © 2020 Nicolò Cavalleri. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nicolò Cavalleri
-/
import geometry.manifold.algebra.structures
/-!
# Algebraic structures over smooth functions
In this file, we define instances of algebraic structures over smooth functions.
-/
noncomputable theory
open_locale manifold
variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]
{E : Type*} [normed_group E] [normed_space 𝕜 E]
{E' : Type*} [normed_group E'] [normed_space 𝕜 E']
{H : Type*} [topological_space H] {I : model_with_corners 𝕜 E H}
{H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}
{N : Type*} [topological_space N] [charted_space H N]
{E'' : Type*} [normed_group E''] [normed_space 𝕜 E'']
{H'' : Type*} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''}
{N' : Type*} [topological_space N'] [charted_space H'' N']
namespace smooth_map
@[to_additive]
instance has_mul {G : Type*} [has_mul G] [topological_space G] [charted_space H' G]
[has_smooth_mul I' G] :
has_mul C^∞⟮I, N; I', G⟯ :=
⟨λ f g, ⟨f * g, f.smooth.mul g.smooth⟩⟩
@[simp, to_additive]
lemma coe_mul {G : Type*} [has_mul G] [topological_space G] [charted_space H' G]
[has_smooth_mul I' G] (f g : C^∞⟮I, N; I', G⟯) :
⇑(f * g) = f * g := rfl
@[simp, to_additive] lemma mul_comp {G : Type*} [has_mul G] [topological_space G]
[charted_space H' G] [has_smooth_mul I' G] (f g : C^∞⟮I'', N'; I', G⟯) (h : C^∞⟮I, N; I'', N'⟯) :
(f * g).comp h = (f.comp h) * (g.comp h) :=
by ext; simp only [cont_mdiff_map.comp_apply, coe_mul, pi.mul_apply]
@[to_additive]
instance has_one {G : Type*} [monoid G] [topological_space G] [charted_space H' G] :
has_one C^∞⟮I, N; I', G⟯ :=
⟨cont_mdiff_map.const (1 : G)⟩
@[simp, to_additive]
lemma coe_one {G : Type*} [monoid G] [topological_space G] [charted_space H' G] :
⇑(1 : C^∞⟮I, N; I', G⟯) = 1 := rfl
section group_structure
/-!
### Group structure
In this section we show that smooth functions valued in a Lie group inherit a group structure
under pointwise multiplication.
-/
@[to_additive]
instance semigroup {G : Type*} [semigroup G] [topological_space G]
[charted_space H' G] [has_smooth_mul I' G] :
semigroup C^∞⟮I, N; I', G⟯ :=
{ mul_assoc := λ a b c, by ext; exact mul_assoc _ _ _,
..smooth_map.has_mul}
@[to_additive]
instance monoid {G : Type*} [monoid G] [topological_space G]
[charted_space H' G] [has_smooth_mul I' G] :
monoid C^∞⟮I, N; I', G⟯ :=
{ one_mul := λ a, by ext; exact one_mul _,
mul_one := λ a, by ext; exact mul_one _,
..smooth_map.semigroup,
..smooth_map.has_one }
/-- Coercion to a function as an `monoid_hom`. Similar to `monoid_hom.coe_fn`. -/
@[to_additive "Coercion to a function as an `add_monoid_hom`. Similar to `add_monoid_hom.coe_fn`.",
simps]
def coe_fn_monoid_hom {G : Type*} [monoid G] [topological_space G]
[charted_space H' G] [has_smooth_mul I' G] : C^∞⟮I, N; I', G⟯ →* (N → G) :=
{ to_fun := coe_fn, map_one' := coe_one, map_mul' := coe_mul }
@[to_additive]
instance comm_monoid {G : Type*} [comm_monoid G] [topological_space G]
[charted_space H' G] [has_smooth_mul I' G] :
comm_monoid C^∞⟮I, N; I', G⟯ :=
{ mul_comm := λ a b, by ext; exact mul_comm _ _,
..smooth_map.monoid,
..smooth_map.has_one }
@[to_additive]
instance group {G : Type*} [group G] [topological_space G]
[charted_space H' G] [lie_group I' G] :
group C^∞⟮I, N; I', G⟯ :=
{ inv := λ f, ⟨λ x, (f x)⁻¹, f.smooth.inv⟩,
mul_left_inv := λ a, by ext; exact mul_left_inv _,
div := λ f g, ⟨f / g, f.smooth.div g.smooth⟩,
div_eq_mul_inv := λ f g, by ext; exact div_eq_mul_inv _ _,
.. smooth_map.monoid }
@[simp, to_additive]
lemma coe_inv {G : Type*} [group G] [topological_space G]
[charted_space H' G] [lie_group I' G] (f : C^∞⟮I, N; I', G⟯) :
⇑f⁻¹ = f⁻¹ := rfl
@[simp, to_additive]
lemma coe_div {G : Type*} [group G] [topological_space G]
[charted_space H' G] [lie_group I' G] (f g : C^∞⟮I, N; I', G⟯) :
⇑(f / g) = f / g :=
rfl
@[to_additive]
instance comm_group {G : Type*} [comm_group G] [topological_space G]
[charted_space H' G] [lie_group I' G] :
comm_group C^∞⟮I, N; I', G⟯ :=
{ ..smooth_map.group,
..smooth_map.comm_monoid }
end group_structure
section ring_structure
/-!
### Ring stucture
In this section we show that smooth functions valued in a smooth ring `R` inherit a ring structure
under pointwise multiplication.
-/
instance semiring {R : Type*} [semiring R] [topological_space R]
[charted_space H' R] [smooth_ring I' R] :
semiring C^∞⟮I, N; I', R⟯ :=
{ left_distrib := λ a b c, by ext; exact left_distrib _ _ _,
right_distrib := λ a b c, by ext; exact right_distrib _ _ _,
zero_mul := λ a, by ext; exact zero_mul _,
mul_zero := λ a, by ext; exact mul_zero _,
..smooth_map.add_comm_monoid,
..smooth_map.monoid }
instance ring {R : Type*} [ring R] [topological_space R]
[charted_space H' R] [smooth_ring I' R] :
ring C^∞⟮I, N; I', R⟯ :=
{ ..smooth_map.semiring,
..smooth_map.add_comm_group, }
instance comm_ring {R : Type*} [comm_ring R] [topological_space R]
[charted_space H' R] [smooth_ring I' R] :
comm_ring C^∞⟮I, N; I', R⟯ :=
{ ..smooth_map.semiring,
..smooth_map.add_comm_group,
..smooth_map.comm_monoid,}
/-- Coercion to a function as a `ring_hom`. -/
@[simps]
def coe_fn_ring_hom {R : Type*} [comm_ring R] [topological_space R]
[charted_space H' R] [smooth_ring I' R] : C^∞⟮I, N; I', R⟯ →+* (N → R) :=
{ to_fun := coe_fn,
..(coe_fn_monoid_hom : C^∞⟮I, N; I', R⟯ →* _),
..(coe_fn_add_monoid_hom : C^∞⟮I, N; I', R⟯ →+ _) }
/-- `function.eval` as a `ring_hom` on the ring of smooth functions. -/
def eval_ring_hom {R : Type*} [comm_ring R] [topological_space R]
[charted_space H' R] [smooth_ring I' R] (n : N) : C^∞⟮I, N; I', R⟯ →+* R :=
(pi.eval_ring_hom _ n : (N → R) →+* R).comp smooth_map.coe_fn_ring_hom
end ring_structure
section module_structure
/-!
### Semiodule stucture
In this section we show that smooth functions valued in a vector space `M` over a normed
field `𝕜` inherit a vector space structure.
-/
instance has_smul {V : Type*} [normed_group V] [normed_space 𝕜 V] :
has_smul 𝕜 C^∞⟮I, N; 𝓘(𝕜, V), V⟯ :=
⟨λ r f, ⟨r • f, smooth_const.smul f.smooth⟩⟩
@[simp]
lemma coe_smul {V : Type*} [normed_group V] [normed_space 𝕜 V]
(r : 𝕜) (f : C^∞⟮I, N; 𝓘(𝕜, V), V⟯) :
⇑(r • f) = r • f := rfl
@[simp] lemma smul_comp {V : Type*} [normed_group V] [normed_space 𝕜 V]
(r : 𝕜) (g : C^∞⟮I'', N'; 𝓘(𝕜, V), V⟯) (h : C^∞⟮I, N; I'', N'⟯) :
(r • g).comp h = r • (g.comp h) := rfl
instance module {V : Type*} [normed_group V] [normed_space 𝕜 V] :
module 𝕜 C^∞⟮I, N; 𝓘(𝕜, V), V⟯ :=
function.injective.module 𝕜 coe_fn_add_monoid_hom cont_mdiff_map.coe_inj coe_smul
/-- Coercion to a function as a `linear_map`. -/
@[simps]
def coe_fn_linear_map {V : Type*} [normed_group V] [normed_space 𝕜 V] :
C^∞⟮I, N; 𝓘(𝕜, V), V⟯ →ₗ[𝕜] (N → V) :=
{ to_fun := coe_fn,
map_smul' := coe_smul,
..(coe_fn_add_monoid_hom : C^∞⟮I, N; 𝓘(𝕜, V), V⟯ →+ _) }
end module_structure
section algebra_structure
/-!
### Algebra structure
In this section we show that smooth functions valued in a normed algebra `A` over a normed field `𝕜`
inherit an algebra structure.
-/
variables {A : Type*} [normed_ring A] [normed_algebra 𝕜 A] [smooth_ring 𝓘(𝕜, A) A]
/-- Smooth constant functions as a `ring_hom`. -/
def C : 𝕜 →+* C^∞⟮I, N; 𝓘(𝕜, A), A⟯ :=
{ to_fun := λ c : 𝕜, ⟨λ x, ((algebra_map 𝕜 A) c), smooth_const⟩,
map_one' := by ext x; exact (algebra_map 𝕜 A).map_one,
map_mul' := λ c₁ c₂, by ext x; exact (algebra_map 𝕜 A).map_mul _ _,
map_zero' := by ext x; exact (algebra_map 𝕜 A).map_zero,
map_add' := λ c₁ c₂, by ext x; exact (algebra_map 𝕜 A).map_add _ _ }
instance algebra : algebra 𝕜 C^∞⟮I, N; 𝓘(𝕜, A), A⟯ :=
{ smul := λ r f,
⟨r • f, smooth_const.smul f.smooth⟩,
to_ring_hom := smooth_map.C,
commutes' := λ c f, by ext x; exact algebra.commutes' _ _,
smul_def' := λ c f, by ext x; exact algebra.smul_def' _ _,
..smooth_map.semiring }
/-- Coercion to a function as an `alg_hom`. -/
@[simps]
def coe_fn_alg_hom : C^∞⟮I, N; 𝓘(𝕜, A), A⟯ →ₐ[𝕜] (N → A) :=
{ to_fun := coe_fn,
commutes' := λ r, rfl,
-- `..(smooth_map.coe_fn_ring_hom : C^∞⟮I, N; 𝓘(𝕜, A), A⟯ →+* _)` times out for some reason
map_zero' := smooth_map.coe_zero,
map_one' := smooth_map.coe_one,
map_add' := smooth_map.coe_add,
map_mul' := smooth_map.coe_mul }
end algebra_structure
section module_over_continuous_functions
/-!
### Structure as module over scalar functions
If `V` is a module over `𝕜`, then we show that the space of smooth functions from `N` to `V`
is naturally a vector space over the ring of smooth functions from `N` to `𝕜`. -/
instance has_smul' {V : Type*} [normed_group V] [normed_space 𝕜 V] :
has_smul C^∞⟮I, N; 𝕜⟯ C^∞⟮I, N; 𝓘(𝕜, V), V⟯ :=
⟨λ f g, ⟨λ x, (f x) • (g x), (smooth.smul f.2 g.2)⟩⟩
@[simp] lemma smul_comp' {V : Type*} [normed_group V] [normed_space 𝕜 V]
(f : C^∞⟮I'', N'; 𝕜⟯) (g : C^∞⟮I'', N'; 𝓘(𝕜, V), V⟯) (h : C^∞⟮I, N; I'', N'⟯) :
(f • g).comp h = (f.comp h) • (g.comp h) := rfl
instance module' {V : Type*} [normed_group V] [normed_space 𝕜 V] :
module C^∞⟮I, N; 𝓘(𝕜), 𝕜⟯ C^∞⟮I, N; 𝓘(𝕜, V), V⟯ :=
{ smul := (•),
smul_add := λ c f g, by ext x; exact smul_add (c x) (f x) (g x),
add_smul := λ c₁ c₂ f, by ext x; exact add_smul (c₁ x) (c₂ x) (f x),
mul_smul := λ c₁ c₂ f, by ext x; exact mul_smul (c₁ x) (c₂ x) (f x),
one_smul := λ f, by ext x; exact one_smul 𝕜 (f x),
zero_smul := λ f, by ext x; exact zero_smul _ _,
smul_zero := λ r, by ext x; exact smul_zero _, }
end module_over_continuous_functions
end smooth_map
|
064bc0cddda2035fcba1325f3d86577878f790c6 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/category_theory/monoidal/functor.lean | d43a48e845e3c62f58fde9850df1fb5dc101568d | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 17,641 | lean | /-
Copyright (c) 2018 Michael Jendrusch. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Jendrusch, Scott Morrison, Bhavik Mehta
-/
import category_theory.monoidal.category
import category_theory.adjunction.basic
import category_theory.products.basic
/-!
# (Lax) monoidal functors
A lax monoidal functor `F` between monoidal categories `C` and `D`
is a functor between the underlying categories equipped with morphisms
* `ε : 𝟙_ D ⟶ F.obj (𝟙_ C)` (called the unit morphism)
* `μ X Y : (F.obj X) ⊗ (F.obj Y) ⟶ F.obj (X ⊗ Y)` (called the tensorator, or strength).
satisfying various axioms.
A monoidal functor is a lax monoidal functor for which `ε` and `μ` are isomorphisms.
We show that the composition of (lax) monoidal functors gives a (lax) monoidal functor.
See also `category_theory.monoidal.functorial` for a typeclass decorating an object-level
function with the additional data of a monoidal functor.
This is useful when stating that a pre-existing functor is monoidal.
See `category_theory.monoidal.natural_transformation` for monoidal natural transformations.
We show in `category_theory.monoidal.Mon_` that lax monoidal functors take monoid objects
to monoid objects.
## Future work
* Oplax monoidal functors.
## References
See <https://stacks.math.columbia.edu/tag/0FFL>.
-/
open category_theory
universes v₁ v₂ v₃ u₁ u₂ u₃
open category_theory.category
open category_theory.functor
namespace category_theory
section
open monoidal_category
variables (C : Type u₁) [category.{v₁} C] [monoidal_category.{v₁} C]
(D : Type u₂) [category.{v₂} D] [monoidal_category.{v₂} D]
/-- A lax monoidal functor is a functor `F : C ⥤ D` between monoidal categories,
equipped with morphisms `ε : 𝟙 _D ⟶ F.obj (𝟙_ C)` and `μ X Y : F.obj X ⊗ F.obj Y ⟶ F.obj (X ⊗ Y)`,
satisfying the appropriate coherences. -/
-- The direction of `left_unitality` and `right_unitality` as simp lemmas may look strange:
-- remember the rule of thumb that component indices of natural transformations
-- "weigh more" than structural maps.
-- (However by this argument `associativity` is currently stated backwards!)
structure lax_monoidal_functor extends C ⥤ D :=
-- unit morphism
(ε : 𝟙_ D ⟶ obj (𝟙_ C))
-- tensorator
(μ : Π X Y : C, (obj X) ⊗ (obj Y) ⟶ obj (X ⊗ Y))
(μ_natural' : ∀ {X Y X' Y' : C}
(f : X ⟶ Y) (g : X' ⟶ Y'),
((map f) ⊗ (map g)) ≫ μ Y Y' = μ X X' ≫ map (f ⊗ g)
. obviously)
-- associativity of the tensorator
(associativity' : ∀ (X Y Z : C),
(μ X Y ⊗ 𝟙 (obj Z)) ≫ μ (X ⊗ Y) Z ≫ map (α_ X Y Z).hom
= (α_ (obj X) (obj Y) (obj Z)).hom ≫ (𝟙 (obj X) ⊗ μ Y Z) ≫ μ X (Y ⊗ Z)
. obviously)
-- unitality
(left_unitality' : ∀ X : C,
(λ_ (obj X)).hom
= (ε ⊗ 𝟙 (obj X)) ≫ μ (𝟙_ C) X ≫ map (λ_ X).hom
. obviously)
(right_unitality' : ∀ X : C,
(ρ_ (obj X)).hom
= (𝟙 (obj X) ⊗ ε) ≫ μ X (𝟙_ C) ≫ map (ρ_ X).hom
. obviously)
restate_axiom lax_monoidal_functor.μ_natural'
attribute [simp, reassoc] lax_monoidal_functor.μ_natural
restate_axiom lax_monoidal_functor.left_unitality'
attribute [simp] lax_monoidal_functor.left_unitality
restate_axiom lax_monoidal_functor.right_unitality'
attribute [simp] lax_monoidal_functor.right_unitality
restate_axiom lax_monoidal_functor.associativity'
attribute [simp, reassoc] lax_monoidal_functor.associativity
-- When `rewrite_search` lands, add @[search] attributes to
-- lax_monoidal_functor.μ_natural lax_monoidal_functor.left_unitality
-- lax_monoidal_functor.right_unitality lax_monoidal_functor.associativity
section
variables {C D}
@[simp, reassoc]
lemma lax_monoidal_functor.left_unitality_inv (F : lax_monoidal_functor C D) (X : C) :
(λ_ (F.obj X)).inv ≫ (F.ε ⊗ 𝟙 (F.obj X)) ≫ F.μ (𝟙_ C) X = F.map (λ_ X).inv :=
begin
rw [iso.inv_comp_eq, F.left_unitality, category.assoc, category.assoc,
←F.to_functor.map_comp, iso.hom_inv_id, F.to_functor.map_id, comp_id],
end
@[simp, reassoc]
lemma lax_monoidal_functor.right_unitality_inv (F : lax_monoidal_functor C D) (X : C) :
(ρ_ (F.obj X)).inv ≫ (𝟙 (F.obj X) ⊗ F.ε) ≫ F.μ X (𝟙_ C) = F.map (ρ_ X).inv :=
begin
rw [iso.inv_comp_eq, F.right_unitality, category.assoc, category.assoc,
←F.to_functor.map_comp, iso.hom_inv_id, F.to_functor.map_id, comp_id],
end
@[simp, reassoc]
lemma lax_monoidal_functor.associativity_inv (F : lax_monoidal_functor C D) (X Y Z : C) :
(𝟙 (F.obj X) ⊗ F.μ Y Z) ≫ F.μ X (Y ⊗ Z) ≫ F.map (α_ X Y Z).inv =
(α_ (F.obj X) (F.obj Y) (F.obj Z)).inv ≫ (F.μ X Y ⊗ 𝟙 (F.obj Z)) ≫ F.μ (X ⊗ Y) Z :=
begin
rw [iso.eq_inv_comp, ←F.associativity_assoc,
←F.to_functor.map_comp, iso.hom_inv_id, F.to_functor.map_id, comp_id],
end
end
/--
A monoidal functor is a lax monoidal functor for which the tensorator and unitor as isomorphisms.
See <https://stacks.math.columbia.edu/tag/0FFL>.
-/
structure monoidal_functor
extends lax_monoidal_functor.{v₁ v₂} C D :=
(ε_is_iso : is_iso ε . tactic.apply_instance)
(μ_is_iso : Π X Y : C, is_iso (μ X Y) . tactic.apply_instance)
attribute [instance] monoidal_functor.ε_is_iso monoidal_functor.μ_is_iso
variables {C D}
/--
The unit morphism of a (strong) monoidal functor as an isomorphism.
-/
noncomputable
def monoidal_functor.ε_iso (F : monoidal_functor.{v₁ v₂} C D) :
tensor_unit D ≅ F.obj (tensor_unit C) :=
as_iso F.ε
/--
The tensorator of a (strong) monoidal functor as an isomorphism.
-/
noncomputable
def monoidal_functor.μ_iso (F : monoidal_functor.{v₁ v₂} C D) (X Y : C) :
(F.obj X) ⊗ (F.obj Y) ≅ F.obj (X ⊗ Y) :=
as_iso (F.μ X Y)
end
open monoidal_category
namespace lax_monoidal_functor
variables (C : Type u₁) [category.{v₁} C] [monoidal_category.{v₁} C]
/-- The identity lax monoidal functor. -/
@[simps] def id : lax_monoidal_functor.{v₁ v₁} C C :=
{ ε := 𝟙 _,
μ := λ X Y, 𝟙 _,
.. 𝟭 C }
instance : inhabited (lax_monoidal_functor C C) := ⟨id C⟩
end lax_monoidal_functor
namespace monoidal_functor
section
variables {C : Type u₁} [category.{v₁} C] [monoidal_category.{v₁} C]
variables {D : Type u₂} [category.{v₂} D] [monoidal_category.{v₂} D]
variable (F : monoidal_functor.{v₁ v₂} C D)
lemma map_tensor {X Y X' Y' : C} (f : X ⟶ Y) (g : X' ⟶ Y') :
F.map (f ⊗ g) = inv (F.μ X X') ≫ ((F.map f) ⊗ (F.map g)) ≫ F.μ Y Y' :=
by simp
lemma map_left_unitor (X : C) :
F.map (λ_ X).hom = inv (F.μ (𝟙_ C) X) ≫ (inv F.ε ⊗ 𝟙 (F.obj X)) ≫ (λ_ (F.obj X)).hom :=
begin
simp only [lax_monoidal_functor.left_unitality],
slice_rhs 2 3 { rw ←comp_tensor_id, simp, },
simp,
end
lemma map_right_unitor (X : C) :
F.map (ρ_ X).hom = inv (F.μ X (𝟙_ C)) ≫ (𝟙 (F.obj X) ⊗ inv F.ε) ≫ (ρ_ (F.obj X)).hom :=
begin
simp only [lax_monoidal_functor.right_unitality],
slice_rhs 2 3 { rw ←id_tensor_comp, simp, },
simp,
end
/-- The tensorator as a natural isomorphism. -/
noncomputable
def μ_nat_iso :
(functor.prod F.to_functor F.to_functor) ⋙ (tensor D) ≅ (tensor C) ⋙ F.to_functor :=
nat_iso.of_components
(by { intros, apply F.μ_iso })
(by { intros, apply F.to_lax_monoidal_functor.μ_natural })
@[simp] lemma μ_iso_hom (X Y : C) : (F.μ_iso X Y).hom = F.μ X Y := rfl
@[simp, reassoc] lemma μ_inv_hom_id (X Y : C) : (F.μ_iso X Y).inv ≫ F.μ X Y = 𝟙 _ :=
(F.μ_iso X Y).inv_hom_id
@[simp] lemma μ_hom_inv_id (X Y : C) : F.μ X Y ≫ (F.μ_iso X Y).inv = 𝟙 _ :=
(F.μ_iso X Y).hom_inv_id
@[simp] lemma ε_iso_hom : F.ε_iso.hom = F.ε := rfl
@[simp, reassoc] lemma ε_inv_hom_id : F.ε_iso.inv ≫ F.ε = 𝟙 _ := F.ε_iso.inv_hom_id
@[simp] lemma ε_hom_inv_id : F.ε ≫ F.ε_iso.inv = 𝟙 _ := F.ε_iso.hom_inv_id
/-- Monoidal functors commute with left tensoring up to isomorphism -/
@[simps] noncomputable def comm_tensor_left (X : C) :
F.to_functor ⋙ (tensor_left (F.to_functor.obj X)) ≅
tensor_left X ⋙ F.to_functor :=
nat_iso.of_components (λ Y, F.μ_iso X Y) (λ Y Z f, by { convert F.μ_natural' (𝟙 _) f, simp })
/-- Monoidal functors commute with right tensoring up to isomorphism -/
@[simps] noncomputable def comm_tensor_right (X : C) :
F.to_functor ⋙ (tensor_right (F.to_functor.obj X)) ≅
tensor_right X ⋙ F.to_functor :=
nat_iso.of_components (λ Y, F.μ_iso Y X) (λ Y Z f, by { convert F.μ_natural' f (𝟙 _), simp })
end
section
variables (C : Type u₁) [category.{v₁} C] [monoidal_category.{v₁} C]
/-- The identity monoidal functor. -/
@[simps] def id : monoidal_functor.{v₁ v₁} C C :=
{ ε := 𝟙 _,
μ := λ X Y, 𝟙 _,
.. 𝟭 C }
instance : inhabited (monoidal_functor C C) := ⟨id C⟩
end
end monoidal_functor
variables {C : Type u₁} [category.{v₁} C] [monoidal_category.{v₁} C]
variables {D : Type u₂} [category.{v₂} D] [monoidal_category.{v₂} D]
variables {E : Type u₃} [category.{v₃} E] [monoidal_category.{v₃} E]
namespace lax_monoidal_functor
variables (F : lax_monoidal_functor.{v₁ v₂} C D) (G : lax_monoidal_functor.{v₂ v₃} D E)
-- The proofs here are horrendous; rewrite_search helps a lot.
/-- The composition of two lax monoidal functors is again lax monoidal. -/
@[simps] def comp : lax_monoidal_functor.{v₁ v₃} C E :=
{ ε := G.ε ≫ (G.map F.ε),
μ := λ X Y, G.μ (F.obj X) (F.obj Y) ≫ G.map (F.μ X Y),
μ_natural' := λ _ _ _ _ f g,
begin
simp only [functor.comp_map, assoc],
rw [←category.assoc, lax_monoidal_functor.μ_natural, category.assoc, ←map_comp, ←map_comp,
←lax_monoidal_functor.μ_natural]
end,
associativity' := λ X Y Z,
begin
dsimp,
rw id_tensor_comp,
slice_rhs 3 4 { rw [← G.to_functor.map_id, G.μ_natural], },
slice_rhs 1 3 { rw ←G.associativity, },
rw comp_tensor_id,
slice_lhs 2 3 { rw [← G.to_functor.map_id, G.μ_natural], },
rw [category.assoc, category.assoc, category.assoc, category.assoc, category.assoc,
←G.to_functor.map_comp, ←G.to_functor.map_comp, ←G.to_functor.map_comp,
←G.to_functor.map_comp, F.associativity],
end,
left_unitality' := λ X,
begin
dsimp,
rw [G.left_unitality, comp_tensor_id, category.assoc, category.assoc],
apply congr_arg,
rw [F.left_unitality, map_comp, ←nat_trans.id_app, ←category.assoc,
←lax_monoidal_functor.μ_natural, nat_trans.id_app, map_id, ←category.assoc, map_comp],
end,
right_unitality' := λ X,
begin
dsimp,
rw [G.right_unitality, id_tensor_comp, category.assoc, category.assoc],
apply congr_arg,
rw [F.right_unitality, map_comp, ←nat_trans.id_app, ←category.assoc,
←lax_monoidal_functor.μ_natural, nat_trans.id_app, map_id, ←category.assoc, map_comp],
end,
.. (F.to_functor) ⋙ (G.to_functor) }.
infixr ` ⊗⋙ `:80 := comp
end lax_monoidal_functor
namespace lax_monoidal_functor
universes v₀ u₀
variables {B : Type u₀} [category.{v₀} B] [monoidal_category.{v₀} B]
variables (F : lax_monoidal_functor.{v₀ v₁} B C) (G : lax_monoidal_functor.{v₂ v₃} D E)
local attribute [simp] μ_natural associativity left_unitality right_unitality
/-- The cartesian product of two lax monoidal functors is lax monoidal. -/
@[simps]
def prod : lax_monoidal_functor (B × D) (C × E) :=
{ ε := (ε F, ε G),
μ := λ X Y, (μ F X.1 Y.1, μ G X.2 Y.2),
.. (F.to_functor).prod (G.to_functor) }
end lax_monoidal_functor
namespace monoidal_functor
variable (C)
/-- The diagonal functor as a monoidal functor. -/
@[simps]
def diag : monoidal_functor C (C × C) :=
{ ε := 𝟙 _,
μ := λ X Y, 𝟙 _,
.. functor.diag C }
end monoidal_functor
namespace lax_monoidal_functor
variables (F : lax_monoidal_functor.{v₁ v₂} C D) (G : lax_monoidal_functor.{v₁ v₃} C E)
/-- The cartesian product of two lax monoidal functors starting from the same monoidal category `C`
is lax monoidal. -/
def prod' : lax_monoidal_functor C (D × E) :=
(monoidal_functor.diag C).to_lax_monoidal_functor ⊗⋙ (F.prod G)
@[simp] lemma prod'_to_functor :
(F.prod' G).to_functor = (F.to_functor).prod' (G.to_functor) := rfl
@[simp] lemma prod'_ε : (F.prod' G).ε = (F.ε, G.ε) :=
by { dsimp [prod'], simp }
@[simp] lemma prod'_μ (X Y : C) : (F.prod' G).μ X Y = (F.μ X Y, G.μ X Y) :=
by { dsimp [prod'], simp }
end lax_monoidal_functor
namespace monoidal_functor
variables (F : monoidal_functor.{v₁ v₂} C D) (G : monoidal_functor.{v₂ v₃} D E)
/-- The composition of two monoidal functors is again monoidal. -/
@[simps]
def comp : monoidal_functor.{v₁ v₃} C E :=
{ ε_is_iso := by { dsimp, apply_instance },
μ_is_iso := by { dsimp, apply_instance },
.. (F.to_lax_monoidal_functor).comp (G.to_lax_monoidal_functor) }.
-- We overload notation; potentially dangerous, but it seems to work.
infixr (name := monoidal_functor.comp) ` ⊗⋙ `:80 := comp
end monoidal_functor
namespace monoidal_functor
universes v₀ u₀
variables {B : Type u₀} [category.{v₀} B] [monoidal_category.{v₀} B]
variables (F : monoidal_functor.{v₀ v₁} B C) (G : monoidal_functor.{v₂ v₃} D E)
/-- The cartesian product of two monoidal functors is monoidal. -/
@[simps]
def prod : monoidal_functor (B × D) (C × E) :=
{ ε_is_iso := (is_iso_prod_iff C E).mpr ⟨ε_is_iso F, ε_is_iso G⟩,
μ_is_iso := λ X Y, (is_iso_prod_iff C E).mpr ⟨μ_is_iso F X.1 Y.1, μ_is_iso G X.2 Y.2⟩,
.. (F.to_lax_monoidal_functor).prod (G.to_lax_monoidal_functor) }
end monoidal_functor
namespace monoidal_functor
variables (F : monoidal_functor.{v₁ v₂} C D) (G : monoidal_functor.{v₁ v₃} C E)
/-- The cartesian product of two monoidal functors starting from the same monoidal category `C`
is monoidal. -/
def prod' : monoidal_functor C (D × E) := diag C ⊗⋙ (F.prod G)
@[simp] lemma prod'_to_lax_monoidal_functor :
(F.prod' G).to_lax_monoidal_functor
= (F.to_lax_monoidal_functor).prod' (G.to_lax_monoidal_functor) := rfl
end monoidal_functor
/--
If we have a right adjoint functor `G` to a monoidal functor `F`, then `G` has a lax monoidal
structure as well.
-/
@[simps]
noncomputable
def monoidal_adjoint (F : monoidal_functor C D) {G : D ⥤ C} (h : F.to_functor ⊣ G) :
lax_monoidal_functor D C :=
{ to_functor := G,
ε := h.hom_equiv _ _ (inv F.ε),
μ := λ X Y,
h.hom_equiv _ (X ⊗ Y) (inv (F.μ (G.obj X) (G.obj Y)) ≫ (h.counit.app X ⊗ h.counit.app Y)),
μ_natural' := λ X Y X' Y' f g,
begin
rw [←h.hom_equiv_naturality_left, ←h.hom_equiv_naturality_right, equiv.apply_eq_iff_eq, assoc,
is_iso.eq_inv_comp, ←F.to_lax_monoidal_functor.μ_natural_assoc, is_iso.hom_inv_id_assoc,
←tensor_comp, adjunction.counit_naturality, adjunction.counit_naturality, tensor_comp],
end,
associativity' := λ X Y Z,
begin
rw [←h.hom_equiv_naturality_right, ←h.hom_equiv_naturality_left, ←h.hom_equiv_naturality_left,
←h.hom_equiv_naturality_left, equiv.apply_eq_iff_eq,
← cancel_epi (F.to_lax_monoidal_functor.μ (G.obj X ⊗ G.obj Y) (G.obj Z)),
← cancel_epi (F.to_lax_monoidal_functor.μ (G.obj X) (G.obj Y) ⊗ 𝟙 (F.obj (G.obj Z))),
F.to_lax_monoidal_functor.associativity_assoc (G.obj X) (G.obj Y) (G.obj Z),
←F.to_lax_monoidal_functor.μ_natural_assoc, assoc, is_iso.hom_inv_id_assoc,
←F.to_lax_monoidal_functor.μ_natural_assoc, is_iso.hom_inv_id_assoc, ←tensor_comp,
←tensor_comp, id_comp, functor.map_id, functor.map_id, id_comp, ←tensor_comp_assoc,
←tensor_comp_assoc, id_comp, id_comp, h.hom_equiv_unit, h.hom_equiv_unit, functor.map_comp,
assoc, assoc, h.counit_naturality, h.left_triangle_components_assoc, is_iso.hom_inv_id_assoc,
functor.map_comp, assoc, h.counit_naturality, h.left_triangle_components_assoc,
is_iso.hom_inv_id_assoc],
exact associator_naturality (h.counit.app X) (h.counit.app Y) (h.counit.app Z),
end,
left_unitality' := λ X,
begin
rw [←h.hom_equiv_naturality_right, ←h.hom_equiv_naturality_left, ←equiv.symm_apply_eq,
h.hom_equiv_counit, F.map_left_unitor, h.hom_equiv_unit, assoc, assoc, assoc, F.map_tensor,
assoc, assoc, is_iso.hom_inv_id_assoc, ←tensor_comp_assoc, functor.map_id, id_comp,
functor.map_comp, assoc, h.counit_naturality, h.left_triangle_components_assoc,
←left_unitor_naturality, ←tensor_comp_assoc, id_comp, comp_id],
end,
right_unitality' := λ X,
begin
rw [←h.hom_equiv_naturality_right, ←h.hom_equiv_naturality_left, ←equiv.symm_apply_eq,
h.hom_equiv_counit, F.map_right_unitor, assoc, assoc, ←right_unitor_naturality,
←tensor_comp_assoc, comp_id, id_comp, h.hom_equiv_unit, F.map_tensor, assoc, assoc, assoc,
is_iso.hom_inv_id_assoc, functor.map_comp, functor.map_id, ←tensor_comp_assoc, assoc,
h.counit_naturality, h.left_triangle_components_assoc, id_comp],
end }.
/-- If a monoidal functor `F` is an equivalence of categories then its inverse is also monoidal. -/
@[simps]
noncomputable
def monoidal_inverse (F : monoidal_functor C D) [is_equivalence F.to_functor] :
monoidal_functor D C :=
{ to_lax_monoidal_functor := monoidal_adjoint F (as_equivalence _).to_adjunction,
ε_is_iso := by { dsimp [equivalence.to_adjunction], apply_instance },
μ_is_iso := λ X Y, by { dsimp [equivalence.to_adjunction], apply_instance } }
end category_theory
|
43bb538d22525da48f685853ffae6b571cae0b78 | 1abd1ed12aa68b375cdef28959f39531c6e95b84 | /src/linear_algebra/determinant.lean | 581bbc3d9f03be18f7dd04270ccad12e9a8d3123 | [
"Apache-2.0"
] | permissive | jumpy4/mathlib | d3829e75173012833e9f15ac16e481e17596de0f | af36f1a35f279f0e5b3c2a77647c6bf2cfd51a13 | refs/heads/master | 1,693,508,842,818 | 1,636,203,271,000 | 1,636,203,271,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 15,852 | lean | /-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Patrick Massot, Casper Putz, Anne Baanen
-/
import linear_algebra.free_module.pid
import linear_algebra.matrix.basis
import linear_algebra.matrix.diagonal
import linear_algebra.matrix.to_linear_equiv
import linear_algebra.matrix.reindex
import linear_algebra.multilinear.basic
import linear_algebra.dual
import ring_theory.algebra_tower
/-!
# Determinant of families of vectors
This file defines the determinant of an endomorphism, and of a family of vectors
with respect to some basis. For the determinant of a matrix, see the file
`linear_algebra.matrix.determinant`.
## Main definitions
In the list below, and in all this file, `R` is a commutative ring (semiring
is sometimes enough), `M` and its variations are `R`-modules, `ι`, `κ`, `n` and `m` are finite
types used for indexing.
* `basis.det`: the determinant of a family of vectors with respect to a basis,
as a multilinear map
* `linear_map.det`: the determinant of an endomorphism `f : End R M` as a
multiplicative homomorphism (if `M` does not have a finite `R`-basis, the
result is `1` instead)
## Tags
basis, det, determinant
-/
noncomputable theory
open_locale big_operators
open_locale matrix
open linear_map
open submodule
universes u v w
open linear_map matrix
variables {R : Type*} [comm_ring R]
variables {M : Type*} [add_comm_group M] [module R M]
variables {M' : Type*} [add_comm_group M'] [module R M']
variables {ι : Type*} [decidable_eq ι] [fintype ι]
variables (e : basis ι R M)
section conjugate
variables {A : Type*} [comm_ring A]
variables {m n : Type*} [fintype m] [fintype n]
/-- If `R^m` and `R^n` are linearly equivalent, then `m` and `n` are also equivalent. -/
def equiv_of_pi_lequiv_pi {R : Type*} [comm_ring R] [is_domain R]
(e : (m → R) ≃ₗ[R] (n → R)) : m ≃ n :=
basis.index_equiv (basis.of_equiv_fun e.symm) (pi.basis_fun _ _)
namespace matrix
/-- If `M` and `M'` are each other's inverse matrices, they are square matrices up to
equivalence of types. -/
def index_equiv_of_inv [is_domain A] [decidable_eq m] [decidable_eq n]
{M : matrix m n A} {M' : matrix n m A}
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
m ≃ n :=
equiv_of_pi_lequiv_pi (to_lin'_of_inv hMM' hM'M)
lemma det_comm [decidable_eq n] (M N : matrix n n A) : det (M ⬝ N) = det (N ⬝ M) :=
by rw [det_mul, det_mul, mul_comm]
/-- If there exists a two-sided inverse `M'` for `M` (indexed differently),
then `det (N ⬝ M) = det (M ⬝ N)`. -/
lemma det_comm' [is_domain A] [decidable_eq m] [decidable_eq n]
{M : matrix n m A} {N : matrix m n A} {M' : matrix m n A}
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
det (M ⬝ N) = det (N ⬝ M) :=
-- Although `m` and `n` are different a priori, we will show they have the same cardinality.
-- This turns the problem into one for square matrices, which is easy.
let e := index_equiv_of_inv hMM' hM'M in
by rw [← det_minor_equiv_self e, minor_mul_equiv _ _ _ (equiv.refl n) _, det_comm,
← minor_mul_equiv, equiv.coe_refl, minor_id_id]
/-- If `M'` is a two-sided inverse for `M` (indexed differently), `det (M ⬝ N ⬝ M') = det N`. -/
lemma det_conj [is_domain A] [decidable_eq m] [decidable_eq n]
{M : matrix m n A} {M' : matrix n m A} {N : matrix n n A}
(hMM' : M ⬝ M' = 1) (hM'M : M' ⬝ M = 1) :
det (M ⬝ N ⬝ M') = det N :=
by rw [← det_comm' hM'M hMM', ← matrix.mul_assoc, hM'M, matrix.one_mul]
end matrix
end conjugate
namespace linear_map
/-! ### Determinant of a linear map -/
variables {A : Type*} [comm_ring A] [is_domain A] [module A M]
variables {κ : Type*} [fintype κ]
/-- The determinant of `linear_map.to_matrix` does not depend on the choice of basis. -/
lemma det_to_matrix_eq_det_to_matrix [decidable_eq κ]
(b : basis ι A M) (c : basis κ A M) (f : M →ₗ[A] M) :
det (linear_map.to_matrix b b f) = det (linear_map.to_matrix c c f) :=
by rw [← linear_map_to_matrix_mul_basis_to_matrix c b c,
← basis_to_matrix_mul_linear_map_to_matrix b c b,
matrix.det_conj]; rw [basis.to_matrix_mul_to_matrix, basis.to_matrix_self]
/-- The determinant of an endomorphism given a basis.
See `linear_map.det` for a version that populates the basis non-computably.
Although the `trunc (basis ι A M)` parameter makes it slightly more convenient to switch bases,
there is no good way to generalize over universe parameters, so we can't fully state in `det_aux`'s
type that it does not depend on the choice of basis. Instead you can use the `det_aux_def'` lemma,
or avoid mentioning a basis at all using `linear_map.det`.
-/
def det_aux : trunc (basis ι A M) → (M →ₗ[A] M) →* A :=
trunc.lift
(λ b : basis ι A M,
(det_monoid_hom).comp (to_matrix_alg_equiv b : (M →ₗ[A] M) →* matrix ι ι A))
(λ b c, monoid_hom.ext $ det_to_matrix_eq_det_to_matrix b c)
/-- Unfold lemma for `det_aux`.
See also `det_aux_def'` which allows you to vary the basis.
-/
lemma det_aux_def (b : basis ι A M) (f : M →ₗ[A] M) :
linear_map.det_aux (trunc.mk b) f = matrix.det (linear_map.to_matrix b b f) :=
rfl
-- Discourage the elaborator from unfolding `det_aux` and producing a huge term.
attribute [irreducible] linear_map.det_aux
lemma det_aux_def' {ι' : Type*} [fintype ι'] [decidable_eq ι']
(tb : trunc $ basis ι A M) (b' : basis ι' A M) (f : M →ₗ[A] M) :
linear_map.det_aux tb f = matrix.det (linear_map.to_matrix b' b' f) :=
by { apply trunc.induction_on tb, intro b, rw [det_aux_def, det_to_matrix_eq_det_to_matrix b b'] }
@[simp]
lemma det_aux_id (b : trunc $ basis ι A M) : linear_map.det_aux b (linear_map.id) = 1 :=
(linear_map.det_aux b).map_one
@[simp]
lemma det_aux_comp (b : trunc $ basis ι A M) (f g : M →ₗ[A] M) :
linear_map.det_aux b (f.comp g) = linear_map.det_aux b f * linear_map.det_aux b g :=
(linear_map.det_aux b).map_mul f g
section
open_locale classical
-- Discourage the elaborator from unfolding `det` and producing a huge term by marking it
-- as irreducible.
/-- The determinant of an endomorphism independent of basis.
If there is no finite basis on `M`, the result is `1` instead.
-/
@[irreducible] protected def det : (M →ₗ[A] M) →* A :=
if H : ∃ (s : finset M), nonempty (basis s A M)
then linear_map.det_aux (trunc.mk H.some_spec.some)
else 1
lemma coe_det [decidable_eq M] : ⇑(linear_map.det : (M →ₗ[A] M) →* A) =
if H : ∃ (s : finset M), nonempty (basis s A M)
then linear_map.det_aux (trunc.mk H.some_spec.some)
else 1 :=
by { ext, unfold linear_map.det,
split_ifs,
{ congr }, -- use the correct `decidable_eq` instance
refl }
end
-- Auxiliary lemma, the `simp` normal form goes in the other direction
-- (using `linear_map.det_to_matrix`)
lemma det_eq_det_to_matrix_of_finset [decidable_eq M]
{s : finset M} (b : basis s A M) (f : M →ₗ[A] M) :
f.det = matrix.det (linear_map.to_matrix b b f) :=
have ∃ (s : finset M), nonempty (basis s A M),
from ⟨s, ⟨b⟩⟩,
by rw [linear_map.coe_det, dif_pos, det_aux_def' _ b]; assumption
@[simp] lemma det_to_matrix
(b : basis ι A M) (f : M →ₗ[A] M) :
matrix.det (to_matrix b b f) = f.det :=
by { haveI := classical.dec_eq M,
rw [det_eq_det_to_matrix_of_finset b.reindex_finset_range, det_to_matrix_eq_det_to_matrix b] }
@[simp] lemma det_to_matrix' {ι : Type*} [fintype ι] [decidable_eq ι]
(f : (ι → A) →ₗ[A] (ι → A)) :
det f.to_matrix' = f.det :=
by simp [← to_matrix_eq_to_matrix']
/-- To show `P f.det` it suffices to consider `P (to_matrix _ _ f).det` and `P 1`. -/
@[elab_as_eliminator]
lemma det_cases [decidable_eq M] {P : A → Prop} (f : M →ₗ[A] M)
(hb : ∀ (s : finset M) (b : basis s A M), P (to_matrix b b f).det) (h1 : P 1) :
P f.det :=
begin
unfold linear_map.det,
split_ifs with h,
{ convert hb _ h.some_spec.some,
apply det_aux_def' },
{ exact h1 }
end
@[simp]
lemma det_comp (f g : M →ₗ[A] M) : (f.comp g).det = f.det * g.det :=
linear_map.det.map_mul f g
@[simp]
lemma det_id : (linear_map.id : M →ₗ[A] M).det = 1 :=
linear_map.det.map_one
/-- Multiplying a map by a scalar `c` multiplies its determinant by `c ^ dim M`. -/
@[simp] lemma det_smul {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M]
(c : 𝕜) (f : M →ₗ[𝕜] M) :
linear_map.det (c • f) = c ^ (finite_dimensional.finrank 𝕜 M) * linear_map.det f :=
begin
by_cases H : ∃ (s : finset M), nonempty (basis s 𝕜 M),
{ haveI : finite_dimensional 𝕜 M,
{ rcases H with ⟨s, ⟨hs⟩⟩, exact finite_dimensional.of_finset_basis hs },
simp only [← det_to_matrix (finite_dimensional.fin_basis 𝕜 M), linear_equiv.map_smul,
fintype.card_fin, det_smul] },
{ classical,
have : finite_dimensional.finrank 𝕜 M = 0 := finrank_eq_zero_of_not_exists_basis H,
simp [coe_det, H, this] }
end
lemma det_zero' {ι : Type*} [fintype ι] [nonempty ι] (b : basis ι A M) :
linear_map.det (0 : M →ₗ[A] M) = 0 :=
by { haveI := classical.dec_eq ι,
rw [← det_to_matrix b, linear_equiv.map_zero, det_zero],
assumption }
/-- In a finite-dimensional vector space, the zero map has determinant `1` in dimension `0`,
and `0` otherwise. -/
@[simp] lemma det_zero {𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M] :
linear_map.det (0 : M →ₗ[𝕜] M) = (0 : 𝕜) ^ (finite_dimensional.finrank 𝕜 M) :=
by simp only [← zero_smul 𝕜 (1 : M →ₗ[𝕜] M), det_smul, mul_one, monoid_hom.map_one]
/-- Conjugating a linear map by a linear equiv does not change its determinant. -/
@[simp] lemma det_conj {N : Type*} [add_comm_group N] [module A N]
(f : M →ₗ[A] M) (e : M ≃ₗ[A] N) :
linear_map.det ((e : M →ₗ[A] N) ∘ₗ (f ∘ₗ (e.symm : N →ₗ[A] M))) = linear_map.det f :=
begin
classical,
by_cases H : ∃ (s : finset M), nonempty (basis s A M),
{ rcases H with ⟨s, ⟨b⟩⟩,
rw [← det_to_matrix b f, ← det_to_matrix (b.map e), to_matrix_comp (b.map e) b (b.map e),
to_matrix_comp (b.map e) b b, ← matrix.mul_assoc, matrix.det_conj],
{ rw [← to_matrix_comp, linear_equiv.comp_coe, e.symm_trans,
linear_equiv.refl_to_linear_map, to_matrix_id] },
{ rw [← to_matrix_comp, linear_equiv.comp_coe, e.trans_symm,
linear_equiv.refl_to_linear_map, to_matrix_id] } },
{ have H' : ¬ (∃ (t : finset N), nonempty (basis t A N)),
{ contrapose! H,
rcases H with ⟨s, ⟨b⟩⟩,
exact ⟨_, ⟨(b.map e.symm).reindex_finset_range⟩⟩ },
simp only [coe_det, H, H', pi.one_apply, dif_neg, not_false_iff] }
end
end linear_map
-- Cannot be stated using `linear_map.det` because `f` is not an endomorphism.
lemma linear_equiv.is_unit_det (f : M ≃ₗ[R] M') (v : basis ι R M) (v' : basis ι R M') :
is_unit (linear_map.to_matrix v v' f).det :=
begin
apply is_unit_det_of_left_inverse,
simpa using (linear_map.to_matrix_comp v v' v f.symm f).symm
end
/-- Specialization of `linear_equiv.is_unit_det` -/
lemma linear_equiv.is_unit_det' {A : Type*} [comm_ring A] [is_domain A] [module A M]
(f : M ≃ₗ[A] M) : is_unit (linear_map.det (f : M →ₗ[A] M)) :=
by haveI := classical.dec_eq M; exact
(f : M →ₗ[A] M).det_cases (λ s b, f.is_unit_det _ _) is_unit_one
/-- Builds a linear equivalence from a linear map whose determinant in some bases is a unit. -/
@[simps]
def linear_equiv.of_is_unit_det {f : M →ₗ[R] M'} {v : basis ι R M} {v' : basis ι R M'}
(h : is_unit (linear_map.to_matrix v v' f).det) : M ≃ₗ[R] M' :=
{ to_fun := f,
map_add' := f.map_add,
map_smul' := f.map_smul,
inv_fun := to_lin v' v (to_matrix v v' f)⁻¹,
left_inv := λ x,
calc to_lin v' v (to_matrix v v' f)⁻¹ (f x)
= to_lin v v ((to_matrix v v' f)⁻¹ ⬝ to_matrix v v' f) x :
by { rw [to_lin_mul v v' v, to_lin_to_matrix, linear_map.comp_apply] }
... = x : by simp [h],
right_inv := λ x,
calc f (to_lin v' v (to_matrix v v' f)⁻¹ x)
= to_lin v' v' (to_matrix v v' f ⬝ (to_matrix v v' f)⁻¹) x :
by { rw [to_lin_mul v' v v', linear_map.comp_apply, to_lin_to_matrix v v'] }
... = x : by simp [h] }
/-- Builds a linear equivalence from a linear map on a finite-dimensional vector space whose
determinant is nonzero. -/
@[reducible] def linear_map.equiv_of_det_ne_zero
{𝕜 : Type*} [field 𝕜] {M : Type*} [add_comm_group M] [module 𝕜 M]
[finite_dimensional 𝕜 M] (f : M →ₗ[𝕜] M) (hf : linear_map.det f ≠ 0) :
M ≃ₗ[𝕜] M :=
have is_unit (linear_map.to_matrix (finite_dimensional.fin_basis 𝕜 M)
(finite_dimensional.fin_basis 𝕜 M) f).det :=
by simp only [linear_map.det_to_matrix, is_unit_iff_ne_zero.2 hf],
linear_equiv.of_is_unit_det this
/-- The determinant of a family of vectors with respect to some basis, as an alternating
multilinear map. -/
def basis.det : alternating_map R M R ι :=
{ to_fun := λ v, det (e.to_matrix v),
map_add' := begin
intros v i x y,
simp only [e.to_matrix_update, linear_equiv.map_add],
apply det_update_column_add
end,
map_smul' := begin
intros u i c x,
simp only [e.to_matrix_update, algebra.id.smul_eq_mul, linear_equiv.map_smul],
apply det_update_column_smul
end,
map_eq_zero_of_eq' := begin
intros v i j h hij,
rw [←function.update_eq_self i v, h, ←det_transpose, e.to_matrix_update,
←update_row_transpose, ←e.to_matrix_transpose_apply],
apply det_zero_of_row_eq hij,
rw [update_row_ne hij.symm, update_row_self],
end }
lemma basis.det_apply (v : ι → M) : e.det v = det (e.to_matrix v) := rfl
lemma basis.det_self : e.det e = 1 :=
by simp [e.det_apply]
/-- `basis.det` is not the zero map. -/
lemma basis.det_ne_zero [nontrivial R] : e.det ≠ 0 :=
λ h, by simpa [h] using e.det_self
lemma is_basis_iff_det {v : ι → M} :
linear_independent R v ∧ span R (set.range v) = ⊤ ↔ is_unit (e.det v) :=
begin
split,
{ rintro ⟨hli, hspan⟩,
set v' := basis.mk hli hspan with v'_eq,
rw e.det_apply,
convert linear_equiv.is_unit_det (linear_equiv.refl _ _) v' e using 2,
ext i j,
simp },
{ intro h,
rw [basis.det_apply, basis.to_matrix_eq_to_matrix_constr] at h,
set v' := basis.map e (linear_equiv.of_is_unit_det h) with v'_def,
have : ⇑ v' = v,
{ ext i, rw [v'_def, basis.map_apply, linear_equiv.of_is_unit_det_apply, e.constr_basis] },
rw ← this,
exact ⟨v'.linear_independent, v'.span_eq⟩ },
end
lemma basis.is_unit_det (e' : basis ι R M) : is_unit (e.det e') :=
(is_basis_iff_det e).mp ⟨e'.linear_independent, e'.span_eq⟩
variables {A : Type*} [comm_ring A] [is_domain A] [module A M]
@[simp] lemma basis.det_comp (e : basis ι A M) (f : M →ₗ[A] M) (v : ι → M) :
e.det (f ∘ v) = f.det * e.det v :=
by { rw [basis.det_apply, basis.det_apply, ← f.det_to_matrix e, ← matrix.det_mul,
e.to_matrix_eq_to_matrix_constr (f ∘ v), e.to_matrix_eq_to_matrix_constr v,
← to_matrix_comp, e.constr_comp] }
lemma basis.det_reindex {ι' : Type*} [fintype ι'] [decidable_eq ι']
(b : basis ι R M) (v : ι' → M) (e : ι ≃ ι') :
(b.reindex e).det v = b.det (v ∘ e) :=
by rw [basis.det_apply, basis.to_matrix_reindex', det_reindex_alg_equiv, basis.det_apply]
lemma basis.det_reindex_symm {ι' : Type*} [fintype ι'] [decidable_eq ι']
(b : basis ι R M) (v : ι → M) (e : ι' ≃ ι) :
(b.reindex e.symm).det (v ∘ e) = b.det v :=
by rw [basis.det_reindex, function.comp.assoc, e.self_comp_symm, function.comp.right_id]
@[simp]
lemma basis.det_map (b : basis ι R M) (f : M ≃ₗ[R] M') (v : ι → M') :
(b.map f).det v = b.det (f.symm ∘ v) :=
by { rw [basis.det_apply, basis.to_matrix_map, basis.det_apply] }
|
1550bb84cc422e0efa1f3c22ec88e8be864cb02c | d7189ea2ef694124821b033e533f18905b5e87ef | /galois/category/monad/state/default.lean | 4e3a36a039595d508d887350b0771a0c57346d74 | [
"Apache-2.0"
] | permissive | digama0/lean-protocol-support | eaa7e6f8b8e0d5bbfff1f7f52bfb79a3b11b0f59 | cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda | refs/heads/master | 1,625,421,450,627 | 1,506,035,462,000 | 1,506,035,462,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 3,710 | lean | /- This file defines a monad transformer for state, called monad.state_t that is
similiar to the Haskell MTL type by the same name.
-/
import galois.category.monad.state.class
universe variables u v
namespace monad
/- The state transformer -/
structure state_t (s : Type u) (m : Type u → Type v) (α : Type u) :=
(run : s → m (α × s))
namespace state_t
section
parameter {S : Type u}
parameter {M : Type u → Type v}
/- Two state_t values are equivalent if their underlying function is. -/
def eq {α : Type u} (x y : monad.state_t S M α) (p : x.run = y.run) : x = y :=
begin
cases x with xr,
cases y with yr,
apply congr_arg,
exact p,
end
def pure [applicative M] (α : Type u) (x : α) : monad.state_t S M α := ⟨λs, pure (x, s)⟩
def map [functor M] {α β : Type u} (f : α → β) (m : state_t S M α) : state_t S M β := ⟨ λs, do
(λ(p : α × S), (f p.fst, p.snd)) <$> m.run s ⟩
def bind [monad M] {α β : Type u} (m : state_t S M α) (h : α → state_t S M β) : state_t S M β :=
⟨ λs, m.run s >>= λp, (h (p.fst))^.run (p.snd) ⟩
end
-- Map a computation over M into a computation over state_t.
def lift {S : Type u} {M : Type u → Type v} [functor M] {α : Type u} (m : M α) : state_t S M α :=
{ run := λs, (λv, (v, s)) <$> m }
/- Show state_t is a functor if the underlying action is a functor -/
instance is_functor (S : Type u) (M : Type u → Type v) [inst : functor M]
: functor (state_t S M) :=
{ map := @map S M inst
, id_map :=
begin
intros α x,
cases x with f,
apply eq,
unfold map,
dsimp,
apply funext,
intros s,
transitivity,
{ change (λ (p : α × S), (id (p.fst), p.snd)) <$> f s = id <$> f s,
apply congr_fun,
apply congr_arg,
apply funext,
intro p,
cases p,
refl,
},
exact functor.id_map _,
end
, map_comp :=
begin
intros α β γ f g m,
dsimp [map],
apply congr_arg,
apply funext,
intro s,
rw [eq.symm (functor.map_comp _ _ (m.run s))],
end
}
end state_t
end monad
/- Show state_t is a monad if the underlying action is a monad -/
instance monad.state_t.is_monad (S : Type u) (M : Type u → Type v) [inst : monad M]
: monad (monad.state_t S M) :=
{ to_functor := @monad.state_t.is_functor S M inst.to_functor
, bind := @monad.state_t.bind S M inst
, pure := @monad.state_t.pure S M (by apply_instance)
, pure_bind :=
begin
intros α β x f,
apply monad.state_t.eq,
unfold has_bind.bind monad.state_t.bind has_pure.pure monad.state_t.pure,
transitivity,
apply funext,
intro s,
apply monad.pure_bind,
simp,
end
, bind_assoc :=
begin
intros α β γ m f g,
apply monad.state_t.eq,
unfold has_bind.bind monad.state_t.bind,
apply funext,
intro s,
dsimp,
apply monad.bind_assoc,
end
, bind_pure_comp_eq_map :=
begin
unfold auto_param,
intros α β f m,
apply monad.state_t.eq,
apply funext,
intro s,
simp [monad.state_t.bind, function.comp, monad.state_t.pure],
transitivity,
{ change (m.run s >>= λ (p : α × S), pure (f (p.fst), p.snd))
= (m.run s >>= pure ∘ λ p, (f p.fst, p.snd)),
apply congr_arg,
apply funext,
intro p,
refl,
},
transitivity,
{ apply monad.bind_pure_comp_eq_map, },
unfold has_map.map monad.state_t.map,
end
}
-- A typeclas for monad states.
-- Used to provide monad transformers.
@[reducible]
instance monad.state_t.is_monad_state (s : Type u) (m : Type u → Type v) [inst : monad m]
: monad.monad_state (monad.state_t s m) :=
{ to_monad := monad.state_t.is_monad s m
, state := s
, with_state := λα f, ⟨pure ∘ f⟩
}
|
d7042a23e22c3272cdc8156cd9a783fe850cfd8e | 63abd62053d479eae5abf4951554e1064a4c45b4 | /src/data/complex/module.lean | c4e89faa5729bf19b3d8457b9926861c0e44c4d4 | [
"Apache-2.0"
] | permissive | Lix0120/mathlib | 0020745240315ed0e517cbf32e738d8f9811dd80 | e14c37827456fc6707f31b4d1d16f1f3a3205e91 | refs/heads/master | 1,673,102,855,024 | 1,604,151,044,000 | 1,604,151,044,000 | 308,930,245 | 0 | 0 | Apache-2.0 | 1,604,164,710,000 | 1,604,163,547,000 | null | UTF-8 | Lean | false | false | 4,326 | lean | /-
Copyright (c) 2020 Alexander Bentkamp, Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alexander Bentkamp, Sébastien Gouëzel
-/
import data.complex.basic
import data.matrix.notation
import field_theory.tower
import linear_algebra.finite_dimensional
/-!
# Complex number as a vector space over `ℝ`
This file contains three instances:
* `ℂ` is an `ℝ` algebra;
* any complex vector space is a real vector space;
* any finite dimensional complex vector space is a finite dimesional real vector space;
* the space of `ℝ`-linear maps from a real vector space to a complex vector space is a complex
vector space.
It also defines three linear maps:
* `complex.linear_map.re`;
* `complex.linear_map.im`;
* `complex.linear_map.of_real`.
They are bundled versions of the real part, the imaginary part, and the embedding of `ℝ` in `ℂ`,
as `ℝ`-linear maps.
-/
noncomputable theory
namespace complex
instance algebra_over_reals : algebra ℝ ℂ := (complex.of_real).to_algebra
@[simp] lemma coe_algebra_map : ⇑(algebra_map ℝ ℂ) = complex.of_real := rfl
@[simp] lemma re_smul (a : ℝ) (z : ℂ) : re (a • z) = a * re z := by simp [algebra.smul_def]
@[simp] lemma im_smul (a : ℝ) (z : ℂ) : im (a • z) = a * im z := by simp [algebra.smul_def]
open submodule finite_dimensional
lemma is_basis_one_I : is_basis ℝ ![1, I] :=
begin
refine ⟨linear_independent_fin2.2 ⟨I_ne_zero, λ a, mt (congr_arg re) $ by simp⟩,
eq_top_iff'.2 $ λ z, _⟩,
suffices : ∃ a b, z = a • I + b • 1,
by simpa [mem_span_insert, mem_span_singleton, -set.singleton_one],
use [z.im, z.re],
simp [algebra.smul_def, add_comm]
end
instance : finite_dimensional ℝ ℂ := of_fintype_basis is_basis_one_I
@[simp] lemma findim_real_complex : finite_dimensional.findim ℝ ℂ = 2 :=
by rw [findim_eq_card_basis is_basis_one_I, fintype.card_fin]
@[simp] lemma dim_real_complex : vector_space.dim ℝ ℂ = 2 :=
by simp [← findim_eq_dim, findim_real_complex]
lemma {u} dim_real_complex' : cardinal.lift.{0 u} (vector_space.dim ℝ ℂ) = 2 :=
by simp [← findim_eq_dim, findim_real_complex, bit0]
end complex
/- Register as an instance (with low priority) the fact that a complex vector space is also a real
vector space. -/
@[priority 900]
instance module.complex_to_real (E : Type*) [add_comm_group E] [module ℂ E] : module ℝ E :=
restrict_scalars.semimodule ℝ ℂ E
instance module.real_complex_tower (E : Type*) [add_comm_group E] [module ℂ E] :
is_scalar_tower ℝ ℂ E :=
restrict_scalars.is_scalar_tower ℝ ℂ E
instance (E : Type*) [add_comm_group E] [module ℝ E]
(F : Type*) [add_comm_group F] [module ℂ F] : module ℂ (E →ₗ[ℝ] F) :=
linear_map.module_extend_scalars _ _ _ _
@[priority 100]
instance finite_dimensional.complex_to_real (E : Type*) [add_comm_group E] [module ℂ E]
[finite_dimensional ℂ E] : finite_dimensional ℝ E :=
finite_dimensional.trans ℝ ℂ E
lemma dim_real_of_complex (E : Type*) [add_comm_group E] [module ℂ E] :
vector_space.dim ℝ E = 2 * vector_space.dim ℂ E :=
cardinal.lift_inj.1 $
by { rw [← dim_mul_dim' ℝ ℂ E, complex.dim_real_complex], simp [bit0] }
lemma findim_real_of_complex (E : Type*) [add_comm_group E] [module ℂ E] :
finite_dimensional.findim ℝ E = 2 * finite_dimensional.findim ℂ E :=
by rw [← finite_dimensional.findim_mul_findim ℝ ℂ E, complex.findim_real_complex]
namespace complex
/-- Linear map version of the real part function, from `ℂ` to `ℝ`. -/
def linear_map.re : ℂ →ₗ[ℝ] ℝ :=
{ to_fun := λx, x.re,
map_add' := add_re,
map_smul' := re_smul }
@[simp] lemma linear_map.coe_re : ⇑linear_map.re = re := rfl
/-- Linear map version of the imaginary part function, from `ℂ` to `ℝ`. -/
def linear_map.im : ℂ →ₗ[ℝ] ℝ :=
{ to_fun := λx, x.im,
map_add' := add_im,
map_smul' := im_smul }
@[simp] lemma linear_map.coe_im : ⇑linear_map.im = im := rfl
/-- Linear map version of the canonical embedding of `ℝ` in `ℂ`. -/
def linear_map.of_real : ℝ →ₗ[ℝ] ℂ :=
{ to_fun := coe,
map_add' := of_real_add,
map_smul' := λc x, by simp [algebra.smul_def] }
@[simp] lemma linear_map.coe_of_real : ⇑linear_map.of_real = coe := rfl
end complex
|
da88191ccf07917d10ebe60fa3567d0304563c26 | 5ae26df177f810c5006841e9c73dc56e01b978d7 | /src/data/nat/gcd.lean | 68bdc8701bd37e217e8ccd835b3875c655bd7f42 | [
"Apache-2.0"
] | permissive | ChrisHughes24/mathlib | 98322577c460bc6b1fe5c21f42ce33ad1c3e5558 | a2a867e827c2a6702beb9efc2b9282bd801d5f9a | refs/heads/master | 1,583,848,251,477 | 1,565,164,247,000 | 1,565,164,247,000 | 129,409,993 | 0 | 1 | Apache-2.0 | 1,565,164,817,000 | 1,523,628,059,000 | Lean | UTF-8 | Lean | false | false | 13,511 | lean | /-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura
Definitions and properties of gcd, lcm, and coprime.
-/
import data.nat.basic
namespace nat
/- gcd -/
theorem gcd_dvd (m n : ℕ) : (gcd m n ∣ m) ∧ (gcd m n ∣ n) :=
gcd.induction m n
(λn, by rw gcd_zero_left; exact ⟨dvd_zero n, dvd_refl n⟩)
(λm n npos, by rw ←gcd_rec; exact λ ⟨IH₁, IH₂⟩, ⟨IH₂, (dvd_mod_iff IH₂).1 IH₁⟩)
theorem gcd_dvd_left (m n : ℕ) : gcd m n ∣ m := (gcd_dvd m n).left
theorem gcd_dvd_right (m n : ℕ) : gcd m n ∣ n := (gcd_dvd m n).right
theorem dvd_gcd {m n k : ℕ} : k ∣ m → k ∣ n → k ∣ gcd m n :=
gcd.induction m n (λn _ kn, by rw gcd_zero_left; exact kn)
(λn m mpos IH H1 H2, by rw gcd_rec; exact IH ((dvd_mod_iff H1).2 H2) H1)
theorem gcd_comm (m n : ℕ) : gcd m n = gcd n m :=
dvd_antisymm
(dvd_gcd (gcd_dvd_right m n) (gcd_dvd_left m n))
(dvd_gcd (gcd_dvd_right n m) (gcd_dvd_left n m))
theorem gcd_assoc (m n k : ℕ) : gcd (gcd m n) k = gcd m (gcd n k) :=
dvd_antisymm
(dvd_gcd
(dvd.trans (gcd_dvd_left (gcd m n) k) (gcd_dvd_left m n))
(dvd_gcd (dvd.trans (gcd_dvd_left (gcd m n) k) (gcd_dvd_right m n)) (gcd_dvd_right (gcd m n) k)))
(dvd_gcd
(dvd_gcd (gcd_dvd_left m (gcd n k)) (dvd.trans (gcd_dvd_right m (gcd n k)) (gcd_dvd_left n k)))
(dvd.trans (gcd_dvd_right m (gcd n k)) (gcd_dvd_right n k)))
@[simp] theorem gcd_one_right (n : ℕ) : gcd n 1 = 1 :=
eq.trans (gcd_comm n 1) $ gcd_one_left n
theorem gcd_mul_left (m n k : ℕ) : gcd (m * n) (m * k) = m * gcd n k :=
gcd.induction n k
(λk, by repeat {rw mul_zero <|> rw gcd_zero_left})
(λk n H IH, by rwa [←mul_mod_mul_left, ←gcd_rec, ←gcd_rec] at IH)
theorem gcd_mul_right (m n k : ℕ) : gcd (m * n) (k * n) = gcd m k * n :=
by rw [mul_comm m n, mul_comm k n, mul_comm (gcd m k) n, gcd_mul_left]
theorem gcd_pos_of_pos_left {m : ℕ} (n : ℕ) (mpos : m > 0) : gcd m n > 0 :=
pos_of_dvd_of_pos (gcd_dvd_left m n) mpos
theorem gcd_pos_of_pos_right (m : ℕ) {n : ℕ} (npos : n > 0) : gcd m n > 0 :=
pos_of_dvd_of_pos (gcd_dvd_right m n) npos
theorem eq_zero_of_gcd_eq_zero_left {m n : ℕ} (H : gcd m n = 0) : m = 0 :=
or.elim (eq_zero_or_pos m) id
(assume H1 : m > 0, absurd (eq.symm H) (ne_of_lt (gcd_pos_of_pos_left _ H1)))
theorem eq_zero_of_gcd_eq_zero_right {m n : ℕ} (H : gcd m n = 0) : n = 0 :=
by rw gcd_comm at H; exact eq_zero_of_gcd_eq_zero_left H
theorem gcd_div {m n k : ℕ} (H1 : k ∣ m) (H2 : k ∣ n) :
gcd (m / k) (n / k) = gcd m n / k :=
or.elim (eq_zero_or_pos k)
(λk0, by rw [k0, nat.div_zero, nat.div_zero, nat.div_zero, gcd_zero_right])
(λH3, nat.eq_of_mul_eq_mul_right H3 $ by rw [
nat.div_mul_cancel (dvd_gcd H1 H2), ←gcd_mul_right,
nat.div_mul_cancel H1, nat.div_mul_cancel H2])
theorem gcd_dvd_gcd_of_dvd_left {m k : ℕ} (n : ℕ) (H : m ∣ k) : gcd m n ∣ gcd k n :=
dvd_gcd (dvd.trans (gcd_dvd_left m n) H) (gcd_dvd_right m n)
theorem gcd_dvd_gcd_of_dvd_right {m k : ℕ} (n : ℕ) (H : m ∣ k) : gcd n m ∣ gcd n k :=
dvd_gcd (gcd_dvd_left n m) (dvd.trans (gcd_dvd_right n m) H)
theorem gcd_dvd_gcd_mul_left (m n k : ℕ) : gcd m n ∣ gcd (k * m) n :=
gcd_dvd_gcd_of_dvd_left _ (dvd_mul_left _ _)
theorem gcd_dvd_gcd_mul_right (m n k : ℕ) : gcd m n ∣ gcd (m * k) n :=
gcd_dvd_gcd_of_dvd_left _ (dvd_mul_right _ _)
theorem gcd_dvd_gcd_mul_left_right (m n k : ℕ) : gcd m n ∣ gcd m (k * n) :=
gcd_dvd_gcd_of_dvd_right _ (dvd_mul_left _ _)
theorem gcd_dvd_gcd_mul_right_right (m n k : ℕ) : gcd m n ∣ gcd m (n * k) :=
gcd_dvd_gcd_of_dvd_right _ (dvd_mul_right _ _)
theorem gcd_eq_left {m n : ℕ} (H : m ∣ n) : gcd m n = m :=
dvd_antisymm (gcd_dvd_left _ _) (dvd_gcd (dvd_refl _) H)
theorem gcd_eq_right {m n : ℕ} (H : n ∣ m) : gcd m n = n :=
by rw [gcd_comm, gcd_eq_left H]
@[simp] lemma gcd_mul_left_left (m n : ℕ) : gcd (m * n) n = n :=
dvd_antisymm (gcd_dvd_right _ _) (dvd_gcd (dvd_mul_left _ _) (dvd_refl _))
@[simp] lemma gcd_mul_left_right (m n : ℕ) : gcd n (m * n) = n :=
by rw [gcd_comm, gcd_mul_left_left]
@[simp] lemma gcd_mul_right_left (m n : ℕ) : gcd (n * m) n = n :=
by rw [mul_comm, gcd_mul_left_left]
@[simp] lemma gcd_mul_right_right (m n : ℕ) : gcd n (n * m) = n :=
by rw [gcd_comm, gcd_mul_right_left]
@[simp] lemma gcd_gcd_self_right_left (m n : ℕ) : gcd m (gcd m n) = gcd m n :=
dvd_antisymm (gcd_dvd_right _ _) (dvd_gcd (gcd_dvd_left _ _) (dvd_refl _))
@[simp] lemma gcd_gcd_self_right_right (m n : ℕ) : gcd m (gcd n m) = gcd n m :=
by rw [gcd_comm n m, gcd_gcd_self_right_left]
@[simp] lemma gcd_gcd_self_left_right (m n : ℕ) : gcd (gcd n m) m = gcd n m :=
by rw [gcd_comm, gcd_gcd_self_right_right]
@[simp] lemma gcd_gcd_self_left_left (m n : ℕ) : gcd (gcd m n) m = gcd m n :=
by rw [gcd_comm m n, gcd_gcd_self_left_right]
/- lcm -/
theorem lcm_comm (m n : ℕ) : lcm m n = lcm n m :=
by delta lcm; rw [mul_comm, gcd_comm]
theorem lcm_zero_left (m : ℕ) : lcm 0 m = 0 :=
by delta lcm; rw [zero_mul, nat.zero_div]
theorem lcm_zero_right (m : ℕ) : lcm m 0 = 0 := lcm_comm 0 m ▸ lcm_zero_left m
theorem lcm_one_left (m : ℕ) : lcm 1 m = m :=
by delta lcm; rw [one_mul, gcd_one_left, nat.div_one]
theorem lcm_one_right (m : ℕ) : lcm m 1 = m := lcm_comm 1 m ▸ lcm_one_left m
theorem lcm_self (m : ℕ) : lcm m m = m :=
or.elim (eq_zero_or_pos m)
(λh, by rw [h, lcm_zero_left])
(λh, by delta lcm; rw [gcd_self, nat.mul_div_cancel _ h])
theorem dvd_lcm_left (m n : ℕ) : m ∣ lcm m n :=
dvd.intro (n / gcd m n) (nat.mul_div_assoc _ $ gcd_dvd_right m n).symm
theorem dvd_lcm_right (m n : ℕ) : n ∣ lcm m n :=
lcm_comm n m ▸ dvd_lcm_left n m
theorem gcd_mul_lcm (m n : ℕ) : gcd m n * lcm m n = m * n :=
by delta lcm; rw [nat.mul_div_cancel' (dvd.trans (gcd_dvd_left m n) (dvd_mul_right m n))]
theorem lcm_dvd {m n k : ℕ} (H1 : m ∣ k) (H2 : n ∣ k) : lcm m n ∣ k :=
or.elim (eq_zero_or_pos k)
(λh, by rw h; exact dvd_zero _)
(λkpos, dvd_of_mul_dvd_mul_left (gcd_pos_of_pos_left n (pos_of_dvd_of_pos H1 kpos)) $
by rw [gcd_mul_lcm, ←gcd_mul_right, mul_comm n k];
exact dvd_gcd (mul_dvd_mul_left _ H2) (mul_dvd_mul_right H1 _))
theorem lcm_assoc (m n k : ℕ) : lcm (lcm m n) k = lcm m (lcm n k) :=
dvd_antisymm
(lcm_dvd
(lcm_dvd (dvd_lcm_left m (lcm n k)) (dvd.trans (dvd_lcm_left n k) (dvd_lcm_right m (lcm n k))))
(dvd.trans (dvd_lcm_right n k) (dvd_lcm_right m (lcm n k))))
(lcm_dvd
(dvd.trans (dvd_lcm_left m n) (dvd_lcm_left (lcm m n) k))
(lcm_dvd (dvd.trans (dvd_lcm_right m n) (dvd_lcm_left (lcm m n) k)) (dvd_lcm_right (lcm m n) k)))
/- coprime -/
instance (m n : ℕ) : decidable (coprime m n) := by unfold coprime; apply_instance
theorem coprime.gcd_eq_one {m n : ℕ} : coprime m n → gcd m n = 1 := id
theorem coprime.symm {m n : ℕ} : coprime n m → coprime m n := (gcd_comm m n).trans
theorem coprime_of_dvd {m n : ℕ} (H : ∀ k > 1, k ∣ m → ¬ k ∣ n) : coprime m n :=
or.elim (eq_zero_or_pos (gcd m n))
(λg0, by rw [eq_zero_of_gcd_eq_zero_left g0, eq_zero_of_gcd_eq_zero_right g0] at H; exact false.elim
(H 2 dec_trivial (dvd_zero _) (dvd_zero _)))
(λ(g1 : 1 ≤ _), eq.symm $ (lt_or_eq_of_le g1).resolve_left $ λg2,
H _ g2 (gcd_dvd_left _ _) (gcd_dvd_right _ _))
theorem coprime_of_dvd' {m n : ℕ} (H : ∀ k, k ∣ m → k ∣ n → k ∣ 1) : coprime m n :=
coprime_of_dvd $ λk kl km kn, not_le_of_gt kl $ le_of_dvd zero_lt_one (H k km kn)
theorem coprime.dvd_of_dvd_mul_right {m n k : ℕ} (H1 : coprime k n) (H2 : k ∣ m * n) : k ∣ m :=
let t := dvd_gcd (dvd_mul_left k m) H2 in
by rwa [gcd_mul_left, H1.gcd_eq_one, mul_one] at t
theorem coprime.dvd_of_dvd_mul_left {m n k : ℕ} (H1 : coprime k m) (H2 : k ∣ m * n) : k ∣ n :=
by rw mul_comm at H2; exact H1.dvd_of_dvd_mul_right H2
theorem coprime.gcd_mul_left_cancel {k : ℕ} (m : ℕ) {n : ℕ} (H : coprime k n) :
gcd (k * m) n = gcd m n :=
have H1 : coprime (gcd (k * m) n) k,
by rw [coprime, gcd_assoc, H.symm.gcd_eq_one, gcd_one_right],
dvd_antisymm
(dvd_gcd (H1.dvd_of_dvd_mul_left (gcd_dvd_left _ _)) (gcd_dvd_right _ _))
(gcd_dvd_gcd_mul_left _ _ _)
theorem coprime.gcd_mul_right_cancel (m : ℕ) {k n : ℕ} (H : coprime k n) :
gcd (m * k) n = gcd m n :=
by rw [mul_comm m k, H.gcd_mul_left_cancel m]
theorem coprime.gcd_mul_left_cancel_right {k m : ℕ} (n : ℕ) (H : coprime k m) :
gcd m (k * n) = gcd m n :=
by rw [gcd_comm m n, gcd_comm m (k * n), H.gcd_mul_left_cancel n]
theorem coprime.gcd_mul_right_cancel_right {k m : ℕ} (n : ℕ) (H : coprime k m) :
gcd m (n * k) = gcd m n :=
by rw [mul_comm n k, H.gcd_mul_left_cancel_right n]
theorem coprime_div_gcd_div_gcd {m n : ℕ} (H : gcd m n > 0) :
coprime (m / gcd m n) (n / gcd m n) :=
by delta coprime; rw [gcd_div (gcd_dvd_left m n) (gcd_dvd_right m n), nat.div_self H]
theorem not_coprime_of_dvd_of_dvd {m n d : ℕ} (dgt1 : d > 1) (Hm : d ∣ m) (Hn : d ∣ n) :
¬ coprime m n :=
λ (co : gcd m n = 1),
not_lt_of_ge (le_of_dvd zero_lt_one $ by rw ←co; exact dvd_gcd Hm Hn) dgt1
theorem exists_coprime {m n : ℕ} (H : gcd m n > 0) :
∃ m' n', coprime m' n' ∧ m = m' * gcd m n ∧ n = n' * gcd m n :=
⟨_, _, coprime_div_gcd_div_gcd H,
(nat.div_mul_cancel (gcd_dvd_left m n)).symm,
(nat.div_mul_cancel (gcd_dvd_right m n)).symm⟩
theorem exists_coprime' {m n : ℕ} (H : gcd m n > 0) :
∃ g m' n', 0 < g ∧ coprime m' n' ∧ m = m' * g ∧ n = n' * g :=
let ⟨m', n', h⟩ := exists_coprime H in ⟨_, m', n', H, h⟩
theorem coprime.mul {m n k : ℕ} (H1 : coprime m k) (H2 : coprime n k) : coprime (m * n) k :=
(H1.gcd_mul_left_cancel n).trans H2
theorem coprime.mul_right {k m n : ℕ} (H1 : coprime k m) (H2 : coprime k n) : coprime k (m * n) :=
(H1.symm.mul H2.symm).symm
theorem coprime.coprime_dvd_left {m k n : ℕ} (H1 : m ∣ k) (H2 : coprime k n) : coprime m n :=
eq_one_of_dvd_one (by delta coprime at H2; rw ← H2; exact gcd_dvd_gcd_of_dvd_left _ H1)
theorem coprime.coprime_dvd_right {m k n : ℕ} (H1 : n ∣ m) (H2 : coprime k m) : coprime k n :=
(H2.symm.coprime_dvd_left H1).symm
theorem coprime.coprime_mul_left {k m n : ℕ} (H : coprime (k * m) n) : coprime m n :=
H.coprime_dvd_left (dvd_mul_left _ _)
theorem coprime.coprime_mul_right {k m n : ℕ} (H : coprime (m * k) n) : coprime m n :=
H.coprime_dvd_left (dvd_mul_right _ _)
theorem coprime.coprime_mul_left_right {k m n : ℕ} (H : coprime m (k * n)) : coprime m n :=
H.coprime_dvd_right (dvd_mul_left _ _)
theorem coprime.coprime_mul_right_right {k m n : ℕ} (H : coprime m (n * k)) : coprime m n :=
H.coprime_dvd_right (dvd_mul_right _ _)
lemma coprime_mul_iff_left {k m n : ℕ} : coprime (m * n) k ↔ coprime m k ∧ coprime n k :=
⟨λ h, ⟨coprime.coprime_mul_right h, coprime.coprime_mul_left h⟩,
λ ⟨h, _⟩, by rwa [coprime, coprime.gcd_mul_left_cancel n h]⟩
lemma coprime_mul_iff_right {k m n : ℕ} : coprime k (m * n) ↔ coprime k m ∧ coprime k n :=
by { repeat { rw [coprime, nat.gcd_comm k] }, exact coprime_mul_iff_left }
lemma coprime.mul_dvd_of_dvd_of_dvd {a n m : ℕ} (hmn : coprime m n)
(hm : m ∣ a) (hn : n ∣ a) : m * n ∣ a :=
let ⟨k, hk⟩ := hm in hk.symm ▸ mul_dvd_mul_left _ (hmn.symm.dvd_of_dvd_mul_left (hk ▸ hn))
theorem coprime_one_left : ∀ n, coprime 1 n := gcd_one_left
theorem coprime_one_right : ∀ n, coprime n 1 := gcd_one_right
theorem coprime.pow_left {m k : ℕ} (n : ℕ) (H1 : coprime m k) : coprime (m ^ n) k :=
nat.rec_on n (coprime_one_left _) (λn IH, IH.mul H1)
theorem coprime.pow_right {m k : ℕ} (n : ℕ) (H1 : coprime k m) : coprime k (m ^ n) :=
(H1.symm.pow_left n).symm
theorem coprime.pow {k l : ℕ} (m n : ℕ) (H1 : coprime k l) : coprime (k ^ m) (l ^ n) :=
(H1.pow_left _).pow_right _
theorem coprime.eq_one_of_dvd {k m : ℕ} (H : coprime k m) (d : k ∣ m) : k = 1 :=
by rw [← H.gcd_eq_one, gcd_eq_left d]
@[simp] theorem coprime_zero_left (n : ℕ) : coprime 0 n ↔ n = 1 :=
by simp [coprime]
@[simp] theorem coprime_zero_right (n : ℕ) : coprime n 0 ↔ n = 1 :=
by simp [coprime]
@[simp] theorem coprime_one_left_iff (n : ℕ) : coprime 1 n ↔ true :=
by simp [coprime]
@[simp] theorem coprime_one_right_iff (n : ℕ) : coprime n 1 ↔ true :=
by simp [coprime]
@[simp] theorem coprime_self (n : ℕ) : coprime n n ↔ n = 1 :=
by simp [coprime]
theorem exists_eq_prod_and_dvd_and_dvd {m n k : ℕ} (H : k ∣ m * n) :
∃ m' n', k = m' * n' ∧ m' ∣ m ∧ n' ∣ n :=
or.elim (eq_zero_or_pos (gcd k m))
(λg0, ⟨0, n,
by rw [zero_mul, eq_zero_of_gcd_eq_zero_left g0],
by rw [eq_zero_of_gcd_eq_zero_right g0]; apply dvd_zero, dvd_refl _⟩)
(λgpos, let hd := (nat.mul_div_cancel' (gcd_dvd_left k m)).symm in
⟨_, _, hd, gcd_dvd_right _ _,
dvd_of_mul_dvd_mul_left gpos $ by rw [←hd, ←gcd_mul_right]; exact
dvd_gcd (dvd_mul_right _ _) H⟩)
theorem pow_dvd_pow_iff {a b n : ℕ} (n0 : 0 < n) : a ^ n ∣ b ^ n ↔ a ∣ b :=
begin
refine ⟨λ h, _, λ h, pow_dvd_pow_of_dvd h _⟩,
cases eq_zero_or_pos (gcd a b) with g0 g0,
{ simp [eq_zero_of_gcd_eq_zero_right g0] },
rcases exists_coprime' g0 with ⟨g, a', b', g0', co, rfl, rfl⟩,
rw [mul_pow, mul_pow] at h,
replace h := dvd_of_mul_dvd_mul_right (pos_pow_of_pos _ g0') h,
have := pow_dvd_pow a' n0,
rw [pow_one, (co.pow n n).eq_one_of_dvd h] at this,
simp [eq_one_of_dvd_one this]
end
end nat
|
1ee79f641e46765b4233e64f007eb4c46f683e40 | 0845ae2ca02071debcfd4ac24be871236c01784f | /tests/lean/string_imp.lean | 06e9b4d466ec37bfe5adb3920bdb881a0bb1da35 | [
"Apache-2.0"
] | permissive | GaloisInc/lean4 | 74c267eb0e900bfaa23df8de86039483ecbd60b7 | 228ddd5fdcd98dd4e9c009f425284e86917938aa | refs/heads/master | 1,643,131,356,301 | 1,562,715,572,000 | 1,562,715,572,000 | 192,390,898 | 0 | 0 | null | 1,560,792,750,000 | 1,560,792,749,000 | null | UTF-8 | Lean | false | false | 1,582 | lean | #exit -- Disabled until we implement new VM
#eval ("abc" ++ "cde").length
#eval "abc".popBack
#eval "".popBack
#eval "abcd".popBack
#eval ("abcd".mkIterator.nextn 2).remainingToString
#eval ("abcd".mkIterator.nextn 2).prevToString
#eval ("abcd".mkIterator.nextn 10).remainingToString
#eval ("abcd".mkIterator.nextn 10).prevToString
#eval "foo.Lean".popnBack 5
#eval "foo.Lean".backn 5
#eval "αβγ".popBack
#eval "αβ".length
#eval ("αβcc".mkIterator.next.insert "_foo_").toString
#eval ("αβcc".mkIterator.next.next.insert "_foo_").toString
#eval ("αβcc".mkIterator.next.next.prev.insert "_foo_").toString
#eval ("αβcc".mkIterator.remaining)
#eval ("αβcc".mkIterator.next.remaining)
#eval ("αβcc".mkIterator.next.insert "αbcβ").remaining
#eval (("αβcc".mkIterator.next.insert "αbcβ").remove 2).remaining
#eval (("αβcc".mkIterator.next.insert "αbcβ").remove 2).prev.remaining
#eval ("αβcc".mkIterator.next.toEnd).remaining
#eval "αβcc".mkIterator.offset
#eval "αβcc".mkIterator.next.offset
#eval "αβcc".mkIterator.next.next.offset
#eval ("αβcc".mkIterator.next.setCurr 'a').offset
#eval ("αβcc".mkIterator.next.insert "αbc").offset
#eval ("αβcc".mkIterator.next.insert "αbc").remaining
#eval ("αβcc".mkIterator.insert "αbc").offset
#eval ("αβcc".mkIterator.next.insert "αbcβ").offset
#eval "αβcd".mkIterator.toEnd.offset
#eval "ab\n\nfoo bla".lineColumn 0
#eval "ab\n\nfoo bla".lineColumn 1
#eval "ab\n\nfoo bla".lineColumn 2
#eval "ab\n\nfoo bla".lineColumn 3
#eval "ab\n\nfoo bla".lineColumn 8
#eval "ab\n\nfoo bla".lineColumn 100
|
a49faa8d11f655eefad2090bd976538aaf4642f1 | 4fa118f6209450d4e8d058790e2967337811b2b5 | /src/for_mathlib/group.lean | a73b0e8837fc944b67aa09195f03d47ecce38746 | [
"Apache-2.0"
] | permissive | leanprover-community/lean-perfectoid-spaces | 16ab697a220ed3669bf76311daa8c466382207f7 | 95a6520ce578b30a80b4c36e36ab2d559a842690 | refs/heads/master | 1,639,557,829,139 | 1,638,797,866,000 | 1,638,797,866,000 | 135,769,296 | 96 | 10 | Apache-2.0 | 1,638,797,866,000 | 1,527,892,754,000 | Lean | UTF-8 | Lean | false | false | 1,730 | lean | import algebra.group data.equiv.basic
import group_theory.subgroup
import group_theory.quotient_group
import for_mathlib.equiv
variables {G : Type*} [group G]
open quotient_group
-- this one lemma is not PR'ed yet.
def mul_equiv.quot_eq_of_eq {G1 : set G} [normal_subgroup G1] {G2 : set G} [normal_subgroup G2]
(h : G1 = G2) : mul_equiv (quotient G1) (quotient G2) :=
{ to_fun := λ q, quotient.lift_on' q (quotient_group.mk : G → quotient G2) $
λ a b hab, quotient.sound'
begin
change a⁻¹ * b ∈ G1 at hab, rwa h at hab
end,
inv_fun := λ q, quotient.lift_on' q (quotient_group.mk : G → quotient G1) $
λ a b hab, quotient.sound'
begin
change a⁻¹ * b ∈ G2 at hab, rwa ←h at hab,
end,
left_inv := λ x, by induction x; refl,
right_inv := λ x, by induction x; refl,
map_mul' := λ a b, begin
let f : G → quotient G2 := quotient_group.mk,
have h2 := quotient_group.is_group_hom_quotient_lift G1 f,
have h3 := h2 (λ x hx, by rwa [←is_group_hom.mem_ker f, quotient_group.ker_mk G2, ←h]),
have h4 := h3.map_mul,
exact h4 a b,
end
}
variables {M : Type*} [monoid M]
lemma units.ext_inv (a b : units M) (h : a.inv = b.inv) : a = b :=
inv_inj $ units.ext h
-- is this true for non-commutative monoids?
-- KL: No, s := nat.pred, t := nat.succ, u := id
/-- produces a unit s from a proof that s divides a unit -/
def units.unit_of_mul_left_eq_unit {M : Type*} [comm_monoid M]
{s t : M} {u : units M}
(h : s * t = u) : units M :=
{ val := s,
inv := t * (u⁻¹ : units M),
val_inv := by {show s * (t * (u⁻¹ : units M)) = 1, rw [←mul_assoc, h], simp},
inv_val := by {show t * (u⁻¹ : units M) * s = 1, rw [mul_comm, ←mul_assoc, h], simp} }
|
ea468c14d07574a2a248efa7736ebfdd813a4831 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/lean/interactive/editAfterError.lean | aa28b67e868e51d21841e66f068af9450b83821e | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | leanprover/lean4 | 4bdf9790294964627eb9be79f5e8f6157780b4cc | f1f9dc0f2f531af3312398999d8b8303fa5f096b | refs/heads/master | 1,693,360,665,786 | 1,693,350,868,000 | 1,693,350,868,000 | 129,571,436 | 2,827 | 311 | Apache-2.0 | 1,694,716,156,000 | 1,523,760,560,000 | Lean | UTF-8 | Lean | false | false | 75 | lean | #check tru
#check fal
--^ insert: s
--^ collectDiagnostics
|
ea19cf91b241a4b05ba67037945657840155ed98 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/data/list/indexes.lean | bc47dbbec6dcff379657020fdfa7bc9fd52ac7f2 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 7,990 | lean | /-
Copyright (c) 2020 Jannis Limperg. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jannis Limperg
-/
import data.list.range
/-!
# Lemmas about list.*_with_index functions.
Some specification lemmas for `list.map_with_index`, `list.mmap_with_index`, `list.foldl_with_index`
and `list.foldr_with_index`.
-/
universes u v
open function
namespace list
variables {α : Type u} {β : Type v}
section map_with_index
@[simp] lemma map_with_index_nil {α β} (f : ℕ → α → β) :
map_with_index f [] = [] := rfl
lemma map_with_index_core_eq (l : list α) (f : ℕ → α → β) (n : ℕ) :
l.map_with_index_core f n = l.map_with_index (λ i a, f (i + n) a) :=
begin
induction l with hd tl hl generalizing f n,
{ simpa },
{ rw [map_with_index],
simp [map_with_index_core, hl, add_left_comm, add_assoc, add_comm] }
end
lemma map_with_index_eq_enum_map (l : list α) (f : ℕ → α → β) :
l.map_with_index f = l.enum.map (function.uncurry f) :=
begin
induction l with hd tl hl generalizing f,
{ simp [list.enum_eq_zip_range] },
{ rw [map_with_index, map_with_index_core, map_with_index_core_eq, hl],
simp [enum_eq_zip_range, range_succ_eq_map, zip_with_map_left,
map_uncurry_zip_eq_zip_with] }
end
@[simp] lemma map_with_index_cons {α β} (l : list α) (f : ℕ → α → β) (a : α) :
map_with_index f (a :: l) = f 0 a :: map_with_index (λ i, f (i + 1)) l :=
by simp [map_with_index_eq_enum_map, enum_eq_zip_range, map_uncurry_zip_eq_zip_with,
range_succ_eq_map, zip_with_map_left]
lemma map_with_index_append {α} (K L : list α) (f : ℕ → α → β) :
(K ++ L).map_with_index f = K.map_with_index f ++ L.map_with_index (λ i a, f (i + K.length) a) :=
begin
induction K with a J IH generalizing f,
{ simp },
{ simp [IH (λ i, f (i+1)), add_assoc], }
end
@[simp] lemma length_map_with_index {α β} (l : list α) (f : ℕ → α → β) :
(l.map_with_index f).length = l.length :=
begin
induction l with hd tl IH generalizing f,
{ simp },
{ simp [IH] }
end
@[simp] lemma nth_le_map_with_index {α β} (l : list α) (f : ℕ → α → β) (i : ℕ) (h : i < l.length)
(h' : i < (l.map_with_index f).length := h.trans_le (l.length_map_with_index f).ge):
(l.map_with_index f).nth_le i h' = f i (l.nth_le i h) :=
by simp [map_with_index_eq_enum_map, enum_eq_zip_range]
lemma map_with_index_eq_of_fn {α β} (l : list α) (f : ℕ → α → β) :
l.map_with_index f = of_fn (λ (i : fin l.length), f (i : ℕ) (l.nth_le i i.is_lt)) :=
begin
induction l with hd tl IH generalizing f,
{ simp },
{ simpa [IH] }
end
end map_with_index
section foldr_with_index
/-- Specification of `foldr_with_index_aux`. -/
def foldr_with_index_aux_spec (f : ℕ → α → β → β) (start : ℕ) (b : β)
(as : list α) : β :=
foldr (uncurry f) b $ enum_from start as
theorem foldr_with_index_aux_spec_cons (f : ℕ → α → β → β) (start b a as) :
foldr_with_index_aux_spec f start b (a :: as) =
f start a (foldr_with_index_aux_spec f (start + 1) b as) :=
rfl
theorem foldr_with_index_aux_eq_foldr_with_index_aux_spec (f : ℕ → α → β → β)
(start b as) :
foldr_with_index_aux f start b as = foldr_with_index_aux_spec f start b as :=
begin
induction as generalizing start,
{ refl },
{ simp only [foldr_with_index_aux, foldr_with_index_aux_spec_cons, *] }
end
theorem foldr_with_index_eq_foldr_enum (f : ℕ → α → β → β) (b : β) (as : list α) :
foldr_with_index f b as = foldr (uncurry f) b (enum as) :=
by simp only
[foldr_with_index, foldr_with_index_aux_spec,
foldr_with_index_aux_eq_foldr_with_index_aux_spec, enum]
end foldr_with_index
theorem indexes_values_eq_filter_enum (p : α → Prop) [decidable_pred p]
(as : list α) :
indexes_values p as = filter (p ∘ prod.snd) (enum as) :=
by simp [indexes_values, foldr_with_index_eq_foldr_enum, uncurry, filter_eq_foldr]
theorem find_indexes_eq_map_indexes_values (p : α → Prop) [decidable_pred p]
(as : list α) :
find_indexes p as = map prod.fst (indexes_values p as) :=
by simp only
[indexes_values_eq_filter_enum, map_filter_eq_foldr, find_indexes,
foldr_with_index_eq_foldr_enum, uncurry]
section foldl_with_index
/-- Specification of `foldl_with_index_aux`. -/
def foldl_with_index_aux_spec (f : ℕ → α → β → α) (start : ℕ) (a : α)
(bs : list β) : α :=
foldl (λ a (p : ℕ × β), f p.fst a p.snd) a $ enum_from start bs
theorem foldl_with_index_aux_spec_cons (f : ℕ → α → β → α) (start a b bs) :
foldl_with_index_aux_spec f start a (b :: bs) =
foldl_with_index_aux_spec f (start + 1) (f start a b) bs :=
rfl
theorem foldl_with_index_aux_eq_foldl_with_index_aux_spec (f : ℕ → α → β → α)
(start a bs) :
foldl_with_index_aux f start a bs = foldl_with_index_aux_spec f start a bs :=
begin
induction bs generalizing start a,
{ refl },
{ simp [foldl_with_index_aux, foldl_with_index_aux_spec_cons, *] }
end
theorem foldl_with_index_eq_foldl_enum (f : ℕ → α → β → α) (a : α) (bs : list β) :
foldl_with_index f a bs =
foldl (λ a (p : ℕ × β), f p.fst a p.snd) a (enum bs) :=
by simp only
[foldl_with_index, foldl_with_index_aux_spec,
foldl_with_index_aux_eq_foldl_with_index_aux_spec, enum]
end foldl_with_index
section mfold_with_index
variables {m : Type u → Type v} [monad m]
theorem mfoldr_with_index_eq_mfoldr_enum {α β} (f : ℕ → α → β → m β) (b : β) (as : list α) :
mfoldr_with_index f b as = mfoldr (uncurry f) b (enum as) :=
by simp only
[mfoldr_with_index, mfoldr_eq_foldr, foldr_with_index_eq_foldr_enum, uncurry]
theorem mfoldl_with_index_eq_mfoldl_enum [is_lawful_monad m] {α β}
(f : ℕ → β → α → m β) (b : β) (as : list α) :
mfoldl_with_index f b as =
mfoldl (λ b (p : ℕ × α), f p.fst b p.snd) b (enum as) :=
by rw [mfoldl_with_index, mfoldl_eq_foldl, foldl_with_index_eq_foldl_enum]
end mfold_with_index
section mmap_with_index
variables {m : Type u → Type v} [applicative m]
/-- Specification of `mmap_with_index_aux`. -/
def mmap_with_index_aux_spec {α β} (f : ℕ → α → m β) (start : ℕ) (as : list α) :
m (list β) :=
list.traverse (uncurry f) $ enum_from start as
-- Note: `traverse` the class method would require a less universe-polymorphic
-- `m : Type u → Type u`.
theorem mmap_with_index_aux_spec_cons {α β} (f : ℕ → α → m β) (start : ℕ)
(a : α) (as : list α) :
mmap_with_index_aux_spec f start (a :: as) =
list.cons <$> f start a <*> mmap_with_index_aux_spec f (start + 1) as :=
rfl
theorem mmap_with_index_aux_eq_mmap_with_index_aux_spec {α β} (f : ℕ → α → m β)
(start : ℕ) (as : list α) :
mmap_with_index_aux f start as = mmap_with_index_aux_spec f start as :=
begin
induction as generalizing start,
{ refl },
{ simp [mmap_with_index_aux, mmap_with_index_aux_spec_cons, *] }
end
theorem mmap_with_index_eq_mmap_enum {α β} (f : ℕ → α → m β) (as : list α) :
mmap_with_index f as = list.traverse (uncurry f) (enum as) :=
by simp only
[mmap_with_index, mmap_with_index_aux_spec,
mmap_with_index_aux_eq_mmap_with_index_aux_spec, enum ]
end mmap_with_index
section mmap_with_index'
variables {m : Type u → Type v} [applicative m] [is_lawful_applicative m]
theorem mmap_with_index'_aux_eq_mmap_with_index_aux {α} (f : ℕ → α → m punit)
(start : ℕ) (as : list α) :
mmap_with_index'_aux f start as =
mmap_with_index_aux f start as *> pure punit.star :=
by induction as generalizing start;
simp [mmap_with_index'_aux, mmap_with_index_aux, *, seq_right_eq, const, -comp_const]
with functor_norm
theorem mmap_with_index'_eq_mmap_with_index {α} (f : ℕ → α → m punit) (as : list α) :
mmap_with_index' f as = mmap_with_index f as *> pure punit.star :=
by apply mmap_with_index'_aux_eq_mmap_with_index_aux
end mmap_with_index'
end list
|
fab3c57b8556d067a1ed8525ebbe7f2d21998841 | 432d948a4d3d242fdfb44b81c9e1b1baacd58617 | /src/algebra/monoid_algebra.lean | d4c5f6cdd0ca98347dcc3adafebae10731172980 | [
"Apache-2.0"
] | permissive | JLimperg/aesop3 | 306cc6570c556568897ed2e508c8869667252e8a | a4a116f650cc7403428e72bd2e2c4cda300fe03f | refs/heads/master | 1,682,884,916,368 | 1,620,320,033,000 | 1,620,320,033,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 44,760 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Yury G. Kudryashov, Scott Morrison
-/
import algebra.algebra.basic
import linear_algebra.finsupp
/-!
# Monoid algebras
When the domain of a `finsupp` has a multiplicative or additive structure, we can define
a convolution product. To mathematicians this structure is known as the "monoid algebra",
i.e. the finite formal linear combinations over a given semiring of elements of the monoid.
The "group ring" ℤ[G] or the "group algebra" k[G] are typical uses.
In this file we define `monoid_algebra k G := G →₀ k`, and `add_monoid_algebra k G`
in the same way, and then define the convolution product on these.
When the domain is additive, this is used to define polynomials:
```
polynomial α := add_monoid_algebra ℕ α
mv_polynomial σ α := add_monoid_algebra (σ →₀ ℕ) α
```
When the domain is multiplicative, e.g. a group, this will be used to define the group ring.
## Implementation note
Unfortunately because additive and multiplicative structures both appear in both cases,
it doesn't appear to be possible to make much use of `to_additive`, and we just settle for
saying everything twice.
Similarly, I attempted to just define
`add_monoid_algebra k G := monoid_algebra k (multiplicative G)`, but the definitional equality
`multiplicative G = G` leaks through everywhere, and seems impossible to use.
-/
noncomputable theory
open_locale classical big_operators
open finset finsupp
universes u₁ u₂ u₃
variables (k : Type u₁) (G : Type u₂)
/-! ### Multiplicative monoids -/
section
variables [semiring k]
/--
The monoid algebra over a semiring `k` generated by the monoid `G`.
It is the type of finite formal `k`-linear combinations of terms of `G`,
endowed with the convolution product.
-/
@[derive [inhabited, add_comm_monoid, has_coe_to_fun]]
def monoid_algebra : Type (max u₁ u₂) := G →₀ k
end
namespace monoid_algebra
variables {k G}
section has_mul
variables [semiring k] [has_mul G]
/-- The product of `f g : monoid_algebra k G` is the finitely supported function
whose value at `a` is the sum of `f x * g y` over all pairs `x, y`
such that `x * y = a`. (Think of the group ring of a group.) -/
instance : has_mul (monoid_algebra k G) :=
⟨λf g, f.sum $ λa₁ b₁, g.sum $ λa₂ b₂, single (a₁ * a₂) (b₁ * b₂)⟩
lemma mul_def {f g : monoid_algebra k G} :
f * g = (f.sum $ λa₁ b₁, g.sum $ λa₂ b₂, single (a₁ * a₂) (b₁ * b₂)) :=
rfl
instance : distrib (monoid_algebra k G) :=
{ mul := (*),
add := (+),
left_distrib := assume f g h, by simp only [mul_def, sum_add_index, mul_add, mul_zero,
single_zero, single_add, eq_self_iff_true, forall_true_iff, forall_3_true_iff, sum_add],
right_distrib := assume f g h, by simp only [mul_def, sum_add_index, add_mul, mul_zero, zero_mul,
single_zero, single_add, eq_self_iff_true, forall_true_iff, forall_3_true_iff, sum_zero,
sum_add],
.. finsupp.add_comm_monoid }
instance : mul_zero_class (monoid_algebra k G) :=
{ zero := 0,
mul := (*),
zero_mul := assume f, by simp only [mul_def, sum_zero_index],
mul_zero := assume f, by simp only [mul_def, sum_zero_index, sum_zero] }
end has_mul
section semigroup
variables [semiring k] [semigroup G]
instance : semigroup_with_zero (monoid_algebra k G) :=
{ mul := (*),
mul_assoc := assume f g h, by simp only [mul_def, sum_sum_index, sum_zero_index, sum_add_index,
sum_single_index, single_zero, single_add, eq_self_iff_true, forall_true_iff, forall_3_true_iff,
add_mul, mul_add, add_assoc, mul_assoc, zero_mul, mul_zero, sum_zero, sum_add],
.. monoid_algebra.mul_zero_class }
end semigroup
section has_one
variables [semiring k] [has_one G]
/-- The unit of the multiplication is `single 1 1`, i.e. the function
that is `1` at `1` and zero elsewhere. -/
instance : has_one (monoid_algebra k G) :=
⟨single 1 1⟩
lemma one_def : (1 : monoid_algebra k G) = single 1 1 :=
rfl
end has_one
section mul_one_class
variables [semiring k] [mul_one_class G]
instance : mul_zero_one_class (monoid_algebra k G) :=
{ one := 1,
mul := (*),
one_mul := assume f, by simp only [mul_def, one_def, sum_single_index, zero_mul,
single_zero, sum_zero, zero_add, one_mul, sum_single],
mul_one := assume f, by simp only [mul_def, one_def, sum_single_index, mul_zero,
single_zero, sum_zero, add_zero, mul_one, sum_single],
..monoid_algebra.mul_zero_class }
variables {R : Type*} [semiring R]
/-- A non-commutative version of `monoid_algebra.lift`: given a additive homomorphism `f : k →+ R`
and a multiplicative monoid homomorphism `g : G →* R`, returns the additive homomorphism from
`monoid_algebra k G` such that `lift_nc f g (single a b) = f b * g a`. If `f` is a ring homomorphism
and the range of either `f` or `g` is in center of `R`, then the result is a ring homomorphism. If
`R` is a `k`-algebra and `f = algebra_map k R`, then the result is an algebra homomorphism called
`monoid_algebra.lift`. -/
def lift_nc (f : k →+ R) (g : G →* R) : monoid_algebra k G →+ R :=
lift_add_hom (λ x : G, (add_monoid_hom.mul_right (g x)).comp f)
@[simp] lemma lift_nc_single (f : k →+ R) (g : G →* R) (a : G) (b : k) :
lift_nc f g (single a b) = f b * g a :=
lift_add_hom_apply_single _ _ _
@[simp] lemma lift_nc_one (f : k →+* R) (g : G →* R) : lift_nc (f : k →+ R) g 1 = 1 :=
by simp [one_def]
lemma lift_nc_mul (f : k →+* R) (g : G →* R)
(a b : monoid_algebra k G) (h_comm : ∀ {x y}, y ∈ a.support → commute (f (b x)) (g y)) :
lift_nc (f : k →+ R) g (a * b) = lift_nc (f : k →+ R) g a * lift_nc (f : k →+ R) g b :=
begin
conv_rhs { rw [← sum_single a, ← sum_single b] },
simp_rw [mul_def, (lift_nc _ g).map_finsupp_sum, lift_nc_single, finsupp.sum_mul,
finsupp.mul_sum],
refine finset.sum_congr rfl (λ y hy, finset.sum_congr rfl (λ x hx, _)),
simp [mul_assoc, (h_comm hy).left_comm]
end
end mul_one_class
/-! #### Semiring structure -/
section semiring
variables [semiring k] [monoid G]
instance : semiring (monoid_algebra k G) :=
{ one := 1,
mul := (*),
zero := 0,
add := (+),
.. monoid_algebra.mul_zero_one_class,
.. monoid_algebra.semigroup_with_zero,
.. monoid_algebra.distrib,
.. finsupp.add_comm_monoid }
variables {R : Type*} [semiring R]
/-- `lift_nc` as a `ring_hom`, for when `f x` and `g y` commute -/
def lift_nc_ring_hom (f : k →+* R) (g : G →* R) (h_comm : ∀ x y, commute (f x) (g y)) :
monoid_algebra k G →+* R :=
{ to_fun := lift_nc (f : k →+ R) g,
map_one' := lift_nc_one _ _,
map_mul' := λ a b, lift_nc_mul _ _ _ _ $ λ _ _ _, h_comm _ _,
..(lift_nc (f : k →+ R) g)}
end semiring
instance [comm_semiring k] [comm_monoid G] : comm_semiring (monoid_algebra k G) :=
{ mul_comm := assume f g,
begin
simp only [mul_def, finsupp.sum, mul_comm],
rw [finset.sum_comm],
simp only [mul_comm]
end,
.. monoid_algebra.semiring }
instance [semiring k] [nontrivial k] [nonempty G]: nontrivial (monoid_algebra k G) :=
finsupp.nontrivial
/-! #### Derived instances -/
section derived_instances
instance [semiring k] [subsingleton k] : unique (monoid_algebra k G) :=
finsupp.unique_of_right
instance [ring k] : add_group (monoid_algebra k G) :=
finsupp.add_group
instance [ring k] [monoid G] : ring (monoid_algebra k G) :=
{ neg := has_neg.neg,
add_left_neg := add_left_neg,
.. monoid_algebra.semiring }
instance [comm_ring k] [comm_monoid G] : comm_ring (monoid_algebra k G) :=
{ mul_comm := mul_comm, .. monoid_algebra.ring}
variables {R S : Type*}
instance [semiring R] [semiring k] [module R k] :
has_scalar R (monoid_algebra k G) :=
finsupp.has_scalar
instance [semiring R] [semiring k] [module R k] :
module R (monoid_algebra k G) :=
finsupp.module G k
instance [semiring R] [semiring S] [semiring k] [module R k] [module S k]
[has_scalar R S] [is_scalar_tower R S k] :
is_scalar_tower R S (monoid_algebra k G) :=
finsupp.is_scalar_tower G k
instance [semiring R] [semiring S] [semiring k] [module R k] [module S k]
[smul_comm_class R S k] :
smul_comm_class R S (monoid_algebra k G) :=
finsupp.smul_comm_class G k
instance [group G] [semiring k] : distrib_mul_action G (monoid_algebra k G) :=
finsupp.comap_distrib_mul_action_self
end derived_instances
section misc_theorems
variables [semiring k]
local attribute [reducible] monoid_algebra
lemma mul_apply [has_mul G] (f g : monoid_algebra k G) (x : G) :
(f * g) x = (f.sum $ λa₁ b₁, g.sum $ λa₂ b₂, if a₁ * a₂ = x then b₁ * b₂ else 0) :=
begin
rw [mul_def],
simp only [finsupp.sum_apply, single_apply],
end
lemma mul_apply_antidiagonal [has_mul G] (f g : monoid_algebra k G) (x : G) (s : finset (G × G))
(hs : ∀ {p : G × G}, p ∈ s ↔ p.1 * p.2 = x) :
(f * g) x = ∑ p in s, (f p.1 * g p.2) :=
let F : G × G → k := λ p, if p.1 * p.2 = x then f p.1 * g p.2 else 0 in
calc (f * g) x = (∑ a₁ in f.support, ∑ a₂ in g.support, F (a₁, a₂)) :
mul_apply f g x
... = ∑ p in f.support.product g.support, F p : finset.sum_product.symm
... = ∑ p in (f.support.product g.support).filter (λ p : G × G, p.1 * p.2 = x), f p.1 * g p.2 :
(finset.sum_filter _ _).symm
... = ∑ p in s.filter (λ p : G × G, p.1 ∈ f.support ∧ p.2 ∈ g.support), f p.1 * g p.2 :
sum_congr (by { ext, simp only [mem_filter, mem_product, hs, and_comm] }) (λ _ _, rfl)
... = ∑ p in s, f p.1 * g p.2 : sum_subset (filter_subset _ _) $ λ p hps hp,
begin
simp only [mem_filter, mem_support_iff, not_and, not_not] at hp ⊢,
by_cases h1 : f p.1 = 0,
{ rw [h1, zero_mul] },
{ rw [hp hps h1, mul_zero] }
end
lemma support_mul [has_mul G] (a b : monoid_algebra k G) :
(a * b).support ⊆ a.support.bUnion (λa₁, b.support.bUnion $ λa₂, {a₁ * a₂}) :=
subset.trans support_sum $ bUnion_mono $ assume a₁ _,
subset.trans support_sum $ bUnion_mono $ assume a₂ _, support_single_subset
@[simp] lemma single_mul_single [has_mul G] {a₁ a₂ : G} {b₁ b₂ : k} :
(single a₁ b₁ : monoid_algebra k G) * single a₂ b₂ = single (a₁ * a₂) (b₁ * b₂) :=
(sum_single_index (by simp only [zero_mul, single_zero, sum_zero])).trans
(sum_single_index (by rw [mul_zero, single_zero]))
@[simp] lemma single_pow [monoid G] {a : G} {b : k} :
∀ n : ℕ, (single a b : monoid_algebra k G)^n = single (a^n) (b ^ n)
| 0 := by { simp only [pow_zero], refl }
| (n+1) := by simp only [pow_succ, single_pow n, single_mul_single]
section
/-- Like `finsupp.map_domain_add`, but for the convolutive multiplication we define in this file -/
lemma map_domain_mul {α : Type*} {β : Type*} {α₂ : Type*} [semiring β] [has_mul α] [has_mul α₂]
{x y : monoid_algebra β α} (f : mul_hom α α₂) :
(map_domain f (x * y : monoid_algebra β α) : monoid_algebra β α₂) =
(map_domain f x * map_domain f y : monoid_algebra β α₂) :=
begin
simp_rw [mul_def, map_domain_sum, map_domain_single, f.map_mul],
rw finsupp.sum_map_domain_index,
{ congr,
ext a b,
rw finsupp.sum_map_domain_index,
{ simp },
{ simp [mul_add] } },
{ simp },
{ simp [add_mul] }
end
variables (k G) [mul_one_class G]
/-- Embedding of a monoid into its monoid algebra. -/
def of : G →* monoid_algebra k G :=
{ to_fun := λ a, single a 1,
map_one' := rfl,
map_mul' := λ a b, by rw [single_mul_single, one_mul] }
end
@[simp] lemma of_apply [mul_one_class G] (a : G) : of k G a = single a 1 := rfl
lemma of_injective [mul_one_class G] [nontrivial k] : function.injective (of k G) :=
λ a b h, by simpa using (single_eq_single_iff _ _ _ _).mp h
lemma mul_single_apply_aux [has_mul G] (f : monoid_algebra k G) {r : k}
{x y z : G} (H : ∀ a, a * x = z ↔ a = y) :
(f * single x r) z = f y * r :=
have A : ∀ a₁ b₁, (single x r).sum (λ a₂ b₂, ite (a₁ * a₂ = z) (b₁ * b₂) 0) =
ite (a₁ * x = z) (b₁ * r) 0,
from λ a₁ b₁, sum_single_index $ by simp,
calc (f * single x r) z = sum f (λ a b, if (a = y) then (b * r) else 0) :
-- different `decidable` instances make it not trivial
by { simp only [mul_apply, A, H], congr, funext, split_ifs; refl }
... = if y ∈ f.support then f y * r else 0 : f.support.sum_ite_eq' _ _
... = f y * r : by split_ifs with h; simp at h; simp [h]
lemma mul_single_one_apply [mul_one_class G] (f : monoid_algebra k G) (r : k) (x : G) :
(f * single 1 r) x = f x * r :=
f.mul_single_apply_aux $ λ a, by rw [mul_one]
lemma single_mul_apply_aux [has_mul G] (f : monoid_algebra k G) {r : k} {x y z : G}
(H : ∀ a, x * a = y ↔ a = z) :
(single x r * f) y = r * f z :=
have f.sum (λ a b, ite (x * a = y) (0 * b) 0) = 0, by simp,
calc (single x r * f) y = sum f (λ a b, ite (x * a = y) (r * b) 0) :
(mul_apply _ _ _).trans $ sum_single_index this
... = f.sum (λ a b, ite (a = z) (r * b) 0) :
by { simp only [H], congr' with g s, split_ifs; refl }
... = if z ∈ f.support then (r * f z) else 0 : f.support.sum_ite_eq' _ _
... = _ : by split_ifs with h; simp at h; simp [h]
lemma single_one_mul_apply [mul_one_class G] (f : monoid_algebra k G) (r : k) (x : G) :
(single 1 r * f) x = r * f x :=
f.single_mul_apply_aux $ λ a, by rw [one_mul]
lemma lift_nc_smul [mul_one_class G] {R : Type*} [semiring R] (f : k →+* R) (g : G →* R) (c : k)
(φ : monoid_algebra k G) :
lift_nc (f : k →+ R) g (c • φ) = f c * lift_nc (f : k →+ R) g φ :=
begin
suffices : (lift_nc ↑f g).comp (smul_add_hom k (monoid_algebra k G) c) =
(add_monoid_hom.mul_left (f c)).comp (lift_nc ↑f g),
from add_monoid_hom.congr_fun this φ,
ext a b, simp [mul_assoc]
end
end misc_theorems
/-! #### Algebra structure -/
section algebra
local attribute [reducible] monoid_algebra
lemma single_one_comm [comm_semiring k] [mul_one_class G] (r : k) (f : monoid_algebra k G) :
single 1 r * f = f * single 1 r :=
by { ext, rw [single_one_mul_apply, mul_single_one_apply, mul_comm] }
/-- `finsupp.single 1` as a `ring_hom` -/
@[simps] def single_one_ring_hom [semiring k] [monoid G] : k →+* monoid_algebra k G :=
{ map_one' := rfl,
map_mul' := λ x y, by rw [single_add_hom, single_mul_single, one_mul],
..finsupp.single_add_hom 1}
/-- If two ring homomorphisms from `monoid_algebra k G` are equal on all `single a 1`
and `single 1 b`, then they are equal. -/
lemma ring_hom_ext {R} [semiring k] [monoid G] [semiring R]
{f g : monoid_algebra k G →+* R} (h₁ : ∀ b, f (single 1 b) = g (single 1 b))
(h_of : ∀ a, f (single a 1) = g (single a 1)) : f = g :=
ring_hom.coe_add_monoid_hom_injective $ add_hom_ext $ λ a b,
by rw [← one_mul a, ← mul_one b, ← single_mul_single, f.coe_add_monoid_hom,
g.coe_add_monoid_hom, f.map_mul, g.map_mul, h₁, h_of]
/-- If two ring homomorphisms from `monoid_algebra k G` are equal on all `single a 1`
and `single 1 b`, then they are equal.
See note [partially-applied ext lemmas]. -/
@[ext] lemma ring_hom_ext' {R} [semiring k] [monoid G] [semiring R]
{f g : monoid_algebra k G →+* R} (h₁ : f.comp single_one_ring_hom = g.comp single_one_ring_hom)
(h_of : (f : monoid_algebra k G →* R).comp (of k G) =
(g : monoid_algebra k G →* R).comp (of k G)) :
f = g :=
ring_hom_ext (ring_hom.congr_fun h₁) (monoid_hom.congr_fun h_of)
/--
The instance `algebra k (monoid_algebra A G)` whenever we have `algebra k A`.
In particular this provides the instance `algebra k (monoid_algebra k G)`.
-/
instance {A : Type*} [comm_semiring k] [semiring A] [algebra k A] [monoid G] :
algebra k (monoid_algebra A G) :=
{ smul_def' := λ r a, by { ext, simp [single_one_mul_apply, algebra.smul_def'', pi.smul_apply], },
commutes' := λ r f, by { ext, simp [single_one_mul_apply, mul_single_one_apply,
algebra.commutes], },
..single_one_ring_hom.comp (algebra_map k A) }
/-- `finsupp.single 1` as a `alg_hom` -/
@[simps]
def single_one_alg_hom {A : Type*} [comm_semiring k] [semiring A] [algebra k A] [monoid G] :
A →ₐ[k] monoid_algebra A G :=
{ commutes' := λ r, by { ext, simp, refl, }, ..single_one_ring_hom}
@[simp] lemma coe_algebra_map {A : Type*} [comm_semiring k] [semiring A] [algebra k A] [monoid G] :
⇑(algebra_map k (monoid_algebra A G)) = single 1 ∘ (algebra_map k A) :=
rfl
lemma single_eq_algebra_map_mul_of [comm_semiring k] [monoid G] (a : G) (b : k) :
single a b = algebra_map k (monoid_algebra k G) b * of k G a :=
by simp
lemma single_algebra_map_eq_algebra_map_mul_of {A : Type*} [comm_semiring k] [semiring A]
[algebra k A] [monoid G] (a : G) (b : k) :
single a (algebra_map k A b) = algebra_map k (monoid_algebra A G) b * of A G a :=
by simp
lemma induction_on [semiring k] [monoid G] {p : monoid_algebra k G → Prop} (f : monoid_algebra k G)
(hM : ∀ g, p (of k G g)) (hadd : ∀ f g : monoid_algebra k G, p f → p g → p (f + g))
(hsmul : ∀ (r : k) f, p f → p (r • f)) : p f :=
begin
refine finsupp.induction_linear f _ (λ f g hf hg, hadd f g hf hg) (λ g r, _),
{ simpa using hsmul 0 (of k G 1) (hM 1) },
{ convert hsmul r (of k G g) (hM g),
simp only [mul_one, smul_single', of_apply] },
end
end algebra
section lift
variables {k G} [comm_semiring k] [monoid G]
variables {A : Type u₃} [semiring A] [algebra k A] {B : Type*} [semiring B] [algebra k B]
/-- `lift_nc_ring_hom` as a `alg_hom`, for when `f` is an `alg_hom` -/
def lift_nc_alg_hom (f : A →ₐ[k] B) (g : G →* B) (h_comm : ∀ x y, commute (f x) (g y)) :
monoid_algebra A G →ₐ[k] B :=
{ to_fun := lift_nc_ring_hom (f : A →+* B) g h_comm,
commutes' := by simp [lift_nc_ring_hom],
..(lift_nc_ring_hom (f : A →+* B) g h_comm)}
/-- A `k`-algebra homomorphism from `monoid_algebra k G` is uniquely defined by its
values on the functions `single a 1`. -/
lemma alg_hom_ext ⦃φ₁ φ₂ : monoid_algebra k G →ₐ[k] A⦄
(h : ∀ x, φ₁ (single x 1) = φ₂ (single x 1)) : φ₁ = φ₂ :=
alg_hom.to_linear_map_inj $ finsupp.lhom_ext' $ λ a, linear_map.ext_ring (h a)
/-- See note [partially-applied ext lemmas]. -/
@[ext] lemma alg_hom_ext' ⦃φ₁ φ₂ : monoid_algebra k G →ₐ[k] A⦄
(h : (φ₁ : monoid_algebra k G →* A).comp (of k G) =
(φ₂ : monoid_algebra k G →* A).comp (of k G)) : φ₁ = φ₂ :=
alg_hom_ext $ monoid_hom.congr_fun h
variables (k G A)
/-- Any monoid homomorphism `G →* A` can be lifted to an algebra homomorphism
`monoid_algebra k G →ₐ[k] A`. -/
def lift : (G →* A) ≃ (monoid_algebra k G →ₐ[k] A) :=
{ inv_fun := λ f, (f : monoid_algebra k G →* A).comp (of k G),
to_fun := λ F, lift_nc_alg_hom (algebra.of_id k A) F $ λ _ _, algebra.commutes _ _,
left_inv := λ f, by { ext, simp [lift_nc_alg_hom, lift_nc_ring_hom] },
right_inv := λ F, by { ext, simp [lift_nc_alg_hom, lift_nc_ring_hom] } }
variables {k G A}
lemma lift_apply' (F : G →* A) (f : monoid_algebra k G) :
lift k G A F f = f.sum (λ a b, (algebra_map k A b) * F a) := rfl
lemma lift_apply (F : G →* A) (f : monoid_algebra k G) :
lift k G A F f = f.sum (λ a b, b • F a) :=
by simp only [lift_apply', algebra.smul_def]
lemma lift_def (F : G →* A) :
⇑(lift k G A F) = lift_nc ((algebra_map k A : k →+* A) : k →+ A) F :=
rfl
@[simp] lemma lift_symm_apply (F : monoid_algebra k G →ₐ[k] A) (x : G) :
(lift k G A).symm F x = F (single x 1) := rfl
lemma lift_of (F : G →* A) (x) :
lift k G A F (of k G x) = F x :=
by rw [of_apply, ← lift_symm_apply, equiv.symm_apply_apply]
@[simp] lemma lift_single (F : G →* A) (a b) :
lift k G A F (single a b) = b • F a :=
by rw [lift_def, lift_nc_single, algebra.smul_def, ring_hom.coe_add_monoid_hom]
lemma lift_unique' (F : monoid_algebra k G →ₐ[k] A) :
F = lift k G A ((F : monoid_algebra k G →* A).comp (of k G)) :=
((lift k G A).apply_symm_apply F).symm
/-- Decomposition of a `k`-algebra homomorphism from `monoid_algebra k G` by
its values on `F (single a 1)`. -/
lemma lift_unique (F : monoid_algebra k G →ₐ[k] A) (f : monoid_algebra k G) :
F f = f.sum (λ a b, b • F (single a 1)) :=
by conv_lhs { rw lift_unique' F, simp [lift_apply] }
end lift
section
local attribute [reducible] monoid_algebra
variables (k)
/-- When `V` is a `k[G]`-module, multiplication by a group element `g` is a `k`-linear map. -/
def group_smul.linear_map [monoid G] [comm_semiring k]
(V : Type u₃) [add_comm_monoid V] [module k V] [module (monoid_algebra k G) V]
[is_scalar_tower k (monoid_algebra k G) V] (g : G) :
V →ₗ[k] V :=
{ to_fun := λ v, (single g (1 : k) • v : V),
map_add' := λ x y, smul_add (single g (1 : k)) x y,
map_smul' := λ c x, smul_algebra_smul_comm _ _ _ }
@[simp]
lemma group_smul.linear_map_apply [monoid G] [comm_semiring k]
(V : Type u₃) [add_comm_monoid V] [module k V] [module (monoid_algebra k G) V]
[is_scalar_tower k (monoid_algebra k G) V] (g : G) (v : V) :
(group_smul.linear_map k V g) v = (single g (1 : k) • v : V) :=
rfl
section
variables {k}
variables [monoid G] [comm_semiring k] {V W : Type u₃}
[add_comm_monoid V] [module k V] [module (monoid_algebra k G) V]
[is_scalar_tower k (monoid_algebra k G) V]
[add_comm_monoid W] [module k W] [module (monoid_algebra k G) W]
[is_scalar_tower k (monoid_algebra k G) W]
(f : V →ₗ[k] W)
(h : ∀ (g : G) (v : V), f (single g (1 : k) • v : V) = (single g (1 : k) • (f v) : W))
include h
/-- Build a `k[G]`-linear map from a `k`-linear map and evidence that it is `G`-equivariant. -/
def equivariant_of_linear_of_comm : V →ₗ[monoid_algebra k G] W :=
{ to_fun := f,
map_add' := λ v v', by simp,
map_smul' := λ c v,
begin
apply finsupp.induction c,
{ simp, },
{ intros g r c' nm nz w,
simp only [add_smul, f.map_add, w, add_left_inj, single_eq_algebra_map_mul_of, ← smul_smul],
erw [algebra_map_smul (monoid_algebra k G) r, algebra_map_smul (monoid_algebra k G) r,
f.map_smul, h g v, of_apply],
all_goals { apply_instance } }
end, }
@[simp]
lemma equivariant_of_linear_of_comm_apply (v : V) : (equivariant_of_linear_of_comm f h) v = f v :=
rfl
end
end
section
universe ui
variable {ι : Type ui}
local attribute [reducible] monoid_algebra
lemma prod_single [comm_semiring k] [comm_monoid G]
{s : finset ι} {a : ι → G} {b : ι → k} :
(∏ i in s, single (a i) (b i)) = single (∏ i in s, a i) (∏ i in s, b i) :=
finset.induction_on s rfl $ λ a s has ih, by rw [prod_insert has, ih,
single_mul_single, prod_insert has, prod_insert has]
end
section -- We now prove some additional statements that hold for group algebras.
variables [semiring k] [group G]
local attribute [reducible] monoid_algebra
@[simp]
lemma mul_single_apply (f : monoid_algebra k G) (r : k) (x y : G) :
(f * single x r) y = f (y * x⁻¹) * r :=
f.mul_single_apply_aux $ λ a, eq_mul_inv_iff_mul_eq.symm
@[simp]
lemma single_mul_apply (r : k) (x : G) (f : monoid_algebra k G) (y : G) :
(single x r * f) y = r * f (x⁻¹ * y) :=
f.single_mul_apply_aux $ λ z, eq_inv_mul_iff_mul_eq.symm
lemma mul_apply_left (f g : monoid_algebra k G) (x : G) :
(f * g) x = (f.sum $ λ a b, b * (g (a⁻¹ * x))) :=
calc (f * g) x = sum f (λ a b, (single a b * g) x) :
by rw [← finsupp.sum_apply, ← finsupp.sum_mul, f.sum_single]
... = _ : by simp only [single_mul_apply, finsupp.sum]
-- If we'd assumed `comm_semiring`, we could deduce this from `mul_apply_left`.
lemma mul_apply_right (f g : monoid_algebra k G) (x : G) :
(f * g) x = (g.sum $ λa b, (f (x * a⁻¹)) * b) :=
calc (f * g) x = sum g (λ a b, (f * single a b) x) :
by rw [← finsupp.sum_apply, ← finsupp.mul_sum, g.sum_single]
... = _ : by simp only [mul_single_apply, finsupp.sum]
end
section span
variables [semiring k] [mul_one_class G]
lemma mem_span_support (f : monoid_algebra k G) :
f ∈ submodule.span k (of k G '' (f.support : set G)) :=
by rw [of, monoid_hom.coe_mk, ← finsupp.supported_eq_span_single, finsupp.mem_supported]
end span
end monoid_algebra
/-! ### Additive monoids -/
section
variables [semiring k]
/--
The monoid algebra over a semiring `k` generated by the additive monoid `G`.
It is the type of finite formal `k`-linear combinations of terms of `G`,
endowed with the convolution product.
-/
@[derive [inhabited, add_comm_monoid, has_coe_to_fun]]
def add_monoid_algebra := G →₀ k
end
namespace add_monoid_algebra
variables {k G}
section has_mul
variables [semiring k] [has_add G]
/-- The product of `f g : add_monoid_algebra k G` is the finitely supported function
whose value at `a` is the sum of `f x * g y` over all pairs `x, y`
such that `x + y = a`. (Think of the product of multivariate
polynomials where `α` is the additive monoid of monomial exponents.) -/
instance : has_mul (add_monoid_algebra k G) :=
⟨λf g, f.sum $ λa₁ b₁, g.sum $ λa₂ b₂, single (a₁ + a₂) (b₁ * b₂)⟩
lemma mul_def {f g : add_monoid_algebra k G} :
f * g = (f.sum $ λa₁ b₁, g.sum $ λa₂ b₂, single (a₁ + a₂) (b₁ * b₂)) :=
rfl
instance : distrib (add_monoid_algebra k G) :=
{ mul := (*),
add := (+),
left_distrib := assume f g h, by simp only [mul_def, sum_add_index, mul_add, mul_zero,
single_zero, single_add, eq_self_iff_true, forall_true_iff, forall_3_true_iff, sum_add],
right_distrib := assume f g h, by simp only [mul_def, sum_add_index, add_mul, mul_zero, zero_mul,
single_zero, single_add, eq_self_iff_true, forall_true_iff, forall_3_true_iff, sum_zero,
sum_add], }
instance : mul_zero_class (add_monoid_algebra k G) :=
{ zero := 0,
mul := (*),
zero_mul := assume f, by simp only [mul_def, sum_zero_index],
mul_zero := assume f, by simp only [mul_def, sum_zero_index, sum_zero] }
end has_mul
section has_one
variables [semiring k] [has_zero G]
/-- The unit of the multiplication is `single 1 1`, i.e. the function
that is `1` at `0` and zero elsewhere. -/
instance : has_one (add_monoid_algebra k G) :=
⟨single 0 1⟩
lemma one_def : (1 : add_monoid_algebra k G) = single 0 1 :=
rfl
end has_one
section semigroup
variables [semiring k] [add_semigroup G]
instance : semigroup_with_zero (add_monoid_algebra k G) :=
{ mul := (*),
mul_assoc := assume f g h, by simp only [mul_def, sum_sum_index, sum_zero_index, sum_add_index,
sum_single_index, single_zero, single_add, eq_self_iff_true, forall_true_iff, forall_3_true_iff,
add_mul, mul_add, add_assoc, mul_assoc, zero_mul, mul_zero, sum_zero, sum_add],
.. add_monoid_algebra.mul_zero_class }
end semigroup
section mul_one_class
variables [semiring k] [add_zero_class G]
instance : mul_zero_one_class (add_monoid_algebra k G) :=
{ one := 1,
mul := (*),
one_mul := assume f, by simp only [mul_def, one_def, sum_single_index, zero_mul,
single_zero, sum_zero, zero_add, one_mul, sum_single],
mul_one := assume f, by simp only [mul_def, one_def, sum_single_index, mul_zero,
single_zero, sum_zero, add_zero, mul_one, sum_single],
.. add_monoid_algebra.mul_zero_class }
variables {R : Type*} [semiring R]
/-- A non-commutative version of `add_monoid_algebra.lift`: given a additive homomorphism `f : k →+
R` and a multiplicative monoid homomorphism `g : multiplicative G →* R`, returns the additive
homomorphism from `add_monoid_algebra k G` such that `lift_nc f g (single a b) = f b * g a`. If `f`
is a ring homomorphism and the range of either `f` or `g` is in center of `R`, then the result is a
ring homomorphism. If `R` is a `k`-algebra and `f = algebra_map k R`, then the result is an algebra
homomorphism called `add_monoid_algebra.lift`. -/
def lift_nc (f : k →+ R) (g : multiplicative G →* R) : add_monoid_algebra k G →+ R :=
lift_add_hom (λ x : G, (add_monoid_hom.mul_right (g $ multiplicative.of_add x)).comp f)
@[simp] lemma lift_nc_single (f : k →+ R) (g : multiplicative G →* R) (a : G) (b : k) :
lift_nc f g (single a b) = f b * g (multiplicative.of_add a) :=
lift_add_hom_apply_single _ _ _
@[simp] lemma lift_nc_one (f : k →+* R) (g : multiplicative G →* R) :
lift_nc (f : k →+ R) g 1 = 1 :=
@monoid_algebra.lift_nc_one k (multiplicative G) _ _ _ _ f g
lemma lift_nc_mul (f : k →+* R) (g : multiplicative G →* R) (a b : add_monoid_algebra k G)
(h_comm : ∀ {x y}, y ∈ a.support → commute (f (b x)) (g $ multiplicative.of_add y)) :
lift_nc (f : k →+ R) g (a * b) = lift_nc (f : k →+ R) g a * lift_nc (f : k →+ R) g b :=
@monoid_algebra.lift_nc_mul k (multiplicative G) _ _ _ _ f g a b @h_comm
end mul_one_class
/-! #### Semiring structure -/
section semiring
instance {R : Type*} [semiring R] [semiring k] [module R k] :
has_scalar R (add_monoid_algebra k G) :=
finsupp.has_scalar
variables [semiring k] [add_monoid G]
instance : semiring (add_monoid_algebra k G) :=
{ one := 1,
mul := (*),
zero := 0,
add := (+),
nsmul := λ n f, n • f,
nsmul_zero' := by { intros, ext, simp [-nsmul_eq_mul, add_smul] },
nsmul_succ' := by { intros, ext, simp [-nsmul_eq_mul, nat.succ_eq_one_add, add_smul] },
.. add_monoid_algebra.mul_zero_one_class,
.. add_monoid_algebra.semigroup_with_zero,
.. add_monoid_algebra.distrib,
.. finsupp.add_comm_monoid }
variables {R : Type*} [semiring R]
/-- `lift_nc` as a `ring_hom`, for when `f` and `g` commute -/
def lift_nc_ring_hom (f : k →+* R) (g : multiplicative G →* R)
(h_comm : ∀ x y, commute (f x) (g y)) :
add_monoid_algebra k G →+* R :=
{ to_fun := lift_nc (f : k →+ R) g,
map_one' := lift_nc_one _ _,
map_mul' := λ a b, lift_nc_mul _ _ _ _ $ λ _ _ _, h_comm _ _,
..(lift_nc (f : k →+ R) g)}
end semiring
instance [comm_semiring k] [add_comm_monoid G] : comm_semiring (add_monoid_algebra k G) :=
{ mul_comm := @mul_comm (monoid_algebra k $ multiplicative G) _,
.. add_monoid_algebra.semiring }
instance [semiring k] [nontrivial k] [nonempty G] : nontrivial (add_monoid_algebra k G) :=
finsupp.nontrivial
/-! #### Derived instances -/
section derived_instances
instance [semiring k] [subsingleton k] : unique (add_monoid_algebra k G) :=
finsupp.unique_of_right
instance [ring k] : add_group (add_monoid_algebra k G) :=
finsupp.add_group
instance [ring k] [add_monoid G] : ring (add_monoid_algebra k G) :=
{ neg := has_neg.neg,
add_left_neg := add_left_neg,
sub := has_sub.sub,
sub_eq_add_neg := finsupp.add_group.sub_eq_add_neg,
.. add_monoid_algebra.semiring }
instance [comm_ring k] [add_comm_monoid G] : comm_ring (add_monoid_algebra k G) :=
{ mul_comm := mul_comm, .. add_monoid_algebra.ring}
variables {R S : Type*}
instance [semiring R] [semiring k] [module R k] : module R (add_monoid_algebra k G) :=
finsupp.module G k
instance [semiring R] [semiring S] [semiring k] [module R k] [module S k]
[has_scalar R S] [is_scalar_tower R S k] :
is_scalar_tower R S (add_monoid_algebra k G) :=
finsupp.is_scalar_tower G k
instance [semiring R] [semiring S] [semiring k] [module R k] [module S k]
[smul_comm_class R S k] :
smul_comm_class R S (add_monoid_algebra k G) :=
finsupp.smul_comm_class G k
/-! It is hard to state the equivalent of `distrib_mul_action G (add_monoid_algebra k G)`
because we've never discussed actions of additive groups. -/
end derived_instances
section misc_theorems
variables [semiring k]
lemma mul_apply [has_add G] (f g : add_monoid_algebra k G) (x : G) :
(f * g) x = (f.sum $ λa₁ b₁, g.sum $ λa₂ b₂, if a₁ + a₂ = x then b₁ * b₂ else 0) :=
@monoid_algebra.mul_apply k (multiplicative G) _ _ _ _ _
lemma mul_apply_antidiagonal [has_add G] (f g : add_monoid_algebra k G) (x : G) (s : finset (G × G))
(hs : ∀ {p : G × G}, p ∈ s ↔ p.1 + p.2 = x) :
(f * g) x = ∑ p in s, (f p.1 * g p.2) :=
@monoid_algebra.mul_apply_antidiagonal k (multiplicative G) _ _ _ _ _ s @hs
lemma support_mul [has_add G] (a b : add_monoid_algebra k G) :
(a * b).support ⊆ a.support.bUnion (λa₁, b.support.bUnion $ λa₂, {a₁ + a₂}) :=
@monoid_algebra.support_mul k (multiplicative G) _ _ _ _
lemma single_mul_single [has_add G] {a₁ a₂ : G} {b₁ b₂ : k} :
(single a₁ b₁ * single a₂ b₂ : add_monoid_algebra k G) = single (a₁ + a₂) (b₁ * b₂) :=
@monoid_algebra.single_mul_single k (multiplicative G) _ _ _ _ _ _
-- This should be a `@[simp]` lemma, but the simp_nf linter times out if we add this.
-- Probably the correct fix is to make a `[add_]monoid_algebra.single` with the correct type,
-- instead of relying on `finsupp.single`.
lemma single_pow [add_monoid G] {a : G} {b : k} :
∀ n : ℕ, ((single a b)^n : add_monoid_algebra k G) = single (n • a) (b ^ n)
| 0 := by { simp only [pow_zero, zero_nsmul], refl }
| (n+1) :=
by rw [pow_succ, pow_succ, single_pow n, single_mul_single, add_comm, add_nsmul, one_nsmul]
/-- Like `finsupp.map_domain_add`, but for the convolutive multiplication we define in this file -/
lemma map_domain_mul {α : Type*} {β : Type*} {α₂ : Type*}
[semiring β] [has_add α] [has_add α₂]
{x y : add_monoid_algebra β α} (f : add_hom α α₂) :
(map_domain f (x * y : add_monoid_algebra β α) : add_monoid_algebra β α₂) =
(map_domain f x * map_domain f y : add_monoid_algebra β α₂) :=
begin
simp_rw [mul_def, map_domain_sum, map_domain_single, f.map_add],
rw finsupp.sum_map_domain_index,
{ congr,
ext a b,
rw finsupp.sum_map_domain_index,
{ simp },
{ simp [mul_add] } },
{ simp },
{ simp [add_mul] }
end
section
variables (k G)
/-- Embedding of a monoid into its monoid algebra. -/
def of [add_zero_class G] : multiplicative G →* add_monoid_algebra k G :=
{ to_fun := λ a, single a 1,
map_one' := rfl,
map_mul' := λ a b, by { rw [single_mul_single, one_mul], refl } }
/-- Embedding of a monoid into its monoid algebra, having `G` as source. -/
def of' : G → add_monoid_algebra k G := λ a, single a 1
end
@[simp] lemma of_apply [add_zero_class G] (a : multiplicative G) : of k G a = single a.to_add 1 :=
rfl
@[simp] lemma of'_apply (a : G) : of' k G a = single a 1 := rfl
lemma of_injective [nontrivial k] [add_zero_class G] : function.injective (of k G) :=
λ a b h, by simpa using (single_eq_single_iff _ _ _ _).mp h
lemma mul_single_apply_aux [has_add G] (f : add_monoid_algebra k G) (r : k)
(x y z : G) (H : ∀ a, a + x = z ↔ a = y) :
(f * single x r) z = f y * r :=
@monoid_algebra.mul_single_apply_aux k (multiplicative G) _ _ _ _ _ _ _ H
lemma mul_single_zero_apply [add_zero_class G] (f : add_monoid_algebra k G) (r : k) (x : G) :
(f * single 0 r) x = f x * r :=
f.mul_single_apply_aux r _ _ _ $ λ a, by rw [add_zero]
lemma single_mul_apply_aux [has_add G] (f : add_monoid_algebra k G) (r : k) (x y z : G)
(H : ∀ a, x + a = y ↔ a = z) :
(single x r * f : add_monoid_algebra k G) y = r * f z :=
@monoid_algebra.single_mul_apply_aux k (multiplicative G) _ _ _ _ _ _ _ H
lemma single_zero_mul_apply [add_zero_class G] (f : add_monoid_algebra k G) (r : k) (x : G) :
(single 0 r * f : add_monoid_algebra k G) x = r * f x :=
f.single_mul_apply_aux r _ _ _ $ λ a, by rw [zero_add]
lemma lift_nc_smul {R : Type*} [add_zero_class G] [semiring R] (f : k →+* R)
(g : multiplicative G →* R) (c : k) (φ : monoid_algebra k G) :
lift_nc (f : k →+ R) g (c • φ) = f c * lift_nc (f : k →+ R) g φ :=
@monoid_algebra.lift_nc_smul k (multiplicative G) _ _ _ _ f g c φ
variables {k G}
lemma induction_on [add_monoid G] {p : add_monoid_algebra k G → Prop} (f : add_monoid_algebra k G)
(hM : ∀ g, p (of k G (multiplicative.of_add g)))
(hadd : ∀ f g : add_monoid_algebra k G, p f → p g → p (f + g))
(hsmul : ∀ (r : k) f, p f → p (r • f)) : p f :=
begin
refine finsupp.induction_linear f _ (λ f g hf hg, hadd f g hf hg) (λ g r, _),
{ simpa using hsmul 0 (of k G (multiplicative.of_add 0)) (hM 0) },
{ convert hsmul r (of k G (multiplicative.of_add g)) (hM g),
simp only [mul_one, to_add_of_add, smul_single', of_apply] },
end
end misc_theorems
section span
variables [semiring k]
lemma mem_span_support [add_zero_class G] (f : add_monoid_algebra k G) :
f ∈ submodule.span k (of k G '' (f.support : set G)) :=
by rw [of, monoid_hom.coe_mk, ← finsupp.supported_eq_span_single, finsupp.mem_supported]
lemma mem_span_support' (f : add_monoid_algebra k G) :
f ∈ submodule.span k (of' k G '' (f.support : set G)) :=
by rw [of', ← finsupp.supported_eq_span_single, finsupp.mem_supported]
end span
end add_monoid_algebra
/-!
#### Conversions between `add_monoid_algebra` and `monoid_algebra`
While we were not able to define `add_monoid_algebra k G = monoid_algebra k (multiplicative G)` due
to definitional inconveniences, we can still show the types are isomorphic.
TODO: with the new definitional `nsmul`, there is a direct equality here, so this paragraph could be
improved.
-/
/-- The equivalence between `add_monoid_algebra` and `monoid_algebra` in terms of
`multiplicative` -/
protected def add_monoid_algebra.to_multiplicative [semiring k] [has_add G] :
add_monoid_algebra k G ≃+* monoid_algebra k (multiplicative G) :=
{ map_mul' := λ x y, by convert add_monoid_algebra.map_domain_mul (add_hom.id G),
..finsupp.dom_congr multiplicative.of_add }
/-- The equivalence between `monoid_algebra` and `add_monoid_algebra` in terms of `additive` -/
protected def monoid_algebra.to_additive [semiring k] [has_mul G] :
monoid_algebra k G ≃+* add_monoid_algebra k (additive G) :=
{ map_mul' := λ x y, by convert monoid_algebra.map_domain_mul (mul_hom.id G),
..finsupp.dom_congr additive.of_mul }
namespace add_monoid_algebra
variables {k G}
/-! #### Algebra structure -/
section algebra
variables {R : Type*}
local attribute [reducible] add_monoid_algebra
/-- `finsupp.single 0` as a `ring_hom` -/
@[simps] def single_zero_ring_hom [semiring k] [add_monoid G] : k →+* add_monoid_algebra k G :=
{ map_one' := rfl,
map_mul' := λ x y, by rw [single_add_hom, single_mul_single, zero_add],
..finsupp.single_add_hom 0}
/-- If two ring homomorphisms from `add_monoid_algebra k G` are equal on all `single a 1`
and `single 0 b`, then they are equal. -/
lemma ring_hom_ext {R} [semiring k] [add_monoid G] [semiring R]
{f g : add_monoid_algebra k G →+* R} (h₀ : ∀ b, f (single 0 b) = g (single 0 b))
(h_of : ∀ a, f (single a 1) = g (single a 1)) : f = g :=
@monoid_algebra.ring_hom_ext k (multiplicative G) R _ _ _ _ _ h₀ h_of
/-- If two ring homomorphisms from `add_monoid_algebra k G` are equal on all `single a 1`
and `single 0 b`, then they are equal.
See note [partially-applied ext lemmas]. -/
@[ext] lemma ring_hom_ext' {R} [semiring k] [add_monoid G] [semiring R]
{f g : add_monoid_algebra k G →+* R}
(h₁ : f.comp single_zero_ring_hom = g.comp single_zero_ring_hom)
(h_of : (f : add_monoid_algebra k G →* R).comp (of k G) =
(g : add_monoid_algebra k G →* R).comp (of k G)) :
f = g :=
ring_hom_ext (ring_hom.congr_fun h₁) (monoid_hom.congr_fun h_of)
/--
The instance `algebra R (add_monoid_algebra k G)` whenever we have `algebra R k`.
In particular this provides the instance `algebra k (add_monoid_algebra k G)`.
-/
instance [comm_semiring R] [semiring k] [algebra R k] [add_monoid G] :
algebra R (add_monoid_algebra k G) :=
{ smul_def' := λ r a, by { ext, simp [single_zero_mul_apply, algebra.smul_def'', pi.smul_apply], },
commutes' := λ r f, by { ext, simp [single_zero_mul_apply, mul_single_zero_apply,
algebra.commutes], },
..single_zero_ring_hom.comp (algebra_map R k) }
/-- `finsupp.single 0` as a `alg_hom` -/
@[simps] def single_zero_alg_hom [comm_semiring R] [semiring k] [algebra R k] [add_monoid G] :
k →ₐ[R] add_monoid_algebra k G :=
{ commutes' := λ r, by { ext, simp, refl, }, ..single_zero_ring_hom}
@[simp] lemma coe_algebra_map [comm_semiring R] [semiring k] [algebra R k] [add_monoid G] :
(algebra_map R (add_monoid_algebra k G) : R → add_monoid_algebra k G) =
single 0 ∘ (algebra_map R k) :=
rfl
end algebra
section lift
variables {k G} [comm_semiring k] [add_monoid G]
variables {A : Type u₃} [semiring A] [algebra k A] {B : Type*} [semiring B] [algebra k B]
/-- `lift_nc_ring_hom` as a `alg_hom`, for when `f` is an `alg_hom` -/
def lift_nc_alg_hom (f : A →ₐ[k] B) (g : multiplicative G →* B)
(h_comm : ∀ x y, commute (f x) (g y)) :
add_monoid_algebra A G →ₐ[k] B :=
{ to_fun := lift_nc_ring_hom (f : A →+* B) g h_comm,
commutes' := by simp [lift_nc_ring_hom],
..(lift_nc_ring_hom (f : A →+* B) g h_comm)}
/-- A `k`-algebra homomorphism from `monoid_algebra k G` is uniquely defined by its
values on the functions `single a 1`. -/
lemma alg_hom_ext ⦃φ₁ φ₂ : add_monoid_algebra k G →ₐ[k] A⦄
(h : ∀ x, φ₁ (single x 1) = φ₂ (single x 1)) : φ₁ = φ₂ :=
@monoid_algebra.alg_hom_ext k (multiplicative G) _ _ _ _ _ _ _ h
/-- See note [partially-applied ext lemmas]. -/
@[ext] lemma alg_hom_ext' ⦃φ₁ φ₂ : add_monoid_algebra k G →ₐ[k] A⦄
(h : (φ₁ : add_monoid_algebra k G →* A).comp (of k G) =
(φ₂ : add_monoid_algebra k G →* A).comp (of k G)) : φ₁ = φ₂ :=
alg_hom_ext $ monoid_hom.congr_fun h
variables (k G A)
/-- Any monoid homomorphism `G →* A` can be lifted to an algebra homomorphism
`monoid_algebra k G →ₐ[k] A`. -/
def lift : (multiplicative G →* A) ≃ (add_monoid_algebra k G →ₐ[k] A) :=
{ inv_fun := λ f, (f : add_monoid_algebra k G →* A).comp (of k G),
to_fun := λ F, {
to_fun := lift_nc_alg_hom (algebra.of_id k A) F $ λ _ _, algebra.commutes _ _,
.. @monoid_algebra.lift k (multiplicative G) _ _ A _ _ F},
.. @monoid_algebra.lift k (multiplicative G) _ _ A _ _ }
variables {k G A}
lemma lift_apply' (F : multiplicative G →* A) (f : monoid_algebra k G) :
lift k G A F f = f.sum (λ a b, (algebra_map k A b) * F (multiplicative.of_add a)) := rfl
lemma lift_apply (F : multiplicative G →* A) (f : monoid_algebra k G) :
lift k G A F f = f.sum (λ a b, b • F (multiplicative.of_add a)) :=
by simp only [lift_apply', algebra.smul_def]
lemma lift_def (F : multiplicative G →* A) :
⇑(lift k G A F) = lift_nc ((algebra_map k A : k →+* A) : k →+ A) F :=
rfl
@[simp] lemma lift_symm_apply (F : add_monoid_algebra k G →ₐ[k] A) (x : multiplicative G) :
(lift k G A).symm F x = F (single x.to_add 1) := rfl
lemma lift_of (F : multiplicative G →* A) (x : multiplicative G) :
lift k G A F (of k G x) = F x :=
by rw [of_apply, ← lift_symm_apply, equiv.symm_apply_apply]
@[simp] lemma lift_single (F : multiplicative G →* A) (a b) :
lift k G A F (single a b) = b • F (multiplicative.of_add a) :=
by rw [lift_def, lift_nc_single, algebra.smul_def, ring_hom.coe_add_monoid_hom]
lemma lift_unique' (F : add_monoid_algebra k G →ₐ[k] A) :
F = lift k G A ((F : add_monoid_algebra k G →* A).comp (of k G)) :=
((lift k G A).apply_symm_apply F).symm
/-- Decomposition of a `k`-algebra homomorphism from `monoid_algebra k G` by
its values on `F (single a 1)`. -/
lemma lift_unique (F : add_monoid_algebra k G →ₐ[k] A) (f : monoid_algebra k G) :
F f = f.sum (λ a b, b • F (single a 1)) :=
by conv_lhs { rw lift_unique' F, simp [lift_apply] }
lemma alg_hom_ext_iff {φ₁ φ₂ : add_monoid_algebra k G →ₐ[k] A} :
(∀ x, φ₁ (finsupp.single x 1) = φ₂ (finsupp.single x 1)) ↔ φ₁ = φ₂ :=
⟨λ h, alg_hom_ext h, by rintro rfl _; refl⟩
end lift
section
local attribute [reducible] add_monoid_algebra
universe ui
variable {ι : Type ui}
lemma prod_single [comm_semiring k] [add_comm_monoid G]
{s : finset ι} {a : ι → G} {b : ι → k} :
(∏ i in s, single (a i) (b i)) = single (∑ i in s, a i) (∏ i in s, b i) :=
finset.induction_on s rfl $ λ a s has ih, by rw [prod_insert has, ih,
single_mul_single, sum_insert has, prod_insert has]
end
end add_monoid_algebra
variables {R : Type*} [comm_semiring R] (k G)
/-- The algebra equivalence between `add_monoid_algebra` and `monoid_algebra` in terms of
`multiplicative`. -/
def add_monoid_algebra.to_multiplicative_alg_equiv [semiring k] [algebra R k] [add_monoid G] :
add_monoid_algebra k G ≃ₐ[R] monoid_algebra k (multiplicative G) :=
{ commutes' := λ r, by simp [add_monoid_algebra.to_multiplicative],
..add_monoid_algebra.to_multiplicative k G }
/-- The algebra equivalence between `monoid_algebra` and `add_monoid_algebra` in terms of
`additive`. -/
def monoid_algebra.to_additive_alg_equiv [semiring k] [algebra R k] [monoid G] :
monoid_algebra k G ≃ₐ[R] add_monoid_algebra k (additive G) :=
{ commutes' := λ r, by simp [monoid_algebra.to_additive],
..monoid_algebra.to_additive k G }
|
4955958792226d81c9da1e9f6906fd4b9448c389 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/logic/unique.lean | 5384a49f64e38f90a6597c22da6259596cee9e0e | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 8,296 | lean | /-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import tactic.basic
import logic.is_empty
/-!
# Types with a unique term
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
In this file we define a typeclass `unique`,
which expresses that a type has a unique term.
In other words, a type that is `inhabited` and a `subsingleton`.
## Main declaration
* `unique`: a typeclass that expresses that a type has a unique term.
## Main statements
* `unique.mk'`: an inhabited subsingleton type is `unique`. This can not be an instance because it
would lead to loops in typeclass inference.
* `function.surjective.unique`: if the domain of a surjective function is `unique`, then its
codomain is `unique` as well.
* `function.injective.subsingleton`: if the codomain of an injective function is `subsingleton`,
then its domain is `subsingleton` as well.
* `function.injective.unique`: if the codomain of an injective function is `subsingleton` and its
domain is `inhabited`, then its domain is `unique`.
## Implementation details
The typeclass `unique α` is implemented as a type,
rather than a `Prop`-valued predicate,
for good definitional properties of the default term.
-/
universes u v w
variables {α : Sort u} {β : Sort v} {γ : Sort w}
/-- `unique α` expresses that `α` is a type with a unique term `default`.
This is implemented as a type, rather than a `Prop`-valued predicate,
for good definitional properties of the default term. -/
@[ext]
structure unique (α : Sort u) extends inhabited α :=
(uniq : ∀ a : α, a = default)
attribute [class] unique
lemma unique_iff_exists_unique (α : Sort u) : nonempty (unique α) ↔ ∃! a : α, true :=
⟨λ ⟨u⟩, ⟨u.default, trivial, λ a _, u.uniq a⟩, λ ⟨a,_,h⟩, ⟨⟨⟨a⟩, λ _, h _ trivial⟩⟩⟩
lemma unique_subtype_iff_exists_unique {α} (p : α → Prop) :
nonempty (unique (subtype p)) ↔ ∃! a, p a :=
⟨λ ⟨u⟩, ⟨u.default.1, u.default.2, λ a h, congr_arg subtype.val (u.uniq ⟨a,h⟩)⟩,
λ ⟨a,ha,he⟩, ⟨⟨⟨⟨a,ha⟩⟩, λ ⟨b,hb⟩, by { congr, exact he b hb }⟩⟩⟩
/-- Given an explicit `a : α` with `[subsingleton α]`, we can construct
a `[unique α]` instance. This is a def because the typeclass search cannot
arbitrarily invent the `a : α` term. Nevertheless, these instances are all
equivalent by `unique.subsingleton.unique`.
See note [reducible non-instances]. -/
@[reducible] def unique_of_subsingleton {α : Sort*} [subsingleton α] (a : α) : unique α :=
{ default := a,
uniq := λ _, subsingleton.elim _ _ }
instance punit.unique : unique punit.{u} :=
{ default := punit.star,
uniq := λ x, punit_eq x _ }
@[simp] lemma punit.default_eq_star : (default : punit) = punit.star := rfl
/-- Every provable proposition is unique, as all proofs are equal. -/
def unique_prop {p : Prop} (h : p) : unique p :=
{ default := h, uniq := λ x, rfl }
instance : unique true := unique_prop trivial
lemma fin.eq_zero : ∀ n : fin 1, n = 0
| ⟨n, hn⟩ := fin.eq_of_veq (nat.eq_zero_of_le_zero (nat.le_of_lt_succ hn))
instance {n : ℕ} : inhabited (fin n.succ) := ⟨0⟩
instance inhabited_fin_one_add (n : ℕ) : inhabited (fin (1 + n)) := ⟨⟨0, nat.zero_lt_one_add n⟩⟩
@[simp] lemma fin.default_eq_zero (n : ℕ) : (default : fin n.succ) = 0 := rfl
instance fin.unique : unique (fin 1) :=
{ uniq := fin.eq_zero, .. fin.inhabited }
namespace unique
open function
section
variables [unique α]
@[priority 100] -- see Note [lower instance priority]
instance : inhabited α := to_inhabited ‹unique α›
lemma eq_default (a : α) : a = default := uniq _ a
lemma default_eq (a : α) : default = a := (uniq _ a).symm
@[priority 100] -- see Note [lower instance priority]
instance : subsingleton α := subsingleton_of_forall_eq _ eq_default
lemma forall_iff {p : α → Prop} : (∀ a, p a) ↔ p default :=
⟨λ h, h _, λ h x, by rwa [unique.eq_default x]⟩
lemma exists_iff {p : α → Prop} : Exists p ↔ p default :=
⟨λ ⟨a, ha⟩, eq_default a ▸ ha, exists.intro default⟩
end
@[ext] protected lemma subsingleton_unique' : ∀ (h₁ h₂ : unique α), h₁ = h₂
| ⟨⟨x⟩, h⟩ ⟨⟨y⟩, _⟩ := by congr; rw [h x, h y]
instance subsingleton_unique : subsingleton (unique α) :=
⟨unique.subsingleton_unique'⟩
/-- Construct `unique` from `inhabited` and `subsingleton`. Making this an instance would create
a loop in the class inheritance graph. -/
@[reducible] def mk' (α : Sort u) [h₁ : inhabited α] [subsingleton α] : unique α :=
{ uniq := λ x, subsingleton.elim _ _, .. h₁ }
end unique
lemma unique_iff_subsingleton_and_nonempty (α : Sort u) :
nonempty (unique α) ↔ subsingleton α ∧ nonempty α :=
⟨λ ⟨u⟩, by split; exactI infer_instance,
λ ⟨hs, hn⟩, ⟨by { resetI, inhabit α, exact unique.mk' α }⟩⟩
@[simp] lemma pi.default_def {β : α → Sort v} [Π a, inhabited (β a)] :
@default (Π a, β a) _ = λ a : α, @default (β a) _ := rfl
lemma pi.default_apply {β : α → Sort v} [Π a, inhabited (β a)] (a : α) :
@default (Π a, β a) _ a = default := rfl
instance pi.unique {β : α → Sort v} [Π a, unique (β a)] : unique (Π a, β a) :=
{ uniq := λ f, funext $ λ x, unique.eq_default _,
.. pi.inhabited α }
/-- There is a unique function on an empty domain. -/
instance pi.unique_of_is_empty [is_empty α] (β : α → Sort v) :
unique (Π a, β a) :=
{ default := is_empty_elim,
uniq := λ f, funext is_empty_elim }
lemma eq_const_of_unique [unique α] (f : α → β) : f = function.const α (f default) :=
by { ext x, rw subsingleton.elim x default }
lemma heq_const_of_unique [unique α] {β : α → Sort v}
(f : Π a, β a) : f == function.const α (f default) :=
function.hfunext rfl $ λ i _ _, by rw subsingleton.elim i default
namespace function
variable {f : α → β}
/-- If the codomain of an injective function is a subsingleton, then the domain
is a subsingleton as well. -/
protected lemma injective.subsingleton (hf : injective f) [subsingleton β] :
subsingleton α :=
⟨λ x y, hf $ subsingleton.elim _ _⟩
/-- If the domain of a surjective function is a subsingleton, then the codomain is a subsingleton as
well. -/
protected lemma surjective.subsingleton [subsingleton α] (hf : surjective f) :
subsingleton β :=
⟨hf.forall₂.2 $ λ x y, congr_arg f $ subsingleton.elim x y⟩
/-- If the domain of a surjective function is a singleton,
then the codomain is a singleton as well. -/
protected def surjective.unique (hf : surjective f) [unique α] : unique β :=
@unique.mk' _ ⟨f default⟩ hf.subsingleton
/-- If `α` is inhabited and admits an injective map to a subsingleton type, then `α` is `unique`. -/
protected def injective.unique [inhabited α] [subsingleton β] (hf : injective f) : unique α :=
@unique.mk' _ _ hf.subsingleton
/-- If a constant function is surjective, then the codomain is a singleton. -/
def surjective.unique_of_surjective_const (α : Type*) {β : Type*} (b : β)
(h : function.surjective (function.const α b)) : unique β :=
@unique_of_subsingleton _ (subsingleton_of_forall_eq b $ h.forall.mpr (λ _, rfl)) b
end function
lemma unique.bijective {A B} [unique A] [unique B] {f : A → B} : function.bijective f :=
begin
rw function.bijective_iff_has_inverse,
refine ⟨default, _, _⟩; intro x; simp
end
namespace option
/-- `option α` is a `subsingleton` if and only if `α` is empty. -/
lemma subsingleton_iff_is_empty {α} : subsingleton (option α) ↔ is_empty α :=
⟨λ h, ⟨λ x, option.no_confusion $ @subsingleton.elim _ h x none⟩,
λ h, ⟨λ x y, option.cases_on x (option.cases_on y rfl (λ x, h.elim x)) (λ x, h.elim x)⟩⟩
instance {α} [is_empty α] : unique (option α) := @unique.mk' _ _ (subsingleton_iff_is_empty.2 ‹_›)
end option
section subtype
instance unique.subtype_eq (y : α) : unique {x // x = y} :=
{ default := ⟨y, rfl⟩,
uniq := λ ⟨x, hx⟩, by simpa using hx }
instance unique.subtype_eq' (y : α) : unique {x // y = x} :=
{ default := ⟨y, rfl⟩,
uniq := λ ⟨x, hx⟩, by simpa using hx.symm }
end subtype
|
c7172de9530f453055ac252c07330107d86c42f0 | bd30ef9a38da5172e55165b5cf19d92706763afa | /src/fin_group.lean | b6ad58ef575bbb513e47a9602e90a8a2b39c32c8 | [] | no_license | kendfrey/rubiks-cube-group | 8838ce34704d8d150e5feba6f1e536b3d228dd37 | 3baebd73972384294931c75d584a491eb0fbc15c | refs/heads/master | 1,671,557,772,358 | 1,601,554,362,000 | 1,601,554,362,000 | 285,715,961 | 21 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,715 | lean | import data.fin
open fin nat
def fin' := fin
variables {n : ℕ} (a b c : fin' n.succ)
instance : has_one (fin' n.succ) := ⟨(0 : fin n.succ)⟩
instance : has_mul (fin' n.succ) := ⟨((+) : fin n.succ → fin n.succ → fin n.succ)⟩
include a
private def inv : fin' n.succ :=
begin
cases a,
cases a_val,
{
exact 1,
},
{
exact (n - a_val : fin n.succ),
},
end
omit a
instance : has_inv (fin' n.succ) := ⟨inv⟩
private lemma mul_assoc : a * b * c = a * (b * c) :=
begin
apply eq_of_veq,
simp [(*), fin.add_def, add_assoc],
end
private lemma one_mul : 1 * a = a :=
begin
apply eq_of_veq,
simp [has_one.one, (*), fin.add_def, mod_eq_of_lt a.is_lt],
end
private lemma mul_one : a * 1 = a :=
begin
apply eq_of_veq,
simp [has_one.one, (*), fin.add_def, mod_eq_of_lt a.is_lt],
end
private lemma mul_left_inv : a⁻¹ * a = 1 :=
begin
apply eq_of_veq,
cases a,
cases a_val,
{
simp only [has_one.one, (*), has_inv.inv, inv, fin.add_def],
simp,
},
{
simp only [(*), has_inv.inv, inv, fin.add_def, fin.sub_def],
rw [coe_val_of_lt, coe_val_of_lt]; try { simp [lt_of_succ_lt a_property], },
have : (n - a_val + a_val.succ) = n.succ,
{
rw add_succ,
congr,
apply nat.sub_add_cancel,
apply le_of_lt,
apply lt_of_succ_lt_succ,
apply a_property,
},
rw this,
apply mod_self,
},
end
private lemma mul_comm : a * b = b * a :=
begin
apply eq_of_veq,
simp [(*), fin.add_def, add_comm],
end
instance : comm_group (fin' n.succ) :=
{
mul := (*),
mul_assoc := mul_assoc,
one := 0,
one_mul := one_mul,
mul_one := mul_one,
inv := inv,
mul_left_inv := mul_left_inv,
mul_comm := mul_comm,
} |
ca731c817fe985215de0691725cf104472fb19ce | 1a61aba1b67cddccce19532a9596efe44be4285f | /library/algebra/complete_lattice.lean | c7f0a70b67b444689e41f67a182a563f7a0db661 | [
"Apache-2.0"
] | permissive | eigengrau/lean | 07986a0f2548688c13ba36231f6cdbee82abf4c6 | f8a773be1112015e2d232661ce616d23f12874d0 | refs/heads/master | 1,610,939,198,566 | 1,441,352,386,000 | 1,441,352,494,000 | 41,903,576 | 0 | 0 | null | 1,441,352,210,000 | 1,441,352,210,000 | null | UTF-8 | Lean | false | false | 9,963 | lean | /-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
Complete lattices
TODO: define dual complete lattice and simplify proof of dual theorems.
-/
import algebra.lattice data.set.basic
open set
namespace algebra
variable {A : Type}
structure complete_lattice [class] (A : Type) extends lattice A :=
(Inf : set A → A)
(Sup : set A → A)
(Inf_le : ∀ {a : A} {s : set A}, a ∈ s → le (Inf s) a)
(le_Inf : ∀ {b : A} {s : set A}, (∀ (a : A), a ∈ s → le b a) → le b (Inf s))
(le_Sup : ∀ {a : A} {s : set A}, a ∈ s → le a (Sup s))
(Sup_le : ∀ {b : A} {s : set A} (h : ∀ (a : A), a ∈ s → le a b), le (Sup s) b)
-- Minimal complete_lattice definition based just on Inf.
-- We latet show that complete_lattice_Inf is a complete_lattice
structure complete_lattice_Inf [class] (A : Type) extends weak_order A :=
(Inf : set A → A)
(Inf_le : ∀ {a : A} {s : set A}, a ∈ s → le (Inf s) a)
(le_Inf : ∀ {b : A} {s : set A}, (∀ (a : A), a ∈ s → le b a) → le b (Inf s))
-- Minimal complete_lattice definition based just on Sup.
-- We later show that complete_lattice_Sup is a complete_lattice
structure complete_lattice_Sup [class] (A : Type) extends weak_order A :=
(Sup : set A → A)
(le_Sup : ∀ {a : A} {s : set A}, a ∈ s → le a (Sup s))
(Sup_le : ∀ {b : A} {s : set A} (h : ∀ (a : A), a ∈ s → le a b), le (Sup s) b)
namespace complete_lattice_Inf
variable [C : complete_lattice_Inf A]
include C
definition Sup (s : set A) : A :=
Inf {b | ∀ a, a ∈ s → a ≤ b}
local prefix `⨅`:70 := Inf
local prefix `⨆`:65 := Sup
lemma le_Sup {a : A} {s : set A} : a ∈ s → a ≤ ⨆ s :=
suppose a ∈ s, le_Inf
(show ∀ (b : A), (∀ (a : A), a ∈ s → a ≤ b) → a ≤ b, from
take b, assume h, h a `a ∈ s`)
lemma Sup_le {b : A} {s : set A} (h : ∀ (a : A), a ∈ s → a ≤ b) : ⨆ s ≤ b :=
Inf_le h
definition inf (a b : A) := ⨅ '{a, b}
definition sup (a b : A) := ⨆ '{a, b}
local infix `⊓` := inf
local infix `⊔` := sup
lemma inf_le_left (a b : A) : a ⊓ b ≤ a :=
Inf_le !mem_insert
lemma inf_le_right (a b : A) : a ⊓ b ≤ b :=
Inf_le (!mem_insert_of_mem !mem_insert)
lemma le_inf {a b c : A} : c ≤ a → c ≤ b → c ≤ a ⊓ b :=
assume h₁ h₂,
le_Inf (take x, suppose x ∈ '{a, b},
or.elim (eq_or_mem_of_mem_insert this)
(suppose x = a, by subst x; assumption)
(suppose x ∈ '{b},
assert x = b, from !eq_of_mem_singleton this,
by subst x; assumption))
lemma le_sup_left (a b : A) : a ≤ a ⊔ b :=
le_Sup !mem_insert
lemma le_sup_right (a b : A) : b ≤ a ⊔ b :=
le_Sup (!mem_insert_of_mem !mem_insert)
lemma sup_le {a b c : A} : a ≤ c → b ≤ c → a ⊔ b ≤ c :=
assume h₁ h₂,
Sup_le (take x, suppose x ∈ '{a, b},
or.elim (eq_or_mem_of_mem_insert this)
(suppose x = a, by subst x; assumption)
(suppose x ∈ '{b},
assert x = b, from !eq_of_mem_singleton this,
by subst x; assumption))
end complete_lattice_Inf
-- Every complete_lattice_Inf is a complete_lattice_Sup
definition complete_lattice_Inf_to_complete_lattice_Sup [instance] [C : complete_lattice_Inf A] : complete_lattice_Sup A :=
⦃ complete_lattice_Sup, C ⦄
-- Every complete_lattice_Inf is a complete_lattice
definition complete_lattice_Inf_to_complete_lattice [instance] [C : complete_lattice_Inf A] : complete_lattice A :=
⦃ complete_lattice, C ⦄
namespace complete_lattice_Sup
variable [C : complete_lattice_Sup A]
include C
definition Inf (s : set A) : A :=
Sup {b | ∀ a, a ∈ s → b ≤ a}
lemma Inf_le {a : A} {s : set A} : a ∈ s → Inf s ≤ a :=
suppose a ∈ s, Sup_le
(show ∀ (b : A), (∀ (a : A), a ∈ s → b ≤ a) → b ≤ a, from
take b, assume h, h a `a ∈ s`)
lemma le_Inf {b : A} {s : set A} (h : ∀ (a : A), a ∈ s → b ≤ a) : b ≤ Inf s :=
le_Sup h
end complete_lattice_Sup
-- Every complete_lattice_Sup is a complete_lattice_Inf
definition complete_lattice_Sup_to_complete_lattice_Inf [instance] [C : complete_lattice_Sup A] : complete_lattice_Inf A :=
⦃ complete_lattice_Inf, C ⦄
-- Every complete_lattice_Sup is a complete_lattice
definition complete_lattice_Sup_to_complete_lattice [instance] [C : complete_lattice_Sup A] : complete_lattice A :=
_
namespace complete_lattice
variable [C : complete_lattice A]
include C
prefix `⨅`:70 := Inf
prefix `⨆`:65 := Sup
infix `⊓` := inf
infix `⊔` := sup
variable {f : A → A}
premise (mono : ∀ x y : A, x ≤ y → f x ≤ f y)
theorem knaster_tarski : ∃ a, f a = a ∧ ∀ b, f b = b → a ≤ b :=
let a := ⨅ {u | f u ≤ u} in
have h₁ : f a = a, from
have ge : f a ≤ a, from
have ∀ b, b ∈ {u | f u ≤ u} → f a ≤ b, from
take b, suppose f b ≤ b,
have a ≤ b, from Inf_le this,
have f a ≤ f b, from !mono this,
le.trans `f a ≤ f b` `f b ≤ b`,
le_Inf this,
have le : a ≤ f a, from
have f (f a) ≤ f a, from !mono ge,
have f a ∈ {u | f u ≤ u}, from this,
Inf_le this,
le.antisymm ge le,
have h₂ : ∀ b, f b = b → a ≤ b, from
take b,
suppose f b = b,
have b ∈ {u | f u ≤ u}, from
show f b ≤ b, by rewrite this; apply le.refl,
Inf_le this,
exists.intro a (and.intro h₁ h₂)
theorem knaster_tarski_dual : ∃ a, f a = a ∧ ∀ b, f b = b → b ≤ a :=
let a := ⨆ {u | u ≤ f u} in
have h₁ : f a = a, from
have le : a ≤ f a, from
have ∀ b, b ∈ {u | u ≤ f u} → b ≤ f a, from
take b, suppose b ≤ f b,
have b ≤ a, from le_Sup this,
have f b ≤ f a, from !mono this,
le.trans `b ≤ f b` `f b ≤ f a`,
Sup_le this,
have ge : f a ≤ a, from
have f a ≤ f (f a), from !mono le,
have f a ∈ {u | u ≤ f u}, from this,
le_Sup this,
le.antisymm ge le,
have h₂ : ∀ b, f b = b → b ≤ a, from
take b,
suppose f b = b,
have b ≤ f b, by rewrite this; apply le.refl,
le_Sup this,
exists.intro a (and.intro h₁ h₂)
definition bot : A := ⨅ univ
definition top : A := ⨆ univ
notation `⊥` := bot
notation `⊤` := top
lemma bot_le (a : A) : ⊥ ≤ a :=
Inf_le !mem_univ
lemma eq_bot {a : A} : (∀ b, a ≤ b) → a = ⊥ :=
assume h,
have a ≤ ⊥, from le_Inf (take b bin, h b),
le.antisymm this !bot_le
lemma le_top (a : A) : a ≤ ⊤ :=
le_Sup !mem_univ
lemma eq_top {a : A} : (∀ b, b ≤ a) → a = ⊤ :=
assume h,
have ⊤ ≤ a, from Sup_le (take b bin, h b),
le.antisymm !le_top this
lemma Inf_singleton {a : A} : ⨅'{a} = a :=
have ⨅'{a} ≤ a, from
Inf_le !mem_insert,
have a ≤ ⨅'{a}, from
le_Inf (take b, suppose b ∈ '{a}, assert b = a, from eq_of_mem_singleton this, by rewrite this; apply le.refl),
le.antisymm `⨅'{a} ≤ a` `a ≤ ⨅'{a}`
lemma Sup_singleton {a : A} : ⨆'{a} = a :=
have ⨆'{a} ≤ a, from
Sup_le (take b, suppose b ∈ '{a}, assert b = a, from eq_of_mem_singleton this, by rewrite this; apply le.refl),
have a ≤ ⨆'{a}, from
le_Sup !mem_insert,
le.antisymm `⨆'{a} ≤ a` `a ≤ ⨆'{a}`
lemma Inf_antimono {s₁ s₂ : set A} : s₁ ⊆ s₂ → ⨅ s₂ ≤ ⨅ s₁ :=
suppose s₁ ⊆ s₂, le_Inf (take a : A, suppose a ∈ s₁, Inf_le (mem_of_subset_of_mem `s₁ ⊆ s₂` `a ∈ s₁`))
lemma Sup_mono {s₁ s₂ : set A} : s₁ ⊆ s₂ → ⨆ s₁ ≤ ⨆ s₂ :=
suppose s₁ ⊆ s₂, Sup_le (take a : A, suppose a ∈ s₁, le_Sup (mem_of_subset_of_mem `s₁ ⊆ s₂` `a ∈ s₁`))
lemma Inf_union (s₁ s₂ : set A) : ⨅ (s₁ ∪ s₂) = (⨅s₁) ⊓ (⨅s₂) :=
have le₁ : ⨅ (s₁ ∪ s₂) ≤ (⨅s₁) ⊓ (⨅s₂), from
!le_inf
(le_Inf (take a : A, suppose a ∈ s₁, Inf_le (mem_unionl `a ∈ s₁`)))
(le_Inf (take a : A, suppose a ∈ s₂, Inf_le (mem_unionr `a ∈ s₂`))),
have le₂ : (⨅s₁) ⊓ (⨅s₂) ≤ ⨅ (s₁ ∪ s₂), from
le_Inf (take a : A, suppose a ∈ s₁ ∪ s₂,
or.elim this
(suppose a ∈ s₁,
have (⨅s₁) ⊓ (⨅s₂) ≤ ⨅s₁, from !inf_le_left,
have ⨅s₁ ≤ a, from Inf_le `a ∈ s₁`,
le.trans `(⨅s₁) ⊓ (⨅s₂) ≤ ⨅s₁` `⨅s₁ ≤ a`)
(suppose a ∈ s₂,
have (⨅s₁) ⊓ (⨅s₂) ≤ ⨅s₂, from !inf_le_right,
have ⨅s₂ ≤ a, from Inf_le `a ∈ s₂`,
le.trans `(⨅s₁) ⊓ (⨅s₂) ≤ ⨅s₂` `⨅s₂ ≤ a`)),
le.antisymm le₁ le₂
lemma Sup_union (s₁ s₂ : set A) : ⨆ (s₁ ∪ s₂) = (⨆s₁) ⊔ (⨆s₂) :=
have le₁ : ⨆ (s₁ ∪ s₂) ≤ (⨆s₁) ⊔ (⨆s₂), from
Sup_le (take a : A, suppose a ∈ s₁ ∪ s₂,
or.elim this
(suppose a ∈ s₁,
have a ≤ ⨆s₁, from le_Sup `a ∈ s₁`,
have ⨆s₁ ≤ (⨆s₁) ⊔ (⨆s₂), from !le_sup_left,
le.trans `a ≤ ⨆s₁` `⨆s₁ ≤ (⨆s₁) ⊔ (⨆s₂)`)
(suppose a ∈ s₂,
have a ≤ ⨆s₂, from le_Sup `a ∈ s₂`,
have ⨆s₂ ≤ (⨆s₁) ⊔ (⨆s₂), from !le_sup_right,
le.trans `a ≤ ⨆s₂` `⨆s₂ ≤ (⨆s₁) ⊔ (⨆s₂)`)),
have le₂ : (⨆s₁) ⊔ (⨆s₂) ≤ ⨆ (s₁ ∪ s₂), from
!sup_le
(Sup_le (take a : A, suppose a ∈ s₁, le_Sup (mem_unionl `a ∈ s₁`)))
(Sup_le (take a : A, suppose a ∈ s₂, le_Sup (mem_unionr `a ∈ s₂`))),
le.antisymm le₁ le₂
lemma Inf_empty_eq_Sup_univ : ⨅ (∅ : set A) = ⨆ univ :=
have le₁ : ⨅ ∅ ≤ ⨆ univ, from
le_Sup !mem_univ,
have le₂ : ⨆ univ ≤ ⨅ ∅, from
le_Inf (take a, suppose a ∈ ∅, absurd this !not_mem_empty),
le.antisymm le₁ le₂
lemma Sup_empty_eq_Inf_univ : ⨆ (∅ : set A) = ⨅ univ :=
have le₁ : ⨆ (∅ : set A) ≤ ⨅ univ, from
Sup_le (take a, suppose a ∈ ∅, absurd this !not_mem_empty),
have le₂ : ⨅ univ ≤ ⨆ (∅ : set A), from
Inf_le !mem_univ,
le.antisymm le₁ le₂
end complete_lattice
end algebra
|
5ab050e4c6e6c64596e870d7b6713209120d349b | 57c233acf9386e610d99ed20ef139c5f97504ba3 | /src/ring_theory/discriminant.lean | eab5a926a4adc09679abd41381ff17a08d76058d | [
"Apache-2.0"
] | permissive | robertylewis/mathlib | 3d16e3e6daf5ddde182473e03a1b601d2810952c | 1d13f5b932f5e40a8308e3840f96fc882fae01f0 | refs/heads/master | 1,651,379,945,369 | 1,644,276,960,000 | 1,644,276,960,000 | 98,875,504 | 0 | 0 | Apache-2.0 | 1,644,253,514,000 | 1,501,495,700,000 | Lean | UTF-8 | Lean | false | false | 14,725 | lean | /-
Copyright (c) 2021 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import ring_theory.trace
import ring_theory.norm
import ring_theory.integrally_closed
/-!
# Discriminant of a family of vectors
Given an `A`-algebra `B` and `b`, an `ι`-indexed family of elements of `B`, we define the
*discriminant* of `b` as the determinant of the matrix whose `(i j)`-th element is the trace of
`b i * b j`.
## Main definition
* `algebra.discr A b` : the discriminant of `b : ι → B`.
## Main results
* `algebra.discr_zero_of_not_linear_independent` : if `b` is not linear independent, then
`algebra.discr A b = 0`.
* `algebra.discr_of_matrix_vec_mul` and `discr_of_matrix_mul_vec` : formulas relating
`algebra.discr A ι b` with `algebra.discr A ((P.map (algebra_map A B)).vec_mul b)` and
`algebra.discr A ((P.map (algebra_map A B)).mul_vec b)`.
* `algebra.discr_not_zero_of_basis` : over a field, if `b` is a basis, then
`algebra.discr K b ≠ 0`.
* `algebra.discr_eq_det_embeddings_matrix_reindex_pow_two` : if `L/K` is a field extension and
`b : ι → L`, then `discr K b` is the square of the determinant of the matrix whose `(i, j)`
coefficient is `σⱼ (b i)`, where `σⱼ : L →ₐ[K] E` is the embedding in an algebraically closed
field `E` corresponding to `j : ι` via a bijection `e : ι ≃ (L →ₐ[K] E)`.
* `algebra.discr_of_power_basis_eq_prod` : the discriminant of a power basis.
* `discr_is_integral` : if `K` and `L` are fields and `is_scalar_tower R K L`, is `b : ι → L`
satisfies ` ∀ i, is_integral R (b i)`, then `is_integral R (discr K b)`.
* `discr_mul_is_integral_mem_adjoin` : let `K` be the fraction field of an integrally closed domain
`R` and let `L` be a finite separable extension of `K`. Let `B : power_basis K L` be such that
`is_integral R B.gen`. Then for all, `z : L` we have
`(discr K B.basis) • z ∈ adjoin R ({B.gen} : set L)`.
## Implementation details
Our definition works for any `A`-algebra `B`, but note that if `B` is not free as an `A`-module,
then `trace A B = 0` by definition, so `discr A b = 0` for any `b`.
-/
universes u v w z
open_locale matrix big_operators
open matrix finite_dimensional fintype polynomial finset intermediate_field
namespace algebra
variables (A : Type u) {B : Type v} (C : Type z) {ι : Type w}
variables [comm_ring A] [comm_ring B] [algebra A B] [comm_ring C] [algebra A C]
section discr
/-- Given an `A`-algebra `B` and `b`, an `ι`-indexed family of elements of `B`, we define
`discr A ι b` as the determinant of `trace_matrix A ι b`. -/
noncomputable
def discr (A : Type u) {B : Type v} [comm_ring A] [comm_ring B] [algebra A B] [fintype ι]
(b : ι → B) := by { classical, exact (trace_matrix A b).det }
lemma discr_def [decidable_eq ι] [fintype ι] (b : ι → B) :
discr A b = (trace_matrix A b).det := by convert rfl
variable [fintype ι]
section basic
/-- If `b` is not linear independent, then `algebra.discr A b = 0`. -/
lemma discr_zero_of_not_linear_independent [is_domain A] {b : ι → B}
(hli : ¬linear_independent A b) : discr A b = 0 :=
begin
classical,
obtain ⟨g, hg, i, hi⟩ := fintype.not_linear_independent_iff.1 hli,
have : (trace_matrix A b).mul_vec g = 0,
{ ext i,
have : ∀ j, (trace A B) (b i * b j) * g j = (trace A B) (((g j) • (b j)) * b i),
{ intro j, simp [mul_comm], },
simp only [mul_vec, dot_product, trace_matrix, pi.zero_apply, trace_form_apply,
λ j, this j, ← linear_map.map_sum, ← sum_mul, hg, zero_mul, linear_map.map_zero] },
by_contra h,
rw discr_def at h,
simpa [matrix.eq_zero_of_mul_vec_eq_zero h this] using hi,
end
variable {A}
/-- Relation between `algebra.discr A ι b` and
`algebra.discr A ((P.map (algebra_map A B)).vec_mul b)`. -/
lemma discr_of_matrix_vec_mul [decidable_eq ι] (b : ι → B) (P : matrix ι ι A) :
discr A ((P.map (algebra_map A B)).vec_mul b) = P.det ^ 2 * discr A b :=
by rw [discr_def, trace_matrix_of_matrix_vec_mul, det_mul, det_mul, det_transpose, mul_comm,
← mul_assoc, discr_def, pow_two]
/-- Relation between `algebra.discr A ι b` and
`algebra.discr A ((P.map (algebra_map A B)).mul_vec b)`. -/
lemma discr_of_matrix_mul_vec [decidable_eq ι] (b : ι → B) (P : matrix ι ι A) :
discr A ((P.map (algebra_map A B)).mul_vec b) = P.det ^ 2 * discr A b :=
by rw [discr_def, trace_matrix_of_matrix_mul_vec, det_mul, det_mul, det_transpose,
mul_comm, ← mul_assoc, discr_def, pow_two]
end basic
section field
variables (K : Type u) {L : Type v} (E : Type z) [field K] [field L] [field E]
variables [algebra K L] [algebra K E]
variables [module.finite K L] [is_alg_closed E]
/-- Over a field, if `b` is a basis, then `algebra.discr K b ≠ 0`. -/
lemma discr_not_zero_of_basis [is_separable K L] (b : basis ι K L) : discr K b ≠ 0 :=
begin
by_cases h : nonempty ι,
{ classical,
have := span_eq_top_of_linear_independent_of_card_eq_finrank b.linear_independent
(finrank_eq_card_basis b).symm,
rw [discr_def, trace_matrix_def],
simp_rw [← basis.mk_apply b.linear_independent this],
rw [← trace_matrix_def, trace_matrix_of_basis, ← bilin_form.nondegenerate_iff_det_ne_zero],
exact trace_form_nondegenerate _ _ },
letI := not_nonempty_iff.1 h,
simp [discr],
end
/-- Over a field, if `b` is a basis, then `algebra.discr K b` is a unit. -/
lemma discr_is_unit_of_basis [is_separable K L] (b : basis ι K L) : is_unit (discr K b) :=
is_unit.mk0 _ (discr_not_zero_of_basis _ _)
variables (b : ι → L) (pb : power_basis K L)
/-- If `L/K` is a field extension and `b : ι → L`, then `discr K b` is the square of the
determinant of the matrix whose `(i, j)` coefficient is `σⱼ (b i)`, where `σⱼ : L →ₐ[K] E` is the
embedding in an algebraically closed field `E` corresponding to `j : ι` via a bijection
`e : ι ≃ (L →ₐ[K] E)`. -/
lemma discr_eq_det_embeddings_matrix_reindex_pow_two [decidable_eq ι] [is_separable K L]
(e : ι ≃ (L →ₐ[K] E)) : algebra_map K E (discr K b) =
(embeddings_matrix_reindex K E b e).det ^ 2 :=
by rw [discr_def, ring_hom.map_det, ring_hom.map_matrix_apply,
trace_matrix_eq_embeddings_matrix_reindex_mul_trans, det_mul, det_transpose, pow_two]
/-- The discriminant of a power basis. -/
lemma discr_power_basis_eq_prod (e : fin pb.dim ≃ (L →ₐ[K] E)) [is_separable K L] :
algebra_map K E (discr K pb.basis) =
∏ i : fin pb.dim, ∏ j in finset.univ.filter (λ j, i < j), (e j pb.gen- (e i pb.gen)) ^ 2 :=
begin
rw [discr_eq_det_embeddings_matrix_reindex_pow_two K E pb.basis e,
embeddings_matrix_reindex_eq_vandermonde, det_transpose, det_vandermonde, ← prod_pow],
congr, ext i,
rw [← prod_pow]
end
/-- A variation of `of_power_basis_eq_prod`. -/
lemma of_power_basis_eq_prod' [is_separable K L] (e : fin pb.dim ≃ (L →ₐ[K] E)) :
algebra_map K E (discr K pb.basis) =
∏ i : fin pb.dim, ∏ j in finset.univ.filter (λ j, i < j),
-((e j pb.gen- (e i pb.gen)) * (e i pb.gen- (e j pb.gen))) :=
begin
rw [discr_power_basis_eq_prod _ _ _ e],
congr, ext i, congr, ext j,
ring
end
local notation `n` := finrank K L
/-- A variation of `of_power_basis_eq_prod`. -/
lemma of_power_basis_eq_prod'' [is_separable K L] (e : fin pb.dim ≃ (L →ₐ[K] E)) :
algebra_map K E (discr K pb.basis) =
(-1) ^ (n * (n - 1) / 2) * ∏ i : fin pb.dim, ∏ j in finset.univ.filter (λ j, i < j),
((e j pb.gen- (e i pb.gen)) * (e i pb.gen- (e j pb.gen))) :=
begin
rw [of_power_basis_eq_prod' _ _ _ e],
simp_rw [λ i j, neg_eq_neg_one_mul ((e j pb.gen- (e i pb.gen)) * (e i pb.gen- (e j pb.gen))),
prod_mul_distrib],
congr,
simp only [prod_pow_eq_pow_sum, prod_const],
congr,
simp_rw [fin.card_filter_lt],
apply (@nat.cast_inj ℚ _ _ _ _ _).1,
rw [nat.cast_sum],
have : ∀ (x : fin pb.dim), (↑x + 1) ≤ pb.dim := by simp [nat.succ_le_iff, fin.is_lt],
simp_rw [nat.sub_sub],
simp only [nat.cast_sub, this, finset.card_fin, nsmul_eq_mul, sum_const, sum_sub_distrib,
nat.cast_add, nat.cast_one, sum_add_distrib, mul_one],
rw [← nat.cast_sum, ← @finset.sum_range ℕ _ pb.dim (λ i, i), sum_range_id ],
have hn : n = pb.dim,
{ rw [← alg_hom.card K L E, ← fintype.card_fin pb.dim],
exact card_congr (equiv.symm e) },
have h₂ : 2 ∣ (pb.dim * (pb.dim - 1)) := even_iff_two_dvd.1 (nat.even_mul_self_pred _),
have hne : ((2 : ℕ) : ℚ) ≠ 0 := by simp,
have hle : 1 ≤ pb.dim,
{ rw [← hn, nat.one_le_iff_ne_zero, ← zero_lt_iff, finite_dimensional.finrank_pos_iff],
apply_instance },
rw [hn, nat.cast_dvd h₂ hne, nat.cast_mul, nat.cast_sub hle],
field_simp,
ring,
end
/-- Formula for the discriminant of a power basis using the norm of the field extension. -/
lemma of_power_basis_eq_norm [is_separable K L] : discr K pb.basis =
(-1) ^ (n * (n - 1) / 2) * (norm K (aeval pb.gen (minpoly K pb.gen).derivative)) :=
begin
let E := algebraic_closure L,
letI := λ (a b : E), classical.prop_decidable (eq a b),
have e : fin pb.dim ≃ (L →ₐ[K] E),
{ refine equiv_of_card_eq _,
rw [fintype.card_fin, alg_hom.card],
exact (power_basis.finrank pb).symm },
have hnodup : (map (algebra_map K E) (minpoly K pb.gen)).roots.nodup :=
nodup_roots (separable.map (is_separable.separable K pb.gen)),
have hroots : ∀ σ : L →ₐ[K] E, σ pb.gen ∈ (map (algebra_map K E) (minpoly K pb.gen)).roots,
{ intro σ,
rw [mem_roots, is_root.def, eval_map, ← aeval_def, aeval_alg_hom_apply],
repeat { simp [minpoly.ne_zero (is_separable.is_integral K pb.gen)] } },
apply (algebra_map K E).injective,
rw [ring_hom.map_mul, ring_hom.map_pow, ring_hom.map_neg, ring_hom.map_one,
of_power_basis_eq_prod'' _ _ _ e],
congr,
rw [norm_eq_prod_embeddings, fin.prod_filter_lt_mul_neg_eq_prod_off_diag],
conv_rhs { congr, skip, funext,
rw [← aeval_alg_hom_apply, aeval_root_derivative_of_splits (minpoly.monic
(is_separable.is_integral K pb.gen)) (is_alg_closed.splits_codomain _) (hroots σ),
← finset.prod_mk _ (multiset.nodup_erase_of_nodup _ hnodup)] },
rw [prod_sigma', prod_sigma'],
refine prod_bij (λ i hi, ⟨e i.2, e i.1 pb.gen⟩) (λ i hi, _) (λ i hi, by simp at hi)
(λ i j hi hj hij, _) (λ σ hσ, _),
{ simp only [true_and, finset.mem_mk, mem_univ, mem_sigma],
rw [multiset.mem_erase_of_ne (λ h, _)],
{ exact hroots _ },
{ simp only [true_and, mem_filter, mem_univ, ne.def, mem_sigma] at hi,
refine hi (equiv.injective e (equiv.injective (power_basis.lift_equiv pb) _)),
rw [← power_basis.lift_equiv_apply_coe, ← power_basis.lift_equiv_apply_coe] at h,
exact subtype.eq h } },
{ simp only [equiv.apply_eq_iff_eq, heq_iff_eq] at hij,
have h := hij.2,
rw [← power_basis.lift_equiv_apply_coe, ← power_basis.lift_equiv_apply_coe] at h,
refine sigma.eq (equiv.injective e (equiv.injective _ (subtype.eq h))) (by simp [hij.1]) },
{ simp only [true_and, finset.mem_mk, mem_univ, mem_sigma] at hσ,
simp only [sigma.exists, true_and, exists_prop, mem_filter, mem_univ, ne.def, mem_sigma],
refine ⟨e.symm (power_basis.lift pb σ.2 _), e.symm σ.1, ⟨λ h, _, sigma.eq _ _⟩⟩,
{ rw [aeval_def, eval₂_eq_eval_map, ← is_root.def, ← mem_roots],
{ exact multiset.erase_subset _ _ hσ },
{ simp [minpoly.ne_zero (is_separable.is_integral K pb.gen)] } },
{ replace h := alg_hom.congr_fun (equiv.injective _ h) pb.gen,
rw [power_basis.lift_gen] at h,
rw [← h] at hσ,
refine multiset.mem_erase_of_nodup hnodup hσ, },
all_goals { simp } }
end
section integral
variables {R : Type z} [comm_ring R] [algebra R K] [algebra R L] [is_scalar_tower R K L]
local notation `is_integral` := _root_.is_integral
/-- If `K` and `L` are fields and `is_scalar_tower R K L`, and `b : ι → L` satisfies
` ∀ i, is_integral R (b i)`, then `is_integral R (discr K b)`. -/
lemma discr_is_integral {b : ι → L} (h : ∀ i, is_integral R (b i)) :
is_integral R (discr K b) :=
begin
classical,
rw [discr_def],
exact is_integral.det (λ i j, is_integral_trace (is_integral_mul (h i) (h j)))
end
/-- Let `K` be the fraction field of an integrally closed domain `R` and let `L` be a finite
separable extension of `K`. Let `B : power_basis K L` be such that `is_integral R B.gen`.
Then for all, `z : L` that are integral over `R`, we have
`(discr K B.basis) • z ∈ adjoin R ({B.gen} : set L)`. -/
lemma discr_mul_is_integral_mem_adjoin [is_domain R] [is_separable K L] [is_integrally_closed R]
[is_fraction_ring R K] {B : power_basis K L} (hint : is_integral R B.gen) {z : L}
(hz : is_integral R z) : (discr K B.basis) • z ∈ adjoin R ({B.gen} : set L) :=
begin
have hinv : is_unit (trace_matrix K B.basis).det :=
by simpa [← discr_def] using discr_is_unit_of_basis _ B.basis,
have H : (trace_matrix K B.basis).det • (trace_matrix K B.basis).mul_vec (B.basis.equiv_fun z) =
(trace_matrix K B.basis).det • (λ i, trace K L (z * B.basis i)),
{ congr, exact trace_matrix_of_basis_mul_vec _ _ },
have cramer := mul_vec_cramer (trace_matrix K B.basis) (λ i, trace K L (z * B.basis i)),
suffices : ∀ i, ((trace_matrix K B.basis).det • (B.basis.equiv_fun z)) i ∈ (⊥ : subalgebra R K),
{ rw [← B.basis.sum_repr z, finset.smul_sum],
refine subalgebra.sum_mem _ (λ i hi, _),
replace this := this i,
rw [← discr_def, pi.smul_apply, mem_bot] at this,
obtain ⟨r, hr⟩ := this,
rw [basis.equiv_fun_apply] at hr,
rw [← smul_assoc, ← hr, algebra_map_smul],
refine subalgebra.smul_mem _ _ _,
rw [B.basis_eq_pow i],
refine subalgebra.pow_mem _ (subset_adjoin (set.mem_singleton _)) _},
intro i,
rw [← H, ← mul_vec_smul] at cramer,
replace cramer := congr_arg (mul_vec (trace_matrix K B.basis)⁻¹) cramer,
rw [mul_vec_mul_vec, nonsing_inv_mul _ hinv, mul_vec_mul_vec, nonsing_inv_mul _ hinv,
one_mul_vec, one_mul_vec] at cramer,
rw [← congr_fun cramer i, cramer_apply, det_apply],
refine subalgebra.sum_mem _ (λ σ _, subalgebra.zsmul_mem _ (subalgebra.prod_mem _ (λ j _, _)) _),
by_cases hji : j = i,
{ simp only [update_column_apply, hji, eq_self_iff_true, power_basis.coe_basis],
exact mem_bot.2 (is_integrally_closed.is_integral_iff.1 $ is_integral_trace $
is_integral_mul hz $ is_integral.pow hint _) },
{ simp only [update_column_apply, hji, power_basis.coe_basis],
exact mem_bot.2 (is_integrally_closed.is_integral_iff.1 $ is_integral_trace
$ is_integral_mul (is_integral.pow hint _) (is_integral.pow hint _)) }
end
end integral
end field
end discr
end algebra
|
2d606012fe40532f8e9b0e31e7527c7361f7b252 | 4d2583807a5ac6caaffd3d7a5f646d61ca85d532 | /src/computability/DFA.lean | 778349df0f3039e4ae819f865dd1e4edc149fa76 | [
"Apache-2.0"
] | permissive | AntoineChambert-Loir/mathlib | 64aabb896129885f12296a799818061bc90da1ff | 07be904260ab6e36a5769680b6012f03a4727134 | refs/heads/master | 1,693,187,631,771 | 1,636,719,886,000 | 1,636,719,886,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 4,619 | lean | /-
Copyright (c) 2020 Fox Thomson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Fox Thomson
-/
import data.fintype.basic
import computability.language
import tactic.norm_num
/-!
# Deterministic Finite Automata
This file contains the definition of a Deterministic Finite Automaton (DFA), a state machine which
determines whether a string (implemented as a list over an arbitrary alphabet) is in a regular set
in linear time.
Note that this definition allows for Automaton with infinite states, a `fintype` instance must be
supplied for true DFA's.
-/
universes u v
/-- A DFA is a set of states (`σ`), a transition function from state to state labelled by the
alphabet (`step`), a starting state (`start`) and a set of acceptance states (`accept`). -/
structure DFA (α : Type u) (σ : Type v) :=
(step : σ → α → σ)
(start : σ)
(accept : set σ)
namespace DFA
variables {α : Type u} {σ : Type v} (M : DFA α σ)
instance [inhabited σ] : inhabited (DFA α σ) :=
⟨DFA.mk (λ _ _, default σ) (default σ) ∅⟩
/-- `M.eval_from s x` evaluates `M` with input `x` starting from the state `s`. -/
def eval_from (start : σ) : list α → σ :=
list.foldl M.step start
/-- `M.eval x` evaluates `M` with input `x` starting from the state `M.start`. -/
def eval := M.eval_from M.start
/-- `M.accepts` is the language of `x` such that `M.eval x` is an accept state. -/
def accepts : language α :=
λ x, M.eval x ∈ M.accept
lemma mem_accepts (x : list α) : x ∈ M.accepts ↔ M.eval_from M.start x ∈ M.accept := by refl
lemma eval_from_of_append (start : σ) (x y : list α) :
M.eval_from start (x ++ y) = M.eval_from (M.eval_from start x) y :=
x.foldl_append _ _ y
lemma eval_from_split [fintype σ] {x : list α} {s t : σ} (hlen : fintype.card σ ≤ x.length)
(hx : M.eval_from s x = t) :
∃ q a b c,
x = a ++ b ++ c ∧
a.length + b.length ≤ fintype.card σ ∧
b ≠ [] ∧
M.eval_from s a = q ∧
M.eval_from q b = q ∧
M.eval_from q c = t :=
begin
obtain ⟨n, m, hneq, heq⟩ := fintype.exists_ne_map_eq_of_card_lt
(λ n : fin (fintype.card σ + 1), M.eval_from s (x.take n)) (by norm_num),
wlog hle : (n : ℕ) ≤ m using n m,
have hlt : (n : ℕ) < m := (ne.le_iff_lt hneq).mp hle,
have hm : (m : ℕ) ≤ fintype.card σ := fin.is_le m,
dsimp at heq,
refine ⟨M.eval_from s ((x.take m).take n), (x.take m).take n, (x.take m).drop n, x.drop m,
_, _, _, by refl, _⟩,
{ rw [list.take_append_drop, list.take_append_drop] },
{ simp only [list.length_drop, list.length_take],
rw [min_eq_left (hm.trans hlen), min_eq_left hle, add_tsub_cancel_of_le hle],
exact hm },
{ intro h,
have hlen' := congr_arg list.length h,
simp only [list.length_drop, list.length, list.length_take] at hlen',
rw [min_eq_left, tsub_eq_zero_iff_le] at hlen',
{ apply hneq,
apply le_antisymm,
assumption' },
exact hm.trans hlen, },
have hq :
M.eval_from (M.eval_from s ((x.take m).take n)) ((x.take m).drop n) =
M.eval_from s ((x.take m).take n),
{ rw [list.take_take, min_eq_left hle, ←eval_from_of_append, heq, ←min_eq_left hle,
←list.take_take, min_eq_left hle, list.take_append_drop] },
use hq,
rwa [←hq, ←eval_from_of_append, ←eval_from_of_append, ←list.append_assoc, list.take_append_drop,
list.take_append_drop]
end
lemma eval_from_of_pow {x y : list α} {s : σ} (hx : M.eval_from s x = s)
(hy : y ∈ @language.star α {x}) : M.eval_from s y = s :=
begin
rw language.mem_star at hy,
rcases hy with ⟨ S, rfl, hS ⟩,
induction S with a S ih,
{ refl },
{ have ha := hS a (list.mem_cons_self _ _),
rw set.mem_singleton_iff at ha,
rw [list.join, eval_from_of_append, ha, hx],
apply ih,
intros z hz,
exact hS z (list.mem_cons_of_mem a hz) }
end
lemma pumping_lemma [fintype σ] {x : list α} (hx : x ∈ M.accepts)
(hlen : fintype.card σ ≤ list.length x) :
∃ a b c, x = a ++ b ++ c ∧ a.length + b.length ≤ fintype.card σ ∧ b ≠ [] ∧
{a} * language.star {b} * {c} ≤ M.accepts :=
begin
obtain ⟨_, a, b, c, hx, hlen, hnil, rfl, hb, hc⟩ := M.eval_from_split hlen rfl,
use [a, b, c, hx, hlen, hnil],
intros y hy,
rw language.mem_mul at hy,
rcases hy with ⟨ ab, c', hab, hc', rfl ⟩,
rw language.mem_mul at hab,
rcases hab with ⟨ a', b', ha', hb', rfl ⟩,
rw set.mem_singleton_iff at ha' hc',
substs ha' hc',
have h := M.eval_from_of_pow hb hb',
rwa [mem_accepts, eval_from_of_append, eval_from_of_append, h, hc]
end
end DFA
|
7c0d8cd9c015245547a5575cc2c259f2c4c32915 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/algebraic_geometry/projective_spectrum/structure_sheaf.lean | d6d743bec77d11f99cb4b4e52aa4cadf8da78adc | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 17,788 | lean | /-
Copyright (c) 2022 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang
-/
import algebraic_geometry.projective_spectrum.topology
import topology.sheaves.local_predicate
import ring_theory.graded_algebra.homogeneous_localization
import algebraic_geometry.locally_ringed_space
/-!
# The structure sheaf on `projective_spectrum 𝒜`.
In `src/algebraic_geometry/topology.lean`, we have given a topology on `projective_spectrum 𝒜`; in
this file we will construct a sheaf on `projective_spectrum 𝒜`.
## Notation
- `R` is a commutative semiring;
- `A` is a commutative ring and an `R`-algebra;
- `𝒜 : ℕ → submodule R A` is the grading of `A`;
- `U` is opposite object of some open subset of `projective_spectrum.Top`.
## Main definitions and results
We define the structure sheaf as the subsheaf of all dependent function
`f : Π x : U, homogeneous_localization 𝒜 x` such that `f` is locally expressible as ratio of two
elements of the *same grading*, i.e. `∀ y ∈ U, ∃ (V ⊆ U) (i : ℕ) (a b ∈ 𝒜 i), ∀ z ∈ V, f z = a / b`.
* `algebraic_geometry.projective_spectrum.structure_sheaf.is_locally_fraction`: the predicate that
a dependent function is locally expressible as a ratio of two elements of the same grading.
* `algebraic_geometry.projective_spectrum.structure_sheaf.sections_subring`: the dependent functions
satisfying the above local property forms a subring of all dependent functions
`Π x : U, homogeneous_localization 𝒜 x`.
* `algebraic_geometry.Proj.structure_sheaf`: the sheaf with `U ↦ sections_subring U` and natural
restriction map.
Then we establish that `Proj 𝒜` is a `LocallyRingedSpace`:
* `algebraic_geometry.Proj.stalk_iso'`: for any `x : projective_spectrum 𝒜`, the stalk of
`Proj.structure_sheaf` at `x` is isomorphic to `homogeneous_localization 𝒜 x`.
* `algebraic_geometry.Proj.to_LocallyRingedSpace`: `Proj` as a locally ringed space.
## References
* [Robin Hartshorne, *Algebraic Geometry*][Har77]
-/
noncomputable theory
namespace algebraic_geometry
open_locale direct_sum big_operators pointwise
open direct_sum set_like localization Top topological_space category_theory opposite
variables {R A: Type*}
variables [comm_ring R] [comm_ring A] [algebra R A]
variables (𝒜 : ℕ → submodule R A) [graded_algebra 𝒜]
local notation `at ` x := homogeneous_localization.at_prime 𝒜 x.as_homogeneous_ideal.to_ideal
namespace projective_spectrum.structure_sheaf
variables {𝒜}
/--
The predicate saying that a dependent function on an open `U` is realised as a fixed fraction
`r / s` of *same grading* in each of the stalks (which are localizations at various prime ideals).
-/
def is_fraction {U : opens (projective_spectrum.Top 𝒜)} (f : Π x : U, at x.1) : Prop :=
∃ (i : ℕ) (r s : 𝒜 i),
∀ x : U, ∃ (s_nin : s.1 ∉ x.1.as_homogeneous_ideal),
(f x) = quotient.mk' ⟨i, r, s, s_nin⟩
variables (𝒜)
/--
The predicate `is_fraction` is "prelocal", in the sense that if it holds on `U` it holds on any open
subset `V` of `U`.
-/
def is_fraction_prelocal : prelocal_predicate (λ (x : projective_spectrum.Top 𝒜), at x) :=
{ pred := λ U f, is_fraction f,
res := by rintros V U i f ⟨j, r, s, w⟩; exact ⟨j, r, s, λ y, w (i y)⟩ }
/--
We will define the structure sheaf as the subsheaf of all dependent functions in
`Π x : U, homogeneous_localization 𝒜 x` consisting of those functions which can locally be expressed
as a ratio of `A` of same grading.-/
def is_locally_fraction : local_predicate (λ (x : projective_spectrum.Top 𝒜), at x) :=
(is_fraction_prelocal 𝒜).sheafify
namespace section_subring
variable {𝒜}
open submodule set_like.graded_monoid homogeneous_localization
lemma zero_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ) :
(is_locally_fraction 𝒜).pred (0 : Π x : unop U, at x.1) :=
λ x, ⟨unop U, x.2, 𝟙 (unop U), ⟨0, ⟨0, zero_mem _⟩, ⟨1, one_mem⟩, λ y, ⟨_, rfl⟩⟩⟩
lemma one_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ) :
(is_locally_fraction 𝒜).pred (1 : Π x : unop U, at x.1) :=
λ x, ⟨unop U, x.2, 𝟙 (unop U), ⟨0, ⟨1, one_mem⟩, ⟨1, one_mem⟩, λ y, ⟨_, rfl⟩⟩⟩
lemma add_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ)
(a b : Π x : unop U, at x.1)
(ha : (is_locally_fraction 𝒜).pred a) (hb : (is_locally_fraction 𝒜).pred b) :
(is_locally_fraction 𝒜).pred (a + b) := λ x,
begin
rcases ha x with ⟨Va, ma, ia, ja, ⟨ra, ra_mem⟩, ⟨sa, sa_mem⟩, wa⟩,
rcases hb x with ⟨Vb, mb, ib, jb, ⟨rb, rb_mem⟩, ⟨sb, sb_mem⟩, wb⟩,
refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, opens.inf_le_left _ _ ≫ ia, ja + jb,
⟨sb * ra + sa * rb, add_mem (add_comm jb ja ▸ mul_mem sb_mem ra_mem : sb * ra ∈ 𝒜 (ja + jb))
(mul_mem sa_mem rb_mem)⟩,
⟨sa * sb, mul_mem sa_mem sb_mem⟩, λ y, ⟨λ h, _, _⟩⟩,
{ cases (y : projective_spectrum.Top 𝒜).is_prime.mem_or_mem h with h h,
{ obtain ⟨nin, -⟩ := (wa ⟨y, (opens.inf_le_left Va Vb y).2⟩), exact nin h },
{ obtain ⟨nin, -⟩ := (wb ⟨y, (opens.inf_le_right Va Vb y).2⟩), exact nin h } },
{ simp only [add_mul, map_add, pi.add_apply, ring_hom.map_mul, ext_iff_val, add_val],
obtain ⟨nin1, hy1⟩ := (wa (opens.inf_le_left Va Vb y)),
obtain ⟨nin2, hy2⟩ := (wb (opens.inf_le_right Va Vb y)),
dsimp only at hy1 hy2,
erw [hy1, hy2],
simpa only [val_mk', add_mk, ← subtype.val_eq_coe, add_comm, mul_comm sa sb], }
end
lemma neg_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ)
(a : Π x : unop U, at x.1)
(ha : (is_locally_fraction 𝒜).pred a) :
(is_locally_fraction 𝒜).pred (-a) := λ x,
begin
rcases ha x with ⟨V, m, i, j, ⟨r, r_mem⟩, ⟨s, s_mem⟩, w⟩,
choose nin hy using w,
refine ⟨V, m, i, j, ⟨-r, submodule.neg_mem _ r_mem⟩, ⟨s, s_mem⟩, λ y, ⟨nin y, _⟩⟩,
simp only [ext_iff_val, val_mk', ←subtype.val_eq_coe] at hy,
simp only [pi.neg_apply, ext_iff_val, neg_val, hy, val_mk', ←subtype.val_eq_coe, neg_mk],
end
lemma mul_mem' (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ)
(a b : Π x : unop U, at x.1)
(ha : (is_locally_fraction 𝒜).pred a) (hb : (is_locally_fraction 𝒜).pred b) :
(is_locally_fraction 𝒜).pred (a * b) := λ x,
begin
rcases ha x with ⟨Va, ma, ia, ja, ⟨ra, ra_mem⟩, ⟨sa, sa_mem⟩, wa⟩,
rcases hb x with ⟨Vb, mb, ib, jb, ⟨rb, rb_mem⟩, ⟨sb, sb_mem⟩, wb⟩,
refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, opens.inf_le_left _ _ ≫ ia, ja + jb,
⟨ra * rb, set_like.mul_mem_graded ra_mem rb_mem⟩,
⟨sa * sb, set_like.mul_mem_graded sa_mem sb_mem⟩, λ y, ⟨λ h, _, _⟩⟩,
{ cases (y : projective_spectrum.Top 𝒜).is_prime.mem_or_mem h with h h,
{ choose nin hy using wa ⟨y, (opens.inf_le_left Va Vb y).2⟩, exact nin h },
{ choose nin hy using wb ⟨y, (opens.inf_le_right Va Vb y).2⟩, exact nin h }, },
{ simp only [pi.mul_apply, ring_hom.map_mul],
choose nin1 hy1 using wa (opens.inf_le_left Va Vb y),
choose nin2 hy2 using wb (opens.inf_le_right Va Vb y),
rw ext_iff_val at hy1 hy2 ⊢,
erw [mul_val, hy1, hy2],
simpa only [val_mk', mk_mul, ← subtype.val_eq_coe] }
end
end section_subring
section
open section_subring
variable {𝒜}
/--The functions satisfying `is_locally_fraction` form a subring of all dependent functions
`Π x : U, homogeneous_localization 𝒜 x`.-/
def sections_subring (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ) : subring (Π x : unop U, at x.1) :=
{ carrier := { f | (is_locally_fraction 𝒜).pred f },
zero_mem' := zero_mem' U,
one_mem' := one_mem' U,
add_mem' := add_mem' U,
neg_mem' := neg_mem' U,
mul_mem' := mul_mem' U }
end
/--The structure sheaf (valued in `Type`, not yet `CommRing`) is the subsheaf consisting of
functions satisfying `is_locally_fraction`.-/
def structure_sheaf_in_Type : sheaf Type* (projective_spectrum.Top 𝒜):=
subsheaf_to_Types (is_locally_fraction 𝒜)
instance comm_ring_structure_sheaf_in_Type_obj (U : (opens (projective_spectrum.Top 𝒜))ᵒᵖ) :
comm_ring ((structure_sheaf_in_Type 𝒜).1.obj U) := (sections_subring U).to_comm_ring
/--The structure presheaf, valued in `CommRing`, constructed by dressing up the `Type` valued
structure presheaf.-/
@[simps] def structure_presheaf_in_CommRing : presheaf CommRing (projective_spectrum.Top 𝒜) :=
{ obj := λ U, CommRing.of ((structure_sheaf_in_Type 𝒜).1.obj U),
map := λ U V i,
{ to_fun := ((structure_sheaf_in_Type 𝒜).1.map i),
map_zero' := rfl,
map_add' := λ x y, rfl,
map_one' := rfl,
map_mul' := λ x y, rfl, }, }
/--Some glue, verifying that that structure presheaf valued in `CommRing` agrees with the `Type`
valued structure presheaf.-/
def structure_presheaf_comp_forget :
structure_presheaf_in_CommRing 𝒜 ⋙ (forget CommRing) ≅ (structure_sheaf_in_Type 𝒜).1 :=
nat_iso.of_components (λ U, iso.refl _) (by tidy)
end projective_spectrum.structure_sheaf
namespace projective_spectrum
open Top.presheaf projective_spectrum.structure_sheaf opens
/--The structure sheaf on `Proj` 𝒜, valued in `CommRing`.-/
def Proj.structure_sheaf : sheaf CommRing (projective_spectrum.Top 𝒜) :=
⟨structure_presheaf_in_CommRing 𝒜,
-- We check the sheaf condition under `forget CommRing`.
(is_sheaf_iff_is_sheaf_comp _ _).mpr
(is_sheaf_of_iso (structure_presheaf_comp_forget 𝒜).symm
(structure_sheaf_in_Type 𝒜).cond)⟩
end projective_spectrum
section
open projective_spectrum projective_spectrum.structure_sheaf opens
@[simp] lemma res_apply (U V : opens (projective_spectrum.Top 𝒜)) (i : V ⟶ U)
(s : (Proj.structure_sheaf 𝒜).1.obj (op U)) (x : V) :
((Proj.structure_sheaf 𝒜).1.map i.op s).1 x = (s.1 (i x) : _) :=
rfl
/--`Proj` of a graded ring as a `SheafedSpace`-/
def Proj.to_SheafedSpace : SheafedSpace CommRing :=
{ carrier := Top.of (projective_spectrum 𝒜),
presheaf := (Proj.structure_sheaf 𝒜).1,
is_sheaf := (Proj.structure_sheaf 𝒜).2 }
/-- The ring homomorphism that takes a section of the structure sheaf of `Proj` on the open set `U`,
implemented as a subtype of dependent functions to localizations at homogeneous prime ideals, and
evaluates the section on the point corresponding to a given homogeneous prime ideal. -/
def open_to_localization (U : opens (projective_spectrum.Top 𝒜)) (x : projective_spectrum.Top 𝒜)
(hx : x ∈ U) :
(Proj.structure_sheaf 𝒜).1.obj (op U) ⟶ CommRing.of (at x) :=
{ to_fun := λ s, (s.1 ⟨x, hx⟩ : _),
map_one' := rfl,
map_mul' := λ _ _, rfl,
map_zero' := rfl,
map_add' := λ _ _, rfl }
/-- The ring homomorphism from the stalk of the structure sheaf of `Proj` at a point corresponding
to a homogeneous prime ideal `x` to the *homogeneous localization* at `x`,
formed by gluing the `open_to_localization` maps. -/
def stalk_to_fiber_ring_hom (x : projective_spectrum.Top 𝒜) :
(Proj.structure_sheaf 𝒜).presheaf.stalk x ⟶ CommRing.of (at x) :=
limits.colimit.desc (((open_nhds.inclusion x).op) ⋙ (Proj.structure_sheaf 𝒜).1)
{ X := _,
ι :=
{ app := λ U, open_to_localization 𝒜 ((open_nhds.inclusion _).obj (unop U)) x (unop U).2, } }
@[simp] lemma germ_comp_stalk_to_fiber_ring_hom (U : opens (projective_spectrum.Top 𝒜)) (x : U) :
(Proj.structure_sheaf 𝒜).presheaf.germ x ≫ stalk_to_fiber_ring_hom 𝒜 x =
open_to_localization 𝒜 U x x.2 :=
limits.colimit.ι_desc _ _
@[simp] lemma stalk_to_fiber_ring_hom_germ' (U : opens (projective_spectrum.Top 𝒜))
(x : projective_spectrum.Top 𝒜) (hx : x ∈ U) (s : (Proj.structure_sheaf 𝒜).1.obj (op U)) :
stalk_to_fiber_ring_hom 𝒜 x
((Proj.structure_sheaf 𝒜).presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=
ring_hom.ext_iff.1 (germ_comp_stalk_to_fiber_ring_hom 𝒜 U ⟨x, hx⟩ : _) s
@[simp] lemma stalk_to_fiber_ring_hom_germ (U : opens (projective_spectrum.Top 𝒜)) (x : U)
(s : (Proj.structure_sheaf 𝒜).1.obj (op U)) :
stalk_to_fiber_ring_hom 𝒜 x ((Proj.structure_sheaf 𝒜).presheaf.germ x s) = s.1 x :=
by { cases x, exact stalk_to_fiber_ring_hom_germ' 𝒜 U _ _ _ }
lemma homogeneous_localization.mem_basic_open (x : projective_spectrum.Top 𝒜) (f : at x) :
x ∈ projective_spectrum.basic_open 𝒜 f.denom :=
by { rw projective_spectrum.mem_basic_open, exact f.denom_mem }
variable (𝒜)
/--Given a point `x` corresponding to a homogeneous prime ideal, there is a (dependent) function
such that, for any `f` in the homogeneous localization at `x`, it returns the obvious section in the
basic open set `D(f.denom)`-/
def section_in_basic_open (x : projective_spectrum.Top 𝒜) :
Π (f : at x),
(Proj.structure_sheaf 𝒜).1.obj (op (projective_spectrum.basic_open 𝒜 f.denom)) :=
λ f, ⟨λ y, quotient.mk' ⟨f.deg, ⟨f.num, f.num_mem_deg⟩, ⟨f.denom, f.denom_mem_deg⟩, y.2⟩,
λ y, ⟨projective_spectrum.basic_open 𝒜 f.denom, y.2,
⟨𝟙 _, ⟨f.deg, ⟨⟨f.num, f.num_mem_deg⟩, ⟨f.denom, f.denom_mem_deg⟩,
λ z, ⟨z.2, rfl⟩⟩⟩⟩⟩⟩
/--Given any point `x` and `f` in the homogeneous localization at `x`, there is an element in the
stalk at `x` obtained by `section_in_basic_open`. This is the inverse of `stalk_to_fiber_ring_hom`.
-/
def homogeneous_localization_to_stalk (x : projective_spectrum.Top 𝒜) :
(at x) → (Proj.structure_sheaf 𝒜).presheaf.stalk x :=
λ f, (Proj.structure_sheaf 𝒜).presheaf.germ
(⟨x, homogeneous_localization.mem_basic_open _ x f⟩ : projective_spectrum.basic_open _ f.denom)
(section_in_basic_open _ x f)
/--Using `homogeneous_localization_to_stalk`, we construct a ring isomorphism between stalk at `x`
and homogeneous localization at `x` for any point `x` in `Proj`.-/
def Proj.stalk_iso' (x : projective_spectrum.Top 𝒜) :
(Proj.structure_sheaf 𝒜).presheaf.stalk x ≃+* CommRing.of (at x) :=
ring_equiv.of_bijective (stalk_to_fiber_ring_hom _ x)
⟨λ z1 z2 eq1, begin
obtain ⟨u1, memu1, s1, rfl⟩ := (Proj.structure_sheaf 𝒜).presheaf.germ_exist x z1,
obtain ⟨u2, memu2, s2, rfl⟩ := (Proj.structure_sheaf 𝒜).presheaf.germ_exist x z2,
obtain ⟨v1, memv1, i1, ⟨j1, ⟨a1, a1_mem⟩, ⟨b1, b1_mem⟩, hs1⟩⟩ := s1.2 ⟨x, memu1⟩,
obtain ⟨v2, memv2, i2, ⟨j2, ⟨a2, a2_mem⟩, ⟨b2, b2_mem⟩, hs2⟩⟩ := s2.2 ⟨x, memu2⟩,
obtain ⟨b1_nin_x, eq2⟩ := hs1 ⟨x, memv1⟩,
obtain ⟨b2_nin_x, eq3⟩ := hs2 ⟨x, memv2⟩,
dsimp only at eq1 eq2 eq3,
erw [stalk_to_fiber_ring_hom_germ 𝒜 u1 ⟨x, memu1⟩ s1,
stalk_to_fiber_ring_hom_germ 𝒜 u2 ⟨x, memu2⟩ s2] at eq1,
erw eq1 at eq2,
erw [eq2, quotient.eq] at eq3,
change localization.mk _ _ = localization.mk _ _ at eq3,
rw [localization.mk_eq_mk', is_localization.eq] at eq3,
obtain ⟨⟨c, hc⟩, eq3⟩ := eq3,
simp only [← subtype.val_eq_coe] at eq3,
have eq3' : ∀ (y : projective_spectrum.Top 𝒜)
(hy : y ∈ projective_spectrum.basic_open 𝒜 b1 ⊓
projective_spectrum.basic_open 𝒜 b2 ⊓
projective_spectrum.basic_open 𝒜 c),
(localization.mk a1
⟨b1, show b1 ∉ y.as_homogeneous_ideal,
by rw ←projective_spectrum.mem_basic_open;
exact le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_left _ _) hy⟩ :
localization.at_prime y.1.to_ideal) =
localization.mk a2
⟨b2, show b2 ∉ y.as_homogeneous_ideal,
by rw ←projective_spectrum.mem_basic_open;
exact le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_right _ _) hy⟩,
{ intros y hy,
rw [localization.mk_eq_mk', is_localization.eq],
exact ⟨⟨c, show c ∉ y.as_homogeneous_ideal, by rw ←projective_spectrum.mem_basic_open;
exact le_of_hom (opens.inf_le_right _ _) hy⟩, eq3⟩ },
refine presheaf.germ_ext (Proj.structure_sheaf 𝒜).1
(projective_spectrum.basic_open _ b1 ⊓
projective_spectrum.basic_open _ b2 ⊓
projective_spectrum.basic_open _ c ⊓ v1 ⊓ v2)
⟨⟨⟨⟨b1_nin_x, b2_nin_x⟩, hc⟩, memv1⟩, memv2⟩
(opens.inf_le_left _ _ ≫ opens.inf_le_right _ _ ≫ i1) (opens.inf_le_right _ _ ≫ i2) _,
rw subtype.ext_iff_val,
ext1 y,
simp only [res_apply],
obtain ⟨b1_nin_y, eq6⟩ := hs1 ⟨_, le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_right _ _) y.2⟩,
obtain ⟨b2_nin_y, eq7⟩ := hs2 ⟨_, le_of_hom (opens.inf_le_right _ _) y.2⟩,
simp only at eq6 eq7,
erw [eq6, eq7, quotient.eq],
change localization.mk _ _ = localization.mk _ _,
exact eq3' _ ⟨⟨le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_left _ _ ≫
opens.inf_le_left _ _ ≫ opens.inf_le_left _ _) y.2,
le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_left _ _ ≫
opens.inf_le_left _ _ ≫ opens.inf_le_right _ _) y.2⟩,
le_of_hom (opens.inf_le_left _ _ ≫ opens.inf_le_left _ _ ≫
opens.inf_le_right _ _) y.2⟩,
end, function.surjective_iff_has_right_inverse.mpr ⟨homogeneous_localization_to_stalk 𝒜 x,
λ f, begin
rw homogeneous_localization_to_stalk,
erw stalk_to_fiber_ring_hom_germ 𝒜
(projective_spectrum.basic_open 𝒜 f.denom) ⟨x, _⟩ (section_in_basic_open _ x f),
simp only [section_in_basic_open, subtype.ext_iff_val, homogeneous_localization.ext_iff_val,
homogeneous_localization.val_mk', f.eq_num_div_denom],
refl,
end⟩⟩
/--`Proj` of a graded ring as a `LocallyRingedSpace`-/
def Proj.to_LocallyRingedSpace : LocallyRingedSpace :=
{ local_ring := λ x, @@ring_equiv.local_ring _
(show local_ring (at x), from infer_instance) _
(Proj.stalk_iso' 𝒜 x).symm,
..(Proj.to_SheafedSpace 𝒜) }
end
end algebraic_geometry
|
01048611a2fb1fdfab681c80ec4e2c1ff3a1fd42 | a9d0fb7b0e4f802bd3857b803e6c5c23d87fef91 | /library/algebra/interval.lean | 82372f13cf1bffa00d41ae8668ca8c666cd92b3d | [
"Apache-2.0"
] | permissive | soonhokong/lean-osx | 4a954262c780e404c1369d6c06516161d07fcb40 | 3670278342d2f4faa49d95b46d86642d7875b47c | refs/heads/master | 1,611,410,334,552 | 1,474,425,686,000 | 1,474,425,686,000 | 12,043,103 | 5 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 6,598 | lean | /-
Copyright (c) 2015 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Jeremy Avigad
Notation for intervals and some properties.
The mnemonic: o = open, c = closed, i = infinity. For example, Ioi a b is '(a, ∞).
-/
import .order data.set
open set
namespace interval
section order_pair
variables {A : Type} [order_pair A]
definition Ioo (a b : A) : set A := {x | a < x ∧ x < b}
definition Ioc (a b : A) : set A := {x | a < x ∧ x ≤ b}
definition Ico (a b : A) : set A := {x | a ≤ x ∧ x < b}
definition Icc (a b : A) : set A := {x | a ≤ x ∧ x ≤ b}
definition Ioi (a : A) : set A := {x | a < x}
definition Ici (a : A) : set A := {x | a ≤ x}
definition Iio (b : A) : set A := {x | x < b}
definition Iic (b : A) : set A := {x | x ≤ b}
notation `'(` a `, ` b `)` := Ioo a b
notation `'(` a `, ` b `]` := Ioc a b
notation `'[` a `, ` b `)` := Ico a b
notation `'[` a `, ` b `]` := Icc a b
notation `'(` a `, ` `∞` `)` := Ioi a
notation `'[` a `, ` `∞` `)` := Ici a
notation `'(` `-∞` `, ` b `)` := Iio b
notation `'(` `-∞` `, ` b `]` := Iic b
variables a b : A
proposition Ioi_inter_Iio : '(a, ∞) ∩ '(-∞, b) = '(a, b) := rfl
proposition Ici_inter_Iio : '[a, ∞) ∩ '(-∞, b) = '[a, b) := rfl
proposition Ioi_inter_Iic : '(a, ∞) ∩ '(-∞, b] = '(a, b] := rfl
proposition Ioc_inter_Iic : '[a, ∞) ∩ '(-∞, b] = '[a, b] := rfl
proposition Icc_self : '[a, a] = '{a} :=
set.ext (take x, iff.intro
(suppose x ∈ '[a, a],
have x = a, from le.antisymm (and.right this) (and.left this),
show x ∈ '{a}, from mem_singleton_of_eq this)
(suppose x ∈ '{a},
have x = a, from eq_of_mem_singleton this,
show a ≤ x ∧ x ≤ a, from and.intro (eq.subst this !le.refl) (eq.subst this !le.refl)))
proposition Icc_eq_empty {a b : A} (H : b < a) : '[a, b] = ∅ :=
eq_empty_of_forall_not_mem
(take x, suppose x ∈ '[a, b],
have a ≤ b, from le.trans (and.left this) (and.right this),
not_le_of_gt H this)
end order_pair
section strong_order_pair
variables {A : Type} [linear_strong_order_pair A]
proposition compl_Ici (a : A) : -'[a, ∞) = '(-∞, a) :=
ext (take x, iff.intro
(assume H, lt_of_not_ge H)
(assume H, not_le_of_gt H))
proposition compl_Iic (a : A) : -'(-∞, a] = '(a, ∞) :=
ext (take x, iff.intro
(assume H, lt_of_not_ge H)
(assume H, not_le_of_gt H))
proposition compl_Ioi (a : A) : -'(a, ∞) = '(-∞, a] :=
ext (take x, iff.intro
(assume H, le_of_not_gt H)
(assume H, not_lt_of_ge H))
proposition compl_Iio (a : A) : -'(-∞, a) = '[a, ∞) :=
ext (take x, iff.intro
(assume H, le_of_not_gt H)
(assume H, not_lt_of_ge H))
proposition Icc_eq_Icc_union_Ioc {a b c : A} (H1 : a ≤ b) (H2 : b ≤ c) :
'[a, c] = '[a, b] ∪ '(b, c] :=
set.ext (take x, iff.intro
(assume H3 : x ∈ '[a, c],
or.elim (le_or_gt x b)
(suppose x ≤ b,
or.inl (and.intro (and.left H3) this))
(suppose x > b,
or.inr (and.intro this (and.right H3))))
(suppose x ∈ '[a, b] ∪ '(b, c],
or.elim this
(suppose x ∈ '[a, b],
and.intro (and.left this) (le.trans (and.right this) H2))
(suppose x ∈ '(b, c],
and.intro (le_of_lt (lt_of_le_of_lt H1 (and.left this))) (and.right this))))
proposition singleton_union_Ioc {a b : A} (H : a ≤ b) : '{a} ∪ '(a, b] = '[a,b] :=
by rewrite [-Icc_self, Icc_eq_Icc_union_Ioc !le.refl H]
end strong_order_pair
/- intervals of natural numbers -/
namespace nat
open nat eq.ops
variables m n : ℕ
proposition Ioc_eq_Icc_succ : '(m, n] = '[succ m, n] := rfl
proposition Ioo_eq_Ico_succ : '(m, n) = '[succ m, n) := rfl
proposition Ico_succ_eq_Icc : '[m, succ n) = '[m, n] :=
set.ext (take x, iff.intro
(assume H, and.intro (and.left H) (le_of_lt_succ (and.right H)))
(assume H, and.intro (and.left H) (lt_succ_of_le (and.right H))))
proposition Ioo_succ_eq_Ioc : '(m, succ n) = '(m, n] :=
set.ext (take x, iff.intro
(assume H, and.intro (and.left H) (le_of_lt_succ (and.right H)))
(assume H, and.intro (and.left H) (lt_succ_of_le (and.right H))))
proposition Ici_zero : '[(0 : nat), ∞) = univ :=
eq_univ_of_forall (take x, zero_le x)
proposition Icc_zero (n : ℕ) : '[0, n] = '(-∞, n] :=
have '[0, n] = '[0, ∞) ∩ '(-∞, n], from rfl,
by rewrite [this, Ici_zero, univ_inter]
proposition bij_on_add_Icc_zero (m n : ℕ) : bij_on (add m) ('[0, n]) ('[m, m+n]) :=
have mapsto : ∀₀ i ∈ '[0, n], m + i ∈ '[m, m+n], from
(take i, assume imem,
have H1 : m ≤ m + i, from !le_add_right,
have H2 : m + i ≤ m + n, from add_le_add_left (and.right imem) m,
show m + i ∈ '[m, m+n], from and.intro H1 H2),
have injon : inj_on (add m) ('[0, n]), from
(take i j, assume Hi Hj H, !eq_of_add_eq_add_left H),
have surjon : surj_on (add m) ('[0, n]) ('[m, m+n]), from
(take j, assume Hj : j ∈ '[m, m+n],
obtain lej jle, from Hj,
let i := j - m in
have ile : i ≤ n, from calc
j - m ≤ m + n - m : nat.sub_le_sub_right jle m
... = n : nat.add_sub_cancel_left,
have iadd : m + i = j, by rewrite add.comm; apply nat.sub_add_cancel lej,
exists.intro i (and.intro (and.intro !zero_le ile) iadd)),
bij_on.mk mapsto injon surjon
end nat
section nat -- put the instances in the intervals namespace
open nat eq.ops
variables m n : ℕ
attribute [instance]
proposition nat.Iic_finite (n : ℕ) : finite '(-∞, n] :=
nat.induction_on n
(have '(-∞, 0] ⊆ '{0}, from λ x H, mem_singleton_of_eq (le.antisymm H !zero_le),
finite_subset this)
(take n, assume ih : finite '(-∞, n],
have '(-∞, succ n] ⊆ '(-∞, n] ∪ '{succ n},
by intro x H; rewrite [mem_union_iff, mem_singleton_iff]; apply le_or_eq_succ_of_le_succ H,
finite_subset this)
attribute [instance]
proposition nat.Iio_finite (n : ℕ) : finite '(-∞, n) :=
have '(-∞, n) ⊆ '(-∞, n], from λ x, le_of_lt,
finite_subset this
attribute [instance]
proposition nat.Icc_finite (m n : ℕ) : finite ('[m, n]) :=
have '[m, n] ⊆ '(-∞, n], from λ x H, and.right H,
finite_subset this
attribute [instance]
proposition nat.Ico_finite (m n : ℕ) : finite ('[m, n)) :=
have '[m, n) ⊆ '(-∞, n), from λ x H, and.right H,
finite_subset this
attribute [instance]
proposition nat.Ioc_finite (m n : ℕ) : finite '(m, n] :=
have '(m, n] ⊆ '(-∞, n], from λ x H, and.right H,
finite_subset this
end nat
end interval
|
96612a6018a494e9c0adb3d01092bbf5a05367b6 | cf39355caa609c0f33405126beee2739aa3cb77e | /library/init/meta/mk_has_reflect_instance.lean | cff1dcb415e6ff0cc46dd0cae48a0c6789c90c0a | [
"Apache-2.0"
] | permissive | leanprover-community/lean | 12b87f69d92e614daea8bcc9d4de9a9ace089d0e | cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0 | refs/heads/master | 1,687,508,156,644 | 1,684,951,104,000 | 1,684,951,104,000 | 169,960,991 | 457 | 107 | Apache-2.0 | 1,686,744,372,000 | 1,549,790,268,000 | C++ | UTF-8 | Lean | false | false | 3,779 | lean | /-
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sebastian Ullrich
Helper tactic for constructing a has_reflect instance.
-/
prelude
import init.meta.rec_util
namespace tactic
open expr environment list
/-- Retrieve the name of the type we are building a has_reflect instance for. -/
private meta def get_has_reflect_type_name : tactic name :=
do {
(app (const n ls) t) ← target,
when (n ≠ `has_reflect) failed,
(const I ls) ← return (get_app_fn t),
return I }
<|>
fail "mk_has_reflect_instance tactic failed, target type is expected to be of the form (has_reflect ...)"
/-- Try to synthesize constructor argument using type class resolution -/
private meta def mk_has_reflect_instance_for (a : expr) : tactic expr :=
do t ← infer_type a,
do {
m ← mk_mapp `reflected [none, some a],
inst ← mk_instance m
<|> do {
f ← pp t,
fail (to_fmt "mk_has_reflect_instance failed, failed to generate instance for" ++ format.nest 2 (format.line ++ f))
},
mk_app `reflect [a, inst] }
/-- Synthesize (recursive) instances of `reflected` for all fields -/
private meta def mk_reflect : name → name → list name → nat → tactic (list expr)
| I_name F_name [] num_rec := return []
| I_name F_name (fname::fnames) num_rec := do
field ← get_local fname,
rec ← is_type_app_of field I_name,
quote ← if rec then mk_brec_on_rec_value F_name num_rec else mk_has_reflect_instance_for field,
quotes ← mk_reflect I_name F_name fnames (if rec then num_rec + 1 else num_rec),
return (quote :: quotes)
/-- Solve the subgoal for constructor `F_name` -/
private meta def has_reflect_case (I_name F_name : name) (field_names : list name) : tactic unit :=
do field_quotes ← mk_reflect I_name F_name field_names 0,
-- fn should be of the form `F_name ps fs`, where ps are the inductive parameter arguments,
-- and `fs.length = field_names.length`
`(reflected _ %%fn) ← target,
-- `reflected _ (F_name ps)` should be synthesizable directly, using instances from the context
let fn := field_names.foldl (λ fn _, expr.app_fn fn) fn,
quote ← mk_mapp `reflected [none, some fn] >>= mk_instance,
-- now extend to an instance of `reflected _ (F_name ps fs)`
quote ← field_quotes.mfoldl (λ quote fquote, to_expr ``(reflected.subst %%quote %%fquote)) quote,
exact quote
private meta def for_each_has_reflect_goal : name → name → list (list name) → tactic unit
| I_name F_name [] := done <|> fail "mk_has_reflect_instance failed, unexpected number of cases"
| I_name F_name (ns::nss) := do
solve1 (has_reflect_case I_name F_name ns),
for_each_has_reflect_goal I_name F_name nss
/-- Solves a goal of the form `has_reflect α` where α is an inductive type.
Needs to synthesize a `reflected` instance for each inductive parameter type of α
and for each constructor parameter of α. -/
meta def mk_has_reflect_instance : tactic unit :=
do I_name ← get_has_reflect_type_name,
env ← get_env,
v_name : name ← return `_v,
F_name : name ← return `_F,
guard (env.inductive_num_indices I_name = 0) <|>
fail "mk_has_reflect_instance failed, indexed families are currently not supported",
-- Use brec_on if type is recursive.
-- We store the functional in the variable F.
if is_recursive env I_name
then intro `_v >>= (λ x, induction x [v_name, F_name] (some $ I_name <.> "brec_on") >> return ())
else intro v_name >> return (),
arg_names : list (list name) ← mk_constructors_arg_names I_name `_p,
get_local v_name >>= λ v, cases v (join arg_names),
for_each_has_reflect_goal I_name F_name arg_names
end tactic
|
891c46643191d9fd86c861831bc17e2c2b18fa1f | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/lean/unusedLet.lean | d1f0f86ffe1d8cd2c807caae319df7202e2b8fbc | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | leanprover/lean4 | 4bdf9790294964627eb9be79f5e8f6157780b4cc | f1f9dc0f2f531af3312398999d8b8303fa5f096b | refs/heads/master | 1,693,360,665,786 | 1,693,350,868,000 | 1,693,350,868,000 | 129,571,436 | 2,827 | 311 | Apache-2.0 | 1,694,716,156,000 | 1,523,760,560,000 | Lean | UTF-8 | Lean | false | false | 123 | lean | def pro := let x := 42; false
#print pro
def f : Nat → Nat
| 0 => 1
| n+1 =>
let y := 42
2 * f n
#print f
|
5267a3c6d9a37b452d2081fe69654b687b88525f | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/linear_algebra/quotient.lean | 514cef1e606862a2aaeeae821c83d54ff903e205 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 21,248 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov
-/
import group_theory.quotient_group
import linear_algebra.span
/-!
# Quotients by submodules
* If `p` is a submodule of `M`, `M ⧸ p` is the quotient of `M` with respect to `p`:
that is, elements of `M` are identified if their difference is in `p`. This is itself a module.
-/
-- For most of this file we work over a noncommutative ring
section ring
namespace submodule
variables {R M : Type*} {r : R} {x y : M} [ring R] [add_comm_group M] [module R M]
variables (p p' : submodule R M)
open linear_map quotient_add_group
/-- The equivalence relation associated to a submodule `p`, defined by `x ≈ y` iff `-x + y ∈ p`.
Note this is equivalent to `y - x ∈ p`, but defined this way to be be defeq to the `add_subgroup`
version, where commutativity can't be assumed. -/
def quotient_rel : setoid M :=
quotient_add_group.left_rel p.to_add_subgroup
lemma quotient_rel_r_def {x y : M} : @setoid.r _ (p.quotient_rel) x y ↔ x - y ∈ p :=
iff.trans (by { rw [left_rel_apply, sub_eq_add_neg, neg_add, neg_neg], refl }) neg_mem_iff
/-- The quotient of a module `M` by a submodule `p ⊆ M`. -/
instance has_quotient : has_quotient M (submodule R M) := ⟨λ p, quotient (quotient_rel p)⟩
namespace quotient
/-- Map associating to an element of `M` the corresponding element of `M/p`,
when `p` is a submodule of `M`. -/
def mk {p : submodule R M} : M → M ⧸ p := quotient.mk'
@[simp] theorem mk_eq_mk {p : submodule R M} (x : M) :
(@_root_.quotient.mk _ (quotient_rel p) x) = mk x := rfl
@[simp] theorem mk'_eq_mk {p : submodule R M} (x : M) : (quotient.mk' x : M ⧸ p) = mk x := rfl
@[simp] theorem quot_mk_eq_mk {p : submodule R M} (x : M) : (quot.mk _ x : M ⧸ p) = mk x := rfl
protected theorem eq' {x y : M} : (mk x : M ⧸ p) = mk y ↔ -x + y ∈ p := quotient_add_group.eq
protected theorem eq {x y : M} : (mk x : M ⧸ p) = mk y ↔ x - y ∈ p :=
(p^.quotient.eq').trans (left_rel_apply.symm.trans p.quotient_rel_r_def)
instance : has_zero (M ⧸ p) := ⟨mk 0⟩
instance : inhabited (M ⧸ p) := ⟨0⟩
@[simp] theorem mk_zero : mk 0 = (0 : M ⧸ p) := rfl
@[simp] theorem mk_eq_zero : (mk x : M ⧸ p) = 0 ↔ x ∈ p :=
by simpa using (quotient.eq p : mk x = 0 ↔ _)
instance add_comm_group : add_comm_group (M ⧸ p) :=
quotient_add_group.add_comm_group p.to_add_subgroup
@[simp] theorem mk_add : (mk (x + y) : M ⧸ p) = mk x + mk y := rfl
@[simp] theorem mk_neg : (mk (-x) : M ⧸ p) = -mk x := rfl
@[simp] theorem mk_sub : (mk (x - y) : M ⧸ p) = mk x - mk y := rfl
section has_smul
variables {S : Type*} [has_smul S R] [has_smul S M] [is_scalar_tower S R M] (P : submodule R M)
instance has_smul' : has_smul S (M ⧸ P) :=
⟨λ a, quotient.map' ((•) a) $ λ x y h, left_rel_apply.mpr $
by simpa [smul_sub] using P.smul_mem (a • 1 : R) (left_rel_apply.mp h)⟩
/-- Shortcut to help the elaborator in the common case. -/
instance has_smul : has_smul R (M ⧸ P) :=
quotient.has_smul' P
@[simp] theorem mk_smul (r : S) (x : M) : (mk (r • x) : M ⧸ p) = r • mk x := rfl
instance smul_comm_class (T : Type*) [has_smul T R] [has_smul T M] [is_scalar_tower T R M]
[smul_comm_class S T M] : smul_comm_class S T (M ⧸ P) :=
{ smul_comm := λ x y, quotient.ind' $ by exact λ z, congr_arg mk (smul_comm _ _ _) }
instance is_scalar_tower (T : Type*) [has_smul T R] [has_smul T M] [is_scalar_tower T R M]
[has_smul S T] [is_scalar_tower S T M] : is_scalar_tower S T (M ⧸ P) :=
{ smul_assoc := λ x y, quotient.ind' $ by exact λ z, congr_arg mk (smul_assoc _ _ _) }
instance is_central_scalar [has_smul Sᵐᵒᵖ R] [has_smul Sᵐᵒᵖ M] [is_scalar_tower Sᵐᵒᵖ R M]
[is_central_scalar S M] : is_central_scalar S (M ⧸ P) :=
{ op_smul_eq_smul := λ x, quotient.ind' $ by exact λ z, congr_arg mk $ op_smul_eq_smul _ _ }
end has_smul
section module
variables {S : Type*}
instance mul_action' [monoid S] [has_smul S R] [mul_action S M] [is_scalar_tower S R M]
(P : submodule R M) : mul_action S (M ⧸ P) :=
function.surjective.mul_action mk (surjective_quot_mk _) P^.quotient.mk_smul
instance mul_action (P : submodule R M) : mul_action R (M ⧸ P) :=
quotient.mul_action' P
instance smul_zero_class' [has_smul S R] [smul_zero_class S M]
[is_scalar_tower S R M]
(P : submodule R M) : smul_zero_class S (M ⧸ P) :=
zero_hom.smul_zero_class ⟨mk, mk_zero _⟩ P^.quotient.mk_smul
instance smul_zero_class (P : submodule R M) : smul_zero_class R (M ⧸ P) :=
quotient.smul_zero_class' P
instance distrib_smul' [has_smul S R] [distrib_smul S M]
[is_scalar_tower S R M]
(P : submodule R M) : distrib_smul S (M ⧸ P) :=
function.surjective.distrib_smul
⟨mk, rfl, λ _ _, rfl⟩ (surjective_quot_mk _) P^.quotient.mk_smul
instance distrib_smul (P : submodule R M) : distrib_smul R (M ⧸ P) :=
quotient.distrib_smul' P
instance distrib_mul_action' [monoid S] [has_smul S R] [distrib_mul_action S M]
[is_scalar_tower S R M]
(P : submodule R M) : distrib_mul_action S (M ⧸ P) :=
function.surjective.distrib_mul_action
⟨mk, rfl, λ _ _, rfl⟩ (surjective_quot_mk _) P^.quotient.mk_smul
instance distrib_mul_action (P : submodule R M) : distrib_mul_action R (M ⧸ P) :=
quotient.distrib_mul_action' P
instance module' [semiring S] [has_smul S R] [module S M] [is_scalar_tower S R M]
(P : submodule R M) : module S (M ⧸ P) :=
function.surjective.module _
⟨mk, rfl, λ _ _, rfl⟩ (surjective_quot_mk _) P^.quotient.mk_smul
instance module (P : submodule R M) : module R (M ⧸ P) :=
quotient.module' P
variables (S)
/-- The quotient of `P` as an `S`-submodule is the same as the quotient of `P` as an `R`-submodule,
where `P : submodule R M`.
-/
def restrict_scalars_equiv [ring S] [has_smul S R] [module S M] [is_scalar_tower S R M]
(P : submodule R M) :
(M ⧸ P.restrict_scalars S) ≃ₗ[S] M ⧸ P :=
{ map_add' := λ x y, quotient.induction_on₂' x y (λ x' y', rfl),
map_smul' := λ c x, quotient.induction_on' x (λ x', rfl),
..quotient.congr_right $ λ _ _, iff.rfl }
@[simp] lemma restrict_scalars_equiv_mk
[ring S] [has_smul S R] [module S M] [is_scalar_tower S R M] (P : submodule R M)
(x : M) : restrict_scalars_equiv S P (mk x) = mk x :=
rfl
@[simp] lemma restrict_scalars_equiv_symm_mk
[ring S] [has_smul S R] [module S M] [is_scalar_tower S R M] (P : submodule R M)
(x : M) : (restrict_scalars_equiv S P).symm (mk x) = mk x :=
rfl
end module
lemma mk_surjective : function.surjective (@mk _ _ _ _ _ p) :=
by { rintros ⟨x⟩, exact ⟨x, rfl⟩ }
lemma nontrivial_of_lt_top (h : p < ⊤) : nontrivial (M ⧸ p) :=
begin
obtain ⟨x, _, not_mem_s⟩ := set_like.exists_of_lt h,
refine ⟨⟨mk x, 0, _⟩⟩,
simpa using not_mem_s
end
end quotient
instance quotient_bot.infinite [infinite M] : infinite (M ⧸ (⊥ : submodule R M)) :=
infinite.of_injective submodule.quotient.mk $ λ x y h, sub_eq_zero.mp $
(submodule.quotient.eq ⊥).mp h
instance quotient_top.unique : unique (M ⧸ (⊤ : submodule R M)) :=
{ default := 0,
uniq := λ x, quotient.induction_on' x $ λ x, (submodule.quotient.eq ⊤).mpr submodule.mem_top }
instance quotient_top.fintype : fintype (M ⧸ (⊤ : submodule R M)) :=
fintype.of_subsingleton 0
variables {p}
lemma subsingleton_quotient_iff_eq_top : subsingleton (M ⧸ p) ↔ p = ⊤ :=
begin
split,
{ rintro h,
refine eq_top_iff.mpr (λ x _, _),
have this : x - 0 ∈ p := (submodule.quotient.eq p).mp (by exactI subsingleton.elim _ _),
rwa sub_zero at this },
{ rintro rfl,
apply_instance }
end
lemma unique_quotient_iff_eq_top : nonempty (unique (M ⧸ p)) ↔ p = ⊤ :=
⟨λ ⟨h⟩, subsingleton_quotient_iff_eq_top.mp (@@unique.subsingleton h),
by { rintro rfl, exact ⟨quotient_top.unique⟩ }⟩
variables (p)
noncomputable instance quotient.fintype [fintype M] (S : submodule R M) :
fintype (M ⧸ S) :=
@@quotient.fintype _ _ (λ _ _, classical.dec _)
lemma card_eq_card_quotient_mul_card [fintype M] (S : submodule R M) [decidable_pred (∈ S)] :
fintype.card M = fintype.card S * fintype.card (M ⧸ S) :=
by { rw [mul_comm, ← fintype.card_prod],
exact fintype.card_congr add_subgroup.add_group_equiv_quotient_times_add_subgroup }
section
variables {M₂ : Type*} [add_comm_group M₂] [module R M₂]
lemma quot_hom_ext ⦃f g : M ⧸ p →ₗ[R] M₂⦄ (h : ∀ x, f (quotient.mk x) = g (quotient.mk x)) :
f = g :=
linear_map.ext $ λ x, quotient.induction_on' x h
/-- The map from a module `M` to the quotient of `M` by a submodule `p` as a linear map. -/
def mkq : M →ₗ[R] M ⧸ p :=
{ to_fun := quotient.mk, map_add' := by simp, map_smul' := by simp }
@[simp] theorem mkq_apply (x : M) : p.mkq x = quotient.mk x := rfl
lemma mkq_surjective (A : submodule R M) : function.surjective A.mkq :=
by rintro ⟨x⟩; exact ⟨x, rfl⟩
end
variables {R₂ M₂ : Type*} [ring R₂] [add_comm_group M₂] [module R₂ M₂] {τ₁₂ : R →+* R₂}
/-- Two `linear_map`s from a quotient module are equal if their compositions with
`submodule.mkq` are equal.
See note [partially-applied ext lemmas]. -/
@[ext]
lemma linear_map_qext ⦃f g : M ⧸ p →ₛₗ[τ₁₂] M₂⦄ (h : f.comp p.mkq = g.comp p.mkq) : f = g :=
linear_map.ext $ λ x, quotient.induction_on' x $ (linear_map.congr_fun h : _)
/-- The map from the quotient of `M` by a submodule `p` to `M₂` induced by a linear map `f : M → M₂`
vanishing on `p`, as a linear map. -/
def liftq (f : M →ₛₗ[τ₁₂] M₂) (h : p ≤ f.ker) : M ⧸ p →ₛₗ[τ₁₂] M₂ :=
{ map_smul' := by rintro a ⟨x⟩; exact f.map_smulₛₗ a x,
..quotient_add_group.lift p.to_add_subgroup f.to_add_monoid_hom h }
@[simp] theorem liftq_apply (f : M →ₛₗ[τ₁₂] M₂) {h} (x : M) :
p.liftq f h (quotient.mk x) = f x := rfl
@[simp] theorem liftq_mkq (f : M →ₛₗ[τ₁₂] M₂) (h) : (p.liftq f h).comp p.mkq = f :=
by ext; refl
/--Special case of `liftq` when `p` is the span of `x`. In this case, the condition on `f` simply
becomes vanishing at `x`.-/
def liftq_span_singleton (x : M) (f : M →ₛₗ[τ₁₂] M₂) (h : f x = 0) : (M ⧸ R ∙ x) →ₛₗ[τ₁₂] M₂ :=
(R ∙ x).liftq f $ by rw [span_singleton_le_iff_mem, linear_map.mem_ker, h]
@[simp] lemma liftq_span_singleton_apply (x : M) (f : M →ₛₗ[τ₁₂] M₂) (h : f x = 0) (y : M) :
liftq_span_singleton x f h (quotient.mk y) = f y := rfl
@[simp] theorem range_mkq : p.mkq.range = ⊤ :=
eq_top_iff'.2 $ by rintro ⟨x⟩; exact ⟨x, rfl⟩
@[simp] theorem ker_mkq : p.mkq.ker = p :=
by ext; simp
lemma le_comap_mkq (p' : submodule R (M ⧸ p)) : p ≤ comap p.mkq p' :=
by simpa using (comap_mono bot_le : p.mkq.ker ≤ comap p.mkq p')
@[simp] theorem mkq_map_self : map p.mkq p = ⊥ :=
by rw [eq_bot_iff, map_le_iff_le_comap, comap_bot, ker_mkq]; exact le_rfl
@[simp] theorem comap_map_mkq : comap p.mkq (map p.mkq p') = p ⊔ p' :=
by simp [comap_map_eq, sup_comm]
@[simp] theorem map_mkq_eq_top : map p.mkq p' = ⊤ ↔ p ⊔ p' = ⊤ :=
by simp only [map_eq_top_iff p.range_mkq, sup_comm, ker_mkq]
variables (q : submodule R₂ M₂)
/-- The map from the quotient of `M` by submodule `p` to the quotient of `M₂` by submodule `q` along
`f : M → M₂` is linear. -/
def mapq (f : M →ₛₗ[τ₁₂] M₂) (h : p ≤ comap f q) :
(M ⧸ p) →ₛₗ[τ₁₂] (M₂ ⧸ q) :=
p.liftq (q.mkq.comp f) $ by simpa [ker_comp] using h
@[simp] theorem mapq_apply (f : M →ₛₗ[τ₁₂] M₂) {h} (x : M) :
mapq p q f h (quotient.mk x) = quotient.mk (f x) := rfl
theorem mapq_mkq (f : M →ₛₗ[τ₁₂] M₂) {h} : (mapq p q f h).comp p.mkq = q.mkq.comp f :=
by ext x; refl
@[simp] lemma mapq_zero (h : p ≤ q.comap (0 : M →ₛₗ[τ₁₂] M₂) := by simp) :
p.mapq q (0 : M →ₛₗ[τ₁₂] M₂) h = 0 :=
by { ext, simp, }
/-- Given submodules `p ⊆ M`, `p₂ ⊆ M₂`, `p₃ ⊆ M₃` and maps `f : M → M₂`, `g : M₂ → M₃` inducing
`mapq f : M ⧸ p → M₂ ⧸ p₂` and `mapq g : M₂ ⧸ p₂ → M₃ ⧸ p₃` then
`mapq (g ∘ f) = (mapq g) ∘ (mapq f)`. -/
lemma mapq_comp {R₃ M₃ : Type*} [ring R₃] [add_comm_group M₃] [module R₃ M₃]
(p₂ : submodule R₂ M₂) (p₃ : submodule R₃ M₃)
{τ₂₃ : R₂ →+* R₃} {τ₁₃ : R →+* R₃} [ring_hom_comp_triple τ₁₂ τ₂₃ τ₁₃]
(f : M →ₛₗ[τ₁₂] M₂) (g : M₂ →ₛₗ[τ₂₃] M₃) (hf : p ≤ p₂.comap f) (hg : p₂ ≤ p₃.comap g)
(h := (hf.trans (comap_mono hg))) :
p.mapq p₃ (g.comp f) h = (p₂.mapq p₃ g hg).comp (p.mapq p₂ f hf) :=
by { ext, simp, }
@[simp] lemma mapq_id (h : p ≤ p.comap linear_map.id := by { rw comap_id, exact le_refl _ }) :
p.mapq p linear_map.id h = linear_map.id :=
by { ext, simp, }
lemma mapq_pow {f : M →ₗ[R] M} (h : p ≤ p.comap f) (k : ℕ)
(h' : p ≤ p.comap (f^k) := p.le_comap_pow_of_le_comap h k) :
p.mapq p (f^k) h' = (p.mapq p f h)^k :=
begin
induction k with k ih,
{ simp [linear_map.one_eq_id], },
{ simp only [linear_map.iterate_succ, ← ih],
apply p.mapq_comp, },
end
theorem comap_liftq (f : M →ₛₗ[τ₁₂] M₂) (h) :
q.comap (p.liftq f h) = (q.comap f).map (mkq p) :=
le_antisymm
(by rintro ⟨x⟩ hx; exact ⟨_, hx, rfl⟩)
(by rw [map_le_iff_le_comap, ← comap_comp, liftq_mkq]; exact le_rfl)
theorem map_liftq [ring_hom_surjective τ₁₂] (f : M →ₛₗ[τ₁₂] M₂) (h) (q : submodule R (M ⧸ p)) :
q.map (p.liftq f h) = (q.comap p.mkq).map f :=
le_antisymm
(by rintro _ ⟨⟨x⟩, hxq, rfl⟩; exact ⟨x, hxq, rfl⟩)
(by rintro _ ⟨x, hxq, rfl⟩; exact ⟨quotient.mk x, hxq, rfl⟩)
theorem ker_liftq (f : M →ₛₗ[τ₁₂] M₂) (h) :
ker (p.liftq f h) = (ker f).map (mkq p) := comap_liftq _ _ _ _
theorem range_liftq [ring_hom_surjective τ₁₂] (f : M →ₛₗ[τ₁₂] M₂) (h) :
range (p.liftq f h) = range f :=
by simpa only [range_eq_map] using map_liftq _ _ _ _
theorem ker_liftq_eq_bot (f : M →ₛₗ[τ₁₂] M₂) (h) (h' : ker f ≤ p) : ker (p.liftq f h) = ⊥ :=
by rw [ker_liftq, le_antisymm h h', mkq_map_self]
/-- The correspondence theorem for modules: there is an order isomorphism between submodules of the
quotient of `M` by `p`, and submodules of `M` larger than `p`. -/
def comap_mkq.rel_iso :
submodule R (M ⧸ p) ≃o {p' : submodule R M // p ≤ p'} :=
{ to_fun := λ p', ⟨comap p.mkq p', le_comap_mkq p _⟩,
inv_fun := λ q, map p.mkq q,
left_inv := λ p', map_comap_eq_self $ by simp,
right_inv := λ ⟨q, hq⟩, subtype.ext_val $ by simpa [comap_map_mkq p],
map_rel_iff' := λ p₁ p₂, comap_le_comap_iff $ range_mkq _ }
/-- The ordering on submodules of the quotient of `M` by `p` embeds into the ordering on submodules
of `M`. -/
def comap_mkq.order_embedding :
submodule R (M ⧸ p) ↪o submodule R M :=
(rel_iso.to_rel_embedding $ comap_mkq.rel_iso p).trans (subtype.rel_embedding _ _)
@[simp] lemma comap_mkq_embedding_eq (p' : submodule R (M ⧸ p)) :
comap_mkq.order_embedding p p' = comap p.mkq p' := rfl
lemma span_preimage_eq [ring_hom_surjective τ₁₂] {f : M →ₛₗ[τ₁₂] M₂} {s : set M₂} (h₀ : s.nonempty)
(h₁ : s ⊆ range f) :
span R (f ⁻¹' s) = (span R₂ s).comap f :=
begin
suffices : (span R₂ s).comap f ≤ span R (f ⁻¹' s),
{ exact le_antisymm (span_preimage_le f s) this, },
have hk : ker f ≤ span R (f ⁻¹' s),
{ let y := classical.some h₀, have hy : y ∈ s, { exact classical.some_spec h₀, },
rw ker_le_iff, use [y, h₁ hy], rw ← set.singleton_subset_iff at hy,
exact set.subset.trans subset_span (span_mono (set.preimage_mono hy)), },
rw ← left_eq_sup at hk, rw f.range_coe at h₁,
rw [hk, ←linear_map.map_le_map_iff, map_span, map_comap_eq, set.image_preimage_eq_of_subset h₁],
exact inf_le_right,
end
/-- If `P` is a submodule of `M` and `Q` a submodule of `N`,
and `f : M ≃ₗ N` maps `P` to `Q`, then `M ⧸ P` is equivalent to `N ⧸ Q`. -/
@[simps] def quotient.equiv {N : Type*} [add_comm_group N] [module R N]
(P : submodule R M) (Q : submodule R N)
(f : M ≃ₗ[R] N) (hf : P.map f = Q) : (M ⧸ P) ≃ₗ[R] N ⧸ Q :=
{ to_fun := P.mapq Q (f : M →ₗ[R] N) (λ x hx, hf ▸ submodule.mem_map_of_mem hx),
inv_fun := Q.mapq P (f.symm : N →ₗ[R] M) (λ x hx, begin
rw [← hf, submodule.mem_map] at hx,
obtain ⟨y, hy, rfl⟩ := hx,
simpa
end),
left_inv := λ x, quotient.induction_on' x (by simp),
right_inv := λ x, quotient.induction_on' x (by simp),
.. P.mapq Q (f : M →ₗ[R] N) (λ x hx, hf ▸ submodule.mem_map_of_mem hx) }
@[simp] lemma quotient.equiv_symm {R M N : Type*} [comm_ring R]
[add_comm_group M] [module R M] [add_comm_group N] [module R N]
(P : submodule R M) (Q : submodule R N)
(f : M ≃ₗ[R] N) (hf : P.map f = Q) :
(quotient.equiv P Q f hf).symm =
quotient.equiv Q P f.symm ((submodule.map_symm_eq_iff f).mpr hf) :=
rfl
@[simp] lemma quotient.equiv_trans {N O : Type*} [add_comm_group N] [module R N]
[add_comm_group O] [module R O]
(P : submodule R M) (Q : submodule R N) (S : submodule R O)
(e : M ≃ₗ[R] N) (f : N ≃ₗ[R] O)
(he : P.map e = Q) (hf : Q.map f = S) (hef : P.map (e.trans f) = S) :
quotient.equiv P S (e.trans f) hef = (quotient.equiv P Q e he).trans (quotient.equiv Q S f hf) :=
begin
ext,
-- `simp` can deal with `hef` depending on `e` and `f`
simp only [quotient.equiv_apply, linear_equiv.trans_apply, linear_equiv.coe_trans],
-- `rw` can deal with `mapq_comp` needing extra hypotheses coming from the RHS
rw [mapq_comp, linear_map.comp_apply]
end
end submodule
open submodule
namespace linear_map
section ring
variables {R M R₂ M₂ R₃ M₃ : Type*}
variables [ring R] [ring R₂] [ring R₃]
variables [add_comm_monoid M] [add_comm_group M₂] [add_comm_monoid M₃]
variables [module R M] [module R₂ M₂] [module R₃ M₃]
variables {τ₁₂ : R →+* R₂} {τ₂₃ : R₂ →+* R₃} {τ₁₃ : R →+* R₃}
variables [ring_hom_comp_triple τ₁₂ τ₂₃ τ₁₃] [ring_hom_surjective τ₁₂]
lemma range_mkq_comp (f : M →ₛₗ[τ₁₂] M₂) : f.range.mkq.comp f = 0 :=
linear_map.ext $ λ x, by simp
lemma ker_le_range_iff {f : M →ₛₗ[τ₁₂] M₂} {g : M₂ →ₛₗ[τ₂₃] M₃} :
g.ker ≤ f.range ↔ f.range.mkq.comp g.ker.subtype = 0 :=
by rw [←range_le_ker_iff, submodule.ker_mkq, submodule.range_subtype]
/-- An epimorphism is surjective. -/
lemma range_eq_top_of_cancel {f : M →ₛₗ[τ₁₂] M₂}
(h : ∀ (u v : M₂ →ₗ[R₂] M₂ ⧸ f.range), u.comp f = v.comp f → u = v) : f.range = ⊤ :=
begin
have h₁ : (0 : M₂ →ₗ[R₂] M₂ ⧸ f.range).comp f = 0 := zero_comp _,
rw [←submodule.ker_mkq f.range, ←h 0 f.range.mkq (eq.trans h₁ (range_mkq_comp _).symm)],
exact ker_zero
end
end ring
end linear_map
open linear_map
namespace submodule
variables {R M : Type*} {r : R} {x y : M} [ring R] [add_comm_group M] [module R M]
variables (p p' : submodule R M)
/-- If `p = ⊥`, then `M / p ≃ₗ[R] M`. -/
def quot_equiv_of_eq_bot (hp : p = ⊥) : (M ⧸ p) ≃ₗ[R] M :=
linear_equiv.of_linear (p.liftq id $ hp.symm ▸ bot_le) p.mkq (liftq_mkq _ _ _) $
p.quot_hom_ext $ λ x, rfl
@[simp] lemma quot_equiv_of_eq_bot_apply_mk (hp : p = ⊥) (x : M) :
p.quot_equiv_of_eq_bot hp (quotient.mk x) = x := rfl
@[simp] lemma quot_equiv_of_eq_bot_symm_apply (hp : p = ⊥) (x : M) :
(p.quot_equiv_of_eq_bot hp).symm x = quotient.mk x := rfl
@[simp] lemma coe_quot_equiv_of_eq_bot_symm (hp : p = ⊥) :
((p.quot_equiv_of_eq_bot hp).symm : M →ₗ[R] M ⧸ p) = p.mkq := rfl
/-- Quotienting by equal submodules gives linearly equivalent quotients. -/
def quot_equiv_of_eq (h : p = p') : (M ⧸ p) ≃ₗ[R] M ⧸ p' :=
{ map_add' := by { rintros ⟨x⟩ ⟨y⟩, refl }, map_smul' := by { rintros x ⟨y⟩, refl },
..@quotient.congr _ _ (quotient_rel p) (quotient_rel p') (equiv.refl _) $
λ a b, by { subst h, refl } }
@[simp]
lemma quot_equiv_of_eq_mk (h : p = p') (x : M) :
submodule.quot_equiv_of_eq p p' h (submodule.quotient.mk x) = submodule.quotient.mk x :=
rfl
@[simp] lemma quotient.equiv_refl (P : submodule R M) (Q : submodule R M)
(hf : P.map (linear_equiv.refl R M : M →ₗ[R] M) = Q) :
quotient.equiv P Q (linear_equiv.refl R M) hf = quot_equiv_of_eq _ _ (by simpa using hf) :=
rfl
end submodule
end ring
section comm_ring
variables {R M M₂ : Type*} {r : R} {x y : M} [comm_ring R]
[add_comm_group M] [module R M] [add_comm_group M₂] [module R M₂]
(p : submodule R M) (q : submodule R M₂)
namespace submodule
/-- Given modules `M`, `M₂` over a commutative ring, together with submodules `p ⊆ M`, `q ⊆ M₂`,
the natural map $\{f ∈ Hom(M, M₂) | f(p) ⊆ q \} \to Hom(M/p, M₂/q)$ is linear. -/
def mapq_linear : compatible_maps p q →ₗ[R] (M ⧸ p) →ₗ[R] (M₂ ⧸ q) :=
{ to_fun := λ f, mapq _ _ f.val f.property,
map_add' := λ x y, by { ext, refl, },
map_smul' := λ c f, by { ext, refl, } }
end submodule
end comm_ring
|
78b2e4e305d6130c7b3d8c731cd5434a37436d76 | 8034095e1be60c0b8f6559c39220bd537d1f9933 | /lambda/types.lean | 972502d9482039b43bfdefa203160667472a5629 | [] | no_license | teodorov/lambda | 40c573e2dd268824641702d9f94cf61e019ae6c5 | 4dc4d595dd0ee20c59913ef0171fd33eb0d637a1 | refs/heads/master | 1,585,318,070,303 | 1,530,364,515,000 | 1,530,364,515,000 | 146,645,753 | 1 | 0 | null | 1,535,569,435,000 | 1,535,569,434,000 | null | UTF-8 | Lean | false | false | 2,053 | lean | namespace types
inductive term : Type
| var : string → term
| app : term → term → term
| lam : string → term → term
open term
def multi_lam (names : list string) (body : term) : term :=
list.foldr lam body names
def multi_app (t : term) (b : list term) : term :=
list.foldl app t b
def term_to_string : term → string
| (var n) := sformat! "{n}"
| (app (var e₁) (var e₂)) := sformat! "{e₁} {e₂}"
| (app e₁ (var e₂)) := sformat! "({term_to_string e₁}) {e₂}"
| (app (var e₁) e₂) := sformat! "{e₁} ({term_to_string e₂})"
| (app e₁ e₂) := sformat! "({term_to_string e₁}) ({term_to_string e₂})"
| (lam n t) := sformat! "λ{n}, {term_to_string t}"
instance term_has_to_string : has_to_string term :=
⟨term_to_string⟩
instance term_has_repr : has_repr term :=
⟨term_to_string⟩
def subst : string → term → term → term
| x newVal (lam y body) :=
if x ≠ y then lam y (subst x newVal body)
else lam y body
| x newVal (app e₁ e₂) :=
app (subst x newVal e₁) (subst x newVal e₂)
| x newVal (var y) :=
if x = y then newVal
else var y
inductive eval_result
| limit | normal
def result_to_string : eval_result → string
| eval_result.limit := "maximum recursion depth exceeded"
| eval_result.normal := "normal form"
instance result_has_to_string : has_to_string eval_result :=
⟨result_to_string⟩
instance result_has_repr : has_repr eval_result :=
⟨result_to_string⟩
def eval : nat → term → term × eval_result
| 0 r := (r, eval_result.limit)
| _ (lam x e) := (lam x e, eval_result.normal)
| _ (var n) := (var n, eval_result.normal)
| (nat.succ n) (app e₁ e₂) :=
match eval n e₁ with
| (lam x body, _) := eval n (subst x e₂ body)
| (res, r) := (app res e₂, r)
end
inductive repl_command : Type
| term : term → repl_command
| quit | help | env
| show_depth | clear_env | nothing
| show_import_depth
| load : string → repl_command
| depth : nat → repl_command
| import_depth : nat → repl_command
| bind : string → term → repl_command
end types
|
c69b7d41e72a58da0be302e43c7ae45d725fcead | 6df8d5ae3acf20ad0d7f0247d2cee1957ef96df1 | /notes/9.17.19.notes.lean | 4df3b6643dae2e81b7c786d50451aac2c8b5ad2d | [] | no_license | derekjohnsonva/CS2102 | 8ed45daa6658e6121bac0f6691eac6147d08246d | b3f507d4be824a2511838a1054d04fc9aef3304c | refs/heads/master | 1,648,529,162,527 | 1,578,851,859,000 | 1,578,851,859,000 | 233,433,207 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 803 | lean | /-
Namespaces: Declarative regions that provide scope to an identifier
-/
--First Namespace
namespace cs
def x := 1
#check x
#eval x
end cs
--Second Namespace
namespace oc
def x := "Hi!"
#check x
#eval x
end oc
--to evaluate variables outside of the namespace, prepend the variable with the namespace
#eval cs.x
#eval oc.x
open cs -- this opens the cs namespace until it is closed
--TYPES
#check 1 --check will return the data type
#check bool --data of type Type
--making a new data Type
inductive day : Type
| sun : day
| mon : day
| tue : day
| wed : day
| thu : day
| fri : day
| sat : day
inductive mybool : Type
| ttt
| fff
open day
def nextDay : day → day
| sun := mon
| mon := tue
| tue := wed
| wed := thu
| thu := fri
| fri := sat
| sat := sun |
dbc7c54e79add008997f4e0c47e94e07d84d6a3c | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/run/sorry.lean | 8685e3a5afae0963d922c7a865dd5e0dda5a4fce | [
"Apache-2.0"
] | permissive | leanprover-community/lean | 12b87f69d92e614daea8bcc9d4de9a9ace089d0e | cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0 | refs/heads/master | 1,687,508,156,644 | 1,684,951,104,000 | 1,684,951,104,000 | 169,960,991 | 457 | 107 | Apache-2.0 | 1,686,744,372,000 | 1,549,790,268,000 | C++ | UTF-8 | Lean | false | false | 66 | lean | definition b : Prop :=
sorry
theorem tst : true = false :=
sorry
|
12088de2a4abd8147a35ac7d2bf7f7a9f53114a3 | 5d166a16ae129621cb54ca9dde86c275d7d2b483 | /tests/lean/run/even_odd2.lean | c5f5ecb9cdd0ca9bef0c93a279d269918ed26c1a | [
"Apache-2.0"
] | permissive | jcarlson23/lean | b00098763291397e0ac76b37a2dd96bc013bd247 | 8de88701247f54d325edd46c0eed57aeacb64baf | refs/heads/master | 1,611,571,813,719 | 1,497,020,963,000 | 1,497,021,515,000 | 93,882,536 | 1 | 0 | null | 1,497,029,896,000 | 1,497,029,896,000 | null | UTF-8 | Lean | false | false | 487 | lean | mutual def even, odd
with even : nat → bool
| 0 := tt
| (a+1) := odd a
with odd : nat → bool
| 0 := ff
| (a+1) := even a
using_well_founded {rel_tac := λ f eqns, tactic.trace f >> tactic.trace eqns >> tactic.apply_instance}
example (a : nat) : even (a + 1) = odd a :=
by simp [even]
example (a : nat) : odd (a + 1) = even a :=
by simp [odd]
lemma even_eq_not_odd : ∀ a, even a = bnot (odd a) :=
begin
intro a, induction a,
simp [even, odd],
simph [even, odd]
end
|
60156e10f9ea38178b0f4e0746c2a2639bfc2e73 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/linear_algebra/matrix/spectrum.lean | e7f85b320877c26f6b727753fce9ecb969f35295 | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 5,518 | lean | /-
Copyright (c) 2022 Alexander Bentkamp. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alexander Bentkamp
-/
import analysis.inner_product_space.spectrum
import linear_algebra.matrix.hermitian
/-! # Spectral theory of hermitian matrices
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file proves the spectral theorem for matrices. The proof of the spectral theorem is based on
the spectral theorem for linear maps (`diagonalization_basis_apply_self_apply`).
## Tags
spectral theorem, diagonalization theorem
-/
namespace matrix
variables {𝕜 : Type*} [is_R_or_C 𝕜] [decidable_eq 𝕜] {n : Type*} [fintype n] [decidable_eq n]
variables {A : matrix n n 𝕜}
open_locale matrix
open_locale big_operators
namespace is_hermitian
variables (hA : A.is_hermitian)
/-- The eigenvalues of a hermitian matrix, indexed by `fin (fintype.card n)` where `n` is the index
type of the matrix. -/
noncomputable def eigenvalues₀ : fin (fintype.card n) → ℝ :=
(is_hermitian_iff_is_symmetric.1 hA).eigenvalues finrank_euclidean_space
/-- The eigenvalues of a hermitian matrix, reusing the index `n` of the matrix entries. -/
noncomputable def eigenvalues : n → ℝ :=
λ i, hA.eigenvalues₀ $ (fintype.equiv_of_card_eq (fintype.card_fin _)).symm i
/-- A choice of an orthonormal basis of eigenvectors of a hermitian matrix. -/
noncomputable def eigenvector_basis : orthonormal_basis n 𝕜 (euclidean_space 𝕜 n) :=
((is_hermitian_iff_is_symmetric.1 hA).eigenvector_basis finrank_euclidean_space).reindex
(fintype.equiv_of_card_eq (fintype.card_fin _))
/-- A matrix whose columns are an orthonormal basis of eigenvectors of a hermitian matrix. -/
noncomputable def eigenvector_matrix : matrix n n 𝕜 :=
(pi_Lp.basis_fun _ 𝕜 n).to_matrix (eigenvector_basis hA).to_basis
/-- The inverse of `eigenvector_matrix` -/
noncomputable def eigenvector_matrix_inv : matrix n n 𝕜 :=
(eigenvector_basis hA).to_basis.to_matrix (pi_Lp.basis_fun _ 𝕜 n)
lemma eigenvector_matrix_mul_inv :
hA.eigenvector_matrix ⬝ hA.eigenvector_matrix_inv = 1 :=
by apply basis.to_matrix_mul_to_matrix_flip
noncomputable instance : invertible hA.eigenvector_matrix_inv :=
invertible_of_left_inverse _ _ hA.eigenvector_matrix_mul_inv
noncomputable instance : invertible hA.eigenvector_matrix :=
invertible_of_right_inverse _ _ hA.eigenvector_matrix_mul_inv
lemma eigenvector_matrix_apply (i j : n) : hA.eigenvector_matrix i j = hA.eigenvector_basis j i :=
by simp_rw [eigenvector_matrix, basis.to_matrix_apply, orthonormal_basis.coe_to_basis,
pi_Lp.basis_fun_repr]
lemma eigenvector_matrix_inv_apply (i j : n) :
hA.eigenvector_matrix_inv i j = star (hA.eigenvector_basis i j) :=
begin
rw [eigenvector_matrix_inv, basis.to_matrix_apply, orthonormal_basis.coe_to_basis_repr_apply,
orthonormal_basis.repr_apply_apply, pi_Lp.basis_fun_apply, pi_Lp.equiv_symm_single,
euclidean_space.inner_single_right, one_mul, is_R_or_C.star_def],
end
lemma conj_transpose_eigenvector_matrix_inv : hA.eigenvector_matrix_invᴴ = hA.eigenvector_matrix :=
by { ext i j,
rw [conj_transpose_apply, eigenvector_matrix_inv_apply, eigenvector_matrix_apply, star_star] }
lemma conj_transpose_eigenvector_matrix : hA.eigenvector_matrixᴴ = hA.eigenvector_matrix_inv :=
by rw [← conj_transpose_eigenvector_matrix_inv, conj_transpose_conj_transpose]
/-- *Diagonalization theorem*, *spectral theorem* for matrices; A hermitian matrix can be
diagonalized by a change of basis.
For the spectral theorem on linear maps, see `diagonalization_basis_apply_self_apply`. -/
theorem spectral_theorem :
hA.eigenvector_matrix_inv ⬝ A =
diagonal (coe ∘ hA.eigenvalues) ⬝ hA.eigenvector_matrix_inv :=
begin
rw [eigenvector_matrix_inv, pi_Lp.basis_to_matrix_basis_fun_mul],
ext i j,
have := is_hermitian_iff_is_symmetric.1 hA,
convert this.diagonalization_basis_apply_self_apply finrank_euclidean_space
(euclidean_space.single j 1)
((fintype.equiv_of_card_eq (fintype.card_fin _)).symm i) using 1,
{ dsimp only [euclidean_space.single, to_euclidean_lin_pi_Lp_equiv_symm, to_lin'_apply,
matrix.of_apply, is_hermitian.eigenvector_basis],
simp_rw [mul_vec_single, mul_one, orthonormal_basis.coe_to_basis_repr_apply,
orthonormal_basis.repr_reindex],
refl },
{ simp only [diagonal_mul, (∘), eigenvalues],
rw [eigenvector_basis, basis.to_matrix_apply,
orthonormal_basis.coe_to_basis_repr_apply, orthonormal_basis.repr_reindex,
eigenvalues₀, pi_Lp.basis_fun_apply, pi_Lp.equiv_symm_single] }
end
lemma eigenvalues_eq (i : n) :
hA.eigenvalues i =
is_R_or_C.re ((star (hA.eigenvector_matrixᵀ i) ⬝ᵥ (A.mul_vec (hA.eigenvector_matrixᵀ i)))) :=
begin
have := hA.spectral_theorem,
rw [←matrix.mul_inv_eq_iff_eq_mul_of_invertible] at this,
have := congr_arg is_R_or_C.re (congr_fun (congr_fun this i) i),
rw [diagonal_apply_eq, is_R_or_C.of_real_re, inv_eq_left_inv hA.eigenvector_matrix_mul_inv,
← conj_transpose_eigenvector_matrix, mul_mul_apply] at this,
exact this.symm,
end
/-- The determinant of a hermitian matrix is the product of its eigenvalues. -/
lemma det_eq_prod_eigenvalues : det A = ∏ i, hA.eigenvalues i :=
begin
apply mul_left_cancel₀ (det_ne_zero_of_left_inverse (eigenvector_matrix_mul_inv hA)),
rw [←det_mul, spectral_theorem, det_mul, mul_comm, det_diagonal]
end
end is_hermitian
end matrix
|
6a1b655c0e740e0753f7dde282c534295dab83a9 | 96338d06deb5f54f351493a71d6ecf6c546089a2 | /priv/Lean/SetoidLim.lean | 4976f8337e604e90b7209f6baec78b308a0488eb | [] | no_license | silky/exe | 5f9e4eea772d74852a1a2fac57d8d20588282d2b | e81690d6e16f2a83c105cce446011af6ae905b81 | refs/heads/master | 1,609,385,766,412 | 1,472,164,223,000 | 1,472,164,223,000 | 66,610,224 | 1 | 0 | null | 1,472,178,919,000 | 1,472,178,919,000 | null | UTF-8 | Lean | false | false | 4,935 | lean | /- SetoidLim -/
import Setoid
import Mor
import Functor
import Adjunction
import Initial
set_option pp.universes true
set_option pp.metavar_args false
namespace EXE
/-
- Definition of LIMIT in SetoidCat
-/
namespace Setoid
record LimType {C : CatType} (F : C⟶SetoidCat) : Type :=
(atOb : Π(X : C), [F X])
(atHom : ∀{X Y : C}, ∀(m : X ⇒C⇒ Y), (atOb Y) ≡(F Y)≡ ((F m) $ (atOb X)))
abbreviation MkLim {C : CatType} {F : C⟶SetoidCat} := @LimType.mk C F
print LimType
end Setoid
-- action
attribute Setoid.LimType.atOb [coercion]
attribute Setoid.LimType.atHom [coercion]
namespace Setoid
definition LimSet {C : CatType} (F : C ⟶ SetoidCat) : SetoidType :=
Setoid.MkOb
(LimType F)
( λ(a b : LimType F), ∀(X : C), (a X) ≡(F X)≡ (b X))
( λ(a : LimType F), λ(X : C),
@SetoidType.Refl (F X) (a X))
( λ(a b c : LimType F), λ ab bc, λ(X : C),
@SetoidType.Trans (F X) (a X) (b X) (c X) (ab X) (bc X))
( λ(a b : LimType F), λ ab, λ(X : C),
@SetoidType.Sym (F X) (a X) (b X) (ab X))
check LimSet
namespace Lim
definition onHom.onElEl {C : CatType} {F G : C ⟶ SetoidCat}
: (F ⟹ G) → LimSet F → LimSet G
:= λ (nat : F ⟹ G), λ(lim : LimType F), Setoid.MkLim
/- atOb -/ ( λ(X : C), (nat /$$ X) $ (lim X))
/- atHom -/ ( λ(X Y : C), λ(m : X ⇒C⇒ Y),
((nat /$$ Y) $/ (lim m)) ⊡(G Y)⊡ ((nat /$$/ m) /$ (lim X)))
definition onHom.onElEqu {C : CatType} {F G : C ⟶ SetoidCat}
: ∀(nat : F ⟹ G), ∀{a b : LimSet F}, (a ≡(LimSet F)≡ b) →
((onHom.onElEl nat a) ≡(LimSet G)≡ (onHom.onElEl nat b))
:= λ (nat : F ⟹ G), λ (a b : LimSet F), λ (eq : a ≡(LimSet F)≡ b),
λ (X : C), (nat /$$ X) $/ (eq X)
definition onHom.onEquEl {C : CatType} {F G : C ⟶ SetoidCat}
: ∀{nat nat' : F ⟹ G}, ∀(eq : nat ≡(F ⟹ G)≡ nat'), ∀(a : LimSet F),
((onHom.onElEl nat a) ≡(LimSet G)≡ (onHom.onElEl nat' a))
:= λ (nat nat' : F ⟹ G), λ (eq : nat ≡(F ⟹ G)≡ nat'), λ (a : LimSet F),
λ (X : C), (eq X) /$ (a X)
definition onHom {C : CatType} {F G : C ⟶ SetoidCat}
: (F ⟹ G) ⥤ (LimSet F ⥤ LimSet G)
:= Setoid.MkHom2 (F ⟹ G) (LimSet F) (LimSet G)
onHom.onElEl (@onHom.onElEqu C F G) (@onHom.onEquEl C F G)
definition OnId {C : CatType}
: Functor.OnIdProp (C ⟶ SetoidCat) SetoidCat (@LimSet C) (@onHom C)
:= λ(F : C ⟶ SetoidCat), λ(lim : LimSet F), λ(X : C), ⊜
definition OnMul {C : CatType}
: Functor.OnMulProp (C ⟶ SetoidCat) SetoidCat (@LimSet C) (@onHom C)
:= λ(F G H : C ⟶ SetoidCat), λ(g : G ⟹ H), λ(f : F ⟹ G), λ(lim : LimSet F), λ(X : C), ⊜
definition diagonal (C : CatType) (T : SetoidCat)
: T ⥤ LimSet (Cat.Delta C SetoidCat T)
:= Setoid.MkHom
/- onEl -/ ( λ(t : T), Setoid.MkLim
/- atOb -/ ( λ(X : C), t)
/- atHom -/ ( λ(X Y : C), λ(m : X ⇒C⇒ Y), ⊜))
/- onEqu -/ ( λ(t1 t2 : T), λ(eq : t1 ≡(T)≡ t2), λ(X : C), eq)
definition projection {C : CatType} (F : C ⟶ SetoidCat) (X : C)
: LimSet F ⥤ (F X)
:= Setoid.MkHom
/- onEl -/ ( λ(lim : Setoid.LimSet F), (lim X))
/- onEqu -/ ( λ(lim lim': Setoid.LimSet F),
λ(eq : lim ≡(Setoid.LimSet F)≡ lim'), eq X)
print projection
definition projection.cone {C : CatType} (F : C ⟶ SetoidCat)
: Functor.IsConeProp (LimSet F) F (projection F)
:= λ(A B : C), λ(m : A ⇒C⇒ B), λ(lim : LimSet F), lim m
print projection.cone
end Lim
-- limit in SetoidCat
definition Lim {C : CatType}
: (C ⟶ SetoidCat) ⟶ SetoidCat
:= Functor.MkOb (@LimSet C) (@Lim.onHom C) (@Lim.OnId C) (@Lim.OnMul C)
print Lim
definition HasLim : HaveAllLim SetoidCat :=
λ(C : CatType), RightAdj.mk
(@Setoid.Lim C)
(AdjType.mk
(Functor.MkHom
/- onOb -/ ( Setoid.Lim.diagonal C )
/- onHom -/ ( λ(T T' : SetoidCat), λ(f : T ⥤ T'), λ(t : T), ⊜))
(Functor.MkHom
/- onOb -/ ( λ F, Functor.NatFromCone (Lim.projection F) (@Lim.projection.cone C F))
/- onHom -/ ( λ F1 F2, λ(f : F1 ⟹ F2), λ(X : C), λ(lim : LimSet F1), ⊜))
( λ(T : SetoidCat), λ(X : C), λ(t : T), ⊜ )
( λ(F : C⟶SetoidCat), λ(lim : LimSet F), λ(X : C), ⊜) )
print HasLim
end Setoid
-- problem with levels in PREDICATIVE universe hierarchy
axiom BottomSet : SetoidType -- := Initial.FromLim Setoid.HasLim
noncomputable -- OK in IMPREDICATIVE universe hierarchy
definition BottomCat : CatType := Cat.FromSet BottomSet
end EXE
|
446b0d0a55fac9c5d67a6f9a44e7ab11652f8382 | 2a70b774d16dbdf5a533432ee0ebab6838df0948 | /_target/deps/mathlib/src/group_theory/congruence.lean | 1554efd9278cbf6c5550ba3790511177df7066c4 | [
"Apache-2.0"
] | permissive | hjvromen/lewis | 40b035973df7c77ebf927afab7878c76d05ff758 | 105b675f73630f028ad5d890897a51b3c1146fb0 | refs/heads/master | 1,677,944,636,343 | 1,676,555,301,000 | 1,676,555,301,000 | 327,553,599 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 44,063 | lean | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston
-/
import data.setoid.basic
import algebra.group.pi
import algebra.group.prod
import data.equiv.mul_add
import group_theory.submonoid.operations
/-!
# Congruence relations
This file defines congruence relations: equivalence relations that preserve a binary operation,
which in this case is multiplication or addition. The principal definition is a `structure`
extending a `setoid` (an equivalence relation), and the inductive definition of the smallest
congruence relation containing a binary relation is also given (see `con_gen`).
The file also proves basic properties of the quotient of a type by a congruence relation, and the
complete lattice of congruence relations on a type. We then establish an order-preserving bijection
between the set of congruence relations containing a congruence relation `c` and the set of
congruence relations on the quotient by `c`.
The second half of the file concerns congruence relations on monoids, in which case the
quotient by the congruence relation is also a monoid. There are results about the universal
property of quotients of monoids, and the isomorphism theorems for monoids.
## Implementation notes
The inductive definition of a congruence relation could be a nested inductive type, defined using
the equivalence closure of a binary relation `eqv_gen`, but the recursor generated does not work.
A nested inductive definition could conceivably shorten proofs, because they would allow invocation
of the corresponding lemmas about `eqv_gen`.
The lemmas `refl`, `symm` and `trans` are not tagged with `@[refl]`, `@[symm]`, and `@[trans]`
respectively as these tags do not work on a structure coerced to a binary relation.
There is a coercion from elements of a type to the element's equivalence class under a
congruence relation.
A congruence relation on a monoid `M` can be thought of as a submonoid of `M × M` for which
membership is an equivalence relation, but whilst this fact is established in the file, it is not
used, since this perspective adds more layers of definitional unfolding.
## Tags
congruence, congruence relation, quotient, quotient by congruence relation, monoid,
quotient monoid, isomorphism theorems
-/
variables (M : Type*) {N : Type*} {P : Type*}
set_option old_structure_cmd true
open function setoid
/-- A congruence relation on a type with an addition is an equivalence relation which
preserves addition. -/
structure add_con [has_add M] extends setoid M :=
(add' : ∀ {w x y z}, r w x → r y z → r (w + y) (x + z))
/-- A congruence relation on a type with a multiplication is an equivalence relation which
preserves multiplication. -/
@[to_additive add_con] structure con [has_mul M] extends setoid M :=
(mul' : ∀ {w x y z}, r w x → r y z → r (w * y) (x * z))
/-- The equivalence relation underlying an additive congruence relation. -/
add_decl_doc add_con.to_setoid
/-- The equivalence relation underlying a multiplicative congruence relation. -/
add_decl_doc con.to_setoid
variables {M}
/-- The inductively defined smallest additive congruence relation containing a given binary
relation. -/
inductive add_con_gen.rel [has_add M] (r : M → M → Prop) : M → M → Prop
| of : Π x y, r x y → add_con_gen.rel x y
| refl : Π x, add_con_gen.rel x x
| symm : Π x y, add_con_gen.rel x y → add_con_gen.rel y x
| trans : Π x y z, add_con_gen.rel x y → add_con_gen.rel y z → add_con_gen.rel x z
| add : Π w x y z, add_con_gen.rel w x → add_con_gen.rel y z → add_con_gen.rel (w + y) (x + z)
/-- The inductively defined smallest multiplicative congruence relation containing a given binary
relation. -/
@[to_additive add_con_gen.rel]
inductive con_gen.rel [has_mul M] (r : M → M → Prop) : M → M → Prop
| of : Π x y, r x y → con_gen.rel x y
| refl : Π x, con_gen.rel x x
| symm : Π x y, con_gen.rel x y → con_gen.rel y x
| trans : Π x y z, con_gen.rel x y → con_gen.rel y z → con_gen.rel x z
| mul : Π w x y z, con_gen.rel w x → con_gen.rel y z → con_gen.rel (w * y) (x * z)
/-- The inductively defined smallest multiplicative congruence relation containing a given binary
relation. -/
@[to_additive add_con_gen "The inductively defined smallest additive congruence relation containing
a given binary relation."]
def con_gen [has_mul M] (r : M → M → Prop) : con M :=
⟨con_gen.rel r, ⟨con_gen.rel.refl, con_gen.rel.symm, con_gen.rel.trans⟩, con_gen.rel.mul⟩
namespace con
section
variables [has_mul M] [has_mul N] [has_mul P] (c : con M)
@[to_additive]
instance : inhabited (con M) :=
⟨con_gen empty_relation⟩
/-- A coercion from a congruence relation to its underlying binary relation. -/
@[to_additive "A coercion from an additive congruence relation to its underlying binary relation."]
instance : has_coe_to_fun (con M) := ⟨_, λ c, λ x y, c.r x y⟩
@[simp, to_additive] lemma rel_eq_coe (c : con M) : c.r = c := rfl
/-- Congruence relations are reflexive. -/
@[to_additive "Additive congruence relations are reflexive."]
protected lemma refl (x) : c x x := c.2.1 x
/-- Congruence relations are symmetric. -/
@[to_additive "Additive congruence relations are symmetric."]
protected lemma symm : ∀ {x y}, c x y → c y x := λ _ _ h, c.2.2.1 h
/-- Congruence relations are transitive. -/
@[to_additive "Additive congruence relations are transitive."]
protected lemma trans : ∀ {x y z}, c x y → c y z → c x z :=
λ _ _ _ h, c.2.2.2 h
/-- Multiplicative congruence relations preserve multiplication. -/
@[to_additive "Additive congruence relations preserve addition."]
protected lemma mul : ∀ {w x y z}, c w x → c y z → c (w * y) (x * z) :=
λ _ _ _ _ h1 h2, c.3 h1 h2
/-- Given a type `M` with a multiplication, a congruence relation `c` on `M`, and elements of `M`
`x, y`, `(x, y) ∈ M × M` iff `x` is related to `y` by `c`. -/
@[to_additive "Given a type `M` with an addition, `x, y ∈ M`, and an additive congruence relation
`c` on `M`, `(x, y) ∈ M × M` iff `x` is related to `y` by `c`."]
instance : has_mem (M × M) (con M) := ⟨λ x c, c x.1 x.2⟩
variables {c}
/-- The map sending a congruence relation to its underlying binary relation is injective. -/
@[to_additive "The map sending an additive congruence relation to its underlying binary relation
is injective."]
lemma ext' {c d : con M} (H : c.r = d.r) : c = d :=
by cases c; cases d; simpa using H
/-- Extensionality rule for congruence relations. -/
@[ext, to_additive "Extensionality rule for additive congruence relations."]
lemma ext {c d : con M} (H : ∀ x y, c x y ↔ d x y) : c = d :=
ext' $ by ext; apply H
attribute [ext] add_con.ext
/-- The map sending a congruence relation to its underlying equivalence relation is injective. -/
@[to_additive "The map sending an additive congruence relation to its underlying equivalence
relation is injective."]
lemma to_setoid_inj {c d : con M} (H : c.to_setoid = d.to_setoid) : c = d :=
ext $ ext_iff.1 H
/-- Iff version of extensionality rule for congruence relations. -/
@[to_additive "Iff version of extensionality rule for additive congruence relations."]
lemma ext_iff {c d : con M} : (∀ x y, c x y ↔ d x y) ↔ c = d :=
⟨ext, λ h _ _, h ▸ iff.rfl⟩
/-- Two congruence relations are equal iff their underlying binary relations are equal. -/
@[to_additive "Two additive congruence relations are equal iff their underlying binary relations
are equal."]
lemma ext'_iff {c d : con M} : c.r = d.r ↔ c = d :=
⟨ext', λ h, h ▸ rfl⟩
/-- The kernel of a multiplication-preserving function as a congruence relation. -/
@[to_additive "The kernel of an addition-preserving function as an additive congruence relation."]
def mul_ker (f : M → P) (h : ∀ x y, f (x * y) = f x * f y) : con M :=
{ r := λ x y, f x = f y,
iseqv := ⟨λ _, rfl, λ _ _, eq.symm, λ _ _ _, eq.trans⟩,
mul' := λ _ _ _ _ h1 h2, by rw [h, h1, h2, h] }
/-- Given types with multiplications `M, N`, the product of two congruence relations `c` on `M` and
`d` on `N`: `(x₁, x₂), (y₁, y₂) ∈ M × N` are related by `c.prod d` iff `x₁` is related to `y₁`
by `c` and `x₂` is related to `y₂` by `d`. -/
@[to_additive prod "Given types with additions `M, N`, the product of two congruence relations
`c` on `M` and `d` on `N`: `(x₁, x₂), (y₁, y₂) ∈ M × N` are related by `c.prod d` iff `x₁`
is related to `y₁` by `c` and `x₂` is related to `y₂` by `d`."]
protected def prod (c : con M) (d : con N) : con (M × N) :=
{ mul' := λ _ _ _ _ h1 h2, ⟨c.mul h1.1 h2.1, d.mul h1.2 h2.2⟩, ..c.to_setoid.prod d.to_setoid }
/-- The product of an indexed collection of congruence relations. -/
@[to_additive "The product of an indexed collection of additive congruence relations."]
def pi {ι : Type*} {f : ι → Type*} [Π i, has_mul (f i)]
(C : Π i, con (f i)) : con (Π i, f i) :=
{ mul' := λ _ _ _ _ h1 h2 i, (C i).mul (h1 i) (h2 i), ..@pi_setoid _ _ $ λ i, (C i).to_setoid }
variables (c)
@[simp, to_additive] lemma coe_eq : c.to_setoid.r = c := rfl
-- Quotients
/-- Defining the quotient by a congruence relation of a type with a multiplication. -/
@[to_additive "Defining the quotient by an additive congruence relation of a type with
an addition."]
protected def quotient := quotient $ c.to_setoid
/-- Coercion from a type with a multiplication to its quotient by a congruence relation.
See Note [use has_coe_t]. -/
@[to_additive "Coercion from a type with an addition to its quotient by an additive congruence
relation", priority 0]
instance : has_coe_t M c.quotient := ⟨@quotient.mk _ c.to_setoid⟩
/-- The quotient of a type with decidable equality by a congruence relation also has
decidable equality. -/
@[to_additive "The quotient of a type with decidable equality by an additive congruence relation
also has decidable equality."]
instance [d : ∀ a b, decidable (c a b)] : decidable_eq c.quotient :=
@quotient.decidable_eq M c.to_setoid d
/-- The function on the quotient by a congruence relation `c` induced by a function that is
constant on `c`'s equivalence classes. -/
@[elab_as_eliminator, to_additive "The function on the quotient by a congruence relation `c`
induced by a function that is constant on `c`'s equivalence classes."]
protected def lift_on {β} {c : con M} (q : c.quotient) (f : M → β)
(h : ∀ a b, c a b → f a = f b) : β := quotient.lift_on' q f h
/-- The binary function on the quotient by a congruence relation `c` induced by a binary function
that is constant on `c`'s equivalence classes. -/
@[elab_as_eliminator, to_additive "The binary function on the quotient by a congruence relation `c`
induced by a binary function that is constant on `c`'s equivalence classes."]
protected def lift_on₂ {β} {c : con M} (q r : c.quotient) (f : M → M → β)
(h : ∀ a₁ a₂ b₁ b₂, c a₁ b₁ → c a₂ b₂ → f a₁ a₂ = f b₁ b₂) : β := quotient.lift_on₂' q r f h
variables {c}
/-- The inductive principle used to prove propositions about the elements of a quotient by a
congruence relation. -/
@[elab_as_eliminator, to_additive "The inductive principle used to prove propositions about
the elements of a quotient by an additive congruence relation."]
protected lemma induction_on {C : c.quotient → Prop} (q : c.quotient) (H : ∀ x : M, C x) : C q :=
quotient.induction_on' q H
/-- A version of `con.induction_on` for predicates which take two arguments. -/
@[elab_as_eliminator, to_additive "A version of `add_con.induction_on` for predicates which take
two arguments."]
protected lemma induction_on₂ {d : con N} {C : c.quotient → d.quotient → Prop}
(p : c.quotient) (q : d.quotient) (H : ∀ (x : M) (y : N), C x y) : C p q :=
quotient.induction_on₂' p q H
variables (c)
/-- Two elements are related by a congruence relation `c` iff they are represented by the same
element of the quotient by `c`. -/
@[simp, to_additive "Two elements are related by an additive congruence relation `c` iff they
are represented by the same element of the quotient by `c`."]
protected lemma eq {a b : M} : (a : c.quotient) = b ↔ c a b :=
quotient.eq'
/-- The multiplication induced on the quotient by a congruence relation on a type with a
multiplication. -/
@[to_additive "The addition induced on the quotient by an additive congruence relation on a type
with an addition."]
instance has_mul : has_mul c.quotient :=
⟨λ x y, quotient.lift_on₂' x y (λ w z, ((w * z : M) : c.quotient))
$ λ _ _ _ _ h1 h2, c.eq.2 $ c.mul h1 h2⟩
/-- The kernel of the quotient map induced by a congruence relation `c` equals `c`. -/
@[simp, to_additive "The kernel of the quotient map induced by an additive congruence relation
`c` equals `c`."]
lemma mul_ker_mk_eq : mul_ker (coe : M → c.quotient) (λ x y, rfl) = c :=
ext $ λ x y, quotient.eq'
variables {c}
/-- The coercion to the quotient of a congruence relation commutes with multiplication (by
definition). -/
@[simp, to_additive "The coercion to the quotient of an additive congruence relation commutes with
addition (by definition)."]
lemma coe_mul (x y : M) : (↑(x * y) : c.quotient) = ↑x * ↑y := rfl
/-- Definition of the function on the quotient by a congruence relation `c` induced by a function
that is constant on `c`'s equivalence classes. -/
@[simp, to_additive "Definition of the function on the quotient by an additive congruence
relation `c` induced by a function that is constant on `c`'s equivalence classes."]
protected lemma lift_on_beta {β} (c : con M) (f : M → β)
(h : ∀ a b, c a b → f a = f b) (x : M) :
con.lift_on (x : c.quotient) f h = f x := rfl
/-- Makes an isomorphism of quotients by two congruence relations, given that the relations are
equal. -/
@[to_additive "Makes an additive isomorphism of quotients by two additive congruence relations,
given that the relations are equal."]
protected def congr {c d : con M} (h : c = d) : c.quotient ≃* d.quotient :=
{ map_mul' := λ x y, by rcases x; rcases y; refl,
..quotient.congr (equiv.refl M) $ by apply ext_iff.2 h }
-- The complete lattice of congruence relations on a type
/-- For congruence relations `c, d` on a type `M` with a multiplication, `c ≤ d` iff `∀ x y ∈ M`,
`x` is related to `y` by `d` if `x` is related to `y` by `c`. -/
@[to_additive "For additive congruence relations `c, d` on a type `M` with an addition, `c ≤ d` iff
`∀ x y ∈ M`, `x` is related to `y` by `d` if `x` is related to `y` by `c`."]
instance : has_le (con M) := ⟨λ c d, ∀ ⦃x y⦄, c x y → d x y⟩
/-- Definition of `≤` for congruence relations. -/
@[to_additive "Definition of `≤` for additive congruence relations."]
theorem le_def {c d : con M} : c ≤ d ↔ ∀ {x y}, c x y → d x y := iff.rfl
/-- The infimum of a set of congruence relations on a given type with a multiplication. -/
@[to_additive "The infimum of a set of additive congruence relations on a given type with
an addition."]
instance : has_Inf (con M) :=
⟨λ S, ⟨λ x y, ∀ c : con M, c ∈ S → c x y,
⟨λ x c hc, c.refl x, λ _ _ h c hc, c.symm $ h c hc,
λ _ _ _ h1 h2 c hc, c.trans (h1 c hc) $ h2 c hc⟩,
λ _ _ _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc⟩⟩
/-- The infimum of a set of congruence relations is the same as the infimum of the set's image
under the map to the underlying equivalence relation. -/
@[to_additive "The infimum of a set of additive congruence relations is the same as the infimum of
the set's image under the map to the underlying equivalence relation."]
lemma Inf_to_setoid (S : set (con M)) : (Inf S).to_setoid = Inf (to_setoid '' S) :=
setoid.ext' $ λ x y, ⟨λ h r ⟨c, hS, hr⟩, by rw ←hr; exact h c hS,
λ h c hS, h c.to_setoid ⟨c, hS, rfl⟩⟩
/-- The infimum of a set of congruence relations is the same as the infimum of the set's image
under the map to the underlying binary relation. -/
@[to_additive "The infimum of a set of additive congruence relations is the same as the infimum
of the set's image under the map to the underlying binary relation."]
lemma Inf_def (S : set (con M)) : (Inf S).r = Inf (r '' S) :=
by { ext, simp only [Inf_image, infi_apply, infi_Prop_eq], refl }
@[to_additive]
instance : partial_order (con M) :=
{ le := (≤),
lt := λ c d, c ≤ d ∧ ¬d ≤ c,
le_refl := λ c _ _, id,
le_trans := λ c1 c2 c3 h1 h2 x y h, h2 $ h1 h,
lt_iff_le_not_le := λ _ _, iff.rfl,
le_antisymm := λ c d hc hd, ext $ λ x y, ⟨λ h, hc h, λ h, hd h⟩ }
/-- The complete lattice of congruence relations on a given type with a multiplication. -/
@[to_additive "The complete lattice of additive congruence relations on a given type with
an addition."]
instance : complete_lattice (con M) :=
{ inf := λ c d, ⟨(c.to_setoid ⊓ d.to_setoid).1, (c.to_setoid ⊓ d.to_setoid).2,
λ _ _ _ _ h1 h2, ⟨c.mul h1.1 h2.1, d.mul h1.2 h2.2⟩⟩,
inf_le_left := λ _ _ _ _ h, h.1,
inf_le_right := λ _ _ _ _ h, h.2,
le_inf := λ _ _ _ hb hc _ _ h, ⟨hb h, hc h⟩,
top := { mul' := by tauto, ..setoid.complete_lattice.top},
le_top := λ _ _ _ h, trivial,
bot := { mul' := λ _ _ _ _ h1 h2, h1 ▸ h2 ▸ rfl, ..setoid.complete_lattice.bot},
bot_le := λ c x y h, h ▸ c.refl x,
.. complete_lattice_of_Inf (con M) $ assume s,
⟨λ r hr x y h, (h : ∀ r ∈ s, (r : con M) x y) r hr, λ r hr x y h r' hr', hr hr' h⟩ }
/-- The infimum of two congruence relations equals the infimum of the underlying binary
operations. -/
@[to_additive "The infimum of two additive congruence relations equals the infimum of the
underlying binary operations."]
lemma inf_def {c d : con M} : (c ⊓ d).r = c.r ⊓ d.r := rfl
/-- Definition of the infimum of two congruence relations. -/
@[to_additive "Definition of the infimum of two additive congruence relations."]
theorem inf_iff_and {c d : con M} {x y} : (c ⊓ d) x y ↔ c x y ∧ d x y := iff.rfl
/-- The inductively defined smallest congruence relation containing a binary relation `r` equals
the infimum of the set of congruence relations containing `r`. -/
@[to_additive add_con_gen_eq "The inductively defined smallest additive congruence relation
containing a binary relation `r` equals the infimum of the set of additive congruence relations
containing `r`."]
theorem con_gen_eq (r : M → M → Prop) :
con_gen r = Inf {s : con M | ∀ x y, r x y → s x y} :=
le_antisymm
(λ x y H, con_gen.rel.rec_on H (λ _ _ h _ hs, hs _ _ h) (con.refl _) (λ _ _ _, con.symm _)
(λ _ _ _ _ _, con.trans _)
$ λ w x y z _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc)
(Inf_le (λ _ _, con_gen.rel.of _ _))
/-- The smallest congruence relation containing a binary relation `r` is contained in any
congruence relation containing `r`. -/
@[to_additive add_con_gen_le "The smallest additive congruence relation containing a binary
relation `r` is contained in any additive congruence relation containing `r`."]
theorem con_gen_le {r : M → M → Prop} {c : con M} (h : ∀ x y, r x y → c.r x y) :
con_gen r ≤ c :=
by rw con_gen_eq; exact Inf_le h
/-- Given binary relations `r, s` with `r` contained in `s`, the smallest congruence relation
containing `s` contains the smallest congruence relation containing `r`. -/
@[to_additive add_con_gen_mono "Given binary relations `r, s` with `r` contained in `s`, the
smallest additive congruence relation containing `s` contains the smallest additive congruence
relation containing `r`."]
theorem con_gen_mono {r s : M → M → Prop} (h : ∀ x y, r x y → s x y) :
con_gen r ≤ con_gen s :=
con_gen_le $ λ x y hr, con_gen.rel.of _ _ $ h x y hr
/-- Congruence relations equal the smallest congruence relation in which they are contained. -/
@[simp, to_additive add_con_gen_of_add_con "Additive congruence relations equal the smallest
additive congruence relation in which they are contained."]
lemma con_gen_of_con (c : con M) : con_gen c = c :=
le_antisymm (by rw con_gen_eq; exact Inf_le (λ _ _, id)) con_gen.rel.of
/-- The map sending a binary relation to the smallest congruence relation in which it is
contained is idempotent. -/
@[simp, to_additive add_con_gen_idem "The map sending a binary relation to the smallest additive
congruence relation in which it is contained is idempotent."]
lemma con_gen_idem (r : M → M → Prop) :
con_gen (con_gen r) = con_gen r :=
con_gen_of_con _
/-- The supremum of congruence relations `c, d` equals the smallest congruence relation containing
the binary relation '`x` is related to `y` by `c` or `d`'. -/
@[to_additive sup_eq_add_con_gen "The supremum of additive congruence relations `c, d` equals the
smallest additive congruence relation containing the binary relation '`x` is related to `y`
by `c` or `d`'."]
lemma sup_eq_con_gen (c d : con M) :
c ⊔ d = con_gen (λ x y, c x y ∨ d x y) :=
begin
rw con_gen_eq,
apply congr_arg Inf,
simp only [le_def, or_imp_distrib, ← forall_and_distrib]
end
/-- The supremum of two congruence relations equals the smallest congruence relation containing
the supremum of the underlying binary operations. -/
@[to_additive "The supremum of two additive congruence relations equals the smallest additive
congruence relation containing the supremum of the underlying binary operations."]
lemma sup_def {c d : con M} : c ⊔ d = con_gen (c.r ⊔ d.r) :=
by rw sup_eq_con_gen; refl
/-- The supremum of a set of congruence relations `S` equals the smallest congruence relation
containing the binary relation 'there exists `c ∈ S` such that `x` is related to `y` by
`c`'. -/
@[to_additive Sup_eq_add_con_gen "The supremum of a set of additive congruence relations `S` equals
the smallest additive congruence relation containing the binary relation 'there exists `c ∈ S`
such that `x` is related to `y` by `c`'."]
lemma Sup_eq_con_gen (S : set (con M)) :
Sup S = con_gen (λ x y, ∃ c : con M, c ∈ S ∧ c x y) :=
begin
rw con_gen_eq,
apply congr_arg Inf,
ext,
exact ⟨λ h _ _ ⟨r, hr⟩, h hr.1 hr.2,
λ h r hS _ _ hr, h _ _ ⟨r, hS, hr⟩⟩,
end
/-- The supremum of a set of congruence relations is the same as the smallest congruence relation
containing the supremum of the set's image under the map to the underlying binary relation. -/
@[to_additive "The supremum of a set of additive congruence relations is the same as the smallest
additive congruence relation containing the supremum of the set's image under the map to the
underlying binary relation."]
lemma Sup_def {S : set (con M)} : Sup S = con_gen (Sup (r '' S)) :=
begin
rw [Sup_eq_con_gen, Sup_image],
congr' with x y,
simp only [Sup_image, supr_apply, supr_Prop_eq, exists_prop, rel_eq_coe]
end
variables (M)
/-- There is a Galois insertion of congruence relations on a type with a multiplication `M` into
binary relations on `M`. -/
@[to_additive "There is a Galois insertion of additive congruence relations on a type with
an addition `M` into binary relations on `M`."]
protected noncomputable def gi : @galois_insertion (M → M → Prop) (con M) _ _ con_gen r :=
{ choice := λ r h, con_gen r,
gc := λ r c, ⟨λ H _ _ h, H $ con_gen.rel.of _ _ h, λ H, con_gen_of_con c ▸ con_gen_mono H⟩,
le_l_u := λ x, (con_gen_of_con x).symm ▸ le_refl x,
choice_eq := λ _ _, rfl }
variables {M} (c)
/-- Given a function `f`, the smallest congruence relation containing the binary relation on `f`'s
image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)`
by a congruence relation `c`.' -/
@[to_additive "Given a function `f`, the smallest additive congruence relation containing the
binary relation on `f`'s image defined by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the
elements of `f⁻¹(y)` by an additive congruence relation `c`.'"]
def map_gen (f : M → N) : con N :=
con_gen $ λ x y, ∃ a b, f a = x ∧ f b = y ∧ c a b
/-- Given a surjective multiplicative-preserving function `f` whose kernel is contained in a
congruence relation `c`, the congruence relation on `f`'s codomain defined by '`x ≈ y` iff the
elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)` by `c`.' -/
@[to_additive "Given a surjective addition-preserving function `f` whose kernel is contained in
an additive congruence relation `c`, the additive congruence relation on `f`'s codomain defined
by '`x ≈ y` iff the elements of `f⁻¹(x)` are related to the elements of `f⁻¹(y)` by `c`.'"]
def map_of_surjective (f : M → N) (H : ∀ x y, f (x * y) = f x * f y) (h : mul_ker f H ≤ c)
(hf : surjective f) : con N :=
{ mul' := λ w x y z ⟨a, b, hw, hx, h1⟩ ⟨p, q, hy, hz, h2⟩,
⟨a * p, b * q, by rw [H, hw, hy], by rw [H, hx, hz], c.mul h1 h2⟩,
..c.to_setoid.map_of_surjective f h hf }
/-- A specialization of 'the smallest congruence relation containing a congruence relation `c`
equals `c`'. -/
@[to_additive "A specialization of 'the smallest additive congruence relation containing
an additive congruence relation `c` equals `c`'."]
lemma map_of_surjective_eq_map_gen {c : con M} {f : M → N} (H : ∀ x y, f (x * y) = f x * f y)
(h : mul_ker f H ≤ c) (hf : surjective f) :
c.map_gen f = c.map_of_surjective f H h hf :=
by rw ←con_gen_of_con (c.map_of_surjective f H h hf); refl
/-- Given types with multiplications `M, N` and a congruence relation `c` on `N`, a
multiplication-preserving map `f : M → N` induces a congruence relation on `f`'s domain
defined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `c`.' -/
@[to_additive "Given types with additions `M, N` and an additive congruence relation `c` on `N`,
an addition-preserving map `f : M → N` induces an additive congruence relation on `f`'s domain
defined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `c`.' "]
def comap (f : M → N) (H : ∀ x y, f (x * y) = f x * f y) (c : con N) : con M :=
{ mul' := λ w x y z h1 h2, show c (f (w * y)) (f (x * z)), by rw [H, H]; exact c.mul h1 h2,
..c.to_setoid.comap f }
section
open quotient
/-- Given a congruence relation `c` on a type `M` with a multiplication, the order-preserving
bijection between the set of congruence relations containing `c` and the congruence relations
on the quotient of `M` by `c`. -/
@[to_additive "Given an additive congruence relation `c` on a type `M` with an addition,
the order-preserving bijection between the set of additive congruence relations containing `c` and
the additive congruence relations on the quotient of `M` by `c`."]
def correspondence : {d // c ≤ d} ≃o (con c.quotient) :=
{ to_fun := λ d, d.1.map_of_surjective coe _
(by rw mul_ker_mk_eq; exact d.2) $ @exists_rep _ c.to_setoid,
inv_fun := λ d, ⟨comap (coe : M → c.quotient) (λ x y, rfl) d, λ _ _ h,
show d _ _, by rw c.eq.2 h; exact d.refl _ ⟩,
left_inv := λ d, subtype.ext_iff_val.2 $ ext $ λ _ _,
⟨λ h, let ⟨a, b, hx, hy, H⟩ := h in
d.1.trans (d.1.symm $ d.2 $ c.eq.1 hx) $ d.1.trans H $ d.2 $ c.eq.1 hy,
λ h, ⟨_, _, rfl, rfl, h⟩⟩,
right_inv := λ d, let Hm : mul_ker (coe : M → c.quotient) (λ x y, rfl) ≤
comap (coe : M → c.quotient) (λ x y, rfl) d :=
λ x y h, show d _ _, by rw mul_ker_mk_eq at h; exact c.eq.2 h ▸ d.refl _ in
ext $ λ x y, ⟨λ h, let ⟨a, b, hx, hy, H⟩ := h in hx ▸ hy ▸ H,
con.induction_on₂ x y $ λ w z h, ⟨w, z, rfl, rfl, h⟩⟩,
map_rel_iff' := λ s t, ⟨λ h _ _ hs, let ⟨a, b, hx, hy, ht⟩ := h ⟨_, _, rfl, rfl, hs⟩ in
t.1.trans (t.1.symm $ t.2 $ eq_rel.1 hx) $ t.1.trans ht $ t.2 $ eq_rel.1 hy,
λ h _ _ hs, let ⟨a, b, hx, hy, Hs⟩ := hs in ⟨a, b, hx, hy, h Hs⟩⟩ }
end
end
-- Monoids
section monoids
variables {M} [monoid M] [monoid N] [monoid P] (c : con M)
/-- The quotient of a monoid by a congruence relation is a monoid. -/
@[to_additive "The quotient of an `add_monoid` by an additive congruence relation is
an `add_monoid`."]
instance monoid : monoid c.quotient :=
{ one := ((1 : M) : c.quotient),
mul := (*),
mul_assoc := λ x y z, quotient.induction_on₃' x y z
$ λ _ _ _, congr_arg coe $ mul_assoc _ _ _,
mul_one := λ x, quotient.induction_on' x $ λ _, congr_arg coe $ mul_one _,
one_mul := λ x, quotient.induction_on' x $ λ _, congr_arg coe $ one_mul _ }
/-- The quotient of a `comm_monoid` by a congruence relation is a `comm_monoid`. -/
@[to_additive "The quotient of an `add_comm_monoid` by an additive congruence
relation is an `add_comm_monoid`."]
instance comm_monoid {α : Type*} [comm_monoid α] (c : con α) :
comm_monoid c.quotient :=
{ mul_comm := λ x y, con.induction_on₂ x y $ λ w z, by rw [←coe_mul, ←coe_mul, mul_comm],
..c.monoid}
variables {c}
/-- The 1 of the quotient of a monoid by a congruence relation is the equivalence class of the
monoid's 1. -/
@[simp, to_additive "The 0 of the quotient of an `add_monoid` by an additive congruence relation
is the equivalence class of the `add_monoid`'s 0."]
lemma coe_one : ((1 : M) : c.quotient) = 1 := rfl
variables (M c)
/-- The submonoid of `M × M` defined by a congruence relation on a monoid `M`. -/
@[to_additive "The `add_submonoid` of `M × M` defined by an additive congruence
relation on an `add_monoid` `M`."]
protected def submonoid : submonoid (M × M) :=
{ carrier := { x | c x.1 x.2 },
one_mem' := c.iseqv.1 1,
mul_mem' := λ _ _, c.mul }
variables {M c}
/-- The congruence relation on a monoid `M` from a submonoid of `M × M` for which membership
is an equivalence relation. -/
@[to_additive "The additive congruence relation on an `add_monoid` `M` from
an `add_submonoid` of `M × M` for which membership is an equivalence relation."]
def of_submonoid (N : submonoid (M × M)) (H : equivalence (λ x y, (x, y) ∈ N)) : con M :=
{ r := λ x y, (x, y) ∈ N,
iseqv := H,
mul' := λ _ _ _ _, N.mul_mem }
/-- Coercion from a congruence relation `c` on a monoid `M` to the submonoid of `M × M` whose
elements are `(x, y)` such that `x` is related to `y` by `c`. -/
@[to_additive "Coercion from a congruence relation `c` on an `add_monoid` `M`
to the `add_submonoid` of `M × M` whose elements are `(x, y)` such that `x`
is related to `y` by `c`."]
instance to_submonoid : has_coe (con M) (submonoid (M × M)) := ⟨λ c, c.submonoid M⟩
@[to_additive] lemma mem_coe {c : con M} {x y} :
(x, y) ∈ (↑c : submonoid (M × M)) ↔ (x, y) ∈ c := iff.rfl
@[to_additive]
theorem to_submonoid_inj (c d : con M) (H : (c : submonoid (M × M)) = d) : c = d :=
ext $ λ x y, show (x, y) ∈ (c : submonoid (M × M)) ↔ (x, y) ∈ ↑d, by rw H
@[to_additive]
lemma le_iff {c d : con M} : c ≤ d ↔ (c : submonoid (M × M)) ≤ d :=
⟨λ h x H, h H, λ h x y hc, h $ show (x, y) ∈ c, from hc⟩
/-- The kernel of a monoid homomorphism as a congruence relation. -/
@[to_additive "The kernel of an `add_monoid` homomorphism as an additive congruence relation."]
def ker (f : M →* P) : con M := mul_ker f f.3
/-- The definition of the congruence relation defined by a monoid homomorphism's kernel. -/
@[to_additive "The definition of the additive congruence relation defined by an `add_monoid`
homomorphism's kernel."]
lemma ker_rel (f : M →* P) {x y} : ker f x y ↔ f x = f y := iff.rfl
/-- There exists an element of the quotient of a monoid by a congruence relation (namely 1). -/
@[to_additive "There exists an element of the quotient of an `add_monoid` by a congruence relation
(namely 0)."]
instance quotient.inhabited : inhabited c.quotient := ⟨((1 : M) : c.quotient)⟩
variables (c)
/-- The natural homomorphism from a monoid to its quotient by a congruence relation. -/
@[to_additive "The natural homomorphism from an `add_monoid` to its quotient by an additive
congruence relation."]
def mk' : M →* c.quotient := ⟨coe, rfl, λ _ _, rfl⟩
variables (x y : M)
/-- The kernel of the natural homomorphism from a monoid to its quotient by a congruence
relation `c` equals `c`. -/
@[simp, to_additive "The kernel of the natural homomorphism from an `add_monoid` to its quotient by
an additive congruence relation `c` equals `c`."]
lemma mk'_ker : ker c.mk' = c := ext $ λ _ _, c.eq
variables {c}
/-- The natural homomorphism from a monoid to its quotient by a congruence relation is
surjective. -/
@[to_additive "The natural homomorphism from an `add_monoid` to its quotient by a congruence
relation is surjective."]
lemma mk'_surjective : surjective c.mk' :=
λ x, by rcases x; exact ⟨x, rfl⟩
@[simp, to_additive] lemma comp_mk'_apply (g : c.quotient →* P) {x} :
g.comp c.mk' x = g x := rfl
/-- The elements related to `x ∈ M`, `M` a monoid, by the kernel of a monoid homomorphism are
those in the preimage of `f(x)` under `f`. -/
@[to_additive "The elements related to `x ∈ M`, `M` an `add_monoid`, by the kernel of
an `add_monoid` homomorphism are those in the preimage of `f(x)` under `f`. "]
lemma ker_apply_eq_preimage {f : M →* P} (x) : (ker f) x = f ⁻¹' {f x} :=
set.ext $ λ x,
⟨λ h, set.mem_preimage.2 $ set.mem_singleton_iff.2 h.symm,
λ h, (set.mem_singleton_iff.1 $ set.mem_preimage.1 h).symm⟩
/-- Given a monoid homomorphism `f : N → M` and a congruence relation `c` on `M`, the congruence
relation induced on `N` by `f` equals the kernel of `c`'s quotient homomorphism composed with
`f`. -/
@[to_additive "Given an `add_monoid` homomorphism `f : N → M` and an additive congruence relation
`c` on `M`, the additive congruence relation induced on `N` by `f` equals the kernel of `c`'s
quotient homomorphism composed with `f`."]
lemma comap_eq {f : N →* M} : comap f f.map_mul c = ker (c.mk'.comp f) :=
ext $ λ x y, show c _ _ ↔ c.mk' _ = c.mk' _, by rw ←c.eq; refl
variables (c) (f : M →* P)
/-- The homomorphism on the quotient of a monoid by a congruence relation `c` induced by a
homomorphism constant on `c`'s equivalence classes. -/
@[to_additive "The homomorphism on the quotient of an `add_monoid` by an additive congruence
relation `c` induced by a homomorphism constant on `c`'s equivalence classes."]
def lift (H : c ≤ ker f) : c.quotient →* P :=
{ to_fun := λ x, con.lift_on x f $ λ _ _ h, H h,
map_one' := by rw ←f.map_one; refl,
map_mul' := λ x y, con.induction_on₂ x y $ λ m n, f.map_mul m n ▸ rfl }
variables {c f}
/-- The diagram describing the universal property for quotients of monoids commutes. -/
@[simp, to_additive "The diagram describing the universal property for quotients of `add_monoid`s
commutes."]
lemma lift_mk' (H : c ≤ ker f) (x) :
c.lift f H (c.mk' x) = f x := rfl
/-- The diagram describing the universal property for quotients of monoids commutes. -/
@[simp, to_additive "The diagram describing the universal property for quotients of `add_monoid`s
commutes."]
lemma lift_coe (H : c ≤ ker f) (x : M) :
c.lift f H x = f x := rfl
/-- The diagram describing the universal property for quotients of monoids commutes. -/
@[simp, to_additive "The diagram describing the universal property for quotients of `add_monoid`s
commutes."]
theorem lift_comp_mk' (H : c ≤ ker f) :
(c.lift f H).comp c.mk' = f := by ext; refl
/-- Given a homomorphism `f` from the quotient of a monoid by a congruence relation, `f` equals the
homomorphism on the quotient induced by `f` composed with the natural map from the monoid to
the quotient. -/
@[simp, to_additive "Given a homomorphism `f` from the quotient of an `add_monoid` by an additive
congruence relation, `f` equals the homomorphism on the quotient induced by `f` composed with the
natural map from the `add_monoid` to the quotient."]
lemma lift_apply_mk' (f : c.quotient →* P) :
c.lift (f.comp c.mk') (λ x y h, show f ↑x = f ↑y, by rw c.eq.2 h) = f :=
by ext; rcases x; refl
/-- Homomorphisms on the quotient of a monoid by a congruence relation are equal if they
are equal on elements that are coercions from the monoid. -/
@[to_additive "Homomorphisms on the quotient of an `add_monoid` by an additive congruence relation
are equal if they are equal on elements that are coercions from the `add_monoid`."]
lemma lift_funext (f g : c.quotient →* P) (h : ∀ a : M, f a = g a) : f = g :=
begin
rw [←lift_apply_mk' f, ←lift_apply_mk' g],
congr' 1,
exact monoid_hom.ext_iff.2 h,
end
/-- The uniqueness part of the universal property for quotients of monoids. -/
@[to_additive "The uniqueness part of the universal property for quotients of `add_monoid`s."]
theorem lift_unique (H : c ≤ ker f) (g : c.quotient →* P)
(Hg : g.comp c.mk' = f) : g = c.lift f H :=
lift_funext g (c.lift f H) $ λ x, by rw [lift_coe H, ←comp_mk'_apply, Hg]
/-- Given a congruence relation `c` on a monoid and a homomorphism `f` constant on `c`'s
equivalence classes, `f` has the same image as the homomorphism that `f` induces on the
quotient. -/
@[to_additive "Given an additive congruence relation `c` on an `add_monoid` and a homomorphism `f`
constant on `c`'s equivalence classes, `f` has the same image as the homomorphism that `f` induces
on the quotient."]
theorem lift_range (H : c ≤ ker f) : (c.lift f H).mrange = f.mrange :=
submonoid.ext $ λ x,
⟨λ ⟨y, hy⟩, by revert hy; rcases y; exact
λ hy, ⟨y, hy.1, by rw [hy.2.symm, ←lift_coe H]; refl⟩,
λ ⟨y, hy⟩, ⟨↑y, hy.1, by rw ←hy.2; refl⟩⟩
/-- Surjective monoid homomorphisms constant on a congruence relation `c`'s equivalence classes
induce a surjective homomorphism on `c`'s quotient. -/
@[to_additive "Surjective `add_monoid` homomorphisms constant on an additive congruence
relation `c`'s equivalence classes induce a surjective homomorphism on `c`'s quotient."]
lemma lift_surjective_of_surjective (h : c ≤ ker f) (hf : surjective f) :
surjective (c.lift f h) :=
λ y, exists.elim (hf y) $ λ w hw, ⟨w, (lift_mk' h w).symm ▸ hw⟩
variables (c f)
/-- Given a monoid homomorphism `f` from `M` to `P`, the kernel of `f` is the unique congruence
relation on `M` whose induced map from the quotient of `M` to `P` is injective. -/
@[to_additive "Given an `add_monoid` homomorphism `f` from `M` to `P`, the kernel of `f`
is the unique additive congruence relation on `M` whose induced map from the quotient of `M`
to `P` is injective."]
lemma ker_eq_lift_of_injective (H : c ≤ ker f) (h : injective (c.lift f H)) :
ker f = c :=
to_setoid_inj $ ker_eq_lift_of_injective f H h
variables {c}
/-- The homomorphism induced on the quotient of a monoid by the kernel of a monoid homomorphism. -/
@[to_additive "The homomorphism induced on the quotient of an `add_monoid` by the kernel
of an `add_monoid` homomorphism."]
def ker_lift : (ker f).quotient →* P :=
(ker f).lift f $ λ _ _, id
variables {f}
/-- The diagram described by the universal property for quotients of monoids, when the congruence
relation is the kernel of the homomorphism, commutes. -/
@[simp, to_additive "The diagram described by the universal property for quotients
of `add_monoid`s, when the additive congruence relation is the kernel of the homomorphism,
commutes."]
lemma ker_lift_mk (x : M) : ker_lift f x = f x := rfl
/-- Given a monoid homomorphism `f`, the induced homomorphism on the quotient by `f`'s kernel has
the same image as `f`. -/
@[simp, to_additive "Given an `add_monoid` homomorphism `f`, the induced homomorphism
on the quotient by `f`'s kernel has the same image as `f`."]
lemma ker_lift_range_eq : (ker_lift f).mrange = f.mrange :=
lift_range $ λ _ _, id
/-- A monoid homomorphism `f` induces an injective homomorphism on the quotient by `f`'s kernel. -/
@[to_additive "An `add_monoid` homomorphism `f` induces an injective homomorphism on the quotient
by `f`'s kernel."]
lemma ker_lift_injective (f : M →* P) : injective (ker_lift f) :=
λ x y, quotient.induction_on₂' x y $ λ _ _, (ker f).eq.2
/-- Given congruence relations `c, d` on a monoid such that `d` contains `c`, `d`'s quotient
map induces a homomorphism from the quotient by `c` to the quotient by `d`. -/
@[to_additive "Given additive congruence relations `c, d` on an `add_monoid` such that `d`
contains `c`, `d`'s quotient map induces a homomorphism from the quotient by `c` to the quotient
by `d`."]
def map (c d : con M) (h : c ≤ d) : c.quotient →* d.quotient :=
c.lift d.mk' $ λ x y hc, show (ker d.mk') x y, from
(mk'_ker d).symm ▸ h hc
/-- Given congruence relations `c, d` on a monoid such that `d` contains `c`, the definition of
the homomorphism from the quotient by `c` to the quotient by `d` induced by `d`'s quotient
map. -/
@[to_additive "Given additive congruence relations `c, d` on an `add_monoid` such that `d`
contains `c`, the definition of the homomorphism from the quotient by `c` to the quotient by `d`
induced by `d`'s quotient map."]
lemma map_apply {c d : con M} (h : c ≤ d) (x) :
c.map d h x = c.lift d.mk' (λ x y hc, d.eq.2 $ h hc) x := rfl
variables (c)
/-- The first isomorphism theorem for monoids. -/
@[to_additive "The first isomorphism theorem for `add_monoid`s."]
noncomputable def quotient_ker_equiv_range (f : M →* P) : (ker f).quotient ≃* f.mrange :=
{ map_mul' := monoid_hom.map_mul _,
..equiv.of_bijective
((@mul_equiv.to_monoid_hom (ker_lift f).mrange _ _ _
$ mul_equiv.submonoid_congr ker_lift_range_eq).comp (ker_lift f).mrange_restrict) $
(equiv.bijective _).comp
⟨λ x y h, ker_lift_injective f $ by rcases x; rcases y; injections,
λ ⟨w, z, hzm, hz⟩, ⟨z, by rcases hz; rcases _x; refl⟩⟩ }
/-- The first isomorphism theorem for monoids in the case of a surjective homomorphism. -/
@[to_additive "The first isomorphism theorem for `add_monoid`s in the case of a surjective
homomorphism."]
noncomputable def quotient_ker_equiv_of_surjective (f : M →* P) (hf : surjective f) :
(ker f).quotient ≃* P :=
{ map_mul' := monoid_hom.map_mul _,
..equiv.of_bijective (ker_lift f)
⟨ker_lift_injective f, lift_surjective_of_surjective (le_refl _) hf⟩ }
/-- The second isomorphism theorem for monoids. -/
@[to_additive "The second isomorphism theorem for `add_monoid`s."]
noncomputable def comap_quotient_equiv (f : N →* M) :
(comap f f.map_mul c).quotient ≃* (c.mk'.comp f).mrange :=
(con.congr comap_eq).trans $ quotient_ker_equiv_range $ c.mk'.comp f
/-- The third isomorphism theorem for monoids. -/
@[to_additive "The third isomorphism theorem for `add_monoid`s."]
def quotient_quotient_equiv_quotient (c d : con M) (h : c ≤ d) :
(ker (c.map d h)).quotient ≃* d.quotient :=
{ map_mul' := λ x y, con.induction_on₂ x y $ λ w z, con.induction_on₂ w z $ λ a b,
show _ = d.mk' a * d.mk' b, by rw ←d.mk'.map_mul; refl,
..quotient_quotient_equiv_quotient c.to_setoid d.to_setoid h }
end monoids
section groups
variables {M} [group M] [group N] [group P] (c : con M)
/-- Multiplicative congruence relations preserve inversion. -/
@[to_additive "Additive congruence relations preserve negation."]
protected lemma inv : ∀ {w x}, c w x → c w⁻¹ x⁻¹ :=
λ x y h, by simpa using c.symm (c.mul (c.mul (c.refl x⁻¹) h) (c.refl y⁻¹))
/-- The inversion induced on the quotient by a congruence relation on a type with a
inversion. -/
@[to_additive "The negation induced on the quotient by an additive congruence relation on a type
with an negation."]
instance has_inv : has_inv c.quotient :=
⟨λ x, quotient.lift_on' x (λ w, ((w⁻¹ : M) : c.quotient))
$ λ x y h, c.eq.2 $ c.inv h⟩
/-- The quotient of a group by a congruence relation is a group. -/
@[to_additive "The quotient of an `add_group` by an additive congruence relation is
an `add_group`."]
instance group : group c.quotient :=
{ inv := λ x, x⁻¹,
mul_left_inv := λ x, show x⁻¹ * x = 1,
from quotient.induction_on' x $ λ _, congr_arg coe $ mul_left_inv _,
.. con.monoid c}
end groups
end con
|
d4513fcf5555fe027fe700012d1d2fcdfbda6f23 | 35677d2df3f081738fa6b08138e03ee36bc33cad | /src/ring_theory/free_ring.lean | 9c0e085f949e26d5499da01c5b8f2e154734d984 | [
"Apache-2.0"
] | permissive | gebner/mathlib | eab0150cc4f79ec45d2016a8c21750244a2e7ff0 | cc6a6edc397c55118df62831e23bfbd6e6c6b4ab | refs/heads/master | 1,625,574,853,976 | 1,586,712,827,000 | 1,586,712,827,000 | 99,101,412 | 1 | 0 | Apache-2.0 | 1,586,716,389,000 | 1,501,667,958,000 | Lean | UTF-8 | Lean | false | false | 3,985 | lean | /-
Copyright (c) 2019 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Johan Commelin
-/
import algebra.free_monoid group_theory.free_abelian_group data.polynomial
universes u v
def free_ring (α : Type u) : Type u :=
free_abelian_group $ free_monoid α
namespace free_ring
variables (α : Type u)
instance : ring (free_ring α) := free_abelian_group.ring _
instance : inhabited (free_ring α) := ⟨0⟩
variables {α}
def of (x : α) : free_ring α :=
free_abelian_group.of [x]
@[elab_as_eliminator] protected lemma induction_on
{C : free_ring α → Prop} (z : free_ring α)
(hn1 : C (-1)) (hb : ∀ b, C (of b))
(ha : ∀ x y, C x → C y → C (x + y))
(hm : ∀ x y, C x → C y → C (x * y)) : C z :=
have hn : ∀ x, C x → C (-x), from λ x ih, neg_one_mul x ▸ hm _ _ hn1 ih,
have h1 : C 1, from neg_neg (1 : free_ring α) ▸ hn _ hn1,
free_abelian_group.induction_on z
(add_left_neg (1 : free_ring α) ▸ ha _ _ hn1 h1)
(λ m, list.rec_on m h1 $ λ a m ih, hm _ _ (hb a) ih)
(λ m ih, hn _ ih)
ha
section lift
variables {β : Type v} [ring β] (f : α → β)
def lift : free_ring α → β :=
free_abelian_group.lift $ λ L, (list.map f L).prod
@[simp] lemma lift_zero : lift f 0 = 0 := rfl
@[simp] lemma lift_one : lift f 1 = 1 :=
free_abelian_group.lift.of _ _
@[simp] lemma lift_of (x : α) : lift f (of x) = f x :=
(free_abelian_group.lift.of _ _).trans $ one_mul _
@[simp] lemma lift_add (x y) : lift f (x + y) = lift f x + lift f y :=
free_abelian_group.lift.add _ _ _
@[simp] lemma lift_neg (x) : lift f (-x) = -lift f x :=
free_abelian_group.lift.neg _ _
@[simp] lemma lift_sub (x y) : lift f (x - y) = lift f x - lift f y :=
free_abelian_group.lift.sub _ _ _
@[simp] lemma lift_mul (x y) : lift f (x * y) = lift f x * lift f y :=
begin
refine free_abelian_group.induction_on y (mul_zero _).symm _ _ _,
{ intros L2, conv { to_lhs, dsimp only [(*), mul_zero_class.mul, semiring.mul, ring.mul, semigroup.mul] },
rw [free_abelian_group.lift.of, lift, free_abelian_group.lift.of],
refine free_abelian_group.induction_on x (zero_mul _).symm _ _ _,
{ intros L1, iterate 3 { rw free_abelian_group.lift.of },
show list.prod (list.map f (_ ++ _)) = _, rw [list.map_append, list.prod_append] },
{ intros L1 ih, iterate 3 { rw free_abelian_group.lift.neg }, rw [ih, neg_mul_eq_neg_mul] },
{ intros x1 x2 ih1 ih2, iterate 3 { rw free_abelian_group.lift.add }, rw [ih1, ih2, add_mul] } },
{ intros L2 ih, rw [mul_neg_eq_neg_mul_symm, lift_neg, lift_neg, mul_neg_eq_neg_mul_symm, ih] },
{ intros y1 y2 ih1 ih2, rw [mul_add, lift_add, lift_add, mul_add, ih1, ih2] },
end
instance : is_ring_hom (lift f) :=
{ map_one := lift_one f,
map_mul := lift_mul f,
map_add := lift_add f }
@[simp] lemma lift_pow (x) (n : ℕ) : lift f (x ^ n) = lift f x ^ n :=
is_semiring_hom.map_pow _ x n
@[simp] lemma lift_comp_of (f : free_ring α → β) [is_ring_hom f] : lift (f ∘ of) = f :=
funext $ λ x, free_ring.induction_on x
(by rw [lift_neg, lift_one, is_ring_hom.map_neg f, is_ring_hom.map_one f])
(lift_of _)
(λ x y ihx ihy, by rw [lift_add, is_ring_hom.map_add f, ihx, ihy])
(λ x y ihx ihy, by rw [lift_mul, is_ring_hom.map_mul f, ihx, ihy])
end lift
variables {β : Type v} (f : α → β)
def map : free_ring α → free_ring β :=
lift $ of ∘ f
@[simp] lemma map_zero : map f 0 = 0 := rfl
@[simp] lemma map_one : map f 1 = 1 := rfl
@[simp] lemma map_of (x : α) : map f (of x) = of (f x) := lift_of _ _
@[simp] lemma map_add (x y) : map f (x + y) = map f x + map f y := lift_add _ _ _
@[simp] lemma map_neg (x) : map f (-x) = -map f x := lift_neg _ _
@[simp] lemma map_sub (x y) : map f (x - y) = map f x - map f y := lift_sub _ _ _
@[simp] lemma map_mul (x y) : map f (x * y) = map f x * map f y := lift_mul _ _ _
@[simp] lemma map_pow (x) (n : ℕ) : map f (x ^ n) = (map f x) ^ n := lift_pow _ _ _
end free_ring
|
c94615d3dc9e918d0e869038a3399923ce828689 | d1a52c3f208fa42c41df8278c3d280f075eb020c | /tests/lean/run/split2.lean | f5b697c9b3844fb0021104b301592493551669fc | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | cipher1024/lean4 | 6e1f98bb58e7a92b28f5364eb38a14c8d0aae393 | 69114d3b50806264ef35b57394391c3e738a9822 | refs/heads/master | 1,642,227,983,603 | 1,642,011,696,000 | 1,642,011,696,000 | 228,607,691 | 0 | 0 | Apache-2.0 | 1,576,584,269,000 | 1,576,584,268,000 | null | UTF-8 | Lean | false | false | 942 | lean | def f (x y z : Nat) : Nat :=
match x, y, z with
| 5, _, _ => y
| _, 5, _ => y
| _, _, 5 => y
| _, _, _ => 1
example (x y z : Nat) : x ≠ 5 → y ≠ 5 → z ≠ 5 → f x y z = 1 := by
intros
simp [f]
split
. contradiction
. contradiction
. contradiction
. rfl
example (x y z : Nat) : f x y z = y ∨ f x y z = 1 := by
intros
simp [f]
split
. exact Or.inl rfl
. exact Or.inl rfl
. exact Or.inl rfl
. exact Or.inr rfl
example (x y z : Nat) : f x y z = y ∨ f x y z = 1 := by
intros
simp [f]
split <;> (first | apply Or.inl rfl | apply Or.inr rfl)
def g (xs ys : List Nat) : Nat :=
match xs, ys with
| [a, b], _ => Nat.succ (a+b)
| _, [b, c] => Nat.succ b
| _, _ => 1
example (xs ys : List Nat) : g xs ys > 0 := by
simp [g]
split
next a b _ => show Nat.succ (a + b) > 0; apply Nat.zero_lt_succ
next xs b c _ => show Nat.succ b > 0; apply Nat.zero_lt_succ
next => decide
|
f109f8daf3eaa2fdb31788effaa33d2e994f3e54 | 618003631150032a5676f229d13a079ac875ff77 | /src/tactic/norm_num.lean | 9aafb5a5d4fecfc5224e8c970d04a7b1af1ccab5 | [
"Apache-2.0"
] | permissive | awainverse/mathlib | 939b68c8486df66cfda64d327ad3d9165248c777 | ea76bd8f3ca0a8bf0a166a06a475b10663dec44a | refs/heads/master | 1,659,592,962,036 | 1,590,987,592,000 | 1,590,987,592,000 | 268,436,019 | 1 | 0 | Apache-2.0 | 1,590,990,500,000 | 1,590,990,500,000 | null | UTF-8 | Lean | false | false | 62,105 | lean | /-
Copyright (c) 2017 Simon Hudon All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon, Mario Carneiro
-/
import data.rat.cast
import data.rat.meta_defs
import tactic.doc_commands
/-!
# `norm_num`
Evaluating arithmetic expressions including *, +, -, ^, ≤
-/
universes u v w
namespace tactic
/-- Reflexivity conversion: given `e` returns `(e, ⊢ e = e)` -/
meta def refl_conv (e : expr) : tactic (expr × expr) :=
do p ← mk_eq_refl e, return (e, p)
/-- Transitivity conversion: given two conversions (which take an
expression `e` and returns `(e', ⊢ e = e')`), produces another
conversion that combines them with transitivity, treating failures
as reflexivity conversions. -/
meta def trans_conv (t₁ t₂ : expr → tactic (expr × expr)) (e : expr) :
tactic (expr × expr) :=
(do (e₁, p₁) ← t₁ e,
(do (e₂, p₂) ← t₂ e₁,
p ← mk_eq_trans p₁ p₂, return (e₂, p)) <|>
return (e₁, p₁)) <|> t₂ e
namespace instance_cache
/-- Faster version of `mk_app ``bit0 [e]`. -/
meta def mk_bit0 (c : instance_cache) (e : expr) : tactic (instance_cache × expr) :=
do (c, ai) ← c.get ``has_add,
return (c, (expr.const ``bit0 [c.univ]).mk_app [c.α, ai, e])
/-- Faster version of `mk_app ``bit1 [e]`. -/
meta def mk_bit1 (c : instance_cache) (e : expr) : tactic (instance_cache × expr) :=
do (c, ai) ← c.get ``has_add,
(c, oi) ← c.get ``has_one,
return (c, (expr.const ``bit1 [c.univ]).mk_app [c.α, oi, ai, e])
end instance_cache
end tactic
open tactic
namespace norm_num
variable {α : Type u}
lemma subst_into_add {α} [has_add α] (l r tl tr t)
(prl : (l : α) = tl) (prr : r = tr) (prt : tl + tr = t) : l + r = t :=
by rw [prl, prr, prt]
lemma subst_into_mul {α} [has_mul α] (l r tl tr t)
(prl : (l : α) = tl) (prr : r = tr) (prt : tl * tr = t) : l * r = t :=
by rw [prl, prr, prt]
lemma subst_into_neg {α} [has_neg α] (a ta t : α) (pra : a = ta) (prt : -ta = t) : -a = t :=
by simp [pra, prt]
/-- The result type of `match_numeral`, either `0`, `1`, or a top level
decomposition of `bit0 e` or `bit1 e`. The `other` case means it is not a numeral. -/
meta inductive match_numeral_result
| zero | one | bit0 (e : expr) | bit1 (e : expr) | other
/-- Unfold the top level constructor of the numeral expression. -/
meta def match_numeral : expr → match_numeral_result
| `(bit0 %%e) := match_numeral_result.bit0 e
| `(bit1 %%e) := match_numeral_result.bit1 e
| `(@has_zero.zero _ _) := match_numeral_result.zero
| `(@has_one.one _ _) := match_numeral_result.one
| _ := match_numeral_result.other
theorem zero_succ {α} [semiring α] : (0 + 1 : α) = 1 := zero_add _
theorem one_succ {α} [semiring α] : (1 + 1 : α) = 2 := rfl
theorem bit0_succ {α} [semiring α] (a : α) : bit0 a + 1 = bit1 a := rfl
theorem bit1_succ {α} [semiring α] (a b : α) (h : a + 1 = b) : bit1 a + 1 = bit0 b :=
h ▸ by simp [bit1, bit0, add_left_comm, add_assoc]
section
open match_numeral_result
/-- Given `a`, `b` natural numerals, proves `⊢ a + 1 = b`, assuming that this is provable.
(It may prove garbage instead of failing if `a + 1 = b` is false.) -/
meta def prove_succ : instance_cache → expr → expr → tactic (instance_cache × expr)
| c e r := match match_numeral e with
| zero := c.mk_app ``zero_succ []
| one := c.mk_app ``one_succ []
| bit0 e := c.mk_app ``bit0_succ [e]
| bit1 e := do
let r := r.app_arg,
(c, p) ← prove_succ c e r,
c.mk_app ``bit1_succ [e, r, p]
| _ := failed
end
end
theorem zero_adc {α} [semiring α] (a b : α) (h : a + 1 = b) : 0 + a + 1 = b := by rwa zero_add
theorem adc_zero {α} [semiring α] (a b : α) (h : a + 1 = b) : a + 0 + 1 = b := by rwa add_zero
theorem one_add {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + a = b := by rwa add_comm
theorem add_bit0_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit0 b = bit0 c :=
h ▸ by simp [bit0, add_left_comm, add_assoc]
theorem add_bit0_bit1 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit1 b = bit1 c :=
h ▸ by simp [bit0, bit1, add_left_comm, add_assoc]
theorem add_bit1_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit1 a + bit0 b = bit1 c :=
h ▸ by simp [bit0, bit1, add_left_comm, add_comm]
theorem add_bit1_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) : bit1 a + bit1 b = bit0 c :=
h ▸ by simp [bit0, bit1, add_left_comm, add_comm]
theorem adc_one_one {α} [semiring α] : (1 + 1 + 1 : α) = 3 := rfl
theorem adc_bit0_one {α} [semiring α] (a b : α) (h : a + 1 = b) : bit0 a + 1 + 1 = bit0 b :=
h ▸ by simp [bit0, add_left_comm, add_assoc]
theorem adc_one_bit0 {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + bit0 a + 1 = bit0 b :=
h ▸ by simp [bit0, add_left_comm, add_assoc]
theorem adc_bit1_one {α} [semiring α] (a b : α) (h : a + 1 = b) : bit1 a + 1 + 1 = bit1 b :=
h ▸ by simp [bit1, bit0, add_left_comm, add_assoc]
theorem adc_one_bit1 {α} [semiring α] (a b : α) (h : a + 1 = b) : 1 + bit1 a + 1 = bit1 b :=
h ▸ by simp [bit1, bit0, add_left_comm, add_assoc]
theorem adc_bit0_bit0 {α} [semiring α] (a b c : α) (h : a + b = c) : bit0 a + bit0 b + 1 = bit1 c :=
h ▸ by simp [bit1, bit0, add_left_comm, add_assoc]
theorem adc_bit1_bit0 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) : bit1 a + bit0 b + 1 = bit0 c :=
h ▸ by simp [bit1, bit0, add_left_comm, add_assoc]
theorem adc_bit0_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) : bit0 a + bit1 b + 1 = bit0 c :=
h ▸ by simp [bit1, bit0, add_left_comm, add_assoc]
theorem adc_bit1_bit1 {α} [semiring α] (a b c : α) (h : a + b + 1 = c) : bit1 a + bit1 b + 1 = bit1 c :=
h ▸ by simp [bit1, bit0, add_left_comm, add_assoc]
section
open match_numeral_result
meta mutual def prove_add_nat, prove_adc_nat
with prove_add_nat : instance_cache → expr → expr → expr → tactic (instance_cache × expr)
| c a b r := do
match match_numeral a, match_numeral b with
| zero, _ := c.mk_app ``zero_add [b]
| _, zero := c.mk_app ``add_zero [a]
| _, one := prove_succ c a r
| one, _ := do (c, p) ← prove_succ c b r, c.mk_app ``one_add [b, r, p]
| bit0 a, bit0 b := do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit0_bit0 [a, b, r, p]
| bit0 a, bit1 b := do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit0_bit1 [a, b, r, p]
| bit1 a, bit0 b := do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``add_bit1_bit0 [a, b, r, p]
| bit1 a, bit1 b := do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``add_bit1_bit1 [a, b, r, p]
| _, _ := failed
end
with prove_adc_nat : instance_cache → expr → expr → expr → tactic (instance_cache × expr)
| c a b r := do
match match_numeral a, match_numeral b with
| zero, _ := do (c, p) ← prove_succ c b r, c.mk_app ``zero_adc [b, r, p]
| _, zero := do (c, p) ← prove_succ c b r, c.mk_app ``adc_zero [b, r, p]
| one, one := c.mk_app ``adc_one_one []
| bit0 a, one := do let r := r.app_arg, (c, p) ← prove_succ c a r, c.mk_app ``adc_bit0_one [a, r, p]
| one, bit0 b := do let r := r.app_arg, (c, p) ← prove_succ c b r, c.mk_app ``adc_one_bit0 [b, r, p]
| bit1 a, one := do let r := r.app_arg, (c, p) ← prove_succ c a r, c.mk_app ``adc_bit1_one [a, r, p]
| one, bit1 b := do let r := r.app_arg, (c, p) ← prove_succ c b r, c.mk_app ``adc_one_bit1 [b, r, p]
| bit0 a, bit0 b := do let r := r.app_arg, (c, p) ← prove_add_nat c a b r, c.mk_app ``adc_bit0_bit0 [a, b, r, p]
| bit0 a, bit1 b := do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit0_bit1 [a, b, r, p]
| bit1 a, bit0 b := do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit1_bit0 [a, b, r, p]
| bit1 a, bit1 b := do let r := r.app_arg, (c, p) ← prove_adc_nat c a b r, c.mk_app ``adc_bit1_bit1 [a, b, r, p]
| _, _ := failed
end
/-- Given `a`,`b`,`r` natural numerals, proves `⊢ a + b = r`. -/
add_decl_doc prove_add_nat
/-- Given `a`,`b`,`r` natural numerals, proves `⊢ a + b + 1 = r`. -/
add_decl_doc prove_adc_nat
/-- Given `a`,`b` natural numerals, returns `(r, ⊢ a + b = r)`. -/
meta def prove_add_nat' (c : instance_cache) (a b : expr) : tactic (instance_cache × expr × expr) := do
na ← a.to_nat,
nb ← b.to_nat,
(c, r) ← c.of_nat (na + nb),
(c, p) ← prove_add_nat c a b r,
return (c, r, p)
end
theorem bit0_mul {α} [semiring α] (a b c : α) (h : a * b = c) :
bit0 a * b = bit0 c := h ▸ by simp [bit0, add_mul]
theorem mul_bit0' {α} [semiring α] (a b c : α) (h : a * b = c) :
a * bit0 b = bit0 c := h ▸ by simp [bit0, mul_add]
theorem mul_bit0_bit0 {α} [semiring α] (a b c : α) (h : a * b = c) :
bit0 a * bit0 b = bit0 (bit0 c) := bit0_mul _ _ _ (mul_bit0' _ _ _ h)
theorem mul_bit1_bit1 {α} [semiring α] (a b c d e : α)
(hc : a * b = c) (hd : a + b = d) (he : bit0 c + d = e) :
bit1 a * bit1 b = bit1 e :=
by rw [← he, ← hd, ← hc]; simp [bit1, bit0, mul_add, add_mul, add_left_comm, add_assoc]
section
open match_numeral_result
/-- Given `a`,`b` natural numerals, returns `(r, ⊢ a * b = r)`. -/
meta def prove_mul_nat : instance_cache → expr → expr → tactic (instance_cache × expr × expr)
| ic a b :=
match match_numeral a, match_numeral b with
| zero, _ := do
(ic, z) ← ic.mk_app ``has_zero.zero [],
(ic, p) ← ic.mk_app ``zero_mul [b],
return (ic, z, p)
| _, zero := do
(ic, z) ← ic.mk_app ``has_zero.zero [],
(ic, p) ← ic.mk_app ``mul_zero [a],
return (ic, z, p)
| one, _ := do (ic, p) ← ic.mk_app ``one_mul [b], return (ic, b, p)
| _, one := do (ic, p) ← ic.mk_app ``mul_one [a], return (ic, a, p)
| bit0 a, bit0 b := do
(ic, c, p) ← prove_mul_nat ic a b,
(ic, p) ← ic.mk_app ``mul_bit0_bit0 [a, b, c, p],
(ic, c') ← ic.mk_bit0 c,
(ic, c') ← ic.mk_bit0 c',
return (ic, c', p)
| bit0 a, _ := do
(ic, c, p) ← prove_mul_nat ic a b,
(ic, p) ← ic.mk_app ``bit0_mul [a, b, c, p],
(ic, c') ← ic.mk_bit0 c,
return (ic, c', p)
| _, bit0 b := do
(ic, c, p) ← prove_mul_nat ic a b,
(ic, p) ← ic.mk_app ``mul_bit0' [a, b, c, p],
(ic, c') ← ic.mk_bit0 c,
return (ic, c', p)
| bit1 a, bit1 b := do
(ic, c, pc) ← prove_mul_nat ic a b,
(ic, d, pd) ← prove_add_nat' ic a b,
(ic, c') ← ic.mk_bit0 c,
(ic, e, pe) ← prove_add_nat' ic c' d,
(ic, p) ← ic.mk_app ``mul_bit1_bit1 [a, b, c, d, e, pc, pd, pe],
(ic, e') ← ic.mk_bit1 e,
return (ic, e', p)
| _, _ := failed
end
end
section
open match_numeral_result
/-- Given `a` a positive natural numeral, returns `⊢ 0 < a`. -/
meta def prove_pos_nat (c : instance_cache) : expr → tactic (instance_cache × expr)
| e :=
match match_numeral e with
| one := c.mk_app ``zero_lt_one []
| bit0 e := do (c, p) ← prove_pos_nat e, c.mk_app ``bit0_pos [e, p]
| bit1 e := do (c, p) ← prove_pos_nat e, c.mk_app ``bit1_pos' [e, p]
| _ := failed
end
end
/-- Given `a` a rational numeral, returns `⊢ 0 < a`. -/
meta def prove_pos (c : instance_cache) : expr → tactic (instance_cache × expr)
| `(%%e₁ / %%e₂) := do
(c, p₁) ← prove_pos_nat c e₁, (c, p₂) ← prove_pos_nat c e₂,
c.mk_app ``div_pos_of_pos_of_pos [e₁, e₂, p₁, p₂]
| e := prove_pos_nat c e
/-- `match_neg (- e) = some e`, otherwise `none` -/
meta def match_neg : expr → option expr
| `(- %%e) := some e
| _ := none
/-- `match_sign (- e) = inl e`, `match_sign 0 = inr ff`, otherwise `inr tt` -/
meta def match_sign : expr → expr ⊕ bool
| `(- %%e) := sum.inl e
| `(has_zero.zero) := sum.inr ff
| _ := sum.inr tt
theorem ne_zero_of_pos {α} [ordered_add_comm_group α] (a : α) : 0 < a → a ≠ 0 := ne_of_gt
theorem ne_zero_neg {α} [add_group α] (a : α) : a ≠ 0 → -a ≠ 0 := mt neg_eq_zero.1
/-- Given `a` a rational numeral, returns `⊢ a ≠ 0`. -/
meta def prove_ne_zero (c : instance_cache) : expr → tactic (instance_cache × expr)
| a :=
match match_neg a with
| some a := do (c, p) ← prove_ne_zero a, c.mk_app ``ne_zero_neg [a, p]
| none := do (c, p) ← prove_pos c a, c.mk_app ``ne_zero_of_pos [a, p]
end
theorem clear_denom_div {α} [division_ring α] (a b b' c d : α)
(h₀ : b ≠ 0) (h₁ : b * b' = d) (h₂ : a * b' = c) : (a / b) * d = c :=
by rwa [← h₁, ← mul_assoc, div_mul_cancel _ h₀]
/-- Given `a` nonnegative rational and `d` a natural number, returns `(b, ⊢ a * d = b)`.
(`d` should be a multiple of the denominator of `a`, so that `b` is a natural number.) -/
meta def prove_clear_denom (c : instance_cache) (a d : expr) (na : ℚ) (nd : ℕ) : tactic (instance_cache × expr × expr) :=
if na.denom = 1 then
prove_mul_nat c a d
else do
[_, _, a, b] ← return a.get_app_args,
(c, b') ← c.of_nat (nd / na.denom),
(c, p₀) ← prove_ne_zero c b,
(c, _, p₁) ← prove_mul_nat c b b',
(c, r, p₂) ← prove_mul_nat c a b',
(c, p) ← c.mk_app ``clear_denom_div [a, b, b', r, d, p₀, p₁, p₂],
return (c, r, p)
theorem clear_denom_add {α} [division_ring α] (a a' b b' c c' d : α)
(h₀ : d ≠ 0) (ha : a * d = a') (hb : b * d = b') (hc : c * d = c')
(h : a' + b' = c') : a + b = c :=
mul_right_cancel' h₀ $ by rwa [add_mul, ha, hb, hc]
/-- Given `a`,`b`,`c` nonnegative rational numerals, returns `⊢ a + b = c`. -/
meta def prove_add_nonneg_rat (ic : instance_cache) (a b c : expr) (na nb nc : ℚ) : tactic (instance_cache × expr) :=
if na.denom = 1 ∧ nb.denom = 1 then
prove_add_nat ic a b c
else do
let nd := na.denom.lcm nb.denom,
(ic, d) ← ic.of_nat nd,
(ic, p₀) ← prove_ne_zero ic d,
(ic, a', pa) ← prove_clear_denom ic a d na nd,
(ic, b', pb) ← prove_clear_denom ic b d nb nd,
(ic, c', pc) ← prove_clear_denom ic c d nc nd,
(ic, p) ← prove_add_nat ic a' b' c',
ic.mk_app ``clear_denom_add [a, a', b, b', c, c', d, p₀, pa, pb, pc, p]
theorem add_pos_neg_pos {α} [add_group α] (a b c : α) (h : c + b = a) : a + -b = c :=
h ▸ by simp
theorem add_pos_neg_neg {α} [add_group α] (a b c : α) (h : c + a = b) : a + -b = -c :=
h ▸ by simp
theorem add_neg_pos_pos {α} [add_group α] (a b c : α) (h : a + c = b) : -a + b = c :=
h ▸ by simp
theorem add_neg_pos_neg {α} [add_group α] (a b c : α) (h : b + c = a) : -a + b = -c :=
h ▸ by simp
theorem add_neg_neg {α} [add_group α] (a b c : α) (h : b + a = c) : -a + -b = -c :=
h ▸ by simp
/-- Given `a`,`b`,`c` rational numerals, returns `⊢ a + b = c`. -/
meta def prove_add_rat (ic : instance_cache) (ea eb ec : expr) (a b c : ℚ) : tactic (instance_cache × expr) :=
match match_neg ea, match_neg eb, match_neg ec with
| some ea, some eb, some ec := do
(ic, p) ← prove_add_nonneg_rat ic eb ea ec (-b) (-a) (-c),
ic.mk_app ``add_neg_neg [ea, eb, ec, p]
| some ea, none, some ec := do
(ic, p) ← prove_add_nonneg_rat ic eb ec ea b (-c) (-a),
ic.mk_app ``add_neg_pos_neg [ea, eb, ec, p]
| some ea, none, none := do
(ic, p) ← prove_add_nonneg_rat ic ea ec eb (-a) c b,
ic.mk_app ``add_neg_pos_pos [ea, eb, ec, p]
| none, some eb, some ec := do
(ic, p) ← prove_add_nonneg_rat ic ec ea eb (-c) a (-b),
ic.mk_app ``add_pos_neg_neg [ea, eb, ec, p]
| none, some eb, none := do
(ic, p) ← prove_add_nonneg_rat ic ec eb ea c (-b) a,
ic.mk_app ``add_pos_neg_pos [ea, eb, ec, p]
| _, _, _ := prove_add_nonneg_rat ic ea eb ec a b c
end
/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a + b = c)`. -/
meta def prove_add_rat' (ic : instance_cache) (a b : expr) : tactic (instance_cache × expr × expr) := do
na ← a.to_rat,
nb ← b.to_rat,
let nc := na + nb,
(ic, c) ← ic.of_rat nc,
(ic, p) ← prove_add_rat ic a b c na nb nc,
return (ic, c, p)
theorem clear_denom_simple_nat {α} [division_ring α] (a : α) :
(1:α) ≠ 0 ∧ a * 1 = a := ⟨one_ne_zero, mul_one _⟩
theorem clear_denom_simple_div {α} [division_ring α] (a b : α) (h : b ≠ 0) :
b ≠ 0 ∧ a / b * b = a := ⟨h, div_mul_cancel _ h⟩
/-- Given `a` a nonnegative rational numeral, returns `(b, c, ⊢ a * b = c)`
where `b` and `c` are natural numerals. (`b` will be the denominator of `a`.) -/
meta def prove_clear_denom_simple (c : instance_cache) (a : expr) (na : ℚ) : tactic (instance_cache × expr × expr × expr) :=
if na.denom = 1 then do
(c, d) ← c.mk_app ``has_one.one [],
(c, p) ← c.mk_app ``clear_denom_simple_nat [a],
return (c, d, a, p)
else do
[α, _, a, b] ← return a.get_app_args,
(c, p₀) ← prove_ne_zero c b,
(c, p) ← c.mk_app ``clear_denom_simple_div [a, b, p₀],
return (c, b, a, p)
theorem clear_denom_mul {α} [field α] (a a' b b' c c' d₁ d₂ d : α)
(ha : d₁ ≠ 0 ∧ a * d₁ = a') (hb : d₂ ≠ 0 ∧ b * d₂ = b')
(hc : c * d = c') (hd : d₁ * d₂ = d)
(h : a' * b' = c') : a * b = c :=
mul_right_cancel' ha.1 $ mul_right_cancel' hb.1 $
by rw [mul_assoc c, hd, hc, ← h, ← ha.2, ← hb.2, ← mul_assoc, mul_right_comm a]
/-- Given `a`,`b` nonnegative rational numerals, returns `(c, ⊢ a * b = c)`. -/
meta def prove_mul_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) : tactic (instance_cache × expr × expr) :=
if na.denom = 1 ∧ nb.denom = 1 then
prove_mul_nat ic a b
else do
let nc := na * nb, (ic, c) ← ic.of_rat nc,
(ic, d₁, a', pa) ← prove_clear_denom_simple ic a na,
(ic, d₂, b', pb) ← prove_clear_denom_simple ic b nb,
(ic, d, pd) ← prove_mul_nat ic d₁ d₂, nd ← d.to_nat,
(ic, c', pc) ← prove_clear_denom ic c d nc nd,
(ic, _, p) ← prove_mul_nat ic a' b',
(ic, p) ← ic.mk_app ``clear_denom_mul [a, a', b, b', c, c', d₁, d₂, d, pa, pb, pc, pd, p],
return (ic, c, p)
theorem mul_neg_pos {α} [ring α] (a b c : α) (h : a * b = c) : -a * b = -c := h ▸ by simp
theorem mul_pos_neg {α} [ring α] (a b c : α) (h : a * b = c) : a * -b = -c := h ▸ by simp
theorem mul_neg_neg {α} [ring α] (a b c : α) (h : a * b = c) : -a * -b = c := h ▸ by simp
/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a * b = c)`. -/
meta def prove_mul_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) : tactic (instance_cache × expr × expr) :=
match match_sign a, match_sign b with
| sum.inl a, sum.inl b := do
(ic, c, p) ← prove_mul_nonneg_rat ic a b (-na) (-nb),
(ic, p) ← ic.mk_app ``mul_neg_neg [a, b, c, p],
return (ic, c, p)
| sum.inr ff, _ := do
(ic, z) ← ic.mk_app ``has_zero.zero [],
(ic, p) ← ic.mk_app ``zero_mul [b],
return (ic, z, p)
| _, sum.inr ff := do
(ic, z) ← ic.mk_app ``has_zero.zero [],
(ic, p) ← ic.mk_app ``mul_zero [a],
return (ic, z, p)
| sum.inl a, sum.inr tt := do
(ic, c, p) ← prove_mul_nonneg_rat ic a b (-na) nb,
(ic, p) ← ic.mk_app ``mul_neg_pos [a, b, c, p],
(ic, c') ← ic.mk_app ``has_neg.neg [c],
return (ic, c', p)
| sum.inr tt, sum.inl b := do
(ic, c, p) ← prove_mul_nonneg_rat ic a b na (-nb),
(ic, p) ← ic.mk_app ``mul_pos_neg [a, b, c, p],
(ic, c') ← ic.mk_app ``has_neg.neg [c],
return (ic, c', p)
| sum.inr tt, sum.inr tt := prove_mul_nonneg_rat ic a b na nb
end
theorem inv_neg {α} [division_ring α] (a b : α) (h : a⁻¹ = b) : (-a)⁻¹ = -b :=
h ▸ by simp only [inv_eq_one_div, one_div_neg_eq_neg_one_div]
theorem inv_one {α} [division_ring α] : (1 : α)⁻¹ = 1 := one_inv_eq
theorem inv_one_div {α} [division_ring α] (a : α) : (1 / a)⁻¹ = a :=
by rw [one_div_eq_inv, inv_inv']
theorem inv_div_one {α} [division_ring α] (a : α) : a⁻¹ = 1 / a :=
inv_eq_one_div _
theorem inv_div {α} [division_ring α] (a b : α) : (a / b)⁻¹ = b / a :=
by simp only [inv_eq_one_div, one_div_div]
/-- Given `a` a rational numeral, returns `(b, ⊢ a⁻¹ = b)`. -/
meta def prove_inv : instance_cache → expr → ℚ → tactic (instance_cache × expr × expr)
| ic e n :=
match match_sign e with
| sum.inl e := do
(ic, e', p) ← prove_inv ic e (-n),
(ic, r) ← ic.mk_app ``has_neg.neg [e'],
(ic, p) ← ic.mk_app ``inv_neg [e, e', p],
return (ic, r, p)
| sum.inr ff := do
(ic, p) ← ic.mk_app ``inv_zero [],
return (ic, e, p)
| sum.inr tt :=
if n.num = 1 then
if n.denom = 1 then do
(ic, p) ← ic.mk_app ``one_inv_eq [],
return (ic, e, p)
else do
let e := e.app_arg,
(ic, p) ← ic.mk_app ``inv_one_div [e],
return (ic, e, p)
else if n.denom = 1 then do
(ic, p) ← ic.mk_app ``inv_div_one [e],
e ← infer_type p,
return (ic, e.app_arg, p)
else do
[_, _, a, b] ← return e.get_app_args,
(ic, e') ← ic.mk_app ``has_div.div [b, a],
(ic, p) ← ic.mk_app ``inv_div [a, b],
return (ic, e', p)
end
theorem div_eq {α} [division_ring α] (a b b' c : α)
(hb : b⁻¹ = b') (h : a * b' = c) : a / b = c := by rwa ← hb at h
/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a / b = c)`. -/
meta def prove_div (ic : instance_cache) (a b : expr) (na nb : ℚ) : tactic (instance_cache × expr × expr) :=
do (ic, b', pb) ← prove_inv ic b nb,
(ic, c, p) ← prove_mul_rat ic a b' na nb⁻¹,
(ic, p) ← ic.mk_app ``div_eq [a, b, b', c, pb, p],
return (ic, c, p)
/-- Given `a` a rational numeral, returns `(b, ⊢ -a = b)`. -/
meta def prove_neg (ic : instance_cache) (a : expr) : tactic (instance_cache × expr × expr) :=
match match_sign a with
| sum.inl a := do
(ic, p) ← ic.mk_app ``neg_neg [a],
return (ic, a, p)
| sum.inr ff := do
(ic, p) ← ic.mk_app ``neg_zero [],
return (ic, a, p)
| sum.inr tt := do
(ic, a') ← ic.mk_app ``has_neg.neg [a],
p ← mk_eq_refl a',
return (ic, a', p)
end
theorem sub_pos {α} [add_group α] (a b b' c : α) (hb : -b = b') (h : a + b' = c) : a - b = c :=
by rwa ← hb at h
theorem sub_neg {α} [add_group α] (a b c : α) (h : a + b = c) : a - -b = c :=
by rwa sub_neg_eq_add
/-- Given `a`,`b` rational numerals, returns `(c, ⊢ a - b = c)`. -/
meta def prove_sub (ic : instance_cache) (a b : expr) : tactic (instance_cache × expr × expr) :=
match match_sign b with
| sum.inl b := do
(ic, c, p) ← prove_add_rat' ic a b,
(ic, p) ← ic.mk_app ``sub_neg [a, b, c, p],
return (ic, c, p)
| sum.inr ff := do
(ic, p) ← ic.mk_app ``sub_zero [a],
return (ic, a, p)
| sum.inr tt := do
(ic, b', pb) ← prove_neg ic b,
(ic, c, p) ← prove_add_rat' ic a b',
(ic, p) ← ic.mk_app ``sub_pos [a, b, b', c, pb, p],
return (ic, c, p)
end
theorem sub_nat_pos (a b c : ℕ) (h : b + c = a) : a - b = c :=
h ▸ nat.add_sub_cancel_left _ _
theorem sub_nat_neg (a b c : ℕ) (h : a + c = b) : a - b = 0 :=
nat.sub_eq_zero_of_le $ h ▸ nat.le_add_right _ _
/-- Given `a : nat`,`b : nat` natural numerals, returns `(c, ⊢ a - b = c)`. -/
meta def prove_sub_nat (ic : instance_cache) (a b : expr) : tactic (expr × expr) :=
do na ← a.to_nat, nb ← b.to_nat,
if nb ≤ na then do
(ic, c) ← ic.of_nat (na - nb),
(ic, p) ← prove_add_nat ic b c a,
return (c, `(sub_nat_pos).mk_app [a, b, c, p])
else do
(ic, c) ← ic.of_nat (nb - na),
(ic, p) ← prove_add_nat ic a c b,
return (`(0 : ℕ), `(sub_nat_neg).mk_app [a, b, c, p])
/-- This is needed because when `a` and `b` are numerals lean is more likely to unfold them
than unfold the instances in order to prove that `add_group_has_sub = int.has_sub`. -/
theorem int_sub_hack (a b c : ℤ) (h : @has_sub.sub ℤ add_group_has_sub a b = c) : a - b = c := h
/-- Given `a : ℤ`, `b : ℤ` integral numerals, returns `(c, ⊢ a - b = c)`. -/
meta def prove_sub_int (ic : instance_cache) (a b : expr) : tactic (expr × expr) :=
do (_, c, p) ← prove_sub ic a b,
return (c, `(int_sub_hack).mk_app [a, b, c, p])
/-- Evaluates the basic field operations `+`,`neg`,`-`,`*`,`inv`,`/` on numerals.
Also handles nat subtraction. Does not do recursive simplification; that is,
`1 + 1 + 1` will not simplify but `2 + 1` will. This is handled by the top level
`simp` call in `norm_num.derive`. -/
meta def eval_field : expr → tactic (expr × expr)
| `(%%e₁ + %%e₂) := do
n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
let n₃ := n₁ + n₂,
(c, e₃) ← c.of_rat n₃,
(_, p) ← prove_add_rat c e₁ e₂ e₃ n₁ n₂ n₃,
return (e₃, p)
| `(%%e₁ * %%e₂) := do
n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
prod.snd <$> prove_mul_rat c e₁ e₂ n₁ n₂
| `(- %%e) := do
c ← infer_type e >>= mk_instance_cache,
prod.snd <$> prove_neg c e
| `(@has_sub.sub %%α %%inst %%a %%b) := do
c ← mk_instance_cache α,
if α = `(nat) then prove_sub_nat c a b
else if inst = `(int.has_sub) then prove_sub_int c a b
else prod.snd <$> prove_sub c a b
| `(has_inv.inv %%e) := do
n ← e.to_rat,
c ← infer_type e >>= mk_instance_cache,
prod.snd <$> prove_inv c e n
| `(%%e₁ / %%e₂) := do
n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
prod.snd <$> prove_div c e₁ e₂ n₁ n₂
| _ := failed
lemma pow_bit0 [monoid α] (a c' c : α) (b : ℕ)
(h : a ^ b = c') (h₂ : c' * c' = c) : a ^ bit0 b = c :=
h₂ ▸ by simp [pow_bit0, h]
lemma pow_bit1 [monoid α] (a c₁ c₂ c : α) (b : ℕ)
(h : a ^ b = c₁) (h₂ : c₁ * c₁ = c₂) (h₃ : c₂ * a = c) : a ^ bit1 b = c :=
by rw [← h₃, ← h₂]; simp [pow_bit1, h]
section
open match_numeral_result
/-- Given `a` a rational numeral and `b : nat`, returns `(c, ⊢ a ^ b = c)`. -/
meta def prove_pow (a : expr) (na : ℚ) : instance_cache → expr → tactic (instance_cache × expr × expr)
| ic b :=
match match_numeral b with
| zero := do
(ic, p) ← ic.mk_app ``pow_zero [a],
(ic, o) ← ic.mk_app ``has_one.one [],
return (ic, o, p)
| one := do
(ic, p) ← ic.mk_app ``pow_one [a],
return (ic, a, p)
| bit0 b := do
(ic, c', p) ← prove_pow ic b,
nc' ← expr.to_rat c',
(ic, c, p₂) ← prove_mul_rat ic c' c' nc' nc',
(ic, p) ← ic.mk_app ``pow_bit0 [a, c', c, b, p, p₂],
return (ic, c, p)
| bit1 b := do
(ic, c₁, p) ← prove_pow ic b,
nc₁ ← expr.to_rat c₁,
(ic, c₂, p₂) ← prove_mul_rat ic c₁ c₁ nc₁ nc₁,
(ic, c, p₃) ← prove_mul_rat ic c₂ a (nc₁ * nc₁) na,
(ic, p) ← ic.mk_app ``pow_bit1 [a, c₁, c₂, c, b, p, p₂, p₃],
return (ic, c, p)
| _ := failed
end
end
lemma from_nat_pow (a b c : ℕ) (h : @has_pow.pow _ _ monoid.has_pow a b = c) : a ^ b = c :=
(nat.pow_eq_pow _ _).symm.trans h
/-- Evaluates expressions of the form `a ^ b`, `monoid.pow a b` or `nat.pow a b`. -/
meta def eval_pow : expr → tactic (expr × expr)
| `(@has_pow.pow %%α _ %%m %%e₁ %%e₂) := do
n₁ ← e₁.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
match m with
| `(@monoid.has_pow %%_ %%_) := prod.snd <$> prove_pow e₁ n₁ c e₂
| `(nat.has_pow) := do
(_, c, p) ← prove_pow e₁ n₁ c e₂,
return (c, `(from_nat_pow).mk_app [e₁, e₂, c, p])
| _ := failed
end
| `(monoid.pow %%e₁ %%e₂) := do
n₁ ← e₁.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
prod.snd <$> prove_pow e₁ n₁ c e₂
| `(nat.pow %%e₁ %%e₂) := do
n₁ ← e₁.to_rat,
c ← mk_instance_cache `(ℕ),
(_, c, p) ← prove_pow e₁ n₁ c e₂,
return (c, `(from_nat_pow).mk_app [e₁, e₂, c, p])
| _ := failed
theorem nonneg_pos {α} [ordered_cancel_add_comm_monoid α] (a : α) : 0 < a → 0 ≤ a := le_of_lt
theorem lt_one_bit0 {α} [linear_ordered_semiring α] (a : α) (h : 1 ≤ a) : 1 < bit0 a :=
lt_of_lt_of_le one_lt_two (bit0_le_bit0.2 h)
theorem lt_one_bit1 {α} [linear_ordered_semiring α] (a : α) (h : 0 < a) : 1 < bit1 a :=
one_lt_bit1.2 h
theorem lt_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a < b → bit0 a < bit0 b := bit0_lt_bit0.2
theorem lt_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a < bit1 b :=
lt_of_le_of_lt (bit0_le_bit0.2 h) (lt_add_one _)
theorem lt_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) : bit1 a < bit0 b :=
lt_of_lt_of_le (by simp [bit0, bit1, zero_lt_one, add_assoc]) (bit0_le_bit0.2 h)
theorem lt_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) : a < b → bit1 a < bit1 b := bit1_lt_bit1.2
theorem le_one_bit0 {α} [linear_ordered_semiring α] (a : α) (h : 1 ≤ a) : 1 ≤ bit0 a :=
le_of_lt (lt_one_bit0 _ h)
-- deliberately strong hypothesis because bit1 0 is not a numeral
theorem le_one_bit1 {α} [linear_ordered_semiring α] (a : α) (h : 0 < a) : 1 ≤ bit1 a :=
le_of_lt (lt_one_bit1 _ h)
theorem le_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a ≤ b → bit0 a ≤ bit0 b := bit0_le_bit0.2
theorem le_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a ≤ bit1 b :=
le_of_lt (lt_bit0_bit1 _ _ h)
theorem le_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) : bit1 a ≤ bit0 b :=
le_of_lt (lt_bit1_bit0 _ _ h)
theorem le_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) : a ≤ b → bit1 a ≤ bit1 b := bit1_le_bit1.2
theorem sle_one_bit0 {α} [linear_ordered_semiring α] (a : α) : 1 ≤ a → 1 + 1 ≤ bit0 a := bit0_le_bit0.2
theorem sle_one_bit1 {α} [linear_ordered_semiring α] (a : α) : 1 ≤ a → 1 + 1 ≤ bit1 a := le_bit0_bit1 _ _
theorem sle_bit0_bit0 {α} [linear_ordered_semiring α] (a b : α) : a + 1 ≤ b → bit0 a + 1 ≤ bit0 b := le_bit1_bit0 _ _
theorem sle_bit0_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a ≤ b) : bit0 a + 1 ≤ bit1 b := bit1_le_bit1.2 h
theorem sle_bit1_bit0 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) : bit1 a + 1 ≤ bit0 b :=
(bit1_succ a _ rfl).symm ▸ bit0_le_bit0.2 h
theorem sle_bit1_bit1 {α} [linear_ordered_semiring α] (a b : α) (h : a + 1 ≤ b) : bit1 a + 1 ≤ bit1 b :=
(bit1_succ a _ rfl).symm ▸ le_bit0_bit1 _ _ h
/-- Given `a` a rational numeral, returns `⊢ 0 ≤ a`. -/
meta def prove_nonneg (ic : instance_cache) : expr → tactic (instance_cache × expr)
| e@`(has_zero.zero) := ic.mk_app ``le_refl [e]
| e :=
if ic.α = `(ℕ) then
return (ic, `(nat.zero_le).mk_app [e])
else do
(ic, p) ← prove_pos ic e,
ic.mk_app ``nonneg_pos [e, p]
section
open match_numeral_result
/-- Given `a` a rational numeral, returns `⊢ 1 ≤ a`. -/
meta def prove_one_le_nat (ic : instance_cache) : expr → tactic (instance_cache × expr)
| a :=
match match_numeral a with
| one := ic.mk_app ``le_refl [a]
| bit0 a := do (ic, p) ← prove_one_le_nat a, ic.mk_app ``le_one_bit0 [a, p]
| bit1 a := do (ic, p) ← prove_pos_nat ic a, ic.mk_app ``le_one_bit1 [a, p]
| _ := failed
end
meta mutual def prove_le_nat, prove_sle_nat (ic : instance_cache)
with prove_le_nat : expr → expr → tactic (instance_cache × expr)
| a b :=
if a = b then ic.mk_app ``le_refl [a] else
match match_numeral a, match_numeral b with
| zero, _ := prove_nonneg ic b
| one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``le_one_bit0 [b, p]
| one, bit1 b := do (ic, p) ← prove_pos_nat ic b, ic.mk_app ``le_one_bit1 [b, p]
| bit0 a, bit0 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit0_bit0 [a, b, p]
| bit0 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit0_bit1 [a, b, p]
| bit1 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``le_bit1_bit0 [a, b, p]
| bit1 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``le_bit1_bit1 [a, b, p]
| _, _ := failed
end
with prove_sle_nat : expr → expr → tactic (instance_cache × expr)
| a b :=
match match_numeral a, match_numeral b with
| zero, _ := prove_nonneg ic b
| one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``sle_one_bit0 [b, p]
| one, bit1 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``sle_one_bit1 [b, p]
| bit0 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit0_bit0 [a, b, p]
| bit0 a, bit1 b := do (ic, p) ← prove_le_nat a b, ic.mk_app ``sle_bit0_bit1 [a, b, p]
| bit1 a, bit0 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit1_bit0 [a, b, p]
| bit1 a, bit1 b := do (ic, p) ← prove_sle_nat a b, ic.mk_app ``sle_bit1_bit1 [a, b, p]
| _, _ := failed
end
/-- Given `a`,`b` natural numerals, proves `⊢ a ≤ b`. -/
add_decl_doc prove_le_nat
/-- Given `a`,`b` natural numerals, proves `⊢ a + 1 ≤ b`. -/
add_decl_doc prove_sle_nat
/-- Given `a`,`b` natural numerals, proves `⊢ a < b`. -/
meta def prove_lt_nat (ic : instance_cache) : expr → expr → tactic (instance_cache × expr)
| a b :=
match match_numeral a, match_numeral b with
| zero, _ := prove_pos ic b
| one, bit0 b := do (ic, p) ← prove_one_le_nat ic b, ic.mk_app ``lt_one_bit0 [b, p]
| one, bit1 b := do (ic, p) ← prove_pos_nat ic b, ic.mk_app ``lt_one_bit1 [b, p]
| bit0 a, bit0 b := do (ic, p) ← prove_lt_nat a b, ic.mk_app ``lt_bit0_bit0 [a, b, p]
| bit0 a, bit1 b := do (ic, p) ← prove_le_nat ic a b, ic.mk_app ``lt_bit0_bit1 [a, b, p]
| bit1 a, bit0 b := do (ic, p) ← prove_sle_nat ic a b, ic.mk_app ``lt_bit1_bit0 [a, b, p]
| bit1 a, bit1 b := do (ic, p) ← prove_lt_nat a b, ic.mk_app ``lt_bit1_bit1 [a, b, p]
| _, _ := failed
end
end
theorem clear_denom_lt {α} [linear_ordered_semiring α] (a a' b b' d : α)
(h₀ : 0 < d) (ha : a * d = a') (hb : b * d = b') (h : a' < b') : a < b :=
lt_of_mul_lt_mul_right (by rwa [ha, hb]) (le_of_lt h₀)
/-- Given `a`,`b` nonnegative rational numerals, proves `⊢ a < b`. -/
meta def prove_lt_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) : tactic (instance_cache × expr) :=
if na.denom = 1 ∧ nb.denom = 1 then
prove_lt_nat ic a b
else do
let nd := na.denom.lcm nb.denom,
(ic, d) ← ic.of_nat nd,
(ic, p₀) ← prove_pos ic d,
(ic, a', pa) ← prove_clear_denom ic a d na nd,
(ic, b', pb) ← prove_clear_denom ic b d nb nd,
(ic, p) ← prove_lt_nat ic a' b',
ic.mk_app ``clear_denom_lt [a, a', b, b', d, p₀, pa, pb, p]
lemma lt_neg_pos {α} [ordered_add_comm_group α] (a b : α) (ha : 0 < a) (hb : 0 < b) : -a < b :=
lt_trans (neg_neg_of_pos ha) hb
/-- Given `a`,`b` rational numerals, proves `⊢ a < b`. -/
meta def prove_lt_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) : tactic (instance_cache × expr) :=
match match_sign a, match_sign b with
| sum.inl a, sum.inl b := do
(ic, p) ← prove_lt_nonneg_rat ic a b (-na) (-nb),
ic.mk_app ``neg_lt_neg [a, b, p]
| sum.inl a, sum.inr ff := do
(ic, p) ← prove_pos ic a,
ic.mk_app ``neg_neg_of_pos [a, p]
| sum.inl a, sum.inr tt := do
(ic, pa) ← prove_pos ic a,
(ic, pb) ← prove_pos ic b,
ic.mk_app ``lt_neg_pos [a, b, pa, pb]
| sum.inr ff, _ := prove_pos ic b
| sum.inr tt, _ := prove_lt_nonneg_rat ic a b na nb
end
theorem clear_denom_le {α} [linear_ordered_semiring α] (a a' b b' d : α)
(h₀ : 0 < d) (ha : a * d = a') (hb : b * d = b') (h : a' ≤ b') : a ≤ b :=
le_of_mul_le_mul_right (by rwa [ha, hb]) h₀
/-- Given `a`,`b` nonnegative rational numerals, proves `⊢ a ≤ b`. -/
meta def prove_le_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) : tactic (instance_cache × expr) :=
if na.denom = 1 ∧ nb.denom = 1 then
prove_le_nat ic a b
else do
let nd := na.denom.lcm nb.denom,
(ic, d) ← ic.of_nat nd,
(ic, p₀) ← prove_pos ic d,
(ic, a', pa) ← prove_clear_denom ic a d na nd,
(ic, b', pb) ← prove_clear_denom ic b d nb nd,
(ic, p) ← prove_le_nat ic a' b',
ic.mk_app ``clear_denom_le [a, a', b, b', d, p₀, pa, pb, p]
lemma le_neg_pos {α} [ordered_add_comm_group α] (a b : α) (ha : 0 ≤ a) (hb : 0 ≤ b) : -a ≤ b :=
le_trans (neg_nonpos_of_nonneg ha) hb
/-- Given `a`,`b` rational numerals, proves `⊢ a ≤ b`. -/
meta def prove_le_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) : tactic (instance_cache × expr) :=
match match_sign a, match_sign b with
| sum.inl a, sum.inl b := do
(ic, p) ← prove_le_nonneg_rat ic a b (-na) (-nb),
ic.mk_app ``neg_le_neg [a, b, p]
| sum.inl a, sum.inr ff := do
(ic, p) ← prove_nonneg ic a,
ic.mk_app ``neg_nonpos_of_nonneg [a, p]
| sum.inl a, sum.inr tt := do
(ic, pa) ← prove_nonneg ic a,
(ic, pb) ← prove_nonneg ic b,
ic.mk_app ``le_neg_pos [a, b, pa, pb]
| sum.inr ff, _ := prove_nonneg ic b
| sum.inr tt, _ := prove_le_nonneg_rat ic a b na nb
end
/-- Given `a`,`b` rational numerals, proves `⊢ a ≠ b`. This version
tries to prove `⊢ a < b` or `⊢ b < a`, and so is not appropriate for types without an order relation. -/
meta def prove_ne_rat (ic : instance_cache) (a b : expr) (na nb : ℚ) : tactic (instance_cache × expr) :=
if na < nb then do
(ic, p) ← prove_lt_rat ic a b na nb,
ic.mk_app ``ne_of_lt [a, b, p]
else do
(ic, p) ← prove_lt_rat ic b a nb na,
ic.mk_app ``ne_of_gt [a, b, p]
theorem nat_cast_zero {α} [semiring α] : ↑(0 : ℕ) = (0 : α) := nat.cast_zero
theorem nat_cast_one {α} [semiring α] : ↑(1 : ℕ) = (1 : α) := nat.cast_one
theorem nat_cast_bit0 {α} [semiring α] (a : ℕ) (a' : α) (h : ↑a = a') : ↑(bit0 a) = bit0 a' :=
h ▸ nat.cast_bit0 _
theorem nat_cast_bit1 {α} [semiring α] (a : ℕ) (a' : α) (h : ↑a = a') : ↑(bit1 a) = bit1 a' :=
h ▸ nat.cast_bit1 _
theorem int_cast_zero {α} [ring α] : ↑(0 : ℤ) = (0 : α) := int.cast_zero
theorem int_cast_one {α} [ring α] : ↑(1 : ℤ) = (1 : α) := int.cast_one
theorem int_cast_bit0 {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑(bit0 a) = bit0 a' :=
h ▸ int.cast_bit0 _
theorem int_cast_bit1 {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑(bit1 a) = bit1 a' :=
h ▸ int.cast_bit1 _
theorem rat_cast_bit0 {α} [division_ring α] [char_zero α] (a : ℚ) (a' : α) (h : ↑a = a') : ↑(bit0 a) = bit0 a' :=
h ▸ rat.cast_bit0 _
theorem rat_cast_bit1 {α} [division_ring α] [char_zero α] (a : ℚ) (a' : α) (h : ↑a = a') : ↑(bit1 a) = bit1 a' :=
h ▸ rat.cast_bit1 _
/-- Given `a' : α` a natural numeral, returns `(a : ℕ, ⊢ ↑a = a')`.
(Note that the returned value is on the left of the equality.) -/
meta def prove_nat_uncast (ic nc : instance_cache) : ∀ (a' : expr),
tactic (instance_cache × instance_cache × expr × expr)
| a' :=
match match_numeral a' with
| match_numeral_result.zero := do
(nc, e) ← nc.mk_app ``has_zero.zero [],
(ic, p) ← ic.mk_app ``nat_cast_zero [],
return (ic, nc, e, p)
| match_numeral_result.one := do
(nc, e) ← nc.mk_app ``has_one.one [],
(ic, p) ← ic.mk_app ``nat_cast_one [],
return (ic, nc, e, p)
| match_numeral_result.bit0 a' := do
(ic, nc, a, p) ← prove_nat_uncast a',
(nc, a0) ← nc.mk_bit0 a,
(ic, p) ← ic.mk_app ``nat_cast_bit0 [a, a', p],
return (ic, nc, a0, p)
| match_numeral_result.bit1 a' := do
(ic, nc, a, p) ← prove_nat_uncast a',
(nc, a1) ← nc.mk_bit1 a,
(ic, p) ← ic.mk_app ``nat_cast_bit1 [a, a', p],
return (ic, nc, a1, p)
| _ := failed
end
/-- Given `a' : α` a natural numeral, returns `(a : ℤ, ⊢ ↑a = a')`.
(Note that the returned value is on the left of the equality.) -/
meta def prove_int_uncast_nat (ic zc : instance_cache) : ∀ (a' : expr),
tactic (instance_cache × instance_cache × expr × expr)
| a' :=
match match_numeral a' with
| match_numeral_result.zero := do
(zc, e) ← zc.mk_app ``has_zero.zero [],
(ic, p) ← ic.mk_app ``int_cast_zero [],
return (ic, zc, e, p)
| match_numeral_result.one := do
(zc, e) ← zc.mk_app ``has_one.one [],
(ic, p) ← ic.mk_app ``int_cast_one [],
return (ic, zc, e, p)
| match_numeral_result.bit0 a' := do
(ic, zc, a, p) ← prove_int_uncast_nat a',
(zc, a0) ← zc.mk_bit0 a,
(ic, p) ← ic.mk_app ``int_cast_bit0 [a, a', p],
return (ic, zc, a0, p)
| match_numeral_result.bit1 a' := do
(ic, zc, a, p) ← prove_int_uncast_nat a',
(zc, a1) ← zc.mk_bit1 a,
(ic, p) ← ic.mk_app ``int_cast_bit1 [a, a', p],
return (ic, zc, a1, p)
| _ := failed
end
/-- Given `a' : α` a natural numeral, returns `(a : ℚ, ⊢ ↑a = a')`.
(Note that the returned value is on the left of the equality.) -/
meta def prove_rat_uncast_nat (ic qc : instance_cache) (cz_inst : expr) : ∀ (a' : expr),
tactic (instance_cache × instance_cache × expr × expr)
| a' :=
match match_numeral a' with
| match_numeral_result.zero := do
(qc, e) ← qc.mk_app ``has_zero.zero [],
(ic, p) ← ic.mk_app ``rat.cast_zero [cz_inst],
return (ic, qc, e, p)
| match_numeral_result.one := do
(qc, e) ← qc.mk_app ``has_one.one [],
(ic, p) ← ic.mk_app ``rat.cast_one [],
return (ic, qc, e, p)
| match_numeral_result.bit0 a' := do
(ic, qc, a, p) ← prove_rat_uncast_nat a',
(qc, a0) ← qc.mk_bit0 a,
(ic, p) ← ic.mk_app ``rat_cast_bit0 [cz_inst, a, a', p],
return (ic, qc, a0, p)
| match_numeral_result.bit1 a' := do
(ic, qc, a, p) ← prove_rat_uncast_nat a',
(qc, a1) ← qc.mk_bit1 a,
(ic, p) ← ic.mk_app ``rat_cast_bit1 [cz_inst, a, a', p],
return (ic, qc, a1, p)
| _ := failed
end
theorem rat_cast_div {α} [division_ring α] [char_zero α] (a b : ℚ) (a' b' : α)
(ha : ↑a = a') (hb : ↑b = b') : ↑(a / b) = a' / b' :=
ha ▸ hb ▸ rat.cast_div _ _
/-- Given `a' : α` a nonnegative rational numeral, returns `(a : ℚ, ⊢ ↑a = a')`.
(Note that the returned value is on the left of the equality.) -/
meta def prove_rat_uncast_nonneg (ic qc : instance_cache) (cz_inst a' : expr) (na' : ℚ) :
tactic (instance_cache × instance_cache × expr × expr) :=
if na'.denom = 1 then
prove_rat_uncast_nat ic qc cz_inst a'
else do
[_, _, a', b'] ← return a'.get_app_args,
(ic, qc, a, pa) ← prove_rat_uncast_nat ic qc cz_inst a',
(ic, qc, b, pb) ← prove_rat_uncast_nat ic qc cz_inst b',
(qc, e) ← qc.mk_app ``has_div.div [a, b],
(ic, p) ← ic.mk_app ``rat_cast_div [cz_inst, a, b, a', b', pa, pb],
return (ic, qc, e, p)
theorem int_cast_neg {α} [ring α] (a : ℤ) (a' : α) (h : ↑a = a') : ↑-a = -a' :=
h ▸ int.cast_neg _
theorem rat_cast_neg {α} [division_ring α] (a : ℚ) (a' : α) (h : ↑a = a') : ↑-a = -a' :=
h ▸ rat.cast_neg _
/-- Given `a' : α` an integer numeral, returns `(a : ℤ, ⊢ ↑a = a')`.
(Note that the returned value is on the left of the equality.) -/
meta def prove_int_uncast (ic zc : instance_cache) (a' : expr) :
tactic (instance_cache × instance_cache × expr × expr) :=
match match_neg a' with
| some a' := do
(ic, zc, a, p) ← prove_int_uncast_nat ic zc a',
(zc, e) ← zc.mk_app ``has_neg.neg [a],
(ic, p) ← ic.mk_app ``int_cast_neg [a, a', p],
return (ic, zc, e, p)
| none := prove_int_uncast_nat ic zc a'
end
/-- Given `a' : α` a rational numeral, returns `(a : ℚ, ⊢ ↑a = a')`.
(Note that the returned value is on the left of the equality.) -/
meta def prove_rat_uncast (ic qc : instance_cache) (cz_inst a' : expr) (na' : ℚ) :
tactic (instance_cache × instance_cache × expr × expr) :=
match match_neg a' with
| some a' := do
(ic, qc, a, p) ← prove_rat_uncast_nonneg ic qc cz_inst a' (-na'),
(qc, e) ← qc.mk_app ``has_neg.neg [a],
(ic, p) ← ic.mk_app ``rat_cast_neg [a, a', p],
return (ic, qc, e, p)
| none := prove_rat_uncast_nonneg ic qc cz_inst a' na'
end
theorem nat_cast_ne {α} [semiring α] [char_zero α] (a b : ℕ) (a' b' : α)
(ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=
ha ▸ hb ▸ mt nat.cast_inj.1 h
theorem int_cast_ne {α} [ring α] [char_zero α] (a b : ℤ) (a' b' : α)
(ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=
ha ▸ hb ▸ mt int.cast_inj.1 h
theorem rat_cast_ne {α} [division_ring α] [char_zero α] (a b : ℚ) (a' b' : α)
(ha : ↑a = a') (hb : ↑b = b') (h : a ≠ b) : a' ≠ b' :=
ha ▸ hb ▸ mt rat.cast_inj.1 h
/-- Given `a`,`b` rational numerals, proves `⊢ a ≠ b`. Currently it tries two methods:
* Prove `⊢ a < b` or `⊢ b < a`, if the base type has an order
* Embed `↑(a':ℚ) = a` and `↑(b':ℚ) = b`, and then prove `a' ≠ b'`.
This requires that the base type be `char_zero`, and also that it be a `division_ring`
so that the coercion from `ℚ` is well defined.
We may also add coercions to `ℤ` and `ℕ` as well in order to support `char_zero`
rings and semirings. -/
meta def prove_ne : instance_cache → expr → expr → ℚ → ℚ → tactic (instance_cache × expr)
| ic a b na nb := prove_ne_rat ic a b na nb <|> do
cz_inst ← mk_mapp ``char_zero [ic.α, none, none] >>= mk_instance,
if na.denom = 1 ∧ nb.denom = 1 then
if na ≥ 0 ∧ nb ≥ 0 then do
guard (ic.α ≠ `(ℕ)),
nc ← mk_instance_cache `(ℕ),
(ic, nc, a', pa) ← prove_nat_uncast ic nc a,
(ic, nc, b', pb) ← prove_nat_uncast ic nc b,
(nc, p) ← prove_ne_rat nc a' b' na nb,
ic.mk_app ``nat_cast_ne [cz_inst, a', b', a, b, pa, pb, p]
else do
guard (ic.α ≠ `(ℤ)),
zc ← mk_instance_cache `(ℤ),
(ic, zc, a', pa) ← prove_int_uncast ic zc a,
(ic, zc, b', pb) ← prove_int_uncast ic zc b,
(zc, p) ← prove_ne_rat zc a' b' na nb,
ic.mk_app ``int_cast_ne [cz_inst, a', b', a, b, pa, pb, p]
else do
guard (ic.α ≠ `(ℚ)),
qc ← mk_instance_cache `(ℚ),
(ic, qc, a', pa) ← prove_rat_uncast ic qc cz_inst a na,
(ic, qc, b', pb) ← prove_rat_uncast ic qc cz_inst b nb,
(qc, p) ← prove_ne_rat qc a' b' na nb,
ic.mk_app ``rat_cast_ne [cz_inst, a', b', a, b, pa, pb, p]
/-- Given `∣- p`, returns `(true, ⊢ p = true)`. -/
meta def true_intro (p : expr) : tactic (expr × expr) :=
prod.mk `(true) <$> mk_app ``eq_true_intro [p]
/-- Given `∣- ¬ p`, returns `(false, ⊢ p = false)`. -/
meta def false_intro (p : expr) : tactic (expr × expr) :=
prod.mk `(false) <$> mk_app ``eq_false_intro [p]
theorem not_refl_false_intro {α} (a : α) : (a ≠ a) = false :=
eq_false_intro $ not_not_intro rfl
/-- Evaluates the inequality operations `=`,`<`,`>`,`≤`,`≥`,`≠` on numerals. -/
meta def eval_ineq : expr → tactic (expr × expr)
| `(%%e₁ < %%e₂) := do
n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
if n₁ < n₂ then
do (_, p) ← prove_lt_rat c e₁ e₂ n₁ n₂, true_intro p
else if n₁ = n₂ then do
(_, p) ← c.mk_app ``lt_irrefl [e₁],
false_intro p
else do
(c, p') ← prove_lt_rat c e₂ e₁ n₂ n₁,
(_, p) ← c.mk_app ``not_lt_of_gt [e₁, e₂, p'],
false_intro p
| `(%%e₁ ≤ %%e₂) := do
n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
if n₁ ≤ n₂ then do
(_, p) ←
if n₁ = n₂ then c.mk_app ``le_refl [e₁]
else prove_le_rat c e₁ e₂ n₁ n₂,
true_intro p
else do
(c, p) ← prove_lt_rat c e₂ e₁ n₂ n₁,
(_, p) ← c.mk_app ``not_le_of_gt [e₁, e₂, p],
false_intro p
| `(%%e₁ = %%e₂) := do
n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
if n₁ = n₂ then mk_eq_refl e₁ >>= true_intro
else do (_, p) ← prove_ne c e₁ e₂ n₁ n₂, false_intro p
| `(%%e₁ > %%e₂) := mk_app ``has_lt.lt [e₂, e₁] >>= eval_ineq
| `(%%e₁ ≥ %%e₂) := mk_app ``has_le.le [e₂, e₁] >>= eval_ineq
| `(%%e₁ ≠ %%e₂) := do
n₁ ← e₁.to_rat, n₂ ← e₂.to_rat,
c ← infer_type e₁ >>= mk_instance_cache,
if n₁ = n₂ then
prod.mk `(false) <$> mk_app ``not_refl_false_intro [e₁]
else do (_, p) ← prove_ne c e₁ e₂ n₁ n₂, true_intro p
| _ := failed
theorem nat_succ_eq (a b c : ℕ) (h₁ : a = b) (h₂ : b + 1 = c) : nat.succ a = c := by rwa h₁
/-- Evaluates the expression `nat.succ ... (nat.succ n)` where `n` is a natural numeral.
(We could also just handle `nat.succ n` here and rely on `simp` to work bottom up, but we figure
that towers of successors coming from e.g. `induction` are a common case.) -/
meta def prove_nat_succ (ic : instance_cache) : expr → tactic (instance_cache × ℕ × expr × expr)
| `(nat.succ %%a) := do
(ic, n, b, p₁) ← prove_nat_succ a,
let n' := n + 1,
(ic, c) ← ic.of_nat n',
(ic, p₂) ← prove_add_nat ic b `(1) c,
return (ic, n', c, `(nat_succ_eq).mk_app [a, b, c, p₁, p₂])
| e := do
n ← e.to_nat,
p ← mk_eq_refl e,
return (ic, n, e, p)
lemma nat_div (a b q r m : ℕ) (hm : q * b = m) (h : r + m = a) (h₂ : r < b) : a / b = q :=
by rw [← h, ← hm, nat.add_mul_div_right _ _ (lt_of_le_of_lt (nat.zero_le _) h₂),
nat.div_eq_of_lt h₂, zero_add]
lemma int_div (a b q r m : ℤ) (hm : q * b = m) (h : r + m = a) (h₁ : 0 ≤ r) (h₂ : r < b) : a / b = q :=
by rw [← h, ← hm, int.add_mul_div_right _ _ (ne_of_gt (lt_of_le_of_lt h₁ h₂)),
int.div_eq_zero_of_lt h₁ h₂, zero_add]
lemma nat_mod (a b q r m : ℕ) (hm : q * b = m) (h : r + m = a) (h₂ : r < b) : a % b = r :=
by rw [← h, ← hm, nat.add_mul_mod_self_right, nat.mod_eq_of_lt h₂]
lemma int_mod (a b q r m : ℤ) (hm : q * b = m) (h : r + m = a) (h₁ : 0 ≤ r) (h₂ : r < b) : a % b = r :=
by rw [← h, ← hm, int.add_mul_mod_self, int.mod_eq_of_lt h₁ h₂]
lemma int_div_neg (a b c' c : ℤ) (h : a / b = c') (h₂ : -c' = c) : a / -b = c :=
h₂ ▸ h ▸ int.div_neg _ _
lemma int_mod_neg (a b c : ℤ) (h : a % b = c) : a % -b = c :=
(int.mod_neg _ _).trans h
/-- Given `a`,`b` numerals in `nat` or `int`,
* `prove_div_mod ic a b ff` returns `(c, ⊢ a / b = c)`
* `prove_div_mod ic a b tt` returns `(c, ⊢ a % b = c)`
-/
meta def prove_div_mod (ic : instance_cache) : expr → expr → bool → tactic (instance_cache × expr × expr)
| a b mod :=
match match_neg b with
| some b := do
(ic, c', p) ← prove_div_mod a b mod,
if mod then
return (ic, c', `(int_mod_neg).mk_app [a, b, c', p])
else do
(ic, c, p₂) ← prove_neg ic c',
return (ic, c, `(int_div_neg).mk_app [a, b, c', c, p, p₂])
| none := do
nb ← b.to_nat,
na ← a.to_int,
let nq := na / nb,
let nr := na % nb,
let nm := nq * nr,
(ic, q) ← ic.of_int nq,
(ic, r) ← ic.of_int nr,
(ic, m, pm) ← prove_mul_rat ic q b (rat.of_int nq) (rat.of_int nb),
(ic, p) ← prove_add_rat ic r m a (rat.of_int nr) (rat.of_int nm) (rat.of_int na),
(ic, p') ← prove_lt_nat ic r b,
if ic.α = `(nat) then
if mod then return (ic, r, `(nat_mod).mk_app [a, b, q, r, m, pm, p, p'])
else return (ic, q, `(nat_div).mk_app [a, b, q, r, m, pm, p, p'])
else if ic.α = `(int) then do
(ic, p₀) ← prove_nonneg ic r,
if mod then return (ic, r, `(int_mod).mk_app [a, b, q, r, m, pm, p, p₀, p'])
else return (ic, q, `(int_div).mk_app [a, b, q, r, m, pm, p, p₀, p'])
else failed
end
theorem dvd_eq_nat (a b c : ℕ) (p) (h₁ : b % a = c) (h₂ : (c = 0) = p) : (a ∣ b) = p :=
(propext $ by rw [← h₁, nat.dvd_iff_mod_eq_zero]).trans h₂
theorem dvd_eq_int (a b c : ℤ) (p) (h₁ : b % a = c) (h₂ : (c = 0) = p) : (a ∣ b) = p :=
(propext $ by rw [← h₁, int.dvd_iff_mod_eq_zero]).trans h₂
/-- Evaluates some extra numeric operations on `nat` and `int`, specifically
`nat.succ`, `/` and `%`, and `∣` (divisibility). -/
meta def eval_nat_int_ext : expr → tactic (expr × expr)
| e@`(nat.succ _) := do
ic ← mk_instance_cache `(ℕ),
(_, _, ep) ← prove_nat_succ ic e,
return ep
| `(%%a / %%b) := do
c ← infer_type a >>= mk_instance_cache,
prod.snd <$> prove_div_mod c a b ff
| `(%%a % %%b) := do
c ← infer_type a >>= mk_instance_cache,
prod.snd <$> prove_div_mod c a b tt
| `(%%a ∣ %%b) := do
α ← infer_type a,
ic ← mk_instance_cache α,
th ← if α = `(nat) then return (`(dvd_eq_nat):expr) else
if α = `(int) then return `(dvd_eq_int) else failed,
(ic, c, p₁) ← prove_div_mod ic b a tt,
(ic, z) ← ic.mk_app ``has_zero.zero [],
(e', p₂) ← mk_app ``eq [c, z] >>= eval_ineq,
return (e', th.mk_app [a, b, c, e', p₁, p₂])
| _ := failed
lemma not_prime_helper (a b n : ℕ)
(h : a * b = n) (h₁ : 1 < a) (h₂ : 1 < b) : ¬ nat.prime n :=
by rw ← h; exact nat.not_prime_mul h₁ h₂
lemma is_prime_helper (n : ℕ)
(h₁ : 1 < n) (h₂ : nat.min_fac n = n) : nat.prime n :=
nat.prime_def_min_fac.2 ⟨h₁, h₂⟩
lemma min_fac_bit0 (n : ℕ) : nat.min_fac (bit0 n) = 2 :=
by simp [nat.min_fac_eq, show 2 ∣ bit0 n, by simp [bit0_eq_two_mul n]]
/-- A predicate representing partial progress in a proof of `min_fac`. -/
def min_fac_helper (n k : ℕ) : Prop :=
0 < k ∧ bit1 k ≤ nat.min_fac (bit1 n)
theorem min_fac_helper.n_pos {n k : ℕ} (h : min_fac_helper n k) : 0 < n :=
nat.pos_iff_ne_zero.2 $ λ e,
by rw e at h; exact not_le_of_lt (nat.bit1_lt h.1) h.2
lemma min_fac_ne_bit0 {n k : ℕ} : nat.min_fac (bit1 n) ≠ bit0 k :=
by rw bit0_eq_two_mul; exact λ e, absurd
((nat.dvd_add_iff_right (by simp [bit0_eq_two_mul n])).2
(dvd_trans ⟨_, e⟩ (nat.min_fac_dvd _)))
dec_trivial
lemma min_fac_helper_0 (n : ℕ) (h : 0 < n) : min_fac_helper n 1 :=
begin
refine ⟨zero_lt_one, lt_of_le_of_ne _ min_fac_ne_bit0.symm⟩,
refine @lt_of_le_of_ne ℕ _ _ _ (nat.min_fac_pos _) _,
intro e,
have := nat.min_fac_prime _,
{ rw ← e at this, exact nat.not_prime_one this },
{ exact ne_of_gt (nat.bit1_lt h) }
end
lemma min_fac_helper_1 {n k k' : ℕ} (e : k + 1 = k')
(np : nat.min_fac (bit1 n) ≠ bit1 k)
(h : min_fac_helper n k) : min_fac_helper n k' :=
begin
rw ← e,
refine ⟨nat.succ_pos _,
(lt_of_le_of_ne (lt_of_le_of_ne _ _ : k+1+k < _)
min_fac_ne_bit0.symm : bit0 (k+1) < _)⟩,
{ rw add_right_comm, exact h.2 },
{ rw add_right_comm, exact np.symm }
end
lemma min_fac_helper_2 (n k k' : ℕ) (e : k + 1 = k')
(np : ¬ nat.prime (bit1 k)) (h : min_fac_helper n k) : min_fac_helper n k' :=
begin
refine min_fac_helper_1 e _ h,
intro e₁, rw ← e₁ at np,
exact np (nat.min_fac_prime $ ne_of_gt $ nat.bit1_lt h.n_pos)
end
lemma min_fac_helper_3 (n k k' c : ℕ) (e : k + 1 = k')
(nc : bit1 n % bit1 k = c) (c0 : 0 < c)
(h : min_fac_helper n k) : min_fac_helper n k' :=
begin
refine min_fac_helper_1 e _ h,
refine mt _ (ne_of_gt c0), intro e₁,
rw [← nc, ← nat.dvd_iff_mod_eq_zero, ← e₁],
apply nat.min_fac_dvd
end
lemma min_fac_helper_4 (n k : ℕ) (hd : bit1 n % bit1 k = 0)
(h : min_fac_helper n k) : nat.min_fac (bit1 n) = bit1 k :=
by rw ← nat.dvd_iff_mod_eq_zero at hd; exact
le_antisymm (nat.min_fac_le_of_dvd (nat.bit1_lt h.1) hd) h.2
lemma min_fac_helper_5 (n k k' : ℕ) (e : bit1 k * bit1 k = k')
(hd : bit1 n < k') (h : min_fac_helper n k) : nat.min_fac (bit1 n) = bit1 n :=
begin
refine (nat.prime_def_min_fac.1 (nat.prime_def_le_sqrt.2
⟨nat.bit1_lt h.n_pos, _⟩)).2,
rw ← e at hd,
intros m m2 hm md,
have := le_trans h.2 (le_trans (nat.min_fac_le_of_dvd m2 md) hm),
rw nat.le_sqrt at this,
exact not_le_of_lt hd this
end
/-- Given `e` a natural numeral and `d : nat` a factor of it, return `⊢ ¬ prime e`. -/
meta def prove_non_prime (e : expr) (n d₁ : ℕ) : tactic expr :=
do let e₁ := reflect d₁,
c ← mk_instance_cache `(nat),
(c, p₁) ← prove_lt_nat c `(1) e₁,
let d₂ := n / d₁, let e₂ := reflect d₂,
(c, e', p) ← prove_mul_nat c e₁ e₂,
guard (e' =ₐ e),
(c, p₂) ← prove_lt_nat c `(1) e₂,
return $ `(not_prime_helper).mk_app [e₁, e₂, e, p, p₁, p₂]
/-- Given `a`,`a1 := bit1 a`, `n1` the value of `a1`, `b` and `p : min_fac_helper a b`,
returns `(c, ⊢ min_fac a1 = c)`. -/
meta def prove_min_fac_aux (a a1 : expr) (n1 : ℕ) :
instance_cache → expr → expr → tactic (instance_cache × expr × expr)
| ic b p := do
k ← b.to_nat,
let k1 := bit1 k,
let b1 := `(bit1:ℕ→ℕ).mk_app [b],
if n1 < k1*k1 then do
(ic, e', p₁) ← prove_mul_nat ic b1 b1,
(ic, p₂) ← prove_lt_nat ic a1 e',
return (ic, a1, `(min_fac_helper_5).mk_app [a, b, e', p₁, p₂, p])
else let d := k1.min_fac in
if to_bool (d < k1) then do
let k' := k+1, let e' := reflect k',
(ic, p₁) ← prove_succ ic b e',
p₂ ← prove_non_prime b1 k1 d,
prove_min_fac_aux ic e' $ `(min_fac_helper_2).mk_app [a, b, e', p₁, p₂, p]
else do
let nc := n1 % k1,
(ic, c, pc) ← prove_div_mod ic a1 b1 tt,
if nc = 0 then
return (ic, b1, `(min_fac_helper_4).mk_app [a, b, pc, p])
else do
(ic, p₀) ← prove_pos ic c,
let k' := k+1, let e' := reflect k',
(ic, p₁) ← prove_succ ic b e',
prove_min_fac_aux ic e' $ `(min_fac_helper_3).mk_app [a, b, e', c, p₁, pc, p₀, p]
/-- Given `a` a natural numeral, returns `(b, ⊢ min_fac a = b)`. -/
meta def prove_min_fac (ic : instance_cache) (e : expr) : tactic (instance_cache × expr × expr) :=
match match_numeral e with
| match_numeral_result.zero := return (ic, `(2:ℕ), `(nat.min_fac_zero))
| match_numeral_result.one := return (ic, `(1:ℕ), `(nat.min_fac_one))
| match_numeral_result.bit0 e := return (ic, `(2), `(min_fac_bit0).mk_app [e])
| match_numeral_result.bit1 e := do
n ← e.to_nat,
c ← mk_instance_cache `(nat),
(c, p) ← prove_pos c e,
let a1 := `(bit1:ℕ→ℕ).mk_app [e],
prove_min_fac_aux e a1 (bit1 n) c `(1) (`(min_fac_helper_0).mk_app [e, p])
| _ := failed
end
/-- Evaluates the `prime` and `min_fac` functions. -/
meta def eval_prime : expr → tactic (expr × expr)
| `(nat.prime %%e) := do
n ← e.to_nat,
match n with
| 0 := false_intro `(nat.not_prime_zero)
| 1 := false_intro `(nat.not_prime_one)
| _ := let d₁ := n.min_fac in
if d₁ < n then prove_non_prime e n d₁ >>= false_intro
else do
let e₁ := reflect d₁,
c ← mk_instance_cache `(nat),
(c, p₁) ← prove_lt_nat c `(1) e₁,
(c, e₁, p) ← prove_min_fac c e,
true_intro $ `(is_prime_helper).mk_app [e, p₁, p]
end
| `(nat.min_fac %%e) := do
ic ← mk_instance_cache `(ℕ),
prod.snd <$> prove_min_fac ic e
| _ := failed
/-- This version of `derive` does not fail when the input is already a numeral -/
meta def derive' (e : expr) : tactic (expr × expr) :=
eval_field e <|> eval_nat_int_ext e <|>
eval_pow e <|> eval_ineq e <|> eval_prime e
meta def derive : expr → tactic (expr × expr) | e :=
do e ← instantiate_mvars e,
(_, e', pr) ←
ext_simplify_core () {} simp_lemmas.mk (λ _, failed) (λ _ _ _ _ _, failed)
(λ _ _ _ _ e,
do (new_e, pr) ← derive' e,
guard (¬ new_e =ₐ e),
return ((), new_e, some pr, tt))
`eq e,
return (e', pr)
end norm_num
namespace tactic.interactive
open norm_num interactive interactive.types
/-- Basic version of `norm_num` that does not call `simp`. -/
meta def norm_num1 (loc : parse location) : tactic unit :=
do ns ← loc.get_locals,
tt ← tactic.replace_at derive ns loc.include_goal
| fail "norm_num failed to simplify",
when loc.include_goal $ try tactic.triv,
when (¬ ns.empty) $ try tactic.contradiction
/-- Normalize numerical expressions. Supports the operations
`+` `-` `*` `/` `^` and `%` over numerical types such as
`ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ` and some general algebraic types,
and can prove goals of the form `A = B`, `A ≠ B`, `A < B` and `A ≤ B`,
where `A` and `B` are numerical expressions.
It also has a relatively simple primality prover. -/
meta def norm_num (hs : parse simp_arg_list) (l : parse location) : tactic unit :=
repeat1 $ orelse' (norm_num1 l) $
simp_core {} (norm_num1 (loc.ns [none])) ff hs [] l
add_hint_tactic "norm_num"
/-- Normalizes a numerical expression and tries to close the goal with the result. -/
meta def apply_normed (x : parse texpr) : tactic unit :=
do x₁ ← to_expr x,
(x₂,_) ← derive x₁,
tactic.exact x₂
/--
Normalises numerical expressions. It supports the operations `+` `-` `*` `/` `^` and `%` over
numerical types such as `ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ`, and can prove goals of the form `A = B`, `A ≠ B`,
`A < B` and `A ≤ B`, where `A` and `B` are
numerical expressions. It also has a relatively simple primality prover.
```lean
import data.real.basic
example : (2 : ℝ) + 2 = 4 := by norm_num
example : (12345.2 : ℝ) ≠ 12345.3 := by norm_num
example : (73 : ℝ) < 789/2 := by norm_num
example : 123456789 + 987654321 = 1111111110 := by norm_num
example (R : Type*) [ring R] : (2 : R) + 2 = 4 := by norm_num
example (F : Type*) [linear_ordered_field F] : (2 : F) + 2 < 5 := by norm_num
example : nat.prime (2^13 - 1) := by norm_num
example : ¬ nat.prime (2^11 - 1) := by norm_num
example (x : ℝ) (h : x = 123 + 456) : x = 579 := by norm_num at h; assumption
```
The variant `norm_num1` does not call `simp`.
Both `norm_num` and `norm_num1` can be called inside the `conv` tactic.
The tactic `apply_normed` normalises a numerical expression and tries to close the goal with
the result. Compare:
```lean
def a : ℕ := 2^100
#print a -- 2 ^ 100
def normed_a : ℕ := by apply_normed 2^100
#print normed_a -- 1267650600228229401496703205376
```
-/
add_tactic_doc
{ name := "norm_num",
category := doc_category.tactic,
decl_names := [`tactic.interactive.norm_num1, `tactic.interactive.norm_num,
`tactic.interactive.apply_normed],
tags := ["arithmetic", "decision procedure"] }
end tactic.interactive
namespace conv.interactive
open conv interactive tactic.interactive
open norm_num (derive)
/-- Basic version of `norm_num` that does not call `simp`. -/
meta def norm_num1 : conv unit := replace_lhs derive
/-- Normalize numerical expressions. Supports the operations
`+` `-` `*` `/` `^` and `%` over numerical types such as
`ℕ`, `ℤ`, `ℚ`, `ℝ`, `ℂ` and some general algebraic types,
and can prove goals of the form `A = B`, `A ≠ B`, `A < B` and `A ≤ B`,
where `A` and `B` are numerical expressions.
It also has a relatively simple primality prover. -/
meta def norm_num (hs : parse simp_arg_list) : conv unit :=
repeat1 $ orelse' norm_num1 $
simp_core {} norm_num1 ff hs [] (loc.ns [none])
end conv.interactive
|
406d9968489cbfc87f4b031335c8acf079e42a17 | 5ae26df177f810c5006841e9c73dc56e01b978d7 | /src/topology/instances/nnreal.lean | 61821363737759913c91f6c315e7f5d5c87c1ca8 | [
"Apache-2.0"
] | permissive | ChrisHughes24/mathlib | 98322577c460bc6b1fe5c21f42ce33ad1c3e5558 | a2a867e827c2a6702beb9efc2b9282bd801d5f9a | refs/heads/master | 1,583,848,251,477 | 1,565,164,247,000 | 1,565,164,247,000 | 129,409,993 | 0 | 1 | Apache-2.0 | 1,565,164,817,000 | 1,523,628,059,000 | Lean | UTF-8 | Lean | false | false | 4,502 | lean | /-
Copyright (c) 2018 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
Nonnegative real numbers.
-/
import data.real.nnreal topology.instances.real topology.algebra.infinite_sum
noncomputable theory
open set topological_space metric
namespace nnreal
local notation ` ℝ≥0 ` := nnreal
instance : topological_space ℝ≥0 := infer_instance
instance : topological_semiring ℝ≥0 :=
{ continuous_mul :=
continuous_subtype_mk _
(continuous_mul (continuous.comp continuous_subtype_val continuous_fst)
(continuous.comp continuous_subtype_val continuous_snd)),
continuous_add :=
continuous_subtype_mk _
(continuous_add (continuous.comp continuous_subtype_val continuous_fst)
(continuous.comp continuous_subtype_val continuous_snd)) }
instance : second_countable_topology nnreal :=
topological_space.subtype.second_countable_topology _ _
instance : orderable_topology ℝ≥0 :=
⟨ le_antisymm
(le_generate_from $ assume s hs,
match s, hs with
| _, ⟨⟨a, ha⟩, or.inl rfl⟩ := ⟨{b : ℝ | a < b}, is_open_lt' a, rfl⟩
| _, ⟨⟨a, ha⟩, or.inr rfl⟩ := ⟨{b : ℝ | b < a}, is_open_gt' a, set.ext $ assume b, iff.refl _⟩
end)
begin
apply coinduced_le_iff_le_induced.1,
rw [orderable_topology.topology_eq_generate_intervals ℝ],
apply le_generate_from,
assume s hs,
rcases hs with ⟨a, rfl | rfl⟩,
{ show topological_space.generate_open _ {b : ℝ≥0 | a < b },
by_cases ha : 0 ≤ a,
{ exact topological_space.generate_open.basic _ ⟨⟨a, ha⟩, or.inl rfl⟩ },
{ have : a < 0, from lt_of_not_ge ha,
have : {b : ℝ≥0 | a < b } = set.univ,
from (set.eq_univ_iff_forall.2 $ assume b, lt_of_lt_of_le this b.2),
rw [this],
exact topological_space.generate_open.univ _ } },
{ show (topological_space.generate_from _).is_open {b : ℝ≥0 | a > b },
by_cases ha : 0 ≤ a,
{ exact topological_space.generate_open.basic _ ⟨⟨a, ha⟩, or.inr rfl⟩ },
{ have : {b : ℝ≥0 | a > b } = ∅,
from (set.eq_empty_iff_forall_not_mem.2 $ assume b hb, ha $
show 0 ≤ a, from le_trans b.2 (le_of_lt hb)),
rw [this],
apply @is_open_empty } },
end⟩
section coe
variable {α : Type*}
open filter
lemma continuous_of_real : continuous nnreal.of_real :=
continuous_subtype_mk _ $ continuous_max continuous_id continuous_const
lemma continuous_coe : continuous (coe : nnreal → ℝ) :=
continuous_subtype_val
lemma tendsto_coe {f : filter α} {m : α → nnreal} :
∀{x : nnreal}, tendsto (λa, (m a : ℝ)) f (nhds (x : ℝ)) ↔ tendsto m f (nhds x)
| ⟨r, hr⟩ := by rw [nhds_subtype_eq_comap, tendsto_comap_iff]; refl
lemma tendsto_of_real {f : filter α} {m : α → ℝ} {x : ℝ} (h : tendsto m f (nhds x)) :
tendsto (λa, nnreal.of_real (m a)) f (nhds (nnreal.of_real x)) :=
tendsto.comp (continuous_iff_continuous_at.1 continuous_of_real _) h
lemma tendsto_sub {f : filter α} {m n : α → nnreal} {r p : nnreal}
(hm : tendsto m f (nhds r)) (hn : tendsto n f (nhds p)) :
tendsto (λa, m a - n a) f (nhds (r - p)) :=
tendsto_of_real $ tendsto_sub (tendsto_coe.2 hm) (tendsto_coe.2 hn)
lemma continuous_sub' : continuous (λp:nnreal×nnreal, p.1 - p.2) :=
continuous_subtype_mk _ (continuous_max
(continuous_sub (continuous.comp continuous_coe continuous_fst)
(continuous.comp continuous_coe continuous_snd))
continuous_const)
lemma continuous_sub [topological_space α] {f g : α → nnreal}
(hf : continuous f) (hg : continuous g) : continuous (λ a, f a - g a) :=
continuous_sub'.comp (hf.prod_mk hg)
lemma has_sum_coe {f : α → nnreal} {r : nnreal} : has_sum (λa, (f a : ℝ)) (r : ℝ) ↔ has_sum f r :=
by simp [has_sum, sum_coe.symm, tendsto_coe]
lemma summable_coe {f : α → nnreal} : summable (λa, (f a : ℝ)) ↔ summable f :=
begin
simp [summable],
split,
exact assume ⟨a, ha⟩, ⟨⟨a, has_sum_le (λa, (f a).2) has_sum_zero ha⟩, has_sum_coe.1 ha⟩,
exact assume ⟨a, ha⟩, ⟨a.1, has_sum_coe.2 ha⟩
end
lemma tsum_coe {f : α → nnreal} (hf : summable f) : (∑a, (f a : ℝ)) = ↑(∑a, f a) :=
tsum_eq_has_sum $ has_sum_coe.2 $ has_sum_tsum $ hf
end coe
end nnreal
|
904210f49168f066889eb5b9f1707a89bc6f114f | 43390109ab88557e6090f3245c47479c123ee500 | /src/Geometry/tarski_4.lean | f53c7dc209420967bf35434253267c6cba858da6 | [
"Apache-2.0"
] | permissive | Ja1941/xena-UROP-2018 | 41f0956519f94d56b8bf6834a8d39473f4923200 | b111fb87f343cf79eca3b886f99ee15c1dd9884b | refs/heads/master | 1,662,355,955,139 | 1,590,577,325,000 | 1,590,577,325,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 28,897 | lean | import geometry.tarski_3
open classical set
namespace Euclidean_plane
variables {point : Type} [Euclidean_plane point]
local attribute [instance, priority 0] prop_decidable
-- Planes and Half-planes
def Bl (a : point) (A : set point) (b : point) : Prop := line A ∧ a ∉ A ∧ b ∉ A ∧ ∃ t, t ∈ A ∧ B a t b
theorem nine1 {a p : point} {A : set point} : line A → a ∈ A → p ∉ A → Bl p A (S a p) :=
λ h h1 h2, ⟨h, h2, (λ h_2, h2 ((seven24 h h1).2 h_2)), a, h1, (seven5 a p).1⟩
theorem nine2 {a b : point} {A : set point} : Bl a A b → a ≠ b :=
begin
intros h h1,
subst h1,
unfold Bl at h,
apply h.2.1,
cases h.2.2.2 with x hx,
suffices : a = x,
rw this,
exact hx.1,
exact bet_same hx.2
end
theorem Bl.symm {a b : point} {A : set point} : Bl a A b → Bl b A a :=
begin
unfold Bl,
intro h,
split,
exact h.1,
split,
exact h.2.2.1,
split,
exact h.2.1,
cases h.2.2.2 with t ht,
constructor,
split,
exact ht.1,
exact ht.2.symm
end
lemma nine3 {a c m r : point} {A : set point} : Bl a A c → m ∈ A → M a m c → r ∈ A →
∀ {b}, sided r a b → Bl b A c :=
begin
unfold Bl,
intros h h1 h2 h3 b hb,
cases hb.2.2,
have h4 := (seven15 m).1 h_1,
have h5 := (seven6 h2).symm,
rw h5 at h4,
have h6 := seven5 m b,
cases pasch h6.1 h4 with t ht,
split,
exact h.1,
split,
intro h_2,
apply h.2.1,
exact six27 h.1 h3 h_2 h_1,
split,
exact h.2.2.1,
existsi t,
split,
have h_2 := (seven24 h.1 h1).1 h3,
exact six27 h.1 h1 h_2 ht.1,
exact ht.2.symm,
cases pasch h_1 h2.1.symm with t ht,
split,
exact h.1,
split,
intro h_2,
apply h.2.1,
have h_3 := six18 h.1 hb.2.1.symm h3 h_2,
rw h_3,
left,
exact h_1,
split,
exact h.2.2.1,
existsi t,
split,
exact six27 h.1 h1 h3 ht.2,
exact ht.1
end
lemma nine4a {a c m r s t : point} {A : set point} (h3 : r ∈ A) (h4 : A ⊥ l a r) (h5 : s ∈ A) (h6 : A ⊥ l c s)
(h2 : Bl a A c) (ht : t ∈ A ∧ B a t c) (h_1 : ¬r = s) (h_2 : distle s c r a) :
M r m s → ∀ {u}, (sided r u a ↔ sided s (S m u) c) :=
begin
unfold Bl at h2,
have g2 := six18 h2.1 (ne.symm h_1) h5 h3,
have g3 : (l s r) ⊥ (l c s),
rwa g2 at h6,
have g4 : (l s r) ⊥ (l a r),
rwa g2 at h4,
have g5 : col s r t,
rw g2 at ht,
exact ht.1,
cases h_2 with b gb,
cases eight24 g3.symm g4.symm g5 ht.2.symm gb.1 gb.2 with m' hm,
intro h_2,
have h_3 : m' = m,
exact unique_of_exists_unique (eight22 r s) hm.1.symm h_2,
subst m',
intro u,
have h_3 : sided r a b,
split,
exact six13 (eight14e h4).2,
split,
intro h_4,
subst b,
apply six13 (eight14e h6).2,
exact id_eqd (two4 gb.2),
right,
exact gb.1,
split,
intro h_4,
have h_5 := sided.trans h_4 h_3,
split,
intro h_6,
have h_7 := seven5 m u,
rw h_6 at h_7,
apply h_4.1,
exact seven4 h_7.symm hm.1,
split,
exact six13 (eight14e h6).2,
have h_6 := seven6 h_2,
rw h_6,
have h_7 := seven6 hm.2.symm,
rw h_7,
cases h_5.2.2,
left,
exact (seven15 m).1 h,
right,
exact (seven15 m).1 h,
intro h_4,
suffices : sided r u b,
exact sided.trans this h_3.symm,
have h_5 := seven6 h_2,
have h_6 := seven6 hm.2.symm,
rw [h_5, h_6] at h_4,
split,
intro h_7,
subst u,
apply h_4.1,
refl,
split,
exact h_3.2.1,
cases h_4.2.2,
left,
exact (seven15 m).2 h,
right,
exact (seven15 m).2 h
end
lemma nine4b {a c r s t : point} {A : set point} (h3 : r ∈ A) (h4 : A ⊥ l a r) (h5 : s ∈ A) (h6 : A ⊥ l c s)
(h2 : Bl a A c) (ht : t ∈ A ∧ B a t c) (h_1 : ¬r = s) (h_2 : distle s c r a) :
∀ {u v}, sided r u a → sided s v c → Bl u A v :=
begin
have g2 := six18 h2.1 (ne.symm h_1) h5 h3,
have g3 : (l s r) ⊥ (l c s),
rwa g2 at h6,
have g4 : (l s r) ⊥ (l a r),
rwa g2 at h4,
have g5 : col s r t,
rw g2 at ht,
exact ht.1,
cases h_2 with b gb,
cases eight24 g3.symm g4.symm g5 ht.2.symm gb.1 gb.2 with m hm,
unfold Bl at h2,
intros u v hu hv,
have h7 := nine4a h3 h4 h5 h6 h2 ht h_1 ⟨b, gb⟩ hm.1.symm,
have h8 := (h7).1 hu,
have h9 := sided.trans h8 hv.symm,
have h10 : u ∉ A,
intro h_2,
have h_3 := six18 h2.1 hu.1 h_2 h3,
apply h2.2.1,
rw h_3,
cases hu.2.2 with,
right, right,
exact h.symm,
right, left,
exact h,
have h11 : m ∈ A,
rw g2,
right, left,
exact hm.1.1.symm,
have h12 : Bl (S m u) A u,
unfold Bl,
split,
exact h2.1,
split,
intro h_2,
apply h10,
exact (seven24 h2.1 h11).2 h_2,
split,
exact h10,
existsi m,
split,
exact h11,
exact (seven5 m u).1.symm,
apply Bl.symm,
exact nine3 h12 h11 (seven5 m u).symm h5 h9
end
theorem nine4 {a c m r s : point} {A : set point} : Bl a A c → r ∈ A → perp A (l a r) → s ∈ A → perp A (l c s) →
(M r m s → ∀ {u}, (sided r u a ↔ sided s (S m u) c)) ∧ ∀ {u v}, sided r u a → sided s v c → Bl u A v :=
begin
intros h2 h3 h4 h5 h6,
cases h2.2.2.2 with t ht,
cases em (r = s),
have h_2 : xperp r (l a r) A,
apply eight14c.2,
split,
exact h4.symm,
split,
exact (eight14e h4).2,
split,
exact h2.1,
split,
exact eight14a h4.symm,
simp,
exact h3,
have h_3 : xperp s (l c s) A,
apply eight14c.2,
split,
exact h6.symm,
split,
exact (eight14e h6).2,
split,
exact h2.1,
split,
exact eight14a h6.symm,
simp,
exact h5,
have h_4 := h_2.2.2.2.2 (six17a a r) ht.1,
have h_5 := h_3.2.2.2.2 (six17a c s) ht.1,
subst h,
have h_6 : r = t,
exact eight6 h_4 h_5 ht.2,
subst h_6,
split,
intros h7 u,
have h_7 : m = r,
exact (bet_same h7.1).symm,
rw h_7,
have h8 := seven5 r u,
apply iff.intro,
intro hu,
unfold sided,
split,
intro h_9,
apply hu.1,
exact seven9 (eq.trans h_9 (seven11 r).symm),
split,
exact (six13 (eight14e h6).2),
cases hu.2.2,
have h7 : B u r c,
exact three6a h.symm ht.2,
exact five2 hu.1 h8.1 h7,
have h7 : B u r c,
exact three7a h.symm ht.2 (six13 (eight14e h4).2),
exact five2 hu.1 h8.1 h7,
intro hu,
unfold sided,
split,
intro h_8,
apply hu.1,
simp [h_8],
split,
exact (six13 (eight14e h4).2),
cases hu.2.2,
have h7 : B (S r u) r a,
exact three6a h.symm ht.2.symm,
exact five2 hu.1 h8.1.symm h7,
have h7 : B (S r u) r a,
exact three7a h.symm ht.2.symm (six13 (eight14e h6).2),
exact five2 hu.1 h8.1.symm h7,
intros u v hu hv,
unfold Bl,
split,
exact h2.1,
split,
intro h_6,
have h_7 := six18 h2.1 hu.1 h_6 ht.1,
rw h_7 at h2,
exact h2.2.1 (six4.1 hu).1,
split,
intro h_6,
have h_7 := six18 h2.1 hv.1 h_6 ht.1,
rw h_7 at h2,
exact h2.2.2.1 (six4.1 hv).1,
existsi r,
split,
exact ht.1,
exact six8 hu hv ht.2,
cases five10 s c r a,
split,
apply nine4a;
assumption,
apply nine4b;
assumption,
have g2 := six18 h2.1 h h3 h5,
have g3 : (l r s) ⊥ (l c s),
rwa g2 at h6,
have g4 : (l r s) ⊥ (l a r),
rwa g2 at h4,
have g5 : col r s t,
rw g2 at ht,
exact ht.1,
cases h_1 with b gb,
cases eight24 g4.symm g3.symm g5 ht.2 gb.1 gb.2 with m' hm,
split,
intro h_2,
have h_3 := unique_of_exists_unique (eight22 r s) hm.1 h_2,
subst m',
intro u,
suffices : sided r (S m (S m u)) a ↔ sided s (S m u) c,
simp at this,
exact this,
exact (nine4a h5 h6 h3 h4 h2.symm ⟨ht.1, ht.2.symm⟩ (ne.symm h) ⟨b, gb⟩ hm.1.symm).symm,
intros u v hu hv,
apply Bl.symm,
apply nine4b h5 h6 h3 h4 h2.symm ⟨ht.1, ht.2.symm⟩ (ne.symm h) ⟨b, gb⟩ hv hu
end
theorem nine5 {a b c r : point} {A : set point} : Bl a A c → r ∈ A → sided r a b → Bl b A c :=
begin
intros h h1 h2,
have h3 : b ∉ A,
intro h_1,
have h_2 := six18 h.1 h2.2.1.symm h1 h_1,
apply h.2.1,
rw h_2,
exact (four11 (six4.1 h2).1).2.2.1,
cases eight17 h.1 h.2.1 with x hx,
cases eight17 h.1 h3 with y hy,
cases eight17 h.1 h.2.2.1 with z hz,
cases eight22 x z with m hm,
dsimp at *,
have h4 := six27 h.1 hx.1.2.2.1 hz.1.2.2.1 hm.1.1,
have h5 : a ≠ x,
intro h_1,
apply h.2.1,
rw h_1,
exact hx.1.2.2.1,
have h6 : b ≠ y,
intro h_1,
apply h3,
rw h_1,
exact hy.1.2.2.1,
have h7 : c ≠ z,
intro h_1,
apply h.2.2.1,
rw h_1,
exact hz.1.2.2.1,
have h8 := nine4 h hx.1.2.2.1 ⟨x, hx.1⟩ hz.1.2.2.1 ⟨z, hz.1⟩,
have h9 := (h8.1 hm.1).1 (six5 h5),
have h10 := h8.2 (six5 h5) h9,
have h11 := nine3 h10 h4 (seven5 m a) h1 h2,
have h12 : (S m a) ≠ z,
intro h_1,
apply h5,
apply unique_of_exists_unique (seven8 m z) h_1,
exact (seven6 hm.1).symm,
have h13 : l c z = l (S m a) z,
apply six18 (six14 h7),
exact h12,
exact (four11 (six4.1 h9).1).2.2.2.2,
simp,
have h14 := hz.1,
rw h13 at h14,
have h15 := (nine4 h11 hy.1.2.2.1 ⟨y, hy.1⟩ h14.2.2.1 ⟨z, h14⟩).2 (six5 h6) h9.symm,
exact h15,
exact a
end
theorem nine6 {a b c p q : point} : B a c p → B b q c → ∃ x, B a x b ∧ B p q x :=
begin
intros h h1,
cases em (col p q c),
cases em (B p q c),
have h_3 := three6b h_2 h.symm,
constructor,
split,
exact three3 a b,
exact h_3,
have h_3 : sided q p c,
exact six4.2 ⟨h_1, h_2⟩,
constructor,
split,
exact three1 a b,
exact (six6 h1 h_3.symm).symm,
cases em (b ∈ l p q),
suffices : b = q,
constructor,
split,
exact three1 a b,
rw this,
exact three1 p q,
by_contradiction h_3,
apply h_1,
suffices : c ∈ l p q,
exact this,
suffices : l p q = l b q,
rw this,
left,
exact h1,
exact six18 (six14 (six26 h_1).1) h_3 h_2 (six17b p q),
have h3 : Bl c (l p q) b,
split,
exact six14 (six26 h_1).1,
split,
exact h_1,
split,
exact h_2,
constructor,
split,
exact (six17b p q),
exact h1.symm,
have h4 : sided p c a,
split,
exact (six26 h_1).2.2.symm,
split,
intro h_1,
subst h_1,
apply (six26 h_1).2.2,
exact bet_same h,
left,
exact h.symm,
have h5 := nine5 h3 (six17a p q) h4,
cases h5.2.2.2 with x hx,
constructor,
split,
exact hx.2,
cases pasch h.symm hx.2.symm with t ht,
suffices : t = q,
subst t,
exact ht.2.symm,
apply six21a (six14 (nine2 h3.symm)) (six14 (six26 h_1).1) _ (or.inr (or.inl ht.1)) _ (or.inr (or.inl h1.symm)) (six17b p q),
intro h_1,
exact absurd (six17a b c) (h_1.symm ▸ h_2),
exact (six27 (six14 (six26 h_1).1) (six17a p q) hx.1 ht.2.symm)
end
def side (A : set point) (a b : point) : Prop := ∃ c, Bl a A c ∧ Bl b A c
theorem nine8 {a b c : point} {A : set point} : Bl a A c → (Bl b A c ↔ side A a b) :=
begin
intro h,
split,
intro h1,
constructor,
exact ⟨h, h1⟩,
intro h1,
cases h1 with d hd,
cases hd.1.2.2.2 with x hx,
cases hd.2.2.2.2 with y hy,
cases pasch hx.2 hy.2 with z hz,
cases em (x = y),
subst y,
suffices : sided x a b,
exact nine5 h hx.1 this,
split,
intro h_1,
subst x,
apply hd.1.2.1,
exact hx.1,
split,
intro h_1,
subst x,
apply hd.2.2.1,
exact hx.1,
suffices : d ≠ x,
exact five2 this hx.2.symm hy.2.symm,
intro h_1,
subst d,
apply hd.1.2.2.1,
exact hx.1,
have h1 : A = l x y,
exact six18 h.1 h_1 hx.1 hy.1,
have h2 : z ≠ x,
intro h_1,
subst h1,
subst h_1,
apply hd.1.2.1,
right, right,
exact hz.2.symm,
have h3 : z ≠ y,
intro h_1,
subst h1,
subst h_1,
apply hd.2.2.1,
left,
exact hz.1,
have h4 := nine5 h hy.1 (six7 hz.2 h3).symm,
exact nine5 h4 hx.1 (six7 hz.1 h2)
end
theorem nine9 {a b : point} {A : set point} : Bl a A b → ¬side A a b :=
begin
intros h h1,
suffices : Bl b A b,
apply nine2 this,
refl,
exact (nine8 h).2 h1
end
theorem nine10 {a : point} {A : set point} : line A → a ∉ A → ∃ b, Bl a A b :=
begin
intros h h1,
rcases h with ⟨p, q, h⟩,
cases three14 a p with b hb,
existsi b,
split,
rw h.2,
exact six14 h.1,
split,
exact h1,
split,
intro h_1,
apply h1,
rw h.2 at *,
suffices : l p q = l p b,
rw this,
right, right,
exact hb.1,
exact six18 (six14 h.1) hb.2 (six17a p q) h_1,
existsi p,
split,
rw h.2,
simp,
exact hb.1
end
theorem nine10a {a p : point} {A : set point} : line A → a ∈ A → p ∉ A → Bl p A (S a p) :=
λ h h1 h2, ⟨h, h2, λ h_1, h2 ((seven24 h h1).2 h_1), a, h1, (seven5 a p).1⟩
theorem nine11 {p q : point} {A : set point} : side A p q → line A ∧ p ∉ A ∧ q ∉ A :=
begin
intro h,
cases h with x hx,
split,
exact hx.1.1,
split,
exact hx.1.2.1,
exact hx.2.2.1
end
theorem nine12 {a b p : point} {A : set point} : line A → p ∈ A → sided p a b → a ∉ A → side A a b :=
λ h h1 h2 h3, let ⟨c, hc⟩ := nine10 h h3 in ⟨c, hc, nine5 hc h1 h2⟩
theorem side.refl {a : point} {A : set point} : line A → a ∉ A → side A a a :=
begin
intros h h1,
cases nine10 h h1 with b hb,
existsi b,
split;
assumption
end
theorem side.refla {a b c : point} : ¬col a b c → side (l a b) c c :=
λ h, side.refl (six14 (six26 h).1) h
theorem side.symm {a b : point} {A : set point} : side A a b → side A b a :=
begin
intro h,
cases h with c hc,
constructor,
exact ⟨hc.2, hc.1⟩
end
theorem side.trans {a b c : point} {A : set point} : side A a b → side A b c → side A a c :=
begin
intros h h1,
cases h with d hd,
constructor,
split,
exact hd.1,
exact (nine8 hd.2).2 h1
end
def hp (A : set point) (a : point) : set point := {x | side A x a}
theorem nine14 {a b : point} {A : set point} : b ∈ hp A a → hp A a = hp A b :=
begin
intro h,
ext,
split,
intro h1,
exact side.trans h1 h.symm,
intro h1,
exact side.trans h1 h
end
theorem nine16 {a p : point} {A : set point} : line A → a ∉ A → p ∈ A → Bl a A (S p a) :=
λ h h1 h2, ⟨h, h1, λ h_1, h1 ((seven24 h h2).2 h_1), p, h2, (seven5 p a).1⟩
theorem nine17 {a b c : point} {A : set point} : side A a b → B a c b → side A c a :=
begin
intros h h1,
cases h with d hd,
cases hd.1.2.2.2 with x hx,
cases hd.2.2.2.2 with y hy,
cases three17 hx.2 hy.2 h1 with t ht,
have h2 : t ∈ A,
exact six27 hd.1.1 hx.1 hy.1 ht.2,
have h3 : Bl c A d,
split,
exact hd.1.1,
split,
intro h_1,
suffices : Bl b A b,
apply nine2 this,
refl,
suffices : Bl a A b,
apply (nine8 this).2,
existsi d,
exact hd,
split,
exact hd.1.1,
split,
exact hd.1.2.1,
split,
exact hd.2.2.1,
existsi c,
split,
exact h_1,
exact h1,
split,
exact hd.1.2.2.1,
constructor,
split,
exact h2,
exact ht.1,
existsi d,
split,
exact h3,
exact hd.1
end
theorem nine17a {a b c p : point} {A : set point} : side A p a → side A p c → B a b c → side A p b :=
λ h h1 h2, h.trans (nine17 (h.symm.trans h1) h2).symm
theorem nine18 {a b p : point} {A : set point} : line A → p ∈ A → col a b p →
(Bl a A b ↔ B a p b ∧ a ∉ A ∧ b ∉ A) :=
begin
intros h h1 h2,
split,
intro h3,
split,
cases h3.2.2.2 with q hq,
suffices : p = q,
rw this,
exact hq.2,
apply six21a h (six14 (nine2 h3)) _ h1 h2 hq.1 (or.inr (or.inl hq.2.symm)),
intro h_1,
apply h3.2.1,
simpa [h_1] using (six17a a b),
split,
exact h3.2.1,
exact h3.2.2.1,
intro h3,
split,
exact h,
split,
exact h3.2.1,
split,
exact h3.2.2,
existsi p,
split,
exact h1,
exact h3.1
end
theorem nine19 {a b p : point} {A : set point} : line A → p ∈ A → col a b p →
side A a b → sided p a b ∧ a ∉ A :=
begin
intros h h1 h2 h3,
split,
apply six4.2,
split,
exact (four11 h2).1,
intro h,
cases nine17 h3 h with x hx,
exact hx.1.2.1 h1,
cases h3 with d hd,
exact hd.1.2.1
end
theorem nine19a {a b c p : point} {A : set point} : side A a b → p ∈ A → sided p b c → side A a c :=
λ h h1 h2, h.trans (nine12 (nine11 h).1 h1 h2 (nine11 h).2.2)
theorem nine15 {a b x y p : point} : ¬col a b p → B a p x → B b p y → side (l a b) x y :=
λ h h1 h2, nine19a (nine12 (six14 (six26 h).1) (six17a a b) (six7 h1 (six26 h).2.2.symm) h).symm (six17b a b) (six7 h2 (six26 h).2.1.symm)
def pl (A : set point) (a : point) : set point := {x | side A x a ∨ x ∈ A ∨ Bl a A x}
def plane (P : set point) : Prop := ∃ p q r, ¬col p q r ∧ P = pl (l p q) r
theorem nine20 {a : point} {A : set point} : line A → a ∉ A → plane (pl A a) :=
begin
intros h h1,
rcases h with ⟨p, q, h⟩,
rw h.2 at *,
repeat {constructor},
exact h1
end
theorem nine21a {a b : point} {A : set point} : b ∈ pl A a → b ∉ A → line A ∧ a ∉ A :=
begin
intros h h1,
cases h,
cases h with x hx,
split,
exact hx.1.1,
exact hx.2.2.1,
cases h,
contradiction,
split,
exact h.1,
exact h.2.1
end
theorem nine21b {a b : point} {A : set point} : b ∈ pl A a → b ∉ A → pl A a = pl A b :=
begin
intros h h1,
ext,
cases h,
split,
intro h2,
cases h2,
left,
exact side.trans h2 h.symm,
cases h2,
right, left,
exact h2,
right, right,
exact (nine8 h2).2 h.symm,
intro h2,
cases h2,
left,
exact side.trans h2 h,
cases h2,
right, left,
exact h2,
right, right,
exact (nine8 h2).2 h,
cases h,
contradiction,
split,
intro h2,
cases h2,
right, right,
exact ((nine8 h).2 h2.symm).symm,
cases h2,
right, left,
exact h2,
left,
existsi a,
split,
exact h2.symm,
exact h.symm,
intro h2,
cases h2,
right, right,
exact ((nine8 h.symm).2 h2.symm).symm,
cases h2,
right, left,
exact h2,
left,
existsi b,
split,
exact h2.symm,
exact h
end
theorem nine22 {a x : point} {A A' : set point} : is x A A' → a ∈ A' → a ≠ x → A' ⊆ pl A a :=
begin
intros h h1 h2,
intros p hp,
have h3 : a ∉ A,
intro h_1,
apply h.2.2.1,
exact six21 h2 h.1 h.2.1 h_1 h1 h.2.2.2.1 h.2.2.2.2,
have h4 : A' = l a x,
exact six18 h.2.1 h2 h1 h.2.2.2.2,
cases em (p = x),
rw h_1,
right, left,
exact h.2.2.2.1,
have h5 : p ∉ A,
intro h_2,
apply h.2.2.1,
exact six21 h_1 h.1 h.2.1 h_2 hp h.2.2.2.1 h.2.2.2.2,
rw h4 at hp,
have h6 : col a x p,
exact hp,
cases hp,
right, right,
split,
exact h.1,
split,
exact h3,
split,
exact h5,
existsi x,
split,
exact h.2.2.2.1,
exact hp,
left,
apply nine12 h.1 h.2.2.2.1 _ h5,
split,
exact h_1,
split,
exact h2,
cases hp,
left,
exact hp,
right,
exact hp.symm
end
def planeof (p q s : point) : set point := pl (l p q) s
theorem nine23 (a b c p : point) : a ≠ c → ¬col a b p → col a c p → planeof a b c = planeof a b p :=
begin
intros h_1 h h1,
unfold planeof,
apply nine21b,
suffices : l a c ⊆ pl (l a b) c,
exact this h1,
apply nine22,
split,
exact (six14 (six26 h).1),
split,
exact six14 h_1,
split,
intro h_2,
apply h,
suffices : p ∈ l a c,
rw ←h_2 at this,
exact this,
exact h1,
split,
exact (six17a a b),
simp,
simp,
exact h_1.symm,
exact h
end
theorem nine24b {a b c x : point} : ¬col a b c → side (l a b) x c → x ∈ planeof a c b :=
begin
intros h hx,
have h1 := seven5 a c,
have h2 := seven5 a b,
have h3 : Bl c (l a b) (S a c),
split,
exact six14 (six26 h).1,
split,
exact h,
split,
intro h_1,
apply h,
exact (seven24 (six14 (six26 h).1) (six17a a b)).2 h_1,
constructor,
split,
exact (six17a a b),
exact h1.1,
have h4 : Bl b (l a c) (S a b),
split,
exact six14 (six26 h).2.2,
split,
exact (four10 h).1,
split,
intro h_1,
apply (four10 h).1,
exact (seven24 (six14 (six26 h).2.2) (six17a a c)).2 h_1,
constructor,
split,
exact (six17a a c),
exact h2.1,
have h5 : l a c = l a (S a c),
apply six18 (six14 (six26 h).2.2),
exact (seven12a (six26 h).2.2.symm).symm,
simp,
right, right,
exact h1.1.symm,
unfold planeof,
have h6 := (nine8 h3).2 hx.symm,
cases h6.2.2.2 with t ht,
cases em (t = a),
subst t,
right, left,
rw h5,
right, right,
exact ht.2,
have h7 : sided (S a c) t x,
split,
intro h_2,
apply h3.2.2.1,
rw ←h_2,
exact ht.1,
split,
intro h_2,
suffices : t = S a c,
apply h3.2.2.1,
rw ←this,
exact ht.1,
subst x,
exact (bet_same ht.2).symm,
left,
exact ht.2.symm,
cases ht.1,
left,
have h_3 : B t a (S a b),
exact three7a h_2.symm h2.1 (six26 h).1.symm,
apply side.symm,
suffices : Bl t (l a c) (S a b),
have h8 : side (l a c) b t,
constructor,
split,
exact h4,
exact this,
apply side.trans h8,
apply (nine8 this).1,
apply nine5 this,
right, right,
exact h1.1.symm,
exact h7,
split,
exact six14 (six26 h).2.2,
split,
intro h_4,
suffices : l a b = l a c,
have h_5 : c ∈ l a b,
rw this,
simp,
exact h h_5,
exact six21 h_1 (six14 (six26 h).1) (six14 (six26 h).2.2) ht.1 h_4 (six17a a b) (six17a a c),
split,
intro h_4,
apply (four10 h).1,
exact (seven24 (six14 (six26 h).2.2) (six17a a c)).2 h_4,
constructor,
split,
exact (six17a a c),
exact h_3,
cases h_2,
left,
have h_3 : B t a (S a b),
exact three6a h_2 h2.1,
apply side.symm,
suffices : Bl t (l a c) (S a b),
have h8 : side (l a c) b t,
constructor,
split,
exact h4,
exact this,
apply side.trans h8,
apply (nine8 this).1,
apply nine5 this,
right, right,
exact h1.1.symm,
exact h7,
split,
exact six14 (six26 h).2.2,
split,
intro h_4,
suffices : l a b = l a c,
have h_5 : c ∈ l a b,
rw this,
simp,
exact h h_5,
exact six21 h_1 (six14 (six26 h).1) (six14 (six26 h).2.2) ht.1 h_4 (six17a a b) (six17a a c),
split,
intro h_4,
apply (four10 h).1,
exact (seven24 (six14 (six26 h).2.2) (six17a a c)).2 h_4,
constructor,
split,
exact (six17a a c),
exact h_3,
right, right,
apply Bl.symm,
apply nine5 _,
exact (seven24 (six14 (six26 h).2.2) (six17a a c)).1 (six17b a c),
exact h7,
split,
exact six14 (six26 h).2.2,
split,
intro h_3,
suffices : l a b = l a c,
have h_5 : c ∈ l a b,
rw this,
simp,
exact h h_5,
exact six21 h_1 (six14 (six26 h).1) (six14 (six26 h).2.2) ht.1 h_3 (six17a a b) (six17a a c),
split,
intro h_3,
exact (four10 h).1 h_3,
constructor,
split,
exact (six17a a c),
exact h_2
end
theorem nine24c {a b c : point} : ¬col a b c → planeof a b c ⊆ planeof a c b :=
begin
intro h,
intros x hx,
cases hx,
exact nine24b h hx,
cases hx,
have h1 : l a b ⊆ planeof a c b,
unfold planeof,
apply nine22 (six28 (four10 h).1) (six17b a b) (six26 h).1.symm,
exact h1 hx,
unfold planeof,
have h1 := seven5 a c,
have h2 : l a c = l a (S a c),
apply six18 (six14 (six26 h).2.2),
exact (seven12a (six26 h).2.2.symm).symm,
simp,
right, right,
exact h1.1.symm,
rw h2,
have h3 : ¬col a b (S a c),
intro h_1,
apply h,
exact (seven24 (six14 (six26 h).1) (six17a a b)).2 h_1,
have h4 : side (l a b) x (S a c),
apply (nine8 hx.symm).1,
split,
exact (six14 (six26 h).1),
split,
exact h3,
split,
exact h,
constructor,
split,
exact (six17a a b),
exact h1.1.symm,
exact nine24b h3 h4
end
theorem nine24d {a b c : point} : ¬col a b c → planeof a b c = planeof a c b :=
begin
intro h,
ext,
split,
intro h1,
exact nine24c h h1,
intro h1,
exact nine24c (four10 h).1 h1
end
theorem nine24e (a b c : point) : planeof a b c = planeof b a c :=
begin
unfold planeof,
suffices : l a b = l b a,
rwa this,
ext,
split,
intro h,
exact (four11 h).2.1,
intro h,
exact (four11 h).2.1
end
theorem nine24 {a b c : point} : ¬col a b c → planeof a b c = planeof a c b ∧ planeof a b c = planeof b a c
∧ planeof a b c = planeof b c a ∧ planeof a b c = planeof c a b ∧ planeof a b c = planeof c b a :=
begin
intro h,
repeat {split};
simp [nine24d h, nine24e];
exact eq.trans (nine24e a c b) (eq.trans (nine24d (four10 h).2.2.2.1) (nine24e c b a))
end
theorem nine24a {a b c : point} : ¬col a b c → l a b ⊆ planeof a b c ∧ l b c ⊆ planeof a b c ∧ l a c ⊆ planeof a b c :=
begin
intro h,
split,
intros x hx,
right, left,
assumption,
split,
rw (nine24 h).2.2.1,
intros x hx,
right, left,
assumption,
rw (nine24 h).1,
intros x hx,
right, left,
assumption
end
lemma nine25a {a b p q r : point} (h : ¬col p q r) (h1 : a ∈ pl (l p q) r) (h2 : b ∈ pl (l p q) r) (h3 : a ≠ b)
(h_2 : b ∉ l p q) : l a b ⊆ pl (l p q) r ∧ ∃ c, pl (l p q) r = planeof a b c :=
begin
have h4 : p ≠ b,
exact (six18a h_2).1.symm,
have h5 : pl (l p q) r = pl (l p q) b,
exact nine21b h2 h_2,
rw h5,
have h6 : planeof p q b = planeof p b q,
exact (nine24 h_2).1,
unfold planeof at h6,
rw h6,
cases em (a ∈ l p b) with h_3 h_3,
have h7 : l p b = l a b,
exact six18 (six14 h4) h3 h_3 (six17b p b) ,
rw h7,
have h8 : q ∉ l a b,
intro h_4,
rw ←h7 at h_4,
exact h_2 (four11 h_4).1,
split,
exact (nine24a h8).1,
existsi q,
unfold planeof,
rw (eq.trans h5 h6) at h1,
have h7 : pl (l p b) q = pl (l p b) a,
exact nine21b h1 h_3,
rw h7,
have h8 : planeof p b a = planeof a b p,
exact (nine24 h_3).2.2.2.2,
unfold planeof at h8,
rw h8,
split,
exact (nine24a (four10 h_3).2.2.2.2).1,
existsi p,
unfold planeof
end
theorem nine25 {a b : point} {P : set point} : plane P → a ∈ P → b ∈ P → a ≠ b → l a b ⊆ P ∧ ∃ c, P = planeof a b c :=
begin
intros h h1 h2 h3,
unfold plane at h,
rcases h with ⟨p, q, r, h⟩,
rw h.2 at *,
cases em (a ∈ l p q),
cases em (b ∈ l p q),
have h4 : l p q = l a b,
exact six18 (six14 (six26 h.1).1) h3 h_1 h_2,
split,
rw ←h4,
exact (nine24a h.1).1,
existsi r,
rw h4,
unfold planeof,
exact nine25a h.1 h1 h2 h3 h_2,
rw six17 a b,
split,
exact (nine25a h.1 h2 h1 h3.symm h_1).1,
cases (nine25a h.1 h2 h1 h3.symm h_1).2 with c hc,
existsi c,
rw nine24e a b c,
exact hc
end
theorem nine26 {a b c : point} {P : set point} : ¬col a b c → plane P → a ∈ P → b ∈ P → c ∈ P → P = planeof a b c :=
begin
intros h h1 h2 h3 h4,
cases (nine25 h1 h2 h3 (six26 h).1).2 with c' hc',
subst P,
exact nine21b h4 h
end
theorem nine27 (a b c : point) : a ∈ planeof a b c ∧ b ∈ planeof a b c ∧ c ∈ planeof a b c :=
begin
split,
right, left,
simp,
split,
right, left,
simp,
by_cases h : a = b,
subst b,
right, left, left,
exact three3 a c,
by_cases h1 : c ∈ l a b,
right, left,
exact h1,
left,
exact side.refl (six14 h) h1
end
theorem nine28 {p : point} {A : set point} : line A → plane (pl A p) → p ∉ A :=
begin
intros h h1 h2,
rcases h1 with ⟨x, y, z, h1⟩,
apply h1.1,
suffices : pl A p = A,
rw this at h1,
have h3 := nine27 x y z,
rw [planeof, h1.2.symm] at h3,
exact six23.2 ⟨A, h, h3⟩,
ext t,
split,
intro h3,
cases h3,
exfalso,
exact (nine11 h3).2.2 h2,
cases h3,
exact h3,
exfalso,
exact h3.2.1 h2,
intro h3,
right, left,
exact h3
end
theorem nine31 {p q r s : point} : side (l p q) s r → side (l p r) s q → Bl q (l p s) r :=
begin
intros h h1,
have h2 : ¬col p q r,
cases h with x hx,
exact hx.2.2.1,
have h3 := seven5 p r,
have h4 : Bl r (l p q) (S p r),
split,
exact (nine11 h).1,
split,
exact h2,
split,
intro h_1,
apply h2,
exact (seven24 (nine11 h).1 (six17a p q)).2 h_1,
constructor,
split,
exact (six17a p q),
exact h3.1,
have h5 : Bl (S p r) (l p q) s,
exact ((nine8 h4).2 h.symm).symm,
cases h5.2.2.2 with t ht,
have h6 : sided (S p r) t s,
apply six7 ht.2,
intro h_1,
subst t,
exact h4.2.2.1 ht.1,
have h7 : side (l p r) t s,
apply nine12 (nine11 h1).1 ((seven24 (nine11 h1).1 (six17a p r)).1 (six17b p r)) h6,
intro h_1,
suffices : (S p r) ≠ t,
apply (nine11 h1).2.1,
suffices : l p r = l (S p r) t,
rw this,
left,
exact ht.2,
apply six18 (six14 (six26 h2).2.2) this,
right, right,
exact h3.1.symm,
exact h_1,
intro h_2,
subst t,
apply h4.2.2.1,
exact ht.1,
have h8 : sided p t q,
apply (nine19 (six14 (six26 h2).2.2) (six17a p r) _ _).1,
exact (four11 ht.1).2.2.2.2,
exact side.trans h7 h1,
have h9 : p ≠ s,
intro h_1,
subst s,
apply (nine11 h).2.1,
simp,
have h10 : side (l p s) t q,
apply nine12 (six14 h9) (six17a p s) h8 _,
intro h_1,
apply (nine11 h).2.1,
suffices : l p q = l p s,
rw this,
simp,
exact six21 h8.1 (nine11 h).1 (six14 h9) ht.1 h_1 (six17a p q) (six17a p s),
have h11 : Bl r (l p s) (S p r),
split,
exact six14 h9,
split,
exact (four10 (nine11 h1).2.1).1,
split,
intro h_1,
apply (four10 (nine11 h1).2.1).1,
exact (seven24 (six14 h9) (six17a p s)).2 h_1,
existsi p,
split,
simp,
exact h3.1,
apply (nine8 h11.symm).2 (side.trans _ h10),
apply (nine12 (six14 h9) (six17b p s) (six7 ht.2.symm _) (nine11 h10).2.1).symm,
intro h_1,
subst t,
exact (nine11 h10).2.1 (six17b p s)
end
end Euclidean_plane |
aeb48140c41a6500b80d2e8dd5a522018b5c1f33 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/print_escape_name.lean | 510c637210d610fe77841163d4cee974aa1f9388 | [
"Apache-2.0"
] | permissive | leanprover-community/lean | 12b87f69d92e614daea8bcc9d4de9a9ace089d0e | cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0 | refs/heads/master | 1,687,508,156,644 | 1,684,951,104,000 | 1,684,951,104,000 | 169,960,991 | 457 | 107 | Apache-2.0 | 1,686,744,372,000 | 1,549,790,268,000 | C++ | UTF-8 | Lean | false | false | 125 | lean | constant «x.y» : false
lemma «a.b» : false := «x.y»
#print «x.y»
#print «a.b»
#check «a.b»
#print axioms «a.b» |
f89523c9ff856ca693c2803aec5ead44da1b68bf | e2fc96178628c7451e998a0db2b73877d0648be5 | /src/classes/context_free/closure_properties/permutation.lean | 3a02102a0701057b3a18fef1ad4b70543f0e0292 | [
"BSD-2-Clause"
] | permissive | madvorak/grammars | cd324ae19b28f7b8be9c3ad010ef7bf0fabe5df2 | 1447343a45fcb7821070f1e20b57288d437323a6 | refs/heads/main | 1,692,383,644,884 | 1,692,032,429,000 | 1,692,032,429,000 | 453,948,141 | 7 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 287 | lean | import classes.context_free.closure_properties.bijection
/-- The class of context-free languages is closed under permutation of terminals. -/
theorem CF_of_permute_CF {T : Type} (π : equiv.perm T) (L : language T) :
is_CF L → is_CF (permute_lang L π) :=
CF_of_bijemap_CF π L
|
d60389c4af4219920c670715478b2a6f9cbba2fa | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/data/finsupp/lex.lean | 9178940be7caeb94c20b16c1b5cdf533224250a0 | [
"Apache-2.0"
] | permissive | jcommelin/mathlib | d8456447c36c176e14d96d9e76f39841f69d2d9b | ee8279351a2e434c2852345c51b728d22af5a156 | refs/heads/master | 1,664,782,136,488 | 1,663,638,983,000 | 1,663,638,983,000 | 132,563,656 | 0 | 0 | Apache-2.0 | 1,663,599,929,000 | 1,525,760,539,000 | Lean | UTF-8 | Lean | false | false | 5,804 | lean | /-
Copyright (c) 2022 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import data.pi.lex
import data.finsupp.order
import data.finsupp.ne_locus
/-!
# Lexicographic order on finitely supported functions
This file defines the lexicographic order on `finsupp`.
-/
variables {α N : Type*}
namespace finsupp
section N_has_zero
variables [has_zero N]
/-- `finsupp.lex r s` is the lexicographic relation on `α →₀ N`, where `α` is ordered by `r`,
and `N` is ordered by `s`.
The type synonym `_root_.lex (α →₀ N)` has an order given by `finsupp.lex (<) (<)`.
-/
protected def lex (r : α → α → Prop) (s : N → N → Prop) (x y : α →₀ N) : Prop :=
pi.lex r (λ _, s) x y
lemma _root_.pi.lex_eq_finsupp_lex {r : α → α → Prop} {s : N → N → Prop} (a b : α →₀ N) :
pi.lex r (λ _, s) (a : α → N) (b : α → N) = finsupp.lex r s a b :=
rfl
lemma lex_def {r : α → α → Prop} {s : N → N → Prop} {a b : α →₀ N} :
finsupp.lex r s a b ↔ ∃ j, (∀ d, r d j → a d = b d) ∧ s (a j) (b j) := iff.rfl
instance [has_lt α] [has_lt N] : has_lt (lex (α →₀ N)) :=
⟨λ f g, finsupp.lex (<) (<) (of_lex f) (of_lex g)⟩
instance lex.is_strict_order [linear_order α] [partial_order N] :
is_strict_order (lex (α →₀ N)) (<) :=
let i : is_strict_order (lex (α → N)) (<) := pi.lex.is_strict_order in
{ irrefl := to_lex.surjective.forall.2 $ λ a, @irrefl _ _ i.to_is_irrefl a,
trans := to_lex.surjective.forall₃.2 $ λ a b c, @trans _ _ i.to_is_trans a b c }
variables [linear_order α]
/-- The partial order on `finsupp`s obtained by the lexicographic ordering.
See `finsupp.lex.linear_order` for a proof that this partial order is in fact linear. -/
instance lex.partial_order [partial_order N] : partial_order (lex (α →₀ N)) :=
partial_order.lift (λ x, to_lex ⇑(of_lex x)) finsupp.coe_fn_injective--fun_like.coe_injective
variable [linear_order N]
/-- Auxiliary helper to case split computably. There is no need for this to be public, as it
can be written with `or.by_cases` on `lt_trichotomy` once the instances below are constructed. -/
private def lt_trichotomy_rec {P : lex (α →₀ N) → lex (α →₀ N) → Sort*}
(h_lt : Π {f g}, to_lex f < to_lex g → P (to_lex f) (to_lex g))
(h_eq : Π {f g}, to_lex f = to_lex g → P (to_lex f) (to_lex g))
(h_gt : Π {f g}, to_lex g < to_lex f → P (to_lex f) (to_lex g)) :
∀ f g, P f g :=
lex.rec $ λ f, lex.rec $ λ g,
match _, rfl : ∀ y, (f.ne_locus g).min = y → _ with
| ⊤, h := h_eq (finsupp.ne_locus_eq_empty.mp (finset.min_eq_top.mp h))
| (wit : α), h :=
have hne : f wit ≠ g wit := mem_ne_locus.mp (finset.mem_of_min h),
hne.lt_or_lt.by_cases
(λ hwit, h_lt ⟨wit, λ j hj, mem_ne_locus.not_left.mp (finset.not_mem_of_lt_min hj h), hwit⟩)
(λ hwit, h_gt ⟨wit, by exact λ j hj, begin
refine mem_ne_locus.not_left.mp (finset.not_mem_of_lt_min hj _),
rwa ne_locus_comm,
end, hwit⟩)
end
@[irreducible] instance lex.decidable_le : @decidable_rel (lex (α →₀ N)) (≤) :=
lt_trichotomy_rec
(λ f g h, is_true $ or.inr h)
(λ f g h, is_true $ or.inl $ congr_arg _ h)
(λ f g h, is_false $ λ h', (lt_irrefl _ (h.trans_le h')).elim)
@[irreducible] instance lex.decidable_lt : @decidable_rel (lex (α →₀ N)) (<) :=
lt_trichotomy_rec
(λ f g h, is_true h)
(λ f g h, is_false h.not_lt)
(λ f g h, is_false h.asymm)
/-- The linear order on `finsupp`s obtained by the lexicographic ordering. -/
instance lex.linear_order : linear_order (lex (α →₀ N)) :=
{ le_total := lt_trichotomy_rec
(λ f g h, or.inl h.le)
(λ f g h, or.inl h.le)
(λ f g h, or.inr h.le),
decidable_lt := by apply_instance,
decidable_le := by apply_instance,
decidable_eq := by apply_instance,
..lex.partial_order }
lemma lex.le_of_forall_le {a b : lex (α →₀ N)} (h : ∀ i, of_lex a i ≤ of_lex b i) : a ≤ b :=
le_of_not_lt (λ ⟨i, hi⟩, (h i).not_lt hi.2)
lemma lex.le_of_of_lex_le {a b : lex (α →₀ N)} (h : of_lex a ≤ of_lex b) : a ≤ b :=
lex.le_of_forall_le h
lemma to_lex_monotone : monotone (@to_lex (α →₀ N)) :=
λ _ _, lex.le_of_forall_le
lemma lt_of_forall_lt_of_lt (a b : lex (α →₀ N)) (i : α) :
(∀ j < i, of_lex a j = of_lex b j) → of_lex a i < of_lex b i → a < b :=
λ h1 h2, ⟨i, h1, h2⟩
end N_has_zero
section covariants
variables [linear_order α] [add_monoid N] [linear_order N]
/-! We are about to sneak in a hypothesis that might appear to be too strong.
We assume `covariant_class` with *strict* inequality `<` also when proving the one with the
*weak* inequality `≤`. This is actually necessary: addition on `lex (α →₀ N)` may fail to be
monotone, when it is "just" monotone on `N`. -/
section left
variables [covariant_class N N (+) (<)]
instance lex.covariant_class_lt_left : covariant_class (lex (α →₀ N)) (lex (α →₀ N)) (+) (<) :=
⟨λ f g h ⟨a, lta, ha⟩, ⟨a, λ j ja, congr_arg ((+) _) (lta j ja), add_lt_add_left ha _⟩⟩
instance lex.covariant_class_le_left : covariant_class (lex (α →₀ N)) (lex (α →₀ N)) (+) (≤) :=
has_add.to_covariant_class_left _
end left
section right
variables [covariant_class N N (function.swap (+)) (<)]
instance lex.covariant_class_lt_right :
covariant_class (lex (α →₀ N)) (lex (α →₀ N)) (function.swap (+)) (<) :=
⟨λ f g h ⟨a, lta, ha⟩, ⟨a, λ j ja, congr_arg (+ (of_lex f j)) (lta j ja), add_lt_add_right ha _⟩⟩
instance lex.covariant_class_le_right :
covariant_class (lex (α →₀ N)) (lex (α →₀ N)) (function.swap (+)) (≤) :=
has_add.to_covariant_class_right _
end right
end covariants
end finsupp
|
ca924a7bc0b948e1ab7fb6a98f69518484ee90a3 | 07c76fbd96ea1786cc6392fa834be62643cea420 | /hott/homotopy/freudenthal.hlean | 65507312af130a16931a42e2e47ce11bf5ca9386 | [
"Apache-2.0"
] | permissive | fpvandoorn/lean2 | 5a430a153b570bf70dc8526d06f18fc000a60ad9 | 0889cf65b7b3cebfb8831b8731d89c2453dd1e9f | refs/heads/master | 1,592,036,508,364 | 1,545,093,958,000 | 1,545,093,958,000 | 75,436,854 | 0 | 0 | null | 1,480,718,780,000 | 1,480,718,780,000 | null | UTF-8 | Lean | false | false | 11,784 | hlean | /-
Copyright (c) 2016 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
The Freudenthal Suspension Theorem
-/
import homotopy.wedge homotopy.circle
open eq is_conn is_trunc pointed susp nat pi equiv is_equiv trunc fiber trunc_index
namespace freudenthal section
parameters {A : Type*} {n : ℕ} [is_conn n A]
/-
This proof is ported from Agda
This is the 95% version of the Freudenthal Suspension Theorem, which means that we don't
prove that loop_susp_unit : A →* Ω(susp A) is 2n-connected (if A is n-connected),
but instead we only prove that it induces an equivalence on the first 2n homotopy groups.
-/
private definition up (a : A) : north = north :> susp A :=
loop_susp_unit A a
definition code_merid : A → ptrunc (n + n) A → ptrunc (n + n) A :=
begin
have is_conn n (ptrunc (n + n) A), from !is_conn_trunc,
refine @wedge_extension.ext _ _ n n _ _ (λ x y, ttrunc (n + n) A) _ _ _ _,
{ intros, apply is_trunc_trunc}, -- this subgoal might become unnecessary if
-- type class inference catches it
{ exact tr},
{ exact id},
{ reflexivity}
end
definition code_merid_β_left (a : A) : code_merid a pt = tr a :=
by apply wedge_extension.β_left
definition code_merid_β_right (b : ptrunc (n + n) A) : code_merid pt b = b :=
by apply wedge_extension.β_right
definition code_merid_coh : code_merid_β_left pt = code_merid_β_right pt :=
begin
symmetry, apply eq_of_inv_con_eq_idp, apply wedge_extension.coh
end
definition is_equiv_code_merid (a : A) : is_equiv (code_merid a) :=
begin
have Πa, is_trunc n.-2.+1 (is_equiv (code_merid a)),
from λa, is_trunc_of_le _ !minus_one_le_succ _,
refine is_conn.elim (n.-1) _ _ a,
{ esimp, exact homotopy_closed id code_merid_β_right⁻¹ʰᵗʸ _ }
end
definition code_merid_equiv [constructor] (a : A) : trunc (n + n) A ≃ trunc (n + n) A :=
equiv.mk _ (is_equiv_code_merid a)
definition code_merid_inv_pt (x : trunc (n + n) A) : (code_merid_equiv pt)⁻¹ x = x :=
begin
refine ap010 @(is_equiv.inv _) _ x ⬝ _,
{ exact homotopy_closed id code_merid_β_right⁻¹ʰᵗʸ _ },
{ apply is_conn.elim_β},
{ reflexivity}
end
definition code [unfold 4] : susp A → Type :=
susp.elim_type (trunc (n + n) A) (trunc (n + n) A) code_merid_equiv
definition is_trunc_code (x : susp A) : is_trunc (n + n) (code x) :=
begin
induction x with a: esimp,
{ exact _},
{ exact _},
{ apply is_prop.elimo}
end
local attribute is_trunc_code [instance]
definition decode_north [unfold 4] : code north → trunc (n + n) (north = north :> susp A) :=
trunc_functor (n + n) up
definition decode_north_pt : decode_north (tr pt) = tr idp :=
ap tr !con.right_inv
definition decode_south [unfold 4] : code south → trunc (n + n) (north = south :> susp A) :=
trunc_functor (n + n) merid
definition encode' {x : susp A} (p : north = x) : code x :=
transport code p (tr pt)
definition encode [unfold 5] {x : susp A} (p : trunc (n + n) (north = x)) : code x :=
begin
induction p with p,
exact transport code p (tr pt)
end
theorem encode_decode_north (c : code north) : encode (decode_north c) = c :=
begin
have H : Πc, is_trunc (n + n) (encode (decode_north c) = c), from _,
esimp at *,
induction c with a,
rewrite [↑[encode, decode_north, up, code], con_tr, elim_type_merid, ▸*,
code_merid_β_left, elim_type_merid_inv, ▸*, code_merid_inv_pt]
end
definition decode_coh_f (a : A) : tr (up pt) =[merid a] decode_south (code_merid a (tr pt)) :=
begin
refine _ ⬝op ap decode_south (code_merid_β_left a)⁻¹,
apply trunc_pathover,
apply eq_pathover_constant_left_id_right,
apply square_of_eq,
exact whisker_right (merid a) !con.right_inv
end
definition decode_coh_g (a' : A) : tr (up a') =[merid pt] decode_south (code_merid pt (tr a')) :=
begin
refine _ ⬝op ap decode_south (code_merid_β_right (tr a'))⁻¹,
apply trunc_pathover,
apply eq_pathover_constant_left_id_right,
apply square_of_eq, refine !inv_con_cancel_right ⬝ !idp_con⁻¹
end
definition decode_coh_lem {A : Type} {a a' : A} (p : a = a')
: whisker_right p (con.right_inv p) = inv_con_cancel_right p p ⬝ (idp_con p)⁻¹ :=
by induction p; reflexivity
theorem decode_coh (a : A) : decode_north =[merid a] decode_south :=
begin
apply arrow_pathover_left, intro c,
induction c with a',
rewrite [↑code, elim_type_merid],
refine @wedge_extension.ext _ _ n n _ _ (λ a a', tr (up a') =[merid a] decode_south
(to_fun (code_merid_equiv a) (tr a'))) _ _ _ _ a a',
{ intros, apply is_trunc_pathover, apply is_trunc_succ, apply is_trunc_trunc},
{ exact decode_coh_f},
{ exact decode_coh_g},
{ clear a a', unfold [decode_coh_f, decode_coh_g], refine ap011 concato_eq _ _,
{ refine ap (λp, trunc_pathover (eq_pathover_constant_left_id_right (square_of_eq p))) _,
apply decode_coh_lem},
{ apply ap (λp, ap decode_south p⁻¹), apply code_merid_coh}}
end
definition decode [unfold 4] {x : susp A} (c : code x) : trunc (n + n) (north = x) :=
begin
induction x with a,
{ exact decode_north c},
{ exact decode_south c},
{ exact decode_coh a}
end
theorem decode_encode {x : susp A} (p : trunc (n + n) (north = x)) : decode (encode p) = p :=
begin
induction p with p, induction p, esimp, apply decode_north_pt
end
parameters (A n)
definition equiv' : trunc (n + n) A ≃ trunc (n + n) (Ω (susp A)) :=
equiv.MK decode_north encode decode_encode encode_decode_north
definition pequiv' : ptrunc (n + n) A ≃* ptrunc (n + n) (Ω (susp A)) :=
pequiv_of_equiv equiv' decode_north_pt
-- We don't prove this:
-- theorem freudenthal_suspension : is_conn_fun (n+n) (loop_susp_unit A) := sorry
end end freudenthal
open algebra group
definition freudenthal_pequiv {n k : ℕ} (H : k ≤ 2 * n) (A : Type*) [is_conn n A]
: ptrunc k A ≃* ptrunc k (Ω (susp A)) :=
have H' : k ≤[ℕ₋₂] n + n,
by rewrite [mul.comm at H, -algebra.zero_add n at {1}]; exact of_nat_le_of_nat H,
ptrunc_pequiv_ptrunc_of_le H' (freudenthal.pequiv' A n)
definition freudenthal_equiv {n k : ℕ} (H : k ≤ 2 * n) (A : Type*) [is_conn n A]
: trunc k A ≃ trunc k (Ω (susp A)) :=
freudenthal_pequiv H A
definition freudenthal_homotopy_group_pequiv {n k : ℕ} (H : k ≤ 2 * n) (A : Type*) [is_conn n A]
: π[k + 1] (susp A) ≃* π[k] A :=
calc
π[k + 1] (susp A) ≃* π[k] (Ω (susp A)) : homotopy_group_succ_in k (susp A)
... ≃* Ω[k] (ptrunc k (Ω (susp A))) : homotopy_group_pequiv_loop_ptrunc k (Ω (susp A))
... ≃* Ω[k] (ptrunc k A) : loopn_pequiv_loopn k (freudenthal_pequiv H A)
... ≃* π[k] A : (homotopy_group_pequiv_loop_ptrunc k A)⁻¹ᵉ*
definition freudenthal_homotopy_group_isomorphism {n k : ℕ} (H : k + 1 ≤ 2 * n)
(A : Type*) [is_conn n A] : πg[k+2] (susp A) ≃g πg[k + 1] A :=
begin
fapply isomorphism_of_equiv,
{ exact equiv_of_pequiv (freudenthal_homotopy_group_pequiv H A)},
{ intro g h,
refine _ ⬝ !homotopy_group_pequiv_loop_ptrunc_inv_con,
refine ap !homotopy_group_pequiv_loop_ptrunc⁻¹ᵉ* _,
refine ap (loopn_pequiv_loopn _ _) _ ⬝ !loopn_pequiv_loopn_con,
refine ap !homotopy_group_pequiv_loop_ptrunc _ ⬝ !homotopy_group_pequiv_loop_ptrunc_con,
apply homotopy_group_succ_in_con}
end
definition to_pmap_freudenthal_pequiv (n k : ℕ) (H : k ≤ 2 * n) (A : Type*) [is_conn n A]
: freudenthal_pequiv H A ~* ptrunc_functor k (loop_susp_unit A) :=
begin
fapply phomotopy.mk,
{ intro x, induction x with a, reflexivity },
{ refine !idp_con ⬝ _, refine _ ⬝ ap02 _ !idp_con⁻¹, refine _ ⬝ !ap_compose, apply ap_compose }
end
definition ptrunc_elim_freudenthal_pequiv (n k : ℕ) (H : k ≤ 2 * n) {A B : Type*} [is_conn n A]
(f : A →* Ω B) [is_trunc (k.+1) (B)] :
ptrunc.elim k (Ω→ (susp_elim f)) ∘* freudenthal_pequiv H A ~* ptrunc.elim k f :=
begin
refine pwhisker_left _ !to_pmap_freudenthal_pequiv ⬝* _,
refine !ptrunc_elim_ptrunc_functor ⬝* _,
exact ptrunc_elim_phomotopy k !ap1_susp_elim,
end
definition freudenthal_pequiv_trunc_index' (A : Type*) (n : ℕ) (k : ℕ₋₂) [HA : is_conn n A]
(H : k ≤ of_nat (2 * n)) : ptrunc k A ≃* ptrunc k (Ω (susp A)) :=
begin
assert lem : Π(l : ℕ₋₂), l ≤ 0 → ptrunc l A ≃* ptrunc l (Ω (susp A)),
{ intro l H', exact ptrunc_pequiv_ptrunc_of_le H' (freudenthal_pequiv (zero_le (2 * n)) A) },
cases k with k, { exact lem -2 (minus_two_le 0) },
cases k with k, { exact lem -1 (succ_le_succ (minus_two_le -1)) },
rewrite [-of_nat_add_two at *, add_two_sub_two at HA],
exact freudenthal_pequiv (le_of_of_nat_le_of_nat H) A
end
namespace susp
definition iterate_susp_stability_pequiv_of_is_conn_0 (A : Type*) {k n : ℕ} [is_conn 0 A]
(H : k ≤ 2 * n) : π[k + 1] (iterate_susp (n + 1) A) ≃* π[k] (iterate_susp n A) :=
have is_conn n (iterate_susp n A), by rewrite [-zero_add n]; exact _,
freudenthal_homotopy_group_pequiv H (iterate_susp n A)
definition iterate_susp_stability_isomorphism_of_is_conn_0 {k n : ℕ} (H : k + 1 ≤ 2 * n)
(A : Type*) [is_conn 0 A] : πg[k+2] (iterate_susp (n + 1) A) ≃g πg[k+1] (iterate_susp n A) :=
have is_conn n (iterate_susp n A), by rewrite [-zero_add n]; exact _,
freudenthal_homotopy_group_isomorphism H (iterate_susp n A)
definition stability_helper1 {k n : ℕ} (H : k + 2 ≤ 2 * n) : k ≤ 2 * pred n :=
begin
rewrite [mul_pred_right], change pred (pred (k + 2)) ≤ pred (pred (2 * n)),
apply pred_le_pred, apply pred_le_pred, exact H
end
definition stability_helper2 {k n : ℕ} (H : k + 2 ≤ 2 * n) (A : Type*) :
is_conn (pred n) (iterate_susp n A) :=
have Π(n : ℕ), n = -1 + (n + 1),
begin intro n, induction n with n IH, reflexivity, exact ap succ IH end,
begin
cases n with n,
{ exfalso, exact not_succ_le_zero _ H },
{ esimp, rewrite [this n], exact is_conn_iterate_susp -1 _ A }
end
definition iterate_susp_stability_pequiv {k n : ℕ} (H : k + 2 ≤ 2 * n) (A : Type*) :
π[k + 1] (iterate_susp (n + 1) A) ≃* π[k] (iterate_susp n A) :=
have is_conn (pred n) (iterate_susp n A), from stability_helper2 H A,
freudenthal_homotopy_group_pequiv (stability_helper1 H) (iterate_susp n A)
definition iterate_susp_stability_isomorphism {k n : ℕ} (H : k + 3 ≤ 2 * n) (A : Type*) :
πg[k+2] (iterate_susp (n + 1) A) ≃g πg[k+1] (iterate_susp n A) :=
have is_conn (pred n) (iterate_susp n A), from @stability_helper2 (k+1) n H A,
freudenthal_homotopy_group_isomorphism (stability_helper1 H) (iterate_susp n A)
definition iterated_freudenthal_pequiv {n k m : ℕ} (H : k ≤ 2 * n) (A : Type*) [HA : is_conn n A]
: ptrunc k A ≃* ptrunc k (Ω[m] (iterate_susp m A)) :=
begin
revert A n k HA H, induction m with m IH: intro A n k HA H,
{ reflexivity },
{ have H2 : succ k ≤ 2 * succ n,
from calc
succ k ≤ succ (2 * n) : succ_le_succ H
... ≤ 2 * succ n : self_le_succ,
exact calc
ptrunc k A ≃* ptrunc k (Ω (susp A)) : freudenthal_pequiv H A
... ≃* Ω (ptrunc (succ k) (susp A)) : loop_ptrunc_pequiv
... ≃* Ω (ptrunc (succ k) (Ω[m] (iterate_susp m (susp A)))) :
loop_pequiv_loop (IH (susp A) (succ n) (succ k) _ H2)
... ≃* ptrunc k (Ω[succ m] (iterate_susp m (susp A))) : loop_ptrunc_pequiv
... ≃* ptrunc k (Ω[succ m] (iterate_susp (succ m) A)) :
ptrunc_pequiv_ptrunc _ (loopn_pequiv_loopn _ !iterate_susp_succ_in)}
end
end susp
|
f66301566754fd16d65db13dca52cd6039abada0 | e030b0259b777fedcdf73dd966f3f1556d392178 | /library/init/data/option/basic.lean | a483a19fb06370f7742ac8e26543f0a43b77ed36 | [
"Apache-2.0"
] | permissive | fgdorais/lean | 17b46a095b70b21fa0790ce74876658dc5faca06 | c3b7c54d7cca7aaa25328f0a5660b6b75fe26055 | refs/heads/master | 1,611,523,590,686 | 1,484,412,902,000 | 1,484,412,902,000 | 38,489,734 | 0 | 0 | null | 1,435,923,380,000 | 1,435,923,379,000 | null | UTF-8 | Lean | false | false | 3,344 | lean | /-
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import init.logic init.category
open decidable
universe variables u v
namespace option
def to_monad {m : Type → Type} [monad m] [alternative m] {A} : option A → m A
| none := failure
| (some a) := return a
def get_or_else {α : Type u} : option α → α → α
| (some x) _ := x
| none e := e
def is_some {α : Type u} : option α → bool
| (some _) := tt
| none := ff
end option
instance (α : Type u) : inhabited (option α) :=
⟨none⟩
instance {α : Type u} [d : decidable_eq α] : decidable_eq (option α)
| none none := is_true rfl
| none (some v₂) := is_false (λ h, option.no_confusion h)
| (some v₁) none := is_false (λ h, option.no_confusion h)
| (some v₁) (some v₂) :=
match (d v₁ v₂) with
| (is_true e) := is_true (congr_arg (@some α) e)
| (is_false n) := is_false (λ h, option.no_confusion h (λ e, absurd e n))
end
@[inline] def option_fmap {α : Type u} {β : Type v} (f : α → β) : option α → option β
| none := none
| (some a) := some (f a)
@[inline] def option_bind {α : Type u} {β : Type v} : option α → (α → option β) → option β
| none b := none
| (some a) b := b a
instance : monad option :=
{map := @option_fmap, ret := @some, bind := @option_bind}
def option_orelse {α : Type u} : option α → option α → option α
| (some a) o := some a
| none (some a) := some a
| none none := none
instance {α : Type u} : alternative option :=
alternative.mk @option_fmap @some (@fapp _ _) @none @option_orelse
def option_t (m : Type (max 1 u) → Type v) [monad m] (α : Type u) : Type v :=
m (option α)
@[inline] def option_t_fmap {m : Type (max 1 u) → Type v} [monad m] {α β : Type u} (f : α → β) (e : option_t m α) : option_t m β :=
show m (option β), from
do o ← e,
match o with
| none := return none
| (some a) := return (some (f a))
end
@[inline] def option_t_bind {m : Type (max 1 u) → Type v} [monad m] {α β : Type u} (a : option_t m α) (b : α → option_t m β)
: option_t m β :=
show m (option β), from
do o ← a,
match o with
| none := return none
| (some a) := b a
end
@[inline] def option_t_return {m : Type (max 1 u) → Type v} [monad m] {α : Type u} (a : α) : option_t m α :=
show m (option α), from
return (some a)
instance {m : Type (max 1 u) → Type v} [monad m] : monad (option_t m) :=
{map := @option_t_fmap m _, ret := @option_t_return m _, bind := @option_t_bind m _}
def option_t_orelse {m : Type (max 1 u) → Type v} [monad m] {α : Type u} (a : option_t m α) (b : option_t m α) : option_t m α :=
show m (option α), from
do o ← a,
match o with
| none := b
| (some v) := return (some v)
end
def option_t_fail {m : Type (max 1 u) → Type v} [monad m] {α : Type u} : option_t m α :=
show m (option α), from
return none
instance {m : Type (max 1 u) → Type v} [monad m] : alternative (option_t m) :=
{map := @option_t_fmap m _,
pure := @option_t_return m _,
seq := @fapp (option_t m) (@option_t.monad m _),
failure := @option_t_fail m _,
orelse := @option_t_orelse m _}
|
47a5b65c75bb9aeabf386acd0a14721f4b82957c | 4bcaca5dc83d49803f72b7b5920b75b6e7d9de2d | /tests/lean/run/toFromJson.lean | 0bab2b9329c53149d73621e4ec963437a0f6be42 | [
"Apache-2.0"
] | permissive | subfish-zhou/leanprover-zh_CN.github.io | 30b9fba9bd790720bd95764e61ae796697d2f603 | 8b2985d4a3d458ceda9361ac454c28168d920d3f | refs/heads/master | 1,689,709,967,820 | 1,632,503,056,000 | 1,632,503,056,000 | 409,962,097 | 1 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 3,117 | lean | import Lean
open Lean
open Lean Parser Term
declare_syntax_cat json
syntax strLit : json
syntax numLit : json
syntax "{" (Lean.Parser.ident ": " json),* "}" : json
syntax "[" json,* "]" : json
syntax "json " json : term
/- declare a micro json parser, so we can write our tests in a more legible way. -/
open Json in macro_rules
| `(json $s:strLit) => s
| `(json $n:numLit) => n
| `(json { $[$ns : $js],* }) => do
let mut fields := #[]
for n in ns, j in js do
fields := fields.push (← `(($(quote n.getId.getString!), json $j)))
`(mkObj [$fields,*])
| `(json [ $[$js],* ]) => do
let mut fields := #[]
for j in js do
fields := fields.push (← `(json $j))
`(Json.arr #[$fields,*])
def checkToJson [ToJson α] (obj : α) (rhs : Json) : MetaM Unit :=
let lhs := (obj |> toJson).pretty
if lhs == rhs.pretty then
()
else
throwError "{lhs} ≟ {rhs}"
def checkRoundTrip [Repr α] [BEq α] [ToJson α] [FromJson α] (obj : α) : MetaM Unit :=
let roundTripped := obj |> toJson |> fromJson?
if let some roundTripped := roundTripped then
if obj == roundTripped then
()
else
throwError "{repr obj} ≟ {repr roundTripped}"
else
throwError "couldn't parse: {repr obj} ≟ {obj |> toJson}"
-- set_option trace.Meta.debug true in
structure Foo where
x : Nat
y : String
deriving ToJson, FromJson, Repr, BEq
#eval checkToJson { x := 1, y := "bla" : Foo} (json { y : "bla", x : 1 })
#eval checkRoundTrip { x := 1, y := "bla" : Foo }
-- set_option trace.Elab.command true
structure WInfo where
a : Nat
b : Nat
deriving ToJson, FromJson, Repr, BEq
-- set_option trace.Elab.command true
inductive E
| W : WInfo → E
| WAlt (a b : Nat)
| X : Nat → Nat → E
| Y : Nat → E
| YAlt (a : Nat)
| Z
deriving ToJson, FromJson, Repr, BEq
#eval checkToJson (E.W { a := 2, b := 3}) (json { W : { a : 2, b : 3 } })
#eval checkRoundTrip (E.W { a := 2, b := 3 })
#eval checkToJson (E.WAlt 2 3) (json { WAlt : { a : 2, b : 3 } })
#eval checkRoundTrip (E.WAlt 2 3)
#eval checkToJson (E.X 2 3) (json { X : [2, 3] })
#eval checkRoundTrip (E.X 2 3)
#eval checkToJson (E.Y 4) (json { Y : 4 })
#eval checkRoundTrip (E.Y 4)
#eval checkToJson (E.YAlt 5) (json { YAlt : { a : 5 } })
#eval checkRoundTrip (E.YAlt 5)
#eval checkToJson E.Z (json "Z")
#eval checkRoundTrip E.Z
inductive ERec
| mk : Nat → ERec
| W : ERec → ERec
deriving ToJson, FromJson, Repr, BEq
#eval checkToJson (ERec.W (ERec.mk 6)) (json { W : { mk : 6 }})
#eval checkRoundTrip (ERec.mk 7)
#eval checkRoundTrip (ERec.W (ERec.mk 8))
inductive ENest
| mk : Nat → ENest
| W : (Array ENest) → ENest
deriving ToJson, FromJson, Repr, BEq
#eval checkToJson (ENest.W #[ENest.mk 9]) (json { W : [{ mk : 9 }]})
#eval checkRoundTrip (ENest.mk 10)
#eval checkRoundTrip (ENest.W #[ENest.mk 11])
inductive EParam (α : Type)
| mk : α → EParam α
deriving ToJson, FromJson, Repr, BEq
#eval checkToJson (EParam.mk 12) (json { mk : 12 })
#eval checkToJson (EParam.mk "abcd") (json { mk : "abcd" })
#eval checkRoundTrip (EParam.mk 13)
#eval checkRoundTrip (EParam.mk "efgh")
|
ae37d9029674392ea6645eb5eeb3ac9e92b76cef | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/ring_theory/roots_of_unity_auto.lean | b1c0a267067d90b0ca6b5a0da1c6baefd42e0c51 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 22,263 | lean | /-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.nat.parity
import Mathlib.data.polynomial.ring_division
import Mathlib.group_theory.order_of_element
import Mathlib.ring_theory.integral_domain
import Mathlib.number_theory.divisors
import Mathlib.data.zmod.basic
import Mathlib.tactic.zify
import Mathlib.field_theory.separable
import Mathlib.field_theory.finite.basic
import Mathlib.PostPort
universes u_1 u_2 u_5 l u_3 u_4 u_7
namespace Mathlib
/-!
# Roots of unity and primitive roots of unity
We define roots of unity in the context of an arbitrary commutative monoid,
as a subgroup of the group of units. We also define a predicate `is_primitive_root` on commutative
monoids, expressing that an element is a primitive root of unity.
## Main definitions
* `roots_of_unity n M`, for `n : ℕ+` is the subgroup of the units of a commutative monoid `M`
consisting of elements `x` that satisfy `x ^ n = 1`.
* `is_primitive_root ζ k`: an element `ζ` is a primitive `k`-th root of unity if `ζ ^ k = 1`,
and if `l` satisfies `ζ ^ l = 1` then `k ∣ l`.
* `primitive_roots k R`: the finset of primitive `k`-th roots of unity in an integral domain `R`.
## Main results
* `roots_of_unity.is_cyclic`: the roots of unity in an integral domain form a cyclic group.
* `is_primitive_root.zmod_equiv_gpowers`: `zmod k` is equivalent to
the subgroup generated by a primitive `k`-th root of unity.
* `is_primitive_root.gpowers_eq`: in an integral domain, the subgroup generated by
a primitive `k`-th root of unity is equal to the `k`-th roots of unity.
* `is_primitive_root.card_primitive_roots`: if an integral domain
has a primitive `k`-th root of unity, then it has `φ k` of them.
## Implementation details
It is desirable that `roots_of_unity` is a subgroup,
and it will mainly be applied to rings (e.g. the ring of integers in a number field) and fields.
We therefore implement it as a subgroup of the units of a commutative monoid.
We have chosen to define `roots_of_unity n` for `n : ℕ+`, instead of `n : ℕ`,
because almost all lemmas need the positivity assumption,
and in particular the type class instances for `fintype` and `is_cyclic`.
On the other hand, for primitive roots of unity, it is desirable to have a predicate
not just on units, but directly on elements of the ring/field.
For example, we want to say that `exp (2 * pi * I / n)` is a primitive `n`-th root of unity
in the complex numbers, without having to turn that number into a unit first.
This creates a little bit of friction, but lemmas like `is_primitive_root.is_unit` and
`is_primitive_root.coe_units_iff` should provide the necessary glue.
-/
/-- `roots_of_unity k M` is the subgroup of elements `m : units M` that satisfy `m ^ k = 1` -/
def roots_of_unity (k : ℕ+) (M : Type u_1) [comm_monoid M] : subgroup (units M) :=
subgroup.mk (set_of fun (ζ : units M) => ζ ^ ↑k = 1) sorry sorry sorry
@[simp] theorem mem_roots_of_unity {M : Type u_1} [comm_monoid M] (k : ℕ+) (ζ : units M) :
ζ ∈ roots_of_unity k M ↔ ζ ^ ↑k = 1 :=
iff.rfl
theorem roots_of_unity_le_of_dvd {M : Type u_1} [comm_monoid M] {k : ℕ+} {l : ℕ+} (h : k ∣ l) :
roots_of_unity k M ≤ roots_of_unity l M :=
sorry
theorem map_roots_of_unity {M : Type u_1} {N : Type u_2} [comm_monoid M] [comm_monoid N]
(f : units M →* units N) (k : ℕ+) : subgroup.map f (roots_of_unity k M) ≤ roots_of_unity k N :=
sorry
theorem mem_roots_of_unity_iff_mem_nth_roots {R : Type u_5} [integral_domain R] {k : ℕ+}
{ζ : units R} : ζ ∈ roots_of_unity k R ↔ ↑ζ ∈ polynomial.nth_roots (↑k) 1 :=
sorry
/-- Equivalence between the `k`-th roots of unity in `R` and the `k`-th roots of `1`.
This is implemented as equivalence of subtypes,
because `roots_of_unity` is a subgroup of the group of units,
whereas `nth_roots` is a multiset. -/
def roots_of_unity_equiv_nth_roots (R : Type u_5) [integral_domain R] (k : ℕ+) :
↥(roots_of_unity k R) ≃ Subtype fun (x : R) => x ∈ polynomial.nth_roots (↑k) 1 :=
equiv.mk (fun (x : ↥(roots_of_unity k R)) => { val := ↑x, property := sorry })
(fun (x : Subtype fun (x : R) => x ∈ polynomial.nth_roots (↑k) 1) =>
{ val := units.mk (↑x) (↑x ^ (↑k - 1)) sorry sorry, property := sorry })
sorry sorry
@[simp] theorem roots_of_unity_equiv_nth_roots_apply {R : Type u_5} [integral_domain R] {k : ℕ+}
(x : ↥(roots_of_unity k R)) : ↑(coe_fn (roots_of_unity_equiv_nth_roots R k) x) = ↑x :=
rfl
@[simp] theorem roots_of_unity_equiv_nth_roots_symm_apply {R : Type u_5} [integral_domain R]
{k : ℕ+} (x : Subtype fun (x : R) => x ∈ polynomial.nth_roots (↑k) 1) :
↑(coe_fn (equiv.symm (roots_of_unity_equiv_nth_roots R k)) x) = ↑x :=
rfl
protected instance roots_of_unity.fintype (R : Type u_5) [integral_domain R] (k : ℕ+) :
fintype ↥(roots_of_unity k R) :=
fintype.of_equiv (Subtype fun (x : R) => x ∈ polynomial.nth_roots (↑k) 1)
(equiv.symm (roots_of_unity_equiv_nth_roots R k))
protected instance roots_of_unity.is_cyclic (R : Type u_5) [integral_domain R] (k : ℕ+) :
is_cyclic ↥(roots_of_unity k R) :=
is_cyclic_of_subgroup_integral_domain
(monoid_hom.comp (units.coe_hom R) (subgroup.subtype (roots_of_unity k R)))
(function.injective.comp units.ext subtype.val_injective)
theorem card_roots_of_unity (R : Type u_5) [integral_domain R] (k : ℕ+) :
fintype.card ↥(roots_of_unity k R) ≤ ↑k :=
sorry
/-- An element `ζ` is a primitive `k`-th root of unity if `ζ ^ k = 1`,
and if `l` satisfies `ζ ^ l = 1` then `k ∣ l`. -/
structure is_primitive_root {M : Type u_1} [comm_monoid M] (ζ : M) (k : ℕ) where
pow_eq_one : ζ ^ k = 1
dvd_of_pow_eq_one : ∀ (l : ℕ), ζ ^ l = 1 → k ∣ l
/-- `primitive_roots k R` is the finset of primitive `k`-th roots of unity
in the integral domain `R`. -/
def primitive_roots (k : ℕ) (R : Type u_1) [integral_domain R] : finset R :=
finset.filter (fun (ζ : R) => is_primitive_root ζ k)
(multiset.to_finset (polynomial.nth_roots k 1))
@[simp] theorem mem_primitive_roots {R : Type u_5} [integral_domain R] {k : ℕ} {ζ : R}
(h0 : 0 < k) : ζ ∈ primitive_roots k R ↔ is_primitive_root ζ k :=
sorry
namespace is_primitive_root
theorem iff_def {M : Type u_1} [comm_monoid M] (ζ : M) (k : ℕ) :
is_primitive_root ζ k ↔ ζ ^ k = 1 ∧ ∀ (l : ℕ), ζ ^ l = 1 → k ∣ l :=
sorry
theorem mk_of_lt {M : Type u_1} [comm_monoid M] {k : ℕ} (ζ : M) (hk : 0 < k) (h1 : ζ ^ k = 1)
(h : ∀ (l : ℕ), 0 < l → l < k → ζ ^ l ≠ 1) : is_primitive_root ζ k :=
sorry
theorem pow_eq_one_iff_dvd {M : Type u_1} [comm_monoid M] {k : ℕ} {ζ : M}
(h : is_primitive_root ζ k) (l : ℕ) : ζ ^ l = 1 ↔ k ∣ l :=
sorry
theorem is_unit {M : Type u_1} [comm_monoid M] {k : ℕ} {ζ : M} (h : is_primitive_root ζ k)
(h0 : 0 < k) : is_unit ζ :=
sorry
theorem pow_ne_one_of_pos_of_lt {M : Type u_1} [comm_monoid M] {k : ℕ} {l : ℕ} {ζ : M}
(h : is_primitive_root ζ k) (h0 : 0 < l) (hl : l < k) : ζ ^ l ≠ 1 :=
mt (nat.le_of_dvd h0 ∘ dvd_of_pow_eq_one h l) (not_le_of_lt hl)
theorem pow_inj {M : Type u_1} [comm_monoid M] {k : ℕ} {ζ : M} (h : is_primitive_root ζ k) {i : ℕ}
{j : ℕ} (hi : i < k) (hj : j < k) (H : ζ ^ i = ζ ^ j) : i = j :=
sorry
theorem one {M : Type u_1} [comm_monoid M] : is_primitive_root 1 1 :=
mk (pow_one 1) fun (l : ℕ) (hl : 1 ^ l = 1) => one_dvd l
@[simp] theorem one_right_iff {M : Type u_1} [comm_monoid M] {ζ : M} :
is_primitive_root ζ 1 ↔ ζ = 1 :=
sorry
@[simp] theorem coe_units_iff {M : Type u_1} [comm_monoid M] {k : ℕ} {ζ : units M} :
is_primitive_root (↑ζ) k ↔ is_primitive_root ζ k :=
sorry
theorem pow_of_coprime {M : Type u_1} [comm_monoid M] {k : ℕ} {ζ : M} (h : is_primitive_root ζ k)
(i : ℕ) (hi : nat.coprime i k) : is_primitive_root (ζ ^ i) k :=
sorry
theorem pow_of_prime {M : Type u_1} [comm_monoid M] {k : ℕ} {ζ : M} (h : is_primitive_root ζ k)
{p : ℕ} (hprime : nat.prime p) (hdiv : ¬p ∣ k) : is_primitive_root (ζ ^ p) k :=
pow_of_coprime h p (iff.mpr (nat.prime.coprime_iff_not_dvd hprime) hdiv)
theorem pow_iff_coprime {M : Type u_1} [comm_monoid M] {k : ℕ} {ζ : M} (h : is_primitive_root ζ k)
(h0 : 0 < k) (i : ℕ) : is_primitive_root (ζ ^ i) k ↔ nat.coprime i k :=
sorry
theorem gpow_eq_one {G : Type u_3} [comm_group G] {k : ℕ} {ζ : G} (h : is_primitive_root ζ k) :
ζ ^ ↑k = 1 :=
pow_eq_one h
theorem gpow_eq_one_iff_dvd {G : Type u_3} [comm_group G] {k : ℕ} {ζ : G}
(h : is_primitive_root ζ k) (l : ℤ) : ζ ^ l = 1 ↔ ↑k ∣ l :=
sorry
theorem inv {G : Type u_3} [comm_group G] {k : ℕ} {ζ : G} (h : is_primitive_root ζ k) :
is_primitive_root (ζ⁻¹) k :=
sorry
@[simp] theorem inv_iff {G : Type u_3} [comm_group G] {k : ℕ} {ζ : G} :
is_primitive_root (ζ⁻¹) k ↔ is_primitive_root ζ k :=
sorry
theorem gpow_of_gcd_eq_one {G : Type u_3} [comm_group G] {k : ℕ} {ζ : G} (h : is_primitive_root ζ k)
(i : ℤ) (hi : int.gcd i ↑k = 1) : is_primitive_root (ζ ^ i) k :=
sorry
@[simp] theorem coe_subgroup_iff {G : Type u_3} [comm_group G] {k : ℕ} (H : subgroup G) {ζ : ↥H} :
is_primitive_root (↑ζ) k ↔ is_primitive_root ζ k :=
sorry
theorem fpow_eq_one {G₀ : Type u_4} [comm_group_with_zero G₀] {k : ℕ} {ζ : G₀}
(h : is_primitive_root ζ k) : ζ ^ ↑k = 1 :=
pow_eq_one h
theorem fpow_eq_one_iff_dvd {G₀ : Type u_4} [comm_group_with_zero G₀] {k : ℕ} {ζ : G₀}
(h : is_primitive_root ζ k) (l : ℤ) : ζ ^ l = 1 ↔ ↑k ∣ l :=
sorry
theorem inv' {G₀ : Type u_4} [comm_group_with_zero G₀] {k : ℕ} {ζ : G₀}
(h : is_primitive_root ζ k) : is_primitive_root (ζ⁻¹) k :=
sorry
@[simp] theorem inv_iff' {G₀ : Type u_4} [comm_group_with_zero G₀] {k : ℕ} {ζ : G₀} :
is_primitive_root (ζ⁻¹) k ↔ is_primitive_root ζ k :=
sorry
theorem fpow_of_gcd_eq_one {G₀ : Type u_4} [comm_group_with_zero G₀] {k : ℕ} {ζ : G₀}
(h : is_primitive_root ζ k) (i : ℤ) (hi : int.gcd i ↑k = 1) : is_primitive_root (ζ ^ i) k :=
sorry
@[simp] theorem primitive_roots_zero {R : Type u_5} [integral_domain R] : primitive_roots 0 R = ∅ :=
sorry
@[simp] theorem primitive_roots_one {R : Type u_5} [integral_domain R] :
primitive_roots 1 R = singleton 1 :=
sorry
theorem neg_one {R : Type u_5} [integral_domain R] (p : ℕ) [char_p R p] (hp : p ≠ bit0 1) :
is_primitive_root (-1) (bit0 1) :=
sorry
theorem eq_neg_one_of_two_right {R : Type u_5} [integral_domain R] {ζ : R}
(h : is_primitive_root ζ (bit0 1)) : ζ = -1 :=
sorry
protected theorem mem_roots_of_unity {R : Type u_5} [integral_domain R] {ζ : units R} {n : ℕ+}
(h : is_primitive_root ζ ↑n) : ζ ∈ roots_of_unity n R :=
pow_eq_one h
/-- The (additive) monoid equivalence between `zmod k`
and the powers of a primitive root of unity `ζ`. -/
def zmod_equiv_gpowers {R : Type u_5} [integral_domain R] {k : ℕ} {ζ : units R}
(h : is_primitive_root ζ k) : zmod k ≃+ additive ↥(subgroup.gpowers ζ) :=
add_equiv.of_bijective
(add_monoid_hom.lift_of_surjective (int.cast_add_hom (zmod k)) zmod.int_cast_surjective
(add_monoid_hom.mk (fun (i : ℤ) => coe_fn additive.of_mul { val := ζ ^ i, property := sorry })
sorry sorry)
sorry)
sorry
@[simp] theorem zmod_equiv_gpowers_apply_coe_int {R : Type u_5} [integral_domain R] {k : ℕ}
{ζ : units R} (h : is_primitive_root ζ k) (i : ℤ) :
coe_fn (zmod_equiv_gpowers h) ↑i =
coe_fn additive.of_mul { val := ζ ^ i, property := Exists.intro i rfl } :=
sorry
@[simp] theorem zmod_equiv_gpowers_apply_coe_nat {R : Type u_5} [integral_domain R] {k : ℕ}
{ζ : units R} (h : is_primitive_root ζ k) (i : ℕ) :
coe_fn (zmod_equiv_gpowers h) ↑i =
coe_fn additive.of_mul { val := ζ ^ i, property := Exists.intro (↑i) rfl } :=
sorry
@[simp] theorem zmod_equiv_gpowers_symm_apply_gpow {R : Type u_5} [integral_domain R] {k : ℕ}
{ζ : units R} (h : is_primitive_root ζ k) (i : ℤ) :
coe_fn (add_equiv.symm (zmod_equiv_gpowers h))
(coe_fn additive.of_mul { val := ζ ^ i, property := Exists.intro i rfl }) =
↑i :=
sorry
@[simp] theorem zmod_equiv_gpowers_symm_apply_gpow' {R : Type u_5} [integral_domain R] {k : ℕ}
{ζ : units R} (h : is_primitive_root ζ k) (i : ℤ) :
coe_fn (add_equiv.symm (zmod_equiv_gpowers h))
{ val := ζ ^ i, property := Exists.intro i rfl } =
↑i :=
zmod_equiv_gpowers_symm_apply_gpow h i
@[simp] theorem zmod_equiv_gpowers_symm_apply_pow {R : Type u_5} [integral_domain R] {k : ℕ}
{ζ : units R} (h : is_primitive_root ζ k) (i : ℕ) :
coe_fn (add_equiv.symm (zmod_equiv_gpowers h))
(coe_fn additive.of_mul { val := ζ ^ i, property := Exists.intro (↑i) rfl }) =
↑i :=
sorry
@[simp] theorem zmod_equiv_gpowers_symm_apply_pow' {R : Type u_5} [integral_domain R] {k : ℕ}
{ζ : units R} (h : is_primitive_root ζ k) (i : ℕ) :
coe_fn (add_equiv.symm (zmod_equiv_gpowers h))
{ val := ζ ^ i, property := Exists.intro (↑i) rfl } =
↑i :=
zmod_equiv_gpowers_symm_apply_pow h i
theorem gpowers_eq {R : Type u_5} [integral_domain R] {k : ℕ+} {ζ : units R}
(h : is_primitive_root ζ ↑k) : subgroup.gpowers ζ = roots_of_unity k R :=
sorry
theorem eq_pow_of_mem_roots_of_unity {R : Type u_5} [integral_domain R] {k : ℕ+} {ζ : units R}
{ξ : units R} (h : is_primitive_root ζ ↑k) (hξ : ξ ∈ roots_of_unity k R) :
∃ (i : ℕ), ∃ (hi : i < ↑k), ζ ^ i = ξ :=
sorry
theorem eq_pow_of_pow_eq_one {R : Type u_5} [integral_domain R] {k : ℕ} {ζ : R} {ξ : R}
(h : is_primitive_root ζ k) (hξ : ξ ^ k = 1) (h0 : 0 < k) :
∃ (i : ℕ), ∃ (H : i < k), ζ ^ i = ξ :=
sorry
theorem is_primitive_root_iff' {R : Type u_5} [integral_domain R] {k : ℕ+} {ζ : units R}
{ξ : units R} (h : is_primitive_root ζ ↑k) :
is_primitive_root ξ ↑k ↔ ∃ (i : ℕ), ∃ (H : i < ↑k), ∃ (hi : nat.coprime i ↑k), ζ ^ i = ξ :=
sorry
theorem is_primitive_root_iff {R : Type u_5} [integral_domain R] {k : ℕ} {ζ : R} {ξ : R}
(h : is_primitive_root ζ k) (h0 : 0 < k) :
is_primitive_root ξ k ↔ ∃ (i : ℕ), ∃ (H : i < k), ∃ (hi : nat.coprime i k), ζ ^ i = ξ :=
sorry
theorem card_roots_of_unity' {R : Type u_5} [integral_domain R] {ζ : units R} {n : ℕ+}
(h : is_primitive_root ζ ↑n) : fintype.card ↥(roots_of_unity n R) = ↑n :=
sorry
theorem card_roots_of_unity {R : Type u_5} [integral_domain R] {ζ : R} {n : ℕ+}
(h : is_primitive_root ζ ↑n) : fintype.card ↥(roots_of_unity n R) = ↑n :=
sorry
/-- The cardinality of the multiset `nth_roots ↑n (1 : R)` is `n`
if there is a primitive root of unity in `R`. -/
theorem card_nth_roots {R : Type u_5} [integral_domain R] {ζ : R} {n : ℕ}
(h : is_primitive_root ζ n) : coe_fn multiset.card (polynomial.nth_roots n 1) = n :=
sorry
/-- The multiset `nth_roots ↑n (1 : R)` has no repeated elements
if there is a primitive root of unity in `R`. -/
theorem nth_roots_nodup {R : Type u_5} [integral_domain R] {ζ : R} {n : ℕ}
(h : is_primitive_root ζ n) : multiset.nodup (polynomial.nth_roots n 1) :=
sorry
@[simp] theorem card_nth_roots_finset {R : Type u_5} [integral_domain R] {ζ : R} {n : ℕ}
(h : is_primitive_root ζ n) : finset.card (polynomial.nth_roots_finset n R) = n :=
sorry
/-- If an integral domain has a primitive `k`-th root of unity, then it has `φ k` of them. -/
theorem card_primitive_roots {R : Type u_5} [integral_domain R] {ζ : R} {k : ℕ}
(h : is_primitive_root ζ k) (h0 : 0 < k) : finset.card (primitive_roots k R) = nat.totient k :=
sorry
/-- The sets `primitive_roots k R` are pairwise disjoint. -/
theorem disjoint {R : Type u_5} [integral_domain R] {k : ℕ} {l : ℕ} (hk : 0 < k) (hl : 0 < l)
(h : k ≠ l) : disjoint (primitive_roots k R) (primitive_roots l R) :=
sorry
/-- If there is a `n`-th primitive root of unity in `R` and `b` divides `n`,
then there is a `b`-th primitive root of unity in `R`. -/
theorem pow {R : Type u_5} [integral_domain R] {ζ : R} {n : ℕ} {a : ℕ} {b : ℕ} (hn : 0 < n)
(h : is_primitive_root ζ n) (hprod : n = a * b) : is_primitive_root (ζ ^ a) b :=
sorry
/-- `nth_roots n` as a `finset` is equal to the union of `primitive_roots i R` for `i ∣ n`
if there is a primitive root of unity in `R`. -/
theorem nth_roots_one_eq_bUnion_primitive_roots' {R : Type u_5} [integral_domain R] {ζ : R} {n : ℕ+}
(h : is_primitive_root ζ ↑n) :
polynomial.nth_roots_finset (↑n) R =
finset.bUnion (nat.divisors ↑n) fun (i : ℕ) => primitive_roots i R :=
sorry
/-- `nth_roots n` as a `finset` is equal to the union of `primitive_roots i R` for `i ∣ n`
if there is a primitive root of unity in `R`. -/
theorem nth_roots_one_eq_bUnion_primitive_roots {R : Type u_5} [integral_domain R] {ζ : R} {n : ℕ}
(hpos : 0 < n) (h : is_primitive_root ζ n) :
polynomial.nth_roots_finset n R =
finset.bUnion (nat.divisors n) fun (i : ℕ) => primitive_roots i R :=
nth_roots_one_eq_bUnion_primitive_roots' h
/--`μ` is integral over `ℤ`. -/
theorem is_integral {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) : is_integral ℤ μ :=
sorry
/--The minimal polynomial of a root of unity `μ` divides `X ^ n - 1`. -/
theorem minpoly_dvd_X_pow_sub_one {n : ℕ} {K : Type u_7} [field K] {μ : K}
(h : is_primitive_root μ n) (hpos : 0 < n) [char_zero K] : minpoly ℤ μ ∣ polynomial.X ^ n - 1 :=
sorry
/-- The reduction modulo `p` of the minimal polynomial of a root of unity `μ` is separable. -/
theorem separable_minpoly_mod {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] {p : ℕ} [fact (nat.prime p)] (hdiv : ¬p ∣ n) :
polynomial.separable (polynomial.map (int.cast_ring_hom (zmod p)) (minpoly ℤ μ)) :=
sorry
/-- The reduction modulo `p` of the minimal polynomial of a root of unity `μ` is squarefree. -/
theorem squarefree_minpoly_mod {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] {p : ℕ} [fact (nat.prime p)] (hdiv : ¬p ∣ n) :
squarefree (polynomial.map (int.cast_ring_hom (zmod p)) (minpoly ℤ μ)) :=
polynomial.separable.squarefree (separable_minpoly_mod h hpos hdiv)
/- Let `P` be the minimal polynomial of a root of unity `μ` and `Q` be the minimal polynomial of
`μ ^ p`, where `p` is a prime that does not divide `n`. Then `P` divides `expand ℤ p Q`. -/
theorem minpoly_dvd_expand {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] {p : ℕ} (hprime : nat.prime p) (hdiv : ¬p ∣ n) :
minpoly ℤ μ ∣ coe_fn (polynomial.expand ℤ p) (minpoly ℤ (μ ^ p)) :=
sorry
/- Let `P` be the minimal polynomial of a root of unity `μ` and `Q` be the minimal polynomial of
`μ ^ p`, where `p` is a prime that does not divide `n`. Then `P` divides `Q ^ p` modulo `p`. -/
theorem minpoly_dvd_pow_mod {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] {p : ℕ} [hprime : fact (nat.prime p)] (hdiv : ¬p ∣ n) :
polynomial.map (int.cast_ring_hom (zmod p)) (minpoly ℤ μ) ∣
polynomial.map (int.cast_ring_hom (zmod p)) (minpoly ℤ (μ ^ p)) ^ p :=
sorry
/- Let `P` be the minimal polynomial of a root of unity `μ` and `Q` be the minimal polynomial of
`μ ^ p`, where `p` is a prime that does not divide `n`. Then `P` divides `Q` modulo `p`. -/
theorem minpoly_dvd_mod_p {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] {p : ℕ} [hprime : fact (nat.prime p)] (hdiv : ¬p ∣ n) :
polynomial.map (int.cast_ring_hom (zmod p)) (minpoly ℤ μ) ∣
polynomial.map (int.cast_ring_hom (zmod p)) (minpoly ℤ (μ ^ p)) :=
sorry
/-- If `p` is a prime that does not divide `n`,
then the minimal polynomials of a primitive `n`-th root of unity `μ`
and of `μ ^ p` are the same. -/
theorem minpoly_eq_pow {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] {p : ℕ} [hprime : fact (nat.prime p)] (hdiv : ¬p ∣ n) :
minpoly ℤ μ = minpoly ℤ (μ ^ p) :=
sorry
/-- If `m : ℕ` is coprime with `n`,
then the minimal polynomials of a primitive `n`-th root of unity `μ`
and of `μ ^ m` are the same. -/
theorem minpoly_eq_pow_coprime {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] {m : ℕ} (hcop : nat.coprime m n) :
minpoly ℤ μ = minpoly ℤ (μ ^ m) :=
sorry
/-- If `m : ℕ` is coprime with `n`,
then the minimal polynomial of a primitive `n`-th root of unity `μ`
has `μ ^ m` as root. -/
theorem pow_is_root_minpoly {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] {m : ℕ} (hcop : nat.coprime m n) :
polynomial.is_root (polynomial.map (int.cast_ring_hom K) (minpoly ℤ μ)) (μ ^ m) :=
sorry
/-- `primitive_roots n K` is a subset of the roots of the minimal polynomial of a primitive
`n`-th root of unity `μ`. -/
theorem is_roots_of_minpoly {n : ℕ} {K : Type u_7} [field K] {μ : K} (h : is_primitive_root μ n)
(hpos : 0 < n) [char_zero K] :
primitive_roots n K ⊆
multiset.to_finset
(polynomial.roots (polynomial.map (int.cast_ring_hom K) (minpoly ℤ μ))) :=
sorry
/-- The degree of the minimal polynomial of `μ` is at least `totient n`. -/
theorem totient_le_degree_minpoly {n : ℕ} {K : Type u_7} [field K] {μ : K}
(h : is_primitive_root μ n) (hpos : 0 < n) [char_zero K] :
nat.totient n ≤ polynomial.nat_degree (minpoly ℤ μ) :=
sorry
end Mathlib |
1c4320c9c119837f9a8a5e0d50424c85fe38918d | f3849be5d845a1cb97680f0bbbe03b85518312f0 | /library/init/category/alternative.lean | c5e313c0a333f04dac1a45029ea32c7562e4bbf1 | [
"Apache-2.0"
] | permissive | bjoeris/lean | 0ed95125d762b17bfcb54dad1f9721f953f92eeb | 4e496b78d5e73545fa4f9a807155113d8e6b0561 | refs/heads/master | 1,611,251,218,281 | 1,495,337,658,000 | 1,495,337,658,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,115 | lean | /-
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
-/
prelude
import init.logic init.category.applicative
universes u v
class has_orelse (f : Type u → Type v) : Type (max u+1 v) :=
(orelse : Π {α : Type u}, f α → f α → f α)
infixr ` <|> `:2 := has_orelse.orelse
class alternative (f : Type u → Type v) extends applicative f, has_orelse f : Type (max u+1 v) :=
(failure : Π {α : Type u}, f α)
section
variables {f : Type u → Type v} [alternative f] {α : Type u}
@[inline] def failure : f α :=
alternative.failure f
@[inline] def guard {f : Type → Type v} [alternative f] (p : Prop) [decidable p] : f unit :=
if p then pure () else failure
/- Later we define a coercion from bool to Prop, but this version will still be useful.
Given (t : tactic bool), we can write t >>= guardb -/
@[inline] def guardb {f : Type → Type v} [alternative f] : bool → f unit
| tt := pure ()
| ff := failure
@[inline] def optional (x : f α) : f (option α) :=
some <$> x <|> pure none
end
|
b7ba1f08c5679a7cbeb687765cd3aa013e646ea5 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/order/category/FinBoolAlg.lean | a6a1960a6ed5dfd4855e893b3481859a32291e4b | [
"Apache-2.0"
] | permissive | Vierkantor/mathlib | 0ea59ac32a3a43c93c44d70f441c4ee810ccceca | 83bc3b9ce9b13910b57bda6b56222495ebd31c2f | refs/heads/master | 1,658,323,012,449 | 1,652,256,003,000 | 1,652,256,003,000 | 209,296,341 | 0 | 1 | Apache-2.0 | 1,568,807,655,000 | 1,568,807,655,000 | null | UTF-8 | Lean | false | false | 3,564 | lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import order.category.BoolAlg
import order.category.FinPartialOrder
import order.hom.complete_lattice
/-!
# The category of finite boolean algebras
This file defines `FinBoolAlg`, the category of finite boolean algebras.
## TODO
Birkhoff's representation for finite Boolean algebras.
`Fintype_to_FinBoolAlg_op.left_op ⋙ FinBoolAlg.dual ≅ Fintype_to_FinBoolAlg_op.left_op`
`FinBoolAlg` is essentially small.
-/
universes u
open category_theory order_dual opposite
/-- The category of finite boolean algebras with bounded lattice morphisms. -/
structure FinBoolAlg :=
(to_BoolAlg : BoolAlg)
[is_fintype : fintype to_BoolAlg]
namespace FinBoolAlg
instance : has_coe_to_sort FinBoolAlg Type* := ⟨λ X, X.to_BoolAlg⟩
instance (X : FinBoolAlg) : boolean_algebra X := X.to_BoolAlg.str
attribute [instance] FinBoolAlg.is_fintype
@[simp] lemma coe_to_BoolAlg (X : FinBoolAlg) : ↥X.to_BoolAlg = ↥X := rfl
/-- Construct a bundled `FinBoolAlg` from `boolean_algebra` + `fintype`. -/
def of (α : Type*) [boolean_algebra α] [fintype α] : FinBoolAlg := ⟨⟨α⟩⟩
@[simp] lemma coe_of (α : Type*) [boolean_algebra α] [fintype α] : ↥(of α) = α := rfl
instance : inhabited FinBoolAlg := ⟨of punit⟩
instance large_category : large_category FinBoolAlg :=
induced_category.category FinBoolAlg.to_BoolAlg
instance concrete_category : concrete_category FinBoolAlg :=
induced_category.concrete_category FinBoolAlg.to_BoolAlg
instance has_forget_to_BoolAlg : has_forget₂ FinBoolAlg BoolAlg :=
induced_category.has_forget₂ FinBoolAlg.to_BoolAlg
instance forget_to_BoolAlg_full : full (forget₂ FinBoolAlg BoolAlg) := induced_category.full _
instance forget_to_BoolAlg_faithful : faithful (forget₂ FinBoolAlg BoolAlg) :=
induced_category.faithful _
@[simps] instance has_forget_to_FinPartialOrder : has_forget₂ FinBoolAlg FinPartialOrder :=
{ forget₂ := { obj := λ X, FinPartialOrder.of X, map := λ X Y f,
show order_hom X Y, from ↑(show bounded_lattice_hom X Y, from f) } }
instance forget_to_FinPartialOrder_faithful : faithful (forget₂ FinBoolAlg FinPartialOrder) :=
⟨λ X Y f g h, by { have := congr_arg (coe_fn : _ → X → Y) h, exact fun_like.coe_injective this }⟩
/-- Constructs an equivalence between finite Boolean algebras from an order isomorphism between
them. -/
@[simps] def iso.mk {α β : FinBoolAlg.{u}} (e : α ≃o β) : α ≅ β :=
{ hom := (e : bounded_lattice_hom α β),
inv := (e.symm : bounded_lattice_hom β α),
hom_inv_id' := by { ext, exact e.symm_apply_apply _ },
inv_hom_id' := by { ext, exact e.apply_symm_apply _ } }
/-- `order_dual` as a functor. -/
@[simps] def dual : FinBoolAlg ⥤ FinBoolAlg :=
{ obj := λ X, of Xᵒᵈ, map := λ X Y, bounded_lattice_hom.dual }
/-- The equivalence between `FinBoolAlg` and itself induced by `order_dual` both ways. -/
@[simps functor inverse] def dual_equiv : FinBoolAlg ≌ FinBoolAlg :=
equivalence.mk dual dual
(nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)
(nat_iso.of_components (λ X, iso.mk $ order_iso.dual_dual X) $ λ X Y f, rfl)
end FinBoolAlg
/-- The powerset functor. `set` as a functor. -/
@[simps] def Fintype_to_FinBoolAlg_op : Fintype ⥤ FinBoolAlgᵒᵖ :=
{ obj := λ X, op $ FinBoolAlg.of (set X),
map := λ X Y f, quiver.hom.op $
(complete_lattice_hom.set_preimage f : bounded_lattice_hom (set Y) (set X)) }
|
859aef56855569187a05a55965d5f7d4209843e4 | 367134ba5a65885e863bdc4507601606690974c1 | /src/data/matrix/basic.lean | 48d050229e9f322eca074efc339b5e29dd79ba89 | [
"Apache-2.0"
] | permissive | kodyvajjha/mathlib | 9bead00e90f68269a313f45f5561766cfd8d5cad | b98af5dd79e13a38d84438b850a2e8858ec21284 | refs/heads/master | 1,624,350,366,310 | 1,615,563,062,000 | 1,615,563,062,000 | 162,666,963 | 0 | 0 | Apache-2.0 | 1,545,367,651,000 | 1,545,367,651,000 | null | UTF-8 | Lean | false | false | 44,361 | lean | /-
Copyright (c) 2018 Ellen Arlt. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin
-/
import algebra.big_operators.pi
import algebra.module.pi
import algebra.module.linear_map
import algebra.big_operators.ring
import algebra.star.basic
import data.equiv.ring
import data.fintype.card
/-!
# Matrices
-/
universes u u' v w
open_locale big_operators
/-- `matrix m n` is the type of matrices whose rows are indexed by the fintype `m`
and whose columns are indexed by the fintype `n`. -/
@[nolint unused_arguments]
def matrix (m : Type u) (n : Type u') [fintype m] [fintype n] (α : Type v) : Type (max u u' v) :=
m → n → α
variables {l m n o : Type*} [fintype l] [fintype m] [fintype n] [fintype o]
variables {α : Type v}
namespace matrix
section ext
variables {M N : matrix m n α}
theorem ext_iff : (∀ i j, M i j = N i j) ↔ M = N :=
⟨λ h, funext $ λ i, funext $ h i, λ h, by simp [h]⟩
@[ext] theorem ext : (∀ i j, M i j = N i j) → M = N :=
ext_iff.mp
end ext
/-- `M.map f` is the matrix obtained by applying `f` to each entry of the matrix `M`. -/
def map (M : matrix m n α) {β : Type w} (f : α → β) : matrix m n β := λ i j, f (M i j)
@[simp]
lemma map_apply {M : matrix m n α} {β : Type w} {f : α → β} {i : m} {j : n} :
M.map f i j = f (M i j) := rfl
@[simp]
lemma map_map {M : matrix m n α} {β γ : Type*} {f : α → β} {g : β → γ} :
(M.map f).map g = M.map (g ∘ f) :=
by { ext, simp, }
/-- The transpose of a matrix. -/
def transpose (M : matrix m n α) : matrix n m α
| x y := M y x
localized "postfix `ᵀ`:1500 := matrix.transpose" in matrix
/-- `matrix.col u` is the column matrix whose entries are given by `u`. -/
def col (w : m → α) : matrix m unit α
| x y := w x
/-- `matrix.row u` is the row matrix whose entries are given by `u`. -/
def row (v : n → α) : matrix unit n α
| x y := v y
instance [inhabited α] : inhabited (matrix m n α) := pi.inhabited _
instance [has_add α] : has_add (matrix m n α) := pi.has_add
instance [add_semigroup α] : add_semigroup (matrix m n α) := pi.add_semigroup
instance [add_comm_semigroup α] : add_comm_semigroup (matrix m n α) := pi.add_comm_semigroup
instance [has_zero α] : has_zero (matrix m n α) := pi.has_zero
instance [add_monoid α] : add_monoid (matrix m n α) := pi.add_monoid
instance [add_comm_monoid α] : add_comm_monoid (matrix m n α) := pi.add_comm_monoid
instance [has_neg α] : has_neg (matrix m n α) := pi.has_neg
instance [has_sub α] : has_sub (matrix m n α) := pi.has_sub
instance [add_group α] : add_group (matrix m n α) := pi.add_group
instance [add_comm_group α] : add_comm_group (matrix m n α) := pi.add_comm_group
instance [unique α] : unique (matrix m n α) := pi.unique
instance [subsingleton α] : subsingleton (matrix m n α) := pi.subsingleton
instance [nonempty m] [nonempty n] [nontrivial α] : nontrivial (matrix m n α) :=
function.nontrivial
@[simp] theorem zero_apply [has_zero α] (i j) : (0 : matrix m n α) i j = 0 := rfl
@[simp] theorem neg_apply [has_neg α] (M : matrix m n α) (i j) : (- M) i j = - M i j := rfl
@[simp] theorem add_apply [has_add α] (M N : matrix m n α) (i j) :
(M + N) i j = M i j + N i j :=
rfl
@[simp] theorem sub_apply [has_sub α] (M N : matrix m n α) (i j) :
(M - N) i j = M i j - N i j :=
rfl
@[simp] lemma map_zero [has_zero α] {β : Type w} [has_zero β] {f : α → β} (h : f 0 = 0) :
(0 : matrix m n α).map f = 0 :=
by { ext, simp [h], }
lemma map_add [add_monoid α] {β : Type w} [add_monoid β] (f : α →+ β)
(M N : matrix m n α) : (M + N).map f = M.map f + N.map f :=
by { ext, simp, }
lemma map_sub [add_group α] {β : Type w} [add_group β] (f : α →+ β)
(M N : matrix m n α) : (M - N).map f = M.map f - N.map f :=
by { ext, simp }
lemma subsingleton_of_empty_left (hm : ¬ nonempty m) : subsingleton (matrix m n α) :=
⟨λ M N, by { ext, contrapose! hm, use i }⟩
lemma subsingleton_of_empty_right (hn : ¬ nonempty n) : subsingleton (matrix m n α) :=
⟨λ M N, by { ext, contrapose! hn, use j }⟩
end matrix
/-- The `add_monoid_hom` between spaces of matrices induced by an `add_monoid_hom` between their
coefficients. -/
def add_monoid_hom.map_matrix [add_monoid α] {β : Type w} [add_monoid β] (f : α →+ β) :
matrix m n α →+ matrix m n β :=
{ to_fun := λ M, M.map f,
map_zero' := by simp,
map_add' := matrix.map_add f, }
@[simp] lemma add_monoid_hom.map_matrix_apply [add_monoid α] {β : Type w} [add_monoid β]
(f : α →+ β) (M : matrix m n α) : f.map_matrix M = M.map f := rfl
open_locale matrix
namespace matrix
section diagonal
variables [decidable_eq n]
/-- `diagonal d` is the square matrix such that `(diagonal d) i i = d i` and `(diagonal d) i j = 0`
if `i ≠ j`. -/
def diagonal [has_zero α] (d : n → α) : matrix n n α := λ i j, if i = j then d i else 0
@[simp] theorem diagonal_apply_eq [has_zero α] {d : n → α} (i : n) : (diagonal d) i i = d i :=
by simp [diagonal]
@[simp] theorem diagonal_apply_ne [has_zero α] {d : n → α} {i j : n} (h : i ≠ j) :
(diagonal d) i j = 0 := by simp [diagonal, h]
theorem diagonal_apply_ne' [has_zero α] {d : n → α} {i j : n} (h : j ≠ i) :
(diagonal d) i j = 0 := diagonal_apply_ne h.symm
@[simp] theorem diagonal_zero [has_zero α] : (diagonal (λ _, 0) : matrix n n α) = 0 :=
by simp [diagonal]; refl
@[simp] lemma diagonal_transpose [has_zero α] (v : n → α) :
(diagonal v)ᵀ = diagonal v :=
begin
ext i j,
by_cases h : i = j,
{ simp [h, transpose] },
{ simp [h, transpose, diagonal_apply_ne' h] }
end
@[simp] theorem diagonal_add [add_monoid α] (d₁ d₂ : n → α) :
diagonal d₁ + diagonal d₂ = diagonal (λ i, d₁ i + d₂ i) :=
by ext i j; by_cases h : i = j; simp [h]
@[simp] lemma diagonal_map {β : Type w} [has_zero α] [has_zero β]
{f : α → β} (h : f 0 = 0) {d : n → α} :
(diagonal d).map f = diagonal (λ m, f (d m)) :=
by { ext, simp only [diagonal, map_apply], split_ifs; simp [h], }
section one
variables [has_zero α] [has_one α]
instance : has_one (matrix n n α) := ⟨diagonal (λ _, 1)⟩
@[simp] theorem diagonal_one : (diagonal (λ _, 1) : matrix n n α) = 1 := rfl
theorem one_apply {i j} : (1 : matrix n n α) i j = if i = j then 1 else 0 := rfl
@[simp] theorem one_apply_eq (i) : (1 : matrix n n α) i i = 1 := diagonal_apply_eq i
@[simp] theorem one_apply_ne {i j} : i ≠ j → (1 : matrix n n α) i j = 0 :=
diagonal_apply_ne
theorem one_apply_ne' {i j} : j ≠ i → (1 : matrix n n α) i j = 0 :=
diagonal_apply_ne'
@[simp] lemma one_map {β : Type w} [has_zero β] [has_one β]
{f : α → β} (h₀ : f 0 = 0) (h₁ : f 1 = 1) :
(1 : matrix n n α).map f = (1 : matrix n n β) :=
by { ext, simp only [one_apply, map_apply], split_ifs; simp [h₀, h₁], }
end one
section numeral
@[simp] lemma bit0_apply [has_add α] (M : matrix m m α) (i : m) (j : m) :
(bit0 M) i j = bit0 (M i j) := rfl
variables [add_monoid α] [has_one α]
lemma bit1_apply (M : matrix n n α) (i : n) (j : n) :
(bit1 M) i j = if i = j then bit1 (M i j) else bit0 (M i j) :=
by dsimp [bit1]; by_cases h : i = j; simp [h]
@[simp]
lemma bit1_apply_eq (M : matrix n n α) (i : n) :
(bit1 M) i i = bit1 (M i i) :=
by simp [bit1_apply]
@[simp]
lemma bit1_apply_ne (M : matrix n n α) {i j : n} (h : i ≠ j) :
(bit1 M) i j = bit0 (M i j) :=
by simp [bit1_apply, h]
end numeral
end diagonal
section dot_product
/-- `dot_product v w` is the sum of the entrywise products `v i * w i` -/
def dot_product [has_mul α] [add_comm_monoid α] (v w : m → α) : α :=
∑ i, v i * w i
lemma dot_product_assoc [semiring α] (u : m → α) (v : m → n → α) (w : n → α) :
dot_product (λ j, dot_product u (λ i, v i j)) w = dot_product u (λ i, dot_product (v i) w) :=
by simpa [dot_product, finset.mul_sum, finset.sum_mul, mul_assoc] using finset.sum_comm
lemma dot_product_comm [comm_semiring α] (v w : m → α) :
dot_product v w = dot_product w v :=
by simp_rw [dot_product, mul_comm]
@[simp] lemma dot_product_punit [add_comm_monoid α] [has_mul α] (v w : punit → α) :
dot_product v w = v ⟨⟩ * w ⟨⟩ :=
by simp [dot_product]
@[simp] lemma dot_product_zero [semiring α] (v : m → α) : dot_product v 0 = 0 :=
by simp [dot_product]
@[simp] lemma dot_product_zero' [semiring α] (v : m → α) : dot_product v (λ _, 0) = 0 :=
dot_product_zero v
@[simp] lemma zero_dot_product [semiring α] (v : m → α) : dot_product 0 v = 0 :=
by simp [dot_product]
@[simp] lemma zero_dot_product' [semiring α] (v : m → α) : dot_product (λ _, (0 : α)) v = 0 :=
zero_dot_product v
@[simp] lemma add_dot_product [semiring α] (u v w : m → α) :
dot_product (u + v) w = dot_product u w + dot_product v w :=
by simp [dot_product, add_mul, finset.sum_add_distrib]
@[simp] lemma dot_product_add [semiring α] (u v w : m → α) :
dot_product u (v + w) = dot_product u v + dot_product u w :=
by simp [dot_product, mul_add, finset.sum_add_distrib]
@[simp] lemma diagonal_dot_product [decidable_eq m] [semiring α] (v w : m → α) (i : m) :
dot_product (diagonal v i) w = v i * w i :=
have ∀ j ≠ i, diagonal v i j * w j = 0 := λ j hij, by simp [diagonal_apply_ne' hij],
by convert finset.sum_eq_single i (λ j _, this j) _ using 1; simp
@[simp] lemma dot_product_diagonal [decidable_eq m] [semiring α] (v w : m → α) (i : m) :
dot_product v (diagonal w i) = v i * w i :=
have ∀ j ≠ i, v j * diagonal w i j = 0 := λ j hij, by simp [diagonal_apply_ne' hij],
by convert finset.sum_eq_single i (λ j _, this j) _ using 1; simp
@[simp] lemma dot_product_diagonal' [decidable_eq m] [semiring α] (v w : m → α) (i : m) :
dot_product v (λ j, diagonal w j i) = v i * w i :=
have ∀ j ≠ i, v j * diagonal w j i = 0 := λ j hij, by simp [diagonal_apply_ne hij],
by convert finset.sum_eq_single i (λ j _, this j) _ using 1; simp
@[simp] lemma neg_dot_product [ring α] (v w : m → α) : dot_product (-v) w = - dot_product v w :=
by simp [dot_product]
@[simp] lemma dot_product_neg [ring α] (v w : m → α) : dot_product v (-w) = - dot_product v w :=
by simp [dot_product]
@[simp] lemma smul_dot_product [semiring α] (x : α) (v w : m → α) :
dot_product (x • v) w = x * dot_product v w :=
by simp [dot_product, finset.mul_sum, mul_assoc]
@[simp] lemma dot_product_smul [comm_semiring α] (x : α) (v w : m → α) :
dot_product v (x • w) = x * dot_product v w :=
by simp [dot_product, finset.mul_sum, mul_assoc, mul_comm, mul_left_comm]
end dot_product
/-- `M ⬝ N` is the usual product of matrices `M` and `N`, i.e. we have that
`(M ⬝ N) i k` is the dot product of the `i`-th row of `M` by the `k`-th column of `Ǹ`. -/
protected def mul [has_mul α] [add_comm_monoid α] (M : matrix l m α) (N : matrix m n α) :
matrix l n α :=
λ i k, dot_product (λ j, M i j) (λ j, N j k)
localized "infixl ` ⬝ `:75 := matrix.mul" in matrix
theorem mul_apply [has_mul α] [add_comm_monoid α] {M : matrix l m α} {N : matrix m n α} {i k} :
(M ⬝ N) i k = ∑ j, M i j * N j k := rfl
instance [has_mul α] [add_comm_monoid α] : has_mul (matrix n n α) := ⟨matrix.mul⟩
@[simp] theorem mul_eq_mul [has_mul α] [add_comm_monoid α] (M N : matrix n n α) :
M * N = M ⬝ N := rfl
theorem mul_apply' [has_mul α] [add_comm_monoid α] {M N : matrix n n α} {i k} :
(M ⬝ N) i k = dot_product (λ j, M i j) (λ j, N j k) := rfl
section semigroup
variables [semiring α]
protected theorem mul_assoc (L : matrix l m α) (M : matrix m n α) (N : matrix n o α) :
(L ⬝ M) ⬝ N = L ⬝ (M ⬝ N) :=
by { ext, apply dot_product_assoc }
instance : semigroup (matrix n n α) :=
{ mul_assoc := matrix.mul_assoc, ..matrix.has_mul }
end semigroup
@[simp] theorem diagonal_neg [decidable_eq n] [add_group α] (d : n → α) :
-diagonal d = diagonal (λ i, -d i) :=
by ext i j; by_cases i = j; simp [h]
section semiring
variables [semiring α]
@[simp] protected theorem mul_zero (M : matrix m n α) : M ⬝ (0 : matrix n o α) = 0 :=
by { ext i j, apply dot_product_zero }
@[simp] protected theorem zero_mul (M : matrix m n α) : (0 : matrix l m α) ⬝ M = 0 :=
by { ext i j, apply zero_dot_product }
protected theorem mul_add (L : matrix m n α) (M N : matrix n o α) : L ⬝ (M + N) = L ⬝ M + L ⬝ N :=
by { ext i j, apply dot_product_add }
protected theorem add_mul (L M : matrix l m α) (N : matrix m n α) : (L + M) ⬝ N = L ⬝ N + M ⬝ N :=
by { ext i j, apply add_dot_product }
@[simp] theorem diagonal_mul [decidable_eq m]
(d : m → α) (M : matrix m n α) (i j) : (diagonal d).mul M i j = d i * M i j :=
diagonal_dot_product _ _ _
@[simp] theorem mul_diagonal [decidable_eq n]
(d : n → α) (M : matrix m n α) (i j) : (M ⬝ diagonal d) i j = M i j * d j :=
by { rw ← diagonal_transpose, apply dot_product_diagonal }
@[simp] protected theorem one_mul [decidable_eq m] (M : matrix m n α) :
(1 : matrix m m α) ⬝ M = M :=
by ext i j; rw [← diagonal_one, diagonal_mul, one_mul]
@[simp] protected theorem mul_one [decidable_eq n] (M : matrix m n α) :
M ⬝ (1 : matrix n n α) = M :=
by ext i j; rw [← diagonal_one, mul_diagonal, mul_one]
instance [decidable_eq n] : monoid (matrix n n α) :=
{ one_mul := matrix.one_mul,
mul_one := matrix.mul_one,
..matrix.has_one, ..matrix.semigroup }
instance [decidable_eq n] : semiring (matrix n n α) :=
{ mul_zero := matrix.mul_zero,
zero_mul := matrix.zero_mul,
left_distrib := matrix.mul_add,
right_distrib := matrix.add_mul,
..matrix.add_comm_monoid,
..matrix.monoid }
@[simp] theorem diagonal_mul_diagonal [decidable_eq n] (d₁ d₂ : n → α) :
(diagonal d₁) ⬝ (diagonal d₂) = diagonal (λ i, d₁ i * d₂ i) :=
by ext i j; by_cases i = j; simp [h]
theorem diagonal_mul_diagonal' [decidable_eq n] (d₁ d₂ : n → α) :
diagonal d₁ * diagonal d₂ = diagonal (λ i, d₁ i * d₂ i) :=
diagonal_mul_diagonal _ _
@[simp]
lemma map_mul {L : matrix m n α} {M : matrix n o α}
{β : Type w} [semiring β] {f : α →+* β} :
(L ⬝ M).map f = L.map f ⬝ M.map f :=
by { ext, simp [mul_apply, ring_hom.map_sum], }
-- TODO: there should be a way to avoid restating these for each `foo_hom`.
/-- A version of `one_map` where `f` is a ring hom. -/
@[simp] lemma ring_hom_map_one [decidable_eq n]
{β : Type w} [semiring β] (f : α →+* β) :
(1 : matrix n n α).map f = 1 :=
one_map f.map_zero f.map_one
/-- A version of `one_map` where `f` is a `ring_equiv`. -/
@[simp] lemma ring_equiv_map_one [decidable_eq n]
{β : Type w} [semiring β] (f : α ≃+* β) :
(1 : matrix n n α).map f = 1 :=
one_map f.map_zero f.map_one
/-- A version of `map_zero` where `f` is a `zero_hom`. -/
@[simp] lemma zero_hom_map_zero
{β : Type w} [has_zero β] (f : zero_hom α β) :
(0 : matrix n n α).map f = 0 :=
map_zero f.map_zero
/-- A version of `map_zero` where `f` is a `add_monoid_hom`. -/
@[simp] lemma add_monoid_hom_map_zero
{β : Type w} [add_monoid β] (f : α →+ β) :
(0 : matrix n n α).map f = 0 :=
map_zero f.map_zero
/-- A version of `map_zero` where `f` is a `add_equiv`. -/
@[simp] lemma add_equiv_map_zero
{β : Type w} [add_monoid β] (f : α ≃+ β) :
(0 : matrix n n α).map f = 0 :=
map_zero f.map_zero
/-- A version of `map_zero` where `f` is a `linear_map`. -/
@[simp] lemma linear_map_map_zero {R : Type*} [semiring R]
{β : Type w} [add_comm_monoid β] [semimodule R α] [semimodule R β] (f : α →ₗ[R] β) :
(0 : matrix n n α).map f = 0 :=
map_zero f.map_zero
/-- A version of `map_zero` where `f` is a `linear_equiv`. -/
@[simp] lemma linear_equiv_map_zero {R : Type*} [semiring R]
{β : Type w} [add_comm_monoid β] [semimodule R α] [semimodule R β] (f : α ≃ₗ[R] β) :
(0 : matrix n n α).map f = 0 :=
map_zero f.map_zero
/-- A version of `map_zero` where `f` is a `ring_hom`. -/
@[simp] lemma ring_hom_map_zero
{β : Type w} [semiring β] (f : α →+* β) :
(0 : matrix n n α).map f = 0 :=
map_zero f.map_zero
/-- A version of `map_zero` where `f` is a `ring_equiv`. -/
@[simp] lemma ring_equiv_map_zero
{β : Type w} [semiring β] (f : α ≃+* β) :
(0 : matrix n n α).map f = 0 :=
map_zero f.map_zero
lemma is_add_monoid_hom_mul_left (M : matrix l m α) :
is_add_monoid_hom (λ x : matrix m n α, M ⬝ x) :=
{ to_is_add_hom := ⟨matrix.mul_add _⟩, map_zero := matrix.mul_zero _ }
lemma is_add_monoid_hom_mul_right (M : matrix m n α) :
is_add_monoid_hom (λ x : matrix l m α, x ⬝ M) :=
{ to_is_add_hom := ⟨λ _ _, matrix.add_mul _ _ _⟩, map_zero := matrix.zero_mul _ }
protected lemma sum_mul {β : Type*} (s : finset β) (f : β → matrix l m α)
(M : matrix m n α) : (∑ a in s, f a) ⬝ M = ∑ a in s, f a ⬝ M :=
(@finset.sum_hom _ _ _ _ _ s f (λ x, x ⬝ M)
/- This line does not type-check without `id` and `: _`. Lean did not recognize that two different
`add_monoid` instances were def-eq -/
(id (@is_add_monoid_hom_mul_right l _ _ _ _ _ _ _ M) : _)).symm
protected lemma mul_sum {β : Type*} (s : finset β) (f : β → matrix m n α)
(M : matrix l m α) : M ⬝ ∑ a in s, f a = ∑ a in s, M ⬝ f a :=
(@finset.sum_hom _ _ _ _ _ s f (λ x, M ⬝ x)
/- This line does not type-check without `id` and `: _`. Lean did not recognize that two different
`add_monoid` instances were def-eq -/
(id (@is_add_monoid_hom_mul_left _ _ n _ _ _ _ _ M) : _)).symm
@[simp]
lemma row_mul_col_apply (v w : m → α) (i j) : (row v ⬝ col w) i j = dot_product v w :=
rfl
end semiring
end matrix
/-- The `ring_hom` between spaces of square matrices induced by a `ring_hom` between their
coefficients. -/
def ring_hom.map_matrix [decidable_eq m] [semiring α] {β : Type w} [semiring β] (f : α →+* β) :
matrix m m α →+* matrix m m β :=
{ to_fun := λ M, M.map f,
map_one' := by simp,
map_mul' := λ L M, matrix.map_mul,
..(f.to_add_monoid_hom).map_matrix }
@[simp] lemma ring_hom.map_matrix_apply [decidable_eq m] [semiring α] {β : Type w} [semiring β]
(f : α →+* β) (M : matrix m m α) : f.map_matrix M = M.map f := rfl
open_locale matrix
namespace matrix
section ring
variables [ring α]
@[simp] theorem neg_mul (M : matrix m n α) (N : matrix n o α) :
(-M) ⬝ N = -(M ⬝ N) :=
by { ext, apply neg_dot_product }
@[simp] theorem mul_neg (M : matrix m n α) (N : matrix n o α) :
M ⬝ (-N) = -(M ⬝ N) :=
by { ext, apply dot_product_neg }
protected theorem sub_mul (M M' : matrix m n α) (N : matrix n o α) :
(M - M') ⬝ N = M ⬝ N - M' ⬝ N :=
by rw [sub_eq_add_neg, matrix.add_mul, neg_mul, sub_eq_add_neg]
protected theorem mul_sub (M : matrix m n α) (N N' : matrix n o α) :
M ⬝ (N - N') = M ⬝ N - M ⬝ N' :=
by rw [sub_eq_add_neg, matrix.mul_add, mul_neg, sub_eq_add_neg]
end ring
instance [decidable_eq n] [ring α] : ring (matrix n n α) :=
{ ..matrix.semiring, ..matrix.add_comm_group }
instance [semiring α] : has_scalar α (matrix m n α) := pi.has_scalar
instance {β : Type w} [semiring α] [add_comm_monoid β] [semimodule α β] :
semimodule α (matrix m n β) := pi.semimodule _ _ _
@[simp] lemma smul_apply [semiring α] (a : α) (A : matrix m n α) (i : m) (j : n) :
(a • A) i j = a * A i j := rfl
section semiring
variables [semiring α]
lemma smul_eq_diagonal_mul [decidable_eq m] (M : matrix m n α) (a : α) :
a • M = diagonal (λ _, a) ⬝ M :=
by { ext, simp }
@[simp] lemma smul_mul (M : matrix m n α) (a : α) (N : matrix n l α) : (a • M) ⬝ N = a • M ⬝ N :=
by { ext, apply smul_dot_product }
@[simp] lemma mul_mul_left (M : matrix m n α) (N : matrix n o α) (a : α) :
(λ i j, a * M i j) ⬝ N = a • (M ⬝ N) :=
begin
simp only [←smul_apply],
simp,
end
/--
The ring homomorphism `α →+* matrix n n α`
sending `a` to the diagonal matrix with `a` on the diagonal.
-/
def scalar (n : Type u) [decidable_eq n] [fintype n] : α →+* matrix n n α :=
{ to_fun := λ a, a • 1,
map_zero' := by simp,
map_add' := by { intros, ext, simp [add_mul], },
map_one' := by simp,
map_mul' := by { intros, ext, simp [mul_assoc], }, }
section scalar
variable [decidable_eq n]
@[simp] lemma coe_scalar : (scalar n : α → matrix n n α) = λ a, a • 1 := rfl
lemma scalar_apply_eq (a : α) (i : n) :
scalar n a i i = a :=
by simp only [coe_scalar, mul_one, one_apply_eq, smul_apply]
lemma scalar_apply_ne (a : α) (i j : n) (h : i ≠ j) :
scalar n a i j = 0 :=
by simp only [h, coe_scalar, one_apply_ne, ne.def, not_false_iff, smul_apply, mul_zero]
lemma scalar_inj [nonempty n] {r s : α} : scalar n r = scalar n s ↔ r = s :=
begin
split,
{ intro h,
inhabit n,
rw [← scalar_apply_eq r (arbitrary n), ← scalar_apply_eq s (arbitrary n), h] },
{ rintro rfl, refl }
end
end scalar
end semiring
section comm_semiring
variables [comm_semiring α]
lemma smul_eq_mul_diagonal [decidable_eq n] (M : matrix m n α) (a : α) :
a • M = M ⬝ diagonal (λ _, a) :=
by { ext, simp [mul_comm] }
@[simp] lemma mul_smul (M : matrix m n α) (a : α) (N : matrix n l α) : M ⬝ (a • N) = a • M ⬝ N :=
by { ext, apply dot_product_smul }
@[simp] lemma mul_mul_right (M : matrix m n α) (N : matrix n o α) (a : α) :
M ⬝ (λ i j, a * N i j) = a • (M ⬝ N) :=
begin
simp only [←smul_apply],
simp,
end
lemma scalar.commute [decidable_eq n] (r : α) (M : matrix n n α) : commute (scalar n r) M :=
by simp [commute, semiconj_by]
end comm_semiring
section semiring
variables [semiring α]
/-- For two vectors `w` and `v`, `vec_mul_vec w v i j` is defined to be `w i * v j`.
Put another way, `vec_mul_vec w v` is exactly `col w ⬝ row v`. -/
def vec_mul_vec (w : m → α) (v : n → α) : matrix m n α
| x y := w x * v y
/-- `mul_vec M v` is the matrix-vector product of `M` and `v`, where `v` is seen as a column matrix.
Put another way, `mul_vec M v` is the vector whose entries
are those of `M ⬝ col v` (see `col_mul_vec`). -/
def mul_vec (M : matrix m n α) (v : n → α) : m → α
| i := dot_product (λ j, M i j) v
/-- `vec_mul v M` is the vector-matrix product of `v` and `M`, where `v` is seen as a row matrix.
Put another way, `vec_mul v M` is the vector whose entries
are those of `row v ⬝ M` (see `row_vec_mul`). -/
def vec_mul (v : m → α) (M : matrix m n α) : n → α
| j := dot_product v (λ i, M i j)
instance mul_vec.is_add_monoid_hom_left (v : n → α) :
is_add_monoid_hom (λM:matrix m n α, mul_vec M v) :=
{ map_zero := by ext; simp [mul_vec]; refl,
map_add :=
begin
intros x y,
ext m,
apply add_dot_product
end }
lemma mul_vec_diagonal [decidable_eq m] (v w : m → α) (x : m) :
mul_vec (diagonal v) w x = v x * w x :=
diagonal_dot_product v w x
lemma vec_mul_diagonal [decidable_eq m] (v w : m → α) (x : m) :
vec_mul v (diagonal w) x = v x * w x :=
dot_product_diagonal' v w x
@[simp] lemma mul_vec_one [decidable_eq m] (v : m → α) : mul_vec 1 v = v :=
by { ext, rw [←diagonal_one, mul_vec_diagonal, one_mul] }
@[simp] lemma vec_mul_one [decidable_eq m] (v : m → α) : vec_mul v 1 = v :=
by { ext, rw [←diagonal_one, vec_mul_diagonal, mul_one] }
@[simp] lemma mul_vec_zero (A : matrix m n α) : mul_vec A 0 = 0 :=
by { ext, simp [mul_vec] }
@[simp] lemma vec_mul_zero (A : matrix m n α) : vec_mul 0 A = 0 :=
by { ext, simp [vec_mul] }
@[simp] lemma vec_mul_vec_mul (v : m → α) (M : matrix m n α) (N : matrix n o α) :
vec_mul (vec_mul v M) N = vec_mul v (M ⬝ N) :=
by { ext, apply dot_product_assoc }
@[simp] lemma mul_vec_mul_vec (v : o → α) (M : matrix m n α) (N : matrix n o α) :
mul_vec M (mul_vec N v) = mul_vec (M ⬝ N) v :=
by { ext, symmetry, apply dot_product_assoc }
lemma vec_mul_vec_eq (w : m → α) (v : n → α) :
vec_mul_vec w v = (col w) ⬝ (row v) :=
by { ext i j, simp [vec_mul_vec, mul_apply], refl }
variables [decidable_eq m] [decidable_eq n]
/--
`std_basis_matrix i j a` is the matrix with `a` in the `i`-th row, `j`-th column,
and zeroes elsewhere.
-/
def std_basis_matrix (i : m) (j : n) (a : α) : matrix m n α :=
(λ i' j', if i' = i ∧ j' = j then a else 0)
@[simp] lemma smul_std_basis_matrix (i : m) (j : n) (a b : α) :
b • std_basis_matrix i j a = std_basis_matrix i j (b • a) :=
by { unfold std_basis_matrix, ext, simp }
@[simp] lemma std_basis_matrix_zero (i : m) (j : n) :
std_basis_matrix i j (0 : α) = 0 :=
by { unfold std_basis_matrix, ext, simp }
lemma std_basis_matrix_add (i : m) (j : n) (a b : α) :
std_basis_matrix i j (a + b) = std_basis_matrix i j a + std_basis_matrix i j b :=
begin
unfold std_basis_matrix, ext,
split_ifs with h; simp [h],
end
lemma matrix_eq_sum_std_basis (x : matrix n m α) :
x = ∑ (i : n) (j : m), std_basis_matrix i j (x i j) :=
begin
ext, symmetry,
iterate 2 { rw finset.sum_apply },
convert fintype.sum_eq_single i _,
{ simp [std_basis_matrix] },
{ intros j hj,
simp [std_basis_matrix, hj.symm] }
end
-- TODO: tie this up with the `basis` machinery of linear algebra
-- this is not completely trivial because we are indexing by two types, instead of one
-- TODO: add `std_basis_vec`
lemma std_basis_eq_basis_mul_basis (i : m) (j : n) :
std_basis_matrix i j 1 = vec_mul_vec (λ i', ite (i = i') 1 0) (λ j', ite (j = j') 1 0) :=
begin
ext, norm_num [std_basis_matrix, vec_mul_vec],
split_ifs; tauto,
end
@[elab_as_eliminator] protected lemma induction_on'
{X : Type*} [semiring X] {M : matrix n n X → Prop} (m : matrix n n X)
(h_zero : M 0)
(h_add : ∀p q, M p → M q → M (p + q))
(h_std_basis : ∀ i j x, M (std_basis_matrix i j x)) :
M m :=
begin
rw [matrix_eq_sum_std_basis m, ← finset.sum_product'],
apply finset.sum_induction _ _ h_add h_zero,
{ intros, apply h_std_basis, }
end
@[elab_as_eliminator] protected lemma induction_on
[nonempty n] {X : Type*} [semiring X] {M : matrix n n X → Prop} (m : matrix n n X)
(h_add : ∀p q, M p → M q → M (p + q))
(h_std_basis : ∀ i j x, M (std_basis_matrix i j x)) :
M m :=
matrix.induction_on' m
begin
have i : n := classical.choice (by assumption),
simpa using h_std_basis i i 0,
end
h_add h_std_basis
end semiring
section ring
variables [ring α]
lemma neg_vec_mul (v : m → α) (A : matrix m n α) : vec_mul (-v) A = - vec_mul v A :=
by { ext, apply neg_dot_product }
lemma vec_mul_neg (v : m → α) (A : matrix m n α) : vec_mul v (-A) = - vec_mul v A :=
by { ext, apply dot_product_neg }
lemma neg_mul_vec (v : n → α) (A : matrix m n α) : mul_vec (-A) v = - mul_vec A v :=
by { ext, apply neg_dot_product }
lemma mul_vec_neg (v : n → α) (A : matrix m n α) : mul_vec A (-v) = - mul_vec A v :=
by { ext, apply dot_product_neg }
lemma smul_mul_vec_assoc (A : matrix n n α) (b : n → α) (a : α) :
(a • A).mul_vec b = a • (A.mul_vec b) :=
begin
ext i, change dot_product ((a • A) i) b = _,
simp only [mul_vec, smul_eq_mul, pi.smul_apply, smul_dot_product],
end
end ring
section transpose
open_locale matrix
/--
Tell `simp` what the entries are in a transposed matrix.
Compare with `mul_apply`, `diagonal_apply_eq`, etc.
-/
@[simp] lemma transpose_apply (M : matrix m n α) (i j) : M.transpose j i = M i j := rfl
@[simp] lemma transpose_transpose (M : matrix m n α) :
Mᵀᵀ = M :=
by ext; refl
@[simp] lemma transpose_zero [has_zero α] : (0 : matrix m n α)ᵀ = 0 :=
by ext i j; refl
@[simp] lemma transpose_one [decidable_eq n] [has_zero α] [has_one α] : (1 : matrix n n α)ᵀ = 1 :=
begin
ext i j,
unfold has_one.one transpose,
by_cases i = j,
{ simp only [h, diagonal_apply_eq] },
{ simp only [diagonal_apply_ne h, diagonal_apply_ne (λ p, h (symm p))] }
end
@[simp] lemma transpose_add [has_add α] (M : matrix m n α) (N : matrix m n α) :
(M + N)ᵀ = Mᵀ + Nᵀ :=
by { ext i j, simp }
@[simp] lemma transpose_sub [add_group α] (M : matrix m n α) (N : matrix m n α) :
(M - N)ᵀ = Mᵀ - Nᵀ :=
by { ext i j, simp }
@[simp] lemma transpose_mul [comm_semiring α] (M : matrix m n α) (N : matrix n l α) :
(M ⬝ N)ᵀ = Nᵀ ⬝ Mᵀ :=
begin
ext i j,
apply dot_product_comm
end
@[simp] lemma transpose_smul [semiring α] (c : α) (M : matrix m n α) :
(c • M)ᵀ = c • Mᵀ :=
by { ext i j, refl }
@[simp] lemma transpose_neg [has_neg α] (M : matrix m n α) :
(- M)ᵀ = - Mᵀ :=
by ext i j; refl
lemma transpose_map {β : Type w} {f : α → β} {M : matrix m n α} : Mᵀ.map f = (M.map f)ᵀ :=
by { ext, refl }
end transpose
section star_ring
variables [decidable_eq n] {R : Type*} [semiring R] [star_ring R]
/--
When `R` is a `*`-(semi)ring, `matrix n n R` becomes a `*`-(semi)ring with
the star operation given by taking the conjugate, and the star of each entry.
-/
instance : star_ring (matrix n n R) :=
{ star := λ M, M.transpose.map star,
star_involutive := λ M, by { ext, simp, },
star_add := λ M N, by { ext, simp, },
star_mul := λ M N, by { ext, simp [mul_apply], }, }
@[simp] lemma star_apply (M : matrix n n R) (i j) : star M i j = star (M j i) := rfl
lemma star_mul (M N : matrix n n R) : star (M ⬝ N) = star N ⬝ star M := star_mul _ _
end star_ring
/-- `M.minor row col` is the matrix obtained by reindexing the rows and the lines of
`M`, such that `M.minor row col i j = M (row i) (col j)`. Note that the total number
of row/colums doesn't have to be preserved. -/
def minor (A : matrix m n α) (row : l → m) (col : o → n) : matrix l o α :=
λ i j, A (row i) (col j)
/-- The left `n × l` part of a `n × (l+r)` matrix. -/
@[reducible]
def sub_left {m l r : nat} (A : matrix (fin m) (fin (l + r)) α) : matrix (fin m) (fin l) α :=
minor A id (fin.cast_add r)
/-- The right `n × r` part of a `n × (l+r)` matrix. -/
@[reducible]
def sub_right {m l r : nat} (A : matrix (fin m) (fin (l + r)) α) : matrix (fin m) (fin r) α :=
minor A id (fin.nat_add l)
/-- The top `u × n` part of a `(u+d) × n` matrix. -/
@[reducible]
def sub_up {d u n : nat} (A : matrix (fin (u + d)) (fin n) α) : matrix (fin u) (fin n) α :=
minor A (fin.cast_add d) id
/-- The bottom `d × n` part of a `(u+d) × n` matrix. -/
@[reducible]
def sub_down {d u n : nat} (A : matrix (fin (u + d)) (fin n) α) : matrix (fin d) (fin n) α :=
minor A (fin.nat_add u) id
/-- The top-right `u × r` part of a `(u+d) × (l+r)` matrix. -/
@[reducible]
def sub_up_right {d u l r : nat} (A: matrix (fin (u + d)) (fin (l + r)) α) :
matrix (fin u) (fin r) α :=
sub_up (sub_right A)
/-- The bottom-right `d × r` part of a `(u+d) × (l+r)` matrix. -/
@[reducible]
def sub_down_right {d u l r : nat} (A : matrix (fin (u + d)) (fin (l + r)) α) :
matrix (fin d) (fin r) α :=
sub_down (sub_right A)
/-- The top-left `u × l` part of a `(u+d) × (l+r)` matrix. -/
@[reducible]
def sub_up_left {d u l r : nat} (A : matrix (fin (u + d)) (fin (l + r)) α) :
matrix (fin u) (fin (l)) α :=
sub_up (sub_left A)
/-- The bottom-left `d × l` part of a `(u+d) × (l+r)` matrix. -/
@[reducible]
def sub_down_left {d u l r : nat} (A: matrix (fin (u + d)) (fin (l + r)) α) :
matrix (fin d) (fin (l)) α :=
sub_down (sub_left A)
section row_col
/-!
### `row_col` section
Simplification lemmas for `matrix.row` and `matrix.col`.
-/
open_locale matrix
@[simp] lemma col_add [semiring α] (v w : m → α) : col (v + w) = col v + col w := by { ext, refl }
@[simp] lemma col_smul [semiring α] (x : α) (v : m → α) : col (x • v) = x • col v :=
by { ext, refl }
@[simp] lemma row_add [semiring α] (v w : m → α) : row (v + w) = row v + row w := by { ext, refl }
@[simp] lemma row_smul [semiring α] (x : α) (v : m → α) : row (x • v) = x • row v :=
by { ext, refl }
@[simp] lemma col_apply (v : m → α) (i j) : matrix.col v i j = v i := rfl
@[simp] lemma row_apply (v : m → α) (i j) : matrix.row v i j = v j := rfl
@[simp]
lemma transpose_col (v : m → α) : (matrix.col v).transpose = matrix.row v := by {ext, refl}
@[simp]
lemma transpose_row (v : m → α) : (matrix.row v).transpose = matrix.col v := by {ext, refl}
lemma row_vec_mul [semiring α] (M : matrix m n α) (v : m → α) :
matrix.row (matrix.vec_mul v M) = matrix.row v ⬝ M := by {ext, refl}
lemma col_vec_mul [semiring α] (M : matrix m n α) (v : m → α) :
matrix.col (matrix.vec_mul v M) = (matrix.row v ⬝ M)ᵀ := by {ext, refl}
lemma col_mul_vec [semiring α] (M : matrix m n α) (v : n → α) :
matrix.col (matrix.mul_vec M v) = M ⬝ matrix.col v := by {ext, refl}
lemma row_mul_vec [semiring α] (M : matrix m n α) (v : n → α) :
matrix.row (matrix.mul_vec M v) = (M ⬝ matrix.col v)ᵀ := by {ext, refl}
end row_col
section update
/-- Update, i.e. replace the `i`th row of matrix `A` with the values in `b`. -/
def update_row [decidable_eq n] (M : matrix n m α) (i : n) (b : m → α) : matrix n m α :=
function.update M i b
/-- Update, i.e. replace the `j`th column of matrix `A` with the values in `b`. -/
def update_column [decidable_eq m] (M : matrix n m α) (j : m) (b : n → α) : matrix n m α :=
λ i, function.update (M i) j (b i)
variables {M : matrix n m α} {i : n} {j : m} {b : m → α} {c : n → α}
@[simp] lemma update_row_self [decidable_eq n] : update_row M i b i = b :=
function.update_same i b M
@[simp] lemma update_column_self [decidable_eq m] : update_column M j c i j = c i :=
function.update_same j (c i) (M i)
@[simp] lemma update_row_ne [decidable_eq n] {i' : n} (i_ne : i' ≠ i) :
update_row M i b i' = M i' := function.update_noteq i_ne b M
@[simp] lemma update_column_ne [decidable_eq m] {j' : m} (j_ne : j' ≠ j) :
update_column M j c i j' = M i j' := function.update_noteq j_ne (c i) (M i)
lemma update_row_apply [decidable_eq n] {i' : n} :
update_row M i b i' j = if i' = i then b j else M i' j :=
begin
by_cases i' = i,
{ rw [h, update_row_self, if_pos rfl] },
{ rwa [update_row_ne h, if_neg h] }
end
lemma update_column_apply [decidable_eq m] {j' : m} :
update_column M j c i j' = if j' = j then c i else M i j' :=
begin
by_cases j' = j,
{ rw [h, update_column_self, if_pos rfl] },
{ rwa [update_column_ne h, if_neg h] }
end
lemma update_row_transpose [decidable_eq m] : update_row Mᵀ j c = (update_column M j c)ᵀ :=
begin
ext i' j,
rw [transpose_apply, update_row_apply, update_column_apply],
refl
end
lemma update_column_transpose [decidable_eq n] : update_column Mᵀ i b = (update_row M i b)ᵀ :=
begin
ext i' j,
rw [transpose_apply, update_row_apply, update_column_apply],
refl
end
end update
section block_matrices
/-- We can form a single large matrix by flattening smaller 'block' matrices of compatible
dimensions. -/
def from_blocks (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :
matrix (n ⊕ o) (l ⊕ m) α :=
sum.elim (λ i, sum.elim (A i) (B i))
(λ i, sum.elim (C i) (D i))
@[simp] lemma from_blocks_apply₁₁
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : n) (j : l) :
from_blocks A B C D (sum.inl i) (sum.inl j) = A i j :=
rfl
@[simp] lemma from_blocks_apply₁₂
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : n) (j : m) :
from_blocks A B C D (sum.inl i) (sum.inr j) = B i j :=
rfl
@[simp] lemma from_blocks_apply₂₁
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : o) (j : l) :
from_blocks A B C D (sum.inr i) (sum.inl j) = C i j :=
rfl
@[simp] lemma from_blocks_apply₂₂
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) (i : o) (j : m) :
from_blocks A B C D (sum.inr i) (sum.inr j) = D i j :=
rfl
/-- Given a matrix whose row and column indexes are sum types, we can extract the corresponding
"top left" submatrix. -/
def to_blocks₁₁ (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix n l α :=
λ i j, M (sum.inl i) (sum.inl j)
/-- Given a matrix whose row and column indexes are sum types, we can extract the corresponding
"top right" submatrix. -/
def to_blocks₁₂ (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix n m α :=
λ i j, M (sum.inl i) (sum.inr j)
/-- Given a matrix whose row and column indexes are sum types, we can extract the corresponding
"bottom left" submatrix. -/
def to_blocks₂₁ (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix o l α :=
λ i j, M (sum.inr i) (sum.inl j)
/-- Given a matrix whose row and column indexes are sum types, we can extract the corresponding
"bottom right" submatrix. -/
def to_blocks₂₂ (M : matrix (n ⊕ o) (l ⊕ m) α) : matrix o m α :=
λ i j, M (sum.inr i) (sum.inr j)
lemma from_blocks_to_blocks (M : matrix (n ⊕ o) (l ⊕ m) α) :
from_blocks M.to_blocks₁₁ M.to_blocks₁₂ M.to_blocks₂₁ M.to_blocks₂₂ = M :=
begin
ext i j, rcases i; rcases j; refl,
end
@[simp] lemma to_blocks_from_blocks₁₁
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :
(from_blocks A B C D).to_blocks₁₁ = A :=
rfl
@[simp] lemma to_blocks_from_blocks₁₂
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :
(from_blocks A B C D).to_blocks₁₂ = B :=
rfl
@[simp] lemma to_blocks_from_blocks₂₁
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :
(from_blocks A B C D).to_blocks₂₁ = C :=
rfl
@[simp] lemma to_blocks_from_blocks₂₂
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :
(from_blocks A B C D).to_blocks₂₂ = D :=
rfl
lemma from_blocks_transpose
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :
(from_blocks A B C D)ᵀ = from_blocks Aᵀ Cᵀ Bᵀ Dᵀ :=
begin
ext i j, rcases i; rcases j; simp [from_blocks],
end
/-- Let `p` pick out certain rows and `q` pick out certain columns of a matrix `M`. Then
`to_block M p q` is the corresponding block matrix. -/
def to_block (M : matrix m n α) (p : m → Prop) [decidable_pred p]
(q : n → Prop) [decidable_pred q] : matrix {a // p a} {a // q a} α := M.minor coe coe
@[simp] lemma to_block_apply (M : matrix m n α) (p : m → Prop) [decidable_pred p]
(q : n → Prop) [decidable_pred q] (i : {a // p a}) (j : {a // q a}) :
to_block M p q i j = M ↑i ↑j := rfl
/-- Let `b` map rows and columns of a square matrix `M` to blocks. Then
`to_square_block M b k` is the block `k` matrix. -/
def to_square_block (M : matrix m m α) {n : nat} (b : m → fin n) (k : fin n) :
matrix {a // b a = k} {a // b a = k} α := M.minor coe coe
@[simp] lemma to_square_block_def (M : matrix m m α) {n : nat} (b : m → fin n) (k : fin n) :
to_square_block M b k = λ i j, M ↑i ↑j := rfl
/-- Alternate version with `b : m → nat`. Let `b` map rows and columns of a square matrix `M` to
blocks. Then `to_square_block' M b k` is the block `k` matrix. -/
def to_square_block' (M : matrix m m α) (b : m → nat) (k : nat) :
matrix {a // b a = k} {a // b a = k} α := M.minor coe coe
@[simp] lemma to_square_block_def' (M : matrix m m α) (b : m → nat) (k : nat) :
to_square_block' M b k = λ i j, M ↑i ↑j := rfl
/-- Let `p` pick out certain rows and columns of a square matrix `M`. Then
`to_square_block_prop M p` is the corresponding block matrix. -/
def to_square_block_prop (M : matrix m m α) (p : m → Prop) [decidable_pred p] :
matrix {a // p a} {a // p a} α := M.minor coe coe
@[simp] lemma to_square_block_prop_def (M : matrix m m α) (p : m → Prop) [decidable_pred p] :
to_square_block_prop M p = λ i j, M ↑i ↑j := rfl
variables [semiring α]
lemma from_blocks_smul
(x : α) (A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α) :
x • (from_blocks A B C D) = from_blocks (x • A) (x • B) (x • C) (x • D) :=
begin
ext i j, rcases i; rcases j; simp [from_blocks],
end
lemma from_blocks_add
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α)
(A' : matrix n l α) (B' : matrix n m α) (C' : matrix o l α) (D' : matrix o m α) :
(from_blocks A B C D) + (from_blocks A' B' C' D') =
from_blocks (A + A') (B + B')
(C + C') (D + D') :=
begin
ext i j, rcases i; rcases j; refl,
end
lemma from_blocks_multiply {p q : Type*} [fintype p] [fintype q]
(A : matrix n l α) (B : matrix n m α) (C : matrix o l α) (D : matrix o m α)
(A' : matrix l p α) (B' : matrix l q α) (C' : matrix m p α) (D' : matrix m q α) :
(from_blocks A B C D) ⬝ (from_blocks A' B' C' D') =
from_blocks (A ⬝ A' + B ⬝ C') (A ⬝ B' + B ⬝ D')
(C ⬝ A' + D ⬝ C') (C ⬝ B' + D ⬝ D') :=
begin
ext i j, rcases i; rcases j;
simp only [from_blocks, mul_apply, fintype.sum_sum_type, sum.elim_inl, sum.elim_inr,
pi.add_apply],
end
variables [decidable_eq l] [decidable_eq m]
@[simp] lemma from_blocks_diagonal (d₁ : l → α) (d₂ : m → α) :
from_blocks (diagonal d₁) 0 0 (diagonal d₂) = diagonal (sum.elim d₁ d₂) :=
begin
ext i j, rcases i; rcases j; simp [diagonal],
end
@[simp] lemma from_blocks_one : from_blocks (1 : matrix l l α) 0 0 (1 : matrix m m α) = 1 :=
by { ext i j, rcases i; rcases j; simp [one_apply] }
end block_matrices
section block_diagonal
variables (M N : o → matrix m n α) [decidable_eq o]
section has_zero
variables [has_zero α]
/-- `matrix.block_diagonal M` turns `M : o → matrix m n α'` into a
`m × o`-by`n × o` block matrix which has the entries of `M` along the diagonal
and zero elsewhere. -/
def block_diagonal : matrix (m × o) (n × o) α
| ⟨i, k⟩ ⟨j, k'⟩ := if k = k' then M k i j else 0
lemma block_diagonal_apply (ik jk) :
block_diagonal M ik jk = if ik.2 = jk.2 then M ik.2 ik.1 jk.1 else 0 :=
by { cases ik, cases jk, refl }
@[simp]
lemma block_diagonal_apply_eq (i j k) :
block_diagonal M (i, k) (j, k) = M k i j :=
if_pos rfl
lemma block_diagonal_apply_ne (i j) {k k'} (h : k ≠ k') :
block_diagonal M (i, k) (j, k') = 0 :=
if_neg h
@[simp] lemma block_diagonal_transpose :
(block_diagonal M)ᵀ = (block_diagonal (λ k, (M k)ᵀ)) :=
begin
ext,
simp only [transpose_apply, block_diagonal_apply, eq_comm],
split_ifs with h,
{ rw h },
{ refl }
end
@[simp] lemma block_diagonal_zero :
block_diagonal (0 : o → matrix m n α) = 0 :=
by { ext, simp [block_diagonal_apply] }
@[simp] lemma block_diagonal_diagonal [decidable_eq m] (d : o → m → α) :
(block_diagonal (λ k, diagonal (d k))) = diagonal (λ ik, d ik.2 ik.1) :=
begin
ext ⟨i, k⟩ ⟨j, k'⟩,
simp only [block_diagonal_apply, diagonal],
split_ifs; finish
end
@[simp] lemma block_diagonal_one [decidable_eq m] [has_one α] :
(block_diagonal (1 : o → matrix m m α)) = 1 :=
show (block_diagonal (λ (_ : o), diagonal (λ (_ : m), (1 : α)))) = diagonal (λ _, 1),
by rw [block_diagonal_diagonal]
end has_zero
@[simp] lemma block_diagonal_add [add_monoid α] :
block_diagonal (M + N) = block_diagonal M + block_diagonal N :=
begin
ext,
simp only [block_diagonal_apply, add_apply],
split_ifs; simp
end
@[simp] lemma block_diagonal_neg [add_group α] :
block_diagonal (-M) = - block_diagonal M :=
begin
ext,
simp only [block_diagonal_apply, neg_apply],
split_ifs; simp
end
@[simp] lemma block_diagonal_sub [add_group α] :
block_diagonal (M - N) = block_diagonal M - block_diagonal N :=
by simp [sub_eq_add_neg]
@[simp] lemma block_diagonal_mul {p : Type*} [fintype p] [semiring α]
(N : o → matrix n p α) : block_diagonal (λ k, M k ⬝ N k) = block_diagonal M ⬝ block_diagonal N :=
begin
ext ⟨i, k⟩ ⟨j, k'⟩,
simp only [block_diagonal_apply, mul_apply, ← finset.univ_product_univ, finset.sum_product],
split_ifs with h; simp [h]
end
@[simp] lemma block_diagonal_smul {R : Type*} [semiring R] [add_comm_monoid α] [semimodule R α]
(x : R) : block_diagonal (x • M) = x • block_diagonal M :=
by { ext, simp only [block_diagonal_apply, pi.smul_apply, smul_apply], split_ifs; simp }
end block_diagonal
end matrix
namespace ring_hom
variables {β : Type*} [semiring α] [semiring β]
lemma map_matrix_mul (M : matrix m n α) (N : matrix n o α) (i : m) (j : o) (f : α →+* β) :
f (matrix.mul M N i j) = matrix.mul (λ i j, f (M i j)) (λ i j, f (N i j)) i j :=
by simp [matrix.mul_apply, ring_hom.map_sum]
end ring_hom
|
1ee15ca6fc45d42e650156e40147eec06eb3a54f | 0d22ec5e0205ec4203aae2ddf07e1f695ff21a61 | /src/step3_derivations.lean | 10a8e770d837111801ef847ddc29bc86e42d2481 | [
"Apache-2.0"
] | permissive | shingtaklam1324/step3-06-q8-lean | 4611fda6b002797d38d3f625253960dcfeb2a987 | 20e5161fab8b5c3c2dd051bd707a26f1dc50dac2 | refs/heads/master | 1,649,936,589,910 | 1,585,242,273,000 | 1,585,242,273,000 | 250,318,324 | 2 | 0 | Apache-2.0 | 1,585,389,271,000 | 1,585,241,690,000 | Lean | UTF-8 | Lean | false | false | 1,126 | lean | import data.polynomial
data.real.basic
polynomial_derivations
-- set_option profiler true
section step
open polynomial
parameters Δ : polynomial ℝ → polynomial ℝ
parameter Δ1 : Δ X = C 1
parameter Δ2 : ∀ (f g : polynomial ℝ), Δ(f + g) = Δ f + Δ g
parameter Δ3 : ∀ (k : ℝ) (f : polynomial ℝ), Δ(C k * f) = C k * Δ f
parameter Δ4 : ∀ (f g : polynomial ℝ), Δ(f * g) = f * Δ g + g * Δ f
include Δ1 Δ2 Δ3 Δ4
definition d : polynomial_derivation ℝ :=
{ to_fun := Δ,
map_add' := Δ2,
map_C_mul' := Δ3,
map_mul' := Δ4 }
theorem Δ_is_derivative (p : polynomial ℝ) : Δ p = derivative p := begin
show d p = derivative p,
apply p.induction_on,
{ intro a, simp only [polynomial_derivation.map_C, polynomial.derivative_C]},
{ intros p q hp hq, rw [derivative_add, d.map_add, hp, hq] },
intros n a IH,
rw [pow_succ, mul_comm X, <-mul_assoc, d.map_mul, derivative_mul,
derivative_X, IH], unfold_coes, rw [(show d.to_fun = Δ, by refl),
Δ1, mul_one, (show C a * X ^ n * C 1 = C a * X ^ n, by simp only [mul_one, polynomial.C_1])],
ring,
end
end step |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.