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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c781d8a9776f0bcc8f6cbdcf7a9542c0fed744ea | c055f4b7c29cf1aac2223bd8c1ac8d181a7c6447 | /src/categories/heterogeneous_identity.lean | 12940600f7e7a933560e4ad8fc64c9819803264e | [
"Apache-2.0"
] | permissive | rwbarton/lean-category-theory-pr | 77207b6674eeec1e258ec85dea58f3bff8d27065 | 591847d70c6a11c4d5561cd0eaf69b1fe85a70ab | refs/heads/master | 1,584,595,111,303 | 1,528,029,041,000 | 1,528,029,041,000 | 135,919,126 | 0 | 0 | null | 1,528,041,805,000 | 1,528,041,805,000 | null | UTF-8 | Lean | false | false | 1,544 | lean | import .functor
import .isomorphism
universes u v
-- @[simp] lemma eq.mpr.trans {α β γ: Prop} (p : α = β) (q : β = γ) (g : γ) : eq.mpr (eq.trans p q) g = eq.mpr p (eq.mpr q g) :=
-- begin
-- induction p,
-- induction q,
-- refl,
-- end
-- @[simp] lemma eq.mpr.propext {α : Sort u₁} (a : α) : eq.mpr (propext (eq_self_iff_true a)) trivial = eq.refl a :=
-- begin
-- refl,
-- end
-- @[simp] lemma eq.mpr.refl {α : Sort u₁} (a b : α) (p : a = b) : (eq.mpr (congr_fun (congr_arg eq p) b) (eq.refl b)) = p :=
-- begin
-- induction p,
-- refl,
-- end
namespace categories
open categories.isomorphism
open categories.functor
variables {C : Type u} [𝒞 : category.{u v} C]
include 𝒞
variables {X Y Z : C}
def eq_to_iso (p : X = Y) : X ≅ Y :=
begin
rw p,
exact (Isomorphism.refl Y),
end
@[simp,ematch] lemma eq_to_iso.refl (X : C) : eq_to_iso (eq.refl X) = (Isomorphism.refl X) :=
begin
refl,
end
@[simp,ematch] lemma eq_to_iso.trans (p : X = Y) (q : Y = Z) : (eq_to_iso p) ♢ (eq_to_iso q) = eq_to_iso (p.trans q) :=
begin
induction p,
induction q,
tidy,
end
end categories
open categories
namespace categories.functor
universes u₁ v₁ u₂ v₂
variables {C : Type u₁} [𝒞 : category.{u₁ v₁} C]
variables {D : Type u₂} [𝒟 : category.{u₂ v₂} D]
include 𝒞 𝒟
@[simp,ematch] lemma Functor.eq_to_iso (F : C ↝ D) (X Y : C) (p : X = Y) : F.onIsomorphisms (eq_to_iso p) = eq_to_iso (congr_arg F.onObjects p) :=
begin
induction p,
tidy,
end
end categories.functor
|
777000ed277ba3000858558384ea12d7dae68e8a | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/data/list/nat_antidiagonal_auto.lean | edb1bf18a0ba0323309c4224f4396be589a0b2ec | [] | 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 | 1,380 | 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 Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.list.range
import Mathlib.PostPort
namespace Mathlib
namespace list
namespace nat
/-- The antidiagonal of a natural number `n` is the list of pairs `(i,j)` such that `i+j = n`. -/
def antidiagonal (n : ℕ) : List (ℕ × ℕ) := map (fun (i : ℕ) => (i, n - i)) (range (n + 1))
/-- A pair (i,j) is contained in the antidiagonal of `n` if and only if `i+j=n`. -/
@[simp] theorem mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} :
x ∈ antidiagonal n ↔ prod.fst x + prod.snd x = n :=
sorry
/-- The length of the antidiagonal of `n` is `n+1`. -/
@[simp] theorem length_antidiagonal (n : ℕ) : length (antidiagonal n) = n + 1 := sorry
/-- The antidiagonal of `0` is the list `[(0,0)]` -/
@[simp] theorem antidiagonal_zero : antidiagonal 0 = [(0, 0)] := rfl
/-- The antidiagonal of `n` does not contain duplicate entries. -/
theorem nodup_antidiagonal (n : ℕ) : nodup (antidiagonal n) :=
nodup_map (function.left_inverse.injective fun (i : ℕ) => rfl) (nodup_range (n + 1))
@[simp] theorem antidiagonal_succ {n : ℕ} :
antidiagonal (n + 1) = (0, n + 1) :: map (prod.map Nat.succ id) (antidiagonal n) :=
sorry
end Mathlib |
2ec97e785530222a5145a34dc734839a293a8beb | d29d82a0af640c937e499f6be79fc552eae0aa13 | /src/algebra/pointwise.lean | 7e1c097766e8304ea63a6928e57a553f1c1c2fce | [
"Apache-2.0"
] | permissive | AbdulMajeedkhurasani/mathlib | 835f8a5c5cf3075b250b3737172043ab4fa1edf6 | 79bc7323b164aebd000524ebafd198eb0e17f956 | refs/heads/master | 1,688,003,895,660 | 1,627,788,521,000 | 1,627,788,521,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 27,200 | lean | /-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Floris van Doorn
-/
import algebra.module.basic
import data.set.finite
import group_theory.submonoid.basic
/-!
# Pointwise addition, multiplication, and scalar multiplication of sets.
This file defines pointwise algebraic operations on sets.
* For a type `α` with multiplication, multiplication is defined on `set α` by taking
`s * t` to be the set of all `x * y` where `x ∈ s` and `y ∈ t`. Similarly for addition.
* For `α` a semigroup, `set α` is a semigroup.
* If `α` is a (commutative) monoid, we define an alias `set_semiring α` for `set α`, which then
becomes a (commutative) semiring with union as addition and pointwise multiplication as
multiplication.
* For a type `β` with scalar multiplication by another type `α`, this
file defines a scalar multiplication of `set β` by `set α` and a separate scalar
multiplication of `set β` by `α`.
* We also define pointwise multiplication on `finset`.
Appropriate definitions and results are also transported to the additive theory via `to_additive`.
## Implementation notes
* The following expressions are considered in simp-normal form in a group:
`(λ h, h * g) ⁻¹' s`, `(λ h, g * h) ⁻¹' s`, `(λ h, h * g⁻¹) ⁻¹' s`, `(λ h, g⁻¹ * h) ⁻¹' s`,
`s * t`, `s⁻¹`, `(1 : set _)` (and similarly for additive variants).
Expressions equal to one of these will be simplified.
## Tags
set multiplication, set addition, pointwise addition, pointwise multiplication
-/
namespace set
open function
variables {α : Type*} {β : Type*} {s s₁ s₂ t t₁ t₂ u : set α} {a b : α} {x y : β}
/-! ### Properties about 1 -/
@[to_additive]
instance [has_one α] : has_one (set α) := ⟨{1}⟩
@[to_additive]
lemma singleton_one [has_one α] : ({1} : set α) = 1 := rfl
@[simp, to_additive]
lemma mem_one [has_one α] : a ∈ (1 : set α) ↔ a = 1 := iff.rfl
@[to_additive]
lemma one_mem_one [has_one α] : (1 : α) ∈ (1 : set α) := eq.refl _
@[simp, to_additive]
theorem one_subset [has_one α] : 1 ⊆ s ↔ (1 : α) ∈ s := singleton_subset_iff
@[to_additive]
theorem one_nonempty [has_one α] : (1 : set α).nonempty := ⟨1, rfl⟩
@[simp, to_additive]
theorem image_one [has_one α] {f : α → β} : f '' 1 = {f 1} := image_singleton
/-! ### Properties about multiplication -/
@[to_additive]
instance [has_mul α] : has_mul (set α) := ⟨image2 has_mul.mul⟩
@[simp, to_additive]
lemma image2_mul [has_mul α] : image2 has_mul.mul s t = s * t := rfl
@[to_additive]
lemma mem_mul [has_mul α] : a ∈ s * t ↔ ∃ x y, x ∈ s ∧ y ∈ t ∧ x * y = a := iff.rfl
@[to_additive]
lemma mul_mem_mul [has_mul α] (ha : a ∈ s) (hb : b ∈ t) : a * b ∈ s * t := mem_image2_of_mem ha hb
@[to_additive add_image_prod]
lemma image_mul_prod [has_mul α] : (λ x : α × α, x.fst * x.snd) '' s.prod t = s * t := image_prod _
@[simp, to_additive]
lemma image_mul_left [group α] : (λ b, a * b) '' t = (λ b, a⁻¹ * b) ⁻¹' t :=
by { rw image_eq_preimage_of_inverse; intro c; simp }
@[simp, to_additive]
lemma image_mul_right [group α] : (λ a, a * b) '' t = (λ a, a * b⁻¹) ⁻¹' t :=
by { rw image_eq_preimage_of_inverse; intro c; simp }
@[to_additive]
lemma image_mul_left' [group α] : (λ b, a⁻¹ * b) '' t = (λ b, a * b) ⁻¹' t := by simp
@[to_additive]
lemma image_mul_right' [group α] : (λ a, a * b⁻¹) '' t = (λ a, a * b) ⁻¹' t := by simp
@[simp, to_additive]
lemma preimage_mul_left_singleton [group α] : ((*) a) ⁻¹' {b} = {a⁻¹ * b} :=
by rw [← image_mul_left', image_singleton]
@[simp, to_additive]
lemma preimage_mul_right_singleton [group α] : (* a) ⁻¹' {b} = {b * a⁻¹} :=
by rw [← image_mul_right', image_singleton]
@[simp, to_additive]
lemma preimage_mul_left_one [group α] : (λ b, a * b) ⁻¹' 1 = {a⁻¹} :=
by rw [← image_mul_left', image_one, mul_one]
@[simp, to_additive]
lemma preimage_mul_right_one [group α] : (λ a, a * b) ⁻¹' 1 = {b⁻¹} :=
by rw [← image_mul_right', image_one, one_mul]
@[to_additive]
lemma preimage_mul_left_one' [group α] : (λ b, a⁻¹ * b) ⁻¹' 1 = {a} := by simp
@[to_additive]
lemma preimage_mul_right_one' [group α] : (λ a, a * b⁻¹) ⁻¹' 1 = {b} := by simp
@[simp, to_additive]
lemma mul_singleton [has_mul α] : s * {b} = (λ a, a * b) '' s := image2_singleton_right
@[simp, to_additive]
lemma singleton_mul [has_mul α] : {a} * t = (λ b, a * b) '' t := image2_singleton_left
@[simp, to_additive]
lemma singleton_mul_singleton [has_mul α] : ({a} : set α) * {b} = {a * b} := image2_singleton
@[to_additive set.add_zero_class]
instance [mul_one_class α] : mul_one_class (set α) :=
{ mul_one := λ s, by { simp only [← singleton_one, mul_singleton, mul_one, image_id'] },
one_mul := λ s, by { simp only [← singleton_one, singleton_mul, one_mul, image_id'] },
..set.has_one, ..set.has_mul }
@[to_additive set.add_semigroup]
instance [semigroup α] : semigroup (set α) :=
{ mul_assoc := λ _ _ _, image2_assoc mul_assoc,
..set.has_mul }
@[to_additive set.add_monoid]
instance [monoid α] : monoid (set α) :=
{ ..set.semigroup,
..set.mul_one_class }
lemma pow_mem_pow [monoid α] (ha : a ∈ s) (n : ℕ) :
a ^ n ∈ s ^ n :=
begin
induction n with n ih,
{ rw pow_zero,
exact set.mem_singleton 1 },
{ rw pow_succ,
exact set.mul_mem_mul ha ih },
end
@[to_additive]
protected lemma mul_comm [comm_semigroup α] : s * t = t * s :=
by simp only [← image2_mul, image2_swap _ s, mul_comm]
@[to_additive set.add_comm_monoid]
instance [comm_monoid α] : comm_monoid (set α) :=
{ mul_comm := λ _ _, set.mul_comm, ..set.monoid }
@[to_additive]
lemma singleton.is_mul_hom [has_mul α] : is_mul_hom (singleton : α → set α) :=
{ map_mul := λ a b, singleton_mul_singleton.symm }
@[simp, to_additive]
lemma empty_mul [has_mul α] : ∅ * s = ∅ := image2_empty_left
@[simp, to_additive]
lemma mul_empty [has_mul α] : s * ∅ = ∅ := image2_empty_right
lemma empty_pow [monoid α] (n : ℕ) (hn : n ≠ 0) : (∅ : set α) ^ n = ∅ :=
by rw [←nat.sub_add_cancel (nat.pos_of_ne_zero hn), pow_succ, empty_mul]
instance decidable_mem_mul [monoid α] [fintype α] [decidable_eq α]
[decidable_pred (∈ s)] [decidable_pred (∈ t)] :
decidable_pred (∈ s * t) :=
λ _, decidable_of_iff _ mem_mul.symm
instance decidable_mem_pow [monoid α] [fintype α] [decidable_eq α]
[decidable_pred (∈ s)] (n : ℕ) :
decidable_pred (∈ (s ^ n)) :=
begin
induction n with n ih,
{ simp_rw [pow_zero, mem_one], apply_instance },
{ letI := ih, rw pow_succ, apply_instance }
end
@[to_additive]
lemma mul_subset_mul [has_mul α] (h₁ : s₁ ⊆ t₁) (h₂ : s₂ ⊆ t₂) : s₁ * s₂ ⊆ t₁ * t₂ :=
image2_subset h₁ h₂
lemma pow_subset_pow [monoid α] (hst : s ⊆ t) (n : ℕ) :
s ^ n ⊆ t ^ n :=
begin
induction n with n ih,
{ rw pow_zero,
exact subset.rfl },
{ rw [pow_succ, pow_succ],
exact mul_subset_mul hst ih },
end
@[to_additive]
lemma union_mul [has_mul α] : (s ∪ t) * u = (s * u) ∪ (t * u) := image2_union_left
@[to_additive]
lemma mul_union [has_mul α] : s * (t ∪ u) = (s * t) ∪ (s * u) := image2_union_right
@[to_additive]
lemma Union_mul_left_image [has_mul α] : (⋃ a ∈ s, (λ x, a * x) '' t) = s * t :=
Union_image_left _
@[to_additive]
lemma Union_mul_right_image [has_mul α] : (⋃ a ∈ t, (λ x, x * a) '' s) = s * t :=
Union_image_right _
@[simp, to_additive]
lemma univ_mul_univ [monoid α] : (univ : set α) * univ = univ :=
begin
have : ∀x, ∃a b : α, a * b = x := λx, ⟨x, ⟨1, mul_one x⟩⟩,
simpa only [mem_mul, eq_univ_iff_forall, mem_univ, true_and]
end
/-- `singleton` is a monoid hom. -/
@[to_additive singleton_add_hom "singleton is an add monoid hom"]
def singleton_hom [monoid α] : α →* set α :=
{ to_fun := singleton, map_one' := rfl, map_mul' := λ a b, singleton_mul_singleton.symm }
@[to_additive]
lemma nonempty.mul [has_mul α] : s.nonempty → t.nonempty → (s * t).nonempty := nonempty.image2
@[to_additive]
lemma finite.mul [has_mul α] (hs : finite s) (ht : finite t) : finite (s * t) :=
hs.image2 _ ht
/-- multiplication preserves finiteness -/
@[to_additive "addition preserves finiteness"]
def fintype_mul [has_mul α] [decidable_eq α] (s t : set α) [hs : fintype s] [ht : fintype t] :
fintype (s * t : set α) :=
set.fintype_image2 _ s t
@[to_additive]
lemma bdd_above_mul [ordered_comm_monoid α] {A B : set α} :
bdd_above A → bdd_above B → bdd_above (A * B) :=
begin
rintros ⟨bA, hbA⟩ ⟨bB, hbB⟩,
use bA * bB,
rintros x ⟨xa, xb, hxa, hxb, rfl⟩,
exact mul_le_mul' (hbA hxa) (hbB hxb),
end
section big_operators
open_locale big_operators
variables {ι : Type*} [comm_monoid α]
/-- The n-ary version of `set.mem_mul`. -/
@[to_additive /-" The n-ary version of `set.mem_add`. "-/]
lemma mem_finset_prod (t : finset ι) (f : ι → set α) (a : α) :
a ∈ ∏ i in t, f i ↔ ∃ (g : ι → α) (hg : ∀ {i}, i ∈ t → g i ∈ f i), ∏ i in t, g i = a :=
begin
classical,
induction t using finset.induction_on with i is hi ih generalizing a,
{ simp_rw [finset.prod_empty, set.mem_one],
exact ⟨λ h, ⟨λ i, a, λ i, false.elim, h.symm⟩, λ ⟨f, _, hf⟩, hf.symm⟩ },
rw [finset.prod_insert hi, set.mem_mul],
simp_rw [finset.prod_insert hi],
simp_rw ih,
split,
{ rintros ⟨x, y, hx, ⟨g, hg, rfl⟩, rfl⟩,
refine ⟨function.update g i x, λ j hj, _, _⟩,
obtain rfl | hj := finset.mem_insert.mp hj,
{ rw function.update_same, exact hx },
{ rw update_noteq (ne_of_mem_of_not_mem hj hi), exact hg hj, },
rw [finset.prod_update_of_not_mem hi, function.update_same], },
{ rintros ⟨g, hg, rfl⟩,
exact ⟨g i, is.prod g, hg (is.mem_insert_self _),
⟨g, λ i hi, hg (finset.mem_insert_of_mem hi), rfl⟩, rfl⟩ },
end
/-- A version of `set.mem_finset_prod` with a simpler RHS for products over a fintype. -/
@[to_additive /-" A version of `set.mem_finset_sum` with a simpler RHS for sums over a fintype. "-/]
lemma mem_fintype_prod [fintype ι] (f : ι → set α) (a : α) :
a ∈ ∏ i, f i ↔ ∃ (g : ι → α) (hg : ∀ i, g i ∈ f i), ∏ i, g i = a :=
by { rw mem_finset_prod, simp }
/-- The n-ary version of `set.mul_mem_mul`. -/
@[to_additive /-" The n-ary version of `set.add_mem_add`. "-/]
lemma finset_prod_mem_finset_prod (t : finset ι) (f : ι → set α)
(g : ι → α) (hg : ∀ i ∈ t, g i ∈ f i) :
∏ i in t, g i ∈ ∏ i in t, f i :=
by { rw mem_finset_prod, exact ⟨g, hg, rfl⟩ }
/-- The n-ary version of `set.mul_subset_mul`. -/
@[to_additive /-" The n-ary version of `set.add_subset_add`. "-/]
lemma finset_prod_subset_finset_prod (t : finset ι) (f₁ f₂ : ι → set α)
(hf : ∀ {i}, i ∈ t → f₁ i ⊆ f₂ i) :
∏ i in t, f₁ i ⊆ ∏ i in t, f₂ i :=
begin
intro a,
rw [mem_finset_prod, mem_finset_prod],
rintro ⟨g, hg, rfl⟩,
exact ⟨g, λ i hi, hf hi $ hg hi, rfl⟩
end
/-! TODO: define `decidable_mem_finset_prod` and `decidable_mem_finset_sum`. -/
end big_operators
/-! ### Properties about inversion -/
@[to_additive set.has_neg]
instance [has_inv α] : has_inv (set α) :=
⟨preimage has_inv.inv⟩
@[simp, to_additive]
lemma mem_inv [has_inv α] : a ∈ s⁻¹ ↔ a⁻¹ ∈ s := iff.rfl
@[to_additive]
lemma inv_mem_inv [group α] : a⁻¹ ∈ s⁻¹ ↔ a ∈ s :=
by simp only [mem_inv, inv_inv]
@[simp, to_additive]
lemma inv_preimage [has_inv α] : has_inv.inv ⁻¹' s = s⁻¹ := rfl
@[simp, to_additive]
lemma image_inv [group α] : has_inv.inv '' s = s⁻¹ :=
by { simp only [← inv_preimage], rw [image_eq_preimage_of_inverse]; intro; simp only [inv_inv] }
@[simp, to_additive]
lemma inter_inv [has_inv α] : (s ∩ t)⁻¹ = s⁻¹ ∩ t⁻¹ := preimage_inter
@[simp, to_additive]
lemma union_inv [has_inv α] : (s ∪ t)⁻¹ = s⁻¹ ∪ t⁻¹ := preimage_union
@[simp, to_additive]
lemma compl_inv [has_inv α] : (sᶜ)⁻¹ = (s⁻¹)ᶜ := preimage_compl
@[simp, to_additive]
protected lemma inv_inv [group α] : s⁻¹⁻¹ = s :=
by { simp only [← inv_preimage, preimage_preimage, inv_inv, preimage_id'] }
@[simp, to_additive]
protected lemma univ_inv [group α] : (univ : set α)⁻¹ = univ := preimage_univ
@[simp, to_additive]
lemma inv_subset_inv [group α] {s t : set α} : s⁻¹ ⊆ t⁻¹ ↔ s ⊆ t :=
(equiv.inv α).surjective.preimage_subset_preimage_iff
@[to_additive] lemma inv_subset [group α] {s t : set α} : s⁻¹ ⊆ t ↔ s ⊆ t⁻¹ :=
by { rw [← inv_subset_inv, set.inv_inv] }
@[to_additive] lemma finite.inv [group α] {s : set α} (hs : finite s) : finite s⁻¹ :=
hs.preimage $ inv_injective.inj_on _
/-! ### Properties about scalar multiplication -/
/-- Scaling a set: multiplying every element by a scalar. -/
instance has_scalar_set [has_scalar α β] : has_scalar α (set β) :=
⟨λ a, image (has_scalar.smul a)⟩
@[simp]
lemma image_smul [has_scalar α β] {t : set β} : (λ x, a • x) '' t = a • t := rfl
lemma mem_smul_set [has_scalar α β] {t : set β} : x ∈ a • t ↔ ∃ y, y ∈ t ∧ a • y = x := iff.rfl
lemma smul_mem_smul_set [has_scalar α β] {t : set β} (hy : y ∈ t) : a • y ∈ a • t :=
⟨y, hy, rfl⟩
lemma smul_set_union [has_scalar α β] {s t : set β} : a • (s ∪ t) = a • s ∪ a • t :=
by simp only [← image_smul, image_union]
@[simp]
lemma smul_set_empty [has_scalar α β] (a : α) : a • (∅ : set β) = ∅ :=
by rw [← image_smul, image_empty]
lemma smul_set_mono [has_scalar α β] {s t : set β} (h : s ⊆ t) : a • s ⊆ a • t :=
by { simp only [← image_smul, image_subset, h] }
/-- Pointwise scalar multiplication by a set of scalars. -/
instance [has_scalar α β] : has_scalar (set α) (set β) := ⟨image2 has_scalar.smul⟩
@[simp]
lemma image2_smul [has_scalar α β] {t : set β} : image2 has_scalar.smul s t = s • t := rfl
lemma mem_smul [has_scalar α β] {t : set β} : x ∈ s • t ↔ ∃ a y, a ∈ s ∧ y ∈ t ∧ a • y = x :=
iff.rfl
lemma image_smul_prod [has_scalar α β] {t : set β} :
(λ x : α × β, x.fst • x.snd) '' s.prod t = s • t :=
image_prod _
theorem range_smul_range [has_scalar α β] {ι κ : Type*} (b : ι → α) (c : κ → β) :
range b • range c = range (λ p : ι × κ, b p.1 • c p.2) :=
ext $ λ x, ⟨λ hx, let ⟨p, q, ⟨i, hi⟩, ⟨j, hj⟩, hpq⟩ := set.mem_smul.1 hx in
⟨(i, j), hpq ▸ hi ▸ hj ▸ rfl⟩,
λ ⟨⟨i, j⟩, h⟩, set.mem_smul.2 ⟨b i, c j, ⟨i, rfl⟩, ⟨j, rfl⟩, h⟩⟩
lemma singleton_smul [has_scalar α β] {t : set β} : ({a} : set α) • t = a • t :=
image2_singleton_left
instance smul_comm_class_set {γ : Type*}
[has_scalar α γ] [has_scalar β γ] [smul_comm_class α β γ] :
smul_comm_class α (set β) (set γ) :=
{ smul_comm := λ a T T',
by simp only [←image2_smul, ←image_smul, image2_image_right, image_image2, smul_comm] }
instance smul_comm_class_set' {γ : Type*}
[has_scalar α γ] [has_scalar β γ] [smul_comm_class α β γ] :
smul_comm_class (set α) β (set γ) :=
by haveI := smul_comm_class.symm α β γ; exact smul_comm_class.symm _ _ _
instance smul_comm_class {γ : Type*}
[has_scalar α γ] [has_scalar β γ] [smul_comm_class α β γ] :
smul_comm_class (set α) (set β) (set γ) :=
{ smul_comm := λ T T' T'', begin
simp only [←image2_smul, image2_swap _ T],
exact image2_assoc (λ b c a, smul_comm a b c),
end }
instance is_scalar_tower {γ : Type*}
[has_scalar α β] [has_scalar α γ] [has_scalar β γ] [is_scalar_tower α β γ] :
is_scalar_tower α β (set γ) :=
{ smul_assoc := λ a b T, by simp only [←image_smul, image_image, smul_assoc] }
instance is_scalar_tower' {γ : Type*}
[has_scalar α β] [has_scalar α γ] [has_scalar β γ] [is_scalar_tower α β γ] :
is_scalar_tower α (set β) (set γ) :=
{ smul_assoc := λ a T T',
by simp only [←image_smul, ←image2_smul, image_image2, image2_image_left, smul_assoc] }
instance is_scalar_tower'' {γ : Type*}
[has_scalar α β] [has_scalar α γ] [has_scalar β γ] [is_scalar_tower α β γ] :
is_scalar_tower (set α) (set β) (set γ) :=
{ smul_assoc := λ T T' T'', image2_assoc smul_assoc }
section monoid
/-! ### `set α` as a `(∪,*)`-semiring -/
/-- An alias for `set α`, which has a semiring structure given by `∪` as "addition" and pointwise
multiplication `*` as "multiplication". -/
@[derive inhabited] def set_semiring (α : Type*) : Type* := set α
/-- The identitiy function `set α → set_semiring α`. -/
protected def up (s : set α) : set_semiring α := s
/-- The identitiy function `set_semiring α → set α`. -/
protected def set_semiring.down (s : set_semiring α) : set α := s
@[simp] protected lemma down_up {s : set α} : s.up.down = s := rfl
@[simp] protected lemma up_down {s : set_semiring α} : s.down.up = s := rfl
instance set_semiring.add_comm_monoid : add_comm_monoid (set_semiring α) :=
{ add := λ s t, (s ∪ t : set α),
zero := (∅ : set α),
add_assoc := union_assoc,
zero_add := empty_union,
add_zero := union_empty,
add_comm := union_comm, }
instance set_semiring.non_unital_non_assoc_semiring [has_mul α] :
non_unital_non_assoc_semiring (set_semiring α) :=
{ zero_mul := λ s, empty_mul,
mul_zero := λ s, mul_empty,
left_distrib := λ _ _ _, mul_union,
right_distrib := λ _ _ _, union_mul,
..set.has_mul, ..set_semiring.add_comm_monoid }
instance set_semiring.non_assoc_semiring [mul_one_class α] : non_assoc_semiring (set_semiring α) :=
{ ..set_semiring.non_unital_non_assoc_semiring, ..set.mul_one_class }
instance set_semiring.non_unital_semiring [semigroup α] : non_unital_semiring (set_semiring α) :=
{ ..set_semiring.non_unital_non_assoc_semiring, ..set.semigroup }
instance set_semiring.semiring [monoid α] : semiring (set_semiring α) :=
{ ..set_semiring.non_assoc_semiring, ..set_semiring.non_unital_semiring }
instance set_semiring.comm_semiring [comm_monoid α] : comm_semiring (set_semiring α) :=
{ ..set.comm_monoid, ..set_semiring.semiring }
/-- A multiplicative action of a monoid on a type β gives also a
multiplicative action on the subsets of β. -/
instance mul_action_set [monoid α] [mul_action α β] : mul_action α (set β) :=
{ mul_smul := by { intros, simp only [← image_smul, image_image, ← mul_smul] },
one_smul := by { intros, simp only [← image_smul, image_eta, one_smul, image_id'] },
..set.has_scalar_set }
section is_mul_hom
open is_mul_hom
variables [has_mul α] [has_mul β] (m : α → β) [is_mul_hom m]
@[to_additive]
lemma image_mul : m '' (s * t) = m '' s * m '' t :=
by { simp only [← image2_mul, image_image2, image2_image_left, image2_image_right, map_mul m] }
@[to_additive]
lemma preimage_mul_preimage_subset {s t : set β} : m ⁻¹' s * m ⁻¹' t ⊆ m ⁻¹' (s * t) :=
by { rintros _ ⟨_, _, _, _, rfl⟩, exact ⟨_, _, ‹_›, ‹_›, (map_mul _ _ _).symm ⟩ }
end is_mul_hom
/-- The image of a set under function is a ring homomorphism
with respect to the pointwise operations on sets. -/
def image_hom [monoid α] [monoid β] (f : α →* β) : set_semiring α →+* set_semiring β :=
{ to_fun := image f,
map_zero' := image_empty _,
map_one' := by simp only [← singleton_one, image_singleton, is_monoid_hom.map_one f],
map_add' := image_union _,
map_mul' := λ _ _, image_mul _ }
end monoid
end set
open set
section
variables {α : Type*} {β : Type*}
/-- A nonempty set in a module is scaled by zero to the singleton
containing 0 in the module. -/
lemma zero_smul_set [semiring α] [add_comm_monoid β] [module α β] {s : set β} (h : s.nonempty) :
(0 : α) • s = (0 : set β) :=
by simp only [← image_smul, image_eta, zero_smul, h.image_const, singleton_zero]
lemma mem_inv_smul_set_iff [field α] [mul_action α β] {a : α} (ha : a ≠ 0) (A : set β) (x : β) :
x ∈ a⁻¹ • A ↔ a • x ∈ A :=
by simp only [← image_smul, mem_image, inv_smul_eq_iff' ha, exists_eq_right]
lemma mem_smul_set_iff_inv_smul_mem [field α] [mul_action α β] {a : α} (ha : a ≠ 0) (A : set β)
(x : β) : x ∈ a • A ↔ a⁻¹ • x ∈ A :=
by rw [← mem_inv_smul_set_iff $ inv_ne_zero ha, inv_inv']
end
namespace finset
variables {α : Type*} [decidable_eq α]
/-- The pointwise product of two finite sets `s` and `t`:
`st = s ⬝ t = s * t = { x * y | x ∈ s, y ∈ t }`. -/
@[to_additive "The pointwise sum of two finite sets `s` and `t`:
`s + t = { x + y | x ∈ s, y ∈ t }`."]
instance [has_mul α] : has_mul (finset α) :=
⟨λ s t, (s.product t).image (λ p : α × α, p.1 * p.2)⟩
@[to_additive]
lemma mul_def [has_mul α] {s t : finset α} :
s * t = (s.product t).image (λ p : α × α, p.1 * p.2) := rfl
@[to_additive]
lemma mem_mul [has_mul α] {s t : finset α} {x : α} :
x ∈ s * t ↔ ∃ y z, y ∈ s ∧ z ∈ t ∧ y * z = x :=
by { simp only [finset.mul_def, and.assoc, mem_image, exists_prop, prod.exists, mem_product] }
@[simp, norm_cast, to_additive]
lemma coe_mul [has_mul α] {s t : finset α} : (↑(s * t) : set α) = ↑s * ↑t :=
by { ext, simp only [mem_mul, set.mem_mul, mem_coe] }
@[to_additive]
lemma mul_mem_mul [has_mul α] {s t : finset α} {x y : α} (hx : x ∈ s) (hy : y ∈ t) :
x * y ∈ s * t :=
by { simp only [finset.mem_mul], exact ⟨x, y, hx, hy, rfl⟩ }
lemma add_card_le [has_add α] {s t : finset α} : (s + t).card ≤ s.card * t.card :=
by { convert finset.card_image_le, rw [finset.card_product, mul_comm] }
@[to_additive]
lemma mul_card_le [has_mul α] {s t : finset α} : (s * t).card ≤ s.card * t.card :=
by { convert finset.card_image_le, rw [finset.card_product, mul_comm] }
open_locale classical
/-- A finite set `U` contained in the product of two sets `S * S'` is also contained in the product
of two finite sets `T * T' ⊆ S * S'`. -/
@[to_additive]
lemma subset_mul {M : Type*} [monoid M] {S : set M} {S' : set M} {U : finset M} (f : ↑U ⊆ S * S') :
∃ (T T' : finset M), ↑T ⊆ S ∧ ↑T' ⊆ S' ∧ U ⊆ T * T' :=
begin
apply finset.induction_on' U,
{ use [∅, ∅], simp only [finset.empty_subset, finset.coe_empty, set.empty_subset, and_self], },
rintros a s haU hs has ⟨T, T', hS, hS', h⟩,
obtain ⟨x, y, hx, hy, ha⟩ := set.mem_mul.1 (f haU),
use [insert x T, insert y T'],
simp only [finset.coe_insert],
repeat { rw [set.insert_subset], },
use [hx, hS, hy, hS'],
refine finset.insert_subset.mpr ⟨_, _⟩,
{ rw finset.mem_mul,
use [x,y],
simpa only [true_and, true_or, eq_self_iff_true, finset.mem_insert], },
{ suffices g : (s : set M) ⊆ insert x T * insert y T', { norm_cast at g, assumption, },
transitivity ↑(T * T'),
apply h,
rw finset.coe_mul,
apply set.mul_subset_mul (set.subset_insert x T) (set.subset_insert y T'), },
end
end finset
/-! Some lemmas about pointwise multiplication and submonoids. Ideally we put these in
`group_theory.submonoid.basic`, but currently we cannot because that file is imported by this. -/
namespace submonoid
variables {M : Type*} [monoid M]
@[to_additive]
lemma mul_subset {s t : set M} {S : submonoid M} (hs : s ⊆ S) (ht : t ⊆ S) : s * t ⊆ S :=
by { rintro _ ⟨p, q, hp, hq, rfl⟩, exact submonoid.mul_mem _ (hs hp) (ht hq) }
@[to_additive]
lemma mul_subset_closure {s t u : set M} (hs : s ⊆ u) (ht : t ⊆ u) :
s * t ⊆ submonoid.closure u :=
mul_subset (subset.trans hs submonoid.subset_closure) (subset.trans ht submonoid.subset_closure)
@[to_additive]
lemma coe_mul_self_eq (s : submonoid M) : (s : set M) * s = s :=
begin
ext x,
refine ⟨_, λ h, ⟨x, 1, h, s.one_mem, mul_one x⟩⟩,
rintros ⟨a, b, ha, hb, rfl⟩,
exact s.mul_mem ha hb
end
@[to_additive]
lemma closure_mul_le (S T : set M) : closure (S * T) ≤ closure S ⊔ closure T :=
Inf_le $ λ x ⟨s, t, hs, ht, hx⟩, hx ▸ (closure S ⊔ closure T).mul_mem
(set_like.le_def.mp le_sup_left $ subset_closure hs)
(set_like.le_def.mp le_sup_right $ subset_closure ht)
@[to_additive]
lemma sup_eq_closure (H K : submonoid M) : H ⊔ K = closure (H * K) :=
le_antisymm
(sup_le
(λ h hh, subset_closure ⟨h, 1, hh, K.one_mem, mul_one h⟩)
(λ k hk, subset_closure ⟨1, k, H.one_mem, hk, one_mul k⟩))
(by conv_rhs { rw [← closure_eq H, ← closure_eq K] }; apply closure_mul_le)
end submonoid
namespace group
lemma card_pow_eq_card_pow_card_univ_aux {f : ℕ → ℕ} (h1 : monotone f)
{B : ℕ} (h2 : ∀ n, f n ≤ B) (h3 : ∀ n, f n = f (n + 1) → f (n + 1) = f (n + 2)) :
∀ k, B ≤ k → f k = f B :=
begin
have key : ∃ n : ℕ, n ≤ B ∧ f n = f (n + 1),
{ contrapose! h2,
suffices : ∀ n : ℕ, n ≤ B + 1 → n ≤ f n,
{ exact ⟨B + 1, this (B + 1) (le_refl (B + 1))⟩ },
exact λ n, nat.rec (λ h, nat.zero_le (f 0)) (λ n ih h, lt_of_le_of_lt (ih (n.le_succ.trans h))
(lt_of_le_of_ne (h1 n.le_succ) (h2 n (nat.succ_le_succ_iff.mp h)))) n },
{ obtain ⟨n, hn1, hn2⟩ := key,
replace key : ∀ k : ℕ, f (n + k) = f (n + k + 1) ∧ f (n + k) = f n :=
λ k, nat.rec ⟨hn2, rfl⟩ (λ k ih, ⟨h3 _ ih.1, ih.1.symm.trans ih.2⟩) k,
replace key : ∀ k : ℕ, n ≤ k → f k = f n :=
λ k hk, (congr_arg f (nat.add_sub_cancel' hk)).symm.trans (key (k - n)).2,
exact λ k hk, (key k (hn1.trans hk)).trans (key B hn1).symm },
end
variables {G : Type*} [group G] [fintype G] (S : set G)
lemma card_pow_eq_card_pow_card_univ [∀ (k : ℕ), decidable_pred (∈ (S ^ k))] :
∀ k, fintype.card G ≤ k → fintype.card ↥(S ^ k) = fintype.card ↥(S ^ (fintype.card G)) :=
begin
have hG : 0 < fintype.card G := fintype.card_pos_iff.mpr ⟨1⟩,
by_cases hS : S = ∅,
{ intros k hk,
congr' 2,
rw [hS, empty_pow _ (ne_of_gt (lt_of_lt_of_le hG hk)), empty_pow _ (ne_of_gt hG)] },
obtain ⟨a, ha⟩ := set.ne_empty_iff_nonempty.mp hS,
classical,
have key : ∀ a (s t : set G), (∀ b : G, b ∈ s → a * b ∈ t) → fintype.card s ≤ fintype.card t,
{ refine λ a s t h, fintype.card_le_of_injective (λ ⟨b, hb⟩, ⟨a * b, h b hb⟩) _,
rintros ⟨b, hb⟩ ⟨c, hc⟩ hbc,
exact subtype.ext (mul_left_cancel (subtype.ext_iff.mp hbc)) },
have mono : monotone (λ n, fintype.card ↥(S ^ n) : ℕ → ℕ) :=
monotone_of_monotone_nat (λ n, key a _ _ (λ b hb, set.mul_mem_mul ha hb)),
convert card_pow_eq_card_pow_card_univ_aux mono (λ n, set_fintype_card_le_univ (S ^ n))
(λ n h, le_antisymm (mono (n + 1).le_succ) (key a⁻¹ _ _ _)),
{ simp only [finset.filter_congr_decidable, fintype.card_of_finset] },
replace h : {a} * S ^ n = S ^ (n + 1),
{ refine set.eq_of_subset_of_card_le _ (le_trans (ge_of_eq h) _),
{ exact mul_subset_mul (set.singleton_subset_iff.mpr ha) set.subset.rfl },
{ convert key a (S ^ n) ({a} * S ^ n) (λ b hb, set.mul_mem_mul (set.mem_singleton a) hb) } },
rw [pow_succ', ←h, mul_assoc, ←pow_succ', h],
rintros _ ⟨b, c, hb, hc, rfl⟩,
rwa [set.mem_singleton_iff.mp hb, inv_mul_cancel_left],
end
end group
|
d70d89b10defe30c8e52d019c62b6a9c07230624 | ac89c256db07448984849346288e0eeffe8b20d0 | /src/Lean/Meta/WHNF.lean | b72ede6dc96957736f00523acf2370f3fdef65da | [
"Apache-2.0"
] | permissive | chepinzhang/lean4 | 002cc667f35417a418f0ebc9cb4a44559bb0ccac | 24fe2875c68549b5481f07c57eab4ad4a0ae5305 | refs/heads/master | 1,688,942,838,326 | 1,628,801,942,000 | 1,628,801,995,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 23,890 | 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
-/
import Lean.ToExpr
import Lean.AuxRecursor
import Lean.ProjFns
import Lean.Meta.Basic
import Lean.Meta.LevelDefEq
import Lean.Meta.GetConst
import Lean.Meta.Match.MatcherInfo
namespace Lean.Meta
/- ===========================
Smart unfolding support
=========================== -/
def smartUnfoldingSuffix := "_sunfold"
@[inline] def mkSmartUnfoldingNameFor (declName : Name) : Name :=
Name.mkStr declName smartUnfoldingSuffix
register_builtin_option smartUnfolding : Bool := {
defValue := true
descr := "when computing weak head normal form, use auxiliary definition created for functions defined by structural recursion"
}
/- ===========================
Helper methods
=========================== -/
def isAuxDef (constName : Name) : MetaM Bool := do
let env ← getEnv
return isAuxRecursor env constName || isNoConfusion env constName
@[inline] private def matchConstAux {α} (e : Expr) (failK : Unit → MetaM α) (k : ConstantInfo → List Level → MetaM α) : MetaM α :=
match e with
| Expr.const name lvls _ => do
let (some cinfo) ← getConst? name | failK ()
k cinfo lvls
| _ => failK ()
/- ===========================
Helper functions for reducing recursors
=========================== -/
private def getFirstCtor (d : Name) : MetaM (Option Name) := do
let some (ConstantInfo.inductInfo { ctors := ctor::_, ..}) ← getConstNoEx? d | pure none
return some ctor
private def mkNullaryCtor (type : Expr) (nparams : Nat) : MetaM (Option Expr) := do
match type.getAppFn with
| Expr.const d lvls _ =>
let (some ctor) ← getFirstCtor d | pure none
return mkAppN (mkConst ctor lvls) (type.getAppArgs.shrink nparams)
| _ =>
return none
def toCtorIfLit : Expr → Expr
| Expr.lit (Literal.natVal v) _ =>
if v == 0 then mkConst `Nat.zero
else mkApp (mkConst `Nat.succ) (mkRawNatLit (v-1))
| Expr.lit (Literal.strVal v) _ =>
mkApp (mkConst `String.mk) (toExpr v.toList)
| e => e
private def getRecRuleFor (recVal : RecursorVal) (major : Expr) : Option RecursorRule :=
match major.getAppFn with
| Expr.const fn _ _ => recVal.rules.find? fun r => r.ctor == fn
| _ => none
private def toCtorWhenK (recVal : RecursorVal) (major : Expr) : MetaM (Option Expr) := do
let majorType ← inferType major
let majorType ← instantiateMVars (← whnf majorType)
let majorTypeI := majorType.getAppFn
if !majorTypeI.isConstOf recVal.getInduct then
return none
else if majorType.hasExprMVar && majorType.getAppArgs[recVal.numParams:].any Expr.hasExprMVar then
return none
else do
let (some newCtorApp) ← mkNullaryCtor majorType recVal.numParams | pure none
let newType ← inferType newCtorApp
if (← isDefEq majorType newType) then
return newCtorApp
else
return none
/-- Auxiliary function for reducing recursor applications. -/
private def reduceRec (recVal : RecursorVal) (recLvls : List Level) (recArgs : Array Expr) (failK : Unit → MetaM α) (successK : Expr → MetaM α) : MetaM α :=
let majorIdx := recVal.getMajorIdx
if h : majorIdx < recArgs.size then do
let major := recArgs.get ⟨majorIdx, h⟩
let mut major ← whnf major
if recVal.k then
let newMajor ← toCtorWhenK recVal major
major := newMajor.getD major
major := toCtorIfLit major
match getRecRuleFor recVal major with
| some rule =>
let majorArgs := major.getAppArgs
if recLvls.length != recVal.levelParams.length then
failK ()
else
let rhs := rule.rhs.instantiateLevelParams recVal.levelParams recLvls
-- Apply parameters, motives and minor premises from recursor application.
let rhs := mkAppRange rhs 0 (recVal.numParams+recVal.numMotives+recVal.numMinors) recArgs
/- The number of parameters in the constructor is not necessarily
equal to the number of parameters in the recursor when we have
nested inductive types. -/
let nparams := majorArgs.size - rule.nfields
let rhs := mkAppRange rhs nparams majorArgs.size majorArgs
let rhs := mkAppRange rhs (majorIdx + 1) recArgs.size recArgs
successK rhs
| none => failK ()
else
failK ()
/- ===========================
Helper functions for reducing Quot.lift and Quot.ind
=========================== -/
/-- Auxiliary function for reducing `Quot.lift` and `Quot.ind` applications. -/
private def reduceQuotRec (recVal : QuotVal) (recLvls : List Level) (recArgs : Array Expr) (failK : Unit → MetaM α) (successK : Expr → MetaM α) : MetaM α :=
let process (majorPos argPos : Nat) : MetaM α :=
if h : majorPos < recArgs.size then do
let major := recArgs.get ⟨majorPos, h⟩
let major ← whnf major
match major with
| Expr.app (Expr.app (Expr.app (Expr.const majorFn _ _) _ _) _ _) majorArg _ => do
let some (ConstantInfo.quotInfo { kind := QuotKind.ctor, .. }) ← getConstNoEx? majorFn | failK ()
let f := recArgs[argPos]
let r := mkApp f majorArg
let recArity := majorPos + 1
successK $ mkAppRange r recArity recArgs.size recArgs
| _ => failK ()
else
failK ()
match recVal.kind with
| QuotKind.lift => process 5 3
| QuotKind.ind => process 4 3
| _ => failK ()
/- ===========================
Helper function for extracting "stuck term"
=========================== -/
mutual
private partial def isRecStuck? (recVal : RecursorVal) (recLvls : List Level) (recArgs : Array Expr) : MetaM (Option MVarId) :=
if recVal.k then
-- TODO: improve this case
return none
else do
let majorIdx := recVal.getMajorIdx
if h : majorIdx < recArgs.size then do
let major := recArgs.get ⟨majorIdx, h⟩
let major ← whnf major
getStuckMVar? major
else
return none
private partial def isQuotRecStuck? (recVal : QuotVal) (recLvls : List Level) (recArgs : Array Expr) : MetaM (Option MVarId) :=
let process? (majorPos : Nat) : MetaM (Option MVarId) :=
if h : majorPos < recArgs.size then do
let major := recArgs.get ⟨majorPos, h⟩
let major ← whnf major
getStuckMVar? major
else
return none
match recVal.kind with
| QuotKind.lift => process? 5
| QuotKind.ind => process? 4
| _ => return none
/-- Return `some (Expr.mvar mvarId)` if metavariable `mvarId` is blocking reduction. -/
partial def getStuckMVar? : Expr → MetaM (Option MVarId)
| Expr.mdata _ e _ => getStuckMVar? e
| Expr.proj _ _ e _ => do getStuckMVar? (← whnf e)
| e@(Expr.mvar ..) => do
let e ← instantiateMVars e
match e with
| Expr.mvar mvarId _ => pure (some mvarId)
| _ => getStuckMVar? e
| e@(Expr.app f _ _) =>
let f := f.getAppFn
match f with
| Expr.mvar mvarId _ => return some mvarId
| Expr.const fName fLvls _ => do
let cinfo? ← getConstNoEx? fName
match cinfo? with
| some $ ConstantInfo.recInfo recVal => isRecStuck? recVal fLvls e.getAppArgs
| some $ ConstantInfo.quotInfo recVal => isQuotRecStuck? recVal fLvls e.getAppArgs
| _ => return none
| _ => return none
| _ => return none
end
/- ===========================
Weak Head Normal Form auxiliary combinators
=========================== -/
/-- Auxiliary combinator for handling easy WHNF cases. It takes a function for handling the "hard" cases as an argument -/
@[specialize] partial def whnfEasyCases (e : Expr) (k : Expr → MetaM Expr) : MetaM Expr := do
match e with
| Expr.forallE .. => return e
| Expr.lam .. => return e
| Expr.sort .. => return e
| Expr.lit .. => return e
| Expr.bvar .. => unreachable!
| Expr.letE .. => k e
| Expr.const .. => k e
| Expr.app .. => k e
| Expr.proj .. => k e
| Expr.mdata _ e _ => whnfEasyCases e k
| Expr.fvar fvarId _ =>
let decl ← getLocalDecl fvarId
match decl with
| LocalDecl.cdecl .. => return e
| LocalDecl.ldecl (value := v) (nonDep := nonDep) .. =>
let cfg ← getConfig
if nonDep && !cfg.zetaNonDep then
return e
else
if cfg.trackZeta then
modify fun s => { s with zetaFVarIds := s.zetaFVarIds.insert fvarId }
whnfEasyCases v k
| Expr.mvar mvarId _ =>
match (← getExprMVarAssignment? mvarId) with
| some v => whnfEasyCases v k
| none => return e
/-- Return true iff term is of the form `idRhs ...` -/
private def isIdRhsApp (e : Expr) : Bool :=
e.isAppOf `idRhs
/-- (@idRhs T f a_1 ... a_n) ==> (f a_1 ... a_n) -/
private def extractIdRhs (e : Expr) : Expr :=
if !isIdRhsApp e then e
else
let args := e.getAppArgs
if args.size < 2 then e
else mkAppRange args[1] 2 args.size args
@[specialize] private def deltaDefinition (c : ConstantInfo) (lvls : List Level)
(failK : Unit → α) (successK : Expr → α) : α :=
if c.levelParams.length != lvls.length then failK ()
else
let val := c.instantiateValueLevelParams lvls
successK (extractIdRhs val)
@[specialize] private def deltaBetaDefinition (c : ConstantInfo) (lvls : List Level) (revArgs : Array Expr)
(failK : Unit → α) (successK : Expr → α) : α :=
if c.levelParams.length != lvls.length then
failK ()
else
let val := c.instantiateValueLevelParams lvls
let val := val.betaRev revArgs
successK (extractIdRhs val)
inductive ReduceMatcherResult where
| reduced (val : Expr)
| stuck (val : Expr)
| notMatcher
| partialApp
def reduceMatcher? (e : Expr) : MetaM ReduceMatcherResult := do
match e.getAppFn with
| Expr.const declName declLevels _ =>
let some info ← getMatcherInfo? declName
| return ReduceMatcherResult.notMatcher
let args := e.getAppArgs
let prefixSz := info.numParams + 1 + info.numDiscrs
if args.size < prefixSz + info.numAlts then
return ReduceMatcherResult.partialApp
else
let constInfo ← getConstInfo declName
let f := constInfo.instantiateValueLevelParams declLevels
let auxApp := mkAppN f args[0:prefixSz]
let auxAppType ← inferType auxApp
forallBoundedTelescope auxAppType info.numAlts fun hs _ => do
let auxApp := mkAppN auxApp hs
let auxApp ← whnf auxApp
let auxAppFn := auxApp.getAppFn
let mut i := prefixSz
for h in hs do
if auxAppFn == h then
let result := mkAppN args[i] auxApp.getAppArgs
let result := mkAppN result args[prefixSz + info.numAlts:args.size]
return ReduceMatcherResult.reduced result.headBeta
i := i + 1
return ReduceMatcherResult.stuck auxApp
| _ => pure ReduceMatcherResult.notMatcher
/- Given an expression `e`, compute its WHNF and if the result is a constructor, return field #i. -/
def project? (e : Expr) (i : Nat) : MetaM (Option Expr) := do
let e ← whnf e
let e := toCtorIfLit e
matchConstCtor e.getAppFn (fun _ => pure none) fun ctorVal _ =>
let numArgs := e.getAppNumArgs
let idx := ctorVal.numParams + i
if idx < numArgs then
return some (e.getArg! idx)
else
return none
/-- Reduce kernel projection `Expr.proj ..` expression. -/
def reduceProj? (e : Expr) : MetaM (Option Expr) := do
match e with
| Expr.proj _ i c _ => project? c i
| _ => return none
/-
Auxiliary method for reducing terms of the form `?m t_1 ... t_n` where `?m` is delayed assigned.
Recall that we can only expand a delayed assignment when all holes/metavariables in the assigned value have been "filled".
-/
private def whnfDelayedAssigned? (f' : Expr) (e : Expr) : MetaM (Option Expr) := do
if f'.isMVar then
match (← getDelayedAssignment? f'.mvarId!) with
| none => return none
| some { fvars := fvars, val := val, .. } =>
let args := e.getAppArgs
if fvars.size > args.size then
-- Insufficient number of argument to expand delayed assignment
return none
else
let newVal ← instantiateMVars val
if newVal.hasExprMVar then
-- Delayed assignment still contains metavariables
return none
else
let newVal := newVal.abstract fvars
let result := newVal.instantiateRevRange 0 fvars.size args
return mkAppRange result fvars.size args.size args
else
return none
/--
Apply beta-reduction, zeta-reduction (i.e., unfold let local-decls), iota-reduction,
expand let-expressions, expand assigned meta-variables. -/
partial def whnfCore (e : Expr) : MetaM Expr :=
whnfEasyCases e fun e => do
trace[Meta.whnf] e
match e with
| Expr.const .. => pure e
| Expr.letE _ _ v b _ => whnfCore $ b.instantiate1 v
| Expr.app f .. =>
let f := f.getAppFn
let f' ← whnfCore f
if f'.isLambda then
let revArgs := e.getAppRevArgs
whnfCore <| f'.betaRev revArgs
else if let some eNew ← whnfDelayedAssigned? f' e then
whnfCore eNew
else
let e := if f == f' then e else e.updateFn f'
match (← reduceMatcher? e) with
| ReduceMatcherResult.reduced eNew => whnfCore eNew
| ReduceMatcherResult.partialApp => pure e
| ReduceMatcherResult.stuck _ => pure e
| ReduceMatcherResult.notMatcher =>
matchConstAux f' (fun _ => return e) fun cinfo lvls =>
match cinfo with
| ConstantInfo.recInfo rec => reduceRec rec lvls e.getAppArgs (fun _ => return e) whnfCore
| ConstantInfo.quotInfo rec => reduceQuotRec rec lvls e.getAppArgs (fun _ => return e) whnfCore
| c@(ConstantInfo.defnInfo _) => do
if (← isAuxDef c.name) then
deltaBetaDefinition c lvls e.getAppRevArgs (fun _ => return e) whnfCore
else
return e
| _ => return e
| Expr.proj .. => match (← reduceProj? e) with
| some e => whnfCore e
| none => return e
| _ => unreachable!
mutual
/-- Reduce `e` until `idRhs` application is exposed or it gets stuck.
This is a helper method for implementing smart unfolding. -/
private partial def whnfUntilIdRhs (e : Expr) : MetaM Expr := do
let e ← whnfCore e
match (← getStuckMVar? e) with
| some mvarId =>
/- Try to "unstuck" by resolving pending TC problems -/
if (← Meta.synthPending mvarId) then
whnfUntilIdRhs e
else
return e -- failed because metavariable is blocking reduction
| _ =>
if isIdRhsApp e then
return e -- done
else
match (← unfoldDefinition? e) with
| some e => whnfUntilIdRhs e
| none => pure e -- failed because of symbolic argument
/--
Auxiliary method for unfolding a class projection when transparency is set to `TransparencyMode.instances`.
Recall that class instance projections are not marked with `[reducible]` because we want them to be
in "reducible canonical form".
-/
private partial def unfoldProjInst (e : Expr) : MetaM (Option Expr) := do
if (← getTransparency) != TransparencyMode.instances then
return none
else
match e.getAppFn with
| Expr.const declName .. =>
match (← getProjectionFnInfo? declName) with
| some { fromClass := true, .. } =>
match (← withDefault <| unfoldDefinition? e) with
| none => return none
| some e =>
match (← reduceProj? e.getAppFn) with
| none => return none
| some r => return mkAppN r e.getAppArgs |>.headBeta
| _ => return none
| _ => return none
/-- Unfold definition using "smart unfolding" if possible. -/
partial def unfoldDefinition? (e : Expr) : MetaM (Option Expr) :=
match e with
| Expr.app f _ _ =>
matchConstAux f.getAppFn (fun _ => unfoldProjInst e) fun fInfo fLvls => do
if fInfo.levelParams.length != fLvls.length then
return none
else
let unfoldDefault (_ : Unit) : MetaM (Option Expr) :=
if fInfo.hasValue then
deltaBetaDefinition fInfo fLvls e.getAppRevArgs (fun _ => pure none) (fun e => pure (some e))
else
return none
if smartUnfolding.get (← getOptions) then
let fAuxInfo? ← getConstNoEx? (mkSmartUnfoldingNameFor fInfo.name)
match fAuxInfo? with
| some fAuxInfo@(ConstantInfo.defnInfo _) =>
deltaBetaDefinition fAuxInfo fLvls e.getAppRevArgs (fun _ => pure none) fun e₁ => do
let e₂ ← whnfUntilIdRhs e₁
if isIdRhsApp e₂ then
return some (extractIdRhs e₂)
else
return none
| _ => unfoldDefault ()
else
unfoldDefault ()
| Expr.const declName lvls _ => do
if smartUnfolding.get (← getOptions) && (← getEnv).contains (mkSmartUnfoldingNameFor declName) then
return none
else
let (some (cinfo@(ConstantInfo.defnInfo _))) ← getConstNoEx? declName | pure none
deltaDefinition cinfo lvls
(fun _ => pure none)
(fun e => pure (some e))
| _ => return none
end
def unfoldDefinition (e : Expr) : MetaM Expr := do
let some e ← unfoldDefinition? e | throwError "failed to unfold definition{indentExpr e}"
return e
@[specialize] partial def whnfHeadPred (e : Expr) (pred : Expr → MetaM Bool) : MetaM Expr :=
whnfEasyCases e fun e => do
let e ← whnfCore e
if (← pred e) then
match (← unfoldDefinition? e) with
| some e => whnfHeadPred e pred
| none => return e
else
return e
def whnfUntil (e : Expr) (declName : Name) : MetaM (Option Expr) := do
let e ← whnfHeadPred e (fun e => return !e.isAppOf declName)
if e.isAppOf declName then
return e
else
return none
/-- Try to reduce matcher/recursor/quot applications. We say they are all "morally" recursor applications. -/
def reduceRecMatcher? (e : Expr) : MetaM (Option Expr) := do
if !e.isApp then
return none
else match (← reduceMatcher? e) with
| ReduceMatcherResult.reduced e => return e
| _ => matchConstAux e.getAppFn (fun _ => pure none) fun cinfo lvls => do
match cinfo with
| ConstantInfo.recInfo «rec» => reduceRec «rec» lvls e.getAppArgs (fun _ => pure none) (fun e => pure (some e))
| ConstantInfo.quotInfo «rec» => reduceQuotRec «rec» lvls e.getAppArgs (fun _ => pure none) (fun e => pure (some e))
| c@(ConstantInfo.defnInfo _) =>
if (← isAuxDef c.name) then
deltaBetaDefinition c lvls e.getAppRevArgs (fun _ => pure none) (fun e => pure (some e))
else
return none
| _ => return none
unsafe def reduceBoolNativeUnsafe (constName : Name) : MetaM Bool := evalConstCheck Bool `Bool constName
unsafe def reduceNatNativeUnsafe (constName : Name) : MetaM Nat := evalConstCheck Nat `Nat constName
@[implementedBy reduceBoolNativeUnsafe] constant reduceBoolNative (constName : Name) : MetaM Bool
@[implementedBy reduceNatNativeUnsafe] constant reduceNatNative (constName : Name) : MetaM Nat
def reduceNative? (e : Expr) : MetaM (Option Expr) :=
match e with
| Expr.app (Expr.const fName _ _) (Expr.const argName _ _) _ =>
if fName == `Lean.reduceBool then do
return toExpr (← reduceBoolNative argName)
else if fName == `Lean.reduceNat then do
return toExpr (← reduceNatNative argName)
else
return none
| _ =>
return none
@[inline] def withNatValue {α} (a : Expr) (k : Nat → MetaM (Option α)) : MetaM (Option α) := do
let a ← whnf a
match a with
| Expr.const `Nat.zero _ _ => k 0
| Expr.lit (Literal.natVal v) _ => k v
| _ => return none
def reduceUnaryNatOp (f : Nat → Nat) (a : Expr) : MetaM (Option Expr) :=
withNatValue a fun a =>
return mkRawNatLit <| f a
def reduceBinNatOp (f : Nat → Nat → Nat) (a b : Expr) : MetaM (Option Expr) :=
withNatValue a fun a =>
withNatValue b fun b => do
trace[Meta.isDefEq.whnf.reduceBinOp] "{a} op {b}"
return mkRawNatLit <| f a b
def reduceBinNatPred (f : Nat → Nat → Bool) (a b : Expr) : MetaM (Option Expr) := do
withNatValue a fun a =>
withNatValue b fun b =>
return toExpr <| f a b
def reduceNat? (e : Expr) : MetaM (Option Expr) :=
if e.hasFVar || e.hasMVar then
return none
else match e with
| Expr.app (Expr.const fn _ _) a _ =>
if fn == `Nat.succ then
reduceUnaryNatOp Nat.succ a
else
return none
| Expr.app (Expr.app (Expr.const fn _ _) a1 _) a2 _ =>
if fn == `Nat.add then reduceBinNatOp Nat.add a1 a2
else if fn == `Nat.sub then reduceBinNatOp Nat.sub a1 a2
else if fn == `Nat.mul then reduceBinNatOp Nat.mul a1 a2
else if fn == `Nat.div then reduceBinNatOp Nat.div a1 a2
else if fn == `Nat.mod then reduceBinNatOp Nat.mod a1 a2
else if fn == `Nat.beq then reduceBinNatPred Nat.beq a1 a2
else if fn == `Nat.ble then reduceBinNatPred Nat.ble a1 a2
else return none
| _ =>
return none
@[inline] private def useWHNFCache (e : Expr) : MetaM Bool := do
-- We cache only closed terms without expr metavars.
-- Potential refinement: cache if `e` is not stuck at a metavariable
if e.hasFVar || e.hasExprMVar then
return false
else
match (← getConfig).transparency with
| TransparencyMode.default => true
| TransparencyMode.all => true
| _ => false
@[inline] private def cached? (useCache : Bool) (e : Expr) : MetaM (Option Expr) := do
if useCache then
match (← getConfig).transparency with
| TransparencyMode.default => return (← get).cache.whnfDefault.find? e
| TransparencyMode.all => return (← get).cache.whnfAll.find? e
| _ => unreachable!
else
return none
private def cache (useCache : Bool) (e r : Expr) : MetaM Expr := do
if useCache then
match (← getConfig).transparency with
| TransparencyMode.default => modify fun s => { s with cache.whnfDefault := s.cache.whnfDefault.insert e r }
| TransparencyMode.all => modify fun s => { s with cache.whnfAll := s.cache.whnfAll.insert e r }
| _ => unreachable!
return r
@[export lean_whnf]
partial def whnfImp (e : Expr) : MetaM Expr :=
withIncRecDepth <| whnfEasyCases e fun e => do
checkMaxHeartbeats "whnf"
let useCache ← useWHNFCache e
match (← cached? useCache e) with
| some e' => pure e'
| none =>
let e' ← whnfCore e
match (← reduceNat? e') with
| some v => cache useCache e v
| none =>
match (← reduceNative? e') with
| some v => cache useCache e v
| none =>
match (← unfoldDefinition? e') with
| some e => whnfImp e
| none => cache useCache e e'
/-- If `e` is a projection function that satisfies `p`, then reduce it -/
def reduceProjOf? (e : Expr) (p : Name → Bool) : MetaM (Option Expr) := do
if !e.isApp then
pure none
else match e.getAppFn with
| Expr.const name .. => do
let env ← getEnv
match env.getProjectionStructureName? name with
| some structName =>
if p structName then
Meta.unfoldDefinition? e
else
pure none
| none => pure none
| _ => pure none
builtin_initialize
registerTraceClass `Meta.whnf
end Lean.Meta
|
90bc83d257c633558fa3dcd6e5f8be347617e55f | ea5678cc400c34ff95b661fa26d15024e27ea8cd | /alternating2.lean | 9351ec59e14b68814e9c86bb76a1a49429640c7c | [] | no_license | ChrisHughes24/leanstuff | dca0b5349c3ed893e8792ffbd98cbcadaff20411 | 9efa85f72efaccd1d540385952a6acc18fce8687 | refs/heads/master | 1,654,883,241,759 | 1,652,873,885,000 | 1,652,873,885,000 | 134,599,537 | 1 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 13,099 | 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 group_theory.perm group_theory.order_of_element group_theory.quotient_group
universes u v
open finset is_subgroup equiv equiv.perm quotient_group
instance {α β : Type*} [group α] [group β] [decidable_eq β] (f : α → β) [is_group_hom f] :
decidable_pred (is_group_hom.ker f) :=
λ _, decidable_of_iff _ (is_group_hom.mem_ker f).symm
def alternating (α : Type*) [decidable_eq α] [fintype α] : Type* :=
is_group_hom.ker (sign : perm α → units ℤ)
def perm.of_list_swap (α : Type*) [decidable_eq α] [fintype α] :
list {x : α × α // x.1 ≠ x.2} → perm α
| [] := 1
| (⟨(a, b), _⟩ :: l) := swap a b * perm.of_list_swap l
/- not definitionally equal to `subtype.decidable_eq`, since `subtype.decidable_eq` does
not reduce in the kernel -/
instance (α : Type*) [decidable_eq α] [fintype α] : decidable_eq (alternating α) :=
λ a b, decidable_of_iff (a.1 = b.1) (by cases a; cases b; simp [subtype.mk.inj_eq])
instance (α : Type*) [decidable_eq α] [fintype α] : fintype (alternating α) :=
set_fintype _
instance (α : Type*) [decidable_eq α] [fintype α] : group (alternating α) :=
by unfold alternating; apply_instance
section classical
local attribute [instance, priority 0] classical.prop_decidable
lemma card_alternating {α : Type*} [decidable_eq α] [fintype α] (h : 2 ≤ fintype.card α):
fintype.card (alternating α) = (fintype.card α).fact / 2 :=
have (quotient_group.quotient (is_group_hom.ker (sign : perm α → units ℤ))) ≃ units ℤ,
from quotient_ker_equiv_of_surjective _ (sign_surjective h),
(nat.mul_right_inj (show 0 < 2, from dec_trivial)).1 $
calc fintype.card (alternating α) * 2 = fintype.card (units ℤ × alternating α) :
by rw [mul_comm, fintype.card_prod, fintype.card_units_int]
... = fintype.card (perm α) : fintype.card_congr
(calc (units ℤ × alternating α) ≃
(quotient_group.quotient (is_group_hom.ker (sign : perm α → units ℤ)) × alternating α) :
equiv.prod_congr this.symm (by refl)
... ≃ perm α : (group_equiv_quotient_times_subgroup _).symm)
... = (fintype.card α).fact : fintype.card_perm
... = (fintype.card α).fact / 2 * 2 : eq.symm $
nat.div_mul_cancel (nat.dvd_fact dec_trivial h)
end classical
local notation `A5` := alternating (fin 5)
variables {α : Type*} [fintype α] [decidable_eq α]
section meta_
local attribute [semireducible] reflected
meta instance fin_reflect (n : ℕ) : has_reflect (fin n) :=
λ a, `(@fin.mk %%`(n) %%(nat.reflect a.1) (of_as_true %%`(_root_.trivial)))
meta instance fin_fun.has_reflect : has_reflect (fin 5 → fin 5) :=
list.rec_on (quot.unquot (@univ (fin 5) _).1)
(λ f, `(λ y : fin 5, y))
(λ x l ih f, let e := ih f in
if f x = x then e
else let ex := fin_reflect 5 x in
let efx := fin_reflect 5 (f x) in
if e = `(λ y : fin 5, y)
then `(λ y : fin 5, ite (y = %%ex) (%%efx) y)
else `(λ y : fin 5, ite (y = %%ex) (%%efx) ((%%e : fin 5 → fin 5) y)))
meta instance : has_reflect (perm (fin 5)) :=
λ f, `(@equiv.mk.{1 1} (fin 5) (fin 5)
%%(fin_fun.has_reflect f.to_fun)
%%(fin_fun.has_reflect f.inv_fun)
(of_as_true %%`(_root_.trivial)) (of_as_true %%`(_root_.trivial)))
meta instance I1 : has_reflect A5 :=
λ f, `(@subtype.mk (perm (fin 5)) (is_group_hom.ker (sign : perm (fin 5) → units ℤ))
%%(@reflect (perm (fin 5)) f.1 (equiv.perm.has_reflect f.1))
((is_group_hom.mem_ker sign).2 %%`(@eq.refl (units ℤ) 1)))
meta instance multiset.has_reflect {α : Type} [reflected α] [has_reflect α] :
has_reflect (multiset α) :=
λ s, let l : list α := quot.unquot s in `(@quotient.mk.{1} (list %%`(α)) _ %%`(l))
meta instance I2 (a : A5) :
has_reflect {b : A5 × A5 // b.2 * a * b.2⁻¹ = b.1} :=
λ b, `(@subtype.mk (A5 × A5)
(λ b, b.2 * %%`(a) * b.2⁻¹ = b.1)
%%(prod.has_reflect _ _ b.1) (of_as_true %%`(_root_.trivial)))
meta instance I3 : reflected (A5 × A5) :=
`(A5 × A5)
meta instance I4 : has_reflect (A5 × multiset (A5 × A5)) :=
λ s, let ra : reflected s.1 := (I1 s.1) in
`(let a : A5 := %%ra in
@prod.mk A5 (multiset (A5 × A5))
a %%(multiset.has_reflect s.2))
meta instance I5 : has_reflect (A5 × list (A5 × A5)) :=
λ s, let ra : reflected s.1 := (I1 s.1) in
`(let a : A5 := %%ra in
@prod.mk A5 (list (A5 × A5))
a %%`(s.2))
meta def conjugacy_classes_A5_meta_aux : list A5 → list (A5 × list (A5 × A5))
| [] := []
| (a :: l) :=
let m : A5 × list (A5 × A5) :=
⟨a, ((quot.unquot (@univ A5 _).1).map
(λ x, show A5 × A5,
from (x * a * x⁻¹, x))).pw_filter (λ x y, x.1 ≠ y.1)⟩ in
m :: conjugacy_classes_A5_meta_aux (l.diff (m.2.map prod.fst))
meta def conjugacy_classes_A5_meta : multiset (A5 × multiset (A5 × A5)) :=
(quotient.mk ((conjugacy_classes_A5_meta_aux (quot.unquot univ.1)).map
(λ a, ⟨a.1, (quotient.mk a.2)⟩)))
meta def exact_reflect {α : Sort*} [has_reflect α] (a : α) : tactic unit :=
tactic.exact `(a)
end meta_
@[irreducible] def conjugacy_classes_A5_aux :
multiset (A5 × multiset (A5 × A5)) :=
by exact_reflect (conjugacy_classes_A5_meta)
def conjugacy_classes_A5_aux_list : list (A5 × list (A5 × A5)) :=
by exact_reflect (conjugacy_classes_A5_meta_aux (quot.unquot finset.univ.1))
#print conjugacy_classes_A5_aux
def conjugacy_classes_A5_aux2 : multiset (multiset A5) :=
conjugacy_classes_A5_aux.map (λ s, s.2.map prod.fst)
lemma nodup_conjugacy_classes_A5_aux2_bind : (conjugacy_classes_A5_aux2.bind id).nodup :=
dec_trivial
--#reduce nodup_conjugacy_classes_A5_aux2_bind
lemma nodup_conjugacy_classes_A5_aux2 : ∀ s : multiset A5,
s ∈ conjugacy_classes_A5_aux2 → s.nodup :=
(multiset.nodup_bind.1 nodup_conjugacy_classes_A5_aux2_bind).1
def conjugacy_classes_A5 : finset (finset A5) :=
⟨conjugacy_classes_A5_aux2.pmap finset.mk nodup_conjugacy_classes_A5_aux2, dec_trivial⟩
lemma nodup_conjugacy_classes_A5_bind : (conjugacy_classes_A5.1.bind finset.val).nodup :=
have conjugacy_classes_A5.1.bind finset.val =
conjugacy_classes_A5_aux2.bind id,
from multiset.ext.2 $ λ a,
by rw [conjugacy_classes_A5, @multiset.count_bind A5, @multiset.count_bind A5,
multiset.map_pmap, multiset.pmap_eq_map]; refl,
by rw this; exact nodup_conjugacy_classes_A5_aux2_bind
lemma g : ∀ x ∈ [0,0,0,0,0,0,0], x = 0 := dec_trivial
lemma ajfh : [0,1,2,3,4,5,6].nodup := dec_trivial
local attribute [instance, priority 1000] finset.decidable_dforall_finset
#print of_as_true
lemma is_conj_conjugacy_classes_A5 : ∀ x : A5 × A5 × A5,
x ∈ conjugacy_classes_A5_aux_list.bind (λ s, s.2.map (λ y : A5 × A5, (s.1, y))) →
x.2.2 * x.1 * x.2.2⁻¹ = x.2.1 :=
@of_as_true _ (list.decidable_forall_mem _) (by trivial)
-- #print list.mem
-- lemma is_conj_conjugacy_classes_A5 : ∀ x : A5 × A5 × A5,
-- x ∈ conjugacy_classes_A5_aux_list.bind (λ s, s.2.map (λ y : A5 × A5, (s.1, y))) →
-- x.2.2 * x.1 * x.2.2⁻¹ = x.2.1 :=
-- begin
-- assume x hx,
-- repeat { refine or.rec_on hx (λ h, by rw h; exact dec_trivial)
-- (λ hx, _) <|> assumption },
-- end
lemma is_conj_conjugacy_classes_A5 (s : finset A5) (h : s ∈ conjugacy_classes_A5) :
∀ x y ∈ s, is_conj x y :=
assume x y hx hy,
begin
simp only [conjugacy_classes_A5, finset.mem_def, multiset.mem_pmap,
conjugacy_classes_A5_aux2] at h,
rcases h with ⟨t, ht₁, ht₂⟩,
rw [multiset.mem_map] at ht₁,
rcases ht₁ with ⟨u, hu₁, hu₂⟩,
have hx' : x ∈ multiset.map (λ (b : {b : A5 × A5 // b.2 * u.1 * b.2⁻¹ = b.1}), b.1.1) u.2,
{ simpa [ht₂.symm, hu₂] using hx },
have hy' : y ∈ multiset.map (λ (b : {b : A5 × A5 // b.2 * u.1 * b.2⁻¹ = b.1}), b.1.1) u.2,
{ simpa [ht₂.symm, hu₂] using hy },
cases multiset.mem_map.1 hx' with xc hxc,
cases multiset.mem_map.1 hy' with yc hyc,
exact is_conj_trans
(is_conj_symm (show is_conj u.1 x, from hxc.2 ▸ ⟨_, xc.2⟩))
(hyc.2 ▸ ⟨_, yc.2⟩)
end
variables {G : Type u} [group G] [decidable_eq G]
lemma normal_subgroup_eq_bind_conjugacy_classes (s : finset (finset G)) (h₁ : ∀ x, ∃ t ∈ s, x ∈ t)
(h₂ : ∀ t ∈ s, ∀ x y ∈ t, is_conj x y) (I : finset G) [nI : normal_subgroup (↑I : set G)] :
∃ u ⊆ s, I = u.bind id :=
⟨(s.powerset.filter (λ u : finset (finset G), u.bind id ⊆ I)).bind id,
(λ x, by simp only [finset.subset_iff, mem_bind, mem_filter, exists_imp_distrib, mem_powerset,
and_imp, id.def] {contextual := tt}; tauto),
le_antisymm
(λ x hxI, let ⟨t, ht₁, ht₂⟩ := h₁ x in
mem_bind.2 ⟨t, mem_bind.2 ⟨(s.powerset.filter (λ u : finset (finset G), u.bind id ⊆ I)).bind id,
mem_filter.2 ⟨mem_powerset.2
(λ u hu, let ⟨v, hv₁, hv₂⟩ := mem_bind.1 hu in
mem_powerset.1 (mem_filter.1 hv₁).1 hv₂),
λ y hy, let ⟨u, hu₁, hu₂⟩ := mem_bind.1 hy in
let ⟨v, hv₁, hv₂⟩ := mem_bind.1 hu₁ in
(mem_filter.1 hv₁).2 (mem_bind.2 ⟨u, hv₂, hu₂⟩)⟩,
mem_bind.2 ⟨{t}, mem_filter.2 ⟨by simp [ht₁, finset.subset_iff],
λ y hy, let ⟨u, hu₁, hu₂⟩ := mem_bind.1 hy in
let ⟨z, hz⟩ := h₂ t ht₁ x y ht₂ (by simp * at *) in
hz ▸ @normal_subgroup.normal G _ I.to_set nI _ hxI _⟩,
by simp⟩⟩,
ht₂⟩)
(λ x, by simp only [finset.subset_iff, mem_bind, exists_imp_distrib, mem_filter, mem_powerset]; tauto)⟩
lemma simple_of_card_conjugacy_classes [fintype G] (s : finset (finset G))
(h₁ : ∀ x, ∃ t ∈ s, x ∈ t) (h₂ : ∀ t ∈ s, ∀ x y ∈ t, is_conj x y)
(hs : (s.1.bind finset.val).nodup)
(h₃ : ∀ t ≤ s.1.map finset.card, 1 ∈ t → t.sum ∣ fintype.card G → t.sum = 1 ∨ t.sum = fintype.card G) :
simple_group G :=
by haveI := classical.dec; exact
⟨λ H iH,
let I := (set.to_finset H) in
have Ii : normal_subgroup (↑I : set G), by simpa using iH,
let ⟨u, hu₁, hu₂⟩ :=
@normal_subgroup_eq_bind_conjugacy_classes G _ _ s h₁ h₂ I Ii in
have hInd : ∀ (x : finset G), x ∈ u → ∀ (y : finset G), y ∈ u → x ≠ y → id x ∩ id y = ∅,
from λ x hxu y hyu hxy,
begin
rw multiset.nodup_bind at hs,
rw [← finset.disjoint_iff_inter_eq_empty, finset.disjoint_left],
exact multiset.forall_of_pairwise
(λ (a b : finset G) (h : multiset.disjoint a.1 b.1),
multiset.disjoint.symm h) hs.2 x (hu₁ hxu) y (hu₁ hyu) hxy
end,
have hci : card I = u.sum finset.card,
by rw [hu₂, card_bind hInd]; refl,
have hu1 : (1 : G) ∈ u.bind id, by exactI hu₂ ▸ is_submonoid.one_mem (↑I : set G),
let ⟨v, hv₁, hv₂⟩ := mem_bind.1 hu1 in
have hv : v = finset.singleton (1 : G),
from finset.ext.2 $ λ a, ⟨λ hav, mem_singleton.2 $
is_conj_one_right.1 (h₂ v (hu₁ hv₁) _ _ hv₂ hav),
by simp [show (1 : G) ∈ v, from hv₂] {contextual := tt}⟩,
have hci' : card I = 1 ∨ card I = fintype.card G,
begin
rw [hci],
exact h₃ _ (multiset.map_le_map (show u.1 ≤ s.1,
from (multiset.le_iff_subset u.2).2 hu₁))
(multiset.mem_map.2 ⟨finset.singleton 1, hv ▸ hv₁, rfl⟩)
(calc u.sum finset.card = card I : hci.symm
... = fintype.card (↑I : set G) : (set.card_fintype_of_finset' I (by simp)).symm
... ∣ fintype.card G : by exactI card_subgroup_dvd_card _)
end,
hci'.elim
(λ hci', or.inl (set.ext (λ x,
let ⟨y, hy⟩ := finset.card_eq_one.1 hci' in
by resetI;
simp only [I, finset.ext, set.mem_to_finset, finset.mem_singleton] at hy;
simp [is_subgroup.mem_trivial, hy, (hy 1).1 (is_submonoid.one_mem H)])))
(λ hci', or.inr $
suffices I = finset.univ,
by simpa [I, set.ext_iff, finset.ext] using this,
finset.eq_of_subset_of_card_le (λ _, by simp) (by rw hci'; refl))⟩
lemma card_A5 : fintype.card A5 = 60 := card_alternating dec_trivial
lemma conjugacy_classes_A5_bind_eq_univ :
conjugacy_classes_A5.bind (λ t, t) = univ :=
eq_of_subset_of_card_le (λ _ _, finset.mem_univ _)
(calc card univ = 60 : card_A5
... ≤ (conjugacy_classes_A5.1.bind finset.val).card : dec_trivial
... = (conjugacy_classes_A5.bind id).card :
begin
rw [finset.card_bind, multiset.card_bind], refl,
{ exact multiset.forall_of_pairwise (λ a b, by simp [finset.inter_comm])
(by simp only [finset.disjoint_iff_inter_eq_empty.symm, finset.disjoint_left];
exact (multiset.nodup_bind.1 nodup_conjugacy_classes_A5_bind).2) }
end)
lemma simple_group_A5 : simple_group A5 :=
simple_of_card_conjugacy_classes conjugacy_classes_A5
(λ x, mem_bind.1 $ by rw [conjugacy_classes_A5_bind_eq_univ]; simp)
is_conj_conjugacy_classes_A5
nodup_conjugacy_classes_A5_bind
(by simp only [multiset.mem_powerset.symm, card_A5];
exact dec_trivial)
|
45431f1a1f0447e1883dc7d10e98e90b8a75a6db | 947fa6c38e48771ae886239b4edce6db6e18d0fb | /src/analysis/normed/group/add_torsor.lean | 77b484b3d4dc4086298807c7c30858d54a53b272 | [
"Apache-2.0"
] | permissive | ramonfmir/mathlib | c5dc8b33155473fab97c38bd3aa6723dc289beaa | 14c52e990c17f5a00c0cc9e09847af16fabbed25 | refs/heads/master | 1,661,979,343,526 | 1,660,830,384,000 | 1,660,830,384,000 | 182,072,989 | 0 | 0 | null | 1,555,585,876,000 | 1,555,585,876,000 | null | UTF-8 | Lean | false | false | 10,059 | lean | /-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers, Yury Kudryashov
-/
import analysis.normed.group.basic
import linear_algebra.affine_space.midpoint
/-!
# Torsors of additive normed group actions.
This file defines torsors of additive normed group actions, with a
metric space structure. The motivating case is Euclidean affine
spaces.
-/
noncomputable theory
open_locale nnreal topological_space
open filter
/-- A `normed_add_torsor V P` is a torsor of an additive seminormed group
action by a `seminormed_add_comm_group V` on points `P`. We bundle the pseudometric space
structure and require the distance to be the same as results from the
norm (which in fact implies the distance yields a pseudometric space, but
bundling just the distance and using an instance for the pseudometric space
results in type class problems). -/
class normed_add_torsor (V : out_param $ Type*) (P : Type*)
[out_param $ seminormed_add_comm_group V] [pseudo_metric_space P]
extends add_torsor V P :=
(dist_eq_norm' : ∀ (x y : P), dist x y = ∥(x -ᵥ y : V)∥)
variables {α V P W Q : Type*} [seminormed_add_comm_group V] [pseudo_metric_space P]
[normed_add_torsor V P] [normed_add_comm_group W] [metric_space Q] [normed_add_torsor W Q]
/-- A `seminormed_add_comm_group` is a `normed_add_torsor` over itself. -/
@[priority 100]
instance seminormed_add_comm_group.to_normed_add_torsor : normed_add_torsor V V :=
{ dist_eq_norm' := dist_eq_norm }
include V
section
variables (V W)
/-- The distance equals the norm of subtracting two points. In this
lemma, it is necessary to have `V` as an explicit argument; otherwise
`rw dist_eq_norm_vsub` sometimes doesn't work. -/
lemma dist_eq_norm_vsub (x y : P) : dist x y = ∥x -ᵥ y∥ := normed_add_torsor.dist_eq_norm' x y
/-- The distance equals the norm of subtracting two points. In this
lemma, it is necessary to have `V` as an explicit argument; otherwise
`rw dist_eq_norm_vsub'` sometimes doesn't work. -/
lemma dist_eq_norm_vsub' (x y : P) : dist x y = ∥y -ᵥ x∥ :=
(dist_comm _ _).trans (dist_eq_norm_vsub _ _ _)
end
@[simp] lemma dist_vadd_cancel_left (v : V) (x y : P) :
dist (v +ᵥ x) (v +ᵥ y) = dist x y :=
by rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, vadd_vsub_vadd_cancel_left]
@[simp] lemma dist_vadd_cancel_right (v₁ v₂ : V) (x : P) :
dist (v₁ +ᵥ x) (v₂ +ᵥ x) = dist v₁ v₂ :=
by rw [dist_eq_norm_vsub V, dist_eq_norm, vadd_vsub_vadd_cancel_right]
@[simp] lemma dist_vadd_left (v : V) (x : P) : dist (v +ᵥ x) x = ∥v∥ :=
by simp [dist_eq_norm_vsub V _ x]
@[simp] lemma dist_vadd_right (v : V) (x : P) : dist x (v +ᵥ x) = ∥v∥ :=
by rw [dist_comm, dist_vadd_left]
/-- Isometry between the tangent space `V` of a (semi)normed add torsor `P` and `P` given by
addition/subtraction of `x : P`. -/
@[simps] def isometric.vadd_const (x : P) : V ≃ᵢ P :=
{ to_equiv := equiv.vadd_const x,
isometry_to_fun := isometry.of_dist_eq $ λ _ _, dist_vadd_cancel_right _ _ _ }
section
variable (P)
/-- Self-isometry of a (semi)normed add torsor given by addition of a constant vector `x`. -/
@[simps] def isometric.const_vadd (x : V) : P ≃ᵢ P :=
{ to_equiv := equiv.const_vadd P x,
isometry_to_fun := isometry.of_dist_eq $ λ _ _, dist_vadd_cancel_left _ _ _ }
end
@[simp] lemma dist_vsub_cancel_left (x y z : P) : dist (x -ᵥ y) (x -ᵥ z) = dist y z :=
by rw [dist_eq_norm, vsub_sub_vsub_cancel_left, dist_comm, dist_eq_norm_vsub V]
/-- Isometry between the tangent space `V` of a (semi)normed add torsor `P` and `P` given by
subtraction from `x : P`. -/
@[simps] def isometric.const_vsub (x : P) : P ≃ᵢ V :=
{ to_equiv := equiv.const_vsub x,
isometry_to_fun := isometry.of_dist_eq $ λ y z, dist_vsub_cancel_left _ _ _ }
@[simp] lemma dist_vsub_cancel_right (x y z : P) : dist (x -ᵥ z) (y -ᵥ z) = dist x y :=
(isometric.vadd_const z).symm.dist_eq x y
section pointwise
open_locale pointwise
@[simp] lemma vadd_ball (x : V) (y : P) (r : ℝ) :
x +ᵥ metric.ball y r = metric.ball (x +ᵥ y) r :=
(isometric.const_vadd P x).image_ball y r
@[simp] lemma vadd_closed_ball (x : V) (y : P) (r : ℝ) :
x +ᵥ metric.closed_ball y r = metric.closed_ball (x +ᵥ y) r :=
(isometric.const_vadd P x).image_closed_ball y r
@[simp] lemma vadd_sphere (x : V) (y : P) (r : ℝ) :
x +ᵥ metric.sphere y r = metric.sphere (x +ᵥ y) r :=
(isometric.const_vadd P x).image_sphere y r
end pointwise
lemma dist_vadd_vadd_le (v v' : V) (p p' : P) :
dist (v +ᵥ p) (v' +ᵥ p') ≤ dist v v' + dist p p' :=
by simpa using dist_triangle (v +ᵥ p) (v' +ᵥ p) (v' +ᵥ p')
lemma dist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :
dist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ dist p₁ p₃ + dist p₂ p₄ :=
by { rw [dist_eq_norm, vsub_sub_vsub_comm, dist_eq_norm_vsub V, dist_eq_norm_vsub V],
exact norm_sub_le _ _ }
lemma nndist_vadd_vadd_le (v v' : V) (p p' : P) :
nndist (v +ᵥ p) (v' +ᵥ p') ≤ nndist v v' + nndist p p' :=
by simp only [← nnreal.coe_le_coe, nnreal.coe_add, ← dist_nndist, dist_vadd_vadd_le]
lemma nndist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :
nndist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ nndist p₁ p₃ + nndist p₂ p₄ :=
by simp only [← nnreal.coe_le_coe, nnreal.coe_add, ← dist_nndist, dist_vsub_vsub_le]
lemma edist_vadd_vadd_le (v v' : V) (p p' : P) :
edist (v +ᵥ p) (v' +ᵥ p') ≤ edist v v' + edist p p' :=
by { simp only [edist_nndist], apply_mod_cast nndist_vadd_vadd_le }
lemma edist_vsub_vsub_le (p₁ p₂ p₃ p₄ : P) :
edist (p₁ -ᵥ p₂) (p₃ -ᵥ p₄) ≤ edist p₁ p₃ + edist p₂ p₄ :=
by { simp only [edist_nndist], apply_mod_cast nndist_vsub_vsub_le }
omit V
/-- The pseudodistance defines a pseudometric space structure on the torsor. This
is not an instance because it depends on `V` to define a `metric_space
P`. -/
def pseudo_metric_space_of_normed_add_comm_group_of_add_torsor (V P : Type*)
[seminormed_add_comm_group V] [add_torsor V P] : pseudo_metric_space P :=
{ dist := λ x y, ∥(x -ᵥ y : V)∥,
dist_self := λ x, by simp,
dist_comm := λ x y, by simp only [←neg_vsub_eq_vsub_rev y x, norm_neg],
dist_triangle := begin
intros x y z,
change ∥x -ᵥ z∥ ≤ ∥x -ᵥ y∥ + ∥y -ᵥ z∥,
rw ←vsub_add_vsub_cancel,
apply norm_add_le
end }
/-- The distance defines a metric space structure on the torsor. This
is not an instance because it depends on `V` to define a `metric_space
P`. -/
def metric_space_of_normed_add_comm_group_of_add_torsor (V P : Type*)
[normed_add_comm_group V] [add_torsor V P] :
metric_space P :=
{ dist := λ x y, ∥(x -ᵥ y : V)∥,
dist_self := λ x, by simp,
eq_of_dist_eq_zero := λ x y h, by simpa using h,
dist_comm := λ x y, by simp only [←neg_vsub_eq_vsub_rev y x, norm_neg],
dist_triangle := begin
intros x y z,
change ∥x -ᵥ z∥ ≤ ∥x -ᵥ y∥ + ∥y -ᵥ z∥,
rw ←vsub_add_vsub_cancel,
apply norm_add_le
end }
include V
lemma lipschitz_with.vadd [pseudo_emetric_space α] {f : α → V} {g : α → P} {Kf Kg : ℝ≥0}
(hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :
lipschitz_with (Kf + Kg) (f +ᵥ g) :=
λ x y,
calc edist (f x +ᵥ g x) (f y +ᵥ g y) ≤ edist (f x) (f y) + edist (g x) (g y) :
edist_vadd_vadd_le _ _ _ _
... ≤ Kf * edist x y + Kg * edist x y :
add_le_add (hf x y) (hg x y)
... = (Kf + Kg) * edist x y :
(add_mul _ _ _).symm
lemma lipschitz_with.vsub [pseudo_emetric_space α] {f g : α → P} {Kf Kg : ℝ≥0}
(hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :
lipschitz_with (Kf + Kg) (f -ᵥ g) :=
λ x y,
calc edist (f x -ᵥ g x) (f y -ᵥ g y) ≤ edist (f x) (f y) + edist (g x) (g y) :
edist_vsub_vsub_le _ _ _ _
... ≤ Kf * edist x y + Kg * edist x y :
add_le_add (hf x y) (hg x y)
... = (Kf + Kg) * edist x y :
(add_mul _ _ _).symm
lemma uniform_continuous_vadd : uniform_continuous (λ x : V × P, x.1 +ᵥ x.2) :=
(lipschitz_with.prod_fst.vadd lipschitz_with.prod_snd).uniform_continuous
lemma uniform_continuous_vsub : uniform_continuous (λ x : P × P, x.1 -ᵥ x.2) :=
(lipschitz_with.prod_fst.vsub lipschitz_with.prod_snd).uniform_continuous
@[priority 100] instance normed_add_torsor.to_has_continuous_vadd : has_continuous_vadd V P :=
{ continuous_vadd := uniform_continuous_vadd.continuous }
lemma continuous_vsub : continuous (λ x : P × P, x.1 -ᵥ x.2) :=
uniform_continuous_vsub.continuous
lemma filter.tendsto.vsub {l : filter α} {f g : α → P} {x y : P}
(hf : tendsto f l (𝓝 x)) (hg : tendsto g l (𝓝 y)) :
tendsto (f -ᵥ g) l (𝓝 (x -ᵥ y)) :=
(continuous_vsub.tendsto (x, y)).comp (hf.prod_mk_nhds hg)
section
variables [topological_space α]
lemma continuous.vsub {f g : α → P} (hf : continuous f) (hg : continuous g) :
continuous (f -ᵥ g) :=
continuous_vsub.comp (hf.prod_mk hg : _)
lemma continuous_at.vsub {f g : α → P} {x : α} (hf : continuous_at f x) (hg : continuous_at g x) :
continuous_at (f -ᵥ g) x :=
hf.vsub hg
lemma continuous_within_at.vsub {f g : α → P} {x : α} {s : set α}
(hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :
continuous_within_at (f -ᵥ g) s x :=
hf.vsub hg
end
section
variables {R : Type*} [ring R] [topological_space R] [module R V] [has_continuous_smul R V]
lemma filter.tendsto.line_map {l : filter α} {f₁ f₂ : α → P} {g : α → R} {p₁ p₂ : P} {c : R}
(h₁ : tendsto f₁ l (𝓝 p₁)) (h₂ : tendsto f₂ l (𝓝 p₂)) (hg : tendsto g l (𝓝 c)) :
tendsto (λ x, affine_map.line_map (f₁ x) (f₂ x) (g x)) l (𝓝 $ affine_map.line_map p₁ p₂ c) :=
(hg.smul (h₂.vsub h₁)).vadd h₁
lemma filter.tendsto.midpoint [invertible (2:R)] {l : filter α} {f₁ f₂ : α → P} {p₁ p₂ : P}
(h₁ : tendsto f₁ l (𝓝 p₁)) (h₂ : tendsto f₂ l (𝓝 p₂)) :
tendsto (λ x, midpoint R (f₁ x) (f₂ x)) l (𝓝 $ midpoint R p₁ p₂) :=
h₁.line_map h₂ tendsto_const_nhds
end
|
8829c9d7664ee74d74ff144674b9d05c44d84e71 | 4efff1f47634ff19e2f786deadd394270a59ecd2 | /src/data/multiset/lattice.lean | f0097a9d9ab2c6e907e7d6aadf56145d204d96d0 | [
"Apache-2.0"
] | permissive | agjftucker/mathlib | d634cd0d5256b6325e3c55bb7fb2403548371707 | 87fe50de17b00af533f72a102d0adefe4a2285e8 | refs/heads/master | 1,625,378,131,941 | 1,599,166,526,000 | 1,599,166,526,000 | 160,748,509 | 0 | 0 | Apache-2.0 | 1,544,141,789,000 | 1,544,141,789,000 | null | UTF-8 | Lean | false | false | 7,194 | lean | /-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
-/
import data.multiset.finset_ops
import data.multiset.fold
/-!
# Lattice operations on multisets
-/
namespace multiset
variables {α : Type*}
/-! ### sup -/
section sup
variables [semilattice_sup_bot α]
/-- Supremum of a multiset: `sup {a, b, c} = a ⊔ b ⊔ c` -/
def sup (s : multiset α) : α := s.fold (⊔) ⊥
@[simp] lemma sup_zero : (0 : multiset α).sup = ⊥ :=
fold_zero _ _
@[simp] lemma sup_cons (a : α) (s : multiset α) :
(a :: s).sup = a ⊔ s.sup :=
fold_cons_left _ _ _ _
@[simp] lemma sup_singleton {a : α} : (a::0).sup = a := by simp
@[simp] lemma sup_add (s₁ s₂ : multiset α) : (s₁ + s₂).sup = s₁.sup ⊔ s₂.sup :=
eq.trans (by simp [sup]) (fold_add _ _ _ _ _)
lemma sup_le {s : multiset α} {a : α} : s.sup ≤ a ↔ (∀b ∈ s, b ≤ a) :=
multiset.induction_on s (by simp)
(by simp [or_imp_distrib, forall_and_distrib] {contextual := tt})
lemma le_sup {s : multiset α} {a : α} (h : a ∈ s) : a ≤ s.sup :=
sup_le.1 (le_refl _) _ h
lemma sup_mono {s₁ s₂ : multiset α} (h : s₁ ⊆ s₂) : s₁.sup ≤ s₂.sup :=
sup_le.2 $ assume b hb, le_sup (h hb)
variables [decidable_eq α]
@[simp] lemma sup_erase_dup (s : multiset α) : (erase_dup s).sup = s.sup :=
fold_erase_dup_idem _ _ _
@[simp] lemma sup_ndunion (s₁ s₂ : multiset α) :
(ndunion s₁ s₂).sup = s₁.sup ⊔ s₂.sup :=
by rw [← sup_erase_dup, erase_dup_ext.2, sup_erase_dup, sup_add]; simp
@[simp] lemma sup_union (s₁ s₂ : multiset α) :
(s₁ ∪ s₂).sup = s₁.sup ⊔ s₂.sup :=
by rw [← sup_erase_dup, erase_dup_ext.2, sup_erase_dup, sup_add]; simp
@[simp] lemma sup_ndinsert (a : α) (s : multiset α) :
(ndinsert a s).sup = a ⊔ s.sup :=
by rw [← sup_erase_dup, erase_dup_ext.2, sup_erase_dup, sup_cons]; simp
end sup
/-! ### inf -/
section inf
variables [semilattice_inf_top α]
/-- Infimum of a multiset: `inf {a, b, c} = a ⊓ b ⊓ c` -/
def inf (s : multiset α) : α := s.fold (⊓) ⊤
@[simp] lemma inf_zero : (0 : multiset α).inf = ⊤ :=
fold_zero _ _
@[simp] lemma inf_cons (a : α) (s : multiset α) :
(a :: s).inf = a ⊓ s.inf :=
fold_cons_left _ _ _ _
@[simp] lemma inf_singleton {a : α} : (a::0).inf = a := by simp
@[simp] lemma inf_add (s₁ s₂ : multiset α) : (s₁ + s₂).inf = s₁.inf ⊓ s₂.inf :=
eq.trans (by simp [inf]) (fold_add _ _ _ _ _)
lemma le_inf {s : multiset α} {a : α} : a ≤ s.inf ↔ (∀b ∈ s, a ≤ b) :=
multiset.induction_on s (by simp)
(by simp [or_imp_distrib, forall_and_distrib] {contextual := tt})
lemma inf_le {s : multiset α} {a : α} (h : a ∈ s) : s.inf ≤ a :=
le_inf.1 (le_refl _) _ h
lemma inf_mono {s₁ s₂ : multiset α} (h : s₁ ⊆ s₂) : s₂.inf ≤ s₁.inf :=
le_inf.2 $ assume b hb, inf_le (h hb)
variables [decidable_eq α]
@[simp] lemma inf_erase_dup (s : multiset α) : (erase_dup s).inf = s.inf :=
fold_erase_dup_idem _ _ _
@[simp] lemma inf_ndunion (s₁ s₂ : multiset α) :
(ndunion s₁ s₂).inf = s₁.inf ⊓ s₂.inf :=
by rw [← inf_erase_dup, erase_dup_ext.2, inf_erase_dup, inf_add]; simp
@[simp] lemma inf_union (s₁ s₂ : multiset α) :
(s₁ ∪ s₂).inf = s₁.inf ⊓ s₂.inf :=
by rw [← inf_erase_dup, erase_dup_ext.2, inf_erase_dup, inf_add]; simp
@[simp] lemma inf_ndinsert (a : α) (s : multiset α) :
(ndinsert a s).inf = a ⊓ s.inf :=
by rw [← inf_erase_dup, erase_dup_ext.2, inf_erase_dup, inf_cons]; simp
end inf
section sup'
variable [semilattice_sup α]
--based on finset.max_of_mem
theorem sup_of_mem {s : multiset α} {a : α} (h : a ∈ s) :
∃ b : α, @sup (with_bot α) _ (map coe s) = ↑b :=
(@le_sup (with_bot α) _ _ _ (mem_map_of_mem _ h) _ rfl).imp $ λ b, Exists.fst
--based on finset.max_of_nonempty
theorem sup_of_exists_mem {s : multiset α} (h : ∃ a, a ∈ s) :
∃ b : α, @sup (with_bot α) _ (map coe s) = ↑b :=
let ⟨a, ha⟩ := h in sup_of_mem ha
--based on finset.max_eq_none
theorem sup_eq_bot {s : multiset α} : @sup (with_bot α) _ (map coe s) = ⊥ ↔ s = 0 :=
⟨λ h, s.eq_zero_or_exists_mem.elim id
(λ H, let ⟨a, ha⟩ := sup_of_exists_mem H in by rw h at ha; cases ha),
λ h, h.symm ▸ sup_zero⟩
--based on finset.le_max_of_mem
theorem le_sup_of_mem {s : multiset α} {a b : α} (h₁ : a ∈ s)
(h₂ : @sup (with_bot α) _ (map coe s) = ↑b) : a ≤ b :=
by rcases @le_sup (with_bot α) _ _ _ (mem_map_of_mem _ h₁) _ rfl with ⟨b', hb, ab⟩;
cases h₂.symm.trans hb; assumption
--based on finset.max'
def sup' (s : multiset α) (H : ∃ k, k ∈ s) : α :=
option.get $ let ⟨k, hk⟩ := H in option.is_some_iff_exists.2 (sup_of_mem hk)
variable (s : multiset α)
--based on finset.le_max'
theorem le_sup' (x) (H2 : x ∈ s) : x ≤ s.sup' ⟨x, H2⟩ :=
le_sup_of_mem H2 $ option.get_mem _
--based on finset.max'_singleton
@[simp] lemma sup'_singleton (a : α) : (a::0).sup' ⟨a, or.inl rfl⟩ = a :=
by simp [sup']
end sup'
section inf'
variable [semilattice_inf α]
theorem inf_of_mem {s : multiset α} {a : α} (h : a ∈ s) :
∃ b : α, @inf (with_top α) _ (map coe s) = ↑b :=
@sup_of_mem (order_dual α) _ _ _ h
theorem inf_of_exists_mem {s : multiset α} (h : ∃ a, a ∈ s) :
∃ b : α, @inf (with_top α) _ (map coe s) = ↑b :=
@sup_of_exists_mem (order_dual α) _ _ h
theorem inf_eq_top {s : multiset α} : @inf (with_top α) _ (map coe s) = ⊤ ↔ s = 0 :=
@sup_eq_bot (order_dual α) _ _
theorem inf_le_of_mem {s : multiset α} {a b : α} (h₁ : b ∈ s)
(h₂ : @inf (with_top α) _ (map coe s) = ↑a) : a ≤ b :=
@le_sup_of_mem (order_dual α) _ _ _ _ h₁ h₂
def inf' (s : multiset α) (H : ∃ k, k ∈ s) : α :=
@sup' (order_dual α) _ s H
variable (s : multiset α)
theorem inf'_le (x) (H2 : x ∈ s) : s.inf' ⟨x, H2⟩ ≤ x :=
@le_sup' (order_dual α) _ s x H2
@[simp] lemma inf'_singleton (a : α) : (a::0).inf' ⟨a, or.inl rfl⟩ = a :=
@sup'_singleton (order_dual α) _ a
end inf'
section max_min
variables [decidable_linear_order α]
--based on finset.mem_of_max
theorem mem_of_sup {s : multiset α} : ∀ {a : α}, @sup (with_bot α) _ (map coe s) = ↑a → a ∈ s :=
multiset.induction_on s (λ _ H, by cases H) $
λ b s (ih : ∀ {a}, (map coe s).sup = ↑a → a ∈ s) a (h : (map coe (b::s)).sup = ↑a),
begin
by_cases p : b = a,
{ induction p, exact mem_cons_self b s },
{ cases option.lift_or_get_choice max_choice ↑b (map coe s).sup with q q;
change @has_sup.sup (with_bot α) _ ↑b (map coe s).sup = _ at q;
rw [map_cons, sup_cons, q] at h,
{ cases h, cases p rfl },
{ exact mem_cons_of_mem (ih h) } }
end
theorem mem_of_inf {s : multiset α} : ∀ {a : α}, @inf (with_top α) _ (map coe s) = ↑a → a ∈ s :=
@mem_of_sup (order_dual α) _ _
variables (s : multiset α) (H : ∃ a : α, a ∈ s)
--based on finset.max'_mem
theorem sup'_mem : s.sup' H ∈ s :=
mem_of_sup $ by rw [sup', ←with_bot.some_eq_coe, option.some_get]
theorem inf'_mem : s.inf' H ∈ s :=
@sup'_mem (order_dual α) _ s H
end max_min
end multiset
|
aafafc9df50e4647b5e97009da7b9d70d2a98d73 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /src/Lean/Util/Sorry.lean | 9d6f73065e462a8299bf33646ee1b7621c0af6d6 | [
"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 | 1,141 | 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
-/
import Lean.Util.FindExpr
import Lean.Declaration
namespace Lean
def Expr.isSorry : Expr → Bool
| app (app (.const ``sorryAx ..) ..) .. => true
| _ => false
def Expr.isSyntheticSorry : Expr → Bool
| app (app (const ``sorryAx ..) ..) (const ``Bool.true ..) => true
| _ => false
def Expr.isNonSyntheticSorry : Expr → Bool
| app (app (const ``sorryAx ..) ..) (const ``Bool.false ..) => true
| _ => false
def Expr.hasSorry (e : Expr) : Bool :=
Option.isSome <| e.find? (·.isConstOf ``sorryAx)
def Expr.hasSyntheticSorry (e : Expr) : Bool :=
Option.isSome <| e.find? (·.isSyntheticSorry)
def Expr.hasNonSyntheticSorry (e : Expr) : Bool :=
Option.isSome <| e.find? (·.isNonSyntheticSorry)
def Declaration.hasSorry (d : Declaration) : Bool := Id.run do
d.foldExprM (fun r e => r || e.hasSorry) false
def Declaration.hasNonSyntheticSorry (d : Declaration) : Bool := Id.run do
d.foldExprM (fun r e => r || e.hasNonSyntheticSorry) false
end Lean
|
fda45793a601918bb219a9b102365f4351e63d11 | dd0f5513e11c52db157d2fcc8456d9401a6cd9da | /11_Tactic-Style_Proofs.org.11.lean | 89c5ca84ccf0a23a654dd295facd0cfa01c9936f | [] | 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 | 220 | lean | import standard
import data.nat
open nat
variables x y z w : ℕ
-- BEGIN
example (H1 : x = y) (H2 : y = z) (H3 : z = w) : x = w :=
begin
apply (eq.trans H1),
apply (eq.trans H2),
assumption -- applied H3
end
-- END
|
696df7526110c8022b176863c3357d40b009fea9 | 57aec6ee746bc7e3a3dd5e767e53bd95beb82f6d | /stage0/src/Lean/Compiler/IR/EmitC.lean | 3a0f855709867c1410cf202f48a836971c6d6a44 | [
"Apache-2.0"
] | permissive | collares/lean4 | 861a9269c4592bce49b71059e232ff0bfe4594cc | 52a4f535d853a2c7c7eea5fee8a4fa04c682c1ee | refs/heads/master | 1,691,419,031,324 | 1,618,678,138,000 | 1,618,678,138,000 | 358,989,750 | 0 | 0 | Apache-2.0 | 1,618,696,333,000 | 1,618,696,333,000 | null | UTF-8 | Lean | false | false | 25,172 | 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
-/
import Lean.Runtime
import Lean.Compiler.NameMangling
import Lean.Compiler.ExportAttr
import Lean.Compiler.InitAttr
import Lean.Compiler.IR.CompilerM
import Lean.Compiler.IR.EmitUtil
import Lean.Compiler.IR.NormIds
import Lean.Compiler.IR.SimpCase
import Lean.Compiler.IR.Boxing
namespace Lean.IR.EmitC
open ExplicitBoxing (requiresBoxedVersion mkBoxedName isBoxedName)
def leanMainFn := "_lean_main"
structure Context where
env : Environment
modName : Name
jpMap : JPParamsMap := {}
mainFn : FunId := arbitrary
mainParams : Array Param := #[]
abbrev M := ReaderT Context (EStateM String String)
def getEnv : M Environment := Context.env <$> read
def getModName : M Name := Context.modName <$> read
def getDecl (n : Name) : M Decl := do
let env ← getEnv
match findEnvDecl env n with
| some d => pure d
| none => throw s!"unknown declaration '{n}'"
@[inline] def emit {α : Type} [ToString α] (a : α) : M Unit :=
modify fun out => out ++ toString a
@[inline] def emitLn {α : Type} [ToString α] (a : α) : M Unit := do
emit a; emit "\n"
def emitLns {α : Type} [ToString α] (as : List α) : M Unit :=
as.forM fun a => emitLn a
def argToCString (x : Arg) : String :=
match x with
| Arg.var x => toString x
| _ => "lean_box(0)"
def emitArg (x : Arg) : M Unit :=
emit (argToCString x)
def toCType : IRType → String
| IRType.float => "double"
| IRType.uint8 => "uint8_t"
| IRType.uint16 => "uint16_t"
| IRType.uint32 => "uint32_t"
| IRType.uint64 => "uint64_t"
| IRType.usize => "size_t"
| IRType.object => "lean_object*"
| IRType.tobject => "lean_object*"
| IRType.irrelevant => "lean_object*"
| IRType.struct _ _ => panic! "not implemented yet"
| IRType.union _ _ => panic! "not implemented yet"
def throwInvalidExportName {α : Type} (n : Name) : M α :=
throw s!"invalid export name '{n}'"
def toCName (n : Name) : M String := do
let env ← getEnv;
-- TODO: we should support simple export names only
match getExportNameFor env n with
| some (Name.str Name.anonymous s _) => pure s
| some _ => throwInvalidExportName n
| none => if n == `main then pure leanMainFn else pure n.mangle
def emitCName (n : Name) : M Unit :=
toCName n >>= emit
def toCInitName (n : Name) : M String := do
let env ← getEnv;
-- TODO: we should support simple export names only
match getExportNameFor env n with
| some (Name.str Name.anonymous s _) => pure $ "_init_" ++ s
| some _ => throwInvalidExportName n
| none => pure ("_init_" ++ n.mangle)
def emitCInitName (n : Name) : M Unit :=
toCInitName n >>= emit
def emitFnDeclAux (decl : Decl) (cppBaseName : String) (addExternForConsts : Bool) : M Unit := do
let ps := decl.params
let env ← getEnv
if ps.isEmpty && addExternForConsts then emit "extern "
emit (toCType decl.resultType ++ " " ++ cppBaseName)
unless ps.isEmpty do
emit "("
-- We omit irrelevant parameters for extern constants
let ps := if isExternC env decl.name then ps.filter (fun p => !p.ty.isIrrelevant) else ps
if ps.size > closureMaxArgs && isBoxedName decl.name then
emit "lean_object**"
else
ps.size.forM fun i => do
if i > 0 then emit ", "
emit (toCType ps[i].ty)
emit ")"
emitLn ";"
def emitFnDecl (decl : Decl) (addExternForConsts : Bool) : M Unit := do
let cppBaseName ← toCName decl.name
emitFnDeclAux decl cppBaseName addExternForConsts
def emitExternDeclAux (decl : Decl) (cNameStr : String) : M Unit := do
let cName := Name.mkSimple cNameStr
let env ← getEnv
let extC := isExternC env decl.name
emitFnDeclAux decl cNameStr (!extC)
def emitFnDecls : M Unit := do
let env ← getEnv
let decls := getDecls env
let modDecls : NameSet := decls.foldl (fun s d => s.insert d.name) {}
let usedDecls : NameSet := decls.foldl (fun s d => collectUsedDecls env d (s.insert d.name)) {}
let usedDecls := usedDecls.toList
usedDecls.forM fun n => do
let decl ← getDecl n;
match getExternNameFor env `c decl.name with
| some cName => emitExternDeclAux decl cName
| none => emitFnDecl decl (!modDecls.contains n)
def emitMainFn : M Unit := do
let d ← getDecl `main
match d with
| Decl.fdecl (f := f) (xs := xs) (type := t) (body := b) .. => do
unless xs.size == 2 || xs.size == 1 do throw "invalid main function, incorrect arity when generating code"
let env ← getEnv
let usesLeanAPI := usesModuleFrom env `Lean
if usesLeanAPI then
emitLn "void lean_initialize();"
else
emitLn "void lean_initialize_runtime_module();";
emitLn "
#if defined(WIN32) || defined(_WIN32)
#include <windows.h>
#endif
int main(int argc, char ** argv) {
#if defined(WIN32) || defined(_WIN32)
SetErrorMode(SEM_FAILCRITICALERRORS);
#endif
lean_object* in; lean_object* res;";
if usesLeanAPI then
emitLn "lean_initialize();"
else
emitLn "lean_initialize_runtime_module();"
let modName ← getModName
emitLn ("res = " ++ mkModuleInitializationFunctionName modName ++ "(lean_io_mk_world());")
emitLns ["lean_io_mark_end_initialization();",
"if (lean_io_result_is_ok(res)) {",
"lean_dec_ref(res);",
"lean_init_task_manager();"];
if xs.size == 2 then
emitLns ["in = lean_box(0);",
"int i = argc;",
"while (i > 1) {",
" lean_object* n;",
" i--;",
" n = lean_alloc_ctor(1,2,0); lean_ctor_set(n, 0, lean_mk_string(argv[i])); lean_ctor_set(n, 1, in);",
" in = n;",
"}"]
emitLn ("res = " ++ leanMainFn ++ "(in, lean_io_mk_world());")
else
emitLn ("res = " ++ leanMainFn ++ "(lean_io_mk_world());")
emitLn "}"
emitLns ["if (lean_io_result_is_ok(res)) {",
" int ret = lean_unbox(lean_io_result_get_value(res));",
" lean_dec_ref(res);",
" return ret;",
"} else {",
" lean_io_result_show_error(res);",
" lean_dec_ref(res);",
" return 1;",
"}"]
emitLn "}"
| other => throw "function declaration expected"
def hasMainFn : M Bool := do
let env ← getEnv
let decls := getDecls env
pure $ decls.any (fun d => d.name == `main)
def emitMainFnIfNeeded : M Unit := do
if (← hasMainFn) then emitMainFn
def emitFileHeader : M Unit := do
let env ← getEnv
let modName ← getModName
emitLn "// Lean compiler output"
emitLn ("// Module: " ++ toString modName)
emit "// Imports:"
env.imports.forM fun m => emit (" " ++ toString m)
emitLn ""
emitLn "#include <lean/lean.h>"
emitLns [
"#if defined(__clang__)",
"#pragma clang diagnostic ignored \"-Wunused-parameter\"",
"#pragma clang diagnostic ignored \"-Wunused-label\"",
"#elif defined(__GNUC__) && !defined(__CLANG__)",
"#pragma GCC diagnostic ignored \"-Wunused-parameter\"",
"#pragma GCC diagnostic ignored \"-Wunused-label\"",
"#pragma GCC diagnostic ignored \"-Wunused-but-set-variable\"",
"#endif",
"#ifdef __cplusplus",
"extern \"C\" {",
"#endif"
]
def emitFileFooter : M Unit :=
emitLns [
"#ifdef __cplusplus",
"}",
"#endif"
]
def throwUnknownVar {α : Type} (x : VarId) : M α :=
throw s!"unknown variable '{x}'"
def getJPParams (j : JoinPointId) : M (Array Param) := do
let ctx ← read;
match ctx.jpMap.find? j with
| some ps => pure ps
| none => throw "unknown join point"
def declareVar (x : VarId) (t : IRType) : M Unit := do
emit (toCType t); emit " "; emit x; emit "; "
def declareParams (ps : Array Param) : M Unit :=
ps.forM fun p => declareVar p.x p.ty
partial def declareVars : FnBody → Bool → M Bool
| e@(FnBody.vdecl x t _ b), d => do
let ctx ← read
if isTailCallTo ctx.mainFn e then
pure d
else
declareVar x t; declareVars b true
| FnBody.jdecl j xs _ b, d => do declareParams xs; declareVars b (d || xs.size > 0)
| e, d => if e.isTerminal then pure d else declareVars e.body d
def emitTag (x : VarId) (xType : IRType) : M Unit := do
if xType.isObj then do
emit "lean_obj_tag("; emit x; emit ")"
else
emit x
def isIf (alts : Array Alt) : Option (Nat × FnBody × FnBody) :=
if alts.size != 2 then none
else match alts[0] with
| Alt.ctor c b => some (c.cidx, b, alts[1].body)
| _ => none
def emitInc (x : VarId) (n : Nat) (checkRef : Bool) : M Unit := do
emit $
if checkRef then (if n == 1 then "lean_inc" else "lean_inc_n")
else (if n == 1 then "lean_inc_ref" else "lean_inc_ref_n")
emit "("; emit x
if n != 1 then emit ", "; emit n
emitLn ");"
def emitDec (x : VarId) (n : Nat) (checkRef : Bool) : M Unit := do
emit (if checkRef then "lean_dec" else "lean_dec_ref");
emit "("; emit x;
if n != 1 then emit ", "; emit n
emitLn ");"
def emitDel (x : VarId) : M Unit := do
emit "lean_free_object("; emit x; emitLn ");"
def emitSetTag (x : VarId) (i : Nat) : M Unit := do
emit "lean_ctor_set_tag("; emit x; emit ", "; emit i; emitLn ");"
def emitSet (x : VarId) (i : Nat) (y : Arg) : M Unit := do
emit "lean_ctor_set("; emit x; emit ", "; emit i; emit ", "; emitArg y; emitLn ");"
def emitOffset (n : Nat) (offset : Nat) : M Unit := do
if n > 0 then
emit "sizeof(void*)*"; emit n;
if offset > 0 then emit " + "; emit offset
else
emit offset
def emitUSet (x : VarId) (n : Nat) (y : VarId) : M Unit := do
emit "lean_ctor_set_usize("; emit x; emit ", "; emit n; emit ", "; emit y; emitLn ");"
def emitSSet (x : VarId) (n : Nat) (offset : Nat) (y : VarId) (t : IRType) : M Unit := do
match t with
| IRType.float => emit "lean_ctor_set_float"
| IRType.uint8 => emit "lean_ctor_set_uint8"
| IRType.uint16 => emit "lean_ctor_set_uint16"
| IRType.uint32 => emit "lean_ctor_set_uint32"
| IRType.uint64 => emit "lean_ctor_set_uint64"
| _ => throw "invalid instruction";
emit "("; emit x; emit ", "; emitOffset n offset; emit ", "; emit y; emitLn ");"
def emitJmp (j : JoinPointId) (xs : Array Arg) : M Unit := do
let ps ← getJPParams j
unless xs.size == ps.size do throw "invalid goto"
xs.size.forM fun i => do
let p := ps[i]
let x := xs[i]
emit p.x; emit " = "; emitArg x; emitLn ";"
emit "goto "; emit j; emitLn ";"
def emitLhs (z : VarId) : M Unit := do
emit z; emit " = "
def emitArgs (ys : Array Arg) : M Unit :=
ys.size.forM fun i => do
if i > 0 then emit ", "
emitArg ys[i]
def emitCtorScalarSize (usize : Nat) (ssize : Nat) : M Unit := do
if usize == 0 then emit ssize
else if ssize == 0 then emit "sizeof(size_t)*"; emit usize
else emit "sizeof(size_t)*"; emit usize; emit " + "; emit ssize
def emitAllocCtor (c : CtorInfo) : M Unit := do
emit "lean_alloc_ctor("; emit c.cidx; emit ", "; emit c.size; emit ", "
emitCtorScalarSize c.usize c.ssize; emitLn ");"
def emitCtorSetArgs (z : VarId) (ys : Array Arg) : M Unit :=
ys.size.forM fun i => do
emit "lean_ctor_set("; emit z; emit ", "; emit i; emit ", "; emitArg ys[i]; emitLn ");"
def emitCtor (z : VarId) (c : CtorInfo) (ys : Array Arg) : M Unit := do
emitLhs z;
if c.size == 0 && c.usize == 0 && c.ssize == 0 then do
emit "lean_box("; emit c.cidx; emitLn ");"
else do
emitAllocCtor c; emitCtorSetArgs z ys
def emitReset (z : VarId) (n : Nat) (x : VarId) : M Unit := do
emit "if (lean_is_exclusive("; emit x; emitLn ")) {";
n.forM fun i => do
emit " lean_ctor_release("; emit x; emit ", "; emit i; emitLn ");"
emit " "; emitLhs z; emit x; emitLn ";";
emitLn "} else {";
emit " lean_dec_ref("; emit x; emitLn ");";
emit " "; emitLhs z; emitLn "lean_box(0);";
emitLn "}"
def emitReuse (z : VarId) (x : VarId) (c : CtorInfo) (updtHeader : Bool) (ys : Array Arg) : M Unit := do
emit "if (lean_is_scalar("; emit x; emitLn ")) {";
emit " "; emitLhs z; emitAllocCtor c;
emitLn "} else {";
emit " "; emitLhs z; emit x; emitLn ";";
if updtHeader then emit " lean_ctor_set_tag("; emit z; emit ", "; emit c.cidx; emitLn ");"
emitLn "}";
emitCtorSetArgs z ys
def emitProj (z : VarId) (i : Nat) (x : VarId) : M Unit := do
emitLhs z; emit "lean_ctor_get("; emit x; emit ", "; emit i; emitLn ");"
def emitUProj (z : VarId) (i : Nat) (x : VarId) : M Unit := do
emitLhs z; emit "lean_ctor_get_usize("; emit x; emit ", "; emit i; emitLn ");"
def emitSProj (z : VarId) (t : IRType) (n offset : Nat) (x : VarId) : M Unit := do
emitLhs z;
match t with
| IRType.float => emit "lean_ctor_get_float"
| IRType.uint8 => emit "lean_ctor_get_uint8"
| IRType.uint16 => emit "lean_ctor_get_uint16"
| IRType.uint32 => emit "lean_ctor_get_uint32"
| IRType.uint64 => emit "lean_ctor_get_uint64"
| _ => throw "invalid instruction"
emit "("; emit x; emit ", "; emitOffset n offset; emitLn ");"
def toStringArgs (ys : Array Arg) : List String :=
ys.toList.map argToCString
def emitSimpleExternalCall (f : String) (ps : Array Param) (ys : Array Arg) : M Unit := do
emit f; emit "("
-- We must remove irrelevant arguments to extern calls.
discard <| ys.size.foldM
(fun i (first : Bool) =>
if ps[i].ty.isIrrelevant then
pure first
else do
unless first do emit ", "
emitArg ys[i]
pure false)
true
emitLn ");"
pure ()
def emitExternCall (f : FunId) (ps : Array Param) (extData : ExternAttrData) (ys : Array Arg) : M Unit :=
match getExternEntryFor extData `c with
| some (ExternEntry.standard _ extFn) => emitSimpleExternalCall extFn ps ys
| some (ExternEntry.inline _ pat) => do emit (expandExternPattern pat (toStringArgs ys)); emitLn ";"
| some (ExternEntry.foreign _ extFn) => emitSimpleExternalCall extFn ps ys
| _ => throw s!"failed to emit extern application '{f}'"
def emitFullApp (z : VarId) (f : FunId) (ys : Array Arg) : M Unit := do
emitLhs z
let decl ← getDecl f
match decl with
| Decl.extern _ ps _ extData => emitExternCall f ps extData ys
| _ =>
emitCName f
if ys.size > 0 then emit "("; emitArgs ys; emit ")"
emitLn ";"
def emitPartialApp (z : VarId) (f : FunId) (ys : Array Arg) : M Unit := do
let decl ← getDecl f
let arity := decl.params.size;
emitLhs z; emit "lean_alloc_closure((void*)("; emitCName f; emit "), "; emit arity; emit ", "; emit ys.size; emitLn ");";
ys.size.forM fun i => do
let y := ys[i]
emit "lean_closure_set("; emit z; emit ", "; emit i; emit ", "; emitArg y; emitLn ");"
def emitApp (z : VarId) (f : VarId) (ys : Array Arg) : M Unit :=
if ys.size > closureMaxArgs then do
emit "{ lean_object* _aargs[] = {"; emitArgs ys; emitLn "};";
emitLhs z; emit "lean_apply_m("; emit f; emit ", "; emit ys.size; emitLn ", _aargs); }"
else do
emitLhs z; emit "lean_apply_"; emit ys.size; emit "("; emit f; emit ", "; emitArgs ys; emitLn ");"
def emitBoxFn (xType : IRType) : M Unit :=
match xType with
| IRType.usize => emit "lean_box_usize"
| IRType.uint32 => emit "lean_box_uint32"
| IRType.uint64 => emit "lean_box_uint64"
| IRType.float => emit "lean_box_float"
| other => emit "lean_box"
def emitBox (z : VarId) (x : VarId) (xType : IRType) : M Unit := do
emitLhs z; emitBoxFn xType; emit "("; emit x; emitLn ");"
def emitUnbox (z : VarId) (t : IRType) (x : VarId) : M Unit := do
emitLhs z;
match t with
| IRType.usize => emit "lean_unbox_usize"
| IRType.uint32 => emit "lean_unbox_uint32"
| IRType.uint64 => emit "lean_unbox_uint64"
| IRType.float => emit "lean_unbox_float"
| other => emit "lean_unbox";
emit "("; emit x; emitLn ");"
def emitIsShared (z : VarId) (x : VarId) : M Unit := do
emitLhs z; emit "!lean_is_exclusive("; emit x; emitLn ");"
def emitIsTaggedPtr (z : VarId) (x : VarId) : M Unit := do
emitLhs z; emit "!lean_is_scalar("; emit x; emitLn ");"
def toHexDigit (c : Nat) : String :=
String.singleton c.digitChar
def quoteString (s : String) : String :=
let q := "\"";
let q := s.foldl
(fun q c => q ++
if c == '\n' then "\\n"
else if c == '\n' then "\\t"
else if c == '\\' then "\\\\"
else if c == '\"' then "\\\""
else if c.toNat <= 31 then
"\\x" ++ toHexDigit (c.toNat / 16) ++ toHexDigit (c.toNat % 16)
-- TODO(Leo): we should use `\unnnn` for escaping unicode characters.
else String.singleton c)
q;
q ++ "\""
def emitNumLit (t : IRType) (v : Nat) : M Unit := do
if t.isObj then
if v < UInt32.size then
emit "lean_unsigned_to_nat("; emit v; emit "u)"
else
emit "lean_cstr_to_nat(\""; emit v; emit "\")"
else
emit v
def emitLit (z : VarId) (t : IRType) (v : LitVal) : M Unit := do
emitLhs z;
match v with
| LitVal.num v => emitNumLit t v; emitLn ";"
| LitVal.str v => emit "lean_mk_string("; emit (quoteString v); emitLn ");"
def emitVDecl (z : VarId) (t : IRType) (v : Expr) : M Unit :=
match v with
| Expr.ctor c ys => emitCtor z c ys
| Expr.reset n x => emitReset z n x
| Expr.reuse x c u ys => emitReuse z x c u ys
| Expr.proj i x => emitProj z i x
| Expr.uproj i x => emitUProj z i x
| Expr.sproj n o x => emitSProj z t n o x
| Expr.fap c ys => emitFullApp z c ys
| Expr.pap c ys => emitPartialApp z c ys
| Expr.ap x ys => emitApp z x ys
| Expr.box t x => emitBox z x t
| Expr.unbox x => emitUnbox z t x
| Expr.isShared x => emitIsShared z x
| Expr.isTaggedPtr x => emitIsTaggedPtr z x
| Expr.lit v => emitLit z t v
def isTailCall (x : VarId) (v : Expr) (b : FnBody) : M Bool := do
let ctx ← read;
match v, b with
| Expr.fap f _, FnBody.ret (Arg.var y) => pure $ f == ctx.mainFn && x == y
| _, _ => pure false
def paramEqArg (p : Param) (x : Arg) : Bool :=
match x with
| Arg.var x => p.x == x
| _ => false
/-
Given `[p_0, ..., p_{n-1}]`, `[y_0, ..., y_{n-1}]`, representing the assignments
```
p_0 := y_0,
...
p_{n-1} := y_{n-1}
```
Return true iff we have `(i, j)` where `j > i`, and `y_j == p_i`.
That is, we have
```
p_i := y_i,
...
p_j := p_i, -- p_i was overwritten above
```
-/
def overwriteParam (ps : Array Param) (ys : Array Arg) : Bool :=
let n := ps.size;
n.any $ fun i =>
let p := ps[i]
(i+1, n).anyI fun j => paramEqArg p ys[j]
def emitTailCall (v : Expr) : M Unit :=
match v with
| Expr.fap _ ys => do
let ctx ← read
let ps := ctx.mainParams
unless ps.size == ys.size do throw "invalid tail call"
if overwriteParam ps ys then
emitLn "{"
ps.size.forM fun i => do
let p := ps[i]
let y := ys[i]
unless paramEqArg p y do
emit (toCType p.ty); emit " _tmp_"; emit i; emit " = "; emitArg y; emitLn ";"
ps.size.forM fun i => do
let p := ps[i]
let y := ys[i]
unless paramEqArg p y do emit p.x; emit " = _tmp_"; emit i; emitLn ";"
emitLn "}"
else
ys.size.forM fun i => do
let p := ps[i]
let y := ys[i]
unless paramEqArg p y do emit p.x; emit " = "; emitArg y; emitLn ";"
emitLn "goto _start;"
| _ => throw "bug at emitTailCall"
mutual
partial def emitIf (x : VarId) (xType : IRType) (tag : Nat) (t : FnBody) (e : FnBody) : M Unit := do
emit "if ("; emitTag x xType; emit " == "; emit tag; emitLn ")";
emitFnBody t;
emitLn "else";
emitFnBody e
partial def emitCase (x : VarId) (xType : IRType) (alts : Array Alt) : M Unit :=
match isIf alts with
| some (tag, t, e) => emitIf x xType tag t e
| _ => do
emit "switch ("; emitTag x xType; emitLn ") {";
let alts := ensureHasDefault alts;
alts.forM fun alt => do
match alt with
| Alt.ctor c b => emit "case "; emit c.cidx; emitLn ":"; emitFnBody b
| Alt.default b => emitLn "default: "; emitFnBody b
emitLn "}"
partial def emitBlock (b : FnBody) : M Unit := do
match b with
| FnBody.jdecl j xs v b => emitBlock b
| d@(FnBody.vdecl x t v b) =>
let ctx ← read
if isTailCallTo ctx.mainFn d then
emitTailCall v
else
emitVDecl x t v
emitBlock b
| FnBody.inc x n c p b =>
unless p do emitInc x n c
emitBlock b
| FnBody.dec x n c p b =>
unless p do emitDec x n c
emitBlock b
| FnBody.del x b => emitDel x; emitBlock b
| FnBody.setTag x i b => emitSetTag x i; emitBlock b
| FnBody.set x i y b => emitSet x i y; emitBlock b
| FnBody.uset x i y b => emitUSet x i y; emitBlock b
| FnBody.sset x i o y t b => emitSSet x i o y t; emitBlock b
| FnBody.mdata _ b => emitBlock b
| FnBody.ret x => emit "return "; emitArg x; emitLn ";"
| FnBody.case _ x xType alts => emitCase x xType alts
| FnBody.jmp j xs => emitJmp j xs
| FnBody.unreachable => emitLn "lean_internal_panic_unreachable();"
partial def emitJPs : FnBody → M Unit
| FnBody.jdecl j xs v b => do emit j; emitLn ":"; emitFnBody v; emitJPs b
| e => do unless e.isTerminal do emitJPs e.body
partial def emitFnBody (b : FnBody) : M Unit := do
emitLn "{"
let declared ← declareVars b false
if declared then emitLn ""
emitBlock b
emitJPs b
emitLn "}"
end
def emitDeclAux (d : Decl) : M Unit := do
let env ← getEnv
let (vMap, jpMap) := mkVarJPMaps d
withReader (fun ctx => { ctx with jpMap := jpMap }) do
unless hasInitAttr env d.name do
match d with
| Decl.fdecl (f := f) (xs := xs) (type := t) (body := b) .. =>
let baseName ← toCName f;
if xs.size == 0 then
emit "static "
emit (toCType t); emit " ";
if xs.size > 0 then
emit baseName;
emit "(";
if xs.size > closureMaxArgs && isBoxedName d.name then
emit "lean_object** _args"
else
xs.size.forM fun i => do
if i > 0 then emit ", "
let x := xs[i]
emit (toCType x.ty); emit " "; emit x.x
emit ")"
else
emit ("_init_" ++ baseName ++ "()")
emitLn " {";
if xs.size > closureMaxArgs && isBoxedName d.name then
xs.size.forM fun i => do
let x := xs[i]
emit "lean_object* "; emit x.x; emit " = _args["; emit i; emitLn "];"
emitLn "_start:";
withReader (fun ctx => { ctx with mainFn := f, mainParams := xs }) (emitFnBody b);
emitLn "}"
| _ => pure ()
def emitDecl (d : Decl) : M Unit := do
let d := d.normalizeIds; -- ensure we don't have gaps in the variable indices
try
emitDeclAux d
catch err =>
throw s!"{err}\ncompiling:\n{d}"
def emitFns : M Unit := do
let env ← getEnv;
let decls := getDecls env;
decls.reverse.forM emitDecl
def emitMarkPersistent (d : Decl) (n : Name) : M Unit := do
if d.resultType.isObj then
emit "lean_mark_persistent("
emitCName n
emitLn ");"
def emitDeclInit (d : Decl) : M Unit := do
let env ← getEnv
let n := d.name
if isIOUnitInitFn env n then
emit "res = "; emitCName n; emitLn "(lean_io_mk_world());"
emitLn "if (lean_io_result_is_error(res)) return res;"
emitLn "lean_dec_ref(res);"
else if d.params.size == 0 then
match getInitFnNameFor? env d.name with
| some initFn =>
emit "res = "; emitCName initFn; emitLn "(lean_io_mk_world());"
emitLn "if (lean_io_result_is_error(res)) return res;"
emitCName n; emitLn " = lean_io_result_get_value(res);"
emitMarkPersistent d n
emitLn "lean_dec_ref(res);"
| _ =>
emitCName n; emit " = "; emitCInitName n; emitLn "();"; emitMarkPersistent d n
def emitInitFn : M Unit := do
let env ← getEnv
let modName ← getModName
env.imports.forM fun imp => emitLn ("lean_object* " ++ mkModuleInitializationFunctionName imp.module ++ "(lean_object*);")
emitLns [
"static bool _G_initialized = false;",
"lean_object* " ++ mkModuleInitializationFunctionName modName ++ "(lean_object* w) {",
"lean_object * res;",
"if (_G_initialized) return lean_io_result_mk_ok(lean_box(0));",
"_G_initialized = true;"
]
env.imports.forM fun imp => emitLns [
"res = " ++ mkModuleInitializationFunctionName imp.module ++ "(lean_io_mk_world());",
"if (lean_io_result_is_error(res)) return res;",
"lean_dec_ref(res);"]
let decls := getDecls env
decls.reverse.forM emitDeclInit
emitLns ["return lean_io_result_mk_ok(lean_box(0));", "}"]
def main : M Unit := do
emitFileHeader
emitFnDecls
emitFns
emitInitFn
emitMainFnIfNeeded
emitFileFooter
end EmitC
@[export lean_ir_emit_c]
def emitC (env : Environment) (modName : Name) : Except String String :=
match (EmitC.main { env := env, modName := modName }).run "" with
| EStateM.Result.ok _ s => Except.ok s
| EStateM.Result.error err _ => Except.error err
end Lean.IR
|
8f616b91eb2b7865a77034ec465f4a2131ec0c72 | dd0f5513e11c52db157d2fcc8456d9401a6cd9da | /10_Structures_and_Records.org.1.lean | 8767f62c9f61499c857b281f9185cfa8d3c8ebb0 | [] | 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 | 68 | lean | import standard
structure point (A : Type) :=
mk :: (x : A) (y : A)
|
d198567e98077a2bed39bcb527a2da9930d055ed | 59a4b050600ed7b3d5826a8478db0a9bdc190252 | /src/category_theory/universal/cones.lean | d03db4d9114085adcdf39040dd732db525f347c8 | [] | no_license | rwbarton/lean-category-theory | f720268d800b62a25d69842ca7b5d27822f00652 | 00df814d463406b7a13a56f5dcda67758ba1b419 | refs/heads/master | 1,585,366,296,767 | 1,536,151,349,000 | 1,536,151,349,000 | 147,652,096 | 0 | 0 | null | 1,536,226,960,000 | 1,536,226,960,000 | null | UTF-8 | Lean | false | false | 5,165 | lean | -- Copyright (c) 2017 Scott Morrison. All rights reserved.
-- Released under Apache 2.0 license as described in the file LICENSE.
-- Authors: Stephen Morgan, Scott Morrison
import category_theory.limits.limits
open category_theory
namespace category_theory.limits
universes u v
variables {J : Type v} [small_category J]
variables {C : Type u} [𝒞 : category.{u v} C]
include 𝒞
variable {F : J ⥤ C}
structure cone_morphism (A B : cone F) : Type v :=
(hom : A.X ⟶ B.X)
(w' : Π j : J, hom ≫ (B.π j) = (A.π j) . obviously)
restate_axiom cone_morphism.w'
attribute [simp,search] cone_morphism.w
namespace cone_morphism
@[extensionality] lemma ext {A B : cone F} {f g : cone_morphism A B} (w : f.hom = g.hom) : f = g :=
begin
/- obviously' say: -/
induction f,
induction g,
dsimp at w,
induction w,
refl,
end
end cone_morphism
instance cones (F : J ⥤ C) : category.{(max u v) v} (cone F) :=
{ hom := λ A B, cone_morphism A B,
comp := λ _ _ _ f g, { hom := f.hom ≫ g.hom },
id := λ B, { hom := 𝟙 B.X } }
namespace cones
@[simp] lemma id.hom {F : J ⥤ C} (c : cone F) : (𝟙 c : cone_morphism c c).hom = 𝟙 (c.X) := rfl
@[simp] lemma comp.hom {F : J ⥤ C} {c d e : cone F} (f : c ⟶ d) (g : d ⟶ e) : ((f ≫ g) : cone_morphism c e).hom = (f : cone_morphism c d).hom ≫ (g : cone_morphism d e).hom := rfl
section
variables {D : Type u} [𝒟 : category.{u v} D]
include 𝒟
def functoriality (F : J ⥤ C) (G : C ⥤ D) : (cone F) ⥤ (cone (F ⋙ G)) :=
{ obj := λ A, { X := G A.X,
π := λ j, G.map (A.π j),
w := begin /- `obviously'` says: -/ intros, simp, erw [←functor.map_comp, cone.w] end },
map' := λ X Y f, { hom := G.map f.hom,
w' := begin /- `obviously'` says: -/ intros, dsimp, erw [←functor.map_comp, cone_morphism.w] end } }
end
end cones
structure cocone_morphism (A B : cocone F) :=
(hom : A.X ⟶ B.X)
(w' : Π j : J, (A.ι j) ≫ hom = (B.ι j) . obviously)
restate_axiom cocone_morphism.w'
attribute [simp,search] cocone_morphism.w
namespace cocone_morphism
-- @[simp,search] def commutativity_lemma_assoc {A B : cocone F} (c : cocone_morphism A B) (j : J) {Z : C} (z : B.X ⟶ Z): (A.ι j) ≫ c.hom ≫ z = (B.ι j) ≫ z :=
-- begin
-- -- `obviously'` says:
-- erw [←category.assoc, cocone_morphism.w]
-- end
@[extensionality] lemma ext {A B : cocone F} {f g : cocone_morphism A B} (w : f.hom = g.hom) : f = g :=
begin
induction f,
induction g,
-- `obviously'` says:
dsimp at *,
induction w,
refl,
end
end cocone_morphism
instance cocones (F : J ⥤ C) : category.{(max u v) v} (cocone F) :=
{ hom := λ A B, cocone_morphism A B,
comp := λ _ _ _ f g, { hom := f.hom ≫ g.hom },
id := λ B, { hom := 𝟙 B.X } }
namespace cocones
@[simp] lemma id.hom {F : J ⥤ C} (c : cocone F) : (𝟙 c : cocone_morphism c c).hom = 𝟙 (c.X) := rfl
@[simp] lemma comp.hom {F : J ⥤ C} {c d e : cocone F} (f : c ⟶ d) (g : d ⟶ e) : ((f ≫ g) : cocone_morphism c e).hom = (f : cocone_morphism c d).hom ≫ (g : cocone_morphism d e).hom := rfl
section
variables {D : Type u} [𝒟 : category.{u v} D]
include 𝒟
def functoriality (F : J ⥤ C) (G : C ⥤ D) : (cocone F) ⥤ (cocone (F ⋙ G)) :=
{ obj := λ A, { X := G A.X,
ι := λ j, G.map (A.ι j),
w := begin /- `obviously'` says: -/ intros, simp, erw [←functor.map_comp, cocone.w] end },
map' := λ _ _ f, { hom := G.map f.hom,
w' := begin /- `obviously'` says: -/ intros, dsimp, erw [←functor.map_comp, cocone_morphism.w] end } }
end
end cocones
section
variables [has_limits.{u v} C]
variables (F)
def limit.cone_morphism (c : cone F) : cone_morphism c (limit.cone F) :=
{ hom := (limit.lift F) c }
@[simp] lemma limit.cone_morphism_hom (c : cone F) : (limit.cone_morphism F c).hom = limit.lift F c := rfl
@[simp] lemma limit.cone_morphism_π (c : cone F) (j : J) : (limit.cone_morphism F c).hom ≫ (limit.π F j) = c.π j :=
by erw is_limit.fac
-- def limit.hom
-- {X : C} (π : Π j : J, X ⟶ F j)
-- (w : Π (j j' : J) (f : j ⟶ j'), π j ≫ F.map f = π j') :
-- X ⟶ (limit F) :=
-- (limit.cone_morphism F { X := X, π := π, w := w }).hom
end
end category_theory.limits
namespace category_theory.functor
universes u v
variables {J : Type v} [small_category J]
variables {C : Type u} [category.{u v} C] {D : Type u} [category.{u v} D]
variables {F : J ⥤ C} {G : J ⥤ C}
open category_theory.limits
def map_cone (H : C ⥤ D) (c : cone F) : cone (F ⋙ H) := (cones.functoriality F H) c
def map_cocone (H : C ⥤ D) (c : cocone F) : cocone (F ⋙ H) := (cocones.functoriality F H) c
def map_cone_morphism (H : C ⥤ D) {c c' : cone F} (f : cone_morphism c c') : cone_morphism (H.map_cone c) (H.map_cone c') := (cones.functoriality F H).map f
def map_cocone_morphism (H : C ⥤ D) {c c' : cocone F} (f : cocone_morphism c c') : cocone_morphism (H.map_cocone c) (H.map_cocone c') := (cocones.functoriality F H).map f
end category_theory.functor |
13a899b029f0df342de5a7a8239f03db11e03241 | b7f22e51856f4989b970961f794f1c435f9b8f78 | /tests/lean/run/true_imp_rw.lean | 57b60b3c8bf2b3114eb084e82a572a31aa58a1a4 | [
"Apache-2.0"
] | permissive | soonhokong/lean | cb8aa01055ffe2af0fb99a16b4cda8463b882cd1 | 38607e3eb57f57f77c0ac114ad169e9e4262e24f | refs/heads/master | 1,611,187,284,081 | 1,450,766,737,000 | 1,476,122,547,000 | 11,513,992 | 2 | 0 | null | 1,401,763,102,000 | 1,374,182,235,000 | C++ | UTF-8 | Lean | false | false | 111 | lean | import logic
example (a b c : Prop) (h : a) : true → true → a :=
begin
rewrite *true_imp,
exact h
end
|
e6c31b369f3da7f8fbf47c65758423e3abbe6d57 | fa02ed5a3c9c0adee3c26887a16855e7841c668b | /test/interval_cases.lean | 760ee945abfb62556a67511d0b664cbd57181059 | [
"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 | 4,097 | lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import tactic.interval_cases
example (n : ℕ) : true :=
begin
success_if_fail { interval_cases n },
trivial
end
example (n : ℕ) (h : 2 ≤ n) : true :=
begin
success_if_fail { interval_cases n },
trivial
end
example (n m : ℕ) (h : n ≤ m) : true :=
begin
success_if_fail { interval_cases n },
trivial,
end
example (n : ℕ) (w₂ : n < 0) : false :=
by interval_cases n
example (n : ℕ) (w₂ : n < 1) : n = 0 :=
by { interval_cases n, }
example (n : ℕ) (w₂ : n < 2) : n = 0 ∨ n = 1 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (w₁ : 1 ≤ n) (w₂ : n < 3) : n = 1 ∨ n = 2 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (w₁ : 1 ≤ n) (w₂ : n < 3) : n = 1 ∨ n = 2 :=
by { interval_cases using w₁ w₂, { left, refl }, { right, refl }, }
-- make sure we only pick up bounds on the specified variable:
example (n m : ℕ) (w₁ : 1 ≤ n) (w₂ : n < 3) (w₃ : m < 2) : n = 1 ∨ n = 2 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (w₁ : 1 < n) (w₂ : n < 4) : n = 2 ∨ n = 3 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (w₁ : n ≥ 3) (w₂ : n < 5) : n = 3 ∨ n = 4 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (w₀ : n ≥ 2) (w₁ : n ≥ 3) (w₂ : n < 5) : n = 3 ∨ n = 4 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (w₁ : n > 2) (w₂ : n < 5) : n = 3 ∨ n = 4 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (w₁ : n > 2) (w₂ : n ≤ 4) : n = 3 ∨ n = 4 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (w₁ : 2 < n) (w₂ : 4 ≥ n) : n = 3 ∨ n = 4 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ) (h1 : 4 < n) (h2 : n ≤ 6) : n < 20 :=
begin
interval_cases n,
guard_target 5 < 20, norm_num,
guard_target 6 < 20, norm_num,
end
example (n : ℕ) (w₁ : n % 3 < 1) : n % 3 = 0 :=
by { interval_cases n % 3, assumption }
example (n : ℕ) (h1 : 4 ≤ n) (h2 : n < 10) : n < 20 :=
begin
interval_cases using h1 h2,
all_goals {norm_num}
end
example (n : ℕ+) (w₂ : n < 1) : false :=
by interval_cases n
example (n : ℕ+) (w₂ : n < 2) : n = 1 :=
by interval_cases n
example (n : ℕ+) (h1 : 4 ≤ n) (h2 : n < 5) : n = 4 :=
by interval_cases n
example (n : ℕ+) (w₁ : 2 < n) (w₂ : 4 ≥ n) : n = 3 ∨ n = 4 :=
begin
interval_cases n,
{ guard_target' (3 : ℕ+) = 3 ∨ (3 : ℕ+) = 4, left, refl },
{ guard_target' (4 : ℕ+) = 3 ∨ (4 : ℕ+) = 4, right, refl },
end
example (n : ℕ+) (w₁ : 1 < n) (w₂ : n < 4) : n = 2 ∨ n = 3 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ+) (w₂ : n < 3) : n = 1 ∨ n = 2 :=
by { interval_cases n, { left, refl }, { right, refl }, }
example (n : ℕ+) (w₂ : n < 4) : n = 1 ∨ n = 2 ∨ n = 3 :=
by { interval_cases n, { left, refl }, { right, left, refl }, { right, right, refl }, }
example (z : ℤ) (h1 : z ≥ -3) (h2 : z < 2) : z < 20 :=
begin
interval_cases using h1 h2,
all_goals {norm_num}
end
example (z : ℤ) (h1 : z ≥ -3) (h2 : z < 2) : z < 20 :=
begin
interval_cases z,
guard_target (-3 : ℤ) < 20, norm_num,
guard_target (-2 : ℤ) < 20, norm_num,
guard_target (-1 : ℤ) < 20, norm_num,
guard_target (0 : ℤ) < 20, norm_num,
guard_target (1 : ℤ) < 20, norm_num,
end
example (n : ℕ) : n % 2 = 0 ∨ n % 2 = 1 :=
begin
set r := n % 2 with hr,
have h2 : r < 2 := nat.mod_lt _ (dec_trivial),
interval_cases r with hrv,
{ left, exact hrv },
{ right, exact hrv }
end
/-
Sadly, this one doesn't work, reporting:
`deep recursion was detected at 'expression equality test'`
-/
-- example (n : ℕ) (w₁ : n > 1000000) (w₁ : n < 1000002) : n < 2000000 :=
-- begin
-- interval_cases n,
-- norm_num,
-- end
|
a9918a2b3c0886feb729861129d1f54c75e11d1e | e38e95b38a38a99ecfa1255822e78e4b26f65bb0 | /src/certigrad/aevb/grads_correct.lean | 3adee457d1aa2a1788cce34ea2b28e4ded603f97 | [
"Apache-2.0"
] | permissive | ColaDrill/certigrad | fefb1be3670adccd3bed2f3faf57507f156fd501 | fe288251f623ac7152e5ce555f1cd9d3a20203c2 | refs/heads/master | 1,593,297,324,250 | 1,499,903,753,000 | 1,499,903,753,000 | 97,075,797 | 1 | 0 | null | 1,499,916,210,000 | 1,499,916,210,000 | null | UTF-8 | Lean | false | false | 1,050 | lean | /-
Copyright (c) 2017 Daniel Selsam. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Daniel Selsam
Proofs that integrating out the KL and reparametizing are sound when
applied to the naive variational encoder.
-/
import .util .graph ..prove_model_ok ..backprop_correct
namespace certigrad
namespace aevb
open graph list tactic certigrad.tactic
set_option profiler true
#print "proving backprop_correct_on_aevb..."
theorem backprop_correct_on_aevb (a : arch) (ws : weights a) (x_data : T [a^.n_in, a^.n_x]) :
let g : graph := reparam (integrate_kl $ naive_aevb a x_data) in
let fdict : env := mk_input_dict ws x_data g in
∀ (tgt : reference) (idx : ℕ) (H_at_idx : at_idx g^.targets idx tgt),
∇ (λ θ₀, E (graph.to_dist (λ m, ⟦sum_costs m g^.costs⟧) (env.insert tgt θ₀ fdict) g^.nodes) dvec.head) (env.get tgt fdict)
=
E (graph.to_dist (λ m, backprop g^.costs g^.nodes m g^.targets) fdict g^.nodes) (λ dict, dvec.get tgt.2 dict idx) :=
by prove_model_ok
end aevb
end certigrad
|
d95f56ad9dc4b43802984372e1878295147328f8 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/topology/unit_interval.lean | 0990b7e7a59ddec0d1a73fef46d0a531b84c0131 | [
"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,072 | lean | /-
Copyright (c) 2020 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Scott Morrison
-/
import topology.instances.real
import topology.algebra.field
import data.set.intervals.proj_Icc
import data.set.intervals.instances
/-!
# The unit interval, as a topological space
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
Use `open_locale unit_interval` to turn on the notation `I := set.Icc (0 : ℝ) (1 : ℝ)`.
We provide basic instances, as well as a custom tactic for discharging
`0 ≤ ↑x`, `0 ≤ 1 - ↑x`, `↑x ≤ 1`, and `1 - ↑x ≤ 1` when `x : I`.
-/
noncomputable theory
open_locale classical topology filter
open set int set.Icc
/-! ### The unit interval -/
/-- The unit interval `[0,1]` in ℝ. -/
abbreviation unit_interval : set ℝ := set.Icc 0 1
localized "notation (name := unit_interval) `I` := unit_interval" in unit_interval
namespace unit_interval
lemma zero_mem : (0 : ℝ) ∈ I := ⟨le_rfl, zero_le_one⟩
lemma one_mem : (1 : ℝ) ∈ I := ⟨zero_le_one, le_rfl⟩
lemma mul_mem {x y : ℝ} (hx : x ∈ I) (hy : y ∈ I) : x * y ∈ I :=
⟨mul_nonneg hx.1 hy.1, (mul_le_mul hx.2 hy.2 hy.1 zero_le_one).trans_eq $ one_mul 1⟩
lemma div_mem {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) (hxy : x ≤ y) : x / y ∈ I :=
⟨div_nonneg hx hy, div_le_one_of_le hxy hy⟩
lemma fract_mem (x : ℝ) : fract x ∈ I := ⟨fract_nonneg _, (fract_lt_one _).le⟩
lemma mem_iff_one_sub_mem {t : ℝ} : t ∈ I ↔ 1 - t ∈ I :=
begin
rw [mem_Icc, mem_Icc],
split ; intro ; split ; linarith
end
instance has_zero : has_zero I := ⟨⟨0, zero_mem⟩⟩
instance has_one : has_one I := ⟨⟨1, by split ; norm_num⟩⟩
lemma coe_ne_zero {x : I} : (x : ℝ) ≠ 0 ↔ x ≠ 0 :=
not_iff_not.mpr coe_eq_zero
lemma coe_ne_one {x : I} : (x : ℝ) ≠ 1 ↔ x ≠ 1 :=
not_iff_not.mpr coe_eq_one
instance : nonempty I := ⟨0⟩
instance : has_mul I := ⟨λ x y, ⟨x * y, mul_mem x.2 y.2⟩⟩
-- todo: we could set up a `linear_ordered_comm_monoid_with_zero I` instance
lemma mul_le_left {x y : I} : x * y ≤ x :=
subtype.coe_le_coe.mp $ (mul_le_mul_of_nonneg_left y.2.2 x.2.1).trans_eq $ mul_one x
lemma mul_le_right {x y : I} : x * y ≤ y :=
subtype.coe_le_coe.mp $ (mul_le_mul_of_nonneg_right x.2.2 y.2.1).trans_eq $ one_mul y
/-- Unit interval central symmetry. -/
def symm : I → I := λ t, ⟨1 - t, mem_iff_one_sub_mem.mp t.prop⟩
localized "notation (name := unit_interval.symm) `σ` := unit_interval.symm" in unit_interval
@[simp] lemma symm_zero : σ 0 = 1 :=
subtype.ext $ by simp [symm]
@[simp] lemma symm_one : σ 1 = 0 :=
subtype.ext $ by simp [symm]
@[simp] lemma symm_symm (x : I) : σ (σ x) = x :=
subtype.ext $ by simp [symm]
@[simp] lemma coe_symm_eq (x : I) : (σ x : ℝ) = 1 - x := rfl
@[continuity]
lemma continuous_symm : continuous σ :=
by continuity!
instance : connected_space I :=
subtype.connected_space ⟨nonempty_Icc.mpr zero_le_one, is_preconnected_Icc⟩
/-- Verify there is an instance for `compact_space I`. -/
example : compact_space I := by apply_instance
lemma nonneg (x : I) : 0 ≤ (x : ℝ) := x.2.1
lemma one_minus_nonneg (x : I) : 0 ≤ 1 - (x : ℝ) := by simpa using x.2.2
lemma le_one (x : I) : (x : ℝ) ≤ 1 := x.2.2
lemma one_minus_le_one (x : I) : 1 - (x : ℝ) ≤ 1 := by simpa using x.2.1
lemma add_pos {t : I} {x : ℝ} (hx : 0 < x) : 0 < (x + t : ℝ) :=
add_pos_of_pos_of_nonneg hx $ nonneg _
/-- like `unit_interval.nonneg`, but with the inequality in `I`. -/
lemma nonneg' {t : I} : 0 ≤ t := t.2.1
/-- like `unit_interval.le_one`, but with the inequality in `I`. -/
lemma le_one' {t : I} : t ≤ 1 := t.2.2
lemma mul_pos_mem_iff {a t : ℝ} (ha : 0 < a) : a * t ∈ I ↔ t ∈ set.Icc (0 : ℝ) (1/a) :=
begin
split; rintros ⟨h₁, h₂⟩; split,
{ exact nonneg_of_mul_nonneg_right h₁ ha },
{ rwa [le_div_iff ha, mul_comm] },
{ exact mul_nonneg ha.le h₁ },
{ rwa [le_div_iff ha, mul_comm] at h₂ }
end
lemma two_mul_sub_one_mem_iff {t : ℝ} : 2 * t - 1 ∈ I ↔ t ∈ set.Icc (1/2 : ℝ) 1 :=
by split; rintros ⟨h₁, h₂⟩; split; linarith
end unit_interval
@[simp] lemma proj_Icc_eq_zero {x : ℝ} : proj_Icc (0 : ℝ) 1 zero_le_one x = 0 ↔ x ≤ 0 :=
proj_Icc_eq_left zero_lt_one
@[simp] lemma proj_Icc_eq_one {x : ℝ} : proj_Icc (0 : ℝ) 1 zero_le_one x = 1 ↔ 1 ≤ x :=
proj_Icc_eq_right zero_lt_one
namespace tactic.interactive
/-- A tactic that solves `0 ≤ ↑x`, `0 ≤ 1 - ↑x`, `↑x ≤ 1`, and `1 - ↑x ≤ 1` for `x : I`. -/
meta def unit_interval : tactic unit :=
`[apply unit_interval.nonneg] <|> `[apply unit_interval.one_minus_nonneg] <|>
`[apply unit_interval.le_one] <|> `[apply unit_interval.one_minus_le_one]
end tactic.interactive
section
variables {𝕜 : Type*} [linear_ordered_field 𝕜] [topological_space 𝕜] [topological_ring 𝕜]
/--
The image of `[0,1]` under the homeomorphism `λ x, a * x + b` is `[b, a+b]`.
-/
-- We only need the ordering on `𝕜` here to avoid talking about flipping the interval over.
-- At the end of the day I only care about `ℝ`, so I'm hesitant to put work into generalizing.
lemma affine_homeomorph_image_I (a b : 𝕜) (h : 0 < a) :
affine_homeomorph a b h.ne.symm '' set.Icc 0 1 = set.Icc b (a + b) :=
by simp [h]
/--
The affine homeomorphism from a nontrivial interval `[a,b]` to `[0,1]`.
-/
def Icc_homeo_I (a b : 𝕜) (h : a < b) : set.Icc a b ≃ₜ set.Icc (0 : 𝕜) (1 : 𝕜) :=
begin
let e := homeomorph.image (affine_homeomorph (b-a) a (sub_pos.mpr h).ne.symm) (set.Icc 0 1),
refine (e.trans _).symm,
apply homeomorph.set_congr,
simp [sub_pos.mpr h],
end
@[simp] lemma Icc_homeo_I_apply_coe (a b : 𝕜) (h : a < b) (x : set.Icc a b) :
((Icc_homeo_I a b h) x : 𝕜) = (x - a) / (b - a) :=
rfl
@[simp] lemma Icc_homeo_I_symm_apply_coe (a b : 𝕜) (h : a < b) (x : set.Icc (0 : 𝕜) (1 : 𝕜)) :
((Icc_homeo_I a b h).symm x : 𝕜) = (b - a) * x + a :=
rfl
end
|
1e33f66a0c87a7b65848146a408d307095078543 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/run/1562.lean | bed3a2fb1518c23625ea79418dea5d0702c2e7f4 | [
"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 | 497 | lean | meta constant term : Type
meta constant smt2.builder.int_const : int -> term
meta constant smt2_state : Type
@[reducible] meta def smt2_m (α : Type) :=
state_t smt2_state tactic α
meta instance tactic_to_smt2_m (α : Type) : has_coe (tactic α) (smt2_m α) :=
⟨ fun tc, ⟨fun s, do res ← tc, return (res, s)⟩ ⟩
meta def reflect_arith_formula : expr → smt2_m term
| `(has_zero.zero) := smt2.builder.int_const <$> tactic.eval_expr int `(@has_zero.zero int)
| a := tactic.fail "foo"
|
07a21a7e191007cfe7b7ec9be4a1f6d76ee55fa4 | 57c233acf9386e610d99ed20ef139c5f97504ba3 | /src/category_theory/sites/plus.lean | b096027856ede12aff93578b281d26361e851c26 | [
"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 | 11,003 | lean | /-
Copyright (c) 2021 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import category_theory.sites.sheaf
/-!
# The plus construction for presheaves.
This file contains the construction of `P⁺`, for a presheaf `P : Cᵒᵖ ⥤ D`
where `C` is endowed with a grothendieck topology `J`.
See https://stacks.math.columbia.edu/tag/00W1 for details.
-/
namespace category_theory.grothendieck_topology
open category_theory
open category_theory.limits
open opposite
universes w v u
variables {C : Type u} [category.{v} C] (J : grothendieck_topology C)
variables {D : Type w} [category.{max v u} D]
noncomputable theory
variables [∀ (P : Cᵒᵖ ⥤ D) (X : C) (S : J.cover X), has_multiequalizer (S.index P)]
variables (P : Cᵒᵖ ⥤ D)
/-- The diagram whose colimit defines the values of `plus`. -/
@[simps]
def diagram (X : C) : (J.cover X)ᵒᵖ ⥤ D :=
{ obj := λ S, multiequalizer (S.unop.index P),
map := λ S T f,
multiequalizer.lift _ _ (λ I, multiequalizer.ι (S.unop.index P) (I.map f.unop)) $
λ I, multiequalizer.condition (S.unop.index P) (I.map f.unop),
map_id' := λ S, by { ext I, cases I, simpa },
map_comp' := λ S T W f g, by { ext I, simpa } }
/-- A helper definition used to define the morphisms for `plus`. -/
@[simps]
def diagram_pullback {X Y : C} (f : X ⟶ Y) :
J.diagram P Y ⟶ (J.pullback f).op ⋙ J.diagram P X :=
{ app := λ S, multiequalizer.lift _ _
(λ I, multiequalizer.ι (S.unop.index P) I.base) $
λ I, multiequalizer.condition (S.unop.index P) I.base,
naturality' := λ S T f, by { ext, dsimp, simpa } }
/-- A natural transformation `P ⟶ Q` induces a natural transformation
between diagrams whose colimits define the values of `plus`. -/
@[simps]
def diagram_nat_trans {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (X : C) :
J.diagram P X ⟶ J.diagram Q X :=
{ app := λ W, multiequalizer.lift _ _
(λ i, multiequalizer.ι _ i ≫ η.app _) begin
intros i,
erw [category.assoc, category.assoc, ← η.naturality,
← η.naturality, ← category.assoc, ← category.assoc, multiequalizer.condition],
refl,
end,
naturality' := λ _ _ _, by { dsimp, ext, simpa } }
@[simp]
lemma diagram_nat_trans_id (X : C) (P : Cᵒᵖ ⥤ D) :
J.diagram_nat_trans (𝟙 P) X = 𝟙 (J.diagram P X) :=
begin
ext,
dsimp,
simp only [multiequalizer.lift_ι, category.id_comp],
erw category.comp_id
end
@[simp]
lemma diagram_nat_trans_comp {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R) (X : C) :
J.diagram_nat_trans (η ≫ γ) X = J.diagram_nat_trans η X ≫ J.diagram_nat_trans γ X :=
by { ext, dsimp, simp }
variable (D)
/-- `J.diagram P`, as a functor in `P`. -/
@[simps]
def diagram_functor (X : C) : (Cᵒᵖ ⥤ D) ⥤ (J.cover X)ᵒᵖ ⥤ D :=
{ obj := λ P, J.diagram P X,
map := λ P Q η, J.diagram_nat_trans η X,
map_id' := λ P, J.diagram_nat_trans_id _ _,
map_comp' := λ P Q R η γ, J.diagram_nat_trans_comp _ _ _ }
variable {D}
variable [∀ (X : C), has_colimits_of_shape (J.cover X)ᵒᵖ D]
/-- The plus construction, associating a presheaf to any presheaf.
See `plus_functor` below for a functorial version. -/
def plus_obj : Cᵒᵖ ⥤ D :=
{ obj := λ X, colimit (J.diagram P X.unop),
map := λ X Y f, colim_map (J.diagram_pullback P f.unop) ≫ colimit.pre _ _,
map_id' := begin
intros X,
ext S,
dsimp,
simp only [diagram_pullback_app, colimit.ι_pre,
ι_colim_map_assoc, category.comp_id],
let e := S.unop.pullback_id,
dsimp only [functor.op, pullback_obj],
erw [← colimit.w _ e.inv.op, ← category.assoc],
convert category.id_comp _,
ext I,
dsimp,
simp only [multiequalizer.lift_ι, category.id_comp, category.assoc],
dsimp [cover.arrow.map, cover.arrow.base],
cases I,
congr,
simp,
end,
map_comp' := begin
intros X Y Z f g,
ext S,
dsimp,
simp only [diagram_pullback_app, colimit.ι_pre_assoc,
colimit.ι_pre, ι_colim_map_assoc, category.assoc],
let e := S.unop.pullback_comp g.unop f.unop,
dsimp only [functor.op, pullback_obj],
erw [← colimit.w _ e.inv.op, ← category.assoc, ← category.assoc],
congr' 1,
ext I,
dsimp,
simp only [multiequalizer.lift_ι, category.assoc],
cases I,
dsimp only [cover.arrow.base, cover.arrow.map],
congr' 2,
simp,
end }
/-- An auxiliary definition used in `plus` below. -/
def plus_map {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) : J.plus_obj P ⟶ J.plus_obj Q :=
{ app := λ X, colim_map (J.diagram_nat_trans η X.unop),
naturality' := begin
intros X Y f,
dsimp [plus_obj],
ext,
simp only [diagram_pullback_app, ι_colim_map, colimit.ι_pre_assoc,
colimit.ι_pre, ι_colim_map_assoc, category.assoc],
simp_rw ← category.assoc,
congr' 1,
ext,
dsimp,
simpa,
end }
@[simp]
lemma plus_map_id (P : Cᵒᵖ ⥤ D) : J.plus_map (𝟙 P) = 𝟙 _ :=
begin
ext x : 2,
dsimp only [plus_map, plus_obj],
rw [J.diagram_nat_trans_id, nat_trans.id_app],
ext,
dsimp,
simp,
end
@[simp]
lemma plus_map_comp {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R) :
J.plus_map (η ≫ γ) = J.plus_map η ≫ J.plus_map γ :=
begin
ext : 2,
dsimp only [plus_map],
rw J.diagram_nat_trans_comp,
ext,
dsimp,
simp,
end
variable (D)
/-- The plus construction, a functor sending `P` to `J.plus_obj P`. -/
@[simps]
def plus_functor : (Cᵒᵖ ⥤ D) ⥤ Cᵒᵖ ⥤ D :=
{ obj := λ P, J.plus_obj P,
map := λ P Q η, J.plus_map η,
map_id' := λ _, plus_map_id _ _,
map_comp' := λ _ _ _ _ _, plus_map_comp _ _ _ }
variable {D}
/-- The canonical map from `P` to `J.plus.obj P`.
See `to_plus` for a functorial version. -/
def to_plus : P ⟶ J.plus_obj P :=
{ app := λ X, cover.to_multiequalizer (⊤ : J.cover X.unop) P ≫
colimit.ι (J.diagram P X.unop) (op ⊤),
naturality' := begin
intros X Y f,
dsimp [plus_obj],
delta cover.to_multiequalizer,
simp only [diagram_pullback_app, colimit.ι_pre, ι_colim_map_assoc, category.assoc],
dsimp only [functor.op, unop_op],
let e : (J.pullback f.unop).obj ⊤ ⟶ ⊤ := hom_of_le (order_top.le_top _),
rw [← colimit.w _ e.op, ← category.assoc, ← category.assoc, ← category.assoc],
congr' 1,
ext,
dsimp,
simp only [multiequalizer.lift_ι, category.assoc],
dsimp [cover.arrow.base],
simp,
end }
@[simp, reassoc]
lemma to_plus_naturality {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) :
η ≫ J.to_plus Q = J.to_plus _ ≫ J.plus_map η :=
begin
ext,
dsimp [to_plus, plus_map],
delta cover.to_multiequalizer,
simp only [ι_colim_map, category.assoc],
simp_rw ← category.assoc,
congr' 1,
ext,
dsimp,
simp,
end
variable (D)
/-- The natural transformation from the identity functor to `plus`. -/
@[simps]
def to_plus_nat_trans : (𝟭 (Cᵒᵖ ⥤ D)) ⟶ J.plus_functor D :=
{ app := λ P, J.to_plus P,
naturality' := λ _ _ _, to_plus_naturality _ _ }
variable {D}
/-- `(P ⟶ P⁺)⁺ = P⁺ ⟶ P⁺⁺` -/
@[simp]
lemma plus_map_to_plus : J.plus_map (J.to_plus P) = J.to_plus (J.plus_obj P) :=
begin
ext X S,
dsimp [to_plus, plus_obj, plus_map],
delta cover.to_multiequalizer,
simp only [ι_colim_map],
let e : S.unop ⟶ ⊤ := hom_of_le (order_top.le_top _),
simp_rw [← colimit.w _ e.op, ← category.assoc],
congr' 1,
ext I,
dsimp,
simp only [diagram_pullback_app, colimit.ι_pre, multiequalizer.lift_ι,
ι_colim_map_assoc, category.assoc],
dsimp only [functor.op],
let ee : (J.pullback (I.map e).f).obj S.unop ⟶ ⊤ := hom_of_le (order_top.le_top _),
simp_rw [← colimit.w _ ee.op, ← category.assoc],
congr' 1,
ext II,
dsimp,
simp only [limit.lift_π, multifork.of_ι_π_app, multiequalizer.lift_ι, category.assoc],
dsimp [multifork.of_ι],
convert multiequalizer.condition (S.unop.index P)
⟨_, _, _, II.f, 𝟙 _, I.f, II.f ≫ I.f, I.hf, sieve.downward_closed _ I.hf _, by simp⟩,
{ cases I, refl },
{ dsimp [cover.index],
erw [P.map_id, category.comp_id],
refl }
end
lemma is_iso_to_plus_of_is_sheaf (hP : presheaf.is_sheaf J P) : is_iso (J.to_plus P) :=
begin
rw presheaf.is_sheaf_iff_multiequalizer at hP,
resetI,
suffices : ∀ X, is_iso ((J.to_plus P).app X),
{ resetI, apply nat_iso.is_iso_of_is_iso_app },
intros X, dsimp,
suffices : is_iso (colimit.ι (J.diagram P X.unop) (op ⊤)),
{ resetI, apply is_iso.comp_is_iso },
suffices : ∀ (S T : (J.cover X.unop)ᵒᵖ) (f : S ⟶ T), is_iso ((J.diagram P X.unop).map f),
{ resetI, apply is_iso_ι_of_is_initial (initial_op_of_terminal is_terminal_top) },
intros S T e,
have : S.unop.to_multiequalizer P ≫ (J.diagram P (X.unop)).map e =
T.unop.to_multiequalizer P, by { ext, dsimp, simpa },
have : (J.diagram P (X.unop)).map e = inv (S.unop.to_multiequalizer P) ≫
T.unop.to_multiequalizer P, by simp [← this],
rw this, apply_instance,
end
/-- The natural isomorphism between `P` and `P⁺` when `P` is a sheaf. -/
def iso_to_plus (hP : presheaf.is_sheaf J P) : P ≅ J.plus_obj P :=
by letI := is_iso_to_plus_of_is_sheaf J P hP; exact as_iso (J.to_plus P)
@[simp]
lemma iso_to_plus_hom (hP : presheaf.is_sheaf J P) : (J.iso_to_plus P hP).hom = J.to_plus P := rfl
/-- Lift a morphism `P ⟶ Q` to `P⁺ ⟶ Q` when `Q` is a sheaf. -/
def plus_lift {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : presheaf.is_sheaf J Q) :
J.plus_obj P ⟶ Q :=
J.plus_map η ≫ (J.iso_to_plus Q hQ).inv
@[simp, reassoc]
lemma to_plus_plus_lift {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : presheaf.is_sheaf J Q) :
J.to_plus P ≫ J.plus_lift η hQ = η :=
begin
dsimp [plus_lift],
rw ← category.assoc,
rw iso.comp_inv_eq,
dsimp only [iso_to_plus, as_iso],
rw to_plus_naturality,
end
lemma plus_lift_unique {P Q : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (hQ : presheaf.is_sheaf J Q)
(γ : J.plus_obj P ⟶ Q) (hγ : J.to_plus P ≫ γ = η) : γ = J.plus_lift η hQ :=
begin
dsimp only [plus_lift],
rw [iso.eq_comp_inv, ← hγ, plus_map_comp],
dsimp,
simp,
end
lemma plus_hom_ext {P Q : Cᵒᵖ ⥤ D} (η γ : J.plus_obj P ⟶ Q) (hQ : presheaf.is_sheaf J Q)
(h : J.to_plus P ≫ η = J.to_plus P ≫ γ) : η = γ :=
begin
have : γ = J.plus_lift (J.to_plus P ≫ γ) hQ,
{ apply plus_lift_unique, refl },
rw this,
apply plus_lift_unique, exact h
end
@[simp]
lemma iso_to_plus_inv (hP : presheaf.is_sheaf J P) : (J.iso_to_plus P hP).inv =
J.plus_lift (𝟙 _) hP :=
begin
apply J.plus_lift_unique,
rw [iso.comp_inv_eq, category.id_comp],
refl,
end
@[simp]
lemma plus_map_plus_lift {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R) (hR : presheaf.is_sheaf J R) :
J.plus_map η ≫ J.plus_lift γ hR = J.plus_lift (η ≫ γ) hR :=
begin
apply J.plus_lift_unique,
rw [← category.assoc, ← J.to_plus_naturality, category.assoc, J.to_plus_plus_lift],
end
end category_theory.grothendieck_topology
|
fdf7301a787f057efc6d112ba8536bd702912c27 | a0e23cfdd129a671bf3154ee1a8a3a72bf4c7940 | /stage0/src/Lean/Meta/Offset.lean | e6ca7863a3902b94231773152c019ebca558bbb9 | [
"Apache-2.0"
] | permissive | WojciechKarpiel/lean4 | 7f89706b8e3c1f942b83a2c91a3a00b05da0e65b | f6e1314fa08293dea66a329e05b6c196a0189163 | refs/heads/master | 1,686,633,402,214 | 1,625,821,189,000 | 1,625,821,258,000 | 384,640,886 | 0 | 0 | Apache-2.0 | 1,625,903,617,000 | 1,625,903,026,000 | null | UTF-8 | Lean | false | false | 6,367 | 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
-/
import Lean.Data.LBool
import Lean.Meta.InferType
namespace Lean.Meta
private abbrev withInstantiatedMVars (e : Expr) (k : Expr → OptionT MetaM α) : OptionT MetaM α := do
let eNew ← instantiateMVars e
if eNew.getAppFn.isMVar then
failure
else
k eNew
/--
Evaluate simple `Nat` expressions.
Remark: this method assumes the given expression has type `Nat`. -/
partial def evalNat : Expr → OptionT MetaM Nat
| Expr.lit (Literal.natVal n) _ => return n
| Expr.mdata _ e _ => evalNat e
| Expr.const `Nat.zero .. => return 0
| e@(Expr.app ..) => visit e
| e@(Expr.mvar ..) => visit e
| _ => failure
where
visit e := do
let f := e.getAppFn
match f with
| Expr.mvar .. => withInstantiatedMVars e evalNat
| Expr.const c _ _ =>
let nargs := e.getAppNumArgs
if c == ``Nat.succ && nargs == 1 then
let v ← evalNat (e.getArg! 0)
return v+1
else if c == ``Nat.add && nargs == 2 then
let v₁ ← evalNat (e.getArg! 0)
let v₂ ← evalNat (e.getArg! 1)
return v₁ + v₂
else if c == ``Nat.sub && nargs == 2 then
let v₁ ← evalNat (e.getArg! 0)
let v₂ ← evalNat (e.getArg! 1)
return v₁ - v₂
else if c == ``Nat.mul && nargs == 2 then
let v₁ ← evalNat (e.getArg! 0)
let v₂ ← evalNat (e.getArg! 1)
return v₁ * v₂
else if c == ``Add.add && nargs == 4 then
let v₁ ← evalNat (e.getArg! 2)
let v₂ ← evalNat (e.getArg! 3)
return v₁ + v₂
else if c == ``Sub.sub && nargs == 4 then
let v₁ ← evalNat (e.getArg! 2)
let v₂ ← evalNat (e.getArg! 3)
return v₁ - v₂
else if c == ``Mul.mul && nargs == 4 then
let v₁ ← evalNat (e.getArg! 2)
let v₂ ← evalNat (e.getArg! 3)
return v₁ * v₂
else if c == ``HAdd.hAdd && nargs == 6 then
let v₁ ← evalNat (e.getArg! 3)
let v₂ ← evalNat (e.getArg! 5)
return v₁ + v₂
else if c == ``HSub.hSub && nargs == 6 then
let v₁ ← evalNat (e.getArg! 4)
let v₂ ← evalNat (e.getArg! 5)
return v₁ - v₂
else if c == ``HMul.hMul && nargs == 6 then
let v₁ ← evalNat (e.getArg! 4)
let v₂ ← evalNat (e.getArg! 5)
return v₁ * v₂
else if c == ``OfNat.ofNat && nargs == 3 then
evalNat (e.getArg! 1)
else
failure
| _ => failure
/- Quick function for converting `e` into `s + k` s.t. `e` is definitionally equal to `Nat.add s k`. -/
private partial def getOffsetAux : Expr → Bool → OptionT MetaM (Expr × Nat)
| e@(Expr.app _ a _), top => do
let f := e.getAppFn
match f with
| Expr.mvar .. => withInstantiatedMVars e (getOffsetAux · top)
| Expr.const c _ _ =>
let nargs := e.getAppNumArgs
if c == ``Nat.succ && nargs == 1 then do
let (s, k) ← getOffsetAux a false
pure (s, k+1)
else if c == ``Nat.add && nargs == 2 then do
let v ← evalNat (e.getArg! 1)
let (s, k) ← getOffsetAux (e.getArg! 0) false
pure (s, k+v)
else if c == ``Add.add && nargs == 4 then do
let v ← evalNat (e.getArg! 3)
let (s, k) ← getOffsetAux (e.getArg! 2) false
pure (s, k+v)
else if c == ``HAdd.hAdd && nargs == 6 then do
let v ← evalNat (e.getArg! 5)
let (s, k) ← getOffsetAux (e.getArg! 4) false
pure (s, k+v)
else if top then failure else pure (e, 0)
| _ => if top then failure else pure (e, 0)
| e, top => if top then failure else pure (e, 0)
private def getOffset (e : Expr) : OptionT MetaM (Expr × Nat) :=
getOffsetAux e true
private partial def isOffset : Expr → OptionT MetaM (Expr × Nat)
| e@(Expr.app _ a _) =>
let f := e.getAppFn
match f with
| Expr.mvar .. => withInstantiatedMVars e isOffset
| Expr.const c _ _ =>
let nargs := e.getAppNumArgs
if (c == ``Nat.succ && nargs == 1) || (c == ``Nat.add && nargs == 2) || (c == ``Add.add && nargs == 4) || (c == ``HAdd.hAdd && nargs == 6) then
getOffset e
else
failure
| _ => failure
| _ => failure
private def isNatZero (e : Expr) : MetaM Bool := do
match (← evalNat e) with
| some v => v == 0
| _ => false
private def mkOffset (e : Expr) (offset : Nat) : MetaM Expr := do
if offset == 0 then
return e
else if (← isNatZero e) then
return mkNatLit offset
else
return mkAppB (mkConst ``Nat.add) e (mkNatLit offset)
def isDefEqOffset (s t : Expr) : MetaM LBool := do
let ifNatExpr (x : MetaM LBool) : MetaM LBool := do
let type ← inferType s
-- Remark: we use `withNewMCtxDepth` to make sure we don't assing metavariables when performing the `isDefEq` test
if (← withNewMCtxDepth <| Meta.isExprDefEqAux type (mkConst ``Nat)) then
x
else
return LBool.undef
let isDefEq (s t) : MetaM LBool :=
ifNatExpr <| toLBoolM <| Meta.isExprDefEqAux s t
match (← isOffset s) with
| some (s, k₁) =>
match (← isOffset t) with
| some (t, k₂) => -- s+k₁ =?= t+k₂
if k₁ == k₂ then
isDefEq s t
else if k₁ < k₂ then
isDefEq s (← mkOffset t (k₂ - k₁))
else
isDefEq (← mkOffset s (k₁ - k₂)) t
| none =>
match (← evalNat t) with
| some v₂ => -- s+k₁ =?= v₂
if v₂ ≥ k₁ then
isDefEq s (mkNatLit $ v₂ - k₁)
else
ifNatExpr <| return LBool.false
| none =>
return LBool.undef
| none =>
match (← evalNat s) with
| some v₁ =>
match (← isOffset t) with
| some (t, k₂) => -- v₁ =?= t+k₂
if v₁ ≥ k₂ then
isDefEq (mkNatLit $ v₁ - k₂) t
else
ifNatExpr <| return LBool.false
| none =>
match (← evalNat t) with
| some v₂ => ifNatExpr <| return (v₁ == v₂).toLBool -- v₁ =?= v₂
| none => return LBool.undef
| none => return LBool.undef
end Lean.Meta
|
5c00f3f2d3636d04a69832a6a08cb9314fb83f97 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/linear_algebra/pi_tensor_product.lean | 2173c91696c5cb0969b7eebe8a53ccb335a0b6cf | [
"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 | 24,340 | lean | /-
Copyright (c) 2020 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis, Eric Wieser
-/
import group_theory.congruence
import linear_algebra.multilinear.tensor_product
/-!
# Tensor product of an indexed family of modules over commutative semirings
We define the tensor product of an indexed family `s : ι → Type*` of modules over commutative
semirings. We denote this space by `⨂[R] i, s i` and define it as `free_add_monoid (R × Π i, s i)`
quotiented by the appropriate equivalence relation. The treatment follows very closely that of the
binary tensor product in `linear_algebra/tensor_product.lean`.
## Main definitions
* `pi_tensor_product R s` with `R` a commutative semiring and `s : ι → Type*` is the tensor product
of all the `s i`'s. This is denoted by `⨂[R] i, s i`.
* `tprod R f` with `f : Π i, s i` is the tensor product of the vectors `f i` over all `i : ι`.
This is bundled as a multilinear map from `Π i, s i` to `⨂[R] i, s i`.
* `lift_add_hom` constructs an `add_monoid_hom` from `(⨂[R] i, s i)` to some space `F` from a
function `φ : (R × Π i, s i) → F` with the appropriate properties.
* `lift φ` with `φ : multilinear_map R s E` is the corresponding linear map
`(⨂[R] i, s i) →ₗ[R] E`. This is bundled as a linear equivalence.
* `pi_tensor_product.reindex e` re-indexes the components of `⨂[R] i : ι, M` along `e : ι ≃ ι₂`.
* `pi_tensor_product.tmul_equiv` equivalence between a `tensor_product` of `pi_tensor_product`s and
a single `pi_tensor_product`.
## Notations
* `⨂[R] i, s i` is defined as localized notation in locale `tensor_product`
* `⨂ₜ[R] i, f i` with `f : Π i, f i` is defined globally as the tensor product of all the `f i`'s.
## Implementation notes
* We define it via `free_add_monoid (R × Π i, s i)` with the `R` representing a "hidden" tensor
factor, rather than `free_add_monoid (Π i, s i)` to ensure that, if `ι` is an empty type,
the space is isomorphic to the base ring `R`.
* We have not restricted the index type `ι` to be a `fintype`, as nothing we do here strictly
requires it. However, problems may arise in the case where `ι` is infinite; use at your own
caution.
## TODO
* Define tensor powers, symmetric subspace, etc.
* API for the various ways `ι` can be split into subsets; connect this with the binary
tensor product.
* Include connection with holors.
* Port more of the API from the binary tensor product over to this case.
## Tags
multilinear, tensor, tensor product
-/
open function
section semiring
variables {ι ι₂ ι₃ : Type*} [decidable_eq ι] [decidable_eq ι₂] [decidable_eq ι₃]
variables {R : Type*} [comm_semiring R]
variables {R₁ R₂ : Type*}
variables {s : ι → Type*} [∀ i, add_comm_monoid (s i)] [∀ i, module R (s i)]
variables {M : Type*} [add_comm_monoid M] [module R M]
variables {E : Type*} [add_comm_monoid E] [module R E]
variables {F : Type*} [add_comm_monoid F]
namespace pi_tensor_product
include R
variables (R) (s)
/-- The relation on `free_add_monoid (R × Π i, s i)` that generates a congruence whose quotient is
the tensor product. -/
inductive eqv : free_add_monoid (R × Π i, s i) → free_add_monoid (R × Π i, s i) → Prop
| of_zero : ∀ (r : R) (f : Π i, s i) (i : ι) (hf : f i = 0), eqv (free_add_monoid.of (r, f)) 0
| of_zero_scalar : ∀ (f : Π i, s i), eqv (free_add_monoid.of (0, f)) 0
| of_add : ∀ (r : R) (f : Π i, s i) (i : ι) (m₁ m₂ : s i), eqv
(free_add_monoid.of (r, update f i m₁) + free_add_monoid.of (r, update f i m₂))
(free_add_monoid.of (r, update f i (m₁ + m₂)))
| of_add_scalar : ∀ (r r' : R) (f : Π i, s i), eqv
(free_add_monoid.of (r, f) + free_add_monoid.of (r', f))
(free_add_monoid.of (r + r', f))
| of_smul : ∀ (r : R) (f : Π i, s i) (i : ι) (r' : R), eqv
(free_add_monoid.of (r, update f i (r' • (f i))))
(free_add_monoid.of (r' * r, f))
| add_comm : ∀ x y, eqv (x + y) (y + x)
end pi_tensor_product
variables (R) (s)
/-- `pi_tensor_product R s` with `R` a commutative semiring and `s : ι → Type*` is the tensor
product of all the `s i`'s. This is denoted by `⨂[R] i, s i`. -/
def pi_tensor_product : Type* :=
(add_con_gen (pi_tensor_product.eqv R s)).quotient
variables {R}
/- This enables the notation `⨂[R] i : ι, s i` for the pi tensor product, given `s : ι → Type*`. -/
localized "notation `⨂[`:100 R `] ` binders `, ` r:(scoped:67 f, pi_tensor_product R f) := r"
in tensor_product
open_locale tensor_product
namespace pi_tensor_product
section module
instance : add_comm_monoid (⨂[R] i, s i) :=
{ add_comm := λ x y, add_con.induction_on₂ x y $ λ x y, quotient.sound' $
add_con_gen.rel.of _ _ $ eqv.add_comm _ _,
.. (add_con_gen (pi_tensor_product.eqv R s)).add_monoid }
instance : inhabited (⨂[R] i, s i) := ⟨0⟩
variables (R) {s}
/-- `tprod_coeff R r f` with `r : R` and `f : Π i, s i` is the tensor product of the vectors `f i`
over all `i : ι`, multiplied by the coefficient `r`. Note that this is meant as an auxiliary
definition for this file alone, and that one should use `tprod` defined below for most purposes. -/
def tprod_coeff (r : R) (f : Π i, s i) : ⨂[R] i, s i := add_con.mk' _ $ free_add_monoid.of (r, f)
variables {R}
lemma zero_tprod_coeff (f : Π i, s i) : tprod_coeff R 0 f = 0 :=
quotient.sound' $ add_con_gen.rel.of _ _ $ eqv.of_zero_scalar _
lemma zero_tprod_coeff' (z : R) (f : Π i, s i) (i : ι) (hf: f i = 0) : tprod_coeff R z f = 0 :=
quotient.sound' $ add_con_gen.rel.of _ _ $ eqv.of_zero _ _ i hf
lemma add_tprod_coeff (z : R) (f : Π i, s i) (i : ι) (m₁ m₂ : s i) :
tprod_coeff R z (update f i m₁) + tprod_coeff R z (update f i m₂) =
tprod_coeff R z (update f i (m₁ + m₂)) :=
quotient.sound' $ add_con_gen.rel.of _ _ (eqv.of_add z f i m₁ m₂)
lemma add_tprod_coeff' (z₁ z₂ : R) (f : Π i, s i) :
tprod_coeff R z₁ f + tprod_coeff R z₂ f = tprod_coeff R (z₁ + z₂) f :=
quotient.sound' $ add_con_gen.rel.of _ _ (eqv.of_add_scalar z₁ z₂ f)
lemma smul_tprod_coeff_aux (z : R) (f : Π i, s i) (i : ι) (r : R) :
tprod_coeff R z (update f i (r • f i)) = tprod_coeff R (r * z) f :=
quotient.sound' $ add_con_gen.rel.of _ _ $ eqv.of_smul _ _ _ _
lemma smul_tprod_coeff (z : R) (f : Π i, s i) (i : ι) (r : R₁)
[has_scalar R₁ R] [is_scalar_tower R₁ R R] [has_scalar R₁ (s i)] [is_scalar_tower R₁ R (s i)] :
tprod_coeff R z (update f i (r • f i)) = tprod_coeff R (r • z) f :=
begin
have h₁ : r • z = (r • (1 : R)) * z := by rw [smul_mul_assoc, one_mul],
have h₂ : r • (f i) = (r • (1 : R)) • f i := (smul_one_smul _ _ _).symm,
rw [h₁, h₂],
exact smul_tprod_coeff_aux z f i _,
end
/-- Construct an `add_monoid_hom` from `(⨂[R] i, s i)` to some space `F` from a function
`φ : (R × Π i, s i) → F` with the appropriate properties. -/
def lift_add_hom (φ : (R × Π i, s i) → F)
(C0 : ∀ (r : R) (f : Π i, s i) (i : ι) (hf : f i = 0), φ (r, f) = 0)
(C0' : ∀ (f : Π i, s i), φ (0, f) = 0)
(C_add : ∀ (r : R) (f : Π i, s i) (i : ι) (m₁ m₂ : s i),
φ (r, update f i m₁) + φ (r, update f i m₂) = φ (r, update f i (m₁ + m₂)))
(C_add_scalar : ∀ (r r' : R) (f : Π i, s i),
φ (r , f) + φ (r', f) = φ (r + r', f))
(C_smul : ∀ (r : R) (f : Π i, s i) (i : ι) (r' : R),
φ (r, update f i (r' • (f i))) = φ (r' * r, f))
: (⨂[R] i, s i) →+ F :=
(add_con_gen (pi_tensor_product.eqv R s)).lift (free_add_monoid.lift φ) $ add_con.add_con_gen_le $
λ x y hxy, match x, y, hxy with
| _, _, (eqv.of_zero r' f i hf) := (add_con.ker_rel _).2 $
by simp [free_add_monoid.lift_eval_of, C0 r' f i hf]
| _, _, (eqv.of_zero_scalar f) := (add_con.ker_rel _).2 $
by simp [free_add_monoid.lift_eval_of, C0']
| _, _, (eqv.of_add z f i m₁ m₂) := (add_con.ker_rel _).2 $
by simp [free_add_monoid.lift_eval_of, C_add]
| _, _, (eqv.of_add_scalar z₁ z₂ f) := (add_con.ker_rel _).2 $
by simp [free_add_monoid.lift_eval_of, C_add_scalar]
| _, _, (eqv.of_smul z f i r') := (add_con.ker_rel _).2 $
by simp [free_add_monoid.lift_eval_of, C_smul]
| _, _, (eqv.add_comm x y) := (add_con.ker_rel _).2 $
by simp_rw [add_monoid_hom.map_add, add_comm]
end
@[elab_as_eliminator]
protected theorem induction_on'
{C : (⨂[R] i, s i) → Prop}
(z : ⨂[R] i, s i)
(C1 : ∀ {r : R} {f : Π i, s i}, C (tprod_coeff R r f))
(Cp : ∀ {x y}, C x → C y → C (x + y)) : C z :=
begin
have C0 : C 0,
{ have h₁ := @C1 0 0,
rwa [zero_tprod_coeff] at h₁ },
refine add_con.induction_on z (λ x, free_add_monoid.rec_on x C0 _),
simp_rw add_con.coe_add,
refine λ f y ih, Cp _ ih,
convert @C1 f.1 f.2,
simp only [prod.mk.eta],
end
section distrib_mul_action
variables [monoid R₁] [distrib_mul_action R₁ R] [smul_comm_class R₁ R R]
variables [monoid R₂] [distrib_mul_action R₂ R] [smul_comm_class R₂ R R]
-- Most of the time we want the instance below this one, which is easier for typeclass resolution
-- to find.
instance has_scalar' : has_scalar R₁ (⨂[R] i, s i) :=
⟨λ r, lift_add_hom (λ f : R × Π i, s i, tprod_coeff R (r • f.1) f.2)
(λ r' f i hf, by simp_rw [zero_tprod_coeff' _ f i hf])
(λ f, by simp [zero_tprod_coeff])
(λ r' f i m₁ m₂, by simp [add_tprod_coeff])
(λ r' r'' f, by simp [add_tprod_coeff', mul_add])
(λ z f i r', by simp [smul_tprod_coeff, mul_smul_comm])⟩
instance : has_scalar R (⨂[R] i, s i) := pi_tensor_product.has_scalar'
lemma smul_tprod_coeff' (r : R₁) (z : R) (f : Π i, s i) :
r • (tprod_coeff R z f) = tprod_coeff R (r • z) f := rfl
protected theorem smul_add (r : R₁) (x y : ⨂[R] i, s i) :
r • (x + y) = r • x + r • y :=
add_monoid_hom.map_add _ _ _
instance distrib_mul_action' : distrib_mul_action R₁ (⨂[R] i, s i) :=
{ smul := (•),
smul_add := λ r x y, add_monoid_hom.map_add _ _ _,
mul_smul := λ r r' x, pi_tensor_product.induction_on' x
(λ r'' f, by simp [smul_tprod_coeff', smul_smul])
(λ x y ihx ihy, by simp_rw [pi_tensor_product.smul_add, ihx, ihy]),
one_smul := λ x, pi_tensor_product.induction_on' x
(λ f, by simp [smul_tprod_coeff' _ _])
(λ z y ihz ihy, by simp_rw [pi_tensor_product.smul_add, ihz, ihy]),
smul_zero := λ r, add_monoid_hom.map_zero _ }
instance smul_comm_class' [smul_comm_class R₁ R₂ R] : smul_comm_class R₁ R₂ (⨂[R] i, s i) :=
⟨λ r' r'' x, pi_tensor_product.induction_on' x
(λ xr xf, by simp only [smul_tprod_coeff', smul_comm])
(λ z y ihz ihy, by simp_rw [pi_tensor_product.smul_add, ihz, ihy])⟩
instance is_scalar_tower' [has_scalar R₁ R₂] [is_scalar_tower R₁ R₂ R] :
is_scalar_tower R₁ R₂ (⨂[R] i, s i) :=
⟨λ r' r'' x, pi_tensor_product.induction_on' x
(λ xr xf, by simp only [smul_tprod_coeff', smul_assoc])
(λ z y ihz ihy, by simp_rw [pi_tensor_product.smul_add, ihz, ihy])⟩
end distrib_mul_action
-- Most of the time we want the instance below this one, which is easier for typeclass resolution
-- to find.
instance module' [semiring R₁] [module R₁ R] [smul_comm_class R₁ R R] : module R₁ (⨂[R] i, s i) :=
{ smul := (•),
add_smul := λ r r' x, pi_tensor_product.induction_on' x
(λ r f, by simp [smul_tprod_coeff' _ _, add_smul, add_tprod_coeff'])
(λ x y ihx ihy, by simp [pi_tensor_product.smul_add, ihx, ihy, add_add_add_comm]),
zero_smul := λ x, pi_tensor_product.induction_on' x
(λ r f, by { simp_rw [smul_tprod_coeff' _ _, zero_smul], exact zero_tprod_coeff _ })
(λ x y ihx ihy, by rw [pi_tensor_product.smul_add, ihx, ihy, add_zero]),
..pi_tensor_product.distrib_mul_action' }
-- shortcut instances
instance : module R (⨂[R] i, s i) := pi_tensor_product.module'
instance : smul_comm_class R R (⨂[R] i, s i) := pi_tensor_product.smul_comm_class'
instance : is_scalar_tower R R (⨂[R] i, s i) := pi_tensor_product.is_scalar_tower'
variables {R}
variables (R)
/-- The canonical `multilinear_map R s (⨂[R] i, s i)`. -/
def tprod : multilinear_map R s (⨂[R] i, s i) :=
{ to_fun := tprod_coeff R 1,
map_add' := λ f i x y, (add_tprod_coeff (1 : R) f i x y).symm,
map_smul' := λ f i r x,
by simp_rw [smul_tprod_coeff', ←smul_tprod_coeff (1 : R) _ i, update_idem, update_same] }
variables {R}
notation `⨂ₜ[`:100 R`] ` binders `, ` r:(scoped:67 f, tprod R f) := r
@[simp]
lemma tprod_coeff_eq_smul_tprod (z : R) (f : Π i, s i) : tprod_coeff R z f = z • tprod R f :=
begin
have : z = z • (1 : R) := by simp only [mul_one, algebra.id.smul_eq_mul],
conv_lhs { rw this },
rw ←smul_tprod_coeff',
refl,
end
@[elab_as_eliminator]
protected theorem induction_on
{C : (⨂[R] i, s i) → Prop}
(z : ⨂[R] i, s i)
(C1 : ∀ {r : R} {f : Π i, s i}, C (r • (tprod R f)))
(Cp : ∀ {x y}, C x → C y → C (x + y)) : C z :=
begin
simp_rw ←tprod_coeff_eq_smul_tprod at C1,
exact pi_tensor_product.induction_on' z @C1 @Cp,
end
@[ext]
theorem ext {φ₁ φ₂ : (⨂[R] i, s i) →ₗ[R] E}
(H : φ₁.comp_multilinear_map (tprod R) = φ₂.comp_multilinear_map (tprod R)) : φ₁ = φ₂ :=
begin
refine linear_map.ext _,
refine λ z,
(pi_tensor_product.induction_on' z _ (λ x y hx hy, by rw [φ₁.map_add, φ₂.map_add, hx, hy])),
{ intros r f,
rw [tprod_coeff_eq_smul_tprod, φ₁.map_smul, φ₂.map_smul],
apply _root_.congr_arg,
exact multilinear_map.congr_fun H f }
end
end module
section multilinear
open multilinear_map
variables {s}
/-- Auxiliary function to constructing a linear map `(⨂[R] i, s i) → E` given a
`multilinear map R s E` with the property that its composition with the canonical
`multilinear_map R s (⨂[R] i, s i)` is the given multilinear map. -/
def lift_aux (φ : multilinear_map R s E) : (⨂[R] i, s i) →+ E :=
lift_add_hom (λ (p : R × Π i, s i), p.1 • (φ p.2))
(λ z f i hf, by rw [map_coord_zero φ i hf, smul_zero])
(λ f, by rw [zero_smul])
(λ z f i m₁ m₂, by rw [←smul_add, φ.map_add])
(λ z₁ z₂ f, by rw [←add_smul])
(λ z f i r, by simp [φ.map_smul, smul_smul, mul_comm])
lemma lift_aux_tprod (φ : multilinear_map R s E) (f : Π i, s i) : lift_aux φ (tprod R f) = φ f :=
by simp only [lift_aux, lift_add_hom, tprod, multilinear_map.coe_mk, tprod_coeff,
free_add_monoid.lift_eval_of, one_smul, add_con.lift_mk']
lemma lift_aux_tprod_coeff (φ : multilinear_map R s E) (z : R) (f : Π i, s i) :
lift_aux φ (tprod_coeff R z f) = z • φ f :=
by simp [lift_aux, lift_add_hom, tprod_coeff, free_add_monoid.lift_eval_of]
lemma lift_aux.smul {φ : multilinear_map R s E} (r : R) (x : ⨂[R] i, s i) :
lift_aux φ (r • x) = r • lift_aux φ x :=
begin
refine pi_tensor_product.induction_on' x _ _,
{ intros z f,
rw [smul_tprod_coeff' r z f, lift_aux_tprod_coeff, lift_aux_tprod_coeff, smul_assoc] },
{ intros z y ihz ihy,
rw [smul_add, (lift_aux φ).map_add, ihz, ihy, (lift_aux φ).map_add, smul_add] }
end
/-- Constructing a linear map `(⨂[R] i, s i) → E` given a `multilinear_map R s E` with the
property that its composition with the canonical `multilinear_map R s E` is
the given multilinear map `φ`. -/
def lift : (multilinear_map R s E) ≃ₗ[R] ((⨂[R] i, s i) →ₗ[R] E) :=
{ to_fun := λ φ, { map_smul' := lift_aux.smul, .. lift_aux φ },
inv_fun := λ φ', φ'.comp_multilinear_map (tprod R),
left_inv := λ φ, by { ext, simp [lift_aux_tprod, linear_map.comp_multilinear_map] },
right_inv := λ φ, by { ext, simp [lift_aux_tprod] },
map_add' := λ φ₁ φ₂, by { ext, simp [lift_aux_tprod] },
map_smul' := λ r φ₂, by { ext, simp [lift_aux_tprod] } }
variables {φ : multilinear_map R s E}
@[simp] lemma lift.tprod (f : Π i, s i) : lift φ (tprod R f) = φ f := lift_aux_tprod φ f
theorem lift.unique' {φ' : (⨂[R] i, s i) →ₗ[R] E} (H : φ'.comp_multilinear_map (tprod R) = φ) :
φ' = lift φ :=
ext $ H.symm ▸ (lift.symm_apply_apply φ).symm
theorem lift.unique {φ' : (⨂[R] i, s i) →ₗ[R] E} (H : ∀ f, φ' (tprod R f) = φ f) :
φ' = lift φ :=
lift.unique' (multilinear_map.ext H)
@[simp]
theorem lift_symm (φ' : (⨂[R] i, s i) →ₗ[R] E) : lift.symm φ' = φ'.comp_multilinear_map (tprod R) :=
rfl
@[simp]
theorem lift_tprod : lift (tprod R : multilinear_map R s _) = linear_map.id :=
eq.symm $ lift.unique' rfl
section
variables (R M)
/-- Re-index the components of the tensor power by `e`.
For simplicity, this is defined only for homogeneously- (rather than dependently-) typed components.
-/
def reindex (e : ι ≃ ι₂) : ⨂[R] i : ι, M ≃ₗ[R] ⨂[R] i : ι₂, M :=
linear_equiv.of_linear
(lift (dom_dom_congr e.symm (tprod R : multilinear_map R _ (⨂[R] i : ι₂, M))))
(lift (dom_dom_congr e (tprod R : multilinear_map R _ (⨂[R] i : ι, M))))
(by { ext, simp only [linear_map.comp_apply, linear_map.id_apply, lift_tprod,
linear_map.comp_multilinear_map_apply, lift.tprod,
dom_dom_congr_apply, equiv.apply_symm_apply] })
(by { ext, simp only [linear_map.comp_apply, linear_map.id_apply, lift_tprod,
linear_map.comp_multilinear_map_apply, lift.tprod,
dom_dom_congr_apply, equiv.symm_apply_apply] })
end
@[simp] lemma reindex_tprod (e : ι ≃ ι₂) (f : Π i, M) :
reindex R M e (tprod R f) = tprod R (λ i, f (e.symm i)) :=
lift.tprod f
@[simp] lemma reindex_comp_tprod (e : ι ≃ ι₂) :
(reindex R M e : ⨂[R] i : ι, M →ₗ[R] ⨂[R] i : ι₂, M).comp_multilinear_map (tprod R) =
(tprod R : multilinear_map R (λ i, M) _).dom_dom_congr e.symm :=
multilinear_map.ext $ reindex_tprod e
@[simp] lemma lift_comp_reindex (e : ι ≃ ι₂) (φ : multilinear_map R (λ _ : ι₂, M) E) :
(lift φ) ∘ₗ ↑(reindex R M e) = lift (φ.dom_dom_congr e.symm) :=
by { ext, simp, }
@[simp]
lemma lift_reindex (e : ι ≃ ι₂) (φ : multilinear_map R (λ _, M) E) (x : ⨂[R] i, M) :
lift φ (reindex R M e x) = lift (φ.dom_dom_congr e.symm) x :=
linear_map.congr_fun (lift_comp_reindex e φ) x
@[simp] lemma reindex_trans (e : ι ≃ ι₂) (e' : ι₂ ≃ ι₃) :
(reindex R M e).trans (reindex R M e') = reindex R M (e.trans e') :=
begin
apply linear_equiv.to_linear_map_injective,
ext f,
simp only [linear_equiv.trans_apply, linear_equiv.coe_coe, reindex_tprod,
linear_map.coe_comp_multilinear_map, function.comp_app, multilinear_map.dom_dom_congr_apply,
reindex_comp_tprod],
congr,
end
@[simp] lemma reindex_reindex (e : ι ≃ ι₂) (e' : ι₂ ≃ ι₃) (x : ⨂[R] i, M) :
reindex R M e' (reindex R M e x) = reindex R M (e.trans e') x :=
linear_equiv.congr_fun (reindex_trans e e' : _ = reindex R M (e.trans e')) x
@[simp] lemma reindex_symm (e : ι ≃ ι₂) :
(reindex R M e).symm = reindex R M e.symm := rfl
@[simp] lemma reindex_refl : reindex R M (equiv.refl ι) = linear_equiv.refl R _ :=
begin
apply linear_equiv.to_linear_map_injective,
ext1,
rw [reindex_comp_tprod, linear_equiv.refl_to_linear_map, equiv.refl_symm],
refl,
end
variables (ι)
/-- The tensor product over an empty index type `ι` is isomorphic to the base ring. -/
@[simps symm_apply]
def is_empty_equiv [is_empty ι] : ⨂[R] i : ι, M ≃ₗ[R] R :=
{ to_fun := lift (const_of_is_empty R 1),
inv_fun := λ r, r • tprod R (@is_empty_elim _ _ _),
left_inv := λ x, by
{ apply x.induction_on,
{ intros r f,
have := subsingleton.elim f is_empty_elim,
simp [this], },
{ simp only,
intros x y hx hy,
simp [add_smul, hx, hy] }},
right_inv := λ t, by simp only [mul_one, algebra.id.smul_eq_mul, const_of_is_empty_apply,
linear_map.map_smul, pi_tensor_product.lift.tprod],
map_add' := linear_map.map_add _,
map_smul' := linear_map.map_smul _, }
@[simp]
lemma is_empty_equiv_apply_tprod [is_empty ι] (f : ι → M) : is_empty_equiv ι (tprod R f) = 1 :=
lift.tprod _
variables {ι}
/-- The tensor product over an single index is isomorphic to the module -/
@[simps symm_apply]
def subsingleton_equiv [subsingleton ι] (i₀ : ι) : ⨂[R] i : ι, M ≃ₗ[R] M :=
{ to_fun := lift (multilinear_map.of_subsingleton R M i₀),
inv_fun := λ m, tprod R (λ v, m),
left_inv := λ x, by
{ dsimp only,
have : ∀ (f : ι → M) (z : M), (λ i : ι, z) = update f i₀ z,
{ intros f z,
ext i,
rw [subsingleton.elim i i₀, function.update_same] },
apply x.induction_on,
{ intros r f,
simp only [linear_map.map_smul, lift.tprod, of_subsingleton_apply, function.eval,
this f, map_smul, update_eq_self], },
{ intros x y hx hy,
simp only [multilinear_map.map_add, this 0 (_ + _), linear_map.map_add, ←this 0 (lift _ _),
hx, hy] } },
right_inv := λ t, by simp only [of_subsingleton_apply, lift.tprod, function.eval_apply],
map_add' := linear_map.map_add _,
map_smul' := linear_map.map_smul _, }
@[simp]
lemma subsingleton_equiv_apply_tprod [subsingleton ι] (i : ι) (f : ι → M) :
subsingleton_equiv i (tprod R f) = f i :=
lift.tprod _
section tmul
/-- Collapse a `tensor_product` of `pi_tensor_product`s. -/
private def tmul : (⨂[R] i : ι, M) ⊗[R] (⨂[R] i : ι₂, M) →ₗ[R] ⨂[R] i : ι ⊕ ι₂, M :=
tensor_product.lift
{ to_fun := λ a, pi_tensor_product.lift $ pi_tensor_product.lift
(multilinear_map.curry_sum_equiv R _ _ M _ (tprod R)) a,
map_add' := λ a b, by simp only [linear_equiv.map_add, linear_map.map_add],
map_smul' := λ r a, by simp only [linear_equiv.map_smul, linear_map.map_smul,
ring_hom.id_apply], }
private lemma tmul_apply (a : ι → M) (b : ι₂ → M) :
tmul ((⨂ₜ[R] i, a i) ⊗ₜ[R] (⨂ₜ[R] i, b i)) = ⨂ₜ[R] i, sum.elim a b i :=
begin
erw [tensor_product.lift.tmul, pi_tensor_product.lift.tprod, pi_tensor_product.lift.tprod],
refl
end
/-- Expand `pi_tensor_product` into a `tensor_product` of two factors. -/
private def tmul_symm : ⨂[R] i : ι ⊕ ι₂, M →ₗ[R] (⨂[R] i : ι, M) ⊗[R] (⨂[R] i : ι₂, M) :=
-- by using tactic mode, we avoid the need for a lot of `@`s and `_`s
pi_tensor_product.lift $ by apply multilinear_map.dom_coprod; [exact tprod R, exact tprod R]
private lemma tmul_symm_apply (a : ι ⊕ ι₂ → M) :
tmul_symm (⨂ₜ[R] i, a i) = (⨂ₜ[R] i, a (sum.inl i)) ⊗ₜ[R] (⨂ₜ[R] i, a (sum.inr i)) :=
pi_tensor_product.lift.tprod _
variables (R M)
local attribute [ext] tensor_product.ext
/-- Equivalence between a `tensor_product` of `pi_tensor_product`s and a single
`pi_tensor_product` indexed by a `sum` type.
For simplicity, this is defined only for homogeneously- (rather than dependently-) typed components.
-/
def tmul_equiv : (⨂[R] i : ι, M) ⊗[R] (⨂[R] i : ι₂, M) ≃ₗ[R] ⨂[R] i : ι ⊕ ι₂, M :=
linear_equiv.of_linear tmul tmul_symm
(by { ext x,
show tmul (tmul_symm (tprod R x)) = tprod R x, -- Speed up the call to `simp`.
simp only [tmul_symm_apply, tmul_apply, sum.elim_comp_inl_inr], })
(by { ext x y,
show tmul_symm (tmul (tprod R x ⊗ₜ[R] tprod R y)) = tprod R x ⊗ₜ[R] tprod R y,
simp only [tmul_apply, tmul_symm_apply, sum.elim_inl, sum.elim_inr], })
@[simp] lemma tmul_equiv_apply (a : ι → M) (b : ι₂ → M) :
tmul_equiv R M ((⨂ₜ[R] i, a i) ⊗ₜ[R] (⨂ₜ[R] i, b i)) = ⨂ₜ[R] i, sum.elim a b i :=
tmul_apply a b
@[simp] lemma tmul_equiv_symm_apply (a : ι ⊕ ι₂ → M) :
(tmul_equiv R M).symm (⨂ₜ[R] i, a i) = (⨂ₜ[R] i, a (sum.inl i)) ⊗ₜ[R] (⨂ₜ[R] i, a (sum.inr i)) :=
tmul_symm_apply a
end tmul
end multilinear
end pi_tensor_product
end semiring
section ring
namespace pi_tensor_product
open pi_tensor_product
open_locale tensor_product
variables {ι : Type*} [decidable_eq ι] {R : Type*} [comm_ring R]
variables {s : ι → Type*} [∀ i, add_comm_group (s i)] [∀ i, module R (s i)]
/- Unlike for the binary tensor product, we require `R` to be a `comm_ring` here, otherwise
this is false in the case where `ι` is empty. -/
instance : add_comm_group (⨂[R] i, s i) := module.add_comm_monoid_to_add_comm_group R
end pi_tensor_product
end ring
|
b27f8f20c23864e1716b150f283978175751bc91 | a0e23cfdd129a671bf3154ee1a8a3a72bf4c7940 | /tests/lean/run/newfrontend1.lean | e0c1a6e7f26377b42d2d5d69288f1683960adbc2 | [
"Apache-2.0"
] | permissive | WojciechKarpiel/lean4 | 7f89706b8e3c1f942b83a2c91a3a00b05da0e65b | f6e1314fa08293dea66a329e05b6c196a0189163 | refs/heads/master | 1,686,633,402,214 | 1,625,821,189,000 | 1,625,821,258,000 | 384,640,886 | 0 | 0 | Apache-2.0 | 1,625,903,617,000 | 1,625,903,026,000 | null | UTF-8 | Lean | false | false | 8,783 | lean | def x := 1
#check x
variable {α : Type}
def f (a : α) : α :=
a
def tst (xs : List Nat) : Nat :=
xs.foldl (init := 10) (· + ·)
#check tst [1, 2, 3]
#check fun x y : Nat => x + y
#check tst
#check (fun stx => if True then let e := stx; Pure.pure e else Pure.pure stx : Nat → Id Nat)
#check let x : Nat := 1; x
def foo (a : Nat) (b : Nat := 10) (c : Bool := Bool.true) : Nat :=
a + b
set_option pp.all true
#check foo 1
#check foo 3 (c := false)
def Nat.boo (a : Nat) :=
succ a -- succ here is resolved as `Nat.succ`.
#check Nat.boo
#check true
-- apply is still a valid identifier name
def apply := "hello"
#check apply
theorem simple1 (x y : Nat) (h : x = y) : x = y :=
by {
assumption
}
theorem simple2 (x y : Nat) : x = y → x = y :=
by {
intro h;
assumption
}
syntax "intro2" : tactic
macro_rules
| `(tactic| intro2) => `(tactic| intro; intro )
theorem simple3 (x y : Nat) : x = x → x = y → x = y :=
by {
intro2;
assumption
}
macro "intro3" : tactic => `(intro; intro; intro)
macro "check2" x:term : command => `(#check $x #check $x)
macro "foo" x:term "," y:term : term => `($x + $y + $x)
set_option pp.all false
check2 0+1
check2 foo 0,1
theorem simple4 (x y : Nat) : y = y → x = x → x = y → x = y :=
by {
intro3;
assumption
}
theorem simple5 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intro h1; intro _; intro h3;
exact Eq.trans h3 h1
}
theorem simple6 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intro h1; intro _; intro h3;
refine Eq.trans ?_ h1;
assumption
}
theorem simple7 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intro h1; intro _; intro h3;
refine' Eq.trans ?pre ?post;
exact y;
{ exact h3 }
{ exact h1 }
}
theorem simple8 (x y z : Nat) : y = z → x = x → x = y → x = z := by
intro h1; intro _; intro h3
refine' Eq.trans ?pre ?post
case post => exact h1
case pre => exact h3
theorem simple9 (x y z : Nat) : y = z → x = x → x = y → x = z := by
intros h1 _ h3
traceState
focus
refine' Eq.trans ?pre ?post
first
| exact h1
assumption
| exact y
exact h3
assumption
theorem simple9b (x y z : Nat) : y = z → x = x → x = y → x = z := by
intros h1 _ h3
traceState
focus
refine' Eq.trans ?pre ?post
first
| exact h1
| exact y; exact h3
assumption
theorem simple9c (x y z : Nat) : y = z → x = x → x = y → x = z := by
intros h1 _ h3
solve
| exact h1
| refine' Eq.trans ?pre ?post; exact y; exact h3; assumption
| exact h3
theorem simple9d (x y z : Nat) : y = z → x = x → x = y → x = z := by
intros h1 _ h3
refine' Eq.trans ?pre ?post
solve
| exact h1
| exact y
| exact h3
solve
| exact h1
| exact h3
solve
| exact h1
| assumption
namespace Foo
def Prod.mk := 1
#check (⟨2, 3⟩ : Prod _ _)
end Foo
theorem simple10 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intro h1; intro h2; intro h3;
skip;
apply Eq.trans;
exact h3;
assumption
}
theorem simple11 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intro h1; intro h2; intro h3;
apply @Eq.trans;
traceState;
exact h3;
assumption
}
theorem simple12 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intro h1; intro h2; intro h3;
apply @Eq.trans;
try exact h1; -- `exact h1` fails
traceState;
try exact h3;
traceState;
try exact h1;
}
theorem simple13 (x y z : Nat) : y = z → x = x → x = y → x = z := by
intros h1 h2 h3
traceState
apply @Eq.trans
case b => exact y
traceState
repeat assumption
theorem simple13b (x y z : Nat) : y = z → x = x → x = y → x = z := by {
intros h1 h2 h3;
traceState;
apply @Eq.trans;
case b => exact y;
traceState;
repeat assumption
}
theorem simple14 (x y z : Nat) : y = z → x = x → x = y → x = z := by
intros
apply @Eq.trans
case b => exact y
repeat assumption
theorem simple15 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intros h1 h2 h3;
revert y;
intros y h1 h3;
apply Eq.trans;
exact h3;
exact h1
}
theorem simple16 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intros h1 h2 h3;
try clear x; -- should fail
clear h2;
traceState;
apply Eq.trans;
exact h3;
exact h1
}
macro "blabla" : tactic => `(assumption)
-- Tactic head symbols do not become reserved words
def blabla := 100
#check blabla
theorem simple17 (x : Nat) (h : x = 0) : x = 0 :=
by blabla
theorem simple18 (x : Nat) (h : x = 0) : x = 0 :=
by blabla
theorem simple19 (x y : Nat) (h₁ : x = 0) (h₂ : x = y) : y = 0 :=
by subst x; subst y; exact rfl
theorem tstprec1 (x y z : Nat) : x + y * z = x + (y * z) :=
rfl
theorem tstprec2 (x y z : Nat) : y * z + x = (y * z) + x :=
rfl
set_option pp.all true
#check fun {α} (a : α) => a
#check @(fun α (a : α) => a)
#check
let myid := fun {α} (a : α) => a;
myid [myid 1]
-- In the following example, we need `@` otherwise we will try to insert mvars for α and [Add α],
-- and will fail to generate instance for [Add α]
#check @(fun α (s : Add α) (a : α) => a + a)
def g1 {α} (a₁ a₂ : α) {β} (b : β) : α × α × β :=
(a₁, a₂, b)
def id1 : {α : Type} → α → α :=
fun x => x
def listId : List ({α : Type} → α → α) :=
(fun x => x) :: []
def id2 : {α : Type} → α → α :=
@(fun α (x : α) => id1 x)
def id3 : {α : Type} → α → α :=
@(fun α x => id1 x)
def id4 : {α : Type} → α → α :=
fun x => id1 x
def id5 : {α : Type} → α → α :=
fun {α} x => id1 x
def id6 : {α : Type} → α → α :=
@(fun {α} x => id1 x)
def id7 : {α : Type} → α → α :=
fun {α} x => @id α x
def id8 : {α : Type} → α → α :=
fun {α} x => id (@id α x)
def altTst1 {m σ} [Alternative m] [Monad m] : Alternative (StateT σ m) :=
⟨StateT.failure, StateT.orElse⟩
def altTst2 {m σ} [Alternative m] [Monad m] : Alternative (StateT σ m) :=
⟨@(fun α => StateT.failure), @(fun α => StateT.orElse)⟩
def altTst3 {m σ} [Alternative m] [Monad m] : Alternative (StateT σ m) :=
⟨fun {α} => StateT.failure, fun {α} => StateT.orElse⟩
#check_failure 1 + true
/-
universe u v
/-
MonadFunctorT.{u ?M_1 v} (λ (β : Type u), m α) (λ (β : Type u), m' α) n n'
-/
set_option pp.raw.maxDepth 100
set_option trace.Elab true
def adapt {m m' σ σ'} {n n' : Type → Type} [MonadFunctor m m' n n'] [MonadStateAdapter σ σ' m m'] : MonadStateAdapter σ σ' n n' :=
⟨fun split join => monadMap (adaptState split join : m α → m' α)⟩
-/
syntax "fn" (term:max)+ "=>" term : term
macro_rules
| `(fn $xs* => $b) => `(fun $xs* => $b)
set_option pp.all false
#check fn x => x+1
#check fn α (a : α) => a
def tst1 : {α : Type} → α → α :=
@(fn α a => a)
#check @tst1
syntax ident "==>" term : term
syntax "{" ident "}" "==>" term : term
macro_rules
| `($x:ident ==> $b) => `(fn $x => $b)
| `({$x:ident} ==> $b) => `(fun {$x:ident} => $b)
#check x ==> x+1
def tst2a : {α : Type} → α → α :=
@(α ==> a ==> a)
def tst2b : {α : Type} → α → α :=
{α} ==> a ==> a
#check @tst2a
#check @tst2b
def tst3a : {α : Type} → {β : Type} → α → β → α × β :=
@(α ==> @(β ==> a ==> b ==> (a, b)))
def tst3b : {α : Type} → {β : Type} → α → β → α × β :=
{α} ==> {β} ==> a ==> b ==> (a, b)
syntax "function" (term:max)+ "=>" term : term
macro_rules
| `(function $xs* => $b) => `(@(fun $xs* => $b))
def tst4 : {α : Type} → {β : Type} → α → β → α × β :=
function α β a b => (a, b)
theorem simple20 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by intros h1 h2 h3;
try clear x; -- should fail
clear h2;
traceState;
apply Eq.trans;
exact h3;
exact h1
theorem simple21 (x y z : Nat) : y = z → x = x → y = x → x = z :=
fun h1 _ h3 =>
have : x = y := by { apply Eq.symm; assumption };
Eq.trans this (by assumption)
theorem simple22 (x y z : Nat) : y = z → y = x → id (x = z + 0) :=
fun h1 h2 => show x = z + 0 by
apply Eq.trans
exact h2.symm
assumption
skip
theorem simple23 (x y z : Nat) : y = z → x = x → y = x → x = z :=
fun h1 _ h3 =>
have : x = y := by apply Eq.symm; assumption
Eq.trans this (by assumption)
theorem simple24 (x y z : Nat) : y = z → x = x → y = x → x = z :=
fun h1 _ h3 =>
have h : x = y := by apply Eq.symm; assumption
Eq.trans h (by assumption)
def f1 (x : Nat) : Nat :=
let double x := x + x
let rec loop x :=
match x with
| 0 => 0
| x+1 => loop x + double x
loop x
#eval f1 5
def f2 (x : Nat) : String :=
let bad x : String := toString x
bad x
def f3 x y :=
x + y + 1
theorem f3eq x y : f3 x y = x + y + 1 :=
rfl
def f4 (x y : Nat) : String :=
if x > y + 1 then "hello" else "world"
|
f749a4c8b28f90ac01f622256545144d563ebb8a | b87641ffb6358d6508ccbfa54e67c87070cb28d8 | /ap_cat/src/why.lean | c2a24c57eab32de09e655beb2f40d4cd0809a184 | [] | no_license | Nolrai/LeanGiggle | a4b628745ae3f5a36ae79b673ee8543e18ed4899 | 8326b2a6685b60a3529ee0fe26bd86f5d849b071 | refs/heads/master | 1,545,396,766,168 | 1,538,238,458,000 | 1,538,238,458,000 | 105,524,473 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,020 | lean | universes u v
inductive why (P : Prop) (L : Type u) (R : Type v)
| inL {} : P -> L -> why
| inR {} : ¬ P -> R -> why
inductive option_why (P : Prop) (T : Type v)
| none {} : P -> option_why
| some {} : ¬ P -> T -> option_why
section
parameters {P : Prop}
parameters {R : Type u}
def option_why.to_why: option_why P R -> why P unit R
| (option_why.none p) := why.inL p ()
| (option_why.some p r) := why.inR p r
def option_why.to_why_coe
: has_coe (option_why P R) (why P unit R) :=
⟨option_why.to_why⟩
open option_why
def option_why.map
{P : Prop}
{A : Type u} {B : Type v}
(f : A -> B)
: option_why P A -> option_why P B
| (none p) := option_why.none p
| (some p a) := some p (f a)
instance option_why.functor {P} : functor (option_why P) :=
{map := @option_why.map P}
def riddle : Π (l : list bool) (pulls : nat) (poison : nat), list bool
| l 0 poison := [poison >= 2]
| l (nat.succ n) poison := do x <- l, riddle (list.erase l x) n (poison + if x then 1 else 0)
end
|
31946f5be10234246128d6194954484ada3668f0 | 1a61aba1b67cddccce19532a9596efe44be4285f | /hott/init/trunc.hlean | 0662499c14c49a3cf670bb51be7749b2cd25c3e6 | [
"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 | 11,691 | hlean | /-
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Floris van Doorn
Definition of is_trunc (n-truncatedness)
Ported from Coq HoTT.
-/
--TODO: can we replace some definitions with a hprop as codomain by theorems?
prelude
import .logic .equiv .types .pathover
open eq nat sigma unit
namespace is_trunc
/- Truncation levels -/
inductive trunc_index : Type₀ :=
| minus_two : trunc_index
| succ : trunc_index → trunc_index
/-
notation for trunc_index is -2, -1, 0, 1, ...
from 0 and up this comes from a coercion from num to trunc_index (via nat)
-/
postfix `.+1`:(max+1) := trunc_index.succ
postfix `.+2`:(max+1) := λn, (n .+1 .+1)
notation `-2` := trunc_index.minus_two
notation `-1` := -2.+1 -- ISSUE: -1 gets printed as -2.+1
export [coercions] nat
namespace trunc_index
definition add (n m : trunc_index) : trunc_index :=
trunc_index.rec_on m n (λ k l, l .+1)
definition leq (n m : trunc_index) : Type₀ :=
trunc_index.rec_on n (λm, unit) (λ n p m, trunc_index.rec_on m (λ p, empty) (λ m q p, p m) p) m
infix <= := trunc_index.leq
infix ≤ := trunc_index.leq
end trunc_index
infix `+2+`:65 := trunc_index.add
namespace trunc_index
definition succ_le_succ {n m : trunc_index} (H : n ≤ m) : n.+1 ≤ m.+1 := H
definition le_of_succ_le_succ {n m : trunc_index} (H : n.+1 ≤ m.+1) : n ≤ m := H
definition minus_two_le (n : trunc_index) : -2 ≤ n := star
definition empty_of_succ_le_minus_two {n : trunc_index} (H : n .+1 ≤ -2) : empty := H
end trunc_index
definition trunc_index.of_nat [coercion] [reducible] (n : nat) : trunc_index :=
(nat.rec_on n -2 (λ n k, k.+1)).+2
definition sub_two [reducible] (n : nat) : trunc_index :=
nat.rec_on n -2 (λ n k, k.+1)
postfix `.-2`:(max+1) := sub_two
/- truncated types -/
/-
Just as in Coq HoTT we define an internal version of contractibility and is_trunc, but we only
use `is_trunc` and `is_contr`
-/
structure contr_internal (A : Type) :=
(center : A)
(center_eq : Π(a : A), center = a)
definition is_trunc_internal (n : trunc_index) : Type → Type :=
trunc_index.rec_on n
(λA, contr_internal A)
(λn trunc_n A, (Π(x y : A), trunc_n (x = y)))
end is_trunc open is_trunc
structure is_trunc [class] (n : trunc_index) (A : Type) :=
(to_internal : is_trunc_internal n A)
open nat num is_trunc.trunc_index
namespace is_trunc
abbreviation is_contr := is_trunc -2
abbreviation is_hprop := is_trunc -1
abbreviation is_hset := is_trunc 0
variables {A B : Type}
definition is_trunc_succ_intro (A : Type) (n : trunc_index) [H : ∀x y : A, is_trunc n (x = y)]
: is_trunc n.+1 A :=
is_trunc.mk (λ x y, !is_trunc.to_internal)
definition is_trunc_eq [instance] [priority 1200]
(n : trunc_index) [H : is_trunc (n.+1) A] (x y : A) : is_trunc n (x = y) :=
is_trunc.mk (is_trunc.to_internal (n.+1) A x y)
/- contractibility -/
definition is_contr.mk (center : A) (center_eq : Π(a : A), center = a) : is_contr A :=
is_trunc.mk (contr_internal.mk center center_eq)
definition center (A : Type) [H : is_contr A] : A :=
contr_internal.center (is_trunc.to_internal -2 A)
definition center_eq [H : is_contr A] (a : A) : !center = a :=
contr_internal.center_eq (is_trunc.to_internal -2 A) a
definition eq_of_is_contr [H : is_contr A] (x y : A) : x = y :=
(center_eq x)⁻¹ ⬝ (center_eq y)
definition hprop_eq_of_is_contr {A : Type} [H : is_contr A] {x y : A} (p q : x = y) : p = q :=
have K : ∀ (r : x = y), eq_of_is_contr x y = r, from (λ r, eq.rec_on r !con.left_inv),
(K p)⁻¹ ⬝ K q
theorem is_contr_eq {A : Type} [H : is_contr A] (x y : A) : is_contr (x = y) :=
is_contr.mk !eq_of_is_contr (λ p, !hprop_eq_of_is_contr)
local attribute is_contr_eq [instance]
/- truncation is upward close -/
-- n-types are also (n+1)-types
theorem is_trunc_succ [instance] [priority 900] (A : Type) (n : trunc_index)
[H : is_trunc n A] : is_trunc (n.+1) A :=
trunc_index.rec_on n
(λ A (H : is_contr A), !is_trunc_succ_intro)
(λ n IH A (H : is_trunc (n.+1) A), @is_trunc_succ_intro _ _ (λ x y, IH _ _))
A H
--in the proof the type of H is given explicitly to make it available for class inference
theorem is_trunc_of_leq.{l} (A : Type.{l}) {n m : trunc_index} (Hnm : n ≤ m)
[Hn : is_trunc n A] : is_trunc m A :=
have base : ∀k A, k ≤ -2 → is_trunc k A → (is_trunc -2 A), from
λ k A, trunc_index.cases_on k
(λh1 h2, h2)
(λk h1 h2, empty.elim (trunc_index.empty_of_succ_le_minus_two h1)),
have step : Π (m : trunc_index)
(IHm : Π (n : trunc_index) (A : Type), n ≤ m → is_trunc n A → is_trunc m A)
(n : trunc_index) (A : Type)
(Hnm : n ≤ m .+1) (Hn : is_trunc n A), is_trunc m .+1 A, from
λm IHm n, trunc_index.rec_on n
(λA Hnm Hn, @is_trunc_succ A m (IHm -2 A star Hn))
(λn IHn A Hnm (Hn : is_trunc n.+1 A),
@is_trunc_succ_intro A m (λx y, IHm n (x = y) (trunc_index.le_of_succ_le_succ Hnm) _)),
trunc_index.rec_on m base step n A Hnm Hn
definition is_trunc_of_imp_is_trunc {n : trunc_index} (H : A → is_trunc (n.+1) A)
: is_trunc (n.+1) A :=
@is_trunc_succ_intro _ _ (λx y, @is_trunc_eq _ _ (H x) x y)
definition is_trunc_of_imp_is_trunc_of_leq {n : trunc_index} (Hn : -1 ≤ n) (H : A → is_trunc n A)
: is_trunc n A :=
trunc_index.rec_on n (λHn H, empty.rec _ Hn)
(λn IH Hn, is_trunc_of_imp_is_trunc)
Hn H
-- the following cannot be instances in their current form, because they are looping
theorem is_trunc_of_is_contr (A : Type) (n : trunc_index) [H : is_contr A] : is_trunc n A :=
trunc_index.rec_on n H _
theorem is_trunc_succ_of_is_hprop (A : Type) (n : trunc_index) [H : is_hprop A]
: is_trunc (n.+1) A :=
is_trunc_of_leq A (show -1 ≤ n.+1, from star)
theorem is_trunc_succ_succ_of_is_hset (A : Type) (n : trunc_index) [H : is_hset A]
: is_trunc (n.+2) A :=
is_trunc_of_leq A (show 0 ≤ n.+2, from star)
/- hprops -/
definition is_hprop.elim [H : is_hprop A] (x y : A) : x = y :=
!center
definition is_contr_of_inhabited_hprop {A : Type} [H : is_hprop A] (x : A) : is_contr A :=
is_contr.mk x (λy, !is_hprop.elim)
theorem is_hprop_of_imp_is_contr {A : Type} (H : A → is_contr A) : is_hprop A :=
@is_trunc_succ_intro A -2
(λx y,
have H2 [visible] : is_contr A, from H x,
!is_contr_eq)
theorem is_hprop.mk {A : Type} (H : ∀x y : A, x = y) : is_hprop A :=
is_hprop_of_imp_is_contr (λ x, is_contr.mk x (H x))
theorem is_hprop_elim_self {A : Type} {H : is_hprop A} (x : A) : is_hprop.elim x x = idp :=
!is_hprop.elim
/- hsets -/
theorem is_hset.mk (A : Type) (H : ∀(x y : A) (p q : x = y), p = q) : is_hset A :=
@is_trunc_succ_intro _ _ (λ x y, is_hprop.mk (H x y))
definition is_hset.elim [H : is_hset A] ⦃x y : A⦄ (p q : x = y) : p = q :=
!is_hprop.elim
/- instances -/
definition is_contr_sigma_eq [instance] [priority 800] {A : Type} (a : A)
: is_contr (Σ(x : A), a = x) :=
is_contr.mk (sigma.mk a idp) (λp, sigma.rec_on p (λ b q, eq.rec_on q idp))
definition is_contr_unit : is_contr unit :=
is_contr.mk star (λp, unit.rec_on p idp)
definition is_hprop_empty : is_hprop empty :=
is_hprop.mk (λx, !empty.elim x)
local attribute is_contr_unit is_hprop_empty [instance]
definition is_trunc_unit [instance] (n : trunc_index) : is_trunc n unit :=
!is_trunc_of_is_contr
definition is_trunc_empty [instance] (n : trunc_index) : is_trunc (n.+1) empty :=
!is_trunc_succ_of_is_hprop
/- truncated universe -/
-- TODO: move to root namespace?
structure trunctype (n : trunc_index) :=
(carrier : Type) (struct : is_trunc n carrier)
attribute trunctype.carrier [coercion]
attribute trunctype.struct [instance]
notation n `-Type` := trunctype n
abbreviation hprop := -1-Type
abbreviation hset := 0-Type
protected abbreviation hprop.mk := @trunctype.mk -1
protected abbreviation hset.mk := @trunctype.mk (-1.+1)
protected abbreviation trunctype.mk' [parsing-only] (n : trunc_index) (A : Type)
[H : is_trunc n A] : n-Type :=
trunctype.mk A H
/- interaction with equivalences -/
section
open is_equiv equiv
--should we remove the following two theorems as they are special cases of
--"is_trunc_is_equiv_closed"
definition is_contr_is_equiv_closed (f : A → B) [Hf : is_equiv f] [HA: is_contr A]
: (is_contr B) :=
is_contr.mk (f (center A)) (λp, eq_of_eq_inv !center_eq)
definition is_contr_equiv_closed (H : A ≃ B) [HA: is_contr A] : is_contr B :=
is_contr_is_equiv_closed (to_fun H)
definition equiv_of_is_contr_of_is_contr [HA : is_contr A] [HB : is_contr B] : A ≃ B :=
equiv.mk
(λa, center B)
(is_equiv.adjointify (λa, center B) (λb, center A) center_eq center_eq)
theorem is_trunc_is_equiv_closed (n : trunc_index) (f : A → B) [H : is_equiv f]
[HA : is_trunc n A] : is_trunc n B :=
trunc_index.rec_on n
(λA (HA : is_contr A) B f (H : is_equiv f), is_contr_is_equiv_closed f)
(λn IH A (HA : is_trunc n.+1 A) B f (H : is_equiv f), @is_trunc_succ_intro _ _ (λ x y : B,
IH (f⁻¹ x = f⁻¹ y) _ (x = y) (ap f⁻¹)⁻¹ !is_equiv_inv))
A HA B f H
definition is_trunc_is_equiv_closed_rev (n : trunc_index) (f : A → B) [H : is_equiv f]
[HA : is_trunc n B] : is_trunc n A :=
is_trunc_is_equiv_closed n f⁻¹
definition is_trunc_equiv_closed (n : trunc_index) (f : A ≃ B) [HA : is_trunc n A]
: is_trunc n B :=
is_trunc_is_equiv_closed n (to_fun f)
definition is_trunc_equiv_closed_rev (n : trunc_index) (f : A ≃ B) [HA : is_trunc n B]
: is_trunc n A :=
is_trunc_is_equiv_closed n (to_inv f)
definition is_equiv_of_is_hprop [constructor] [HA : is_hprop A] [HB : is_hprop B]
(f : A → B) (g : B → A) : is_equiv f :=
is_equiv.mk f g (λb, !is_hprop.elim) (λa, !is_hprop.elim) (λa, !is_hset.elim)
definition equiv_of_is_hprop [constructor] [HA : is_hprop A] [HB : is_hprop B]
(f : A → B) (g : B → A) : A ≃ B :=
equiv.mk f (is_equiv_of_is_hprop f g)
definition equiv_of_iff_of_is_hprop [unfold 5] [HA : is_hprop A] [HB : is_hprop B] (H : A ↔ B) : A ≃ B :=
equiv_of_is_hprop (iff.elim_left H) (iff.elim_right H)
end
/- interaction with the Unit type -/
open equiv
-- A contractible type is equivalent to [Unit]. *)
definition equiv_unit_of_is_contr [H : is_contr A] : A ≃ unit :=
equiv.MK (λ (x : A), ⋆)
(λ (u : unit), center A)
(λ (u : unit), unit.rec_on u idp)
(λ (x : A), center_eq x)
/- interaction with pathovers -/
variables {C : A → Type}
{a a₂ : A} (p : a = a₂)
(c : C a) (c₂ : C a₂)
definition is_hprop.elimo [H : is_hprop (C a)] : c =[p] c₂ :=
pathover_of_eq_tr !is_hprop.elim
definition is_trunc_pathover [instance]
(n : trunc_index) [H : is_trunc (n.+1) (C a)] : is_trunc n (c =[p] c₂) :=
is_trunc_equiv_closed_rev n !pathover_equiv_eq_tr
variables {p c c₂}
theorem is_hset.elimo (q q' : c =[p] c₂) [H : is_hset (C a)] : q = q' :=
!is_hprop.elim
-- TODO: port "Truncated morphisms"
end is_trunc
/- truncatedness of lift -/
namespace lift
open is_trunc equiv
definition is_trunc_lift [instance] [priority 1450] (A : Type) (n : trunc_index)
[H : is_trunc n A] : is_trunc n (lift A) :=
is_trunc_equiv_closed _ !equiv_lift
end lift
|
547ed9bd842a479d90de8f1fe3a8045e427a2ff6 | 3268ab3a126f0fef71459fbf170dc38efe5d0506 | /algebra/free_group.hlean | bf6717b18c7cb4355404a8c3e8dd63d62d2eae22 | [
"Apache-2.0"
] | permissive | soraismus/Spectral | f043fed1a4e02ddfeba531769b2980eb817471f4 | 32512bf47db3a1b932856e7ed7c7830b1fc07ef0 | refs/heads/master | 1,585,628,705,579 | 1,538,609,948,000 | 1,538,609,974,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 26,216 | 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
Constructions with groups
-/
import algebra.group_theory hit.set_quotient types.list types.sum ..move_to_lib
open eq algebra is_trunc set_quotient relation sigma sigma.ops prod sum list trunc function equiv
prod.ops decidable is_equiv
universe variable u
namespace group
variables {G G' : Group} {g g' h h' k : G} {A B : AbGroup}
/- Free Group of a set -/
variables (X : Type) [is_set X] {l l' : list (X ⊎ X)}
namespace free_group
inductive free_group_rel : list (X ⊎ X) → list (X ⊎ X) → Type :=
| rrefl : Πl, free_group_rel l l
| cancel1 : Πx, free_group_rel [inl x, inr x] []
| cancel2 : Πx, free_group_rel [inr x, inl x] []
| resp_append : Π{l₁ l₂ l₃ l₄}, free_group_rel l₁ l₂ → free_group_rel l₃ l₄ →
free_group_rel (l₁ ++ l₃) (l₂ ++ l₄)
| rtrans : Π{l₁ l₂ l₃}, free_group_rel l₁ l₂ → free_group_rel l₂ l₃ →
free_group_rel l₁ l₃
open free_group_rel
local abbreviation R [reducible] := free_group_rel
attribute free_group_rel.rrefl [refl]
definition free_group_carrier [reducible] : Type := set_quotient (λx y, ∥R X x y∥)
local abbreviation FG := free_group_carrier
definition is_reflexive_R : is_reflexive (λx y, ∥R X x y∥) :=
begin constructor, intro s, apply tr, unfold R end
local attribute is_reflexive_R [instance]
variable {X}
theorem rel_respect_flip (r : R X l l') : R X (map sum.flip l) (map sum.flip l') :=
begin
induction r with l x x l₁ l₂ l₃ l₄ r₁ r₂ IH₁ IH₂ l₁ l₂ l₃ r₁ r₂ IH₁ IH₂,
{ reflexivity},
{ repeat esimp [map], exact cancel2 x},
{ repeat esimp [map], exact cancel1 x},
{ rewrite [+map_append], exact resp_append IH₁ IH₂},
{ exact rtrans IH₁ IH₂}
end
theorem rel_respect_reverse (r : R X l l') : R X (reverse l) (reverse l') :=
begin
induction r with l x x l₁ l₂ l₃ l₄ r₁ r₂ IH₁ IH₂ l₁ l₂ l₃ r₁ r₂ IH₁ IH₂,
{ reflexivity},
{ repeat esimp [map], exact cancel2 x},
{ repeat esimp [map], exact cancel1 x},
{ rewrite [+reverse_append], exact resp_append IH₂ IH₁},
{ exact rtrans IH₁ IH₂}
end
definition free_group_one [constructor] : FG X := class_of []
definition free_group_inv [unfold 3] : FG X → FG X :=
quotient_unary_map (reverse ∘ map sum.flip)
(λl l', trunc_functor -1 (rel_respect_reverse ∘ rel_respect_flip))
definition free_group_mul [unfold 3 4] : FG X → FG X → FG X :=
quotient_binary_map append (λl l', trunc.elim (λr m m', trunc.elim (λs, tr (resp_append r s))))
section
local notation 1 := free_group_one
local postfix ⁻¹ := free_group_inv
local infix * := free_group_mul
theorem free_group_mul_assoc (g₁ g₂ g₃ : FG X) : g₁ * g₂ * g₃ = g₁ * (g₂ * g₃) :=
begin
refine set_quotient.rec_prop _ g₁,
refine set_quotient.rec_prop _ g₂,
refine set_quotient.rec_prop _ g₃,
clear g₁ g₂ g₃, intro g₁ g₂ g₃,
exact ap class_of !append.assoc
end
theorem free_group_one_mul (g : FG X) : 1 * g = g :=
begin
refine set_quotient.rec_prop _ g, clear g, intro g,
exact ap class_of !append_nil_left
end
theorem free_group_mul_one (g : FG X) : g * 1 = g :=
begin
refine set_quotient.rec_prop _ g, clear g, intro g,
exact ap class_of !append_nil_right
end
theorem free_group_mul_left_inv (g : FG X) : g⁻¹ * g = 1 :=
begin
refine set_quotient.rec_prop _ g, clear g, intro g,
apply eq_of_rel, apply tr,
induction g with s l IH,
{ reflexivity},
{ rewrite [▸*, map_cons, reverse_cons, concat_append],
refine rtrans _ IH,
apply resp_append, reflexivity,
change R X ([flip s, s] ++ l) ([] ++ l),
apply resp_append,
induction s, apply cancel2, apply cancel1,
reflexivity}
end
end
end free_group open free_group
-- export [reduce_hints] free_group
variables (X)
definition group_free_group [constructor] : group (free_group_carrier X) :=
group.mk _ free_group_mul free_group_mul_assoc free_group_one free_group_one_mul
free_group_mul_one free_group_inv free_group_mul_left_inv
definition free_group [constructor] : Group :=
Group.mk _ (group_free_group X)
/- The universal property of the free group -/
variables {X G}
definition free_group_inclusion [constructor] (x : X) : free_group X :=
class_of [inl x]
definition fgh_helper [unfold 6] (f : X → G) (g : G) (x : X ⊎ X) : G :=
g * sum.rec (λx, f x) (λx, (f x)⁻¹) x
theorem fgh_helper_respect_rel (f : X → G) (r : free_group_rel X l l')
: Π(g : G), foldl (fgh_helper f) g l = foldl (fgh_helper f) g l' :=
begin
induction r with l x x l₁ l₂ l₃ l₄ r₁ r₂ IH₁ IH₂ l₁ l₂ l₃ r₁ r₂ IH₁ IH₂: intro g,
{ reflexivity},
{ unfold [foldl], apply mul_inv_cancel_right},
{ unfold [foldl], apply inv_mul_cancel_right},
{ rewrite [+foldl_append, IH₁, IH₂]},
{ exact !IH₁ ⬝ !IH₂}
end
theorem fgh_helper_mul (f : X → G) (l)
: Π(g : G), foldl (fgh_helper f) g l = g * foldl (fgh_helper f) 1 l :=
begin
induction l with s l IH: intro g,
{ unfold [foldl], exact !mul_one⁻¹},
{ rewrite [+foldl_cons, IH], refine _ ⬝ (ap (λx, g * x) !IH⁻¹),
rewrite [-mul.assoc, ↑fgh_helper, one_mul]}
end
definition free_group_hom [constructor] (f : X → G) : free_group X →g G :=
begin
fapply homomorphism.mk,
{ intro g, refine set_quotient.elim _ _ g,
{ intro l, exact foldl (fgh_helper f) 1 l},
{ intro l l' r, esimp at *, refine trunc.rec _ r, clear r, intro r,
exact fgh_helper_respect_rel f r 1}},
{ refine set_quotient.rec_prop _, intro l, refine set_quotient.rec_prop _, intro l',
esimp, refine !foldl_append ⬝ _, esimp, apply fgh_helper_mul}
end
definition free_group_hom_eq [constructor] {φ ψ : free_group X →g G}
(H : Πx, φ (free_group_inclusion x) = ψ (free_group_inclusion x)) : φ ~ ψ :=
begin
refine set_quotient.rec_prop _, intro l,
induction l with s l IH,
{ exact respect_one φ ⬝ (respect_one ψ)⁻¹ },
{ refine respect_mul φ (class_of [s]) (class_of l) ⬝ _ ⬝
(respect_mul ψ (class_of [s]) (class_of l))⁻¹,
refine ap011 mul _ IH, induction s with x x, exact H x,
refine respect_inv φ (class_of [inl x]) ⬝ ap inv (H x) ⬝
(respect_inv ψ (class_of [inl x]))⁻¹ }
end
definition fn_of_free_group_hom [unfold_full] (φ : free_group X →g G) : X → G :=
φ ∘ free_group_inclusion
variables (X G)
definition free_group_hom_equiv_fn : (free_group X →g G) ≃ (X → G) :=
begin
fapply equiv.MK,
{ exact fn_of_free_group_hom},
{ exact free_group_hom},
{ intro f, apply eq_of_homotopy, intro x, esimp, unfold [foldl], apply one_mul},
{ intro φ, apply homomorphism_eq, apply free_group_hom_eq, intro x, apply one_mul }
end
end group
/- alternative definition of free group on a set with decidable equality -/
namespace list
variables {X : Type.{u}} {v w : X ⊎ X} {l : list (X ⊎ X)}
inductive is_reduced {X : Type} : list (X ⊎ X) → Type :=
| nil : is_reduced []
| singleton : Πv, is_reduced [v]
| cons : Π⦃v w l⦄, sum.flip v ≠ w → is_reduced (w::l) → is_reduced (v::w::l)
definition is_reduced_code (H : is_reduced l) : Type.{u} :=
begin
cases l with v l, { exact is_reduced.nil = H },
cases l with w l, { exact is_reduced.singleton v = H },
exact Σ(pH : sum.flip v ≠ w × is_reduced (w::l)), is_reduced.cons pH.1 pH.2 = H
end
definition is_reduced_encode (H : is_reduced l) : is_reduced_code H :=
begin
induction H with v v w l p Hl IH,
{ exact idp },
{ exact idp },
{ exact ⟨(p, Hl), idp⟩ }
end
definition is_prop_is_reduced (l : list (X ⊎ X)) : is_prop (is_reduced l) :=
begin
apply is_prop.mk, intro H₁ H₂, induction H₁ with v v w l p Hl IH,
{ exact is_reduced_encode H₂ },
{ exact is_reduced_encode H₂ },
{ cases is_reduced_encode H₂ with pH' q, cases pH' with p' Hl', esimp at q,
subst q, exact ap011 (λx y, is_reduced.cons x y) !is_prop.elim (IH Hl') }
end
definition rlist (X : Type) : Type :=
Σ(l : list (X ⊎ X)), is_reduced l
local attribute [instance] is_prop_is_reduced
definition rlist_eq {l l' : rlist X} (p : l.1 = l'.1) : l = l' :=
subtype_eq p
definition is_trunc_rlist {n : ℕ₋₂} {X : Type} (H : is_trunc (n.+2) X) :
is_trunc (n.+2) (rlist X) :=
begin
apply is_trunc_sigma, { apply is_trunc_list, apply is_trunc_sum },
intro l, exact is_trunc_succ_of_is_prop _ _ _
end
definition is_reduced_invert (v : X ⊎ X) : is_reduced (v::l) → is_reduced l :=
begin
assert H : Π⦃l'⦄, is_reduced l' → l' = v::l → is_reduced l,
{ intro l' Hl', revert l, induction Hl' with v' v' w' l' p' Hl' IH: intro l p,
{ cases p },
{ cases cons_eq_cons p with q r, subst r, apply is_reduced.nil },
{ cases cons_eq_cons p with q r, subst r, exact Hl' }},
intro Hl, exact H Hl idp
end
definition is_reduced_invert_rev (v : X ⊎ X) : is_reduced (l++[v]) → is_reduced l :=
begin
assert H : Π⦃l'⦄, is_reduced l' → l' = l++[v] → is_reduced l,
{ intro l' Hl', revert l, induction Hl' with v' v' w' l' p' Hl' IH: intro l p,
{ induction l: cases p },
{ induction l with v'' l IH, apply is_reduced.nil, esimp [append] at p,
cases cons_eq_cons p with q r, induction l: cases r },
{ induction l with v'' l IH', cases p, induction l with v''' l IH'',
apply is_reduced.singleton, do 2 esimp [append] at p, cases cons_eq_cons p with q r,
cases cons_eq_cons r with r₁ r₂, subst r₁, subst q, subst r₂,
apply is_reduced.cons p' (IH _ idp) }},
intro Hl, exact H Hl idp
end
definition rnil [constructor] : rlist X :=
⟨[], !is_reduced.nil⟩
definition rsingleton [constructor] (x : X ⊎ X) : rlist X :=
⟨[x], !is_reduced.singleton⟩
definition is_reduced_doubleton [constructor] {x y : X ⊎ X} (p : flip x ≠ y) :
is_reduced [x, y] :=
is_reduced.cons p !is_reduced.singleton
definition rdoubleton [constructor] {x y : X ⊎ X} (p : flip x ≠ y) : rlist X :=
⟨[x, y], is_reduced_doubleton p⟩
definition is_reduced_concat (Hn : sum.flip v ≠ w) (Hl : is_reduced (concat v l)) :
is_reduced (concat w (concat v l)) :=
begin
assert H : Π⦃l'⦄, is_reduced l' → l' = concat v l → is_reduced (concat w l'),
{ clear Hl, intro l' Hl', revert l, induction Hl' with v' v' w' l' p' Hl' IH: intro l p,
{ exfalso, exact concat_neq_nil _ _ p⁻¹ },
{ cases concat_eq_singleton p⁻¹ with q r, subst q,
exact is_reduced_doubleton Hn },
{ do 2 esimp [concat], apply is_reduced.cons p', cases l with x l,
{ cases p },
{ apply IH l, esimp [concat] at p, revert p, generalize concat v l, intro l'' p,
cases cons_eq_cons p with q r, exact r }}},
exact H Hl idp
end
definition is_reduced_reverse (H : is_reduced l) : is_reduced (reverse l) :=
begin
induction H with v v w l p Hl IH,
{ apply is_reduced.nil },
{ apply is_reduced.singleton },
{ refine is_reduced_concat _ IH, intro q, apply p, subst q, apply flip_flip }
end
definition rreverse [constructor] (l : rlist X) : rlist X := ⟨reverse l.1, is_reduced_reverse l.2⟩
definition rreverse_rreverse (l : rlist X) : rreverse (rreverse l) = l :=
subtype_eq (reverse_reverse l.1)
definition is_reduced_flip (H : is_reduced l) : is_reduced (map flip l) :=
begin
induction H with v v w l p Hl IH,
{ apply is_reduced.nil },
{ apply is_reduced.singleton },
{ refine is_reduced.cons _ IH, intro q, apply p, exact !flip_flip⁻¹ ⬝ ap flip q ⬝ !flip_flip }
end
definition rflip [constructor] (l : rlist X) : rlist X := ⟨map flip l.1, is_reduced_flip l.2⟩
definition rcons' [decidable_eq X] (v : X ⊎ X) (l : list (X ⊎ X)) : list (X ⊎ X) :=
begin
cases l with w l,
{ exact [v] },
{ exact if q : sum.flip v = w then l else v::w::l }
end
definition is_reduced_rcons [decidable_eq X] (v : X ⊎ X) (Hl : is_reduced l) :
is_reduced (rcons' v l) :=
begin
cases l with w l, apply is_reduced.singleton,
apply dite (sum.flip v = w): intro q,
{ have is_set (X ⊎ X), from !is_trunc_sum,
rewrite [↑rcons', dite_true q _], exact is_reduced_invert w Hl },
{ rewrite [↑rcons', dite_false q], exact is_reduced.cons q Hl, }
end
definition rcons [constructor] [decidable_eq X] (v : X ⊎ X) (l : rlist X) : rlist X :=
⟨rcons' v l.1, is_reduced_rcons v l.2⟩
definition rcons_eq [decidable_eq X] : is_reduced (v::l) → rcons' v l = v :: l :=
begin
assert H : Π⦃l'⦄, is_reduced l' → l' = v::l → rcons' v l = l',
{ intro l' Hl', revert l, induction Hl' with v' v' w' l' p' Hl' IH: intro l p,
{ cases p },
{ cases cons_eq_cons p with q r, subst r, cases p, reflexivity },
{ cases cons_eq_cons p with q r, subst q, subst r, rewrite [↑rcons', dite_false p'], }},
intro Hl, exact H Hl idp
end
definition rcons_eq2 [decidable_eq X] (H : is_reduced (v::l)) :
⟨v :: l, H⟩ = rcons v ⟨l, is_reduced_invert _ H⟩ :=
subtype_eq (rcons_eq H)⁻¹
definition rcons_rcons_eq [decidable_eq X] (p : flip v = w) (l : rlist X) :
rcons v (rcons w l) = l :=
begin
have is_set (X ⊎ X), from !is_trunc_sum,
induction l with l Hl,
apply rlist_eq, esimp,
induction l with u l IH,
{ exact dite_true p _ },
{ apply dite (sum.flip w = u): intro q,
{ rewrite [↑rcons' at {1}, dite_true q _], subst p, induction (!flip_flip⁻¹ ⬝ q),
exact rcons_eq Hl },
{ rewrite [↑rcons', dite_false q, dite_true p _] }}
end
definition rlist.rec [decidable_eq X] {P : rlist X → Type}
(P1 : P rnil) (Pcons : Πv l, P l → P (rcons v l)) (l : rlist X) : P l :=
begin
induction l with l Hl, induction Hl with v v w l p Hl IH,
{ exact P1 },
{ exact Pcons v rnil P1 },
{ exact transport P (subtype_eq (rcons_eq (is_reduced.cons p Hl))) (Pcons v ⟨w :: l, Hl⟩ IH) }
end
definition reduce_list' [decidable_eq X] (l : list (X ⊎ X)) : list (X ⊎ X) :=
begin
induction l with v l IH,
{ exact [] },
{ exact rcons' v IH }
end
definition is_reduced_reduce_list [decidable_eq X] (l : list (X ⊎ X)) :
is_reduced (reduce_list' l) :=
begin
induction l with v l IH, apply is_reduced.nil,
apply is_reduced_rcons, exact IH
end
definition reduce_list [constructor] [decidable_eq X] (l : list (X ⊎ X)) : rlist X :=
⟨reduce_list' l, is_reduced_reduce_list l⟩
definition rappend' [decidable_eq X] (l : list (X ⊎ X)) (l' : rlist X) : rlist X := foldr rcons l' l
definition rappend_rcons' [decidable_eq X] (x : X ⊎ X) (l₁ : list (X ⊎ X)) (l₂ : rlist X) :
rappend' (rcons' x l₁) l₂ = rcons x (rappend' l₁ l₂) :=
begin
induction l₁ with x' l₁ IH,
{ reflexivity },
{ apply dite (sum.flip x = x'): intro p,
{ have is_set (X ⊎ X), from !is_trunc_sum, rewrite [↑rcons', dite_true p _],
exact (rcons_rcons_eq p _)⁻¹ },
{ rewrite [↑rcons', dite_false p] }}
end
definition rappend_cons' [decidable_eq X] (x : X ⊎ X) (l₁ : list (X ⊎ X)) (l₂ : rlist X) :
rappend' (x::l₁) l₂ = rcons x (rappend' l₁ l₂) :=
idp
definition rappend [decidable_eq X] (l l' : rlist X) : rlist X := rappend' l.1 l'
definition rappend_rcons [decidable_eq X] (x : X ⊎ X) (l₁ l₂ : rlist X) :
rappend (rcons x l₁) l₂ = rcons x (rappend l₁ l₂) :=
rappend_rcons' x l₁.1 l₂
definition rappend_assoc [decidable_eq X] (l₁ l₂ l₃ : rlist X) :
rappend (rappend l₁ l₂) l₃ = rappend l₁ (rappend l₂ l₃) :=
begin
induction l₁ with l₁ h, unfold rappend, clear h, induction l₁ with x l₁ IH,
{ reflexivity },
{ rewrite [rappend_cons', ▸*, rappend_rcons', IH] }
end
definition rappend_rnil [decidable_eq X] (l : rlist X) : rappend l rnil = l :=
begin
induction l with l H, apply rlist_eq, esimp, induction H with v v w l p Hl IH,
{ reflexivity },
{ reflexivity },
{ rewrite [↑rappend at *, rappend_cons', ↑rcons, IH, ↑rcons', dite_false p] }
end
definition rnil_rappend [decidable_eq X] (l : rlist X) : rappend rnil l = l :=
by reflexivity
definition rsingleton_rappend [decidable_eq X] (x : X ⊎ X) (l : rlist X) :
rappend (rsingleton x) l = rcons x l :=
by reflexivity
definition rappend_left_inv [decidable_eq X] (l : rlist X) :
rappend (rflip (rreverse l)) l = rnil :=
begin
induction l with l H, apply rlist_eq, induction l with x l IH,
{ reflexivity },
{ have is_set (X ⊎ X), from !is_trunc_sum,
rewrite [↑rappend, ↑rappend', reverse_cons, map_concat, foldr_concat],
refine ap (λx, (rappend' _ x).1) (rlist_eq (dite_true !flip_flip _)) ⬝
IH (is_reduced_invert _ H) }
end
definition rappend'_eq [decidable_eq X] (v : X ⊎ X) (l : list (X ⊎ X)) (H : is_reduced (l ++ [v])) :
⟨l ++ [v], H⟩ = rappend' l (rsingleton v) :=
begin
assert Hlem : Π⦃l'⦄ (Hl' : is_reduced l'), l' = l ++ [v] → rappend' l (rsingleton v) = ⟨l', Hl'⟩,
{ intro l' Hl', clear H, revert l,
induction Hl' with v' v' w' l' p' Hl' IH: intro l p,
{ induction l: cases p },
{ induction l with v'' l IH,
{ cases cons_eq_cons p with q r, subst q },
{ esimp [append] at p, cases cons_eq_cons p with q r, induction l: cases r }},
{ induction l with v'' l IH', cases p,
induction l with v''' l IH'',
{ do 2 esimp [append] at p, cases cons_eq_cons p with q r, subst q,
cases cons_eq_cons r with q r', subst q, subst r', apply subtype_eq, exact dite_false p' },
{ do 2 esimp [append] at p, cases cons_eq_cons p with q r,
cases cons_eq_cons r with r₁ r₂, subst r₁, subst q, subst r₂,
rewrite [rappend_cons', IH (w' :: l) idp],
apply subtype_eq, apply rcons_eq, apply is_reduced.cons p' Hl' }}},
exact (Hlem H idp)⁻¹
end
definition rappend_eq [decidable_eq X] (v : X ⊎ X) (l : list (X ⊎ X)) (H : is_reduced (l ++ [v])) :
⟨l ++ [v], H⟩ = rappend ⟨l, is_reduced_invert_rev _ H⟩ (rsingleton v) :=
rappend'_eq v l H
definition rreverse_cons [decidable_eq X] (v : X ⊎ X) (l : list (X ⊎ X))
(H : is_reduced (v :: l)) : rreverse ⟨v::l, H⟩ =
rappend ⟨reverse l, is_reduced_reverse (is_reduced_invert _ H)⟩ (rsingleton v) :=
begin
refine dpair_eq_dpair (reverse_cons _ _) !pathover_tr ⬝ _,
refine dpair_eq_dpair (concat_eq_append _ _) !pathover_tr ⬝ _,
refine !rappend_eq ⬝ _,
exact ap (λx, rappend ⟨_, x⟩ _) !is_prop.elim
end
definition rreverse_rcons [decidable_eq X] (v : X ⊎ X) (l : rlist X) :
rreverse (rcons v l) = rappend (rreverse l) (rsingleton v) :=
begin
induction l with l Hl, induction l with v' l IH, reflexivity,
{ symmetry, refine ap (λx, rappend x _) !rreverse_cons ⬝ _,
apply dite (sum.flip v = v'): intro p,
{ have is_set (X ⊎ X), from !is_trunc_sum,
rewrite [↑rcons, ↑rcons', dpair_eq_dpair (dite_true p _) !pathover_tr ],
refine !rappend_assoc ⬝ _, refine ap (rappend _) !rsingleton_rappend ⬝ _,
refine ap (rappend _) (subtype_eq _) ⬝ !rappend_rnil,
exact dite_true (ap flip p⁻¹ ⬝ flip_flip v) _ },
{ rewrite [↑rcons, ↑rcons', dpair_eq_dpair (dite_false p) !pathover_tr],
note H1 := is_reduced_reverse (transport is_reduced (dite_false p) (is_reduced_rcons v Hl)),
rewrite [+reverse_cons at H1, +concat_eq_append at H1],
note H2 := is_reduced_invert_rev _ H1,
refine ap (λx, rappend x _) (rappend_eq _ _ H2)⁻¹ ⬝ _,
refine (rappend_eq _ _ H1)⁻¹ ⬝ _, apply subtype_eq,
rewrite [-+concat_eq_append] }}
end
definition rlist.rec_rev [decidable_eq X] {P : rlist X → Type}
(P1 : P rnil) (Pappend : Πl v, P l → P (rappend l (rsingleton v))) : Π(l : rlist X), P l :=
begin
assert H : Π(l : rlist X), P (rreverse l),
{ refine rlist.rec _ _, exact P1, intro v l p,
rewrite [rreverse_rcons], apply Pappend, exact p },
intro l, exact transport P (rreverse_rreverse l) (H (rreverse l))
end
end list open list
namespace group
open sigma.ops
variables (X : Type) [decidable_eq X] {G : InfGroup}
definition group_dfree_group [constructor] : group (rlist X) :=
group.mk (is_trunc_rlist _) rappend rappend_assoc rnil rnil_rappend rappend_rnil
(rflip ∘ rreverse) rappend_left_inv
definition dfree_group [constructor] : Group :=
Group.mk _ (group_dfree_group X)
variable {X}
definition dfree_group_inclusion [constructor] [reducible] (x : X) : dfree_group X :=
rsingleton (inl x)
definition rsingleton_inr [constructor] (x : X) :
rsingleton (inr x) = (dfree_group_inclusion x)⁻¹ :> dfree_group X :=
by reflexivity
local attribute [instance] is_prop_is_reduced
definition dfree_group.rec {P : dfree_group X → Type}
(P1 : P 1) (Pcons : Πv g, P g → P (rsingleton v * g)) : Π(g : dfree_group X), P g :=
rlist.rec P1 Pcons
definition dfree_group.rec_rev {P : dfree_group X → Type}
(P1 : P 1) (Pcons : Πg v, P g → P (g * rsingleton v)) : Π(g : dfree_group X), P g :=
rlist.rec_rev P1 Pcons
-- definition dfree_group.rec2 [constructor] {P : dfree_group X → Type}
-- (P1 : P 1) (Pcons : Πg x, P g → P (dfree_group_inclusion x * g))
-- (Pinv : Πg, P g → P g⁻¹) : Π(g : dfree_group X), P g :=
-- begin
-- refine dfree_group.rec _ _, exact P1,
-- intro g v p, induction v with x x, exact Pcons g x p,
-- end
definition dfgh_helper [unfold 6] (f : X → G) (g : G) (x : X ⊎ X) : G :=
g * sum.rec (λx, f x) (λx, (f x)⁻¹) x
theorem dfgh_helper_mul (f : X → G) (l : list (X ⊎ X))
: Π(g : G), foldl (dfgh_helper f) g l = g * foldl (dfgh_helper f) 1 l :=
begin
induction l with s l IH: intro g,
{ unfold [foldl], exact !mul_one⁻¹},
{ rewrite [+foldl_cons, IH], refine _ ⬝ (ap (λx, g * x) !IH⁻¹),
rewrite [-mul.assoc, ↑dfgh_helper, one_mul] }
end
definition dfgh_helper_rcons (f : X → G) (g : G) (x : X ⊎ X) {l : list (X ⊎ X)} :
foldl (dfgh_helper f) g (rcons' x l) = foldl (dfgh_helper f) g (x :: l) :=
begin
cases l with x' l, reflexivity,
apply dite (sum.flip x = x'): intro q,
{ have is_set (X ⊎ X), from !is_trunc_sum,
rewrite [↑rcons', dite_true q _, foldl_cons, foldl_cons, -q],
induction x with x, rewrite [↑dfgh_helper,mul_inv_cancel_right],
rewrite [↑dfgh_helper,inv_mul_cancel_right] },
{ rewrite [↑rcons', dite_false q] }
end
definition dfgh_helper_rappend (f : X → G) (g : G) (l l' : rlist X) :
foldl (dfgh_helper f) g (rappend l l').1 = foldl (dfgh_helper f) g (l.1 ++ l'.1) :=
begin
revert g, induction l with l lH, unfold rappend, clear lH,
induction l with v l IH: intro g, reflexivity,
rewrite [rappend_cons', ↑rcons, dfgh_helper_rcons, foldl_cons, IH]
end
local attribute [coercion] InfGroup_of_Group
definition dfree_group_inf_hom [constructor] (G : InfGroup) (f : X → G) : dfree_group X →∞g G :=
inf_homomorphism.mk (λx, foldl (dfgh_helper f) 1 x.1)
(λl₁ l₂, !dfgh_helper_rappend ⬝ !foldl_append ⬝ !dfgh_helper_mul)
definition dfree_group_inf_hom_eq [constructor] {G : InfGroup} {φ ψ : dfree_group X →∞g G}
(H : Πx, φ (dfree_group_inclusion x) = ψ (dfree_group_inclusion x)) : φ ~ ψ :=
begin
assert H2 : Πv, φ (rsingleton v) = ψ (rsingleton v),
{ intro v, induction v with x x, exact H x,
exact to_respect_inv_inf φ _ ⬝ ap inv (H x) ⬝ (to_respect_inv_inf ψ _)⁻¹ },
refine dfree_group.rec _ _,
{ exact !to_respect_one_inf ⬝ !to_respect_one_inf⁻¹ },
{ intro v g p, exact !to_respect_mul_inf ⬝ ap011 mul (H2 v) p ⬝ !to_respect_mul_inf⁻¹ }
end
theorem dfree_group_inf_hom_inclusion [constructor] (G : InfGroup) (f : X → G) (x : X) :
dfree_group_inf_hom G f (dfree_group_inclusion x) = f x :=
by rewrite [▸*, foldl_cons, foldl_nil, ↑dfgh_helper, one_mul]
definition dfree_group_hom [constructor] {G : Group} (f : X → G) : dfree_group X →g G :=
homomorphism_of_inf_homomorphism (dfree_group_inf_hom G f)
-- todo: use the inf-version
definition dfree_group_hom_eq [constructor] {G : Group} {φ ψ : dfree_group X →g G}
(H : Πx, φ (dfree_group_inclusion x) = ψ (dfree_group_inclusion x)) : φ ~ ψ :=
begin
assert H2 : Πv, φ (rsingleton v) = ψ (rsingleton v),
{ intro v, induction v with x x, exact H x,
exact to_respect_inv φ _ ⬝ ap inv (H x) ⬝ (to_respect_inv ψ _)⁻¹ },
refine dfree_group.rec _ _,
{ exact !to_respect_one ⬝ !to_respect_one⁻¹ },
{ intro v g p, exact !to_respect_mul ⬝ ap011 mul (H2 v) p ⬝ !to_respect_mul⁻¹ }
end
definition is_mul_hom_dfree_group_fun {G : InfGroup} {f : dfree_group X → G}
(H1 : f 1 = 1) (H2 : Πv g, f (rsingleton v * g) = f (rsingleton v) * f g) : is_mul_hom f :=
begin
refine dfree_group.rec _ _,
{ intro g, exact ap f (one_mul g) ⬝ (ap (λx, x * _) H1 ⬝ one_mul (f g))⁻¹ },
{ intro g v p h,
exact ap f !mul.assoc ⬝ !H2 ⬝ ap (mul _) !p ⬝ (ap (λx, x * _) !H2 ⬝ !mul.assoc)⁻¹ }
end
definition dfree_group_hom_of_fun [constructor] {G : InfGroup} (f : dfree_group X → G)
(H1 : f 1 = 1) (H2 : Πv g, f (rsingleton v * g) = f (rsingleton v) * f g) :
dfree_group X →∞g G :=
inf_homomorphism.mk f (is_mul_hom_dfree_group_fun H1 H2)
variable (X)
definition free_group_of_dfree_group [constructor] : dfree_group X →g free_group X :=
dfree_group_hom free_group_inclusion
definition dfree_group_of_free_group [constructor] : free_group X →g dfree_group X :=
free_group_hom dfree_group_inclusion
definition dfree_group_isomorphism : dfree_group X ≃g free_group X :=
begin
apply isomorphism.MK (free_group_of_dfree_group X) (dfree_group_of_free_group X),
{ apply free_group_hom_eq, intro x, reflexivity },
{ apply dfree_group_hom_eq, intro x, reflexivity }
end
end group
|
5e67bf5f77b4eef4bdebcf0d69d5f6a2e701eca0 | 4efff1f47634ff19e2f786deadd394270a59ecd2 | /src/algebra/homology/homology.lean | a684e4406bcb37989d40029cdcc3c97628d823c3 | [
"Apache-2.0"
] | permissive | agjftucker/mathlib | d634cd0d5256b6325e3c55bb7fb2403548371707 | 87fe50de17b00af533f72a102d0adefe4a2285e8 | refs/heads/master | 1,625,378,131,941 | 1,599,166,526,000 | 1,599,166,526,000 | 160,748,509 | 0 | 0 | Apache-2.0 | 1,544,141,789,000 | 1,544,141,789,000 | null | UTF-8 | Lean | false | false | 6,706 | lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Markus Himmel
-/
import algebra.homology.chain_complex
import algebra.homology.image_to_kernel_map
/-!
# (Co)homology groups for complexes
We setup that part of the theory of homology groups which works in
any category with kernels and images.
We define the homology groups themselves, and show that they induce maps on kernels.
Under the additional assumption that our category has equalizers and functorial images, we construct
induced morphisms on images and functorial induced morphisms in homology.
## Chains and cochains
Throughout we work with complexes graded by an arbitrary `[add_comm_group β]`,
with a differential with grading `b : β`.
Thus we're simultaneously doing homology and cohomology groups
(and in future, e.g., enabling computing homologies for successive pages of spectral sequences).
At the end of the file we set up abbreviations `cohomology` and `graded_cohomology`,
so that when you're working with a `C : cochain_complex V`, you can write `C.cohomology i`
rather than the confusing `C.homology i`.
-/
universes v u
open category_theory
open category_theory.limits
variables {V : Type u} [category.{v} V] [has_zero_morphisms V]
variables {β : Type} [add_comm_group β] {b : β}
namespace homological_complex
section has_kernels
variable [has_kernels V]
/-- The map induced by a chain map between the kernels of the differentials. -/
def kernel_map {C C' : homological_complex V b} (f : C ⟶ C') (i : β) :
kernel (C.d i) ⟶ kernel (C'.d i) :=
kernel.lift _ (kernel.ι _ ≫ f.f i)
begin
rw [category.assoc, ←comm_at f, ←category.assoc, kernel.condition, has_zero_morphisms.zero_comp],
end
@[simp, reassoc]
lemma kernel_map_condition {C C' : homological_complex V b} (f : C ⟶ C') (i : β) :
kernel_map f i ≫ kernel.ι (C'.d i) = kernel.ι (C.d i) ≫ f.f i :=
by simp [kernel_map]
@[simp]
lemma kernel_map_id (C : homological_complex V b) (i : β) :
kernel_map (𝟙 C) i = 𝟙 _ :=
(cancel_mono (kernel.ι (C.d i))).1 $ by simp
@[simp]
lemma kernel_map_comp {C C' C'' : homological_complex V b} (f : C ⟶ C')
(g : C' ⟶ C'') (i : β) :
kernel_map (f ≫ g) i = kernel_map f i ≫ kernel_map g i :=
(cancel_mono (kernel.ι (C''.d i))).1 $ by simp
/-- The kernels of the differentials of a complex form a `β`-graded object. -/
def kernel_functor : homological_complex V b ⥤ graded_object β V :=
{ obj := λ C i, kernel (C.d i),
map := λ X Y f i, kernel_map f i }
end has_kernels
section has_image_maps
variables [has_images V] [has_image_maps V]
/-- A morphism of complexes induces a morphism on the images of the differentials in every
degree. -/
abbreviation image_map {C C' : homological_complex V b} (f : C ⟶ C') (i : β) :
image (C.d i) ⟶ image (C'.d i) :=
image.map (arrow.hom_mk' (comm_at f i).symm)
@[simp]
lemma image_map_ι {C C' : homological_complex V b} (f : C ⟶ C') (i : β) :
image_map f i ≫ image.ι (C'.d i) = image.ι (C.d i) ≫ f.f (i + b) :=
image.map_hom_mk'_ι (comm_at f i).symm
end has_image_maps
variables [has_images V] [has_equalizers V]
/--
The connecting morphism from the image of `d i` to the kernel of `d (i ± 1)`.
-/
def image_to_kernel_map (C : homological_complex V b) (i : β) :
image (C.d i) ⟶ kernel (C.d (i+b)) :=
category_theory.image_to_kernel_map (C.d i) (C.d (i+b)) (by simp)
@[simp, reassoc]
lemma image_to_kernel_map_condition (C : homological_complex V b) (i : β) :
image_to_kernel_map C i ≫ kernel.ι (C.d (i + b)) = image.ι (C.d i) :=
by simp [image_to_kernel_map]
@[reassoc]
lemma image_to_kernel_map_comp_kernel_map [has_image_maps V]
{C C' : homological_complex V b} (f : C ⟶ C') (i : β) :
image_to_kernel_map C i ≫ kernel_map f (i + b) = image_map f i ≫ image_to_kernel_map C' i :=
by { ext, simp }
variables [has_cokernels V]
/-- The `i`-th homology group of the complex `C`. -/
def homology_group (i : β) (C : homological_complex V b) : V :=
cokernel (image_to_kernel_map C (i-b))
variables [has_image_maps V]
/-- A chain map induces a morphism in homology at every degree. -/
def homology_map {C C' : homological_complex V b} (f : C ⟶ C') (i : β) :
C.homology_group i ⟶ C'.homology_group i :=
cokernel.desc _ (kernel_map f (i - b + b) ≫ cokernel.π _) $
by simp [image_to_kernel_map_comp_kernel_map_assoc]
@[simp, reassoc]
lemma homology_map_condition {C C' : homological_complex V b} (f : C ⟶ C') (i : β) :
cokernel.π (image_to_kernel_map C (i - b)) ≫ homology_map f i =
kernel_map f (i - b + b) ≫ cokernel.π _ :=
by simp [homology_map]
@[simp]
lemma homology_map_id (C : homological_complex V b) (i : β) :
homology_map (𝟙 C) i = 𝟙 (C.homology_group i) :=
begin
ext,
simp only [homology_map_condition, kernel_map_id, category.id_comp],
erw [category.comp_id]
end
@[simp]
lemma homology_map_comp {C C' C'' : homological_complex V b} (f : C ⟶ C') (g : C' ⟶ C'') (i : β) :
homology_map (f ≫ g) i = homology_map f i ≫ homology_map g i :=
by { ext, simp }
variables (V)
/-- The `i`-th homology functor from `β` graded complexes to `V`. -/
@[simps]
def homology (i : β) : homological_complex V b ⥤ V :=
{ obj := λ C, C.homology_group i,
map := λ C C' f, homology_map f i, }
/-- The homology functor from `β` graded complexes to `β` graded objects in `V`. -/
@[simps]
def graded_homology : homological_complex V b ⥤ graded_object β V :=
{ obj := λ C i, C.homology_group i,
map := λ C C' f i, homology_map f i }
end homological_complex
/-!
We now set up abbreviations so that you can write `C.cohomology i` or `(graded_cohomology V).map f`,
etc., when `C` is a cochain complex.
-/
namespace cochain_complex
variables [has_images V] [has_equalizers V] [has_cokernels V]
/-- The `i`-th cohomology group of the cochain complex `C`. -/
abbreviation cohomology_group (C : cochain_complex V) (i : ℤ) : V :=
C.homology_group i
variables [has_image_maps V]
/-- A chain map induces a morphism in cohomology at every degree. -/
abbreviation cohomology_map {C C' : cochain_complex V} (f : C ⟶ C') (i : ℤ) :
C.cohomology_group i ⟶ C'.cohomology_group i :=
homological_complex.homology_map f i
variables (V)
/-- The `i`-th homology functor from cohain complexes to `V`. -/
abbreviation cohomology (i : ℤ) : cochain_complex V ⥤ V :=
homological_complex.homology V i
/-- The cohomology functor from cochain complexes to `ℤ`-graded objects in `V`. -/
abbreviation graded_cohomology : cochain_complex V ⥤ graded_object ℤ V :=
homological_complex.graded_homology V
end cochain_complex
|
3174a91f3dbb1928f0a09d920613ed78de4debc6 | 31f556cdeb9239ffc2fad8f905e33987ff4feab9 | /stage0/src/Lean/Compiler/LCNF/ToExpr.lean | 6ee6b9aaf5458a1009a156fb99de6641ea9cc31f | [
"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 | 3,904 | 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.Compiler.LCNF.Basic
namespace Lean.Compiler.LCNF
namespace ToExpr
private abbrev LevelMap := FVarIdMap Nat
private def _root_.Lean.FVarId.toExpr (offset : Nat) (m : LevelMap) (fvarId : FVarId) : Expr :=
match m.find? fvarId with
| some level => .bvar (offset - level - 1)
| none => .fvar fvarId
private def _root_.Lean.Expr.abstract' (offset : Nat) (m : LevelMap) (e : Expr) : Expr :=
go offset e
where
go (o : Nat) (e : Expr) : Expr :=
match e with
| .fvar fvarId => fvarId.toExpr o m
| .lit .. | .const .. | .sort .. | .mvar .. | .bvar .. => e
| .app f a => .app (go o f) (go o a)
| .mdata k b => .mdata k (go o b)
| .proj s i b => .proj s i (go o b)
| .forallE n d b bi => .forallE n (go o d) (go (o+1) b) bi
| .lam n d b bi => .lam n (go o d) (go (o+1) b) bi
| .letE n t v b nd => .letE n (go o t) (go o v) (go (o+1) b) nd
abbrev ToExprM := ReaderT Nat $ StateM LevelMap
abbrev mkLambdaM (params : Array Param) (e : Expr) : ToExprM Expr :=
return go (← read) (← get) params.size e
where
go (offset : Nat) (m : LevelMap) (i : Nat) (e : Expr) : Expr :=
if i > 0 then
let param := params[i-1]!
let domain := param.type.abstract' (offset - 1) m
go (offset - 1) m (i - 1) (.lam param.binderName domain e .default)
else
e
private abbrev _root_.Lean.FVarId.toExprM (fvarId : FVarId) : ToExprM Expr :=
return fvarId.toExpr (← read) (← get)
private abbrev _root_.Lean.Expr.abstractM (e : Expr) : ToExprM Expr :=
return e.abstract' (← read) (← get)
abbrev abstractM (e : Expr) : ToExprM Expr :=
e.abstractM
@[inline] def withFVar (fvarId : FVarId) (k : ToExprM α) : ToExprM α := do
let offset ← read
modify fun s => s.insert fvarId offset
withReader (·+1) k
@[inline] partial def withParams (params : Array Param) (k : ToExprM α) : ToExprM α :=
go 0
where
@[specialize] go (i : Nat) : ToExprM α := do
if h : i < params.size then
withFVar params[i].fvarId (go (i+1))
else
k
@[inline] def run (x : ToExprM α) (offset : Nat := 0) (levelMap : LevelMap := {}) : α :=
x |>.run offset |>.run' levelMap
@[inline] def run' (x : ToExprM α) (xs : Array FVarId) : α :=
let map := xs.foldl (init := {}) fun map x => map.insert x map.size
run x xs.size map
end ToExpr
open ToExpr
mutual
partial def FunDeclCore.toExprM (decl : FunDecl) : ToExprM Expr :=
withParams decl.params do mkLambdaM decl.params (← decl.value.toExprM)
partial def Code.toExprM (code : Code) : ToExprM Expr := do
match code with
| .let decl k =>
let type ← decl.type.abstractM
let value ← decl.value.abstractM
let body ← withFVar decl.fvarId k.toExprM
return .letE decl.binderName type value body true
| .fun decl k | .jp decl k =>
let type ← decl.type.abstractM
let value ← decl.toExprM
let body ← withFVar decl.fvarId k.toExprM
return .letE decl.binderName type value body true
| .return fvarId => fvarId.toExprM
| .jmp fvarId args => return mkAppN (← fvarId.toExprM) (← args.mapM (·.abstractM))
| .unreach type => return mkApp (mkConst ``lcUnreachable) (← type.abstractM)
| .cases c =>
let alts ← c.alts.mapM fun
| .alt _ params k => withParams params do mkLambdaM params (← k.toExprM)
| .default k => k.toExprM
return mkAppN (mkConst `cases) (#[← c.discr.toExprM] ++ alts)
end
def Code.toExpr (code : Code) (xs : Array FVarId := #[]) : Expr :=
run' code.toExprM xs
def FunDeclCore.toExpr (decl : FunDecl) (xs : Array FVarId := #[]) : Expr :=
run' decl.toExprM xs
def Decl.toExpr (decl : Decl) : Expr :=
run do withParams decl.params do mkLambdaM decl.params (← decl.value.toExprM)
end Lean.Compiler.LCNF
|
4dc5c9fc9173bc4551630ea468e210df035a3778 | 05f637fa14ac28031cb1ea92086a0f4eb23ff2b1 | /tests/lean/tacluacrash.lean | f630e35fd088dbed33a2043c9953e4af83837878 | [
"Apache-2.0"
] | permissive | codyroux/lean0.1 | 1ce92751d664aacff0529e139083304a7bbc8a71 | 0dc6fb974aa85ed6f305a2f4b10a53a44ee5f0ef | refs/heads/master | 1,610,830,535,062 | 1,402,150,480,000 | 1,402,150,480,000 | 19,588,851 | 2 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 46 | lean | theorem T (a : Bool) : a → a.
(* foo_tac *)
|
407429474374506b91de415a00b85efd0f28e10b | fa02ed5a3c9c0adee3c26887a16855e7841c668b | /src/algebra/category/Mon/colimits.lean | ca6f7e5c4ad042e4e116fcac5e742f7aa600ea6e | [
"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 | 7,538 | lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import algebra.category.Mon.basic
import category_theory.limits.has_limits
import category_theory.limits.concrete_category
/-!
# The category of monoids has all colimits.
We do this construction knowing nothing about monoids.
In particular, I want to claim that this file could be produced by a python script
that just looks at the output of `#print monoid`:
-- structure monoid : Type u → Type u
-- fields:
-- monoid.mul : Π {α : Type u} [c : monoid α], α → α → α
-- monoid.mul_assoc : ∀ {α : Type u} [c : monoid α] (a b c_1 : α), a * b * c_1 = a * (b * c_1)
-- monoid.one : Π (α : Type u) [c : monoid α], α
-- monoid.one_mul : ∀ {α : Type u} [c : monoid α] (a : α), 1 * a = a
-- monoid.mul_one : ∀ {α : Type u} [c : monoid α] (a : α), a * 1 = a
and if we'd fed it the output of `#print comm_ring`, this file would instead build
colimits of commutative rings.
A slightly bolder claim is that we could do this with tactics, as well.
-/
universes v
open category_theory
open category_theory.limits
namespace Mon.colimits
/-!
We build the colimit of a diagram in `Mon` by constructing the
free monoid on the disjoint union of all the monoids in the diagram,
then taking the quotient by the monoid laws within each monoid,
and the identifications given by the morphisms in the diagram.
-/
variables {J : Type v} [small_category J] (F : J ⥤ Mon.{v})
/--
An inductive type representing all monoid expressions (without relations)
on a collection of types indexed by the objects of `J`.
-/
inductive prequotient
-- There's always `of`
| of : Π (j : J) (x : F.obj j), prequotient
-- Then one generator for each operation
| one : prequotient
| mul : prequotient → prequotient → prequotient
instance : inhabited (prequotient F) := ⟨prequotient.one⟩
open prequotient
/--
The relation on `prequotient` saying when two expressions are equal
because of the monoid laws, or
because one element is mapped to another by a morphism in the diagram.
-/
inductive relation : prequotient F → prequotient F → Prop
-- Make it an equivalence relation:
| refl : Π (x), relation x x
| symm : Π (x y) (h : relation x y), relation y x
| trans : Π (x y z) (h : relation x y) (k : relation y z), relation x z
-- There's always a `map` relation
| map : Π (j j' : J) (f : j ⟶ j') (x : F.obj j), relation (of j' ((F.map f) x)) (of j x)
-- Then one relation per operation, describing the interaction with `of`
| mul : Π (j) (x y : F.obj j), relation (of j (x * y)) (mul (of j x) (of j y))
| one : Π (j), relation (of j 1) one
-- Then one relation per argument of each operation
| mul_1 : Π (x x' y) (r : relation x x'), relation (mul x y) (mul x' y)
| mul_2 : Π (x y y') (r : relation y y'), relation (mul x y) (mul x y')
-- And one relation per axiom
| mul_assoc : Π (x y z), relation (mul (mul x y) z) (mul x (mul y z))
| one_mul : Π (x), relation (mul one x) x
| mul_one : Π (x), relation (mul x one) x
/--
The setoid corresponding to monoid expressions modulo monoid relations and identifications.
-/
def colimit_setoid : setoid (prequotient F) :=
{ r := relation F, iseqv := ⟨relation.refl, relation.symm, relation.trans⟩ }
attribute [instance] colimit_setoid
/--
The underlying type of the colimit of a diagram in `Mon`.
-/
@[derive inhabited]
def colimit_type : Type v := quotient (colimit_setoid F)
instance monoid_colimit_type : monoid (colimit_type F) :=
{ mul :=
begin
fapply @quot.lift _ _ ((colimit_type F) → (colimit_type F)),
{ intro x,
fapply @quot.lift,
{ intro y,
exact quot.mk _ (mul x y) },
{ intros y y' r,
apply quot.sound,
exact relation.mul_2 _ _ _ r } },
{ intros x x' r,
funext y,
induction y,
dsimp,
apply quot.sound,
{ exact relation.mul_1 _ _ _ r },
{ refl } },
end,
one :=
begin
exact quot.mk _ one
end,
mul_assoc := λ x y z,
begin
induction x,
induction y,
induction z,
dsimp,
apply quot.sound,
apply relation.mul_assoc,
refl,
refl,
refl,
end,
one_mul := λ x,
begin
induction x,
dsimp,
apply quot.sound,
apply relation.one_mul,
refl,
end,
mul_one := λ x,
begin
induction x,
dsimp,
apply quot.sound,
apply relation.mul_one,
refl,
end }
@[simp] lemma quot_one : quot.mk setoid.r one = (1 : colimit_type F) := rfl
@[simp] lemma quot_mul (x y) : quot.mk setoid.r (mul x y) =
((quot.mk setoid.r x) * (quot.mk setoid.r y) : colimit_type F) := rfl
/-- The bundled monoid giving the colimit of a diagram. -/
def colimit : Mon := ⟨colimit_type F, by apply_instance⟩
/-- The function from a given monoid in the diagram to the colimit monoid. -/
def cocone_fun (j : J) (x : F.obj j) : colimit_type F :=
quot.mk _ (of j x)
/-- The monoid homomorphism from a given monoid in the diagram to the colimit monoid. -/
def cocone_morphism (j : J) : F.obj j ⟶ colimit F :=
{ to_fun := cocone_fun F j,
map_one' := quot.sound (relation.one _),
map_mul' := λ x y, quot.sound (relation.mul _ _ _) }
@[simp] lemma cocone_naturality {j j' : J} (f : j ⟶ j') :
F.map f ≫ (cocone_morphism F j') = cocone_morphism F j :=
begin
ext,
apply quot.sound,
apply relation.map,
end
@[simp] lemma cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j):
(cocone_morphism F j') (F.map f x) = (cocone_morphism F j) x :=
by { rw ←cocone_naturality F f, refl }
/-- The cocone over the proposed colimit monoid. -/
def colimit_cocone : cocone F :=
{ X := colimit F,
ι :=
{ app := cocone_morphism F, } }.
/-- The function from the free monoid on the diagram to the cone point of any other cocone. -/
@[simp] def desc_fun_lift (s : cocone F) : prequotient F → s.X
| (of j x) := (s.ι.app j) x
| one := 1
| (mul x y) := desc_fun_lift x * desc_fun_lift y
/-- The function from the colimit monoid to the cone point of any other cocone. -/
def desc_fun (s : cocone F) : colimit_type F → s.X :=
begin
fapply quot.lift,
{ exact desc_fun_lift F s },
{ intros x y r,
induction r; try { dsimp },
-- refl
{ refl },
-- symm
{ exact r_ih.symm },
-- trans
{ exact eq.trans r_ih_h r_ih_k },
-- map
{ simp, },
-- mul
{ simp, },
-- one
{ simp, },
-- mul_1
{ rw r_ih, },
-- mul_2
{ rw r_ih, },
-- mul_assoc
{ rw mul_assoc, },
-- one_mul
{ rw one_mul, },
-- mul_one
{ rw mul_one, } }
end
/-- The monoid homomorphism from the colimit monoid to the cone point of any other cocone. -/
def desc_morphism (s : cocone F) : colimit F ⟶ s.X :=
{ to_fun := desc_fun F s,
map_one' := rfl,
map_mul' := λ x y, by { induction x; induction y; refl }, }
/-- Evidence that the proposed colimit is the colimit. -/
def colimit_is_colimit : is_colimit (colimit_cocone F) :=
{ desc := λ s, desc_morphism F s,
uniq' := λ s m w,
begin
ext,
induction x,
induction x,
{ have w' := congr_fun (congr_arg (λ f : F.obj x_j ⟶ s.X, (f : F.obj x_j → s.X)) (w x_j)) x_x,
erw w',
refl, },
{ simp *, },
{ simp *, },
refl
end }.
instance has_colimits_Mon : has_colimits Mon :=
{ has_colimits_of_shape := λ J 𝒥, by exactI
{ has_colimit := λ F, has_colimit.mk
{ cocone := colimit_cocone F,
is_colimit := colimit_is_colimit F } } }
end Mon.colimits
|
0b7eb815ba0421680eeab8ec86b23eba85ff3097 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/run/1414.lean | ec5ecd4c763a5f9d8f7d1f427996f10edad7e17b | [
"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 | 207 | lean | def Union {α : Prop} {β : Type} (s : α → set β) (x : β) : Prop :=
∃ i, x ∈ s i
example (y : ℕ) (t : set ℕ) : Union (λH : (∃x, x ∈ t), t) y → true
| ⟨⟨z, z_ex⟩, y_in⟩ := ⟨⟩
|
d53dbccf54a8244c4295afd7c8b49d2944caa1b4 | 4e3bf8e2b29061457a887ac8889e88fa5aa0e34c | /lean/love04_functional_programming_homework_sheet.lean | 0d36ce2f78cee4999ce25301b814dd9e2593de39 | [] | no_license | mukeshtiwari/logical_verification_2019 | 9f964c067a71f65eb8884743273fbeef99e6503d | 16f62717f55ed5b7b87e03ae0134791a9bef9b9a | refs/heads/master | 1,619,158,844,208 | 1,585,139,500,000 | 1,585,139,500,000 | 249,906,380 | 0 | 0 | null | 1,585,118,728,000 | 1,585,118,727,000 | null | UTF-8 | Lean | false | false | 1,800 | lean | /- LoVe Homework 4: Functional Programming -/
import .love04_functional_programming_demo
namespace LoVe
/- Question 1: Reverse of a List -/
/- Recall the `reverse` operation and the `reverse_append` lemma from the
lecture. -/
#check reverse
#check reverse_append
/- 1.1. Prove the following distributive property, using a calculational proof
for the inductive step. -/
lemma reverse_append₂ {α : Type} :
∀xs ys : list α, reverse (xs ++ ys) = reverse ys ++ reverse xs
:= sorry
/- 1.2. Prove the induction step in the proof below using the calculational
style, following this proof sketch:
reverse (reverse (x :: xs))
= { by definition of `reverse` }
reverse (reverse xs ++ [x])
= { using the lemma `reverse_append` }
reverse [x] ++ reverse (reverse xs)
= { by the induction hypothesis }
reverse [x] ++ xs
= { by definition of `++` and `reverse` }
[x] ++ xs
= { by computation }
x :: xs -/
lemma reverse_reverse₂ {α : Type} :
∀xs : list α, reverse (reverse xs) = xs
| [] := by refl
| (x :: xs) :=
sorry
/- Question 2: Gauss's Summation Formula -/
-- `sum_upto f n = f 0 + f 1 + ⋯ + f n`
def sum_upto (f : ℕ → ℕ) : ℕ → ℕ
| 0 := f 0
| (m + 1) := sum_upto m + f (m + 1)
/- 2.1. Prove the following lemma, discovered by Carl Friedrich Gauss as a
pupil.
Hints: The `mul_add` and `add_mul` lemmas and the `ac_refl` tactics might be
useful to reason about multiplication. -/
#check mul_add
#check add_mul
lemma sum_upto_eq :
∀m : ℕ, 2 * sum_upto (λi, i) m = m * (m + 1)
:= sorry
/- 2.2. Prove the following property of `sum_upto`. -/
lemma sum_upto_mul (a : ℕ) (f : ℕ → ℕ) :
∀(n : ℕ), sum_upto (λi, a * f i) n = a * sum_upto f n
:= sorry
end LoVe
|
59712a638c41fd7af365851aab0867162f46cbbf | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/interactive/lib/open_locale.lean | cefdc577380beab41e5c45725361f87f582859ac | [
"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 | 146 | lean | open lean lean.parser interactive tactic native
@[user_command] meta def open_locale_cmd (_ : parse $ tk "open_locale") : parser unit :=
pure ()
|
989463fea7b99e150709bab27d1b5d25f781568a | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/combinatorics/quiver/arborescence.lean | 9bc048ce718bd17ff0938c2f3cfd67ff8b16acdc | [
"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 | 4,983 | 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 order.well_founded
import data.nat.basic
import combinatorics.quiver.subquiver
import combinatorics.quiver.path
/-!
# Arborescences
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
A quiver `V` is an arborescence (or directed rooted tree) when we have a root vertex `root : V` such
that for every `b : V` there is a unique path from `root` to `b`.
## Main definitions
- `quiver.arborescence V`: a typeclass asserting that `V` is an arborescence
- `arborescence_mk`: a convenient way of proving that a quiver is an arborescence
- `rooted_connected r`: a typeclass asserting that there is at least one path from `r` to `b` for
every `b`.
- `geodesic_subtree r`: given `[rooted_conntected r]`, this is a subquiver of `V` which contains
just enough edges to include a shortest path from `r` to `b` for every `b`.
- `geodesic_arborescence : arborescence (geodesic_subtree r)`: an instance saying that the geodesic
subtree is an arborescence. This proves the directed analogue of 'every connected graph has a
spanning tree'. This proof avoids the use of Zorn's lemma.
-/
open opposite
universes v u
namespace quiver
/-- A quiver is an arborescence when there is a unique path from the default vertex
to every other vertex. -/
class arborescence (V : Type u) [quiver.{v} V] : Type (max u v) :=
(root : V)
(unique_path : Π (b : V), unique (path root b))
/-- The root of an arborescence. -/
def root (V : Type u) [quiver V] [arborescence V] : V :=
arborescence.root
instance {V : Type u} [quiver V] [arborescence V] (b : V) : unique (path (root V) b) :=
arborescence.unique_path b
/-- To show that `[quiver V]` is an arborescence with root `r : V`, it suffices to
- provide a height function `V → ℕ` such that every arrow goes from a
lower vertex to a higher vertex,
- show that every vertex has at most one arrow to it, and
- show that every vertex other than `r` has an arrow to it. -/
noncomputable def arborescence_mk {V : Type u} [quiver V] (r : V)
(height : V → ℕ)
(height_lt : ∀ ⦃a b⦄, (a ⟶ b) → height a < height b)
(unique_arrow : ∀ ⦃a b c : V⦄ (e : a ⟶ c) (f : b ⟶ c), a = b ∧ e == f)
(root_or_arrow : ∀ b, b = r ∨ ∃ a, nonempty (a ⟶ b)) : arborescence V :=
{ root := r,
unique_path := λ b, ⟨classical.inhabited_of_nonempty
begin
rcases (show ∃ n, height b < n, from ⟨_, nat.lt.base _⟩) with ⟨n, hn⟩,
induction n with n ih generalizing b,
{ exact false.elim (nat.not_lt_zero _ hn) },
rcases root_or_arrow b with ⟨⟨⟩⟩ | ⟨a, ⟨e⟩⟩,
{ exact ⟨path.nil⟩ },
{ rcases ih a (lt_of_lt_of_le (height_lt e) (nat.lt_succ_iff.mp hn)) with ⟨p⟩,
exact ⟨p.cons e⟩ }
end,
begin
have height_le : ∀ {a b}, path a b → height a ≤ height b,
{ intros a b p, induction p with b c p e ih, refl,
exact le_of_lt (lt_of_le_of_lt ih (height_lt e)) },
suffices : ∀ p q : path r b, p = q,
{ intro p, apply this },
intros p q, induction p with a c p e ih; cases q with b _ q f,
{ refl },
{ exact false.elim (lt_irrefl _ (lt_of_le_of_lt (height_le q) (height_lt f))) },
{ exact false.elim (lt_irrefl _ (lt_of_le_of_lt (height_le p) (height_lt e))) },
{ rcases unique_arrow e f with ⟨⟨⟩, ⟨⟩⟩, rw ih },
end ⟩ }
/-- `rooted_connected r` means that there is a path from `r` to any other vertex. -/
class rooted_connected {V : Type u} [quiver V] (r : V) : Prop :=
(nonempty_path : ∀ b : V, nonempty (path r b))
attribute [instance] rooted_connected.nonempty_path
section geodesic_subtree
variables {V : Type u} [quiver.{v+1} V] (r : V) [rooted_connected r]
/-- A path from `r` of minimal length. -/
noncomputable def shortest_path (b : V) : path r b :=
well_founded.min (measure_wf path.length) set.univ set.univ_nonempty
/-- The length of a path is at least the length of the shortest path -/
lemma shortest_path_spec {a : V} (p : path r a) :
(shortest_path r a).length ≤ p.length :=
not_lt.mp (well_founded.not_lt_min (measure_wf _) set.univ _ trivial)
/-- A subquiver which by construction is an arborescence. -/
def geodesic_subtree : wide_subquiver V :=
λ a b, { e | ∃ p : path r a, shortest_path r b = p.cons e }
noncomputable instance geodesic_arborescence : arborescence (geodesic_subtree r) :=
arborescence_mk r (λ a, (shortest_path r a).length)
(by { rintros a b ⟨e, p, h⟩, rw [h, path.length_cons, nat.lt_succ_iff], apply shortest_path_spec })
(by { rintros a b c ⟨e, p, h⟩ ⟨f, q, j⟩, cases h.symm.trans j, split; refl })
begin
intro b,
rcases hp : shortest_path r b with (_ | ⟨p, e⟩),
{ exact or.inl rfl },
{ exact or.inr ⟨_, ⟨⟨e, p, hp⟩⟩⟩ }
end
end geodesic_subtree
end quiver
|
67070c4d7f36551dd65dd90492f45405c335c6d0 | 5749d8999a76f3a8fddceca1f6941981e33aaa96 | /src/order/basic.lean | e546d58fae50930325c36547018553be9bcab1db | [
"Apache-2.0"
] | permissive | jdsalchow/mathlib | 13ab43ef0d0515a17e550b16d09bd14b76125276 | 497e692b946d93906900bb33a51fd243e7649406 | refs/heads/master | 1,585,819,143,348 | 1,580,072,892,000 | 1,580,072,892,000 | 154,287,128 | 0 | 0 | Apache-2.0 | 1,540,281,610,000 | 1,540,281,609,000 | null | UTF-8 | Lean | false | false | 27,472 | lean | /-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Mario Carneiro
-/
import logic.basic data.sum data.set.basic algebra.order
open function
/- TODO: automatic construction of dual definitions / theorems -/
universes u v w
variables {α : Type u} {β : Type v} {γ : Type w} {r : α → α → Prop}
theorem ge_of_eq [preorder α] {a b : α} : a = b → a ≥ b :=
λ h, h ▸ le_refl a
theorem is_refl.swap (r) [is_refl α r] : is_refl α (swap r) := ⟨refl_of r⟩
theorem is_irrefl.swap (r) [is_irrefl α r] : is_irrefl α (swap r) := ⟨irrefl_of r⟩
theorem is_trans.swap (r) [is_trans α r] : is_trans α (swap r) :=
⟨λ a b c h₁ h₂, trans_of r h₂ h₁⟩
theorem is_antisymm.swap (r) [is_antisymm α r] : is_antisymm α (swap r) :=
⟨λ a b h₁ h₂, antisymm h₂ h₁⟩
theorem is_asymm.swap (r) [is_asymm α r] : is_asymm α (swap r) :=
⟨λ a b h₁ h₂, asymm_of r h₂ h₁⟩
theorem is_total.swap (r) [is_total α r] : is_total α (swap r) :=
⟨λ a b, (total_of r a b).swap⟩
theorem is_trichotomous.swap (r) [is_trichotomous α r] : is_trichotomous α (swap r) :=
⟨λ a b, by simpa [swap, or.comm, or.left_comm] using trichotomous_of r a b⟩
theorem is_preorder.swap (r) [is_preorder α r] : is_preorder α (swap r) :=
{..@is_refl.swap α r _, ..@is_trans.swap α r _}
theorem is_strict_order.swap (r) [is_strict_order α r] : is_strict_order α (swap r) :=
{..@is_irrefl.swap α r _, ..@is_trans.swap α r _}
theorem is_partial_order.swap (r) [is_partial_order α r] : is_partial_order α (swap r) :=
{..@is_preorder.swap α r _, ..@is_antisymm.swap α r _}
theorem is_total_preorder.swap (r) [is_total_preorder α r] : is_total_preorder α (swap r) :=
{..@is_preorder.swap α r _, ..@is_total.swap α r _}
theorem is_linear_order.swap (r) [is_linear_order α r] : is_linear_order α (swap r) :=
{..@is_partial_order.swap α r _, ..@is_total.swap α r _}
lemma antisymm_of_asymm (r) [is_asymm α r] : is_antisymm α r :=
⟨λ x y h₁ h₂, (asymm h₁ h₂).elim⟩
/- Convert algebraic structure style to explicit relation style typeclasses -/
instance [preorder α] : is_refl α (≤) := ⟨le_refl⟩
instance [preorder α] : is_refl α (≥) := is_refl.swap _
instance [preorder α] : is_trans α (≤) := ⟨@le_trans _ _⟩
instance [preorder α] : is_trans α (≥) := is_trans.swap _
instance [preorder α] : is_preorder α (≤) := {}
instance [preorder α] : is_preorder α (≥) := {}
instance [preorder α] : is_irrefl α (<) := ⟨lt_irrefl⟩
instance [preorder α] : is_irrefl α (>) := is_irrefl.swap _
instance [preorder α] : is_trans α (<) := ⟨@lt_trans _ _⟩
instance [preorder α] : is_trans α (>) := is_trans.swap _
instance [preorder α] : is_asymm α (<) := ⟨@lt_asymm _ _⟩
instance [preorder α] : is_asymm α (>) := is_asymm.swap _
instance [preorder α] : is_antisymm α (<) := antisymm_of_asymm _
instance [preorder α] : is_antisymm α (>) := antisymm_of_asymm _
instance [preorder α] : is_strict_order α (<) := {}
instance [preorder α] : is_strict_order α (>) := {}
instance preorder.is_total_preorder [preorder α] [is_total α (≤)] : is_total_preorder α (≤) := {}
instance [partial_order α] : is_antisymm α (≤) := ⟨@le_antisymm _ _⟩
instance [partial_order α] : is_antisymm α (≥) := is_antisymm.swap _
instance [partial_order α] : is_partial_order α (≤) := {}
instance [partial_order α] : is_partial_order α (≥) := {}
instance [linear_order α] : is_total α (≤) := ⟨le_total⟩
instance [linear_order α] : is_total α (≥) := is_total.swap _
instance linear_order.is_total_preorder [linear_order α] : is_total_preorder α (≤) := by apply_instance
instance [linear_order α] : is_total_preorder α (≥) := {}
instance [linear_order α] : is_linear_order α (≤) := {}
instance [linear_order α] : is_linear_order α (≥) := {}
instance [linear_order α] : is_trichotomous α (<) := ⟨lt_trichotomy⟩
instance [linear_order α] : is_trichotomous α (>) := is_trichotomous.swap _
theorem preorder.ext {α} {A B : preorder α}
(H : ∀ x y : α, (by haveI := A; exact x ≤ y) ↔ x ≤ y) : A = B :=
begin
resetI, cases A, cases B, congr,
{ funext x y, exact propext (H x y) },
{ funext x y,
dsimp [(≤)] at A_lt_iff_le_not_le B_lt_iff_le_not_le H,
simp [A_lt_iff_le_not_le, B_lt_iff_le_not_le, H] },
end
theorem partial_order.ext {α} {A B : partial_order α}
(H : ∀ x y : α, (by haveI := A; exact x ≤ y) ↔ x ≤ y) : A = B :=
by haveI this := preorder.ext H;
cases A; cases B; injection this; congr'
theorem linear_order.ext {α} {A B : linear_order α}
(H : ∀ x y : α, (by haveI := A; exact x ≤ y) ↔ x ≤ y) : A = B :=
by haveI this := partial_order.ext H;
cases A; cases B; injection this; congr'
/-- Given an order `R` on `β` and a function `f : α → β`,
the preimage order on `α` is defined by `x ≤ y ↔ f x ≤ f y`.
It is the unique order on `α` making `f` an order embedding
(assuming `f` is injective). -/
@[simp] def order.preimage {α β} (f : α → β) (s : β → β → Prop) (x y : α) := s (f x) (f y)
infix ` ⁻¹'o `:80 := order.preimage
section monotone
variables [preorder α] [preorder β] [preorder γ]
/-- A function between preorders is monotone if
`a ≤ b` implies `f a ≤ f b`. -/
def monotone (f : α → β) := ∀⦃a b⦄, a ≤ b → f a ≤ f b
theorem monotone_id : @monotone α α _ _ id := assume x y h, h
theorem monotone_const {b : β} : monotone (λ(a:α), b) := assume x y h, le_refl b
protected theorem monotone.comp {g : β → γ} {f : α → β} (m_g : monotone g) (m_f : monotone f) :
monotone (g ∘ f) :=
assume a b h, m_g (m_f h)
lemma monotone_of_monotone_nat {f : ℕ → α} (hf : ∀n, f n ≤ f (n + 1)) :
monotone f | n m h :=
begin
induction h,
{ refl },
{ transitivity, assumption, exact hf _ }
end
lemma reflect_lt {α β} [linear_order α] [preorder β] {f : α → β} (hf : monotone f)
{x x' : α} (h : f x < f x') : x < x' :=
by { rw [← not_le], intro h', apply not_le_of_lt h, exact hf h' }
end monotone
/-- Type tag for a set with dual order: `≤` means `≥` and `<` means `>`. -/
def order_dual (α : Type*) := α
namespace order_dual
instance (α : Type*) [has_le α] : has_le (order_dual α) := ⟨λx y:α, y ≤ x⟩
instance (α : Type*) [has_lt α] : has_lt (order_dual α) := ⟨λx y:α, y < x⟩
@[simp] lemma dual_le [has_le α] {a b : α} :
@has_le.le (order_dual α) _ a b ↔ @has_le.le α _ b a := iff.rfl
@[simp] lemma dual_lt [has_lt α] {a b : α} :
@has_lt.lt (order_dual α) _ a b ↔ @has_lt.lt α _ b a := iff.rfl
instance (α : Type*) [preorder α] : preorder (order_dual α) :=
{ le_refl := le_refl,
le_trans := assume a b c hab hbc, le_trans hbc hab,
lt_iff_le_not_le := λ _ _, lt_iff_le_not_le,
.. order_dual.has_le α,
.. order_dual.has_lt α }
instance (α : Type*) [partial_order α] : partial_order (order_dual α) :=
{ le_antisymm := assume a b hab hba, @le_antisymm α _ a b hba hab, .. order_dual.preorder α }
instance (α : Type*) [linear_order α] : linear_order (order_dual α) :=
{ le_total := assume a b:α, le_total b a, .. order_dual.partial_order α }
instance (α : Type*) [decidable_linear_order α] : decidable_linear_order (order_dual α) :=
{ decidable_le := show decidable_rel (λa b:α, b ≤ a), by apply_instance,
decidable_lt := show decidable_rel (λa b:α, b < a), by apply_instance,
.. order_dual.linear_order α }
instance : Π [inhabited α], inhabited (order_dual α) := id
end order_dual
/- order instances on the function space -/
instance pi.preorder {ι : Type u} {α : ι → Type v} [∀i, preorder (α i)] : preorder (Πi, α i) :=
{ le := λx y, ∀i, x i ≤ y i,
le_refl := assume a i, le_refl (a i),
le_trans := assume a b c h₁ h₂ i, le_trans (h₁ i) (h₂ i) }
instance pi.partial_order {ι : Type u} {α : ι → Type v} [∀i, partial_order (α i)] : partial_order (Πi, α i) :=
{ le_antisymm := λf g h1 h2, funext (λb, le_antisymm (h1 b) (h2 b)),
..pi.preorder }
theorem comp_le_comp_left_of_monotone [preorder α] [preorder β]
{f : β → α} {g h : γ → β} (m_f : monotone f) (le_gh : g ≤ h) : has_le.le.{max w u} (f ∘ g) (f ∘ h) :=
assume x, m_f (le_gh x)
section monotone
variables [preorder α] [preorder γ]
theorem monotone_lam {f : α → β → γ} (m : ∀b, monotone (λa, f a b)) : monotone f :=
assume a a' h b, m b h
theorem monotone_app (f : β → α → γ) (b : β) (m : monotone (λa b, f b a)) : monotone (f b) :=
assume a a' h, m h b
end monotone
def preorder.lift {α β} (f : α → β) (i : preorder β) : preorder α :=
by exactI
{ le := λx y, f x ≤ f y,
le_refl := λ a, le_refl _,
le_trans := λ a b c, le_trans,
lt := λx y, f x < f y,
lt_iff_le_not_le := λ a b, lt_iff_le_not_le }
def partial_order.lift {α β} (f : α → β) (inj : injective f) (i : partial_order β) :
partial_order α :=
by exactI
{ le_antisymm := λ a b h₁ h₂, inj (le_antisymm h₁ h₂), .. preorder.lift f (by apply_instance) }
def linear_order.lift {α β} (f : α → β) (inj : injective f) (i : linear_order β) :
linear_order α :=
by exactI
{ le_total := λx y, le_total (f x) (f y), .. partial_order.lift f inj (by apply_instance) }
def decidable_linear_order.lift {α β} (f : α → β) (inj : injective f)
(i : decidable_linear_order β) : decidable_linear_order α :=
by exactI
{ decidable_le := λ x y, show decidable (f x ≤ f y), by apply_instance,
decidable_lt := λ x y, show decidable (f x < f y), by apply_instance,
decidable_eq := λ x y, decidable_of_iff _ ⟨@inj x y, congr_arg f⟩,
.. linear_order.lift f inj (by apply_instance) }
instance subtype.preorder {α} [i : preorder α] (p : α → Prop) : preorder (subtype p) :=
preorder.lift subtype.val i
instance subtype.partial_order {α} [i : partial_order α] (p : α → Prop) : partial_order (subtype p) :=
partial_order.lift subtype.val subtype.val_injective i
instance subtype.linear_order {α} [i : linear_order α] (p : α → Prop) : linear_order (subtype p) :=
linear_order.lift subtype.val subtype.val_injective i
instance subtype.decidable_linear_order {α} [i : decidable_linear_order α] (p : α → Prop) :
decidable_linear_order (subtype p) :=
decidable_linear_order.lift subtype.val subtype.val_injective i
instance prod.has_le (α : Type u) (β : Type v) [has_le α] [has_le β] : has_le (α × β) :=
⟨λp q, p.1 ≤ q.1 ∧ p.2 ≤ q.2⟩
instance prod.preorder (α : Type u) (β : Type v) [preorder α] [preorder β] : preorder (α × β) :=
{ le_refl := assume ⟨a, b⟩, ⟨le_refl a, le_refl b⟩,
le_trans := assume ⟨a, b⟩ ⟨c, d⟩ ⟨e, f⟩ ⟨hac, hbd⟩ ⟨hce, hdf⟩,
⟨le_trans hac hce, le_trans hbd hdf⟩,
.. prod.has_le α β }
/-- The pointwise partial order on a product.
(The lexicographic ordering is defined in order/lexicographic.lean, and the instances are
available via the type synonym `lex α β = α × β`.) -/
instance prod.partial_order (α : Type u) (β : Type v) [partial_order α] [partial_order β] :
partial_order (α × β) :=
{ le_antisymm := assume ⟨a, b⟩ ⟨c, d⟩ ⟨hac, hbd⟩ ⟨hca, hdb⟩,
prod.ext (le_antisymm hac hca) (le_antisymm hbd hdb),
.. prod.preorder α β }
/- additional order classes -/
/-- order without a top element; somtimes called cofinal -/
class no_top_order (α : Type u) [preorder α] : Prop :=
(no_top : ∀a:α, ∃a', a < a')
lemma no_top [preorder α] [no_top_order α] : ∀a:α, ∃a', a < a' :=
no_top_order.no_top
/-- order without a bottom element; somtimes called coinitial or dense -/
class no_bot_order (α : Type u) [preorder α] : Prop :=
(no_bot : ∀a:α, ∃a', a' < a)
lemma no_bot [preorder α] [no_bot_order α] : ∀a:α, ∃a', a' < a :=
no_bot_order.no_bot
instance order_dual.no_top_order (α : Type u) [preorder α] [no_bot_order α] :
no_top_order (order_dual α) :=
⟨λ a, @no_bot α _ _ a⟩
instance order_dual.no_bot_order (α : Type u) [preorder α] [no_top_order α] :
no_bot_order (order_dual α) :=
⟨λ a, @no_top α _ _ a⟩
/-- An order is dense if there is an element between any pair of distinct elements. -/
class densely_ordered (α : Type u) [preorder α] : Prop :=
(dense : ∀a₁ a₂:α, a₁ < a₂ → ∃a, a₁ < a ∧ a < a₂)
lemma dense [preorder α] [densely_ordered α] : ∀{a₁ a₂:α}, a₁ < a₂ → ∃a, a₁ < a ∧ a < a₂ :=
densely_ordered.dense
instance order_dual.densely_ordered (α : Type u) [preorder α] [densely_ordered α] :
densely_ordered (order_dual α) :=
⟨λ a₁ a₂ ha, (@dense α _ _ _ _ ha).imp $ λ a, and.symm⟩
lemma le_of_forall_le_of_dense [linear_order α] [densely_ordered α] {a₁ a₂ : α} (h : ∀a₃>a₂, a₁ ≤ a₃) :
a₁ ≤ a₂ :=
le_of_not_gt $ assume ha,
let ⟨a, ha₁, ha₂⟩ := dense ha in
lt_irrefl a $ lt_of_lt_of_le ‹a < a₁› (h _ ‹a₂ < a›)
lemma eq_of_le_of_forall_le_of_dense [linear_order α] [densely_ordered α] {a₁ a₂ : α}
(h₁ : a₂ ≤ a₁) (h₂ : ∀a₃>a₂, a₁ ≤ a₃) : a₁ = a₂ :=
le_antisymm (le_of_forall_le_of_dense h₂) h₁
lemma le_of_forall_ge_of_dense [linear_order α] [densely_ordered α] {a₁ a₂ : α}(h : ∀a₃<a₁, a₂ ≥ a₃) :
a₁ ≤ a₂ :=
le_of_not_gt $ assume ha,
let ⟨a, ha₁, ha₂⟩ := dense ha in
lt_irrefl a $ lt_of_le_of_lt (h _ ‹a < a₁›) ‹a₂ < a›
lemma eq_of_le_of_forall_ge_of_dense [linear_order α] [densely_ordered α] {a₁ a₂ : α}
(h₁ : a₂ ≤ a₁) (h₂ : ∀a₃<a₁, a₂ ≥ a₃) : a₁ = a₂ :=
le_antisymm (le_of_forall_ge_of_dense h₂) h₁
lemma dense_or_discrete [linear_order α] (a₁ a₂ : α) :
(∃a, a₁ < a ∧ a < a₂) ∨ ((∀a>a₁, a ≥ a₂) ∧ (∀a<a₂, a ≤ a₁)) :=
classical.or_iff_not_imp_left.2 $ assume h,
⟨assume a ha₁, le_of_not_gt $ assume ha₂, h ⟨a, ha₁, ha₂⟩,
assume a ha₂, le_of_not_gt $ assume ha₁, h ⟨a, ha₁, ha₂⟩⟩
lemma trans_trichotomous_left [is_trans α r] [is_trichotomous α r] {a b c : α} :
¬r b a → r b c → r a c :=
begin
intros h₁ h₂, rcases trichotomous_of r a b with h₃|h₃|h₃,
exact trans h₃ h₂, rw h₃, exact h₂, exfalso, exact h₁ h₃
end
lemma trans_trichotomous_right [is_trans α r] [is_trichotomous α r] {a b c : α} :
r a b → ¬r c b → r a c :=
begin
intros h₁ h₂, rcases trichotomous_of r b c with h₃|h₃|h₃,
exact trans h₁ h₃, rw ←h₃, exact h₁, exfalso, exact h₂ h₃
end
variables {s : β → β → Prop} {t : γ → γ → Prop}
theorem is_irrefl_of_is_asymm [is_asymm α r] : is_irrefl α r :=
⟨λ a h, asymm h h⟩
/-- Construct a partial order from a `is_strict_order` relation -/
def partial_order_of_SO (r) [is_strict_order α r] : partial_order α :=
{ le := λ x y, x = y ∨ r x y,
lt := r,
le_refl := λ x, or.inl rfl,
le_trans := λ x y z h₁ h₂,
match y, z, h₁, h₂ with
| _, _, or.inl rfl, h₂ := h₂
| _, _, h₁, or.inl rfl := h₁
| _, _, or.inr h₁, or.inr h₂ := or.inr (trans h₁ h₂)
end,
le_antisymm := λ x y h₁ h₂,
match y, h₁, h₂ with
| _, or.inl rfl, h₂ := rfl
| _, h₁, or.inl rfl := rfl
| _, or.inr h₁, or.inr h₂ := (asymm h₁ h₂).elim
end,
lt_iff_le_not_le := λ x y,
⟨λ h, ⟨or.inr h, not_or
(λ e, by rw e at h; exact irrefl _ h)
(asymm h)⟩,
λ ⟨h₁, h₂⟩, h₁.resolve_left (λ e, h₂ $ e ▸ or.inl rfl)⟩ }
section prio
set_option default_priority 100 -- see Note [default priority]
/-- This is basically the same as `is_strict_total_order`, but that definition is
in Type (probably by mistake) and also has redundant assumptions. -/
@[algebra] class is_strict_total_order' (α : Type u) (lt : α → α → Prop) extends is_trichotomous α lt, is_strict_order α lt : Prop.
end prio
/-- Construct a linear order from a `is_strict_total_order'` relation -/
def linear_order_of_STO' (r) [is_strict_total_order' α r] : linear_order α :=
{ le_total := λ x y,
match y, trichotomous_of r x y with
| y, or.inl h := or.inl (or.inr h)
| _, or.inr (or.inl rfl) := or.inl (or.inl rfl)
| _, or.inr (or.inr h) := or.inr (or.inr h)
end,
..partial_order_of_SO r }
/-- Construct a decidable linear order from a `is_strict_total_order'` relation -/
def decidable_linear_order_of_STO' (r) [is_strict_total_order' α r] [decidable_rel r] : decidable_linear_order α :=
by letI LO := linear_order_of_STO' r; exact
{ decidable_le := λ x y, decidable_of_iff (¬ r y x) (@not_lt _ _ y x),
..LO }
noncomputable def classical.DLO (α) [LO : linear_order α] : decidable_linear_order α :=
{ decidable_le := classical.dec_rel _, ..LO }
theorem is_strict_total_order'.swap (r) [is_strict_total_order' α r] : is_strict_total_order' α (swap r) :=
{..is_trichotomous.swap r, ..is_strict_order.swap r}
instance [linear_order α] : is_strict_total_order' α (<) := {}
/-- A connected order is one satisfying the condition `a < c → a < b ∨ b < c`.
This is recognizable as an intuitionistic substitute for `a ≤ b ∨ b ≤ a` on
the constructive reals, and is also known as negative transitivity,
since the contrapositive asserts transitivity of the relation `¬ a < b`. -/
@[algebra] class is_order_connected (α : Type u) (lt : α → α → Prop) : Prop :=
(conn : ∀ a b c, lt a c → lt a b ∨ lt b c)
theorem is_order_connected.neg_trans {r : α → α → Prop} [is_order_connected α r]
{a b c} (h₁ : ¬ r a b) (h₂ : ¬ r b c) : ¬ r a c :=
mt (is_order_connected.conn a b c) $ by simp [h₁, h₂]
theorem is_strict_weak_order_of_is_order_connected [is_asymm α r]
[is_order_connected α r] : is_strict_weak_order α r :=
{ trans := λ a b c h₁ h₂, (is_order_connected.conn _ c _ h₁).resolve_right (asymm h₂),
incomp_trans := λ a b c ⟨h₁, h₂⟩ ⟨h₃, h₄⟩,
⟨is_order_connected.neg_trans h₁ h₃, is_order_connected.neg_trans h₄ h₂⟩,
..@is_irrefl_of_is_asymm α r _ }
@[priority 100] -- see Note [lower instance priority]
instance is_order_connected_of_is_strict_total_order'
[is_strict_total_order' α r] : is_order_connected α r :=
⟨λ a b c h, (trichotomous _ _).imp_right (λ o,
o.elim (λ e, e ▸ h) (λ h', trans h' h))⟩
@[priority 100] -- see Note [lower instance priority]
instance is_strict_total_order_of_is_strict_total_order'
[is_strict_total_order' α r] : is_strict_total_order α r :=
{..is_strict_weak_order_of_is_order_connected}
instance [linear_order α] : is_strict_total_order α (<) := by apply_instance
instance [linear_order α] : is_order_connected α (<) := by apply_instance
instance [linear_order α] : is_incomp_trans α (<) := by apply_instance
instance [linear_order α] : is_strict_weak_order α (<) := by apply_instance
/-- An extensional relation is one in which an element is determined by its set
of predecessors. It is named for the `x ∈ y` relation in set theory, whose
extensionality is one of the first axioms of ZFC. -/
@[algebra] class is_extensional (α : Type u) (r : α → α → Prop) : Prop :=
(ext : ∀ a b, (∀ x, r x a ↔ r x b) → a = b)
@[priority 100] -- see Note [lower instance priority]
instance is_extensional_of_is_strict_total_order'
[is_strict_total_order' α r] : is_extensional α r :=
⟨λ a b H, ((@trichotomous _ r _ a b)
.resolve_left $ mt (H _).2 (irrefl a))
.resolve_right $ mt (H _).1 (irrefl b)⟩
section prio
set_option default_priority 100 -- see Note [default priority]
/-- A well order is a well-founded linear order. -/
@[algebra] class is_well_order (α : Type u) (r : α → α → Prop) extends is_strict_total_order' α r : Prop :=
(wf : well_founded r)
end prio
@[priority 100] -- see Note [lower instance priority]
instance is_well_order.is_strict_total_order {α} (r : α → α → Prop) [is_well_order α r] : is_strict_total_order α r := by apply_instance
@[priority 100] -- see Note [lower instance priority]
instance is_well_order.is_extensional {α} (r : α → α → Prop) [is_well_order α r] : is_extensional α r := by apply_instance
@[priority 100] -- see Note [lower instance priority]
instance is_well_order.is_trichotomous {α} (r : α → α → Prop) [is_well_order α r] : is_trichotomous α r := by apply_instance
@[priority 100] -- see Note [lower instance priority]
instance is_well_order.is_trans {α} (r : α → α → Prop) [is_well_order α r] : is_trans α r := by apply_instance
@[priority 100] -- see Note [lower instance priority]
instance is_well_order.is_irrefl {α} (r : α → α → Prop) [is_well_order α r] : is_irrefl α r := by apply_instance
@[priority 100] -- see Note [lower instance priority]
instance is_well_order.is_asymm {α} (r : α → α → Prop) [is_well_order α r] : is_asymm α r := by apply_instance
noncomputable def decidable_linear_order_of_is_well_order (r : α → α → Prop) [is_well_order α r] :
decidable_linear_order α :=
by { haveI := linear_order_of_STO' r, exact classical.DLO α }
instance empty_relation.is_well_order [subsingleton α] : is_well_order α empty_relation :=
{ trichotomous := λ a b, or.inr $ or.inl $ subsingleton.elim _ _,
irrefl := λ a, id,
trans := λ a b c, false.elim,
wf := ⟨λ a, ⟨_, λ y, false.elim⟩⟩ }
instance nat.lt.is_well_order : is_well_order ℕ (<) := ⟨nat.lt_wf⟩
instance sum.lex.is_well_order [is_well_order α r] [is_well_order β s] : is_well_order (α ⊕ β) (sum.lex r s) :=
{ trichotomous := λ a b, by cases a; cases b; simp; apply trichotomous,
irrefl := λ a, by cases a; simp; apply irrefl,
trans := λ a b c, by cases a; cases b; simp; cases c; simp; apply trans,
wf := sum.lex_wf (is_well_order.wf r) (is_well_order.wf s) }
instance prod.lex.is_well_order [is_well_order α r] [is_well_order β s] : is_well_order (α × β) (prod.lex r s) :=
{ trichotomous := λ ⟨a₁, a₂⟩ ⟨b₁, b₂⟩,
match @trichotomous _ r _ a₁ b₁ with
| or.inl h₁ := or.inl $ prod.lex.left _ _ _ h₁
| or.inr (or.inr h₁) := or.inr $ or.inr $ prod.lex.left _ _ _ h₁
| or.inr (or.inl e) := e ▸ match @trichotomous _ s _ a₂ b₂ with
| or.inl h := or.inl $ prod.lex.right _ _ h
| or.inr (or.inr h) := or.inr $ or.inr $ prod.lex.right _ _ h
| or.inr (or.inl e) := e ▸ or.inr $ or.inl rfl
end
end,
irrefl := λ ⟨a₁, a₂⟩ h, by cases h with _ _ _ _ h _ _ _ h;
[exact irrefl _ h, exact irrefl _ h],
trans := λ a b c h₁ h₂, begin
cases h₁ with a₁ a₂ b₁ b₂ ab a₁ b₁ b₂ ab;
cases h₂ with _ _ c₁ c₂ bc _ _ c₂ bc,
{ exact prod.lex.left _ _ _ (trans ab bc) },
{ exact prod.lex.left _ _ _ ab },
{ exact prod.lex.left _ _ _ bc },
{ exact prod.lex.right _ _ (trans ab bc) }
end,
wf := prod.lex_wf (is_well_order.wf r) (is_well_order.wf s) }
/-- An unbounded or cofinal set -/
def unbounded (r : α → α → Prop) (s : set α) : Prop := ∀ a, ∃ b ∈ s, ¬ r b a
/-- A bounded or final set -/
def bounded (r : α → α → Prop) (s : set α) : Prop := ∃a, ∀ b ∈ s, r b a
@[simp] lemma not_bounded_iff {r : α → α → Prop} (s : set α) : ¬bounded r s ↔ unbounded r s :=
begin
classical,
simp only [bounded, unbounded, not_forall, not_exists, exists_prop, not_and, not_not]
end
@[simp] lemma not_unbounded_iff {r : α → α → Prop} (s : set α) : ¬unbounded r s ↔ bounded r s :=
by { classical, rw [not_iff_comm, not_bounded_iff] }
namespace well_founded
/-- If `r` is a well founded relation, then any nonempty set has a minimum element
with respect to `r`. -/
theorem has_min {α} {r : α → α → Prop} (H : well_founded r)
(s : set α) : s.nonempty → ∃ a ∈ s, ∀ x ∈ s, ¬ r x a
| ⟨a, ha⟩ := (acc.rec_on (H.apply a) $ λ x _ IH, classical.not_imp_not.1 $ λ hne hx, hne $
⟨x, hx, λ y hy hyx, hne $ IH y hyx hy⟩) ha
/-- The minimum element of a nonempty set in a well-founded order -/
noncomputable def min {α} {r : α → α → Prop} (H : well_founded r)
(p : set α) (h : p.nonempty) : α :=
classical.some (H.has_min p h)
theorem min_mem {α} {r : α → α → Prop} (H : well_founded r)
(p : set α) (h : p.nonempty) : H.min p h ∈ p :=
let ⟨h, _⟩ := classical.some_spec (H.has_min p h) in h
theorem not_lt_min {α} {r : α → α → Prop} (H : well_founded r)
(p : set α) (h : p.nonempty) {x} (xp : x ∈ p) : ¬ r x (H.min p h) :=
let ⟨_, h'⟩ := classical.some_spec (H.has_min p h) in h' _ xp
open set
protected noncomputable def sup {α} {r : α → α → Prop} (wf : well_founded r) (s : set α)
(h : bounded r s) : α :=
wf.min { x | ∀a ∈ s, r a x } h
protected lemma lt_sup {α} {r : α → α → Prop} (wf : well_founded r) {s : set α} (h : bounded r s)
{x} (hx : x ∈ s) : r x (wf.sup s h) :=
min_mem wf { x | ∀a ∈ s, r a x } h x hx
section
open_locale classical
protected noncomputable def succ {α} {r : α → α → Prop} (wf : well_founded r) (x : α) : α :=
if h : ∃y, r x y then wf.min { y | r x y } h else x
protected lemma lt_succ {α} {r : α → α → Prop} (wf : well_founded r) {x : α} (h : ∃y, r x y) :
r x (wf.succ x) :=
by { rw [well_founded.succ, dif_pos h], apply min_mem }
end
protected lemma lt_succ_iff {α} {r : α → α → Prop} [wo : is_well_order α r] {x : α} (h : ∃y, r x y)
(y : α) : r y (wo.wf.succ x) ↔ r y x ∨ y = x :=
begin
split,
{ intro h', have : ¬r x y,
{ intro hy, rw [well_founded.succ, dif_pos] at h',
exact wo.wf.not_lt_min _ h hy h' },
rcases trichotomous_of r x y with hy | hy | hy,
exfalso, exact this hy,
right, exact hy.symm,
left, exact hy },
rintro (hy | rfl), exact trans hy (wo.wf.lt_succ h), exact wo.wf.lt_succ h
end
end well_founded
variable (r)
local infix ` ≼ ` : 50 := r
/-- A family of elements of α is directed (with respect to a relation `≼` on α)
if there is a member of the family `≼`-above any pair in the family. -/
def directed {ι : Sort v} (f : ι → α) := ∀x y, ∃z, f x ≼ f z ∧ f y ≼ f z
/-- A subset of α is directed if there is an element of the set `≼`-above any
pair of elements in the set. -/
def directed_on (s : set α) := ∀ (x ∈ s) (y ∈ s), ∃z ∈ s, x ≼ z ∧ y ≼ z
theorem directed_on_iff_directed {s} : @directed_on α r s ↔ directed r (coe : s → α) :=
by simp [directed, directed_on]; refine ball_congr (λ x hx, by simp; refl)
theorem directed_comp {ι} (f : ι → β) (g : β → α) :
directed r (g ∘ f) ↔ directed (g ⁻¹'o r) f := iff.rfl
theorem directed_mono {s : α → α → Prop} {ι} (f : ι → α)
(H : ∀ a b, r a b → s a b) (h : directed r f) : directed s f :=
λ a b, let ⟨c, h₁, h₂⟩ := h a b in ⟨c, H _ _ h₁, H _ _ h₂⟩
theorem directed.mono_comp {ι} {rb : β → β → Prop} {g : α → β} {f : ι → α}
(hg : ∀ ⦃x y⦄, x ≼ y → rb (g x) (g y)) (hf : directed r f) :
directed rb (g ∘ f) :=
(directed_comp rb f g).2 $ directed_mono _ _ hg hf
section prio
set_option default_priority 100 -- see Note [default priority]
class directed_order (α : Type u) extends preorder α :=
(directed : ∀ i j : α, ∃ k, i ≤ k ∧ j ≤ k)
end prio
|
0ab70bc6c91a624e8469e989953bfcc1885e5f1c | 8f209eb34c0c4b9b6be5e518ebfc767a38bed79c | /code/src/internal/utils.lean | 69204a97e1b5be2323ae25d8e6dea0ccab61bdb9 | [] | no_license | hediet/masters-thesis | 13e3bcacb6227f25f7ec4691fb78cb0363f2dfb5 | dc40c14cc4ed073673615412f36b4e386ee7aac9 | refs/heads/master | 1,680,591,056,302 | 1,617,710,887,000 | 1,617,710,887,000 | 311,762,038 | 4 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 4,203 | lean | import tactic
import data.finset
lemma subset_right_union { α: Type } [decidable_eq α] { u v w: finset α } (h: u ⊆ v): u ⊆ v ∪ w :=
begin
have : ∅ ⊆ w := by simp,
have := finset.union_subset_union h this,
finish [this],
end
lemma subset_left_union { α: Type } [decidable_eq α] { u v w: finset α } (h: u ⊆ w): u ⊆ v ∪ w :=
begin
have : ∅ ⊆ v := by simp,
have := finset.union_subset_union this h,
finish [this],
end
lemma subset_union_right_subset { α: Type } [decidable_eq α] { u v w: finset α } (h: u ∪ v ⊆ w): u ⊆ w :=
begin
rw finset.subset_iff,
assume x,
rw finset.subset_iff at h,
assume h',
simp [h', h],
end
lemma subset_inter_subset { α: Type } [decidable_eq α] { s1 s2 s3: finset α }: s1 ⊆ s3 → s1 ∩ s2 ⊆ s3 :=
begin
refine finset.subset.trans _,
exact finset.inter_subset_left s1 s2,
end
lemma subset_inter_subset_subset { α: Type } [decidable_eq α] { s1 s2 s3: finset α } (h: s1 ⊆ s2): s1 ∩ s2 ⊆ s3 ↔ s1 ⊆ s3 :=
begin
split, {
refine finset.subset.trans _,
refine finset.subset_inter _ h,
exact finset.subset.refl s1,
}, {
exact subset_inter_subset,
},
end
lemma not_subset { α: Type } { u v: finset α }: ¬ u ⊆ v ↔ ∃ x ∈ u, ¬ x ∈ v :=
begin
exact not_ball
end
lemma list_to_finset_disjoint_iff_list_disjoint { α: Type } [decidable_eq α] (list1 list2: list α ): disjoint list1.to_finset list2.to_finset ↔ list1.disjoint list2 :=
begin
rw list.disjoint,
rw finset.disjoint_iff_inter_eq_empty,
rw finset.ext_iff,
split; {
assume h a,
specialize @h a,
finish,
},
end
lemma disjoint_set_union_eq_union_iff_right { α: Type } [decidable_eq α] (a: finset α) { b c: finset α } (h1: disjoint a b) (h2: disjoint a c): a ∪ b = a ∪ c ↔ b = c :=
begin
split, {
assume x,
rw finset.ext_iff,
assume e,
rw finset.ext_iff at x,
specialize x e,
rw finset.disjoint_iff_inter_eq_empty at h1,
rw finset.ext_iff at h1,
specialize h1 e,
rw finset.disjoint_iff_inter_eq_empty at h2,
rw finset.ext_iff at h2,
specialize h2 e,
simp * at *,
finish,
}, {
assume x,
simp [x],
}
end
lemma disjoint_set_union_eq_union_iff_left { α: Type } [decidable_eq α] (a: finset α) { b c: finset α } (h1: disjoint b a) (h2: disjoint c a): b ∪ a = c ∪ a ↔ b = c :=
begin
have := disjoint_set_union_eq_union_iff_right a (disjoint.comm.1 h1) (disjoint.comm.1 h2),
simp only [this, finset.union_comm],
end
lemma disjoint_sets { α: Type } [decidable_eq α] { a₁ a₂ b₁ b₂: finset α } (h: disjoint b₁ b₂) (h₁: a₁ ⊆ b₁) (h₂: a₂ ⊆ b₂):
(b₁ ∪ b₂) \ (a₁ ∪ a₂) = (b₁ \ a₁) ∪ (b₂ \ a₂) :=
begin
rw finset.subset_iff at h₁,
rw finset.subset_iff at h₂,
rw finset.ext_iff,
assume a,
specialize @h₁ a,
specialize @h₂ a,
rw finset.disjoint_iff_inter_eq_empty at h,
rw finset.ext_iff at h,
specialize @h a,
finish,
end
@[simp]
lemma list_to_finset_append { α: Type } [decidable_eq α] { l1: list α } { l2: list α }:
(l1 ++ l2).to_finset = l1.to_finset ∪ l2.to_finset :=
begin
induction l1;
finish,
end
@[simp]
lemma list_to_finset_subset_empty_set { α: Type } [decidable_eq α] { l: list α }: l.to_finset ⊆ ∅ ↔ l = list.nil :=
begin
split; assume h, {
cases l;
finish [finset.subset_empty, finset.insert_ne_empty],
}, { simp [h], }
end
@[simp]
lemma list_coe_to_finset_eq_list_to_finset { α: Type } [decidable_eq α] (list: list α): (list: multiset α).to_finset = list.to_finset :=
begin
rw finset.ext_iff,
assume a,
simp,
end
lemma list_to_finset_eq_of_perm { α: Type } [decidable_eq α] { list1 list2: list α } (h: list1 ~ list2):
list1.to_finset = list2.to_finset :=
begin
have : (list1: multiset α).to_finset = (list2: multiset α).to_finset :=
by simp [multiset.coe_eq_coe.2 h],
revert this,
simp only [list_coe_to_finset_eq_list_to_finset, imp_self],
end
|
f887aa615ca1a7bb8251d0a458759e776ae66e1e | 92c6b42948d74fe325c2d88530f1d36da388b2f7 | /src/cvc4/tactic.lean | 45200da822a19df0e2c965a655d8a255fb1925dd | [
"MIT"
] | permissive | riaqn/smtlean | 8ad65055b6c1600cd03b9e345059a3b24419b6d5 | c11768cfb43cd634340b552f5039cba094701a87 | refs/heads/master | 1,584,569,627,940 | 1,535,314,713,000 | 1,535,314,713,000 | 135,333,334 | 0 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 2,937 | lean | import ..smtlib
import .solve
import .reflect
meta def prop_to_formula : expr → tactic term := λ t, match t with
| `(%%(t0) → %%(t1)) := term.app "=>" <$> monad.sequence [prop_to_formula t0, prop_to_formula t1]
| `(%%(t0) ∧ %%(t1)) := term.app "and" <$> monad.sequence [prop_to_formula t0, prop_to_formula t1]
| `(%%(t0) ∨ %%(t1)) := term.app "or" <$> monad.sequence [prop_to_formula t0, prop_to_formula t1]
| `(¬ %%(t')) := term.app "not" <$> monad.sequence [prop_to_formula t']
| `(coe_sort %%(t')) := prop_to_formula t'
| `(false) := return $ term.symbol "false"
| `(true) := return $ term.symbol "true"
| expr.local_const n m bi ty := return $ term.symbol m.to_string
| _ := tactic.fail ("unrecognized prop", t)
end
meta def target_to_query : expr → tactic query := λ t, match t with
| expr.pi n bi ty t' := do sr ← match ty with
| `(bool) := return $ option.some "Bool"
| _ := do return $ option.none
end,
match sr with
| option.some sr := do _ ← tactic.intro n,
v ← tactic.mk_local' n bi ty,
let t' := t'.instantiate_var v,
k ← target_to_query t',
return $ query.mk ((declare.mk n.to_string sr) :: k.declares) k.asserts
| option.none := do k ← prop_to_formula t,
return $ query.mk [] [term.app "not" [k]]
end
| _ := do k ← prop_to_formula t,
return $ query.mk [] [term.app "not" [k]]
end
meta def prove : tactic unit :=
do tg ← tactic.target,
q ← target_to_query tg,
r ← tactic.unsafe_run_io $ solve q,
env ← tactic.get_env,
match r with
| except.error e := tactic.fail e
| except.ok (except.ok model) := tactic.fail $ to_string model
| except.ok (except.error proof) := match reflect.ref_check (reflect.config.mk env) proof with
| except.error e := tactic.fail e
| except.ok (t, _) := do
tactic.to_expr ``(classical.by_contradiction) >>= tactic.apply,
tactic.to_expr t >>= tactic.apply,
tactic.repeat $ (do _ ← tactic.apply `(true.intro), return ())
end
end
def test1 : ∀ (a b c d : bool), (a ∧ b ∧ c) → (a → b ∨ b ∧ c) := by do prove
def test2 : ∀ (a b : bool), a → b → a ∧ b := by do prove
def test3 : ∀ (a b : bool), a → a ∨ b := by do prove
def test4 : ∀ (a b: bool), ¬ (a ∧ ¬ b ∧ (a → b)) := by do prove
def test5 : ∀ a : bool, ¬ (a ∧ ¬ a) := by do prove
|
cf98231cbb19ff3fb91c87188ca1980f56f19dbf | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/tactic/apply_fun.lean | 5df0cc10a3a27c37a4f85482b5f33c3b0dceb22d | [
"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,184 | lean | /-
Copyright (c) 2019 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Keeley Hoek, Patrick Massot
-/
import tactic.monotonicity
namespace tactic
/-- Apply the function `f` given by `e : pexpr` to the local hypothesis `hyp`, which must either be
of the form `a = b` or `a ≤ b`, replacing the type of `hyp` with `f a = f b` or `f a ≤ f b`. If
`hyp` names an inequality then a new goal `monotone f` is created, unless the name of a proof of
this fact is passed as the optional argument `mono_lem`, or the `mono` tactic can prove it.
-/
meta def apply_fun_to_hyp (e : pexpr) (mono_lem : option pexpr) (hyp : expr) : tactic unit :=
do
{ t ← infer_type hyp >>= instantiate_mvars,
prf ← match t with
| `(%%l = %%r) := do
ltp ← infer_type l,
mv ← mk_mvar,
to_expr ``(congr_arg (%%e : %%ltp → %%mv) %%hyp)
| `(%%l ≤ %%r) := do
Hmono ← match mono_lem with
| some mono_lem :=
tactic.i_to_expr mono_lem
| none := do
n ← get_unused_name `mono,
to_expr ``(monotone %%e) >>= assert n,
-- In order to resolve implicit arguments in `%%e`,
-- we build (and discard) the expression `%%n %%hyp` before calling the `mono` tactic.
swap,
n ← get_local n,
to_expr ``(%%n %%hyp),
swap,
do { intro_lst [`x, `y, `h], `[try { dsimp }, mono] } <|> swap,
return n
end,
to_expr ``(%%Hmono %%hyp)
| _ := fail!"failed to apply {e} at {hyp}"
end,
clear hyp,
hyp ← note hyp.local_pp_name none prf,
-- let's try to force β-reduction at `h`
try $ tactic.dsimp_hyp hyp simp_lemmas.mk [] { eta := false, beta := true } }
/--
Attempt to "apply" a function `f` represented by the argument `e : pexpr` to the goal.
If the goal is of the form `a ≠ b`, we obtain the new goal `f a ≠ f b`.
If the goal is of the form `a = b`, we obtain a new goal `f a = f b`, and a subsidiary goal
`injective f`.
(We attempt to discharge this subsidiary goal automatically, or using the optional argument.)
If the goal is of the form `a ≤ b` (or similarly for `a < b`), and `f` is an `order_iso`,
we obtain a new goal `f a ≤ f b`.
-/
meta def apply_fun_to_goal (e : pexpr) (lem : option pexpr) : tactic unit :=
do t ← target,
match t with
| `(%%l ≠ %%r) := to_expr ``(ne_of_apply_ne %%e) >>= apply >> skip
| `(¬%%l = %%r) := to_expr ``(ne_of_apply_ne %%e) >>= apply >> skip
| `(%%l ≤ %%r) := to_expr ``((order_iso.le_iff_le %%e).mp) >>= apply >> skip
| `(%%l < %%r) := to_expr ``((order_iso.lt_iff_lt %%e).mp) >>= apply >> skip
| `(%%l = %%r) := focus1 (do
to_expr ``(%%e %%l), -- build and discard an application, to fill in implicit arguments
n ← get_unused_name `inj,
to_expr ``(function.injective %%e) >>= assert n,
-- Attempt to discharge the `injective f` goal
(focus1 $
assumption <|>
(to_expr ``(equiv.injective) >>= apply >> done) <|>
-- We require that applying the lemma closes the goal, not just makes progress:
(lem.mmap (λ l, to_expr l >>= apply) >> done))
<|> swap, -- return to the main goal if we couldn't discharge `injective f`.
n ← get_local n,
apply n,
clear n)
| _ := fail!"failed to apply {e} to the goal"
end
namespace interactive
setup_tactic_parser
/--
Apply a function to an equality or inequality in either a local hypothesis or the goal.
* If we have `h : a = b`, then `apply_fun f at h` will replace this with `h : f a = f b`.
* If we have `h : a ≤ b`, then `apply_fun f at h` will replace this with `h : f a ≤ f b`,
and create a subsidiary goal `monotone f`.
`apply_fun` will automatically attempt to discharge this subsidiary goal using `mono`,
or an explicit solution can be provided with `apply_fun f at h using P`, where `P : monotone f`.
* If the goal is `a ≠ b`, `apply_fun f` will replace this with `f a ≠ f b`.
* If the goal is `a = b`, `apply_fun f` will replace this with `f a = f b`,
and create a subsidiary goal `injective f`.
`apply_fun` will automatically attempt to discharge this subsidiary goal using local hypotheses,
or if `f` is actually an `equiv`,
or an explicit solution can be provided with `apply_fun f using P`, where `P : injective f`.
* If the goal is `a ≤ b` (or similarly for `a < b`), and `f` is actually an `order_iso`,
`apply_fun f` will replace the goal with `f a ≤ f b`.
If `f` is anything else (e.g. just a function, or an `equiv`), `apply_fun` will fail.
Typical usage is:
```lean
open function
example (X Y Z : Type) (f : X → Y) (g : Y → Z) (H : injective $ g ∘ f) :
injective f :=
begin
intros x x' h,
apply_fun g at h,
exact H h
end
```
-/
meta def apply_fun (q : parse texpr) (locs : parse location) (lem : parse (tk "using" *> texpr)?)
: tactic unit :=
locs.apply (apply_fun_to_hyp q lem) (apply_fun_to_goal q lem)
add_tactic_doc
{ name := "apply_fun",
category := doc_category.tactic,
decl_names := [`tactic.interactive.apply_fun],
tags := ["context management"] }
end interactive
end tactic
|
842b16097b665a811139b088e55711c3dc86d14f | d1a52c3f208fa42c41df8278c3d280f075eb020c | /src/Lean/Data/Lsp/Ipc.lean | 570918d48f37bc2baab9959035e7316e416b9354 | [
"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 | 2,665 | 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 Lean.Data.Json
import Lean.Data.Lsp.Communication
import Lean.Data.Lsp.Diagnostics
import Lean.Data.Lsp.Extra
/-! Provides an IpcM monad for interacting with an external LSP process.
Used for testing the Lean server. -/
namespace Lean.Lsp.Ipc
open IO
open JsonRpc
def ipcStdioConfig : Process.StdioConfig where
stdin := Process.Stdio.piped
stdout := Process.Stdio.piped
stderr := Process.Stdio.inherit
abbrev IpcM := ReaderT (Process.Child ipcStdioConfig) IO
variable [ToJson α]
def stdin : IpcM FS.Stream := do
FS.Stream.ofHandle (←read).stdin
def stdout : IpcM FS.Stream := do
FS.Stream.ofHandle (←read).stdout
def writeRequest (r : Request α) : IpcM Unit := do
(←stdin).writeLspRequest r
def writeNotification (n : Notification α) : IpcM Unit := do
(←stdin).writeLspNotification n
def readMessage : IpcM JsonRpc.Message := do
(←stdout).readLspMessage
def readResponseAs (expectedID : RequestID) (α) [FromJson α] : IpcM (Response α) := do
(←stdout).readLspResponseAs expectedID α
def waitForExit : IpcM UInt32 := do
(←read).wait
/-- Waits for the worker to emit all diagnostics for the current document version
and returns them as a list. -/
partial def collectDiagnostics (waitForDiagnosticsId : RequestID := 0) (target : DocumentUri) (version : Nat)
: IpcM (List (Notification PublishDiagnosticsParams)) := do
writeRequest ⟨waitForDiagnosticsId, "textDocument/waitForDiagnostics", WaitForDiagnosticsParams.mk target version⟩
let rec loop : IpcM (List (Notification PublishDiagnosticsParams)) := do
match (←readMessage) with
| Message.response id _ =>
if id == waitForDiagnosticsId then []
else loop
| Message.responseError id code msg _ =>
if id == waitForDiagnosticsId then
throw $ userError s!"Waiting for diagnostics failed: {msg}"
else loop
| Message.notification "textDocument/publishDiagnostics" (some param) =>
match fromJson? (toJson param) with
| Except.ok diagnosticParam => ⟨"textDocument/publishDiagnostics", diagnosticParam⟩ :: (←loop)
| Except.error inner => throw $ userError s!"Cannot decode publishDiagnostics parameters\n{inner}"
| _ => loop
loop
def runWith (lean : System.FilePath) (args : Array String := #[]) (test : IpcM α) : IO α := do
let proc ← Process.spawn {
toStdioConfig := ipcStdioConfig
cmd := lean.toString
args := args }
ReaderT.run test proc
end Lean.Lsp.Ipc
|
24d9d11a89451b5ec63469db08c04fa220f6e39f | 4727251e0cd73359b15b664c3170e5d754078599 | /src/data/real/hyperreal.lean | 019101769669abbfdde974ae725f4a7ef41c08e8 | [
"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 | 36,908 | lean | /-
Copyright (c) 2019 Abhimanyu Pallavi Sudhir. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Abhimanyu Pallavi Sudhir
-/
import order.filter.filter_product
import analysis.specific_limits.basic
/-!
# Construction of the hyperreal numbers as an ultraproduct of real sequences.
-/
open filter filter.germ
open_locale topological_space classical
/-- Hyperreal numbers on the ultrafilter extending the cofinite filter -/
@[derive [linear_ordered_field, inhabited]]
def hyperreal : Type := germ (hyperfilter ℕ : filter ℕ) ℝ
namespace hyperreal
notation `ℝ*` := hyperreal
noncomputable instance : has_coe_t ℝ ℝ* := ⟨λ x, (↑x : germ _ _)⟩
@[simp, norm_cast]
lemma coe_eq_coe {x y : ℝ} : (x : ℝ*) = y ↔ x = y :=
germ.const_inj
@[simp, norm_cast] lemma coe_eq_zero {x : ℝ} : (x : ℝ*) = 0 ↔ x = 0 := coe_eq_coe
@[simp, norm_cast] lemma coe_eq_one {x : ℝ} : (x : ℝ*) = 1 ↔ x = 1 := coe_eq_coe
@[simp, norm_cast] lemma coe_one : ↑(1 : ℝ) = (1 : ℝ*) := rfl
@[simp, norm_cast] lemma coe_zero : ↑(0 : ℝ) = (0 : ℝ*) := rfl
@[simp, norm_cast] lemma coe_inv (x : ℝ) : ↑(x⁻¹) = (x⁻¹ : ℝ*) := rfl
@[simp, norm_cast] lemma coe_neg (x : ℝ) : ↑(-x) = (-x : ℝ*) := rfl
@[simp, norm_cast] lemma coe_add (x y : ℝ) : ↑(x + y) = (x + y : ℝ*) := rfl
@[simp, norm_cast] lemma coe_bit0 (x : ℝ) : ↑(bit0 x) = (bit0 x : ℝ*) := rfl
@[simp, norm_cast] lemma coe_bit1 (x : ℝ) : ↑(bit1 x) = (bit1 x : ℝ*) := rfl
@[simp, norm_cast] lemma coe_mul (x y : ℝ) : ↑(x * y) = (x * y : ℝ*) := rfl
@[simp, norm_cast] lemma coe_div (x y : ℝ) : ↑(x / y) = (x / y : ℝ*) := rfl
@[simp, norm_cast] lemma coe_sub (x y : ℝ) : ↑(x - y) = (x - y : ℝ*) := rfl
@[simp, norm_cast] lemma coe_lt_coe {x y : ℝ} : (x : ℝ*) < y ↔ x < y := germ.const_lt
@[simp, norm_cast] lemma coe_pos {x : ℝ} : 0 < (x : ℝ*) ↔ 0 < x :=
coe_lt_coe
@[simp, norm_cast] lemma coe_le_coe {x y : ℝ} : (x : ℝ*) ≤ y ↔ x ≤ y := germ.const_le_iff
@[simp, norm_cast] lemma coe_abs (x : ℝ) : ((|x| : ℝ) : ℝ*) = |x| :=
begin
convert const_abs x,
apply linear_order.to_lattice_eq_filter_germ_lattice,
end
@[simp, norm_cast] lemma coe_max (x y : ℝ) : ((max x y : ℝ) : ℝ*) = max x y := germ.const_max _ _
@[simp, norm_cast] lemma coe_min (x y : ℝ) : ((min x y : ℝ) : ℝ*) = min x y := germ.const_min _ _
/-- Construct a hyperreal number from a sequence of real numbers. -/
noncomputable def of_seq (f : ℕ → ℝ) : ℝ* := (↑f : germ (hyperfilter ℕ : filter ℕ) ℝ)
/-- A sample infinitesimal hyperreal-/
noncomputable def epsilon : ℝ* := of_seq $ λ n, n⁻¹
/-- A sample infinite hyperreal-/
noncomputable def omega : ℝ* := of_seq coe
localized "notation `ε` := hyperreal.epsilon" in hyperreal
localized "notation `ω` := hyperreal.omega" in hyperreal
lemma epsilon_eq_inv_omega : ε = ω⁻¹ := rfl
lemma inv_epsilon_eq_omega : ε⁻¹ = ω := @inv_inv _ _ ω
lemma epsilon_pos : 0 < ε :=
suffices ∀ᶠ i in hyperfilter ℕ, (0 : ℝ) < (i : ℕ)⁻¹, by rwa lt_def,
have h0' : {n : ℕ | ¬ 0 < n} = {0} :=
by simp only [not_lt, (set.set_of_eq_eq_singleton).symm]; ext; exact nat.le_zero_iff,
begin
simp only [inv_pos, nat.cast_pos],
exact mem_hyperfilter_of_finite_compl (by convert set.finite_singleton _),
end
lemma epsilon_ne_zero : ε ≠ 0 := ne_of_gt epsilon_pos
lemma omega_pos : 0 < ω := by rw ←inv_epsilon_eq_omega; exact inv_pos.2 epsilon_pos
lemma omega_ne_zero : ω ≠ 0 := ne_of_gt omega_pos
theorem epsilon_mul_omega : ε * ω = 1 := @inv_mul_cancel _ _ ω omega_ne_zero
lemma lt_of_tendsto_zero_of_pos {f : ℕ → ℝ} (hf : tendsto f at_top (𝓝 0)) :
∀ {r : ℝ}, 0 < r → of_seq f < (r : ℝ*) :=
begin
simp only [metric.tendsto_at_top, real.dist_eq, sub_zero, lt_def] at hf ⊢,
intros r hr, cases hf r hr with N hf',
have hs : {i : ℕ | f i < r}ᶜ ⊆ {i : ℕ | i ≤ N} :=
λ i hi1, le_of_lt (by simp only [lt_iff_not_ge];
exact λ hi2, hi1 (lt_of_le_of_lt (le_abs_self _) (hf' i hi2)) : i < N),
exact mem_hyperfilter_of_finite_compl
((set.finite_le_nat N).subset hs)
end
lemma neg_lt_of_tendsto_zero_of_pos {f : ℕ → ℝ} (hf : tendsto f at_top (𝓝 0)) :
∀ {r : ℝ}, 0 < r → (-r : ℝ*) < of_seq f :=
λ r hr, have hg : _ := hf.neg,
neg_lt_of_neg_lt (by rw [neg_zero] at hg; exact lt_of_tendsto_zero_of_pos hg hr)
lemma gt_of_tendsto_zero_of_neg {f : ℕ → ℝ} (hf : tendsto f at_top (𝓝 0)) :
∀ {r : ℝ}, r < 0 → (r : ℝ*) < of_seq f :=
λ r hr, by rw [←neg_neg r, coe_neg];
exact neg_lt_of_tendsto_zero_of_pos hf (neg_pos.mpr hr)
lemma epsilon_lt_pos (x : ℝ) : 0 < x → ε < x :=
lt_of_tendsto_zero_of_pos tendsto_inverse_at_top_nhds_0_nat
/-- Standard part predicate -/
def is_st (x : ℝ*) (r : ℝ) := ∀ δ : ℝ, 0 < δ → (r - δ : ℝ*) < x ∧ x < r + δ
/-- Standard part function: like a "round" to ℝ instead of ℤ -/
noncomputable def st : ℝ* → ℝ :=
λ x, if h : ∃ r, is_st x r then classical.some h else 0
/-- A hyperreal number is infinitesimal if its standard part is 0 -/
def infinitesimal (x : ℝ*) := is_st x 0
/-- A hyperreal number is positive infinite if it is larger than all real numbers -/
def infinite_pos (x : ℝ*) := ∀ r : ℝ, ↑r < x
/-- A hyperreal number is negative infinite if it is smaller than all real numbers -/
def infinite_neg (x : ℝ*) := ∀ r : ℝ, x < r
/-- A hyperreal number is infinite if it is infinite positive or infinite negative -/
def infinite (x : ℝ*) := infinite_pos x ∨ infinite_neg x
/-!
### Some facts about `st`
-/
private lemma is_st_unique' (x : ℝ*) (r s : ℝ) (hr : is_st x r) (hs : is_st x s) (hrs : r < s) :
false :=
have hrs' : _ := half_pos $ sub_pos_of_lt hrs,
have hr' : _ := (hr _ hrs').2,
have hs' : _ := (hs _ hrs').1,
have h : s - ((s - r) / 2) = r + (s - r) / 2 := by linarith,
begin
norm_cast at *,
rw h at hs',
exact not_lt_of_lt hs' hr'
end
theorem is_st_unique {x : ℝ*} {r s : ℝ} (hr : is_st x r) (hs : is_st x s) : r = s :=
begin
rcases lt_trichotomy r s with h | h | h,
{ exact false.elim (is_st_unique' x r s hr hs h) },
{ exact h },
{ exact false.elim (is_st_unique' x s r hs hr h) }
end
theorem not_infinite_of_exists_st {x : ℝ*} : (∃ r : ℝ, is_st x r) → ¬ infinite x :=
λ he hi, Exists.dcases_on he $ λ r hr, hi.elim
(λ hip, not_lt_of_lt (hr 2 zero_lt_two).2 (hip $ r + 2))
(λ hin, not_lt_of_lt (hr 2 zero_lt_two).1 (hin $ r - 2))
theorem is_st_Sup {x : ℝ*} (hni : ¬ infinite x) : is_st x (Sup {y : ℝ | (y : ℝ*) < x}) :=
let S : set ℝ := {y : ℝ | (y : ℝ*) < x} in
let R : _ := Sup S in
have hnile : _ := not_forall.mp (not_or_distrib.mp hni).1,
have hnige : _ := not_forall.mp (not_or_distrib.mp hni).2,
Exists.dcases_on hnile $ Exists.dcases_on hnige $ λ r₁ hr₁ r₂ hr₂,
have HR₁ : S.nonempty :=
⟨r₁ - 1, lt_of_lt_of_le (coe_lt_coe.2 $ sub_one_lt _) (not_lt.mp hr₁) ⟩,
have HR₂ : bdd_above S :=
⟨ r₂, λ y hy, le_of_lt (coe_lt_coe.1 (lt_of_lt_of_le hy (not_lt.mp hr₂))) ⟩,
λ δ hδ,
⟨ lt_of_not_le $ λ c,
have hc : ∀ y ∈ S, y ≤ R - δ := λ y hy, coe_le_coe.1 $ le_of_lt $ lt_of_lt_of_le hy c,
not_lt_of_le (cSup_le HR₁ hc) $ sub_lt_self R hδ,
lt_of_not_le $ λ c,
have hc : ↑(R + δ / 2) < x :=
lt_of_lt_of_le (add_lt_add_left (coe_lt_coe.2 (half_lt_self hδ)) R) c,
not_lt_of_le (le_cSup HR₂ hc) $ (lt_add_iff_pos_right _).mpr $ half_pos hδ⟩
theorem exists_st_of_not_infinite {x : ℝ*} (hni : ¬ infinite x) : ∃ r : ℝ, is_st x r :=
⟨Sup {y : ℝ | (y : ℝ*) < x}, is_st_Sup hni⟩
theorem st_eq_Sup {x : ℝ*} : st x = Sup {y : ℝ | (y : ℝ*) < x} :=
begin
unfold st, split_ifs,
{ exact is_st_unique (classical.some_spec h) (is_st_Sup (not_infinite_of_exists_st h)) },
{ cases not_imp_comm.mp exists_st_of_not_infinite h with H H,
{ rw (set.ext (λ i, ⟨λ hi, set.mem_univ i, λ hi, H i⟩) : {y : ℝ | (y : ℝ*) < x} = set.univ),
exact real.Sup_univ.symm },
{ rw (set.ext (λ i, ⟨λ hi, false.elim (not_lt_of_lt (H i) hi),
λ hi, false.elim (set.not_mem_empty i hi)⟩) : {y : ℝ | (y : ℝ*) < x} = ∅),
exact real.Sup_empty.symm } }
end
theorem exists_st_iff_not_infinite {x : ℝ*} : (∃ r : ℝ, is_st x r) ↔ ¬ infinite x :=
⟨ not_infinite_of_exists_st, exists_st_of_not_infinite ⟩
theorem infinite_iff_not_exists_st {x : ℝ*} : infinite x ↔ ¬ ∃ r : ℝ, is_st x r :=
iff_not_comm.mp exists_st_iff_not_infinite
theorem st_infinite {x : ℝ*} (hi : infinite x) : st x = 0 :=
begin
unfold st, split_ifs,
{ exact false.elim ((infinite_iff_not_exists_st.mp hi) h) },
{ refl }
end
lemma st_of_is_st {x : ℝ*} {r : ℝ} (hxr : is_st x r) : st x = r :=
begin
unfold st, split_ifs,
{ exact is_st_unique (classical.some_spec h) hxr },
{ exact false.elim (h ⟨r, hxr⟩) }
end
lemma is_st_st_of_is_st {x : ℝ*} {r : ℝ} (hxr : is_st x r) : is_st x (st x) :=
by rwa [st_of_is_st hxr]
lemma is_st_st_of_exists_st {x : ℝ*} (hx : ∃ r : ℝ, is_st x r) : is_st x (st x) :=
Exists.dcases_on hx (λ r, is_st_st_of_is_st)
lemma is_st_st {x : ℝ*} (hx : st x ≠ 0) : is_st x (st x) :=
begin
unfold st, split_ifs,
{ exact classical.some_spec h },
{ exact false.elim (hx (by unfold st; split_ifs; refl)) }
end
lemma is_st_st' {x : ℝ*} (hx : ¬ infinite x) : is_st x (st x) :=
is_st_st_of_exists_st $ exists_st_of_not_infinite hx
lemma is_st_refl_real (r : ℝ) : is_st r r :=
λ δ hδ, ⟨ sub_lt_self _ (coe_lt_coe.2 hδ), (lt_add_of_pos_right _ (coe_lt_coe.2 hδ)) ⟩
lemma st_id_real (r : ℝ) : st r = r := st_of_is_st (is_st_refl_real r)
lemma eq_of_is_st_real {r s : ℝ} : is_st r s → r = s := is_st_unique (is_st_refl_real r)
lemma is_st_real_iff_eq {r s : ℝ} : is_st r s ↔ r = s :=
⟨eq_of_is_st_real, λ hrs, by rw [hrs]; exact is_st_refl_real s⟩
lemma is_st_symm_real {r s : ℝ} : is_st r s ↔ is_st s r :=
by rw [is_st_real_iff_eq, is_st_real_iff_eq, eq_comm]
lemma is_st_trans_real {r s t : ℝ} : is_st r s → is_st s t → is_st r t :=
by rw [is_st_real_iff_eq, is_st_real_iff_eq, is_st_real_iff_eq]; exact eq.trans
lemma is_st_inj_real {r₁ r₂ s : ℝ} (h1 : is_st r₁ s) (h2 : is_st r₂ s) : r₁ = r₂ :=
eq.trans (eq_of_is_st_real h1) (eq_of_is_st_real h2).symm
lemma is_st_iff_abs_sub_lt_delta {x : ℝ*} {r : ℝ} :
is_st x r ↔ ∀ (δ : ℝ), 0 < δ → |x - r| < δ :=
by simp only [abs_sub_lt_iff, sub_lt_iff_lt_add, is_st, and_comm, add_comm]
lemma is_st_add {x y : ℝ*} {r s : ℝ} : is_st x r → is_st y s → is_st (x + y) (r + s) :=
λ hxr hys d hd,
have hxr' : _ := hxr (d / 2) (half_pos hd),
have hys' : _ := hys (d / 2) (half_pos hd),
⟨by convert add_lt_add hxr'.1 hys'.1 using 1; norm_cast; linarith,
by convert add_lt_add hxr'.2 hys'.2 using 1; norm_cast; linarith⟩
lemma is_st_neg {x : ℝ*} {r : ℝ} (hxr : is_st x r) : is_st (-x) (-r) :=
λ d hd, show -(r : ℝ*) - d < -x ∧ -x < -r + d, by cases (hxr d hd); split; linarith
lemma is_st_sub {x y : ℝ*} {r s : ℝ} : is_st x r → is_st y s → is_st (x - y) (r - s) :=
λ hxr hys, by rw [sub_eq_add_neg, sub_eq_add_neg]; exact is_st_add hxr (is_st_neg hys)
/- (st x < st y) → (x < y) → (x ≤ y) → (st x ≤ st y) -/
lemma lt_of_is_st_lt {x y : ℝ*} {r s : ℝ} (hxr : is_st x r) (hys : is_st y s) :
r < s → x < y :=
λ hrs, have hrs' : 0 < (s - r) / 2 := half_pos (sub_pos.mpr hrs),
have hxr' : _ := (hxr _ hrs').2, have hys' : _ := (hys _ hrs').1,
have H1 : r + ((s - r) / 2) = (r + s) / 2 := by linarith,
have H2 : s - ((s - r) / 2) = (r + s) / 2 := by linarith,
begin
norm_cast at *,
rw H1 at hxr',
rw H2 at hys',
exact lt_trans hxr' hys'
end
lemma is_st_le_of_le {x y : ℝ*} {r s : ℝ} (hrx : is_st x r) (hsy : is_st y s) :
x ≤ y → r ≤ s := by rw [←not_lt, ←not_lt, not_imp_not]; exact lt_of_is_st_lt hsy hrx
lemma st_le_of_le {x y : ℝ*} (hix : ¬ infinite x) (hiy : ¬ infinite y) :
x ≤ y → st x ≤ st y :=
have hx' : _ := is_st_st' hix, have hy' : _ := is_st_st' hiy,
is_st_le_of_le hx' hy'
lemma lt_of_st_lt {x y : ℝ*} (hix : ¬ infinite x) (hiy : ¬ infinite y) :
st x < st y → x < y :=
have hx' : _ := is_st_st' hix, have hy' : _ := is_st_st' hiy,
lt_of_is_st_lt hx' hy'
/-!
### Basic lemmas about infinite
-/
lemma infinite_pos_def {x : ℝ*} : infinite_pos x ↔ ∀ r : ℝ, ↑r < x := by rw iff_eq_eq; refl
lemma infinite_neg_def {x : ℝ*} : infinite_neg x ↔ ∀ r : ℝ, x < r := by rw iff_eq_eq; refl
lemma ne_zero_of_infinite {x : ℝ*} : infinite x → x ≠ 0 :=
λ hI h0, or.cases_on hI
(λ hip, lt_irrefl (0 : ℝ*) ((by rwa ←h0 : infinite_pos 0) 0))
(λ hin, lt_irrefl (0 : ℝ*) ((by rwa ←h0 : infinite_neg 0) 0))
lemma not_infinite_zero : ¬ infinite 0 := λ hI, ne_zero_of_infinite hI rfl
lemma pos_of_infinite_pos {x : ℝ*} : infinite_pos x → 0 < x := λ hip, hip 0
lemma neg_of_infinite_neg {x : ℝ*} : infinite_neg x → x < 0 := λ hin, hin 0
lemma not_infinite_pos_of_infinite_neg {x : ℝ*} : infinite_neg x → ¬ infinite_pos x :=
λ hn hp, not_lt_of_lt (hn 1) (hp 1)
lemma not_infinite_neg_of_infinite_pos {x : ℝ*} : infinite_pos x → ¬ infinite_neg x :=
imp_not_comm.mp not_infinite_pos_of_infinite_neg
lemma infinite_neg_neg_of_infinite_pos {x : ℝ*} : infinite_pos x → infinite_neg (-x) :=
λ hp r, neg_lt.mp (hp (-r))
lemma infinite_pos_neg_of_infinite_neg {x : ℝ*} : infinite_neg x → infinite_pos (-x) :=
λ hp r, lt_neg.mp (hp (-r))
lemma infinite_pos_iff_infinite_neg_neg {x : ℝ*} : infinite_pos x ↔ infinite_neg (-x) :=
⟨ infinite_neg_neg_of_infinite_pos, λ hin, neg_neg x ▸ infinite_pos_neg_of_infinite_neg hin ⟩
lemma infinite_neg_iff_infinite_pos_neg {x : ℝ*} : infinite_neg x ↔ infinite_pos (-x) :=
⟨ infinite_pos_neg_of_infinite_neg, λ hin, neg_neg x ▸ infinite_neg_neg_of_infinite_pos hin ⟩
lemma infinite_iff_infinite_neg {x : ℝ*} : infinite x ↔ infinite (-x) :=
⟨ λ hi, or.cases_on hi
(λ hip, or.inr (infinite_neg_neg_of_infinite_pos hip))
(λ hin, or.inl (infinite_pos_neg_of_infinite_neg hin)),
λ hi, or.cases_on hi
(λ hipn, or.inr (infinite_neg_iff_infinite_pos_neg.mpr hipn))
(λ hinp, or.inl (infinite_pos_iff_infinite_neg_neg.mpr hinp))⟩
lemma not_infinite_of_infinitesimal {x : ℝ*} : infinitesimal x → ¬ infinite x :=
λ hi hI, have hi' : _ := (hi 2 zero_lt_two), or.dcases_on hI
(λ hip, have hip' : _ := hip 2, not_lt_of_lt hip' (by convert hi'.2; exact (zero_add 2).symm))
(λ hin, have hin' : _ := hin (-2), not_lt_of_lt hin' (by convert hi'.1; exact (zero_sub 2).symm))
lemma not_infinitesimal_of_infinite {x : ℝ*} : infinite x → ¬ infinitesimal x :=
imp_not_comm.mp not_infinite_of_infinitesimal
lemma not_infinitesimal_of_infinite_pos {x : ℝ*} : infinite_pos x → ¬ infinitesimal x :=
λ hp, not_infinitesimal_of_infinite (or.inl hp)
lemma not_infinitesimal_of_infinite_neg {x : ℝ*} : infinite_neg x → ¬ infinitesimal x :=
λ hn, not_infinitesimal_of_infinite (or.inr hn)
lemma infinite_pos_iff_infinite_and_pos {x : ℝ*} : infinite_pos x ↔ (infinite x ∧ 0 < x) :=
⟨ λ hip, ⟨or.inl hip, hip 0⟩,
λ ⟨hi, hp⟩, hi.cases_on (λ hip, hip) (λ hin, false.elim (not_lt_of_lt hp (hin 0))) ⟩
lemma infinite_neg_iff_infinite_and_neg {x : ℝ*} : infinite_neg x ↔ (infinite x ∧ x < 0) :=
⟨ λ hip, ⟨or.inr hip, hip 0⟩,
λ ⟨hi, hp⟩, hi.cases_on (λ hin, false.elim (not_lt_of_lt hp (hin 0))) (λ hip, hip) ⟩
lemma infinite_pos_iff_infinite_of_pos {x : ℝ*} (hp : 0 < x) : infinite_pos x ↔ infinite x :=
by rw [infinite_pos_iff_infinite_and_pos]; exact ⟨λ hI, hI.1, λ hI, ⟨hI, hp⟩⟩
lemma infinite_pos_iff_infinite_of_nonneg {x : ℝ*} (hp : 0 ≤ x) : infinite_pos x ↔ infinite x :=
or.cases_on (lt_or_eq_of_le hp) (infinite_pos_iff_infinite_of_pos)
(λ h, by rw h.symm; exact
⟨λ hIP, false.elim (not_infinite_zero (or.inl hIP)), λ hI, false.elim (not_infinite_zero hI)⟩)
lemma infinite_neg_iff_infinite_of_neg {x : ℝ*} (hn : x < 0) : infinite_neg x ↔ infinite x :=
by rw [infinite_neg_iff_infinite_and_neg]; exact ⟨λ hI, hI.1, λ hI, ⟨hI, hn⟩⟩
lemma infinite_pos_abs_iff_infinite_abs {x : ℝ*} : infinite_pos (|x|) ↔ infinite (|x|) :=
infinite_pos_iff_infinite_of_nonneg (abs_nonneg _)
lemma infinite_iff_infinite_pos_abs {x : ℝ*} : infinite x ↔ infinite_pos (|x|) :=
⟨ λ hi d, or.cases_on hi
(λ hip, by rw [abs_of_pos (hip 0)]; exact hip d)
(λ hin, by rw [abs_of_neg (hin 0)]; exact lt_neg.mp (hin (-d))),
λ hipa, by { rcases (lt_trichotomy x 0) with h | h | h,
{ exact or.inr (infinite_neg_iff_infinite_pos_neg.mpr (by rwa abs_of_neg h at hipa)) },
{ exact false.elim (ne_zero_of_infinite (or.inl (by rw [h]; rwa [h, abs_zero] at hipa)) h) },
{ exact or.inl (by rwa abs_of_pos h at hipa) } } ⟩
lemma infinite_iff_infinite_abs {x : ℝ*} : infinite x ↔ infinite (|x|) :=
by rw [←infinite_pos_iff_infinite_of_nonneg (abs_nonneg _), infinite_iff_infinite_pos_abs]
lemma infinite_iff_abs_lt_abs {x : ℝ*} : infinite x ↔ ∀ r : ℝ, (|r| : ℝ*) < |x| :=
⟨ λ hI r, (coe_abs r) ▸ infinite_iff_infinite_pos_abs.mp hI (|r|),
λ hR, or.cases_on (max_choice x (-x))
(λ h, or.inl $ λ r, lt_of_le_of_lt (le_abs_self _) (h ▸ (hR r)))
(λ h, or.inr $ λ r, neg_lt_neg_iff.mp $ lt_of_le_of_lt (neg_le_abs_self _) (h ▸ (hR r)))⟩
lemma infinite_pos_add_not_infinite_neg {x y : ℝ*} :
infinite_pos x → ¬ infinite_neg y → infinite_pos (x + y) :=
begin
intros hip hnin r,
cases not_forall.mp hnin with r₂ hr₂,
convert add_lt_add_of_lt_of_le (hip (r + -r₂)) (not_lt.mp hr₂) using 1,
simp
end
lemma not_infinite_neg_add_infinite_pos {x y : ℝ*} :
¬ infinite_neg x → infinite_pos y → infinite_pos (x + y) :=
λ hx hy, by rw [add_comm]; exact infinite_pos_add_not_infinite_neg hy hx
lemma infinite_neg_add_not_infinite_pos {x y : ℝ*} :
infinite_neg x → ¬ infinite_pos y → infinite_neg (x + y) :=
by rw [@infinite_neg_iff_infinite_pos_neg x, @infinite_pos_iff_infinite_neg_neg y,
@infinite_neg_iff_infinite_pos_neg (x + y), neg_add];
exact infinite_pos_add_not_infinite_neg
lemma not_infinite_pos_add_infinite_neg {x y : ℝ*} :
¬ infinite_pos x → infinite_neg y → infinite_neg (x + y) :=
λ hx hy, by rw [add_comm]; exact infinite_neg_add_not_infinite_pos hy hx
lemma infinite_pos_add_infinite_pos {x y : ℝ*} :
infinite_pos x → infinite_pos y → infinite_pos (x + y) :=
λ hx hy, infinite_pos_add_not_infinite_neg hx (not_infinite_neg_of_infinite_pos hy)
lemma infinite_neg_add_infinite_neg {x y : ℝ*} :
infinite_neg x → infinite_neg y → infinite_neg (x + y) :=
λ hx hy, infinite_neg_add_not_infinite_pos hx (not_infinite_pos_of_infinite_neg hy)
lemma infinite_pos_add_not_infinite {x y : ℝ*} :
infinite_pos x → ¬ infinite y → infinite_pos (x + y) :=
λ hx hy, infinite_pos_add_not_infinite_neg hx (not_or_distrib.mp hy).2
lemma infinite_neg_add_not_infinite {x y : ℝ*} :
infinite_neg x → ¬ infinite y → infinite_neg (x + y) :=
λ hx hy, infinite_neg_add_not_infinite_pos hx (not_or_distrib.mp hy).1
theorem infinite_pos_of_tendsto_top {f : ℕ → ℝ} (hf : tendsto f at_top at_top) :
infinite_pos (of_seq f) :=
λ r, have hf' : _ := tendsto_at_top_at_top.mp hf,
Exists.cases_on (hf' (r + 1)) $ λ i hi,
have hi' : ∀ (a : ℕ), f a < (r + 1) → a < i :=
λ a, by rw [←not_le, ←not_le]; exact not_imp_not.mpr (hi a),
have hS : {a : ℕ | r < f a}ᶜ ⊆ {a : ℕ | a ≤ i} :=
by simp only [set.compl_set_of, not_lt];
exact λ a har, le_of_lt (hi' a (lt_of_le_of_lt har (lt_add_one _))),
germ.coe_lt.2 $ mem_hyperfilter_of_finite_compl $
(set.finite_le_nat _).subset hS
theorem infinite_neg_of_tendsto_bot {f : ℕ → ℝ} (hf : tendsto f at_top at_bot) :
infinite_neg (of_seq f) :=
λ r, have hf' : _ := tendsto_at_top_at_bot.mp hf,
Exists.cases_on (hf' (r - 1)) $ λ i hi,
have hi' : ∀ (a : ℕ), r - 1 < f a → a < i :=
λ a, by rw [←not_le, ←not_le]; exact not_imp_not.mpr (hi a),
have hS : {a : ℕ | f a < r}ᶜ ⊆ {a : ℕ | a ≤ i} :=
by simp only [set.compl_set_of, not_lt];
exact λ a har, le_of_lt (hi' a (lt_of_lt_of_le (sub_one_lt _) har)),
germ.coe_lt.2 $ mem_hyperfilter_of_finite_compl $
(set.finite_le_nat _).subset hS
lemma not_infinite_neg {x : ℝ*} : ¬ infinite x → ¬ infinite (-x) :=
not_imp_not.mpr infinite_iff_infinite_neg.mpr
lemma not_infinite_add {x y : ℝ*} (hx : ¬ infinite x) (hy : ¬ infinite y) :
¬ infinite (x + y) :=
have hx' : _ := exists_st_of_not_infinite hx, have hy' : _ := exists_st_of_not_infinite hy,
Exists.cases_on hx' $ Exists.cases_on hy' $
λ r hr s hs, not_infinite_of_exists_st $ ⟨s + r, is_st_add hs hr⟩
theorem not_infinite_iff_exist_lt_gt {x : ℝ*} : ¬ infinite x ↔ ∃ r s : ℝ, (r : ℝ*) < x ∧ x < s :=
⟨ λ hni,
Exists.dcases_on (not_forall.mp (not_or_distrib.mp hni).1) $
Exists.dcases_on (not_forall.mp (not_or_distrib.mp hni).2) $ λ r hr s hs,
by rw [not_lt] at hr hs; exact ⟨r - 1, s + 1,
⟨ lt_of_lt_of_le (by rw sub_eq_add_neg; norm_num) hr,
lt_of_le_of_lt hs (by norm_num)⟩ ⟩,
λ hrs, Exists.dcases_on hrs $ λ r hr, Exists.dcases_on hr $ λ s hs,
not_or_distrib.mpr ⟨not_forall.mpr ⟨s, lt_asymm (hs.2)⟩, not_forall.mpr ⟨r, lt_asymm (hs.1) ⟩⟩⟩
theorem not_infinite_real (r : ℝ) : ¬ infinite r := by rw not_infinite_iff_exist_lt_gt; exact
⟨ r - 1, r + 1, coe_lt_coe.2 $ sub_one_lt r, coe_lt_coe.2 $ lt_add_one r⟩
theorem not_real_of_infinite {x : ℝ*} : infinite x → ∀ r : ℝ, x ≠ r :=
λ hi r hr, not_infinite_real r $ @eq.subst _ infinite _ _ hr hi
/-!
### Facts about `st` that require some infinite machinery
-/
private lemma is_st_mul' {x y : ℝ*} {r s : ℝ} (hxr : is_st x r) (hys : is_st y s) (hs : s ≠ 0) :
is_st (x * y) (r * s) :=
have hxr' : _ := is_st_iff_abs_sub_lt_delta.mp hxr,
have hys' : _ := is_st_iff_abs_sub_lt_delta.mp hys,
have h : _ := not_infinite_iff_exist_lt_gt.mp $ not_imp_not.mpr infinite_iff_infinite_abs.mpr $
not_infinite_of_exists_st ⟨r, hxr⟩,
Exists.cases_on h $ λ u h', Exists.cases_on h' $ λ t ⟨hu, ht⟩,
is_st_iff_abs_sub_lt_delta.mpr $ λ d hd,
calc |x * y - r * s|
= |x * (y - s) + (x - r) * s| :
by rw [mul_sub, sub_mul, add_sub, sub_add_cancel]
... ≤ |x * (y - s)| + |(x - r) * s| : abs_add _ _
... ≤ |x| * |y - s| + |x - r| * |s| : by simp only [abs_mul]
... ≤ |x| * ((d / t) / 2 : ℝ) + ((d / |s|) / 2 : ℝ) * |s| : add_le_add
(mul_le_mul_of_nonneg_left (le_of_lt $ hys' _ $ half_pos $ div_pos hd $
coe_pos.1 $ lt_of_le_of_lt (abs_nonneg x) ht) $ abs_nonneg _)
(mul_le_mul_of_nonneg_right (le_of_lt $ hxr' _ $ half_pos $ div_pos hd $
abs_pos.2 hs) $ abs_nonneg _)
... = (d / 2 * (|x| / t) + d / 2 : ℝ*) : by
{ push_cast [-filter.germ.const_div], -- TODO: Why wasn't `hyperreal.coe_div` used?
have : (|s| : ℝ*) ≠ 0, by simpa,
have : (2 : ℝ*) ≠ 0 := two_ne_zero,
field_simp [*, add_mul, mul_add, mul_assoc, mul_comm, mul_left_comm] }
... < (d / 2 * 1 + d / 2 : ℝ*) :
add_lt_add_right (mul_lt_mul_of_pos_left
((div_lt_one $ lt_of_le_of_lt (abs_nonneg x) ht).mpr ht) $
half_pos $ coe_pos.2 hd) _
... = (d : ℝ*) : by rw [mul_one, add_halves]
lemma is_st_mul {x y : ℝ*} {r s : ℝ} (hxr : is_st x r) (hys : is_st y s) :
is_st (x * y) (r * s) :=
have h : _ := not_infinite_iff_exist_lt_gt.mp $
not_imp_not.mpr infinite_iff_infinite_abs.mpr $ not_infinite_of_exists_st ⟨r, hxr⟩,
Exists.cases_on h $ λ u h', Exists.cases_on h' $ λ t ⟨hu, ht⟩,
begin
by_cases hs : s = 0,
{ apply is_st_iff_abs_sub_lt_delta.mpr, intros d hd,
have hys' : _ := is_st_iff_abs_sub_lt_delta.mp hys (d / t)
(div_pos hd (coe_pos.1 (lt_of_le_of_lt (abs_nonneg x) ht))),
rw [hs, coe_zero, sub_zero] at hys',
rw [hs, mul_zero, coe_zero, sub_zero, abs_mul, mul_comm,
←div_mul_cancel (d : ℝ*) (ne_of_gt (lt_of_le_of_lt (abs_nonneg x) ht)),
←coe_div],
exact mul_lt_mul'' hys' ht (abs_nonneg _) (abs_nonneg _) },
exact is_st_mul' hxr hys hs,
end
--AN INFINITE LEMMA THAT REQUIRES SOME MORE ST MACHINERY
lemma not_infinite_mul {x y : ℝ*} (hx : ¬ infinite x) (hy : ¬ infinite y) :
¬ infinite (x * y) :=
have hx' : _ := exists_st_of_not_infinite hx, have hy' : _ := exists_st_of_not_infinite hy,
Exists.cases_on hx' $ Exists.cases_on hy' $ λ r hr s hs, not_infinite_of_exists_st $
⟨s * r, is_st_mul hs hr⟩
---
lemma st_add {x y : ℝ*} (hx : ¬infinite x) (hy : ¬infinite y) : st (x + y) = st x + st y :=
have hx' : _ := is_st_st' hx,
have hy' : _ := is_st_st' hy,
have hxy : _ := is_st_st' (not_infinite_add hx hy),
have hxy' : _ := is_st_add hx' hy',
is_st_unique hxy hxy'
lemma st_neg (x : ℝ*) : st (-x) = - st x :=
if h : infinite x
then by rw [st_infinite h, st_infinite (infinite_iff_infinite_neg.mp h), neg_zero]
else is_st_unique (is_st_st' (not_infinite_neg h)) (is_st_neg (is_st_st' h))
lemma st_mul {x y : ℝ*} (hx : ¬infinite x) (hy : ¬infinite y) : st (x * y) = (st x) * (st y) :=
have hx' : _ := is_st_st' hx,
have hy' : _ := is_st_st' hy,
have hxy : _ := is_st_st' (not_infinite_mul hx hy),
have hxy' : _ := is_st_mul hx' hy',
is_st_unique hxy hxy'
/-!
### Basic lemmas about infinitesimal
-/
theorem infinitesimal_def {x : ℝ*} :
infinitesimal x ↔ (∀ r : ℝ, 0 < r → -(r : ℝ*) < x ∧ x < r) :=
⟨ λ hi r hr, by { convert (hi r hr); simp },
λ hi d hd, by { convert (hi d hd); simp } ⟩
theorem lt_of_pos_of_infinitesimal {x : ℝ*} : infinitesimal x → ∀ r : ℝ, 0 < r → x < r :=
λ hi r hr, ((infinitesimal_def.mp hi) r hr).2
theorem lt_neg_of_pos_of_infinitesimal {x : ℝ*} : infinitesimal x → ∀ r : ℝ, 0 < r → -↑r < x :=
λ hi r hr, ((infinitesimal_def.mp hi) r hr).1
theorem gt_of_neg_of_infinitesimal {x : ℝ*} : infinitesimal x → ∀ r : ℝ, r < 0 → ↑r < x :=
λ hi r hr, by convert ((infinitesimal_def.mp hi) (-r) (neg_pos.mpr hr)).1;
exact (neg_neg ↑r).symm
theorem abs_lt_real_iff_infinitesimal {x : ℝ*} :
infinitesimal x ↔ ∀ r : ℝ, r ≠ 0 → |x| < |r| :=
⟨ λ hi r hr, abs_lt.mpr (by rw ←coe_abs;
exact infinitesimal_def.mp hi (|r|) (abs_pos.2 hr)),
λ hR, infinitesimal_def.mpr $ λ r hr, abs_lt.mp $
(abs_of_pos $ coe_pos.2 hr) ▸ hR r $ ne_of_gt hr ⟩
lemma infinitesimal_zero : infinitesimal 0 := is_st_refl_real 0
lemma zero_of_infinitesimal_real {r : ℝ} : infinitesimal r → r = 0 := eq_of_is_st_real
lemma zero_iff_infinitesimal_real {r : ℝ} : infinitesimal r ↔ r = 0 :=
⟨zero_of_infinitesimal_real, λ hr, by rw hr; exact infinitesimal_zero⟩
lemma infinitesimal_add {x y : ℝ*} (hx : infinitesimal x) (hy : infinitesimal y) :
infinitesimal (x + y) :=
by simpa only [add_zero] using is_st_add hx hy
lemma infinitesimal_neg {x : ℝ*} (hx : infinitesimal x) : infinitesimal (-x) :=
by simpa only [neg_zero] using is_st_neg hx
lemma infinitesimal_neg_iff {x : ℝ*} : infinitesimal x ↔ infinitesimal (-x) :=
⟨infinitesimal_neg, λ h, (neg_neg x) ▸ @infinitesimal_neg (-x) h⟩
lemma infinitesimal_mul {x y : ℝ*} (hx : infinitesimal x) (hy : infinitesimal y) :
infinitesimal (x * y) :=
by simpa only [mul_zero] using is_st_mul hx hy
theorem infinitesimal_of_tendsto_zero {f : ℕ → ℝ} :
tendsto f at_top (𝓝 0) → infinitesimal (of_seq f) :=
λ hf d hd, by rw [sub_eq_add_neg, ←coe_neg, ←coe_add, ←coe_add, zero_add, zero_add];
exact ⟨neg_lt_of_tendsto_zero_of_pos hf hd, lt_of_tendsto_zero_of_pos hf hd⟩
theorem infinitesimal_epsilon : infinitesimal ε :=
infinitesimal_of_tendsto_zero tendsto_inverse_at_top_nhds_0_nat
lemma not_real_of_infinitesimal_ne_zero (x : ℝ*) :
infinitesimal x → x ≠ 0 → ∀ r : ℝ, x ≠ r :=
λ hi hx r hr, hx $ hr.trans $ coe_eq_zero.2 $
is_st_unique (hr.symm ▸ is_st_refl_real r : is_st x r) hi
theorem infinitesimal_sub_is_st {x : ℝ*} {r : ℝ} (hxr : is_st x r) : infinitesimal (x - r) :=
show is_st (x - r) 0,
by { rw [sub_eq_add_neg, ← add_neg_self r], exact is_st_add hxr (is_st_refl_real (-r)) }
theorem infinitesimal_sub_st {x : ℝ*} (hx : ¬infinite x) : infinitesimal (x - st x) :=
infinitesimal_sub_is_st $ is_st_st' hx
lemma infinite_pos_iff_infinitesimal_inv_pos {x : ℝ*} :
infinite_pos x ↔ (infinitesimal x⁻¹ ∧ 0 < x⁻¹) :=
⟨ λ hip, ⟨ infinitesimal_def.mpr $ λ r hr,
⟨ lt_trans (coe_lt_coe.2 (neg_neg_of_pos hr)) (inv_pos.2 (hip 0)),
(inv_lt (coe_lt_coe.2 hr) (hip 0)).mp (by convert hip r⁻¹) ⟩,
inv_pos.2 $ hip 0 ⟩,
λ ⟨hi, hp⟩ r, @classical.by_cases (r = 0) (↑r < x) (λ h, eq.substr h (inv_pos.mp hp)) $
λ h, lt_of_le_of_lt (coe_le_coe.2 (le_abs_self r))
((inv_lt_inv (inv_pos.mp hp) (coe_lt_coe.2 (abs_pos.2 h))).mp
((infinitesimal_def.mp hi) ((|r|)⁻¹) (inv_pos.2 (abs_pos.2 h))).2) ⟩
lemma infinite_neg_iff_infinitesimal_inv_neg {x : ℝ*} :
infinite_neg x ↔ (infinitesimal x⁻¹ ∧ x⁻¹ < 0) :=
⟨ λ hin, have hin' : _ := infinite_pos_iff_infinitesimal_inv_pos.mp
(infinite_pos_neg_of_infinite_neg hin),
by rwa [infinitesimal_neg_iff, ←neg_pos, neg_inv],
λ hin, by rwa [←neg_pos, infinitesimal_neg_iff, neg_inv,
←infinite_pos_iff_infinitesimal_inv_pos, ←infinite_neg_iff_infinite_pos_neg] at hin ⟩
theorem infinitesimal_inv_of_infinite {x : ℝ*} : infinite x → infinitesimal x⁻¹ :=
λ hi, or.cases_on hi
(λ hip, (infinite_pos_iff_infinitesimal_inv_pos.mp hip).1)
(λ hin, (infinite_neg_iff_infinitesimal_inv_neg.mp hin).1)
theorem infinite_of_infinitesimal_inv {x : ℝ*} (h0 : x ≠ 0) (hi : infinitesimal x⁻¹ ) :
infinite x :=
begin
cases (lt_or_gt_of_ne h0) with hn hp,
{ exact or.inr (infinite_neg_iff_infinitesimal_inv_neg.mpr ⟨hi, inv_lt_zero.mpr hn⟩) },
{ exact or.inl (infinite_pos_iff_infinitesimal_inv_pos.mpr ⟨hi, inv_pos.mpr hp⟩) }
end
theorem infinite_iff_infinitesimal_inv {x : ℝ*} (h0 : x ≠ 0) : infinite x ↔ infinitesimal x⁻¹ :=
⟨ infinitesimal_inv_of_infinite, infinite_of_infinitesimal_inv h0 ⟩
lemma infinitesimal_pos_iff_infinite_pos_inv {x : ℝ*} :
infinite_pos x⁻¹ ↔ (infinitesimal x ∧ 0 < x) :=
by convert infinite_pos_iff_infinitesimal_inv_pos; simp only [inv_inv]
lemma infinitesimal_neg_iff_infinite_neg_inv {x : ℝ*} :
infinite_neg x⁻¹ ↔ (infinitesimal x ∧ x < 0) :=
by convert infinite_neg_iff_infinitesimal_inv_neg; simp only [inv_inv]
theorem infinitesimal_iff_infinite_inv {x : ℝ*} (h : x ≠ 0) : infinitesimal x ↔ infinite x⁻¹ :=
by convert (infinite_iff_infinitesimal_inv (inv_ne_zero h)).symm; simp only [inv_inv]
/-!
### `st` stuff that requires infinitesimal machinery
-/
theorem is_st_of_tendsto {f : ℕ → ℝ} {r : ℝ} (hf : tendsto f at_top (𝓝 r)) :
is_st (of_seq f) r :=
have hg : tendsto (λ n, f n - r) at_top (𝓝 0) :=
(sub_self r) ▸ (hf.sub tendsto_const_nhds),
by rw [←(zero_add r), ←(sub_add_cancel f (λ n, r))];
exact is_st_add (infinitesimal_of_tendsto_zero hg) (is_st_refl_real r)
lemma is_st_inv {x : ℝ*} {r : ℝ} (hi : ¬ infinitesimal x) : is_st x r → is_st x⁻¹ r⁻¹ :=
λ hxr, have h : x ≠ 0 := (λ h, hi (h.symm ▸ infinitesimal_zero)),
have H : _ := exists_st_of_not_infinite $ not_imp_not.mpr (infinitesimal_iff_infinite_inv h).mpr hi,
Exists.cases_on H $ λ s hs,
have H' : is_st 1 (r * s) := mul_inv_cancel h ▸ is_st_mul hxr hs,
have H'' : s = r⁻¹ := one_div r ▸ eq_one_div_of_mul_eq_one_right (eq_of_is_st_real H').symm,
H'' ▸ hs
lemma st_inv (x : ℝ*) : st x⁻¹ = (st x)⁻¹ :=
begin
by_cases h0 : x = 0,
rw [h0, inv_zero, ←coe_zero, st_id_real, inv_zero],
by_cases h1 : infinitesimal x,
rw [st_infinite ((infinitesimal_iff_infinite_inv h0).mp h1), st_of_is_st h1, inv_zero],
by_cases h2 : infinite x,
rw [st_of_is_st (infinitesimal_inv_of_infinite h2), st_infinite h2, inv_zero],
exact st_of_is_st (is_st_inv h1 (is_st_st' h2)),
end
/-!
### Infinite stuff that requires infinitesimal machinery
-/
lemma infinite_pos_omega : infinite_pos ω :=
infinite_pos_iff_infinitesimal_inv_pos.mpr ⟨infinitesimal_epsilon, epsilon_pos⟩
lemma infinite_omega : infinite ω :=
(infinite_iff_infinitesimal_inv omega_ne_zero).mpr infinitesimal_epsilon
lemma infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos {x y : ℝ*} :
infinite_pos x → ¬ infinitesimal y → 0 < y → infinite_pos (x * y) :=
λ hx hy₁ hy₂ r, have hy₁' : _ := not_forall.mp (by rw infinitesimal_def at hy₁; exact hy₁),
Exists.dcases_on hy₁' $ λ r₁ hy₁'',
have hyr : _ := by rw [not_imp, ←abs_lt, not_lt, abs_of_pos hy₂] at hy₁''; exact hy₁'',
by rw [←div_mul_cancel r (ne_of_gt hyr.1), coe_mul];
exact mul_lt_mul (hx (r / r₁)) hyr.2 (coe_lt_coe.2 hyr.1) (le_of_lt (hx 0))
lemma infinite_pos_mul_of_not_infinitesimal_pos_infinite_pos {x y : ℝ*} :
¬ infinitesimal x → 0 < x → infinite_pos y → infinite_pos (x * y) :=
λ hx hp hy, by rw mul_comm; exact infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos hy hx hp
lemma infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg {x y : ℝ*} :
infinite_neg x → ¬ infinitesimal y → y < 0 → infinite_pos (x * y) :=
by rw [infinite_neg_iff_infinite_pos_neg, ←neg_pos, ←neg_mul_neg, infinitesimal_neg_iff];
exact infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos
lemma infinite_pos_mul_of_not_infinitesimal_neg_infinite_neg {x y : ℝ*} :
¬ infinitesimal x → x < 0 → infinite_neg y → infinite_pos (x * y) :=
λ hx hp hy, by rw mul_comm; exact infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg hy hx hp
lemma infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg {x y : ℝ*} :
infinite_pos x → ¬ infinitesimal y → y < 0 → infinite_neg (x * y) :=
by rw [infinite_neg_iff_infinite_pos_neg, ←neg_pos, neg_mul_eq_mul_neg, infinitesimal_neg_iff];
exact infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos
lemma infinite_neg_mul_of_not_infinitesimal_neg_infinite_pos {x y : ℝ*} :
¬ infinitesimal x → x < 0 → infinite_pos y → infinite_neg (x * y) :=
λ hx hp hy, by rw mul_comm; exact infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg hy hx hp
lemma infinite_neg_mul_of_infinite_neg_not_infinitesimal_pos {x y : ℝ*} :
infinite_neg x → ¬ infinitesimal y → 0 < y → infinite_neg (x * y) :=
by rw [infinite_neg_iff_infinite_pos_neg, infinite_neg_iff_infinite_pos_neg, neg_mul_eq_neg_mul];
exact infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos
lemma infinite_neg_mul_of_not_infinitesimal_pos_infinite_neg {x y : ℝ*} :
¬ infinitesimal x → 0 < x → infinite_neg y → infinite_neg (x * y) :=
λ hx hp hy, by rw mul_comm; exact infinite_neg_mul_of_infinite_neg_not_infinitesimal_pos hy hx hp
lemma infinite_pos_mul_infinite_pos {x y : ℝ*} :
infinite_pos x → infinite_pos y → infinite_pos (x * y) :=
λ hx hy, infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos
hx (not_infinitesimal_of_infinite_pos hy) (hy 0)
lemma infinite_neg_mul_infinite_neg {x y : ℝ*} :
infinite_neg x → infinite_neg y → infinite_pos (x * y) :=
λ hx hy, infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg
hx (not_infinitesimal_of_infinite_neg hy) (hy 0)
lemma infinite_pos_mul_infinite_neg {x y : ℝ*} :
infinite_pos x → infinite_neg y → infinite_neg (x * y) :=
λ hx hy, infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg
hx (not_infinitesimal_of_infinite_neg hy) (hy 0)
lemma infinite_neg_mul_infinite_pos {x y : ℝ*} :
infinite_neg x → infinite_pos y → infinite_neg (x * y) :=
λ hx hy, infinite_neg_mul_of_infinite_neg_not_infinitesimal_pos
hx (not_infinitesimal_of_infinite_pos hy) (hy 0)
lemma infinite_mul_of_infinite_not_infinitesimal {x y : ℝ*} :
infinite x → ¬ infinitesimal y → infinite (x * y) :=
λ hx hy, have h0 : y < 0 ∨ 0 < y := lt_or_gt_of_ne (λ H0, hy (eq.substr H0 (is_st_refl_real 0))),
or.dcases_on hx
(or.dcases_on h0
(λ H0 Hx, or.inr (infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg Hx hy H0))
(λ H0 Hx, or.inl (infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos Hx hy H0)))
(or.dcases_on h0
(λ H0 Hx, or.inl (infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg Hx hy H0))
(λ H0 Hx, or.inr (infinite_neg_mul_of_infinite_neg_not_infinitesimal_pos Hx hy H0)))
lemma infinite_mul_of_not_infinitesimal_infinite {x y : ℝ*} :
¬ infinitesimal x → infinite y → infinite (x * y) :=
λ hx hy, by rw [mul_comm]; exact infinite_mul_of_infinite_not_infinitesimal hy hx
lemma infinite_mul_infinite {x y : ℝ*} : infinite x → infinite y → infinite (x * y) :=
λ hx hy, infinite_mul_of_infinite_not_infinitesimal hx (not_infinitesimal_of_infinite hy)
end hyperreal
|
f7ffb8d7126272d48d58f84159c74b084cb57ffc | 491068d2ad28831e7dade8d6dff871c3e49d9431 | /hott/types/arrow.hlean | f8b4d5e620415bbecd550dd3c3b2c0b2755effde | [
"Apache-2.0"
] | permissive | davidmueller13/lean | 65a3ed141b4088cd0a268e4de80eb6778b21a0e9 | c626e2e3c6f3771e07c32e82ee5b9e030de5b050 | refs/heads/master | 1,611,278,313,401 | 1,444,021,177,000 | 1,444,021,177,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 4,296 | hlean | /-
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
Ported from Coq HoTT
Theorems about arrow types (function spaces)
-/
import types.pi
open eq equiv is_equiv funext pi equiv.ops is_trunc unit
namespace pi
variables {A A' : Type} {B B' : Type} {C : A → B → Type}
{a a' a'' : A} {b b' b'' : B} {f g : A → B}
-- all lemmas here are special cases of the ones for pi-types
/- Functorial action -/
variables (f0 : A' → A) (f1 : B → B')
definition arrow_functor [unfold-full] : (A → B) → (A' → B') := pi_functor f0 (λa, f1)
/- Equivalences -/
definition is_equiv_arrow_functor [constructor]
[H0 : is_equiv f0] [H1 : is_equiv f1] : is_equiv (arrow_functor f0 f1) :=
is_equiv_pi_functor f0 (λa, f1)
definition arrow_equiv_arrow_rev [constructor] (f0 : A' ≃ A) (f1 : B ≃ B')
: (A → B) ≃ (A' → B') :=
equiv.mk _ (is_equiv_arrow_functor f0 f1)
definition arrow_equiv_arrow [constructor] (f0 : A ≃ A') (f1 : B ≃ B') : (A → B) ≃ (A' → B') :=
arrow_equiv_arrow_rev (equiv.symm f0) f1
variable (A)
definition arrow_equiv_arrow_right [constructor] (f1 : B ≃ B') : (A → B) ≃ (A → B') :=
arrow_equiv_arrow_rev equiv.refl f1
variables {A} (B)
definition arrow_equiv_arrow_left_rev [constructor] (f0 : A' ≃ A) : (A → B) ≃ (A' → B) :=
arrow_equiv_arrow_rev f0 equiv.refl
definition arrow_equiv_arrow_left [constructor] (f0 : A ≃ A') : (A → B) ≃ (A' → B) :=
arrow_equiv_arrow f0 equiv.refl
variables {B}
definition arrow_equiv_arrow_right' [constructor] (f1 : A → (B ≃ B')) : (A → B) ≃ (A → B') :=
pi_equiv_pi_id f1
/- Equivalence if one of the types is contractible -/
variables (A B)
definition arrow_equiv_of_is_contr_left [constructor] [H : is_contr A] : (A → B) ≃ B :=
!pi_equiv_of_is_contr_left
definition arrow_equiv_of_is_contr_right [constructor] [H : is_contr B] : (A → B) ≃ unit :=
!pi_equiv_of_is_contr_right
/- Interaction with other type constructors -/
-- most of these are in the file of the other type constructor
definition arrow_empty_left [constructor] : (empty → B) ≃ unit :=
!pi_empty_left
definition arrow_unit_left [constructor] : (unit → B) ≃ B :=
!arrow_equiv_of_is_contr_left
definition arrow_unit_right [constructor] : (A → unit) ≃ unit :=
!arrow_equiv_of_is_contr_right
variables {A B}
/- Transport -/
definition arrow_transport {B C : A → Type} (p : a = a') (f : B a → C a)
: (transport (λa, B a → C a) p f) ~ (λb, p ▸ f (p⁻¹ ▸ b)) :=
eq.rec_on p (λx, idp)
/- Pathovers -/
definition arrow_pathover {B C : A → Type} {f : B a → C a} {g : B a' → C a'} {p : a = a'}
(r : Π(b : B a) (b' : B a') (q : b =[p] b'), f b =[p] g b') : f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
exact eq_of_pathover_idp (r b b idpo),
end
definition arrow_pathover_left {B C : A → Type} {f : B a → C a} {g : B a' → C a'} {p : a = a'}
(r : Π(b : B a), f b =[p] g (p ▸ b)) : f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
exact eq_of_pathover_idp (r b),
end
definition arrow_pathover_right {B C : A → Type} {f : B a → C a} {g : B a' → C a'} {p : a = a'}
(r : Π(b' : B a'), f (p⁻¹ ▸ b') =[p] g b') : f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
exact eq_of_pathover_idp (r b),
end
definition arrow_pathover_constant_left {B : Type} {C : A → Type} {f : B → C a} {g : B → C a'}
{p : a = a'} (r : Π(b : B), f b =[p] g b) : f =[p] g :=
pi_pathover_constant r
definition arrow_pathover_constant_right {B : A → Type} {C : Type} {f : B a → C} {g : B a' → C}
{p : a = a'} (r : Π(b : B a), f b = g (p ▸ b)) : f =[p] g :=
arrow_pathover_left (λb, pathover_of_eq (r b))
/-
The fact that the arrow type preserves truncation level is a direct consequence
of the fact that pi's preserve truncation level
-/
definition is_trunc_arrow (B : Type) (n : trunc_index) [H : is_trunc n B] : is_trunc n (A → B) :=
_
end pi
|
1f4bbd4acfb3e087aef0f9b10576a4c856e44e7b | 947fa6c38e48771ae886239b4edce6db6e18d0fb | /src/ring_theory/artinian.lean | d565adb36caf6a05c8bc14e78e7603230524b263 | [
"Apache-2.0"
] | permissive | ramonfmir/mathlib | c5dc8b33155473fab97c38bd3aa6723dc289beaa | 14c52e990c17f5a00c0cc9e09847af16fabbed25 | refs/heads/master | 1,661,979,343,526 | 1,660,830,384,000 | 1,660,830,384,000 | 182,072,989 | 0 | 0 | null | 1,555,585,876,000 | 1,555,585,876,000 | null | UTF-8 | Lean | false | false | 18,980 | lean | /-
Copyright (c) 2021 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import ring_theory.nakayama
import data.set_like.fintype
/-!
# Artinian rings and modules
A module satisfying these equivalent conditions is said to be an *Artinian* R-module
if every decreasing chain of submodules is eventually constant, or equivalently,
if the relation `<` on submodules is well founded.
A ring is said to be left (or right) Artinian if it is Artinian as a left (or right) module over
itself, or simply Artinian if it is both left and right Artinian.
## Main definitions
Let `R` be a ring and let `M` and `P` be `R`-modules. Let `N` be an `R`-submodule of `M`.
* `is_artinian R M` is the proposition that `M` is a Artinian `R`-module. It is a class,
implemented as the predicate that the `<` relation on submodules is well founded.
* `is_artinian_ring R` is the proposition that `R` is a left Artinian ring.
## References
* [M. F. Atiyah and I. G. Macdonald, *Introduction to commutative algebra*][atiyah-macdonald]
* [samuel]
## Tags
Artinian, artinian, Artinian ring, Artinian module, artinian ring, artinian module
-/
open set
open_locale big_operators pointwise
/--
`is_artinian R M` is the proposition that `M` is an Artinian `R`-module,
implemented as the well-foundedness of submodule inclusion.
-/
class is_artinian (R M) [semiring R] [add_comm_monoid M] [module R M] : Prop :=
(well_founded_submodule_lt [] : well_founded ((<) : submodule R M → submodule R M → Prop))
section
variables {R M P N : Type*}
variables [ring R] [add_comm_group M] [add_comm_group P] [add_comm_group N]
variables [module R M] [module R P] [module R N]
open is_artinian
include R
theorem is_artinian_of_injective (f : M →ₗ[R] P) (h : function.injective f)
[is_artinian R P] : is_artinian R M :=
⟨subrelation.wf
(λ A B hAB, show A.map f < B.map f,
from submodule.map_strict_mono_of_injective h hAB)
(inv_image.wf (submodule.map f) (is_artinian.well_founded_submodule_lt R P))⟩
instance is_artinian_submodule' [is_artinian R M] (N : submodule R M) : is_artinian R N :=
is_artinian_of_injective N.subtype subtype.val_injective
lemma is_artinian_of_le {s t : submodule R M} [ht : is_artinian R t]
(h : s ≤ t) : is_artinian R s :=
is_artinian_of_injective (submodule.of_le h) (submodule.of_le_injective h)
variable (M)
theorem is_artinian_of_surjective (f : M →ₗ[R] P) (hf : function.surjective f)
[is_artinian R M] : is_artinian R P :=
⟨subrelation.wf
(λ A B hAB, show A.comap f < B.comap f,
from submodule.comap_strict_mono_of_surjective hf hAB)
(inv_image.wf (submodule.comap f) (is_artinian.well_founded_submodule_lt _ _))⟩
variable {M}
theorem is_artinian_of_linear_equiv (f : M ≃ₗ[R] P)
[is_artinian R M] : is_artinian R P :=
is_artinian_of_surjective _ f.to_linear_map f.to_equiv.surjective
theorem is_artinian_of_range_eq_ker
[is_artinian R M] [is_artinian R P]
(f : M →ₗ[R] N) (g : N →ₗ[R] P)
(hf : function.injective f)
(hg : function.surjective g)
(h : f.range = g.ker) :
is_artinian R N :=
⟨well_founded_lt_exact_sequence
(is_artinian.well_founded_submodule_lt _ _)
(is_artinian.well_founded_submodule_lt _ _)
f.range
(submodule.map f)
(submodule.comap f)
(submodule.comap g)
(submodule.map g)
(submodule.gci_map_comap hf)
(submodule.gi_map_comap hg)
(by simp [submodule.map_comap_eq, inf_comm])
(by simp [submodule.comap_map_eq, h])⟩
instance is_artinian_prod [is_artinian R M]
[is_artinian R P] : is_artinian R (M × P) :=
is_artinian_of_range_eq_ker
(linear_map.inl R M P)
(linear_map.snd R M P)
linear_map.inl_injective
linear_map.snd_surjective
(linear_map.range_inl R M P)
@[priority 100]
instance is_artinian_of_finite [finite M] : is_artinian R M :=
⟨finite.well_founded_of_trans_of_irrefl _⟩
local attribute [elab_as_eliminator] finite.induction_empty_option
instance is_artinian_pi {R ι : Type*} [finite ι] : Π {M : ι → Type*} [ring R]
[Π i, add_comm_group (M i)], by exactI Π [Π i, module R (M i)],
by exactI Π [∀ i, is_artinian R (M i)], is_artinian R (Π i, M i) :=
finite.induction_empty_option
(begin
introsI α β e hα M _ _ _ _,
exact is_artinian_of_linear_equiv
(linear_equiv.Pi_congr_left R M e)
end)
(by { introsI M _ _ _ _, apply_instance })
(begin
introsI α _ ih M _ _ _ _,
exact is_artinian_of_linear_equiv
(linear_equiv.pi_option_equiv_prod R).symm,
end)
ι
/-- A version of `is_artinian_pi` for non-dependent functions. We need this instance because
sometimes Lean fails to apply the dependent version in non-dependent settings (e.g., it fails to
prove that `ι → ℝ` is finite dimensional over `ℝ`). -/
instance is_artinian_pi' {R ι M : Type*} [ring R] [add_comm_group M] [module R M] [finite ι]
[is_artinian R M] : is_artinian R (ι → M) :=
is_artinian_pi
end
open is_artinian submodule function
section ring
variables {R M : Type*} [ring R] [add_comm_group M] [module R M]
theorem is_artinian_iff_well_founded :
is_artinian R M ↔ well_founded ((<) : submodule R M → submodule R M → Prop) :=
⟨λ h, h.1, is_artinian.mk⟩
variables {R M}
lemma is_artinian.finite_of_linear_independent [nontrivial R] [is_artinian R M]
{s : set M} (hs : linear_independent R (coe : s → M)) : s.finite :=
begin
refine classical.by_contradiction (λ hf, (rel_embedding.well_founded_iff_no_descending_seq.1
(well_founded_submodule_lt R M)).elim' _),
have f : ℕ ↪ s, from set.infinite.nat_embedding s hf,
have : ∀ n, (coe ∘ f) '' {m | n ≤ m} ⊆ s,
{ rintros n x ⟨y, hy₁, rfl⟩, exact (f y).2 },
have : ∀ a b : ℕ, a ≤ b ↔
span R ((coe ∘ f) '' {m | b ≤ m}) ≤ span R ((coe ∘ f) '' {m | a ≤ m}),
{ assume a b,
rw [span_le_span_iff hs (this b) (this a),
set.image_subset_image_iff (subtype.coe_injective.comp f.injective),
set.subset_def],
simp only [set.mem_set_of_eq],
exact ⟨λ hab x, le_trans hab, λ h, (h _ le_rfl)⟩ },
exact ⟨⟨λ n, span R ((coe ∘ f) '' {m | n ≤ m}),
λ x y, by simp [le_antisymm_iff, (this _ _).symm] {contextual := tt}⟩,
begin
intros a b,
conv_rhs { rw [gt, lt_iff_le_not_le, this, this, ← lt_iff_le_not_le] },
simp
end⟩
end
/-- A module is Artinian iff every nonempty set of submodules has a minimal submodule among them.
-/
theorem set_has_minimal_iff_artinian :
(∀ a : set $ submodule R M, a.nonempty → ∃ M' ∈ a, ∀ I ∈ a, I ≤ M' → I = M') ↔
is_artinian R M :=
by rw [is_artinian_iff_well_founded, well_founded.well_founded_iff_has_min']
theorem is_artinian.set_has_minimal [is_artinian R M] (a : set $ submodule R M) (ha : a.nonempty) :
∃ M' ∈ a, ∀ I ∈ a, I ≤ M' → I = M' :=
set_has_minimal_iff_artinian.mpr ‹_› a ha
/-- A module is Artinian iff every decreasing chain of submodules stabilizes. -/
theorem monotone_stabilizes_iff_artinian :
(∀ (f : ℕ →o (submodule R M)ᵒᵈ), ∃ n, ∀ m, n ≤ m → f n = f m) ↔ is_artinian R M :=
by { rw is_artinian_iff_well_founded, exact well_founded.monotone_chain_condition.symm }
namespace is_artinian
variables [is_artinian R M]
theorem monotone_stabilizes (f : ℕ →o (submodule R M)ᵒᵈ) : ∃ n, ∀ m, n ≤ m → f n = f m :=
monotone_stabilizes_iff_artinian.mpr ‹_› f
/-- If `∀ I > J, P I` implies `P J`, then `P` holds for all submodules. -/
lemma induction {P : submodule R M → Prop} (hgt : ∀ I, (∀ J < I, P J) → P I) (I : submodule R M) :
P I :=
(well_founded_submodule_lt R M).recursion I hgt
/--
For any endomorphism of a Artinian module, there is some nontrivial iterate
with disjoint kernel and range.
-/
theorem exists_endomorphism_iterate_ker_sup_range_eq_top (f : M →ₗ[R] M) :
∃ n : ℕ, n ≠ 0 ∧ (f ^ n).ker ⊔ (f ^ n).range = ⊤ :=
begin
obtain ⟨n, w⟩ := monotone_stabilizes (f.iterate_range.comp ⟨λ n, n+1, λ n m w, by linarith⟩),
specialize w ((n + 1) + n) (by linarith),
dsimp at w,
refine ⟨n + 1, nat.succ_ne_zero _, _⟩,
simp_rw [eq_top_iff', mem_sup],
intro x,
have : (f^(n + 1)) x ∈ (f ^ ((n + 1) + n + 1)).range,
{ rw ← w, exact mem_range_self _ },
rcases this with ⟨y, hy⟩,
use x - (f ^ (n+1)) y,
split,
{ rw [linear_map.mem_ker, linear_map.map_sub, ← hy, sub_eq_zero, pow_add],
simp [iterate_add_apply], },
{ use (f^ (n+1)) y,
simp }
end
/-- Any injective endomorphism of an Artinian module is surjective. -/
theorem surjective_of_injective_endomorphism (f : M →ₗ[R] M) (s : injective f) : surjective f :=
begin
obtain ⟨n, ne, w⟩ := exists_endomorphism_iterate_ker_sup_range_eq_top f,
rw [linear_map.ker_eq_bot.mpr (linear_map.iterate_injective s n), bot_sup_eq,
linear_map.range_eq_top] at w,
exact linear_map.surjective_of_iterate_surjective ne w,
end
/-- Any injective endomorphism of an Artinian module is bijective. -/
theorem bijective_of_injective_endomorphism (f : M →ₗ[R] M) (s : injective f) : bijective f :=
⟨s, surjective_of_injective_endomorphism f s⟩
/--
A sequence `f` of submodules of a artinian module,
with the supremum `f (n+1)` and the infinum of `f 0`, ..., `f n` being ⊤,
is eventually ⊤.
-/
lemma disjoint_partial_infs_eventually_top (f : ℕ → submodule R M)
(h : ∀ n, disjoint (partial_sups (order_dual.to_dual ∘ f) n) (order_dual.to_dual (f (n+1)))) :
∃ n : ℕ, ∀ m, n ≤ m → f m = ⊤ :=
begin
-- A little off-by-one cleanup first:
suffices t : ∃ n : ℕ, ∀ m, n ≤ m → order_dual.to_dual f (m+1) = ⊤,
{ obtain ⟨n, w⟩ := t,
use n+1,
rintros (_|m) p,
{ cases p, },
{ apply w,
exact nat.succ_le_succ_iff.mp p }, },
obtain ⟨n, w⟩ := monotone_stabilizes (partial_sups (order_dual.to_dual ∘ f)),
refine ⟨n, λ m p, _⟩,
exact (h m).eq_bot_of_ge (sup_eq_left.1 $ (w (m + 1) $ le_add_right p).symm.trans $ w m p)
end
end is_artinian
end ring
section comm_ring
variables {R : Type*} (M : Type*) [comm_ring R] [add_comm_group M] [module R M] [is_artinian R M]
namespace is_artinian
lemma range_smul_pow_stabilizes (r : R) : ∃ n : ℕ, ∀ m, n ≤ m →
(r^n • linear_map.id : M →ₗ[R] M).range = (r^m • linear_map.id).range :=
monotone_stabilizes
⟨λ n, (r^n • linear_map.id : M →ₗ[R] M).range,
λ n m h x ⟨y, hy⟩, ⟨r ^ (m - n) • y,
by { dsimp at ⊢ hy, rw [←smul_assoc, smul_eq_mul, ←pow_add, ←hy, add_tsub_cancel_of_le h] }⟩⟩
variables {M}
lemma exists_pow_succ_smul_dvd (r : R) (x : M) :
∃ (n : ℕ) (y : M), r ^ n.succ • y = r ^ n • x :=
begin
obtain ⟨n, hn⟩ := is_artinian.range_smul_pow_stabilizes M r,
simp_rw [set_like.ext_iff] at hn,
exact ⟨n, by simpa using hn n.succ n.le_succ (r ^ n • x)⟩,
end
end is_artinian
end comm_ring
-- TODO: Prove this for artinian modules
-- /--
-- If `M ⊕ N` embeds into `M`, for `M` noetherian over `R`, then `N` is trivial.
-- -/
-- universe w
-- variables {N : Type w} [add_comm_group N] [module R N]
-- noncomputable def is_noetherian.equiv_punit_of_prod_injective [is_noetherian R M]
-- (f : M × N →ₗ[R] M) (i : injective f) : N ≃ₗ[R] punit.{w+1} :=
-- begin
-- apply nonempty.some,
-- obtain ⟨n, w⟩ := is_noetherian.disjoint_partial_sups_eventually_bot (f.tailing i)
-- (f.tailings_disjoint_tailing i),
-- specialize w n (le_refl n),
-- apply nonempty.intro,
-- refine (f.tailing_linear_equiv i n).symm.trans _,
-- rw w,
-- exact submodule.bot_equiv_punit,
-- end
/-- A ring is Artinian if it is Artinian as a module over itself.
Strictly speaking, this should be called `is_left_artinian_ring` but we omit the `left_` for
convenience in the commutative case. For a right Artinian ring, use `is_artinian Rᵐᵒᵖ R`. -/
@[reducible] def is_artinian_ring (R) [ring R] := is_artinian R R
theorem is_artinian_ring_iff {R} [ring R] : is_artinian_ring R ↔ is_artinian R R :=
iff.rfl
theorem ring.is_artinian_of_zero_eq_one {R} [ring R] (h01 : (0 : R) = 1) : is_artinian_ring R :=
have _ := subsingleton_of_zero_eq_one h01, by exactI infer_instance
theorem is_artinian_of_submodule_of_artinian (R M) [ring R] [add_comm_group M] [module R M]
(N : submodule R M) (h : is_artinian R M) : is_artinian R N :=
by apply_instance
theorem is_artinian_of_quotient_of_artinian (R) [ring R] (M) [add_comm_group M] [module R M]
(N : submodule R M) (h : is_artinian R M) : is_artinian R (M ⧸ N) :=
is_artinian_of_surjective M (submodule.mkq N) (submodule.quotient.mk_surjective N)
/-- If `M / S / R` is a scalar tower, and `M / R` is Artinian, then `M / S` is
also Artinian. -/
theorem is_artinian_of_tower (R) {S M} [comm_ring R] [ring S]
[add_comm_group M] [algebra R S] [module S M] [module R M] [is_scalar_tower R S M]
(h : is_artinian R M) : is_artinian S M :=
begin
rw is_artinian_iff_well_founded at h ⊢,
refine (submodule.restrict_scalars_embedding R S M).well_founded h
end
theorem is_artinian_of_fg_of_artinian {R M} [ring R] [add_comm_group M] [module R M]
(N : submodule R M) [is_artinian_ring R] (hN : N.fg) : is_artinian R N :=
let ⟨s, hs⟩ := hN in
begin
haveI := classical.dec_eq M,
haveI := classical.dec_eq R,
have : ∀ x ∈ s, x ∈ N, from λ x hx, hs ▸ submodule.subset_span hx,
refine @@is_artinian_of_surjective ((↑s : set M) → R) _ _ _ (pi.module _ _ _)
_ _ _ is_artinian_pi,
{ fapply linear_map.mk,
{ exact λ f, ⟨∑ i in s.attach, f i • i.1, N.sum_mem (λ c _, N.smul_mem _ $ this _ c.2)⟩ },
{ intros f g, apply subtype.eq,
change ∑ i in s.attach, (f i + g i) • _ = _,
simp only [add_smul, finset.sum_add_distrib], refl },
{ intros c f, apply subtype.eq,
change ∑ i in s.attach, (c • f i) • _ = _,
simp only [smul_eq_mul, mul_smul],
exact finset.smul_sum.symm } },
rintro ⟨n, hn⟩, change n ∈ N at hn,
rw [← hs, ← set.image_id ↑s, finsupp.mem_span_image_iff_total] at hn,
rcases hn with ⟨l, hl1, hl2⟩,
refine ⟨λ x, l x, subtype.ext _⟩,
change ∑ i in s.attach, l i • (i : M) = n,
rw [@finset.sum_attach M M s _ (λ i, l i • i), ← hl2,
finsupp.total_apply, finsupp.sum, eq_comm],
refine finset.sum_subset hl1 (λ x _ hx, _),
rw [finsupp.not_mem_support_iff.1 hx, zero_smul]
end
lemma is_artinian_of_fg_of_artinian' {R M} [ring R] [add_comm_group M] [module R M]
[is_artinian_ring R] (h : (⊤ : submodule R M).fg) : is_artinian R M :=
have is_artinian R (⊤ : submodule R M), from is_artinian_of_fg_of_artinian _ h,
by exactI is_artinian_of_linear_equiv (linear_equiv.of_top (⊤ : submodule R M) rfl)
/-- In a module over a artinian ring, the submodule generated by finitely many vectors is
artinian. -/
theorem is_artinian_span_of_finite (R) {M} [ring R] [add_comm_group M] [module R M]
[is_artinian_ring R] {A : set M} (hA : A.finite) : is_artinian R (submodule.span R A) :=
is_artinian_of_fg_of_artinian _ (submodule.fg_def.mpr ⟨A, hA, rfl⟩)
theorem function.surjective.is_artinian_ring {R} [ring R] {S} [ring S] {F} [ring_hom_class F R S]
{f : F} (hf : function.surjective f) [H : is_artinian_ring R] : is_artinian_ring S :=
begin
rw [is_artinian_ring_iff, is_artinian_iff_well_founded] at H ⊢,
exact (ideal.order_embedding_of_surjective f hf).well_founded H,
end
instance is_artinian_ring_range {R} [ring R] {S} [ring S] (f : R →+* S) [is_artinian_ring R] :
is_artinian_ring f.range :=
f.range_restrict_surjective.is_artinian_ring
namespace is_artinian_ring
open is_artinian
variables {R : Type*} [comm_ring R] [is_artinian_ring R]
lemma is_nilpotent_jacobson_bot : is_nilpotent (ideal.jacobson (⊥ : ideal R)) :=
begin
let Jac := ideal.jacobson (⊥ : ideal R),
let f : ℕ →o (ideal R)ᵒᵈ := ⟨λ n, Jac ^ n, λ _ _ h, ideal.pow_le_pow h⟩,
obtain ⟨n, hn⟩ : ∃ n, ∀ m, n ≤ m → Jac ^ n = Jac ^ m := is_artinian.monotone_stabilizes f,
refine ⟨n, _⟩,
let J : ideal R := annihilator (Jac ^ n),
suffices : J = ⊤,
{ have hJ : J • Jac ^ n = ⊥ := annihilator_smul (Jac ^ n),
simpa only [this, top_smul, ideal.zero_eq_bot] using hJ },
by_contradiction hJ, change J ≠ ⊤ at hJ,
rcases is_artinian.set_has_minimal {J' : ideal R | J < J'} ⟨⊤, hJ.lt_top⟩
with ⟨J', hJJ' : J < J', hJ' : ∀ I, J < I → I ≤ J' → I = J'⟩,
rcases set_like.exists_of_lt hJJ' with ⟨x, hxJ', hxJ⟩,
obtain rfl : J ⊔ ideal.span {x} = J',
{ refine hJ' (J ⊔ ideal.span {x}) _ _,
{ rw set_like.lt_iff_le_and_exists,
exact ⟨le_sup_left, ⟨x, mem_sup_right (mem_span_singleton_self x), hxJ⟩⟩ },
{ exact (sup_le hJJ'.le (span_le.2 (singleton_subset_iff.2 hxJ'))) } },
have : J ⊔ Jac • ideal.span {x} ≤ J ⊔ ideal.span {x},
from sup_le_sup_left (smul_le.2 (λ _ _ _, submodule.smul_mem _ _)) _,
have : Jac * ideal.span {x} ≤ J, --Need version 4 of Nakayamas lemma on Stacks
{ classical, by_contradiction H,
refine H (smul_sup_le_of_le_smul_of_le_jacobson_bot
(fg_span_singleton _) le_rfl (hJ' _ _ this).ge),
exact lt_of_le_of_ne le_sup_left (λ h, H $ h.symm ▸ le_sup_right) },
have : ideal.span {x} * Jac ^ (n + 1) ≤ ⊥,
calc ideal.span {x} * Jac ^ (n + 1) = ideal.span {x} * Jac * Jac ^ n :
by rw [pow_succ, ← mul_assoc]
... ≤ J * Jac ^ n : mul_le_mul (by rwa mul_comm) le_rfl
... = ⊥ : by simp [J],
refine hxJ (mem_annihilator.2 (λ y hy, (mem_bot R).1 _)),
refine this (mul_mem_mul (mem_span_singleton_self x) _),
rwa [← hn (n + 1) (nat.le_succ _)]
end
section localization
variables (S : submonoid R) (L : Type*) [comm_ring L] [algebra R L] [is_localization S L]
include S
/-- Localizing an artinian ring can only reduce the amount of elements. -/
theorem localization_surjective : function.surjective (algebra_map R L) :=
begin
intro r',
obtain ⟨r₁, s, rfl⟩ := is_localization.mk'_surjective S r',
obtain ⟨r₂, h⟩ : ∃ r : R, is_localization.mk' L 1 s = algebra_map R L r,
swap, { exact ⟨r₁ * r₂, by rw [is_localization.mk'_eq_mul_mk'_one, map_mul, h]⟩ },
obtain ⟨n, r, hr⟩ := is_artinian.exists_pow_succ_smul_dvd (s : R) (1 : R),
use r,
rw [smul_eq_mul, smul_eq_mul, pow_succ', mul_assoc] at hr,
apply_fun algebra_map R L at hr,
simp only [map_mul, ←submonoid.coe_pow] at hr,
rw [←is_localization.mk'_one L, is_localization.mk'_eq_iff_eq, one_mul, submonoid.coe_one,
←(is_localization.map_units L (s ^ n)).mul_left_cancel hr, map_mul, mul_comm],
end
lemma localization_artinian : is_artinian_ring L :=
(localization_surjective S L).is_artinian_ring
/-- `is_artinian_ring.localization_artinian` can't be made an instance, as it would make `S` + `R`
into metavariables. However, this is safe. -/
instance : is_artinian_ring (localization S) := localization_artinian S _
end localization
end is_artinian_ring
|
2b62b0587d82ad8021f959599b85c2360e120f25 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/linear_algebra/projective_space/basic.lean | b5b6228c1f27787d158c4d065a4d8bed9d5577cd | [
"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 | 7,793 | lean | /-
Copyright (c) 2022 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import linear_algebra.finite_dimensional
/-!
# Projective Spaces
This file contains the definition of the projectivization of a vector space over a field,
as well as the bijection between said projectivization and the collection of all one
dimensional subspaces of the vector space.
## Notation
`ℙ K V` is notation for `projectivization K V`, the projectivization of a `K`-vector space `V`.
## Constructing terms of `ℙ K V`.
We have three ways to construct terms of `ℙ K V`:
- `projectivization.mk K v hv` where `v : V` and `hv : v ≠ 0`.
- `projectivization.mk' K v` where `v : { w : V // w ≠ 0 }`.
- `projectivization.mk'' H h` where `H : submodule K V` and `h : finrank H = 1`.
## Other definitions
- For `v : ℙ K V`, `v.submodule` gives the corresponding submodule of `V`.
- `projectivization.equiv_submodule` is the equivalence between `ℙ K V`
and `{ H : submodule K V // finrank H = 1 }`.
- For `v : ℙ K V`, `v.rep : V` is a representative of `v`.
## Projects
Everything in this file can be done for `division_ring`s instead of `field`s, but
this would require a significant refactor of the results from
`linear_algebra.finite_dimensional` and its imports.
-/
variables (K V : Type*) [field K] [add_comm_group V] [module K V]
/-- The setoid whose quotient is the projectivization of `V`. -/
def projectivization_setoid : setoid { v : V // v ≠ 0 } :=
(mul_action.orbit_rel Kˣ V).comap coe
/-- The projectivization of the `K`-vector space `V`.
The notation `ℙ K V` is preferred. -/
@[nolint has_inhabited_instance]
def projectivization := quotient (projectivization_setoid K V)
notation `ℙ` := projectivization
namespace projectivization
variables {V}
/-- Construct an element of the projectivization from a nonzero vector. -/
def mk (v : V) (hv : v ≠ 0) : ℙ K V := quotient.mk' ⟨v,hv⟩
/-- A variant of `projectivization.mk` in terms of a subtype. `mk` is preferred. -/
def mk' (v : { v : V // v ≠ 0 }) : ℙ K V := quotient.mk' v
@[simp] lemma mk'_eq_mk (v : { v : V // v ≠ 0}) :
mk' K v = mk K v v.2 :=
by { dsimp [mk, mk'], congr' 1, simp }
instance [nontrivial V] : nonempty (ℙ K V) :=
let ⟨v, hv⟩ := exists_ne (0 : V) in ⟨mk K v hv⟩
variable {K}
/-- Choose a representative of `v : projectivization K V` in `V`. -/
protected noncomputable def rep (v : ℙ K V) : V := v.out'
lemma rep_nonzero (v : ℙ K V) : v.rep ≠ 0 := v.out'.2
@[simp]
lemma mk_rep (v : ℙ K V) :
mk K v.rep v.rep_nonzero = v :=
by { dsimp [mk, projectivization.rep], simp }
open finite_dimensional
/-- Consider an element of the projectivization as a submodule of `V`. -/
protected def submodule (v : ℙ K V) : submodule K V :=
quotient.lift_on' v (λ v, K ∙ (v : V)) $ begin
rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨x, (rfl : x • b = a)⟩,
exact (submodule.span_singleton_group_smul_eq _ x _),
end
variable (K)
lemma mk_eq_mk_iff (v w : V) (hv : v ≠ 0) (hw : w ≠ 0) :
mk K v hv = mk K w hw ↔ ∃ (a : Kˣ), a • w = v :=
quotient.eq'
lemma exists_smul_eq_mk_rep
(v : V) (hv : v ≠ 0) : ∃ (a : Kˣ), a • v = (mk K v hv).rep :=
show (projectivization_setoid K V).rel _ _, from quotient.mk_out' ⟨v, hv⟩
variable {K}
/-- An induction principle for `projectivization`.
Use as `induction v using projectivization.ind`. -/
@[elab_as_eliminator]
lemma ind {P : ℙ K V → Prop} (h : ∀ (v : V) (h : v ≠ 0), P (mk K v h)) :
∀ p, P p :=
quotient.ind' $ subtype.rec $ by exact h
@[simp]
lemma submodule_mk (v : V) (hv : v ≠ 0) : (mk K v hv).submodule = K ∙ v := rfl
lemma submodule_eq (v : ℙ K V) : v.submodule = K ∙ v.rep :=
by { conv_lhs { rw ← v.mk_rep }, refl }
lemma finrank_submodule (v : ℙ K V) : finrank K v.submodule = 1 :=
begin
rw submodule_eq,
exact finrank_span_singleton v.rep_nonzero,
end
instance (v : ℙ K V) : finite_dimensional K v.submodule :=
by { rw ← v.mk_rep, change finite_dimensional K (K ∙ v.rep), apply_instance }
lemma submodule_injective : function.injective
(projectivization.submodule : ℙ K V → submodule K V) :=
begin
intros u v h, replace h := le_of_eq h,
simp only [submodule_eq] at h,
rw submodule.le_span_singleton_iff at h,
rw [← mk_rep v, ← mk_rep u],
apply quotient.sound',
obtain ⟨a,ha⟩ := h u.rep (submodule.mem_span_singleton_self _),
have : a ≠ 0 := λ c, u.rep_nonzero (by simpa [c] using ha.symm),
use [units.mk0 a this, ha],
end
variables (K V)
/-- The equivalence between the projectivization and the
collection of subspaces of dimension 1. -/
noncomputable
def equiv_submodule : ℙ K V ≃ { H : submodule K V // finrank K H = 1 } :=
equiv.of_bijective (λ v, ⟨v.submodule, v.finrank_submodule⟩)
begin
split,
{ intros u v h, apply_fun (λ e, e.val) at h,
apply submodule_injective h },
{ rintros ⟨H, h⟩,
rw finrank_eq_one_iff' at h,
obtain ⟨v, hv, h⟩ := h,
have : (v : V) ≠ 0 := λ c, hv (subtype.coe_injective c),
use mk K v this,
symmetry,
ext x, revert x, erw ← set.ext_iff, ext x,
dsimp,
rw [submodule.span_singleton_eq_range],
refine ⟨λ hh, _, _⟩,
{ obtain ⟨c,hc⟩ := h ⟨x,hh⟩,
exact ⟨c, congr_arg coe hc⟩ },
{ rintros ⟨c,rfl⟩,
refine submodule.smul_mem _ _ v.2 } }
end
variables {K V}
/-- Construct an element of the projectivization from a subspace of dimension 1. -/
noncomputable
def mk'' (H : _root_.submodule K V) (h : finrank K H = 1) : ℙ K V :=
(equiv_submodule K V).symm ⟨H,h⟩
@[simp]
lemma submodule_mk'' (H : _root_.submodule K V) (h : finrank K H = 1) :
(mk'' H h).submodule = H :=
begin
suffices : (equiv_submodule K V) (mk'' H h) = ⟨H,h⟩, by exact congr_arg coe this,
dsimp [mk''],
simp
end
@[simp]
lemma mk''_submodule (v : ℙ K V) : mk'' v.submodule v.finrank_submodule = v :=
show (equiv_submodule K V).symm (equiv_submodule K V _) = _, by simp
section map
variables {L W : Type*} [field L] [add_comm_group W] [module L W]
/-- An injective semilinear map of vector spaces induces a map on projective spaces. -/
def map {σ : K →+* L} (f : V →ₛₗ[σ] W) (hf : function.injective f) :
ℙ K V → ℙ L W :=
quotient.map' (λ v, ⟨f v, λ c, v.2 (hf (by simp [c]))⟩)
begin
rintros ⟨u,hu⟩ ⟨v,hv⟩ ⟨a,ha⟩,
use units.map σ.to_monoid_hom a,
dsimp at ⊢ ha,
erw [← f.map_smulₛₗ, ha],
end
/-- Mapping with respect to a semilinear map over an isomorphism of fields yields
an injective map on projective spaces. -/
lemma map_injective {σ : K →+* L} {τ : L →+* K} [ring_hom_inv_pair σ τ]
(f : V →ₛₗ[σ] W) (hf : function.injective f) :
function.injective (map f hf) :=
begin
intros u v h,
rw [← u.mk_rep, ← v.mk_rep] at *,
apply quotient.sound',
dsimp [map, mk] at h,
simp only [quotient.eq'] at h,
obtain ⟨a,ha⟩ := h,
use units.map τ.to_monoid_hom a,
dsimp at ⊢ ha,
have : (a : L) = σ (τ a), by rw ring_hom_inv_pair.comp_apply_eq₂,
change (a : L) • f v.rep = f u.rep at ha,
rw [this, ← f.map_smulₛₗ] at ha,
exact hf ha,
end
@[simp]
lemma map_id : map
(linear_map.id : V →ₗ[K] V)
(linear_equiv.refl K V).injective = id :=
by { ext v, induction v using projectivization.ind, refl }
@[simp]
lemma map_comp {F U : Type*} [field F] [add_comm_group U] [module F U]
{σ : K →+* L} {τ : L →+* F} {γ : K →+* F} [ring_hom_comp_triple σ τ γ]
(f : V →ₛₗ[σ] W) (hf : function.injective f)
(g : W →ₛₗ[τ] U) (hg : function.injective g) :
map (g.comp f) (hg.comp hf) = map g hg ∘ map f hf :=
by { ext v, induction v using projectivization.ind, refl }
end map
end projectivization
|
cb9ed28a34055bf69fcf15c8705d9f7bb1dde7f6 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/category_theory/connected_components.lean | e4f1e2bc3d2f1ec83cf53fed5cdd73816e86e13a | [
"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 | 5,812 | lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import data.list.chain
import category_theory.punit
import category_theory.is_connected
import category_theory.sigma.basic
import category_theory.full_subcategory
/-!
# Connected components of a category
Defines a type `connected_components J` indexing the connected components of a category, and the
full subcategories giving each connected component: `component j : Type u₁`.
We show that each `component j` is in fact connected.
We show every category can be expressed as a disjoint union of its connected components, in
particular `decomposed J` is the category (definitionally) given by the sigma-type of the connected
components of `J`, and it is shown that this is equivalent to `J`.
-/
universes v₁ v₂ v₃ u₁ u₂
noncomputable theory
open category_theory.category
namespace category_theory
attribute [instance, priority 100] is_connected.is_nonempty
variables {J : Type u₁} [category.{v₁} J]
variables {C : Type u₂} [category.{u₁} C]
/-- This type indexes the connected components of the category `J`. -/
def connected_components (J : Type u₁) [category.{v₁} J] : Type u₁ := quotient (zigzag.setoid J)
instance [inhabited J] : inhabited (connected_components J) := ⟨quotient.mk' default⟩
/-- Given an index for a connected component, produce the actual component as a full subcategory. -/
@[derive category]
def component (j : connected_components J) : Type u₁ := {k : J // quotient.mk' k = j}
/-- The inclusion functor from a connected component to the whole category. -/
@[derive [full, faithful], simps {rhs_md := semireducible}]
def component.ι (j) : component j ⥤ J :=
full_subcategory_inclusion _
/-- Each connected component of the category is nonempty. -/
instance (j : connected_components J) : nonempty (component j) :=
begin
apply quotient.induction_on' j,
intro k,
refine ⟨⟨k, rfl⟩⟩,
end
instance (j : connected_components J) : inhabited (component j) := classical.inhabited_of_nonempty'
/-- Each connected component of the category is connected. -/
instance (j : connected_components J) : is_connected (component j) :=
begin
-- Show it's connected by constructing a zigzag (in `component j`) between any two objects
apply is_connected_of_zigzag,
rintro ⟨j₁, hj₁⟩ ⟨j₂, rfl⟩,
-- We know that the underlying objects j₁ j₂ have some zigzag between them in `J`
have h₁₂ : zigzag j₁ j₂ := quotient.exact' hj₁,
-- Get an explicit zigzag as a list
rcases list.exists_chain_of_relation_refl_trans_gen h₁₂ with ⟨l, hl₁, hl₂⟩,
-- Everything which has a zigzag to j₂ can be lifted to the same component as `j₂`.
let f : Π x, zigzag x j₂ → component (quotient.mk' j₂) := λ x h, ⟨x, quotient.sound' h⟩,
-- Everything in our chosen zigzag from `j₁` to `j₂` has a zigzag to `j₂`.
have hf : ∀ (a : J), a ∈ l → zigzag a j₂,
{ intros i hi,
apply list.chain.induction (λ t, zigzag t j₂) _ hl₁ hl₂ _ _ _ (or.inr hi),
{ intros j k,
apply relation.refl_trans_gen.head },
{ apply relation.refl_trans_gen.refl } },
-- Now lift the zigzag from `j₁` to `j₂` in `J` to the same thing in `component j`.
refine ⟨l.pmap f hf, _, _⟩,
{ refine @@list.chain_pmap_of_chain _ _ _ f (λ x y _ _ h, _) hl₁ h₁₂ _,
exact zag_of_zag_obj (component.ι _) h },
{ erw list.last_pmap _ f (j₁ :: l) (by simpa [h₁₂] using hf) (list.cons_ne_nil _ _),
exact subtype.ext hl₂ },
end
/--
The disjoint union of `J`s connected components, written explicitly as a sigma-type with the
category structure.
This category is equivalent to `J`.
-/
abbreviation decomposed (J : Type u₁) [category.{v₁} J] :=
Σ (j : connected_components J), component j
/--
The inclusion of each component into the decomposed category. This is just `sigma.incl` but having
this abbreviation helps guide typeclass search to get the right category instance on `decomposed J`.
-/
-- This name may cause clashes further down the road, and so might need to be changed.
abbreviation inclusion (j : connected_components J) : component j ⥤ decomposed J :=
sigma.incl _
/-- The forward direction of the equivalence between the decomposed category and the original. -/
@[simps {rhs_md := semireducible}]
def decomposed_to (J : Type u₁) [category.{v₁} J] : decomposed J ⥤ J :=
sigma.desc component.ι
@[simp]
lemma inclusion_comp_decomposed_to (j : connected_components J) :
inclusion j ⋙ decomposed_to J = component.ι j :=
rfl
instance : full (decomposed_to J) :=
{ preimage :=
begin
rintro ⟨j', X, hX⟩ ⟨k', Y, hY⟩ f,
dsimp at f,
have : j' = k',
rw [← hX, ← hY, quotient.eq'],
exact relation.refl_trans_gen.single (or.inl ⟨f⟩),
subst this,
refine sigma.sigma_hom.mk f,
end,
witness' :=
begin
rintro ⟨j', X, hX⟩ ⟨_, Y, rfl⟩ f,
have : quotient.mk' Y = j',
{ rw [← hX, quotient.eq'],
exact relation.refl_trans_gen.single (or.inr ⟨f⟩) },
subst this,
refl,
end }
instance : faithful (decomposed_to J) :=
{ map_injective' :=
begin
rintro ⟨_, j, rfl⟩ ⟨_, k, hY⟩ ⟨_, _, _, f⟩ ⟨_, _, _, g⟩ e,
change f = g at e,
subst e,
end }
instance : ess_surj (decomposed_to J) :=
{ mem_ess_image := λ j, ⟨⟨_, j, rfl⟩, ⟨iso.refl _⟩⟩ }
instance : is_equivalence (decomposed_to J) :=
equivalence.of_fully_faithfully_ess_surj _
/-- This gives that any category is equivalent to a disjoint union of connected categories. -/
@[simps functor {rhs_md := semireducible}]
def decomposed_equiv : decomposed J ≌ J :=
(decomposed_to J).as_equivalence
end category_theory
|
decab4dbfffb16621fc10680f6e129b4c1b45da5 | cc62cd292c1acc80a10b1c645915b70d2cdee661 | /src/category_theory/projectives/default.lean | 4d6d17230ba1e93b2362884af827f31ce1b7b812 | [] | no_license | RitaAhmadi/lean-category-theory | 4afb881c4b387ee2c8ce706c454fbf9db8897a29 | a27b4ae5eac978e9188d2e867c3d11d9a5b87a9e | refs/heads/master | 1,651,786,183,402 | 1,565,604,314,000 | 1,565,604,314,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 2,421 | lean | -- import ..abelian.abelian
-- import category_theory.universal.zero
-- open category_theory
-- open category_theory.limits
-- universes u v
-- class projective {C : Type u} [category.{u v} C] (P : C) :=
-- (lift : Π M N : C, Π f : M ⟶ N, Π w : epi f, Π g : P ⟶ N, P ⟶ M)
-- (factorisation : Π M N : C, Π f : M ⟶ N, Π w : epi f, Π g : P ⟶ N, (lift M N f w g) ≫ f = g)
-- structure projective_cover {C : Type u} [category.{u v} C] (X : C) :=
-- (cover : C)
-- (map : cover ⟶ X)
-- (projectivity: projective cover)
-- (surjectivity: epi map)
-- class enough_projectives (C : Type u) [category.{u v} C] :=
-- (cover : Π X : C, projective_cover X)
-- structure chain_complex (C : Type u) [category.{u v} C] [has_zero_object.{u v} C] :=
-- (objects : ℤ → C)
-- (d : Π i : ℤ, objects i ⟶ objects (i + 1))
-- (d_squared : Π i, (d i) ≫ (d (i+1)) = zero_morphism _ _)
-- structure projective_resolution {C : Type u} [category.{u v} C] [has_zero_object.{u v} C] (X : C) :=
-- (complex : chain_complex C)
-- (projectivity : Π i : ℤ, i < 0 → projective (complex.objects i))
-- (of : complex.objects 0 = X)
-- (nothing : Π i : ℤ, i > 0 → complex.objects i = zero_object.{u v} C) -- it's zero
-- -- TODO find out why we don't also need universe annotations on `enough_projectives`?
-- -- TODO this needs the category to be abelian!
-- def construct_injective_resolution {C : Type u} [category.{u v} C] [has_zero_object.{u v} C] [enough_projectives C] (X : C) : projective_resolution X := sorry
-- -- we define the complex inductively, taking the cover of X, then the cover of its kernel, and so on
-- /-
-- Baer's criterion:
-- A (right) R-module E is injective iff for every right ideal J ⊂ R, every map J → E extends to a map R → E
-- The forward direction is immediate from the definition. The reverse direction is harder, and uses Zorn.
-- -/
-- -- Corollary: If R is a PID, then an R-module A is injective iff it is 'divisible': ∀ r ∈ R, r ≠ 0, ∀ a ∈ A, ∃ b ∈ A so a = b * r.
-- /- Lemmas:
-- M is projective iff Hom_A(M ⟶ -) is exact
-- M is projective in A iff M is injective in Aᵒᵖ
-- M is injective iff Hom_A(- ⟶ M) is exact
-- -/
-- -- Comparision theorem: a map lifts to a chain map between resolutions, which is unique up to homotopy
-- -- If R : D → C is additive, L : C → D is exact, and L ⊣ R, then R preserves injectives.
|
dd4b4095fbfd63e57164118bb4a116be9166bad5 | e0f9ba56b7fedc16ef8697f6caeef5898b435143 | /src/topology/metric_space/basic.lean | a1512463c6f841f3678fbefc9484a0ebb32f7876 | [
"Apache-2.0"
] | permissive | anrddh/mathlib | 6a374da53c7e3a35cb0298b0cd67824efef362b4 | a4266a01d2dcb10de19369307c986d038c7bb6a6 | refs/heads/master | 1,656,710,827,909 | 1,589,560,456,000 | 1,589,560,456,000 | 264,271,800 | 0 | 0 | Apache-2.0 | 1,589,568,062,000 | 1,589,568,061,000 | null | UTF-8 | Lean | false | false | 71,068 | lean | /-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Metric spaces.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
Many definitions and theorems expected on metric spaces are already introduced on uniform spaces and
topological spaces. For example:
open and closed sets, compactness, completeness, continuity and uniform continuity
-/
import topology.metric_space.emetric_space
import topology.algebra.ordered
open set filter classical topological_space
noncomputable theory
open_locale uniformity topological_space
universes u v w
variables {α : Type u} {β : Type v} {γ : Type w}
/-- Construct a uniform structure from a distance function and metric space axioms -/
def uniform_space_of_dist
(dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0)
(dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) : uniform_space α :=
uniform_space.of_core {
uniformity := (⨅ ε>0, principal {p:α×α | dist p.1 p.2 < ε}),
refl := le_infi $ assume ε, le_infi $
by simp [set.subset_def, id_rel, dist_self, (>)] {contextual := tt},
comp := le_infi $ assume ε, le_infi $ assume h, lift'_le
(mem_infi_sets (ε / 2) $ mem_infi_sets (div_pos_of_pos_of_pos h two_pos) (subset.refl _)) $
have ∀ (a b c : α), dist a c < ε / 2 → dist c b < ε / 2 → dist a b < ε,
from assume a b c hac hcb,
calc dist a b ≤ dist a c + dist c b : dist_triangle _ _ _
... < ε / 2 + ε / 2 : add_lt_add hac hcb
... = ε : by rw [div_add_div_same, add_self_div_two],
by simpa [comp_rel],
symm := tendsto_infi.2 $ assume ε, tendsto_infi.2 $ assume h,
tendsto_infi' ε $ tendsto_infi' h $ tendsto_principal_principal.2 $ by simp [dist_comm] }
/-- The distance function (given an ambient metric space on `α`), which returns
a nonnegative real number `dist x y` given `x y : α`. -/
class has_dist (α : Type*) := (dist : α → α → ℝ)
export has_dist (dist)
section prio
set_option default_priority 100 -- see Note [default priority]
/-- Metric space
Each metric space induces a canonical `uniform_space` and hence a canonical `topological_space`.
This is enforced in the type class definition, by extending the `uniform_space` structure. When
instantiating a `metric_space` structure, the uniformity fields are not necessary, they will be
filled in by default. In the same way, each metric space induces an emetric space structure.
It is included in the structure, but filled in by default.
When one instantiates a metric space structure, for instance a product structure,
this makes it possible to use a uniform structure and an edistance that are exactly
the ones for the uniform spaces product and the emetric spaces products, thereby
ensuring that everything in defeq in diamonds.-/
class metric_space (α : Type u) extends has_dist α : Type u :=
(dist_self : ∀ x : α, dist x x = 0)
(eq_of_dist_eq_zero : ∀ {x y : α}, dist x y = 0 → x = y)
(dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z)
(edist : α → α → ennreal := λx y, ennreal.of_real (dist x y))
(edist_dist : ∀ x y : α, edist x y = ennreal.of_real (dist x y) . control_laws_tac)
(to_uniform_space : uniform_space α := uniform_space_of_dist dist dist_self dist_comm dist_triangle)
(uniformity_dist : 𝓤 α = ⨅ ε>0, principal {p:α×α | dist p.1 p.2 < ε} . control_laws_tac)
end prio
variables [metric_space α]
@[priority 100] -- see Note [lower instance priority]
instance metric_space.to_uniform_space' : uniform_space α :=
metric_space.to_uniform_space
@[priority 200] -- see Note [lower instance priority]
instance metric_space.to_has_edist : has_edist α := ⟨metric_space.edist⟩
@[simp] theorem dist_self (x : α) : dist x x = 0 := metric_space.dist_self x
theorem eq_of_dist_eq_zero {x y : α} : dist x y = 0 → x = y :=
metric_space.eq_of_dist_eq_zero
theorem dist_comm (x y : α) : dist x y = dist y x := metric_space.dist_comm x y
theorem edist_dist (x y : α) : edist x y = ennreal.of_real (dist x y) :=
metric_space.edist_dist x y
@[simp] theorem dist_eq_zero {x y : α} : dist x y = 0 ↔ x = y :=
iff.intro eq_of_dist_eq_zero (assume : x = y, this ▸ dist_self _)
@[simp] theorem zero_eq_dist {x y : α} : 0 = dist x y ↔ x = y :=
by rw [eq_comm, dist_eq_zero]
theorem dist_triangle (x y z : α) : dist x z ≤ dist x y + dist y z :=
metric_space.dist_triangle x y z
theorem dist_triangle_left (x y z : α) : dist x y ≤ dist z x + dist z y :=
by rw dist_comm z; apply dist_triangle
theorem dist_triangle_right (x y z : α) : dist x y ≤ dist x z + dist y z :=
by rw dist_comm y; apply dist_triangle
lemma dist_triangle4 (x y z w : α) :
dist x w ≤ dist x y + dist y z + dist z w :=
calc
dist x w ≤ dist x z + dist z w : dist_triangle x z w
... ≤ (dist x y + dist y z) + dist z w : add_le_add_right (metric_space.dist_triangle x y z) _
lemma dist_triangle4_left (x₁ y₁ x₂ y₂ : α) :
dist x₂ y₂ ≤ dist x₁ y₁ + (dist x₁ x₂ + dist y₁ y₂) :=
by rw [add_left_comm, dist_comm x₁, ← add_assoc]; apply dist_triangle4
lemma dist_triangle4_right (x₁ y₁ x₂ y₂ : α) :
dist x₁ y₁ ≤ dist x₁ x₂ + dist y₁ y₂ + dist x₂ y₂ :=
by rw [add_right_comm, dist_comm y₁]; apply dist_triangle4
/-- The triangle (polygon) inequality for sequences of points; `finset.Ico` version. -/
lemma dist_le_Ico_sum_dist (f : ℕ → α) {m n} (h : m ≤ n) :
dist (f m) (f n) ≤ (finset.Ico m n).sum (λ i, dist (f i) (f (i + 1))) :=
begin
revert n,
apply nat.le_induction,
{ simp only [finset.sum_empty, finset.Ico.self_eq_empty, dist_self] },
{ assume n hn hrec,
calc dist (f m) (f (n+1)) ≤ dist (f m) (f n) + dist _ _ : dist_triangle _ _ _
... ≤ (finset.Ico m n).sum _ + _ : add_le_add hrec (le_refl _)
... = (finset.Ico m (n+1)).sum _ :
by rw [finset.Ico.succ_top hn, finset.sum_insert, add_comm]; simp }
end
/-- The triangle (polygon) inequality for sequences of points; `finset.range` version. -/
lemma dist_le_range_sum_dist (f : ℕ → α) (n : ℕ) :
dist (f 0) (f n) ≤ (finset.range n).sum (λ i, dist (f i) (f (i + 1))) :=
finset.Ico.zero_bot n ▸ dist_le_Ico_sum_dist f (nat.zero_le n)
/-- A version of `dist_le_Ico_sum_dist` with each intermediate distance replaced
with an upper estimate. -/
lemma dist_le_Ico_sum_of_dist_le {f : ℕ → α} {m n} (hmn : m ≤ n)
{d : ℕ → ℝ} (hd : ∀ {k}, m ≤ k → k < n → dist (f k) (f (k + 1)) ≤ d k) :
dist (f m) (f n) ≤ (finset.Ico m n).sum d :=
le_trans (dist_le_Ico_sum_dist f hmn) $
finset.sum_le_sum $ λ k hk, hd (finset.Ico.mem.1 hk).1 (finset.Ico.mem.1 hk).2
/-- A version of `dist_le_range_sum_dist` with each intermediate distance replaced
with an upper estimate. -/
lemma dist_le_range_sum_of_dist_le {f : ℕ → α} (n : ℕ)
{d : ℕ → ℝ} (hd : ∀ {k}, k < n → dist (f k) (f (k + 1)) ≤ d k) :
dist (f 0) (f n) ≤ (finset.range n).sum d :=
finset.Ico.zero_bot n ▸ dist_le_Ico_sum_of_dist_le (zero_le n) (λ _ _, hd)
theorem swap_dist : function.swap (@dist α _) = dist :=
by funext x y; exact dist_comm _ _
theorem abs_dist_sub_le (x y z : α) : abs (dist x z - dist y z) ≤ dist x y :=
abs_sub_le_iff.2
⟨sub_le_iff_le_add.2 (dist_triangle _ _ _),
sub_le_iff_le_add.2 (dist_triangle_left _ _ _)⟩
theorem dist_nonneg {x y : α} : 0 ≤ dist x y :=
have 2 * dist x y ≥ 0,
from calc 2 * dist x y = dist x y + dist y x : by rw [dist_comm x y, two_mul]
... ≥ 0 : by rw ← dist_self x; apply dist_triangle,
nonneg_of_mul_nonneg_left this two_pos
@[simp] theorem dist_le_zero {x y : α} : dist x y ≤ 0 ↔ x = y :=
by simpa [le_antisymm_iff, dist_nonneg] using @dist_eq_zero _ _ x y
@[simp] theorem dist_pos {x y : α} : 0 < dist x y ↔ x ≠ y :=
by simpa only [not_le] using not_congr dist_le_zero
@[simp] theorem abs_dist {a b : α} : abs (dist a b) = dist a b :=
abs_of_nonneg dist_nonneg
theorem eq_of_forall_dist_le {x y : α} (h : ∀ε, ε > 0 → dist x y ≤ ε) : x = y :=
eq_of_dist_eq_zero (eq_of_le_of_forall_le_of_dense dist_nonneg h)
/-- Distance as a nonnegative real number. -/
def nndist (a b : α) : nnreal := ⟨dist a b, dist_nonneg⟩
/--Express `nndist` in terms of `edist`-/
lemma nndist_edist (x y : α) : nndist x y = (edist x y).to_nnreal :=
by simp [nndist, edist_dist, nnreal.of_real, max_eq_left dist_nonneg, ennreal.of_real]
/--Express `edist` in terms of `nndist`-/
lemma edist_nndist (x y : α) : edist x y = ↑(nndist x y) :=
by { rw [edist_dist, nndist, ennreal.of_real_eq_coe_nnreal] }
/--In a metric space, the extended distance is always finite-/
lemma edist_ne_top (x y : α) : edist x y ≠ ⊤ :=
by rw [edist_dist x y]; apply ennreal.coe_ne_top
/--In a metric space, the extended distance is always finite-/
lemma edist_lt_top {α : Type*} [metric_space α] (x y : α) : edist x y < ⊤ :=
ennreal.lt_top_iff_ne_top.2 (edist_ne_top x y)
/--`nndist x x` vanishes-/
@[simp] lemma nndist_self (a : α) : nndist a a = 0 := (nnreal.coe_eq_zero _).1 (dist_self a)
/--Express `dist` in terms of `nndist`-/
lemma dist_nndist (x y : α) : dist x y = ↑(nndist x y) := rfl
/--Express `nndist` in terms of `dist`-/
lemma nndist_dist (x y : α) : nndist x y = nnreal.of_real (dist x y) :=
by rw [dist_nndist, nnreal.of_real_coe]
/--Deduce the equality of points with the vanishing of the nonnegative distance-/
theorem eq_of_nndist_eq_zero {x y : α} : nndist x y = 0 → x = y :=
by simp only [← nnreal.eq_iff, ← dist_nndist, imp_self, nnreal.coe_zero, dist_eq_zero]
theorem nndist_comm (x y : α) : nndist x y = nndist y x :=
by simpa only [dist_nndist, nnreal.coe_eq] using dist_comm x y
/--Characterize the equality of points with the vanishing of the nonnegative distance-/
@[simp] theorem nndist_eq_zero {x y : α} : nndist x y = 0 ↔ x = y :=
by simp only [← nnreal.eq_iff, ← dist_nndist, imp_self, nnreal.coe_zero, dist_eq_zero]
@[simp] theorem zero_eq_nndist {x y : α} : 0 = nndist x y ↔ x = y :=
by simp only [← nnreal.eq_iff, ← dist_nndist, imp_self, nnreal.coe_zero, zero_eq_dist]
/--Triangle inequality for the nonnegative distance-/
theorem nndist_triangle (x y z : α) : nndist x z ≤ nndist x y + nndist y z :=
by simpa [nnreal.coe_le_coe] using dist_triangle x y z
theorem nndist_triangle_left (x y z : α) : nndist x y ≤ nndist z x + nndist z y :=
by simpa [nnreal.coe_le_coe] using dist_triangle_left x y z
theorem nndist_triangle_right (x y z : α) : nndist x y ≤ nndist x z + nndist y z :=
by simpa [nnreal.coe_le_coe] using dist_triangle_right x y z
/--Express `dist` in terms of `edist`-/
lemma dist_edist (x y : α) : dist x y = (edist x y).to_real :=
by rw [edist_dist, ennreal.to_real_of_real (dist_nonneg)]
namespace metric
/- instantiate metric space as a topology -/
variables {x y z : α} {ε ε₁ ε₂ : ℝ} {s : set α}
/-- `ball x ε` is the set of all points `y` with `dist y x < ε` -/
def ball (x : α) (ε : ℝ) : set α := {y | dist y x < ε}
@[simp] theorem mem_ball : y ∈ ball x ε ↔ dist y x < ε := iff.rfl
theorem mem_ball' : y ∈ ball x ε ↔ dist x y < ε := by rw dist_comm; refl
/-- `closed_ball x ε` is the set of all points `y` with `dist y x ≤ ε` -/
def closed_ball (x : α) (ε : ℝ) := {y | dist y x ≤ ε}
@[simp] theorem mem_closed_ball : y ∈ closed_ball x ε ↔ dist y x ≤ ε := iff.rfl
theorem ball_subset_closed_ball : ball x ε ⊆ closed_ball x ε :=
assume y (hy : _ < _), le_of_lt hy
theorem pos_of_mem_ball (hy : y ∈ ball x ε) : ε > 0 :=
lt_of_le_of_lt dist_nonneg hy
theorem mem_ball_self (h : ε > 0) : x ∈ ball x ε :=
show dist x x < ε, by rw dist_self; assumption
theorem mem_closed_ball_self (h : ε ≥ 0) : x ∈ closed_ball x ε :=
show dist x x ≤ ε, by rw dist_self; assumption
theorem mem_ball_comm : x ∈ ball y ε ↔ y ∈ ball x ε :=
by simp [dist_comm]
theorem ball_subset_ball (h : ε₁ ≤ ε₂) : ball x ε₁ ⊆ ball x ε₂ :=
λ y (yx : _ < ε₁), lt_of_lt_of_le yx h
theorem closed_ball_subset_closed_ball {α : Type u} [metric_space α] {ε₁ ε₂ : ℝ} {x : α} (h : ε₁ ≤ ε₂) :
closed_ball x ε₁ ⊆ closed_ball x ε₂ :=
λ y (yx : _ ≤ ε₁), le_trans yx h
theorem ball_disjoint (h : ε₁ + ε₂ ≤ dist x y) : ball x ε₁ ∩ ball y ε₂ = ∅ :=
eq_empty_iff_forall_not_mem.2 $ λ z ⟨h₁, h₂⟩,
not_lt_of_le (dist_triangle_left x y z)
(lt_of_lt_of_le (add_lt_add h₁ h₂) h)
theorem ball_disjoint_same (h : ε ≤ dist x y / 2) : ball x ε ∩ ball y ε = ∅ :=
ball_disjoint $ by rwa [← two_mul, ← le_div_iff' (@two_pos ℝ _)]
theorem ball_subset (h : dist x y ≤ ε₂ - ε₁) : ball x ε₁ ⊆ ball y ε₂ :=
λ z zx, by rw ← add_sub_cancel'_right ε₁ ε₂; exact
lt_of_le_of_lt (dist_triangle z x y) (add_lt_add_of_lt_of_le zx h)
theorem ball_half_subset (y) (h : y ∈ ball x (ε / 2)) : ball y (ε / 2) ⊆ ball x ε :=
ball_subset $ by rw sub_self_div_two; exact le_of_lt h
theorem exists_ball_subset_ball (h : y ∈ ball x ε) : ∃ ε' > 0, ball y ε' ⊆ ball x ε :=
⟨_, sub_pos.2 h, ball_subset $ by rw sub_sub_self⟩
theorem ball_eq_empty_iff_nonpos : ε ≤ 0 ↔ ball x ε = ∅ :=
(eq_empty_iff_forall_not_mem.trans
⟨λ h, le_of_not_gt $ λ ε0, h _ $ mem_ball_self ε0,
λ ε0 y h, not_lt_of_le ε0 $ pos_of_mem_ball h⟩).symm
@[simp] lemma ball_zero : ball x 0 = ∅ :=
by rw [← metric.ball_eq_empty_iff_nonpos]
theorem uniformity_basis_dist :
(𝓤 α).has_basis (λ ε : ℝ, 0 < ε) (λ ε, {p:α×α | dist p.1 p.2 < ε}) :=
begin
rw ← metric_space.uniformity_dist.symm,
refine has_basis_binfi_principal _ nonempty_Ioi,
exact λ r (hr : 0 < r) p (hp : 0 < p), ⟨min r p, lt_min hr hp,
λ x (hx : dist _ _ < _), lt_of_lt_of_le hx (min_le_left r p),
λ x (hx : dist _ _ < _), lt_of_lt_of_le hx (min_le_right r p)⟩
end
/-- Given `f : β → ℝ`, if `f` sends `{i | p i}` to a set of positive numbers
accumulating to zero, then `f i`-neighborhoods of the diagonal form a basis of `𝓤 α`.
For specific bases see `uniformity_basis_dist`, `uniformity_basis_dist_inv_nat_succ`,
and `uniformity_basis_dist_inv_nat_pos`. -/
protected theorem mk_uniformity_basis {β : Type*} {p : β → Prop} {f : β → ℝ}
(hf₀ : ∀ i, p i → 0 < f i) (hf : ∀ ⦃ε⦄, 0 < ε → ∃ i (hi : p i), f i ≤ ε) :
(𝓤 α).has_basis p (λ i, {p:α×α | dist p.1 p.2 < f i}) :=
begin
refine ⟨λ s, uniformity_basis_dist.mem_iff.trans _⟩,
split,
{ rintros ⟨ε, ε₀, hε⟩,
obtain ⟨i, hi, H⟩ : ∃ i (hi : p i), f i ≤ ε, from hf ε₀,
exact ⟨i, hi, λ x (hx : _ < _), hε $ lt_of_lt_of_le hx H⟩ },
{ exact λ ⟨i, hi, H⟩, ⟨f i, hf₀ i hi, H⟩ }
end
theorem uniformity_basis_dist_inv_nat_succ :
(𝓤 α).has_basis (λ _, true) (λ n:ℕ, {p:α×α | dist p.1 p.2 < 1 / (↑n+1) }) :=
metric.mk_uniformity_basis (λ n _, div_pos zero_lt_one $ nat.cast_add_one_pos n)
(λ ε ε0, (exists_nat_one_div_lt ε0).imp $ λ n hn, ⟨trivial, le_of_lt hn⟩)
theorem uniformity_basis_dist_inv_nat_pos :
(𝓤 α).has_basis (λ n:ℕ, 0<n) (λ n:ℕ, {p:α×α | dist p.1 p.2 < 1 / ↑n }) :=
metric.mk_uniformity_basis (λ n hn, div_pos zero_lt_one $ nat.cast_pos.2 hn)
(λ ε ε0, let ⟨n, hn⟩ := exists_nat_one_div_lt ε0 in ⟨n+1, nat.succ_pos n, le_of_lt hn⟩)
/-- Given `f : β → ℝ`, if `f` sends `{i | p i}` to a set of positive numbers
accumulating to zero, then closed neighborhoods of the diagonal of sizes `{f i | p i}`
form a basis of `𝓤 α`.
Currently we have only one specific basis `uniformity_basis_dist_le` based on this constructor.
More can be easily added if needed in the future. -/
protected theorem mk_uniformity_basis_le {β : Type*} {p : β → Prop} {f : β → ℝ}
(hf₀ : ∀ x, p x → 0 < f x) (hf : ∀ ε, 0 < ε → ∃ x (hx : p x), f x ≤ ε) :
(𝓤 α).has_basis p (λ x, {p:α×α | dist p.1 p.2 ≤ f x}) :=
begin
refine ⟨λ s, uniformity_basis_dist.mem_iff.trans _⟩,
split,
{ rintros ⟨ε, ε₀, hε⟩,
rcases dense ε₀ with ⟨ε', hε'⟩,
rcases hf ε' hε'.1 with ⟨i, hi, H⟩,
exact ⟨i, hi, λ x (hx : _ ≤ _), hε $ lt_of_le_of_lt (le_trans hx H) hε'.2⟩ },
{ exact λ ⟨i, hi, H⟩, ⟨f i, hf₀ i hi, λ x (hx : _ < _), H (le_of_lt hx)⟩ }
end
/-- Contant size closed neighborhoods of the diagonal form a basis
of the uniformity filter. -/
theorem uniformity_basis_dist_le :
(𝓤 α).has_basis (λ ε : ℝ, 0 < ε) (λ ε, {p:α×α | dist p.1 p.2 ≤ ε}) :=
metric.mk_uniformity_basis_le (λ _, id) (λ ε ε₀, ⟨ε, ε₀, le_refl ε⟩)
theorem mem_uniformity_dist {s : set (α×α)} :
s ∈ 𝓤 α ↔ (∃ε>0, ∀{a b:α}, dist a b < ε → (a, b) ∈ s) :=
uniformity_basis_dist.mem_uniformity_iff
/-- A constant size neighborhood of the diagonal is an entourage. -/
theorem dist_mem_uniformity {ε:ℝ} (ε0 : 0 < ε) :
{p:α×α | dist p.1 p.2 < ε} ∈ 𝓤 α :=
mem_uniformity_dist.2 ⟨ε, ε0, λ a b, id⟩
theorem uniform_continuous_iff [metric_space β] {f : α → β} :
uniform_continuous f ↔ ∀ ε > 0, ∃ δ > 0,
∀{a b:α}, dist a b < δ → dist (f a) (f b) < ε :=
uniformity_basis_dist.uniform_continuous_iff uniformity_basis_dist
theorem uniform_embedding_iff [metric_space β] {f : α → β} :
uniform_embedding f ↔ function.injective f ∧ uniform_continuous f ∧
∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, dist (f a) (f b) < ε → dist a b < δ :=
uniform_embedding_def'.trans $ and_congr iff.rfl $ and_congr iff.rfl
⟨λ H δ δ0, let ⟨t, tu, ht⟩ := H _ (dist_mem_uniformity δ0),
⟨ε, ε0, hε⟩ := mem_uniformity_dist.1 tu in
⟨ε, ε0, λ a b h, ht _ _ (hε h)⟩,
λ H s su, let ⟨δ, δ0, hδ⟩ := mem_uniformity_dist.1 su, ⟨ε, ε0, hε⟩ := H _ δ0 in
⟨_, dist_mem_uniformity ε0, λ a b h, hδ (hε h)⟩⟩
/-- A map between metric spaces is a uniform embedding if and only if the distance between `f x`
and `f y` is controlled in terms of the distance between `x` and `y` and conversely. -/
theorem uniform_embedding_iff' [metric_space β] {f : α → β} :
uniform_embedding f ↔
(∀ ε > 0, ∃ δ > 0, ∀ {a b : α}, dist a b < δ → dist (f a) (f b) < ε) ∧
(∀ δ > 0, ∃ ε > 0, ∀ {a b : α}, dist (f a) (f b) < ε → dist a b < δ) :=
begin
split,
{ assume h,
exact ⟨uniform_continuous_iff.1 (uniform_embedding_iff.1 h).2.1,
(uniform_embedding_iff.1 h).2.2⟩ },
{ rintros ⟨h₁, h₂⟩,
refine uniform_embedding_iff.2 ⟨_, uniform_continuous_iff.2 h₁, h₂⟩,
assume x y hxy,
have : dist x y ≤ 0,
{ refine le_of_forall_lt' (λδ δpos, _),
rcases h₂ δ δpos with ⟨ε, εpos, hε⟩,
have : dist (f x) (f y) < ε, by simpa [hxy],
exact hε this },
simpa using this }
end
theorem totally_bounded_iff {s : set α} :
totally_bounded s ↔ ∀ ε > 0, ∃t : set α, finite t ∧ s ⊆ ⋃y∈t, ball y ε :=
⟨λ H ε ε0, H _ (dist_mem_uniformity ε0),
λ H r ru, let ⟨ε, ε0, hε⟩ := mem_uniformity_dist.1 ru,
⟨t, ft, h⟩ := H ε ε0 in
⟨t, ft, subset.trans h $ Union_subset_Union $ λ y, Union_subset_Union $ λ yt z, hε⟩⟩
/-- A metric space space is totally bounded if one can reconstruct up to any ε>0 any element of the
space from finitely many data. -/
lemma totally_bounded_of_finite_discretization {α : Type u} [metric_space α] {s : set α}
(H : ∀ε > (0 : ℝ), ∃ (β : Type u) [fintype β] (F : s → β),
∀x y, F x = F y → dist (x:α) y < ε) :
totally_bounded s :=
begin
cases s.eq_empty_or_nonempty with hs hs,
{ rw hs, exact totally_bounded_empty },
rcases hs with ⟨x0, hx0⟩,
haveI : inhabited s := ⟨⟨x0, hx0⟩⟩,
refine totally_bounded_iff.2 (λ ε ε0, _),
rcases H ε ε0 with ⟨β, fβ, F, hF⟩,
let Finv := function.inv_fun F,
refine ⟨range (subtype.val ∘ Finv), finite_range _, λ x xs, _⟩,
let x' := Finv (F ⟨x, xs⟩),
have : F x' = F ⟨x, xs⟩ := function.inv_fun_eq ⟨⟨x, xs⟩, rfl⟩,
simp only [set.mem_Union, set.mem_range],
exact ⟨_, ⟨F ⟨x, xs⟩, rfl⟩, hF _ _ this.symm⟩
end
/-- Expressing locally uniform convergence on a set using `dist`. -/
@[nolint ge_or_gt] -- see Note [nolint_ge]
lemma tendsto_locally_uniformly_on_iff {ι : Type*} [topological_space β]
{F : ι → β → α} {f : β → α} {p : filter ι} {s : set β} :
tendsto_locally_uniformly_on F f p s ↔
∀ ε > 0, ∀ x ∈ s, ∃ t ∈ nhds_within x s, ∀ᶠ n in p, ∀ y ∈ t, dist (f y) (F n y) < ε :=
begin
refine ⟨λ H ε hε, H _ (dist_mem_uniformity hε), λ H u hu x hx, _⟩,
rcases mem_uniformity_dist.1 hu with ⟨ε, εpos, hε⟩,
rcases H ε εpos x hx with ⟨t, ht, Ht⟩,
exact ⟨t, ht, Ht.mono (λ n hs x hx, hε (hs x hx))⟩
end
/-- Expressing uniform convergence on a set using `dist`. -/
@[nolint ge_or_gt] -- see Note [nolint_ge]
lemma tendsto_uniformly_on_iff {ι : Type*}
{F : ι → β → α} {f : β → α} {p : filter ι} {s : set β} :
tendsto_uniformly_on F f p s ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x ∈ s, dist (f x) (F n x) < ε :=
begin
refine ⟨λ H ε hε, H _ (dist_mem_uniformity hε), λ H u hu, _⟩,
rcases mem_uniformity_dist.1 hu with ⟨ε, εpos, hε⟩,
exact (H ε εpos).mono (λ n hs x hx, hε (hs x hx))
end
/-- Expressing locally uniform convergence using `dist`. -/
@[nolint ge_or_gt] -- see Note [nolint_ge]
lemma tendsto_locally_uniformly_iff {ι : Type*} [topological_space β]
{F : ι → β → α} {f : β → α} {p : filter ι} :
tendsto_locally_uniformly F f p ↔
∀ ε > 0, ∀ (x : β), ∃ t ∈ 𝓝 x, ∀ᶠ n in p, ∀ y ∈ t, dist (f y) (F n y) < ε :=
by simp [← nhds_within_univ, ← tendsto_locally_uniformly_on_univ, tendsto_locally_uniformly_on_iff]
/-- Expressing uniform convergence using `dist`. -/
@[nolint ge_or_gt] -- see Note [nolint_ge]
lemma tendsto_uniformly_iff {ι : Type*}
{F : ι → β → α} {f : β → α} {p : filter ι} :
tendsto_uniformly F f p ↔ ∀ ε > 0, ∀ᶠ n in p, ∀ x, dist (f x) (F n x) < ε :=
by { rw [← tendsto_uniformly_on_univ, tendsto_uniformly_on_iff], simp }
protected lemma cauchy_iff {f : filter α} :
cauchy f ↔ f ≠ ⊥ ∧ ∀ ε > 0, ∃ t ∈ f, ∀ x y ∈ t, dist x y < ε :=
uniformity_basis_dist.cauchy_iff
theorem nhds_basis_ball : (𝓝 x).has_basis (λ ε:ℝ, 0 < ε) (ball x) :=
nhds_basis_uniformity uniformity_basis_dist
theorem mem_nhds_iff : s ∈ 𝓝 x ↔ ∃ε>0, ball x ε ⊆ s :=
nhds_basis_ball.mem_iff
theorem nhds_basis_closed_ball : (𝓝 x).has_basis (λ ε:ℝ, 0 < ε) (closed_ball x) :=
nhds_basis_uniformity uniformity_basis_dist_le
theorem nhds_basis_ball_inv_nat_succ :
(𝓝 x).has_basis (λ _, true) (λ n:ℕ, ball x (1 / (↑n+1))) :=
nhds_basis_uniformity uniformity_basis_dist_inv_nat_succ
theorem nhds_basis_ball_inv_nat_pos :
(𝓝 x).has_basis (λ n, 0<n) (λ n:ℕ, ball x (1 / ↑n)) :=
nhds_basis_uniformity uniformity_basis_dist_inv_nat_pos
theorem is_open_iff : is_open s ↔ ∀x∈s, ∃ε>0, ball x ε ⊆ s :=
by simp only [is_open_iff_nhds, mem_nhds_iff, le_principal_iff]
theorem is_open_ball : is_open (ball x ε) :=
is_open_iff.2 $ λ y, exists_ball_subset_ball
theorem ball_mem_nhds (x : α) {ε : ℝ} (ε0 : 0 < ε) : ball x ε ∈ 𝓝 x :=
mem_nhds_sets is_open_ball (mem_ball_self ε0)
theorem nhds_within_basis_ball {s : set α} :
(nhds_within x s).has_basis (λ ε:ℝ, 0 < ε) (λ ε, ball x ε ∩ s) :=
nhds_within_has_basis nhds_basis_ball s
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem mem_nhds_within_iff {t : set α} : s ∈ nhds_within x t ↔ ∃ε>0, ball x ε ∩ t ⊆ s :=
nhds_within_basis_ball.mem_iff
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem tendsto_nhds_within_nhds_within [metric_space β] {t : set β} {f : α → β} {a b} :
tendsto f (nhds_within a s) (nhds_within b t) ↔
∀ ε > 0, ∃ δ > 0, ∀{x:α}, x ∈ s → dist x a < δ → f x ∈ t ∧ dist (f x) b < ε :=
(nhds_within_basis_ball.tendsto_iff nhds_within_basis_ball).trans $
by simp only [inter_comm, mem_inter_iff, and_imp, mem_ball]
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem tendsto_nhds_within_nhds [metric_space β] {f : α → β} {a b} :
tendsto f (nhds_within a s) (𝓝 b) ↔
∀ ε > 0, ∃ δ > 0, ∀{x:α}, x ∈ s → dist x a < δ → dist (f x) b < ε :=
by { rw [← nhds_within_univ, tendsto_nhds_within_nhds_within],
simp only [mem_univ, true_and] }
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem tendsto_nhds_nhds [metric_space β] {f : α → β} {a b} :
tendsto f (𝓝 a) (𝓝 b) ↔
∀ ε > 0, ∃ δ > 0, ∀{x:α}, dist x a < δ → dist (f x) b < ε :=
nhds_basis_ball.tendsto_iff nhds_basis_ball
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem continuous_at_iff [metric_space β] {f : α → β} {a : α} :
continuous_at f a ↔
∀ ε > 0, ∃ δ > 0, ∀{x:α}, dist x a < δ → dist (f x) (f a) < ε :=
by rw [continuous_at, tendsto_nhds_nhds]
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem continuous_within_at_iff [metric_space β] {f : α → β} {a : α} {s : set α} :
continuous_within_at f s a ↔
∀ ε > 0, ∃ δ > 0, ∀{x:α}, x ∈ s → dist x a < δ → dist (f x) (f a) < ε :=
by rw [continuous_within_at, tendsto_nhds_within_nhds]
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem continuous_on_iff [metric_space β] {f : α → β} {s : set α} :
continuous_on f s ↔
∀ (b ∈ s) (ε > 0), ∃ δ > 0, ∀a ∈ s, dist a b < δ → dist (f a) (f b) < ε :=
by simp [continuous_on, continuous_within_at_iff]
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem continuous_iff [metric_space β] {f : α → β} :
continuous f ↔
∀b (ε > 0), ∃ δ > 0, ∀a, dist a b < δ → dist (f a) (f b) < ε :=
continuous_iff_continuous_at.trans $ forall_congr $ λ b, tendsto_nhds_nhds
theorem tendsto_nhds {f : filter β} {u : β → α} {a : α} :
tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, dist (u x) a < ε :=
nhds_basis_ball.tendsto_right_iff
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem continuous_at_iff' [topological_space β] {f : β → α} {b : β} :
continuous_at f b ↔
∀ ε > 0, ∀ᶠ x in 𝓝 b, dist (f x) (f b) < ε :=
by rw [continuous_at, tendsto_nhds]
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem continuous_within_at_iff' [topological_space β] {f : β → α} {b : β} {s : set β} :
continuous_within_at f s b ↔
∀ ε > 0, ∀ᶠ x in nhds_within b s, dist (f x) (f b) < ε :=
by rw [continuous_within_at, tendsto_nhds]
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem continuous_on_iff' [topological_space β] {f : β → α} {s : set β} :
continuous_on f s ↔
∀ (b ∈ s) (ε > 0), ∀ᶠ x in nhds_within b s, dist (f x) (f b) < ε :=
by simp [continuous_on, continuous_within_at_iff']
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem continuous_iff' [topological_space β] {f : β → α} :
continuous f ↔ ∀a (ε > 0), ∀ᶠ x in 𝓝 a, dist (f x) (f a) < ε :=
continuous_iff_continuous_at.trans $ forall_congr $ λ b, tendsto_nhds
theorem tendsto_at_top [nonempty β] [semilattice_sup β] {u : β → α} {a : α} :
tendsto u at_top (𝓝 a) ↔ ∀ε>0, ∃N, ∀n≥N, dist (u n) a < ε :=
(at_top_basis.tendsto_iff nhds_basis_ball).trans $
by { simp only [exists_prop, true_and], refl }
end metric
open metric
@[priority 100] -- see Note [lower instance priority]
instance metric_space.to_separated : separated α :=
separated_def.2 $ λ x y h, eq_of_forall_dist_le $
λ ε ε0, le_of_lt (h _ (dist_mem_uniformity ε0))
/-Instantiate a metric space as an emetric space. Before we can state the instance,
we need to show that the uniform structure coming from the edistance and the
distance coincide. -/
/-- Expressing the uniformity in terms of `edist` -/
protected lemma metric.uniformity_basis_edist :
(𝓤 α).has_basis (λ ε:ennreal, 0 < ε) (λ ε, {p | edist p.1 p.2 < ε}) :=
⟨begin
intro t,
refine mem_uniformity_dist.trans ⟨_, _⟩; rintro ⟨ε, ε0, Hε⟩,
{ use [ennreal.of_real ε, ennreal.of_real_pos.2 ε0],
rintros ⟨a, b⟩,
simp only [edist_dist, ennreal.of_real_lt_of_real_iff ε0],
exact Hε },
{ rcases ennreal.lt_iff_exists_real_btwn.1 ε0 with ⟨ε', _, ε0', hε⟩,
rw [ennreal.of_real_pos] at ε0',
refine ⟨ε', ε0', λ a b h, Hε (lt_trans _ hε)⟩,
rwa [edist_dist, ennreal.of_real_lt_of_real_iff ε0'] }
end⟩
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem metric.uniformity_edist : 𝓤 α = (⨅ ε>0, principal {p:α×α | edist p.1 p.2 < ε}) :=
metric.uniformity_basis_edist.eq_binfi
/-- A metric space induces an emetric space -/
@[priority 100] -- see Note [lower instance priority]
instance metric_space.to_emetric_space : emetric_space α :=
{ edist := edist,
edist_self := by simp [edist_dist],
eq_of_edist_eq_zero := assume x y h, by simpa [edist_dist] using h,
edist_comm := by simp only [edist_dist, dist_comm]; simp,
edist_triangle := assume x y z, begin
simp only [edist_dist, ← ennreal.of_real_add, dist_nonneg],
rw ennreal.of_real_le_of_real_iff _,
{ exact dist_triangle _ _ _ },
{ simpa using add_le_add (dist_nonneg : 0 ≤ dist x y) dist_nonneg }
end,
uniformity_edist := metric.uniformity_edist,
..‹metric_space α› }
/-- Balls defined using the distance or the edistance coincide -/
lemma metric.emetric_ball {x : α} {ε : ℝ} : emetric.ball x (ennreal.of_real ε) = ball x ε :=
begin
ext y,
simp only [emetric.mem_ball, mem_ball, edist_dist],
exact ennreal.of_real_lt_of_real_iff_of_nonneg dist_nonneg
end
/-- Balls defined using the distance or the edistance coincide -/
lemma metric.emetric_ball_nnreal {x : α} {ε : nnreal} : emetric.ball x ε = ball x ε :=
by { convert metric.emetric_ball, simp }
/-- Closed balls defined using the distance or the edistance coincide -/
lemma metric.emetric_closed_ball {x : α} {ε : ℝ} (h : 0 ≤ ε) :
emetric.closed_ball x (ennreal.of_real ε) = closed_ball x ε :=
by ext y; simp [edist_dist]; rw ennreal.of_real_le_of_real_iff h
/-- Closed balls defined using the distance or the edistance coincide -/
lemma metric.emetric_closed_ball_nnreal {x : α} {ε : nnreal} :
emetric.closed_ball x ε = closed_ball x ε :=
by { convert metric.emetric_closed_ball ε.2, simp }
def metric_space.replace_uniformity {α} [U : uniform_space α] (m : metric_space α)
(H : @uniformity _ U = @uniformity _ emetric_space.to_uniform_space') :
metric_space α :=
{ dist := @dist _ m.to_has_dist,
dist_self := dist_self,
eq_of_dist_eq_zero := @eq_of_dist_eq_zero _ _,
dist_comm := dist_comm,
dist_triangle := dist_triangle,
edist := edist,
edist_dist := edist_dist,
to_uniform_space := U,
uniformity_dist := H.trans metric_space.uniformity_dist }
/-- One gets a metric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the metric space and the emetric space. In this definition, the distance
is given separately, to be able to prescribe some expression which is not defeq to the push-forward
of the edistance to reals. -/
def emetric_space.to_metric_space_of_dist {α : Type u} [e : emetric_space α]
(dist : α → α → ℝ)
(edist_ne_top : ∀x y: α, edist x y ≠ ⊤)
(h : ∀x y, dist x y = ennreal.to_real (edist x y)) :
metric_space α :=
let m : metric_space α :=
{ dist := dist,
eq_of_dist_eq_zero := λx y hxy, by simpa [h, ennreal.to_real_eq_zero_iff, edist_ne_top x y] using hxy,
dist_self := λx, by simp [h],
dist_comm := λx y, by simp [h, emetric_space.edist_comm],
dist_triangle := λx y z, begin
simp only [h],
rw [← ennreal.to_real_add (edist_ne_top _ _) (edist_ne_top _ _),
ennreal.to_real_le_to_real (edist_ne_top _ _)],
{ exact edist_triangle _ _ _ },
{ simp [ennreal.add_eq_top, edist_ne_top] }
end,
edist := λx y, edist x y,
edist_dist := λx y, by simp [h, ennreal.of_real_to_real, edist_ne_top] } in
m.replace_uniformity $ by { rw [uniformity_edist, metric.uniformity_edist], refl }
/-- One gets a metric space from an emetric space if the edistance
is everywhere finite, by pushing the edistance to reals. We set it up so that the edist and the
uniformity are defeq in the metric space and the emetric space. -/
def emetric_space.to_metric_space {α : Type u} [e : emetric_space α] (h : ∀x y: α, edist x y ≠ ⊤) :
metric_space α :=
emetric_space.to_metric_space_of_dist (λx y, ennreal.to_real (edist x y)) h (λx y, rfl)
/-- A very useful criterion to show that a space is complete is to show that all sequences
which satisfy a bound of the form `dist (u n) (u m) < B N` for all `n m ≥ N` are
converging. This is often applied for `B N = 2^{-N}`, i.e., with a very fast convergence to
`0`, which makes it possible to use arguments of converging series, while this is impossible
to do in general for arbitrary Cauchy sequences. -/
theorem metric.complete_of_convergent_controlled_sequences (B : ℕ → real) (hB : ∀n, 0 < B n)
(H : ∀u : ℕ → α, (∀N n m : ℕ, N ≤ n → N ≤ m → dist (u n) (u m) < B N) → ∃x, tendsto u at_top (𝓝 x)) :
complete_space α :=
begin
-- this follows from the same criterion in emetric spaces. We just need to translate
-- the convergence assumption from `dist` to `edist`
apply emetric.complete_of_convergent_controlled_sequences (λn, ennreal.of_real (B n)),
{ simp [hB] },
{ assume u Hu,
apply H,
assume N n m hn hm,
rw [← ennreal.of_real_lt_of_real_iff (hB N), ← edist_dist],
exact Hu N n m hn hm }
end
theorem metric.complete_of_cauchy_seq_tendsto :
(∀ u : ℕ → α, cauchy_seq u → ∃a, tendsto u at_top (𝓝 a)) → complete_space α :=
emetric.complete_of_cauchy_seq_tendsto
section real
/-- Instantiate the reals as a metric space. -/
instance real.metric_space : metric_space ℝ :=
{ dist := λx y, abs (x - y),
dist_self := by simp [abs_zero],
eq_of_dist_eq_zero := by simp [sub_eq_zero],
dist_comm := assume x y, abs_sub _ _,
dist_triangle := assume x y z, abs_sub_le _ _ _ }
theorem real.dist_eq (x y : ℝ) : dist x y = abs (x - y) := rfl
theorem real.dist_0_eq_abs (x : ℝ) : dist x 0 = abs x :=
by simp [real.dist_eq]
instance : order_topology ℝ :=
order_topology_of_nhds_abs $ λ x, begin
simp only [show ∀ r, {b : ℝ | abs (x - b) < r} = ball x r,
by simp [abs_sub, ball, real.dist_eq]],
apply le_antisymm,
{ simp [le_infi_iff],
exact λ ε ε0, mem_nhds_sets (is_open_ball) (mem_ball_self ε0) },
{ intros s h,
rcases mem_nhds_iff.1 h with ⟨ε, ε0, ss⟩,
exact mem_infi_sets _ (mem_infi_sets ε0 (mem_principal_sets.2 ss)) },
end
lemma closed_ball_Icc {x r : ℝ} : closed_ball x r = Icc (x-r) (x+r) :=
by ext y; rw [mem_closed_ball, dist_comm, real.dist_eq,
abs_sub_le_iff, mem_Icc, ← sub_le_iff_le_add', sub_le]
/-- Special case of the sandwich theorem; see `tendsto_of_tendsto_of_tendsto_of_le_of_le`
and `tendsto_of_tendsto_of_tendsto_of_le_of_le'` for the general case. -/
lemma squeeze_zero {α} {f g : α → ℝ} {t₀ : filter α} (hf : ∀t, 0 ≤ f t) (hft : ∀t, f t ≤ g t)
(g0 : tendsto g t₀ (𝓝 0)) : tendsto f t₀ (𝓝 0) :=
tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds g0 hf hft
theorem metric.uniformity_eq_comap_nhds_zero :
𝓤 α = comap (λp:α×α, dist p.1 p.2) (𝓝 (0 : ℝ)) :=
by { ext s,
simp [mem_uniformity_dist, (nhds_basis_ball.comap _).mem_iff, subset_def, real.dist_0_eq_abs] }
lemma cauchy_seq_iff_tendsto_dist_at_top_0 [nonempty β] [semilattice_sup β] {u : β → α} :
cauchy_seq u ↔ tendsto (λ (n : β × β), dist (u n.1) (u n.2)) at_top (𝓝 0) :=
by rw [cauchy_seq_iff_tendsto, metric.uniformity_eq_comap_nhds_zero, tendsto_comap_iff,
prod.map_def]
lemma tendsto_uniformity_iff_dist_tendsto_zero {ι : Type*} {f : ι → α × α} {p : filter ι} :
tendsto f p (𝓤 α) ↔ tendsto (λ x, dist (f x).1 (f x).2) p (𝓝 0) :=
by rw [metric.uniformity_eq_comap_nhds_zero, tendsto_comap_iff]
lemma filter.tendsto.congr_dist {ι : Type*} {f₁ f₂ : ι → α} {p : filter ι} {a : α}
(h₁ : tendsto f₁ p (𝓝 a)) (h : tendsto (λ x, dist (f₁ x) (f₂ x)) p (𝓝 0)) :
tendsto f₂ p (𝓝 a) :=
h₁.congr_uniformity $ tendsto_uniformity_iff_dist_tendsto_zero.2 h
alias filter.tendsto.congr_dist ← tendsto_of_tendsto_of_dist
lemma tendsto_iff_of_dist {ι : Type*} {f₁ f₂ : ι → α} {p : filter ι} {a : α}
(h : tendsto (λ x, dist (f₁ x) (f₂ x)) p (𝓝 0)) :
tendsto f₁ p (𝓝 a) ↔ tendsto f₂ p (𝓝 a) :=
uniform.tendsto_congr $ tendsto_uniformity_iff_dist_tendsto_zero.2 h
end real
section cauchy_seq
variables [nonempty β] [semilattice_sup β]
/-- In a metric space, Cauchy sequences are characterized by the fact that, eventually,
the distance between its elements is arbitrarily small -/
theorem metric.cauchy_seq_iff {u : β → α} :
cauchy_seq u ↔ ∀ε>0, ∃N, ∀m n≥N, dist (u m) (u n) < ε :=
uniformity_basis_dist.cauchy_seq_iff
/-- A variation around the metric characterization of Cauchy sequences -/
theorem metric.cauchy_seq_iff' {u : β → α} :
cauchy_seq u ↔ ∀ε>0, ∃N, ∀n≥N, dist (u n) (u N) < ε :=
uniformity_basis_dist.cauchy_seq_iff'
/-- If the distance between `s n` and `s m`, `n, m ≥ N` is bounded above by `b N`
and `b` converges to zero, then `s` is a Cauchy sequence. -/
lemma cauchy_seq_of_le_tendsto_0 {s : β → α} (b : β → ℝ)
(h : ∀ n m N : β, N ≤ n → N ≤ m → dist (s n) (s m) ≤ b N) (h₀ : tendsto b at_top (nhds 0)) :
cauchy_seq s :=
metric.cauchy_seq_iff.2 $ λ ε ε0,
(metric.tendsto_at_top.1 h₀ ε ε0).imp $ λ N hN m n hm hn,
calc dist (s m) (s n) ≤ b N : h m n N hm hn
... ≤ abs (b N) : le_abs_self _
... = dist (b N) 0 : by rw real.dist_0_eq_abs; refl
... < ε : (hN _ (le_refl N))
/-- A Cauchy sequence on the natural numbers is bounded. -/
theorem cauchy_seq_bdd {u : ℕ → α} (hu : cauchy_seq u) :
∃ R > 0, ∀ m n, dist (u m) (u n) < R :=
begin
rcases metric.cauchy_seq_iff'.1 hu 1 zero_lt_one with ⟨N, hN⟩,
suffices : ∃ R > 0, ∀ n, dist (u n) (u N) < R,
{ rcases this with ⟨R, R0, H⟩,
exact ⟨_, add_pos R0 R0, λ m n,
lt_of_le_of_lt (dist_triangle_right _ _ _) (add_lt_add (H m) (H n))⟩ },
let R := finset.sup (finset.range N) (λ n, nndist (u n) (u N)),
refine ⟨↑R + 1, add_pos_of_nonneg_of_pos R.2 zero_lt_one, λ n, _⟩,
cases le_or_lt N n,
{ exact lt_of_lt_of_le (hN _ h) (le_add_of_nonneg_left R.2) },
{ have : _ ≤ R := finset.le_sup (finset.mem_range.2 h),
exact lt_of_le_of_lt this (lt_add_of_pos_right _ zero_lt_one) }
end
/-- Yet another metric characterization of Cauchy sequences on integers. This one is often the
most efficient. -/
lemma cauchy_seq_iff_le_tendsto_0 {s : ℕ → α} : cauchy_seq s ↔ ∃ b : ℕ → ℝ,
(∀ n, 0 ≤ b n) ∧
(∀ n m N : ℕ, N ≤ n → N ≤ m → dist (s n) (s m) ≤ b N) ∧
tendsto b at_top (𝓝 0) :=
⟨λ hs, begin
/- `s` is a Cauchy sequence. The sequence `b` will be constructed by taking
the supremum of the distances between `s n` and `s m` for `n m ≥ N`.
First, we prove that all these distances are bounded, as otherwise the Sup
would not make sense. -/
let S := λ N, (λ(p : ℕ × ℕ), dist (s p.1) (s p.2)) '' {p | p.1 ≥ N ∧ p.2 ≥ N},
have hS : ∀ N, ∃ x, ∀ y ∈ S N, y ≤ x,
{ rcases cauchy_seq_bdd hs with ⟨R, R0, hR⟩,
refine λ N, ⟨R, _⟩, rintro _ ⟨⟨m, n⟩, _, rfl⟩,
exact le_of_lt (hR m n) },
have bdd : bdd_above (range (λ(p : ℕ × ℕ), dist (s p.1) (s p.2))),
{ rcases cauchy_seq_bdd hs with ⟨R, R0, hR⟩,
use R, rintro _ ⟨⟨m, n⟩, rfl⟩, exact le_of_lt (hR m n) },
-- Prove that it bounds the distances of points in the Cauchy sequence
have ub : ∀ m n N, N ≤ m → N ≤ n → dist (s m) (s n) ≤ Sup (S N) :=
λ m n N hm hn, real.le_Sup _ (hS N) ⟨⟨_, _⟩, ⟨hm, hn⟩, rfl⟩,
have S0m : ∀ n, (0:ℝ) ∈ S n := λ n, ⟨⟨n, n⟩, ⟨le_refl _, le_refl _⟩, dist_self _⟩,
have S0 := λ n, real.le_Sup _ (hS n) (S0m n),
-- Prove that it tends to `0`, by using the Cauchy property of `s`
refine ⟨λ N, Sup (S N), S0, ub, metric.tendsto_at_top.2 (λ ε ε0, _)⟩,
refine (metric.cauchy_seq_iff.1 hs (ε/2) (half_pos ε0)).imp (λ N hN n hn, _),
rw [real.dist_0_eq_abs, abs_of_nonneg (S0 n)],
refine lt_of_le_of_lt (real.Sup_le_ub _ ⟨_, S0m _⟩ _) (half_lt_self ε0),
rintro _ ⟨⟨m', n'⟩, ⟨hm', hn'⟩, rfl⟩,
exact le_of_lt (hN _ _ (le_trans hn hm') (le_trans hn hn'))
end,
λ ⟨b, _, b_bound, b_lim⟩, cauchy_seq_of_le_tendsto_0 b b_bound b_lim⟩
end cauchy_seq
def metric_space.induced {α β} (f : α → β) (hf : function.injective f)
(m : metric_space β) : metric_space α :=
{ dist := λ x y, dist (f x) (f y),
dist_self := λ x, dist_self _,
eq_of_dist_eq_zero := λ x y h, hf (dist_eq_zero.1 h),
dist_comm := λ x y, dist_comm _ _,
dist_triangle := λ x y z, dist_triangle _ _ _,
edist := λ x y, edist (f x) (f y),
edist_dist := λ x y, edist_dist _ _,
to_uniform_space := uniform_space.comap f m.to_uniform_space,
uniformity_dist := begin
apply @uniformity_dist_of_mem_uniformity _ _ _ _ _ (λ x y, dist (f x) (f y)),
refine λ s, mem_comap_sets.trans _,
split; intro H,
{ rcases H with ⟨r, ru, rs⟩,
rcases mem_uniformity_dist.1 ru with ⟨ε, ε0, hε⟩,
refine ⟨ε, ε0, λ a b h, rs (hε _)⟩, exact h },
{ rcases H with ⟨ε, ε0, hε⟩,
exact ⟨_, dist_mem_uniformity ε0, λ ⟨a, b⟩, hε⟩ }
end }
instance subtype.metric_space {α : Type*} {p : α → Prop} [t : metric_space α] :
metric_space (subtype p) :=
metric_space.induced coe (λ x y, subtype.coe_ext.2) t
theorem subtype.dist_eq {p : α → Prop} (x y : subtype p) : dist x y = dist (x : α) y := rfl
section nnreal
instance : metric_space nnreal := by unfold nnreal; apply_instance
lemma nnreal.dist_eq (a b : nnreal) : dist a b = abs ((a:ℝ) - b) := rfl
lemma nnreal.nndist_eq (a b : nnreal) :
nndist a b = max (a - b) (b - a) :=
begin
wlog h : a ≤ b,
{ apply nnreal.coe_eq.1,
rw [nnreal.sub_eq_zero h, max_eq_right (zero_le $ b - a), ← dist_nndist, nnreal.dist_eq,
nnreal.coe_sub h, abs, neg_sub],
apply max_eq_right,
linarith [nnreal.coe_le_coe.2 h] },
rwa [nndist_comm, max_comm]
end
end nnreal
section prod
instance prod.metric_space_max [metric_space β] : metric_space (α × β) :=
{ dist := λ x y, max (dist x.1 y.1) (dist x.2 y.2),
dist_self := λ x, by simp,
eq_of_dist_eq_zero := λ x y h, begin
cases max_le_iff.1 (le_of_eq h) with h₁ h₂,
exact prod.ext_iff.2 ⟨dist_le_zero.1 h₁, dist_le_zero.1 h₂⟩
end,
dist_comm := λ x y, by simp [dist_comm],
dist_triangle := λ x y z, max_le
(le_trans (dist_triangle _ _ _) (add_le_add (le_max_left _ _) (le_max_left _ _)))
(le_trans (dist_triangle _ _ _) (add_le_add (le_max_right _ _) (le_max_right _ _))),
edist := λ x y, max (edist x.1 y.1) (edist x.2 y.2),
edist_dist := assume x y, begin
have : monotone ennreal.of_real := assume x y h, ennreal.of_real_le_of_real h,
rw [edist_dist, edist_dist, ← this.map_max]
end,
uniformity_dist := begin
refine uniformity_prod.trans _,
simp only [uniformity_basis_dist.eq_binfi, comap_infi],
rw ← infi_inf_eq, congr, funext,
rw ← infi_inf_eq, congr, funext,
simp [inf_principal, ext_iff, max_lt_iff]
end,
to_uniform_space := prod.uniform_space }
lemma prod.dist_eq [metric_space β] {x y : α × β} :
dist x y = max (dist x.1 y.1) (dist x.2 y.2) := rfl
end prod
theorem uniform_continuous_dist' : uniform_continuous (λp:α×α, dist p.1 p.2) :=
metric.uniform_continuous_iff.2 (λ ε ε0, ⟨ε/2, half_pos ε0,
begin
suffices,
{ intros p q h, cases p with p₁ p₂, cases q with q₁ q₂,
cases max_lt_iff.1 h with h₁ h₂, clear h,
dsimp at h₁ h₂ ⊢,
rw real.dist_eq,
refine abs_sub_lt_iff.2 ⟨_, _⟩,
{ revert p₁ p₂ q₁ q₂ h₁ h₂, exact this },
{ apply this; rwa dist_comm } },
intros p₁ p₂ q₁ q₂ h₁ h₂,
have := add_lt_add
(abs_sub_lt_iff.1 (lt_of_le_of_lt (abs_dist_sub_le p₁ q₁ p₂) h₁)).1
(abs_sub_lt_iff.1 (lt_of_le_of_lt (abs_dist_sub_le p₂ q₂ q₁) h₂)).1,
rwa [add_halves, dist_comm p₂, sub_add_sub_cancel, dist_comm q₂] at this
end⟩)
theorem uniform_continuous_dist [uniform_space β] {f g : β → α}
(hf : uniform_continuous f) (hg : uniform_continuous g) :
uniform_continuous (λb, dist (f b) (g b)) :=
uniform_continuous_dist'.comp (hf.prod_mk hg)
theorem continuous_dist : continuous (λp:α×α, dist p.1 p.2) :=
uniform_continuous_dist'.continuous
theorem continuous.dist [topological_space β] {f g : β → α}
(hf : continuous f) (hg : continuous g) : continuous (λb, dist (f b) (g b)) :=
continuous_dist.comp (hf.prod_mk hg)
theorem filter.tendsto.dist {f g : β → α} {x : filter β} {a b : α}
(hf : tendsto f x (𝓝 a)) (hg : tendsto g x (𝓝 b)) :
tendsto (λx, dist (f x) (g x)) x (𝓝 (dist a b)) :=
(continuous_dist.tendsto (a, b)).comp (hf.prod_mk_nhds hg)
lemma nhds_comap_dist (a : α) : (𝓝 (0 : ℝ)).comap (λa', dist a' a) = 𝓝 a :=
by simp only [@nhds_eq_comap_uniformity α, metric.uniformity_eq_comap_nhds_zero,
comap_comap_comp, (∘), dist_comm]
lemma tendsto_iff_dist_tendsto_zero {f : β → α} {x : filter β} {a : α} :
(tendsto f x (𝓝 a)) ↔ (tendsto (λb, dist (f b) a) x (𝓝 0)) :=
by rw [← nhds_comap_dist a, tendsto_comap_iff]
lemma uniform_continuous_nndist : uniform_continuous (λp:α×α, nndist p.1 p.2) :=
uniform_continuous_subtype_mk uniform_continuous_dist' _
lemma continuous_nndist : continuous (λp:α×α, nndist p.1 p.2) :=
uniform_continuous_nndist.continuous
lemma continuous.nndist [topological_space β] {f g : β → α}
(hf : continuous f) (hg : continuous g) : continuous (λb, nndist (f b) (g b)) :=
continuous_nndist.comp (hf.prod_mk hg)
theorem filter.tendsto.nndist {f g : β → α} {x : filter β} {a b : α}
(hf : tendsto f x (𝓝 a)) (hg : tendsto g x (𝓝 b)) :
tendsto (λx, nndist (f x) (g x)) x (𝓝 (nndist a b)) :=
(continuous_nndist.tendsto (a, b)).comp (hf.prod_mk_nhds hg)
namespace metric
variables {x y z : α} {ε ε₁ ε₂ : ℝ} {s : set α}
theorem is_closed_ball : is_closed (closed_ball x ε) :=
is_closed_le (continuous_id.dist continuous_const) continuous_const
/-- ε-characterization of the closure in metric spaces-/
@[nolint ge_or_gt] -- see Note [nolint_ge]
theorem mem_closure_iff {α : Type u} [metric_space α] {s : set α} {a : α} :
a ∈ closure s ↔ ∀ε>0, ∃b ∈ s, dist a b < ε :=
(mem_closure_iff_nhds_basis nhds_basis_ball).trans $
by simp only [mem_ball, dist_comm]
lemma mem_closure_range_iff {α : Type u} [metric_space α] {e : β → α} {a : α} :
a ∈ closure (range e) ↔ ∀ε>0, ∃ k : β, dist a (e k) < ε :=
by simp only [mem_closure_iff, exists_range_iff]
lemma mem_closure_range_iff_nat {α : Type u} [metric_space α] {e : β → α} {a : α} :
a ∈ closure (range e) ↔ ∀n : ℕ, ∃ k : β, dist a (e k) < 1 / ((n : ℝ) + 1) :=
(mem_closure_iff_nhds_basis nhds_basis_ball_inv_nat_succ).trans $
by simp only [mem_ball, dist_comm, exists_range_iff, forall_const]
theorem mem_of_closed' {α : Type u} [metric_space α] {s : set α} (hs : is_closed s)
{a : α} : a ∈ s ↔ ∀ε>0, ∃b ∈ s, dist a b < ε :=
by simpa only [closure_eq_of_is_closed hs] using @mem_closure_iff _ _ s a
end metric
section pi
open finset
variables {π : β → Type*} [fintype β] [∀b, metric_space (π b)]
/-- A finite product of metric spaces is a metric space, with the sup distance. -/
instance metric_space_pi : metric_space (Πb, π b) :=
begin
/- we construct the instance from the emetric space instance to avoid checking again that the
uniformity is the same as the product uniformity, but we register nevertheless a nice formula
for the distance -/
refine emetric_space.to_metric_space_of_dist
(λf g, ((sup univ (λb, nndist (f b) (g b)) : nnreal) : ℝ)) _ _,
show ∀ (x y : Π (b : β), π b), edist x y ≠ ⊤,
{ assume x y,
rw ← lt_top_iff_ne_top,
have : (⊥ : ennreal) < ⊤ := ennreal.coe_lt_top,
simp [edist, this],
assume b,
rw lt_top_iff_ne_top,
exact edist_ne_top (x b) (y b) },
show ∀ (x y : Π (b : β), π b), ↑(sup univ (λ (b : β), nndist (x b) (y b))) =
ennreal.to_real (sup univ (λ (b : β), edist (x b) (y b))),
{ assume x y,
have : sup univ (λ (b : β), edist (x b) (y b)) = ↑(sup univ (λ (b : β), nndist (x b) (y b))),
{ simp [edist_nndist],
refine eq.symm (comp_sup_eq_sup_comp _ _ _),
exact (assume x y h, ennreal.coe_le_coe.2 h), refl },
rw this,
refl }
end
lemma dist_pi_def (f g : Πb, π b) :
dist f g = (sup univ (λb, nndist (f b) (g b)) : nnreal) := rfl
lemma dist_pi_lt_iff {f g : Πb, π b} {r : ℝ} (hr : 0 < r) :
dist f g < r ↔ ∀b, dist (f b) (g b) < r :=
begin
lift r to nnreal using le_of_lt hr,
rw_mod_cast [dist_pi_def, finset.sup_lt_iff],
{ simp [nndist], refl },
{ exact hr }
end
lemma dist_pi_le_iff {f g : Πb, π b} {r : ℝ} (hr : 0 ≤ r) :
dist f g ≤ r ↔ ∀b, dist (f b) (g b) ≤ r :=
begin
lift r to nnreal using hr,
rw_mod_cast [dist_pi_def, finset.sup_le_iff],
simp [nndist],
refl
end
/-- An open ball in a product space is a product of open balls. The assumption `0 < r`
is necessary for the case of the empty product. -/
lemma ball_pi (x : Πb, π b) {r : ℝ} (hr : 0 < r) :
ball x r = { y | ∀b, y b ∈ ball (x b) r } :=
by { ext p, simp [dist_pi_lt_iff hr] }
/-- A closed ball in a product space is a product of closed balls. The assumption `0 ≤ r`
is necessary for the case of the empty product. -/
lemma closed_ball_pi (x : Πb, π b) {r : ℝ} (hr : 0 ≤ r) :
closed_ball x r = { y | ∀b, y b ∈ closed_ball (x b) r } :=
by { ext p, simp [dist_pi_le_iff hr] }
end pi
section compact
/-- Any compact set in a metric space can be covered by finitely many balls of a given positive
radius -/
lemma finite_cover_balls_of_compact {α : Type u} [metric_space α] {s : set α}
(hs : compact s) {e : ℝ} (he : 0 < e) :
∃t ⊆ s, finite t ∧ s ⊆ ⋃x∈t, ball x e :=
begin
apply hs.elim_finite_subcover_image,
{ simp [is_open_ball] },
{ intros x xs,
simp,
exact ⟨x, ⟨xs, by simpa⟩⟩ }
end
alias finite_cover_balls_of_compact ← compact.finite_cover_balls
end compact
section proper_space
open metric
/-- A metric space is proper if all closed balls are compact. -/
class proper_space (α : Type u) [metric_space α] : Prop :=
(compact_ball : ∀x:α, ∀r, compact (closed_ball x r))
/-- If all closed balls of large enough radius are compact, then the space is proper. Especially
useful when the lower bound for the radius is 0. -/
lemma proper_space_of_compact_closed_ball_of_le
(R : ℝ) (h : ∀x:α, ∀r, R ≤ r → compact (closed_ball x r)) :
proper_space α :=
⟨begin
assume x r,
by_cases hr : R ≤ r,
{ exact h x r hr },
{ have : closed_ball x r = closed_ball x R ∩ closed_ball x r,
{ symmetry,
apply inter_eq_self_of_subset_right,
exact closed_ball_subset_closed_ball (le_of_lt (not_le.1 hr)) },
rw this,
exact (h x R (le_refl _)).inter_right is_closed_ball }
end⟩
/- A compact metric space is proper -/
@[priority 100] -- see Note [lower instance priority]
instance proper_of_compact [compact_space α] : proper_space α :=
⟨assume x r, compact_of_is_closed_subset compact_univ is_closed_ball (subset_univ _)⟩
/-- A proper space is locally compact -/
@[priority 100] -- see Note [lower instance priority]
instance locally_compact_of_proper [proper_space α] :
locally_compact_space α :=
begin
apply locally_compact_of_compact_nhds,
intros x,
existsi closed_ball x 1,
split,
{ apply mem_nhds_iff.2,
existsi (1 : ℝ),
simp,
exact ⟨zero_lt_one, ball_subset_closed_ball⟩ },
{ apply proper_space.compact_ball }
end
/-- A proper space is complete -/
@[priority 100] -- see Note [lower instance priority]
instance complete_of_proper [proper_space α] : complete_space α :=
⟨begin
intros f hf,
/- We want to show that the Cauchy filter `f` is converging. It suffices to find a closed
ball (therefore compact by properness) where it is nontrivial. -/
have A : ∃ t ∈ f, ∀ x y ∈ t, dist x y < 1 := (metric.cauchy_iff.1 hf).2 1 zero_lt_one,
rcases A with ⟨t, ⟨t_fset, ht⟩⟩,
rcases nonempty_of_mem_sets hf.1 t_fset with ⟨x, xt⟩,
have : t ⊆ closed_ball x 1 := by intros y yt; simp [dist_comm]; apply le_of_lt (ht x y xt yt),
have : closed_ball x 1 ∈ f := f.sets_of_superset t_fset this,
rcases (compact_iff_totally_bounded_complete.1 (proper_space.compact_ball x 1)).2 f hf (le_principal_iff.2 this)
with ⟨y, _, hy⟩,
exact ⟨y, hy⟩
end⟩
/-- A proper metric space is separable, and therefore second countable. Indeed, any ball is
compact, and therefore admits a countable dense subset. Taking a countable union over the balls
centered at a fixed point and with integer radius, one obtains a countable set which is
dense in the whole space. -/
@[priority 100] -- see Note [lower instance priority]
instance second_countable_of_proper [proper_space α] :
second_countable_topology α :=
begin
/- We show that the space admits a countable dense subset. The case where the space is empty
is special, and trivial. -/
have A : (univ : set α) = ∅ → ∃(s : set α), countable s ∧ closure s = (univ : set α) :=
assume H, ⟨∅, ⟨by simp, by simp; exact H.symm⟩⟩,
have B : (univ : set α).nonempty → ∃(s : set α), countable s ∧ closure s = (univ : set α) :=
begin
/- When the space is not empty, we take a point `x` in the space, and then a countable set
`T r` which is dense in the closed ball `closed_ball x r` for each `r`. Then the set
`t = ⋃ T n` (where the union is over all integers `n`) is countable, as a countable union
of countable sets, and dense in the space by construction. -/
rintros ⟨x, x_univ⟩,
choose T a using show ∀ (r:ℝ), ∃ t ⊆ closed_ball x r, (countable (t : set α) ∧ closed_ball x r = closure t),
from assume r, emetric.countable_closure_of_compact (proper_space.compact_ball _ _),
let t := (⋃n:ℕ, T (n : ℝ)),
have T₁ : countable t := by finish [countable_Union],
have T₂ : closure t ⊆ univ := by simp,
have T₃ : univ ⊆ closure t :=
begin
intros y y_univ,
rcases exists_nat_gt (dist y x) with ⟨n, n_large⟩,
have h : y ∈ closed_ball x (n : ℝ) := by simp; apply le_of_lt n_large,
have h' : closed_ball x (n : ℝ) = closure (T (n : ℝ)) := by finish,
have : y ∈ closure (T (n : ℝ)) := by rwa h' at h,
show y ∈ closure t, from mem_of_mem_of_subset this (by apply closure_mono; apply subset_Union (λ(n:ℕ), T (n:ℝ))),
end,
exact ⟨t, ⟨T₁, subset.antisymm T₂ T₃⟩⟩
end,
haveI : separable_space α := ⟨(eq_empty_or_nonempty univ).elim A B⟩,
apply emetric.second_countable_of_separable,
end
/-- A finite product of proper spaces is proper. -/
instance pi_proper_space {π : β → Type*} [fintype β] [∀b, metric_space (π b)]
[h : ∀b, proper_space (π b)] : proper_space (Πb, π b) :=
begin
refine proper_space_of_compact_closed_ball_of_le 0 (λx r hr, _),
rw closed_ball_pi _ hr,
apply compact_pi_infinite (λb, _),
apply (h b).compact_ball
end
end proper_space
namespace metric
section second_countable
open topological_space
/-- A metric space is second countable if, for every ε > 0, there is a countable set which is ε-dense. -/
lemma second_countable_of_almost_dense_set
(H : ∀ε > (0 : ℝ), ∃ s : set α, countable s ∧ (∀x, ∃y ∈ s, dist x y ≤ ε)) :
second_countable_topology α :=
begin
choose T T_dense using H,
have I1 : ∀n:ℕ, (n:ℝ) + 1 > 0 :=
λn, lt_of_lt_of_le zero_lt_one (le_add_of_nonneg_left (nat.cast_nonneg _)),
have I : ∀n:ℕ, (n+1 : ℝ)⁻¹ > 0 := λn, inv_pos.2 (I1 n),
let t := ⋃n:ℕ, T (n+1)⁻¹ (I n),
have count_t : countable t := by finish [countable_Union],
have clos_t : closure t = univ,
{ refine subset.antisymm (subset_univ _) (λx xuniv, mem_closure_iff.2 (λε εpos, _)),
rcases exists_nat_gt ε⁻¹ with ⟨n, hn⟩,
have : ε⁻¹ < n + 1 := lt_of_lt_of_le hn (le_add_of_nonneg_right zero_le_one),
have nε : ((n:ℝ)+1)⁻¹ < ε := (inv_lt (I1 n) εpos).2 this,
rcases (T_dense (n+1)⁻¹ (I n)).2 x with ⟨y, yT, Dxy⟩,
have : y ∈ t := mem_of_mem_of_subset yT (by apply subset_Union (λ (n:ℕ), T (n+1)⁻¹ (I n))),
exact ⟨y, this, lt_of_le_of_lt Dxy nε⟩ },
haveI : separable_space α := ⟨⟨t, ⟨count_t, clos_t⟩⟩⟩,
exact emetric.second_countable_of_separable α
end
/-- A metric space space is second countable if one can reconstruct up to any ε>0 any element of the
space from countably many data. -/
lemma second_countable_of_countable_discretization {α : Type u} [metric_space α]
(H : ∀ε > (0 : ℝ), ∃ (β : Type u) [encodable β] (F : α → β), ∀x y, F x = F y → dist x y ≤ ε) :
second_countable_topology α :=
begin
cases (univ : set α).eq_empty_or_nonempty with hs hs,
{ haveI : compact_space α := ⟨by rw hs; exact compact_empty⟩, by apply_instance },
rcases hs with ⟨x0, hx0⟩,
letI : inhabited α := ⟨x0⟩,
refine second_countable_of_almost_dense_set (λε ε0, _),
rcases H ε ε0 with ⟨β, fβ, F, hF⟩,
let Finv := function.inv_fun F,
refine ⟨range Finv, ⟨countable_range _, λx, _⟩⟩,
let x' := Finv (F x),
have : F x' = F x := function.inv_fun_eq ⟨x, rfl⟩,
exact ⟨x', mem_range_self _, hF _ _ this.symm⟩
end
end second_countable
end metric
lemma lebesgue_number_lemma_of_metric
{s : set α} {ι} {c : ι → set α} (hs : compact s)
(hc₁ : ∀ i, is_open (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
∃ δ > 0, ∀ x ∈ s, ∃ i, ball x δ ⊆ c i :=
let ⟨n, en, hn⟩ := lebesgue_number_lemma hs hc₁ hc₂,
⟨δ, δ0, hδ⟩ := mem_uniformity_dist.1 en in
⟨δ, δ0, assume x hx, let ⟨i, hi⟩ := hn x hx in
⟨i, assume y hy, hi (hδ (mem_ball'.mp hy))⟩⟩
lemma lebesgue_number_lemma_of_metric_sUnion
{s : set α} {c : set (set α)} (hs : compact s)
(hc₁ : ∀ t ∈ c, is_open t) (hc₂ : s ⊆ ⋃₀ c) :
∃ δ > 0, ∀ x ∈ s, ∃ t ∈ c, ball x δ ⊆ t :=
by rw sUnion_eq_Union at hc₂;
simpa using lebesgue_number_lemma_of_metric hs (by simpa) hc₂
namespace metric
/-- Boundedness of a subset of a metric space. We formulate the definition to work
even in the empty space. -/
def bounded (s : set α) : Prop :=
∃C, ∀x y ∈ s, dist x y ≤ C
section bounded
variables {x : α} {s t : set α} {r : ℝ}
@[simp] lemma bounded_empty : bounded (∅ : set α) :=
⟨0, by simp⟩
lemma bounded_iff_mem_bounded : bounded s ↔ ∀ x ∈ s, bounded s :=
⟨λ h _ _, h, λ H,
s.eq_empty_or_nonempty.elim
(λ hs, hs.symm ▸ bounded_empty)
(λ ⟨x, hx⟩, H x hx)⟩
/-- Subsets of a bounded set are also bounded -/
lemma bounded.subset (incl : s ⊆ t) : bounded t → bounded s :=
Exists.imp $ λ C hC x y hx hy, hC x y (incl hx) (incl hy)
/-- Closed balls are bounded -/
lemma bounded_closed_ball : bounded (closed_ball x r) :=
⟨r + r, λ y z hy hz, begin
simp only [mem_closed_ball] at *,
calc dist y z ≤ dist y x + dist z x : dist_triangle_right _ _ _
... ≤ r + r : add_le_add hy hz
end⟩
/-- Open balls are bounded -/
lemma bounded_ball : bounded (ball x r) :=
bounded_closed_ball.subset ball_subset_closed_ball
/-- Given a point, a bounded subset is included in some ball around this point -/
lemma bounded_iff_subset_ball (c : α) : bounded s ↔ ∃r, s ⊆ closed_ball c r :=
begin
split; rintro ⟨C, hC⟩,
{ cases s.eq_empty_or_nonempty with h h,
{ subst s, exact ⟨0, by simp⟩ },
{ rcases h with ⟨x, hx⟩,
exact ⟨C + dist x c, λ y hy, calc
dist y c ≤ dist y x + dist x c : dist_triangle _ _ _
... ≤ C + dist x c : add_le_add_right (hC y x hy hx) _⟩ } },
{ exact bounded_closed_ball.subset hC }
end
/-- The union of two bounded sets is bounded iff each of the sets is bounded -/
@[simp] lemma bounded_union :
bounded (s ∪ t) ↔ bounded s ∧ bounded t :=
⟨λh, ⟨h.subset (by simp), h.subset (by simp)⟩,
begin
rintro ⟨hs, ht⟩,
refine bounded_iff_mem_bounded.2 (λ x _, _),
rw bounded_iff_subset_ball x at hs ht ⊢,
rcases hs with ⟨Cs, hCs⟩, rcases ht with ⟨Ct, hCt⟩,
exact ⟨max Cs Ct, union_subset
(subset.trans hCs $ closed_ball_subset_closed_ball $ le_max_left _ _)
(subset.trans hCt $ closed_ball_subset_closed_ball $ le_max_right _ _)⟩,
end⟩
/-- A finite union of bounded sets is bounded -/
lemma bounded_bUnion {I : set β} {s : β → set α} (H : finite I) :
bounded (⋃i∈I, s i) ↔ ∀i ∈ I, bounded (s i) :=
finite.induction_on H (by simp) $ λ x I _ _ IH,
by simp [or_imp_distrib, forall_and_distrib, IH]
/-- A compact set is bounded -/
lemma bounded_of_compact {s : set α} (h : compact s) : bounded s :=
-- We cover the compact set by finitely many balls of radius 1,
-- and then argue that a finite union of bounded sets is bounded
let ⟨t, ht, fint, subs⟩ := finite_cover_balls_of_compact h zero_lt_one in
bounded.subset subs $ (bounded_bUnion fint).2 $ λ i hi, bounded_ball
alias bounded_of_compact ← compact.bounded
/-- A finite set is bounded -/
lemma bounded_of_finite {s : set α} (h : finite s) : bounded s :=
h.compact.bounded
/-- A singleton is bounded -/
lemma bounded_singleton {x : α} : bounded ({x} : set α) :=
bounded_of_finite $ finite_singleton _
/-- Characterization of the boundedness of the range of a function -/
lemma bounded_range_iff {f : β → α} : bounded (range f) ↔ ∃C, ∀x y, dist (f x) (f y) ≤ C :=
exists_congr $ λ C, ⟨
λ H x y, H _ _ ⟨x, rfl⟩ ⟨y, rfl⟩,
by rintro H _ _ ⟨x, rfl⟩ ⟨y, rfl⟩; exact H x y⟩
/-- In a compact space, all sets are bounded -/
lemma bounded_of_compact_space [compact_space α] : bounded s :=
compact_univ.bounded.subset (subset_univ _)
/-- The Heine–Borel theorem:
In a proper space, a set is compact if and only if it is closed and bounded -/
lemma compact_iff_closed_bounded [proper_space α] :
compact s ↔ is_closed s ∧ bounded s :=
⟨λ h, ⟨closed_of_compact _ h, h.bounded⟩, begin
rintro ⟨hc, hb⟩,
cases s.eq_empty_or_nonempty with h h, {simp [h, compact_empty]},
rcases h with ⟨x, hx⟩,
rcases (bounded_iff_subset_ball x).1 hb with ⟨r, hr⟩,
exact compact_of_is_closed_subset (proper_space.compact_ball x r) hc hr
end⟩
/-- The image of a proper space under an expanding onto map is proper. -/
lemma proper_image_of_proper [proper_space α] [metric_space β] (f : α → β)
(f_cont : continuous f) (hf : range f = univ) (C : ℝ)
(hC : ∀x y, dist x y ≤ C * dist (f x) (f y)) : proper_space β :=
begin
apply proper_space_of_compact_closed_ball_of_le 0 (λx₀ r hr, _),
let K := f ⁻¹' (closed_ball x₀ r),
have A : is_closed K :=
continuous_iff_is_closed.1 f_cont (closed_ball x₀ r) (is_closed_ball),
have B : bounded K := ⟨max C 0 * (r + r), λx y hx hy, calc
dist x y ≤ C * dist (f x) (f y) : hC x y
... ≤ max C 0 * dist (f x) (f y) : mul_le_mul_of_nonneg_right (le_max_left _ _) (dist_nonneg)
... ≤ max C 0 * (dist (f x) x₀ + dist (f y) x₀) :
mul_le_mul_of_nonneg_left (dist_triangle_right (f x) (f y) x₀) (le_max_right _ _)
... ≤ max C 0 * (r + r) : begin
simp only [mem_closed_ball, mem_preimage] at hx hy,
exact mul_le_mul_of_nonneg_left (add_le_add hx hy) (le_max_right _ _)
end⟩,
have : compact K := compact_iff_closed_bounded.2 ⟨A, B⟩,
have C : compact (f '' K) := this.image f_cont,
have : f '' K = closed_ball x₀ r,
by { rw image_preimage_eq_of_subset, rw hf, exact subset_univ _ },
rwa this at C
end
end bounded
section diam
variables {s : set α} {x y z : α}
/-- The diameter of a set in a metric space. To get controllable behavior even when the diameter
should be infinite, we express it in terms of the emetric.diameter -/
def diam (s : set α) : ℝ := ennreal.to_real (emetric.diam s)
/-- The diameter of a set is always nonnegative -/
lemma diam_nonneg : 0 ≤ diam s := ennreal.to_real_nonneg
lemma diam_subsingleton (hs : s.subsingleton) : diam s = 0 :=
by simp only [diam, emetric.diam_subsingleton hs, ennreal.zero_to_real]
/-- The empty set has zero diameter -/
@[simp] lemma diam_empty : diam (∅ : set α) = 0 :=
diam_subsingleton subsingleton_empty
/-- A singleton has zero diameter -/
@[simp] lemma diam_singleton : diam ({x} : set α) = 0 :=
diam_subsingleton subsingleton_singleton
-- Does not work as a simp-lemma, since {x, y} reduces to (insert y {x})
lemma diam_pair : diam ({x, y} : set α) = dist x y :=
by simp only [diam, emetric.diam_pair, dist_edist]
-- Does not work as a simp-lemma, since {x, y, z} reduces to (insert z (insert y {x}))
lemma diam_triple :
metric.diam ({x, y, z} : set α) = max (dist x y) (max (dist y z) (dist x z)) :=
begin
simp only [metric.diam, emetric.diam_triple, dist_edist],
rw [ennreal.to_real_max, ennreal.to_real_max];
apply_rules [ne_of_lt, edist_lt_top, max_lt]
end
/-- If the distance between any two points in a set is bounded by some constant `C`,
then `ennreal.of_real C` bounds the emetric diameter of this set. -/
lemma ediam_le_of_forall_dist_le {C : ℝ} (h : ∀ (x ∈ s) (y ∈ s), dist x y ≤ C) :
emetric.diam s ≤ ennreal.of_real C :=
emetric.diam_le_of_forall_edist_le $
λ x hx y hy, (edist_dist x y).symm ▸ ennreal.of_real_le_of_real (h x hx y hy)
/-- If the distance between any two points in a set is bounded by some non-negative constant,
this constant bounds the diameter. -/
lemma diam_le_of_forall_dist_le {C : ℝ} (h₀ : 0 ≤ C) (h : ∀ (x ∈ s) (y ∈ s), dist x y ≤ C) :
diam s ≤ C :=
ennreal.to_real_le_of_le_of_real h₀ (ediam_le_of_forall_dist_le h)
/-- If the distance between any two points in a nonempty set is bounded by some constant,
this constant bounds the diameter. -/
lemma diam_le_of_forall_dist_le_of_nonempty (hs : s.nonempty) {C : ℝ}
(h : ∀ (x ∈ s) (y ∈ s), dist x y ≤ C) : diam s ≤ C :=
have h₀ : 0 ≤ C, from let ⟨x, hx⟩ := hs in le_trans dist_nonneg (h x hx x hx),
diam_le_of_forall_dist_le h₀ h
/-- The distance between two points in a set is controlled by the diameter of the set. -/
lemma dist_le_diam_of_mem' (h : emetric.diam s ≠ ⊤) (hx : x ∈ s) (hy : y ∈ s) :
dist x y ≤ diam s :=
begin
rw [diam, dist_edist],
rw ennreal.to_real_le_to_real (edist_ne_top _ _) h,
exact emetric.edist_le_diam_of_mem hx hy
end
/-- Characterize the boundedness of a set in terms of the finiteness of its emetric.diameter. -/
lemma bounded_iff_ediam_ne_top : bounded s ↔ emetric.diam s ≠ ⊤ :=
iff.intro
(λ ⟨C, hC⟩, ne_top_of_le_ne_top ennreal.of_real_ne_top
(ediam_le_of_forall_dist_le $ λ x hx y hy, hC x y hx hy))
(λ h, ⟨diam s, λ x y hx hy, dist_le_diam_of_mem' h hx hy⟩)
lemma bounded.ediam_ne_top (h : bounded s) : emetric.diam s ≠ ⊤ :=
bounded_iff_ediam_ne_top.1 h
/-- The distance between two points in a set is controlled by the diameter of the set. -/
lemma dist_le_diam_of_mem (h : bounded s) (hx : x ∈ s) (hy : y ∈ s) : dist x y ≤ diam s :=
dist_le_diam_of_mem' h.ediam_ne_top hx hy
/-- An unbounded set has zero diameter. If you would prefer to get the value ∞, use `emetric.diam`.
This lemma makes it possible to avoid side conditions in some situations -/
lemma diam_eq_zero_of_unbounded (h : ¬(bounded s)) : diam s = 0 :=
begin
simp only [bounded_iff_ediam_ne_top, not_not, ne.def] at h,
simp [diam, h]
end
/-- If `s ⊆ t`, then the diameter of `s` is bounded by that of `t`, provided `t` is bounded. -/
lemma diam_mono {s t : set α} (h : s ⊆ t) (ht : bounded t) : diam s ≤ diam t :=
begin
unfold diam,
rw ennreal.to_real_le_to_real (bounded.subset h ht).ediam_ne_top ht.ediam_ne_top,
exact emetric.diam_mono h
end
/-- The diameter of a union is controlled by the sum of the diameters, and the distance between
any two points in each of the sets. This lemma is true without any side condition, since it is
obviously true if `s ∪ t` is unbounded. -/
lemma diam_union {t : set α} (xs : x ∈ s) (yt : y ∈ t) : diam (s ∪ t) ≤ diam s + dist x y + diam t :=
begin
classical, by_cases H : bounded (s ∪ t),
{ have hs : bounded s, from H.subset (subset_union_left _ _),
have ht : bounded t, from H.subset (subset_union_right _ _),
rw [bounded_iff_ediam_ne_top] at H hs ht,
rw [dist_edist, diam, diam, diam, ← ennreal.to_real_add, ← ennreal.to_real_add,
ennreal.to_real_le_to_real];
repeat { apply ennreal.add_ne_top.2; split }; try { assumption };
try { apply edist_ne_top },
exact emetric.diam_union xs yt },
{ rw [diam_eq_zero_of_unbounded H],
apply_rules [add_nonneg, diam_nonneg, dist_nonneg] }
end
/-- If two sets intersect, the diameter of the union is bounded by the sum of the diameters. -/
lemma diam_union' {t : set α} (h : (s ∩ t).nonempty) : diam (s ∪ t) ≤ diam s + diam t :=
begin
rcases h with ⟨x, ⟨xs, xt⟩⟩,
simpa using diam_union xs xt
end
/-- The diameter of a closed ball of radius `r` is at most `2 r`. -/
lemma diam_closed_ball {r : ℝ} (h : r ≥ 0) : diam (closed_ball x r) ≤ 2 * r :=
diam_le_of_forall_dist_le (mul_nonneg (le_of_lt two_pos) h) $ λa ha b hb, calc
dist a b ≤ dist a x + dist b x : dist_triangle_right _ _ _
... ≤ r + r : add_le_add ha hb
... = 2 * r : by simp [mul_two, mul_comm]
/-- The diameter of a ball of radius `r` is at most `2 r`. -/
lemma diam_ball {r : ℝ} (h : r ≥ 0) : diam (ball x r) ≤ 2 * r :=
le_trans (diam_mono ball_subset_closed_ball bounded_closed_ball) (diam_closed_ball h)
end diam
end metric
|
d2ae88938f54acd0c2e41a09c9d4212451daa03e | 37da0369b6c03e380e057bf680d81e6c9fdf9219 | /hott/init/pathover.hlean | f27c7417b574ceed8900833c16f2309259f37cb2 | [
"Apache-2.0"
] | permissive | kodyvajjha/lean2 | 72b120d95c3a1d77f54433fa90c9810e14a931a4 | 227fcad22ab2bc27bb7471be7911075d101ba3f9 | refs/heads/master | 1,627,157,512,295 | 1,501,855,676,000 | 1,504,809,427,000 | 109,317,326 | 0 | 0 | null | 1,509,839,253,000 | 1,509,655,713,000 | C++ | UTF-8 | Lean | false | false | 19,207 | hlean | /-
Copyright (c) 2015 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Floris van Doorn
Basic theorems about pathovers
-/
prelude
import .path .equiv
open equiv is_equiv function
variables {A A' : Type} {B B' : A → Type} {B'' : A' → Type} {C : Π⦃a⦄, B a → Type}
{a a₂ a₃ a₄ : A} {p p' : a = a₂} {p₂ : a₂ = a₃} {p₃ : a₃ = a₄} {p₁₃ : a = a₃}
{b b' : B a} {b₂ b₂' : B a₂} {b₃ : B a₃} {b₄ : B a₄}
{c : C b} {c₂ : C b₂}
namespace eq
inductive pathover.{l} (B : A → Type.{l}) (b : B a) : Π{a₂ : A}, a = a₂ → B a₂ → Type.{l} :=
idpatho : pathover B b (refl a) b
notation b ` =[`:50 p:0 `] `:0 b₂:50 := pathover _ b p b₂
definition idpo [reducible] [constructor] : b =[refl a] b :=
pathover.idpatho b
definition idpatho [reducible] [constructor] (b : B a) : b =[refl a] b :=
pathover.idpatho b
/- equivalences with equality using transport -/
definition pathover_of_tr_eq [unfold 5 8] (r : p ▸ b = b₂) : b =[p] b₂ :=
by cases p; cases r; constructor
definition pathover_of_eq_tr [unfold 5 8] (r : b = p⁻¹ ▸ b₂) : b =[p] b₂ :=
by cases p; cases r; constructor
definition tr_eq_of_pathover [unfold 8] (r : b =[p] b₂) : p ▸ b = b₂ :=
by cases r; reflexivity
definition eq_tr_of_pathover [unfold 8] (r : b =[p] b₂) : b = p⁻¹ ▸ b₂ :=
by cases r; reflexivity
definition pathover_equiv_tr_eq [constructor] (p : a = a₂) (b : B a) (b₂ : B a₂)
: (b =[p] b₂) ≃ (p ▸ b = b₂) :=
begin
fapply equiv.MK,
{ exact tr_eq_of_pathover},
{ exact pathover_of_tr_eq},
{ intro r, cases p, cases r, apply idp},
{ intro r, cases r, apply idp},
end
definition pathover_equiv_eq_tr [constructor] (p : a = a₂) (b : B a) (b₂ : B a₂)
: (b =[p] b₂) ≃ (b = p⁻¹ ▸ b₂) :=
begin
fapply equiv.MK,
{ exact eq_tr_of_pathover},
{ exact pathover_of_eq_tr},
{ intro r, cases p, cases r, apply idp},
{ intro r, cases r, apply idp},
end
definition pathover_tr [unfold 5] (p : a = a₂) (b : B a) : b =[p] p ▸ b :=
by cases p; constructor
definition tr_pathover [unfold 5] (p : a = a₂) (b : B a₂) : p⁻¹ ▸ b =[p] b :=
by cases p; constructor
definition concato [unfold 12] (r : b =[p] b₂) (r₂ : b₂ =[p₂] b₃) : b =[p ⬝ p₂] b₃ :=
by induction r₂; exact r
definition inverseo [unfold 8] (r : b =[p] b₂) : b₂ =[p⁻¹] b :=
by induction r; constructor
definition concato_eq [unfold 10] (r : b =[p] b₂) (q : b₂ = b₂') : b =[p] b₂' :=
by induction q; exact r
definition eq_concato [unfold 9] (q : b = b') (r : b' =[p] b₂) : b =[p] b₂ :=
by induction q; exact r
definition change_path [unfold 9] (q : p = p') (r : b =[p] b₂) : b =[p'] b₂ :=
q ▸ r
definition change_path_idp [unfold_full] (r : b =[p] b₂) : change_path idp r = r :=
by reflexivity
-- infix ` ⬝ ` := concato
infix ` ⬝o `:72 := concato
infix ` ⬝op `:73 := concato_eq
infix ` ⬝po `:74 := eq_concato
-- postfix `⁻¹` := inverseo
postfix `⁻¹ᵒ`:(max+10) := inverseo
definition pathover_cancel_right (q : b =[p ⬝ p₂] b₃) (r : b₃ =[p₂⁻¹] b₂) : b =[p] b₂ :=
change_path !con_inv_cancel_right (q ⬝o r)
definition pathover_cancel_right' (q : b =[p₁₃ ⬝ p₂⁻¹] b₂) (r : b₂ =[p₂] b₃) : b =[p₁₃] b₃ :=
change_path !inv_con_cancel_right (q ⬝o r)
definition pathover_cancel_left (q : b₂ =[p⁻¹] b) (r : b =[p ⬝ p₂] b₃) : b₂ =[p₂] b₃ :=
change_path !inv_con_cancel_left (q ⬝o r)
definition pathover_cancel_left' (q : b =[p] b₂) (r : b₂ =[p⁻¹ ⬝ p₁₃] b₃) : b =[p₁₃] b₃ :=
change_path !con_inv_cancel_left (q ⬝o r)
/- Some of the theorems analogous to theorems for = in init.path -/
definition cono_idpo (r : b =[p] b₂) : r ⬝o idpo = r :=
by reflexivity
definition idpo_cono (r : b =[p] b₂) : idpo ⬝o r =[idp_con p] r :=
by induction r; constructor
definition cono.assoc' (r : b =[p] b₂) (r₂ : b₂ =[p₂] b₃) (r₃ : b₃ =[p₃] b₄) :
r ⬝o (r₂ ⬝o r₃) =[!con.assoc'] (r ⬝o r₂) ⬝o r₃ :=
by induction r₃; constructor
definition cono.assoc (r : b =[p] b₂) (r₂ : b₂ =[p₂] b₃) (r₃ : b₃ =[p₃] b₄) :
(r ⬝o r₂) ⬝o r₃ =[!con.assoc] r ⬝o (r₂ ⬝o r₃) :=
by induction r₃; constructor
definition cono.right_inv (r : b =[p] b₂) : r ⬝o r⁻¹ᵒ =[!con.right_inv] idpo :=
by induction r; constructor
definition cono.left_inv (r : b =[p] b₂) : r⁻¹ᵒ ⬝o r =[!con.left_inv] idpo :=
by induction r; constructor
definition eq_of_pathover {a' a₂' : A'} (q : a' =[p] a₂') : a' = a₂' :=
by cases q;reflexivity
definition pathover_of_eq [unfold 5 8] (p : a = a₂) {a' a₂' : A'} (q : a' = a₂') : a' =[p] a₂' :=
by cases p;cases q;constructor
definition pathover_constant [constructor] (p : a = a₂) (a' a₂' : A') : a' =[p] a₂' ≃ a' = a₂' :=
begin
fapply equiv.MK,
{ exact eq_of_pathover},
{ exact pathover_of_eq p},
{ intro r, cases p, cases r, reflexivity},
{ intro r, cases r, reflexivity},
end
definition pathover_of_eq_tr_constant_inv (p : a = a₂) (a' : A')
: pathover_of_eq p (tr_constant p a')⁻¹ = pathover_tr p a' :=
by cases p; constructor
definition eq_of_pathover_idp [unfold 6] {b' : B a} (q : b =[idpath a] b') : b = b' :=
tr_eq_of_pathover q
--should B be explicit in the next two definitions?
definition pathover_idp_of_eq [unfold 6] {b' : B a} (q : b = b') : b =[idpath a] b' :=
pathover_of_tr_eq q
definition pathover_idp [constructor] (b : B a) (b' : B a) : b =[idpath a] b' ≃ b = b' :=
equiv.MK eq_of_pathover_idp
(pathover_idp_of_eq)
(to_right_inv !pathover_equiv_tr_eq)
(to_left_inv !pathover_equiv_tr_eq)
definition eq_of_pathover_idp_pathover_of_eq {A X : Type} (x : X) {a a' : A} (p : a = a') :
eq_of_pathover_idp (pathover_of_eq (idpath x) p) = p :=
by induction p; reflexivity
variable (B)
definition idpo_concato_eq (r : b = b') : eq_of_pathover_idp (@idpo A B a b ⬝op r) = r :=
by induction r; reflexivity
variable {B}
-- definition pathover_idp (b : B a) (b' : B a) : b =[idpath a] b' ≃ b = b' :=
-- pathover_equiv_tr_eq idp b b'
-- definition eq_of_pathover_idp [reducible] {b' : B a} (q : b =[idpath a] b') : b = b' :=
-- to_fun !pathover_idp q
-- definition pathover_idp_of_eq [reducible] {b' : B a} (q : b = b') : b =[idpath a] b' :=
-- to_inv !pathover_idp q
definition idp_rec_on [recursor] [unfold 7] {P : Π⦃b₂ : B a⦄, b =[idpath a] b₂ → Type}
{b₂ : B a} (r : b =[idpath a] b₂) (H : P idpo) : P r :=
have H2 : P (pathover_idp_of_eq (eq_of_pathover_idp r)), from
eq.rec_on (eq_of_pathover_idp r) H,
proof left_inv !pathover_idp r ▸ H2 qed
definition rec_on_right [recursor] {P : Π⦃b₂ : B a₂⦄, b =[p] b₂ → Type}
{b₂ : B a₂} (r : b =[p] b₂) (H : P !pathover_tr) : P r :=
by cases r; exact H
definition rec_on_left [recursor] {P : Π⦃b : B a⦄, b =[p] b₂ → Type}
{b : B a} (r : b =[p] b₂) (H : P !tr_pathover) : P r :=
by cases r; exact H
--pathover with fibration B' ∘ f
definition pathover_ap [unfold 10] (B' : A' → Type) (f : A → A') {p : a = a₂}
{b : B' (f a)} {b₂ : B' (f a₂)} (q : b =[p] b₂) : b =[ap f p] b₂ :=
by cases q; constructor
definition pathover_of_pathover_ap (B' : A' → Type) (f : A → A') {p : a = a₂}
{b : B' (f a)} {b₂ : B' (f a₂)} (q : b =[ap f p] b₂) : b =[p] b₂ :=
by cases p; apply (idp_rec_on q); apply idpo
definition pathover_compose [constructor] (B' : A' → Type) (f : A → A') (p : a = a₂)
(b : B' (f a)) (b₂ : B' (f a₂)) : b =[p] b₂ ≃ b =[ap f p] b₂ :=
begin
fapply equiv.MK,
{ exact pathover_ap B' f},
{ exact pathover_of_pathover_ap B' f},
{ intro q, cases p, esimp, apply (idp_rec_on q), apply idp},
{ intro q, cases q, reflexivity},
end
definition pathover_of_pathover_tr (q : b =[p ⬝ p₂] p₂ ▸ b₂) : b =[p] b₂ :=
pathover_cancel_right q !pathover_tr⁻¹ᵒ
definition pathover_tr_of_pathover (q : b =[p₁₃ ⬝ p₂⁻¹] b₂) : b =[p₁₃] p₂ ▸ b₂ :=
pathover_cancel_right' q !pathover_tr
definition pathover_of_tr_pathover (q : p ▸ b =[p⁻¹ ⬝ p₁₃] b₃) : b =[p₁₃] b₃ :=
pathover_cancel_left' !pathover_tr q
definition tr_pathover_of_pathover (q : b =[p ⬝ p₂] b₃) : p ▸ b =[p₂] b₃ :=
pathover_cancel_left !pathover_tr⁻¹ᵒ q
definition pathover_tr_of_eq (q : b = b') : b =[p] p ▸ b' :=
by cases q;apply pathover_tr
definition tr_pathover_of_eq (q : b₂ = b₂') : p⁻¹ ▸ b₂ =[p] b₂' :=
by cases q;apply tr_pathover
definition eq_of_parallel_po_right (q : b =[p] b₂) (q' : b =[p] b₂') : b₂ = b₂' :=
begin
apply @eq_of_pathover_idp A B, apply change_path (con.left_inv p),
exact q⁻¹ᵒ ⬝o q'
end
definition eq_of_parallel_po_left (q : b =[p] b₂) (q' : b' =[p] b₂) : b = b' :=
begin
apply @eq_of_pathover_idp A B, apply change_path (con.right_inv p),
exact q ⬝o q'⁻¹ᵒ
end
variable (C)
definition transporto [unfold 9] (r : b =[p] b₂) (c : C b) : C b₂ :=
by induction r;exact c
infix ` ▸o `:75 := transporto _
definition fn_tro_eq_tro_fn {C' : Π ⦃a : A⦄, B a → Type} (q : b =[p] b₂)
(f : Π⦃a : A⦄ (b : B a), C b → C' b) (c : C b) : f b₂ (q ▸o c) = q ▸o (f b c) :=
by induction q; reflexivity
variable {C}
/- various variants of ap for pathovers -/
definition apd [unfold 6] (f : Πa, B a) (p : a = a₂) : f a =[p] f a₂ :=
by induction p; constructor
definition apd_idp [unfold_full] (f : Πa, B a) : apd f idp = @idpo A B a (f a) :=
by reflexivity
definition apo [unfold 12] {f : A → A'} (g : Πa, B a → B'' (f a)) (q : b =[p] b₂) :
g a b =[p] g a₂ b₂ :=
by induction q; constructor
definition apd011 [unfold 10] (f : Πa, B a → A') (Ha : a = a₂) (Hb : b =[Ha] b₂)
: f a b = f a₂ b₂ :=
by cases Hb; reflexivity
definition apd0111 [unfold 13 14] (f : Πa b, C b → A') (Ha : a = a₂) (Hb : b =[Ha] b₂)
(Hc : c =[apd011 C Ha Hb] c₂) : f a b c = f a₂ b₂ c₂ :=
by cases Hb; apply (idp_rec_on Hc); apply idp
definition apod11 {f : Πb, C b} {g : Πb₂, C b₂} (r : f =[p] g)
{b : B a} {b₂ : B a₂} (q : b =[p] b₂) : f b =[apd011 C p q] g b₂ :=
by cases r; apply (idp_rec_on q); constructor
definition apdo10 {f : Πb, C b} {g : Πb₂, C b₂} (r : f =[p] g)
(b : B a) : f b =[apd011 C p !pathover_tr] g (p ▸ b) :=
by cases r; constructor
definition apo10 [unfold 9] {f : B a → B' a} {g : B a₂ → B' a₂} (r : f =[p] g)
(b : B a) : f b =[p] g (p ▸ b) :=
by cases r; constructor
definition apo10_constant_right [unfold 9] {f : B a → A'} {g : B a₂ → A'} (r : f =[p] g)
(b : B a) : f b = g (p ▸ b) :=
by cases r; constructor
definition apo10_constant_left [unfold 9] {f : A' → B a} {g : A' → B a₂} (r : f =[p] g)
(a' : A') : f a' =[p] g a' :=
by cases r; constructor
definition apo11 {f : B a → B' a} {g : B a₂ → B' a₂} (r : f =[p] g)
(q : b =[p] b₂) : f b =[p] g b₂ :=
by induction q; exact apo10 r b
definition apo011 {A : Type} {B C D : A → Type} {a a' : A} {p : a = a'} {b : B a} {b' : B a'}
{c : C a} {c' : C a'} (f : Π⦃a⦄, B a → C a → D a) (q : b =[p] b') (r : c =[p] c') :
f b c =[p] f b' c' :=
begin induction q, induction r using idp_rec_on, exact idpo end
definition apdo011 {A : Type} {B : A → Type} {C : Π⦃a⦄, B a → Type}
(f : Π⦃a⦄ (b : B a), C b) {a a' : A} (p : a = a') {b : B a} {b' : B a'} (q : b =[p] b')
: f b =[apd011 C p q] f b' :=
by cases q; constructor
definition apdo0111 {A : Type} {B : A → Type} {C C' : Π⦃a⦄, B a → Type}
(f : Π⦃a⦄ {b : B a}, C b → C' b) {a a' : A} (p : a = a') {b : B a} {b' : B a'} (q : b =[p] b')
{c : C b} {c' : C b'} (r : c =[apd011 C p q] c')
: f c =[apd011 C' p q] f c' :=
begin
induction q, esimp at r, induction r using idp_rec_on, constructor
end
definition apo11_constant_right [unfold 12] {f : B a → A'} {g : B a₂ → A'}
(q : f =[p] g) (r : b =[p] b₂) : f b = g b₂ :=
eq_of_pathover (apo11 q r)
/- properties about these "ap"s, transporto and pathover_ap -/
definition apd_con (f : Πa, B a) (p : a = a₂) (q : a₂ = a₃)
: apd f (p ⬝ q) = apd f p ⬝o apd f q :=
by cases p; cases q; reflexivity
definition apd_inv (f : Πa, B a) (p : a = a₂) : apd f p⁻¹ = (apd f p)⁻¹ᵒ :=
by cases p; reflexivity
definition apd_eq_pathover_of_eq_ap (f : A → A') (p : a = a₂) :
apd f p = pathover_of_eq p (ap f p) :=
eq.rec_on p idp
definition apo_invo (f : Πa, B a → B' a) {Ha : a = a₂} (Hb : b =[Ha] b₂)
: (apo f Hb)⁻¹ᵒ = apo f Hb⁻¹ᵒ :=
by induction Hb; reflexivity
definition apd011_inv (f : Πa, B a → A') (Ha : a = a₂) (Hb : b =[Ha] b₂)
: (apd011 f Ha Hb)⁻¹ = (apd011 f Ha⁻¹ Hb⁻¹ᵒ) :=
by induction Hb; reflexivity
definition cast_apd011 (q : b =[p] b₂) (c : C b) : cast (apd011 C p q) c = q ▸o c :=
by induction q; reflexivity
definition apd_compose1 (g : Πa, B a → B' a) (f : Πa, B a) (p : a = a₂)
: apd (g ∘' f) p = apo g (apd f p) :=
by induction p; reflexivity
definition apd_compose2 (g : Πa', B'' a') (f : A → A') (p : a = a₂)
: apd (λa, g (f a)) p = pathover_of_pathover_ap B'' f (apd g (ap f p)) :=
by induction p; reflexivity
definition apo_tro (C : Π⦃a⦄, B' a → Type) (f : Π⦃a⦄, B a → B' a) (q : b =[p] b₂)
(c : C (f b)) : apo f q ▸o c = q ▸o c :=
by induction q; reflexivity
definition pathover_ap_tro {B' : A' → Type} (C : Π⦃a'⦄, B' a' → Type) (f : A → A')
{b : B' (f a)} {b₂ : B' (f a₂)} (q : b =[p] b₂) (c : C b) : pathover_ap B' f q ▸o c = q ▸o c :=
by induction q; reflexivity
definition pathover_ap_invo_tro {B' : A' → Type} (C : Π⦃a'⦄, B' a' → Type) (f : A → A')
{b : B' (f a)} {b₂ : B' (f a₂)} (q : b =[p] b₂) (c : C b₂)
: (pathover_ap B' f q)⁻¹ᵒ ▸o c = q⁻¹ᵒ ▸o c :=
by induction q; reflexivity
definition pathover_tro (q : b =[p] b₂) (c : C b) : c =[apd011 C p q] q ▸o c :=
by induction q; constructor
definition pathover_ap_invo {B' : A' → Type} (f : A → A') {p : a = a₂}
{b : B' (f a)} {b₂ : B' (f a₂)} (q : b =[p] b₂)
: pathover_ap B' f q⁻¹ᵒ =[ap_inv f p] (pathover_ap B' f q)⁻¹ᵒ :=
by induction q; exact idpo
definition tro_invo_tro {A : Type} {B : A → Type} (C : Π⦃a⦄, B a → Type)
{a a' : A} {p : a = a'} {b : B a} {b' : B a'} (q : b =[p] b') (c : C b') :
q ▸o (q⁻¹ᵒ ▸o c) = c :=
by induction q; reflexivity
definition invo_tro_tro {A : Type} {B : A → Type} (C : Π⦃a⦄, B a → Type)
{a a' : A} {p : a = a'} {b : B a} {b' : B a'} (q : b =[p] b') (c : C b) :
q⁻¹ᵒ ▸o (q ▸o c) = c :=
by induction q; reflexivity
definition cono_tro {A : Type} {B : A → Type} (C : Π⦃a⦄, B a → Type)
{a₁ a₂ a₃ : A} {p₁ : a₁ = a₂} {p₂ : a₂ = a₃} {b₁ : B a₁} {b₂ : B a₂} {b₃ : B a₃}
(q₁ : b₁ =[p₁] b₂) (q₂ : b₂ =[p₂] b₃) (c : C b₁) :
transporto C (q₁ ⬝o q₂) c = transporto C q₂ (transporto C q₁ c) :=
by induction q₂; reflexivity
definition is_equiv_transporto [constructor] {A : Type} {B : A → Type} (C : Π⦃a⦄, B a → Type)
{a a' : A} {p : a = a'} {b : B a} {b' : B a'} (q : b =[p] b') : is_equiv (transporto C q) :=
begin
fapply adjointify,
{ exact transporto C q⁻¹ᵒ},
{ exact tro_invo_tro C q},
{ exact invo_tro_tro C q}
end
definition equiv_apd011 [constructor] {A : Type} {B : A → Type} (C : Π⦃a⦄, B a → Type)
{a a' : A} {p : a = a'} {b : B a} {b' : B a'} (q : b =[p] b') : C b ≃ C b' :=
equiv.mk (transporto C q) !is_equiv_transporto
/- some cancellation laws for concato_eq an variants -/
definition cono.right_inv_eq (q : b = b') :
pathover_idp_of_eq q ⬝op q⁻¹ = (idpo : b =[refl a] b) :=
by induction q; constructor
definition cono.right_inv_eq' (q : b = b') :
q ⬝po (pathover_idp_of_eq q⁻¹) = (idpo : b =[refl a] b) :=
by induction q; constructor
definition cono.left_inv_eq (q : b = b') :
pathover_idp_of_eq q⁻¹ ⬝op q = (idpo : b' =[refl a] b') :=
by induction q; constructor
definition cono.left_inv_eq' (q : b = b') :
q⁻¹ ⬝po pathover_idp_of_eq q = (idpo : b' =[refl a] b') :=
by induction q; constructor
definition pathover_of_fn_pathover_fn (f : Π{a}, B a ≃ B' a) (r : f b =[p] f b₂) : b =[p] b₂ :=
(left_inv f b)⁻¹ ⬝po apo (λa, f⁻¹ᵉ) r ⬝op left_inv f b₂
/- a pathover in a pathover type where the only thing which varies is the path is the same as
an equality with a change_path -/
definition change_path_of_pathover (s : p = p') (r : b =[p] b₂) (r' : b =[p'] b₂)
(q : r =[s] r') : change_path s r = r' :=
by induction s; eapply idp_rec_on q; reflexivity
definition pathover_of_change_path (s : p = p') (r : b =[p] b₂) (r' : b =[p'] b₂)
(q : change_path s r = r') : r =[s] r' :=
by induction s; induction q; constructor
definition pathover_pathover_path [constructor] (s : p = p') (r : b =[p] b₂) (r' : b =[p'] b₂) :
(r =[s] r') ≃ change_path s r = r' :=
begin
fapply equiv.MK,
{ apply change_path_of_pathover},
{ apply pathover_of_change_path},
{ intro q, induction s, induction q, reflexivity},
{ intro q, induction s, eapply idp_rec_on q, reflexivity},
end
/- variants of inverse2 and concat2 -/
definition inverseo2 [unfold 10] {r r' : b =[p] b₂} (s : r = r') : r⁻¹ᵒ = r'⁻¹ᵒ :=
by induction s; reflexivity
definition concato2 [unfold 15 16] {r r' : b =[p] b₂} {r₂ r₂' : b₂ =[p₂] b₃}
(s : r = r') (s₂ : r₂ = r₂') : r ⬝o r₂ = r' ⬝o r₂' :=
by induction s; induction s₂; reflexivity
infixl ` ◾o `:79 := concato2
postfix [parsing_only] `⁻²ᵒ`:(max+10) := inverseo2 --this notation is abusive, should we use it?
-- find a better name for this
definition fn_tro_eq_tro_fn2 (q : b =[p] b₂)
{k : A → A} {l : Π⦃a⦄, B a → B (k a)} (m : Π⦃a⦄ {b : B a}, C b → C (l b))
(c : C b) :
m (q ▸o c) = (pathover_ap B k (apo l q)) ▸o (m c) :=
by induction q; reflexivity
definition apd0111_precompose (f : Π⦃a⦄ {b : B a}, C b → A')
{k : A → A} {l : Π⦃a⦄, B a → B (k a)} (m : Π⦃a⦄ {b : B a}, C b → C (l b))
{q : b =[p] b₂} (c : C b)
: apd0111 (λa b c, f (m c)) p q (pathover_tro q c) ⬝ ap (@f _ _) (fn_tro_eq_tro_fn2 q m c) =
apd0111 f (ap k p) (pathover_ap B k (apo l q)) (pathover_tro _ (m c)) :=
by induction q; reflexivity
end eq
|
6d324ca5556ac635d02964585c331f074cb074be | ff5230333a701471f46c57e8c115a073ebaaa448 | /library/init/coe.lean | 0e91e64debf0e0477595bede1adc27271116a958 | [
"Apache-2.0"
] | permissive | stanford-cs242/lean | f81721d2b5d00bc175f2e58c57b710d465e6c858 | 7bd861261f4a37326dcf8d7a17f1f1f330e4548c | refs/heads/master | 1,600,957,431,849 | 1,576,465,093,000 | 1,576,465,093,000 | 225,779,423 | 0 | 3 | Apache-2.0 | 1,575,433,936,000 | 1,575,433,935,000 | null | UTF-8 | Lean | false | false | 7,183 | 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
-/
/-
The elaborator tries to insert coercions automatically.
Only instances of has_coe type class are considered in the process.
Lean also provides a "lifting" operator: ↑a.
It uses all instances of has_lift type class.
Every has_coe instance is also a has_lift instance.
We recommend users only use has_coe for coercions that do not produce a lot
of ambiguity.
All coercions and lifts can be identified with the constant coe.
We use the has_coe_to_fun type class for encoding coercions from
a type to a function space.
We use the has_coe_to_sort type class for encoding coercions from
a type to a sort.
-/
prelude
import init.data.list.basic init.data.subtype.basic init.data.prod
universes u v
/-- Can perform a lifting operation `↑a`. -/
class has_lift (a : Sort u) (b : Sort v) :=
(lift : a → b)
/-- Auxiliary class that contains the transitive closure of has_lift. -/
class has_lift_t (a : Sort u) (b : Sort v) :=
(lift : a → b)
class has_coe (a : Sort u) (b : Sort v) :=
(coe : a → b)
/-- Auxiliary class that contains the transitive closure of has_coe. -/
class has_coe_t (a : Sort u) (b : Sort v) :=
(coe : a → b)
class has_coe_to_fun (a : Sort u) : Sort (max u (v+1)) :=
(F : a → Sort v) (coe : Π x, F x)
class has_coe_to_sort (a : Sort u) : Type (max u (v+1)) :=
(S : Sort v) (coe : a → S)
def lift {a : Sort u} {b : Sort v} [has_lift a b] : a → b :=
@has_lift.lift a b _
def lift_t {a : Sort u} {b : Sort v} [has_lift_t a b] : a → b :=
@has_lift_t.lift a b _
def coe_b {a : Sort u} {b : Sort v} [has_coe a b] : a → b :=
@has_coe.coe a b _
def coe_t {a : Sort u} {b : Sort v} [has_coe_t a b] : a → b :=
@has_coe_t.coe a b _
def coe_fn_b {a : Sort u} [has_coe_to_fun.{u v} a] : Π x : a, has_coe_to_fun.F.{u v} x :=
has_coe_to_fun.coe
/- User level coercion operators -/
@[reducible] def coe {a : Sort u} {b : Sort v} [has_lift_t a b] : a → b :=
lift_t
@[reducible] def coe_fn {a : Sort u} [has_coe_to_fun.{u v} a] : Π x : a, has_coe_to_fun.F.{u v} x :=
has_coe_to_fun.coe
@[reducible] def coe_sort {a : Sort u} [has_coe_to_sort.{u v} a] : a → has_coe_to_sort.S.{u v} a :=
has_coe_to_sort.coe
/- Notation -/
notation `↑`:max x:max := coe x
notation `⇑`:max x:max := coe_fn x
notation `↥`:max x:max := coe_sort x
universes u₁ u₂ u₃
/- Transitive closure for has_lift, has_coe, has_coe_to_fun -/
instance lift_trans {a : Sort u₁} {b : Sort u₂} {c : Sort u₃} [has_lift a b] [has_lift_t b c] : has_lift_t a c :=
⟨λ x, lift_t (lift x : b)⟩
instance lift_base {a : Sort u} {b : Sort v} [has_lift a b] : has_lift_t a b :=
⟨lift⟩
instance coe_trans {a : Sort u₁} {b : Sort u₂} {c : Sort u₃} [has_coe a b] [has_coe_t b c] : has_coe_t a c :=
⟨λ x, coe_t (coe_b x : b)⟩
instance coe_base {a : Sort u} {b : Sort v} [has_coe a b] : has_coe_t a b :=
⟨coe_b⟩
/- We add this instance directly into has_coe_t to avoid non-termination.
Suppose coe_option had type (has_coe a (option a)).
Then, we can loop when searching a coercion from α to β (has_coe_t α β)
1- coe_trans at (has_coe_t α β)
(has_coe α ?b₁) and (has_coe_t ?b₁ c)
2- coe_option at (has_coe α ?b₁)
?b₁ := option α
3- coe_trans at (has_coe_t (option α) β)
(has_coe (option α) ?b₂) and (has_coe_t ?b₂ β)
4- coe_option at (has_coe (option α) ?b₂)
?b₂ := option (option α))
...
-/
instance coe_option {a : Type u} : has_coe_t a (option a) :=
⟨λ x, some x⟩
/- Auxiliary transitive closure for has_coe which does not contain
instances such as coe_option.
They would produce non-termination when combined with coe_fn_trans and coe_sort_trans.
-/
class has_coe_t_aux (a : Sort u) (b : Sort v) :=
(coe : a → b)
instance coe_trans_aux {a : Sort u₁} {b : Sort u₂} {c : Sort u₃} [has_coe a b] [has_coe_t_aux b c] : has_coe_t_aux a c :=
⟨λ x : a, @has_coe_t_aux.coe b c _ (coe_b x)⟩
instance coe_base_aux {a : Sort u} {b : Sort v} [has_coe a b] : has_coe_t_aux a b :=
⟨coe_b⟩
instance coe_fn_trans {a : Sort u₁} {b : Sort u₂} [has_coe_t_aux a b] [has_coe_to_fun.{u₂ u₃} b] : has_coe_to_fun.{u₁ u₃} a :=
{ F := λ x, @has_coe_to_fun.F.{u₂ u₃} b _ (@has_coe_t_aux.coe a b _ x),
coe := λ x, coe_fn (@has_coe_t_aux.coe a b _ x) }
instance coe_sort_trans {a : Sort u₁} {b : Sort u₂} [has_coe_t_aux a b] [has_coe_to_sort.{u₂ u₃} b] : has_coe_to_sort.{u₁ u₃} a :=
{ S := has_coe_to_sort.S.{u₂ u₃} b,
coe := λ x, coe_sort (@has_coe_t_aux.coe a b _ x) }
/- Every coercion is also a lift -/
instance coe_to_lift {a : Sort u} {b : Sort v} [has_coe_t a b] : has_lift_t a b :=
⟨coe_t⟩
/- basic coercions -/
instance coe_bool_to_Prop : has_coe bool Prop :=
⟨λ y, y = tt⟩
/- Tactics such as the simplifier only unfold reducible constants when checking whether two terms are definitionally
equal or a term is a proposition. The motivation is performance.
In particular, when simplifying `p -> q`, the tactic `simp` only visits `p` if it can establish that it is a proposition.
Thus, we mark the following instance as @[reducible], otherwise `simp` will not visit `↑p` when simplifying `↑p -> q`.
-/
@[reducible] instance coe_sort_bool : has_coe_to_sort bool :=
⟨Prop, λ y, y = tt⟩
instance coe_decidable_eq (x : bool) : decidable (coe x) :=
show decidable (x = tt), from bool.decidable_eq x tt
instance coe_subtype {a : Sort u} {p : a → Prop} : has_coe {x // p x} a :=
⟨subtype.val⟩
/- basic lifts -/
universes ua ua₁ ua₂ ub ub₁ ub₂
/- Remark: we can't use [has_lift_t a₂ a₁] since it will produce non-termination whenever a type class resolution
problem does not have a solution. -/
instance lift_fn {a₁ : Sort ua₁} {a₂ : Sort ua₂} {b₁ : Sort ub₁} {b₂ : Sort ub₂} [has_lift a₂ a₁] [has_lift_t b₁ b₂] : has_lift (a₁ → b₁) (a₂ → b₂) :=
⟨λ f x, ↑(f ↑x)⟩
instance lift_fn_range {a : Sort ua} {b₁ : Sort ub₁} {b₂ : Sort ub₂} [has_lift_t b₁ b₂] : has_lift (a → b₁) (a → b₂) :=
⟨λ f x, ↑(f x)⟩
instance lift_fn_dom {a₁ : Sort ua₁} {a₂ : Sort ua₂} {b : Sort ub} [has_lift a₂ a₁] : has_lift (a₁ → b) (a₂ → b) :=
⟨λ f x, f ↑x⟩
instance lift_pair {a₁ : Type ua₁} {a₂ : Type ub₂} {b₁ : Type ub₁} {b₂ : Type ub₂} [has_lift_t a₁ a₂] [has_lift_t b₁ b₂] : has_lift (a₁ × b₁) (a₂ × b₂) :=
⟨λ p, prod.cases_on p (λ x y, (↑x, ↑y))⟩
instance lift_pair₁ {a₁ : Type ua₁} {a₂ : Type ua₂} {b : Type ub} [has_lift_t a₁ a₂] : has_lift (a₁ × b) (a₂ × b) :=
⟨λ p, prod.cases_on p (λ x y, (↑x, y))⟩
instance lift_pair₂ {a : Type ua} {b₁ : Type ub₁} {b₂ : Type ub₂} [has_lift_t b₁ b₂] : has_lift (a × b₁) (a × b₂) :=
⟨λ p, prod.cases_on p (λ x y, (x, ↑y))⟩
instance lift_list {a : Type u} {b : Type v} [has_lift_t a b] : has_lift (list a) (list b) :=
⟨λ l, list.map (@coe a b _) l⟩
|
ed1d3d407184a353584abea1953ff5e6e3123130 | b7b549d2cf38ac9d4e49372b7ad4d37f70449409 | /src/LeanLLVM/LLVMFFI.lean | d9024e7b8af724e03e6f06636fc02f6f0e7d49e5 | [
"Apache-2.0"
] | permissive | GaloisInc/lean-llvm | 7cc196172fe02ff3554edba6cc82f333c30fdc2b | 36e2ec604ae22d8ec1b1b66eca0f8887880db6c6 | refs/heads/master | 1,637,359,020,356 | 1,629,332,114,000 | 1,629,402,464,000 | 146,700,234 | 29 | 1 | Apache-2.0 | 1,631,225,695,000 | 1,535,607,191,000 | Lean | UTF-8 | Lean | false | false | 10,953 | lean | /-
Copyright (c) 2019 Galois, Inc. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Dockins, Joe Hendrix
Lean declarations to link against LLVM C++ declarations.
-/
import Init.Core
import LeanLLVM.LLVMCodes
namespace LLVM
namespace FFI
constant Context : Type := Unit
def Type_ : Type := Unit
instance Type_.inhabited : Inhabited Type_ := inferInstanceAs (Inhabited Unit)
constant Value : Type := Unit
def Function : Type := Value
def BasicBlock : Type := Value
def Instruction : Type := Value
def Constant : Type := Value
def GlobalVar : Type := Value
def InlineAsm : Type := Value
constant Module : Type := Unit
constant MemoryBuffer : Type := Unit
def Triple : Type := Unit
instance Triple.inhabited : Inhabited Triple := inferInstanceAs (Inhabited Unit)
------------------------------------------------------------------------
-- Context
@[extern 1 "lean_llvm_newContext"]
def newContext : IO Context := arbitrary
------------------------------------------------------------------------
-- Types
@[extern 2 "lean_llvm_getTypeTag"]
def getTypeTag : @& Type_ -> IO Code.TypeID := arbitrary
@[extern 2 "lean_llvm_getTypeName"]
def getTypeName : @& Type_ -> IO (Option String) := arbitrary
@[extern 2 "lean_llvm_typeIsOpaque"]
def typeIsOpaque : @& Type_ -> IO Bool := arbitrary
@[extern 2 "lean_llvm_getIntegerTypeWidth"]
def getIntegerTypeWidth : @& Type_ -> IO Nat := arbitrary
@[extern 2 "lean_llvm_getPointerElementType"]
def getPointerElementType : @& Type_ -> IO (Option Type_) := arbitrary
@[extern 2 "lean_llvm_getSequentialTypeData"]
def getSequentialTypeData : @&Type_ -> IO (Option (Nat × Type_)) := arbitrary
@[extern 2 "lean_llvm_getStructTypeData"]
def getStructTypeData : @&Type_ -> IO (Option (Bool × Array Type_)) := arbitrary
@[extern 2 "lean_llvm_getFunctionTypeData"]
def getFunctionTypeData : @&Type_ -> IO (Option (Type_ × (Array Type_ × Bool))) := arbitrary
@[extern 3 "lean_llvm_newPrimitiveType"]
def newPrimitiveType : @& Context → @& Code.TypeID → IO Type_ := arbitrary
@[extern 3 "lean_llvm_newIntegerType"]
def newIntegerType : @& Context → @& Nat → IO Type_ := arbitrary
@[extern 3 "lean_llvm_newArrayType"]
def newArrayType : @& Nat → @& Type_ → IO Type_ := arbitrary
@[extern 3 "lean_llvm_newVectorType"]
def newVectorType : @& Nat → @& Type_ → IO Type_ := arbitrary
@[extern 2 "lean_llvm_newPointerType"]
def newPointerType : @& Type_ → IO Type_ := arbitrary
@[extern 4 "lean_llvm_newFunctionType"]
def newFunctionType : @& Type_ → @& Array Type_ → Bool → IO Type_ := arbitrary
@[extern 3 "lean_llvm_newLiteralStructType"]
def newLiteralStructType : @& Bool → @& Array Type_ → IO Type_ := arbitrary
@[extern 2 "lean_llvm_newOpaqueStructType"]
def newOpaqueStructType : @& Context → @& String → IO Type_ := arbitrary
@[extern 4 "lean_llvm_setStructTypeBody"]
def setStructTypeBody : @& Type_ → @& Bool → @& Array Type_ → IO Unit := arbitrary
------------------------------------------------------------------------
-- Value
@[extern 2 "lean_llvm_getValueType"]
def getValueType : @& Value -> IO Type_ := arbitrary
inductive ValueView
| unknown
| constantView (c:Constant)
| argument (a:Nat)
| block (b:BasicBlock)
| instruction (i:Instruction)
| inlineasm (asm:InlineAsm)
@[extern 2 "lean_llvm_decomposeValue"]
def decomposeValue : @& Value -> IO ValueView := arbitrary
def functionToValue (f:Function) : Value := f
def basicBlockToValue (bb:BasicBlock) : Value := bb
def instructionToValue (i:Instruction) : Value := i
def constantToValue (c:Constant) : Value := c
-- def inlineAsmToValue (a:InlineAsm) : Value := a
------------------------------------------------------------------------
-- Constant
@[extern 2 "lean_llvm_getConstantName"]
def getConstantName : @& Constant -> IO (Option String) := arbitrary
@[extern 2 "lean_llvm_getConstantTag"]
def getConstantTag : @&Constant -> IO Code.Const := arbitrary
-- return bitwidth and value
@[extern 2 "lean_llvm_getConstIntData"]
def getConstIntData : @& Constant -> IO (Option (Nat × Nat)) := arbitrary
@[extern 2 "lean_llvm_getConstExprData"]
def getConstExprData : @& Constant -> IO (Option (Code.Instr × Array Constant)) := arbitrary
@[extern 2 "lean_llvm_getConstArrayData"]
def getConstArrayData : @& Constant -> IO (Option (Type_ × Array Constant)) := arbitrary
------------------------------------------------------------------------
-- InlineAsm
@[extern 2 "lean_llvm_getInlineAsmData"]
def getInlineAsmData : @& InlineAsm -> IO (Bool × (Bool × (String × String))) := arbitrary
------------------------------------------------------------------------
-- Instruction
@[extern 2 "lean_llvm_instructionLt"]
def instructionLt : @& Instruction -> @&Instruction -> Bool := arbitrary
@[extern 2 "lean_llvm_getInstructionName"]
def getInstructionName : @& Instruction -> IO (Option String) := arbitrary
@[extern 2 "lean_llvm_getInstructionType"]
def getInstructionType : @& Instruction -> IO Type_ := arbitrary
@[extern 2 "lean_llvm_getInstructionOpcode"]
def getInstructionOpcode : @& Instruction -> IO Code.Instr := arbitrary
@[extern 2 "lean_llvm_getInstructionReturnValue"]
def getInstructionReturnValue : @& Instruction -> IO (Option Value) := arbitrary
@[extern 2 "lean_llvm_getBinaryOperatorValues"]
def getBinaryOperatorValues : @& Instruction -> IO (Option (Value × Value)) := arbitrary
@[extern 2 "lean_llvm_hasNoSignedWrap"]
def hasNoSignedWrap : @& Instruction -> IO Bool := arbitrary
@[extern 2 "lean_llvm_hasNoUnsignedWrap"]
def hasNoUnsignedWrap : @& Instruction -> IO Bool := arbitrary
@[extern 2 "lean_llvm_isExact"]
def isExact : @&Instruction -> IO Bool := arbitrary
@[extern 2 "lean_llvm_getICmpInstData"]
def getICmpInstData : @& Instruction -> IO (Option (Code.ICmp × (Value × Value))) := arbitrary
@[extern 2 "lean_llvm_getSelectInstData"]
def getSelectInstData : @& Instruction -> IO (Option (Value × (Value × Value))) := arbitrary
@[extern 2 "lean_llvm_getExtractValueInstData"]
def getExtractValueInstData : @& Instruction -> IO (Option (Value × Array Nat)) := arbitrary
@[extern 2 "lean_llvm_getInsertValueInstData"]
def getInsertValueInstData : @& Instruction -> IO (Option (Value × (Value × Array Nat))) := arbitrary
namespace Instruction
instance : Ord Instruction where
compare x y := if instructionLt x y then Ordering.lt
else if instructionLt y x then Ordering.gt
else Ordering.eq
end Instruction
inductive BranchView
| unconditional (b:BasicBlock)
| conditional (c:Value) (t f : BasicBlock)
@[extern 2 "lean_llvm_getBranchInstData"]
def getBranchInstData : @& Instruction -> IO (Option BranchView) := arbitrary
@[extern 2 "lean_llvm_getPhiData"]
def getPhiData : @& Instruction -> IO (Option (Array (Value × BasicBlock))) := arbitrary
@[extern 2 "lean_llvm_getCastInstData"]
def getCastInstData : @& Instruction -> IO (Option (Nat × Value)) := arbitrary
@[extern 2 "lean_llvm_getAllocaData"]
def getAllocaData : @& Instruction -> IO (Option (Type_ × (Option Value × Option Nat))) := arbitrary
@[extern 2 "lean_llvm_getStoreData"]
def getStoreData : @& Instruction -> IO (Option (Value × (Value × Option Nat))) := arbitrary
@[extern 2 "lean_llvm_getLoadData"]
def getLoadData : @& Instruction -> IO (Option (Value × Option Nat)) := arbitrary
@[extern 2 "lean_llvm_getGEPData"]
def getGEPData : @& Instruction -> IO (Option (Bool × (Value × Array Value))) := arbitrary
@[extern 2 "lean_llvm_getCallInstData"]
def getCallInstData : @& Instruction -> IO (Option (Bool × (Type_ × (Value × Array Value)))) := arbitrary
------------------------------------------------------------------------
-- Basic block
@[extern 2 "lean_llvm_basicBlockLt"]
def basicBlockLt : @& BasicBlock -> @& BasicBlock -> Bool := arbitrary
@[extern 2 "lean_llvm_getBBName"]
def getBBName : @& BasicBlock -> IO (Option String) := arbitrary
@[extern 2 "lean_llvm_getInstructionArray"]
def getInstructionArray : @& BasicBlock -> IO (Array Instruction) := arbitrary
namespace BasicBlock
instance : Ord BasicBlock where
compare x y := if basicBlockLt x y then Ordering.lt
else if basicBlockLt y x then Ordering.gt
else Ordering.eq
end BasicBlock
------------------------------------------------------------------------
-- Function
@[extern 3 "lean_llvm_newFunction"]
def newFunction : Module → @&Type_ → @&String → IO Function := arbitrary
@[extern 2 "lean_llvm_getFunctionName"]
def getFunctionName : @& Function -> IO String := arbitrary
@[extern 2 "lean_llvm_getFunctionArgs"]
def getFunctionArgs : @& Function -> IO (Array (Option String × Type_)) := arbitrary
@[extern 2 "lean_llvm_getReturnType"]
def getReturnType : @& Function -> IO Type_ := arbitrary
@[extern 2 "lean_llvm_getBasicBlockArray"]
def getBasicBlockArray : @& Function -> IO (Array BasicBlock) := arbitrary
------------------------------------------------------------------------
-- GlobalVar
@[extern 2 "lean_llvm_getGlobalVarData"]
def getGlobalVarData : @& GlobalVar → IO (Option (String × (Option Value × Nat))) := arbitrary
------------------------------------------------------------------------
-- Module
@[extern 3 "lean_llvm_parseBitcodeFile"]
def parseBitcodeFile : @&MemoryBuffer → Context → IO Module := arbitrary
@[extern 3 "lean_llvm_parseAssembly"]
def parseAssembly : @&MemoryBuffer → Context → IO Module := arbitrary
@[extern 2 "lean_llvm_printModule"]
def printModule : @& Module -> IO Unit := arbitrary
@[extern 3 "lean_llvm_newModule"]
def newModule : Context → @&String → IO Module := arbitrary
@[extern 2 "lean_llvm_getModuleIdentifier"]
def getModuleIdentifier : @&Module → IO String := arbitrary
@[extern 3 "lean_llvm_setModuleIdentifier"]
def setModuleIdentifier : @&Module → @&String → IO Unit := arbitrary
@[extern 2 "lean_llvm_getModuleDataLayoutStr"]
def getModuleDataLayoutStr : @& Module → IO String := arbitrary
@[extern 2 "lean_llvm_getFunctionArray"]
def getFunctionArray : @& Module -> IO (Array Function) := arbitrary
@[extern 2 "lean_llvm_getGlobalArray"]
def getGlobalArray : @& Module -> IO (Array GlobalVar) := arbitrary
------------------------------------------------------------------------
-- Other
/-- Initialize machine code functions for the current architecture. -/
@[extern 1 "lean_llvm_initNativeFns"]
def initNativeFns : IO Unit := arbitrary
@[extern 2 "lean_llvm_newMemoryBufferFromFile"]
def newMemoryBufferFromFile : String → IO MemoryBuffer := arbitrary
------------------------------------------------------------------------
-- Triple
@[extern "lean_llvm_getProcessTriple"]
def processTriple : Unit → String := arbitrary
/-- This constructs a compiler session and frees it when done. -/
@[extern "lean_llvm_newTriple"]
constant newTriple : String → Triple := arbitrary
end FFI
end LLVM
|
8f58dba13c2f69407748cd8ce6f634f5b6c8ef8d | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/lean/interactive/completion.lean | ac77f755ee9398ed7e220bc6dc853670fb04c26d | [
"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 | 345 | lean | structure Foo where
foo : Nat
example (f : Foo) : f.
--^ textDocument/completion
example (f : Foo) : f.f
--^ textDocument/completion
example (f : Foo) : id f |>.
--^ textDocument/completion
example (f : Foo) : id f |>.f
--^ textDocument/completion
|
b4045380f7ede86ac4db7bad871518c98143a00c | 94e33a31faa76775069b071adea97e86e218a8ee | /src/data/bracket.lean | e5cb5e55f2ff45624e11b3f1f4ddcddf6334a985 | [
"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 | 1,456 | lean | /-
Copyright (c) 2021 Patrick Lutz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Lutz, Oliver Nash
-/
/-!
# Bracket Notation
This file provides notation which can be used for the Lie bracket, for the commutator of two
subgroups, and for other similar operations.
## Main Definitions
* `has_bracket L M` for a binary operation that takes something in `L` and something in `M` and
produces something in `M`. Defining an instance of this structure gives access to the notation `⁅ ⁆`
## Notation
We introduce the notation `⁅x, y⁆` for the `bracket` of any `has_bracket` structure. Note that
these are the Unicode "square with quill" brackets rather than the usual square brackets.
-/
/-- The has_bracket class has three intended uses:
1. for certain binary operations on structures, like the product `⁅x, y⁆` of two elements
`x`, `y` in a Lie algebra or the commutator of two elements `x` and `y` in a group.
2. for certain actions of one structure on another, like the action `⁅x, m⁆` of an element `x`
of a Lie algebra on an element `m` in one of its modules (analogous to `has_smul` in the
associative setting).
3. for binary operations on substructures, like the commutator `⁅H, K⁆` of two subgroups `H` and
`K` of a group. -/
class has_bracket (L M : Type*) := (bracket : L → M → M)
notation `⁅`x`,` y`⁆` := has_bracket.bracket x y
|
1049710c3ddbe4d3dbf1c740395802090ee7a93d | ac49064e8a9a038e07cf5574b4fccd8a70d115c8 | /hott/algebra/bundled.hlean | a3e5b8a9ddf35f98636b41d446fc6243354dc48f | [
"Apache-2.0"
] | permissive | Bolt64/lean2 | 7c75016729569e04a3f403c7a4fc7c1de4377c9d | 75fd8162488214a959dbe3303a185cbbb83f60f9 | refs/heads/master | 1,611,290,445,156 | 1,493,763,922,000 | 1,493,763,922,000 | 81,566,307 | 0 | 0 | null | 1,486,732,167,000 | 1,486,732,167,000 | null | UTF-8 | Lean | false | false | 5,647 | hlean | /-
Copyright (c) 2015 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
Bundled structures
-/
import algebra.group homotopy.interval
open algebra pointed is_trunc
namespace algebra
structure Semigroup :=
(carrier : Type) (struct : semigroup carrier)
attribute Semigroup.carrier [coercion]
attribute Semigroup.struct [instance]
structure CommSemigroup :=
(carrier : Type) (struct : comm_semigroup carrier)
attribute CommSemigroup.carrier [coercion]
attribute CommSemigroup.struct [instance]
structure Monoid :=
(carrier : Type) (struct : monoid carrier)
attribute Monoid.carrier [coercion]
attribute Monoid.struct [instance]
structure CommMonoid :=
(carrier : Type) (struct : comm_monoid carrier)
attribute CommMonoid.carrier [coercion]
attribute CommMonoid.struct [instance]
structure Group :=
(carrier : Type) (struct : group carrier)
attribute Group.carrier [coercion]
attribute Group.struct [instance]
section
local attribute Group.struct [instance]
definition pSet_of_Group [constructor] [reducible] [coercion] (G : Group) : Set* :=
ptrunctype.mk G !semigroup.is_set_carrier 1
end
attribute algebra._trans_of_pSet_of_Group [unfold 1]
attribute algebra._trans_of_pSet_of_Group_1 algebra._trans_of_pSet_of_Group_2 [constructor]
definition pType_of_Group [reducible] [constructor] : Group → Type* :=
algebra._trans_of_pSet_of_Group_1
definition Set_of_Group [reducible] [constructor] : Group → Set :=
algebra._trans_of_pSet_of_Group_2
definition AddGroup : Type := Group
definition AddGroup.mk [constructor] [reducible] (G : Type) (H : add_group G) : AddGroup :=
Group.mk G H
definition AddGroup.struct [reducible] (G : AddGroup) : add_group G :=
Group.struct G
attribute AddGroup.struct Group.struct [instance] [priority 2000]
structure AbGroup :=
(carrier : Type) (struct : ab_group carrier)
attribute AbGroup.carrier [coercion]
definition AddAbGroup : Type := AbGroup
definition AddAbGroup.mk [constructor] [reducible] (G : Type) (H : add_ab_group G) :
AddAbGroup :=
AbGroup.mk G H
definition AddAbGroup.struct [reducible] (G : AddAbGroup) : add_ab_group G :=
AbGroup.struct G
attribute AddAbGroup.struct AbGroup.struct [instance] [priority 2000]
definition Group_of_AbGroup [coercion] [constructor] (G : AbGroup) : Group :=
Group.mk G _
attribute algebra._trans_of_Group_of_AbGroup_1
algebra._trans_of_Group_of_AbGroup
algebra._trans_of_Group_of_AbGroup_3 [constructor]
attribute algebra._trans_of_Group_of_AbGroup_2 [unfold 1]
definition ab_group_AbGroup [instance] (G : AbGroup) : ab_group G :=
AbGroup.struct G
definition add_ab_group_AddAbGroup [instance] (G : AddAbGroup) : add_ab_group G :=
AbGroup.struct G
-- structure AddSemigroup :=
-- (carrier : Type) (struct : add_semigroup carrier)
-- attribute AddSemigroup.carrier [coercion]
-- attribute AddSemigroup.struct [instance]
-- structure AddCommSemigroup :=
-- (carrier : Type) (struct : add_comm_semigroup carrier)
-- attribute AddCommSemigroup.carrier [coercion]
-- attribute AddCommSemigroup.struct [instance]
-- structure AddMonoid :=
-- (carrier : Type) (struct : add_monoid carrier)
-- attribute AddMonoid.carrier [coercion]
-- attribute AddMonoid.struct [instance]
-- structure AddCommMonoid :=
-- (carrier : Type) (struct : add_comm_monoid carrier)
-- attribute AddCommMonoid.carrier [coercion]
-- attribute AddCommMonoid.struct [instance]
-- structure AddGroup :=
-- (carrier : Type) (struct : add_group carrier)
-- attribute AddGroup.carrier [coercion]
-- attribute AddGroup.struct [instance]
-- structure AddAbGroup :=
-- (carrier : Type) (struct : add_ab_group carrier)
-- attribute AddAbGroup.carrier [coercion]
-- attribute AddAbGroup.struct [instance]
-- some bundled infinity-structures
structure InfGroup :=
(carrier : Type) (struct : inf_group carrier)
attribute InfGroup.carrier [coercion]
attribute InfGroup.struct [instance]
section
local attribute InfGroup.struct [instance]
definition pType_of_InfGroup [constructor] [reducible] [coercion] (G : InfGroup) : Type* :=
pType.mk G 1
end
attribute algebra._trans_of_pType_of_InfGroup [unfold 1]
definition AddInfGroup : Type := InfGroup
definition AddInfGroup.mk [constructor] [reducible] (G : Type) (H : add_inf_group G) :
AddInfGroup :=
InfGroup.mk G H
definition AddInfGroup.struct [reducible] (G : AddInfGroup) : add_inf_group G :=
InfGroup.struct G
attribute AddInfGroup.struct InfGroup.struct [instance] [priority 2000]
structure AbInfGroup :=
(carrier : Type) (struct : ab_inf_group carrier)
attribute AbInfGroup.carrier [coercion]
definition AddAbInfGroup : Type := AbInfGroup
definition AddAbInfGroup.mk [constructor] [reducible] (G : Type) (H : add_ab_inf_group G) :
AddAbInfGroup :=
AbInfGroup.mk G H
definition AddAbInfGroup.struct [reducible] (G : AddAbInfGroup) : add_ab_inf_group G :=
AbInfGroup.struct G
attribute AddAbInfGroup.struct AbInfGroup.struct [instance] [priority 2000]
definition InfGroup_of_AbInfGroup [coercion] [constructor] (G : AbInfGroup) : InfGroup :=
InfGroup.mk G _
attribute algebra._trans_of_InfGroup_of_AbInfGroup_1 [constructor]
attribute algebra._trans_of_InfGroup_of_AbInfGroup [unfold 1]
definition InfGroup_of_Group [constructor] (G : Group) : InfGroup :=
InfGroup.mk G _
definition AddInfGroup_of_AddGroup [constructor] (G : AddGroup) : AddInfGroup :=
AddInfGroup.mk G _
definition AbInfGroup_of_AbGroup [constructor] (G : AbGroup) : AbInfGroup :=
AbInfGroup.mk G _
definition AddAbInfGroup_of_AddAbGroup [constructor] (G : AddAbGroup) : AddAbInfGroup :=
AddAbInfGroup.mk G _
end algebra
|
8df7a51f1d06287a30585df28a794fe576f1111f | ce6917c5bacabee346655160b74a307b4a5ab620 | /src/ch5/ex0105.lean | f6fa0bff1dd246a6d69a968ed4c8ffe78b79434b | [] | no_license | Ailrun/Theorem_Proving_in_Lean | ae6a23f3c54d62d401314d6a771e8ff8b4132db2 | 2eb1b5caf93c6a5a555c79e9097cf2ba5a66cf68 | refs/heads/master | 1,609,838,270,467 | 1,586,846,743,000 | 1,586,846,743,000 | 240,967,761 | 1 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 134 | lean | theorem test (p q : Prop) (hp : p) (hq : q) : p ∧ q ∧ p :=
begin
apply and.intro hp,
exact and.intro hq hp,
end
#print test
|
3b3383751092b7a9db979ee9a3f3efc0d06f1d4e | d9d511f37a523cd7659d6f573f990e2a0af93c6f | /src/topology/maps.lean | 8e039021e0d5046ea2f44a601661748678201573 | [
"Apache-2.0"
] | permissive | hikari0108/mathlib | b7ea2b7350497ab1a0b87a09d093ecc025a50dfa | a9e7d333b0cfd45f13a20f7b96b7d52e19fa2901 | refs/heads/master | 1,690,483,608,260 | 1,631,541,580,000 | 1,631,541,580,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 17,999 | 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
-/
import topology.order
/-!
# Specific classes of maps between topological spaces
This file introduces the following properties of a map `f : X → Y` between topological spaces:
* `is_open_map f` means the image of an open set under `f` is open.
* `is_closed_map f` means the image of a closed set under `f` is closed.
(Open and closed maps need not be continuous.)
* `inducing f` means the topology on `X` is the one induced via `f` from the topology on `Y`.
These behave like embeddings except they need not be injective. Instead, points of `X` which
are identified by `f` are also indistinguishable in the topology on `X`.
* `embedding f` means `f` is inducing and also injective. Equivalently, `f` identifies `X` with
a subspace of `Y`.
* `open_embedding f` means `f` is an embedding with open image, so it identifies `X` with an
open subspace of `Y`. Equivalently, `f` is an embedding and an open map.
* `closed_embedding f` similarly means `f` is an embedding with closed image, so it identifies
`X` with a closed subspace of `Y`. Equivalently, `f` is an embedding and a closed map.
* `quotient_map f` is the dual condition to `embedding f`: `f` is surjective and the topology
on `Y` is the one coinduced via `f` from the topology on `X`. Equivalently, `f` identifies
`Y` with a quotient of `X`. Quotient maps are also sometimes known as identification maps.
## References
* <https://en.wikipedia.org/wiki/Open_and_closed_maps>
* <https://en.wikipedia.org/wiki/Embedding#General_topology>
* <https://en.wikipedia.org/wiki/Quotient_space_(topology)#Quotient_map>
## Tags
open map, closed map, embedding, quotient map, identification map
-/
open set filter
open_locale topological_space filter
variables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
section inducing
structure inducing [tα : topological_space α] [tβ : topological_space β] (f : α → β) : Prop :=
(induced : tα = tβ.induced f)
variables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]
lemma inducing_id : inducing (@id α) :=
⟨induced_id.symm⟩
protected lemma inducing.comp {g : β → γ} {f : α → β} (hg : inducing g) (hf : inducing f) :
inducing (g ∘ f) :=
⟨by rw [hf.induced, hg.induced, induced_compose]⟩
lemma inducing_of_inducing_compose {f : α → β} {g : β → γ} (hf : continuous f) (hg : continuous g)
(hgf : inducing (g ∘ f)) : inducing f :=
⟨le_antisymm
(by rwa ← continuous_iff_le_induced)
(by { rw [hgf.induced, ← continuous_iff_le_induced], apply hg.comp continuous_induced_dom })⟩
lemma inducing.nhds_eq_comap {f : α → β} (hf : inducing f) :
∀ (a : α), 𝓝 a = comap f (𝓝 $ f a) :=
(induced_iff_nhds_eq f).1 hf.induced
lemma inducing.map_nhds_eq {f : α → β} (hf : inducing f) (a : α) :
(𝓝 a).map f = 𝓝[range f] (f a) :=
hf.induced.symm ▸ map_nhds_induced_eq a
lemma inducing.map_nhds_of_mem {f : α → β} (hf : inducing f) (a : α) (h : range f ∈ 𝓝 (f a)) :
(𝓝 a).map f = 𝓝 (f a) :=
hf.induced.symm ▸ map_nhds_induced_of_mem h
lemma inducing.tendsto_nhds_iff {ι : Type*}
{f : ι → β} {g : β → γ} {a : filter ι} {b : β} (hg : inducing g) :
tendsto f a (𝓝 b) ↔ tendsto (g ∘ f) a (𝓝 (g b)) :=
by rw [tendsto, tendsto, hg.induced, nhds_induced, ← map_le_iff_le_comap, filter.map_map]
lemma inducing.continuous_iff {f : α → β} {g : β → γ} (hg : inducing g) :
continuous f ↔ continuous (g ∘ f) :=
by simp [continuous_iff_continuous_at, continuous_at, inducing.tendsto_nhds_iff hg]
lemma inducing.continuous {f : α → β} (hf : inducing f) : continuous f :=
hf.continuous_iff.mp continuous_id
lemma inducing.closure_eq_preimage_closure_image {f : α → β} (hf : inducing f) (s : set α) :
closure s = f ⁻¹' closure (f '' s) :=
by { ext x, rw [set.mem_preimage, ← closure_induced, hf.induced] }
lemma inducing.is_closed_iff {f : α → β} (hf : inducing f) {s : set α} :
is_closed s ↔ ∃ t, is_closed t ∧ f ⁻¹' t = s :=
by rw [hf.induced, is_closed_induced_iff]
lemma inducing.is_open_iff {f : α → β} (hf : inducing f) {s : set α} :
is_open s ↔ ∃ t, is_open t ∧ f ⁻¹' t = s :=
by rw [hf.induced, is_open_induced_iff]
end inducing
section embedding
/-- A function between topological spaces is an embedding if it is injective,
and for all `s : set α`, `s` is open iff it is the preimage of an open set. -/
structure embedding [tα : topological_space α] [tβ : topological_space β] (f : α → β)
extends inducing f : Prop :=
(inj : function.injective f)
variables [topological_space α] [topological_space β] [topological_space γ]
lemma embedding.mk' (f : α → β) (inj : function.injective f)
(induced : ∀a, comap f (𝓝 (f a)) = 𝓝 a) : embedding f :=
⟨⟨(induced_iff_nhds_eq f).2 (λ a, (induced a).symm)⟩, inj⟩
lemma embedding_id : embedding (@id α) :=
⟨inducing_id, assume a₁ a₂ h, h⟩
lemma embedding.comp {g : β → γ} {f : α → β} (hg : embedding g) (hf : embedding f) :
embedding (g ∘ f) :=
{ inj:= assume a₁ a₂ h, hf.inj $ hg.inj h,
..hg.to_inducing.comp hf.to_inducing }
lemma embedding_of_embedding_compose {f : α → β} {g : β → γ} (hf : continuous f) (hg : continuous g)
(hgf : embedding (g ∘ f)) : embedding f :=
{ induced := (inducing_of_inducing_compose hf hg hgf.to_inducing).induced,
inj := assume a₁ a₂ h, hgf.inj $ by simp [h, (∘)] }
protected lemma function.left_inverse.embedding {f : α → β} {g : β → α}
(h : function.left_inverse f g) (hf : continuous f) (hg : continuous g) :
embedding g :=
embedding_of_embedding_compose hg hf $ h.comp_eq_id.symm ▸ embedding_id
lemma embedding.map_nhds_eq {f : α → β} (hf : embedding f) (a : α) :
(𝓝 a).map f = 𝓝[range f] (f a) :=
hf.1.map_nhds_eq a
lemma embedding.map_nhds_of_mem {f : α → β}
(hf : embedding f) (a : α) (h : range f ∈ 𝓝 (f a)) : (𝓝 a).map f = 𝓝 (f a) :=
hf.1.map_nhds_of_mem a h
lemma embedding.tendsto_nhds_iff {ι : Type*}
{f : ι → β} {g : β → γ} {a : filter ι} {b : β} (hg : embedding g) :
tendsto f a (𝓝 b) ↔ tendsto (g ∘ f) a (𝓝 (g b)) :=
hg.to_inducing.tendsto_nhds_iff
lemma embedding.continuous_iff {f : α → β} {g : β → γ} (hg : embedding g) :
continuous f ↔ continuous (g ∘ f) :=
inducing.continuous_iff hg.1
lemma embedding.continuous {f : α → β} (hf : embedding f) : continuous f :=
inducing.continuous hf.1
lemma embedding.closure_eq_preimage_closure_image {e : α → β} (he : embedding e) (s : set α) :
closure s = e ⁻¹' closure (e '' s) :=
he.1.closure_eq_preimage_closure_image s
end embedding
/-- A function between topological spaces is a quotient map if it is surjective,
and for all `s : set β`, `s` is open iff its preimage is an open set. -/
def quotient_map {α : Type*} {β : Type*} [tα : topological_space α] [tβ : topological_space β]
(f : α → β) : Prop :=
function.surjective f ∧ tβ = tα.coinduced f
lemma quotient_map_iff {α β : Type*} [topological_space α] [topological_space β] {f : α → β} :
quotient_map f ↔ function.surjective f ∧ ∀ s : set β, is_open s ↔ is_open (f ⁻¹' s) :=
and_congr iff.rfl topological_space_eq_iff
namespace quotient_map
variables [topological_space α] [topological_space β] [topological_space γ] [topological_space δ]
protected lemma id : quotient_map (@id α) :=
⟨assume a, ⟨a, rfl⟩, coinduced_id.symm⟩
protected lemma comp {g : β → γ} {f : α → β} (hg : quotient_map g) (hf : quotient_map f) :
quotient_map (g ∘ f) :=
⟨hg.left.comp hf.left, by rw [hg.right, hf.right, coinduced_compose]⟩
protected lemma of_quotient_map_compose {f : α → β} {g : β → γ}
(hf : continuous f) (hg : continuous g)
(hgf : quotient_map (g ∘ f)) : quotient_map g :=
⟨assume b, let ⟨a, h⟩ := hgf.left b in ⟨f a, h⟩,
le_antisymm
(by rw [hgf.right, ← continuous_iff_coinduced_le];
apply continuous_coinduced_rng.comp hf)
(by rwa ← continuous_iff_coinduced_le)⟩
protected lemma continuous_iff {f : α → β} {g : β → γ} (hf : quotient_map f) :
continuous g ↔ continuous (g ∘ f) :=
by rw [continuous_iff_coinduced_le, continuous_iff_coinduced_le, hf.right, coinduced_compose]
protected lemma continuous {f : α → β} (hf : quotient_map f) : continuous f :=
hf.continuous_iff.mp continuous_id
protected lemma surjective {f : α → β} (hf : quotient_map f) : function.surjective f := hf.1
protected lemma is_open_preimage {f : α → β} (hf : quotient_map f) {s : set β} :
is_open (f ⁻¹' s) ↔ is_open s :=
((quotient_map_iff.1 hf).2 s).symm
end quotient_map
/-- A map `f : α → β` is said to be an *open map*, if the image of any open `U : set α`
is open in `β`. -/
def is_open_map [topological_space α] [topological_space β] (f : α → β) :=
∀ U : set α, is_open U → is_open (f '' U)
namespace is_open_map
variables [topological_space α] [topological_space β] [topological_space γ] {f : α → β}
open function
protected lemma id : is_open_map (@id α) := assume s hs, by rwa [image_id]
protected lemma comp
{g : β → γ} {f : α → β} (hg : is_open_map g) (hf : is_open_map f) : is_open_map (g ∘ f) :=
by intros s hs; rw [image_comp]; exact hg _ (hf _ hs)
lemma is_open_range (hf : is_open_map f) : is_open (range f) :=
by { rw ← image_univ, exact hf _ is_open_univ }
lemma image_mem_nhds (hf : is_open_map f) {x : α} {s : set α} (hx : s ∈ 𝓝 x) :
f '' s ∈ 𝓝 (f x) :=
let ⟨t, hts, ht, hxt⟩ := mem_nhds_iff.1 hx in
mem_of_superset (is_open.mem_nhds (hf t ht) (mem_image_of_mem _ hxt)) (image_subset _ hts)
lemma image_interior_subset (hf : is_open_map f) (s : set α) :
f '' interior s ⊆ interior (f '' s) :=
interior_maximal (image_subset _ interior_subset) (hf _ is_open_interior)
lemma nhds_le (hf : is_open_map f) (a : α) : 𝓝 (f a) ≤ (𝓝 a).map f :=
le_map $ λ s, hf.image_mem_nhds
lemma of_nhds_le (hf : ∀ a, 𝓝 (f a) ≤ map f (𝓝 a)) : is_open_map f :=
λ s hs, is_open_iff_mem_nhds.2 $ λ b ⟨a, has, hab⟩,
hab ▸ hf _ (image_mem_map $ is_open.mem_nhds hs has)
lemma of_inverse {f : α → β} {f' : β → α}
(h : continuous f') (l_inv : left_inverse f f') (r_inv : right_inverse f f') :
is_open_map f :=
begin
assume s hs,
rw [image_eq_preimage_of_inverse r_inv l_inv],
exact hs.preimage h
end
lemma to_quotient_map {f : α → β}
(open_map : is_open_map f) (cont : continuous f) (surj : function.surjective f) :
quotient_map f :=
⟨ surj,
begin
ext s,
show is_open s ↔ is_open (f ⁻¹' s),
split,
{ exact continuous_def.1 cont s },
{ assume h,
rw ← surj.image_preimage s,
exact open_map _ h }
end⟩
end is_open_map
lemma is_open_map_iff_nhds_le [topological_space α] [topological_space β] {f : α → β} :
is_open_map f ↔ ∀(a:α), 𝓝 (f a) ≤ (𝓝 a).map f :=
⟨λ hf, hf.nhds_le, is_open_map.of_nhds_le⟩
lemma inducing.is_open_map [topological_space α] [topological_space β] {f : α → β}
(hi : inducing f) (ho : is_open (range f)) :
is_open_map f :=
is_open_map.of_nhds_le $ λ x, (hi.map_nhds_of_mem _ $ is_open.mem_nhds ho $ mem_range_self _).ge
section is_closed_map
variables [topological_space α] [topological_space β]
/-- A map `f : α → β` is said to be a *closed map*, if the image of any closed `U : set α`
is closed in `β`. -/
def is_closed_map (f : α → β) := ∀ U : set α, is_closed U → is_closed (f '' U)
end is_closed_map
namespace is_closed_map
variables [topological_space α] [topological_space β] [topological_space γ]
open function
protected lemma id : is_closed_map (@id α) := assume s hs, by rwa image_id
protected lemma comp {g : β → γ} {f : α → β} (hg : is_closed_map g) (hf : is_closed_map f) :
is_closed_map (g ∘ f) :=
by { intros s hs, rw image_comp, exact hg _ (hf _ hs) }
lemma of_inverse {f : α → β} {f' : β → α}
(h : continuous f') (l_inv : left_inverse f f') (r_inv : right_inverse f f') :
is_closed_map f :=
assume s hs,
have f' ⁻¹' s = f '' s, by ext x; simp [mem_image_iff_of_inverse r_inv l_inv],
this ▸ hs.preimage h
lemma of_nonempty {f : α → β} (h : ∀ s, is_closed s → s.nonempty → is_closed (f '' s)) :
is_closed_map f :=
begin
intros s hs, cases eq_empty_or_nonempty s with h2s h2s,
{ simp_rw [h2s, image_empty, is_closed_empty] },
{ exact h s hs h2s }
end
end is_closed_map
lemma inducing.is_closed_map [topological_space α] [topological_space β]
{f : α → β} (hf : inducing f) (h : is_closed (range f)) : is_closed_map f :=
begin
intros s hs,
rcases hf.is_closed_iff.1 hs with ⟨t, ht, rfl⟩,
rw image_preimage_eq_inter_range,
exact is_closed.inter ht h
end
section open_embedding
variables [topological_space α] [topological_space β] [topological_space γ]
/-- An open embedding is an embedding with open image. -/
structure open_embedding (f : α → β) extends embedding f : Prop :=
(open_range : is_open $ range f)
lemma open_embedding.is_open_map {f : α → β} (hf : open_embedding f) : is_open_map f :=
hf.to_embedding.to_inducing.is_open_map hf.open_range
lemma open_embedding.map_nhds_eq {f : α → β} (hf : open_embedding f) (a : α) :
map f (𝓝 a) = 𝓝 (f a) :=
hf.to_embedding.map_nhds_of_mem _ $ is_open.mem_nhds hf.open_range $ mem_range_self _
lemma open_embedding.open_iff_image_open {f : α → β} (hf : open_embedding f)
{s : set α} : is_open s ↔ is_open (f '' s) :=
⟨hf.is_open_map s,
λ h, begin
convert ← h.preimage hf.to_embedding.continuous,
apply preimage_image_eq _ hf.inj
end⟩
lemma open_embedding.tendsto_nhds_iff {ι : Type*}
{f : ι → β} {g : β → γ} {a : filter ι} {b : β} (hg : open_embedding g) :
tendsto f a (𝓝 b) ↔ tendsto (g ∘ f) a (𝓝 (g b)) :=
hg.to_embedding.tendsto_nhds_iff
lemma open_embedding.continuous {f : α → β} (hf : open_embedding f) : continuous f :=
hf.to_embedding.continuous
lemma open_embedding.open_iff_preimage_open {f : α → β} (hf : open_embedding f)
{s : set β} (hs : s ⊆ range f) : is_open s ↔ is_open (f ⁻¹' s) :=
begin
convert ←hf.open_iff_image_open.symm,
rwa [image_preimage_eq_inter_range, inter_eq_self_of_subset_left]
end
lemma open_embedding_of_embedding_open {f : α → β} (h₁ : embedding f)
(h₂ : is_open_map f) : open_embedding f :=
⟨h₁, h₂.is_open_range⟩
lemma open_embedding_of_continuous_injective_open {f : α → β} (h₁ : continuous f)
(h₂ : function.injective f) (h₃ : is_open_map f) : open_embedding f :=
begin
refine open_embedding_of_embedding_open ⟨⟨_⟩, h₂⟩ h₃,
apply le_antisymm (continuous_iff_le_induced.mp h₁) _,
intro s,
change is_open _ → is_open _,
rw is_open_induced_iff,
refine λ hs, ⟨f '' s, h₃ s hs, _⟩,
rw preimage_image_eq _ h₂
end
lemma open_embedding_id : open_embedding (@id α) :=
⟨embedding_id, by convert is_open_univ; apply range_id⟩
lemma open_embedding.comp {g : β → γ} {f : α → β}
(hg : open_embedding g) (hf : open_embedding f) : open_embedding (g ∘ f) :=
⟨hg.1.comp hf.1, show is_open (range (g ∘ f)),
by rw [range_comp, ←hg.open_iff_image_open]; exact hf.2⟩
end open_embedding
section closed_embedding
variables [topological_space α] [topological_space β] [topological_space γ]
/-- A closed embedding is an embedding with closed image. -/
structure closed_embedding (f : α → β) extends embedding f : Prop :=
(closed_range : is_closed $ range f)
variables {f : α → β}
lemma closed_embedding.tendsto_nhds_iff {ι : Type*}
{g : ι → α} {a : filter ι} {b : α} (hf : closed_embedding f) :
tendsto g a (𝓝 b) ↔ tendsto (f ∘ g) a (𝓝 (f b)) :=
hf.to_embedding.tendsto_nhds_iff
lemma closed_embedding.continuous (hf : closed_embedding f) : continuous f :=
hf.to_embedding.continuous
lemma closed_embedding.is_closed_map (hf : closed_embedding f) : is_closed_map f :=
hf.to_embedding.to_inducing.is_closed_map hf.closed_range
lemma closed_embedding.closed_iff_image_closed (hf : closed_embedding f)
{s : set α} : is_closed s ↔ is_closed (f '' s) :=
⟨hf.is_closed_map s,
λ h, begin
convert ←continuous_iff_is_closed.mp hf.continuous _ h,
apply preimage_image_eq _ hf.inj
end⟩
lemma closed_embedding.closed_iff_preimage_closed (hf : closed_embedding f)
{s : set β} (hs : s ⊆ range f) : is_closed s ↔ is_closed (f ⁻¹' s) :=
begin
convert ←hf.closed_iff_image_closed.symm,
rwa [image_preimage_eq_inter_range, inter_eq_self_of_subset_left]
end
lemma closed_embedding_of_embedding_closed (h₁ : embedding f)
(h₂ : is_closed_map f) : closed_embedding f :=
⟨h₁, by convert h₂ univ is_closed_univ; simp⟩
lemma closed_embedding_of_continuous_injective_closed (h₁ : continuous f)
(h₂ : function.injective f) (h₃ : is_closed_map f) : closed_embedding f :=
begin
refine closed_embedding_of_embedding_closed ⟨⟨_⟩, h₂⟩ h₃,
apply le_antisymm (continuous_iff_le_induced.mp h₁) _,
intro s',
change is_open _ ≤ is_open _,
rw [←is_closed_compl_iff, ←is_closed_compl_iff],
generalize : s'ᶜ = s,
rw is_closed_induced_iff,
refine λ hs, ⟨f '' s, h₃ s hs, _⟩,
rw preimage_image_eq _ h₂
end
lemma closed_embedding_id : closed_embedding (@id α) :=
⟨embedding_id, by convert is_closed_univ; apply range_id⟩
lemma closed_embedding.comp {g : β → γ} {f : α → β}
(hg : closed_embedding g) (hf : closed_embedding f) : closed_embedding (g ∘ f) :=
⟨hg.to_embedding.comp hf.to_embedding, show is_closed (range (g ∘ f)),
by rw [range_comp, ←hg.closed_iff_image_closed]; exact hf.closed_range⟩
end closed_embedding
|
94714b9907ac389980fb1da947a76f78ecaf0bd9 | 649957717d58c43b5d8d200da34bf374293fe739 | /src/logic/unique.lean | c30b4e825c884feaed6881da44b674f01b087dec | [
"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 | 1,384 | lean | /-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
universes u v w
variables {α : Sort u} {β : Sort v} {γ : Sort w}
structure unique (α : Sort u) extends inhabited α :=
(uniq : ∀ a:α, a = default)
attribute [class] unique
instance punit.unique : unique punit.{u} :=
{ default := punit.star,
uniq := λ x, punit_eq x _ }
instance fin.unique : unique (fin 1) :=
{ default := 0,
uniq := λ ⟨n, hn⟩, fin.eq_of_veq
(nat.eq_zero_of_le_zero (nat.le_of_lt_succ hn)) }
namespace unique
open function
section
variables [unique α]
instance : inhabited α := to_inhabited ‹unique α›
lemma eq_default (a : α) : a = default α := uniq _ a
lemma default_eq (a : α) : default α = a := (uniq _ a).symm
instance : subsingleton α := ⟨λ a b, by rw [eq_default a, eq_default b]⟩
end
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'⟩
def of_surjective {f : α → β} (hf : surjective f) [unique α] : unique β :=
{ default := f (default _),
uniq := λ b,
begin
cases hf b with a ha,
subst ha,
exact congr_arg f (eq_default a)
end }
end unique
|
3f480bf25fe928994b6e19ef427ee1cd609083d1 | 82b86ba2ae0d5aed0f01f49c46db5afec0eb2bd7 | /tests/lean/run/beginEndAsMacro.lean | 078b9f99228485bf39e7d886a92b3b3a522a68c1 | [
"Apache-2.0"
] | permissive | banksonian/lean4 | 3a2e6b0f1eb63aa56ff95b8d07b2f851072d54dc | 78da6b3aa2840693eea354a41e89fc5b212a5011 | refs/heads/master | 1,673,703,624,165 | 1,605,123,551,000 | 1,605,123,551,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 592 | lean | syntax[beginEndKind] "begin " (sepBy (allowTrailingSep := true) tactic ", ") "end" : term
open Lean in
@[macro beginEndKind] def expandBeginEnd : Lean.Macro := fun stx =>
match_syntax stx with
| `(begin $ts* end) => do
let ts := ts.getSepElems.map fun t => mkNullNode #[t, mkNullNode]
let tseq := mkNode `Lean.Parser.Tactic.tacticSeqBracketed #[mkAtomFrom stx "{", mkNullNode ts, mkAtomFrom stx[2] "}"]
`(by $tseq:tacticSeqBracketed)
| _ => Macro.throwUnsupported
theorem ex1 (x : Nat) : x + 0 = 0 + x :=
begin
rw Nat.zeroAdd,
rw Nat.addZero,
rfl
end
|
92071913622ffde1a2a0b42ac1b25bf0cc2b2cb2 | f618aea02cb4104ad34ecf3b9713065cc0d06103 | /src/category_theory/instances/Top/open_nhds.lean | 3d05a774f0e526298dcb3dd6187f1b3ed6223444 | [
"Apache-2.0"
] | permissive | joehendrix/mathlib | 84b6603f6be88a7e4d62f5b1b0cbb523bb82b9a5 | c15eab34ad754f9ecd738525cb8b5a870e834ddc | refs/heads/master | 1,589,606,591,630 | 1,555,946,393,000 | 1,555,946,393,000 | 182,813,854 | 0 | 0 | null | 1,555,946,309,000 | 1,555,946,308,000 | null | UTF-8 | Lean | false | false | 1,514 | lean | import category_theory.instances.Top.opens
open category_theory
open category_theory.instances
open topological_space
universe u
namespace topological_space.open_nhds
variables {X Y : Top.{u}} (f : X ⟶ Y)
def open_nhds (x : X.α) := { U : opens X // x ∈ U }
instance open_nhds_category (x : X.α) : category.{u+1} (open_nhds x) := by {unfold open_nhds, apply_instance}
def inclusion (x : X.α) : open_nhds x ⥤ opens X :=
full_subcategory_inclusion _
@[simp] lemma inclusion_obj (x : X.α) (U) (p) : (inclusion x).obj ⟨U,p⟩ = U := rfl
def map (x : X) : open_nhds (f x) ⥤ open_nhds x :=
{ obj := λ U, ⟨(opens.map f).obj U.1, by tidy⟩,
map := λ U V i, (opens.map f).map i }
@[simp] lemma map_id_obj' (x : X) (U) (p) (q) : (map (𝟙 X) x).obj ⟨⟨U, p⟩, q⟩ = ⟨⟨U, p⟩, q⟩ :=
rfl
@[simp] lemma map_id_obj (x : X) (U) : (map (𝟙 X) x).obj U = U :=
by tidy
@[simp] lemma map_id_obj_unop (x : X) (U : (open_nhds x)ᵒᵖ) : (map (𝟙 X) x).obj (unop U) = unop U :=
by simp
@[simp] lemma op_map_id_obj (x : X) (U : (open_nhds x)ᵒᵖ) : (map (𝟙 X) x).op.obj U = U :=
by simp
def inclusion_map_iso (x : X) : inclusion (f x) ⋙ opens.map f ≅ map f x ⋙ inclusion x :=
nat_iso.of_components
(λ U, begin split, exact 𝟙 _, exact 𝟙 _ end)
(by tidy)
@[simp] lemma inclusion_map_iso_hom (x : X) : (inclusion_map_iso f x).hom = 𝟙 _ := rfl
@[simp] lemma inclusion_map_iso_inv (x : X) : (inclusion_map_iso f x).inv = 𝟙 _ := rfl
end topological_space.open_nhds
|
9f1216271bb91afd44269760f20403755ef42b46 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /src/Lean/Compiler.lean | 55b38b3efd7734fd339c8c511807982c2a43879e | [
"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 | 717 | 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
-/
import Lean.Compiler.InlineAttrs
import Lean.Compiler.Specialize
import Lean.Compiler.ConstFolding
import Lean.Compiler.ClosedTermCache
import Lean.Compiler.ExternAttr
import Lean.Compiler.ImplementedByAttr
import Lean.Compiler.NeverExtractAttr
import Lean.Compiler.IR
import Lean.Compiler.CSimpAttr
import Lean.Compiler.FFI
import Lean.Compiler.NoncomputableAttr
import Lean.Compiler.Main
import Lean.Compiler.AtMostOnce -- TODO: delete after we port code generator to Lean
import Lean.Compiler.Old -- TODO: delete after we port code generator to Lean
|
a003e7a8d0bc70d1f002320a67a4c8cf727800ab | a537b538f2bea3181e24409d8a52590603d1ddd9 | /examples/quotient_group.lean | a39a9978630c5ea243abf14e04d58d0478fb0f5f | [] | no_license | rwbarton/lean-tidy | 6134813ded72b275d19d4d32514dba80c21708e3 | fe1125d32adb60decda7a77d0f679614ba9f6fbb | refs/heads/master | 1,585,549,718,705 | 1,538,120,619,000 | 1,538,120,624,000 | 150,864,330 | 0 | 0 | null | 1,538,225,790,000 | 1,538,225,790,000 | null | UTF-8 | Lean | false | false | 2,175 | lean | import group_theory.coset data.equiv data.quot
import tidy.tidy
open set function
section quotient_group
variable {α : Type*}
-- Some instances allowing us to use quotient notation
local attribute [instance] left_rel normal_subgroup.to_is_subgroup
-- We now prove two lemmas about elements in normal subgroups. I haven't attempted any automation here.
lemma quotient_group_aux [group α] (s : set α) [normal_subgroup s] (a b : α) (h : a⁻¹ * b ∈ s) : a * b⁻¹ ∈ s :=
begin
rw [← inv_inv a, ← mul_inv_rev],
exact is_subgroup.inv_mem (is_subgroup.mem_norm_comm h),
end
lemma quotient_group_aux' [group α] (s : set α) [normal_subgroup s] (a b c d : α) (h₁ : a * b ∈ s) (h₂ : c * d ∈ s) : c * (a * (b * d)) ∈ s :=
begin
apply is_subgroup.mem_norm_comm,
rw [← mul_assoc, mul_assoc],
apply (is_subgroup.mul_mem_cancel_right s h₁).2,
exact is_subgroup.mem_norm_comm h₂
end
lemma quotient_group_aux'' [group α] (s : set α) [normal_subgroup s] (a b c d : α) (h₁ : a * b ∈ s) (h₂ : c * d ∈ s) : c * a * (b * d) ∈ s :=
begin
sorry
end
-- PROJECT one could write a tactic proving "all such" lemmas as above:
-- Given a word in α, write it as a vector in ℤ^α, and similarly write any hypotheses.
-- Now use Smith normal form (or perhaps Hermite normal form) to determine if there are solutions to the corresponding integer Diophantine equation.
-- Some 'hint' attributes for obviously.
local attribute [reducible] setoid_has_equiv left_rel
local attribute [applicable] is_submonoid.one_mem -- `applicable` means the lemma should be applied whenever relevant
local attribute [semiapplicable] quotient_group_aux quotient_group_aux' quotient_group_aux'' -- `semiapplicable` means the lemma should be applied if all its hypotheses can be satisfied from the context
local attribute [simp] mul_assoc
instance quotient_group' [group α] (s : set α) [normal_subgroup s] : group (left_cosets s) :=
by refine
{ one := ⟦1⟧,
mul := λ a b, quotient.lift_on₂ a b (λ a b, ⟦a * b⟧) (by obviously),
inv := λ a', quotient.lift_on a' (λ a, ⟦a⁻¹⟧) (by obviously),
.. }; obviously
end quotient_group |
a1c2c76fc9d773dee42da84908d7ee8e837665af | 4727251e0cd73359b15b664c3170e5d754078599 | /src/algebra/graded_monoid.lean | 498e2fb4aaa54178e6abc986145bb1fcd52dde8b | [
"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 | 21,388 | lean | /-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import algebra.group.inj_surj
import data.list.big_operators
import data.list.range
import group_theory.group_action.defs
import group_theory.submonoid.basic
import data.set_like.basic
import data.sigma.basic
/-!
# Additively-graded multiplicative structures
This module provides a set of heterogeneous typeclasses for defining a multiplicative structure
over the sigma type `graded_monoid A` such that `(*) : A i → A j → A (i + j)`; that is to say, `A`
forms an additively-graded monoid. The typeclasses are:
* `graded_monoid.ghas_one A`
* `graded_monoid.ghas_mul A`
* `graded_monoid.gmonoid A`
* `graded_monoid.gcomm_monoid A`
With the `sigma_graded` locale open, these respectively imbue:
* `has_one (graded_monoid A)`
* `has_mul (graded_monoid A)`
* `monoid (graded_monoid A)`
* `comm_monoid (graded_monoid A)`
the base type `A 0` with:
* `graded_monoid.grade_zero.has_one`
* `graded_monoid.grade_zero.has_mul`
* `graded_monoid.grade_zero.monoid`
* `graded_monoid.grade_zero.comm_monoid`
and the `i`th grade `A i` with `A 0`-actions (`•`) defined as left-multiplication:
* (nothing)
* `graded_monoid.grade_zero.has_scalar (A 0)`
* `graded_monoid.grade_zero.mul_action (A 0)`
* (nothing)
For now, these typeclasses are primarily used in the construction of `direct_sum.ring` and the rest
of that file.
## Dependent graded products
This also introduces `list.dprod`, which takes the (possibly non-commutative) product of a list
of graded elements of type `A i`. This definition primarily exist to allow `graded_monoid.mk`
and `direct_sum.of` to be pulled outside a product, such as in `graded_monoid.mk_list_dprod` and
`direct_sum.of_list_dprod`.
## Internally graded monoids
In addition to the above typeclasses, in the most frequent case when `A` is an indexed collection of
`set_like` subobjects (such as `add_submonoid`s, `add_subgroup`s, or `submodule`s), this file
provides the `Prop` typeclasses:
* `set_like.has_graded_one A` (which provides the obvious `graded_monoid.ghas_one A` instance)
* `set_like.has_graded_mul A` (which provides the obvious `graded_monoid.ghas_mul A` instance)
* `set_like.graded_monoid A` (which provides the obvious `graded_monoid.gmonoid A` and
`graded_monoid.gcomm_monoid A` instances)
* `set_like.is_homogeneous A` (which says that `a` is homogeneous iff `a ∈ A i` for some `i : ι`)
Strictly this last class is unecessary as it has no fields not present in its parents, but it is
included for convenience. Note that there is no need for `graded_ring` or similar, as all the
information it would contain is already supplied by `graded_monoid` when `A` is a collection
of additively-closed set_like objects such as `submodules`. These constructions are explored in
`algebra.direct_sum.internal`.
This file also contains the definition of `set_like.homogeneous_submonoid A`, which is, as the name
suggests, the submonoid consisting of all the homogeneous elements.
## tags
graded monoid
-/
set_option old_structure_cmd true
variables {ι : Type*}
/-- A type alias of sigma types for graded monoids. -/
def graded_monoid (A : ι → Type*) := sigma A
namespace graded_monoid
instance {A : ι → Type*} [inhabited ι] [inhabited (A default)]: inhabited (graded_monoid A) :=
sigma.inhabited
/-- Construct an element of a graded monoid. -/
def mk {A : ι → Type*} : Π i, A i → graded_monoid A := sigma.mk
/-! ### Typeclasses -/
section defs
variables (A : ι → Type*)
/-- A graded version of `has_one`, which must be of grade 0. -/
class ghas_one [has_zero ι] :=
(one : A 0)
/-- `ghas_one` implies `has_one (graded_monoid A)` -/
instance ghas_one.to_has_one [has_zero ι] [ghas_one A] : has_one (graded_monoid A) :=
⟨⟨_, ghas_one.one⟩⟩
/-- A graded version of `has_mul`. Multiplication combines grades additively, like
`add_monoid_algebra`. -/
class ghas_mul [has_add ι] :=
(mul {i j} : A i → A j → A (i + j))
/-- `ghas_mul` implies `has_mul (graded_monoid A)`. -/
instance ghas_mul.to_has_mul [has_add ι] [ghas_mul A] :
has_mul (graded_monoid A) :=
⟨λ (x y : graded_monoid A), ⟨_, ghas_mul.mul x.snd y.snd⟩⟩
lemma mk_mul_mk [has_add ι] [ghas_mul A] {i j} (a : A i) (b : A j) :
mk i a * mk j b = mk (i + j) (ghas_mul.mul a b) :=
rfl
namespace gmonoid
variables {A} [add_monoid ι] [ghas_mul A] [ghas_one A]
/-- A default implementation of power on a graded monoid, like `npow_rec`.
`gmonoid.gnpow` should be used instead. -/
def gnpow_rec : Π (n : ℕ) {i}, A i → A (n • i)
| 0 i a := cast (congr_arg A (zero_nsmul i).symm) ghas_one.one
| (n + 1) i a := cast (congr_arg A (succ_nsmul i n).symm) (ghas_mul.mul a $ gnpow_rec _ a)
@[simp] lemma gnpow_rec_zero (a : graded_monoid A) : graded_monoid.mk _ (gnpow_rec 0 a.snd) = 1 :=
sigma.ext (zero_nsmul _) (heq_of_cast_eq _ rfl).symm
/-- Tactic used to autofill `graded_monoid.gmonoid.gnpow_zero'` when the default
`graded_monoid.gmonoid.gnpow_rec` is used. -/
meta def apply_gnpow_rec_zero_tac : tactic unit := `[apply graded_monoid.gmonoid.gnpow_rec_zero]
@[simp] lemma gnpow_rec_succ (n : ℕ) (a : graded_monoid A) :
(graded_monoid.mk _ $ gnpow_rec n.succ a.snd) = a * ⟨_, gnpow_rec n a.snd⟩ :=
sigma.ext (succ_nsmul _ _) (heq_of_cast_eq _ rfl).symm
/-- Tactic used to autofill `graded_monoid.gmonoid.gnpow_succ'` when the default
`graded_monoid.gmonoid.gnpow_rec` is used. -/
meta def apply_gnpow_rec_succ_tac : tactic unit := `[apply graded_monoid.gmonoid.gnpow_rec_succ]
end gmonoid
/-- A graded version of `monoid`.
Like `monoid.npow`, this has an optional `gmonoid.gnpow` field to allow definitional control of
natural powers of a graded monoid. -/
class gmonoid [add_monoid ι] extends ghas_mul A, ghas_one A :=
(one_mul (a : graded_monoid A) : 1 * a = a)
(mul_one (a : graded_monoid A) : a * 1 = a)
(mul_assoc (a b c : graded_monoid A) : a * b * c = a * (b * c))
(gnpow : Π (n : ℕ) {i}, A i → A (n • i) := gmonoid.gnpow_rec)
(gnpow_zero' : Π (a : graded_monoid A), graded_monoid.mk _ (gnpow 0 a.snd) = 1
. gmonoid.apply_gnpow_rec_zero_tac)
(gnpow_succ' : Π (n : ℕ) (a : graded_monoid A),
(graded_monoid.mk _ $ gnpow n.succ a.snd) = a * ⟨_, gnpow n a.snd⟩
. gmonoid.apply_gnpow_rec_succ_tac)
/-- `gmonoid` implies a `monoid (graded_monoid A)`. -/
instance gmonoid.to_monoid [add_monoid ι] [gmonoid A] :
monoid (graded_monoid A) :=
{ one := (1), mul := (*),
npow := λ n a, graded_monoid.mk _ (gmonoid.gnpow n a.snd),
npow_zero' := λ a, gmonoid.gnpow_zero' a,
npow_succ' := λ n a, gmonoid.gnpow_succ' n a,
one_mul := gmonoid.one_mul, mul_one := gmonoid.mul_one, mul_assoc := gmonoid.mul_assoc }
lemma mk_pow [add_monoid ι] [gmonoid A] {i} (a : A i) (n : ℕ) :
mk i a ^ n = mk (n • i) (gmonoid.gnpow _ a) :=
begin
induction n with n,
{ rw [pow_zero],
exact (gmonoid.gnpow_zero' ⟨_, a⟩).symm, },
{ rw [pow_succ, n_ih, mk_mul_mk],
exact (gmonoid.gnpow_succ' n ⟨_, a⟩).symm, },
end
/-- A graded version of `comm_monoid`. -/
class gcomm_monoid [add_comm_monoid ι] extends gmonoid A :=
(mul_comm (a : graded_monoid A) (b : graded_monoid A) : a * b = b * a)
/-- `gcomm_monoid` implies a `comm_monoid (graded_monoid A)`, although this is only used as an
instance locally to define notation in `gmonoid` and similar typeclasses. -/
instance gcomm_monoid.to_comm_monoid [add_comm_monoid ι] [gcomm_monoid A] :
comm_monoid (graded_monoid A) :=
{ mul_comm := gcomm_monoid.mul_comm, ..gmonoid.to_monoid A }
end defs
/-! ### Instances for `A 0`
The various `g*` instances are enough to promote the `add_comm_monoid (A 0)` structure to various
types of multiplicative structure.
-/
section grade_zero
variables (A : ι → Type*)
section one
variables [has_zero ι] [ghas_one A]
/-- `1 : A 0` is the value provided in `ghas_one.one`. -/
@[nolint unused_arguments]
instance grade_zero.has_one : has_one (A 0) :=
⟨ghas_one.one⟩
end one
section mul
variables [add_zero_class ι] [ghas_mul A]
/-- `(•) : A 0 → A i → A i` is the value provided in `graded_monoid.ghas_mul.mul`, composed with
an `eq.rec` to turn `A (0 + i)` into `A i`.
-/
instance grade_zero.has_scalar (i : ι) : has_scalar (A 0) (A i) :=
{ smul := λ x y, (zero_add i).rec (ghas_mul.mul x y) }
/-- `(*) : A 0 → A 0 → A 0` is the value provided in `graded_monoid.ghas_mul.mul`, composed with
an `eq.rec` to turn `A (0 + 0)` into `A 0`.
-/
instance grade_zero.has_mul : has_mul (A 0) :=
{ mul := (•) }
variables {A}
@[simp] lemma mk_zero_smul {i} (a : A 0) (b : A i) : mk _ (a • b) = mk _ a * mk _ b :=
sigma.ext (zero_add _).symm $ eq_rec_heq _ _
@[simp] lemma grade_zero.smul_eq_mul (a b : A 0) : a • b = a * b := rfl
end mul
section monoid
variables [add_monoid ι] [gmonoid A]
instance : has_pow (A 0) ℕ :=
{ pow := λ x n, (nsmul_zero n).rec (gmonoid.gnpow n x : A (n • 0)) }
variables {A}
@[simp] lemma mk_zero_pow (a : A 0) (n : ℕ) : mk _ (a ^ n) = mk _ a ^ n :=
sigma.ext (nsmul_zero n).symm $ eq_rec_heq _ _
variables (A)
/-- The `monoid` structure derived from `gmonoid A`. -/
instance grade_zero.monoid : monoid (A 0) :=
function.injective.monoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow
end monoid
section monoid
variables [add_comm_monoid ι] [gcomm_monoid A]
/-- The `comm_monoid` structure derived from `gcomm_monoid A`. -/
instance grade_zero.comm_monoid : comm_monoid (A 0) :=
function.injective.comm_monoid (mk 0) sigma_mk_injective rfl mk_zero_smul mk_zero_pow
end monoid
section mul_action
variables [add_monoid ι] [gmonoid A]
/-- `graded_monoid.mk 0` is a `monoid_hom`, using the `graded_monoid.grade_zero.monoid` structure.
-/
def mk_zero_monoid_hom : A 0 →* (graded_monoid A) :=
{ to_fun := mk 0, map_one' := rfl, map_mul' := mk_zero_smul }
/-- Each grade `A i` derives a `A 0`-action structure from `gmonoid A`. -/
instance grade_zero.mul_action {i} : mul_action (A 0) (A i) :=
begin
letI := mul_action.comp_hom (graded_monoid A) (mk_zero_monoid_hom A),
exact function.injective.mul_action (mk i) sigma_mk_injective mk_zero_smul,
end
end mul_action
end grade_zero
end graded_monoid
/-! ### Dependent products of graded elements -/
section dprod
variables {α : Type*} {A : ι → Type*} [add_monoid ι] [graded_monoid.gmonoid A]
/-- The index used by `list.dprod`. Propositionally this is equal to `(l.map fι).sum`, but
definitionally it needs to have a different form to avoid introducing `eq.rec`s in `list.dprod`. -/
def list.dprod_index (l : list α) (fι : α → ι) : ι :=
l.foldr (λ i b, fι i + b) 0
@[simp] lemma list.dprod_index_nil (fι : α → ι) : ([] : list α).dprod_index fι = 0 := rfl
@[simp] lemma list.dprod_index_cons (a : α) (l : list α) (fι : α → ι) :
(a :: l).dprod_index fι = fι a + l.dprod_index fι := rfl
lemma list.dprod_index_eq_map_sum (l : list α) (fι : α → ι) :
l.dprod_index fι = (l.map fι).sum :=
begin
dunfold list.dprod_index,
induction l,
{ simp, },
{ simp [l_ih], },
end
/-- A dependent product for graded monoids represented by the indexed family of types `A i`.
This is a dependent version of `(l.map fA).prod`.
For a list `l : list α`, this computes the product of `fA a` over `a`, where each `fA` is of type
`A (fι a)`. -/
def list.dprod (l : list α) (fι : α → ι) (fA : Π a, A (fι a)) :
A (l.dprod_index fι) :=
l.foldr_rec_on _ _ graded_monoid.ghas_one.one (λ i x a ha, graded_monoid.ghas_mul.mul (fA a) x)
@[simp] lemma list.dprod_nil (fι : α → ι) (fA : Π a, A (fι a)) :
(list.nil : list α).dprod fι fA = graded_monoid.ghas_one.one := rfl
-- the `( : _)` in this lemma statement results in the type on the RHS not being unfolded, which
-- is nicer in the goal view.
@[simp] lemma list.dprod_cons (fι : α → ι) (fA : Π a, A (fι a)) (a : α) (l : list α) :
(a :: l).dprod fι fA = (graded_monoid.ghas_mul.mul (fA a) (l.dprod fι fA) : _) := rfl
lemma graded_monoid.mk_list_dprod (l : list α) (fι : α → ι) (fA : Π a, A (fι a)) :
graded_monoid.mk _ (l.dprod fι fA) = (l.map (λ a, graded_monoid.mk (fι a) (fA a))).prod :=
begin
induction l,
{ simp, refl },
{ simp [←l_ih, graded_monoid.mk_mul_mk, list.prod_cons],
refl, },
end
/-- A variant of `graded_monoid.mk_list_dprod` for rewriting in the other direction. -/
lemma graded_monoid.list_prod_map_eq_dprod (l : list α) (f : α → graded_monoid A) :
(l.map f).prod = graded_monoid.mk _ (l.dprod (λ i, (f i).1) (λ i, (f i).2)) :=
begin
rw [graded_monoid.mk_list_dprod, graded_monoid.mk],
simp_rw sigma.eta,
end
lemma graded_monoid.list_prod_of_fn_eq_dprod {n : ℕ} (f : fin n → graded_monoid A) :
(list.of_fn f).prod =
graded_monoid.mk _ ((list.fin_range n).dprod (λ i, (f i).1) (λ i, (f i).2)) :=
by rw [list.of_fn_eq_map, graded_monoid.list_prod_map_eq_dprod]
end dprod
/-! ### Concrete instances -/
section
variables (ι) {R : Type*}
@[simps one]
instance has_one.ghas_one [has_zero ι] [has_one R] : graded_monoid.ghas_one (λ i : ι, R) :=
{ one := 1 }
@[simps mul]
instance has_mul.ghas_mul [has_add ι] [has_mul R] : graded_monoid.ghas_mul (λ i : ι, R) :=
{ mul := λ i j, (*) }
/-- If all grades are the same type and themselves form a monoid, then there is a trivial grading
structure. -/
@[simps gnpow]
instance monoid.gmonoid [add_monoid ι] [monoid R] : graded_monoid.gmonoid (λ i : ι, R) :=
{ one_mul := λ a, sigma.ext (zero_add _) (heq_of_eq (one_mul _)),
mul_one := λ a, sigma.ext (add_zero _) (heq_of_eq (mul_one _)),
mul_assoc := λ a b c, sigma.ext (add_assoc _ _ _) (heq_of_eq (mul_assoc _ _ _)),
gnpow := λ n i a, a ^ n,
gnpow_zero' := λ a, sigma.ext (zero_nsmul _) (heq_of_eq (monoid.npow_zero' _)),
gnpow_succ' := λ n ⟨i, a⟩, sigma.ext (succ_nsmul _ _) (heq_of_eq (monoid.npow_succ' _ _)),
..has_one.ghas_one ι,
..has_mul.ghas_mul ι }
/-- If all grades are the same type and themselves form a commutative monoid, then there is a
trivial grading structure. -/
instance comm_monoid.gcomm_monoid [add_comm_monoid ι] [comm_monoid R] :
graded_monoid.gcomm_monoid (λ i : ι, R) :=
{ mul_comm := λ a b, sigma.ext (add_comm _ _) (heq_of_eq (mul_comm _ _)),
..monoid.gmonoid ι }
/-- When all the indexed types are the same, the dependent product is just the regular product. -/
@[simp] lemma list.dprod_monoid {α} [add_monoid ι] [monoid R] (l : list α) (fι : α → ι)
(fA : α → R) :
(l.dprod fι fA : (λ i : ι, R) _) = ((l.map fA).prod : _) :=
begin
induction l,
{ rw [list.dprod_nil, list.map_nil, list.prod_nil], refl },
{ rw [list.dprod_cons, list.map_cons, list.prod_cons, l_ih], refl },
end
end
/-! ### Shorthands for creating instance of the above typeclasses for collections of subobjects -/
section subobjects
variables {R : Type*}
/-- A version of `graded_monoid.ghas_one` for internally graded objects. -/
class set_like.has_graded_one {S : Type*} [set_like S R] [has_one R] [has_zero ι]
(A : ι → S) : Prop :=
(one_mem : (1 : R) ∈ A 0)
instance set_like.ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero ι] (A : ι → S)
[set_like.has_graded_one A] : graded_monoid.ghas_one (λ i, A i) :=
{ one := ⟨1, set_like.has_graded_one.one_mem⟩ }
@[simp] lemma set_like.coe_ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero ι] (A : ι → S)
[set_like.has_graded_one A] : ↑(@graded_monoid.ghas_one.one _ (λ i, A i) _ _) = (1 : R) := rfl
/-- A version of `graded_monoid.ghas_one` for internally graded objects. -/
class set_like.has_graded_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι]
(A : ι → S) : Prop :=
(mul_mem : ∀ ⦃i j⦄ {gi gj}, gi ∈ A i → gj ∈ A j → gi * gj ∈ A (i + j))
instance set_like.ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι] (A : ι → S)
[set_like.has_graded_mul A] :
graded_monoid.ghas_mul (λ i, A i) :=
{ mul := λ i j a b, ⟨(a * b : R), set_like.has_graded_mul.mul_mem a.prop b.prop⟩ }
@[simp] lemma set_like.coe_ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add ι] (A : ι → S)
[set_like.has_graded_mul A] {i j : ι} (x : A i) (y : A j) :
↑(@graded_monoid.ghas_mul.mul _ (λ i, A i) _ _ _ _ x y) = (x * y : R) := rfl
/-- A version of `graded_monoid.gmonoid` for internally graded objects. -/
class set_like.graded_monoid {S : Type*} [set_like S R] [monoid R] [add_monoid ι]
(A : ι → S) extends set_like.has_graded_one A, set_like.has_graded_mul A : Prop
namespace set_like.graded_monoid
variables {S : Type*} [set_like S R] [monoid R] [add_monoid ι]
variables {A : ι → S} [set_like.graded_monoid A]
lemma pow_mem (n : ℕ) {r : R} {i : ι} (h : r ∈ A i) : r ^ n ∈ A (n • i) :=
begin
induction n,
{ rw [pow_zero, zero_nsmul], exact one_mem },
{ rw [pow_succ', succ_nsmul'], exact mul_mem n_ih h },
end
lemma list_prod_map_mem {ι'} (l : list ι') (i : ι' → ι) (r : ι' → R) (h : ∀ j ∈ l, r j ∈ A (i j)) :
(l.map r).prod ∈ A (l.map i).sum :=
begin
induction l,
{ rw [list.map_nil, list.map_nil, list.prod_nil, list.sum_nil],
exact one_mem },
{ rw [list.map_cons, list.map_cons, list.prod_cons, list.sum_cons],
exact mul_mem (h _ $ list.mem_cons_self _ _) (l_ih $ λ j hj, h _ $ list.mem_cons_of_mem _ hj) },
end
lemma list_prod_of_fn_mem {n} (i : fin n → ι) (r : fin n → R) (h : ∀ j, r j ∈ A (i j)) :
(list.of_fn r).prod ∈ A (list.of_fn i).sum :=
begin
rw [list.of_fn_eq_map, list.of_fn_eq_map],
exact list_prod_map_mem _ _ _ (λ _ _, h _),
end
end set_like.graded_monoid
/-- Build a `gmonoid` instance for a collection of subobjects. -/
instance set_like.gmonoid {S : Type*} [set_like S R] [monoid R] [add_monoid ι] (A : ι → S)
[set_like.graded_monoid A] :
graded_monoid.gmonoid (λ i, A i) :=
{ one_mul := λ ⟨i, a, h⟩, sigma.subtype_ext (zero_add _) (one_mul _),
mul_one := λ ⟨i, a, h⟩, sigma.subtype_ext (add_zero _) (mul_one _),
mul_assoc := λ ⟨i, a, ha⟩ ⟨j, b, hb⟩ ⟨k, c, hc⟩,
sigma.subtype_ext (add_assoc _ _ _) (mul_assoc _ _ _),
gnpow := λ n i a, ⟨a ^ n, set_like.graded_monoid.pow_mem n a.prop⟩,
gnpow_zero' := λ n, sigma.subtype_ext (zero_nsmul _) (pow_zero _),
gnpow_succ' := λ n a, sigma.subtype_ext (succ_nsmul _ _) (pow_succ _ _),
..set_like.ghas_one A,
..set_like.ghas_mul A }
@[simp] lemma set_like.coe_gnpow {S : Type*} [set_like S R] [monoid R] [add_monoid ι] (A : ι → S)
[set_like.graded_monoid A] {i : ι} (x : A i) (n : ℕ) :
↑(@graded_monoid.gmonoid.gnpow _ (λ i, A i) _ _ n _ x) = (x ^ n : R) := rfl
/-- Build a `gcomm_monoid` instance for a collection of subobjects. -/
instance set_like.gcomm_monoid {S : Type*} [set_like S R] [comm_monoid R] [add_comm_monoid ι]
(A : ι → S) [set_like.graded_monoid A] :
graded_monoid.gcomm_monoid (λ i, A i) :=
{ mul_comm := λ ⟨i, a, ha⟩ ⟨j, b, hb⟩, sigma.subtype_ext (add_comm _ _) (mul_comm _ _),
..set_like.gmonoid A}
section dprod
open set_like set_like.graded_monoid
variables {α S : Type*} [set_like S R] [monoid R] [add_monoid ι]
/-- Coercing a dependent product of subtypes is the same as taking the regular product of the
coercions. -/
@[simp] lemma set_like.coe_list_dprod (A : ι → S) [set_like.graded_monoid A]
(fι : α → ι) (fA : Π a, A (fι a)) (l : list α) :
↑(l.dprod fι fA : (λ i, ↥(A i)) _) = (list.prod (l.map (λ a, fA a)) : R) :=
begin
induction l,
{ rw [list.dprod_nil, coe_ghas_one, list.map_nil, list.prod_nil] },
{ rw [list.dprod_cons, coe_ghas_mul, list.map_cons, list.prod_cons, l_ih], },
end
include R
/-- A version of `list.coe_dprod_set_like` with `subtype.mk`. -/
lemma set_like.list_dprod_eq (A : ι → S) [set_like.graded_monoid A]
(fι : α → ι) (fA : Π a, A (fι a)) (l : list α) :
(l.dprod fι fA : (λ i, ↥(A i)) _) =
⟨list.prod (l.map (λ a, fA a)), (l.dprod_index_eq_map_sum fι).symm ▸
list_prod_map_mem l _ _ (λ i hi, (fA i).prop)⟩ :=
subtype.ext $ set_like.coe_list_dprod _ _ _ _
end dprod
end subobjects
section homogeneous_elements
variables {R S : Type*} [set_like S R]
/-- An element `a : R` is said to be homogeneous if there is some `i : ι` such that `a ∈ A i`. -/
def set_like.is_homogeneous (A : ι → S) (a : R) : Prop := ∃ i, a ∈ A i
@[simp] lemma set_like.is_homogeneous_coe {A : ι → S} {i} (x : A i) :
set_like.is_homogeneous A (x : R) :=
⟨i, x.prop⟩
lemma set_like.is_homogeneous_one [has_zero ι] [has_one R]
(A : ι → S) [set_like.has_graded_one A] : set_like.is_homogeneous A (1 : R) :=
⟨0, set_like.has_graded_one.one_mem⟩
lemma set_like.is_homogeneous.mul [has_add ι] [has_mul R] {A : ι → S}
[set_like.has_graded_mul A] {a b : R} :
set_like.is_homogeneous A a → set_like.is_homogeneous A b → set_like.is_homogeneous A (a * b)
| ⟨i, hi⟩ ⟨j, hj⟩ := ⟨i + j, set_like.has_graded_mul.mul_mem hi hj⟩
/-- When `A` is a `set_like.graded_monoid A`, then the homogeneous elements forms a submonoid. -/
def set_like.homogeneous_submonoid [add_monoid ι] [monoid R]
(A : ι → S) [set_like.graded_monoid A] : submonoid R :=
{ carrier := { a | set_like.is_homogeneous A a },
one_mem' := set_like.is_homogeneous_one A,
mul_mem' := λ a b, set_like.is_homogeneous.mul }
end homogeneous_elements
|
5db78376cc3baef4616ebf6f136c94fad7e63c01 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/algebra/big_operators/fin.lean | 4090639cea233b4bb42a59c76acc0fad4c994ec1 | [
"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 | 11,614 | lean | /-
Copyright (c) 2020 Yury Kudryashov, Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Anne Baanen
-/
import data.fintype.big_operators
import data.fintype.fin
import logic.equiv.fin
/-!
# Big operators and `fin`
Some results about products and sums over the type `fin`.
The most important results are the induction formulas `fin.prod_univ_cast_succ`
and `fin.prod_univ_succ`, and the formula `fin.prod_const` for the product of a
constant function. These results have variants for sums instead of products.
-/
open_locale big_operators
open finset
variables {α : Type*} {β : Type*}
namespace finset
@[to_additive]
theorem prod_range [comm_monoid β] {n : ℕ} (f : ℕ → β) :
∏ i in finset.range n, f i = ∏ i : fin n, f i :=
prod_bij'
(λ k w, ⟨k, mem_range.mp w⟩)
(λ a ha, mem_univ _)
(λ a ha, congr_arg _ (fin.coe_mk _).symm)
(λ a m, a)
(λ a m, mem_range.mpr a.prop)
(λ a ha, fin.coe_mk _)
(λ a ha, fin.eta _ _)
end finset
namespace fin
@[to_additive]
theorem prod_univ_def [comm_monoid β] {n : ℕ} (f : fin n → β) :
∏ i, f i = ((list.fin_range n).map f).prod :=
by simp [univ_def]
@[to_additive]
theorem prod_of_fn [comm_monoid β] {n : ℕ} (f : fin n → β) :
(list.of_fn f).prod = ∏ i, f i :=
by rw [list.of_fn_eq_map, prod_univ_def]
/-- A product of a function `f : fin 0 → β` is `1` because `fin 0` is empty -/
@[to_additive "A sum of a function `f : fin 0 → β` is `0` because `fin 0` is empty"]
theorem prod_univ_zero [comm_monoid β] (f : fin 0 → β) : ∏ i, f i = 1 := rfl
/-- A product of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
is the product of `f x`, for some `x : fin (n + 1)` times the remaining product -/
@[to_additive "A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)` is the sum of `f x`,
for some `x : fin (n + 1)` plus the remaining product"]
theorem prod_univ_succ_above [comm_monoid β] {n : ℕ} (f : fin (n + 1) → β) (x : fin (n + 1)) :
∏ i, f i = f x * ∏ i : fin n, f (x.succ_above i) :=
by rw [univ_succ_above, prod_cons, finset.prod_map, rel_embedding.coe_fn_to_embedding]
/-- A product of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
is the product of `f 0` plus the remaining product -/
@[to_additive "A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)` is the sum of `f 0`
plus the remaining product"]
theorem prod_univ_succ [comm_monoid β] {n : ℕ} (f : fin (n + 1) → β) :
∏ i, f i = f 0 * ∏ i : fin n, f i.succ :=
prod_univ_succ_above f 0
/-- A product of a function `f : fin (n + 1) → β` over all `fin (n + 1)`
is the product of `f (fin.last n)` plus the remaining product -/
@[to_additive "A sum of a function `f : fin (n + 1) → β` over all `fin (n + 1)` is the sum of
`f (fin.last n)` plus the remaining sum"]
theorem prod_univ_cast_succ [comm_monoid β] {n : ℕ} (f : fin (n + 1) → β) :
∏ i, f i = (∏ i : fin n, f i.cast_succ) * f (last n) :=
by simpa [mul_comm] using prod_univ_succ_above f (last n)
@[to_additive] lemma prod_cons [comm_monoid β] {n : ℕ} (x : β) (f : fin n → β) :
∏ i : fin n.succ, (cons x f : fin n.succ → β) i = x * ∏ i : fin n, f i :=
by simp_rw [prod_univ_succ, cons_zero, cons_succ]
@[to_additive sum_univ_one] theorem prod_univ_one [comm_monoid β] (f : fin 1 → β) :
∏ i, f i = f 0 :=
by simp
@[simp, to_additive] theorem prod_univ_two [comm_monoid β] (f : fin 2 → β) :
∏ i, f i = f 0 * f 1 :=
by simp [prod_univ_succ]
@[to_additive] theorem prod_univ_three [comm_monoid β] (f : fin 3 → β) :
∏ i, f i = f 0 * f 1 * f 2 :=
by { rw [prod_univ_cast_succ, prod_univ_two], refl }
@[to_additive] theorem prod_univ_four [comm_monoid β] (f : fin 4 → β) :
∏ i, f i = f 0 * f 1 * f 2 * f 3 :=
by { rw [prod_univ_cast_succ, prod_univ_three], refl }
@[to_additive] theorem prod_univ_five [comm_monoid β] (f : fin 5 → β) :
∏ i, f i = f 0 * f 1 * f 2 * f 3 * f 4 :=
by { rw [prod_univ_cast_succ, prod_univ_four], refl }
@[to_additive] theorem prod_univ_six [comm_monoid β] (f : fin 6 → β) :
∏ i, f i = f 0 * f 1 * f 2 * f 3 * f 4 * f 5 :=
by { rw [prod_univ_cast_succ, prod_univ_five], refl }
@[to_additive] theorem prod_univ_seven [comm_monoid β] (f : fin 7 → β) :
∏ i, f i = f 0 * f 1 * f 2 * f 3 * f 4 * f 5 * f 6 :=
by { rw [prod_univ_cast_succ, prod_univ_six], refl }
@[to_additive] theorem prod_univ_eight [comm_monoid β] (f : fin 8 → β) :
∏ i, f i = f 0 * f 1 * f 2 * f 3 * f 4 * f 5 * f 6 * f 7 :=
by { rw [prod_univ_cast_succ, prod_univ_seven], refl }
lemma sum_pow_mul_eq_add_pow {n : ℕ} {R : Type*} [comm_semiring R] (a b : R) :
∑ s : finset (fin n), a ^ s.card * b ^ (n - s.card) = (a + b) ^ n :=
by simpa using fintype.sum_pow_mul_eq_add_pow (fin n) a b
lemma prod_const [comm_monoid α] (n : ℕ) (x : α) : ∏ i : fin n, x = x ^ n := by simp
lemma sum_const [add_comm_monoid α] (n : ℕ) (x : α) : ∑ i : fin n, x = n • x := by simp
@[to_additive] lemma prod_Ioi_zero {M : Type*} [comm_monoid M] {n : ℕ} {v : fin n.succ → M} :
∏ i in Ioi 0, v i = ∏ j : fin n, v j.succ :=
by rw [Ioi_zero_eq_map, finset.prod_map, rel_embedding.coe_fn_to_embedding, coe_succ_embedding]
@[to_additive]
lemma prod_Ioi_succ {M : Type*} [comm_monoid M] {n : ℕ} (i : fin n) (v : fin n.succ → M) :
∏ j in Ioi i.succ, v j = ∏ j in Ioi i, v j.succ :=
by rw [Ioi_succ, finset.prod_map, rel_embedding.coe_fn_to_embedding, coe_succ_embedding]
@[to_additive]
lemma prod_congr' {M : Type*} [comm_monoid M] {a b : ℕ} (f : fin b → M) (h : a = b) :
∏ (i : fin a), f (cast h i) = ∏ (i : fin b), f i :=
by { subst h, congr, ext, congr, ext, rw coe_cast, }
@[to_additive]
lemma prod_univ_add {M : Type*} [comm_monoid M] {a b : ℕ} (f : fin (a+b) → M) :
∏ (i : fin (a+b)), f i =
(∏ (i : fin a), f (cast_add b i)) * ∏ (i : fin b), f (nat_add a i) :=
begin
rw fintype.prod_equiv fin_sum_fin_equiv.symm f (λ i, f (fin_sum_fin_equiv.to_fun i)), swap,
{ intro x,
simp only [equiv.to_fun_as_coe, equiv.apply_symm_apply], },
apply fintype.prod_sum_type,
end
@[to_additive]
lemma prod_trunc {M : Type*} [comm_monoid M] {a b : ℕ} (f : fin (a+b) → M)
(hf : ∀ (j : fin b), f (nat_add a j) = 1) :
∏ (i : fin (a+b)), f i =
∏ (i : fin a), f (cast_le (nat.le.intro rfl) i) :=
by simpa only [prod_univ_add, fintype.prod_eq_one _ hf, mul_one]
section partial_prod
variables [monoid α] {n : ℕ}
/-- For `f = (a₁, ..., aₙ)` in `αⁿ`, `partial_prod f` is `(1, a₁, a₁a₂, ..., a₁...aₙ)` in `αⁿ⁺¹`. -/
@[to_additive "For `f = (a₁, ..., aₙ)` in `αⁿ`, `partial_sum f` is
`(0, a₁, a₁ + a₂, ..., a₁ + ... + aₙ)` in `αⁿ⁺¹`."]
def partial_prod (f : fin n → α) (i : fin (n + 1)) : α :=
((list.of_fn f).take i).prod
@[simp, to_additive] lemma partial_prod_zero (f : fin n → α) :
partial_prod f 0 = 1 :=
by simp [partial_prod]
@[to_additive] lemma partial_prod_succ (f : fin n → α) (j : fin n) :
partial_prod f j.succ = partial_prod f j.cast_succ * (f j) :=
by simp [partial_prod, list.take_succ, list.of_fn_nth_val, dif_pos j.is_lt, ←option.coe_def]
@[to_additive] lemma partial_prod_succ' (f : fin (n + 1) → α) (j : fin (n + 1)) :
partial_prod f j.succ = f 0 * partial_prod (fin.tail f) j :=
by simpa [partial_prod]
@[to_additive] lemma partial_prod_left_inv {G : Type*} [group G] (f : fin (n + 1) → G) :
f 0 • partial_prod (λ i : fin n, (f i)⁻¹ * f i.succ) = f :=
funext $ λ x, fin.induction_on x (by simp) (λ x hx,
begin
simp only [coe_eq_cast_succ, pi.smul_apply, smul_eq_mul] at hx ⊢,
rw [partial_prod_succ, ←mul_assoc, hx, mul_inv_cancel_left],
end)
@[to_additive] lemma partial_prod_right_inv {G : Type*} [group G]
(g : G) (f : fin n → G) (i : fin n) :
((g • partial_prod f) i)⁻¹ * (g • partial_prod f) i.succ = f i :=
begin
cases i with i hn,
induction i with i hi generalizing hn,
{ simp [←fin.succ_mk, partial_prod_succ] },
{ specialize hi (lt_trans (nat.lt_succ_self i) hn),
simp only [mul_inv_rev, fin.coe_eq_cast_succ, fin.succ_mk, fin.cast_succ_mk,
smul_eq_mul, pi.smul_apply] at hi ⊢,
rw [←fin.succ_mk _ _ (lt_trans (nat.lt_succ_self _) hn), ←fin.succ_mk],
simp only [partial_prod_succ, mul_inv_rev, fin.cast_succ_mk],
assoc_rw [hi, inv_mul_cancel_left] }
end
end partial_prod
end fin
namespace list
section comm_monoid
variables [comm_monoid α]
@[to_additive]
lemma prod_take_of_fn {n : ℕ} (f : fin n → α) (i : ℕ) :
((of_fn f).take i).prod = ∏ j in finset.univ.filter (λ (j : fin n), j.val < i), f j :=
begin
have A : ∀ (j : fin n), ¬ ((j : ℕ) < 0) := λ j, not_lt_bot,
induction i with i IH, { simp [A] },
by_cases h : i < n,
{ have : i < length (of_fn f), by rwa [length_of_fn f],
rw prod_take_succ _ _ this,
have A : ((finset.univ : finset (fin n)).filter (λ j, j.val < i + 1))
= ((finset.univ : finset (fin n)).filter (λ j, j.val < i)) ∪ {(⟨i, h⟩ : fin n)},
by { ext ⟨_, _⟩, simp [nat.lt_succ_iff_lt_or_eq] },
have B : _root_.disjoint (finset.filter (λ (j : fin n), j.val < i) finset.univ)
(singleton (⟨i, h⟩ : fin n)), by simp,
rw [A, finset.prod_union B, IH],
simp },
{ have A : (of_fn f).take i = (of_fn f).take i.succ,
{ rw ← length_of_fn f at h,
have : length (of_fn f) ≤ i := not_lt.mp h,
rw [take_all_of_le this, take_all_of_le (le_trans this (nat.le_succ _))] },
have B : ∀ (j : fin n), ((j : ℕ) < i.succ) = ((j : ℕ) < i),
{ assume j,
have : (j : ℕ) < i := lt_of_lt_of_le j.2 (not_lt.mp h),
simp [this, lt_trans this (nat.lt_succ_self _)] },
simp [← A, B, IH] }
end
@[to_additive]
lemma prod_of_fn {n : ℕ} {f : fin n → α} :
(of_fn f).prod = ∏ i, f i :=
begin
convert prod_take_of_fn f n,
{ rw [take_all_of_le (le_of_eq (length_of_fn f))] },
{ have : ∀ (j : fin n), (j : ℕ) < n := λ j, j.is_lt,
simp [this] }
end
end comm_monoid
lemma alternating_sum_eq_finset_sum {G : Type*} [add_comm_group G] :
∀ (L : list G), alternating_sum L = ∑ i : fin L.length, (-1 : ℤ) ^ (i : ℕ) • L.nth_le i i.is_lt
| [] := by { rw [alternating_sum, finset.sum_eq_zero], rintro ⟨i, ⟨⟩⟩ }
| (g :: []) := by simp
| (g :: h :: L) :=
calc g + -h + L.alternating_sum
= g + -h + ∑ i : fin L.length, (-1 : ℤ) ^ (i : ℕ) • L.nth_le i i.2 :
congr_arg _ (alternating_sum_eq_finset_sum _)
... = ∑ i : fin (L.length + 2), (-1 : ℤ) ^ (i : ℕ) • list.nth_le (g :: h :: L) i _ :
begin
rw [fin.sum_univ_succ, fin.sum_univ_succ, add_assoc],
unfold_coes,
simp [nat.succ_eq_add_one, pow_add],
refl,
end
@[to_additive]
lemma alternating_prod_eq_finset_prod {G : Type*} [comm_group G] :
∀ (L : list G), alternating_prod L = ∏ i : fin L.length, (L.nth_le i i.2) ^ ((-1 : ℤ) ^ (i : ℕ))
| [] := by { rw [alternating_prod, finset.prod_eq_one], rintro ⟨i, ⟨⟩⟩ }
| (g :: []) :=
begin
show g = ∏ i : fin 1, [g].nth_le i i.2 ^ (-1 : ℤ) ^ (i : ℕ),
rw [fin.prod_univ_succ], simp,
end
| (g :: h :: L) :=
calc g * h⁻¹ * L.alternating_prod
= g * h⁻¹ * ∏ i : fin L.length, L.nth_le i i.2 ^ (-1 : ℤ) ^ (i : ℕ) :
congr_arg _ (alternating_prod_eq_finset_prod _)
... = ∏ i : fin (L.length + 2), list.nth_le (g :: h :: L) i _ ^ (-1 : ℤ) ^ (i : ℕ) :
begin
rw [fin.prod_univ_succ, fin.prod_univ_succ, mul_assoc],
unfold_coes,
simp [nat.succ_eq_add_one, pow_add],
refl,
end
end list
|
e78d0fbe20491c86469d450cd5324f7c26d43dcb | 1abd1ed12aa68b375cdef28959f39531c6e95b84 | /src/order/filter/germ.lean | bd18ab11284af47fd1a893c6e20f5a1fefa5f802 | [
"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 | 21,519 | lean | /-
Copyright (c) 2020 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Abhimanyu Pallavi Sudhir
-/
import order.filter.basic
import algebra.module.pi
/-!
# Germ of a function at a filter
The germ of a function `f : α → β` at a filter `l : filter α` is the equivalence class of `f`
with respect to the equivalence relation `eventually_eq l`: `f ≈ g` means `∀ᶠ x in l, f x = g x`.
## Main definitions
We define
* `germ l β` to be the space of germs of functions `α → β` at a filter `l : filter α`;
* coercion from `α → β` to `germ l β`: `(f : germ l β)` is the germ of `f : α → β`
at `l : filter α`; this coercion is declared as `has_coe_t`, so it does not require an explicit
up arrow `↑`;
* coercion from `β` to `germ l β`: `(↑c : germ l β)` is the germ of the constant function
`λ x:α, c` at a filter `l`; this coercion is declared as `has_lift_t`, so it requires an explicit
up arrow `↑`, see [TPiL][TPiL_coe] for details.
* `map (F : β → γ) (f : germ l β)` to be the composition of a function `F` and a germ `f`;
* `map₂ (F : β → γ → δ) (f : germ l β) (g : germ l γ)` to be the germ of `λ x, F (f x) (g x)`
at `l`;
* `f.tendsto lb`: we say that a germ `f : germ l β` tends to a filter `lb` if its representatives
tend to `lb` along `l`;
* `f.comp_tendsto g hg` and `f.comp_tendsto' g hg`: given `f : germ l β` and a function
`g : γ → α` (resp., a germ `g : germ lc α`), if `g` tends to `l` along `lc`, then the composition
`f ∘ g` is a well-defined germ at `lc`;
* `germ.lift_pred`, `germ.lift_rel`: lift a predicate or a relation to the space of germs:
`(f : germ l β).lift_pred p` means `∀ᶠ x in l, p (f x)`, and similarly for a relation.
[TPiL_coe]: https://leanprover.github.io/theorem_proving_in_lean/type_classes.html#coercions-using-type-classes
We also define `map (F : β → γ) : germ l β → germ l γ` sending each germ `f` to `F ∘ f`.
For each of the following structures we prove that if `β` has this structure, then so does
`germ l β`:
* one-operation algebraic structures up to `comm_group`;
* `mul_zero_class`, `distrib`, `semiring`, `comm_semiring`, `ring`, `comm_ring`;
* `mul_action`, `distrib_mul_action`, `module`;
* `preorder`, `partial_order`, and `lattice` structures up to `bounded_lattice`;
* `ordered_cancel_comm_monoid` and `ordered_cancel_add_comm_monoid`.
## Tags
filter, germ
-/
namespace filter
variables {α β γ δ : Type*} {l : filter α} {f g h : α → β}
lemma const_eventually_eq' [ne_bot l] {a b : β} : (∀ᶠ x in l, a = b) ↔ a = b :=
eventually_const
lemma const_eventually_eq [ne_bot l] {a b : β} : ((λ _, a) =ᶠ[l] (λ _, b)) ↔ a = b :=
@const_eventually_eq' _ _ _ _ a b
lemma eventually_eq.comp_tendsto {f' : α → β} (H : f =ᶠ[l] f') {g : γ → α} {lc : filter γ}
(hg : tendsto g lc l) :
f ∘ g =ᶠ[lc] f' ∘ g :=
hg.eventually H
/-- Setoid used to define the space of germs. -/
def germ_setoid (l : filter α) (β : Type*) : setoid (α → β) :=
{ r := eventually_eq l,
iseqv := ⟨eventually_eq.refl _, λ _ _, eventually_eq.symm, λ _ _ _, eventually_eq.trans⟩ }
/-- The space of germs of functions `α → β` at a filter `l`. -/
def germ (l : filter α) (β : Type*) : Type* := quotient (germ_setoid l β)
namespace germ
instance : has_coe_t (α → β) (germ l β) := ⟨quotient.mk'⟩
instance : has_lift_t β (germ l β) := ⟨λ c, ↑(λ (x : α), c)⟩
@[simp] lemma quot_mk_eq_coe (l : filter α) (f : α → β) : quot.mk _ f = (f : germ l β) := rfl
@[simp] lemma mk'_eq_coe (l : filter α) (f : α → β) : quotient.mk' f = (f : germ l β) := rfl
@[elab_as_eliminator]
lemma induction_on (f : germ l β) {p : germ l β → Prop} (h : ∀ f : α → β, p f) : p f :=
quotient.induction_on' f h
@[elab_as_eliminator]
lemma induction_on₂ (f : germ l β) (g : germ l γ) {p : germ l β → germ l γ → Prop}
(h : ∀ (f : α → β) (g : α → γ), p f g) : p f g :=
quotient.induction_on₂' f g h
@[elab_as_eliminator]
lemma induction_on₃ (f : germ l β) (g : germ l γ) (h : germ l δ)
{p : germ l β → germ l γ → germ l δ → Prop}
(H : ∀ (f : α → β) (g : α → γ) (h : α → δ), p f g h) :
p f g h :=
quotient.induction_on₃' f g h H
/-- Given a map `F : (α → β) → (γ → δ)` that sends functions eventually equal at `l` to functions
eventually equal at `lc`, returns a map from `germ l β` to `germ lc δ`. -/
def map' {lc : filter γ} (F : (α → β) → (γ → δ)) (hF : (l.eventually_eq ⇒ lc.eventually_eq) F F) :
germ l β → germ lc δ :=
quotient.map' F hF
/-- Given a germ `f : germ l β` and a function `F : (α → β) → γ` sending eventually equal functions
to the same value, returns the value `F` takes on functions having germ `f` at `l`. -/
def lift_on {γ : Sort*} (f : germ l β) (F : (α → β) → γ) (hF : (l.eventually_eq ⇒ (=)) F F) : γ :=
quotient.lift_on' f F hF
@[simp] lemma map'_coe {lc : filter γ} (F : (α → β) → (γ → δ))
(hF : (l.eventually_eq ⇒ lc.eventually_eq) F F) (f : α → β) :
map' F hF f = F f :=
rfl
@[simp, norm_cast] lemma coe_eq : (f : germ l β) = g ↔ (f =ᶠ[l] g) := quotient.eq'
alias coe_eq ↔ _ filter.eventually_eq.germ_eq
/-- Lift a function `β → γ` to a function `germ l β → germ l γ`. -/
def map (op : β → γ) : germ l β → germ l γ :=
map' ((∘) op) $ λ f g H, H.mono $ λ x H, congr_arg op H
@[simp] lemma map_coe (op : β → γ) (f : α → β) : map op (f : germ l β) = op ∘ f := rfl
@[simp] lemma map_id : map id = (id : germ l β → germ l β) := by { ext ⟨f⟩, refl }
lemma map_map (op₁ : γ → δ) (op₂ : β → γ) (f : germ l β) :
map op₁ (map op₂ f) = map (op₁ ∘ op₂) f :=
induction_on f $ λ f, rfl
/-- Lift a binary function `β → γ → δ` to a function `germ l β → germ l γ → germ l δ`. -/
def map₂ (op : β → γ → δ) : germ l β → germ l γ → germ l δ :=
quotient.map₂' (λ f g x, op (f x) (g x)) $ λ f f' Hf g g' Hg,
Hg.mp $ Hf.mono $ λ x Hf Hg, by simp only [Hf, Hg]
@[simp] lemma map₂_coe (op : β → γ → δ) (f : α → β) (g : α → γ) :
map₂ op (f : germ l β) g = λ x, op (f x) (g x) :=
rfl
/-- A germ at `l` of maps from `α` to `β` tends to `lb : filter β` if it is represented by a map
which tends to `lb` along `l`. -/
protected def tendsto (f : germ l β) (lb : filter β) : Prop :=
lift_on f (λ f, tendsto f l lb) $ λ f g H, propext (tendsto_congr' H)
@[simp, norm_cast] lemma coe_tendsto {f : α → β} {lb : filter β} :
(f : germ l β).tendsto lb ↔ tendsto f l lb :=
iff.rfl
alias coe_tendsto ↔ _ filter.tendsto.germ_tendsto
/-- Given two germs `f : germ l β`, and `g : germ lc α`, where `l : filter α`, if `g` tends to `l`,
then the composition `f ∘ g` is well-defined as a germ at `lc`. -/
def comp_tendsto' (f : germ l β) {lc : filter γ} (g : germ lc α) (hg : g.tendsto l) :
germ lc β :=
lift_on f (λ f, g.map f) $ λ f₁ f₂ hF, (induction_on g $ λ g hg, coe_eq.2 $ hg.eventually hF) hg
@[simp] lemma coe_comp_tendsto' (f : α → β) {lc : filter γ} {g : germ lc α} (hg : g.tendsto l) :
(f : germ l β).comp_tendsto' g hg = g.map f :=
rfl
/-- Given a germ `f : germ l β` and a function `g : γ → α`, where `l : filter α`, if `g` tends
to `l` along `lc : filter γ`, then the composition `f ∘ g` is well-defined as a germ at `lc`. -/
def comp_tendsto (f : germ l β) {lc : filter γ} (g : γ → α) (hg : tendsto g lc l) :
germ lc β :=
f.comp_tendsto' _ hg.germ_tendsto
@[simp] lemma coe_comp_tendsto (f : α → β) {lc : filter γ} {g : γ → α} (hg : tendsto g lc l) :
(f : germ l β).comp_tendsto g hg = f ∘ g :=
rfl
@[simp] lemma comp_tendsto'_coe (f : germ l β) {lc : filter γ} {g : γ → α} (hg : tendsto g lc l) :
f.comp_tendsto' _ hg.germ_tendsto = f.comp_tendsto g hg :=
rfl
@[simp, norm_cast] lemma const_inj [ne_bot l] {a b : β} : (↑a : germ l β) = ↑b ↔ a = b :=
coe_eq.trans $ const_eventually_eq
@[simp] lemma map_const (l : filter α) (a : β) (f : β → γ) :
(↑a : germ l β).map f = ↑(f a) :=
rfl
@[simp] lemma map₂_const (l : filter α) (b : β) (c : γ) (f : β → γ → δ) :
map₂ f (↑b : germ l β) ↑c = ↑(f b c) :=
rfl
@[simp] lemma const_comp_tendsto {l : filter α} (b : β) {lc : filter γ} {g : γ → α}
(hg : tendsto g lc l) :
(↑b : germ l β).comp_tendsto g hg = ↑b :=
rfl
@[simp] lemma const_comp_tendsto' {l : filter α} (b : β) {lc : filter γ} {g : germ lc α}
(hg : g.tendsto l) :
(↑b : germ l β).comp_tendsto' g hg = ↑b :=
induction_on g (λ _ _, rfl) hg
/-- Lift a predicate on `β` to `germ l β`. -/
def lift_pred (p : β → Prop) (f : germ l β) : Prop :=
lift_on f (λ f, ∀ᶠ x in l, p (f x)) $
λ f g H, propext $ eventually_congr $ H.mono $ λ x hx, hx ▸ iff.rfl
@[simp] lemma lift_pred_coe {p : β → Prop} {f : α → β} :
lift_pred p (f : germ l β) ↔ ∀ᶠ x in l, p (f x) :=
iff.rfl
lemma lift_pred_const {p : β → Prop} {x : β} (hx : p x) :
lift_pred p (↑x : germ l β) :=
eventually_of_forall $ λ y, hx
@[simp] lemma lift_pred_const_iff [ne_bot l] {p : β → Prop} {x : β} :
lift_pred p (↑x : germ l β) ↔ p x :=
@eventually_const _ _ _ (p x)
/-- Lift a relation `r : β → γ → Prop` to `germ l β → germ l γ → Prop`. -/
def lift_rel (r : β → γ → Prop) (f : germ l β) (g : germ l γ) : Prop :=
quotient.lift_on₂' f g (λ f g, ∀ᶠ x in l, r (f x) (g x)) $
λ f g f' g' Hf Hg, propext $ eventually_congr $ Hg.mp $ Hf.mono $ λ x hf hg, hf ▸ hg ▸ iff.rfl
@[simp] lemma lift_rel_coe {r : β → γ → Prop} {f : α → β} {g : α → γ} :
lift_rel r (f : germ l β) g ↔ ∀ᶠ x in l, r (f x) (g x) :=
iff.rfl
lemma lift_rel_const {r : β → γ → Prop} {x : β} {y : γ} (h : r x y) :
lift_rel r (↑x : germ l β) ↑y :=
eventually_of_forall $ λ _, h
@[simp] lemma lift_rel_const_iff [ne_bot l] {r : β → γ → Prop} {x : β} {y : γ} :
lift_rel r (↑x : germ l β) ↑y ↔ r x y :=
@eventually_const _ _ _ (r x y)
instance [inhabited β] : inhabited (germ l β) := ⟨↑(default β)⟩
section monoid
variables {M : Type*} {G : Type*}
@[to_additive]
instance [has_mul M] : has_mul (germ l M) := ⟨map₂ (*)⟩
@[simp, norm_cast, to_additive]
lemma coe_mul [has_mul M] (f g : α → M) : ↑(f * g) = (f * g : germ l M) := rfl
@[to_additive]
instance [has_one M] : has_one (germ l M) := ⟨↑(1:M)⟩
@[simp, norm_cast, to_additive]
lemma coe_one [has_one M] : ↑(1 : α → M) = (1 : germ l M) := rfl
@[to_additive]
instance [semigroup M] : semigroup (germ l M) :=
{ mul := (*), mul_assoc := by { rintros ⟨f⟩ ⟨g⟩ ⟨h⟩,
simp only [mul_assoc, quot_mk_eq_coe, ← coe_mul] } }
@[to_additive]
instance [comm_semigroup M] : comm_semigroup (germ l M) :=
{ mul := (*),
mul_comm := by { rintros ⟨f⟩ ⟨g⟩, simp only [mul_comm, quot_mk_eq_coe, ← coe_mul] },
.. germ.semigroup }
@[to_additive add_left_cancel_semigroup]
instance [left_cancel_semigroup M] : left_cancel_semigroup (germ l M) :=
{ mul := (*),
mul_left_cancel := λ f₁ f₂ f₃, induction_on₃ f₁ f₂ f₃ $ λ f₁ f₂ f₃ H,
coe_eq.2 ((coe_eq.1 H).mono $ λ x, mul_left_cancel),
.. germ.semigroup }
@[to_additive add_right_cancel_semigroup]
instance [right_cancel_semigroup M] : right_cancel_semigroup (germ l M) :=
{ mul := (*),
mul_right_cancel := λ f₁ f₂ f₃, induction_on₃ f₁ f₂ f₃ $ λ f₁ f₂ f₃ H,
coe_eq.2 $ (coe_eq.1 H).mono $ λ x, mul_right_cancel,
.. germ.semigroup }
@[to_additive]
instance [monoid M] : monoid (germ l M) :=
{ mul := (*),
one := 1,
one_mul := λ f, induction_on f $ λ f, by { norm_cast, rw [one_mul] },
mul_one := λ f, induction_on f $ λ f, by { norm_cast, rw [mul_one] },
.. germ.semigroup }
/-- coercion from functions to germs as a monoid homomorphism. -/
@[to_additive]
def coe_mul_hom [monoid M] (l : filter α) : (α → M) →* germ l M := ⟨coe, rfl, λ f g, rfl⟩
/-- coercion from functions to germs as an additive monoid homomorphism. -/
add_decl_doc coe_add_hom
@[simp, to_additive]
lemma coe_coe_mul_hom [monoid M] : (coe_mul_hom l : (α → M) → germ l M) = coe := rfl
@[to_additive]
instance [comm_monoid M] : comm_monoid (germ l M) :=
{ mul := (*),
one := 1,
.. germ.comm_semigroup, .. germ.monoid }
@[to_additive]
instance [has_inv G] : has_inv (germ l G) := ⟨map has_inv.inv⟩
@[simp, norm_cast, to_additive]
lemma coe_inv [has_inv G] (f : α → G) : ↑f⁻¹ = (f⁻¹ : germ l G) := rfl
@[to_additive]
instance [has_div M] : has_div (germ l M) := ⟨map₂ (/)⟩
@[simp, norm_cast, to_additive]
lemma coe_div [has_div M] (f g : α → M) : ↑(f / g) = (f / g : germ l M) := rfl
@[to_additive]
instance [div_inv_monoid G] : div_inv_monoid (germ l G) :=
{ inv := has_inv.inv,
div := has_div.div,
div_eq_mul_inv := by { rintros ⟨f⟩ ⟨g⟩, exact congr_arg (quot.mk _) (div_eq_mul_inv f g) },
.. germ.monoid }
@[to_additive]
instance [group G] : group (germ l G) :=
{ mul := (*),
one := 1,
mul_left_inv := by { rintros ⟨f⟩, exact congr_arg (quot.mk _) (mul_left_inv f) },
.. germ.div_inv_monoid }
@[to_additive]
instance [comm_group G] : comm_group (germ l G) :=
{ mul := (*),
one := 1,
inv := has_inv.inv,
.. germ.group, .. germ.comm_monoid }
end monoid
section ring
variables {R : Type*}
instance nontrivial [nontrivial R] [ne_bot l] : nontrivial (germ l R) :=
let ⟨x, y, h⟩ := exists_pair_ne R in ⟨⟨↑x, ↑y, mt const_inj.1 h⟩⟩
instance [mul_zero_class R] : mul_zero_class (germ l R) :=
{ zero := 0,
mul := (*),
mul_zero := λ f, induction_on f $ λ f, by { norm_cast, rw [mul_zero] },
zero_mul := λ f, induction_on f $ λ f, by { norm_cast, rw [zero_mul] } }
instance [distrib R] : distrib (germ l R) :=
{ mul := (*),
add := (+),
left_distrib := λ f g h, induction_on₃ f g h $ λ f g h, by { norm_cast, rw [left_distrib] },
right_distrib := λ f g h, induction_on₃ f g h $ λ f g h, by { norm_cast, rw [right_distrib] } }
instance [semiring R] : semiring (germ l R) :=
{ .. germ.add_comm_monoid, .. germ.monoid, .. germ.distrib, .. germ.mul_zero_class }
/-- Coercion `(α → R) → germ l R` as a `ring_hom`. -/
def coe_ring_hom [semiring R] (l : filter α) : (α → R) →+* germ l R :=
{ to_fun := coe, .. (coe_mul_hom l : _ →* germ l R), .. (coe_add_hom l : _ →+ germ l R) }
@[simp] lemma coe_coe_ring_hom [semiring R] : (coe_ring_hom l : (α → R) → germ l R) = coe := rfl
instance [ring R] : ring (germ l R) :=
{ .. germ.add_comm_group, .. germ.monoid, .. germ.distrib, .. germ.mul_zero_class }
instance [comm_semiring R] : comm_semiring (germ l R) :=
{ .. germ.semiring, .. germ.comm_monoid }
instance [comm_ring R] : comm_ring (germ l R) :=
{ .. germ.ring, .. germ.comm_monoid }
end ring
section module
variables {M N R : Type*}
instance [has_scalar M β] : has_scalar M (germ l β) :=
⟨λ c, map ((•) c)⟩
instance has_scalar' [has_scalar M β] : has_scalar (germ l M) (germ l β) :=
⟨map₂ (•)⟩
@[simp, norm_cast] lemma coe_smul [has_scalar M β] (c : M) (f : α → β) :
↑(c • f) = (c • f : germ l β) :=
rfl
@[simp, norm_cast] lemma coe_smul' [has_scalar M β] (c : α → M) (f : α → β) :
↑(c • f) = (c : germ l M) • (f : germ l β) :=
rfl
instance [monoid M] [mul_action M β] : mul_action M (germ l β) :=
{ one_smul := λ f, induction_on f $ λ f, by { norm_cast, simp only [one_smul] },
mul_smul := λ c₁ c₂ f, induction_on f $ λ f, by { norm_cast, simp only [mul_smul] } }
instance mul_action' [monoid M] [mul_action M β] : mul_action (germ l M) (germ l β) :=
{ one_smul := λ f, induction_on f $ λ f, by simp only [← coe_one, ← coe_smul', one_smul],
mul_smul := λ c₁ c₂ f, induction_on₃ c₁ c₂ f $ λ c₁ c₂ f, by { norm_cast, simp only [mul_smul] } }
instance [monoid M] [add_monoid N] [distrib_mul_action M N] :
distrib_mul_action M (germ l N) :=
{ smul_add := λ c f g, induction_on₂ f g $ λ f g, by { norm_cast, simp only [smul_add] },
smul_zero := λ c, by simp only [← coe_zero, ← coe_smul, smul_zero] }
instance distrib_mul_action' [monoid M] [add_monoid N] [distrib_mul_action M N] :
distrib_mul_action (germ l M) (germ l N) :=
{ smul_add := λ c f g, induction_on₃ c f g $ λ c f g, by { norm_cast, simp only [smul_add] },
smul_zero := λ c, induction_on c $ λ c, by simp only [← coe_zero, ← coe_smul', smul_zero] }
instance [semiring R] [add_comm_monoid M] [module R M] :
module R (germ l M) :=
{ add_smul := λ c₁ c₂ f, induction_on f $ λ f, by { norm_cast, simp only [add_smul] },
zero_smul := λ f, induction_on f $ λ f, by { norm_cast, simp only [zero_smul, coe_zero] } }
instance module' [semiring R] [add_comm_monoid M] [module R M] :
module (germ l R) (germ l M) :=
{ add_smul := λ c₁ c₂ f, induction_on₃ c₁ c₂ f $ λ c₁ c₂ f, by { norm_cast, simp only [add_smul] },
zero_smul := λ f, induction_on f $ λ f, by simp only [← coe_zero, ← coe_smul', zero_smul] }
end module
instance [has_le β] : has_le (germ l β) :=
⟨lift_rel (≤)⟩
@[simp] lemma coe_le [has_le β] : (f : germ l β) ≤ g ↔ (f ≤ᶠ[l] g) := iff.rfl
lemma le_def [has_le β] : ((≤) : germ l β → germ l β → Prop) = lift_rel (≤) := rfl
lemma const_le [has_le β] {x y : β} (h : x ≤ y) : (↑x : germ l β) ≤ ↑y :=
lift_rel_const h
@[simp, norm_cast]
lemma const_le_iff [has_le β] [ne_bot l] {x y : β} : (↑x : germ l β) ≤ ↑y ↔ x ≤ y :=
lift_rel_const_iff
instance [preorder β] : preorder (germ l β) :=
{ le := (≤),
le_refl := λ f, induction_on f $ eventually_le.refl l,
le_trans := λ f₁ f₂ f₃, induction_on₃ f₁ f₂ f₃ $ λ f₁ f₂ f₃, eventually_le.trans }
instance [partial_order β] : partial_order (germ l β) :=
{ le := (≤),
le_antisymm := λ f g, induction_on₂ f g $ λ f g h₁ h₂, (eventually_le.antisymm h₁ h₂).germ_eq,
.. germ.preorder }
instance [has_bot β] : has_bot (germ l β) := ⟨↑(⊥:β)⟩
@[simp, norm_cast] lemma const_bot [has_bot β] : (↑(⊥:β) : germ l β) = ⊥ := rfl
instance [order_bot β] : order_bot (germ l β) :=
{ bot := ⊥,
le := (≤),
bot_le := λ f, induction_on f $ λ f, eventually_of_forall $ λ x, bot_le,
.. germ.partial_order }
instance [has_top β] : has_top (germ l β) := ⟨↑(⊤:β)⟩
@[simp, norm_cast] lemma const_top [has_top β] : (↑(⊤:β) : germ l β) = ⊤ := rfl
instance [order_top β] : order_top (germ l β) :=
{ top := ⊤,
le := (≤),
le_top := λ f, induction_on f $ λ f, eventually_of_forall $ λ x, le_top,
.. germ.partial_order }
instance [has_sup β] : has_sup (germ l β) := ⟨map₂ (⊔)⟩
@[simp, norm_cast] lemma const_sup [has_sup β] (a b : β) : ↑(a ⊔ b) = (↑a ⊔ ↑b : germ l β) := rfl
instance [has_inf β] : has_inf (germ l β) := ⟨map₂ (⊓)⟩
@[simp, norm_cast] lemma const_inf [has_inf β] (a b : β) : ↑(a ⊓ b) = (↑a ⊓ ↑b : germ l β) := rfl
instance [semilattice_sup β] : semilattice_sup (germ l β) :=
{ sup := (⊔),
le_sup_left := λ f g, induction_on₂ f g $ λ f g,
eventually_of_forall $ λ x, le_sup_left,
le_sup_right := λ f g, induction_on₂ f g $ λ f g,
eventually_of_forall $ λ x, le_sup_right,
sup_le := λ f₁ f₂ g, induction_on₃ f₁ f₂ g $ λ f₁ f₂ g h₁ h₂,
h₂.mp $ h₁.mono $ λ x, sup_le,
.. germ.partial_order }
instance [semilattice_inf β] : semilattice_inf (germ l β) :=
{ inf := (⊓),
inf_le_left := λ f g, induction_on₂ f g $ λ f g,
eventually_of_forall $ λ x, inf_le_left,
inf_le_right := λ f g, induction_on₂ f g $ λ f g,
eventually_of_forall $ λ x, inf_le_right,
le_inf := λ f₁ f₂ g, induction_on₃ f₁ f₂ g $ λ f₁ f₂ g h₁ h₂,
h₂.mp $ h₁.mono $ λ x, le_inf,
.. germ.partial_order }
instance [semilattice_inf_bot β] : semilattice_inf_bot (germ l β) :=
{ .. germ.semilattice_inf, .. germ.order_bot }
instance [semilattice_sup_bot β] : semilattice_sup_bot (germ l β) :=
{ .. germ.semilattice_sup, .. germ.order_bot }
instance [semilattice_inf_top β] : semilattice_inf_top (germ l β) :=
{ .. germ.semilattice_inf, .. germ.order_top }
instance [semilattice_sup_top β] : semilattice_sup_top (germ l β) :=
{ .. germ.semilattice_sup, .. germ.order_top }
instance [lattice β] : lattice (germ l β) :=
{ .. germ.semilattice_sup, .. germ.semilattice_inf }
instance [bounded_lattice β] : bounded_lattice (germ l β) :=
{ .. germ.lattice, .. germ.order_bot, .. germ.order_top }
@[to_additive]
instance [ordered_cancel_comm_monoid β] : ordered_cancel_comm_monoid (germ l β) :=
{ mul_le_mul_left := λ f g, induction_on₂ f g $ λ f g H h, induction_on h $ λ h,
H.mono $ λ x H, mul_le_mul_left' H _,
le_of_mul_le_mul_left := λ f g h, induction_on₃ f g h $ λ f g h H,
H.mono $ λ x, le_of_mul_le_mul_left',
.. germ.partial_order, .. germ.comm_monoid, .. germ.left_cancel_semigroup }
@[to_additive]
instance ordered_comm_group [ordered_comm_group β] : ordered_comm_group (germ l β) :=
{ mul_le_mul_left := λ f g, induction_on₂ f g $ λ f g H h, induction_on h $ λ h,
H.mono $ λ x H, mul_le_mul_left' H _,
.. germ.partial_order, .. germ.comm_group }
end germ
end filter
|
3452f2f327b59f3651b584b67162217f99939e25 | 63abd62053d479eae5abf4951554e1064a4c45b4 | /src/category_theory/opposites.lean | 4ea5634cb0da5a8a72cb6230e8fdf5fd74379a29 | [
"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 | 13,602 | lean | /-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Stephen Morgan, Scott Morrison
-/
import category_theory.types
import category_theory.equivalence
import data.opposite
universes v₁ v₂ u₁ u₂ -- declare the `v`'s first; see `category_theory.category` for an explanation
namespace category_theory
open opposite
variables {C : Type u₁}
section has_hom
variables [has_hom.{v₁} C]
/-- The hom types of the opposite of a category (or graph).
As with the objects, we'll make this irreducible below.
Use `f.op` and `f.unop` to convert between morphisms of C
and morphisms of Cᵒᵖ.
-/
instance has_hom.opposite : has_hom Cᵒᵖ :=
{ hom := λ X Y, unop Y ⟶ unop X }
/--
The opposite of a morphism in `C`.
-/
def has_hom.hom.op {X Y : C} (f : X ⟶ Y) : op Y ⟶ op X := f
/--
Given a morphism in `Cᵒᵖ`, we can take the "unopposite" back in `C`.
-/
def has_hom.hom.unop {X Y : Cᵒᵖ} (f : X ⟶ Y) : unop Y ⟶ unop X := f
attribute [irreducible] has_hom.opposite
lemma has_hom.hom.op_inj {X Y : C} :
function.injective (has_hom.hom.op : (X ⟶ Y) → (op Y ⟶ op X)) :=
λ _ _ H, congr_arg has_hom.hom.unop H
lemma has_hom.hom.unop_inj {X Y : Cᵒᵖ} :
function.injective (has_hom.hom.unop : (X ⟶ Y) → (unop Y ⟶ unop X)) :=
λ _ _ H, congr_arg has_hom.hom.op H
@[simp] lemma has_hom.hom.unop_op {X Y : C} {f : X ⟶ Y} : f.op.unop = f := rfl
@[simp] lemma has_hom.hom.op_unop {X Y : Cᵒᵖ} {f : X ⟶ Y} : f.unop.op = f := rfl
end has_hom
variables [category.{v₁} C]
/--
The opposite category.
See https://stacks.math.columbia.edu/tag/001M.
-/
instance category.opposite : category.{v₁} Cᵒᵖ :=
{ comp := λ _ _ _ f g, (g.unop ≫ f.unop).op,
id := λ X, (𝟙 (unop X)).op }
@[simp] lemma op_comp {X Y Z : C} {f : X ⟶ Y} {g : Y ⟶ Z} :
(f ≫ g).op = g.op ≫ f.op := rfl
@[simp] lemma op_id {X : C} : (𝟙 X).op = 𝟙 (op X) := rfl
@[simp] lemma unop_comp {X Y Z : Cᵒᵖ} {f : X ⟶ Y} {g : Y ⟶ Z} :
(f ≫ g).unop = g.unop ≫ f.unop := rfl
@[simp] lemma unop_id {X : Cᵒᵖ} : (𝟙 X).unop = 𝟙 (unop X) := rfl
@[simp] lemma unop_id_op {X : C} : (𝟙 (op X)).unop = 𝟙 X := rfl
@[simp] lemma op_id_unop {X : Cᵒᵖ} : (𝟙 (unop X)).op = 𝟙 X := rfl
section
variables (C)
/-- The functor from the double-opposite of a category to the underlying category. -/
@[simps]
def op_op : (Cᵒᵖ)ᵒᵖ ⥤ C :=
{ obj := λ X, unop (unop X),
map := λ X Y f, f.unop.unop }
/-- The functor from a category to its double-opposite. -/
@[simps]
def unop_unop : C ⥤ Cᵒᵖᵒᵖ :=
{ obj := λ X, op (op X),
map := λ X Y f, f.op.op }
/-- The double opposite category is equivalent to the original. -/
@[simps]
def op_op_equivalence : Cᵒᵖᵒᵖ ≌ C :=
{ functor := op_op C,
inverse := unop_unop C,
unit_iso := iso.refl (𝟭 Cᵒᵖᵒᵖ),
counit_iso := iso.refl (unop_unop C ⋙ op_op C) }
end
/--
If `f.op` is an isomorphism `f` must be too.
(This cannot be an instance as it would immediately loop!)
-/
def is_iso_of_op {X Y : C} (f : X ⟶ Y) [is_iso f.op] : is_iso f :=
{ inv := (inv (f.op)).unop,
hom_inv_id' := has_hom.hom.op_inj (by simp),
inv_hom_id' := has_hom.hom.op_inj (by simp) }
namespace functor
section
variables {D : Type u₂} [category.{v₂} D]
variables {C D}
/--
The opposite of a functor, i.e. considering a functor `F : C ⥤ D` as a functor `Cᵒᵖ ⥤ Dᵒᵖ`.
In informal mathematics no distinction is made between these.
-/
@[simps]
protected def op (F : C ⥤ D) : Cᵒᵖ ⥤ Dᵒᵖ :=
{ obj := λ X, op (F.obj (unop X)),
map := λ X Y f, (F.map f.unop).op }
/--
Given a functor `F : Cᵒᵖ ⥤ Dᵒᵖ` we can take the "unopposite" functor `F : C ⥤ D`.
In informal mathematics no distinction is made between these.
-/
@[simps]
protected def unop (F : Cᵒᵖ ⥤ Dᵒᵖ) : C ⥤ D :=
{ obj := λ X, unop (F.obj (op X)),
map := λ X Y f, (F.map f.op).unop }
/-- The isomorphism between `F.op.unop` and `F`. -/
def op_unop_iso (F : C ⥤ D) : F.op.unop ≅ F :=
nat_iso.of_components (λ X, iso.refl _) (by tidy)
/-- The isomorphism between `F.unop.op` and `F`. -/
def unop_op_iso (F : Cᵒᵖ ⥤ Dᵒᵖ) : F.unop.op ≅ F :=
nat_iso.of_components (λ X, iso.refl _) (by tidy)
variables (C D)
/--
Taking the opposite of a functor is functorial.
-/
@[simps]
def op_hom : (C ⥤ D)ᵒᵖ ⥤ (Cᵒᵖ ⥤ Dᵒᵖ) :=
{ obj := λ F, (unop F).op,
map := λ F G α,
{ app := λ X, (α.unop.app (unop X)).op,
naturality' := λ X Y f, has_hom.hom.unop_inj (α.unop.naturality f.unop).symm } }
/--
Take the "unopposite" of a functor is functorial.
-/
@[simps]
def op_inv : (Cᵒᵖ ⥤ Dᵒᵖ) ⥤ (C ⥤ D)ᵒᵖ :=
{ obj := λ F, op F.unop,
map := λ F G α, has_hom.hom.op
{ app := λ X, (α.app (op X)).unop,
naturality' := λ X Y f, has_hom.hom.op_inj $ (α.naturality f.op).symm } }
-- TODO show these form an equivalence
variables {C D}
/--
Another variant of the opposite of functor, turning a functor `C ⥤ Dᵒᵖ` into a functor `Cᵒᵖ ⥤ D`.
In informal mathematics no distinction is made.
-/
@[simps]
protected def left_op (F : C ⥤ Dᵒᵖ) : Cᵒᵖ ⥤ D :=
{ obj := λ X, unop (F.obj (unop X)),
map := λ X Y f, (F.map f.unop).unop }
/--
Another variant of the opposite of functor, turning a functor `Cᵒᵖ ⥤ D` into a functor `C ⥤ Dᵒᵖ`.
In informal mathematics no distinction is made.
-/
@[simps]
protected def right_op (F : Cᵒᵖ ⥤ D) : C ⥤ Dᵒᵖ :=
{ obj := λ X, op (F.obj (op X)),
map := λ X Y f, (F.map f.op).op }
-- TODO show these form an equivalence
instance {F : C ⥤ D} [full F] : full F.op :=
{ preimage := λ X Y f, (F.preimage f.unop).op }
instance {F : C ⥤ D} [faithful F] : faithful F.op :=
{ map_injective' := λ X Y f g h,
has_hom.hom.unop_inj $ by simpa using map_injective F (has_hom.hom.op_inj h) }
/-- If F is faithful then the right_op of F is also faithful. -/
instance right_op_faithful {F : Cᵒᵖ ⥤ D} [faithful F] : faithful F.right_op :=
{ map_injective' := λ X Y f g h, has_hom.hom.op_inj (map_injective F (has_hom.hom.op_inj h)) }
/-- If F is faithful then the left_op of F is also faithful. -/
instance left_op_faithful {F : C ⥤ Dᵒᵖ} [faithful F] : faithful F.left_op :=
{ map_injective' := λ X Y f g h, has_hom.hom.unop_inj (map_injective F (has_hom.hom.unop_inj h)) }
end
end functor
namespace nat_trans
variables {D : Type u₂} [category.{v₂} D]
section
variables {F G : C ⥤ D}
local attribute [semireducible] has_hom.opposite
/-- The opposite of a natural transformation. -/
@[simps] protected def op (α : F ⟶ G) : G.op ⟶ F.op :=
{ app := λ X, (α.app (unop X)).op,
naturality' := begin tidy, erw α.naturality, refl, end }
@[simp] lemma op_id (F : C ⥤ D) : nat_trans.op (𝟙 F) = 𝟙 (F.op) := rfl
/-- The "unopposite" of a natural transformation. -/
@[simps] protected def unop {F G : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ⟶ G) : G.unop ⟶ F.unop :=
{ app := λ X, (α.app (op X)).unop,
naturality' := begin tidy, erw α.naturality, refl, end }
@[simp] lemma unop_id (F : Cᵒᵖ ⥤ Dᵒᵖ) : nat_trans.unop (𝟙 F) = 𝟙 (F.unop) := rfl
/--
Given a natural transformation `α : F.op ⟶ G.op`,
we can take the "unopposite" of each component obtaining a natural transformation `G ⟶ F`.
-/
@[simps] protected def remove_op (α : F.op ⟶ G.op) : G ⟶ F :=
{ app := λ X, (α.app (op X)).unop,
naturality' :=
begin
intros X Y f,
have := congr_arg has_hom.hom.op (α.naturality f.op),
dsimp at this,
erw this,
refl,
end }
@[simp] lemma remove_op_id (F : C ⥤ D) : nat_trans.remove_op (𝟙 F.op) = 𝟙 F := rfl
end
section
variables {F G : C ⥤ Dᵒᵖ}
local attribute [semireducible] has_hom.opposite
/--
Given a natural transformation `α : F ⟶ G`, for `F G : C ⥤ Dᵒᵖ`,
taking `unop` of each component gives a natural transformation `G.left_op ⟶ F.left_op`.
-/
protected def left_op (α : F ⟶ G) : G.left_op ⟶ F.left_op :=
{ app := λ X, (α.app (unop X)).unop,
naturality' := begin tidy, erw α.naturality, refl, end }
@[simp] lemma left_op_app (α : F ⟶ G) (X) :
(nat_trans.left_op α).app X = (α.app (unop X)).unop :=
rfl
/--
Given a natural transformation `α : F.left_op ⟶ G.left_op`, for `F G : C ⥤ Dᵒᵖ`,
taking `op` of each component gives a natural transformation `G ⟶ F`.
-/
protected def remove_left_op (α : F.left_op ⟶ G.left_op) : G ⟶ F :=
{ app := λ X, (α.app (op X)).op,
naturality' :=
begin
intros X Y f,
have := congr_arg has_hom.hom.op (α.naturality f.op),
dsimp at this,
erw this
end }
@[simp] lemma remove_left_op_app (α : F.left_op ⟶ G.left_op) (X) :
(nat_trans.remove_left_op α).app X = (α.app (op X)).op :=
rfl
end
end nat_trans
namespace iso
variables {X Y : C}
/--
The opposite isomorphism.
-/
protected def op (α : X ≅ Y) : op Y ≅ op X :=
{ hom := α.hom.op,
inv := α.inv.op,
hom_inv_id' := has_hom.hom.unop_inj α.inv_hom_id,
inv_hom_id' := has_hom.hom.unop_inj α.hom_inv_id }
@[simp] lemma op_hom {α : X ≅ Y} : α.op.hom = α.hom.op := rfl
@[simp] lemma op_inv {α : X ≅ Y} : α.op.inv = α.inv.op := rfl
end iso
namespace nat_iso
variables {D : Type u₂} [category.{v₂} D]
variables {F G : C ⥤ D}
/-- The natural isomorphism between opposite functors `G.op ≅ F.op` induced by a natural
isomorphism between the original functors `F ≅ G`. -/
protected def op (α : F ≅ G) : G.op ≅ F.op :=
{ hom := nat_trans.op α.hom,
inv := nat_trans.op α.inv,
hom_inv_id' := begin ext, dsimp, rw ←op_comp, rw α.inv_hom_id_app, refl, end,
inv_hom_id' := begin ext, dsimp, rw ←op_comp, rw α.hom_inv_id_app, refl, end }
@[simp] lemma op_hom (α : F ≅ G) : (nat_iso.op α).hom = nat_trans.op α.hom := rfl
@[simp] lemma op_inv (α : F ≅ G) : (nat_iso.op α).inv = nat_trans.op α.inv := rfl
/-- The natural isomorphism between functors `G ≅ F` induced by a natural isomorphism
between the opposite functors `F.op ≅ G.op`. -/
protected def remove_op (α : F.op ≅ G.op) : G ≅ F :=
{ hom := nat_trans.remove_op α.hom,
inv := nat_trans.remove_op α.inv,
hom_inv_id' := begin ext, dsimp, rw ←unop_comp, rw α.inv_hom_id_app, refl, end,
inv_hom_id' := begin ext, dsimp, rw ←unop_comp, rw α.hom_inv_id_app, refl, end }
@[simp] lemma remove_op_hom (α : F.op ≅ G.op) :
(nat_iso.remove_op α).hom = nat_trans.remove_op α.hom := rfl
@[simp] lemma remove_op_inv (α : F.op ≅ G.op) :
(nat_iso.remove_op α).inv = nat_trans.remove_op α.inv := rfl
/-- The natural isomorphism between functors `G.unop ≅ F.unop` induced by a natural isomorphism
between the original functors `F ≅ G`. -/
protected def unop {F G : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ≅ G) : G.unop ≅ F.unop :=
{ hom := nat_trans.unop α.hom,
inv := nat_trans.unop α.inv,
hom_inv_id' := begin ext, dsimp, rw ←unop_comp, rw α.inv_hom_id_app, refl, end,
inv_hom_id' := begin ext, dsimp, rw ←unop_comp, rw α.hom_inv_id_app, refl, end }
@[simp] lemma unop_hom {F G : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ≅ G) :
(nat_iso.unop α).hom = nat_trans.unop α.hom := rfl
@[simp] lemma unop_inv {F G : Cᵒᵖ ⥤ Dᵒᵖ} (α : F ≅ G) :
(nat_iso.unop α).inv = nat_trans.unop α.inv := rfl
end nat_iso
namespace equivalence
variables {D : Type u₂} [category.{v₂} D]
/--
An equivalence between categories gives an equivalence between the opposite categories.
-/
@[simps]
def op (e : C ≌ D) : Cᵒᵖ ≌ Dᵒᵖ :=
{ functor := e.functor.op,
inverse := e.inverse.op,
unit_iso := (nat_iso.op e.unit_iso).symm,
counit_iso := (nat_iso.op e.counit_iso).symm,
functor_unit_iso_comp' := λ X, by { apply has_hom.hom.unop_inj, dsimp, simp, }, }
/--
An equivalence between opposite categories gives an equivalence between the original categories.
-/
@[simps]
def unop (e : Cᵒᵖ ≌ Dᵒᵖ) : C ≌ D :=
{ functor := e.functor.unop,
inverse := e.inverse.unop,
unit_iso := (nat_iso.unop e.unit_iso).symm,
counit_iso := (nat_iso.unop e.counit_iso).symm,
functor_unit_iso_comp' := λ X, by { apply has_hom.hom.op_inj, dsimp, simp, }, }
end equivalence
/-- The equivalence between arrows of the form `A ⟶ B` and `B.unop ⟶ A.unop`. Useful for building
adjunctions.
Note that this (definitionally) gives variants
```
def op_equiv' (A : C) (B : Cᵒᵖ) : (opposite.op A ⟶ B) ≃ (B.unop ⟶ A) :=
op_equiv _ _
def op_equiv'' (A : Cᵒᵖ) (B : C) : (A ⟶ opposite.op B) ≃ (B ⟶ A.unop) :=
op_equiv _ _
def op_equiv''' (A B : C) : (opposite.op A ⟶ opposite.op B) ≃ (B ⟶ A) :=
op_equiv _ _
```
-/
def op_equiv (A B : Cᵒᵖ) : (A ⟶ B) ≃ (B.unop ⟶ A.unop) :=
{ to_fun := λ f, f.unop,
inv_fun := λ g, g.op,
left_inv := λ _, rfl,
right_inv := λ _, rfl }
-- These two are made by hand rather than by simps because simps generates
-- `(op_equiv _ _).to_fun f = ...` rather than the coercion version.
@[simp]
lemma op_equiv_apply (A B : Cᵒᵖ) (f : A ⟶ B) : op_equiv _ _ f = f.unop :=
rfl
@[simp]
lemma op_equiv_symm_apply (A B : Cᵒᵖ) (f : B.unop ⟶ A.unop) : (op_equiv _ _).symm f = f.op :=
rfl
universes v
variables {α : Type v} [preorder α]
/-- Construct a morphism in the opposite of a preorder category from an inequality. -/
def op_hom_of_le {U V : αᵒᵖ} (h : unop V ≤ unop U) : U ⟶ V :=
has_hom.hom.op (hom_of_le h)
lemma le_of_op_hom {U V : αᵒᵖ} (h : U ⟶ V) : unop V ≤ unop U :=
le_of_hom (h.unop)
end category_theory
|
a9df0ceb2cb98bb4e056926df2eb672be72a4635 | 82e44445c70db0f03e30d7be725775f122d72f3e | /src/data/setoid/partition.lean | 4bb071b6d7e50d5f797f7eccc2bc7d1f1c27c5de | [
"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 | 14,864 | lean | /-
Copyright (c) 2019 Amelia Livingston. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Bryan Gin-ge Chen, Patrick Massot
-/
import data.setoid.basic
import data.set.lattice
/-!
# Equivalence relations: partitions
This file comprises properties of equivalence relations viewed as partitions.
There are two implementations of partitions here:
* A collection `c : set (set α)` of sets is a partition of `α` if `∅ ∉ c` and each element `a : α`
belongs to a unique set `b ∈ c`. This is expressed as `is_partition c`
* An indexed partition is a map `s : ι → α` whose image is a partition. This is
expressed as `indexed_partition s`.
Of course both implementations are related to `quotient` and `setoid`.
## Tags
setoid, equivalence, iseqv, relation, equivalence relation, partition, equivalence class
-/
namespace setoid
variables {α : Type*}
/-- If x ∈ α is in 2 elements of a set of sets partitioning α, those 2 sets are equal. -/
lemma eq_of_mem_eqv_class {c : set (set α)} (H : ∀ a, ∃! b ∈ c, a ∈ b)
{x b b'} (hc : b ∈ c) (hb : x ∈ b) (hc' : b' ∈ c) (hb' : x ∈ b') :
b = b' :=
(H x).unique2 hc hb hc' hb'
/-- Makes an equivalence relation from a set of sets partitioning α. -/
def mk_classes (c : set (set α)) (H : ∀ a, ∃! b ∈ c, a ∈ b) :
setoid α :=
⟨λ x y, ∀ s ∈ c, x ∈ s → y ∈ s, ⟨λ _ _ _ hx, hx,
λ x y h s hs hy, (H x).elim2 $ λ t ht hx _,
have s = t, from eq_of_mem_eqv_class H hs hy ht (h t ht hx),
this.symm ▸ hx,
λ x y z h1 h2 s hs hx, (H y).elim2 $ λ t ht hy _, (H z).elim2 $ λ t' ht' hz _,
have hst : s = t, from eq_of_mem_eqv_class H hs (h1 _ hs hx) ht hy,
have htt' : t = t', from eq_of_mem_eqv_class H ht (h2 _ ht hy) ht' hz,
(hst.trans htt').symm ▸ hz⟩⟩
/-- Makes the equivalence classes of an equivalence relation. -/
def classes (r : setoid α) : set (set α) :=
{s | ∃ y, s = {x | r.rel x y}}
lemma mem_classes (r : setoid α) (y) : {x | r.rel x y} ∈ r.classes := ⟨y, rfl⟩
/-- Two equivalence relations are equal iff all their equivalence classes are equal. -/
lemma eq_iff_classes_eq {r₁ r₂ : setoid α} :
r₁ = r₂ ↔ ∀ x, {y | r₁.rel x y} = {y | r₂.rel x y} :=
⟨λ h x, h ▸ rfl, λ h, ext' $ λ x, set.ext_iff.1 $ h x⟩
lemma rel_iff_exists_classes (r : setoid α) {x y} :
r.rel x y ↔ ∃ c ∈ r.classes, x ∈ c ∧ y ∈ c :=
⟨λ h, ⟨_, r.mem_classes y, h, r.refl' y⟩,
λ ⟨c, ⟨z, hz⟩, hx, hy⟩, by { subst c, exact r.trans' hx (r.symm' hy) }⟩
/-- Two equivalence relations are equal iff their equivalence classes are equal. -/
lemma classes_inj {r₁ r₂ : setoid α} :
r₁ = r₂ ↔ r₁.classes = r₂.classes :=
⟨λ h, h ▸ rfl, λ h, ext' $ λ a b, by simp only [rel_iff_exists_classes, exists_prop, h] ⟩
/-- The empty set is not an equivalence class. -/
lemma empty_not_mem_classes {r : setoid α} : ∅ ∉ r.classes :=
λ ⟨y, hy⟩, set.not_mem_empty y $ hy.symm ▸ r.refl' y
/-- Equivalence classes partition the type. -/
lemma classes_eqv_classes {r : setoid α} (a) : ∃! b ∈ r.classes, a ∈ b :=
exists_unique.intro2 {x | r.rel x a} (r.mem_classes a) (r.refl' _) $
begin
rintros _ ⟨y, rfl⟩ ha,
ext x,
exact ⟨λ hx, r.trans' hx (r.symm' ha), λ hx, r.trans' hx ha⟩
end
/-- If x ∈ α is in 2 equivalence classes, the equivalence classes are equal. -/
lemma eq_of_mem_classes {r : setoid α} {x b} (hc : b ∈ r.classes)
(hb : x ∈ b) {b'} (hc' : b' ∈ r.classes) (hb' : x ∈ b') : b = b' :=
eq_of_mem_eqv_class classes_eqv_classes hc hb hc' hb'
/-- The elements of a set of sets partitioning α are the equivalence classes of the
equivalence relation defined by the set of sets. -/
lemma eq_eqv_class_of_mem {c : set (set α)}
(H : ∀ a, ∃! b ∈ c, a ∈ b) {s y} (hs : s ∈ c) (hy : y ∈ s) :
s = {x | (mk_classes c H).rel x y} :=
set.ext $ λ x,
⟨λ hs', symm' (mk_classes c H) $ λ b' hb' h', eq_of_mem_eqv_class H hs hy hb' h' ▸ hs',
λ hx, (H x).elim2 $ λ b' hc' hb' h',
(eq_of_mem_eqv_class H hs hy hc' $ hx b' hc' hb').symm ▸ hb'⟩
/-- The equivalence classes of the equivalence relation defined by a set of sets
partitioning α are elements of the set of sets. -/
lemma eqv_class_mem {c : set (set α)} (H : ∀ a, ∃! b ∈ c, a ∈ b) {y} :
{x | (mk_classes c H).rel x y} ∈ c :=
(H y).elim2 $ λ b hc hy hb, eq_eqv_class_of_mem H hc hy ▸ hc
lemma eqv_class_mem' {c : set (set α)} (H : ∀ a, ∃! b ∈ c, a ∈ b) {x} :
{y : α | (mk_classes c H).rel x y} ∈ c :=
by { convert setoid.eqv_class_mem H, ext, rw setoid.comm' }
/-- Distinct elements of a set of sets partitioning α are disjoint. -/
lemma eqv_classes_disjoint {c : set (set α)} (H : ∀ a, ∃! b ∈ c, a ∈ b) :
set.pairwise_disjoint c :=
λ b₁ h₁ b₂ h₂ h, set.disjoint_left.2 $
λ x hx1 hx2, (H x).elim2 $ λ b hc hx hb, h $ eq_of_mem_eqv_class H h₁ hx1 h₂ hx2
/-- A set of disjoint sets covering α partition α (classical). -/
lemma eqv_classes_of_disjoint_union {c : set (set α)}
(hu : set.sUnion c = @set.univ α) (H : set.pairwise_disjoint c) (a) :
∃! b ∈ c, a ∈ b :=
let ⟨b, hc, ha⟩ := set.mem_sUnion.1 $ show a ∈ _, by rw hu; exact set.mem_univ a in
exists_unique.intro2 b hc ha $ λ b' hc' ha', H.elim hc' hc a ha' ha
/-- Makes an equivalence relation from a set of disjoints sets covering α. -/
def setoid_of_disjoint_union {c : set (set α)} (hu : set.sUnion c = @set.univ α)
(H : set.pairwise_disjoint c) : setoid α :=
setoid.mk_classes c $ eqv_classes_of_disjoint_union hu H
/-- The equivalence relation made from the equivalence classes of an equivalence
relation r equals r. -/
theorem mk_classes_classes (r : setoid α) :
mk_classes r.classes classes_eqv_classes = r :=
ext' $ λ x y, ⟨λ h, r.symm' (h {z | r.rel z x} (r.mem_classes x) $ r.refl' x),
λ h b hb hx, eq_of_mem_classes (r.mem_classes x) (r.refl' x) hb hx ▸ r.symm' h⟩
@[simp] theorem sUnion_classes (r : setoid α) : ⋃₀ r.classes = set.univ :=
set.eq_univ_of_forall $ λ x, set.mem_sUnion.2 ⟨{ y | r.rel y x }, ⟨x, rfl⟩, setoid.refl _⟩
section partition
/-- A collection `c : set (set α)` of sets is a partition of `α` into pairwise
disjoint sets if `∅ ∉ c` and each element `a : α` belongs to a unique set `b ∈ c`. -/
def is_partition (c : set (set α)) :=
∅ ∉ c ∧ ∀ a, ∃! b ∈ c, a ∈ b
/-- A partition of `α` does not contain the empty set. -/
lemma nonempty_of_mem_partition {c : set (set α)} (hc : is_partition c) {s} (h : s ∈ c) :
s.nonempty :=
set.ne_empty_iff_nonempty.1 $ λ hs0, hc.1 $ hs0 ▸ h
lemma is_partition_classes (r : setoid α) : is_partition r.classes :=
⟨empty_not_mem_classes, classes_eqv_classes⟩
lemma is_partition.pairwise_disjoint {c : set (set α)} (hc : is_partition c) :
c.pairwise_disjoint :=
eqv_classes_disjoint hc.2
lemma is_partition.sUnion_eq_univ {c : set (set α)} (hc : is_partition c) :
⋃₀ c = set.univ :=
set.eq_univ_of_forall $ λ x, set.mem_sUnion.2 $
let ⟨t, ht⟩ := hc.2 x in ⟨t, by clear_aux_decl; finish⟩
/-- All elements of a partition of α are the equivalence class of some y ∈ α. -/
lemma exists_of_mem_partition {c : set (set α)} (hc : is_partition c) {s} (hs : s ∈ c) :
∃ y, s = {x | (mk_classes c hc.2).rel x y} :=
let ⟨y, hy⟩ := nonempty_of_mem_partition hc hs in
⟨y, eq_eqv_class_of_mem hc.2 hs hy⟩
/-- The equivalence classes of the equivalence relation defined by a partition of α equal
the original partition. -/
theorem classes_mk_classes (c : set (set α)) (hc : is_partition c) :
(mk_classes c hc.2).classes = c :=
set.ext $ λ s,
⟨λ ⟨y, hs⟩, (hc.2 y).elim2 $ λ b hm hb hy,
by rwa (show s = b, from hs.symm ▸ set.ext
(λ x, ⟨λ hx, symm' (mk_classes c hc.2) hx b hm hb,
λ hx b' hc' hx', eq_of_mem_eqv_class hc.2 hm hx hc' hx' ▸ hb⟩)),
exists_of_mem_partition hc⟩
/-- Defining `≤` on partitions as the `≤` defined on their induced equivalence relations. -/
instance partition.le : has_le (subtype (@is_partition α)) :=
⟨λ x y, mk_classes x.1 x.2.2 ≤ mk_classes y.1 y.2.2⟩
/-- Defining a partial order on partitions as the partial order on their induced
equivalence relations. -/
instance partition.partial_order : partial_order (subtype (@is_partition α)) :=
{ le := (≤),
lt := λ x y, x ≤ y ∧ ¬y ≤ x,
le_refl := λ _, @le_refl (setoid α) _ _,
le_trans := λ _ _ _, @le_trans (setoid α) _ _ _ _,
lt_iff_le_not_le := λ _ _, iff.rfl,
le_antisymm := λ x y hx hy, let h := @le_antisymm (setoid α) _ _ _ hx hy in by
rw [subtype.ext_iff_val, ←classes_mk_classes x.1 x.2, ←classes_mk_classes y.1 y.2, h] }
variables (α)
/-- The order-preserving bijection between equivalence relations and partitions of sets. -/
protected def partition.order_iso :
setoid α ≃o subtype (@is_partition α) :=
{ to_fun := λ r, ⟨r.classes, empty_not_mem_classes, classes_eqv_classes⟩,
inv_fun := λ x, mk_classes x.1 x.2.2,
left_inv := mk_classes_classes,
right_inv := λ x, by rw [subtype.ext_iff_val, ←classes_mk_classes x.1 x.2],
map_rel_iff' := λ x y,
by { conv_rhs { rw [←mk_classes_classes x, ←mk_classes_classes y] }, refl } }
variables {α}
/-- A complete lattice instance for partitions; there is more infrastructure for the
equivalent complete lattice on equivalence relations. -/
instance partition.complete_lattice : complete_lattice (subtype (@is_partition α)) :=
galois_insertion.lift_complete_lattice $ @order_iso.to_galois_insertion
_ (subtype (@is_partition α)) _ (partial_order.to_preorder _) $ partition.order_iso α
end partition
end setoid
/-- Constructive information associated with a partition of a type `α` indexed by another type `ι`,
`s : ι → set α`.
`indexed_partition.index` sends an element to its index, while `indexed_partition.some` sends
an index to an element of the corresponding set.
This type is primarily useful for definitional control of `s` - if this is not needed, then
`setoid.ker index` by itself may be sufficient. -/
structure indexed_partition {ι α : Type*} (s : ι → set α) :=
(eq_of_mem : ∀ {x i j}, x ∈ s i → x ∈ s j → i = j)
(some : ι → α)
(some_mem : ∀ i, some i ∈ s i)
(index : α → ι)
(mem_index : ∀ x, x ∈ s (index x))
/-- The non-constructive constructor for `indexed_partition`. -/
noncomputable
def indexed_partition.mk' {ι α : Type*} (s : ι → set α) (dis : ∀ i j, i ≠ j → disjoint (s i) (s j))
(nonempty : ∀ i, (s i).nonempty) (ex : ∀ x, ∃ i, x ∈ s i) : indexed_partition s :=
{ eq_of_mem := λ x i j hxi hxj, classical.by_contradiction $ λ h, dis _ _ h ⟨hxi, hxj⟩,
some := λ i, (nonempty i).some,
some_mem := λ i, (nonempty i).some_spec,
index := λ x, (ex x).some,
mem_index := λ x, (ex x).some_spec }
namespace indexed_partition
open set
variables {ι α : Type*} {s : ι → set α} (hs : indexed_partition s)
/-- On a unique index set there is the obvious trivial partition -/
instance [unique ι] [inhabited α] :
inhabited (indexed_partition (λ i : ι, (set.univ : set α))) :=
⟨{ eq_of_mem := λ x i j hi hj, subsingleton.elim _ _,
some := λ i, default α,
some_mem := set.mem_univ,
index := λ a, default ι,
mem_index := set.mem_univ }⟩
attribute [simp] some_mem mem_index
include hs
lemma exists_mem (x : α) : ∃ i, x ∈ s i := ⟨hs.index x, hs.mem_index x⟩
lemma Union : (⋃ i, s i) = univ :=
by { ext x, simp [hs.exists_mem x] }
lemma disjoint : ∀ {i j}, i ≠ j → disjoint (s i) (s j) :=
λ i j h x ⟨hxi, hxj⟩, h (hs.eq_of_mem hxi hxj)
lemma mem_iff_index_eq {x i} : x ∈ s i ↔ hs.index x = i :=
⟨λ hxi, (hs.eq_of_mem hxi (hs.mem_index x)).symm, λ h, h ▸ hs.mem_index _⟩
lemma eq (i) : s i = {x | hs.index x = i} :=
set.ext $ λ _, hs.mem_iff_index_eq
/-- The equivalence relation associated to an indexed partition. Two
elements are equivalent if they belong to the same set of the partition. -/
protected abbreviation setoid (hs : indexed_partition s) : setoid α :=
setoid.ker hs.index
@[simp] lemma index_some (i : ι) : hs.index (hs.some i) = i :=
(mem_iff_index_eq _).1 $ hs.some_mem i
lemma some_index (x : α) : hs.setoid.rel (hs.some (hs.index x)) x :=
hs.index_some (hs.index x)
/-- The quotient associated to an indexed partition. -/
protected def quotient := quotient hs.setoid
/-- The projection onto the quotient associated to an indexed partition. -/
def proj : α → hs.quotient := quotient.mk'
instance [inhabited α] : inhabited (hs.quotient) := ⟨hs.proj (default α)⟩
lemma proj_eq_iff {x y : α} : hs.proj x = hs.proj y ↔ hs.index x = hs.index y :=
quotient.eq_rel
@[simp] lemma proj_some_index (x : α) : hs.proj (hs.some (hs.index x)) = hs.proj x :=
quotient.eq'.2 (hs.some_index x)
/-- The obvious equivalence between the quotient associated to an indexed partition and
the indexing type. -/
def equiv_quotient : ι ≃ hs.quotient :=
(setoid.quotient_ker_equiv_of_right_inverse hs.index hs.some $ hs.index_some).symm
@[simp] lemma equiv_quotient_index_apply (x : α) : hs.equiv_quotient (hs.index x) = hs.proj x :=
hs.proj_eq_iff.mpr (some_index hs x)
@[simp] lemma equiv_quotient_symm_proj_apply (x : α) :
hs.equiv_quotient.symm (hs.proj x) = hs.index x :=
rfl
lemma equiv_quotient_index : hs.equiv_quotient ∘ hs.index = hs.proj :=
funext hs.equiv_quotient_index_apply
/-- A map choosing a representative for each element of the quotient associated to an indexed
partition. This is a computable version of `quotient.out'` using `indexed_partition.some`. -/
def out : hs.quotient ↪ α :=
hs.equiv_quotient.symm.to_embedding.trans ⟨hs.some, function.left_inverse.injective hs.index_some⟩
/-- This lemma is analogous to `quotient.mk_out'`. -/
@[simp]
lemma out_proj (x : α) : hs.out (hs.proj x) = hs.some (hs.index x) :=
rfl
/-- The indices of `quotient.out'` and `indexed_partition.out` are equal. -/
lemma index_out' (x : hs.quotient) : hs.index (x.out') = hs.index (hs.out x) :=
quotient.induction_on' x $ λ x, (setoid.ker_apply_mk_out' x).trans (hs.index_some _).symm
/-- This lemma is analogous to `quotient.out_eq'`. -/
@[simp] lemma proj_out (x : hs.quotient) : hs.proj (hs.out x) = x :=
quotient.induction_on' x $ λ x, quotient.sound' $ hs.some_index x
lemma class_of {x : α} : set_of (hs.setoid.rel x) = s (hs.index x) :=
set.ext $ λ y, eq_comm.trans hs.mem_iff_index_eq.symm
lemma proj_fiber (x : hs.quotient) : hs.proj ⁻¹' {x} = s (hs.equiv_quotient.symm x) :=
quotient.induction_on' x $ λ x, begin
ext y,
simp only [set.mem_preimage, set.mem_singleton_iff, hs.mem_iff_index_eq],
exact quotient.eq',
end
end indexed_partition
|
681cd90bd41e41f5f4eb31e0f6f6242cc9c0706a | 6dc0c8ce7a76229dd81e73ed4474f15f88a9e294 | /stage0/src/Lean/Meta/Tactic/Cases.lean | acdb7eed1532fba7bfeae4378cd1291ae27332ca | [
"Apache-2.0"
] | permissive | williamdemeo/lean4 | 72161c58fe65c3ad955d6a3050bb7d37c04c0d54 | 6d00fcf1d6d873e195f9220c668ef9c58e9c4a35 | refs/heads/master | 1,678,305,356,877 | 1,614,708,995,000 | 1,614,708,995,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 14,481 | lean | /-
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Lean.Meta.AppBuilder
import Lean.Meta.Tactic.Induction
import Lean.Meta.Tactic.Injection
import Lean.Meta.Tactic.Assert
import Lean.Meta.Tactic.Subst
namespace Lean.Meta
private def throwInductiveTypeExpected {α} (type : Expr) : MetaM α := do
throwError! "failed to compile pattern matching, inductive type expected{indentExpr type}"
def getInductiveUniverseAndParams (type : Expr) : MetaM (List Level × Array Expr) := do
let type ← whnfD type
matchConstInduct type.getAppFn (fun _ => throwInductiveTypeExpected type) fun val us =>
let I := type.getAppFn
let Iargs := type.getAppArgs
let params := Iargs.extract 0 val.numParams
pure (us, params)
private def mkEqAndProof (lhs rhs : Expr) : MetaM (Expr × Expr) := do
let lhsType ← inferType lhs
let rhsType ← inferType rhs
let u ← getLevel lhsType
if (← isDefEq lhsType rhsType) then
pure (mkApp3 (mkConst `Eq [u]) lhsType lhs rhs, mkApp2 (mkConst `Eq.refl [u]) lhsType lhs)
else
pure (mkApp4 (mkConst `HEq [u]) lhsType lhs rhsType rhs, mkApp2 (mkConst `HEq.refl [u]) lhsType lhs)
private partial def withNewEqs {α} (targets targetsNew : Array Expr) (k : Array Expr → Array Expr → MetaM α) : MetaM α :=
let rec loop (i : Nat) (newEqs : Array Expr) (newRefls : Array Expr) := do
if h : i < targets.size then
let (newEqType, newRefl) ← mkEqAndProof targets[i] targetsNew[i]
withLocalDeclD `h newEqType fun newEq => do
loop (i+1) (newEqs.push newEq) (newRefls.push newRefl)
else
k newEqs newRefls
loop 0 #[] #[]
def generalizeTargets (mvarId : MVarId) (motiveType : Expr) (targets : Array Expr) : MetaM MVarId :=
withMVarContext mvarId do
checkNotAssigned mvarId `generalizeTargets
let (typeNew, eqRefls) ←
forallTelescopeReducing motiveType fun targetsNew _ => do
unless targetsNew.size == targets.size do
throwError! "invalid number of targets #{targets.size}, motive expects #{targetsNew.size}"
withNewEqs targets targetsNew fun eqs eqRefls => do
let type ← getMVarType mvarId
let typeNew ← mkForallFVars eqs type
let typeNew ← mkForallFVars targetsNew typeNew
pure (typeNew, eqRefls)
let mvarNew ← mkFreshExprSyntheticOpaqueMVar typeNew (← getMVarTag mvarId)
assignExprMVar mvarId (mkAppN (mkAppN mvarNew targets) eqRefls)
pure mvarNew.mvarId!
structure GeneralizeIndicesSubgoal where
mvarId : MVarId
indicesFVarIds : Array FVarId
fvarId : FVarId
numEqs : Nat
/--
Similar to `generalizeTargets` but customized for the `casesOn` motive.
Given a metavariable `mvarId` representing the
```
Ctx, h : I A j, D |- T
```
where `fvarId` is `h`s id, and the type `I A j` is an inductive datatype where `A` are parameters,
and `j` the indices. Generate the goal
```
Ctx, h : I A j, D, j' : J, h' : I A j' |- j == j' -> h == h' -> T
```
Remark: `(j == j' -> h == h')` is a "telescopic" equality.
Remark: `j` is sequence of terms, and `j'` a sequence of free variables.
The result contains the fields
- `mvarId`: the new goal
- `indicesFVarIds`: `j'` ids
- `fvarId`: `h'` id
- `numEqs`: number of equations in the target -/
def generalizeIndices (mvarId : MVarId) (fvarId : FVarId) : MetaM GeneralizeIndicesSubgoal :=
withMVarContext mvarId do
let lctx ← getLCtx
let localInsts ← getLocalInstances
checkNotAssigned mvarId `generalizeIndices
let fvarDecl ← getLocalDecl fvarId
let type ← whnf fvarDecl.type
type.withApp fun f args => matchConstInduct f (fun _ => throwTacticEx `generalizeIndices mvarId "inductive type expected") fun val _ => do
unless val.numIndices > 0 do throwTacticEx `generalizeIndices mvarId "indexed inductive type expected"
unless args.size == val.numIndices + val.numParams do throwTacticEx `generalizeIndices mvarId "ill-formed inductive datatype"
let indices := args.extract (args.size - val.numIndices) args.size
let IA := mkAppN f (args.extract 0 val.numParams) -- `I A`
let IAType ← inferType IA
forallTelescopeReducing IAType fun newIndices _ => do
let newType := mkAppN IA newIndices
withLocalDeclD fvarDecl.userName newType fun h' =>
withNewEqs indices newIndices fun newEqs newRefls => do
let (newEqType, newRefl) ← mkEqAndProof fvarDecl.toExpr h'
let newRefls := newRefls.push newRefl
withLocalDeclD `h newEqType fun newEq => do
let newEqs := newEqs.push newEq
/- auxType `forall (j' : J) (h' : I A j'), j == j' -> h == h' -> target -/
let target ← getMVarType mvarId
let tag ← getMVarTag mvarId
let auxType ← mkForallFVars newEqs target
let auxType ← mkForallFVars #[h'] auxType
let auxType ← mkForallFVars newIndices auxType
let newMVar ← mkFreshExprMVarAt lctx localInsts auxType MetavarKind.syntheticOpaque tag
/- assign mvarId := newMVar indices h refls -/
assignExprMVar mvarId (mkAppN (mkApp (mkAppN newMVar indices) fvarDecl.toExpr) newRefls)
let (indicesFVarIds, newMVarId) ← introNP newMVar.mvarId! newIndices.size
let (fvarId, newMVarId) ← intro1P newMVarId
pure {
mvarId := newMVarId,
indicesFVarIds := indicesFVarIds,
fvarId := fvarId,
numEqs := newEqs.size
}
structure CasesSubgoal extends InductionSubgoal where
ctorName : Name
namespace Cases
structure Context where
inductiveVal : InductiveVal
casesOnVal : DefinitionVal
nminors : Nat := inductiveVal.ctors.length
majorDecl : LocalDecl
majorTypeFn : Expr
majorTypeArgs : Array Expr
majorTypeIndices : Array Expr := majorTypeArgs.extract (majorTypeArgs.size - inductiveVal.numIndices) majorTypeArgs.size
private def mkCasesContext? (majorFVarId : FVarId) : MetaM (Option Context) := do
let env ← getEnv
if !env.contains `Eq || !env.contains `HEq then
pure none
else
let majorDecl ← getLocalDecl majorFVarId
let majorType ← whnf majorDecl.type
majorType.withApp fun f args => matchConstInduct f (fun _ => pure none) fun ival _ =>
if args.size != ival.numIndices + ival.numParams then pure none
else match env.find? (Name.mkStr ival.name "casesOn") with
| ConstantInfo.defnInfo cval =>
pure $ some {
inductiveVal := ival,
casesOnVal := cval,
majorDecl := majorDecl,
majorTypeFn := f,
majorTypeArgs := args
}
| _ => pure none
/-
We say the major premise has independent indices IF
1- its type is *not* an indexed inductive family, OR
2- its type is an indexed inductive family, but all indices are distinct free variables, and
all local declarations different from the major and its indices do not depend on the indices.
-/
private def hasIndepIndices (ctx : Context) : MetaM Bool := do
if ctx.majorTypeIndices.isEmpty then
pure true
else if ctx.majorTypeIndices.any $ fun idx => !idx.isFVar then
/- One of the indices is not a free variable. -/
pure false
else if ctx.majorTypeIndices.size.any fun i => i.any fun j => ctx.majorTypeIndices[i] == ctx.majorTypeIndices[j] then
/- An index ocurrs more than once -/
pure false
else
let lctx ← getLCtx
let mctx ← getMCtx
pure $ lctx.all fun decl =>
decl.fvarId == ctx.majorDecl.fvarId || -- decl is the major
ctx.majorTypeIndices.any (fun index => decl.fvarId == index.fvarId!) || -- decl is one of the indices
mctx.findLocalDeclDependsOn decl (fun fvarId => ctx.majorTypeIndices.all $ fun idx => idx.fvarId! != fvarId) -- or does not depend on any index
private def elimAuxIndices (s₁ : GeneralizeIndicesSubgoal) (s₂ : Array CasesSubgoal) : MetaM (Array CasesSubgoal) :=
let indicesFVarIds := s₁.indicesFVarIds
s₂.mapM fun s => do
indicesFVarIds.foldlM (init := s) fun s indexFVarId =>
match s.subst.get indexFVarId with
| Expr.fvar indexFVarId' _ =>
(do let mvarId ← clear s.mvarId indexFVarId'; pure { s with mvarId := mvarId, subst := s.subst.erase indexFVarId })
<|>
(pure s)
| _ => pure s
/-
Convert `s` into an array of `CasesSubgoal`, by attaching the corresponding constructor name,
and adding the substitution `majorFVarId -> ctor_i us params fields` into each subgoal. -/
private def toCasesSubgoals (s : Array InductionSubgoal) (ctorNames : Array Name) (majorFVarId : FVarId) (us : List Level) (params : Array Expr)
: Array CasesSubgoal :=
s.mapIdx fun i s =>
let ctorName := ctorNames[i]
let ctorApp := mkAppN (mkAppN (mkConst ctorName us) params) s.fields
let s := { s with subst := s.subst.insert majorFVarId ctorApp }
{ ctorName := ctorName,
toInductionSubgoal := s }
/- Convert heterogeneous equality into a homegeneous one -/
private def heqToEq (mvarId : MVarId) (eqDecl : LocalDecl) : MetaM MVarId := do
/- Convert heterogeneous equality into a homegeneous one -/
let prf ← mkEqOfHEq (mkFVar eqDecl.fvarId)
let aEqb ← whnf (← inferType prf)
let mvarId ← assert mvarId eqDecl.userName aEqb prf
clear mvarId eqDecl.fvarId
partial def unifyEqs (numEqs : Nat) (mvarId : MVarId) (subst : FVarSubst) : MetaM (Option (MVarId × FVarSubst)) := do
if numEqs == 0 then
pure (some (mvarId, subst))
else
let (eqFVarId, mvarId) ← intro1 mvarId
withMVarContext mvarId do
let eqDecl ← getLocalDecl eqFVarId
if eqDecl.type.isHEq then
let mvarId ← heqToEq mvarId eqDecl
unifyEqs numEqs mvarId subst
else match eqDecl.type.eq? with
| none => throwError! "equality expected{indentExpr eqDecl.type}"
| some (α, a, b) =>
if (← isDefEq a b) then
/- Skip equality -/
unifyEqs (numEqs - 1) (← clear mvarId eqFVarId) subst
else
-- Remark: we use `let rec` here because otherwise the compiler would generate an insane amount of code.
-- We can remove the `rec` after we fix the eagerly inlining issue in the compiler.
let rec substEq (symm : Bool) := do
/- TODO: support for acyclicity (e.g., `xs ≠ x :: xs`) -/
let (substNew, mvarId) ← substCore mvarId eqFVarId symm subst
unifyEqs (numEqs - 1) mvarId substNew
let rec injection (a b : Expr) := do
let env ← getEnv
if a.isConstructorApp env && b.isConstructorApp env then
/- ctor_i ... = ctor_j ... -/
match (← injectionCore mvarId eqFVarId) with
| InjectionResultCore.solved => pure none -- this alternative has been solved
| InjectionResultCore.subgoal mvarId numEqsNew => unifyEqs (numEqs - 1 + numEqsNew) mvarId subst
else
let a' ← whnf a
let b' ← whnf b
if a' != a || b' != b then
/- Reduced lhs/rhs of current equality -/
let prf := mkFVar eqFVarId
let aEqb' ← mkEq a' b'
let mvarId ← assert mvarId eqDecl.userName aEqb' prf
let mvarId ← clear mvarId eqFVarId
unifyEqs numEqs mvarId subst
else
throwError! "dependent elimination failed, stuck at auxiliary equation{indentExpr eqDecl.type}"
match a, b with
| Expr.fvar aFVarId _, Expr.fvar bFVarId _ =>
/- x = y -/
let aDecl ← getLocalDecl aFVarId
let bDecl ← getLocalDecl bFVarId
substEq (aDecl.index < bDecl.index)
| Expr.fvar .., _ => /- x = t -/ substEq (symm := false)
| _, Expr.fvar .. => /- t = x -/ substEq (symm := true)
| a, b => injection a b
private def unifyCasesEqs (numEqs : Nat) (subgoals : Array CasesSubgoal) : MetaM (Array CasesSubgoal) :=
subgoals.foldlM (init := #[]) fun subgoals s => do
match (← unifyEqs numEqs s.mvarId s.subst) with
| none => pure subgoals
| some (mvarId, subst) =>
pure $ subgoals.push { s with
mvarId := mvarId,
subst := subst,
fields := s.fields.map (subst.apply ·)
}
private def inductionCasesOn (mvarId : MVarId) (majorFVarId : FVarId) (givenNames : Array AltVarNames) (ctx : Context)
: MetaM (Array CasesSubgoal) := do
withMVarContext mvarId do
let majorType ← inferType (mkFVar majorFVarId)
let (us, params) ← getInductiveUniverseAndParams majorType
let casesOn := mkCasesOnName ctx.inductiveVal.name
let ctors := ctx.inductiveVal.ctors.toArray
let s ← induction mvarId majorFVarId casesOn givenNames
pure $ toCasesSubgoals s ctors majorFVarId us params
def cases (mvarId : MVarId) (majorFVarId : FVarId) (givenNames : Array AltVarNames := #[]) : MetaM (Array CasesSubgoal) :=
withMVarContext mvarId do
checkNotAssigned mvarId `cases
let context? ← mkCasesContext? majorFVarId
match context? with
| none => throwTacticEx `cases mvarId "not applicable to the given hypothesis"
| some ctx =>
/- Remark: if caller does not need a `FVarSubst` (variable substitution), and `hasIndepIndices ctx` is true,
then we can also use the simple case. This is a minor optimization, and we currently do not even
allow callers to specify whether they want the `FVarSubst` or not. -/
if ctx.inductiveVal.numIndices == 0 then
-- Simple case
inductionCasesOn mvarId majorFVarId givenNames ctx
else
let s₁ ← generalizeIndices mvarId majorFVarId
trace[Meta.Tactic.cases]! "after generalizeIndices\n{MessageData.ofGoal s₁.mvarId}"
let s₂ ← inductionCasesOn s₁.mvarId s₁.fvarId givenNames ctx
let s₂ ← elimAuxIndices s₁ s₂
unifyCasesEqs s₁.numEqs s₂
end Cases
def cases (mvarId : MVarId) (majorFVarId : FVarId) (givenNames : Array AltVarNames := #[]) : MetaM (Array CasesSubgoal) :=
Cases.cases mvarId majorFVarId givenNames
builtin_initialize registerTraceClass `Meta.Tactic.cases
end Lean.Meta
|
3c776272bf7a268162aca432a36cc60f08ebf3f2 | b9a81ebb9de684db509231c4469a7d2c88915808 | /src/super/factoring.lean | c29e5bc8a272dbd8a0f5dae700b933bfdd84ab3b | [] | no_license | leanprover/super | 3dd81ce8d9ac3cba20bce55e84833fadb2f5716e | 47b107b4cec8f3b41d72daba9cbda2f9d54025de | refs/heads/master | 1,678,482,996,979 | 1,676,526,367,000 | 1,676,526,367,000 | 92,215,900 | 12 | 6 | null | 1,513,327,539,000 | 1,495,570,640,000 | Lean | UTF-8 | Lean | false | false | 1,827 | lean | /-
Copyright (c) 2017 Gabriel Ebner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner
-/
import .clause .prover_state .subsumption
open tactic expr monad
namespace super
variable gt : expr → expr → bool
meta def inst_lit (c : clause) (i : nat) (e : expr) : tactic clause := do
opened ← clause.open_constn c i,
return $ clause.close_constn (clause.inst opened.1 e) opened.2
private meta def try_factor' (c : clause) (i j : nat) : tactic clause := do
-- instantiate universal quantifiers using meta-variables
(qf, mvars) ← c.open_metan c.num_quants,
-- unify the two literals
unify_lit (qf.get_lit i) (qf.get_lit j),
-- check maximality condition
qfi ← qf.inst_mvars, guard $ clause.is_maximal gt qfi i,
-- construct proof
(at_j, cs) ← qf.open_constn j, hyp_i ← cs.nth i,
let qf' := (at_j.inst hyp_i).close_constn cs,
-- instantiate meta-variables and replace remaining meta-variables by quantifiers
clause.meta_closure mvars qf'
meta def try_factor (c : clause) (i j : nat) : tactic clause :=
if i > j then try_factor' gt c j i else try_factor' gt c i j
meta def try_infer_factor (c : derived_clause) (i j : nat) : prover unit := do
f ← try_factor gt c.c i j,
ss ← does_subsume f c.c,
if ss then do
f ← mk_derived f c.sc.sched_now,
add_inferred f,
remove_redundant c.id [f]
else do
inf_score 1 [c.sc] >>= mk_derived f >>= add_inferred
@[super.inf]
meta def factor_inf : inf_decl := inf_decl.mk 40 $
assume given, do gt ← get_term_order, sequence' $ do
i ← given.selected,
j ← list.range given.c.num_lits,
return $ try_infer_factor gt given i j <|> return ()
meta def factor_dup_lits_pre := preprocessing_rule $ assume new, do
new.mmap $ λdc, do
dist ← dc.c.distinct,
return { dc with c := dist }
end super
|
940f000d46e7a7c1d71fac5d7216f7cc196f565d | f083c4ed5d443659f3ed9b43b1ca5bb037ddeb58 | /logic/embedding.lean | 1baace2d0260770046b88b224bc7a523454d7436 | [
"Apache-2.0"
] | permissive | semorrison/mathlib | 1be6f11086e0d24180fec4b9696d3ec58b439d10 | 20b4143976dad48e664c4847b75a85237dca0a89 | refs/heads/master | 1,583,799,212,170 | 1,535,634,130,000 | 1,535,730,505,000 | 129,076,205 | 0 | 0 | Apache-2.0 | 1,551,697,998,000 | 1,523,442,265,000 | Lean | UTF-8 | Lean | false | false | 5,734 | 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
Injective functions.
-/
import data.equiv.basic
universes u v w x
namespace function
structure embedding (α : Sort*) (β : Sort*) :=
(to_fun : α → β)
(inj : injective to_fun)
infixr ` ↪ `:25 := embedding
instance {α : Sort u} {β : Sort v} : has_coe_to_fun (α ↪ β) := ⟨_, embedding.to_fun⟩
end function
protected def equiv.to_embedding {α : Sort u} {β : Sort v} (f : α ≃ β) : α ↪ β :=
⟨f, f.bijective.1⟩
@[simp] theorem equiv.to_embedding_coe_fn {α : Sort u} {β : Sort v} (f : α ≃ β) :
(f.to_embedding : α → β) = f := rfl
namespace function
namespace embedding
@[simp] theorem to_fun_eq_coe {α β} (f : α ↪ β) : to_fun f = f := rfl
@[simp] theorem coe_fn_mk {α β} (f : α → β) (i) :
(@mk _ _ f i : α → β) = f := rfl
theorem inj' {α β} : ∀ (f : α ↪ β), injective f
| ⟨f, hf⟩ := hf
@[refl] protected def refl (α : Sort*) : α ↪ α :=
⟨id, injective_id⟩
@[trans] protected def trans {α β γ} (f : α ↪ β) (g : β ↪ γ) : α ↪ γ :=
⟨_, injective_comp g.inj' f.inj'⟩
@[simp] theorem refl_apply {α} (x : α) : embedding.refl α x = x := rfl
@[simp] theorem trans_apply {α β γ} (f : α ↪ β) (g : β ↪ γ) (a : α) :
(f.trans g) a = g (f a) := rfl
protected def congr {α : Sort u} {β : Sort v} {γ : Sort w} {δ : Sort x}
(e₁ : α ≃ β) (e₂ : γ ≃ δ) (f : α ↪ γ) : (β ↪ δ) :=
(equiv.to_embedding e₁.symm).trans (f.trans e₂.to_embedding)
protected noncomputable def of_surjective {α β} {f : β → α} (hf : surjective f) :
α ↪ β :=
⟨surj_inv hf, injective_surj_inv _⟩
protected noncomputable def equiv_of_surjective {α β} (f : α ↪ β) (hf : surjective f) :
α ≃ β :=
equiv.of_bijective ⟨f.inj, hf⟩
protected def of_not_nonempty {α β} (hα : ¬ nonempty α) : α ↪ β :=
⟨λa, (hα ⟨a⟩).elim, assume a, (hα ⟨a⟩).elim⟩
noncomputable def set_value {α β} (f : α ↪ β) (a : α) (b : β) : α ↪ β :=
by haveI := classical.dec; exact
if h : ∃ a', f a' = b then
(equiv.swap a (classical.some h)).to_embedding.trans f
else
⟨λ a', if a' = a then b else f a',
λ a₁ a₂ e, begin
simp at e, split_ifs at e with h₁ h₂,
{ cc },
{ cases h ⟨_, e.symm⟩ },
{ cases h ⟨_, e⟩ },
{ exact f.2 e }
end⟩
theorem set_value_eq {α β} (f : α ↪ β) (a : α) (b : β) : set_value f a b a = b :=
begin
rw [set_value],
cases classical.dec (∃ a', f a' = b);
dsimp [dite], {simp},
simp [equiv.swap_apply_left],
apply classical.some_spec h
end
def subtype {α} (p : α → Prop) : subtype p ↪ α :=
⟨subtype.val, λ _ _, subtype.eq'⟩
/-- Restrict the codomain of an embedding. -/
def cod_restrict {α β} (p : set β) (f : α ↪ β) (H : ∀ a, f a ∈ p) : α ↪ p :=
⟨λ a, ⟨f a, H a⟩, λ a b h, f.inj (@congr_arg _ _ _ _ subtype.val h)⟩
@[simp] theorem cod_restrict_apply {α β} (p) (f : α ↪ β) (H a) :
cod_restrict p f H a = ⟨f a, H a⟩ := rfl
def prod_congr {α β γ δ : Type*} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : α × γ ↪ β × δ :=
⟨assume ⟨a, b⟩, (e₁ a, e₂ b),
assume ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ h,
have a₁ = a₂ ∧ b₁ = b₂, from (prod.mk.inj h).imp (assume h, e₁.inj h) (assume h, e₂.inj h),
this.left ▸ this.right ▸ rfl⟩
section sum
open sum
def sum_congr {α β γ δ : Type*} (e₁ : α ↪ β) (e₂ : γ ↪ δ) : α ⊕ γ ↪ β ⊕ δ :=
⟨assume s, match s with inl a := inl (e₁ a) | inr b := inr (e₂ b) end,
assume s₁ s₂ h, match s₁, s₂, h with
| inl a₁, inl a₂, h := congr_arg inl $ e₁.inj $ inl.inj h
| inr b₁, inr b₂, h := congr_arg inr $ e₂.inj $ inr.inj h
end⟩
@[simp] theorem sum_congr_apply_inl {α β γ δ}
(e₁ : α ↪ β) (e₂ : γ ↪ δ) (a) : sum_congr e₁ e₂ (inl a) = inl (e₁ a) := rfl
@[simp] theorem sum_congr_apply_inr {α β γ δ}
(e₁ : α ↪ β) (e₂ : γ ↪ δ) (b) : sum_congr e₁ e₂ (inr b) = inr (e₂ b) := rfl
end sum
section sigma
open sigma
def sigma_congr_right {α : Type*} {β γ : α → Type*} (e : ∀ a, β a ↪ γ a) : sigma β ↪ sigma γ :=
⟨λ ⟨a, b⟩, ⟨a, e a b⟩, λ ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ h, begin
injection h with h₁ h₂, subst a₂,
congr,
exact (e a₁).2 (eq_of_heq h₂)
end⟩
end sigma
def Pi_congr_right {α : Sort*} {β γ : α → Sort*} (e : ∀ a, β a ↪ γ a) : (Π a, β a) ↪ (Π a, γ a) :=
⟨λf a, e a (f a), λ f₁ f₂ h, funext $ λ a, (e a).inj (congr_fun h a)⟩
def arrow_congr_left {α : Sort u} {β : Sort v} {γ : Sort w}
(e : α ↪ β) : (γ → α) ↪ (γ → β) :=
Pi_congr_right (λ _, e)
noncomputable def arrow_congr_right {α : Sort u} {β : Sort v} {γ : Sort w} [inhabited γ]
(e : α ↪ β) : (α → γ) ↪ (β → γ) :=
by haveI := classical.prop_decidable; exact
let f' : (α → γ) → (β → γ) := λf b, if h : ∃c, e c = b then f (classical.some h) else default γ in
⟨f', assume f₁ f₂ h, funext $ assume c,
have ∃c', e c' = e c, from ⟨c, rfl⟩,
have eq' : f' f₁ (e c) = f' f₂ (e c), from congr_fun h _,
have eq_b : classical.some this = c, from e.inj $ classical.some_spec this,
by simp [f', this, if_pos, eq_b] at eq'; assumption⟩
end embedding
end function
namespace set
/-- The injection map is an embedding between subsets. -/
def embedding_of_subset {α} {s t : set α} (h : s ⊆ t) : s ↪ t :=
⟨λ x, ⟨x.1, h x.2⟩, λ ⟨x, hx⟩ ⟨y, hy⟩ h, by congr; injection h⟩
end set
|
774175b000ead1d8de9bb703fbb68e71018ec44d | bbecf0f1968d1fba4124103e4f6b55251d08e9c4 | /src/topology/metric_space/hausdorff_dimension.lean | 86b32543e2203c5e45aa2408fdcf956b47ba1e26 | [
"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 | 23,141 | lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import measure_theory.measure.hausdorff
/-!
# Hausdorff dimension
The Hausdorff dimension of a set `X` in an (extended) metric space is the unique number
`dimH s : ℝ≥0∞` such that for any `d : ℝ≥0` we have
- `μH[d] s = 0` if `dimH s < d`, and
- `μH[d] s = ∞` if `d < dimH s`.
In this file we define `dimH s` to be the Hausdorff dimension of `s`, then prove some basic
properties of Hausdorff dimension.
## Main definitions
* `measure_theory.dimH`: the Hausdorff dimension of a set. For the Hausdorff dimension of the whole
space we use `measure_theory.dimH (set.univ : set X)`.
## Main results
### Basic properties of Hausdorff dimension
* `hausdorff_measure_of_lt_dimH`, `dimH_le_of_hausdorff_measure_ne_top`,
`le_dimH_of_hausdorff_measure_eq_top`, `hausdorff_measure_of_dimH_lt`, `measure_zero_of_dimH_lt`,
`le_dimH_of_hausdorff_measure_ne_zero`, `dimH_of_hausdorff_measure_ne_zero_ne_top`: various forms
of the characteristic property of the Hausdorff dimension;
* `dimH_union`: the Hausdorff dimension of the union of two sets is the maximum of their Hausdorff
dimensions.
* `dimH_Union`, `dimH_bUnion`, `dimH_sUnion`: the Hausdorff dimension of a countable union of sets
is the supremum of their Hausdorff dimensions;
* `dimH_empty`, `dimH_singleton`, `set.subsingleton.dimH_zero`, `set.countable.dimH_zero` : `dimH s
= 0` whenever `s` is countable;
### (Pre)images under (anti)lipschitz and Hölder continuous maps
* `holder_with.dimH_image_le` etc: if `f : X → Y` is Hölder continuous with exponent `r > 0`, then
for any `s`, `dimH (f '' s) ≤ dimH s / r`. We prove versions of this statement for `holder_with`,
`holder_on_with`, and locally Hölder maps, as well as for `set.image` and `set.range`.
* `lipschitz_with.dimH_image_le` etc: Lipschitz continuous maps do not increase the Hausdorff
dimension of sets.
* for a map that is known to be both Lipschitz and antilipschitz (e.g., for an `isometry` or
a `continuous_linear_equiv`) we also prove `dimH (f '' s) = dimH s`.
### Hausdorff measure in `ℝⁿ`
* `real.dimH_of_nonempty_interior`: if `s` is a set in a finite dimensional real vector space `E`
with nonempty interior, then the Hausdorff dimension of `s` is equal to the dimension of `E`.
* `dense_compl_of_dimH_lt_finrank`: if `s` is a set in a finite dimensional real vector space `E`
with Hausdorff dimension strictly less than the dimension of `E`, the `s` has a dense complement.
* `times_cont_diff.dense_compl_range_of_finrank_lt_finrank`: the complement to the range of a `C¹`
smooth map is dense provided that the dimension of the domain is strictly less than the dimension
of the codomain.
## Notations
We use the following notation localized in `measure_theory`. It is defined in
`measure_theory.measure.hausdorff`.
- `μH[d]` : `measure_theory.measure.hausdorff_measure d`
## Implementation notes
* The definition of `dimH` explicitly uses `borel X` as a measurable space structure. This way we
can formulate lemmas about Hausdorff dimension without assuming that the environment has a
`[measurable_space X]` instance that is equal but possibly not defeq to `borel X`.
Lemma `dimH_def` unfolds this definition using whatever `[measurable_space X]` instance we have in
the environment (as long as it is equal to `borel X`).
* The definition `dimH` is irreducible; use API lemmas or `dimH_def` instead.
## Tags
Hausdorff measure, Hausdorff dimension, dimension
-/
open_locale measure_theory ennreal nnreal topological_space
open measure_theory measure_theory.measure set topological_space finite_dimensional filter
variables {ι X Y : Type*} [emetric_space X] [emetric_space Y]
/-- Hausdorff dimension of a set in an (e)metric space. -/
@[irreducible] noncomputable def dimH (s : set X) : ℝ≥0∞ :=
by letI := borel X; exact ⨆ (d : ℝ≥0) (hd : @hausdorff_measure X _ _ ⟨rfl⟩ d s = ∞), d
/-!
### Basic properties
-/
section measurable
variables [measurable_space X] [borel_space X]
/-- Unfold the definition of `dimH` using `[measurable_space X] [borel_space X]` from the
environment. -/
lemma dimH_def (s : set X) : dimH s = ⨆ (d : ℝ≥0) (hd : μH[d] s = ∞), d :=
begin
unfreezingI { obtain rfl : ‹measurable_space X› = borel X := borel_space.measurable_eq },
rw dimH
end
lemma hausdorff_measure_of_lt_dimH {s : set X} {d : ℝ≥0} (h : ↑d < dimH s) : μH[d] s = ∞ :=
begin
simp only [dimH_def, lt_supr_iff] at h,
rcases h with ⟨d', hsd', hdd'⟩,
rw [ennreal.coe_lt_coe, ← nnreal.coe_lt_coe] at hdd',
exact top_unique (hsd' ▸ hausdorff_measure_mono hdd'.le _)
end
lemma dimH_le {s : set X} {d : ℝ≥0∞} (H : ∀ d' : ℝ≥0, μH[d'] s = ∞ → ↑d' ≤ d) : dimH s ≤ d :=
(dimH_def s).trans_le $ bsupr_le H
lemma dimH_le_of_hausdorff_measure_ne_top {s : set X} {d : ℝ≥0} (h : μH[d] s ≠ ∞) :
dimH s ≤ d :=
le_of_not_lt $ mt hausdorff_measure_of_lt_dimH h
lemma le_dimH_of_hausdorff_measure_eq_top {s : set X} {d : ℝ≥0} (h : μH[d] s = ∞) :
↑d ≤ dimH s :=
by { rw dimH_def, exact le_bsupr d h }
lemma hausdorff_measure_of_dimH_lt {s : set X} {d : ℝ≥0}
(h : dimH s < d) : μH[d] s = 0 :=
begin
rw dimH_def at h,
rcases ennreal.lt_iff_exists_nnreal_btwn.1 h with ⟨d', hsd', hd'd⟩,
rw [ennreal.coe_lt_coe, ← nnreal.coe_lt_coe] at hd'd,
exact (hausdorff_measure_zero_or_top hd'd s).resolve_right
(λ h, hsd'.not_le (le_bsupr d' h))
end
lemma measure_zero_of_dimH_lt {μ : measure X} {d : ℝ≥0}
(h : μ ≪ μH[d]) {s : set X} (hd : dimH s < d) :
μ s = 0 :=
h $ hausdorff_measure_of_dimH_lt hd
lemma le_dimH_of_hausdorff_measure_ne_zero {s : set X} {d : ℝ≥0} (h : μH[d] s ≠ 0) :
↑d ≤ dimH s :=
le_of_not_lt $ mt hausdorff_measure_of_dimH_lt h
lemma dimH_of_hausdorff_measure_ne_zero_ne_top {d : ℝ≥0} {s : set X} (h : μH[d] s ≠ 0)
(h' : μH[d] s ≠ ∞) : dimH s = d :=
le_antisymm (dimH_le_of_hausdorff_measure_ne_top h') (le_dimH_of_hausdorff_measure_ne_zero h)
end measurable
@[mono] lemma dimH_mono {s t : set X} (h : s ⊆ t) : dimH s ≤ dimH t :=
begin
letI := borel X, haveI : borel_space X := ⟨rfl⟩,
exact dimH_le (λ d hd, le_dimH_of_hausdorff_measure_eq_top $
top_unique $ hd ▸ measure_mono h)
end
lemma dimH_subsingleton {s : set X} (h : s.subsingleton) : dimH s = 0 :=
by simp [dimH, h.measure_zero]
alias dimH_subsingleton ← set.subsingleton.dimH_zero
@[simp] lemma dimH_empty : dimH (∅ : set X) = 0 := subsingleton_empty.dimH_zero
@[simp] lemma dimH_singleton (x : X) : dimH ({x} : set X) = 0 := subsingleton_singleton.dimH_zero
@[simp] lemma dimH_Union [encodable ι] (s : ι → set X) :
dimH (⋃ i, s i) = ⨆ i, dimH (s i) :=
begin
letI := borel X, haveI : borel_space X := ⟨rfl⟩,
refine le_antisymm (dimH_le $ λ d hd, _) (supr_le $ λ i, dimH_mono $ subset_Union _ _),
contrapose! hd,
have : ∀ i, μH[d] (s i) = 0,
from λ i, hausdorff_measure_of_dimH_lt ((le_supr (λ i, dimH (s i)) i).trans_lt hd),
rw measure_Union_null this,
exact ennreal.zero_ne_top
end
@[simp] lemma dimH_bUnion {s : set ι} (hs : countable s) (t : ι → set X) :
dimH (⋃ i ∈ s, t i) = ⨆ i ∈ s, dimH (t i) :=
begin
haveI := hs.to_encodable,
rw [← Union_subtype, dimH_Union, ← supr_subtype'']
end
@[simp] lemma dimH_sUnion {S : set (set X)} (hS : countable S) : dimH (⋃₀ S) = ⨆ s ∈ S, dimH s :=
by rw [sUnion_eq_bUnion, dimH_bUnion hS]
@[simp] lemma dimH_union (s t : set X) : dimH (s ∪ t) = max (dimH s) (dimH t) :=
by rw [union_eq_Union, dimH_Union, supr_bool_eq, cond, cond, ennreal.sup_eq_max]
lemma dimH_countable {s : set X} (hs : countable s) : dimH s = 0 :=
bUnion_of_singleton s ▸ by simp only [dimH_bUnion hs, dimH_singleton, ennreal.supr_zero_eq_zero]
alias dimH_countable ← set.countable.dimH_zero
lemma dimH_finite {s : set X} (hs : finite s) : dimH s = 0 := hs.countable.dimH_zero
alias dimH_finite ← set.finite.dimH_zero
@[simp] lemma dimH_coe_finset (s : finset X) : dimH (s : set X) = 0 := s.finite_to_set.dimH_zero
alias dimH_coe_finset ← finset.dimH_zero
/-!
### Hausdorff dimension as the supremum of local Hausdorff dimensions
-/
section
variables [second_countable_topology X]
/-- If `r` is less than the Hausdorff dimension of a set `s` in an (extended) metric space with
second countable topology, then there exists a point `x ∈ s` such that every neighborhood
`t` of `x` within `s` has Hausdorff dimension greater than `r`. -/
lemma exists_mem_nhds_within_lt_dimH_of_lt_dimH {s : set X} {r : ℝ≥0∞} (h : r < dimH s) :
∃ x ∈ s, ∀ t ∈ 𝓝[s] x, r < dimH t :=
begin
contrapose! h, choose! t htx htr using h,
rcases countable_cover_nhds_within htx with ⟨S, hSs, hSc, hSU⟩,
calc dimH s ≤ dimH (⋃ x ∈ S, t x) : dimH_mono hSU
... = ⨆ x ∈ S, dimH (t x) : dimH_bUnion hSc _
... ≤ r : bsupr_le (λ x hx, htr x (hSs hx))
end
/-- In an (extended) metric space with second countable topology, the Hausdorff dimension
of a set `s` is the supremum over `x ∈ s` of the limit superiors of `dimH t` along
`(𝓝[s] x).lift' powerset`. -/
lemma bsupr_limsup_dimH (s : set X) : (⨆ x ∈ s, limsup ((𝓝[s] x).lift' powerset) dimH) = dimH s :=
begin
refine le_antisymm (bsupr_le $ λ x hx, _) _,
{ refine Limsup_le_of_le (by apply_auto_param) (eventually_map.2 _),
exact eventually_lift'_powerset.2 ⟨s, self_mem_nhds_within, λ t, dimH_mono⟩ },
{ refine le_of_forall_ge_of_dense (λ r hr, _),
rcases exists_mem_nhds_within_lt_dimH_of_lt_dimH hr with ⟨x, hxs, hxr⟩,
refine le_bsupr_of_le x hxs _, rw limsup_eq, refine le_Inf (λ b hb, _),
rcases eventually_lift'_powerset.1 hb with ⟨t, htx, ht⟩,
exact (hxr t htx).le.trans (ht t subset.rfl) }
end
/-- In an (extended) metric space with second countable topology, the Hausdorff dimension
of a set `s` is the supremum over all `x` of the limit superiors of `dimH t` along
`(𝓝[s] x).lift' powerset`. -/
lemma supr_limsup_dimH (s : set X) : (⨆ x, limsup ((𝓝[s] x).lift' powerset) dimH) = dimH s :=
begin
refine le_antisymm (supr_le $ λ x, _) _,
{ refine Limsup_le_of_le (by apply_auto_param) (eventually_map.2 _),
exact eventually_lift'_powerset.2 ⟨s, self_mem_nhds_within, λ t, dimH_mono⟩ },
{ rw ← bsupr_limsup_dimH, exact bsupr_le_supr _ _ }
end
end
/-!
### Hausdorff dimension and Hölder continuity
-/
variables {C K r : ℝ≥0} {f : X → Y} {s t : set X}
/-- If `f` is a Hölder continuous map with exponent `r > 0`, then `dimH (f '' s) ≤ dimH s / r`. -/
lemma holder_on_with.dimH_image_le (h : holder_on_with C r f s) (hr : 0 < r) :
dimH (f '' s) ≤ dimH s / r :=
begin
letI := borel X, haveI : borel_space X := ⟨rfl⟩,
letI := borel Y, haveI : borel_space Y := ⟨rfl⟩,
refine dimH_le (λ d hd, _),
have := h.hausdorff_measure_image_le hr d.coe_nonneg,
rw [hd, ennreal.coe_rpow_of_nonneg _ d.coe_nonneg, top_le_iff] at this,
have Hrd : μH[(r * d : ℝ≥0)] s = ⊤,
{ contrapose this, exact ennreal.mul_ne_top ennreal.coe_ne_top this },
rw [ennreal.le_div_iff_mul_le, mul_comm, ← ennreal.coe_mul],
exacts [le_dimH_of_hausdorff_measure_eq_top Hrd, or.inl (mt ennreal.coe_eq_zero.1 hr.ne'),
or.inl ennreal.coe_ne_top]
end
namespace holder_with
/-- If `f : X → Y` is Hölder continuous with a positive exponent `r`, then the Hausdorff dimension
of the image of a set `s` is at most `dimH s / r`. -/
lemma dimH_image_le (h : holder_with C r f) (hr : 0 < r) (s : set X) :
dimH (f '' s) ≤ dimH s / r :=
(h.holder_on_with s).dimH_image_le hr
/-- If `f` is a Hölder continuous map with exponent `r > 0`, then the Hausdorff dimension of its
range is at most the Hausdorff dimension of its domain divided by `r`. -/
lemma dimH_range_le (h : holder_with C r f) (hr : 0 < r) :
dimH (range f) ≤ dimH (univ : set X) / r :=
@image_univ _ _ f ▸ h.dimH_image_le hr univ
end holder_with
/-- If `s` is a set in a space `X` with second countable topology and `f : X → Y` is Hölder
continuous in a neighborhood within `s` of every point `x ∈ s` with the same positive exponent `r`
but possibly different coefficients, then the Hausdorff dimension of the image `f '' s` is at most
the Hausdorff dimension of `s` divided by `r`. -/
lemma dimH_image_le_of_locally_holder_on [second_countable_topology X] {r : ℝ≥0} {f : X → Y}
(hr : 0 < r) {s : set X} (hf : ∀ x ∈ s, ∃ (C : ℝ≥0) (t ∈ 𝓝[s] x), holder_on_with C r f t) :
dimH (f '' s) ≤ dimH s / r :=
begin
choose! C t htn hC using hf,
rcases countable_cover_nhds_within htn with ⟨u, hus, huc, huU⟩,
replace huU := inter_eq_self_of_subset_left huU, rw inter_bUnion at huU,
rw [← huU, image_bUnion, dimH_bUnion huc, dimH_bUnion huc], simp only [ennreal.supr_div],
exact bsupr_le_bsupr (λ x hx, ((hC x (hus hx)).mono (inter_subset_right _ _)).dimH_image_le hr)
end
/-- If `f : X → Y` is Hölder continuous in a neighborhood of every point `x : X` with the same
positive exponent `r` but possibly different coefficients, then the Hausdorff dimension of the range
of `f` is at most the Hausdorff dimension of `X` divided by `r`. -/
lemma dimH_range_le_of_locally_holder_on [second_countable_topology X] {r : ℝ≥0} {f : X → Y}
(hr : 0 < r) (hf : ∀ x : X, ∃ (C : ℝ≥0) (s ∈ 𝓝 x), holder_on_with C r f s) :
dimH (range f) ≤ dimH (univ : set X) / r :=
begin
rw ← image_univ,
refine dimH_image_le_of_locally_holder_on hr (λ x _, _),
simpa only [exists_prop, nhds_within_univ] using hf x
end
/-!
### Hausdorff dimension and Lipschitz continuity
-/
/-- If `f : X → Y` is Lipschitz continuous on `s`, then `dimH (f '' s) ≤ dimH s`. -/
lemma lipschitz_on_with.dimH_image_le (h : lipschitz_on_with K f s) : dimH (f '' s) ≤ dimH s :=
by simpa using h.holder_on_with.dimH_image_le zero_lt_one
namespace lipschitz_with
/-- If `f` is a Lipschitz continuous map, then `dimH (f '' s) ≤ dimH s`. -/
lemma dimH_image_le (h : lipschitz_with K f) (s : set X) : dimH (f '' s) ≤ dimH s :=
(h.lipschitz_on_with s).dimH_image_le
/-- If `f` is a Lipschitz continuous map, then the Hausdorff dimension of its range is at most the
Hausdorff dimension of its domain. -/
lemma dimH_range_le (h : lipschitz_with K f) : dimH (range f) ≤ dimH (univ : set X) :=
@image_univ _ _ f ▸ h.dimH_image_le univ
end lipschitz_with
/-- If `s` is a set in an extended metric space `X` with second countable topology and `f : X → Y`
is Lipschitz in a neighborhood within `s` of every point `x ∈ s`, then the Hausdorff dimension of
the image `f '' s` is at most the Hausdorff dimension of `s`. -/
lemma dimH_image_le_of_locally_lipschitz_on [second_countable_topology X] {f : X → Y}
{s : set X} (hf : ∀ x ∈ s, ∃ (C : ℝ≥0) (t ∈ 𝓝[s] x), lipschitz_on_with C f t) :
dimH (f '' s) ≤ dimH s :=
begin
have : ∀ x ∈ s, ∃ (C : ℝ≥0) (t ∈ 𝓝[s] x), holder_on_with C 1 f t,
by simpa only [holder_on_with_one] using hf,
simpa only [ennreal.coe_one, ennreal.div_one]
using dimH_image_le_of_locally_holder_on zero_lt_one this
end
/-- If `f : X → Y` is Lipschitz in a neighborhood of each point `x : X`, then the Hausdorff
dimension of `range f` is at most the Hausdorff dimension of `X`. -/
lemma dimH_range_le_of_locally_lipschitz_on [second_countable_topology X] {f : X → Y}
(hf : ∀ x : X, ∃ (C : ℝ≥0) (s ∈ 𝓝 x), lipschitz_on_with C f s) :
dimH (range f) ≤ dimH (univ : set X) :=
begin
rw ← image_univ,
refine dimH_image_le_of_locally_lipschitz_on (λ x _, _),
simpa only [exists_prop, nhds_within_univ] using hf x
end
namespace antilipschitz_with
lemma dimH_preimage_le (hf : antilipschitz_with K f) (s : set Y) :
dimH (f ⁻¹' s) ≤ dimH s :=
begin
letI := borel X, haveI : borel_space X := ⟨rfl⟩,
letI := borel Y, haveI : borel_space Y := ⟨rfl⟩,
refine dimH_le (λ d hd, le_dimH_of_hausdorff_measure_eq_top _),
have := hf.hausdorff_measure_preimage_le d.coe_nonneg s,
rw [hd, top_le_iff] at this,
contrapose! this,
exact ennreal.mul_ne_top (by simp) this
end
lemma le_dimH_image (hf : antilipschitz_with K f) (s : set X) :
dimH s ≤ dimH (f '' s) :=
calc dimH s ≤ dimH (f ⁻¹' (f '' s)) : dimH_mono (subset_preimage_image _ _)
... ≤ dimH (f '' s) : hf.dimH_preimage_le _
end antilipschitz_with
/-!
### Isometries preserve Hausdorff dimension
-/
lemma isometry.dimH_image (hf : isometry f) (s : set X) : dimH (f '' s) = dimH s :=
le_antisymm (hf.lipschitz.dimH_image_le _) (hf.antilipschitz.le_dimH_image _)
namespace isometric
@[simp] lemma dimH_image (e : X ≃ᵢ Y) (s : set X) : dimH (e '' s) = dimH s :=
e.isometry.dimH_image s
@[simp] lemma dimH_preimage (e : X ≃ᵢ Y) (s : set Y) : dimH (e ⁻¹' s) = dimH s :=
by rw [← e.image_symm, e.symm.dimH_image]
lemma dimH_univ (e : X ≃ᵢ Y) : dimH (univ : set X) = dimH (univ : set Y) :=
by rw [← e.dimH_preimage univ, preimage_univ]
end isometric
namespace continuous_linear_equiv
variables {𝕜 E F : Type*} [nondiscrete_normed_field 𝕜]
[normed_group E] [normed_space 𝕜 E] [normed_group F] [normed_space 𝕜 F]
@[simp] lemma dimH_image (e : E ≃L[𝕜] F) (s : set E) : dimH (e '' s) = dimH s :=
le_antisymm (e.lipschitz.dimH_image_le s) $
by simpa only [e.symm_image_image] using e.symm.lipschitz.dimH_image_le (e '' s)
@[simp] lemma dimH_preimage (e : E ≃L[𝕜] F) (s : set F) : dimH (e ⁻¹' s) = dimH s :=
by rw [← e.image_symm_eq_preimage, e.symm.dimH_image]
lemma dimH_univ (e : E ≃L[𝕜] F) : dimH (univ : set E) = dimH (univ : set F) :=
by rw [← e.dimH_preimage, preimage_univ]
end continuous_linear_equiv
/-!
### Hausdorff dimension in a real vector space
-/
namespace real
variables {E : Type*} [fintype ι] [normed_group E] [normed_space ℝ E] [finite_dimensional ℝ E]
theorem dimH_ball_pi (x : ι → ℝ) {r : ℝ} (hr : 0 < r) :
dimH (metric.ball x r) = fintype.card ι :=
begin
casesI is_empty_or_nonempty ι,
{ rwa [dimH_subsingleton, eq_comm, nat.cast_eq_zero, fintype.card_eq_zero_iff],
exact λ x _ y _, subsingleton.elim x y },
{ rw ← ennreal.coe_nat,
have : μH[fintype.card ι] (metric.ball x r) = ennreal.of_real ((2 * r) ^ fintype.card ι),
by rw [hausdorff_measure_pi_real, real.volume_pi_ball _ hr],
refine dimH_of_hausdorff_measure_ne_zero_ne_top _ _; rw [nnreal.coe_nat_cast, this],
{ simp [pow_pos (mul_pos zero_lt_two hr)] },
{ exact ennreal.of_real_ne_top } }
end
theorem dimH_ball_pi_fin {n : ℕ} (x : fin n → ℝ) {r : ℝ} (hr : 0 < r) :
dimH (metric.ball x r) = n :=
by rw [dimH_ball_pi x hr, fintype.card_fin]
theorem dimH_univ_pi (ι : Type*) [fintype ι] : dimH (univ : set (ι → ℝ)) = fintype.card ι :=
by simp only [← metric.Union_ball_nat_succ (0 : ι → ℝ), dimH_Union,
dimH_ball_pi _ (nat.cast_add_one_pos _), supr_const]
theorem dimH_univ_pi_fin (n : ℕ) : dimH (univ : set (fin n → ℝ)) = n :=
by rw [dimH_univ_pi, fintype.card_fin]
theorem dimH_of_mem_nhds {x : E} {s : set E} (h : s ∈ 𝓝 x) :
dimH s = finrank ℝ E :=
begin
haveI : finite_dimensional ℝ (fin (finrank ℝ E) → ℝ), from is_noetherian_pi',
have e : E ≃L[ℝ] (fin (finrank ℝ E) → ℝ),
from continuous_linear_equiv.of_finrank_eq (finite_dimensional.finrank_fin_fun ℝ).symm,
rw ← e.dimH_image,
refine le_antisymm _ _,
{ exact (dimH_mono (subset_univ _)).trans_eq (dimH_univ_pi_fin _) },
{ have : e '' s ∈ 𝓝 (e x), by { rw ← e.map_nhds_eq, exact image_mem_map h },
rcases metric.nhds_basis_ball.mem_iff.1 this with ⟨r, hr0, hr⟩,
simpa only [dimH_ball_pi_fin (e x) hr0] using dimH_mono hr }
end
theorem dimH_of_nonempty_interior {s : set E} (h : (interior s).nonempty) :
dimH s = finrank ℝ E :=
let ⟨x, hx⟩ := h in dimH_of_mem_nhds (mem_interior_iff_mem_nhds.1 hx)
variable (E)
theorem dimH_univ_eq_finrank : dimH (univ : set E) = finrank ℝ E :=
dimH_of_mem_nhds (@univ_mem _ (𝓝 0))
theorem dimH_univ : dimH (univ : set ℝ) = 1 :=
by rw [dimH_univ_eq_finrank ℝ, finite_dimensional.finrank_self, nat.cast_one]
end real
variables {E F : Type*}
[normed_group E] [normed_space ℝ E] [finite_dimensional ℝ E]
[normed_group F] [normed_space ℝ F]
theorem dense_compl_of_dimH_lt_finrank {s : set E} (hs : dimH s < finrank ℝ E) : dense sᶜ :=
begin
refine λ x, mem_closure_iff_nhds.2 (λ t ht, ne_empty_iff_nonempty.1 $ λ he, hs.not_le _),
rw [← diff_eq, diff_eq_empty] at he,
rw [← real.dimH_of_mem_nhds ht],
exact dimH_mono he
end
/-!
### Hausdorff dimension and `C¹`-smooth maps
`C¹`-smooth maps are locally Lipschitz continuous, hence they do not increase the Hausdorff
dimension of sets.
-/
/-- Let `f` be a function defined on a finite dimensional real normed space. If `f` is `C¹`-smooth
on a convex set `s`, then the Hausdorff dimension of `f '' s` is less than or equal to the Hausdorff
dimension of `s`.
TODO: do we actually need `convex ℝ s`? -/
lemma times_cont_diff_on.dimH_image_le {f : E → F} {s t : set E} (hf : times_cont_diff_on ℝ 1 f s)
(hc : convex ℝ s) (ht : t ⊆ s) :
dimH (f '' t) ≤ dimH t :=
dimH_image_le_of_locally_lipschitz_on $ λ x hx,
let ⟨C, u, hu, hf⟩ := (hf x (ht hx)).exists_lipschitz_on_with hc
in ⟨C, u, nhds_within_mono _ ht hu, hf⟩
/-- The Hausdorff dimension of the range of a `C¹`-smooth function defined on a finite dimensional
real normed space is at most the dimension of its domain as a vector space over `ℝ`. -/
lemma times_cont_diff.dimH_range_le {f : E → F} (h : times_cont_diff ℝ 1 f) :
dimH (range f) ≤ finrank ℝ E :=
calc dimH (range f) = dimH (f '' univ) : by rw image_univ
... ≤ dimH (univ : set E) : h.times_cont_diff_on.dimH_image_le convex_univ subset.rfl
... = finrank ℝ E : real.dimH_univ_eq_finrank E
/-- A particular case of Sard's Theorem. Let `f : E → F` be a map between finite dimensional real
vector spaces. Suppose that `f` is `C¹` smooth on a convex set `s` of Hausdorff dimension strictly
less than the dimension of `F`. Then the complement of the image `f '' s` is dense in `F`. -/
lemma times_cont_diff_on.dense_compl_image_of_dimH_lt_finrank [finite_dimensional ℝ F] {f : E → F}
{s t : set E} (h : times_cont_diff_on ℝ 1 f s) (hc : convex ℝ s) (ht : t ⊆ s)
(htF : dimH t < finrank ℝ F) :
dense (f '' t)ᶜ :=
dense_compl_of_dimH_lt_finrank $ (h.dimH_image_le hc ht).trans_lt htF
/-- A particular case of Sard's Theorem. If `f` is a `C¹` smooth map from a real vector space to a
real vector space `F` of strictly larger dimension, then the complement of the range of `f` is dense
in `F`. -/
lemma times_cont_diff.dense_compl_range_of_finrank_lt_finrank [finite_dimensional ℝ F] {f : E → F}
(h : times_cont_diff ℝ 1 f) (hEF : finrank ℝ E < finrank ℝ F) :
dense (range f)ᶜ :=
dense_compl_of_dimH_lt_finrank $ h.dimH_range_le.trans_lt $ ennreal.coe_nat_lt_coe_nat.2 hEF
|
53bd21bfb7e36e9a433335998aadf3cc8657b6ce | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/number_theory/sum_four_squares.lean | 8ea1a82447bc6ccda080a0a2afe5b9466ef1bfdf | [
"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 | 12,135 | 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 algebra.group_power.identities
import data.zmod.basic
import field_theory.finite.basic
import data.int.parity
import data.fintype.big_operators
/-!
# Lagrange's four square theorem
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
The main result in this file is `sum_four_squares`,
a proof that every natural number is the sum of four square numbers.
## Implementation Notes
The proof used is close to Lagrange's original proof.
-/
open finset polynomial finite_field equiv
open_locale big_operators
namespace int
lemma sq_add_sq_of_two_mul_sq_add_sq {m x y : ℤ} (h : 2 * m = x^2 + y^2) :
m = ((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2 :=
have even (x^2 + y^2), by simp [←h, even_mul],
have hxaddy : even (x + y), by simpa [sq] with parity_simps,
have hxsuby : even (x - y), by simpa [sq] with parity_simps,
(mul_right_inj' (show (2*2 : ℤ) ≠ 0, from dec_trivial)).1 $
calc 2 * 2 * m = (x - y)^2 + (x + y)^2 : by rw [mul_assoc, h]; ring
... = (2 * ((x - y) / 2))^2 + (2 * ((x + y) / 2))^2 :
by { rw even_iff_two_dvd at hxsuby hxaddy,
rw [int.mul_div_cancel' hxsuby, int.mul_div_cancel' hxaddy] }
... = 2 * 2 * (((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2) :
by simp [mul_add, pow_succ, mul_comm, mul_assoc, mul_left_comm]
lemma exists_sq_add_sq_add_one_eq_k (p : ℕ) [hp : fact p.prime] :
∃ (a b : ℤ) (k : ℕ), a^2 + b^2 + 1 = k * p ∧ k < p :=
hp.1.eq_two_or_odd.elim (λ hp2, hp2.symm ▸ ⟨1, 0, 1, rfl, dec_trivial⟩) $ λ hp1,
let ⟨a, b, hab⟩ := zmod.sq_add_sq p (-1) in
have hab' : (p : ℤ) ∣ a.val_min_abs ^ 2 + b.val_min_abs ^ 2 + 1,
from (char_p.int_cast_eq_zero_iff (zmod p) p _).1 $ by simpa [eq_neg_iff_add_eq_zero] using hab,
let ⟨k, hk⟩ := hab' in
have hk0 : 0 ≤ k, from nonneg_of_mul_nonneg_right
(by rw ← hk; exact (add_nonneg (add_nonneg (sq_nonneg _) (sq_nonneg _)) zero_le_one))
(int.coe_nat_pos.2 hp.1.pos),
⟨a.val_min_abs, b.val_min_abs, k.nat_abs,
by rw [hk, int.nat_abs_of_nonneg hk0, mul_comm],
lt_of_mul_lt_mul_left
(calc p * k.nat_abs = a.val_min_abs.nat_abs ^ 2 + b.val_min_abs.nat_abs ^ 2 + 1 :
by rw [← int.coe_nat_inj', int.coe_nat_add, int.coe_nat_add, int.coe_nat_pow,
int.coe_nat_pow, int.nat_abs_sq, int.nat_abs_sq,
int.coe_nat_one, hk, int.coe_nat_mul, int.nat_abs_of_nonneg hk0]
... ≤ (p / 2) ^ 2 + (p / 2)^2 + 1 :
add_le_add
(add_le_add
(nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)
(nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))
le_rfl
... < (p / 2) ^ 2 + (p / 2)^ 2 + (p % 2)^2 + ((2 * (p / 2)^2 + (4 * (p / 2) * (p % 2)))) :
by rw [hp1, one_pow, mul_one];
exact (lt_add_iff_pos_right _).2
(add_pos_of_nonneg_of_pos (nat.zero_le _) (mul_pos dec_trivial
(nat.div_pos hp.1.two_le dec_trivial)))
... = p * p : by { conv_rhs { rw [← nat.mod_add_div p 2] }, ring })
(show 0 ≤ p, from nat.zero_le _)⟩
end int
namespace nat
open int
open_locale classical
private lemma sum_four_squares_of_two_mul_sum_four_squares {m a b c d : ℤ}
(h : a^2 + b^2 + c^2 + d^2 = 2 * m) : ∃ w x y z : ℤ, w^2 + x^2 + y^2 + z^2 = m :=
have ∀ f : fin 4 → zmod 2, (f 0)^2 + (f 1)^2 + (f 2)^2 + (f 3)^2 = 0 →
∃ i : (fin 4), (f i)^2 + f (swap i 0 1)^2 = 0 ∧ f (swap i 0 2)^2 + f (swap i 0 3)^2 = 0,
from dec_trivial,
let f : fin 4 → ℤ :=
vector.nth (a ::ᵥ b ::ᵥ c ::ᵥ d ::ᵥ vector.nil) in
let ⟨i, hσ⟩ := this (λ x, coe (f x)) (by rw [← @zero_mul (zmod 2) _ m,
← show ((2 : ℤ) : zmod 2) = 0, from rfl,
← int.cast_mul, ← h]; simp only [int.cast_add, int.cast_pow]; refl) in
let σ := swap i 0 in
have h01 : 2 ∣ f (σ 0) ^ 2 + f (σ 1) ^ 2,
from (char_p.int_cast_eq_zero_iff (zmod 2) 2 _).1 $
by simpa only [int.cast_pow, int.cast_add, equiv.swap_apply_right, zmod.pow_card] using hσ.1,
have h23 : 2 ∣ f (σ 2) ^ 2 + f (σ 3) ^ 2,
from (char_p.int_cast_eq_zero_iff (zmod 2) 2 _).1 $
by simpa only [int.cast_pow, int.cast_add, zmod.pow_card] using hσ.2,
let ⟨x, hx⟩ := h01 in let ⟨y, hy⟩ := h23 in
⟨(f (σ 0) - f (σ 1)) / 2, (f (σ 0) + f (σ 1)) / 2, (f (σ 2) - f (σ 3)) / 2, (f (σ 2) + f (σ 3)) / 2,
begin
rw [← int.sq_add_sq_of_two_mul_sq_add_sq hx.symm, add_assoc,
← int.sq_add_sq_of_two_mul_sq_add_sq hy.symm,
← mul_right_inj' (show (2 : ℤ) ≠ 0, from dec_trivial), ← h, mul_add, ← hx, ← hy],
have : ∑ x, f (σ x)^2 = ∑ x, f x^2,
{ conv_rhs { rw ←equiv.sum_comp σ } },
simpa only [fin.sum_univ_four, add_assoc] using this,
end⟩
private lemma prime_sum_four_squares (p : ℕ) [hp : fact p.prime] :
∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = p :=
have hm : ∃ m < p, 0 < m ∧ ∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = m * p,
from let ⟨a, b, k, hk⟩ := exists_sq_add_sq_add_one_eq_k p in
⟨k, hk.2, nat.pos_of_ne_zero $
(λ hk0, by { rw [hk0, int.coe_nat_zero, zero_mul] at hk,
exact ne_of_gt (show a^2 + b^2 + 1 > 0, from add_pos_of_nonneg_of_pos
(add_nonneg (sq_nonneg _) (sq_nonneg _)) zero_lt_one) hk.1 }),
a, b, 1, 0, by simpa only [zero_pow two_pos, one_pow, add_zero] using hk.1⟩,
let m := nat.find hm in
let ⟨a, b, c, d, (habcd : a^2 + b^2 + c^2 + d^2 = m * p)⟩ := (nat.find_spec hm).snd.2 in
by haveI hm0 : ne_zero m := ne_zero.of_pos (nat.find_spec hm).snd.1; exact
have hmp : m < p, from (nat.find_spec hm).fst,
m.mod_two_eq_zero_or_one.elim
(λ hm2 : m % 2 = 0,
let ⟨k, hk⟩ := nat.dvd_iff_mod_eq_zero.2 hm2 in
have hk0 : 0 < k, from nat.pos_of_ne_zero $
by { rintro rfl, rw mul_zero at hk, exact ne_zero.ne m hk },
have hkm : k < m, { rw [hk, two_mul], exact (lt_add_iff_pos_left _).2 hk0 },
false.elim $ nat.find_min hm hkm ⟨lt_trans hkm hmp, hk0,
sum_four_squares_of_two_mul_sum_four_squares
(show a^2 + b^2 + c^2 + d^2 = 2 * (k * p),
by { rw [habcd, hk, int.coe_nat_mul, mul_assoc], norm_num })⟩)
(λ hm2 : m % 2 = 1,
if hm1 : m = 1 then ⟨a, b, c, d, by simp only [hm1, habcd, int.coe_nat_one, one_mul]⟩
else
let w := (a : zmod m).val_min_abs, x := (b : zmod m).val_min_abs,
y := (c : zmod m).val_min_abs, z := (d : zmod m).val_min_abs in
have hnat_abs : w^2 + x^2 + y^2 + z^2 =
(w.nat_abs^2 + x.nat_abs^2 + y.nat_abs ^2 + z.nat_abs ^ 2 : ℕ),
by { push_cast, simp_rw sq_abs, },
have hwxyzlt : w^2 + x^2 + y^2 + z^2 < m^2,
from calc w^2 + x^2 + y^2 + z^2
= (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs ^2 + z.nat_abs ^ 2 : ℕ) : hnat_abs
... ≤ ((m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 : ℕ) :
int.coe_nat_le.2 $ add_le_add (add_le_add (add_le_add
(nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)
(nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))
(nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _))
(nat.pow_le_pow_of_le_left (zmod.nat_abs_val_min_abs_le _) _)
... = 4 * (m / 2 : ℕ) ^ 2 : by simp only [bit0_mul, one_mul, two_smul,
nat.cast_add, nat.cast_pow, add_assoc]
... < 4 * (m / 2 : ℕ) ^ 2 + ((4 * (m / 2) : ℕ) * (m % 2 : ℕ) + (m % 2 : ℕ)^2) :
(lt_add_iff_pos_right _).2 (by { rw [hm2, int.coe_nat_one, one_pow, mul_one],
exact add_pos_of_nonneg_of_pos (int.coe_nat_nonneg _) zero_lt_one })
... = m ^ 2 : by { conv_rhs {rw [← nat.mod_add_div m 2]},
simp [-nat.mod_add_div, mul_add, add_mul, bit0, bit1, mul_comm, mul_assoc, mul_left_comm,
pow_add, add_comm, add_left_comm] },
have hwxyzabcd : ((w^2 + x^2 + y^2 + z^2 : ℤ) : zmod m) =
((a^2 + b^2 + c^2 + d^2 : ℤ) : zmod m),
by push_cast,
have hwxyz0 : ((w^2 + x^2 + y^2 + z^2 : ℤ) : zmod m) = 0,
by rw [hwxyzabcd, habcd, int.cast_mul, cast_coe_nat, zmod.nat_cast_self, zero_mul],
let ⟨n, hn⟩ := ((char_p.int_cast_eq_zero_iff _ m _).1 hwxyz0) in
have hn0 : 0 < n.nat_abs, from int.nat_abs_pos_of_ne_zero (λ hn0,
have hwxyz0 : (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs^2 + z.nat_abs^2 : ℕ) = 0,
by { rw [← int.coe_nat_eq_zero, ← hnat_abs], rwa [hn0, mul_zero] at hn },
have habcd0 : (m : ℤ) ∣ a ∧ (m : ℤ) ∣ b ∧ (m : ℤ) ∣ c ∧ (m : ℤ) ∣ d,
by simpa only [add_eq_zero_iff, int.nat_abs_eq_zero, zmod.val_min_abs_eq_zero, and.assoc,
pow_eq_zero_iff two_pos, char_p.int_cast_eq_zero_iff _ m _] using hwxyz0,
let ⟨ma, hma⟩ := habcd0.1, ⟨mb, hmb⟩ := habcd0.2.1,
⟨mc, hmc⟩ := habcd0.2.2.1, ⟨md, hmd⟩ := habcd0.2.2.2 in
have hmdvdp : m ∣ p,
from int.coe_nat_dvd.1 ⟨ma^2 + mb^2 + mc^2 + md^2,
(mul_right_inj' (show (m : ℤ) ≠ 0, from int.coe_nat_ne_zero.2 hm0.1)).1 $
by { rw [← habcd, hma, hmb, hmc, hmd], ring }⟩,
(hp.1.eq_one_or_self_of_dvd _ hmdvdp).elim hm1
(λ hmeqp, by simpa [lt_irrefl, hmeqp] using hmp)),
have hawbxcydz : ((m : ℕ) : ℤ) ∣ a * w + b * x + c * y + d * z,
from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $
by { rw [← hwxyz0], simp_rw [sq], push_cast },
have haxbwczdy : ((m : ℕ) : ℤ) ∣ a * x - b * w - c * z + d * y,
from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { push_cast, ring },
have haybzcwdx : ((m : ℕ) : ℤ) ∣ a * y + b * z - c * w - d * x,
from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { push_cast, ring },
have hazbycxdw : ((m : ℕ) : ℤ) ∣ a * z - b * y + c * x - d * w,
from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { push_cast, ring },
let ⟨s, hs⟩ := hawbxcydz, ⟨t, ht⟩ := haxbwczdy, ⟨u, hu⟩ := haybzcwdx, ⟨v, hv⟩ := hazbycxdw in
have hn_nonneg : 0 ≤ n,
from nonneg_of_mul_nonneg_right
(by { erw [← hn], repeat {try {refine add_nonneg _ _}, try {exact sq_nonneg _}} })
(int.coe_nat_pos.2 $ ne_zero.pos m),
have hnm : n.nat_abs < m,
from int.coe_nat_lt.1 (lt_of_mul_lt_mul_left
(by { rw [int.nat_abs_of_nonneg hn_nonneg, ← hn, ← sq], exact hwxyzlt })
(int.coe_nat_nonneg m)),
have hstuv : s^2 + t^2 + u^2 + v^2 = n.nat_abs * p,
from (mul_right_inj' (show (m^2 : ℤ) ≠ 0, from pow_ne_zero 2
(int.coe_nat_ne_zero.2 hm0.1))).1 $
calc (m : ℤ)^2 * (s^2 + t^2 + u^2 + v^2) = ((m : ℕ) * s)^2 + ((m : ℕ) * t)^2 +
((m : ℕ) * u)^2 + ((m : ℕ) * v)^2 :
by { simp [mul_pow], ring }
... = (w^2 + x^2 + y^2 + z^2) * (a^2 + b^2 + c^2 + d^2) :
by { simp only [hs.symm, ht.symm, hu.symm, hv.symm], ring }
... = _ : by { rw [hn, habcd, int.nat_abs_of_nonneg hn_nonneg], dsimp [m], ring },
false.elim $ nat.find_min hm hnm ⟨lt_trans hnm hmp, hn0, s, t, u, v, hstuv⟩)
/-- **Four squares theorem** -/
lemma sum_four_squares : ∀ n : ℕ, ∃ a b c d : ℕ, a^2 + b^2 + c^2 + d^2 = n
| 0 := ⟨0, 0, 0, 0, rfl⟩
| 1 := ⟨1, 0, 0, 0, rfl⟩
| n@(k+2) :=
have hm : fact (min_fac (k+2)).prime := ⟨min_fac_prime dec_trivial⟩,
have n / min_fac n < n := factors_lemma,
let ⟨a, b, c, d, h₁⟩ := show ∃ a b c d : ℤ, a^2 + b^2 + c^2 + d^2 = min_fac n,
by exactI prime_sum_four_squares (min_fac (k+2)) in
let ⟨w, x, y, z, h₂⟩ := sum_four_squares (n / min_fac n) in
⟨(a * w - b * x - c * y - d * z).nat_abs,
(a * x + b * w + c * z - d * y).nat_abs,
(a * y - b * z + c * w + d * x).nat_abs,
(a * z + b * y - c * x + d * w).nat_abs,
begin
rw [← int.coe_nat_inj', ← nat.mul_div_cancel' (min_fac_dvd (k+2)), int.coe_nat_mul, ← h₁, ← h₂],
simp [sum_four_sq_mul_sum_four_sq],
end⟩
end nat
|
d293feddf2307bc0254d4c4c76958f8981990fe4 | 76c77df8a58af24dbf1d75c7012076a42244d728 | /tutorial_src/exercises/01_equality_rewriting.lean | 54fa8e0b91c6832d0747744a21477def7fced3b2 | [] | no_license | kris-brown/theorem_proving_in_lean | 7a7a584ba2c657a35335dc895d49d991c997a0c9 | 774460c21bf857daff158210741bd88d1c8323cd | refs/heads/master | 1,668,278,123,743 | 1,593,445,161,000 | 1,593,445,161,000 | 265,748,924 | 0 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 5,185 | 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.
-/
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
rw mul_comm c b,
rw mul_assoc b c a,
rw mul_comm a c
end
-- 0002
example (a b c : ℝ) : a * (b * c) = b * (a * c) :=
begin
rw <- mul_assoc a b c,
rw mul_comm a b,
rw mul_assoc b a c
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
rw <- mul_assoc,
rw mul_comm a b,
rw mul_assoc
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
rw mul_comm a b at hyp',
rw ← hyp' at hyp,
rw sub_self d at hyp,
exact hyp
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
calc c = b*a - d : by {rw hyp}
... = b*a - a*b : by {rw hyp'}
... = b*a - b*a : by {rw mul_comm b a}
... = 0 : by {rw sub_self (b*a)}
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) := by ring
/-
This is too much fun. Let's do it again.
-/
-- 0007
example (a b : ℝ) : (a + b) + a = 2*a + b := by ring
/-
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 := by ring
/- Let's stick to ring in the end. -/
|
0dadf655819fd52ac2b2872a4ca265bd2d1f04a6 | a9d0fb7b0e4f802bd3857b803e6c5c23d87fef91 | /library/algebra/category/limit.lean | 1ac6aea04535d910df9b235b4515ed0e53959a3e | [
"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 | 918 | 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 .natural_transformation
import data.sigma
open eq eq.ops category functor natural_transformation
namespace limits
--representable functor
section
variables {I C : Category} {D : I ⇒ C}
definition constant_diagram (a : C) : I ⇒ C :=
mk (λ i, a)
(λ i j u, id)
(λ i, rfl)
(λ i j k v u, symm !id_compose)
definition cone := Σ(a : C), constant_diagram a ⟹ D
-- definition cone_category : category cone :=
-- mk (λa b, sorry)
-- (λ a b c g f, sorry)
-- (λ a, sorry)
-- (λ a b c d h g f, sorry)
-- (λ a b f, sorry)
-- (λ a b f, sorry)
end
end limits
-- functor.mk (λ a, sorry)
-- (λ a b f, sorry)
-- (λ a, sorry)
-- (λ a b c g f, sorry)
|
af3788a9fd50061f14a699f0b4b5760683e220de | 5719a16e23dfc08cdea7a5bf035b81690f307965 | /stage0/src/Init/Control/Except.lean | 2432a60c616e5e73b03a72d0841a68005a12d9ed | [
"Apache-2.0"
] | permissive | postmasters/lean4 | 488b03969a371e1507e1e8a4df9ebf63c7cbe7ac | f3976fc53a883ac7606fc59357d43f4b51016ca7 | refs/heads/master | 1,655,582,707,480 | 1,588,682,595,000 | 1,588,682,595,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 7,097 | lean | /-
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jared Roesch, Sebastian Ullrich
The Except monad transformer.
-/
prelude
import Init.Control.Alternative
import Init.Control.Lift
import Init.Data.ToString
universes u v w
inductive Except (ε : Type u) (α : Type v)
| error {} : ε → Except
| ok {} : α → Except
attribute [unbox] Except
instance {ε : Type u} {α : Type v} [Inhabited ε] : Inhabited (Except ε α) :=
⟨Except.error (arbitrary ε)⟩
section
variables {ε : Type u} {α : Type v}
protected def Except.toString [HasToString ε] [HasToString α] : Except ε α → String
| Except.error e => "(error " ++ toString e ++ ")"
| Except.ok a => "(ok " ++ toString a ++ ")"
protected def Except.repr [HasRepr ε] [HasRepr α] : Except ε α → String
| Except.error e => "(error " ++ repr e ++ ")"
| Except.ok a => "(ok " ++ repr a ++ ")"
instance [HasToString ε] [HasToString α] : HasToString (Except ε α) :=
⟨Except.toString⟩
instance [HasRepr ε] [HasRepr α] : HasRepr (Except ε α) :=
⟨Except.repr⟩
end
namespace Except
variables {ε : Type u}
@[inline] protected def return {α : Type v} (a : α) : Except ε α :=
Except.ok a
@[inline] protected def map {α β : Type v} (f : α → β) : Except ε α → Except ε β
| Except.error err => Except.error err
| Except.ok v => Except.ok $ f v
@[inline] protected def mapError {ε' : Type u} {α : Type v} (f : ε → ε') : Except ε α → Except ε' α
| Except.error err => Except.error $ f err
| Except.ok v => Except.ok v
@[inline] protected def bind {α β : Type v} (ma : Except ε α) (f : α → Except ε β) : Except ε β :=
match ma with
| (Except.error err) => Except.error err
| (Except.ok v) => f v
@[inline] protected def toBool {α : Type v} : Except ε α → Bool
| Except.ok _ => true
| Except.error _ => false
@[inline] protected def toOption {α : Type v} : Except ε α → Option α
| Except.ok a => some a
| Except.error _ => none
@[inline] protected def catch {α : Type u} (ma : Except ε α) (handle : ε → Except ε α) : Except ε α :=
match ma with
| Except.ok a => Except.ok a
| Except.error e => handle e
instance : Monad (Except ε) :=
{ pure := @Except.return _, bind := @Except.bind _, map := @Except.map _ }
end Except
def ExceptT (ε : Type u) (m : Type u → Type v) (α : Type u) : Type v :=
m (Except ε α)
@[inline] def ExceptT.mk {ε : Type u} {m : Type u → Type v} {α : Type u} (x : m (Except ε α)) : ExceptT ε m α :=
x
@[inline] def ExceptT.run {ε : Type u} {m : Type u → Type v} {α : Type u} (x : ExceptT ε m α) : m (Except ε α) :=
x
namespace ExceptT
variables {ε : Type u} {m : Type u → Type v} [Monad m]
@[inline] protected def pure {α : Type u} (a : α) : ExceptT ε m α :=
ExceptT.mk $ pure (Except.ok a)
@[inline] protected def bindCont {α β : Type u} (f : α → ExceptT ε m β) : Except ε α → m (Except ε β)
| Except.ok a => f a
| Except.error e => pure (Except.error e)
@[inline] protected def bind {α β : Type u} (ma : ExceptT ε m α) (f : α → ExceptT ε m β) : ExceptT ε m β :=
ExceptT.mk $ ma >>= ExceptT.bindCont f
@[inline] protected def map {α β : Type u} (f : α → β) (x : ExceptT ε m α) : ExceptT ε m β :=
ExceptT.mk $ x >>= fun a => match a with
| (Except.ok a) => pure $ Except.ok (f a)
| (Except.error e) => pure $ Except.error e
@[inline] protected def lift {α : Type u} (t : m α) : ExceptT ε m α :=
ExceptT.mk $ Except.ok <$> t
instance exceptTOfExcept : HasMonadLift (Except ε) (ExceptT ε m) :=
⟨fun α e => ExceptT.mk $ pure e⟩
instance : HasMonadLift m (ExceptT ε m) :=
⟨@ExceptT.lift _ _ _⟩
@[inline] protected def catch {α : Type u} (ma : ExceptT ε m α) (handle : ε → ExceptT ε m α) : ExceptT ε m α :=
ExceptT.mk $ ma >>= fun res => match res with
| Except.ok a => pure (Except.ok a)
| Except.error e => (handle e)
instance (m') [Monad m'] : MonadFunctor m m' (ExceptT ε m) (ExceptT ε m') :=
⟨fun _ f x => f x⟩
instance : Monad (ExceptT ε m) :=
{ pure := @ExceptT.pure _ _ _, bind := @ExceptT.bind _ _ _, map := @ExceptT.map _ _ _ }
@[inline] protected def adapt {ε' α : Type u} (f : ε → ε') : ExceptT ε m α → ExceptT ε' m α :=
fun x => ExceptT.mk $ Except.mapError f <$> x
end ExceptT
/-- An implementation of [MonadError](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Except.html#t:MonadError) -/
class MonadExcept (ε : outParam (Type u)) (m : Type v → Type w) :=
(throw {} {α : Type v} : ε → m α)
(catch {} {α : Type v} : m α → (ε → m α) → m α)
namespace MonadExcept
variables {ε : Type u} {m : Type v → Type w}
@[inline] protected def orelse [MonadExcept ε m] {α : Type v} (t₁ t₂ : m α) : m α :=
catch t₁ $ fun _ => t₂
instance [MonadExcept ε m] {α : Type v} : HasOrelse (m α) :=
⟨MonadExcept.orelse⟩
/-- Alternative orelse operator that allows to select which exception should be used.
The default is to use the first exception since the standard `orelse` uses the second. -/
@[inline] def orelse' [MonadExcept ε m] {α : Type v} (t₁ t₂ : m α) (useFirstEx := true) : m α :=
catch t₁ $ fun e₁ => catch t₂ $ fun e₂ => throw (if useFirstEx then e₁ else e₂)
end MonadExcept
export MonadExcept (throw catch)
instance (m : Type u → Type v) (ε : Type u) [Monad m] : MonadExcept ε (ExceptT ε m) :=
{ throw := fun α e => ExceptT.mk $ pure (Except.error e),
catch := @ExceptT.catch ε _ _ }
instance (ε) : MonadExcept ε (Except ε) :=
{ throw := fun α => Except.error, catch := @Except.catch _ }
/-- Adapt a Monad stack, changing its top-most error Type.
Note: This class can be seen as a simplification of the more "principled" definition
```
class MonadExceptFunctor (ε ε' : outParam (Type u)) (n n' : Type u → Type u) :=
(map {} {α : Type u} : (∀ {m : Type u → Type u} [Monad m], ExceptT ε m α → ExceptT ε' m α) → n α → n' α)
```
-/
class MonadExceptAdapter (ε ε' : outParam (Type u)) (m m' : Type u → Type v) :=
(adaptExcept {} {α : Type u} : (ε → ε') → m α → m' α)
export MonadExceptAdapter (adaptExcept)
section
variables {ε ε' : Type u} {m m' : Type u → Type v}
instance monadExceptAdapterTrans {n n' : Type u → Type v} [MonadExceptAdapter ε ε' m m'] [MonadFunctor m m' n n'] : MonadExceptAdapter ε ε' n n' :=
⟨fun α f => monadMap (fun α => (adaptExcept f : m α → m' α))⟩
instance [Monad m] : MonadExceptAdapter ε ε' (ExceptT ε m) (ExceptT ε' m) :=
⟨fun α => ExceptT.adapt⟩
end
instance (ε m out) [MonadRun out m] : MonadRun (fun α => out (Except ε α)) (ExceptT ε m) :=
⟨fun α => run⟩
/-- Execute `x` and then execute `finalizer` even if `x` threw an exception -/
@[inline] def finally {ε α β : Type u} {m : Type u → Type v} [Monad m] [MonadExcept ε m] (x : m α) (finalizer : m β) : m α :=
catch
(do a ← x; finalizer; pure a)
(fun e => do finalizer; throw e)
|
fd89b1caa6fa646c6606a462a2987d6eef246149 | 57c233acf9386e610d99ed20ef139c5f97504ba3 | /src/deprecated/group.lean | c3ecbf527ffd9f6966544992059b05730b609cbd | [
"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 | 13,109 | lean | /-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import algebra.group.type_tags
import algebra.group.units_hom
import algebra.ring.basic
import data.equiv.mul_add
/-!
# Unbundled monoid and group homomorphisms
This file defines predicates for unbundled monoid and group homomorphisms. Though
bundled morphisms are preferred in mathlib, these unbundled predicates are still occasionally used
in mathlib, and probably will not go away before Lean 4
because Lean 3 often fails to coerce a bundled homomorphism to a function.
## Main Definitions
`is_monoid_hom` (deprecated), `is_group_hom` (deprecated)
## Tags
is_group_hom, is_monoid_hom
-/
universes u v
variables {α : Type u} {β : Type v}
/-- Predicate for maps which preserve an addition. -/
structure is_add_hom {α β : Type*} [has_add α] [has_add β] (f : α → β) : Prop :=
(map_add [] : ∀ x y, f (x + y) = f x + f y)
/-- Predicate for maps which preserve a multiplication. -/
@[to_additive]
structure is_mul_hom {α β : Type*} [has_mul α] [has_mul β] (f : α → β) : Prop :=
(map_mul [] : ∀ x y, f (x * y) = f x * f y)
namespace is_mul_hom
variables [has_mul α] [has_mul β] {γ : Type*} [has_mul γ]
/-- The identity map preserves multiplication. -/
@[to_additive "The identity map preserves addition"]
lemma id : is_mul_hom (id : α → α) := {map_mul := λ _ _, rfl}
/-- The composition of maps which preserve multiplication, also preserves multiplication. -/
@[to_additive "The composition of addition preserving maps also preserves addition"]
lemma comp {f : α → β} {g : β → γ} (hf : is_mul_hom f) (hg : is_mul_hom g) : is_mul_hom (g ∘ f) :=
{ map_mul := λ x y, by simp only [function.comp, hf.map_mul, hg.map_mul] }
/-- A product of maps which preserve multiplication,
preserves multiplication when the target is commutative. -/
@[to_additive]
lemma mul {α β} [semigroup α] [comm_semigroup β]
{f g : α → β} (hf : is_mul_hom f) (hg : is_mul_hom g) :
is_mul_hom (λ a, f a * g a) :=
{ map_mul := λ a b, by simp only [hf.map_mul, hg.map_mul, mul_comm, mul_assoc, mul_left_comm] }
/-- The inverse of a map which preserves multiplication,
preserves multiplication when the target is commutative. -/
@[to_additive]
lemma inv {α β} [has_mul α] [comm_group β] {f : α → β} (hf : is_mul_hom f) :
is_mul_hom (λ a, (f a)⁻¹) :=
{ map_mul := λ a b, (hf.map_mul a b).symm ▸ mul_inv _ _ }
end is_mul_hom
/-- Predicate for add_monoid homomorphisms (deprecated -- use the bundled `monoid_hom` version). -/
structure is_add_monoid_hom [add_zero_class α] [add_zero_class β] (f : α → β)
extends is_add_hom f : Prop :=
(map_zero [] : f 0 = 0)
/-- Predicate for monoid homomorphisms (deprecated -- use the bundled `monoid_hom` version). -/
@[to_additive]
structure is_monoid_hom [mul_one_class α] [mul_one_class β] (f : α → β)
extends is_mul_hom f : Prop :=
(map_one [] : f 1 = 1)
namespace monoid_hom
variables {M : Type*} {N : Type*} [mM : mul_one_class M] [mN : mul_one_class N]
include mM mN
/-- Interpret a map `f : M → N` as a homomorphism `M →* N`. -/
@[to_additive "Interpret a map `f : M → N` as a homomorphism `M →+ N`."]
def of {f : M → N} (h : is_monoid_hom f) : M →* N :=
{ to_fun := f,
map_one' := h.2,
map_mul' := h.1.1 }
variables {mM mN}
@[simp, to_additive]
lemma coe_of {f : M → N} (hf : is_monoid_hom f) : ⇑ (monoid_hom.of hf) = f :=
rfl
@[to_additive]
lemma is_monoid_hom_coe (f : M →* N) : is_monoid_hom (f : M → N) :=
{ map_mul := f.map_mul,
map_one := f.map_one }
end monoid_hom
namespace mul_equiv
variables {M : Type*} {N : Type*} [mul_one_class M] [mul_one_class N]
/-- A multiplicative isomorphism preserves multiplication (deprecated). -/
@[to_additive]
theorem is_mul_hom (h : M ≃* N) : is_mul_hom h := ⟨h.map_mul⟩
/-- A multiplicative bijection between two monoids is a monoid hom
(deprecated -- use `mul_equiv.to_monoid_hom`). -/
@[to_additive]
lemma is_monoid_hom (h : M ≃* N) : is_monoid_hom h :=
{ map_mul := h.map_mul,
map_one := h.map_one }
end mul_equiv
namespace is_monoid_hom
variables [mul_one_class α] [mul_one_class β] {f : α → β} (hf : is_monoid_hom f)
/-- A monoid homomorphism preserves multiplication. -/
@[to_additive]
lemma map_mul (x y) : f (x * y) = f x * f y :=
hf.map_mul x y
/-- The inverse of a map which preserves multiplication,
preserves multiplication when the target is commutative. -/
@[to_additive]
lemma inv {α β} [mul_one_class α] [comm_group β] {f : α → β} (hf : is_monoid_hom f) :
is_monoid_hom (λ a, (f a)⁻¹) :=
{ map_one := hf.map_one.symm ▸ one_inv,
map_mul := λ a b, (hf.map_mul a b).symm ▸ mul_inv _ _ }
end is_monoid_hom
/-- A map to a group preserving multiplication is a monoid homomorphism. -/
@[to_additive]
theorem is_mul_hom.to_is_monoid_hom [mul_one_class α] [group β] {f : α → β} (hf : is_mul_hom f) :
is_monoid_hom f :=
{ map_one := mul_right_eq_self.1 $ by rw [← hf.map_mul, one_mul],
map_mul := hf.map_mul }
namespace is_monoid_hom
variables [mul_one_class α] [mul_one_class β] {f : α → β}
/-- The identity map is a monoid homomorphism. -/
@[to_additive]
lemma id : is_monoid_hom (@id α) := { map_one := rfl, map_mul := λ _ _, rfl }
/-- The composite of two monoid homomorphisms is a monoid homomorphism. -/
@[to_additive]
lemma comp (hf : is_monoid_hom f) {γ} [mul_one_class γ] {g : β → γ} (hg : is_monoid_hom g) :
is_monoid_hom (g ∘ f) :=
{ map_one := show g _ = 1, by rw [hf.map_one, hg.map_one],
..is_mul_hom.comp hf.to_is_mul_hom hg.to_is_mul_hom }
end is_monoid_hom
namespace is_add_monoid_hom
/-- Left multiplication in a ring is an additive monoid morphism. -/
lemma is_add_monoid_hom_mul_left {γ : Type*} [non_unital_non_assoc_semiring γ] (x : γ) :
is_add_monoid_hom (λ y : γ, x * y) :=
{ map_zero := mul_zero x, map_add := λ y z, mul_add x y z }
/-- Right multiplication in a ring is an additive monoid morphism. -/
lemma is_add_monoid_hom_mul_right {γ : Type*} [non_unital_non_assoc_semiring γ] (x : γ) :
is_add_monoid_hom (λ y : γ, y * x) :=
{ map_zero := zero_mul x, map_add := λ y z, add_mul y z x }
end is_add_monoid_hom
/-- Predicate for additive group homomorphism (deprecated -- use bundled `monoid_hom`). -/
structure is_add_group_hom [add_group α] [add_group β] (f : α → β) extends is_add_hom f : Prop
/-- Predicate for group homomorphisms (deprecated -- use bundled `monoid_hom`). -/
@[to_additive]
structure is_group_hom [group α] [group β] (f : α → β) extends is_mul_hom f : Prop
@[to_additive]
lemma monoid_hom.is_group_hom {G H : Type*} {_ : group G} {_ : group H} (f : G →* H) :
is_group_hom (f : G → H) :=
{ map_mul := f.map_mul }
@[to_additive]
lemma mul_equiv.is_group_hom {G H : Type*} {_ : group G} {_ : group H} (h : G ≃* H) :
is_group_hom h := { map_mul := h.map_mul }
/-- Construct `is_group_hom` from its only hypothesis. -/
@[to_additive]
lemma is_group_hom.mk' [group α] [group β] {f : α → β} (hf : ∀ x y, f (x * y) = f x * f y) :
is_group_hom f :=
{ map_mul := hf }
namespace is_group_hom
variables [group α] [group β] {f : α → β} (hf : is_group_hom f)
open is_mul_hom (map_mul)
lemma map_mul : ∀ (x y), f (x * y) = f x * f y := hf.to_is_mul_hom.map_mul
/-- A group homomorphism is a monoid homomorphism. -/
@[to_additive]
lemma to_is_monoid_hom : is_monoid_hom f :=
hf.to_is_mul_hom.to_is_monoid_hom
/-- A group homomorphism sends 1 to 1. -/
@[to_additive]
lemma map_one : f 1 = 1 := hf.to_is_monoid_hom.map_one
/-- A group homomorphism sends inverses to inverses. -/
@[to_additive]
theorem map_inv (hf : is_group_hom f) (a : α) : f a⁻¹ = (f a)⁻¹ :=
eq_inv_of_mul_eq_one $ by rw [← hf.map_mul, inv_mul_self, hf.map_one]
/-- The identity is a group homomorphism. -/
@[to_additive]
lemma id : is_group_hom (@id α) := { map_mul := λ _ _, rfl}
/-- The composition of two group homomorphisms is a group homomorphism. -/
@[to_additive]
lemma comp (hf : is_group_hom f) {γ} [group γ] {g : β → γ} (hg : is_group_hom g) :
is_group_hom (g ∘ f) :=
{ ..is_mul_hom.comp hf.to_is_mul_hom hg.to_is_mul_hom }
/-- A group homomorphism is injective iff its kernel is trivial. -/
@[to_additive]
lemma injective_iff {f : α → β} (hf : is_group_hom f) :
function.injective f ↔ (∀ a, f a = 1 → a = 1) :=
⟨λ h _, by rw ← hf.map_one; exact @h _ _,
λ h x y hxy, by rw [← inv_inv (f x), inv_eq_iff_mul_eq_one, ← hf.map_inv,
← hf.map_mul] at hxy;
simpa using inv_eq_of_mul_eq_one (h _ hxy)⟩
/-- The product of group homomorphisms is a group homomorphism if the target is commutative. -/
@[to_additive]
lemma mul {α β} [group α] [comm_group β]
{f g : α → β} (hf : is_group_hom f) (hg : is_group_hom g) :
is_group_hom (λa, f a * g a) :=
{ map_mul := (hf.to_is_mul_hom.mul hg.to_is_mul_hom).map_mul }
/-- The inverse of a group homomorphism is a group homomorphism if the target is commutative. -/
@[to_additive]
lemma inv {α β} [group α] [comm_group β] {f : α → β} (hf : is_group_hom f) :
is_group_hom (λa, (f a)⁻¹) :=
{ map_mul := hf.to_is_mul_hom.inv.map_mul }
end is_group_hom
namespace ring_hom
/-!
These instances look redundant, because `deprecated.ring` provides `is_ring_hom` for a `→+*`.
Nevertheless these are harmless, and helpful for stripping out dependencies on `deprecated.ring`.
-/
variables {R : Type*} {S : Type*}
section
variables [non_assoc_semiring R] [non_assoc_semiring S]
lemma to_is_monoid_hom (f : R →+* S) : is_monoid_hom f :=
{ map_one := f.map_one,
map_mul := f.map_mul }
lemma to_is_add_monoid_hom (f : R →+* S) : is_add_monoid_hom f :=
{ map_zero := f.map_zero,
map_add := f.map_add }
end
section
variables [ring R] [ring S]
lemma to_is_add_group_hom (f : R →+* S) : is_add_group_hom f :=
{ map_add := f.map_add }
end
end ring_hom
/-- Inversion is a group homomorphism if the group is commutative. -/
@[to_additive neg.is_add_group_hom
"Negation is an `add_group` homomorphism if the `add_group` is commutative."]
lemma inv.is_group_hom [comm_group α] : is_group_hom (has_inv.inv : α → α) :=
{ map_mul := mul_inv }
namespace is_add_group_hom
variables [add_group α] [add_group β] {f : α → β} (hf : is_add_group_hom f)
/-- Additive group homomorphisms commute with subtraction. -/
lemma map_sub (a b) : f (a - b) = f a - f b :=
calc f (a - b) = f (a + -b) : congr_arg f (sub_eq_add_neg a b)
... = f a + f (-b) : hf.map_add _ _
... = f a + -f b : by rw [hf.map_neg]
... = f a - f b : (sub_eq_add_neg _ _).symm
end is_add_group_hom
/-- The difference of two additive group homomorphisms is an additive group
homomorphism if the target is commutative. -/
lemma is_add_group_hom.sub {α β} [add_group α] [add_comm_group β]
{f g : α → β} (hf : is_add_group_hom f) (hg : is_add_group_hom g) :
is_add_group_hom (λa, f a - g a) :=
by simpa only [sub_eq_add_neg] using hf.add hg.neg
namespace units
variables {M : Type*} {N : Type*} [monoid M] [monoid N]
/-- The group homomorphism on units induced by a multiplicative morphism. -/
@[reducible] def map' {f : M → N} (hf : is_monoid_hom f) : Mˣ →* Nˣ :=
map (monoid_hom.of hf)
@[simp] lemma coe_map' {f : M → N} (hf : is_monoid_hom f) (x : Mˣ) :
↑((map' hf : Mˣ → Nˣ) x) = f x :=
rfl
lemma coe_is_monoid_hom : is_monoid_hom (coe : Mˣ → M) := (coe_hom M).is_monoid_hom_coe
end units
namespace is_unit
variables {M : Type*} {N : Type*} [monoid M] [monoid N] {x : M}
lemma map' {f : M → N} (hf :is_monoid_hom f) {x : M} (h : is_unit x) :
is_unit (f x) :=
h.map (monoid_hom.of hf)
end is_unit
lemma additive.is_add_hom [has_mul α] [has_mul β] {f : α → β} (hf : is_mul_hom f) :
@is_add_hom (additive α) (additive β) _ _ f :=
{ map_add := is_mul_hom.map_mul hf }
lemma multiplicative.is_mul_hom [has_add α] [has_add β] {f : α → β} (hf : is_add_hom f) :
@is_mul_hom (multiplicative α) (multiplicative β) _ _ f :=
{ map_mul := is_add_hom.map_add hf }
-- defeq abuse
lemma additive.is_add_monoid_hom [mul_one_class α] [mul_one_class β] {f : α → β}
(hf : is_monoid_hom f) : @is_add_monoid_hom (additive α) (additive β) _ _ f :=
{ map_zero := hf.map_one,
..additive.is_add_hom hf.to_is_mul_hom }
lemma multiplicative.is_monoid_hom
[add_zero_class α] [add_zero_class β] {f : α → β} (hf : is_add_monoid_hom f) :
@is_monoid_hom (multiplicative α) (multiplicative β) _ _ f :=
{ map_one := is_add_monoid_hom.map_zero hf,
..multiplicative.is_mul_hom hf.to_is_add_hom }
lemma additive.is_add_group_hom [group α] [group β] {f : α → β} (hf : is_group_hom f) :
@is_add_group_hom (additive α) (additive β) _ _ f :=
{ map_add := hf.to_is_mul_hom.map_mul }
lemma multiplicative.is_group_hom [add_group α] [add_group β] {f : α → β}
(hf : is_add_group_hom f) : @is_group_hom (multiplicative α) (multiplicative β) _ _ f :=
{ map_mul := hf.to_is_add_hom.map_add }
|
d3bdcae8eb596b091ccb2dbcf3005943bb290103 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/topology/sheaves/sheafify.lean | acc3b40344654b26d51bb9091aa6063663e1c90e | [
"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 | 4,400 | lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import topology.sheaves.local_predicate
import topology.sheaves.stalks
/-!
# Sheafification of `Type` valued presheaves
We construct the sheafification of a `Type` valued presheaf,
as the subsheaf of dependent functions into the stalks
consisting of functions which are locally germs.
We show that the stalks of the sheafification are isomorphic to the original stalks,
via `stalk_to_fiber` which evaluates a germ of a dependent function at a point.
We construct a morphism `to_sheafify` from a presheaf to (the underlying presheaf of)
its sheafification, given by sending a section to its collection of germs.
## Future work
Show that the map induced on stalks by `to_sheafify` is the inverse of `stalk_to_fiber`.
Show sheafification is a functor from presheaves to sheaves,
and that it is the left adjoint of the forgetful functor,
following <https://stacks.math.columbia.edu/tag/007X>.
-/
universes v
noncomputable theory
open Top
open opposite
open topological_space
variables {X : Top.{v}} (F : presheaf (Type v) X)
namespace Top.presheaf
namespace sheafify
/--
The prelocal predicate on functions into the stalks, asserting that the function is equal to a germ.
-/
def is_germ : prelocal_predicate (λ x, F.stalk x) :=
{ pred := λ U f, ∃ (g : F.obj (op U)), ∀ x : U, f x = F.germ x g,
res := λ V U i f ⟨g, p⟩, ⟨F.map i.op g, λ x, (p (i x)).trans (F.germ_res_apply _ _ _).symm⟩, }
/--
The local predicate on functions into the stalks,
asserting that the function is locally equal to a germ.
-/
def is_locally_germ : local_predicate (λ x, F.stalk x) := (is_germ F).sheafify
end sheafify
/--
The sheafification of a `Type` valued presheaf, defined as the functions into the stalks which
are locally equal to germs.
-/
def sheafify : sheaf (Type v) X :=
subsheaf_to_Types (sheafify.is_locally_germ F)
/--
The morphism from a presheaf to its sheafification,
sending each section to its germs.
(This forms the unit of the adjunction.)
-/
def to_sheafify : F ⟶ F.sheafify.1 :=
{ app := λ U f, ⟨λ x, F.germ x f, prelocal_predicate.sheafify_of ⟨f, λ x, rfl⟩⟩,
naturality' := λ U U' f, by { ext x ⟨u, m⟩, exact germ_res_apply F f.unop ⟨u, m⟩ x } }
/--
The natural morphism from the stalk of the sheafification to the original stalk.
In `sheafify_stalk_iso` we show this is an isomorphism.
-/
def stalk_to_fiber (x : X) : F.sheafify.1.stalk x ⟶ F.stalk x :=
stalk_to_fiber (sheafify.is_locally_germ F) x
lemma stalk_to_fiber_surjective (x : X) : function.surjective (F.stalk_to_fiber x) :=
begin
apply stalk_to_fiber_surjective,
intro t,
obtain ⟨U, m, s, rfl⟩ := F.germ_exist _ t,
{ use ⟨U, m⟩,
fsplit,
{ exact λ y, F.germ y s, },
{ exact ⟨prelocal_predicate.sheafify_of ⟨s, (λ _, rfl)⟩, rfl⟩, }, },
end
lemma stalk_to_fiber_injective (x : X) : function.injective (F.stalk_to_fiber x) :=
begin
apply stalk_to_fiber_injective,
intros,
rcases hU ⟨x, U.2⟩ with ⟨U', mU, iU, gU, wU⟩,
rcases hV ⟨x, V.2⟩ with ⟨V', mV, iV, gV, wV⟩,
have wUx := wU ⟨x, mU⟩,
dsimp at wUx, erw wUx at e, clear wUx,
have wVx := wV ⟨x, mV⟩,
dsimp at wVx, erw wVx at e, clear wVx,
rcases F.germ_eq x mU mV gU gV e with ⟨W, mW, iU', iV', e'⟩,
dsimp at e',
use ⟨W ⊓ (U' ⊓ V'), ⟨mW, mU, mV⟩⟩,
refine ⟨_, _, _⟩,
{ change W ⊓ (U' ⊓ V') ⟶ U.val,
exact (opens.inf_le_right _ _) ≫ (opens.inf_le_left _ _) ≫ iU, },
{ change W ⊓ (U' ⊓ V') ⟶ V.val,
exact (opens.inf_le_right _ _) ≫ (opens.inf_le_right _ _) ≫ iV, },
{ intro w,
dsimp,
specialize wU ⟨w.1, w.2.2.1⟩,
dsimp at wU,
specialize wV ⟨w.1, w.2.2.2⟩,
dsimp at wV,
erw [wU, ←F.germ_res iU' ⟨w, w.2.1⟩, wV, ←F.germ_res iV' ⟨w, w.2.1⟩,
category_theory.types_comp_apply, category_theory.types_comp_apply, e'] },
end
/--
The isomorphism betweeen a stalk of the sheafification and the original stalk.
-/
def sheafify_stalk_iso (x : X) : F.sheafify.1.stalk x ≅ F.stalk x :=
(equiv.of_bijective _ ⟨stalk_to_fiber_injective _ _, stalk_to_fiber_surjective _ _⟩).to_iso
-- PROJECT functoriality, and that sheafification is the left adjoint of the forgetful functor.
end Top.presheaf
|
c05e9ab1f18fa7186c4282a3d2faf6dde862fb1b | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/algebra/order/interval.lean | 5372b31fabdea9ef3dd077b7c6a5372889cdd348 | [
"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 | 15,280 | 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 algebra.big_operators.order
import algebra.group.prod
import data.option.n_ary
import data.set.pointwise.basic
import order.interval
import tactic.positivity
/-!
# Interval arithmetic
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file defines arithmetic operations on intervals and prove their correctness. Note that this is
full precision operations. The essentials of float operations can be found
in `data.fp.basic`. We have not yet integrated these with the rest of the library.
-/
open function set
open_locale big_operators pointwise
universe u
variables {ι α : Type*}
/-! ### One/zero -/
section one
section preorder
variables [preorder α] [has_one α]
@[to_additive] instance : has_one (nonempty_interval α) := ⟨nonempty_interval.pure 1⟩
@[to_additive] instance : has_one (interval α) := ⟨interval.pure 1⟩
namespace nonempty_interval
@[simp, to_additive to_prod_zero] lemma to_prod_one : (1 : nonempty_interval α).to_prod = 1 := rfl
@[to_additive] lemma fst_one : (1 : nonempty_interval α).fst = 1 := rfl
@[to_additive] lemma snd_one : (1 : nonempty_interval α).snd = 1 := rfl
@[simp, norm_cast, to_additive]
lemma coe_one_interval : ((1 : nonempty_interval α) : interval α) = 1 := rfl
@[simp, to_additive] lemma pure_one : pure (1 : α) = 1 := rfl
end nonempty_interval
namespace interval
@[simp, to_additive] lemma pure_one : pure (1 : α) = 1 := rfl
@[simp, to_additive] lemma one_ne_bot : (1 : interval α) ≠ ⊥ := pure_ne_bot
@[simp, to_additive] lemma bot_ne_one : (⊥ : interval α) ≠ 1 := bot_ne_pure
end interval
end preorder
section partial_order
variables [partial_order α] [has_one α]
namespace nonempty_interval
@[simp, to_additive] lemma coe_one : ((1 : nonempty_interval α) : set α) = 1 := coe_pure _
@[to_additive] lemma one_mem_one : (1 : α) ∈ (1 : nonempty_interval α) := ⟨le_rfl, le_rfl⟩
end nonempty_interval
namespace interval
@[simp, to_additive] lemma coe_one : ((1 : interval α) : set α) = 1 := Icc_self _
@[to_additive] lemma one_mem_one : (1 : α) ∈ (1 : interval α) := ⟨le_rfl, le_rfl⟩
end interval
end partial_order
end one
/-!
### Addition/multiplication
Note that this multiplication does not apply to `ℚ` or `ℝ`.
-/
section mul
variables [preorder α] [has_mul α] [covariant_class α α (*) (≤)]
[covariant_class α α (swap (*)) (≤)]
@[to_additive] instance : has_mul (nonempty_interval α) :=
⟨λ s t, ⟨s.to_prod * t.to_prod, mul_le_mul' s.fst_le_snd t.fst_le_snd⟩⟩
@[to_additive] instance : has_mul (interval α) := ⟨option.map₂ (*)⟩
namespace nonempty_interval
variables (s t : nonempty_interval α) (a b : α)
@[simp, to_additive to_prod_add] lemma to_prod_mul : (s * t).to_prod = s.to_prod * t.to_prod := rfl
@[to_additive] lemma fst_mul : (s * t).fst = s.fst * t.fst := rfl
@[to_additive] lemma snd_mul : (s * t).snd = s.snd * t.snd := rfl
@[simp, to_additive] lemma coe_mul_interval : (↑(s * t) : interval α) = s * t := rfl
@[simp, to_additive] lemma pure_mul_pure : pure a * pure b = pure (a * b) := rfl
end nonempty_interval
namespace interval
variables (s t : interval α)
@[simp, to_additive] lemma bot_mul : ⊥ * t = ⊥ := rfl
@[simp, to_additive] lemma mul_bot : s * ⊥ = ⊥ := option.map₂_none_right _ _
end interval
end mul
/-! ### Powers -/
-- TODO: if `to_additive` gets improved sufficiently, derive this from `has_pow`
instance nonempty_interval.has_nsmul [add_monoid α] [preorder α] [covariant_class α α (+) (≤)]
[covariant_class α α (swap (+)) (≤)] : has_smul ℕ (nonempty_interval α) :=
⟨λ n s, ⟨(n • s.fst, n • s.snd), nsmul_le_nsmul_of_le_right s.fst_le_snd _⟩⟩
section pow
variables [monoid α] [preorder α] [covariant_class α α (*) (≤)] [covariant_class α α (swap (*)) (≤)]
@[to_additive nonempty_interval.has_nsmul]
instance nonempty_interval.has_pow : has_pow (nonempty_interval α) ℕ :=
⟨λ s n, ⟨s.to_prod ^ n, pow_le_pow_of_le_left' s.fst_le_snd _⟩⟩
namespace nonempty_interval
variables (s : nonempty_interval α) (a : α) (n : ℕ)
@[simp, to_additive to_prod_nsmul] lemma to_prod_pow : (s ^ n).to_prod = s.to_prod ^ n := rfl
@[to_additive] lemma fst_pow : (s ^ n).fst = s.fst ^ n := rfl
@[to_additive] lemma snd_pow : (s ^ n).snd = s.snd ^ n := rfl
@[simp, to_additive] lemma pure_pow : pure a ^ n = pure (a ^ n) := rfl
end nonempty_interval
end pow
namespace nonempty_interval
@[to_additive]
instance [ordered_comm_monoid α] : comm_monoid (nonempty_interval α) :=
nonempty_interval.to_prod_injective.comm_monoid _ to_prod_one to_prod_mul to_prod_pow
end nonempty_interval
@[to_additive]
instance [ordered_comm_monoid α] : mul_one_class (interval α) :=
{ mul := (*),
one := 1,
one_mul := λ s, (option.map₂_coe_left _ _ _).trans $
by simp only [nonempty_interval.pure_one, one_mul, ←id_def, option.map_id, id],
mul_one := λ s, (option.map₂_coe_right _ _ _).trans $
by simp only [nonempty_interval.pure_one, mul_one, ←id_def, option.map_id, id] }
@[to_additive]
instance [ordered_comm_monoid α] : comm_monoid (interval α) :=
{ mul_comm := λ _ _, option.map₂_comm mul_comm,
mul_assoc := λ _ _ _, option.map₂_assoc mul_assoc,
..interval.mul_one_class }
namespace nonempty_interval
@[simp, to_additive] lemma coe_pow_interval [ordered_comm_monoid α] (s : nonempty_interval α)
(n : ℕ) :
(↑(s ^ n) : interval α) = s ^ n :=
map_pow (⟨coe, coe_one_interval, coe_mul_interval⟩ : nonempty_interval α →* interval α) _ _
end nonempty_interval
namespace interval
variables [ordered_comm_monoid α] (s : interval α) {n : ℕ}
@[to_additive] lemma bot_pow : ∀ {n : ℕ} (hn : n ≠ 0), (⊥ : interval α) ^ n = ⊥
| 0 h := (h rfl).elim
| (nat.succ n) _ := bot_mul (⊥ ^ n)
end interval
/-!
### Subtraction
Subtraction is defined more generally than division so that it applies to `ℕ` (and `has_ordered_div`
is not a thing and probably should not become one).
-/
section sub
variables [preorder α] [add_comm_semigroup α] [has_sub α] [has_ordered_sub α]
[covariant_class α α (+) (≤)]
instance : has_sub (nonempty_interval α) :=
⟨λ s t, ⟨(s.fst - t.snd, s.snd - t.fst), tsub_le_tsub s.fst_le_snd t.fst_le_snd⟩⟩
instance : has_sub (interval α) := ⟨option.map₂ has_sub.sub⟩
namespace nonempty_interval
variables (s t : nonempty_interval α) {a b : α}
@[simp] lemma fst_sub : (s - t).fst = s.fst - t.snd := rfl
@[simp] lemma snd_sub : (s - t).snd = s.snd - t.fst := rfl
@[simp] lemma coe_sub_interval : (↑(s - t) : interval α) = s - t := rfl
lemma sub_mem_sub (ha : a ∈ s) (hb : b ∈ t) : a - b ∈ s - t :=
⟨tsub_le_tsub ha.1 hb.2, tsub_le_tsub ha.2 hb.1⟩
@[simp] lemma pure_sub_pure (a b : α) : pure a - pure b = pure (a - b) := rfl
end nonempty_interval
namespace interval
variables (s t : interval α)
@[simp] lemma bot_sub : ⊥ - t = ⊥ := rfl
@[simp] lemma sub_bot : s - ⊥ = ⊥ := option.map₂_none_right _ _
end interval
end sub
/-!
### Division in ordered groups
Note that this division does not apply to `ℚ` or `ℝ`.
-/
section div
variables [preorder α] [comm_group α] [covariant_class α α (*) (≤)]
@[to_additive] instance : has_div (nonempty_interval α) :=
⟨λ s t, ⟨(s.fst / t.snd, s.snd / t.fst), div_le_div'' s.fst_le_snd t.fst_le_snd⟩⟩
@[to_additive] instance : has_div (interval α) := ⟨option.map₂ (/)⟩
namespace nonempty_interval
variables (s t : nonempty_interval α) (a b : α)
@[simp, to_additive] lemma fst_div : (s / t).fst = s.fst / t.snd := rfl
@[simp, to_additive] lemma snd_div : (s / t).snd = s.snd / t.fst := rfl
@[simp, to_additive] lemma coe_div_interval : (↑(s / t) : interval α) = s / t := rfl
@[to_additive] lemma div_mem_div (ha : a ∈ s) (hb : b ∈ t) : a / b ∈ s / t :=
⟨div_le_div'' ha.1 hb.2, div_le_div'' ha.2 hb.1⟩
@[simp, to_additive] lemma pure_div_pure : pure a / pure b = pure (a / b) := rfl
end nonempty_interval
namespace interval
variables (s t : interval α)
@[simp, to_additive] lemma bot_div : ⊥ / t = ⊥ := rfl
@[simp, to_additive] lemma div_bot : s / ⊥ = ⊥ := option.map₂_none_right _ _
end interval
end div
/-! ### Negation/inversion -/
section inv
variables [ordered_comm_group α]
@[to_additive] instance : has_inv (nonempty_interval α) :=
⟨λ s, ⟨(s.snd⁻¹, s.fst⁻¹), inv_le_inv' s.fst_le_snd⟩⟩
@[to_additive] instance : has_inv (interval α) := ⟨option.map has_inv.inv⟩
namespace nonempty_interval
variables (s t : nonempty_interval α) (a : α)
@[simp, to_additive] lemma fst_inv : s⁻¹.fst = s.snd⁻¹ := rfl
@[simp, to_additive] lemma snd_inv : s⁻¹.snd = s.fst⁻¹ := rfl
@[simp, to_additive] lemma coe_inv_interval : (↑(s⁻¹) : interval α) = s⁻¹ := rfl
@[to_additive] lemma inv_mem_inv (ha : a ∈ s) : a⁻¹ ∈ s⁻¹ := ⟨inv_le_inv' ha.2, inv_le_inv' ha.1⟩
@[simp, to_additive] lemma inv_pure : (pure a)⁻¹ = pure a⁻¹ := rfl
end nonempty_interval
@[simp, to_additive] lemma interval.inv_bot : (⊥ : interval α)⁻¹ = ⊥ := rfl
end inv
namespace nonempty_interval
variables [ordered_comm_group α] {s t : nonempty_interval α}
@[to_additive] protected lemma mul_eq_one_iff :
s * t = 1 ↔ ∃ a b, s = pure a ∧ t = pure b ∧ a * b = 1 :=
begin
refine ⟨λ h, _, _⟩,
{ rw [ext_iff, prod.ext_iff] at h,
have := (mul_le_mul_iff_of_ge s.fst_le_snd t.fst_le_snd).1 (h.2.trans h.1.symm).le,
refine ⟨s.fst, t.fst, _, _, h.1⟩; ext; try { refl },
exacts [this.1.symm, this.2.symm] },
{ rintro ⟨b, c, rfl, rfl, h⟩,
rw [pure_mul_pure, h, pure_one] }
end
instance {α : Type u} [ordered_add_comm_group α] : subtraction_comm_monoid (nonempty_interval α) :=
{ neg := has_neg.neg,
sub := has_sub.sub,
sub_eq_add_neg := λ s t, by ext; exact sub_eq_add_neg _ _,
neg_neg := λ s, by ext; exact neg_neg _,
neg_add_rev := λ s t, by ext; exact neg_add_rev _ _,
neg_eq_of_add := λ s t h, begin
obtain ⟨a, b, rfl, rfl, hab⟩ := nonempty_interval.add_eq_zero_iff.1 h,
rw [neg_pure, neg_eq_of_add_eq_zero_right hab],
end,
..nonempty_interval.add_comm_monoid }
@[to_additive nonempty_interval.subtraction_comm_monoid]
instance : division_comm_monoid (nonempty_interval α) :=
{ inv := has_inv.inv,
div := (/),
div_eq_mul_inv := λ s t, by ext; exact div_eq_mul_inv _ _,
inv_inv := λ s, by ext; exact inv_inv _,
mul_inv_rev := λ s t, by ext; exact mul_inv_rev _ _,
inv_eq_of_mul := λ s t h, begin
obtain ⟨a, b, rfl, rfl, hab⟩ := nonempty_interval.mul_eq_one_iff.1 h,
rw [inv_pure, inv_eq_of_mul_eq_one_right hab],
end,
..nonempty_interval.comm_monoid }
end nonempty_interval
namespace interval
variables [ordered_comm_group α] {s t : interval α}
@[to_additive] protected lemma mul_eq_one_iff :
s * t = 1 ↔ ∃ a b, s = pure a ∧ t = pure b ∧ a * b = 1 :=
begin
cases s,
{ simp [with_bot.none_eq_bot] },
cases t,
{ simp [with_bot.none_eq_bot] },
{ simp [with_bot.some_eq_coe, ←nonempty_interval.coe_mul_interval,
nonempty_interval.mul_eq_one_iff] }
end
instance {α : Type u} [ordered_add_comm_group α] : subtraction_comm_monoid (interval α) :=
{ neg := has_neg.neg,
sub := has_sub.sub,
sub_eq_add_neg := by rintro (_ | s) (_ | t); refl <|> exact congr_arg some (sub_eq_add_neg _ _),
neg_neg := by rintro (_ | s); refl <|> exact congr_arg some (neg_neg _),
neg_add_rev := by rintro (_ | s) (_ | t); refl <|> exact congr_arg some (neg_add_rev _ _),
neg_eq_of_add := by rintro (_ | s) (_ | t) h;
cases h <|> exact congr_arg some (neg_eq_of_add_eq_zero_right $ option.some_injective _ h),
..interval.add_comm_monoid }
@[to_additive interval.subtraction_comm_monoid]
instance : division_comm_monoid (interval α) :=
{ inv := has_inv.inv,
div := (/),
div_eq_mul_inv := by rintro (_ | s) (_ | t); refl <|> exact congr_arg some (div_eq_mul_inv _ _),
inv_inv := by rintro (_ | s); refl <|> exact congr_arg some (inv_inv _),
mul_inv_rev := by rintro (_ | s) (_ | t); refl <|> exact congr_arg some (mul_inv_rev _ _),
inv_eq_of_mul := by rintro (_ | s) (_ | t) h;
cases h <|> exact congr_arg some (inv_eq_of_mul_eq_one_right $ option.some_injective _ h),
..interval.comm_monoid }
end interval
section length
variables [ordered_add_comm_group α]
namespace nonempty_interval
variables (s t : nonempty_interval α) (a : α)
/-- The length of an interval is its first component minus its second component. This measures the
accuracy of the approximation by an interval. -/
def length : α := s.snd - s.fst
@[simp] lemma length_nonneg : 0 ≤ s.length := sub_nonneg_of_le s.fst_le_snd
@[simp] lemma length_pure : (pure a).length = 0 := sub_self _
@[simp] lemma length_zero : (0 : nonempty_interval α).length = 0 := length_pure _
@[simp] lemma length_neg : (-s).length = s.length := neg_sub_neg _ _
@[simp] lemma length_add : (s + t).length = s.length + t.length := add_sub_add_comm _ _ _ _
@[simp] lemma length_sub : (s - t).length = s.length + t.length := by simp [sub_eq_add_neg]
@[simp] lemma length_sum (f : ι → nonempty_interval α) (s : finset ι) :
(∑ i in s, f i).length = ∑ i in s, (f i).length :=
map_sum (⟨length, length_zero, length_add⟩ : nonempty_interval α →+ α) _ _
end nonempty_interval
namespace interval
variables (s t : interval α) (a : α)
/-- The length of an interval is its first component minus its second component. This measures the
accuracy of the approximation by an interval. -/
def length : interval α → α
| ⊥ := 0
| (s : nonempty_interval α) := s.length
@[simp] lemma length_nonneg : ∀ s : interval α, 0 ≤ s.length
| ⊥ := le_rfl
| (s : nonempty_interval α) := s.length_nonneg
@[simp] lemma length_pure : (pure a).length = 0 := nonempty_interval.length_pure _
@[simp] lemma length_zero : (0 : interval α).length = 0 := length_pure _
@[simp] lemma length_neg : ∀ s : interval α, (-s).length = s.length
| ⊥ := rfl
| (s : nonempty_interval α) := s.length_neg
lemma length_add_le : ∀ s t : interval α, (s + t).length ≤ s.length + t.length
| ⊥ _ := by simp
| _ ⊥ := by simp
| (s : nonempty_interval α) (t : nonempty_interval α) := (s.length_add t).le
lemma length_sub_le : (s - t).length ≤ s.length + t.length :=
by simpa [sub_eq_add_neg] using length_add_le s (-t)
lemma length_sum_le (f : ι → interval α) (s : finset ι) :
(∑ i in s, f i).length ≤ ∑ i in s, (f i).length :=
finset.le_sum_of_subadditive _ length_zero length_add_le _ _
end interval
end length
namespace tactic
open positivity
/-- Extension for the `positivity` tactic: The length of an interval is always nonnegative. -/
@[positivity]
meta def positivity_interval_length : expr → tactic strictness
| `(nonempty_interval.length %%s) := nonnegative <$> mk_app `nonempty_interval.length_nonneg [s]
| `(interval.length %%s) := nonnegative <$> mk_app `interval.length_nonneg [s]
| e := pp e >>= fail ∘ format.bracket "The expression `"
"` isn't of the form `nonempty_interval.length s` or `interval.length s`"
end tactic
|
50f49299c5801db765b9d525eb52a450586afe0e | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/data/nat/nth.lean | 42541ced019d360e1a664a6fbd739623a27be6e9 | [
"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 | 15,839 | lean | /-
Copyright (c) 2021 Vladimir Goryachev. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Vladimir Goryachev, Kyle Miller, Scott Morrison, Eric Rodriguez
-/
import data.nat.count
import data.set.intervals.monotone
import order.order_iso_nat
/-!
# The `n`th Number Satisfying a Predicate
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file defines a function for "what is the `n`th number that satisifies a given predicate `p`",
and provides lemmas that deal with this function and its connection to `nat.count`.
## Main definitions
* `nat.nth p n`: The `n`-th natural `k` (zero-indexed) such that `p k`. If there is no
such natural (that is, `p` is true for at most `n` naturals), then `nat.nth p n = 0`.
## Main results
* `nat.nth_set_card`: For a fintely-often true `p`, gives the cardinality of the set of numbers
satisfying `p` above particular values of `nth p`
* `nat.count_nth_gc`: Establishes a Galois connection between `nat.nth p` and `nat.count p`.
* `nat.nth_eq_order_iso_of_nat`: For an infinitely-ofter true predicate, `nth` agrees with the
order-isomorphism of the subtype to the natural numbers.
There has been some discussion on the subject of whether both of `nth` and
`nat.subtype.order_iso_of_nat` should exist. See discussion
[here](https://github.com/leanprover-community/mathlib/pull/9457#pullrequestreview-767221180).
Future work should address how lemmas that use these should be written.
-/
open finset
namespace nat
variable (p : ℕ → Prop)
/-- Find the `n`-th natural number satisfying `p` (indexed from `0`, so `nth p 0` is the first
natural number satisfying `p`), or `0` if there is no such number. See also
`subtype.order_iso_of_nat` for the order isomorphism with ℕ when `p` is infinitely often true. -/
noncomputable def nth (p : ℕ → Prop) (n : ℕ) : ℕ :=
by classical; exact
if h : set.finite (set_of p) then (h.to_finset.sort (≤)).nthd n 0
else @nat.subtype.order_iso_of_nat (set_of p) (set.infinite.to_subtype h) n
variable {p}
/-!
### Lemmas about `nat.nth` on a finite set
-/
theorem nth_of_card_le (hf : (set_of p).finite) {n : ℕ} (hn : hf.to_finset.card ≤ n) :
nth p n = 0 :=
by { rw [nth, dif_pos hf, list.nthd_eq_default], rwa [finset.length_sort] }
theorem nth_eq_nthd_sort (h : (set_of p).finite) (n : ℕ) :
nth p n = (h.to_finset.sort (≤)).nthd n 0 :=
dif_pos h
theorem nth_eq_order_emb_of_fin (hf : (set_of p).finite) {n : ℕ} (hn : n < hf.to_finset.card) :
nth p n = hf.to_finset.order_emb_of_fin rfl ⟨n, hn⟩ :=
by { rw [nth_eq_nthd_sort hf, finset.order_emb_of_fin_apply, list.nthd_eq_nth_le], refl }
theorem nth_strict_mono_on (hf : (set_of p).finite) :
strict_mono_on (nth p) (set.Iio hf.to_finset.card) :=
begin
rintro m (hm : m < _) n (hn : n < _) h,
simp only [nth_eq_order_emb_of_fin, *],
exact order_embedding.strict_mono _ h
end
theorem nth_lt_nth_of_lt_card (hf : (set_of p).finite) {m n : ℕ} (h : m < n)
(hn : n < hf.to_finset.card) : nth p m < nth p n :=
nth_strict_mono_on hf (h.trans hn) hn h
theorem nth_le_nth_of_lt_card (hf : (set_of p).finite) {m n : ℕ} (h : m ≤ n)
(hn : n < hf.to_finset.card) : nth p m ≤ nth p n :=
(nth_strict_mono_on hf).monotone_on (h.trans_lt hn) hn h
theorem lt_of_nth_lt_nth_of_lt_card (hf : (set_of p).finite) {m n : ℕ} (h : nth p m < nth p n)
(hm : m < hf.to_finset.card) : m < n :=
not_le.1 $ λ hle, h.not_le $ nth_le_nth_of_lt_card hf hle hm
theorem le_of_nth_le_nth_of_lt_card (hf : (set_of p).finite) {m n : ℕ} (h : nth p m ≤ nth p n)
(hm : m < hf.to_finset.card) : m ≤ n :=
not_lt.1 $ λ hlt, h.not_lt $ nth_lt_nth_of_lt_card hf hlt hm
theorem nth_inj_on (hf : (set_of p).finite) : (set.Iio hf.to_finset.card).inj_on (nth p) :=
(nth_strict_mono_on hf).inj_on
theorem range_nth_of_finite (hf : (set_of p).finite) : set.range (nth p) = insert 0 (set_of p) :=
by simpa only [← nth_eq_nthd_sort hf, mem_sort, set.finite.mem_to_finset]
using set.range_list_nthd (hf.to_finset.sort (≤)) 0
@[simp] theorem image_nth_Iio_card (hf : (set_of p).finite) :
nth p '' set.Iio hf.to_finset.card = set_of p :=
calc nth p '' set.Iio hf.to_finset.card = set.range (hf.to_finset.order_emb_of_fin rfl) :
by ext x; simp only [set.mem_image, set.mem_range, fin.exists_iff,
← nth_eq_order_emb_of_fin hf, set.mem_Iio, exists_prop]
... = set_of p : by rw [range_order_emb_of_fin, set.finite.coe_to_finset]
lemma nth_mem_of_lt_card {n : ℕ} (hf : (set_of p).finite) (hlt : n < hf.to_finset.card) :
p (nth p n) :=
(image_nth_Iio_card hf).subset $ set.mem_image_of_mem _ hlt
theorem exists_lt_card_finite_nth_eq (hf : (set_of p).finite) {x} (h : p x) :
∃ n, n < hf.to_finset.card ∧ nth p n = x :=
by rwa [← @set.mem_set_of_eq _ _ p, ← image_nth_Iio_card hf] at h
/-!
### Lemmas about `nat.nth` on an infinite set
-/
/-- When `s` is an infinite set, `nth` agrees with `nat.subtype.order_iso_of_nat`. -/
theorem nth_apply_eq_order_iso_of_nat (hf : (set_of p).infinite) (n : ℕ) :
nth p n = @nat.subtype.order_iso_of_nat (set_of p) hf.to_subtype n :=
by rw [nth, dif_neg hf]
/-- When `s` is an infinite set, `nth` agrees with `nat.subtype.order_iso_of_nat`. -/
theorem nth_eq_order_iso_of_nat (hf : (set_of p).infinite) :
nth p = coe ∘ @nat.subtype.order_iso_of_nat (set_of p) hf.to_subtype :=
funext $ nth_apply_eq_order_iso_of_nat hf
lemma nth_strict_mono (hf : (set_of p).infinite) : strict_mono (nth p) :=
begin
rw [nth_eq_order_iso_of_nat hf],
exact (subtype.strict_mono_coe _).comp (order_iso.strict_mono _)
end
lemma nth_injective (hf : (set_of p).infinite) : function.injective (nth p) :=
(nth_strict_mono hf).injective
lemma nth_monotone (hf : (set_of p).infinite) : monotone (nth p) :=
(nth_strict_mono hf).monotone
lemma nth_lt_nth (hf : (set_of p).infinite) {k n} : nth p k < nth p n ↔ k < n :=
(nth_strict_mono hf).lt_iff_lt
lemma nth_le_nth (hf : (set_of p).infinite) {k n} : nth p k ≤ nth p n ↔ k ≤ n :=
(nth_strict_mono hf).le_iff_le
lemma range_nth_of_infinite (hf : (set_of p).infinite) : set.range (nth p) = set_of p :=
begin
rw [nth_eq_order_iso_of_nat hf],
haveI := hf.to_subtype,
exact nat.subtype.coe_comp_of_nat_range
end
theorem nth_mem_of_infinite (hf : (set_of p).infinite) (n : ℕ) : p (nth p n) :=
set.range_subset_iff.1 (range_nth_of_infinite hf).le n
/-!
### Lemmas that work for finite and infinite sets
-/
theorem exists_lt_card_nth_eq {x} (h : p x) :
∃ n, (∀ hf : (set_of p).finite, n < hf.to_finset.card) ∧ nth p n = x :=
begin
refine (set_of p).finite_or_infinite.elim (λ hf, _) (λ hf, _),
{ rcases exists_lt_card_finite_nth_eq hf h with ⟨n, hn, hx⟩,
exact ⟨n, λ hf', hn, hx⟩ },
{ rw [← @set.mem_set_of_eq _ _ p, ← range_nth_of_infinite hf] at h,
rcases h with ⟨n, hx⟩,
exact ⟨n, λ hf', absurd hf' hf, hx⟩ }
end
theorem subset_range_nth : set_of p ⊆ set.range (nth p) :=
λ x (hx : p x), let ⟨n, _, hn⟩ := exists_lt_card_nth_eq hx in ⟨n, hn⟩
theorem range_nth_subset : set.range (nth p) ⊆ insert 0 (set_of p) :=
(set_of p).finite_or_infinite.elim (λ h, (range_nth_of_finite h).subset)
(λ h, (range_nth_of_infinite h).trans_subset (set.subset_insert _ _))
theorem nth_mem (n : ℕ) (h : ∀ hf : (set_of p).finite, n < hf.to_finset.card) : p (nth p n) :=
(set_of p).finite_or_infinite.elim (λ hf, nth_mem_of_lt_card hf (h hf))
(λ h, nth_mem_of_infinite h n)
theorem nth_lt_nth' {m n : ℕ} (hlt : m < n) (h : ∀ hf : (set_of p).finite, n < hf.to_finset.card) :
nth p m < nth p n :=
(set_of p).finite_or_infinite.elim (λ hf, nth_lt_nth_of_lt_card hf hlt (h _))
(λ hf, (nth_lt_nth hf).2 hlt)
theorem nth_le_nth' {m n : ℕ} (hle : m ≤ n) (h : ∀ hf : (set_of p).finite, n < hf.to_finset.card) :
nth p m ≤ nth p n :=
(set_of p).finite_or_infinite.elim (λ hf, nth_le_nth_of_lt_card hf hle (h _))
(λ hf, (nth_le_nth hf).2 hle)
theorem le_nth {n : ℕ} (h : ∀ hf : (set_of p).finite, n < hf.to_finset.card) : n ≤ nth p n :=
(set_of p).finite_or_infinite.elim
(λ hf, ((nth_strict_mono_on hf).mono $ set.Iic_subset_Iio.2 (h _)).Iic_id_le _ le_rfl)
(λ hf, (nth_strict_mono hf).id_le _)
theorem is_least_nth {n} (h : ∀ hf : (set_of p).finite, n < hf.to_finset.card) :
is_least { i | p i ∧ ∀ k < n, nth p k < i } (nth p n) :=
⟨⟨nth_mem n h, λ k hk, nth_lt_nth' hk h⟩, λ x hx, let ⟨k, hk, hkx⟩ := exists_lt_card_nth_eq hx.1
in (lt_or_le k n).elim (λ hlt, absurd hkx (hx.2 _ hlt).ne) (λ hle, hkx ▸ nth_le_nth' hle hk)⟩
theorem is_least_nth_of_lt_card {n : ℕ} (hf : (set_of p).finite) (hn : n < hf.to_finset.card) :
is_least { i | p i ∧ ∀ k < n, nth p k < i } (nth p n) :=
is_least_nth $ λ _, hn
theorem is_least_nth_of_infinite (hf : (set_of p).infinite) (n : ℕ) :
is_least { i | p i ∧ ∀ k < n, nth p k < i } (nth p n) :=
is_least_nth $ λ h, absurd h hf
/-- An alternative recursive definition of `nat.nth`: `nat.nth s n` is the infimum of `x ∈ s` such
that `nat.nth s k < x` for all `k < n`, if this set is nonempty. We do not assume that the set is
nonempty because we use the same "garbage value" `0` both for `Inf` on `ℕ` and for `nat.nth s n` for
`n ≥ card s`. -/
lemma nth_eq_Inf (p : ℕ → Prop) (n : ℕ) : nth p n = Inf {x | p x ∧ ∀ k < n, nth p k < x} :=
begin
by_cases hn : ∀ hf : (set_of p).finite, n < hf.to_finset.card,
{ exact (is_least_nth hn).cInf_eq.symm },
{ push_neg at hn,
rcases hn with ⟨hf, hn⟩,
rw [nth_of_card_le _ hn],
refine ((congr_arg Inf $ set.eq_empty_of_forall_not_mem $ λ k hk, _).trans Inf_empty).symm,
rcases exists_lt_card_nth_eq hk.1 with ⟨k, hlt, rfl⟩,
exact (hk.2 _ ((hlt hf).trans_le hn)).false }
end
lemma nth_zero : nth p 0 = Inf (set_of p) := by { rw nth_eq_Inf, simp }
@[simp] lemma nth_zero_of_zero (h : p 0) : nth p 0 = 0 := by simp [nth_zero, h]
lemma nth_zero_of_exists [decidable_pred p] (h : ∃ n, p n) : nth p 0 = nat.find h :=
by { rw [nth_zero], convert nat.Inf_def h }
lemma nth_eq_zero {n} :
nth p n = 0 ↔ p 0 ∧ n = 0 ∨ ∃ hf : (set_of p).finite, hf.to_finset.card ≤ n :=
begin
refine ⟨λ h, _, _⟩,
{ simp only [or_iff_not_imp_right, not_exists, not_le],
exact λ hn, ⟨h ▸ nth_mem _ hn, nonpos_iff_eq_zero.1 $ h ▸ le_nth hn⟩ },
{ rintro (⟨h₀, rfl⟩ | ⟨hf, hle⟩),
exacts [nth_zero_of_zero h₀, nth_of_card_le hf hle] }
end
lemma nth_eq_zero_mono (h₀ : ¬p 0) {a b : ℕ} (hab : a ≤ b) (ha : nth p a = 0) :
nth p b = 0 :=
begin
simp only [nth_eq_zero, h₀, false_and, false_or] at ha ⊢,
exact ha.imp (λ hf hle, hle.trans hab)
end
lemma le_nth_of_lt_nth_succ {k a : ℕ} (h : a < nth p (k + 1)) (ha : p a) :
a ≤ nth p k :=
begin
cases (set_of p).finite_or_infinite with hf hf,
{ rcases exists_lt_card_finite_nth_eq hf ha with ⟨n, hn, rfl⟩,
cases lt_or_le (k + 1) hf.to_finset.card with hk hk,
{ rwa [(nth_strict_mono_on hf).lt_iff_lt hn hk, lt_succ_iff,
← (nth_strict_mono_on hf).le_iff_le hn (k.lt_succ_self.trans hk)] at h },
{ rw [nth_of_card_le _ hk] at h,
exact absurd h (zero_le _).not_lt } },
{ rcases subset_range_nth ha with ⟨n, rfl⟩,
rwa [nth_lt_nth hf, lt_succ_iff, ← nth_le_nth hf] at h }
end
section count
variables (p) [decidable_pred p]
@[simp] lemma count_nth_zero : count p (nth p 0) = 0 :=
begin
rw [count_eq_card_filter_range, card_eq_zero, filter_eq_empty_iff, nth_zero],
exact λ n h₁ h₂, (mem_range.1 h₁).not_le (nat.Inf_le h₂)
end
lemma filter_range_nth_subset_insert (k : ℕ) :
(range (nth p (k + 1))).filter p ⊆ insert (nth p k) ((range (nth p k)).filter p) :=
begin
intros a ha,
simp only [mem_insert, mem_filter, mem_range] at ha ⊢,
exact (le_nth_of_lt_nth_succ ha.1 ha.2).eq_or_lt.imp_right (λ h, ⟨h, ha.2⟩)
end
variable {p}
lemma filter_range_nth_eq_insert {k : ℕ}
(hlt : ∀ hf : (set_of p).finite, k + 1 < hf.to_finset.card) :
(range (nth p (k + 1))).filter p = insert (nth p k) ((range (nth p k)).filter p) :=
begin
refine (filter_range_nth_subset_insert p k).antisymm (λ a ha, _),
simp only [mem_insert, mem_filter, mem_range] at ha ⊢,
have : nth p k < nth p (k + 1) := nth_lt_nth' k.lt_succ_self hlt,
rcases ha with (rfl | ⟨hlt, hpa⟩),
{ exact ⟨this, nth_mem _ (λ hf, k.lt_succ_self.trans (hlt hf))⟩ },
{ exact ⟨hlt.trans this, hpa⟩ },
end
lemma filter_range_nth_eq_insert_of_finite (hf : (set_of p).finite) {k : ℕ}
(hlt : k + 1 < hf.to_finset.card) :
(range (nth p (k + 1))).filter p = insert (nth p k) ((range (nth p k)).filter p) :=
filter_range_nth_eq_insert $ λ _, hlt
lemma filter_range_nth_eq_insert_of_infinite (hp : (set_of p).infinite) (k : ℕ) :
(range (nth p (k + 1))).filter p = insert (nth p k) ((range (nth p k)).filter p) :=
filter_range_nth_eq_insert $ λ hf, absurd hf hp
lemma count_nth {n : ℕ} (hn : ∀ hf : (set_of p).finite, n < hf.to_finset.card) :
count p (nth p n) = n :=
begin
induction n with k ihk,
{ exact count_nth_zero _ },
{ rw [count_eq_card_filter_range, filter_range_nth_eq_insert hn, card_insert_of_not_mem,
←count_eq_card_filter_range, ihk (λ hf, lt_of_succ_lt (hn hf))],
simp }
end
lemma count_nth_of_lt_card_finite {n : ℕ} (hp : (set_of p).finite)
(hlt : n < hp.to_finset.card) : count p (nth p n) = n :=
count_nth $ λ _, hlt
lemma count_nth_of_infinite (hp : (set_of p).infinite) (n : ℕ) : count p (nth p n) = n :=
count_nth $ λ hf, absurd hf hp
lemma count_nth_succ {n : ℕ} (hn : ∀ hf : (set_of p).finite, n < hf.to_finset.card) :
count p (nth p n + 1) = n + 1 :=
by rw [count_succ, count_nth hn, if_pos (nth_mem _ hn)]
@[simp] lemma nth_count {n : ℕ} (hpn : p n) : nth p (count p n) = n :=
have ∀ hf : (set_of p).finite, count p n < hf.to_finset.card,
from λ hf, count_lt_card hf hpn,
count_injective (nth_mem _ this) hpn (count_nth this)
lemma nth_lt_of_lt_count {n k : ℕ} (h : k < count p n) : nth p k < n :=
begin
refine (count_monotone p).reflect_lt _,
rwa [count_nth],
exact λ hf, h.trans_le (count_le_card hf n)
end
lemma le_nth_of_count_le {n k : ℕ} (h : n ≤ nth p k) : count p n ≤ k :=
not_lt.1 $ λ hlt, h.not_lt $ nth_lt_of_lt_count hlt
variable (p)
lemma nth_count_eq_Inf (n : ℕ) : nth p (count p n) = Inf {i : ℕ | p i ∧ n ≤ i} :=
begin
refine (nth_eq_Inf _ _).trans (congr_arg Inf _),
refine set.ext (λ a, and_congr_right $ λ hpa, _),
refine ⟨λ h, not_lt.1 (λ ha, _), λ hn k hk, lt_of_lt_of_le (nth_lt_of_lt_count hk) hn⟩,
have hn : nth p (count p a) < a := h _ (count_strict_mono hpa ha),
rwa [nth_count hpa, lt_self_iff_false] at hn
end
variable {p}
lemma le_nth_count' {n : ℕ} (hpn : ∃ k, p k ∧ n ≤ k) : n ≤ nth p (count p n) :=
(le_cInf hpn $ λ k, and.right).trans (nth_count_eq_Inf p n).ge
lemma le_nth_count (hp : (set_of p).infinite) (n : ℕ) : n ≤ nth p (count p n) :=
let ⟨m, hp, hn⟩ := hp.exists_gt n in le_nth_count' ⟨m, hp, hn.le⟩
/-- If a predicate `p : ℕ → Prop` is true for infinitely many numbers, then `nat.count p` and
`nat.nth p` form a Galois insertion. -/
noncomputable def gi_count_nth (hp : (set_of p).infinite) : galois_insertion (count p) (nth p) :=
galois_insertion.monotone_intro (nth_monotone hp) (count_monotone p)
(le_nth_count hp) (count_nth_of_infinite hp)
lemma gc_count_nth (hp : (set_of p).infinite) : galois_connection (count p) (nth p) :=
(gi_count_nth hp).gc
lemma count_le_iff_le_nth (hp : (set_of p).infinite) {a b : ℕ} :
count p a ≤ b ↔ a ≤ nth p b := gc_count_nth hp _ _
lemma lt_nth_iff_count_lt (hp : (set_of p).infinite) {a b : ℕ} :
a < count p b ↔ nth p a < b := (gc_count_nth hp).lt_iff_lt
end count
end nat
|
11ed3b9409b90c11f8242d56a7399cc6287fa0ec | 82b86ba2ae0d5aed0f01f49c46db5afec0eb2bd7 | /stage0/src/Lean/Elab/Term.lean | 85ced09fc56f4dd9566d118a97d9bf337b77d7dd | [
"Apache-2.0"
] | permissive | banksonian/lean4 | 3a2e6b0f1eb63aa56ff95b8d07b2f851072d54dc | 78da6b3aa2840693eea354a41e89fc5b212a5011 | refs/heads/master | 1,673,703,624,165 | 1,605,123,551,000 | 1,605,123,551,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 55,255 | 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
-/
import Lean.ResolveName
import Lean.Util.Sorry
import Lean.Structure
import Lean.Meta.ExprDefEq
import Lean.Meta.AppBuilder
import Lean.Meta.SynthInstance
import Lean.Meta.CollectMVars
import Lean.Meta.Tactic.Util
import Lean.Hygiene
import Lean.Util.RecDepth
import Lean.Elab.Log
import Lean.Elab.Level
import Lean.Elab.Attributes
namespace Lean.Elab.Term
/-
Set isDefEq configuration for the elaborator.
Note that we enable all approximations but `quasiPatternApprox`
In Lean3 and Lean 4, we used to use the quasi-pattern approximation during elaboration.
The example:
```
def ex : StateT δ (StateT σ Id) σ :=
monadLift (get : StateT σ Id σ)
```
demonstrates why it produces counterintuitive behavior.
We have the `Monad-lift` application:
```
@monadLift ?m ?n ?c ?α (get : StateT σ id σ) : ?n ?α
```
It produces the following unification problem when we process the expected type:
```
?n ?α =?= StateT δ (StateT σ id) σ
==> (approximate using first-order unification)
?n := StateT δ (StateT σ id)
?α := σ
```
Then, we need to solve:
```
?m ?α =?= StateT σ id σ
==> instantiate metavars
?m σ =?= StateT σ id σ
==> (approximate since it is a quasi-pattern unification constraint)
?m := fun σ => StateT σ id σ
```
Note that the constraint is not a Milner pattern because σ is in
the local context of `?m`. We are ignoring the other possible solutions:
```
?m := fun σ' => StateT σ id σ
?m := fun σ' => StateT σ' id σ
?m := fun σ' => StateT σ id σ'
We need the quasi-pattern approximation for elaborating recursor-like expressions (e.g., dependent `match with` expressions).
If we had use first-order unification, then we would have produced
the right answer: `?m := StateT σ id`
Haskell would work on this example since it always uses
first-order unification.
-/
def setElabConfig (cfg : Meta.Config) : Meta.Config :=
{ cfg with foApprox := true, ctxApprox := true, constApprox := false, quasiPatternApprox := false }
structure Context :=
(fileName : String)
(fileMap : FileMap)
(currNamespace : Name)
(declName? : Option Name := none)
(levelNames : List Name := [])
(openDecls : List OpenDecl := [])
(macroStack : MacroStack := [])
(currMacroScope : MacroScope := firstFrontendMacroScope)
/- When `mayPostpone == true`, an elaboration function may interrupt its execution by throwing `Exception.postpone`.
The function `elabTerm` catches this exception and creates fresh synthetic metavariable `?m`, stores `?m` in
the list of pending synthetic metavariables, and returns `?m`. -/
(mayPostpone : Bool := true)
/- When `errToSorry` is set to true, the method `elabTerm` catches
exceptions and converts them into synthetic `sorry`s.
The implementation of choice nodes and overloaded symbols rely on the fact
that when `errToSorry` is set to false for an elaboration function `F`, then
`errToSorry` remains `false` for all elaboration functions invoked by `F`.
That is, it is safe to transition `errToSorry` from `true` to `false`, but
we must not set `errToSorry` to `true` when it is currently set to `false`. -/
(errToSorry : Bool := true)
/-- We use synthetic metavariables as placeholders for pending elaboration steps. -/
inductive SyntheticMVarKind
-- typeclass instance search
| typeClass
/- Similar to typeClass, but error messages are different.
if `f?` is `some f`, we produce an application type mismatch error message.
Otherwise, if `header?` is `some header`, we generate the error `(header ++ "has type" ++ eType ++ "but it is expected to have type" ++ expectedType)`
Otherwise, we generate the error `("type mismatch" ++ e ++ "has type" ++ eType ++ "but it is expected to have type" ++ expectedType)` -/
| coe (header? : Option String) (expectedType : Expr) (eType : Expr) (e : Expr) (f? : Option Expr)
-- tactic block execution
| tactic (declName? : Option Name) (tacticCode : Syntax)
-- `elabTerm` call that threw `Exception.postpone` (input is stored at `SyntheticMVarDecl.ref`)
| postponed (macroStack : MacroStack) (declName? : Option Name)
-- type defaulting (currently: defaulting numeric literals to `Nat`)
| withDefault (defaultVal : Expr)
structure SyntheticMVarDecl :=
(mvarId : MVarId) (stx : Syntax) (kind : SyntheticMVarKind)
inductive MVarErrorKind
| implicitArg (ctx : Expr)
| hole
| custom (msgData : MessageData)
structure MVarErrorInfo :=
(mvarId : MVarId)
(ref : Syntax)
(kind : MVarErrorKind)
structure LetRecToLift :=
(ref : Syntax)
(fvarId : FVarId)
(attrs : Array Attribute)
(shortDeclName : Name)
(declName : Name)
(lctx : LocalContext)
(localInstances : LocalInstances)
(type : Expr)
(val : Expr)
(mvarId : MVarId)
structure State :=
(syntheticMVars : List SyntheticMVarDecl := [])
(mvarErrorInfos : List MVarErrorInfo := [])
(messages : MessageLog := {})
(letRecsToLift : List LetRecToLift := [])
instance : Inhabited State := ⟨{}⟩
abbrev TermElabM := ReaderT Context $ StateRefT State MetaM
abbrev TermElab := Syntax → Option Expr → TermElabM Expr
open Meta
instance {α} : Inhabited (TermElabM α) := ⟨throw $ arbitrary _⟩
structure SavedState :=
(core : Core.State)
(meta : Meta.State)
(«elab» : State)
instance : Inhabited SavedState := ⟨⟨arbitrary _, arbitrary _, arbitrary _⟩⟩
def saveAllState : TermElabM SavedState := do
pure { core := (← getThe Core.State), meta := (← getThe Meta.State), «elab» := (← get) }
def SavedState.restore (s : SavedState) : TermElabM Unit := do
let traceState ← getTraceState -- We never backtrack trace message
set s.core
set s.meta
set s.elab
setTraceState traceState
abbrev TermElabResult := EStateM.Result Exception SavedState Expr
instance : Inhabited TermElabResult := ⟨EStateM.Result.ok (arbitrary _) (arbitrary _)⟩
def setMessageLog (messages : MessageLog) : TermElabM Unit :=
modify fun s => { s with messages := messages }
def resetMessageLog : TermElabM Unit :=
setMessageLog {}
def getMessageLog : TermElabM MessageLog :=
return (← get).messages
/--
Execute `x`, save resulting expression and new state.
If `x` fails, then it also stores exception and new state.
Remark: we do not capture `Exception.postpone`. -/
@[inline] def observing (x : TermElabM Expr) : TermElabM TermElabResult := do
let s ← saveAllState
try
let e ← x
let sNew ← saveAllState
s.restore
pure (EStateM.Result.ok e sNew)
catch
| ex@(Exception.error _ _) =>
let sNew ← saveAllState
s.restore
pure (EStateM.Result.error ex sNew)
| ex@(Exception.internal id) =>
if id == postponeExceptionId then s.restore
throw ex
/--
Apply the result/exception and state captured with `observing`.
We use this method to implement overloaded notation and symbols. -/
def applyResult (result : TermElabResult) : TermElabM Expr :=
match result with
| EStateM.Result.ok e r => do r.restore; pure e
| EStateM.Result.error ex r => do r.restore; throw ex
instance : MonadIO TermElabM :=
{ liftIO := fun x => liftMetaM $ liftIO x }
@[inline] protected def liftMetaM {α} (x : MetaM α) : TermElabM α :=
liftM x
@[inline] def liftCoreM {α} (x : CoreM α) : TermElabM α :=
Term.liftMetaM $ liftM x
instance : MonadLiftT MetaM TermElabM :=
⟨Term.liftMetaM⟩
def getLevelNames : TermElabM (List Name) :=
return (← read).levelNames
def getFVarLocalDecl! (fvar : Expr) : TermElabM LocalDecl := do
match (← getLCtx).find? fvar.fvarId! with
| some d => pure d
| none => unreachable!
instance : AddErrorMessageContext TermElabM := {
add := fun ref msg => do
let ctx ← read
let ref := getBetterRef ref ctx.macroStack
let msg ← addMessageContext msg
let msg ← addMacroStack msg ctx.macroStack
pure (ref, msg)
}
instance : MonadLog TermElabM := {
getRef := getRef,
getFileMap := do pure (← read).fileMap,
getFileName := do pure (← read).fileName,
logMessage := fun msg => do
let ctx ← read
let msg := { msg with data := MessageData.withNamingContext { currNamespace := ctx.currNamespace, openDecls := ctx.openDecls } msg.data };
modify fun s => { s with messages := s.messages.add msg }
}
protected def getCurrMacroScope : TermElabM MacroScope := do pure (← read).currMacroScope
protected def getMainModule : TermElabM Name := do pure (← getEnv).mainModule
@[inline] protected def withFreshMacroScope {α} (x : TermElabM α) : TermElabM α := do
let fresh ← modifyGetThe Core.State (fun st => (st.nextMacroScope, { st with nextMacroScope := st.nextMacroScope + 1 }))
withReader (fun ctx => { ctx with currMacroScope := fresh }) x
instance : MonadQuotation TermElabM := {
getCurrMacroScope := Term.getCurrMacroScope,
getMainModule := Term.getMainModule,
withFreshMacroScope := Term.withFreshMacroScope
}
unsafe def mkTermElabAttributeUnsafe : IO (KeyedDeclsAttribute TermElab) :=
mkElabAttribute TermElab `Lean.Elab.Term.termElabAttribute `builtinTermElab `termElab `Lean.Parser.Term `Lean.Elab.Term.TermElab "term"
@[implementedBy mkTermElabAttributeUnsafe]
constant mkTermElabAttribute : IO (KeyedDeclsAttribute TermElab)
builtin_initialize termElabAttribute : KeyedDeclsAttribute TermElab ← mkTermElabAttribute
/--
Auxiliary datatatype for presenting a Lean lvalue modifier.
We represent a unelaborated lvalue as a `Syntax` (or `Expr`) and `List LVal`.
Example: `a.foo[i].1` is represented as the `Syntax` `a` and the list
`[LVal.fieldName "foo", LVal.getOp i, LVal.fieldIdx 1]`.
Recall that the notation `a[i]` is not just for accessing arrays in Lean. -/
inductive LVal
| fieldIdx (i : Nat)
| fieldName (name : String)
| getOp (idx : Syntax)
instance : ToString LVal := ⟨fun
| LVal.fieldIdx i => toString i
| LVal.fieldName n => n
| LVal.getOp idx => "[" ++ toString idx ++ "]"⟩
instance : MonadResolveName TermElabM := {
getCurrNamespace := do pure (← read).currNamespace,
getOpenDecls := do pure (← read).openDecls
}
def getDeclName? : TermElabM (Option Name) := return (← read).declName?
def getLetRecsToLift : TermElabM (List LetRecToLift) := return (← get).letRecsToLift
def isExprMVarAssigned (mvarId : MVarId) : TermElabM Bool := return (← getMCtx).isExprAssigned mvarId
def getMVarDecl (mvarId : MVarId) : TermElabM MetavarDecl := return (← getMCtx).getDecl mvarId
def assignLevelMVar (mvarId : MVarId) (val : Level) : TermElabM Unit := modifyThe Meta.State fun s => { s with mctx := s.mctx.assignLevel mvarId val }
def withDeclName {α} (name : Name) (x : TermElabM α) : TermElabM α :=
withReader (fun ctx => { ctx with declName? := name }) x
def withLevelNames {α} (levelNames : List Name) (x : TermElabM α) : TermElabM α :=
withReader (fun ctx => { ctx with levelNames := levelNames }) x
def withoutErrToSorry {α} (x : TermElabM α) : TermElabM α :=
withReader (fun ctx => { ctx with errToSorry := false }) x
/-- For testing `TermElabM` methods. The #eval command will sign the error. -/
def throwErrorIfErrors : TermElabM Unit := do
if (← get).messages.hasErrors then
throwError "Error(s)"
@[inline] def traceAtCmdPos (cls : Name) (msg : Unit → MessageData) : TermElabM Unit :=
withRef Syntax.missing $ trace cls msg
def ppGoal (mvarId : MVarId) : TermElabM Format := liftMetaM $ Meta.ppGoal mvarId
@[inline] def savingMCtx {α} (x : TermElabM α) : TermElabM α := do
let mctx ← getMCtx
try x finally setMCtx mctx
open Level (LevelElabM)
def liftLevelM {α} (x : LevelElabM α) : TermElabM α := do
let ctx ← read
let ref ← getRef
let mctx ← getMCtx
let ngen ← getNGen
let lvlCtx : Level.Context := { ref := ref, levelNames := ctx.levelNames }
match (x lvlCtx).run { ngen := ngen, mctx := mctx } with
| EStateM.Result.ok a newS => do setMCtx newS.mctx; setNGen newS.ngen; pure a
| EStateM.Result.error ex _ => throw ex
def elabLevel (stx : Syntax) : TermElabM Level :=
liftLevelM $ Level.elabLevel stx
/- Elaborate `x` with `stx` on the macro stack -/
@[inline] def withMacroExpansion {α} (beforeStx afterStx : Syntax) (x : TermElabM α) : TermElabM α :=
withReader (fun ctx => { ctx with macroStack := { before := beforeStx, after := afterStx } :: ctx.macroStack }) x
/-
Add the given metavariable to the list of pending synthetic metavariables.
The method `synthesizeSyntheticMVars` is used to process the metavariables on this list. -/
def registerSyntheticMVar (stx : Syntax) (mvarId : MVarId) (kind : SyntheticMVarKind) : TermElabM Unit := do
modify fun s => { s with syntheticMVars := { mvarId := mvarId, stx := stx, kind := kind } :: s.syntheticMVars }
def registerSyntheticMVarWithCurrRef (mvarId : MVarId) (kind : SyntheticMVarKind) : TermElabM Unit := do
registerSyntheticMVar (← getRef) mvarId kind
def registerMVarErrorHoleInfo (mvarId : MVarId) (ref : Syntax) : TermElabM Unit := do
modify fun s => { s with mvarErrorInfos := { mvarId := mvarId, ref := ref, kind := MVarErrorKind.hole } :: s.mvarErrorInfos }
def registerMVarErrorImplicitArgInfo (mvarId : MVarId) (ref : Syntax) (app : Expr) : TermElabM Unit := do
modify fun s => { s with mvarErrorInfos := { mvarId := mvarId, ref := ref, kind := MVarErrorKind.implicitArg app } :: s.mvarErrorInfos }
def registerMVarErrorCustomInfo (mvarId : MVarId) (ref : Syntax) (msgData : MessageData) : TermElabM Unit := do
modify fun s => { s with mvarErrorInfos := { mvarId := mvarId, ref := ref, kind := MVarErrorKind.custom msgData } :: s.mvarErrorInfos }
def registerCustomErrorIfMVar (e : Expr) (ref : Syntax) (msgData : MessageData) : TermElabM Unit :=
match e.getAppFn with
| Expr.mvar mvarId _ => registerMVarErrorCustomInfo mvarId ref msgData
| _ => pure ()
def MVarErrorInfo.logError (mvarErrorInfo : MVarErrorInfo) : TermElabM Unit := do
match mvarErrorInfo.kind with
| MVarErrorKind.implicitArg app => do
let app ← instantiateMVars app
let f := app.getAppFn
let args := app.getAppArgs
let msg := args.foldl (init := "@" ++ MessageData.ofExpr f) fun (msg : MessageData) (arg : Expr) =>
if arg.getAppFn.isMVar then
msg ++ " " ++ arg.getAppFn
else
msg ++ " …"
let msg : MessageData := msg!"don't know how to synthesize implicit argument{indentD msg}"
let msg := msg ++ Format.line ++ "context:" ++ Format.line ++ MessageData.ofGoal mvarErrorInfo.mvarId
logErrorAt mvarErrorInfo.ref msg
| MVarErrorKind.hole => do
let msg : MessageData := "don't know how to synthesize placeholder"
let msg := msg ++ Format.line ++ "context:" ++ Format.line ++ MessageData.ofGoal mvarErrorInfo.mvarId
logErrorAt mvarErrorInfo.ref msg
| MVarErrorKind.custom msgData =>
logErrorAt mvarErrorInfo.ref msgData
/--
Try to log errors for the unassigned metavariables `pendingMVarIds`.
Return `true` if at least one error was logged.
Remark: This method only succeeds if we have information for at least one given metavariable
at `mvarErrorInfos`. -/
def logUnassignedUsingErrorInfos (pendingMVarIds : Array MVarId) : TermElabM Bool := do
let s ← get
let errorInfos := s.mvarErrorInfos
let (foundErrors, _) ← errorInfos.foldlM (init := (false, {})) fun (foundErrors, (alreadyVisited : NameSet)) mvarErrorInfo => do
let mvarId := mvarErrorInfo.mvarId;
if alreadyVisited.contains mvarId then
pure (foundErrors, alreadyVisited)
else withMVarContext mvarId do
let alreadyVisited := alreadyVisited.insert mvarId
/- The metavariable `mvarErrorInfo.mvarId` may have been assigned or
delayed assigned to another metavariable that is unassigned. -/
let mvarDeps ← getMVars (mkMVar mvarId)
if mvarDeps.any pendingMVarIds.contains then do
mvarErrorInfo.logError;
pure (true, alreadyVisited)
else
pure (foundErrors, alreadyVisited)
pure foundErrors
/-- Ensure metavariables registered using `registerMVarErrorInfos` (and used in the given declaration) have been assigned. -/
def ensureNoUnassignedMVars (decl : Declaration) : TermElabM Unit := do
let pendingMVarIds ← getMVarsAtDecl decl
let foundError ← logUnassignedUsingErrorInfos pendingMVarIds
if foundError then
throwAbort
/-
Execute `x` without allowing it to postpone elaboration tasks.
That is, `tryPostpone` is a noop. -/
@[inline] def withoutPostponing {α} (x : TermElabM α) : TermElabM α :=
withReader (fun ctx => { ctx with mayPostpone := false }) x
/-- Creates syntax for `(` <ident> `:` <type> `)` -/
def mkExplicitBinder (ident : Syntax) (type : Syntax) : Syntax :=
mkNode `Lean.Parser.Term.explicitBinder #[mkAtom "(", mkNullNode #[ident], mkNullNode #[mkAtom ":", type], mkNullNode, mkAtom ")"]
/--
Convert unassigned universe level metavariables into parameters.
The new parameter names are of the form `u_i` where `i >= nextParamIdx`.
The method returns the updated expression and new `nextParamIdx`.
Remark: we make sure the generated parameter names do not clash with the universes at `ctx.levelNames`. -/
def levelMVarToParam (e : Expr) (nextParamIdx : Nat := 1) : TermElabM (Expr × Nat) := do
let ctx ← read
let mctx ← getMCtx
let r := mctx.levelMVarToParam (fun n => ctx.levelNames.elem n) e `u nextParamIdx
setMCtx r.mctx
pure (r.expr, r.nextParamIdx)
/-- Variant of `levelMVarToParam` where `nextParamIdx` is stored in a state monad. -/
def levelMVarToParam' (e : Expr) : StateRefT Nat TermElabM Expr := do
let nextParamIdx ← get
let (e, nextParamIdx) ← levelMVarToParam e nextParamIdx
set nextParamIdx
pure e
/--
Auxiliary method for creating fresh binder names.
Do not confuse with the method for creating fresh free/meta variable ids. -/
def mkFreshBinderName : TermElabM Name :=
withFreshMacroScope $ MonadQuotation.addMacroScope `x
/--
Auxiliary method for creating a `Syntax.ident` containing
a fresh name. This method is intended for creating fresh binder names.
It is just a thin layer on top of `mkFreshUserName`. -/
def mkFreshIdent (ref : Syntax) : TermElabM Syntax :=
return mkIdentFrom ref (← mkFreshBinderName)
/--
Auxiliary method for creating binder names for local instances. -/
def mkFreshInstanceName : TermElabM Name :=
withFreshMacroScope $ MonadQuotation.addMacroScope `inst
private def liftAttrM {α} (x : AttrM α) : TermElabM α := do
let ctx ← read
liftCoreM $ x.run { currNamespace := ctx.currNamespace, openDecls := ctx.openDecls }
private def applyAttributesCore
(declName : Name) (attrs : Array Attribute)
(applicationTime? : Option AttributeApplicationTime) (persistent : Bool) : TermElabM Unit :=
for attr in attrs do
let env ← getEnv
match getAttributeImpl env attr.name with
| Except.error errMsg => throwError errMsg
| Except.ok attrImpl =>
match applicationTime? with
| none => liftAttrM $ attrImpl.add declName attr.args persistent
| some applicationTime =>
if applicationTime == attrImpl.applicationTime then
liftAttrM $ attrImpl.add declName attr.args persistent
/-- Apply given attributes **at** a given application time -/
def applyAttributesAt (declName : Name) (attrs : Array Attribute) (applicationTime : AttributeApplicationTime) (persistent : Bool := true) : TermElabM Unit :=
applyAttributesCore declName attrs applicationTime persistent
def applyAttributes (declName : Name) (attrs : Array Attribute) (persistent : Bool) : TermElabM Unit :=
applyAttributesCore declName attrs none persistent
def mkTypeMismatchError (header? : Option String) (e : Expr) (eType : Expr) (expectedType : Expr) : MessageData :=
let header : MessageData := match header? with
| some header => msg!"{header} has type"
| none => msg!"type mismatch{indentExpr e}\nhas type"
msg!"{header}{indentExpr eType}\nbut is expected to have type{indentExpr expectedType}"
def throwTypeMismatchError {α} (header? : Option String) (expectedType : Expr) (eType : Expr) (e : Expr)
(f? : Option Expr := none) (extraMsg? : Option MessageData := none) : TermElabM α :=
/-
We ignore `extraMsg?` for now. In all our tests, it contained no useful information. It was
always of the form:
```
failed to synthesize instance
CoeT <eType> <e> <expectedType>
```
We should revisit this decision in the future and decide whether it may contain useful information
or not. -/
let extraMsg := Format.nil
/-
let extraMsg : MessageData := match extraMsg? with
| none => Format.nil
| some extraMsg => Format.line ++ extraMsg;
-/
match f? with
| none => throwError $ mkTypeMismatchError header? e eType expectedType ++ extraMsg
| some f => Meta.throwAppTypeMismatch f e extraMsg
@[inline] def withoutMacroStackAtErr {α} (x : TermElabM α) : TermElabM α :=
withTheReader Core.Context (fun (ctx : Core.Context) => { ctx with options := setMacroStackOption ctx.options false }) x
/- Try to synthesize metavariable using type class resolution.
This method assumes the local context and local instances of `instMVar` coincide
with the current local context and local instances.
Return `true` if the instance was synthesized successfully, and `false` if
the instance contains unassigned metavariables that are blocking the type class
resolution procedure. Throw an exception if resolution or assignment irrevocably fails. -/
def synthesizeInstMVarCore (instMVar : MVarId) : TermElabM Bool := do
let instMVarDecl ← getMVarDecl instMVar
let type := instMVarDecl.type
let type ← instantiateMVars type
let result ← trySynthInstance type
match result with
| LOption.some val =>
if (← isExprMVarAssigned instMVar) then
let oldVal ← instantiateMVars (mkMVar instMVar)
unless (← isDefEq oldVal val) do
throwError! "synthesized type class instance is not definitionally equal to expression inferred by typing rules, synthesized{indentExpr val}\ninferred{indentExpr oldVal}"
else
assignExprMVar instMVar val
pure true
| LOption.undef => pure false -- we will try later
| LOption.none => throwError! "failed to synthesize instance{indentExpr type}"
/-
The coercion from `α` to `Thunk α` cannot be implemented using an instance because it would
eagerly evaluate `e` -/
def tryCoeThunk? (expectedType : Expr) (eType : Expr) (e : Expr) : TermElabM (Option Expr) := do
match expectedType with
| Expr.app (Expr.const `Thunk u _) arg _ =>
if (← isDefEq eType arg) then
pure (some (mkApp2 (mkConst `Thunk.mk u) arg (mkSimpleThunk e)))
else
pure none
| _ =>
pure none
/--
Try to apply coercion to make sure `e` has type `expectedType`.
Relevant definitions:
```
class CoeT (α : Sort u) (a : α) (β : Sort v)
abbrev coe {α : Sort u} {β : Sort v} (a : α) [CoeT α a β] : β
``` -/
private def tryCoe (errorMsgHeader? : Option String) (expectedType : Expr) (eType : Expr) (e : Expr) (f? : Option Expr) : TermElabM Expr := do
if (← isDefEq expectedType eType) then
pure e
else match (← tryCoeThunk? expectedType eType e) with
| some r => pure r
| none =>
let u ← getLevel eType
let v ← getLevel expectedType
let coeTInstType := mkAppN (mkConst `CoeT [u, v]) #[eType, e, expectedType]
let mvar ← mkFreshExprMVar coeTInstType MetavarKind.synthetic
let eNew := mkAppN (mkConst `coe [u, v]) #[eType, expectedType, e, mvar]
let mvarId := mvar.mvarId!
try
withoutMacroStackAtErr do
unless (← synthesizeInstMVarCore mvarId) do
registerSyntheticMVarWithCurrRef mvarId (SyntheticMVarKind.coe errorMsgHeader? expectedType eType e f?)
pure eNew
catch
| Exception.error _ msg => throwTypeMismatchError errorMsgHeader? expectedType eType e f? msg
| _ => throwTypeMismatchError errorMsgHeader? expectedType eType e f?
private def isTypeApp? (type : Expr) : TermElabM (Option (Expr × Expr)) := do
let type ← withReducible $ whnf type
match type with
| Expr.app m α _ => pure (some ((← instantiateMVars m), (← instantiateMVars α)))
| _ => pure none
/-
private def isMonad? (type : Expr) : TermElabM (Option IsMonadResult) := do
let type ← withReducible $ whnf type
match type with
| Expr.app m α _ =>
try
let monadType ← mkAppM `Monad #[m]
let result ← trySynthInstance monadType
match result with
| LOption.some inst => pure (some { m := m, α := α, inst := inst })
| _ => pure none
catch _ => pure none
| _ => pure none
-/
private def isMonad? (m : Expr) : TermElabM (Option Expr) :=
try
let monadType ← mkAppM `Monad #[m]
let result ← trySynthInstance monadType
match result with
| LOption.some inst => pure inst
| _ => pure none
catch _ =>
pure none
def synthesizeInst (type : Expr) : TermElabM Expr := do
let type ← instantiateMVars type
match (← trySynthInstance type) with
| LOption.some val => pure val
| LOption.undef => throwError! "failed to synthesize instance{indentExpr type}"
| LOption.none => throwError! "failed to synthesize instance{indentExpr type}"
/--
Try to coerce `a : α` into `m β` by first coercing `a : α` into ‵β`, and then using `pure`.
The method is only applied if one of the following cases hold:
- Head of `α` and head of ‵β` are not metavariables.
- Head of `α` is not a metavariable, and it is not a Monad.
The main limitation of the approach above is polymorphic code. As usual, coercions and polymorphism
do not interact well. In the example above, the lift is successfully applied to `true`, `false` and `!y`
since none of them is polymorphic
```
def f (x : Bool) : IO Bool := do
let y ← if x == 0 then IO.println "hello"; true else false;
!y
```
On the other hand, the following fails since `+` is polymorphic
```
def f (x : Bool) : IO Nat := do
IO.prinln x
x + x -- Error: failed to synthesize `Add (IO Nat)`
```
-/
private def tryPureCoe? (errorMsgHeader? : Option String) (m β α a : Expr) : TermElabM (Option Expr) := do
let doIt : TermElabM (Option Expr) := do
try
let aNew ← tryCoe errorMsgHeader? β α a none
let aNew ← mkPure m aNew
pure (some aNew)
catch _ =>
pure none
let αHead := α.getAppFn
if !β.getAppFn.isMVar && !αHead.isMVar then
doIt -- case 1
else
let αIsMonad? ← isMonad? α
if !αHead.isMVar && αIsMonad?.isNone then
doIt -- case 2
else
pure none
/-
Try coercions and monad lifts to make sure `e` has type `expectedType`.
If `expectedType` is of the form `n β`, we try monad lifts and other extensions.
Otherwise, we just use the basic `tryCoe`.
Extensions for monads.
Given an expected type of the form `n β`, if `eType` is of the form `α`, but not `m α`
1 - Try to coerce ‵α` into ‵β`, and use `pure` to lift it to `n α`.
It only works if `n` implements `Pure`
If `eType` is of the form `m α`. We use the following approaches.
1- Try to unify `n` and `m`. If it succeeds, then we use
```
coeM {m : Type u → Type v} {α β : Type u} [∀ a, CoeT α a β] [Monad m] (x : m α) : m β
```
`n` must be a `Monad` to use this one.
2- If there is monad lift from `m` to `n` and we can unify `α` and `β`, we use
```
liftM : ∀ {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [self : MonadLiftT m n] {α : Type u_1}, m α → n α
```
Note that `n` may not be a `Monad` in this case. This happens quite a bit in code such as
```
def g (x : Nat) : IO Nat := do
IO.println x
pure x
def f {m} [MonadLiftT IO m] : m Nat :=
g 10
```
3- If there is a monad lif from `m` to `n` and a coercion from `α` to `β`, we use
```
liftCoeM {m : Type u → Type v} {n : Type u → Type w} {α β : Type u} [MonadLiftT m n] [∀ a, CoeT α a β] [Monad n] (x : m α) : n β
```
Note that approach 3 does not subsume 1 because it is only applicable if there is a coercion from `α` to `β` for all values in `α`.
This is not the case for example for `pure $ x > 0` when the expected type is `IO Bool`. The given type is `IO Prop`, and
we only have a coercion from decidable propositions. Approach 1 works because it constructs the coercion `CoeT (m Prop) (pure $ x > 0) (m Bool)`
using the instance `pureCoeDepProp`.
Note that, approach 2 is more powerful than `tryCoe`.
Recall that type class resolution never assigns metavariables created by other modules.
Now, consider the following scenario
```lean
def g (x : Nat) : IO Nat := ...
deg h (x : Nat) : StateT Nat IO Nat := do
v ← g x;
IO.Println v;
...
```
Let's assume there is no other occurrence of `v` in `h`.
Thus, we have that the expected of `g x` is `StateT Nat IO ?α`,
and the given type is `IO Nat`. So, even if we add a coercion.
```
instance {α m n} [MonadLiftT m n] {α} : Coe (m α) (n α) := ...
```
It is not applicable because TC would have to assign `?α := Nat`.
On the other hand, TC can easily solve `[MonadLiftT IO (StateT Nat IO)]`
since this goal does not contain any metavariables. And then, we
convert `g x` into `liftM $ g x`.
-/
private def tryLiftAndCoe (errorMsgHeader? : Option String) (expectedType : Expr) (eType : Expr) (e : Expr) (f? : Option Expr) : TermElabM Expr := do
let expectedType ← instantiateMVars expectedType
let eType ← instantiateMVars eType
let throwMismatch {α} : TermElabM α := throwTypeMismatchError errorMsgHeader? expectedType eType e f?
let tryCoeSimple : TermElabM Expr :=
tryCoe errorMsgHeader? expectedType eType e f?
let some (n, β) ← isTypeApp? expectedType | tryCoeSimple
let tryPureCoeAndSimple : TermElabM Expr := do
match (← tryPureCoe? errorMsgHeader? n β eType e) with
| some eNew => pure eNew
| none => tryCoeSimple
let some (m, α) ← isTypeApp? eType | tryPureCoeAndSimple
if (← isDefEq m n) then
let some monadInst ← isMonad? n | tryCoeSimple
try mkAppOptM `coeM #[m, α, β, none, monadInst, e] catch _ => throwMismatch
else
try
-- Construct lift from `m` to `n`
let monadLiftType ← mkAppM `MonadLiftT #[m, n]
let monadLiftVal ← synthesizeInst monadLiftType
let u_1 ← getDecLevel α
let u_2 ← getDecLevel eType
let u_3 ← getDecLevel expectedType
let eNew := mkAppN (Lean.mkConst `liftM [u_1, u_2, u_3]) #[m, n, monadLiftVal, α, e]
let eNewType ← inferType eNew
if (← isDefEq expectedType eNewType) then
pure eNew -- approach 2 worked
else
let some monadInst ← isMonad? n | tryCoeSimple
let u ← getLevel α
let v ← getLevel β
let coeTInstType := Lean.mkForall `a BinderInfo.default α $ mkAppN (mkConst `CoeT [u, v]) #[α, mkBVar 0, β]
let coeTInstVal ← synthesizeInst coeTInstType
let eNew := mkAppN (Lean.mkConst `liftCoeM [u_1, u_2, u_3]) #[m, n, α, β, monadLiftVal, coeTInstVal, monadInst, e]
let eNewType ← inferType eNew
unless (← isDefEq expectedType eNewType) do throwMismatch
pure eNew -- approach 3 worked
catch _ =>
/-
If `m` is not a monad, then we try to use `tryPureCoe?` and then `tryCoe?`.
Otherwise, we just try `tryCoe?`.
-/
match (← isMonad? m) with
| none => tryPureCoeAndSimple
| some _ => tryCoeSimple
/--
If `expectedType?` is `some t`, then ensure `t` and `eType` are definitionally equal.
If they are not, then try coercions.
Argument `f?` is used only for generating error messages. -/
def ensureHasTypeAux (expectedType? : Option Expr) (eType : Expr) (e : Expr)
(f? : Option Expr := none) (errorMsgHeader? : Option String := none) : TermElabM Expr := do
match expectedType? with
| none => pure e
| some expectedType =>
if (← isDefEq eType expectedType) then
pure e
else
tryLiftAndCoe errorMsgHeader? expectedType eType e f?
/--
If `expectedType?` is `some t`, then ensure `t` and type of `e` are definitionally equal.
If they are not, then try coercions. -/
def ensureHasType (expectedType? : Option Expr) (e : Expr) (errorMsgHeader? : Option String := none) : TermElabM Expr :=
match expectedType? with
| none => pure e
| _ => do
let eType ← inferType e
ensureHasTypeAux expectedType? eType e none errorMsgHeader?
private def exceptionToSorry (ex : Exception) (expectedType? : Option Expr) : TermElabM Expr := do
let expectedType ← match expectedType? with
| none => mkFreshTypeMVar
| some expectedType => pure expectedType
let u ← getLevel expectedType
-- TODO: should be `(sorryAx.{$u} $expectedType true) when we support antiquotations at that place
let syntheticSorry := mkApp2 (mkConst `sorryAx [u]) expectedType (mkConst `Bool.true);
unless ex.hasSyntheticSorry do
logException ex
pure syntheticSorry
/-- If `mayPostpone == true`, throw `Expection.postpone`. -/
def tryPostpone : TermElabM Unit := do
if (← read).mayPostpone then
throwPostpone
/-- If `mayPostpone == true` and `e`'s head is a metavariable, throw `Exception.postpone`. -/
def tryPostponeIfMVar (e : Expr) : TermElabM Unit := do
if e.getAppFn.isMVar then
let e ← instantiateMVars e
if e.getAppFn.isMVar then
tryPostpone
def tryPostponeIfNoneOrMVar (e? : Option Expr) : TermElabM Unit :=
match e? with
| some e => tryPostponeIfMVar e
| none => tryPostpone
def tryPostponeIfHasMVars (expectedType? : Option Expr) (msg : String) : TermElabM Expr := do
tryPostponeIfNoneOrMVar expectedType?
let some expectedType ← pure expectedType? |
throwError! "{msg}, expected type must be known"
let expectedType ← instantiateMVars expectedType
if expectedType.hasExprMVar then
tryPostpone
throwError! "{msg}, expected type contains metavariables{indentExpr expectedType}"
pure expectedType
private def postponeElabTerm (stx : Syntax) (expectedType? : Option Expr) : TermElabM Expr := do
trace[Elab.postpone]! "{stx} : {expectedType?}"
let mvar ← mkFreshExprMVar expectedType? MetavarKind.syntheticOpaque
let ctx ← read
registerSyntheticMVar stx mvar.mvarId! (SyntheticMVarKind.postponed ctx.macroStack ctx.declName?)
pure mvar
/-
Helper function for `elabTerm` is tries the registered elaboration functions for `stxNode` kind until it finds one that supports the syntax or
an error is found. -/
private def elabUsingElabFnsAux (s : SavedState) (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone : Bool)
: List TermElab → TermElabM Expr
| [] => do throwError! "unexpected syntax{MessageData.nestD (Format.line ++ stx)}"
| (elabFn::elabFns) => do
try
elabFn stx expectedType?
catch ex => match ex with
| Exception.error _ _ =>
if (← read).errToSorry then
exceptionToSorry ex expectedType?
else
throw ex
| Exception.internal id =>
if id == unsupportedSyntaxExceptionId then
s.restore
elabUsingElabFnsAux s stx expectedType? catchExPostpone elabFns
else if catchExPostpone && id == postponeExceptionId then
/- If `elab` threw `Exception.postpone`, we reset any state modifications.
For example, we want to make sure pending synthetic metavariables created by `elab` before
it threw `Exception.postpone` are discarded.
Note that we are also discarding the messages created by `elab`.
For example, consider the expression.
`((f.x a1).x a2).x a3`
Now, suppose the elaboration of `f.x a1` produces an `Exception.postpone`.
Then, a new metavariable `?m` is created. Then, `?m.x a2` also throws `Exception.postpone`
because the type of `?m` is not yet known. Then another, metavariable `?n` is created, and
finally `?n.x a3` also throws `Exception.postpone`. If we did not restore the state, we would
keep "dead" metavariables `?m` and `?n` on the pending synthetic metavariable list. This is
wasteful because when we resume the elaboration of `((f.x a1).x a2).x a3`, we start it from scratch
and new metavariables are created for the nested functions. -/
s.restore
postponeElabTerm stx expectedType?
else
throw ex
private def elabUsingElabFns (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone : Bool) : TermElabM Expr := do
let s ← saveAllState
let table := termElabAttribute.ext.getState (← getEnv) $.table
let k := stx.getKind
match table.find? k with
| some elabFns => elabUsingElabFnsAux s stx expectedType? catchExPostpone elabFns
| none => throwError! "elaboration function for '{k}' has not been implemented"
instance : MonadMacroAdapter TermElabM := {
getCurrMacroScope := getCurrMacroScope,
getNextMacroScope := return (← getThe Core.State).nextMacroScope,
setNextMacroScope := fun next => modifyThe Core.State fun s => { s with nextMacroScope := next }
}
private def isExplicit (stx : Syntax) : Bool :=
match_syntax stx with
| `(@$f) => true
| _ => false
private def isExplicitApp (stx : Syntax) : Bool :=
stx.getKind == `Lean.Parser.Term.app && isExplicit stx[0]
/--
Return true if `stx` if a lambda abstraction containing a `{}` or `[]` binder annotation.
Example: `fun {α} (a : α) => a` -/
private def isLambdaWithImplicit (stx : Syntax) : Bool :=
match_syntax stx with
| `(fun $binders* => $body) => binders.any fun b => b.isOfKind `Lean.Parser.Term.implicitBinder || b.isOfKind `Lean.Parser.Term.instBinder
| _ => false
private partial def dropTermParens : Syntax → Syntax | stx =>
match_syntax stx with
| `(($stx)) => dropTermParens stx
| _ => stx
/-- Block usage of implicit lambdas if `stx` is `@f` or `@f arg1 ...` or `fun` with an implicit binder annotation. -/
def blockImplicitLambda (stx : Syntax) : Bool :=
let stx := dropTermParens stx
isExplicit stx || isExplicitApp stx || isLambdaWithImplicit stx
/--
Return normalized expected type if it is of the form `{a : α} → β` or `[a : α] → β` and
`blockImplicitLambda stx` is not true, else return `none`. -/
private def useImplicitLambda? (stx : Syntax) (expectedType? : Option Expr) : TermElabM (Option Expr) :=
if blockImplicitLambda stx then
pure none
else match expectedType? with
| some expectedType => do
let expectedType ← whnfForall expectedType
match expectedType with
| Expr.forallE _ _ _ c => if c.binderInfo.isExplicit then pure none else pure $ some expectedType
| _ => pure none
| _ => pure none
private def elabImplicitLambdaAux (stx : Syntax) (catchExPostpone : Bool) (expectedType : Expr) (fvars : Array Expr) : TermElabM Expr := do
let body ← elabUsingElabFns stx expectedType catchExPostpone
let body ← ensureHasType expectedType body
let r ← mkLambdaFVars fvars body
trace[Elab.implicitForall]! r
pure r
private partial def elabImplicitLambda (stx : Syntax) (catchExPostpone : Bool) : Expr → Array Expr → TermElabM Expr
| type@(Expr.forallE n d b c), fvars =>
if c.binderInfo.isExplicit then
elabImplicitLambdaAux stx catchExPostpone type fvars
else withFreshMacroScope do
let n ← MonadQuotation.addMacroScope n
withLocalDecl n c.binderInfo d fun fvar => do
let type ← whnfForall (b.instantiate1 fvar)
elabImplicitLambda stx catchExPostpone type (fvars.push fvar)
| type, fvars =>
elabImplicitLambdaAux stx catchExPostpone type fvars
/- Main loop for `elabTerm` -/
private partial def elabTermAux (expectedType? : Option Expr) (catchExPostpone : Bool) (implicitLambda : Bool) : Syntax → TermElabM Expr
| stx => withFreshMacroScope $ withIncRecDepth do
trace[Elab.step]! "expected type: {expectedType?}, term\n{stx}"
withNestedTraces do
let env ← getEnv
let stxNew? ← catchInternalId unsupportedSyntaxExceptionId
(do let newStx ← adaptMacro (getMacros env) stx; pure (some newStx))
(fun _ => pure none)
match stxNew? with
| some stxNew => withMacroExpansion stx stxNew $ elabTermAux expectedType? catchExPostpone implicitLambda stxNew
| _ =>
let implicit? ← if implicitLambda then useImplicitLambda? stx expectedType? else pure none
match implicit? with
| some expectedType => elabImplicitLambda stx catchExPostpone expectedType #[]
| none => elabUsingElabFns stx expectedType? catchExPostpone
/--
Main function for elaborating terms.
It extracts the elaboration methods from the environment using the node kind.
Recall that the environment has a mapping from `SyntaxNodeKind` to `TermElab` methods.
It creates a fresh macro scope for executing the elaboration method.
All unlogged trace messages produced by the elaboration method are logged using
the position information at `stx`. If the elaboration method throws an `Exception.error` and `errToSorry == true`,
the error is logged and a synthetic sorry expression is returned.
If the elaboration throws `Exception.postpone` and `catchExPostpone == true`,
a new synthetic metavariable of kind `SyntheticMVarKind.postponed` is created, registered,
and returned.
The option `catchExPostpone == false` is used to implement `resumeElabTerm`
to prevent the creation of another synthetic metavariable when resuming the elaboration. -/
def elabTerm (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone := true) : TermElabM Expr :=
withRef stx $ elabTermAux expectedType? catchExPostpone true stx
def elabTermEnsuringType (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone := true) (errorMsgHeader? : Option String := none) : TermElabM Expr := do
let e ← elabTerm stx expectedType? catchExPostpone
withRef stx $ ensureHasType expectedType? e errorMsgHeader?
def elabTermWithoutImplicitLambdas (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone := true) : TermElabM Expr := do
elabTermAux expectedType? catchExPostpone false stx
/-- Adapt a syntax transformation to a regular, term-producing elaborator. -/
def adaptExpander (exp : Syntax → TermElabM Syntax) : TermElab := fun stx expectedType? => do
let stx' ← exp stx
withMacroExpansion stx stx' $ elabTerm stx' expectedType?
def mkInstMVar (type : Expr) : TermElabM Expr := do
let mvar ← mkFreshExprMVar type MetavarKind.synthetic
let mvarId := mvar.mvarId!
unless (← synthesizeInstMVarCore mvarId) do
registerSyntheticMVarWithCurrRef mvarId SyntheticMVarKind.typeClass
pure mvar
/-
Relevant definitions:
```
class CoeSort (α : Sort u) (β : outParam (Sort v))
abbrev coeSort {α : Sort u} {β : Sort v} (a : α) [CoeSort α β] : β
``` -/
private def tryCoeSort (α : Expr) (a : Expr) : TermElabM Expr := do
let β ← mkFreshTypeMVar
let u ← getLevel α
let v ← getLevel β
let coeSortInstType := mkAppN (Lean.mkConst `CoeSort [u, v]) #[α, β]
let mvar ← mkFreshExprMVar coeSortInstType MetavarKind.synthetic
let mvarId := mvar.mvarId!
try
withoutMacroStackAtErr do
if (← synthesizeInstMVarCore mvarId) then
pure $ mkAppN (Lean.mkConst `coeSort [u, v]) #[α, β, a, mvar]
else
throwError "type expected"
catch
| Exception.error _ msg => throwError! "type expected\n{msg}"
| _ => throwError! "type expected"
/--
Make sure `e` is a type by inferring its type and making sure it is a `Expr.sort`
or is unifiable with `Expr.sort`, or can be coerced into one. -/
def ensureType (e : Expr) : TermElabM Expr := do
if (← isType e) then
pure e
else
let eType ← inferType e
let u ← mkFreshLevelMVar
if (← isDefEq eType (mkSort u)) then
pure e
else
tryCoeSort eType e
/-- Elaborate `stx` and ensure result is a type. -/
def elabType (stx : Syntax) : TermElabM Expr := do
let u ← mkFreshLevelMVar
let type ← elabTerm stx (mkSort u)
withRef stx $ ensureType type
def mkAuxName (suffix : Name) : TermElabM Name := do
match (← read).declName? with
| none => throwError "auxiliary declaration cannot be created when declaration name is not available"
| some declName => Lean.mkAuxName (declName ++ suffix) 1
builtin_initialize registerTraceClass `Elab.letrec
/- Return true if mvarId is an auxiliary metavariable created for compiling `let rec` or it
is delayed assigned to one. -/
def isLetRecAuxMVar (mvarId : MVarId) : TermElabM Bool := do
trace[Elab.letrec]! "mvarId: {mkMVar mvarId} letrecMVars: {(← get).letRecsToLift.map (mkMVar $ ·.mvarId)}"
let mvarId := (← getMCtx).getDelayedRoot mvarId
trace[Elab.letrec]! "mvarId root: {mkMVar mvarId}"
return (← get).letRecsToLift.any (·.mvarId == mvarId)
/- =======================================
Builtin elaboration functions
======================================= -/
@[builtinTermElab «prop»] def elabProp : TermElab := fun _ _ =>
return mkSort levelZero
private def elabOptLevel (stx : Syntax) : TermElabM Level :=
if stx.isNone then
pure levelZero
else
elabLevel stx[0]
@[builtinTermElab «sort»] def elabSort : TermElab := fun stx _ =>
return mkSort (← elabOptLevel stx[1])
@[builtinTermElab «type»] def elabTypeStx : TermElab := fun stx _ =>
return mkSort (mkLevelSucc (← elabOptLevel stx[1]))
@[builtinTermElab «hole»] def elabHole : TermElab := fun stx expectedType? => do
let mvar ← mkFreshExprMVar expectedType?
registerMVarErrorHoleInfo mvar.mvarId! stx
pure mvar
@[builtinTermElab «syntheticHole»] def elabSyntheticHole : TermElab := fun stx expectedType? => do
let arg := stx[1]
let userName := if arg.isIdent then arg.getId else Name.anonymous
let mkNewHole : Unit → TermElabM Expr := fun _ => do
let mvar ← mkFreshExprMVar expectedType? MetavarKind.syntheticOpaque userName
registerMVarErrorHoleInfo mvar.mvarId! stx
pure mvar
if userName.isAnonymous then
mkNewHole ()
else
let mctx ← getMCtx
match mctx.findUserName? userName with
| none => mkNewHole ()
| some mvarId =>
let mvar := mkMVar mvarId
let mvarDecl ← getMVarDecl mvarId
let lctx ← getLCtx
if mvarDecl.lctx.isSubPrefixOf lctx then
pure mvar
else match mctx.getExprAssignment? mvarId with
| some val =>
let val ← instantiateMVars val
if mctx.isWellFormed lctx val then
pure val
else
withLCtx mvarDecl.lctx mvarDecl.localInstances do
throwError! "synthetic hole has already been defined and assigned to value incompatible with the current context{indentExpr val}"
| none =>
if mctx.isDelayedAssigned mvarId then
-- We can try to improve this case if needed.
throwError "synthetic hole has already beend defined and delayed assigned with an incompatible local context"
else if lctx.isSubPrefixOf mvarDecl.lctx then
let mvarNew ← mkNewHole ()
modifyMCtx fun mctx => mctx.assignExpr mvarId mvarNew
pure mvarNew
else
throwError "synthetic hole has already been defined with an incompatible local context"
private def mkTacticMVar (type : Expr) (tacticCode : Syntax) : TermElabM Expr := do
let mvar ← mkFreshExprMVar type MetavarKind.syntheticOpaque
let mvarId := mvar.mvarId!
let ref ← getRef
let declName? ← getDeclName?
registerSyntheticMVar ref mvarId $ SyntheticMVarKind.tactic declName? tacticCode
pure mvar
@[builtinTermElab byTactic] def elabByTactic : TermElab := fun stx expectedType? =>
match expectedType? with
| some expectedType => mkTacticMVar expectedType stx
| none => throwError ("invalid 'by' tactic, expected type has not been provided")
@[builtinMacro Lean.Parser.Term.listLit] def expandListLit : Macro := fun stx =>
let openBkt := stx[0]
let args := stx[1]
let closeBkt := stx[2]
let consId := mkIdentFrom openBkt `List.cons
let nilId := mkIdentFrom closeBkt `List.nil
return args.getSepArgs.foldr (init := nilId) fun arg r =>
Syntax.mkApp consId #[arg, r]
@[builtinMacro Lean.Parser.Term.arrayLit] def expandArrayLit : Macro := fun stx =>
match_syntax stx with
| `(#[$args*]) => `(List.toArray [$args*])
| _ => throw $ Macro.Exception.error stx "unexpected array literal syntax"
def resolveLocalName (n : Name) : TermElabM (Option (Expr × List String)) := do
let lctx ← getLCtx
let view := extractMacroScopes n
let rec loop (n : Name) (projs : List String) :=
match lctx.findFromUserName? { view with name := n }.review with
| some decl => some (decl.toExpr, projs)
| none => match n with
| Name.str pre s _ => loop pre (s::projs)
| _ => none
pure $ loop view.name []
/- Return true iff `stx` is a `Syntax.ident`, and it is a local variable. -/
def isLocalIdent? (stx : Syntax) : TermElabM (Option Expr) :=
match stx with
| Syntax.ident _ _ val _ => do
let r? ← resolveLocalName val
match r? with
| some (fvar, []) => pure (some fvar)
| _ => pure none
| _ => pure none
private def mkFreshLevelMVars (num : Nat) : TermElabM (List Level) :=
num.foldM (init := []) fun _ us =>
return (← mkFreshLevelMVar)::us
/--
Create an `Expr.const` using the given name and explicit levels.
Remark: fresh universe metavariables are created if the constant has more universe
parameters than `explicitLevels`. -/
def mkConst (constName : Name) (explicitLevels : List Level := []) : TermElabM Expr := do
let cinfo ← getConstInfo constName
if explicitLevels.length > cinfo.lparams.length then
throwError "too many explicit universe levels"
else
let numMissingLevels := cinfo.lparams.length - explicitLevels.length
let us ← mkFreshLevelMVars numMissingLevels
pure $ Lean.mkConst constName (explicitLevels ++ us)
private def mkConsts (candidates : List (Name × List String)) (explicitLevels : List Level) : TermElabM (List (Expr × List String)) := do
candidates.foldlM (init := []) fun result (constName, projs) => do
-- TODO: better suppor for `mkConst` failure. We may want to cache the failures, and report them if all candidates fail.
let const ← mkConst constName explicitLevels
pure $ (const, projs) :: result
def resolveName (n : Name) (preresolved : List (Name × List String)) (explicitLevels : List Level) : TermElabM (List (Expr × List String)) := do
match (← resolveLocalName n) with
| some (e, projs) =>
unless explicitLevels.isEmpty do
throwError! "invalid use of explicit universe parameters, '{e}' is a local"
pure [(e, projs)]
| none =>
let process (candidates : List (Name × List String)) : TermElabM (List (Expr × List String)) := do
if candidates.isEmpty then
let mainModule ← getMainModule
let view := extractMacroScopes n
throwError! "unknown identifier '{view.format mainModule}'"
mkConsts candidates explicitLevels
if preresolved.isEmpty then
process (← resolveGlobalName n)
else
process preresolved
@[builtinTermElab cdot] def elabBadCDot : TermElab := fun stx _ =>
throwError "invalid occurrence of `·` notation, it must be surrounded by parentheses (e.g. `(· + 1)`)"
@[builtinTermElab strLit] def elabStrLit : TermElab := fun stx _ => do
match stx.isStrLit? with
| some val => pure $ mkStrLit val
| none => throwIllFormedSyntax
@[builtinTermElab numLit] def elabNumLit : TermElab := fun stx expectedType? => do
let val ← match stx.isNatLit? with
| some val => pure (mkNatLit val)
| none => throwIllFormedSyntax
let typeMVar ← mkFreshTypeMVar MetavarKind.synthetic
registerSyntheticMVar stx typeMVar.mvarId! (SyntheticMVarKind.withDefault (Lean.mkConst `Nat))
match expectedType? with
| some expectedType => isDefEq expectedType typeMVar; pure ()
| _ => pure ()
let u ← getLevel typeMVar
let u ← decLevel u
let mvar ← mkInstMVar (mkApp (Lean.mkConst `OfNat [u]) typeMVar)
pure $ mkApp3 (Lean.mkConst `OfNat.ofNat [u]) typeMVar mvar val
@[builtinTermElab charLit] def elabCharLit : TermElab := fun stx _ => do
match stx.isCharLit? with
| some val => return mkApp (Lean.mkConst `Char.ofNat) (mkNatLit val.toNat)
| none => throwIllFormedSyntax
@[builtinTermElab quotedName] def elabQuotedName : TermElab :=
fun stx _ =>
match stx[0].isNameLit? with
| some val => pure $ toExpr val
| none => throwIllFormedSyntax
@[builtinTermElab typeOf] def elabTypeOf : TermElab := fun stx _ => do
inferType (← elabTerm stx[1] none)
@[builtinTermElab ensureTypeOf] def elabEnsureTypeOf : TermElab := fun stx expectedType? =>
match stx[2].isStrLit? with
| none => throwIllFormedSyntax
| some msg => do
let refTerm ← elabTerm stx[1] none
let refTermType ← inferType refTerm
elabTermEnsuringType stx[3] refTermType true msg
@[builtinTermElab ensureExpectedType] def elabEnsureExpectedType : TermElab := fun stx expectedType? =>
match stx[1].isStrLit? with
| none => throwIllFormedSyntax
| some msg => elabTermEnsuringType stx[2] expectedType? true msg
private def mkSomeContext : Context := {
fileName := "<TermElabM>",
fileMap := arbitrary _,
currNamespace := Name.anonymous
}
@[inline] def TermElabM.run {α} (x : TermElabM α) (ctx : Context := mkSomeContext) (s : State := {}) : MetaM (α × State) :=
withConfig setElabConfig (x ctx $.run s)
@[inline] def TermElabM.run' {α} (x : TermElabM α) (ctx : Context := mkSomeContext) (s : State := {}) : MetaM α :=
(·.1) <$> x.run ctx s
@[inline] def TermElabM.toIO {α} (x : TermElabM α)
(ctxCore : Core.Context) (sCore : Core.State)
(ctxMeta : Meta.Context) (sMeta : Meta.State)
(ctx : Context) (s : State) : IO (α × Core.State × Meta.State × State) := do
let ((a, s), sCore, sMeta) ← (x.run ctx s).toIO ctxCore sCore ctxMeta sMeta
pure (a, sCore, sMeta, s)
instance {α} [MetaEval α] : MetaEval (TermElabM α) :=
⟨fun env opts x _ =>
let x : TermElabM α := do
try x finally
let s ← get
liftIO $ s.messages.forM fun msg => msg.toString >>= IO.println
MetaEval.eval env opts (hideUnit := true) $ x.run' mkSomeContext⟩
end Term
builtin_initialize
registerTraceClass `Elab.postpone
registerTraceClass `Elab.coe
registerTraceClass `Elab.debug
export Term (TermElabM)
end Lean.Elab
|
6ea7bde23d676052e9c0e5bfe51c5f6b28dfceca | d31b9f832ff922a603f76cf32e0f3aa822640508 | /src/hott/hit/quotient.lean | 83d10bbd60947d265631de876b5b39946d874a51 | [
"Apache-2.0"
] | permissive | javra/hott3 | 6e7a9e72a991a2fae32e5764982e521dca617b16 | cd51f2ab2aa48c1246a188f9b525b30f76c3d651 | refs/heads/master | 1,585,819,679,148 | 1,531,232,382,000 | 1,536,682,965,000 | 154,294,022 | 0 | 0 | Apache-2.0 | 1,540,284,376,000 | 1,540,284,375,000 | null | UTF-8 | Lean | false | false | 11,427 | lean | /-
Copyright (c) 2017 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Ulrik Buchholtz
Quotients. This is a quotient without truncation for an arbitrary type-valued binary relation
(graph).
See also .set_quotient
-/
/-
The hit quotient is primitive, declared in init.hit.
The constructors are, given {A : Type _} (R : A → A → Type _),
* class_of : A → quotient R (A implicit, R explicit)
* eq_of_rel : Π{a a' : A}, R a a' → class_of a = class_of a' (R explicit)
-/
import hott.arity hott.cubical.squareover hott.types.arrow hott.cubical.pathover2 hott.types.pointed
universes u v w
hott_theory
namespace hott
open hott.eq hott.equiv hott.pi is_trunc pointed hott.sigma
namespace quotient
section
variables {A : Type _} {R : A → A → Type _}
@[hott, induction, priority 1500] protected def elim {P : Type _} (Pc : A → P) (Pp : Π⦃a a' : A⦄
(H : R a a'), Pc a = Pc a') (x : quotient R) : P :=
begin hinduction x, exact Pc a, exact pathover_of_eq _ (Pp H) end
@[hott, reducible] protected def elim_on {P : Type _} (x : quotient R)
(Pc : A → P) (Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a = Pc a') : P :=
quotient.elim Pc Pp x
@[hott] theorem elim_eq_of_rel {P : Type _} (Pc : A → P)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a = Pc a') {a a' : A} (H : R a a')
: ap (quotient.elim Pc Pp) (eq_of_rel R H) = Pp H :=
begin
apply eq_of_fn_eq_fn_inv ((pathover_constant (eq_of_rel R H)) _ _),
refine (apd_eq_pathover_of_eq_ap _ _)⁻¹ ⬝ rec_eq_of_rel _ _ _
end
@[hott] protected def rec_prop {A : Type _} {R : A → A → Type _} {P : quotient R → Type _}
[H : Πx, is_prop (P x)] (Pc : Π(a : A), P (class_of R a)) (x : quotient R) : P x :=
quotient.rec Pc (λa a' H, is_prop.elimo _ _ _) x
@[hott] protected def elim_prop {P : Type _} [H : is_prop P] (Pc : A → P) (x : quotient R) : P :=
quotient.elim Pc (λa a' H, is_prop.elim _ _) x
@[hott] protected def elim_type (Pc : A → Type _)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a ≃ Pc a') : quotient R → Type _ :=
quotient.elim Pc (λa a' H, ua (Pp H))
@[hott, reducible] protected def elim_type_on (x : quotient R) (Pc : A → Type _)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a ≃ Pc a') : Type _ :=
quotient.elim_type Pc Pp x
@[hott] theorem elim_type_eq_of_rel_fn (Pc : A → Type _)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a ≃ Pc a') {a a' : A} (H : R a a')
: transport (quotient.elim_type Pc Pp) (eq_of_rel R H) = to_fun (Pp H) :=
begin
refine tr_eq_cast_ap_fn _ ⬝ ap cast _ ⬝ cast_ua_fn _,
apply elim_eq_of_rel
end
-- rename to elim_type_eq_of_rel_fn_inv
@[hott] theorem elim_type_eq_of_rel_inv (Pc : A → Type _)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a ≃ Pc a') {a a' : A} (H : R a a')
: transport (quotient.elim_type Pc Pp) (eq_of_rel R H)⁻¹ = to_inv (Pp H) :=
begin
hsimp [tr_eq_cast_ap_fn, quotient.elim_type, ap_inv, elim_eq_of_rel, cast_ua_inv_fn]
end
-- remove '
@[hott] theorem elim_type_eq_of_rel_inv' (Pc : A → Type _)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a ≃ Pc a') {a a' : A} (H : R a a') (x : Pc a')
: transport (quotient.elim_type Pc Pp) (eq_of_rel R H)⁻¹ x = to_inv (Pp H) x :=
ap10 (elim_type_eq_of_rel_inv Pc Pp H) x
@[hott] theorem elim_type_eq_of_rel (Pc : A → Type u)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a ≃ Pc a') {a a' : A} (H : R a a') (p : Pc a)
: transport (quotient.elim_type Pc Pp) (eq_of_rel R H) p = to_fun (Pp H) p :=
ap10 (elim_type_eq_of_rel_fn Pc Pp H) p
@[hott] def elim_type_eq_of_rel' (Pc : A → Type _)
(Pp : Π⦃a a' : A⦄ (H : R a a'), Pc a ≃ Pc a') {a a' : A} (H : R a a') (p : Pc a)
: @pathover _ (class_of _ a) (quotient.elim_type Pc Pp) p _ (eq_of_rel R H) (to_fun (Pp H) p) :=
pathover_of_tr_eq (elim_type_eq_of_rel Pc Pp H p)
@[hott] def elim_type_uncurried (H : Σ(Pc : A → Type _), Π⦃a a' : A⦄ (H : R a a'), Pc a ≃ Pc a')
: quotient R → Type _ :=
quotient.elim_type H.1 H.2
/- The dependent universal property -/
@[hott] def quotient_pi_equiv (C : quotient R → Type _) : (Πx, C x) ≃
(Σ(f : Π(a : A), C (class_of R a)), Π⦃a a' : A⦄ (H : R a a'), f a =[eq_of_rel R H] f a') :=
begin
fapply equiv.MK,
{ intro f, exact ⟨λa, f (class_of R a), λa a' H, apd f (eq_of_rel R H)⟩},
{ intros v x, induction v with i p, hinduction x,
exact (i a),
exact (p H)},
{ intro v, induction v with i p,
apply ap (sigma.mk i), apply eq_of_homotopy3, intros a a' H, apply rec_eq_of_rel},
{ intro f, apply eq_of_homotopy, intro x, hinduction x, reflexivity,
apply eq_pathover_dep, rwr rec_eq_of_rel, exact hrflo},
end
@[hott] def pquotient {A : Type*} (R : A → A → Type _) : Type* :=
pType.mk (quotient R) (class_of R pt)
end
/- the flattening lemma -/
namespace flattening
section
parameters {A : Type u} (R : A → A → Type v) (C : A → Type w) (f : Π⦃a a'⦄, R a a' → C a ≃ C a')
include f
variables {a a' : A} {r : R a a'}
private def P : quotient R → Type w := quotient.elim_type C f
@[hott] def flattening_type : Type (max u w) := Σa, C a
private def X := flattening_type
inductive flattening_rel : X → X → Type (max u v w)
| mk : Π⦃a a' : A⦄ (r : R a a') (c : C a), flattening_rel ⟨a, c⟩ ⟨a', f r c⟩
@[hott] def Ppt (c : C a) : sigma P :=
⟨class_of R a, c⟩
@[hott] def Peq (r : R a a') (c : C a) : Ppt c = Ppt (f r c) :=
begin
fapply sigma_eq,
{ apply eq_of_rel R r},
{ refine elim_type_eq_of_rel' C f r c}
end
@[hott] def rec {Q : sigma P → Type _} (Qpt : Π{a : A} (x : C a), Q (Ppt x))
(Qeq : Π⦃a a' : A⦄ (r : R a a') (c : C a), Qpt c =[Peq r c] Qpt (f r c))
(v : sigma P) : Q v :=
begin
induction v with q p,
hinduction q,
{ exact Qpt p},
{ apply pi_pathover_left, intro c,
refine _ ⬝op apdt Qpt (elim_type_eq_of_rel C f H c)⁻¹ᵖ,
refine _ ⬝op (tr_compose Q (Ppt R C f) _ _)⁻¹,
rwr ap_inv,
refine pathover_cancel_right _ (tr_pathover _ _)⁻¹ᵒ,
refine change_path _ (Qeq H c),
symmetry, dsimp [Ppt, Peq],
refine whisker_left _ (ap_dpair _) ⬝ _,
refine (dpair_eq_dpair_con _ _ _ _)⁻¹ ⬝ _,
apply ap (dpair_eq_dpair _), symmetry,
exact pathover_of_tr_eq_eq_concato _ },
end
@[hott] def elim' {Q : Type _} (Qpt : Π{a : A}, C a → Q)
(Qeq : Π⦃a a' : A⦄ (r : R a a') (c : C a), Qpt c = Qpt (f r c))
(q : quotient R) (p : P q) : Q :=
begin
hinduction q,
{ exact Qpt p},
{ apply arrow_pathover_constant_right,
intro c, exact Qeq H c ⬝ ap Qpt (elim_type_eq_of_rel C f H c)⁻¹},
end
@[hott] def elim {Q : Type _} (Qpt : Π{a : A}, C a → Q)
(Qeq : Π⦃a a' : A⦄ (r : R a a') (c : C a), Qpt c = Qpt (f r c))
(v : sigma P) : Q :=
begin
induction v with q p, exact elim' R C f @Qpt Qeq q p,
end
@[hott] theorem elim_Peq {Q : Type _} (Qpt : Π{a : A}, C a → Q)
(Qeq : Π⦃a a' : A⦄ (r : R a a') (c : C a), Qpt c = Qpt (f r c)) {a a' : A} (r : R a a')
(c : C a) : ap (elim @Qpt Qeq) (Peq r c) = Qeq r c :=
begin
refine ap_dpair_eq_dpair _ _ _ ⬝ _,
refine apd011_eq_apo11_apd (elim' R C f @Qpt Qeq) _ _ ⬝ _,
delta elim', dsimp, rwr [rec_eq_of_rel], dsimp,
refine @apo11_arrow_pathover_constant_right _ _ _ _ _ _ _ _ _ _ _
(λc : P R C f (class_of R a), Qeq r c ⬝ ap Qpt (elim_type_eq_of_rel C f r c)⁻¹) ⬝ _,
-- we need the @ because otherwise the elaborator unfolds too much
dsimp [elim_type_eq_of_rel'],
refine idp ◾ idp ◾ ap02 _ begin exact to_right_inv (pathover_equiv_tr_eq _ _ _) _ end ⬝ _,
rwr [ap_inv], apply inv_con_cancel_right
end
open flattening_rel
@[hott] def flattening_lemma : sigma P ≃ quotient flattening_rel :=
begin
fapply equiv.MK,
{ refine elim R C f _ _,
{ intros a c, exact class_of _ ⟨a, c⟩},
{ intros a a' r c, apply eq_of_rel, constructor}},
{ intro q, hinduction q with x x x' H,
{ exact Ppt R C f x.2},
{ induction H, apply Peq}},
{ intro q, hinduction q with x x x' H,
{ induction x with a c, reflexivity},
{ induction H, apply eq_pathover, apply hdeg_square,
refine ap_compose (elim R C f _ _) (quotient.elim _ _) _ ⬝ _,
rwr [elim_eq_of_rel, ap_id],
apply elim_Peq }},
{ refine rec R C f (λa x, idp) _, intros,
apply eq_pathover, apply hdeg_square,
refine ap_compose (quotient.elim _ _) (elim R C f _ _) _ ⬝ _,
rwr [elim_Peq, ap_id],
apply elim_eq_of_rel }
end
end
end flattening
section
open hott.is_equiv hott.equiv prod
variables {A : Type _} {R : A → A → Type _}
{B : Type _} {Q : B → B → Type _}
{C : Type _} {S : C → C → Type _}
(f : A → B) (k : Πa a' : A, R a a' → Q (f a) (f a'))
(g : B → C) (l : Πb b' : B, Q b b' → S (g b) (g b'))
@[hott] protected def functor : quotient R → quotient Q :=
quotient.elim (λa, class_of Q (f a)) (λa a' r, eq_of_rel Q (k a a' r))
@[hott, hsimp] def functor_class_of (a : A) :
quotient.functor f k (class_of R a) = class_of Q (f a) :=
by refl
@[hott, hsimp] def functor_eq_of_rel {a a' : A} (r : R a a') :
ap (quotient.functor f k) (eq_of_rel R r) = eq_of_rel Q (k a a' r) :=
elim_eq_of_rel _ _ r
@[hott] protected def functor_compose :
quotient.functor (g ∘ f) (λa a' r, l (f a) (f a') (k a a' r)) ~
quotient.functor g l ∘ quotient.functor f k :=
begin
intro x, hinduction x,
{ refl },
{ dsimp, apply eq_pathover_compose_right, apply hdeg_square, hsimp }
end
@[hott] protected def functor_homotopy {f f' : A → B} {k : Πa a' : A, R a a' → Q (f a) (f a')}
{k' : Πa a' : A, R a a' → Q (f' a) (f' a')} (h : f ~ f')
(h2 : Π(a a' : A) (r : R a a'), transport11 Q (h a) (h a') (k a a' r) = k' a a' r) :
quotient.functor f k ~ quotient.functor f' k' :=
begin
intro x, hinduction x with a a a' r,
{ exact ap (class_of Q) (h a) },
{ dsimp, apply eq_pathover, hsimp, apply transpose, apply natural_square2, apply h2 }
end
@[hott] protected def functor_id (x : quotient R) :
quotient.functor id (λa a' r, r) x = x :=
begin
hinduction x,
{ refl },
{ apply eq_pathover_id_right, apply hdeg_square, hsimp }
end
variables [F : is_equiv f] [K : Πa a', is_equiv (k a a')]
include F K
@[hott] instance is_equiv : is_equiv (quotient.functor f k) :=
begin
apply adjointify _ (quotient.functor f⁻¹ᶠ
(λb b' q, (k (f⁻¹ᶠ b) (f⁻¹ᶠ b'))⁻¹ᶠ (transport11 Q (right_inv f b)⁻¹ (right_inv f b')⁻¹ q))),
abstract { intro x, refine (quotient.functor_compose _ _ _ _ x)⁻¹ ⬝ _ ⬝ quotient.functor_id x,
apply quotient.functor_homotopy (right_inv f), intros a a' r,
rwr [right_inv (k _ _), ←transport11_con, con.left_inv, con.left_inv] },
abstract { intro x, refine (quotient.functor_compose _ _ _ _ x)⁻¹ ⬝ _ ⬝ quotient.functor_id x,
apply quotient.functor_homotopy (left_inv f), intros a a' r,
rwr [adj f, adj f, ←ap_inv, ←ap_inv, transport11_ap,
←fn_transport11_eq_transport11_fn _ _ _ _ k, left_inv (k _ _), ←transport11_con,
con.left_inv, con.left_inv] }
end
end
section
variables {A : Type _} (R : A → A → Type _)
{B : Type _} (Q : B → B → Type _)
(f : A ≃ B) (k : Πa a' : A, R a a' ≃ Q (f a) (f a'))
include f k
@[hott] protected def equiv : quotient R ≃ quotient Q :=
equiv.mk (quotient.functor f (λa a', k a a')) (quotient.is_equiv _ _)
end
end quotient
end hott
|
2607fc0604d32e61b9a7e95036b822463897caf0 | d1a52c3f208fa42c41df8278c3d280f075eb020c | /src/Lean/Message.lean | 817e35a372188cf3635465080a43a791de7cc31f | [
"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 | 14,864 | lean | /-
Copyright (c) 2018 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Sebastian Ullrich, Leonardo de Moura
Message Type used by the Lean frontend
-/
import Lean.Data.Position
import Lean.Data.OpenDecl
import Lean.Syntax
import Lean.MetavarContext
import Lean.Environment
import Lean.Util.PPExt
namespace Lean
def mkErrorStringWithPos (fileName : String) (pos : Position) (msg : String) (endPos : Option Position := none) : String :=
let endPos := match endPos with
| some endPos => s!"-{endPos.line}:{endPos.column}"
| none => ""
s!"{fileName}:{pos.line}:{pos.column}{endPos}: {msg}"
inductive MessageSeverity where
| information | warning | error
deriving Inhabited, BEq
structure MessageDataContext where
env : Environment
mctx : MetavarContext
lctx : LocalContext
opts : Options
structure NamingContext where
currNamespace : Name
openDecls : List OpenDecl
/- Structure message data. We use it for reporting errors, trace messages, etc. -/
inductive MessageData where
| ofFormat : Format → MessageData
| ofSyntax : Syntax → MessageData
| ofExpr : Expr → MessageData
| ofLevel : Level → MessageData
| ofName : Name → MessageData
| ofGoal : MVarId → MessageData
/- `withContext ctx d` specifies the pretty printing context `(env, mctx, lctx, opts)` for the nested expressions in `d`. -/
| withContext : MessageDataContext → MessageData → MessageData
| withNamingContext : NamingContext → MessageData → MessageData
/- Lifted `Format.nest` -/
| nest : Nat → MessageData → MessageData
/- Lifted `Format.group` -/
| group : MessageData → MessageData
/- Lifted `Format.compose` -/
| compose : MessageData → MessageData → MessageData
/- Tagged sections. `Name` should be viewed as a "kind", and is used by `MessageData` inspector functions.
Example: an inspector that tries to find "definitional equality failures" may look for the tag "DefEqFailure". -/
| tagged : Name → MessageData → MessageData
| node : Array MessageData → MessageData
deriving Inhabited
namespace MessageData
/- Instantiate metavariables occurring in nexted `ofExpr` constructors.
It uses the surrounding `MetavarContext` at `withContext` constructors.
-/
partial def instantiateMVars (msg : MessageData) : MessageData :=
visit msg {}
where
visit (msg : MessageData) (mctx : MetavarContext) : MessageData :=
match msg with
| ofExpr e => ofExpr <| mctx.instantiateMVars e |>.1
| withContext ctx msg => withContext ctx <| visit msg ctx.mctx
| withNamingContext ctx msg => withNamingContext ctx <| visit msg mctx
| nest n msg => nest n <| visit msg mctx
| group msg => group <| visit msg mctx
| compose msg₁ msg₂ => compose (visit msg₁ mctx) <| visit msg₂ mctx
| tagged n msg => tagged n <| visit msg mctx
| node msgs => node <| msgs.map (visit . mctx)
| _ => msg
variable (p : Name → Bool) in
partial def hasTag : MessageData → Bool
| withContext _ msg => hasTag msg
| withNamingContext _ msg => hasTag msg
| nest _ msg => hasTag msg
| group msg => hasTag msg
| compose msg₁ msg₂ => hasTag msg₁ || hasTag msg₂
| tagged n msg => p n || hasTag msg
| node msgs => msgs.any hasTag
| _ => false
def nil : MessageData :=
ofFormat Format.nil
def isNil : MessageData → Bool
| ofFormat Format.nil => true
| _ => false
def isNest : MessageData → Bool
| nest _ _ => true
| _ => false
def mkPPContext (nCtx : NamingContext) (ctx : MessageDataContext) : PPContext := {
env := ctx.env, mctx := ctx.mctx, lctx := ctx.lctx, opts := ctx.opts,
currNamespace := nCtx.currNamespace, openDecls := nCtx.openDecls
}
partial def formatAux : NamingContext → Option MessageDataContext → MessageData → IO Format
| _, _, ofFormat fmt => pure fmt
| _, _, ofLevel u => pure $ format u
| _, _, ofName n => pure $ format n
| nCtx, some ctx, ofSyntax s => ppTerm (mkPPContext nCtx ctx) s -- HACK: might not be a term
| _, none, ofSyntax s => pure $ s.formatStx
| _, none, ofExpr e => pure $ format (toString e)
| nCtx, some ctx, ofExpr e => ppExpr (mkPPContext nCtx ctx) e
| _, none, ofGoal mvarId => pure $ "goal " ++ format (mkMVar mvarId)
| nCtx, some ctx, ofGoal mvarId => ppGoal (mkPPContext nCtx ctx) mvarId
| nCtx, _, withContext ctx d => formatAux nCtx ctx d
| _, ctx, withNamingContext nCtx d => formatAux nCtx ctx d
| nCtx, ctx, tagged t d =>
/- Messages starting a trace context have their tags postfixed with `_traceCtx` so that
we can detect them later. Here, we do so in order to print the trace context class. -/
if let Name.str cls "_traceCtx" _ := t then do
let d₁ ← formatAux nCtx ctx d
return f!"[{cls}] {d₁}"
else
formatAux nCtx ctx d
| nCtx, ctx, nest n d => Format.nest n <$> formatAux nCtx ctx d
| nCtx, ctx, compose d₁ d₂ => do let d₁ ← formatAux nCtx ctx d₁; let d₂ ← formatAux nCtx ctx d₂; pure $ d₁ ++ d₂
| nCtx, ctx, group d => Format.group <$> formatAux nCtx ctx d
| nCtx, ctx, node ds => Format.nest 2 <$> ds.foldlM (fun r d => do let d ← formatAux nCtx ctx d; pure $ r ++ Format.line ++ d) Format.nil
protected def format (msgData : MessageData) : IO Format :=
formatAux { currNamespace := Name.anonymous, openDecls := [] } none msgData
protected def toString (msgData : MessageData) : IO String := do
let fmt ← msgData.format
pure $ toString fmt
instance : Append MessageData := ⟨compose⟩
instance : Coe String MessageData := ⟨ofFormat ∘ format⟩
instance : Coe Format MessageData := ⟨ofFormat⟩
instance : Coe Level MessageData := ⟨ofLevel⟩
instance : Coe Expr MessageData := ⟨ofExpr⟩
instance : Coe Name MessageData := ⟨ofName⟩
instance : Coe Syntax MessageData := ⟨ofSyntax⟩
instance : Coe (Option Expr) MessageData := ⟨fun o => match o with | none => "none" | some e => ofExpr e⟩
partial def arrayExpr.toMessageData (es : Array Expr) (i : Nat) (acc : MessageData) : MessageData :=
if h : i < es.size then
let e := es.get ⟨i, h⟩;
let acc := if i == 0 then acc ++ ofExpr e else acc ++ ", " ++ ofExpr e;
toMessageData es (i+1) acc
else
acc ++ "]"
instance : Coe (Array Expr) MessageData := ⟨fun es => arrayExpr.toMessageData es 0 "#["⟩
def bracket (l : String) (f : MessageData) (r : String) : MessageData := group (nest l.length $ l ++ f ++ r)
def paren (f : MessageData) : MessageData := bracket "(" f ")"
def sbracket (f : MessageData) : MessageData := bracket "[" f "]"
def joinSep : List MessageData → MessageData → MessageData
| [], sep => Format.nil
| [a], sep => a
| a::as, sep => a ++ sep ++ joinSep as sep
def ofList: List MessageData → MessageData
| [] => "[]"
| xs => sbracket $ joinSep xs (ofFormat "," ++ Format.line)
def ofArray (msgs : Array MessageData) : MessageData :=
ofList msgs.toList
instance : Coe (List MessageData) MessageData := ⟨ofList⟩
instance : Coe (List Expr) MessageData := ⟨fun es => ofList $ es.map ofExpr⟩
end MessageData
structure Message where
fileName : String
pos : Position
endPos : Option Position := none
severity : MessageSeverity := MessageSeverity.error
caption : String := ""
data : MessageData
deriving Inhabited
namespace Message
protected def toString (msg : Message) (includeEndPos := false) : IO String := do
let mut str ← msg.data.toString
let endPos := if includeEndPos then msg.endPos else none
unless msg.caption == "" do
str := msg.caption ++ ":\n" ++ str
match msg.severity with
| MessageSeverity.information => pure ()
| MessageSeverity.warning => str := mkErrorStringWithPos msg.fileName msg.pos (endPos := endPos) "warning: " ++ str
| MessageSeverity.error => str := mkErrorStringWithPos msg.fileName msg.pos (endPos := endPos) "error: " ++ str
if str.isEmpty || str.back != '\n' then
str := str ++ "\n"
return str
end Message
structure MessageLog where
msgs : Std.PersistentArray Message := {}
deriving Inhabited
namespace MessageLog
def empty : MessageLog := ⟨{}⟩
def isEmpty (log : MessageLog) : Bool :=
log.msgs.isEmpty
def add (msg : Message) (log : MessageLog) : MessageLog :=
⟨log.msgs.push msg⟩
protected def append (l₁ l₂ : MessageLog) : MessageLog :=
⟨l₁.msgs ++ l₂.msgs⟩
instance : Append MessageLog :=
⟨MessageLog.append⟩
def hasErrors (log : MessageLog) : Bool :=
log.msgs.any fun m => match m.severity with
| MessageSeverity.error => true
| _ => false
def errorsToWarnings (log : MessageLog) : MessageLog :=
{ msgs := log.msgs.map (fun m => match m.severity with | MessageSeverity.error => { m with severity := MessageSeverity.warning } | _ => m) }
def getInfoMessages (log : MessageLog) : MessageLog :=
{ msgs := log.msgs.filter fun m => match m.severity with | MessageSeverity.information => true | _ => false }
def forM {m : Type → Type} [Monad m] (log : MessageLog) (f : Message → m Unit) : m Unit :=
log.msgs.forM f
def toList (log : MessageLog) : List Message :=
(log.msgs.foldl (fun acc msg => msg :: acc) []).reverse
end MessageLog
def MessageData.nestD (msg : MessageData) : MessageData :=
MessageData.nest 2 msg
def indentD (msg : MessageData) : MessageData :=
MessageData.nestD (Format.line ++ msg)
def indentExpr (e : Expr) : MessageData :=
indentD e
class AddMessageContext (m : Type → Type) where
addMessageContext : MessageData → m MessageData
export AddMessageContext (addMessageContext)
instance (m n) [MonadLift m n] [AddMessageContext m] : AddMessageContext n where
addMessageContext := fun msg => liftM (addMessageContext msg : m _)
def addMessageContextPartial {m} [Monad m] [MonadEnv m] [MonadOptions m] (msgData : MessageData) : m MessageData := do
let env ← getEnv
let opts ← getOptions
pure $ MessageData.withContext { env := env, mctx := {}, lctx := {}, opts := opts } msgData
def addMessageContextFull {m} [Monad m] [MonadEnv m] [MonadMCtx m] [MonadLCtx m] [MonadOptions m] (msgData : MessageData) : m MessageData := do
let env ← getEnv
let mctx ← getMCtx
let lctx ← getLCtx
let opts ← getOptions
pure $ MessageData.withContext { env := env, mctx := mctx, lctx := lctx, opts := opts } msgData
class ToMessageData (α : Type) where
toMessageData : α → MessageData
export ToMessageData (toMessageData)
def stringToMessageData (str : String) : MessageData :=
let lines := str.split (· == '\n')
let lines := lines.map (MessageData.ofFormat ∘ format)
MessageData.joinSep lines (MessageData.ofFormat Format.line)
instance {α} [ToFormat α] : ToMessageData α := ⟨MessageData.ofFormat ∘ format⟩
instance : ToMessageData Expr := ⟨MessageData.ofExpr⟩
instance : ToMessageData Level := ⟨MessageData.ofLevel⟩
instance : ToMessageData Name := ⟨MessageData.ofName⟩
instance : ToMessageData String := ⟨stringToMessageData⟩
instance : ToMessageData Syntax := ⟨MessageData.ofSyntax⟩
instance : ToMessageData Format := ⟨MessageData.ofFormat⟩
instance : ToMessageData MessageData := ⟨id⟩
instance {α} [ToMessageData α] : ToMessageData (List α) := ⟨fun as => MessageData.ofList $ as.map toMessageData⟩
instance {α} [ToMessageData α] : ToMessageData (Array α) := ⟨fun as => toMessageData as.toList⟩
instance {α} [ToMessageData α] : ToMessageData (Subarray α) := ⟨fun as => toMessageData as.toArray.toList⟩
instance {α} [ToMessageData α] : ToMessageData (Option α) := ⟨fun | none => "none" | some e => "some (" ++ toMessageData e ++ ")"⟩
instance : ToMessageData (Option Expr) := ⟨fun | none => "<not-available>" | some e => toMessageData e⟩
syntax:max "m!" interpolatedStr(term) : term
macro_rules
| `(m! $interpStr) => do interpStr.expandInterpolatedStr (← `(MessageData)) (← `(toMessageData))
namespace KernelException
private def mkCtx (env : Environment) (lctx : LocalContext) (opts : Options) (msg : MessageData) : MessageData :=
MessageData.withContext { env := env, mctx := {}, lctx := lctx, opts := opts } msg
def toMessageData (e : KernelException) (opts : Options) : MessageData :=
match e with
| unknownConstant env constName => mkCtx env {} opts m!"(kernel) unknown constant '{constName}'"
| alreadyDeclared env constName => mkCtx env {} opts m!"(kernel) constant has already been declared '{constName}'"
| declTypeMismatch env decl givenType =>
let process (n : Name) (expectedType : Expr) : MessageData :=
m!"(kernel) declaration type mismatch, '{n}' has type{indentExpr givenType}\nbut it is expected to have type{indentExpr expectedType}";
match decl with
| Declaration.defnDecl { name := n, type := type, .. } => process n type
| Declaration.thmDecl { name := n, type := type, .. } => process n type
| _ => "(kernel) declaration type mismatch" -- TODO fix type checker, type mismatch for mutual decls does not have enough information
| declHasMVars env constName _ => mkCtx env {} opts m!"(kernel) declaration has metavariables '{constName}'"
| declHasFVars env constName _ => mkCtx env {} opts m!"(kernel) declaration has free variables '{constName}'"
| funExpected env lctx e => mkCtx env lctx opts m!"(kernel) function expected{indentExpr e}"
| typeExpected env lctx e => mkCtx env lctx opts m!"(kernel) type expected{indentExpr e}"
| letTypeMismatch env lctx n _ _ => mkCtx env lctx opts m!"(kernel) let-declaration type mismatch '{n}'"
| exprTypeMismatch env lctx e _ => mkCtx env lctx opts m!"(kernel) type mismatch at{indentExpr e}"
| appTypeMismatch env lctx e fnType argType =>
mkCtx env lctx opts m!"application type mismatch{indentExpr e}\nargument has type{indentExpr argType}\nbut function has type{indentExpr fnType}"
| invalidProj env lctx e => mkCtx env lctx opts m!"(kernel) invalid projection{indentExpr e}"
| other msg => m!"(kernel) {msg}"
end KernelException
end Lean
|
4f7a44bf29e5403f94270528c82f7f0165b2f5e9 | ee8cdbabf07f77e7be63a449b8483ce308d37218 | /lean/src/valid/mathd-numbertheory-42.lean | d195ad5ea967bd4c60f7c5a03885db51eda0951a | [
"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 | 329 | 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.pnat.basic
example (u v : ℕ+) (h₀ : 40 ∣ (27*u - 17)) (h₁ : 40 ∣ (27*v - 17)) (h₂ : u < 40) (h₃ : v < 80) (h₄ : 40 < v) : (u + v) = 62 :=
begin
sorry
end
|
f152eed623cbae2d0ae957d6958533d568ad3039 | 54d7e71c3616d331b2ec3845d31deb08f3ff1dea | /library/tools/super/clausifier.lean | 218256117148c2a4072d6b7670a7cc9b4e68bfa8 | [
"Apache-2.0"
] | permissive | pachugupta/lean | 6f3305c4292288311cc4ab4550060b17d49ffb1d | 0d02136a09ac4cf27b5c88361750e38e1f485a1a | refs/heads/master | 1,611,110,653,606 | 1,493,130,117,000 | 1,493,167,649,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 10,792 | lean | /-
Copyright (c) 2016 Gabriel Ebner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner
-/
import .clause .clause_ops
import .prover_state .misc_preprocessing
open expr list tactic monad decidable
universe u
namespace super
meta def try_option {a : Type u} (tac : tactic a) : tactic (option a) :=
lift some tac <|> return none
private meta def normalize : expr → tactic expr | e := do
e' ← whnf e reducible,
args' ← monad.for e'.get_app_args normalize,
return $ app_of_list e'.get_app_fn args'
meta def inf_normalize_l (c : clause) : tactic (list clause) :=
on_first_left c $ λtype, do
type' ← normalize type,
guard $ type' ≠ type,
h ← mk_local_def `h type',
return [([h], h)]
meta def inf_normalize_r (c : clause) : tactic (list clause) :=
on_first_right c $ λha, do
a' ← normalize ha.local_type,
guard $ a' ≠ ha.local_type,
hna ← mk_local_def `hna (imp a' c.local_false),
return [([hna], app hna ha)]
meta def inf_false_l (c : clause) : tactic (list clause) :=
first $ do i ← list.range c.num_lits,
if c.get_lit i = clause.literal.left ```(false)
then [return []]
else []
meta def inf_false_r (c : clause) : tactic (list clause) :=
on_first_right c $ λhf,
if hf.local_type = c.local_false
then return [([], hf)]
else match hf.local_type with
| const ``false [] := do
pr ← mk_app ``false.rec [c.local_false, hf],
return [([], pr)]
| _ := failed
end
meta def inf_true_l (c : clause) : tactic (list clause) :=
on_first_left c $ λt,
match t with
| (const ``true []) := return [([], const ``true.intro [])]
| _ := failed
end
meta def inf_true_r (c : clause) : tactic (list clause) :=
first $ do i ← list.range c.num_lits,
if c.get_lit i = clause.literal.right (const ``true [])
then [return []]
else []
meta def inf_not_l (c : clause) : tactic (list clause) :=
on_first_left c $ λtype,
match type with
| app (const ``not []) a := do
hna ← mk_local_def `h ```(%%a → false),
return [([hna], hna)]
| _ := failed
end
meta def inf_not_r (c : clause) : tactic (list clause) :=
on_first_right c $ λhna,
match hna.local_type with
| app (const ``not []) a := do
hnna ← mk_local_def `h ```((%%a → false) → %%c.local_false),
return [([hnna], app hnna hna)]
| _ := failed
end
meta def inf_and_l (c : clause) : tactic (list clause) :=
on_first_left c $ λab,
match ab with
| (app (app (const ``and []) a) b) := do
ha ← mk_local_def `l a,
hb ← mk_local_def `r b,
pab ← mk_mapp ``and.intro [some a, some b, some ha, some hb],
return [([ha, hb], pab)]
| _ := failed
end
meta def inf_and_r (c : clause) : tactic (list clause) :=
on_first_right' c $ λhyp, do
pa ← mk_mapp ``and.left [none, none, some hyp],
pb ← mk_mapp ``and.right [none, none, some hyp],
return [([], pa), ([], pb)]
meta def inf_iff_l (c : clause) : tactic (list clause) :=
on_first_left c $ λab,
match ab with
| (app (app (const ``iff []) a) b) := do
hab ← mk_local_def `l (imp a b),
hba ← mk_local_def `r (imp b a),
pab ← mk_mapp ``iff.intro [some a, some b, some hab, some hba],
return [([hab, hba], pab)]
| _ := failed
end
meta def inf_iff_r (c : clause) : tactic (list clause) :=
on_first_right' c $ λhyp, do
pa ← mk_mapp ``iff.mp [none, none, some hyp],
pb ← mk_mapp ``iff.mpr [none, none, some hyp],
return [([], pa), ([], pb)]
meta def inf_or_r (c : clause) : tactic (list clause) :=
on_first_right c $ λhab,
match hab.local_type with
| (app (app (const ``or []) a) b) := do
hna ← mk_local_def `l (imp a c.local_false),
hnb ← mk_local_def `r (imp b c.local_false),
proof ← mk_app ``or.elim [a, b, c.local_false, hab, hna, hnb],
return [([hna, hnb], proof)]
| _ := failed
end
meta def inf_or_l (c : clause) : tactic (list clause) :=
on_first_left c $ λab,
match ab with
| (app (app (const ``or []) a) b) := do
ha ← mk_local_def `l a,
hb ← mk_local_def `l b,
pa ← mk_mapp ``or.inl [some a, some b, some ha],
pb ← mk_mapp ``or.inr [some a, some b, some hb],
return [([ha], pa), ([hb], pb)]
| _ := failed
end
meta def inf_all_r (c : clause) : tactic (list clause) :=
on_first_right' c $ λhallb,
match hallb.local_type with
| (pi n bi a b) := do
ha ← mk_local_def `x a,
return [([ha], app hallb ha)]
| _ := failed
end
lemma imp_l {F a b} [decidable a] : ((a → b) → F) → ((a → F) → F) :=
λhabf haf, decidable.by_cases
(assume ha : a, haf ha)
(assume hna : ¬a, habf (take ha, absurd ha hna))
lemma imp_l' {F a b} [decidable F] : ((a → b) → F) → ((a → F) → F) :=
λhabf haf, decidable.by_cases
(assume hf : F, hf)
(assume hnf : ¬F, habf (take ha, absurd (haf ha) hnf))
lemma imp_l_c {F : Prop} {a b} : ((a → b) → F) → ((a → F) → F) :=
λhabf haf, classical.by_cases
(assume hf : F, hf)
(assume hnf : ¬F, habf (take ha, absurd (haf ha) hnf))
meta def inf_imp_l (c : clause) : tactic (list clause) :=
on_first_left_dn c $ λhnab,
match hnab.local_type with
| (pi _ _ (pi _ _ a b) _) :=
if b.has_var then failed else do
hna ← mk_local_def `na (imp a c.local_false),
pf ← first (do r ← [``super.imp_l, ``super.imp_l', ``super.imp_l_c],
[mk_app r [hnab, hna]]),
hb ← mk_local_def `b b,
return [([hna], pf), ([hb], app hnab (lam `a binder_info.default a hb))]
| _ := failed
end
meta def inf_ex_l (c : clause) : tactic (list clause) :=
on_first_left c $ λexp,
match exp with
| (app (app (const ``Exists [u]) dom) pred) := do
hx ← mk_local_def `x dom,
predx ← whnf $ app pred hx,
hpx ← mk_local_def `hpx predx,
return [([hx,hpx], app_of_list (const ``exists.intro [u])
[dom, pred, hx, hpx])]
| _ := failed
end
lemma demorgan' {F a} {b : a → Prop} : ((∀x, b x) → F) → (((∃x, b x → F) → F) → F) :=
assume hab hnenb,
classical.by_cases
(assume h : ∃x, ¬b x, begin cases h with x, apply hnenb, existsi x, intros, contradiction end)
(assume h : ¬∃x, ¬b x, hab (take x,
classical.by_cases
(assume bx : b x, bx)
(assume nbx : ¬b x, begin assert hf : false, apply h, existsi x, assumption, contradiction end)))
meta def inf_all_l (c : clause) : tactic (list clause) :=
on_first_left_dn c $ λhnallb,
match hnallb.local_type with
| pi _ _ (pi n bi a b) _ := do
enb ← mk_mapp ``Exists [none, some $ lam n binder_info.default a (imp b c.local_false)],
hnenb ← mk_local_def `h (imp enb c.local_false),
pr ← mk_app ``super.demorgan' [hnallb, hnenb],
return [([hnenb], pr)]
| _ := failed
end
meta def inf_ex_r (c : clause) : tactic (list clause) := do
(qf, ctx) ← c.open_constn c.num_quants,
skolemized ← on_first_right' qf $ λhexp,
match hexp.local_type with
| (app (app (const ``Exists [_]) d) p) := do
sk_sym_name_pp ← get_unused_name `sk (some 1),
inh_lc ← mk_local' `w binder_info.implicit d,
sk_sym ← mk_local_def sk_sym_name_pp (pis (ctx ++ [inh_lc]) d),
sk_p ← whnf_no_delta $ app p (app_of_list sk_sym (ctx ++ [inh_lc])),
sk_ax ← mk_mapp ``Exists [some (local_type sk_sym),
some (lambdas [sk_sym] (pis (ctx ++ [inh_lc]) (imp hexp.local_type sk_p)))],
sk_ax_name ← get_unused_name `sk_axiom (some 1), assert sk_ax_name sk_ax,
nonempt_of_inh ← mk_mapp ``nonempty.intro [some d, some inh_lc],
eps ← mk_mapp ``classical.epsilon [some d, some nonempt_of_inh, some p],
existsi (lambdas (ctx ++ [inh_lc]) eps),
eps_spec ← mk_mapp ``classical.epsilon_spec [some d, some p],
exact (lambdas (ctx ++ [inh_lc]) eps_spec),
sk_ax_local ← get_local sk_ax_name, cases sk_ax_local [sk_sym_name_pp, sk_ax_name],
sk_ax' ← get_local sk_ax_name,
return [([inh_lc], app_of_list sk_ax' (ctx ++ [inh_lc, hexp]))]
| _ := failed
end,
return $ skolemized.map (λs, s.close_constn ctx)
meta def first_some {a : Type} : list (tactic (option a)) → tactic (option a)
| [] := return none
| (x::xs) := do xres ← x, match xres with some y := return (some y) | none := first_some xs end
private meta def get_clauses_core' (rules : list (clause → tactic (list clause)))
: list clause → tactic (list clause) | cs :=
lift list.join $ do
for cs $ λc, do first $
rules.map (λr, r c >>= get_clauses_core') ++ [return [c]]
meta def get_clauses_core (rules : list (clause → tactic (list clause))) (initial : list clause)
: tactic (list clause) := do
clauses ← get_clauses_core' rules initial,
filter (λc, lift bnot $ is_taut c) $ list.nub_on clause.type clauses
meta def clausification_rules_intuit : list (clause → tactic (list clause)) :=
[ inf_false_l, inf_false_r, inf_true_l, inf_true_r,
inf_not_l, inf_not_r,
inf_and_l, inf_and_r,
inf_iff_l, inf_iff_r,
inf_or_l, inf_or_r,
inf_ex_l,
inf_normalize_l, inf_normalize_r ]
meta def clausification_rules_classical : list (clause → tactic (list clause)) :=
[ inf_false_l, inf_false_r, inf_true_l, inf_true_r,
inf_not_l, inf_not_r,
inf_and_l, inf_and_r,
inf_iff_l, inf_iff_r,
inf_or_l, inf_or_r,
inf_imp_l, inf_all_r,
inf_ex_l,
inf_all_l, inf_ex_r,
inf_normalize_l, inf_normalize_r ]
meta def get_clauses_classical : list clause → tactic (list clause) :=
get_clauses_core clausification_rules_classical
meta def get_clauses_intuit : list clause → tactic (list clause) :=
get_clauses_core clausification_rules_intuit
meta def as_refutation : tactic unit := do
repeat (do intro1, skip),
tgt ← target,
if tgt.is_constant || tgt.is_local_constant then skip else do
local_false_name ← get_unused_name `F none, tgt_type ← infer_type tgt,
definev local_false_name tgt_type tgt, local_false ← get_local local_false_name,
target_name ← get_unused_name `target none,
assertv target_name (imp tgt local_false) (lam `hf binder_info.default tgt $ mk_var 0),
change local_false
meta def clauses_of_context : tactic (list clause) := do
local_false ← target,
l ← local_context,
monad.for l (clause.of_proof local_false)
meta def clausify_pre := preprocessing_rule $ take new, lift list.join $ for new $ λ dc, do
cs ← get_clauses_classical [dc.c],
if cs.length ≤ 1 then
return (for cs $ λ c, { dc with c := c })
else
for cs (λc, mk_derived c dc.sc)
-- @[super.inf]
meta def clausification_inf : inf_decl := inf_decl.mk 0 $
λgiven, list.foldr orelse (return ()) $
do r ← clausification_rules_classical,
[do cs ← r given.c,
cs' ← get_clauses_classical cs,
for' cs' (λc, mk_derived c given.sc.sched_now >>= add_inferred),
remove_redundant given.id []]
end super
|
0cd8cd82056daae6bf05e6f52979b2f049f4a76a | 900ff83b8a995f83b07c2fa0715d52fa265c4b9e | /library/init/function.lean | 118cc44e1eab3f3907ff73a55fb5caf4374d9db0 | [
"Apache-2.0"
] | permissive | moritzbuhl/lean | b2ee98197f1c47255c647228c07c830b229ba766 | 89e98b56713c027afdf97ad96abd2d54b35a43d5 | refs/heads/master | 1,688,295,006,616 | 1,627,741,115,000 | 1,627,741,115,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 6,645 | lean | /-
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura, Jeremy Avigad, Haitao Zhang
-/
prelude
import init.data.prod init.funext init.logic
/-!
# General operations on functions
-/
universes u₁ u₂ u₃ u₄
namespace function
variables {α : Sort u₁} {β : Sort u₂} {φ : Sort u₃} {δ : Sort u₄} {ζ : Sort u₁}
/-- Composition of functions: `(f ∘ g) x = f (g x)`. -/
@[inline, reducible] def comp (f : β → φ) (g : α → β) : α → φ :=
λ x, f (g x)
/-- Composition of dependent functions: `(f ∘' g) x = f (g x)`, where type of `g x` depends on `x`
and type of `f (g x)` depends on `x` and `g x`. -/
@[inline, reducible] def dcomp {β : α → Sort u₂} {φ : Π {x : α}, β x → Sort u₃}
(f : Π {x : α} (y : β x), φ y) (g : Π x, β x) : Π x, φ (g x) :=
λ x, f (g x)
infixr ` ∘ ` := function.comp
infixr ` ∘' `:80 := function.dcomp
@[reducible] def comp_right (f : β → β → β) (g : α → β) : β → α → β :=
λ b a, f b (g a)
@[reducible] def comp_left (f : β → β → β) (g : α → β) : α → β → β :=
λ a b, f (g a) b
/-- Given functions `f : β → β → φ` and `g : α → β`, produce a function `α → α → φ` that evaluates
`g` on each argument, then applies `f` to the results. Can be used, e.g., to transfer a relation
from `β` to `α`. -/
@[reducible] def on_fun (f : β → β → φ) (g : α → β) : α → α → φ :=
λ x y, f (g x) (g y)
@[reducible] def combine (f : α → β → φ) (op : φ → δ → ζ) (g : α → β → δ)
: α → β → ζ :=
λ x y, op (f x y) (g x y)
/-- Constant `λ _, a`. -/
@[reducible] def const (β : Sort u₂) (a : α) : β → α :=
λ x, a
@[reducible] def swap {φ : α → β → Sort u₃} (f : Π x y, φ x y) : Π y x, φ x y :=
λ y x, f x y
@[reducible] def app {β : α → Sort u₂} (f : Π x, β x) (x : α) : β x :=
f x
infixl ` on `:2 := on_fun
notation f ` -[` op `]- ` g := combine f op g
lemma left_id (f : α → β) : id ∘ f = f := rfl
lemma right_id (f : α → β) : f ∘ id = f := rfl
@[simp] lemma comp_app (f : β → φ) (g : α → β) (a : α) : (f ∘ g) a = f (g a) := rfl
lemma comp.assoc (f : φ → δ) (g : β → φ) (h : α → β) : (f ∘ g) ∘ h = f ∘ (g ∘ h) := rfl
@[simp] lemma comp.left_id (f : α → β) : id ∘ f = f := rfl
@[simp] lemma comp.right_id (f : α → β) : f ∘ id = f := rfl
lemma comp_const_right (f : β → φ) (b : β) : f ∘ (const α b) = const α (f b) := rfl
/-- A function `f : α → β` is called injective if `f x = f y` implies `x = y`. -/
@[reducible] def injective (f : α → β) : Prop := ∀ ⦃a₁ a₂⦄, f a₁ = f a₂ → a₁ = a₂
lemma injective.comp {g : β → φ} {f : α → β} (hg : injective g) (hf : injective f) :
injective (g ∘ f) :=
assume a₁ a₂, assume h, hf (hg h)
/-- A function `f : α → β` is called surjective if every `b : β` is equal to `f a`
for some `a : α`. -/
@[reducible] def surjective (f : α → β) : Prop := ∀ b, ∃ a, f a = b
lemma surjective.comp {g : β → φ} {f : α → β} (hg : surjective g) (hf : surjective f) :
surjective (g ∘ f) :=
λ (c : φ), exists.elim (hg c) (λ b hb, exists.elim (hf b) (λ a ha,
exists.intro a (show g (f a) = c, from (eq.trans (congr_arg g ha) hb))))
/-- A function is called bijective if it is both injective and surjective. -/
def bijective (f : α → β) := injective f ∧ surjective f
lemma bijective.comp {g : β → φ} {f : α → β} : bijective g → bijective f → bijective (g ∘ f)
| ⟨h_ginj, h_gsurj⟩ ⟨h_finj, h_fsurj⟩ := ⟨h_ginj.comp h_finj, h_gsurj.comp h_fsurj⟩
/-- `left_inverse g f` means that g is a left inverse to f. That is, `g ∘ f = id`. -/
def left_inverse (g : β → α) (f : α → β) : Prop := ∀ x, g (f x) = x
/-- `has_left_inverse f` means that `f` has an unspecified left inverse. -/
def has_left_inverse (f : α → β) : Prop := ∃ finv : β → α, left_inverse finv f
/-- `right_inverse g f` means that g is a right inverse to f. That is, `f ∘ g = id`. -/
def right_inverse (g : β → α) (f : α → β) : Prop := left_inverse f g
/-- `has_right_inverse f` means that `f` has an unspecified right inverse. -/
def has_right_inverse (f : α → β) : Prop := ∃ finv : β → α, right_inverse finv f
lemma left_inverse.injective {g : β → α} {f : α → β} : left_inverse g f → injective f :=
assume h a b faeqfb,
calc a = g (f a) : (h a).symm
... = g (f b) : congr_arg g faeqfb
... = b : h b
lemma has_left_inverse.injective {f : α → β} : has_left_inverse f → injective f :=
assume h, exists.elim h (λ finv inv, inv.injective)
lemma right_inverse_of_injective_of_left_inverse {f : α → β} {g : β → α}
(injf : injective f) (lfg : left_inverse f g) :
right_inverse f g :=
assume x,
have h : f (g (f x)) = f x, from lfg (f x),
injf h
lemma right_inverse.surjective {f : α → β} {g : β → α} (h : right_inverse g f) : surjective f :=
assume y, ⟨g y, h y⟩
lemma has_right_inverse.surjective {f : α → β} : has_right_inverse f → surjective f
| ⟨finv, inv⟩ := inv.surjective
lemma left_inverse_of_surjective_of_right_inverse {f : α → β} {g : β → α}
(surjf : surjective f) (rfg : right_inverse f g) :
left_inverse f g :=
assume y, exists.elim (surjf y) (λ x hx, calc
f (g y) = f (g (f x)) : hx ▸ rfl
... = f x : eq.symm (rfg x) ▸ rfl
... = y : hx)
lemma injective_id : injective (@id α) := assume a₁ a₂ h, h
lemma surjective_id : surjective (@id α) := assume a, ⟨a, rfl⟩
lemma bijective_id : bijective (@id α) := ⟨injective_id, surjective_id⟩
end function
namespace function
variables {α : Type u₁} {β : Type u₂} {φ : Type u₃}
/-- Interpret a function on `α × β` as a function with two arguments. -/
@[inline] def curry : (α × β → φ) → α → β → φ :=
λ f a b, f (a, b)
/-- Interpret a function with two arguments as a function on `α × β` -/
@[inline] def uncurry : (α → β → φ) → α × β → φ :=
λ f a, f a.1 a.2
@[simp] lemma curry_uncurry (f : α → β → φ) : curry (uncurry f) = f :=
rfl
@[simp] lemma uncurry_curry (f : α × β → φ) : uncurry (curry f) = f :=
funext (λ ⟨a, b⟩, rfl)
protected lemma left_inverse.id {g : β → α} {f : α → β} (h : left_inverse g f) : g ∘ f = id :=
funext h
protected lemma right_inverse.id {g : β → α} {f : α → β} (h : right_inverse g f) : f ∘ g = id :=
funext h
end function
|
b4592f8f78646615a4b5c04e72b53994d3a54de2 | 9dd3f3912f7321eb58ee9aa8f21778ad6221f87c | /library/init/native/result.lean | aa79273e640698ce9977c4eae5578524b7a2199c | [
"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 | 2,590 | lean | /-
Copyright (c) 2016 Jared Roesch. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jared Roesch
-/
prelude
import init.category.applicative
import init.category.functor
import init.category.monad
import init.logic
import init.function
namespace native
inductive result (E : Type) (R : Type) : Type
| err {} : E → result
| ok {} : R → result
def unwrap_or {E T : Type} : result E T → T → T
| (result.err _) default := default
| (result.ok t) _ := t
def result.map : Π {E : Type} {T : Type} {U : Type}, (T → U) → result E T → result E U
| E T U f (result.err e) := result.err e
| E T U f (result.ok t) := result.ok (f t)
def result.and_then {E T U : Type} : result E T → (T → result E U) → result E U
| (result.err e) _ := result.err e
| (result.ok t) f := f t
instance result_functor (E : Type) : functor (result E) := functor.mk (@result.map E)
def result.seq {E T U : Type} : result E (T → U) → result E T → result E U
| f t := result.and_then f (fun f', result.and_then t (fun t', result.ok (f' t')))
instance result_applicative (E : Type) : applicative (result E) :=
applicative.mk (@result.map E) (@result.ok E) (@result.seq E)
instance result_monad (E : Type) : monad (result E) :=
{map := @result.map E, ret := @result.ok E, bind := @result.and_then E}
inductive resultT (M : Type → Type) (E : Type) (A : Type) : Type
| run : M (result E A) → resultT
section resultT
variable {M : Type → Type}
def resultT.map [functor : functor M] {E : Type} {A B : Type} : (A → B) → resultT M E A → resultT M E B
| f (resultT.run action) := resultT.run (@functor.map M functor _ _ (result.map f) action)
def resultT.pure [monad : monad M] {E A : Type} (x : A) : resultT M E A :=
resultT.run $ return (result.ok x)
def resultT.and_then [monad : monad M] {E A B : Type} : resultT M E A → (A → resultT M E B) → resultT M E B
| (resultT.run action) f := resultT.run (do
res_a ← action,
-- a little ugly with this match
(match res_a with
| native.result.err e := return (native.result.err e)
| native.result.ok a := let (resultT.run actionB) := f a in actionB
end : M (result E B)))
instance resultT_functor [f : functor M] (E : Type) : functor (resultT M E) :=
functor.mk (@resultT.map M f E)
-- Should we unify functor and monad like haskell?
instance resultT_monad [f : functor M] [m : monad M] (E : Type) : monad (resultT M E) :=
{map := @resultT.map M f E, ret := @resultT.pure M m E, bind := @resultT.and_then M m E}
end resultT
end native
|
4bb3200575639526dac10b36ed51aec932a9cce7 | bf532e3e865883a676110e756f800e0ddeb465be | /set_theory/zfc.lean | b1e6ee340dac1c9f6ab1bde6634337fdd15b7644 | [
"Apache-2.0"
] | permissive | aqjune/mathlib | da42a97d9e6670d2efaa7d2aa53ed3585dafc289 | f7977ff5a6bcf7e5c54eec908364ceb40dafc795 | refs/heads/master | 1,631,213,225,595 | 1,521,089,840,000 | 1,521,089,840,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 29,692 | lean | import data.set.basic
universes u v
/-- The type of `n`-ary functions `α → α → ... → α`. -/
def arity (α : Type u) : nat → Type u
| 0 := α
| (n+1) := α → arity n
/-- The type of pre-sets in universe `u`. A pre-set
is a family of pre-sets indexed by a type in `Type u`.
The ZFC universe is defined as a quotient of this
to ensure extensionality. -/
inductive pSet : Type (u+1)
| mk (α : Type u) (A : α → pSet) : pSet
namespace pSet
/-- The underlying type of a pre-set -/
def type : pSet → Type u
| ⟨α, A⟩ := α
/-- The underlying pre-set family of a pre-set -/
def func : Π (x : pSet), x.type → pSet
| ⟨α, A⟩ := A
theorem mk_type_func : Π (x : pSet), mk x.type x.func = x
| ⟨α, A⟩ := rfl
/-- Two pre-sets are extensionally equivalent if every
element of the first family is extensionally equivalent to
some element of the second family and vice-versa. -/
def equiv (x y : pSet) : Prop :=
pSet.rec (λα z m ⟨β, B⟩, (∀a, ∃b, m a (B b)) ∧ (∀b, ∃a, m a (B b))) x y
theorem equiv.refl (x) : equiv x x :=
pSet.rec_on x $ λα A IH, ⟨λa, ⟨a, IH a⟩, λa, ⟨a, IH a⟩⟩
theorem equiv.euc {x} : Π {y z}, equiv x y → equiv z y → equiv x z :=
pSet.rec_on x $ λα A IH y, pSet.rec_on y $ λβ B _ ⟨γ, Γ⟩ ⟨αβ, βα⟩ ⟨γβ, βγ⟩,
⟨λa, let ⟨b, ab⟩ := αβ a, ⟨c, bc⟩ := βγ b in ⟨c, IH a ab bc⟩,
λc, let ⟨b, cb⟩ := γβ c, ⟨a, ba⟩ := βα b in ⟨a, IH a ba cb⟩⟩
theorem equiv.symm {x y} : equiv x y → equiv y x :=
equiv.euc (equiv.refl y)
theorem equiv.trans {x y z} (h1 : equiv x y) (h2 : equiv y z) : equiv x z :=
equiv.euc h1 (equiv.symm h2)
instance setoid : setoid pSet :=
⟨pSet.equiv, equiv.refl, λx y, equiv.symm, λx y z, equiv.trans⟩
protected def subset : pSet → pSet → Prop
| ⟨α, A⟩ ⟨β, B⟩ := ∀a, ∃b, equiv (A a) (B b)
instance : has_subset pSet := ⟨pSet.subset⟩
theorem equiv.ext : Π (x y : pSet), equiv x y ↔ (x ⊆ y ∧ y ⊆ x)
| ⟨α, A⟩ ⟨β, B⟩ :=
⟨λ⟨αβ, βα⟩, ⟨αβ, λb, let ⟨a, h⟩ := βα b in ⟨a, equiv.symm h⟩⟩,
λ⟨αβ, βα⟩, ⟨αβ, λb, let ⟨a, h⟩ := βα b in ⟨a, equiv.symm h⟩⟩⟩
theorem subset.congr_left : Π {x y z : pSet}, equiv x y → (x ⊆ z ↔ y ⊆ z)
| ⟨α, A⟩ ⟨β, B⟩ ⟨γ, Γ⟩ ⟨αβ, βα⟩ :=
⟨λαγ b, let ⟨a, ba⟩ := βα b, ⟨c, ac⟩ := αγ a in ⟨c, equiv.trans (equiv.symm ba) ac⟩,
λβγ a, let ⟨b, ab⟩ := αβ a, ⟨c, bc⟩ := βγ b in ⟨c, equiv.trans ab bc⟩⟩
theorem subset.congr_right : Π {x y z : pSet}, equiv x y → (z ⊆ x ↔ z ⊆ y)
| ⟨α, A⟩ ⟨β, B⟩ ⟨γ, Γ⟩ ⟨αβ, βα⟩ :=
⟨λγα c, let ⟨a, ca⟩ := γα c, ⟨b, ab⟩ := αβ a in ⟨b, equiv.trans ca ab⟩,
λγβ c, let ⟨b, cb⟩ := γβ c, ⟨a, ab⟩ := βα b in ⟨a, equiv.trans cb (equiv.symm ab)⟩⟩
/-- `x ∈ y` as pre-sets if `x` is extensionally equivalent to a member
of the family `y`. -/
def mem : pSet → pSet → Prop
| x ⟨β, B⟩ := ∃b, equiv x (B b)
instance : has_mem pSet.{u} pSet.{u} := ⟨mem⟩
theorem mem.mk {α: Type u} (A : α → pSet) (a : α) : A a ∈ mk α A :=
show mem (A a) ⟨α, A⟩, from ⟨a, equiv.refl (A a)⟩
theorem mem.ext : Π {x y : pSet.{u}}, (∀w:pSet.{u}, w ∈ x ↔ w ∈ y) → equiv x y
| ⟨α, A⟩ ⟨β, B⟩ h := ⟨λa, (h (A a)).1 (mem.mk A a),
λb, let ⟨a, ha⟩ := (h (B b)).2 (mem.mk B b) in ⟨a, equiv.symm ha⟩⟩
theorem mem.congr_right : Π {x y : pSet.{u}}, equiv x y → (∀{w:pSet.{u}}, w ∈ x ↔ w ∈ y)
| ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩ w :=
⟨λ⟨a, ha⟩, let ⟨b, hb⟩ := αβ a in ⟨b, equiv.trans ha hb⟩,
λ⟨b, hb⟩, let ⟨a, ha⟩ := βα b in ⟨a, equiv.euc hb ha⟩⟩
theorem mem.congr_left : Π {x y : pSet.{u}}, equiv x y → (∀{w : pSet.{u}}, x ∈ w ↔ y ∈ w)
| x y h ⟨α, A⟩ := ⟨λ⟨a, ha⟩, ⟨a, equiv.trans (equiv.symm h) ha⟩, λ⟨a, ha⟩, ⟨a, equiv.trans h ha⟩⟩
/-- Convert a pre-set to a `set` of pre-sets. -/
def to_set (u : pSet.{u}) : set pSet.{u} := {x | x ∈ u}
/-- Equivalent pre-sets have the same members. The converse
is false because having the same members does not suffice
to get extensional equivalence, which is a hereditary notion. -/
theorem equiv.eq {x y : pSet} (h : equiv x y) : to_set x = to_set y :=
set.ext (λz, mem.congr_right h)
instance : has_coe pSet (set pSet) := ⟨to_set⟩
/-- The empty pre-set -/
protected def empty : pSet := ⟨ulift empty, λe, match e with end⟩
instance : has_emptyc pSet := ⟨pSet.empty⟩
theorem mem_empty (x : pSet.{u}) : x ∉ (∅:pSet.{u}) := λe, match e with end
/-- Insert an element into a pre-set -/
protected def insert : pSet → pSet → pSet
| u ⟨α, A⟩ := ⟨option α, λo, option.rec u A o⟩
instance : has_insert pSet pSet := ⟨pSet.insert⟩
/-- The n-th von Neumann ordinal -/
def of_nat : ℕ → pSet
| 0 := ∅
| (n+1) := pSet.insert (of_nat n) (of_nat n)
/-- The von Neumann ordinal ω -/
def omega : pSet := ⟨ulift ℕ, λn, of_nat n.down⟩
/-- The separation operation `{x ∈ a | p x}` -/
protected def sep (p : set pSet) : pSet → pSet
| ⟨α, A⟩ := ⟨{a // p (A a)}, λx, A x.1⟩
instance : has_sep pSet pSet := ⟨pSet.sep⟩
/-- The powerset operator -/
def powerset : pSet → pSet
| ⟨α, A⟩ := ⟨set α, λp, ⟨{a // p a}, λx, A x.1⟩⟩
theorem mem_powerset : Π {x y : pSet}, y ∈ powerset x ↔ y ⊆ x
| ⟨α, A⟩ ⟨β, B⟩ := ⟨λ⟨p, e⟩, (subset.congr_left e).2 $ λ⟨a, pa⟩, ⟨a, equiv.refl (A a)⟩,
λβα, ⟨{a | ∃b, equiv (B b) (A a)}, λb, let ⟨a, ba⟩ := βα b in ⟨⟨a, b, ba⟩, ba⟩,
λ⟨a, b, ba⟩, ⟨b, ba⟩⟩⟩
/-- The set union operator -/
def Union : pSet → pSet
| ⟨α, A⟩ := ⟨Σx, (A x).type, λ⟨x, y⟩, (A x).func y⟩
theorem mem_Union : Π {x y : pSet.{u}}, y ∈ Union x ↔ ∃ z:pSet.{u}, ∃_:z ∈ x, y ∈ z
| ⟨α, A⟩ y :=
⟨λ⟨⟨a, c⟩, (e : equiv y ((A a).func c))⟩,
have func (A a) c ∈ mk (A a).type (A a).func, from mem.mk (A a).func c,
⟨_, mem.mk _ _, (mem.congr_left e).2 (by rwa mk_type_func at this)⟩,
λ⟨⟨β, B⟩, ⟨a, (e:equiv (mk β B) (A a))⟩, ⟨b, yb⟩⟩,
by rw ←(mk_type_func (A a)) at e; exact
let ⟨βt, tβ⟩ := e, ⟨c, bc⟩ := βt b in ⟨⟨a, c⟩, equiv.trans yb bc⟩⟩
/-- The image of a function -/
def image (f : pSet.{u} → pSet.{u}) : pSet.{u} → pSet
| ⟨α, A⟩ := ⟨α, λa, f (A a)⟩
theorem mem_image {f : pSet.{u} → pSet.{u}} (H : ∀{x y}, equiv x y → equiv (f x) (f y)) :
Π {x y : pSet.{u}}, y ∈ image f x ↔ ∃z ∈ x, equiv y (f z)
| ⟨α, A⟩ y := ⟨λ⟨a, ya⟩, ⟨A a, mem.mk A a, ya⟩, λ⟨z, ⟨a, za⟩, yz⟩, ⟨a, equiv.trans yz (H za)⟩⟩
/-- Universe lift operation -/
protected def lift : pSet.{u} → pSet.{max u v}
| ⟨α, A⟩ := ⟨ulift α, λ⟨x⟩, lift (A x)⟩
/-- Embedding of one universe in another -/
def embed : pSet.{max (u+1) v} := ⟨ulift.{v u+1} pSet, λ⟨x⟩, pSet.lift.{u (max (u+1) v)} x⟩
theorem lift_mem_embed : Π (x : pSet.{u}), pSet.lift.{u (max (u+1) v)} x ∈ embed.{u v} :=
λx, ⟨⟨x⟩, equiv.refl _⟩
/-- Function equivalence is defined so that `f ~ g` iff
`∀ x y, x ~ y → f x ~ g y`. This extends to equivalence of n-ary
functions. -/
def arity.equiv : Π {n}, arity pSet.{u} n → arity pSet.{u} n → Prop
| 0 a b := equiv a b
| (n+1) a b := ∀ x y, equiv x y → arity.equiv (a x) (b y)
/-- `resp n` is the collection of n-ary functions on `pSet` that respect
equivalence, i.e. when the inputs are equivalent the output is as well. -/
def resp (n) := { x : arity pSet.{u} n // arity.equiv x x }
def resp.f {n} (f : resp (n+1)) (x : pSet) : resp n :=
⟨f.1 x, f.2 _ _ $ equiv.refl x⟩
def resp.equiv {n} (a b : resp n) : Prop := arity.equiv a.1 b.1
theorem resp.refl {n} (a : resp n) : resp.equiv a a := a.2
theorem resp.euc : Π {n} {a b c : resp n}, resp.equiv a b → resp.equiv c b → resp.equiv a c
| 0 a b c hab hcb := equiv.euc hab hcb
| (n+1) a b c hab hcb := by delta resp.equiv; simp [arity.equiv]; exact λx y h,
@resp.euc n (a.f x) (b.f y) (c.f y) (hab _ _ h) (hcb _ _ $ equiv.refl y)
instance resp.setoid {n} : setoid (resp n) :=
⟨resp.equiv, resp.refl, λx y h, resp.euc (resp.refl y) h, λx y z h1 h2, resp.euc h1 $ resp.euc (resp.refl z) h2⟩
end pSet
/-- The ZFC universe of sets consists of the type of pre-sets,
quotiented by extensional equivalence. -/
def Set : Type (u+1) := quotient pSet.setoid.{u}
namespace pSet
namespace resp
def eval_aux : Π {n}, { f : resp n → arity Set.{u} n // ∀ (a b : resp n), resp.equiv a b → f a = f b }
| 0 := ⟨λa, ⟦a.1⟧, λa b h, quotient.sound h⟩
| (n+1) := let F : resp (n + 1) → arity Set (n + 1) := λa, @quotient.lift _ _ pSet.setoid
(λx, eval_aux.1 (a.f x)) (λb c h, eval_aux.2 _ _ (a.2 _ _ h)) in
⟨F, λb c h, funext $ @quotient.ind _ _ (λq, F b q = F c q) $ λz,
eval_aux.2 (resp.f b z) (resp.f c z) (h _ _ (equiv.refl z))⟩
/-- An equivalence-respecting function yields an n-ary Set function. -/
def eval (n) : resp n → arity Set.{u} n := eval_aux.1
@[simp] def eval_val {n f x} : (@eval (n+1) f : Set → arity Set n) ⟦x⟧ = eval n (resp.f f x) := rfl
end resp
/-- A set function is "definable" if it is the image of some n-ary pre-set
function. This isn't exactly definability, but is useful as a sufficient
condition for functions that have a computable image. -/
@[class] inductive definable (n) : arity Set.{u} n → Type (u+1)
| mk (f) : definable (resp.eval _ f)
attribute [instance] definable.mk
def definable.eq_mk {n} (f) : Π {s : arity Set.{u} n} (H : resp.eval _ f = s), definable n s
| ._ rfl := ⟨f⟩
def definable.resp {n} : Π (s : arity Set.{u} n) [definable n s], resp n
| ._ ⟨f⟩ := f
theorem definable.eq {n} : Π (s : arity Set.{u} n) [H : definable n s], (@definable.resp n s H).eval _ = s
| ._ ⟨f⟩ := rfl
end pSet
namespace classical
open pSet
noncomputable theorem all_definable : Π {n} (F : arity Set.{u} n), definable n F
| 0 F := let p := @quotient.exists_rep pSet _ F in
definable.eq_mk ⟨some p, equiv.refl _⟩ (some_spec p)
| (n+1) (F : arity Set.{u} (n + 1)) := begin
have I := λx, (all_definable (F x)),
refine definable.eq_mk ⟨λx:pSet, (@definable.resp _ _ (I ⟦x⟧)).1, _⟩ _,
{ dsimp [arity.equiv],
introsI x y h,
rw @quotient.sound pSet _ _ _ h,
exact (definable.resp (F ⟦y⟧)).2 },
exact funext (λq, quotient.induction_on q $ λx,
by simp [resp.f]; exact @definable.eq _ (F ⟦x⟧) (I ⟦x⟧))
end
end classical
namespace Set
open pSet
def mk : pSet → Set := quotient.mk
@[simp] theorem mk_eq (x : pSet) : @eq Set ⟦x⟧ (mk x) := rfl
def mem : Set → Set → Prop :=
quotient.lift₂ pSet.mem
(λx y x' y' hx hy, propext (iff.trans (mem.congr_left hx) (mem.congr_right hy)))
instance : has_mem Set Set := ⟨mem⟩
/-- Convert a ZFC set into a `set` of sets -/
def to_set (u : Set.{u}) : set Set.{u} := {x | x ∈ u}
protected def subset (x y : Set.{u}) :=
∀ ⦃z⦄, z ∈ x → z ∈ y
instance has_subset : has_subset Set :=
⟨Set.subset⟩
theorem subset_iff : Π (x y : pSet), mk x ⊆ mk y ↔ x ⊆ y
| ⟨α, A⟩ ⟨β, B⟩ := ⟨λh a, @h ⟦A a⟧ (mem.mk A a),
λh z, quotient.induction_on z (λz ⟨a, za⟩, let ⟨b, ab⟩ := h a in ⟨b, equiv.trans za ab⟩)⟩
theorem ext {x y : Set.{u}} : (∀z:Set.{u}, z ∈ x ↔ z ∈ y) → x = y :=
quotient.induction_on₂ x y (λu v h, quotient.sound (mem.ext (λw, h ⟦w⟧)))
theorem ext_iff {x y : Set.{u}} : (∀z:Set.{u}, z ∈ x ↔ z ∈ y) ↔ x = y :=
⟨ext, λh, by simp [h]⟩
/-- The empty set -/
def empty : Set := mk ∅
instance : has_emptyc Set := ⟨empty⟩
instance : inhabited Set := ⟨∅⟩
@[simp] theorem mem_empty (x) : x ∉ (∅:Set.{u}) :=
quotient.induction_on x pSet.mem_empty
theorem eq_empty (x : Set.{u}) : x = ∅ ↔ ∀y:Set.{u}, y ∉ x :=
⟨λh, by rw h; exact mem_empty,
λh, ext (λy, ⟨λyx, absurd yx (h y), λy0, absurd y0 (mem_empty _)⟩)⟩
/-- `insert x y` is the set `{x} ∪ y` -/
protected def insert : Set → Set → Set :=
resp.eval 2 ⟨pSet.insert, λu v uv ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,
⟨λo, match o with
| some a := let ⟨b, hb⟩ := αβ a in ⟨some b, hb⟩
| none := ⟨none, uv⟩
end, λo, match o with
| some b := let ⟨a, ha⟩ := βα b in ⟨some a, ha⟩
| none := ⟨none, uv⟩
end⟩⟩
instance : has_insert Set Set := ⟨Set.insert⟩
@[simp] theorem mem_insert {x y z : Set.{u}} : x ∈ insert y z ↔ x = y ∨ x ∈ z :=
quotient.induction_on₃ x y z
(λx y ⟨α, A⟩, show x ∈ pSet.mk (option α) (λo, option.rec y A o) ↔
mk x = mk y ∨ x ∈ pSet.mk α A, from
⟨λm, match m with
| ⟨some a, ha⟩ := or.inr ⟨a, ha⟩
| ⟨none, h⟩ := or.inl (quotient.sound h)
end, λm, match m with
| or.inr ⟨a, ha⟩ := ⟨some a, ha⟩
| or.inl h := ⟨none, quotient.exact h⟩
end⟩)
@[simp] theorem mem_singleton {x y : Set.{u}} : x ∈ @singleton Set.{u} Set.{u} _ _ y ↔ x = y :=
iff.trans mem_insert ⟨λo, or.rec (λh, h) (λn, absurd n (mem_empty _)) o, or.inl⟩
@[simp] theorem mem_singleton' {x y : Set.{u}} : x ∈ @insert Set.{u} Set.{u} _ y ∅ ↔ x = y := mem_singleton
@[simp] theorem mem_pair {x y z : Set.{u}} : x ∈ ({y, z} : Set) ↔ x = y ∨ x = z :=
iff.trans mem_insert $ iff.trans or.comm $ let m := @mem_singleton x y in ⟨or.imp_left m.1, or.imp_left m.2⟩
/-- `omega` is the first infinite von Neumann ordinal -/
def omega : Set := mk omega
@[simp] theorem omega_zero : ∅ ∈ omega :=
show pSet.mem ∅ pSet.omega, from ⟨⟨0⟩, equiv.refl _⟩
@[simp] theorem omega_succ {n} : n ∈ omega.{u} → insert n n ∈ omega.{u} :=
quotient.induction_on n (λx ⟨⟨n⟩, h⟩, ⟨⟨n+1⟩,
have Set.insert ⟦x⟧ ⟦x⟧ = Set.insert ⟦of_nat n⟧ ⟦of_nat n⟧, by rw (@quotient.sound pSet _ _ _ h),
quotient.exact this⟩)
/-- `{x ∈ a | p x}` is the set of elements in `a` satisfying `p` -/
protected def sep (p : Set → Prop) : Set → Set :=
resp.eval 1 ⟨pSet.sep (λy, p ⟦y⟧), λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,
⟨λ⟨a, pa⟩, let ⟨b, hb⟩ := αβ a in ⟨⟨b, by rwa ←(@quotient.sound pSet _ _ _ hb)⟩, hb⟩,
λ⟨b, pb⟩, let ⟨a, ha⟩ := βα b in ⟨⟨a, by rwa (@quotient.sound pSet _ _ _ ha)⟩, ha⟩⟩⟩
instance : has_sep Set Set := ⟨Set.sep⟩
@[simp] theorem mem_sep {p : Set.{u} → Prop} {x y : Set.{u}} : y ∈ {y ∈ x | p y} ↔ y ∈ x ∧ p y :=
quotient.induction_on₂ x y (λ⟨α, A⟩ y,
⟨λ⟨⟨a, pa⟩, h⟩, ⟨⟨a, h⟩, by rw (@quotient.sound pSet _ _ _ h); exact pa⟩,
λ⟨⟨a, h⟩, pa⟩, ⟨⟨a, by rw ←(@quotient.sound pSet _ _ _ h); exact pa⟩, h⟩⟩)
/-- The powerset operation, the collection of subsets of a set -/
def powerset : Set → Set :=
resp.eval 1 ⟨powerset, λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,
⟨λp, ⟨{b | ∃a, p a ∧ equiv (A a) (B b)},
λ⟨a, pa⟩, let ⟨b, ab⟩ := αβ a in ⟨⟨b, a, pa, ab⟩, ab⟩,
λ⟨b, a, pa, ab⟩, ⟨⟨a, pa⟩, ab⟩⟩,
λq, ⟨{a | ∃b, q b ∧ equiv (A a) (B b)},
λ⟨a, b, qb, ab⟩, ⟨⟨b, qb⟩, ab⟩,
λ⟨b, qb⟩, let ⟨a, ab⟩ := βα b in ⟨⟨a, b, qb, ab⟩, ab⟩⟩⟩⟩
@[simp] theorem mem_powerset {x y : Set} : y ∈ powerset x ↔ y ⊆ x :=
quotient.induction_on₂ x y (λ⟨α, A⟩ ⟨β, B⟩,
show (⟨β, B⟩ : pSet) ∈ (pSet.powerset ⟨α, A⟩) ↔ _,
by simp [mem_powerset, subset_iff])
theorem Union_lem {α β : Type u} (A : α → pSet) (B : β → pSet)
(αβ : ∀a, ∃b, equiv (A a) (B b)) : ∀a, ∃b, (equiv ((Union ⟨α, A⟩).func a) ((Union ⟨β, B⟩).func b))
| ⟨a, c⟩ := let ⟨b, hb⟩ := αβ a in
begin
induction ea : A a with γ Γ,
induction eb : B b with δ Δ,
rw [ea, eb] at hb,
cases hb with γδ δγ,
exact
let c : type (A a) := c, ⟨d, hd⟩ := γδ (by rwa ea at c) in
have equiv ((A a).func c) ((B b).func (eq.rec d (eq.symm eb))), from
match A a, B b, ea, eb, c, d, hd with ._, ._, rfl, rfl, x, y, hd := hd end,
⟨⟨b, eq.rec d (eq.symm eb)⟩, this⟩
end
/-- The union operator, the collection of elements of elements of a set -/
def Union : Set → Set :=
resp.eval 1 ⟨pSet.Union, λ⟨α, A⟩ ⟨β, B⟩ ⟨αβ, βα⟩,
⟨Union_lem A B αβ, λa, exists.elim (Union_lem B A (λb,
exists.elim (βα b) (λc hc, ⟨c, equiv.symm hc⟩)) a) (λb hb, ⟨b, equiv.symm hb⟩)⟩⟩
notation `⋃` := Union
@[simp] theorem mem_Union {x y : Set.{u}} : y ∈ Union x ↔ ∃ z ∈ x, y ∈ z :=
quotient.induction_on₂ x y (λx y, iff.trans mem_Union
⟨λ⟨z, h⟩, ⟨⟦z⟧, h⟩, λ⟨z, h⟩, quotient.induction_on z (λz h, ⟨z, h⟩) h⟩)
@[simp] theorem Union_singleton {x : Set.{u}} : Union {x} = x :=
ext $ λy, by simp; exact ⟨λ⟨z, zx, yz⟩, by subst z; exact yz, λyx, ⟨x, by simp, yx⟩⟩
theorem singleton_inj {x y : Set.{u}} (H : ({x} : Set) = {y}) : x = y :=
let this := congr_arg Union H in by rwa [Union_singleton, Union_singleton] at this
/-- The binary union operation -/
protected def union (x y : Set.{u}) : Set.{u} := ⋃ {x, y}
/-- The binary intersection operation -/
protected def inter (x y : Set.{u}) : Set.{u} := {z ∈ x | z ∈ y}
/-- The set difference operation -/
protected def diff (x y : Set.{u}) : Set.{u} := {z ∈ x | z ∉ y}
instance : has_union Set := ⟨Set.union⟩
instance : has_inter Set := ⟨Set.inter⟩
instance : has_sdiff Set := ⟨Set.diff⟩
@[simp] theorem mem_union {x y z : Set.{u}} : z ∈ x ∪ y ↔ z ∈ x ∨ z ∈ y :=
iff.trans mem_Union
⟨λ⟨w, wxy, zw⟩, match mem_pair.1 wxy with
| or.inl wx := or.inl (by rwa ←wx)
| or.inr wy := or.inr (by rwa ←wy)
end, λzxy, match zxy with
| or.inl zx := ⟨x, mem_pair.2 (or.inl rfl), zx⟩
| or.inr zy := ⟨y, mem_pair.2 (or.inr rfl), zy⟩
end⟩
@[simp] theorem mem_inter {x y z : Set.{u}} : z ∈ x ∩ y ↔ z ∈ x ∧ z ∈ y :=
@@mem_sep (λz:Set.{u}, z ∈ y)
@[simp] theorem mem_diff {x y z : Set.{u}} : z ∈ x \ y ↔ z ∈ x ∧ z ∉ y :=
@@mem_sep (λz:Set.{u}, z ∉ y)
theorem induction_on {p : Set → Prop} (x) (h : ∀x, (∀y ∈ x, p y) → p x) : p x :=
quotient.induction_on x $ λu, pSet.rec_on u $ λα A IH, h _ $ λy,
show @has_mem.mem _ _ Set.has_mem y ⟦⟨α, A⟩⟧ → p y, from
quotient.induction_on y (λv ⟨a, ha⟩, by rw (@quotient.sound pSet _ _ _ ha); exact IH a)
theorem regularity (x : Set.{u}) (h : x ≠ ∅) : ∃ y ∈ x, x ∩ y = ∅ :=
classical.by_contradiction $ λne, h $ (eq_empty x).2 $ λy,
induction_on y $ λz (IH : ∀w:Set.{u}, w ∈ z → w ∉ x), show z ∉ x, from λzx,
ne ⟨z, zx, (eq_empty _).2 (λw wxz, let ⟨wx, wz⟩ := mem_inter.1 wxz in IH w wz wx)⟩
/-- The image of a (definable) set function -/
def image (f : Set → Set) [H : definable 1 f] : Set → Set :=
let r := @definable.resp 1 f _ in
resp.eval 1 ⟨image r.1, λx y e, mem.ext $ λz,
iff.trans (mem_image r.2) $ iff.trans (by exact
⟨λ⟨w, h1, h2⟩, ⟨w, (mem.congr_right e).1 h1, h2⟩,
λ⟨w, h1, h2⟩, ⟨w, (mem.congr_right e).2 h1, h2⟩⟩) $
iff.symm (mem_image r.2)⟩
theorem image.mk : Π (f : Set.{u} → Set.{u}) [H : definable 1 f] (x) {y} (h : y ∈ x), f y ∈ @image f H x
| ._ ⟨F⟩ x y := quotient.induction_on₂ x y $ λ⟨α, A⟩ y ⟨a, ya⟩, ⟨a, F.2 _ _ ya⟩
@[simp] theorem mem_image : Π {f : Set.{u} → Set.{u}} [H : definable 1 f] {x y : Set.{u}}, y ∈ @image f H x ↔ ∃z ∈ x, f z = y
| ._ ⟨F⟩ x y := quotient.induction_on₂ x y $ λ⟨α, A⟩ y,
⟨λ⟨a, ya⟩, ⟨⟦A a⟧, mem.mk A a, eq.symm $ quotient.sound ya⟩,
λ⟨z, hz, e⟩, e ▸ image.mk _ _ hz⟩
/-- Kuratowski ordered pair -/
def pair (x y : Set.{u}) : Set.{u} := {{x}, {x, y}}
/-- A subset of pairs `{(a, b) ∈ x × y | p a b}` -/
def pair_sep (p : Set.{u} → Set.{u} → Prop) (x y : Set.{u}) : Set.{u} :=
{z ∈ powerset (powerset (x ∪ y)) | ∃a ∈ x, ∃b ∈ y, z = pair a b ∧ p a b}
@[simp] theorem mem_pair_sep {p} {x y z : Set.{u}} : z ∈ pair_sep p x y ↔ ∃a ∈ x, ∃b ∈ y, z = pair a b ∧ p a b := by
refine iff.trans mem_sep ⟨and.right, λe, ⟨_, e⟩⟩; exact
let ⟨a, ax, b, bY, ze, pab⟩ := e in by rw ze; exact
mem_powerset.2 (λu uz, mem_powerset.2 $ (mem_pair.1 uz).elim
(λua, by rw ua; exact λv vu, by rw mem_singleton.1 vu; exact mem_union.2 (or.inl ax))
(λuab, by rw uab; exact λv vu, (mem_pair.1 vu).elim
(λva, by rw va; exact mem_union.2 (or.inl ax))
(λvb, by rw vb; exact mem_union.2 (or.inr bY))))
theorem pair_inj {x y x' y' : Set.{u}} (H : pair x y = pair x' y') : x = x' ∧ y = y' := begin
have ae := ext_iff.2 H,
simp [pair] at ae,
have : x = x',
{ cases (ae {x}).1 (by simp) with h h,
{ exact singleton_inj h },
{ have m : x' ∈ ({x} : Set),
{ rw h, simp },
simp at m, simp [*] } },
subst x',
have he : y = x → y = y',
{ intro yx, subst y,
cases (ae {x, y'}).2 (by simp) with xy'x xy'xx,
{ have y'x : y' ∈ ({x} : Set) := by rw ← xy'x; simp,
simp at y'x, simp [*] },
{ have yxx := (ext_iff.2 xy'xx y').1 (by simp),
simp at yxx, subst y' } },
have xyxy' := (ae {x, y}).1 (by simp),
cases xyxy' with xyx xyy',
{ have yx := (ext_iff.2 xyx y).1 (by simp),
simp at yx, simp [he yx] },
{ have yxy' := (ext_iff.2 xyy' y).1 (by simp),
simp at yxy',
cases yxy' with yx yy',
{ simp [he yx] },
{ simp [yy'] } }
end
/-- The cartesian product, `{(a, b) | a ∈ x, b ∈ y}` -/
def prod : Set.{u} → Set.{u} → Set.{u} := pair_sep (λa b, true)
@[simp] theorem mem_prod {x y z : Set.{u}} : z ∈ prod x y ↔ ∃a ∈ x, ∃b ∈ y, z = pair a b :=
by simp [prod]
@[simp] theorem pair_mem_prod {x y a b : Set.{u}} : pair a b ∈ prod x y ↔ a ∈ x ∧ b ∈ y :=
⟨λh, let ⟨a', a'x, b', b'y, e⟩ := mem_prod.1 h in
match a', b', pair_inj e, a'x, b'y with ._, ._, ⟨rfl, rfl⟩, ax, bY := ⟨ax, bY⟩ end,
λ⟨ax, bY⟩, by simp; exact ⟨a, ax, b, bY, rfl⟩⟩
/-- `is_func x y f` is the assertion `f : x → y` where `f` is a ZFC function
(a set of ordered pairs) -/
def is_func (x y f : Set.{u}) : Prop :=
f ⊆ prod x y ∧ ∀z:Set.{u}, z ∈ x → ∃! w, pair z w ∈ f
/-- `funs x y` is `y ^ x`, the set of all set functions `x → y` -/
def funs (x y : Set.{u}) : Set.{u} :=
{f ∈ powerset (prod x y) | is_func x y f}
@[simp] theorem mem_funs {x y f : Set.{u}} : f ∈ funs x y ↔ is_func x y f :=
by simp [funs]; exact and_iff_right_of_imp and.left
-- TODO(Mario): Prove this computably
noncomputable instance map_definable_aux (f : Set → Set) [H : definable 1 f] : definable 1 (λy, pair y (f y)) :=
@classical.all_definable 1 _
/-- Graph of a function: `map f x` is the ZFC function which maps `a ∈ x` to `f a` -/
noncomputable def map (f : Set → Set) [H : definable 1 f] : Set → Set :=
image (λy, pair y (f y))
@[simp] theorem mem_map {f : Set → Set} [H : definable 1 f] {x y : Set} : y ∈ map f x ↔ ∃z ∈ x, pair z (f z) = y :=
mem_image
theorem map_unique {f : Set.{u} → Set.{u}} [H : definable 1 f] {x z : Set.{u}} (zx : z ∈ x) : ∃! w, pair z w ∈ map f x :=
⟨f z, image.mk _ _ zx, λy yx, let ⟨w, wx, we⟩ := mem_image.1 yx, ⟨wz, fy⟩ := pair_inj we in by rw[←fy, wz]⟩
@[simp] theorem map_is_func {f : Set → Set} [H : definable 1 f] {x y : Set} : is_func x y (map f x) ↔ ∀z ∈ x, f z ∈ y :=
⟨λ⟨ss, h⟩ z zx, let ⟨t, t1, t2⟩ := h z zx in by rw (t2 (f z) (image.mk _ _ zx)); exact (pair_mem_prod.1 (ss t1)).right,
λh, ⟨λy yx, let ⟨z, zx, ze⟩ := mem_image.1 yx in by rw ←ze; exact pair_mem_prod.2 ⟨zx, h z zx⟩,
λz, map_unique⟩⟩
end Set
def Class := set Set
namespace Class
instance : has_subset Class := ⟨set.subset⟩
instance : has_sep Set Class := ⟨set.sep⟩
instance : has_emptyc Class := ⟨λ a, false⟩
instance : has_insert Set Class := ⟨set.insert⟩
instance : has_union Class := ⟨set.union⟩
instance : has_inter Class := ⟨set.inter⟩
instance : has_neg Class := ⟨set.compl⟩
instance : has_sdiff Class := ⟨set.diff⟩
/-- Coerce a set into a class -/
def of_Set (x : Set.{u}) : Class.{u} := {y | y ∈ x}
instance : has_coe Set Class := ⟨of_Set⟩
/-- The universal class -/
def univ : Class := set.univ
/-- Assert that `A` is a set satisfying `p` -/
def to_Set (p : Set.{u} → Prop) (A : Class.{u}) : Prop := ∃x, ↑x = A ∧ p x
/-- `A ∈ B` if `A` is a set which is a member of `B` -/
protected def mem (A B : Class.{u}) : Prop := to_Set.{u} B A
instance : has_mem Class Class := ⟨Class.mem⟩
theorem mem_univ {A : Class.{u}} : A ∈ univ.{u} ↔ ∃ x : Set.{u}, ↑x = A :=
exists_congr $ λx, and_true _
/-- Convert a conglomerate (a collection of classes) into a class -/
def Cong_to_Class (x : set Class.{u}) : Class.{u} := {y | ↑y ∈ x}
/-- Convert a class into a conglomerate (a collection of classes) -/
def Class_to_Cong (x : Class.{u}) : set Class.{u} := {y | y ∈ x}
/-- The power class of a class is the class of all subclasses that are sets -/
def powerset (x : Class) : Class := Cong_to_Class (set.powerset x)
/-- The union of a class is the class of all members of sets in the class -/
def Union (x : Class) : Class := set.sUnion (Class_to_Cong x)
notation `⋃` := Union
theorem of_Set.inj {x y : Set.{u}} (h : (x : Class.{u}) = y) : x = y :=
Set.ext $ λz, by change (x : Class.{u}) z ↔ (y : Class.{u}) z; simp [*]
@[simp] theorem to_Set_of_Set (p : Set.{u} → Prop) (x : Set.{u}) : to_Set p x ↔ p x :=
⟨λ⟨y, yx, py⟩, by rwa of_Set.inj yx at py, λpx, ⟨x, rfl, px⟩⟩
@[simp] theorem mem_hom_left (x : Set.{u}) (A : Class.{u}) : (x : Class.{u}) ∈ A ↔ A x :=
to_Set_of_Set _ _
@[simp] theorem mem_hom_right (x y : Set.{u}) : (y : Class.{u}) x ↔ x ∈ y := iff.refl _
@[simp] theorem subset_hom (x y : Set.{u}) : (x : Class.{u}) ⊆ y ↔ x ⊆ y := iff.refl _
@[simp] theorem sep_hom (p : Set.{u} → Prop) (x : Set.{u}) : (↑{y ∈ x | p y} : Class.{u}) = {y ∈ x | p y} :=
set.ext $ λy, Set.mem_sep
@[simp] theorem empty_hom : ↑(∅ : Set.{u}) = (∅ : Class.{u}) :=
set.ext $ λy, show _ ↔ false, by simp; exact Set.mem_empty y
@[simp] theorem insert_hom (x y : Set.{u}) : (@insert Set.{u} Class.{u} _ x y) = ↑(insert x y) :=
set.ext $ λz, iff.symm Set.mem_insert
@[simp] theorem union_hom (x y : Set.{u}) : (x : Class.{u}) ∪ y = (x ∪ y : Set.{u}) :=
set.ext $ λz, iff.symm Set.mem_union
@[simp] theorem inter_hom (x y : Set.{u}) : (x : Class.{u}) ∩ y = (x ∩ y : Set.{u}) :=
set.ext $ λz, iff.symm Set.mem_inter
@[simp] theorem diff_hom (x y : Set.{u}) : (x : Class.{u}) \ y = (x \ y : Set.{u}) :=
set.ext $ λz, iff.symm Set.mem_diff
@[simp] theorem powerset_hom (x : Set.{u}) : powerset.{u} x = Set.powerset x :=
set.ext $ λz, iff.symm Set.mem_powerset
@[simp] theorem Union_hom (x : Set.{u}) : Union.{u} x = Set.Union x :=
set.ext $ λz, by refine iff.trans _ (iff.symm Set.mem_Union); exact
⟨λ⟨._, ⟨a, rfl, ax⟩, za⟩, ⟨a, ax, za⟩, λ⟨a, ax, za⟩, ⟨_, ⟨a, rfl, ax⟩, za⟩⟩
/-- The definite description operator, which is {x} if `{a | p a} = {x}`
and ∅ otherwise -/
def iota (p : Set → Prop) : Class := Union {x | ∀y, p y ↔ y = x}
theorem iota_val (p : Set → Prop) (x : Set) (H : ∀y, p y ↔ y = x) : iota p = ↑x :=
set.ext $ λy, ⟨λ⟨._, ⟨x', rfl, h⟩, yx'⟩, by rwa ←((H x').1 $ (h x').2 rfl), λyx, ⟨_, ⟨x, rfl, H⟩, yx⟩⟩
/-- Unlike the other set constructors, the `iota` definite descriptor
is a set for any set input, but not constructively so, so there is no
associated `(Set → Prop) → Set` function. -/
theorem iota_ex (p) : iota.{u} p ∈ univ.{u} :=
mem_univ.2 $ or.elim (classical.em $ ∃x, ∀y, p y ↔ y = x)
(λ⟨x, h⟩, ⟨x, eq.symm $ iota_val p x h⟩)
(λhn, ⟨∅, by simp; exact set.ext (λz, ⟨false.rec _, λ⟨._, ⟨x, rfl, H⟩, zA⟩, hn ⟨x, H⟩⟩)⟩)
/-- Function value -/
def fval (F A : Class.{u}) : Class.{u} := iota (λy, to_Set (λx, F (Set.pair x y)) A)
infixl `′`:100 := fval
theorem fval_ex (F A : Class.{u}) : F ′ A ∈ univ.{u} := iota_ex _
end Class
namespace Set
@[simp] theorem map_fval {f : Set.{u} → Set.{u}} [H : pSet.definable 1 f] {x y : Set.{u}} (h : y ∈ x) :
(Set.map f x ′ y : Class.{u}) = f y :=
Class.iota_val _ _ (λz, by simp; exact
⟨λ⟨w, wz, pr⟩, let ⟨wy, fw⟩ := Set.pair_inj pr in by rw[←fw, wy],
λe, by cases e; exact ⟨_, h, rfl⟩⟩)
variables (x : Set.{u}) (h : ∅ ∉ x)
/-- A choice function on the set of nonempty sets `x` -/
noncomputable def choice : Set := @map (λy, classical.epsilon (λz, z ∈ y)) (classical.all_definable _) x
include h
theorem choice_mem_aux (y : Set.{u}) (yx : y ∈ x) : classical.epsilon (λz:Set.{u}, z ∈ y) ∈ y :=
@classical.epsilon_spec _ (λz:Set.{u}, z ∈ y) $ classical.by_contradiction $ λn, h $
by rwa ←((eq_empty y).2 $ λz zx, n ⟨z, zx⟩)
theorem choice_is_func : is_func x (Union x) (choice x) :=
(@map_is_func _ (classical.all_definable _) _ _).2 $ λy yx, by simp; exact ⟨y, yx, choice_mem_aux x h y yx⟩
theorem choice_mem (y : Set.{u}) (yx : y ∈ x) : (choice x ′ y : Class.{u}) ∈ (y : Class.{u}) :=
by delta choice; rw map_fval yx; simp [choice_mem_aux x h y yx]
end Set
|
943337cc40f403e55cd759689396678787891167 | ebf7140a9ea507409ff4c994124fa36e79b4ae35 | /src/exercises_sources/tuesday/logic.lean | 7852de524410e8fb86293fcc0693721dd2db5bca | [] | no_license | fundou/lftcm2020 | 3e88d58a92755ea5dd49f19c36239c35286ecf5e | 99d11bf3bcd71ffeaef0250caa08ecc46e69b55b | refs/heads/master | 1,685,610,799,304 | 1,624,070,416,000 | 1,624,070,416,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 5,602 | lean | /-
Lean for the Curious Mathematician
Tuesday, July 14, 2020
13:00 session
Happy Bastille Day!
-/
import data.real.basic
/-! ## Logic -/
/-!
### Agenda
- a quick overview of Lean's tactics for dealing with logical connectives
- continue with Patrick Massot's tutorial
After the overview, I will ask you to tell us how far you have gotten in the
tutorial (by file number), so we can group you in rooms accordingly. (Tutors,
please self identify as well!)
An apology:
In this presentation, I won't tell you anything you don't already know.
For example, I will say:
"To prove 'A and B', is suffices to prove A and then to prove B."
"If you know 'A and B', you can use A and you can use B."
The point is, to communicate these intentions to Lean, we have to give names
to these actions.
Analogies:
- Learning grammar.
- Learning Latex.
Other resources:
- Everything I go over here is in the tutorial.
- It is also in *Mathematics in Lean*.
- *Theorem Proving in Lean* has a more foundational, logician's perspective.
- See also the cheat sheet:
https://leanprover-community.github.io//img/lean-tactics.pdf
You can find links to all of these (including the cheat sheet) on the mathlib
web pages, under "Learning resources."
This file is in the LFTCM repository.
Most of the examples here are from *Mathematics in Lean*.
-/
/-!
### Overview
The list:
→ \to, \r if ... then implication
∀ \all for all universal quantifier
∃ \ex there exists existential quantifier
¬ \not, \n not negation
∧ \and and conjunction
↔ \iff, \lr if and only if bi-implication
∨ \or or disjunction
false contradiction falsity
true this is trivial! truth
Remember that a goal in Lean is of the form
1 goal
x y : ℕ,
h₁ : prime x,
h₂ : ¬even x,
h₃ : y > x
⊢ y ≥ 4
The stuff before the `⊢` is called the *context*, or *local context*. The facts
there are called *hypotheses* or *local hypotheses*.
The stuff after the `⊢` is also called the *goal*, or the *target*.
A common theme:
- Some tactics tell us how to *prove* a goal involving the connective.
(Logician's terminology: "introduce" the connective.)
- Some tactics tell us how to *use* a hypothesis involving the connective.
(Logician's terminology: "eliminate" the connective.)
Summary:
→ if ... then `intro`, `intros` `apply`, `have h₃ := h₁ h₂`
∀ for all `intro`, `intros` `apply`, `specialize`,
`have h₂ := h₁ t`
∃ there exists `use` `cases`
¬ not `intro`, `intros` `apply`, `contradiction`
∧ and `split` `cases`, `h.1` / `h.2`,
`h.left` / `h.right`
↔ if and only if `split` `cases`, `h.1` / `h.2`,
`h.mp` / `h.mpr`, `rw`
∨ or `left` / `right` `cases`
false contradiction `contradiction`, `ex_falso`
true this is trivial! `trivial`
Also, for proof by contradiction:
Use `open_locale classical` (but not right after the `import`s.)
Use the `by_contradiction` tactic.
There are lots of other tactics and methods. But these are all you need to deal
with the logical connectives.
Another theme: sometimes the logical structure is hidden under a definition.
For example:
`x ∣ y` is existential
`s ⊆ t` is universal
Lean will unfold definitions as needed.
-/
/-!
### Implication and the universal quantifier
-/
section
variables a b c d : ℝ
variable h₁ : a ≤ b
variables h₂ : c ≤ d
#check @add_le_add
#check @add_le_add _ a b
#check @add_le_add _ a b c d _ _ _ _ h₁
#check add_le_add h₁
include h₁ h₂
-- demonstrate variations on `apply` and `have`
example : a + c ≤ b + d :=
sorry
end
section
def fn_ub (f : ℝ → ℝ) (a : ℝ) : Prop := ∀ x, f x ≤ a
variables {f g : ℝ → ℝ} {a b : ℝ}
-- demonstrate variations on `apply`, `have`, and `specialize`
-- `dsimp` helps clarify the goal
theorem fn_ub_add (hfa : fn_ub f a) (hgb : fn_ub g b) :
fn_ub (λ x, f x + g x) (a + b) :=
sorry
end
/-!
### The existential quantifier
-/
-- demonstrate `use` and `norm_num`
example : ∃ x : ℝ, 2 < x ∧ x < 3 :=
sorry
-- demonstrate `cases` and `use`, and use `fn_ub_add`
section
def fn_has_ub (f : ℝ → ℝ) := ∃ a, fn_ub f a
variables {f g : ℝ → ℝ}
example (ubf : fn_has_ub f) (ubg : fn_has_ub g) :
fn_has_ub (λ x, f x + g x) :=
sorry
end
/-!
### Negation
-/
section
variable {f : ℝ → ℝ}
example (h : ∀ a, ∃ x, f x > a) : ¬ fn_has_ub f :=
sorry
end
/-!
### Conjunction
-/
section
variables {x y : ℝ}
-- demonstrate `split`
example (h₀ : x ≤ y) (h₁ : ¬ y ≤ x) : x ≤ y ∧ x ≠ y :=
sorry
-- demonstrate `cases`, `h.1`, `h.2`
example (h : x ≤ y ∧ x ≠ y) : ¬ y ≤ x :=
sorry
end
/-!
### Disjunction
-/
section
variables x y : ℝ
#check le_or_gt 0 y
#check @abs_of_nonneg
#check @abs_of_neg
example : x < abs y → x < y ∨ x < -y :=
sorry
end
/-!
### Final note
I haven't done everything! In particular, I skipped bi-implication, `true`, `false`,
proof by contradiction, and more.
But this should get you started, and you can consult the resources for more.
-/
|
ff841993881cfd451201c386f9e68edcaa2b89a3 | b7f22e51856f4989b970961f794f1c435f9b8f78 | /tests/lean/run/coercion_bug2.lean | ea842448c3dfe7e9c9910a7b73be07ed0be9614a | [
"Apache-2.0"
] | permissive | soonhokong/lean | cb8aa01055ffe2af0fb99a16b4cda8463b882cd1 | 38607e3eb57f57f77c0ac114ad169e9e4262e24f | refs/heads/master | 1,611,187,284,081 | 1,450,766,737,000 | 1,476,122,547,000 | 11,513,992 | 2 | 0 | null | 1,401,763,102,000 | 1,374,182,235,000 | C++ | UTF-8 | Lean | false | false | 264 | lean | import data.nat
open nat
inductive list (T : Type) : Type :=
| nil {} : list T
| cons : T → list T → list T
definition length {T : Type} : list T → nat := list.rec 0 (fun x l m, succ m)
theorem length_nil {T : Type} : length (@list.nil T) = 0
:= eq.refl _
|
04873c0948bda86836e22ce1a988818200bbd563 | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/data/nat/factorization/prime_pow.lean | 5428dc4b658c91e79834a934be9451554edbb615 | [
"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 | 6,426 | lean | /-
Copyright (c) 2022 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import algebra.is_prime_pow
import data.nat.factorization.basic
/-!
# Prime powers and factorizations
This file deals with factorizations of prime powers.
-/
variables {R : Type*} [comm_monoid_with_zero R] (n p : R) (k : ℕ)
lemma is_prime_pow.min_fac_pow_factorization_eq {n : ℕ} (hn : is_prime_pow n) :
n.min_fac ^ n.factorization n.min_fac = n :=
begin
obtain ⟨p, k, hp, hk, rfl⟩ := hn,
rw ←nat.prime_iff at hp,
rw [hp.pow_min_fac hk.ne', hp.factorization_pow, finsupp.single_eq_same],
end
lemma is_prime_pow_of_min_fac_pow_factorization_eq {n : ℕ}
(h : n.min_fac ^ n.factorization n.min_fac = n) (hn : n ≠ 1) :
is_prime_pow n :=
begin
rcases eq_or_ne n 0 with rfl | hn',
{ simpa using h },
refine ⟨_, _, nat.prime_iff.1 (nat.min_fac_prime hn), _, h⟩,
rw [pos_iff_ne_zero, ←finsupp.mem_support_iff, nat.factor_iff_mem_factorization,
nat.mem_factors_iff_dvd hn' (nat.min_fac_prime hn)],
apply nat.min_fac_dvd
end
lemma is_prime_pow_iff_min_fac_pow_factorization_eq {n : ℕ} (hn : n ≠ 1) :
is_prime_pow n ↔ n.min_fac ^ n.factorization n.min_fac = n :=
⟨λ h, h.min_fac_pow_factorization_eq, λ h, is_prime_pow_of_min_fac_pow_factorization_eq h hn⟩
lemma is_prime_pow_iff_factorization_eq_single {n : ℕ} :
is_prime_pow n ↔ ∃ p k : ℕ, 0 < k ∧ n.factorization = finsupp.single p k :=
begin
rw is_prime_pow_nat_iff,
refine exists₂_congr (λ p k, _),
split,
{ rintros ⟨hp, hk, hn⟩,
exact ⟨hk, by rw [←hn, nat.prime.factorization_pow hp]⟩ },
{ rintros ⟨hk, hn⟩,
have hn0 : n ≠ 0,
{ rintro rfl,
simpa only [finsupp.single_eq_zero, eq_comm, nat.factorization_zero, hk.ne'] using hn },
rw nat.eq_pow_of_factorization_eq_single hn0 hn,
exact ⟨nat.prime_of_mem_factorization
(by simp [hn, hk.ne'] : p ∈ n.factorization.support), hk, rfl⟩ }
end
lemma is_prime_pow_iff_card_support_factorization_eq_one {n : ℕ} :
is_prime_pow n ↔ n.factorization.support.card = 1 :=
by simp_rw [is_prime_pow_iff_factorization_eq_single, finsupp.card_support_eq_one', exists_prop,
pos_iff_ne_zero]
lemma is_prime_pow.exists_ord_compl_eq_one {n : ℕ} (h : is_prime_pow n) :
∃ p : ℕ, p.prime ∧ ord_compl[p] n = 1 :=
begin
rcases eq_or_ne n 0 with rfl | hn0, { cases not_is_prime_pow_zero h },
rcases is_prime_pow_iff_factorization_eq_single.mp h with ⟨p, k, hk0, h1⟩,
rcases em' p.prime with pp | pp,
{ refine absurd _ hk0.ne', simp [←nat.factorization_eq_zero_of_non_prime n pp, h1] },
refine ⟨p, pp, _⟩,
refine nat.eq_of_factorization_eq (nat.ord_compl_pos p hn0).ne' (by simp) (λ q, _),
rw [nat.factorization_ord_compl n p, h1],
simp,
end
lemma exists_ord_compl_eq_one_iff_is_prime_pow {n : ℕ} (hn : n ≠ 1) :
is_prime_pow n ↔ ∃ p : ℕ, p.prime ∧ ord_compl[p] n = 1 :=
begin
refine ⟨λ h, is_prime_pow.exists_ord_compl_eq_one h, λ h, _⟩,
rcases h with ⟨p, pp, h⟩,
rw is_prime_pow_nat_iff,
rw [←nat.eq_of_dvd_of_div_eq_one (nat.ord_proj_dvd n p) h] at ⊢ hn,
refine ⟨p, n.factorization p, pp, _, by simp⟩,
contrapose! hn,
simp [le_zero_iff.1 hn],
end
/-- An equivalent definition for prime powers: `n` is a prime power iff there is a unique prime
dividing it. -/
lemma is_prime_pow_iff_unique_prime_dvd {n : ℕ} :
is_prime_pow n ↔ ∃! p : ℕ, p.prime ∧ p ∣ n :=
begin
rw is_prime_pow_nat_iff,
split,
{ rintro ⟨p, k, hp, hk, rfl⟩,
refine ⟨p, ⟨hp, dvd_pow_self _ hk.ne'⟩, _⟩,
rintro q ⟨hq, hq'⟩,
exact (nat.prime_dvd_prime_iff_eq hq hp).1 (hq.dvd_of_dvd_pow hq') },
rintro ⟨p, ⟨hp, hn⟩, hq⟩,
rcases eq_or_ne n 0 with rfl | hn₀,
{ cases (hq 2 ⟨nat.prime_two, dvd_zero 2⟩).trans (hq 3 ⟨nat.prime_three, dvd_zero 3⟩).symm },
refine ⟨p, n.factorization p, hp, hp.factorization_pos_of_dvd hn₀ hn, _⟩,
simp only [and_imp] at hq,
apply nat.dvd_antisymm (nat.ord_proj_dvd _ _),
-- We need to show n ∣ p ^ n.factorization p
apply nat.dvd_of_factors_subperm hn₀,
rw [hp.factors_pow, list.subperm_ext_iff],
intros q hq',
rw nat.mem_factors hn₀ at hq',
cases hq _ hq'.1 hq'.2,
simp,
end
lemma is_prime_pow_pow_iff {n k : ℕ} (hk : k ≠ 0) :
is_prime_pow (n ^ k) ↔ is_prime_pow n :=
begin
simp only [is_prime_pow_iff_unique_prime_dvd],
apply exists_unique_congr,
simp only [and.congr_right_iff],
intros p hp,
exact ⟨hp.dvd_of_dvd_pow, λ t, t.trans (dvd_pow_self _ hk)⟩,
end
lemma nat.coprime.is_prime_pow_dvd_mul {n a b : ℕ} (hab : nat.coprime a b) (hn : is_prime_pow n) :
n ∣ a * b ↔ n ∣ a ∨ n ∣ b :=
begin
rcases eq_or_ne a 0 with rfl | ha,
{ simp only [nat.coprime_zero_left] at hab,
simp [hab, finset.filter_singleton, not_is_prime_pow_one] },
rcases eq_or_ne b 0 with rfl | hb,
{ simp only [nat.coprime_zero_right] at hab,
simp [hab, finset.filter_singleton, not_is_prime_pow_one] },
refine ⟨_, λ h, or.elim h (λ i, i.trans (dvd_mul_right _ _)) (λ i, i.trans (dvd_mul_left _ _))⟩,
obtain ⟨p, k, hp, hk, rfl⟩ := (is_prime_pow_nat_iff _).1 hn,
simp only [hp.pow_dvd_iff_le_factorization (mul_ne_zero ha hb),
nat.factorization_mul ha hb, hp.pow_dvd_iff_le_factorization ha,
hp.pow_dvd_iff_le_factorization hb, pi.add_apply, finsupp.coe_add],
have : a.factorization p = 0 ∨ b.factorization p = 0,
{ rw [←finsupp.not_mem_support_iff, ←finsupp.not_mem_support_iff, ←not_and_distrib,
←finset.mem_inter],
exact λ t, nat.factorization_disjoint_of_coprime hab t },
cases this;
simp [this, imp_or_distrib],
end
lemma nat.mul_divisors_filter_prime_pow {a b : ℕ} (hab : a.coprime b) :
(a * b).divisors.filter is_prime_pow = (a.divisors ∪ b.divisors).filter is_prime_pow :=
begin
rcases eq_or_ne a 0 with rfl | ha,
{ simp only [nat.coprime_zero_left] at hab,
simp [hab, finset.filter_singleton, not_is_prime_pow_one] },
rcases eq_or_ne b 0 with rfl | hb,
{ simp only [nat.coprime_zero_right] at hab,
simp [hab, finset.filter_singleton, not_is_prime_pow_one] },
ext n,
simp only [ha, hb, finset.mem_union, finset.mem_filter, nat.mul_eq_zero, and_true, ne.def,
and.congr_left_iff, not_false_iff, nat.mem_divisors, or_self],
apply hab.is_prime_pow_dvd_mul,
end
|
ef29a1f839c2dedeefd0ccfa535c46ea8f42e498 | c777c32c8e484e195053731103c5e52af26a25d1 | /src/algebraic_topology/dold_kan/degeneracies.lean | c3b3de9892ba2ba3e58948967557a6973073a38b | [
"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 | 6,127 | lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import algebraic_topology.dold_kan.decomposition
import tactic.fin_cases
/-!
# Behaviour of P_infty with respect to degeneracies
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
For any `X : simplicial_object C` where `C` is an abelian category,
the projector `P_infty : K[X] ⟶ K[X]` is supposed to be the projection
on the normalized subcomplex, parallel to the degenerate subcomplex, i.e.
the subcomplex generated by the images of all `X.σ i`.
In this file, we obtain `degeneracy_comp_P_infty` which states that
if `X : simplicial_object C` with `C` a preadditive category,
`θ : [n] ⟶ Δ'` is a non injective map in `simplex_category`, then
`X.map θ.op ≫ P_infty.f n = 0`. It follows from the more precise
statement vanishing statement `σ_comp_P_eq_zero` for the `P q`.
-/
open category_theory category_theory.category category_theory.limits
category_theory.preadditive opposite
open_locale simplicial dold_kan
namespace algebraic_topology
namespace dold_kan
variables {C : Type*} [category C] [preadditive C]
lemma higher_faces_vanish.comp_σ {Y : C} {X : simplicial_object C} {n b q : ℕ} {φ : Y ⟶ X _[n+1]}
(v : higher_faces_vanish q φ) (hnbq : n + 1 = b + q) :
higher_faces_vanish q (φ ≫ X.σ ⟨b,
by simpa only [hnbq, nat.lt_succ_iff, le_add_iff_nonneg_right] using zero_le q⟩) :=
λ j hj, begin
rw [assoc, simplicial_object.δ_comp_σ_of_gt', fin.pred_succ,
v.comp_δ_eq_zero_assoc _ _ hj, zero_comp],
{ intro hj',
simpa only [hj', hnbq, fin.coe_zero, zero_add, add_comm b, add_assoc, false_and,
add_le_iff_nonpos_right, le_zero_iff, add_eq_zero_iff, nat.one_ne_zero] using hj, },
{ simp only [fin.lt_iff_coe_lt_coe, nat.lt_iff_add_one_le,
fin.succ_mk, fin.coe_mk, fin.coe_succ, add_le_add_iff_right],
linarith, },
end
lemma σ_comp_P_eq_zero (X : simplicial_object C)
{n q : ℕ} (i : fin (n + 1)) (hi : n + 1 ≤ i + q) : (X.σ i) ≫ (P q).f (n + 1) = 0 :=
begin
induction q with q hq generalizing i hi,
{ exfalso,
have h := fin.is_lt i,
linarith, },
{ by_cases n+1 ≤ (i : ℕ) + q,
{ unfold P,
simp only [homological_complex.comp_f, ← assoc],
rw [hq i h, zero_comp], },
{ have hi' : n = (i : ℕ) + q,
{ cases le_iff_exists_add.mp hi with j hj,
rw [← nat.lt_succ_iff, nat.succ_eq_add_one, add_assoc, hj, not_lt,
add_le_iff_nonpos_right, nonpos_iff_eq_zero] at h,
rw [← add_left_inj 1, add_assoc, hj, self_eq_add_right, h], },
cases n,
{ fin_cases i,
rw [show q = 0, by linarith],
unfold P,
simp only [id_comp, homological_complex.add_f_apply, comp_add, homological_complex.id_f,
Hσ, homotopy.null_homotopic_map'_f (c_mk 2 1 rfl) (c_mk 1 0 rfl),
alternating_face_map_complex.obj_d_eq],
erw [hσ'_eq' (zero_add 0).symm, hσ'_eq' (add_zero 1).symm, comp_id,
fin.sum_univ_two, fin.sum_univ_succ, fin.sum_univ_two],
simp only [pow_zero, pow_one, pow_two, fin.coe_zero, fin.coe_one, fin.coe_two,
one_zsmul, neg_zsmul, fin.mk_zero, fin.mk_one, fin.coe_succ, pow_add, one_mul,
neg_mul, neg_neg, fin.succ_zero_eq_one, fin.succ_one_eq_two, comp_neg, neg_comp,
add_comp, comp_add],
erw [simplicial_object.δ_comp_σ_self, simplicial_object.δ_comp_σ_self_assoc,
simplicial_object.δ_comp_σ_succ, comp_id, simplicial_object.δ_comp_σ_of_le X
(show (0 : fin(2)) ≤ fin.cast_succ 0, by rw fin.cast_succ_zero),
simplicial_object.δ_comp_σ_self_assoc, simplicial_object.δ_comp_σ_succ_assoc],
abel, },
{ rw [← id_comp (X.σ i), ← (P_add_Q_f q n.succ : _ = 𝟙 (X.obj _)), add_comp, add_comp],
have v : higher_faces_vanish q ((P q).f n.succ ≫ X.σ i) :=
(higher_faces_vanish.of_P q n).comp_σ hi',
unfold P,
erw [← assoc, v.comp_P_eq_self, homological_complex.add_f_apply,
preadditive.comp_add, comp_id, v.comp_Hσ_eq hi', assoc,
simplicial_object.δ_comp_σ_succ'_assoc, fin.eta,
decomposition_Q n q, sum_comp, sum_comp, finset.sum_eq_zero, add_zero,
add_neg_eq_zero], swap,
{ ext, simp only [fin.coe_mk, fin.coe_succ], },
{ intros j hj,
simp only [true_and, finset.mem_univ, finset.mem_filter] at hj,
simp only [nat.succ_eq_add_one] at hi',
obtain ⟨k, hk⟩ := nat.le.dest (nat.lt_succ_iff.mp (fin.is_lt j)),
rw add_comm at hk,
have hi'' : i = fin.cast_succ ⟨i, by linarith⟩ :=
by { ext, simp only [fin.cast_succ_mk, fin.eta], },
have eq := hq j.rev.succ begin
simp only [← hk, fin.rev_eq j hk.symm, nat.succ_eq_add_one, fin.succ_mk, fin.coe_mk],
linarith,
end,
rw [homological_complex.comp_f, assoc, assoc, assoc, hi'',
simplicial_object.σ_comp_σ_assoc, reassoc_of eq, zero_comp, comp_zero,
comp_zero, comp_zero],
simp only [fin.rev_eq j hk.symm, fin.le_iff_coe_le_coe, fin.coe_mk],
linarith, }, }, }, }
end
@[simp, reassoc]
lemma σ_comp_P_infty (X : simplicial_object C) {n : ℕ} (i : fin (n+1)) :
(X.σ i) ≫ P_infty.f (n+1) = 0 :=
begin
rw [P_infty_f, σ_comp_P_eq_zero X i],
simp only [le_add_iff_nonneg_left, zero_le],
end
@[reassoc]
lemma degeneracy_comp_P_infty (X : simplicial_object C)
(n : ℕ) {Δ' : simplex_category} (θ : [n] ⟶ Δ') (hθ : ¬mono θ) :
X.map θ.op ≫ P_infty.f n = 0 :=
begin
rw simplex_category.mono_iff_injective at hθ,
cases n,
{ exfalso,
apply hθ,
intros x y h,
fin_cases x,
fin_cases y, },
{ obtain ⟨i, α, h⟩ := simplex_category.eq_σ_comp_of_not_injective θ hθ,
rw [h, op_comp, X.map_comp, assoc, (show X.map (simplex_category.σ i).op = X.σ i, by refl),
σ_comp_P_infty, comp_zero], },
end
end dold_kan
end algebraic_topology
|
34fbed4a9b579de97fe84837a92478957ee5af96 | d1a52c3f208fa42c41df8278c3d280f075eb020c | /tests/lean/run/sarray.lean | 75061c6544702dde188bf2c59c681d7003ab7258 | [
"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 | 920 | lean | def mkByteArray (n : Nat) : ByteArray := Id.run <| do
let mut r := {}
for i in [:n] do
r := r.push (UInt8.ofNat i)
return r
def tst1 (n : Nat) (expected : UInt32) : IO Unit := do
let bs := mkByteArray n
let sum := bs.foldl (init := 0) fun s b => s + b.toUInt32
assert! sum == expected
IO.println sum
#eval tst1 100 4950
def tst2 (n : Nat) (expected : UInt32) : IO Unit := do
let bs := mkByteArray n
let mut sum := 0
for b in bs do
sum := sum + b.toUInt32
assert! sum == expected
IO.println sum
#eval tst2 100 4950
def tst3 (n : Nat) (expected : UInt32) : IO Unit := do
let bs := mkByteArray n
let mut sum := 0
for i in [:bs.size] do
sum := sum + bs[i].toUInt32
assert! sum == expected
IO.println sum
#eval tst3 100 4950
set_option trace.compiler.ir.result true in
def computeByteHash (bytes : ByteArray) :=
bytes.foldl (init := 1723) fun h b => mixHash h (hash b)
|
ac60bacdf4c51956b41f853d257bbcf5a4299e9a | a339bc2ac96174381fb610f4b2e1ba42df2be819 | /hott/hit/pushout.hlean | aedc791bd57cae3380c8340d95005213bb298571 | [
"Apache-2.0"
] | permissive | kalfsvag/lean2 | 25b2dccc07a98e5aa20f9a11229831f9d3edf2e7 | 4d4a0c7c53a9922c5f630f6f8ebdccf7ddef2cc7 | refs/heads/master | 1,610,513,122,164 | 1,483,135,198,000 | 1,483,135,198,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 14,038 | hlean | /-
Copyright (c) 2015-16 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Ulrik Buchholtz, Jakob von Raumer
Declaration and properties of the pushout
-/
import .quotient types.sigma types.arrow_2
open quotient eq sum equiv is_trunc pointed
namespace pushout
section
parameters {TL BL TR : Type} (f : TL → BL) (g : TL → TR)
local abbreviation A := BL + TR
inductive pushout_rel : A → A → Type :=
| Rmk : Π(x : TL), pushout_rel (inl (f x)) (inr (g x))
open pushout_rel
local abbreviation R := pushout_rel
definition pushout : Type := quotient R -- TODO: define this in root namespace
parameters {f g}
definition inl (x : BL) : pushout :=
class_of R (inl x)
definition inr (x : TR) : pushout :=
class_of R (inr x)
definition glue (x : TL) : inl (f x) = inr (g x) :=
eq_of_rel pushout_rel (Rmk f g x)
protected definition rec {P : pushout → Type} (Pinl : Π(x : BL), P (inl x))
(Pinr : Π(x : TR), P (inr x)) (Pglue : Π(x : TL), Pinl (f x) =[glue x] Pinr (g x))
(y : pushout) : P y :=
begin
induction y,
{ cases a,
apply Pinl,
apply Pinr},
{ cases H, apply Pglue}
end
protected definition rec_on [reducible] {P : pushout → Type} (y : pushout)
(Pinl : Π(x : BL), P (inl x)) (Pinr : Π(x : TR), P (inr x))
(Pglue : Π(x : TL), Pinl (f x) =[glue x] Pinr (g x)) : P y :=
rec Pinl Pinr Pglue y
theorem rec_glue {P : pushout → Type} (Pinl : Π(x : BL), P (inl x))
(Pinr : Π(x : TR), P (inr x)) (Pglue : Π(x : TL), Pinl (f x) =[glue x] Pinr (g x))
(x : TL) : apd (rec Pinl Pinr Pglue) (glue x) = Pglue x :=
!rec_eq_of_rel
protected definition elim {P : Type} (Pinl : BL → P) (Pinr : TR → P)
(Pglue : Π(x : TL), Pinl (f x) = Pinr (g x)) (y : pushout) : P :=
rec Pinl Pinr (λx, pathover_of_eq _ (Pglue x)) y
protected definition elim_on [reducible] {P : Type} (y : pushout) (Pinl : BL → P)
(Pinr : TR → P) (Pglue : Π(x : TL), Pinl (f x) = Pinr (g x)) : P :=
elim Pinl Pinr Pglue y
theorem elim_glue {P : Type} (Pinl : BL → P) (Pinr : TR → P)
(Pglue : Π(x : TL), Pinl (f x) = Pinr (g x)) (x : TL)
: ap (elim Pinl Pinr Pglue) (glue x) = Pglue x :=
begin
apply eq_of_fn_eq_fn_inv !(pathover_constant (glue x)),
rewrite [▸*,-apd_eq_pathover_of_eq_ap,↑pushout.elim,rec_glue],
end
protected definition elim_type (Pinl : BL → Type) (Pinr : TR → Type)
(Pglue : Π(x : TL), Pinl (f x) ≃ Pinr (g x)) : pushout → Type :=
quotient.elim_type (sum.rec Pinl Pinr)
begin intro v v' r, induction r, apply Pglue end
protected definition elim_type_on [reducible] (y : pushout) (Pinl : BL → Type)
(Pinr : TR → Type) (Pglue : Π(x : TL), Pinl (f x) ≃ Pinr (g x)) : Type :=
elim_type Pinl Pinr Pglue y
theorem elim_type_glue (Pinl : BL → Type) (Pinr : TR → Type)
(Pglue : Π(x : TL), Pinl (f x) ≃ Pinr (g x)) (x : TL)
: transport (elim_type Pinl Pinr Pglue) (glue x) = Pglue x :=
!elim_type_eq_of_rel_fn
theorem elim_type_glue_inv (Pinl : BL → Type) (Pinr : TR → Type)
(Pglue : Π(x : TL), Pinl (f x) ≃ Pinr (g x)) (x : TL)
: transport (elim_type Pinl Pinr Pglue) (glue x)⁻¹ = to_inv (Pglue x) :=
!elim_type_eq_of_rel_inv
protected definition rec_prop {P : pushout → Type} [H : Πx, is_prop (P x)]
(Pinl : Π(x : BL), P (inl x)) (Pinr : Π(x : TR), P (inr x)) (y : pushout) :=
rec Pinl Pinr (λx, !is_prop.elimo) y
protected definition elim_prop {P : Type} [H : is_prop P] (Pinl : BL → P) (Pinr : TR → P)
(y : pushout) : P :=
elim Pinl Pinr (λa, !is_prop.elim) y
end
end pushout
attribute pushout.inl pushout.inr [constructor]
attribute pushout.rec pushout.elim [unfold 10] [recursor 10]
attribute pushout.elim_type [unfold 9]
attribute pushout.rec_on pushout.elim_on [unfold 7]
attribute pushout.elim_type_on [unfold 6]
open sigma
namespace pushout
variables {TL BL TR : Type} (f : TL → BL) (g : TL → TR)
/- The non-dependent universal property -/
definition pushout_arrow_equiv (C : Type)
: (pushout f g → C) ≃ (Σ(i : BL → C) (j : TR → C), Πc, i (f c) = j (g c)) :=
begin
fapply equiv.MK,
{ intro f, exact ⟨λx, f (inl x), λx, f (inr x), λx, ap f (glue x)⟩},
{ intro v x, induction v with i w, induction w with j p, induction x,
exact (i a), exact (j a), exact (p x)},
{ intro v, induction v with i w, induction w with j p, esimp,
apply ap (λp, ⟨i, j, p⟩), apply eq_of_homotopy, intro x, apply elim_glue},
{ intro f, apply eq_of_homotopy, intro x, induction x: esimp,
apply eq_pathover, apply hdeg_square, esimp, apply elim_glue},
end
/- glue squares -/
protected definition glue_square {x x' : TL} (p : x = x')
: square (glue x) (glue x') (ap inl (ap f p)) (ap inr (ap g p)) :=
by cases p; apply vrefl
end pushout
open function sigma.ops
namespace pushout
/- The flattening lemma -/
section
universe variable u
parameters {TL BL TR : Type} (f : TL → BL) (g : TL → TR)
(Pinl : BL → Type.{u}) (Pinr : TR → Type.{u})
(Pglue : Π(x : TL), Pinl (f x) ≃ Pinr (g x))
include Pglue
local abbreviation A := BL + TR
local abbreviation R : A → A → Type := pushout_rel f g
local abbreviation P [unfold 5] := pushout.elim_type Pinl Pinr Pglue
local abbreviation F : sigma (Pinl ∘ f) → sigma Pinl :=
λz, ⟨ f z.1 , z.2 ⟩
local abbreviation G : sigma (Pinl ∘ f) → sigma Pinr :=
λz, ⟨ g z.1 , Pglue z.1 z.2 ⟩
protected definition flattening : sigma P ≃ pushout F G :=
begin
apply equiv.trans !quotient.flattening.flattening_lemma,
fapply equiv.MK,
{ intro q, induction q with z z z' fr,
{ induction z with a p, induction a with x x,
{ exact inl ⟨x, p⟩ },
{ exact inr ⟨x, p⟩ } },
{ induction fr with a a' r p, induction r with x,
exact glue ⟨x, p⟩ } },
{ intro q, induction q with xp xp xp,
{ exact class_of _ ⟨sum.inl xp.1, xp.2⟩ },
{ exact class_of _ ⟨sum.inr xp.1, xp.2⟩ },
{ apply eq_of_rel, constructor } },
{ intro q, induction q with xp xp xp: induction xp with x p,
{ apply ap inl, reflexivity },
{ apply ap inr, reflexivity },
{ unfold F, unfold G, apply eq_pathover,
rewrite [ap_id,ap_compose' (quotient.elim _ _)],
krewrite elim_glue, krewrite elim_eq_of_rel, apply hrefl } },
{ intro q, induction q with z z z' fr,
{ induction z with a p, induction a with x x,
{ reflexivity },
{ reflexivity } },
{ induction fr with a a' r p, induction r with x,
esimp, apply eq_pathover,
rewrite [ap_id,ap_compose' (pushout.elim _ _ _)],
krewrite elim_eq_of_rel, krewrite elim_glue, apply hrefl } }
end
end
-- Commutativity of pushouts
section
variables {TL BL TR : Type} (f : TL → BL) (g : TL → TR)
protected definition transpose [constructor] : pushout f g → pushout g f :=
begin
intro x, induction x, apply inr a, apply inl a, apply !glue⁻¹
end
--TODO prove without krewrite?
protected definition transpose_involutive (x : pushout f g) :
pushout.transpose g f (pushout.transpose f g x) = x :=
begin
induction x, apply idp, apply idp,
apply eq_pathover, refine _ ⬝hp !ap_id⁻¹,
refine !(ap_compose (pushout.transpose _ _)) ⬝ph _, esimp[pushout.transpose],
krewrite [elim_glue, ap_inv, elim_glue, inv_inv], apply hrfl
end
protected definition symm : pushout f g ≃ pushout g f :=
begin
fapply equiv.MK, do 2 exact !pushout.transpose,
do 2 (intro x; apply pushout.transpose_involutive),
end
end
-- Functoriality of pushouts
section
section lemmas
variables {X : Type} {x₀ x₁ x₂ x₃ : X}
(p : x₀ = x₁) (q : x₁ = x₂) (r : x₂ = x₃)
private definition is_equiv_functor_lemma₁
: (r ⬝ ((p ⬝ q ⬝ r)⁻¹ ⬝ p)) = q⁻¹ :=
by cases p; cases r; cases q; reflexivity
private definition is_equiv_functor_lemma₂
: (p ⬝ q ⬝ r)⁻¹ ⬝ (p ⬝ q) = r⁻¹ :=
by cases p; cases r; cases q; reflexivity
end lemmas
variables {TL BL TR : Type} (f : TL → BL) (g : TL → TR)
{TL' BL' TR' : Type} (f' : TL' → BL') (g' : TL' → TR')
(tl : TL → TL') (bl : BL → BL') (tr : TR → TR')
(fh : bl ∘ f ~ f' ∘ tl) (gh : tr ∘ g ~ g' ∘ tl)
include fh gh
protected definition functor [reducible] : pushout f g → pushout f' g' :=
begin
intro x, induction x with a b z,
{ exact inl (bl a) },
{ exact inr (tr b) },
{ exact (ap inl (fh z)) ⬝ glue (tl z) ⬝ (ap inr (gh z)⁻¹) }
end
protected definition ap_functor_inl [reducible] {x x' : BL} (p : x = x')
: ap (pushout.functor f g f' g' tl bl tr fh gh) (ap inl p) = ap inl (ap bl p) :=
by cases p; reflexivity
protected definition ap_functor_inr [reducible] {x x' : TR} (p : x = x')
: ap (pushout.functor f g f' g' tl bl tr fh gh) (ap inr p) = ap inr (ap tr p) :=
by cases p; reflexivity
variables [ietl : is_equiv tl] [iebl : is_equiv bl] [ietr : is_equiv tr]
include ietl iebl ietr
open equiv is_equiv arrow
protected definition is_equiv_functor [instance]
: is_equiv (pushout.functor f g f' g' tl bl tr fh gh) :=
adjointify
(pushout.functor f g f' g' tl bl tr fh gh)
(pushout.functor f' g' f g tl⁻¹ bl⁻¹ tr⁻¹
(inv_commute_of_commute tl bl f f' fh)
(inv_commute_of_commute tl tr g g' gh))
abstract begin
intro x', induction x' with a' b' z',
{ apply ap inl, apply right_inv },
{ apply ap inr, apply right_inv },
{ apply eq_pathover,
rewrite [ap_id,ap_compose' (pushout.functor f g f' g' tl bl tr fh gh)],
krewrite elim_glue,
rewrite [ap_inv,ap_con,ap_inv],
krewrite [pushout.ap_functor_inr], rewrite ap_con,
krewrite [pushout.ap_functor_inl,elim_glue],
apply transpose,
apply move_top_of_right, apply move_top_of_left',
krewrite [-(ap_inv inl),-ap_con,-(ap_inv inr),-ap_con],
apply move_top_of_right, apply move_top_of_left',
krewrite [-ap_con,-(ap_inv inl),-ap_con],
rewrite ap_bot_inv_commute_of_commute,
apply eq_hconcat (ap02 inl
(is_equiv_functor_lemma₁
(right_inv bl (f' z'))
(ap f' (right_inv tl z')⁻¹)
(fh (tl⁻¹ z'))⁻¹)),
rewrite [ap_inv f',inv_inv],
rewrite ap_bot_inv_commute_of_commute,
refine hconcat_eq _ (ap02 inr
(is_equiv_functor_lemma₁
(right_inv tr (g' z'))
(ap g' (right_inv tl z')⁻¹)
(gh (tl⁻¹ z'))⁻¹))⁻¹,
rewrite [ap_inv g',inv_inv],
apply pushout.glue_square }
end end
abstract begin
intro x, induction x with a b z,
{ apply ap inl, apply left_inv },
{ apply ap inr, apply left_inv },
{ apply eq_pathover,
rewrite [ap_id,ap_compose'
(pushout.functor f' g' f g tl⁻¹ bl⁻¹ tr⁻¹ _ _)
(pushout.functor f g f' g' tl bl tr _ _)],
krewrite elim_glue,
rewrite [ap_inv,ap_con,ap_inv],
krewrite [pushout.ap_functor_inr], rewrite ap_con,
krewrite [pushout.ap_functor_inl,elim_glue],
apply transpose,
apply move_top_of_right, apply move_top_of_left',
krewrite [-(ap_inv inl),-ap_con,-(ap_inv inr),-ap_con],
apply move_top_of_right, apply move_top_of_left',
krewrite [-ap_con,-(ap_inv inl),-ap_con],
rewrite inv_commute_of_commute_top,
apply eq_hconcat (ap02 inl
(is_equiv_functor_lemma₂
(ap bl⁻¹ (fh z))⁻¹
(left_inv bl (f z))
(ap f (left_inv tl z)⁻¹))),
rewrite [ap_inv f,inv_inv],
rewrite inv_commute_of_commute_top,
refine hconcat_eq _ (ap02 inr
(is_equiv_functor_lemma₂
(ap tr⁻¹ (gh z))⁻¹
(left_inv tr (g z))
(ap g (left_inv tl z)⁻¹)))⁻¹,
rewrite [ap_inv g,inv_inv],
apply pushout.glue_square }
end end
end
/- version giving the equivalence -/
section
variables {TL BL TR : Type} (f : TL → BL) (g : TL → TR)
{TL' BL' TR' : Type} (f' : TL' → BL') (g' : TL' → TR')
(tl : TL ≃ TL') (bl : BL ≃ BL') (tr : TR ≃ TR')
(fh : bl ∘ f ~ f' ∘ tl) (gh : tr ∘ g ~ g' ∘ tl)
include fh gh
protected definition equiv : pushout f g ≃ pushout f' g' :=
equiv.mk (pushout.functor f g f' g' tl bl tr fh gh) _
end
definition pointed_pushout [instance] [constructor] {TL BL TR : Type} [HTL : pointed TL]
[HBL : pointed BL] [HTR : pointed TR] (f : TL → BL) (g : TL → TR) : pointed (pushout f g) :=
pointed.mk (inl (point _))
end pushout open pushout
definition ppushout [constructor] {TL BL TR : Type*} (f : TL →* BL) (g : TL →* TR) : Type* :=
pointed.mk' (pushout f g)
namespace pushout
section
parameters {TL BL TR : Type*} (f : TL →* BL) (g : TL →* TR)
parameters {f g}
definition pinl [constructor] : BL →* ppushout f g :=
pmap.mk inl idp
definition pinr [constructor] : TR →* ppushout f g :=
pmap.mk inr ((ap inr (respect_pt g))⁻¹ ⬝ !glue⁻¹ ⬝ (ap inl (respect_pt f)))
definition pglue (x : TL) : pinl (f x) = pinr (g x) := -- TODO do we need this?
!glue
end
section
variables {TL BL TR : Type*} (f : TL →* BL) (g : TL →* TR)
protected definition psymm [constructor] : ppushout f g ≃* ppushout g f :=
begin
fapply pequiv_of_equiv,
{ apply pushout.symm},
{ exact ap inr (respect_pt f)⁻¹ ⬝ !glue⁻¹ ⬝ ap inl (respect_pt g)}
end
end
end pushout
|
0aac43213b428fcdd4dd025b82dc50c2f5f288b4 | 57fdc8de88f5ea3bfde4325e6ecd13f93a274ab5 | /data/nat/prime.lean | 9e0c9283cfb3ba8242608921de19edfbc8de9ba8 | [
"Apache-2.0"
] | permissive | louisanu/mathlib | 11f56f2d40dc792bc05ee2f78ea37d73e98ecbfe | 2bd5e2159d20a8f20d04fc4d382e65eea775ed39 | refs/heads/master | 1,617,706,993,439 | 1,523,163,654,000 | 1,523,163,654,000 | 124,519,997 | 0 | 0 | Apache-2.0 | 1,520,588,283,000 | 1,520,588,283,000 | null | UTF-8 | Lean | false | false | 14,837 | 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
Prime numbers.
-/
import data.nat.sqrt data.nat.gcd data.list.basic data.list.perm
open bool subtype
namespace nat
open decidable
/-- `prime p` means that `p` is a prime number, that is, a natural number
at least 2 whose only divisors are `p` and `1`. -/
def prime (p : ℕ) := p ≥ 2 ∧ ∀ m ∣ p, m = 1 ∨ m = p
theorem prime.ge_two {p : ℕ} : prime p → p ≥ 2 := and.left
theorem prime.gt_one {p : ℕ} : prime p → p > 1 := prime.ge_two
theorem prime_def_lt {p : ℕ} : prime p ↔ p ≥ 2 ∧ ∀ m < p, m ∣ p → m = 1 :=
and_congr_right $ λ p2, forall_congr $ λ m,
⟨λ h l d, (h d).resolve_right (ne_of_lt l),
λ h d, (lt_or_eq_of_le $
le_of_dvd (le_of_succ_le p2) d).imp_left (λ l, h l d)⟩
theorem prime_def_lt' {p : ℕ} : prime p ↔ p ≥ 2 ∧ ∀ m, 2 ≤ m → m < p → ¬ m ∣ p :=
prime_def_lt.trans $ and_congr_right $ λ p2, forall_congr $ λ m,
⟨λ h m2 l d, not_lt_of_ge m2 ((h l d).symm ▸ dec_trivial),
λ h l d, begin
rcases m with _|_|m,
{ rw eq_zero_of_zero_dvd d at p2, revert p2, exact dec_trivial },
{ refl },
{ exact (h dec_trivial l).elim d }
end⟩
theorem prime_def_le_sqrt {p : ℕ} : prime p ↔ p ≥ 2 ∧
∀ m, 2 ≤ m → m ≤ sqrt p → ¬ m ∣ p :=
prime_def_lt'.trans $ and_congr_right $ λ p2,
⟨λ a m m2 l, a m m2 $ lt_of_le_of_lt l $ sqrt_lt_self p2,
λ a, have ∀ {m k}, m ≤ k → 1 < m → p ≠ m * k, from
λ m k mk m1 e, a m m1
(le_sqrt.2 (e.symm ▸ mul_le_mul_left m mk)) ⟨k, e⟩,
λ m m2 l ⟨k, e⟩, begin
cases (le_total m k) with mk km,
{ exact this mk m2 e },
{ rw [mul_comm] at e,
refine this km (lt_of_mul_lt_mul_right _ (zero_le m)) e,
rwa [one_mul, ← e] }
end⟩
def decidable_prime_1 (p : ℕ) : decidable (prime p) :=
decidable_of_iff' _ prime_def_lt'
local attribute [instance] decidable_prime_1
theorem prime.pos {p : ℕ} (pp : prime p) : p > 0 :=
lt_of_succ_lt pp.gt_one
theorem not_prime_zero : ¬ prime 0 := dec_trivial
theorem not_prime_one : ¬ prime 1 := dec_trivial
theorem prime_two : prime 2 := dec_trivial
theorem prime_three : prime 3 := dec_trivial
theorem prime.pred_pos {p : ℕ} (pp : prime p) : pred p > 0 :=
lt_pred_of_succ_lt pp.gt_one
theorem succ_pred_prime {p : ℕ} (pp : prime p) : succ (pred p) = p :=
succ_pred_eq_of_pos pp.pos
theorem dvd_prime {p m : ℕ} (pp : prime p) : m ∣ p ↔ m = 1 ∨ m = p :=
⟨λ d, pp.2 m d, λ h, h.elim (λ e, e.symm ▸ one_dvd _) (λ e, e.symm ▸ dvd_refl _)⟩
theorem dvd_prime_ge_two {p m : ℕ} (pp : prime p) (H : m ≥ 2) : m ∣ p ↔ m = p :=
(dvd_prime pp).trans $ or_iff_right_of_imp $ not.elim $ ne_of_gt H
theorem prime.not_dvd_one {p : ℕ} (pp : prime p) : ¬ p ∣ 1
| d := (not_le_of_gt pp.gt_one) $ le_of_dvd dec_trivial d
section min_fac
private lemma min_fac_lemma (n k : ℕ) (h : ¬ k * k > n) :
sqrt n - k < sqrt n + 2 - k :=
(nat.sub_lt_sub_right_iff $ le_sqrt.2 $ le_of_not_gt h).2 $
nat.lt_add_of_pos_right dec_trivial
def min_fac_aux (n : ℕ) : ℕ → ℕ | k :=
if h : n < k * k then n else
if k ∣ n then k else
have _, from min_fac_lemma n k h,
min_fac_aux (k + 2)
using_well_founded {rel_tac :=
λ _ _, `[exact ⟨_, measure_wf (λ k, sqrt n + 2 - k)⟩]}
/-- Returns the smallest prime factor of `n ≠ 1`. -/
def min_fac : ℕ → ℕ
| 0 := 2
| 1 := 1
| (n+2) := if 2 ∣ n then 2 else min_fac_aux (n + 2) 3
@[simp] theorem min_fac_zero : min_fac 0 = 2 := rfl
@[simp] theorem min_fac_one : min_fac 1 = 1 := rfl
theorem min_fac_eq : ∀ {n : ℕ} (n2 : n ≥ 2),
min_fac n = if 2 ∣ n then 2 else min_fac_aux n 3
| 1 h := (dec_trivial : ¬ _).elim h
| (n+2) h := by by_cases 2 ∣ n;
simp [min_fac, (nat.dvd_add_iff_left (dvd_refl 2)).symm, h]
private def min_fac_prop (n k : ℕ) :=
k ≥ 2 ∧ k ∣ n ∧ ∀ m ≥ 2, m ∣ n → k ≤ m
theorem min_fac_aux_has_prop {n : ℕ} (n2 : n ≥ 2) (nd2 : ¬ 2 ∣ n) :
∀ k i, k = 2*i+3 → (∀ m ≥ 2, m ∣ n → k ≤ m) → min_fac_prop n (min_fac_aux n k)
| k := λ i e a, begin
rw min_fac_aux,
by_cases h : n < k*k; simp [h],
{ have pp : prime n :=
prime_def_le_sqrt.2 ⟨n2, λ m m2 l d,
not_lt_of_ge l $ lt_of_lt_of_le (sqrt_lt.2 h) (a m m2 d)⟩,
from ⟨n2, dvd_refl _, λ m m2 d, le_of_eq
((dvd_prime_ge_two pp m2).1 d).symm⟩ },
have k2 : 2 ≤ k, { subst e, exact dec_trivial },
by_cases dk : k ∣ n; simp [dk],
{ exact ⟨k2, dk, a⟩ },
{ refine have _, from min_fac_lemma n k h,
min_fac_aux_has_prop (k+2) (i+1)
(by simp [e, left_distrib]) (λ m m2 d, _),
cases nat.eq_or_lt_of_le (a m m2 d) with me ml,
{ subst me, contradiction },
apply (nat.eq_or_lt_of_le ml).resolve_left, intro me,
rw [← me, e] at d, change 2 * (i + 2) ∣ n at d,
have := dvd_of_mul_right_dvd d, contradiction }
end
using_well_founded {rel_tac :=
λ _ _, `[exact ⟨_, measure_wf (λ k, sqrt n + 2 - k)⟩]}
theorem min_fac_has_prop {n : ℕ} (n1 : n ≠ 1) :
min_fac_prop n (min_fac n) :=
begin
by_cases n0 : n = 0, {simp [n0, min_fac_prop, ge]},
have n2 : 2 ≤ n, { revert n0 n1, rcases n with _|_|_; exact dec_trivial },
simp [min_fac_eq n2],
by_cases d2 : 2 ∣ n; simp [d2],
{ exact ⟨le_refl _, d2, λ k k2 d, k2⟩ },
{ refine min_fac_aux_has_prop n2 d2 3 0 rfl
(λ m m2 d, (nat.eq_or_lt_of_le m2).resolve_left (mt _ d2)),
exact λ e, e.symm ▸ d }
end
theorem min_fac_dvd (n : ℕ) : min_fac n ∣ n :=
by by_cases n1 : n = 1;
[exact n1.symm ▸ dec_trivial, exact (min_fac_has_prop n1).2.1]
theorem min_fac_prime {n : ℕ} (n1 : n ≠ 1) : prime (min_fac n) :=
let ⟨f2, fd, a⟩ := min_fac_has_prop n1 in
prime_def_lt'.2 ⟨f2, λ m m2 l d, not_le_of_gt l (a m m2 (dvd_trans d fd))⟩
theorem min_fac_le_of_dvd (n : ℕ) : ∀ (m : ℕ), m ≥ 2 → m ∣ n → min_fac n ≤ m :=
by by_cases n1 : n = 1;
[exact λ m m2 d, n1.symm ▸ le_trans dec_trivial m2,
exact (min_fac_has_prop n1).2.2]
theorem min_fac_pos (n : ℕ) : min_fac n > 0 :=
by by_cases n1 : n = 1;
[exact n1.symm ▸ dec_trivial, exact (min_fac_prime n1).pos]
theorem min_fac_le {n : ℕ} (H : n > 0) : min_fac n ≤ n :=
le_of_dvd H (min_fac_dvd n)
theorem prime_def_min_fac {p : ℕ} : prime p ↔ p ≥ 2 ∧ min_fac p = p :=
⟨λ pp, ⟨pp.ge_two,
let ⟨f2, fd, a⟩ := min_fac_has_prop $ ne_of_gt pp.gt_one in
((dvd_prime pp).1 fd).resolve_left (ne_of_gt f2)⟩,
λ ⟨p2, e⟩, e ▸ min_fac_prime (ne_of_gt p2)⟩
instance decidable_prime (p : ℕ) : decidable (prime p) :=
decidable_of_iff' _ prime_def_min_fac
theorem not_prime_iff_min_fac_lt {n : ℕ} (n2 : n ≥ 2) : ¬ prime n ↔ min_fac n < n :=
(not_congr $ prime_def_min_fac.trans $ and_iff_right n2).trans $
(lt_iff_le_and_ne.trans $ and_iff_right $ min_fac_le $ le_of_succ_le n2).symm
end min_fac
theorem exists_dvd_of_not_prime {n : ℕ} (n2 : n ≥ 2) (np : ¬ prime n) :
∃ m, m ∣ n ∧ m ≠ 1 ∧ m ≠ n :=
⟨min_fac n, min_fac_dvd _, ne_of_gt (min_fac_prime (ne_of_gt n2)).gt_one,
ne_of_lt $ (not_prime_iff_min_fac_lt n2).1 np⟩
theorem exists_dvd_of_not_prime2 {n : ℕ} (n2 : n ≥ 2) (np : ¬ prime n) :
∃ m, m ∣ n ∧ m ≥ 2 ∧ m < n :=
⟨min_fac n, min_fac_dvd _, (min_fac_prime (ne_of_gt n2)).ge_two,
(not_prime_iff_min_fac_lt n2).1 np⟩
theorem exists_prime_and_dvd {n : ℕ} (n2 : n ≥ 2) : ∃ p, prime p ∧ p ∣ n :=
⟨min_fac n, min_fac_prime (ne_of_gt n2), min_fac_dvd _⟩
theorem exists_infinite_primes : ∀ n : ℕ, ∃ p, p ≥ n ∧ prime p :=
suffices ∀ {n}, n ≥ 2 → ∃ p, p ≥ n ∧ prime p, from
λ n, let ⟨p, h, pp⟩ := this (nat.le_add_left 2 n) in
⟨p, le_trans (nat.le_add_right n 2) h, pp⟩,
λ n n2,
let p := min_fac (fact n + 1) in
have f1 : fact n + 1 ≠ 1, from ne_of_gt $ succ_lt_succ $ fact_pos _,
have pp : prime p, from min_fac_prime f1,
have n ≤ p, from le_of_not_ge $ λ h,
have p ∣ fact n, from dvd_fact (min_fac_pos _) h,
have p ∣ 1, from (nat.dvd_add_iff_right this).2 (min_fac_dvd _),
pp.not_dvd_one this,
⟨p, this, pp⟩
theorem factors_lemma {k} : (k+2) / min_fac (k+2) < k+2 :=
div_lt_self dec_trivial (min_fac_prime dec_trivial).gt_one
/-- `factors n` is the prime factorization of `n`, listed in increasing order. -/
def factors : ℕ → list ℕ
| 0 := []
| 1 := []
| n@(k+2) :=
let m := min_fac n in have n / m < n := factors_lemma,
m :: factors (n / m)
lemma mem_factors : ∀ {n p}, p ∈ factors n → prime p
| 0 := λ p, false.elim
| 1 := λ p, false.elim
| n@(k+2) := λ p h,
let m := min_fac n in have n / m < n := factors_lemma,
have h₁ : p = m ∨ p ∈ (factors (n / m)) :=
(list.mem_cons_iff _ _ _).1 h,
or.cases_on h₁ (λ h₂, h₂.symm ▸ min_fac_prime dec_trivial)
mem_factors
lemma prod_factors : ∀ {n}, 0 < n → list.prod (factors n) = n
| 0 := (lt_irrefl _).elim
| 1 := λ h, rfl
| n@(k+2) := λ h,
let m := min_fac n in have n / m < n := factors_lemma,
show list.prod (m :: factors (n / m)) = n, from
have h₁ : 0 < n / m :=
nat.pos_of_ne_zero $ λ h,
have n = 0 * m := (nat.div_eq_iff_eq_mul_left (min_fac_pos _) (min_fac_dvd _)).1 h,
by rw zero_mul at this; exact (show k + 2 ≠ 0, from dec_trivial) this,
by rw [list.prod_cons, prod_factors h₁, nat.mul_div_cancel' (min_fac_dvd _)]
theorem prime.coprime_iff_not_dvd {p n : ℕ} (pp : prime p) : coprime p n ↔ ¬ p ∣ n :=
⟨λ co d, pp.not_dvd_one $ co.dvd_of_dvd_mul_left (by simp [d]),
λ nd, coprime_of_dvd $ λ m m2 mp, ((dvd_prime_ge_two pp m2).1 mp).symm ▸ nd⟩
theorem prime.dvd_iff_not_coprime {p n : ℕ} (pp : prime p) : p ∣ n ↔ ¬ coprime p n :=
iff_not_comm.2 pp.coprime_iff_not_dvd
theorem prime.dvd_mul {p m n : ℕ} (pp : prime p) : p ∣ m * n ↔ p ∣ m ∨ p ∣ n :=
⟨λ H, or_iff_not_imp_left.2 $ λ h,
(pp.coprime_iff_not_dvd.2 h).dvd_of_dvd_mul_left H,
or.rec (λ h, dvd_mul_of_dvd_left h _) (λ h, dvd_mul_of_dvd_right h _)⟩
theorem prime.not_dvd_mul {p m n : ℕ} (pp : prime p)
(Hm : ¬ p ∣ m) (Hn : ¬ p ∣ n) : ¬ p ∣ m * n :=
mt pp.dvd_mul.1 $ by simp [Hm, Hn]
theorem prime.dvd_of_dvd_pow {p m n : ℕ} (pp : prime p) (h : p ∣ m^n) : p ∣ m :=
by induction n with n IH;
[exact pp.not_dvd_one.elim h,
exact (pp.dvd_mul.1 h).elim IH id]
theorem prime.coprime_pow_of_not_dvd {p m a : ℕ} (pp : prime p) (h : ¬ p ∣ a) : coprime a (p^m) :=
(pp.coprime_iff_not_dvd.2 h).symm.pow_right _
theorem coprime_primes {p q : ℕ} (pp : prime p) (pq : prime q) : coprime p q ↔ p ≠ q :=
pp.coprime_iff_not_dvd.trans $ not_congr $ dvd_prime_ge_two pq pp.ge_two
theorem coprime_pow_primes {p q : ℕ} (n m : ℕ) (pp : prime p) (pq : prime q) (h : p ≠ q) :
coprime (p^n) (q^m) :=
((coprime_primes pp pq).2 h).pow _ _
theorem coprime_or_dvd_of_prime {p} (pp : prime p) (i : ℕ) : coprime p i ∨ p ∣ i :=
by rw [pp.dvd_iff_not_coprime]; apply em
theorem dvd_prime_pow {p : ℕ} (pp : prime p) {m i : ℕ} : i ∣ (p^m) ↔ ∃ k ≤ m, i = p^k :=
begin
induction m with m IH generalizing i, {simp [pow_succ, le_zero_iff] at *},
by_cases p ∣ i,
{ cases h with a e, subst e,
rw [pow_succ, mul_comm (p^m) p, nat.mul_dvd_mul_iff_left pp.pos, IH],
split; intro h; rcases h with ⟨k, h, e⟩,
{ exact ⟨succ k, succ_le_succ h, by rw [mul_comm, e]; refl⟩ },
cases k with k,
{ apply pp.not_dvd_one.elim,
simp at e, rw ← e, apply dvd_mul_right },
{ refine ⟨k, le_of_succ_le_succ h, _⟩,
rwa [mul_comm, pow_succ, nat.mul_right_inj pp.pos] at e } },
{ split; intro d,
{ rw (pp.coprime_pow_of_not_dvd h).eq_one_of_dvd d,
exact ⟨0, zero_le _, rfl⟩ },
{ rcases d with ⟨k, l, e⟩,
rw e, exact pow_dvd_pow _ l } }
end
section
open list
lemma mem_list_primes_of_dvd_prod {p : ℕ} (hp : prime p) :
∀ {l : list ℕ}, (∀ p ∈ l, prime p) → p ∣ prod l → p ∈ l
| [] := λ h₁ h₂, absurd h₂ (prime.not_dvd_one hp)
| (q :: l) := λ h₁ h₂,
have h₃ : p ∣ q * prod l := @prod_cons _ _ l q ▸ h₂,
have hq : prime q := h₁ q (mem_cons_self _ _),
or.cases_on ((prime.dvd_mul hp).1 h₃)
(λ h, by rw [prime.dvd_iff_not_coprime hp, coprime_primes hp hq, ne.def, not_not] at h;
exact h ▸ mem_cons_self _ _)
(λ h, have hl : ∀ p ∈ l, prime p := λ p hlp, h₁ p ((mem_cons_iff _ _ _).2 (or.inr hlp)),
(mem_cons_iff _ _ _).2 (or.inr (mem_list_primes_of_dvd_prod hl h)))
lemma mem_factors_of_dvd {n p : ℕ} (hn : 0 < n) (hp : prime p) (h : p ∣ n) : p ∈ factors n :=
mem_list_primes_of_dvd_prod hp (@mem_factors n) ((prod_factors hn).symm ▸ h)
lemma perm_of_prod_eq_prod : ∀ {l₁ l₂ : list ℕ}, prod l₁ = prod l₂ →
(∀ p ∈ l₁, prime p) → (∀ p ∈ l₂, prime p) → l₁ ~ l₂
| [] [] _ _ _ := perm.nil
| [] (a :: l) h₁ h₂ h₃ :=
have ha : a ∣ 1 := @prod_nil ℕ _ ▸ h₁.symm ▸ (@prod_cons _ _ l a).symm ▸ dvd_mul_right _ _,
absurd ha (prime.not_dvd_one (h₃ a (mem_cons_self _ _)))
| (a :: l) [] h₁ h₂ h₃ :=
have ha : a ∣ 1 := @prod_nil ℕ _ ▸ h₁ ▸ (@prod_cons _ _ l a).symm ▸ dvd_mul_right _ _,
absurd ha (prime.not_dvd_one (h₂ a (mem_cons_self _ _)))
| (a :: l₁) (b :: l₂) h hl₁ hl₂ :=
have hl₁' : ∀ p ∈ l₁, prime p := λ p hp, hl₁ p (mem_cons_of_mem _ hp),
have hl₂' : ∀ p ∈ (b :: l₂).erase a, prime p := λ p hp, hl₂ p (mem_of_mem_erase hp),
have ha : a ∈ (b :: l₂) := mem_list_primes_of_dvd_prod (hl₁ a (mem_cons_self _ _)) hl₂
(h ▸ by rw prod_cons; exact dvd_mul_right _ _),
have hb : b :: l₂ ~ a :: (b :: l₂).erase a := perm_erase ha,
have hl : prod l₁ = prod ((b :: l₂).erase a) :=
(nat.mul_left_inj (prime.pos (hl₁ a (mem_cons_self _ _)))).1 $
by rwa [← prod_cons, ← prod_cons, ← prod_eq_of_perm hb],
perm.trans (perm.skip _ (perm_of_prod_eq_prod hl hl₁' hl₂')) hb.symm
lemma factors_unique {n : ℕ} {l : list ℕ} (h₁ : prod l = n) (h₂ : ∀ p ∈ l, prime p) : l ~ factors n :=
have hn : 0 < n := nat.pos_of_ne_zero $ λ h, begin
rw h at *, clear h,
induction l with a l hi,
{ exact absurd h₁ dec_trivial },
{ rw prod_cons at h₁,
exact nat.mul_ne_zero (ne_of_lt (prime.pos (h₂ a (mem_cons_self _ _)))).symm
(hi (λ p hp, h₂ p (mem_cons_of_mem _ hp))) h₁ }
end,
perm_of_prod_eq_prod (by rwa prod_factors hn) h₂ (@mem_factors _)
end
end nat
|
62032340955a7c14521af3b64017ae7c03d758fe | 0dfea33a345e7264f2e601256a8e706ae898f46f | /.config.lean | 9381d2fc055a911545e917f7441ad33e907aaac4 | [
"MIT"
] | permissive | hsfengbyte/MT1300 | a47771d4991225c98f86a50980aee650605067f5 | e67f9d6acf97aadc4a14d3df5b3400b774473e32 | refs/heads/main | 1,689,018,537,355 | 1,629,119,139,000 | 1,629,119,139,000 | 396,795,936 | 0 | 0 | MIT | 1,629,118,749,000 | 1,629,118,749,000 | null | UTF-8 | Lean | false | false | 249,749 | lean | # 2021-08-16
# 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_ar71xx 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_bcm63xx is not set
# CONFIG_TARGET_cns3xxx is not set
# CONFIG_TARGET_octeon is not set
# CONFIG_TARGET_gemini is not set
# CONFIG_TARGET_mpc85xx is not set
# CONFIG_TARGET_imx6 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_rb532 is not set
# CONFIG_TARGET_tegra is not set
# CONFIG_TARGET_layerscape 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_rockchip is not set
# CONFIG_TARGET_samsung 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_Default 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_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_asiarf_ap7621-001 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_asiarf_ap7621-nv1 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_xzwifi_creativebox-v1 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_elecom_wrc-1167ghbk2-s is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_elecom_wrc-1900gst 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_edimax_rg21s is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_edimax_ra21s is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_firefly_firewrt is not set
CONFIG_TARGET_ramips_mt7621_DEVICE_glinet_gl-mt1300=y
# CONFIG_TARGET_ramips_mt7621_DEVICE_gehua_ghl-r-001 is not set
# 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-gx300gr is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iodata_wnpr2600g is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_jcg_jhr-ac876m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_jcg_y2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_jdcloud_re-sp-01b is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_ea7500-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_linksys_re6500 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_mediatek_mt7621-eval-board is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mediatek_ap-mt7621a-v60 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_mikrotik_routerboard-750gr3 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_motorola_mr2600 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_ex6150 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_netgear_r6700-v2 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_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_lenovo_newifi-d1 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_phicomm_k2p is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_planex_vr500 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_storylink_sap-g3200u3 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_samknows_whitebox-v8 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_totolink_a7000r is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_re350-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_tplink_re650-v1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_telco-electronics_x1 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_thunder_timecloud 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-nanohd 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_wevo_11acnas is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_wevo_w2914ns-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaoyu_xy-c5 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mir3p is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mir3g is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mir3g-v2 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mir4 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-ac2100 is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_redmi-router-ac2100 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_zio_freezio 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_iptime_a6ns-m is not set
# CONFIG_TARGET_ramips_mt7621_DEVICE_iptime_a8004t 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_ca-certificates=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_kmod-gpio-button-hotplug=y
CONFIG_DEFAULT_kmod-ipt-raw=y
CONFIG_DEFAULT_kmod-leds-gpio=y
CONFIG_DEFAULT_kmod-mt7615-firmware=y
CONFIG_DEFAULT_kmod-mt7615e=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-cpufreq=y
CONFIG_DEFAULT_luci-app-ddns=y
CONFIG_DEFAULT_luci-app-filetransfer=y
CONFIG_DEFAULT_luci-app-flowoffload=y
CONFIG_DEFAULT_luci-app-nlbwmon=y
CONFIG_DEFAULT_luci-app-ramfree=y
CONFIG_DEFAULT_luci-app-ssr-plus=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-webadmin=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_swconfig=y
CONFIG_DEFAULT_uci=y
CONFIG_DEFAULT_uclient-fetch=y
CONFIG_DEFAULT_urandom-seed=y
CONFIG_DEFAULT_urngd=y
CONFIG_DEFAULT_wget=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=256
CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP=y
CONFIG_TARGET_UBIFS_JOURNAL_SIZE=""
#
# Image Options
#
# end of Target Images
#
# 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_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_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_DEBUG_FS=y
CONFIG_KERNEL_MIPS_FPU_EMULATOR=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_FHANDLE=y
CONFIG_KERNEL_FANOTIFY=y
# CONFIG_KERNEL_BLK_DEV_BSG 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 is not set
CONFIG_KERNEL_CGROUPS=y
# CONFIG_KERNEL_CGROUP_DEBUG is not set
CONFIG_KERNEL_FREEZER=y
CONFIG_KERNEL_CGROUP_FREEZER=y
CONFIG_KERNEL_CGROUP_DEVICE=y
CONFIG_KERNEL_CGROUP_PIDS=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 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 is not set
CONFIG_KERNEL_RT_GROUP_SCHED=y
CONFIG_KERNEL_BLK_CGROUP=y
# CONFIG_KERNEL_CFQ_GROUP_IOSCHED is not set
# CONFIG_KERNEL_BLK_DEV_THROTTLING is not set
# CONFIG_KERNEL_DEBUG_BLK_CGROUP is not set
CONFIG_KERNEL_NET_CLS_CGROUP=y
CONFIG_KERNEL_CGROUP_NET_PRIO=y
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_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_CC_OPTIMIZE_FOR_PERFORMANCE=y
# CONFIG_KERNEL_CC_OPTIMIZE_FOR_SIZE 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_STRIP_KERNEL_EXPORTS is not set
# CONFIG_USE_MKLIBS is not set
CONFIG_USE_UCLIBCXX=y
# CONFIG_USE_LIBCXX is not set
# 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_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
# 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_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_USE_MUSL=y
CONFIG_SSP_SUPPORT=y
CONFIG_BINUTILS_VERSION_2_31_1=y
CONFIG_BINUTILS_VERSION="2.31.1"
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
CONFIG_FEED_freifunk=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_PLATFORM_LINUX=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_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_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_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 is not set
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_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_FEATURE_HEXDUMP_REVERSE is not set
# 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_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_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_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=y
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_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 is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_NSLOOKUP_BIG is not set
# CONFIG_BUSYBOX_DEFAULT_FEATURE_NSLOOKUP_LONG_OPTIONS is not set
CONFIG_BUSYBOX_DEFAULT_NSLOOKUP_OPENWRT=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_NSLOOKUP_OPENWRT_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_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_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_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_ca-bundle=y
CONFIG_PACKAGE_ca-certificates=y
# 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 is not set
CONFIG_DROPBEAR_CHACHA20POLY1305=y
# CONFIG_DROPBEAR_ZLIB is not set
CONFIG_DROPBEAR_DBCLIENT=y
# end of Configuration
# CONFIG_PACKAGE_ead is not set
CONFIG_PACKAGE_firewall=y
CONFIG_PACKAGE_fstools=y
CONFIG_FSTOOLS_UBIFS_EXTROOT=y
# 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=y
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-ujail is not set
# CONFIG_PACKAGE_procd-ujail-console is not set
# CONFIG_PACKAGE_qos-scripts 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_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=y
CONFIG_PACKAGE_usign=y
# CONFIG_PACKAGE_wireless-tools is not set
# CONFIG_PACKAGE_zram-swap is not set
# end of Base system
#
# Administration
#
#
# OpenWISP
#
# CONFIG_PACKAGE_openwisp-config-cyassl is not set
# CONFIG_PACKAGE_openwisp-config-mbedtls is not set
# CONFIG_PACKAGE_openwisp-config-nossl is not set
# CONFIG_PACKAGE_openwisp-config-openssl is not set
# end of OpenWISP
#
# 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-mac80211 is not set
# 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
# CONFIG_PACKAGE_atop is not set
# CONFIG_PACKAGE_backuppc is not set
# CONFIG_PACKAGE_debootstrap is not set
# CONFIG_PACKAGE_gkrellmd is not set
# CONFIG_PACKAGE_gotop 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 is not set
# 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_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_mt76-test is not set
# CONFIG_PACKAGE_ninja is not set
# CONFIG_PACKAGE_objdump 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_tang is not set
# CONFIG_PACKAGE_wireguard-tools 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-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-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_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-43362-sdio is not set
# CONFIG_PACKAGE_brcmfmac-firmware-43430-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 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_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=y
# 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 is not set
# CONFIG_PACKAGE_kmod-crypto-cmac is not set
CONFIG_PACKAGE_kmod-crypto-crc32c=y
# CONFIG_PACKAGE_kmod-crypto-ctr is not set
# CONFIG_PACKAGE_kmod-crypto-cts is not set
# CONFIG_PACKAGE_kmod-crypto-deflate is not set
# CONFIG_PACKAGE_kmod-crypto-des is not set
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 is not set
# CONFIG_PACKAGE_kmod-crypto-hw-ccp is not set
# CONFIG_PACKAGE_kmod-crypto-hw-geode is not set
# CONFIG_PACKAGE_kmod-crypto-hw-hifn-795x is not set
# CONFIG_PACKAGE_kmod-crypto-hw-padlock is not set
# CONFIG_PACKAGE_kmod-crypto-hw-talitos is not set
CONFIG_PACKAGE_kmod-crypto-manager=y
# CONFIG_PACKAGE_kmod-crypto-md4 is not set
# CONFIG_PACKAGE_kmod-crypto-md5 is not set
# 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-pcompress=y
# CONFIG_PACKAGE_kmod-crypto-rmd160 is not set
# CONFIG_PACKAGE_kmod-crypto-rng is not set
# CONFIG_PACKAGE_kmod-crypto-seqiv is not set
CONFIG_PACKAGE_kmod-crypto-sha1=y
# CONFIG_PACKAGE_kmod-crypto-sha256 is not set
# CONFIG_PACKAGE_kmod-crypto-sha512 is not set
# CONFIG_PACKAGE_kmod-crypto-test is not set
CONFIG_PACKAGE_kmod-crypto-user=y
# CONFIG_PACKAGE_kmod-crypto-wq is not set
# 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 is not set
# 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-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=y
# 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-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-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-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-leds-gpio=y
# CONFIG_PACKAGE_kmod-leds-pca963x is not set
# CONFIG_PACKAGE_kmod-ledtrig-activity is not set
# CONFIG_PACKAGE_kmod-ledtrig-default-on is not set
# CONFIG_PACKAGE_kmod-ledtrig-gpio is not set
# CONFIG_PACKAGE_kmod-ledtrig-heartbeat is not set
# CONFIG_PACKAGE_kmod-ledtrig-netdev is not set
# CONFIG_PACKAGE_kmod-ledtrig-oneshot is not set
# CONFIG_PACKAGE_kmod-ledtrig-timer 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=y
# 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=y
# 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=y
# 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-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-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-mvsw61xx 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-capi 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-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-cake-virtual 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-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-bmp085 is not set
# CONFIG_PACKAGE_kmod-bmp085-i2c is not set
# CONFIG_PACKAGE_kmod-bmp085-spi 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-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-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-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-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-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-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-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=y
# CONFIG_PACKAGE_CFG80211_TESTMODE 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=y
CONFIG_PACKAGE_MAC80211_DEBUGFS=y
# CONFIG_PACKAGE_MAC80211_TRACING is not set
CONFIG_PACKAGE_MAC80211_MESH=y
# CONFIG_PACKAGE_kmod-mac80211-hwsim is not set
# CONFIG_PACKAGE_kmod-mt76 is not set
CONFIG_PACKAGE_kmod-mt76-core=y
# 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-common=y
CONFIG_PACKAGE_kmod-mt7615-firmware=y
# CONFIG_PACKAGE_kmod-mt7615d is not set
# CONFIG_PACKAGE_kmod-mt7615d_dbdc is not set
CONFIG_PACKAGE_kmod-mt7615e=y
# 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-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-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_lpeg is not set
# CONFIG_PACKAGE_lsqlite3 is not set
CONFIG_PACKAGE_lua=y
# 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=y
# CONFIG_PACKAGE_luv 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
#
# PHP
#
# CONFIG_PACKAGE_php7 is not set
# end of PHP
#
# Perl
#
# CONFIG_PACKAGE_perl is not set
# end of Perl
#
# Python
#
# CONFIG_PACKAGE_gunicorn3 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-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-automat is not set
# CONFIG_PACKAGE_python3-awscli is not set
# CONFIG_PACKAGE_python3-base is not set
# CONFIG_PACKAGE_python3-bcrypt 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-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-et_xmlfile is not set
# CONFIG_PACKAGE_python3-evdev is not set
# CONFIG_PACKAGE_python3-flask is not set
# CONFIG_PACKAGE_python3-flask-login 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-gunicorn 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-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-light is not set
#
# Configuration
#
# CONFIG_PYTHON3_BLUETOOTH_SUPPORT 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-multidict is not set
# CONFIG_PACKAGE_python3-multiprocessing is not set
# CONFIG_PACKAGE_python3-mysqlclient 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-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-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-pytest 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-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-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-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-twisted 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=y
#
# Standard Library
#
# CONFIG_PACKAGE_ruby-stdlib is not set
# CONFIG_PACKAGE_ruby-benchmark is not set
CONFIG_PACKAGE_ruby-bigdecimal=y
# CONFIG_PACKAGE_ruby-bundler is not set
# CONFIG_PACKAGE_ruby-cgi is not set
# CONFIG_PACKAGE_ruby-csv is not set
CONFIG_PACKAGE_ruby-date=y
CONFIG_PACKAGE_ruby-dbm=y
# CONFIG_PACKAGE_ruby-debuglib is not set
# CONFIG_PACKAGE_ruby-delegate is not set
# CONFIG_PACKAGE_ruby-dev is not set
# CONFIG_PACKAGE_ruby-did-you-mean is not set
CONFIG_PACKAGE_ruby-digest=y
# CONFIG_RUBY_DIGEST_USE_OPENSSL is not set
# CONFIG_PACKAGE_ruby-drb is not set
CONFIG_PACKAGE_ruby-enc=y
# CONFIG_PACKAGE_ruby-enc-extra is not set
# CONFIG_PACKAGE_ruby-erb is not set
# CONFIG_PACKAGE_ruby-etc is not set
# CONFIG_PACKAGE_ruby-fcntl is not set
# CONFIG_PACKAGE_ruby-fiddle is not set
# CONFIG_PACKAGE_ruby-filelib is not set
# CONFIG_PACKAGE_ruby-fileutils is not set
# CONFIG_PACKAGE_ruby-forwardable is not set
# CONFIG_PACKAGE_ruby-gdbm is not set
# CONFIG_PACKAGE_ruby-gems is not set
# CONFIG_PACKAGE_ruby-getoptlong is not set
# CONFIG_PACKAGE_ruby-io-console is not set
# CONFIG_PACKAGE_ruby-ipaddr is not set
# CONFIG_PACKAGE_ruby-irb is not set
# CONFIG_PACKAGE_ruby-json is not set
# CONFIG_PACKAGE_ruby-logger is not set
# CONFIG_PACKAGE_ruby-matrix is not set
# CONFIG_PACKAGE_ruby-minitest is not set
# CONFIG_PACKAGE_ruby-misc is not set
# CONFIG_PACKAGE_ruby-mkmf is not set
# CONFIG_PACKAGE_ruby-multithread is not set
# CONFIG_PACKAGE_ruby-mutex_m is not set
# CONFIG_PACKAGE_ruby-net is not set
# CONFIG_PACKAGE_ruby-net-pop is not set
# CONFIG_PACKAGE_ruby-net-smtp is not set
# CONFIG_PACKAGE_ruby-net-telnet is not set
# CONFIG_PACKAGE_ruby-nkf is not set
# CONFIG_PACKAGE_ruby-observer is not set
# CONFIG_PACKAGE_ruby-open3 is not set
# CONFIG_PACKAGE_ruby-openssl is not set
# CONFIG_PACKAGE_ruby-optparse is not set
# CONFIG_PACKAGE_ruby-ostruct is not set
# CONFIG_PACKAGE_ruby-powerassert is not set
# CONFIG_PACKAGE_ruby-prettyprint is not set
# CONFIG_PACKAGE_ruby-prime is not set
CONFIG_PACKAGE_ruby-pstore=y
CONFIG_PACKAGE_ruby-psych=y
# CONFIG_PACKAGE_ruby-racc is not set
# CONFIG_PACKAGE_ruby-rake is not set
# CONFIG_PACKAGE_ruby-rbconfig is not set
# CONFIG_PACKAGE_ruby-rdoc is not set
# CONFIG_PACKAGE_ruby-readline is not set
# CONFIG_PACKAGE_ruby-readline-ext is not set
# CONFIG_PACKAGE_ruby-reline is not set
# CONFIG_PACKAGE_ruby-rexml is not set
# CONFIG_PACKAGE_ruby-rinda is not set
# CONFIG_PACKAGE_ruby-ripper is not set
# CONFIG_PACKAGE_ruby-rss is not set
# CONFIG_PACKAGE_ruby-sdbm is not set
# CONFIG_PACKAGE_ruby-singleton is not set
# CONFIG_PACKAGE_ruby-socket is not set
CONFIG_PACKAGE_ruby-stringio=y
CONFIG_PACKAGE_ruby-strscan=y
# CONFIG_PACKAGE_ruby-testunit is not set
# CONFIG_PACKAGE_ruby-time is not set
# CONFIG_PACKAGE_ruby-timeout is not set
# CONFIG_PACKAGE_ruby-tracer is not set
# CONFIG_PACKAGE_ruby-unicodenormalize is not set
# CONFIG_PACKAGE_ruby-uri is not set
# CONFIG_PACKAGE_ruby-webrick is not set
# CONFIG_PACKAGE_ruby-xmlrpc is not set
CONFIG_PACKAGE_ruby-yaml=y
# CONFIG_PACKAGE_ruby-zlib 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_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-full 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-node is not set
# CONFIG_PACKAGE_libupm-a110x is not set
# CONFIG_PACKAGE_libupm-a110x-node is not set
# CONFIG_PACKAGE_libupm-abp is not set
# CONFIG_PACKAGE_libupm-abp-node is not set
# CONFIG_PACKAGE_libupm-ad8232 is not set
# CONFIG_PACKAGE_libupm-ad8232-node is not set
# CONFIG_PACKAGE_libupm-adafruitms1438 is not set
# CONFIG_PACKAGE_libupm-adafruitms1438-node is not set
# CONFIG_PACKAGE_libupm-adafruitss is not set
# CONFIG_PACKAGE_libupm-adafruitss-node is not set
# CONFIG_PACKAGE_libupm-adc121c021 is not set
# CONFIG_PACKAGE_libupm-adc121c021-node is not set
# CONFIG_PACKAGE_libupm-adis16448 is not set
# CONFIG_PACKAGE_libupm-adis16448-node is not set
# CONFIG_PACKAGE_libupm-ads1x15 is not set
# CONFIG_PACKAGE_libupm-ads1x15-node is not set
# CONFIG_PACKAGE_libupm-adxl335 is not set
# CONFIG_PACKAGE_libupm-adxl335-node is not set
# CONFIG_PACKAGE_libupm-adxl345 is not set
# CONFIG_PACKAGE_libupm-adxl345-node is not set
# CONFIG_PACKAGE_libupm-adxrs610 is not set
# CONFIG_PACKAGE_libupm-adxrs610-node is not set
# CONFIG_PACKAGE_libupm-am2315 is not set
# CONFIG_PACKAGE_libupm-am2315-node is not set
# CONFIG_PACKAGE_libupm-apa102 is not set
# CONFIG_PACKAGE_libupm-apa102-node is not set
# CONFIG_PACKAGE_libupm-apds9002 is not set
# CONFIG_PACKAGE_libupm-apds9002-node is not set
# CONFIG_PACKAGE_libupm-apds9930 is not set
# CONFIG_PACKAGE_libupm-apds9930-node is not set
# CONFIG_PACKAGE_libupm-at42qt1070 is not set
# CONFIG_PACKAGE_libupm-at42qt1070-node is not set
# CONFIG_PACKAGE_libupm-bh1749 is not set
# CONFIG_PACKAGE_libupm-bh1749-node is not set
# CONFIG_PACKAGE_libupm-bh1750 is not set
# CONFIG_PACKAGE_libupm-bh1750-node is not set
# CONFIG_PACKAGE_libupm-bh1792 is not set
# CONFIG_PACKAGE_libupm-bh1792-node is not set
# CONFIG_PACKAGE_libupm-biss0001 is not set
# CONFIG_PACKAGE_libupm-biss0001-node is not set
# CONFIG_PACKAGE_libupm-bma220 is not set
# CONFIG_PACKAGE_libupm-bma220-node is not set
# CONFIG_PACKAGE_libupm-bma250e is not set
# CONFIG_PACKAGE_libupm-bma250e-node is not set
# CONFIG_PACKAGE_libupm-bmg160 is not set
# CONFIG_PACKAGE_libupm-bmg160-node is not set
# CONFIG_PACKAGE_libupm-bmi160 is not set
# CONFIG_PACKAGE_libupm-bmi160-node is not set
# CONFIG_PACKAGE_libupm-bmm150 is not set
# CONFIG_PACKAGE_libupm-bmm150-node is not set
# CONFIG_PACKAGE_libupm-bmp280 is not set
# CONFIG_PACKAGE_libupm-bmp280-node is not set
# CONFIG_PACKAGE_libupm-bmpx8x is not set
# CONFIG_PACKAGE_libupm-bmpx8x-node is not set
# CONFIG_PACKAGE_libupm-bmx055 is not set
# CONFIG_PACKAGE_libupm-bmx055-node is not set
# CONFIG_PACKAGE_libupm-bno055 is not set
# CONFIG_PACKAGE_libupm-bno055-node is not set
# CONFIG_PACKAGE_libupm-button is not set
# CONFIG_PACKAGE_libupm-button-node is not set
# CONFIG_PACKAGE_libupm-buzzer is not set
# CONFIG_PACKAGE_libupm-buzzer-node is not set
# CONFIG_PACKAGE_libupm-cjq4435 is not set
# CONFIG_PACKAGE_libupm-cjq4435-node is not set
# CONFIG_PACKAGE_libupm-collision is not set
# CONFIG_PACKAGE_libupm-collision-node is not set
# CONFIG_PACKAGE_libupm-curieimu is not set
# CONFIG_PACKAGE_libupm-curieimu-node is not set
# CONFIG_PACKAGE_libupm-cwlsxxa is not set
# CONFIG_PACKAGE_libupm-cwlsxxa-node is not set
# CONFIG_PACKAGE_libupm-dfrec is not set
# CONFIG_PACKAGE_libupm-dfrec-node is not set
# CONFIG_PACKAGE_libupm-dfrorp is not set
# CONFIG_PACKAGE_libupm-dfrorp-node is not set
# CONFIG_PACKAGE_libupm-dfrph is not set
# CONFIG_PACKAGE_libupm-dfrph-node is not set
# CONFIG_PACKAGE_libupm-ds1307 is not set
# CONFIG_PACKAGE_libupm-ds1307-node is not set
# CONFIG_PACKAGE_libupm-ds1808lc is not set
# CONFIG_PACKAGE_libupm-ds1808lc-node is not set
# CONFIG_PACKAGE_libupm-ds18b20 is not set
# CONFIG_PACKAGE_libupm-ds18b20-node is not set
# CONFIG_PACKAGE_libupm-ds2413 is not set
# CONFIG_PACKAGE_libupm-ds2413-node is not set
# CONFIG_PACKAGE_libupm-ecezo is not set
# CONFIG_PACKAGE_libupm-ecezo-node is not set
# CONFIG_PACKAGE_libupm-ecs1030 is not set
# CONFIG_PACKAGE_libupm-ecs1030-node is not set
# CONFIG_PACKAGE_libupm-ehr is not set
# CONFIG_PACKAGE_libupm-ehr-node is not set
# CONFIG_PACKAGE_libupm-eldriver is not set
# CONFIG_PACKAGE_libupm-eldriver-node is not set
# CONFIG_PACKAGE_libupm-electromagnet is not set
# CONFIG_PACKAGE_libupm-electromagnet-node is not set
# CONFIG_PACKAGE_libupm-emg is not set
# CONFIG_PACKAGE_libupm-emg-node is not set
# CONFIG_PACKAGE_libupm-enc03r is not set
# CONFIG_PACKAGE_libupm-enc03r-node is not set
# CONFIG_PACKAGE_libupm-flex is not set
# CONFIG_PACKAGE_libupm-flex-node is not set
# CONFIG_PACKAGE_libupm-gas is not set
# CONFIG_PACKAGE_libupm-gas-node is not set
# CONFIG_PACKAGE_libupm-gp2y0a is not set
# CONFIG_PACKAGE_libupm-gp2y0a-node is not set
# CONFIG_PACKAGE_libupm-gprs is not set
# CONFIG_PACKAGE_libupm-gprs-node is not set
# CONFIG_PACKAGE_libupm-gsr is not set
# CONFIG_PACKAGE_libupm-gsr-node is not set
# CONFIG_PACKAGE_libupm-guvas12d is not set
# CONFIG_PACKAGE_libupm-guvas12d-node is not set
# CONFIG_PACKAGE_libupm-h3lis331dl is not set
# CONFIG_PACKAGE_libupm-h3lis331dl-node is not set
# CONFIG_PACKAGE_libupm-h803x is not set
# CONFIG_PACKAGE_libupm-h803x-node is not set
# CONFIG_PACKAGE_libupm-hcsr04 is not set
# CONFIG_PACKAGE_libupm-hcsr04-node is not set
# CONFIG_PACKAGE_libupm-hdc1000 is not set
# CONFIG_PACKAGE_libupm-hdc1000-node is not set
# CONFIG_PACKAGE_libupm-hdxxvxta is not set
# CONFIG_PACKAGE_libupm-hdxxvxta-node is not set
# CONFIG_PACKAGE_libupm-hka5 is not set
# CONFIG_PACKAGE_libupm-hka5-node is not set
# CONFIG_PACKAGE_libupm-hlg150h is not set
# CONFIG_PACKAGE_libupm-hlg150h-node is not set
# CONFIG_PACKAGE_libupm-hm11 is not set
# CONFIG_PACKAGE_libupm-hm11-node is not set
# CONFIG_PACKAGE_libupm-hmc5883l is not set
# CONFIG_PACKAGE_libupm-hmc5883l-node is not set
# CONFIG_PACKAGE_libupm-hmtrp is not set
# CONFIG_PACKAGE_libupm-hmtrp-node is not set
# CONFIG_PACKAGE_libupm-hp20x is not set
# CONFIG_PACKAGE_libupm-hp20x-node is not set
# CONFIG_PACKAGE_libupm-ht9170 is not set
# CONFIG_PACKAGE_libupm-ht9170-node is not set
# CONFIG_PACKAGE_libupm-htu21d is not set
# CONFIG_PACKAGE_libupm-htu21d-node is not set
# CONFIG_PACKAGE_libupm-hwxpxx is not set
# CONFIG_PACKAGE_libupm-hwxpxx-node is not set
# CONFIG_PACKAGE_libupm-hx711 is not set
# CONFIG_PACKAGE_libupm-hx711-node is not set
# CONFIG_PACKAGE_libupm-ili9341 is not set
# CONFIG_PACKAGE_libupm-ili9341-node is not set
# CONFIG_PACKAGE_libupm-ims is not set
# CONFIG_PACKAGE_libupm-ims-node is not set
# CONFIG_PACKAGE_libupm-ina132 is not set
# CONFIG_PACKAGE_libupm-ina132-node is not set
# CONFIG_PACKAGE_libupm-interfaces is not set
# CONFIG_PACKAGE_libupm-interfaces-node is not set
# CONFIG_PACKAGE_libupm-isd1820 is not set
# CONFIG_PACKAGE_libupm-isd1820-node is not set
# CONFIG_PACKAGE_libupm-itg3200 is not set
# CONFIG_PACKAGE_libupm-itg3200-node is not set
# CONFIG_PACKAGE_libupm-jhd1313m1 is not set
# CONFIG_PACKAGE_libupm-jhd1313m1-node is not set
# CONFIG_PACKAGE_libupm-joystick12 is not set
# CONFIG_PACKAGE_libupm-joystick12-node is not set
# CONFIG_PACKAGE_libupm-kx122 is not set
# CONFIG_PACKAGE_libupm-kx122-node is not set
# CONFIG_PACKAGE_libupm-kxcjk1013 is not set
# CONFIG_PACKAGE_libupm-kxcjk1013-node is not set
# CONFIG_PACKAGE_libupm-kxtj3 is not set
# CONFIG_PACKAGE_libupm-kxtj3-node is not set
# CONFIG_PACKAGE_libupm-l298 is not set
# CONFIG_PACKAGE_libupm-l298-node is not set
# CONFIG_PACKAGE_libupm-l3gd20 is not set
# CONFIG_PACKAGE_libupm-l3gd20-node is not set
# CONFIG_PACKAGE_libupm-lcd is not set
# CONFIG_PACKAGE_libupm-lcd-node is not set
# CONFIG_PACKAGE_libupm-lcdks is not set
# CONFIG_PACKAGE_libupm-lcdks-node is not set
# CONFIG_PACKAGE_libupm-lcm1602 is not set
# CONFIG_PACKAGE_libupm-lcm1602-node is not set
# CONFIG_PACKAGE_libupm-ldt0028 is not set
# CONFIG_PACKAGE_libupm-ldt0028-node is not set
# CONFIG_PACKAGE_libupm-led is not set
# CONFIG_PACKAGE_libupm-led-node is not set
# CONFIG_PACKAGE_libupm-lidarlitev3 is not set
# CONFIG_PACKAGE_libupm-lidarlitev3-node is not set
# CONFIG_PACKAGE_libupm-light is not set
# CONFIG_PACKAGE_libupm-light-node is not set
# CONFIG_PACKAGE_libupm-linefinder is not set
# CONFIG_PACKAGE_libupm-linefinder-node is not set
# CONFIG_PACKAGE_libupm-lis2ds12 is not set
# CONFIG_PACKAGE_libupm-lis2ds12-node is not set
# CONFIG_PACKAGE_libupm-lis3dh is not set
# CONFIG_PACKAGE_libupm-lis3dh-node is not set
# CONFIG_PACKAGE_libupm-lm35 is not set
# CONFIG_PACKAGE_libupm-lm35-node is not set
# CONFIG_PACKAGE_libupm-lol is not set
# CONFIG_PACKAGE_libupm-lol-node is not set
# CONFIG_PACKAGE_libupm-loudness is not set
# CONFIG_PACKAGE_libupm-loudness-node is not set
# CONFIG_PACKAGE_libupm-lp8860 is not set
# CONFIG_PACKAGE_libupm-lp8860-node is not set
# CONFIG_PACKAGE_libupm-lpd8806 is not set
# CONFIG_PACKAGE_libupm-lpd8806-node is not set
# CONFIG_PACKAGE_libupm-lsm303agr is not set
# CONFIG_PACKAGE_libupm-lsm303agr-node is not set
# CONFIG_PACKAGE_libupm-lsm303d is not set
# CONFIG_PACKAGE_libupm-lsm303d-node is not set
# CONFIG_PACKAGE_libupm-lsm303dlh is not set
# CONFIG_PACKAGE_libupm-lsm303dlh-node is not set
# CONFIG_PACKAGE_libupm-lsm6ds3h is not set
# CONFIG_PACKAGE_libupm-lsm6ds3h-node is not set
# CONFIG_PACKAGE_libupm-lsm6dsl is not set
# CONFIG_PACKAGE_libupm-lsm6dsl-node is not set
# CONFIG_PACKAGE_libupm-lsm9ds0 is not set
# CONFIG_PACKAGE_libupm-lsm9ds0-node is not set
# CONFIG_PACKAGE_libupm-m24lr64e is not set
# CONFIG_PACKAGE_libupm-m24lr64e-node is not set
# CONFIG_PACKAGE_libupm-mag3110 is not set
# CONFIG_PACKAGE_libupm-mag3110-node is not set
# CONFIG_PACKAGE_libupm-max30100 is not set
# CONFIG_PACKAGE_libupm-max30100-node is not set
# CONFIG_PACKAGE_libupm-max31723 is not set
# CONFIG_PACKAGE_libupm-max31723-node is not set
# CONFIG_PACKAGE_libupm-max31855 is not set
# CONFIG_PACKAGE_libupm-max31855-node is not set
# CONFIG_PACKAGE_libupm-max44000 is not set
# CONFIG_PACKAGE_libupm-max44000-node is not set
# CONFIG_PACKAGE_libupm-max44009 is not set
# CONFIG_PACKAGE_libupm-max44009-node is not set
# CONFIG_PACKAGE_libupm-max5487 is not set
# CONFIG_PACKAGE_libupm-max5487-node is not set
# CONFIG_PACKAGE_libupm-maxds3231m is not set
# CONFIG_PACKAGE_libupm-maxds3231m-node is not set
# CONFIG_PACKAGE_libupm-maxsonarez is not set
# CONFIG_PACKAGE_libupm-maxsonarez-node is not set
# CONFIG_PACKAGE_libupm-mb704x is not set
# CONFIG_PACKAGE_libupm-mb704x-node is not set
# CONFIG_PACKAGE_libupm-mcp2515 is not set
# CONFIG_PACKAGE_libupm-mcp2515-node is not set
# CONFIG_PACKAGE_libupm-mcp9808 is not set
# CONFIG_PACKAGE_libupm-mcp9808-node is not set
# CONFIG_PACKAGE_libupm-md is not set
# CONFIG_PACKAGE_libupm-md-node is not set
# CONFIG_PACKAGE_libupm-mg811 is not set
# CONFIG_PACKAGE_libupm-mg811-node is not set
# CONFIG_PACKAGE_libupm-mhz16 is not set
# CONFIG_PACKAGE_libupm-mhz16-node is not set
# CONFIG_PACKAGE_libupm-mic is not set
# CONFIG_PACKAGE_libupm-mic-node is not set
# CONFIG_PACKAGE_libupm-micsv89 is not set
# CONFIG_PACKAGE_libupm-micsv89-node is not set
# CONFIG_PACKAGE_libupm-mlx90614 is not set
# CONFIG_PACKAGE_libupm-mlx90614-node is not set
# CONFIG_PACKAGE_libupm-mma7361 is not set
# CONFIG_PACKAGE_libupm-mma7361-node is not set
# CONFIG_PACKAGE_libupm-mma7455 is not set
# CONFIG_PACKAGE_libupm-mma7455-node is not set
# CONFIG_PACKAGE_libupm-mma7660 is not set
# CONFIG_PACKAGE_libupm-mma7660-node is not set
# CONFIG_PACKAGE_libupm-mma8x5x is not set
# CONFIG_PACKAGE_libupm-mma8x5x-node is not set
# CONFIG_PACKAGE_libupm-mmc35240 is not set
# CONFIG_PACKAGE_libupm-mmc35240-node is not set
# CONFIG_PACKAGE_libupm-moisture is not set
# CONFIG_PACKAGE_libupm-moisture-node is not set
# CONFIG_PACKAGE_libupm-mpl3115a2 is not set
# CONFIG_PACKAGE_libupm-mpl3115a2-node is not set
# CONFIG_PACKAGE_libupm-mpr121 is not set
# CONFIG_PACKAGE_libupm-mpr121-node is not set
# CONFIG_PACKAGE_libupm-mpu9150 is not set
# CONFIG_PACKAGE_libupm-mpu9150-node is not set
# CONFIG_PACKAGE_libupm-mq303a is not set
# CONFIG_PACKAGE_libupm-mq303a-node is not set
# CONFIG_PACKAGE_libupm-ms5611 is not set
# CONFIG_PACKAGE_libupm-ms5611-node is not set
# CONFIG_PACKAGE_libupm-ms5803 is not set
# CONFIG_PACKAGE_libupm-ms5803-node is not set
# CONFIG_PACKAGE_libupm-my9221 is not set
# CONFIG_PACKAGE_libupm-my9221-node is not set
# CONFIG_PACKAGE_libupm-nlgpio16 is not set
# CONFIG_PACKAGE_libupm-nlgpio16-node is not set
# CONFIG_PACKAGE_libupm-nmea_gps is not set
# CONFIG_PACKAGE_libupm-nmea_gps-node is not set
# CONFIG_PACKAGE_libupm-nrf24l01 is not set
# CONFIG_PACKAGE_libupm-nrf24l01-node is not set
# CONFIG_PACKAGE_libupm-nrf8001 is not set
# CONFIG_PACKAGE_libupm-nrf8001-node is not set
# CONFIG_PACKAGE_libupm-nunchuck is not set
# CONFIG_PACKAGE_libupm-nunchuck-node is not set
# CONFIG_PACKAGE_libupm-o2 is not set
# CONFIG_PACKAGE_libupm-o2-node is not set
# CONFIG_PACKAGE_libupm-otp538u is not set
# CONFIG_PACKAGE_libupm-otp538u-node is not set
# CONFIG_PACKAGE_libupm-ozw is not set
# CONFIG_PACKAGE_libupm-ozw-node is not set
# CONFIG_PACKAGE_libupm-p9813 is not set
# CONFIG_PACKAGE_libupm-p9813-node is not set
# CONFIG_PACKAGE_libupm-pca9685 is not set
# CONFIG_PACKAGE_libupm-pca9685-node is not set
# CONFIG_PACKAGE_libupm-pn532 is not set
# CONFIG_PACKAGE_libupm-pn532-node is not set
# CONFIG_PACKAGE_libupm-ppd42ns is not set
# CONFIG_PACKAGE_libupm-ppd42ns-node is not set
# CONFIG_PACKAGE_libupm-pulsensor is not set
# CONFIG_PACKAGE_libupm-pulsensor-node is not set
# CONFIG_PACKAGE_libupm-relay is not set
# CONFIG_PACKAGE_libupm-relay-node is not set
# CONFIG_PACKAGE_libupm-rf22 is not set
# CONFIG_PACKAGE_libupm-rf22-node is not set
# CONFIG_PACKAGE_libupm-rfr359f is not set
# CONFIG_PACKAGE_libupm-rfr359f-node is not set
# CONFIG_PACKAGE_libupm-rgbringcoder is not set
# CONFIG_PACKAGE_libupm-rgbringcoder-node is not set
# CONFIG_PACKAGE_libupm-rhusb is not set
# CONFIG_PACKAGE_libupm-rhusb-node is not set
# CONFIG_PACKAGE_libupm-rn2903 is not set
# CONFIG_PACKAGE_libupm-rn2903-node is not set
# CONFIG_PACKAGE_libupm-rotary is not set
# CONFIG_PACKAGE_libupm-rotary-node is not set
# CONFIG_PACKAGE_libupm-rotaryencoder is not set
# CONFIG_PACKAGE_libupm-rotaryencoder-node is not set
# CONFIG_PACKAGE_libupm-rpr220 is not set
# CONFIG_PACKAGE_libupm-rpr220-node is not set
# CONFIG_PACKAGE_libupm-rsc is not set
# CONFIG_PACKAGE_libupm-rsc-node is not set
# CONFIG_PACKAGE_libupm-scam is not set
# CONFIG_PACKAGE_libupm-scam-node is not set
# CONFIG_PACKAGE_libupm-sensortemplate is not set
# CONFIG_PACKAGE_libupm-sensortemplate-node is not set
# CONFIG_PACKAGE_libupm-servo is not set
# CONFIG_PACKAGE_libupm-servo-node is not set
# CONFIG_PACKAGE_libupm-sht1x is not set
# CONFIG_PACKAGE_libupm-sht1x-node is not set
# CONFIG_PACKAGE_libupm-si1132 is not set
# CONFIG_PACKAGE_libupm-si1132-node is not set
# CONFIG_PACKAGE_libupm-si114x is not set
# CONFIG_PACKAGE_libupm-si114x-node is not set
# CONFIG_PACKAGE_libupm-si7005 is not set
# CONFIG_PACKAGE_libupm-si7005-node is not set
# CONFIG_PACKAGE_libupm-slide is not set
# CONFIG_PACKAGE_libupm-slide-node is not set
# CONFIG_PACKAGE_libupm-sm130 is not set
# CONFIG_PACKAGE_libupm-sm130-node is not set
# CONFIG_PACKAGE_libupm-smartdrive is not set
# CONFIG_PACKAGE_libupm-smartdrive-node is not set
# CONFIG_PACKAGE_libupm-speaker is not set
# CONFIG_PACKAGE_libupm-speaker-node is not set
# CONFIG_PACKAGE_libupm-ssd1351 is not set
# CONFIG_PACKAGE_libupm-ssd1351-node is not set
# CONFIG_PACKAGE_libupm-st7735 is not set
# CONFIG_PACKAGE_libupm-st7735-node is not set
# CONFIG_PACKAGE_libupm-stepmotor is not set
# CONFIG_PACKAGE_libupm-stepmotor-node is not set
# CONFIG_PACKAGE_libupm-sx1276 is not set
# CONFIG_PACKAGE_libupm-sx1276-node is not set
# CONFIG_PACKAGE_libupm-sx6119 is not set
# CONFIG_PACKAGE_libupm-sx6119-node is not set
# CONFIG_PACKAGE_libupm-t3311 is not set
# CONFIG_PACKAGE_libupm-t3311-node is not set
# CONFIG_PACKAGE_libupm-t6713 is not set
# CONFIG_PACKAGE_libupm-t6713-node is not set
# CONFIG_PACKAGE_libupm-ta12200 is not set
# CONFIG_PACKAGE_libupm-ta12200-node is not set
# CONFIG_PACKAGE_libupm-tca9548a is not set
# CONFIG_PACKAGE_libupm-tca9548a-node is not set
# CONFIG_PACKAGE_libupm-tcs3414cs is not set
# CONFIG_PACKAGE_libupm-tcs3414cs-node is not set
# CONFIG_PACKAGE_libupm-tcs37727 is not set
# CONFIG_PACKAGE_libupm-tcs37727-node is not set
# CONFIG_PACKAGE_libupm-teams is not set
# CONFIG_PACKAGE_libupm-teams-node is not set
# CONFIG_PACKAGE_libupm-temperature is not set
# CONFIG_PACKAGE_libupm-temperature-node is not set
# CONFIG_PACKAGE_libupm-tex00 is not set
# CONFIG_PACKAGE_libupm-tex00-node is not set
# CONFIG_PACKAGE_libupm-th02 is not set
# CONFIG_PACKAGE_libupm-th02-node is not set
# CONFIG_PACKAGE_libupm-tm1637 is not set
# CONFIG_PACKAGE_libupm-tm1637-node is not set
# CONFIG_PACKAGE_libupm-tmp006 is not set
# CONFIG_PACKAGE_libupm-tmp006-node is not set
# CONFIG_PACKAGE_libupm-tsl2561 is not set
# CONFIG_PACKAGE_libupm-tsl2561-node is not set
# CONFIG_PACKAGE_libupm-ttp223 is not set
# CONFIG_PACKAGE_libupm-ttp223-node is not set
# CONFIG_PACKAGE_libupm-uartat is not set
# CONFIG_PACKAGE_libupm-uartat-node is not set
# CONFIG_PACKAGE_libupm-uln200xa is not set
# CONFIG_PACKAGE_libupm-uln200xa-node is not set
# CONFIG_PACKAGE_libupm-ultrasonic is not set
# CONFIG_PACKAGE_libupm-ultrasonic-node is not set
# CONFIG_PACKAGE_libupm-urm37 is not set
# CONFIG_PACKAGE_libupm-urm37-node is not set
# CONFIG_PACKAGE_libupm-utilities is not set
# CONFIG_PACKAGE_libupm-utilities-node is not set
# CONFIG_PACKAGE_libupm-vcap is not set
# CONFIG_PACKAGE_libupm-vcap-node is not set
# CONFIG_PACKAGE_libupm-vdiv is not set
# CONFIG_PACKAGE_libupm-vdiv-node is not set
# CONFIG_PACKAGE_libupm-veml6070 is not set
# CONFIG_PACKAGE_libupm-veml6070-node is not set
# CONFIG_PACKAGE_libupm-water is not set
# CONFIG_PACKAGE_libupm-water-node is not set
# CONFIG_PACKAGE_libupm-waterlevel is not set
# CONFIG_PACKAGE_libupm-waterlevel-node is not set
# CONFIG_PACKAGE_libupm-wfs is not set
# CONFIG_PACKAGE_libupm-wfs-node is not set
# CONFIG_PACKAGE_libupm-wheelencoder is not set
# CONFIG_PACKAGE_libupm-wheelencoder-node is not set
# CONFIG_PACKAGE_libupm-wt5001 is not set
# CONFIG_PACKAGE_libupm-wt5001-node is not set
# CONFIG_PACKAGE_libupm-xbee is not set
# CONFIG_PACKAGE_libupm-xbee-node is not set
# CONFIG_PACKAGE_libupm-yg1006 is not set
# CONFIG_PACKAGE_libupm-yg1006-node is not set
# CONFIG_PACKAGE_libupm-zfm20 is not set
# CONFIG_PACKAGE_libupm-zfm20-node is not set
# end of IoT
#
# Languages
#
CONFIG_PACKAGE_libyaml=y
# 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
# end of Qt5
#
# SSL
#
# CONFIG_PACKAGE_libgnutls is not set
CONFIG_PACKAGE_libmbedtls=y
# CONFIG_LIBMBEDTLS_DEBUG_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_OPENSSL_WITH_GOST is not set
CONFIG_PACKAGE_libopenssl-conf=y
# CONFIG_PACKAGE_libopenssl-devcrypto is not set
# CONFIG_PACKAGE_libopenssl1.1 is not set
# CONFIG_PACKAGE_libpolarssl is not set
# CONFIG_PACKAGE_libwolfssl is not set
# end of SSL
#
# Sound
#
# 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_libplistcxx is not set
# CONFIG_PACKAGE_libusbmuxd is not set
# end of libimobiledevice
# 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 is not set
# CONFIG_boost-context-exclude is not set
# CONFIG_boost-coroutine-exclude is not set
# CONFIG_boost-fiber-exclude 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_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_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_libbsd is not set
CONFIG_PACKAGE_libcap=y
CONFIG_PACKAGE_libcap-bin=y
CONFIG_PACKAGE_libcap-bin-capsh-shell="/bin/sh"
# CONFIG_PACKAGE_libcap-ng is not set
# CONFIG_PACKAGE_libcares 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_libcups is not set
CONFIG_PACKAGE_libcurl=y
#
# SSL support
#
CONFIG_LIBCURL_MBEDTLS=y
# CONFIG_LIBCURL_WOLFSSL is not set
# CONFIG_LIBCURL_OPENSSL is not set
# 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_UNIX_SOCKETS is not set
# CONFIG_LIBCURL_LIBCURL_OPTION is not set
# CONFIG_LIBCURL_VERBOSE is not set
# CONFIG_PACKAGE_libcxx is not set
# CONFIG_PACKAGE_libdaemon is not set
# CONFIG_PACKAGE_libdaq is not set
CONFIG_PACKAGE_libdb47=y
# 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_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 is not set
# 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_libevhtp is not set
# CONFIG_LIBEVHTP_BUILD_DEPENDS 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_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_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=y
# CONFIG_PACKAGE_libgnurl is not set
# CONFIG_PACKAGE_libgpg-error 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_libldns is not set
# CONFIG_PACKAGE_libleptonica is not set
# CONFIG_PACKAGE_libloragw is not set
CONFIG_PACKAGE_libltdl=y
CONFIG_PACKAGE_liblua=y
CONFIG_PACKAGE_liblua5.3=y
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_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_libowfat 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_libpcrecpp 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_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=y
# 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_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_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_libtiffxx is not set
# CONFIG_PACKAGE_libtins is not set
# CONFIG_PACKAGE_libtirpc is not set
# CONFIG_PACKAGE_libtorrent 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_libuclient=y
# CONFIG_PACKAGE_libudev-fbsd is not set
# CONFIG_PACKAGE_libudns is not set
# 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_libwebcam 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_libwslay 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=y
# 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_measurement-kit is not set
# CONFIG_MEASUREMENT_KIT_BUILD_DEPENDS is not set
# CONFIG_PACKAGE_minizip is not set
# CONFIG_PACKAGE_mtdev is not set
# CONFIG_PACKAGE_musl-fts is not set
# CONFIG_PACKAGE_mxml is not set
# CONFIG_PACKAGE_nacl is not set
# CONFIG_PACKAGE_nlohmannjson is not set
# CONFIG_PACKAGE_nspr is not set
# CONFIG_PACKAGE_oniguruma is not set
# CONFIG_PACKAGE_open-isns 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_spice-protocol is not set
CONFIG_PACKAGE_terminfo=y
# CONFIG_PACKAGE_tinycdb is not set
CONFIG_PACKAGE_uclibcxx=y
# 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 is not set
# 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-freifunk is not set
# CONFIG_PACKAGE_luci-mod-freifunk-community is not set
# CONFIG_PACKAGE_luci-mod-rpc is not set
# end of 2. Modules
#
# 3. Applications
#
# CONFIG_PACKAGE_luci-app-accesscontrol is not set
# CONFIG_PACKAGE_luci-app-adblock is not set
CONFIG_PACKAGE_luci-app-adbyby-plus=y
# CONFIG_PACKAGE_luci-app-adguardhome is not set
# 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 is not set
# 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-dump1090 is not set
# CONFIG_PACKAGE_luci-app-dynapoint is not set
# CONFIG_PACKAGE_luci-app-e2guardian is not set
# CONFIG_PACKAGE_luci-app-familycloud is not set
CONFIG_PACKAGE_luci-app-fileassistant=y
# CONFIG_PACKAGE_luci-app-filebrowser is not set
CONFIG_PACKAGE_luci-app-filetransfer=y
CONFIG_PACKAGE_luci-app-firewall=y
CONFIG_PACKAGE_luci-app-flowoffload=y
# CONFIG_PACKAGE_luci-app-freifunk-diagnostics is not set
# CONFIG_PACKAGE_luci-app-freifunk-policyrouting is not set
# CONFIG_PACKAGE_luci-app-freifunk-widgets is not set
# 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=y
# CONFIG_PACKAGE_luci-app-haproxy-tcp is not set
CONFIG_PACKAGE_luci-app-hd-idle=y
# 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-meshwizard is not set
# CONFIG_PACKAGE_luci-app-minidlna is not set
# CONFIG_PACKAGE_luci-app-mjpg-streamer is not set
# CONFIG_PACKAGE_luci-app-mtwifi 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 is not set
# 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=y
# 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_Shadowsocks=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Server is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR_Server is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_V2ray is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_Plus is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_GO is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Brook is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_NaiveProxy is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_kcptun is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_haproxy=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ChinaDNS_NG is not set
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_dns2socks=y
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_v2ray-plugin is not set
# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_simple-obfs is not set
# 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-qbittorrent is not set
# 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-sfe 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-smartdns=y
# 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_Xray=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Trojan is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Redsocks2 is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_NaiveProxy is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_V2ray is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Trojan-go is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Kcptun is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_V2ray_plugin is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Server is not set
# 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=y
CONFIG_PACKAGE_luci-app-ttyd=y
# 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_UnblockNeteaseMusic_Go is not set
# CONFIG_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=y
# CONFIG_PACKAGE_luci-app-watchcat is not set
CONFIG_PACKAGE_luci-app-webadmin=y
CONFIG_PACKAGE_luci-app-wifischedule=y
# 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-freifunk-generic is not set
CONFIG_PACKAGE_luci-theme-material=y
# 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-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-docker is not set
# 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-px5g is not set
# end of 6. Libraries
#
# 9. Freifunk
#
# CONFIG_PACKAGE_freifunk-common is not set
# CONFIG_PACKAGE_freifunk-firewall is not set
# CONFIG_PACKAGE_freifunk-policyrouting is not set
# CONFIG_PACKAGE_freifunk-watchdog is not set
# CONFIG_PACKAGE_meshwizard is not set
# end of 9. Freifunk
CONFIG_PACKAGE_default-settings=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-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-filetransfer-zh-cn=y
# 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-flowoffload-zh-cn=y
CONFIG_PACKAGE_luci-i18n-guest-wifi-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-hd-idle-ca is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-cs is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-de is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-el is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-en is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-es is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-fr is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-he is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-hu is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-it is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-ja is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-ms is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-no is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-pl is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-pt is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-pt-br is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-ro is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-ru is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-sk is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-sv is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-tr is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-uk is not set
# CONFIG_PACKAGE_luci-i18n-hd-idle-vi is not set
CONFIG_PACKAGE_luci-i18n-hd-idle-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-hd-idle-zh-tw 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-smartdns-zh-cn=y
CONFIG_PACKAGE_luci-i18n-ssr-plus-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-ssr-plus-zh_Hans is not set
# CONFIG_PACKAGE_luci-i18n-travelmate-ja is not set
# CONFIG_PACKAGE_luci-i18n-travelmate-pt-br is not set
# CONFIG_PACKAGE_luci-i18n-travelmate-ru is not set
CONFIG_PACKAGE_luci-i18n-ttyd-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-vsftpd-zh-cn=y
CONFIG_PACKAGE_luci-i18n-webadmin-zh-cn=y
# CONFIG_PACKAGE_luci-i18n-wifischedule-it is not set
# CONFIG_PACKAGE_luci-i18n-wifischedule-ja is not set
# CONFIG_PACKAGE_luci-i18n-wifischedule-pt-br is not set
# CONFIG_PACKAGE_luci-i18n-wifischedule-ru is not set
# CONFIG_PACKAGE_luci-i18n-wifischedule-sv is not set
CONFIG_PACKAGE_luci-i18n-wifischedule-zh-cn=y
CONFIG_PACKAGE_luci-i18n-zerotier-zh-cn=y
# end of LuCI
#
# Mail
#
# CONFIG_PACKAGE_alpine is not set
# CONFIG_PACKAGE_alpine-nossl is not set
# CONFIG_PACKAGE_bogofilter is not set
# CONFIG_PACKAGE_clamsmtp 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_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_ssmtp is not set
# end of Mail
#
# Multimedia
#
#
# Streaming
#
# CONFIG_PACKAGE_oggfwd is not set
# end of Streaming
# 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=y
CONFIG_VSFTPD_USE_UCI_SCRIPTS=y
# CONFIG_PACKAGE_vsftpd-tls is not set
CONFIG_PACKAGE_wget=y
# CONFIG_PACKAGE_wget-nossl is not set
# 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=y
# 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
# 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_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_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-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
#
# NeteaseMusic
#
# CONFIG_PACKAGE_UnblockNeteaseMusic is not set
# CONFIG_PACKAGE_UnblockNeteaseMusicGo is not set
CONFIG_UnblockNeteaseMusicGo_INCLUDE_GOPROXY=y
# end of NeteaseMusic
#
# 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
# 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 is not set
# CONFIG_PACKAGE_v2ray-plugin is not set
CONFIG_v2ray-plugin_INCLUDE_GOPROXY=y
# end of Project V
#
# Project X
#
CONFIG_PACKAGE_xray=y
#
# Xray Configuration
#
# CONFIG_XRAY_COMPRESS_GOPROXY is not set
CONFIG_XRAY_EXCLUDE_ASSETS=y
CONFIG_XRAY_COMPRESS_UPX=y
# CONFIG_XRAY_COMPATIBILITY_MODE is not set
# end of Xray Configuration
# end of Project X
#
# 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 is not set
# CONFIG_PACKAGE_tcpproxy 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
# 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_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_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-nossl is not set
# CONFIG_PACKAGE_openvpn-openssl 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_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 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_umbim is not set
# CONFIG_PACKAGE_uqmi is not set
# end of WWAN
#
# Web Servers/Proxies
#
# CONFIG_PACKAGE_apache is not set
# CONFIG_PACKAGE_cgi-io is not set
# CONFIG_PACKAGE_clamav is not set
# CONFIG_PACKAGE_e2guardian is not set
# CONFIG_PACKAGE_etesync-server is not set
# CONFIG_PACKAGE_freshclam is not set
# CONFIG_PACKAGE_frpc is not set
# CONFIG_PACKAGE_frps is not set
CONFIG_PACKAGE_haproxy=y
# CONFIG_PACKAGE_halog is not set
# CONFIG_PACKAGE_haproxy-nossl is not set
# CONFIG_PACKAGE_kcptun-client is not set
# CONFIG_PACKAGE_kcptun-server is not set
# CONFIG_PACKAGE_lighttpd is not set
# CONFIG_PACKAGE_naiveproxy is not set
# CONFIG_PACKAGE_nginx is not set
CONFIG_NGINX_NOPCRE=y
# CONFIG_PACKAGE_nginx-all-module is not set
# CONFIG_PACKAGE_nginx-mod-luci is not set
# CONFIG_PACKAGE_nginx-mod-luci-ssl 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_nginx-util is not set
CONFIG_PACKAGE_pdnsd-alt=y
# CONFIG_PACKAGE_polipo is not set
# CONFIG_PACKAGE_privoxy 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_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_kismet-client is not set
# CONFIG_PACKAGE_kismet-drone is not set
# CONFIG_PACKAGE_kismet-server 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=y
# 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=y
# CONFIG_PACKAGE_hostapd-mini is not set
# CONFIG_PACKAGE_hostapd-openssl is not set
# CONFIG_PACKAGE_hostapd-wolfssl 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_DRIVER_11W_SUPPORT=y
# CONFIG_WPA_ENABLE_WEP is not set
# CONFIG_PACKAGE_wpa-supplicant-basic is not set
# CONFIG_PACKAGE_wpa-supplicant-mesh-openssl is not set
# CONFIG_PACKAGE_wpa-supplicant-mesh-wolfssl is not set
# CONFIG_PACKAGE_wpa-supplicant-mini is not set
# CONFIG_PACKAGE_wpa-supplicant-openssl is not set
# CONFIG_PACKAGE_wpa-supplicant-p2p 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-mesh-openssl is not set
# CONFIG_PACKAGE_wpad-mesh-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_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_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_baidupcs-web is not set
# 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_brook 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 is not set
# 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_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_fakeidentd is not set
# CONFIG_PACKAGE_family-dns is not set
# CONFIG_PACKAGE_foolsm is not set
# CONFIG_PACKAGE_fping is not set
# CONFIG_PACKAGE_geth 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-ping6 is not set
# CONFIG_PACKAGE_iputils-tftpd is not set
# CONFIG_PACKAGE_iputils-tracepath is not set
# CONFIG_PACKAGE_iputils-tracepath6 is not set
# CONFIG_PACKAGE_iputils-traceroute6 is not set
# CONFIG_PACKAGE_ipvsadm is not set
CONFIG_PACKAGE_iw=y
# CONFIG_PACKAGE_iw-full is not set
# CONFIG_PACKAGE_jool 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_memcached is not set
CONFIG_PACKAGE_microsocks=y
# 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_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_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_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_oor 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_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_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_scapy is not set
# CONFIG_PACKAGE_sctp 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_shadowsocksr-libev is not set
CONFIG_PACKAGE_shadowsocksr-libev-alt=y
# CONFIG_PACKAGE_shadowsocksr-libev-server is not set
CONFIG_PACKAGE_shadowsocksr-libev-ssr-local=y
# 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=y
# CONFIG_PACKAGE_smartsnmpd 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_snmpd-static 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=y
# CONFIG_PACKAGE_ssocksd 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_tor is not set
# CONFIG_PACKAGE_tor-fw-helper is not set
# CONFIG_PACKAGE_tor-gencert is not set
# CONFIG_PACKAGE_tor-geoip is not set
# CONFIG_PACKAGE_tor-resolve is not set
# CONFIG_PACKAGE_trafficshaper is not set
CONFIG_PACKAGE_travelmate=y
# CONFIG_PACKAGE_trojan is not set
# CONFIG_PACKAGE_trojan-plus is not set
# 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_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_wol is not set
# CONFIG_PACKAGE_wpan-tools is not set
# CONFIG_PACKAGE_wwan is not set
# CONFIG_PACKAGE_xinetd is not set
# 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_madplay-alsa 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
#
#
# BigClown
#
# CONFIG_PACKAGE_bigclown-control-tool is not set
# CONFIG_PACKAGE_bigclown-firmware-tool 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_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=y
# CONFIG_PACKAGE_hdparm is not set
CONFIG_PACKAGE_lsblk=y
# CONFIG_PACKAGE_lvm2 is not set
# CONFIG_PACKAGE_mdadm is not set
CONFIG_PACKAGE_parted=y
# CONFIG_PACKAGE_partx-utils is not set
# CONFIG_PACKAGE_sfdisk is not set
# CONFIG_PACKAGE_sgdisk is not set
# CONFIG_PACKAGE_wipefs is not set
# end of Disc
#
# Editors
#
# CONFIG_PACKAGE_joe 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_gnutls-utils is not set
# CONFIG_PACKAGE_gpgv is not set
# CONFIG_PACKAGE_keyctl is not set
# CONFIG_PACKAGE_px5g-mbedtls is not set
# CONFIG_PACKAGE_px5g-standalone 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_f2fsck is not set
# CONFIG_PACKAGE_filefrag is not set
# CONFIG_PACKAGE_fstrim is not set
# CONFIG_PACKAGE_fuse-utils is not set
# CONFIG_PACKAGE_hfsfsck is not set
# CONFIG_PACKAGE_lsattr is not set
# CONFIG_PACKAGE_mkf2fs 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_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=y
# 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
# CONFIG_PACKAGE_acpid is not set
# CONFIG_PACKAGE_adb is not set
# CONFIG_PACKAGE_ap51-flash is not set
# CONFIG_PACKAGE_at 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_bonniexx 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_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_cmdpad is not set
# CONFIG_PACKAGE_coap-client is not set
# CONFIG_PACKAGE_collectd is not set
CONFIG_PACKAGE_coremark=y
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_csstidy is not set
# CONFIG_PACKAGE_ct-bugcheck 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_domoticz is not set
# CONFIG_PACKAGE_dropbearconvert is not set
# CONFIG_PACKAGE_dtc 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_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_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 is not set
# CONFIG_PACKAGE_lxc is not set
# CONFIG_PACKAGE_maccalc is not set
# CONFIG_PACKAGE_macchanger 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_netopeer2-cli is not set
# CONFIG_PACKAGE_netopeer2-keystored 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_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_pciutils is not set
# CONFIG_PACKAGE_pcsc-tools is not set
# CONFIG_PACKAGE_pcscd 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_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_sane-backends is not set
# CONFIG_PACKAGE_sane-daemon is not set
# CONFIG_PACKAGE_sane-frontends is not set
# CONFIG_PACKAGE_sed is not set
# CONFIG_PACKAGE_serdisplib-tools is not set
# CONFIG_PACKAGE_setserial is not set
# CONFIG_PACKAGE_shadow-utils is not set
CONFIG_PACKAGE_shellsync=y
# 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_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_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_uledd is not set
# CONFIG_PACKAGE_unshare is not set
# CONFIG_PACKAGE_usb-modeswitch is not set
# CONFIG_PACKAGE_usbreset is not set
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_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
# end of Utilities
#
# Xorg
#
#
# Font-Utils
#
# CONFIG_PACKAGE_fontconfig is not set
# end of Font-Utils
# end of Xorg
CONFIG_OVERRIDE_PKGS="smartdns"
|
fa258a16539f5fef0f74443cf7aa97f75caf41bc | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/Lean3Lib/init/data/repr_auto.lean | 8381870e78164a7d588f93f7f056a32e353716b5 | [] | 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 | 5,817 | 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
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.data.string.basic
import Mathlib.Lean3Lib.init.data.bool.basic
import Mathlib.Lean3Lib.init.data.subtype.basic
import Mathlib.Lean3Lib.init.data.unsigned.basic
import Mathlib.Lean3Lib.init.data.prod
import Mathlib.Lean3Lib.init.data.sum.basic
import Mathlib.Lean3Lib.init.data.nat.div
universes u l v
namespace Mathlib
/--
Implement `has_repr` if the output string is valid lean code that evaluates back to the original object.
If you just want to view the object as a string for a trace message, use `has_to_string`.
### Example:
```
#eval to_string "hello world"
-- [Lean] "hello world"
-- [Lean] "hello world"
#eval repr "hello world"
-- [Lean] "\"hello world\""
-- [Lean] "\"hello world\""
```
Reference: https://github.com/leanprover/lean/issues/1664
-/
class has_repr (α : Type u) where
repr : α → string
/-- `repr` is similar to `to_string` except that we should have the property `eval (repr x) = x` for most sensible datatypes.
Hence, `repr "hello"` has the value `"\"hello\""` not `"hello"`. -/
def repr {α : Type u} [has_repr α] : α → string := has_repr.repr
protected instance bool.has_repr : has_repr Bool :=
has_repr.mk
fun (b : Bool) =>
cond b
(string.str
(string.str string.empty (char.of_nat (bit0 (bit0 (bit1 (bit0 (bit1 (bit1 1))))))))
(char.of_nat (bit0 (bit0 (bit1 (bit0 (bit1 (bit1 1))))))))
(string.str
(string.str string.empty (char.of_nat (bit0 (bit1 (bit1 (bit0 (bit0 (bit1 1))))))))
(char.of_nat (bit0 (bit1 (bit1 (bit0 (bit0 (bit1 1))))))))
-- Remark: type class inference will not consider local instance `b` in the new elaborator
protected instance decidable.has_repr {p : Prop} : has_repr (Decidable p) :=
has_repr.mk
fun (b : Decidable p) =>
ite p
(string.str
(string.str string.empty (char.of_nat (bit0 (bit0 (bit1 (bit0 (bit1 (bit1 1))))))))
(char.of_nat (bit0 (bit0 (bit1 (bit0 (bit1 (bit1 1))))))))
(string.str
(string.str string.empty (char.of_nat (bit0 (bit1 (bit1 (bit0 (bit0 (bit1 1))))))))
(char.of_nat (bit0 (bit1 (bit1 (bit0 (bit0 (bit1 1))))))))
protected def list.repr_aux {α : Type u} [has_repr α] : Bool → List α → string := sorry
protected def list.repr {α : Type u} [has_repr α] : List α → string := sorry
protected instance list.has_repr {α : Type u} [has_repr α] : has_repr (List α) :=
has_repr.mk list.repr
protected instance unit.has_repr : has_repr Unit :=
has_repr.mk
fun (u : Unit) =>
string.str
(string.str
(string.str
(string.str string.empty (char.of_nat (bit1 (bit1 (bit0 (bit0 (bit1 (bit1 1))))))))
(char.of_nat (bit0 (bit0 (bit1 (bit0 (bit1 (bit1 1))))))))
(char.of_nat (bit1 (bit0 (bit0 (bit0 (bit0 (bit1 1))))))))
(char.of_nat (bit0 (bit1 (bit0 (bit0 (bit1 (bit1 1)))))))
protected instance option.has_repr {α : Type u} [has_repr α] : has_repr (Option α) :=
has_repr.mk fun (o : Option α) => sorry
protected instance sum.has_repr {α : Type u} {β : Type v} [has_repr α] [has_repr β] :
has_repr (α ⊕ β) :=
has_repr.mk fun (s : α ⊕ β) => sorry
protected instance prod.has_repr {α : Type u} {β : Type v} [has_repr α] [has_repr β] :
has_repr (α × β) :=
has_repr.mk fun (_x : α × β) => sorry
protected instance sigma.has_repr {α : Type u} {β : α → Type v} [has_repr α]
[s : (x : α) → has_repr (β x)] : has_repr (sigma β) :=
has_repr.mk fun (_x : sigma β) => sorry
protected instance subtype.has_repr {α : Type u} {p : α → Prop} [has_repr α] :
has_repr (Subtype p) :=
has_repr.mk fun (s : Subtype p) => repr (subtype.val s)
namespace nat
def digit_char (n : ℕ) : char := sorry
def digit_succ (base : ℕ) : List ℕ → List ℕ := sorry
def to_digits (base : ℕ) : ℕ → List ℕ := sorry
protected def repr (n : ℕ) : string :=
list.as_string (list.reverse (list.map digit_char (to_digits (bit0 (bit1 (bit0 1))) n)))
end nat
protected instance nat.has_repr : has_repr ℕ := has_repr.mk nat.repr
def hex_digit_repr (n : ℕ) : string := string.singleton (nat.digit_char n)
def char_to_hex (c : char) : string :=
let n : ℕ := char.to_nat c;
let d2 : ℕ := n / bit0 (bit0 (bit0 (bit0 1)));
let d1 : ℕ := n % bit0 (bit0 (bit0 (bit0 1)));
hex_digit_repr d2 ++ hex_digit_repr d1
def char.quote_core (c : char) : string := sorry
protected instance char.has_repr : has_repr char :=
has_repr.mk
fun (c : char) =>
string.str string.empty (char.of_nat (bit1 (bit1 (bit1 (bit0 (bit0 1)))))) ++
char.quote_core c ++
string.str string.empty (char.of_nat (bit1 (bit1 (bit1 (bit0 (bit0 1))))))
def string.quote_aux : List char → string := sorry
def string.quote (s : string) : string :=
ite (string.is_empty s = tt)
(string.str (string.str string.empty (char.of_nat (bit0 (bit1 (bit0 (bit0 (bit0 1)))))))
(char.of_nat (bit0 (bit1 (bit0 (bit0 (bit0 1)))))))
(string.str string.empty (char.of_nat (bit0 (bit1 (bit0 (bit0 (bit0 1)))))) ++
string.quote_aux (string.to_list s) ++
string.str string.empty (char.of_nat (bit0 (bit1 (bit0 (bit0 (bit0 1)))))))
protected instance string.has_repr : has_repr string := has_repr.mk string.quote
protected instance fin.has_repr (n : ℕ) : has_repr (fin n) :=
has_repr.mk fun (f : fin n) => repr (subtype.val f)
protected instance unsigned.has_repr : has_repr unsigned :=
has_repr.mk fun (n : unsigned) => repr (subtype.val n)
def char.repr (c : char) : string := repr c
end Mathlib |
10509dc3106946efa3408b41dde8e046a78cf515 | d9d511f37a523cd7659d6f573f990e2a0af93c6f | /archive/examples/prop_encodable.lean | 51c36b0464b59bf9f3b5585bff00dad98fe1ec3e | [
"Apache-2.0"
] | permissive | hikari0108/mathlib | b7ea2b7350497ab1a0b87a09d093ecc025a50dfa | a9e7d333b0cfd45f13a20f7b96b7d52e19fa2901 | refs/heads/master | 1,690,483,608,260 | 1,631,541,580,000 | 1,631,541,580,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 2,976 | lean | /-
Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
import data.W
/-!
# W types
The file `data/W.lean` shows that if `α` is an an encodable fintype and for every `a : α`,
`β a` is encodable, then `W β` is encodable.
As an example of how this can be used, we show that the type of propositional formulas with
variables labeled from an encodable type is encodable.
The strategy is to define a type of labels corresponding to the constructors.
From the definition (using `sum`, `unit`, and an encodable type), Lean can infer
that it is encodable. We then define a map from propositional formulas to the
corresponding `Wfin` type, and show that map has a left inverse.
We mark the auxiliary constructions `private`, since their only purpose is to
show encodability.
-/
/-- Propositional formulas with labels from `α`. -/
inductive prop_form (α : Type*)
| var : α → prop_form
| not : prop_form → prop_form
| and : prop_form → prop_form → prop_form
| or : prop_form → prop_form → prop_form
/-!
The next three functions make it easier to construct functions from a small
`fin`.
-/
section
variable {α : Type*}
/-- the trivial function out of `fin 0`. -/
def mk_fn0 : fin 0 → α
| ⟨_, h⟩ := absurd h dec_trivial
/-- defines a function out of `fin 1` -/
def mk_fn1 (t : α) : fin 1 → α
| ⟨0, _⟩ := t
| ⟨n+1, h⟩ := absurd h dec_trivial
/-- defines a function out of `fin 2` -/
def mk_fn2 (s t : α) : fin 2 → α
| ⟨0, _⟩ := s
| ⟨1, _⟩ := t
| ⟨n+2, h⟩ := absurd h dec_trivial
attribute [simp] mk_fn0 mk_fn1 mk_fn2
end
namespace prop_form
private def constructors (α : Type*) := α ⊕ unit ⊕ unit ⊕ unit
local notation `cvar` a := sum.inl a
local notation `cnot` := sum.inr (sum.inl unit.star)
local notation `cand` := sum.inr (sum.inr (sum.inr unit.star))
local notation `cor` := sum.inr (sum.inr (sum.inl unit.star))
@[simp]
private def arity (α : Type*) : constructors α → nat
| (cvar a) := 0
| cnot := 1
| cand := 2
| cor := 2
variable {α : Type*}
private def f : prop_form α → W_type (λ i, fin (arity α i))
| (var a) := ⟨cvar a, mk_fn0⟩
| (not p) := ⟨cnot, mk_fn1 (f p)⟩
| (and p q) := ⟨cand, mk_fn2 (f p) (f q)⟩
| (or p q) := ⟨cor, mk_fn2 (f p) (f q)⟩
private def finv : W_type (λ i, fin (arity α i)) → prop_form α
| ⟨cvar a, fn⟩ := var a
| ⟨cnot, fn⟩ := not (finv (fn ⟨0, dec_trivial⟩))
| ⟨cand, fn⟩ := and (finv (fn ⟨0, dec_trivial⟩)) (finv (fn ⟨1, dec_trivial⟩))
| ⟨cor, fn⟩ := or (finv (fn ⟨0, dec_trivial⟩)) (finv (fn ⟨1, dec_trivial⟩))
instance [encodable α] : encodable (prop_form α) :=
begin
haveI : encodable (constructors α),
{ unfold constructors, apply_instance },
exact encodable.of_left_inverse f finv
(by { intro p, induction p; simp [f, finv, *] })
end
end prop_form
|
25522f396375b385d40edb2887b52c4faf12ce7c | 1890046a4987fbd27f3f50dbac83f3ce095556d5 | /01_Equality/01_equality.lean | be8c789e3a5254c1c5dcc69d25922ce4286185ca | [] | no_license | kbhuynh/cs-dm | 9f335727d1779f7c3d9e8221a52b4c9c106659ba | 4041bd73618a49ef6870a1a80764e8947e60e768 | refs/heads/master | 1,585,353,017,958 | 1,536,055,215,000 | 1,536,055,215,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,879 | lean | /- ** An inference rule for equality in general ** -/
/-
Intuitively you would suppose that the proposition,
0 = 0, should be true in any reasonable logical system.
There are two ways a logic could make this happen.
The first is that the logic could provide 0 = 0 as
an axiom, as we just discussed.
That'd be ok, but then we'd need similar axioms for
every other number. We'd also need similar axioms
for every object of every other type: person, car,
plant, atom, book, idea, etc. We end up with a pretty
unwieldy (and infinite) set of axioms. Moreover, if
we were ever to define a new type of objects (e.g.,
digital pets), we'd have to extend the logic with
similar inference rules for every value of the new
type. (Fido = Fido, Spot = Spot, Kitty = Kitty, etc).
What would be much better would be to have just one
inference rule that basically allow us to conclude
that *any* object, or value, of any type whatsoever
is always equal to itself (and that nothing else
is ever equal to that object).
It'd go something like this: if T is any "type"
(such as natural number, car, person), and t is any
object or value of that type, T (e.g., t could be
the value, 0, which is a value of type "natural
number", or "nat" for short), then you can derive
that t = t is true.
We could write this inference rule something like
this:
T: Type, t : T
-------------- (eq_refl)
pf: t = t
In English you could pronounce this rule as
saying, "if you can give any type, T, and any
value, t, of that type, T, then the eq_refl
rule will derive a proof of the proposition
that t = t. In mathematical logic, this notion
of equality is called Leibniz equality.
EXERCISE: Give an expression in which eq_refl
is applied to two arguments to derive a proof
of 0 = 0.
EXERCISE: Why exactly can this rule never be used
to derive a proof of the proposition that 0 = 1?
-/ |
19f503c7190a8c7cacae6996331992776120771b | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/data/dlist/basic.lean | d73414a31a5ae6732179161fc34e5c6a1b7a6541 | [
"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 | 1,250 | lean | /-
Copyright (c) 2018 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import data.dlist
/-!
# Difference list
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file provides a few results about `dlist`, which is defined in core Lean.
A difference list is a function that, given a list, returns the original content of the
difference list prepended to the given list. It is useful to represent elements of a given type
as `a₁ + ... + aₙ` where `+ : α → α → α` is any operation, without actually computing.
This structure supports `O(1)` `append` and `concat` operations on lists, making it
useful for append-heavy uses such as logging and pretty printing.
-/
/-- Concatenates a list of difference lists to form a single difference list. Similar to
`list.join`. -/
def dlist.join {α : Type*} : list (dlist α) → dlist α
| [] := dlist.empty
| (x :: xs) := x ++ dlist.join xs
@[simp] lemma dlist_singleton {α : Type*} {a : α} :
dlist.singleton a = dlist.lazy_of_list ([a]) := rfl
@[simp] lemma dlist_lazy {α : Type*} {l : list α} :
dlist.lazy_of_list l = dlist.of_list l := rfl
|
a24415724b3357352b079ddf0555b100304e129a | 66a6486e19b71391cc438afee5f081a4257564ec | /pointed_cubes.hlean | 79392cc9ea9bcfbace532e30905eee7c656482d9 | [
"Apache-2.0"
] | permissive | spiceghello/Spectral | c8ccd1e32d4b6a9132ccee20fcba44b477cd0331 | 20023aa3de27c22ab9f9b4a177f5a1efdec2b19f | refs/heads/master | 1,611,263,374,078 | 1,523,349,717,000 | 1,523,349,717,000 | 92,312,239 | 0 | 0 | null | 1,495,642,470,000 | 1,495,642,470,000 | null | UTF-8 | Lean | false | false | 7,857 | hlean | /-
Copyright (c) 2017 Egbert Rijke. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Egbert Rijke
-/
/-
The goal of this file is to extend the library of pointed types and pointed maps to support the library of prespectra
-/
import types.pointed2 .pointed_pi
open eq pointed
definition psquare_of_phtpy_top {A B C D : Type*} {ftop : A →* B} {fbot : C →* D} {fleft : A →* C} {fright : B →* D} {ftop' : A →* B} (phtpy : ftop ~* ftop') (psq : psquare ftop' fbot fleft fright) : psquare ftop fbot fleft fright :=
begin
induction phtpy using phomotopy_rec_idp, exact psq,
end
definition psquare_of_phtpy_bot {A B C D : Type*} {ftop : A →* B} {fbot : C →* D} {fleft : A →* C} {fright : B →* D} {fbot' : C →* D} (phtpy : fbot ~* fbot') (psq : psquare ftop fbot' fleft fright) : psquare ftop fbot fleft fright :=
begin
induction phtpy using phomotopy_rec_idp, exact psq,
end
definition psquare_of_phtpy_left {A B C D : Type*} {ftop : A →* B} {fbot : C →* D} {fleft : A →* C} {fright : B →* D} {fleft' : A →* C} (phtpy : fleft ~* fleft') (psq : psquare ftop fbot fleft fright) : psquare ftop fbot fleft' fright :=
begin
induction phtpy using phomotopy_rec_idp, exact psq,
end
definition psquare_of_phtpy_right {A B C D : Type*} {ftop : A →* B} {fbot : C →* D} {fleft : A →* C} {fright : B →* D} {fright' : B →* D} (phtpy : fright ~* fright') (psq : psquare ftop fbot fleft fright) : psquare ftop fbot fleft fright' :=
begin
induction phtpy using phomotopy_rec_idp, exact psq,
end
definition psquare_of_pid_top_bot {A B : Type*} {fleft : A →* B} {fright : A →* B} (phtpy : fright ~* fleft) : psquare (pid A) (pid B) fleft fright :=
psquare_of_phomotopy ((pcompose_pid fright) ⬝* phtpy ⬝* (pid_pcompose fleft)⁻¹*)
--print psquare_of_pid_top_bot
--λ phtpy, psquare_of_phomotopy ((pid_pcompose fleft) ⬝* phtpy ⬝* ((pcompose_pid fright)⁻¹*))
definition psquare_of_pid_left_right {A B : Type*} {ftop : A →* B} {fbot : A →* B} (phtpy : ftop ~* fbot) : psquare ftop fbot (pid A) (pid B) :=
psquare_of_phomotopy ((pid_pcompose ftop) ⬝* phtpy ⬝* ((pcompose_pid fbot)⁻¹*))
--print psquare_of_pid_left_right
definition psquare_hcompose {A B C D E F : Type*} {ftop : A →* B} {fbot : D →* E} {fleft : A →* D} {fright : B →* E} {gtop : B →* C} {gbot : E →* F} {gright : C →* F} (psq_left : psquare ftop fbot fleft fright) (psq_right : psquare gtop gbot fright gright) : psquare (gtop ∘* ftop) (gbot ∘* fbot) fleft gright :=
begin
fapply psquare_of_phomotopy,
refine (passoc gright gtop ftop)⁻¹* ⬝* _ ⬝* (passoc gbot fbot fleft)⁻¹*,
refine (pwhisker_right ftop psq_right) ⬝* (passoc gbot fright ftop) ⬝* _,
exact (pwhisker_left gbot psq_left),
end
definition psquare_vcompose {A B C D E F : Type*} {ftop : A →* B} {fbot : C →* D} {fleft : A →* C} {fright : B →* D} {gbot : E →* F} {gleft : C →* E} {gright : D →* F} (psq_top : psquare ftop fbot fleft fright) (psq_bot : psquare fbot gbot gleft gright) : psquare ftop gbot (gleft ∘* fleft) (gright ∘* fright) :=
begin
fapply psquare_of_phomotopy,
refine (passoc gright fright ftop) ⬝* _ ⬝* (passoc gbot gleft fleft),
refine (pwhisker_left gright psq_top) ⬝* _,
refine (passoc gright fbot fleft)⁻¹* ⬝* _,
exact pwhisker_right fleft psq_bot,
end
definition psquare_of_pconst_top_bot {A B C D : Type*} (fleft : A →* C) (fright : B →* D) : psquare (pconst A B) (pconst C D) fleft fright :=
begin
fapply psquare_of_phomotopy,
refine (pcompose_pconst fright) ⬝* _,
exact (pconst_pcompose fleft)⁻¹*,
end
definition psquare_of_pconst_left_right {A B C D : Type*} (ftop : A →* B) (fbot : C →* D) : psquare ftop fbot (pconst A C) (pconst B D) :=
begin
fapply psquare_of_phomotopy,
refine (pconst_pcompose ftop) ⬝* _,
exact (pcompose_pconst fbot)⁻¹*
end
definition psquare_of_pconst_top_left {A B C D : Type*} (fbot : C →* D) (fright : B →* D) : psquare (pconst A B) fbot (pconst A C) fright :=
begin
fapply psquare_of_phomotopy,
refine (pcompose_pconst fright) ⬝* _,
exact (pcompose_pconst fbot)⁻¹*,
end
definition psquare_of_pconst_bot_right {A B C D : Type*} (ftop : A →* B) (fleft : A →* C) : psquare ftop (pconst C D) fleft (pconst B D) :=
begin
fapply psquare_of_phomotopy,
refine (pconst_pcompose ftop) ⬝* _,
exact (pconst_pcompose fleft)⁻¹*,
end
definition phsquare_of_phomotopy {A B : Type*} {f g h i : A →* B} {phtpy_top : f ~* g} {phtpy_bot : h ~* i} {phtpy_left : f ~* h} {phtpy_right : g ~* i} (H : phtpy_top ⬝* phtpy_right ~* phtpy_left ⬝* phtpy_bot) : phsquare phtpy_top phtpy_bot phtpy_left phtpy_right :=
eq_of_phomotopy H
definition ptube_v {A B C D : Type*} {ftop ftop' : A →* B} (phtpy_top : ftop ~* ftop') {fbot fbot' : C →* D} (phtpy_bot : fbot ~* fbot') {fleft : A →* C} {fright : B →* D} (psq_back : psquare ftop fbot fleft fright) (psq_front : psquare ftop' fbot' fleft fright) : Type :=
phsquare (pwhisker_left fright phtpy_top) (pwhisker_right fleft phtpy_bot) psq_back psq_front
definition ptube_h {A B C D : Type*} {ftop : A →* B} {fbot : C →* D} {fleft fleft' : A →* C} (phtpy_left : fleft ~* fleft') {fright fright' : B →* D} (phtpy_right : fright ~* fright') (psq_back : psquare ftop fbot fleft fright) (psq_front : psquare ftop fbot fleft' fright') : Type :=
phsquare (pwhisker_right ftop phtpy_right) (pwhisker_left fbot phtpy_left) psq_back psq_front
--print pinv_right_phomotopy_of_phomotopy
definition psquare_inv_top_bot {A B C D : Type*} {ftop : A ≃* B} {fbot : C ≃* D} {fleft : A →* C} {fright : B →* D} (psq : psquare ftop fbot fleft fright) : psquare ftop⁻¹ᵉ* fbot⁻¹ᵉ* fright fleft :=
begin
fapply psquare_of_phomotopy,
refine (pinv_right_phomotopy_of_phomotopy _),
refine _ ⬝* (passoc fbot⁻¹ᵉ* fright ftop)⁻¹*,
refine (pinv_left_phomotopy_of_phomotopy _)⁻¹*,
exact psq,
end
definition p2homotopy_ty_respect_pt {A B : Type*} {f g : A →* B} {H K : f ~* g} (htpy : H ~ K) : Type :=
begin
induction H with H p, exact p
end = whisker_right (respect_pt g) (htpy pt) ⬝
begin
induction K with K q, exact q
end
--print p2homotopy_ty_respect_pt
structure p2homotopy {A B : Type*} {f g : A →* B} (H K : f ~* g) : Type :=
( to_2htpy : H ~ K)
( respect_pt : p2homotopy_ty_respect_pt to_2htpy)
definition ptube_v_phtpy_bot {A B C D : Type*}
{ftop ftop' : A →* B} {phtpy_top : ftop ~* ftop'}
{fbot fbot' : C →* D} {phtpy_bot phtpy_bot' : fbot ~* fbot'} (ppi_htpy_bot : phtpy_bot ~* phtpy_bot')
{fleft : A →* C} {fright : B →* D}
{psq_back : psquare ftop fbot fleft fright}
{psq_front : psquare ftop' fbot' fleft fright}
(ptb : ptube_v phtpy_top phtpy_bot psq_back psq_front)
: ptube_v phtpy_top phtpy_bot' psq_back psq_front
:=
begin
induction ppi_htpy_bot using phomotopy_rec_idp,
exact ptb,
end
definition ptube_v_eq_bot {A B C D : Type*} {ftop ftop' : A →* B} (htpy_top : ftop ~* ftop') {fbot fbot' : C →* D} {htpy_bot htpy_bot' : fbot ~* fbot'} (p : htpy_bot = htpy_bot') {fleft : A →* C} {fright : B →* D} (psq_back : psquare ftop fbot fleft fright) (psq_front : psquare ftop' fbot' fleft fright) :
ptube_v htpy_top htpy_bot psq_back psq_front → ptube_v htpy_top htpy_bot' psq_back psq_front :=
begin
induction p,
exact id,
end
definition ptube_v_left_inv {A B C D : Type*} {ftop : A ≃* B} {fbot : C ≃* D} {fleft : A →* C} {fright : B →* D}
(psq : psquare ftop fbot fleft fright) :
ptube_v
(pleft_inv ftop)
(pleft_inv fbot)
(psquare_hcompose psq (psquare_inv_top_bot psq))
(psquare_of_pid_top_bot phomotopy.rfl) :=
begin
refine ptube_v_phtpy_bot _ _,
exact pleft_inv fbot,
exact phomotopy.rfl,
fapply phsquare_of_phomotopy, repeat exact sorry,
end
|
f145ae9d68cfca4073772eb69f07fe1423eb7c2c | 9bf90df35bb15a2f76571e35c48192142a328c40 | /src/ch6_cont.lean | 6195798f0f4d51409d01e3e0dbe26627ef0a13a3 | [] | no_license | ehaskell1/set_theory | ed0726520e84990d5f3180bafa0a3674ed31fb5e | e6c829c4dd953d98c9cba08f9f79784cd91794fb | refs/heads/master | 1,693,282,405,362 | 1,636,928,916,000 | 1,636,928,916,000 | 428,055,746 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 100,411 | lean | import ch7
universe u
namespace Set
local attribute [irreducible] mem
lemma card_nat {n : Set} (hn : n ∈ ω) : n.card = n :=
have hf : n.is_finite := ⟨n, hn, equin_refl⟩,
unique_of_exists_unique (exists_unique_equiv_nat_of_finite hf) (card_finite hf) ⟨hn, equin_refl⟩
lemma eq_empty_of_card_empty {A : Set} (Acard : A.card = ∅) : A = ∅ :=
begin
rw [←card_nat (zero_nat), card_equiv] at Acard,
exact empty_of_equin_empty Acard,
end
lemma ne_empty_of_zero_mem_card {A : Set} (zA : ∅ ∈ A.card) : A ≠ ∅ :=
begin
intro Ae, subst Ae, rw card_nat zero_nat at zA, exact mem_empty _ zA,
end
lemma finite_iff {A : Set} : A.is_finite ↔ ∃ n : Set, n ∈ ω ∧ A.card = n :=
begin
simp only [is_finite, ←card_equiv, subst_right_of_and card_nat],
end
lemma nat_finite {n : Set} (hn : n ∈ ω) : n.is_finite := finite_iff.mpr ⟨_, hn, card_nat hn⟩
theorem nat_is_cardinal {n : Set} (hn : n ∈ ω) : n.is_cardinal := ⟨_, card_nat hn⟩
theorem card_omega_not_nat : ¬ ∃ n : Set, n ∈ ω ∧ card ω = n :=
begin
rintro ⟨n, hn, he⟩, apply nat_infinite, rw [←card_nat hn, card_equiv] at he, exact ⟨_, hn, he⟩,
end
lemma not_empty_of_card_not_empty {κ : Set} (hnz : κ ≠ ∅) {X : Set} (he : X.card = κ) : X ≠ ∅ :=
begin
intro hee, rw [hee, card_nat (nat_induct.zero)] at he, apply hnz, rw he,
end
lemma prod_singleton_equin {X Y : Set} : X.equinumerous (X.prod {Y}) :=
begin
let f : Set := pair_sep (λ a b, b = a.pair Y) X (X.prod {Y}),
have ffun : f.is_function := pair_sep_eq_is_fun,
have fdom : f.dom = X, apply pair_sep_eq_dom_eq, intros a ha,
simp only [mem_prod, exists_prop, mem_singleton], exact ⟨_, ha, _, rfl, rfl⟩,
have fran : f.ran = X.prod {Y}, apply pair_sep_eq_ran_eq, intros b hb,
simp only [mem_prod, exists_prop, mem_singleton] at hb, rcases hb with ⟨a, ha, b', hb', hp⟩, rw hb' at hp,
exact ⟨_, ha, hp⟩,
have foto : f.one_to_one, apply pair_sep_eq_oto, intros a ha a' ha' he, exact (pair_inj he).left,
exact ⟨_, ⟨ffun, fdom, fran⟩, foto⟩,
end
lemma singleton_equin {x y : Set} : equinumerous {x} {y} :=
⟨{x.pair y}, single_pair_onto, single_pair_oto⟩
lemma prod_disj_of_right_disj {A B C D : Set} (h : C ∩ D = ∅) : A.prod C ∩ B.prod D = ∅ :=
begin
rw rel_eq_empty (inter_rel_is_rel prod_is_rel), simp [mem_inter, pair_mem_prod],
intros x y hA hC hB hD, apply mem_empty y, rw [←h, mem_inter], exact ⟨hC, hD⟩,
end
lemma prod_empty_eq_empty {A : Set} : A.prod ∅ = ∅ :=
begin
rw rel_eq_empty prod_is_rel, intros x y h, rw pair_mem_prod at h, exact mem_empty _ h.right,
end
lemma empty_prod_eq_empty {A : Set} : prod ∅ A = ∅ :=
begin
rw rel_eq_empty prod_is_rel, intros x y h, rw pair_mem_prod at h, exact mem_empty _ h.left,
end
-- excercise 6
theorem card_not_set {κ : Set} (hc : κ.is_cardinal) (hnz : κ ≠ ∅) : ¬ ∃ Κ : Set, ∀ X : Set, X ∈ Κ ↔ card X = κ :=
begin
rintro ⟨Κ, h⟩, apply univ_not_set,
existsi Κ.Union.Union.Union, intro X,
rcases hc with ⟨Y, hY⟩,
let Z : Set := Y.prod {X},
have hZ : Z ∈ Κ, rw [h _, ←hY, card_equiv], apply equin_symm, exact prod_singleton_equin,
have hin : Y.inhab := inhabited_of_ne_empty (not_empty_of_card_not_empty hnz hY),
rcases hin with ⟨u, hu⟩,
simp only [mem_Union, exists_prop], refine ⟨{u, X}, ⟨u.pair X, ⟨Z, hZ, _⟩, _⟩, _⟩,
{ simp only [mem_prod, exists_prop, mem_singleton], exact ⟨_, hu, _, rfl, rfl⟩, },
{ rw [pair, mem_insert, mem_singleton], exact or.inr rfl, },
{ rw [mem_insert, mem_singleton], exact or.inr rfl, },
end
def finite_cardinal (κ : Set) : Prop := ∃ X : Set, X.is_finite ∧ card X = κ
lemma fin_card_is_card {κ : Set} (κfin : κ.finite_cardinal) : κ.is_cardinal :=
exists.elim κfin (λ K hK, ⟨_, hK.right⟩)
theorem one_finite_all_finite {κ : Set} (hf : κ.finite_cardinal) {X : Set} (hc : card X = κ) : X.is_finite :=
begin
rcases hf with ⟨X', ⟨n, hn, hX'n⟩, hc'⟩, rw [←hc', card_equiv] at hc, exact ⟨_, hn, equin_trans hc hX'n⟩
end
lemma card_finite_iff_finite {A : Set} : A.card.finite_cardinal ↔ A.is_finite :=
⟨λ h, one_finite_all_finite h rfl, λ h, ⟨_, h, rfl⟩⟩
theorem finite_cardinal_iff_nat {X : Set} : X.finite_cardinal ↔ X ∈ ω :=
begin
simp only [finite_cardinal, is_finite], split,
{ rintro ⟨Y, ⟨n, hn, hYn⟩, hc⟩, rw ←card_equiv at hYn, rw [hYn, card_nat hn] at hc, rw ←hc, exact hn, },
{ rintro hX, refine ⟨X, ⟨X, hX, equin_refl⟩, card_nat hX⟩, },
end
theorem aleph_null_infinite_cardinal : ¬ finite_cardinal (card ω) :=
begin
rintro ⟨X, ⟨n, hn, hXn⟩, hc⟩, apply nat_infinite, rw [card_equiv] at hc, refine ⟨_, hn, equin_trans (equin_symm hc) hXn⟩,
end
lemma Lemma_6F : ∀ {n : Set}, n ∈ ω → ∀ {C : Set}, C ⊂ n → ∃ m : Set, m ∈ n ∧ C.equinumerous m :=
begin
apply @induction (λ n, ∀ {C : Set}, C ⊂ n → ∃ m : Set, m ∈ n ∧ C.equinumerous m),
{ rintros C ⟨hs, hne⟩, exfalso, apply hne, rw eq_iff_subset_and_subset, refine ⟨hs, λ x hx, _⟩, exfalso, exact mem_empty _ hx, },
{ intros k hk hi C hCk, by_cases heCk : C = k,
{ refine ⟨_, self_mem_succ, _⟩, rw heCk, exact equin_refl, },
{ by_cases hkmC : k ∈ C,
{ have hCe : C = (C ∩ k) ∪ {k}, apply ext, simp only [mem_union, mem_inter, mem_singleton], intro x, split,
{ intro hxC,
have hxk : x ∈ k.succ := hCk.left hxC,
rw [mem_succ_iff_le, le_iff] at hxk, cases hxk,
{ left, exact ⟨hxC, hxk⟩, },
{ right, exact hxk, }, },
{ rintro (⟨hxC, hxk⟩|hxk),
{ exact hxC, },
{ rw ←hxk at hkmC, exact hkmC, }, },
have hCkp : C ∩ k ⊂ k, refine ⟨λ x hx, _, _⟩,
{ rw mem_inter at hx, exact hx.right, },
{ intro hCke, apply hCk.right, rw eq_iff_subset_and_subset, refine ⟨hCk.left, λ x hxk, _⟩,
rw [mem_succ_iff_le, le_iff] at hxk, cases hxk,
{ rw ←hCke at hxk, rw mem_inter at hxk, exact hxk.left, },
{ rw ←hxk at hkmC, exact hkmC, }, },
specialize hi hCkp, rcases hi with ⟨m, hmk, f, fonto, foto⟩,
let g : Set := f ∪ {k.pair m},
have ginto : g.into_fun C m.succ, rw fun_def_equiv,
have hf : (C ∩ k).is_func m f, rw ←fun_def_equiv, exact into_of_onto fonto,
refine ⟨λ p hp, _, λ x hxC, _⟩,
{ simp only [mem_prod, exists_prop, mem_succ_iff_le, le_iff], rw [mem_union, mem_singleton] at hp,
cases hp,
{ replace hp := hf.left hp, simp only [mem_prod, exists_prop] at hp,
rcases hp with ⟨x, hx, y, hy, hp⟩, rw mem_inter at hx, exact ⟨_, hx.left, _, or.inl hy, hp⟩, },
{ exact ⟨_, hkmC, _, or.inr rfl, hp⟩, }, },
{ rw [hCe, mem_union, mem_singleton] at hxC, simp only [mem_union, mem_singleton], cases hxC,
{ have he : ∃ y : Set, x.pair y ∈ f := exists_of_exists_unique (hf.right _ hxC),
rcases he with ⟨y, hxyf⟩, refine exists_unique_of_exists_of_unique ⟨_, or.inl hxyf⟩ _,
rintros z z' (hz|hz) (hz'|hz'),
{ exact unique_of_exists_unique (hf.right _ hxC) hz hz', },
{ exfalso, rw mem_inter at hxC, rw (pair_inj hz').left at hxC, exact nat_not_mem_self hk hxC.right, },
{ exfalso, rw mem_inter at hxC, rw (pair_inj hz).left at hxC, exact nat_not_mem_self hk hxC.right, },
{ rw [(pair_inj hz).right, (pair_inj hz').right], }, },
{ rw hxC, refine ⟨_, or.inr rfl, _⟩, rintros y (hy|hy),
{ exfalso, apply nat_not_mem_self hk,
have hkd : k ∈ f.dom, rw mem_dom, exact ⟨_, hy⟩,
rw [fonto.right.left, mem_inter] at hkd, exact hkd.right, },
{ exact (pair_inj hy).right, }, }, },
have gran : g.ran = m.succ, rw [ran_union, fonto.right.right, ran_single_pair, succ], rw union_comm,
have goto : g.one_to_one, apply union_one_to_one foto single_pair_oto, rw [fonto.right.right, ran_single_pair],
rw eq_empty, intros x hx, rw [mem_inter, mem_singleton] at hx, apply nat_not_mem_self ((mem_nat_iff hk).mp hmk).left,
cases hx with hxmm hxem, rw hxem at hxmm, exact hxmm,
existsi m.succ, rw ←mem_iff_succ_mem_succ, exact ⟨hmk, _, ⟨ginto.left, ginto.right.left, gran⟩, goto⟩,
exact ((mem_nat_iff hk).mp hmk).left, exact hk, },
{ have hCpk : C ⊂ k, refine ⟨λ x hxC, _, heCk⟩,
have hxk : x ∈ k.succ := hCk.left hxC,
rw [mem_succ_iff_le, le_iff] at hxk, cases hxk,
{ exact hxk, },
{ exfalso, rw hxk at hxC, exact hkmC hxC, },
specialize hi hCpk, rcases hi with ⟨m, hmk, hCm⟩,
simp only [mem_succ_iff_le, le_iff], exact ⟨_, or.inl hmk, hCm⟩, }, }, },
end
-- Corollary 6G
theorem subset_finite_of_finite {A : Set.{u}} (hA : A.is_finite) {B : Set} (hBA : B ⊆ A) : B.is_finite :=
begin
by_cases he : A = B,
{ rw ←he, exact hA, },
{ rcases hA with ⟨n, hn, f, fonto, foto⟩,
have hBeq : B.equinumerous (f.img B),
let g : Set := f.restrict B,
have gfun : g.is_function := restrict_is_function fonto.left,
have gdom : g.dom = B, refine restrict_dom _, rw fonto.right.left, exact hBA,
have gran : g.ran = f.img B := restrict_ran,
have goto : g.one_to_one, refine restrict_one_to_one fonto.left foto _, rw fonto.right.left, exact hBA,
exact ⟨_, ⟨gfun, gdom, gran⟩, goto⟩,
have hfimgne : f.img B ≠ n, rw ←fonto.right.right, refine img_ne_ran_of_ne_dom fonto.left foto _ _,
{ rw fonto.right.left, exact hBA, },
rw fonto.right.left, symmetry, exact he,
have hfimgsub : f.img B ⊆ n, rw ←fonto.right.right, exact img_subset_ran,
obtain ⟨m, hmn, hfimgeqm⟩ := Lemma_6F hn ⟨hfimgsub, hfimgne⟩,
have hm : m ∈ (ω : Set.{u}) := ((mem_nat_iff hn).mp hmn).left,
exact ⟨_, hm, equin_trans hBeq hfimgeqm⟩, },
end
lemma inf_of_sup_inf {X : Set} (Xinf : ¬ X.is_finite) {Y : Set} (XY : X ⊆ Y) : ¬ Y.is_finite :=
λ Yfin, Xinf (subset_finite_of_finite Yfin XY)
-- All of the excericises at the end of the section on finite sets are worth doing
theorem T6H_a {K₁ K₂ : Set} (hK : K₁.equinumerous K₂) {L₁ L₂ : Set} (hL : L₁.equinumerous L₂) (hd₁ : K₁ ∩ L₁ = ∅) (hd₂ : K₂ ∩ L₂ = ∅) : (K₁ ∪ L₁).equinumerous (K₂ ∪ L₂) :=
begin
rcases hK with ⟨f, fonto, foto⟩,
rcases hL with ⟨g, gonto, goto⟩,
let h : Set := f ∪ g,
have honto : h.onto_fun (K₁ ∪ L₁) (K₂ ∪ L₂), rw [←fonto.right.left, ←gonto.right.left, ←fonto.right.right, ←gonto.right.right],
apply union_fun fonto.left gonto.left,
rw [fonto.right.left, gonto.right.left], exact hd₁,
have hoto : h.one_to_one, apply union_one_to_one foto goto,
rw [fonto.right.right, gonto.right.right], exact hd₂,
exact ⟨h, honto, hoto⟩,
end
lemma T6H_b_lemma {K₁ K₂ f : Set} (fc : K₁.correspondence K₂ f) {L₁ L₂ g : Set} (gc : L₁.correspondence L₂ g) :
correspondence (K₁.prod L₁) (K₂.prod L₂) (pair_sep_eq (K₁.prod L₁) (K₂.prod L₂) (λ a, (f.fun_value a.fst).pair (g.fun_value a.snd))) :=
begin
rcases fc with ⟨fonto, foto⟩, rcases gc with ⟨gonto, goto⟩,
refine ⟨⟨pair_sep_eq_is_fun, pair_sep_eq_dom_eq _, pair_sep_eq_ran_eq _⟩, pair_sep_eq_oto _⟩,
{ intros z hz, dsimp,
rw [pair_mem_prod, ←fonto.right.right, ←gonto.right.right], split,
{ apply fun_value_def'' fonto.left, rw fonto.right.left, exact (fst_snd_mem_dom_ran hz).left, },
{ apply fun_value_def'' gonto.left, rw gonto.right.left, exact (fst_snd_mem_dom_ran hz).right, }, },
{ intros b hb, rw mem_prod at hb,
rcases hb with ⟨k, hk, l, hl, hb⟩,
rw [←fonto.right.right, mem_ran_iff fonto.left] at hk, rw [←gonto.right.right, mem_ran_iff gonto.left] at hl,
rcases hk with ⟨k', hk', hk⟩, rcases hl with ⟨l', hl', hl⟩,
refine ⟨k'.pair l', _, _⟩,
{ rw pair_mem_prod, rw [←fonto.right.left, ←gonto.right.left], finish, },
{ dsimp, rw [fst_congr, snd_congr, hb, hk, hl], }, },
{ intros p hp q hq he,
have he' := pair_inj he,
rw [fst_snd_spec (is_pair_of_mem_prod hp), fst_snd_spec (is_pair_of_mem_prod hq)],
have feq : p.fst = q.fst, refine from_one_to_one fonto.left foto _ _ he'.left,
{ rw fonto.right.left, exact (fst_snd_mem_dom_ran hp).left, },
{ rw fonto.right.left, exact (fst_snd_mem_dom_ran hq).left, },
have seq : p.snd = q.snd, refine from_one_to_one gonto.left goto _ _ he'.right,
{ rw gonto.right.left, exact (fst_snd_mem_dom_ran hp).right, },
{ rw gonto.right.left, exact (fst_snd_mem_dom_ran hq).right, },
rw [feq, seq], },
end
theorem T6H_b {K₁ K₂ : Set} (hK : K₁.equinumerous K₂) {L₁ L₂ : Set} (hL : L₁.equinumerous L₂) : (K₁.prod L₁).equinumerous (K₂.prod L₂) :=
begin
rcases hK with ⟨f, fc⟩, rcases hL with ⟨g, gc⟩, exact ⟨_, T6H_b_lemma fc gc⟩,
end
theorem T6H_c {K₁ K₂ : Set} (hK : K₁.equinumerous K₂) {L₁ L₂ : Set} (hL : L₁.equinumerous L₂) : (L₁.into_funs K₁).equinumerous (L₂.into_funs K₂) :=
begin
rcases hK with ⟨f, fonto, foto⟩,
rcases hL with ⟨g, gonto, goto⟩,
let H : Set := pair_sep (λ j h, h = f.comp (j.comp g.inv)) (L₁.into_funs K₁) (L₂.into_funs K₂),
have Hfun : H.is_function := pair_sep_eq_is_fun,
have Hdom : H.dom = L₁.into_funs K₁, apply pair_sep_eq_dom_eq, intros h hh, rw mem_into_funs at hh, rw mem_into_funs,
apply comp_into_fun,
{ apply comp_into_fun (inv_into_fun gonto goto) hh, },
{ exact into_of_onto fonto, },
have Hran : H.ran = L₂.into_funs K₂, apply pair_sep_eq_ran_eq, intros d hd, rw mem_into_funs at hd,
let j := f.inv.comp (d.comp g), refine ⟨j, _, _⟩,
{ rw mem_into_funs, apply comp_into_fun,
{ apply comp_into_fun (into_of_onto gonto) hd, },
{ exact inv_into_fun fonto foto, }, },
{ rw [←Set.comp_assoc, ←Set.comp_assoc, eq_inv_id fonto.left foto, Set.comp_assoc, Set.comp_assoc, eq_inv_id gonto.left goto],
rw [gonto.right.right, ←hd.right.left, comp_id hd.left, fonto.right.right], symmetry, exact id_comp hd.right.right hd.left, },
have hoto : H.one_to_one, apply pair_sep_eq_oto, intros j hj j' hj' he,
rw mem_into_funs at hj hj',
have h : (f.comp (j.comp g.inv)).comp g = (f.comp (j'.comp g.inv)).comp g, rw he,
rw [comp_assoc, comp_assoc, comp_assoc, comp_assoc, eq_id gonto.left goto, gonto.right.left] at h,
nth_rewrite 0 ←hj.right.left at h, rw [←hj'.right.left, comp_id hj.left, comp_id hj'.left] at h,
apply fun_ext hj.left hj'.left,
{ rw [hj.right.left, hj'.right.left], },
{ intros t ht, apply from_one_to_one fonto.left foto,
{ rw fonto.right.left, apply hj.right.right, apply fun_value_def'' hj.left ht, },
{ rw fonto.right.left, apply hj'.right.right, rw [hj.right.left, ←hj'.right.left] at ht,
apply fun_value_def'' hj'.left ht, },
{ rw [←T3H_c fonto.left hj.left, ←T3H_c fonto.left hj'.left, h],
{ rw [dom_comp, hj'.right.left, ←hj.right.left], exact ht, rw [fonto.right.left], exact hj'.right.right, },
{ rw [dom_comp], exact ht, rw [fonto.right.left], exact hj.right.right, }, }, },
exact ⟨_, ⟨Hfun, Hdom, Hran⟩, hoto⟩,
end
lemma same_card {A x : Set} : (A.prod {x}).card = A.card :=
begin
rw card_equiv, apply equin_symm, exact prod_singleton_equin,
end
lemma disj {A B x y : Set} (hne : x ≠ y) : (A.prod {x}) ∩ (B.prod {y}) = ∅ :=
prod_disj (singleton_disj_of_ne hne)
lemma exists_add {κ μ : Set} : ∃ ν : Set, ∀ (K : Set), K.card = κ → ∀ (M : Set), M.card = μ → K ∩ M = ∅ → (K ∪ M).card = ν :=
begin
let K' := κ.prod {∅},
let M' := μ.prod {one},
have hK' : K'.card = κ.card := same_card,
have hM' : M'.card = μ.card := same_card,
have hdisj : K' ∩ M' = ∅ := disj zero_ne_one,
existsi (K' ∪ M').card, intros J hJ N hN hd,
rw card_equiv, refine T6H_a _ _ hd hdisj,
{ rw [←card_equiv, hJ, hK', card_of_cardinal_eq_self ⟨_, hJ⟩], },
{ rw [←card_equiv, hN, hM', card_of_cardinal_eq_self ⟨_, hN⟩], },
end
lemma exists_mul {κ μ : Set} : ∃ ν : Set, ∀ (K : Set), K.card = κ → ∀ (M : Set), M.card = μ → (K.prod M).card = ν :=
begin
existsi (κ.prod μ).card, intros K' hK' M' hM', rw card_equiv,
apply T6H_b,
{ rw [←card_equiv, hK', card_of_cardinal_eq_self ⟨_, hK'⟩], },
{ rw [←card_equiv, hM', card_of_cardinal_eq_self ⟨_, hM'⟩], },
end
lemma exists_exp {κ μ : Set} : ∃ ν : Set, ∀ (K : Set), K.card = κ → ∀ (M : Set), M.card = μ → (M.into_funs K).card = ν :=
begin
existsi (μ.into_funs κ).card, intros K' hK' M' hM', rw card_equiv,
apply T6H_c,
{ rw [←card_equiv, hK', card_of_cardinal_eq_self ⟨_, hK'⟩], },
{ rw [←card_equiv, hM', card_of_cardinal_eq_self ⟨_, hM'⟩], },
end
lemma exists_add_fun : ∃ (add : Set → Set → Set), ∀ (κ μ : Set) (K : Set), K.card = κ → ∀ (M : Set), M.card = μ → K ∩ M = ∅ → (K ∪ M).card = add κ μ :=
choice_2_arg @exists_add
lemma exists_mul_fun : ∃ (mul : Set → Set → Set), ∀ (κ μ : Set) (K : Set), K.card = κ → ∀ (M : Set), M.card = μ → (K.prod M).card = mul κ μ :=
choice_2_arg @exists_mul
lemma exists_exp_fun : ∃ (exp : Set → Set → Set), ∀ (κ μ : Set) (K : Set), K.card = κ → ∀ (M : Set), M.card = μ → (M.into_funs K).card = exp κ μ :=
choice_2_arg @exists_exp
noncomputable def card_add : Set.{u} → Set.{u} → Set.{u} := classical.some exists_add_fun
noncomputable def card_mul : Set.{u} → Set.{u} → Set.{u} := classical.some exists_mul_fun
noncomputable def card_exp : Set.{u} → Set.{u} → Set.{u} := classical.some exists_exp_fun
lemma card_add_spec : ∀ {κ μ : Set} {K : Set}, K.card = κ → ∀ {M : Set}, M.card = μ → K ∩ M = ∅ → (K ∪ M).card = card_add κ μ :=
classical.some_spec exists_add_fun
lemma card_mul_spec : ∀ {κ μ : Set} {K : Set}, K.card = κ → ∀ {M : Set}, M.card = μ → (K.prod M).card = card_mul κ μ :=
classical.some_spec exists_mul_fun
lemma card_exp_spec : ∀ {κ μ : Set} {K : Set}, K.card = κ → ∀ {M : Set}, M.card = μ → (M.into_funs K).card = card_exp κ μ :=
classical.some_spec exists_exp_fun
lemma add_cardinal {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : (κ.card_add μ).is_cardinal :=
begin
rcases hκ with ⟨K, hK⟩, rcases hμ with ⟨M, hM⟩,
let K' := K.prod {∅},
let M' := M.prod {one},
have hK' : K'.card = κ, rw same_card, exact hK,
have hM' : M'.card = μ, rw same_card, exact hM,
have hdisj : K' ∩ M' = ∅ := disj zero_ne_one,
rw ←card_add_spec hK' hM' hdisj, exact ⟨_, rfl⟩,
end
lemma mul_cardinal {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : (κ.card_mul μ).is_cardinal :=
begin
rcases hκ with ⟨K, hK⟩, rcases hμ with ⟨M, hM⟩,
rw ←card_mul_spec hK hM, exact ⟨_, rfl⟩,
end
lemma exp_cardinal {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : (κ.card_exp μ).is_cardinal :=
begin
rcases hκ with ⟨K, hK⟩, rcases hμ with ⟨M, hM⟩,
rw ←card_exp_spec hK hM, exact ⟨_, rfl⟩,
end
theorem aleph_mul_aleph_eq_aleph : card_mul (card ω) (card ω) = card ω :=
begin
rw [←card_mul_spec rfl rfl, card_equiv], exact nat_prod_nat_equin_nat,
end
-- example 4, part c, page 141
theorem card_mul_one_eq_self {κ : Set} (hκ : κ.is_cardinal) : κ.card_mul one = κ :=
begin
rcases hκ with ⟨K, hK⟩, rw [←card_mul_spec hK (card_nat one_nat), ←hK, card_equiv, one, succ, union_empty],
apply equin_symm, exact prod_singleton_equin,
end
-- example 6, page 141
theorem card_power {A : Set} : A.powerset.card = two.card_exp A.card :=
begin
have h : A.powerset.card = (A.into_funs two).card, rw card_equiv, exact powerset_equinumerous_into_funs,
rw h, apply card_exp_spec (card_nat two_nat) rfl,
end
-- example 7, page 142
theorem card_ne_power {κ : Set} (hκ : κ.is_cardinal) : κ ≠ two.card_exp κ :=
begin
intro he, rcases hκ with ⟨K, hK⟩, rw [←hK, ←card_power, card_equiv] at he,
exact not_equin_powerset he,
end
-- Theorem 6I part 1 part a
theorem card_add_comm {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : κ.card_add μ = μ.card_add κ :=
begin
rcases hκ with ⟨K, hK⟩,
rcases hμ with ⟨M, hM⟩,
let K' := K.prod {∅},
let M' := M.prod {one},
have hK' : K'.card = K.card := same_card,
have hM' : M'.card = M.card := same_card,
have hdisj : K' ∩ M' = ∅ := disj zero_ne_one,
rw hK at hK', rw hM at hM', rw ←card_add_spec hK' hM' hdisj,
rw inter_comm at hdisj, rw ←card_add_spec hM' hK' hdisj, rw union_comm,
end
-- Theorem 6I part 1 part b
theorem card_mul_comm {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : κ.card_mul μ = μ.card_mul κ :=
begin
rcases hκ with ⟨K, hK⟩,
rcases hμ with ⟨M, hM⟩,
rw [←card_mul_spec hK hM, ←card_mul_spec hM hK, card_equiv],
let f : Set := pair_sep_eq (K.prod M) (M.prod K) (λ z, z.snd.pair z.fst),
refine ⟨f, ⟨pair_sep_eq_is_fun, pair_sep_eq_dom_eq _, pair_sep_eq_ran_eq _⟩, pair_sep_eq_oto _⟩,
{ intros z hz, rw mem_prod at hz, rcases hz with ⟨k, hk, m, hm, he⟩, subst he,
rw [pair_mem_prod, snd_congr, fst_congr], exact ⟨hm, hk⟩, },
{ intros z hz, rw mem_prod at hz, rcases hz with ⟨m, hm, k, hk, he⟩, subst he, use k.pair m,
simp only [pair_mem_prod, snd_congr, fst_congr],
exact ⟨⟨hk, hm⟩, rfl⟩, },
{ intros z hz z' hz' he,
obtain ⟨snde, fste⟩ := pair_inj he,
rw mem_prod at hz, rw mem_prod at hz',
rcases hz with ⟨k, hk, m, hm, hze⟩, rcases hz' with ⟨k', hk', m', hm', hze'⟩,
subst hze, subst hze', simp only [snd_congr] at snde, simp only [fst_congr] at fste,
subst snde, subst fste, },
end
-- Theorem 6I part 2 part a
theorem card_add_assoc {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) {ν : Set} (hν : ν.is_cardinal) :
κ.card_add (μ.card_add ν) = (κ.card_add μ).card_add ν :=
begin
rcases hκ with ⟨K, hK⟩,
rcases hμ with ⟨M, hM⟩,
rcases hν with ⟨N, hN⟩,
let K' := K.prod {∅},
let M' := M.prod {one},
let N' := N.prod {two},
have hK' : K'.card = K.card := same_card,
have hM' : M'.card = M.card := same_card,
have hN' : N'.card = N.card := same_card,
have hKM : K' ∩ M' = ∅ := disj zero_ne_one,
have hKN : K' ∩ N' = ∅ := disj zero_ne_two,
have hMN : M' ∩ N' = ∅ := disj one_ne_two,
have hK_MN : K' ∩ (M' ∪ N') = ∅, rw [inter_union, hKM, hKN, union_empty],
have hKM_N : (K' ∪ M') ∩ N' = ∅, rw [union_inter, hKN, hMN, union_empty],
rw hK at hK', rw hM at hM', rw hN at hN',
rw ←card_add_spec hM' hN' hMN,
rw ←card_add_spec hK' rfl hK_MN,
rw ←card_add_spec hK' hM' hKM,
rw ←card_add_spec rfl hN' hKM_N,
rw union_assoc,
end
-- Theorem 6I part 3
theorem card_mul_add {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) {ν : Set} (hν : ν.is_cardinal) :
κ.card_mul (μ.card_add ν) = (κ.card_mul μ).card_add (κ.card_mul ν) :=
begin
rcases hκ with ⟨K, hK⟩,
rcases hμ with ⟨M, hM⟩,
rcases hν with ⟨N, hN⟩,
let K' := K.prod {∅},
let M' := M.prod {one},
let N' := N.prod {two},
have hK' : K'.card = K.card := same_card,
have hM' : M'.card = M.card := same_card,
have hN' : N'.card = N.card := same_card,
have hKM : K' ∩ M' = ∅ := disj zero_ne_one,
have hKN : K' ∩ N' = ∅ := disj zero_ne_two,
have hMN : M' ∩ N' = ∅ := disj one_ne_two,
have hK_MN : K' ∩ (M' ∪ N') = ∅, rw [inter_union, hKM, hKN, union_empty],
have hKM_N : (K' ∪ M') ∩ N' = ∅, rw [union_inter, hKN, hMN, union_empty],
rw hK at hK', rw hM at hM', rw hN at hN',
rw ←card_add_spec hM' hN' hMN,
rw ←card_mul_spec hK' rfl,
rw ←card_mul_spec hK' hM',
rw ←card_mul_spec hK' hN',
rw ←card_add_spec rfl rfl (prod_disj_of_right_disj hMN),
rw prod_union,
end
-- Theorem 6I part 4
theorem card_exp_add {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) {ν : Set} (hν : ν.is_cardinal) :
κ.card_exp (μ.card_add ν) = (κ.card_exp μ).card_mul (κ.card_exp ν) :=
begin
rcases hκ with ⟨K, hK⟩,
rcases hμ with ⟨M, hM⟩,
rcases hν with ⟨N, hN⟩,
let M' := M.prod {∅},
let N' := N.prod {one},
have hM' : M'.card = M.card := same_card,
have hN' : N'.card = N.card := same_card,
have hMN : M' ∩ N' = ∅ := disj zero_ne_one,
rw hM at hM', rw hN at hN',
rw ←card_add_spec hM' hN' hMN,
rw ←card_exp_spec hK rfl,
rw ←card_exp_spec hK hM',
rw ←card_exp_spec hK hN',
rw ←card_mul_spec rfl rfl,
rw card_equiv,
let f : Set := pair_sep_eq ((M' ∪ N').into_funs K) ((M'.into_funs K).prod (N'.into_funs K)) (λ g, (g.restrict M').pair (g.restrict N')),
have hfun : f.is_function := pair_sep_eq_is_fun,
have hdom : f.dom = (M' ∪ N').into_funs K, apply pair_sep_eq_dom_eq,
intros g hg, simp only [pair_mem_prod, mem_into_funs], rw mem_into_funs at hg, split,
{ exact restrict_into_fun hg subset_union_left, },
{ exact restrict_into_fun hg subset_union_right, },
have hran : f.ran = (M'.into_funs K).prod (N'.into_funs K), apply pair_sep_eq_ran_eq,
intros p hp, simp only [mem_prod, exists_prop, mem_into_funs] at hp,
rcases hp with ⟨g, hg, g', hg', he⟩, use g ∪ g', rw mem_into_funs,
refine ⟨union_fun_into_fun hg hg' hMN, _⟩, rw he, congr,
{ symmetry, rw ←hg.right.left, apply restrict_union_eq hg.left.left, rw [hg.right.left, hg'.right.left], exact hMN, },
{ symmetry, rw [←hg'.right.left, union_comm], apply restrict_union_eq hg'.left.left, rw [hg.right.left, hg'.right.left], rw inter_comm, exact hMN, },
have hoto : f.one_to_one, apply pair_sep_eq_oto, intros g hg g' hg' he, simp only [mem_into_funs] at hg hg',
apply fun_ext hg.left hg'.left,
{ rw [hg.right.left, hg'.right.left], },
intros i hi, rw [hg.right.left, mem_union] at hi, cases hi,
{ have hs : M' ⊆ g.dom, rw hg.right.left, exact subset_union_left,
have hs' : M' ⊆ g'.dom, rw hg'.right.left, exact subset_union_left,
rw ←@restrict_fun_value _ hg.left M' hs _ hi,
rw ←@restrict_fun_value _ hg'.left M' hs' _ hi,
rw (pair_inj he).left, },
{ have hs : N' ⊆ g.dom, rw hg.right.left, exact subset_union_right,
have hs' : N' ⊆ g'.dom, rw hg'.right.left, exact subset_union_right,
rw ←@restrict_fun_value _ hg.left N' hs _ hi,
rw ←@restrict_fun_value _ hg'.left N' hs' _ hi,
rw (pair_inj he).right, },
exact ⟨_, ⟨hfun, hdom, hran⟩, hoto⟩,
end
-- theorem 6I part 6
theorem card_exp_exp {κ : Set.{u}} (hκ : κ.is_cardinal) {μ : Set.{u}} (hμ : μ.is_cardinal) {ν : Set.{u}} (hν : ν.is_cardinal) :
(κ.card_exp μ).card_exp ν = κ.card_exp (μ.card_mul ν) :=
begin
rcases hκ with ⟨K, hK⟩,
rcases hμ with ⟨M, hM⟩,
rcases hν with ⟨N, hN⟩,
rw [←card_exp_spec hK hM, ←card_exp_spec rfl hN, ←card_mul_spec hM hN, ←card_exp_spec hK rfl, card_equiv],
let H : Set.{u} := pair_sep_eq (N.into_funs (M.into_funs K)) ((M.prod N).into_funs K) (λ f, pair_sep_eq (M.prod N) K (λ z, (f.fun_value z.snd).fun_value z.fst)),
refine ⟨H, ⟨pair_sep_eq_is_fun, pair_sep_eq_dom_eq _, pair_sep_eq_ran_eq _⟩, pair_sep_eq_oto _⟩,
{ intros f hf, rw mem_into_funs at *, dsimp, apply pair_sep_eq_into, intros z hz, rw mem_prod at hz,
rcases hz with ⟨m, hm, n, hn, he⟩, subst he, rw [fst_congr, snd_congr],
have hfn : (f.fun_value n).into_fun M K, rw ←mem_into_funs, apply hf.right.right,
apply fun_value_def'' hf.left, rw hf.right.left, exact hn,
apply hfn.right.right, apply fun_value_def'' hfn.left, rw hfn.right.left, exact hm, },
{ intros f hf, dsimp,
use pair_sep_eq N (M.into_funs K) (λ n, pair_sep_eq M K (λ m, f.fun_value (m.pair n))), split,
{ rw mem_into_funs, apply pair_sep_eq_into, intros n hn, rw mem_into_funs, apply pair_sep_eq_into,
intros m hm, rw mem_into_funs at hf, apply hf.right.right, apply fun_value_def'' hf.left,
rw [hf.right.left, pair_mem_prod], exact ⟨hm, hn⟩, },
{ rw mem_into_funs at hf, apply fun_ext hf.left pair_sep_eq_is_fun,
{ rw hf.right.left, symmetry, apply pair_sep_eq_dom_eq, intros z hz, rw mem_prod at hz, dsimp,
obtain ⟨a, aM, b, bN, zab⟩ := hz, subst zab, simp only [fst_congr, snd_congr],
have dom : (N.pair_sep_eq (M.into_funs K) (λ (n : Set), M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair n)))).dom = N,
apply pair_sep_eq_dom_eq, intros n nN, rw mem_into_funs, dsimp, apply pair_sep_eq_into,
intros m mM, apply hf.right.right, apply fun_value_def'' hf.left, rw [hf.right.left, pair_mem_prod],
exact ⟨mM, nN⟩,
rw ←dom at bN, rw pair_sep_eq_fun_value bN, dsimp,
have dom' : (M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair b))).dom = M,
apply pair_sep_eq_dom_eq, intros m mM, dsimp, apply hf.right.right, apply fun_value_def'' hf.left,
rw [hf.right.left, pair_mem_prod], rw dom at bN, exact ⟨mM, bN⟩,
rw ←dom' at aM, rw pair_sep_eq_fun_value aM, dsimp, apply hf.right.right, apply fun_value_def'' hf.left,
rw [hf.right.left, pair_mem_prod], rw dom at bN, rw dom' at aM, exact ⟨aM, bN⟩, },
{ intros z hz,
have hz' : z ∈ (pair_sep_eq (M.prod N) K (λ (z : Set),
((N.pair_sep_eq (M.into_funs K)
(λ (n : Set), M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair n)))).fun_value
z.snd).fun_value
z.fst)).dom,
have hd : (pair_sep_eq (M.prod N) K (λ (z : Set),
((N.pair_sep_eq (M.into_funs K)
(λ (n : Set), M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair n)))).fun_value
z.snd).fun_value
z.fst)).dom = (M.prod N),
apply pair_sep_eq_dom_eq, intros z hz, rw mem_prod at hz, dsimp,
obtain ⟨a, aM, b, bN, zab⟩ := hz, subst zab, simp only [snd_congr, fst_congr],
have dom : (N.pair_sep_eq (M.into_funs K) (λ (n : Set), M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair n)))).dom = N,
apply pair_sep_eq_dom_eq, intros n nN, rw mem_into_funs, dsimp, apply pair_sep_eq_into,
intros m mM, apply hf.right.right, apply fun_value_def'' hf.left, rw [hf.right.left, pair_mem_prod],
exact ⟨mM, nN⟩,
rw ←dom at bN, rw pair_sep_eq_fun_value bN, dsimp,
have dom' : (M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair b))).dom = M,
apply pair_sep_eq_dom_eq, intros m mM, dsimp, apply hf.right.right, apply fun_value_def'' hf.left,
rw [hf.right.left, pair_mem_prod], rw dom at bN, exact ⟨mM, bN⟩,
rw ←dom' at aM, rw pair_sep_eq_fun_value aM, dsimp, apply hf.right.right, apply fun_value_def'' hf.left,
rw [hf.right.left, pair_mem_prod], rw dom at bN, rw dom' at aM, exact ⟨aM, bN⟩,
rw hd, rw hf.right.left at hz, exact hz,
change f.fun_value z = (pair_sep_eq (M.prod N) K (λ (z : Set),
((N.pair_sep_eq (M.into_funs K)
(λ (n : Set), M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair n)))).fun_value
z.snd).fun_value
z.fst)).fun_value z,
rw pair_sep_eq_fun_value hz', rw [hf.right.left, mem_prod] at hz, rcases hz with ⟨m, hm, n, hn, he⟩, subst he,
dsimp, rw [fst_congr, snd_congr],
have hfn : n ∈ (pair_sep_eq N (M.into_funs K) (λ (n : Set), M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair n)))).dom,
have hd : (pair_sep_eq N (M.into_funs K) (λ (n : Set), M.pair_sep_eq K (λ (m : Set), f.fun_value (m.pair n)))).dom = N,
apply pair_sep_eq_dom_eq, intros n' hn', rw mem_into_funs, apply pair_sep_eq_into,
intros m' hm', apply hf.right.right, apply fun_value_def'' hf.left, rw [hf.right.left, pair_mem_prod], exact ⟨hm', hn'⟩,
rw hd, exact hn,
rw pair_sep_eq_fun_value hfn, dsimp,
have hfm : m ∈ (pair_sep_eq M K (λ (m : Set), f.fun_value (m.pair n))).dom,
have hd : (pair_sep_eq M K (λ (m : Set), f.fun_value (m.pair n))).dom = M,
apply pair_sep_eq_dom_eq, intros m' hm', dsimp, apply hf.right.right, apply fun_value_def'' hf.left,
rw [hf.right.left, pair_mem_prod], exact ⟨hm', hn⟩,
rw hd, exact hm,
rw pair_sep_eq_fun_value hfm, }, }, },
{ simp only [mem_into_funs], intros f hf g hg he, apply fun_ext hf.left hg.left,
{ rw [hf.right.left, hg.right.left], },
{ intros n hn,
have hf' : (f.fun_value n).into_fun M K, rw ←mem_into_funs, exact hf.right.right (fun_value_def'' hf.left hn),
have hg' : (g.fun_value n).into_fun M K, rw ←mem_into_funs, refine hg.right.right (fun_value_def'' hg.left _),
rw [hg.right.left, ←hf.right.left], exact hn,
apply fun_ext hf'.left hg'.left,
rw [hf'.right.left, hg'.right.left],
intros m hm,
have hf'' : (pair_sep_eq (M.prod N) K (λ (z : Set), (f.fun_value z.snd).fun_value z.fst)).fun_value (m.pair n)
= (f.fun_value (m.pair n).snd).fun_value (m.pair n).fst,
apply pair_sep_eq_fun_value,
have hd : (pair_sep_eq (M.prod N) K (λ (z : Set), (f.fun_value z.snd).fun_value z.fst)).dom = (M.prod N),
apply pair_sep_eq_dom_eq, intros z hz, dsimp, rw mem_prod at hz, rcases hz with ⟨m, hm, n', hn', he⟩, subst he,
rw [fst_congr, snd_congr],
have hfn' : (f.fun_value n').into_fun M K, rw ←mem_into_funs, refine hf.right.right (fun_value_def'' hf.left _),
rw hf.right.left, exact hn',
apply hfn'.right.right, apply fun_value_def'' hfn'.left, rw hfn'.right.left, exact hm,
rw [hd, pair_mem_prod], rw hf.right.left at hn, rw hf'.right.left at hm, exact ⟨hm, hn⟩,
have hg'' : (pair_sep_eq (M.prod N) K (λ (z : Set), (g.fun_value z.snd).fun_value z.fst)).fun_value (m.pair n)
= (g.fun_value (m.pair n).snd).fun_value (m.pair n).fst,
apply pair_sep_eq_fun_value,
have hd : (pair_sep_eq (M.prod N) K (λ (z : Set), (g.fun_value z.snd).fun_value z.fst)).dom = (M.prod N),
apply pair_sep_eq_dom_eq, intros z hz, dsimp, rw mem_prod at hz, rcases hz with ⟨m, hm, n', hn', he⟩, subst he,
rw [fst_congr, snd_congr],
have hgn' : (g.fun_value n').into_fun M K, rw ←mem_into_funs, refine hg.right.right (fun_value_def'' hg.left _),
rw hg.right.left, exact hn',
apply hgn'.right.right, apply fun_value_def'' hgn'.left, rw hgn'.right.left, exact hm,
rw [hd, pair_mem_prod], rw hf.right.left at hn, rw hf'.right.left at hm, exact ⟨hm, hn⟩,
rw [fst_congr, snd_congr] at hf'' hg'',
rw [←hf'', ←hg'', he], }, },
end
theorem one_card_mul_eq_self {κ : Set} (hκ : κ.is_cardinal) : one.card_mul κ = κ :=
begin
rw card_mul_comm (nat_is_cardinal one_nat) hκ, exact card_mul_one_eq_self hκ,
end
lemma card_add_empty {κ : Set} (hκ : κ.is_cardinal) : κ.card_add ∅ = κ :=
begin
rcases hκ with ⟨K, hK⟩,
rw ←card_add_spec hK (card_nat zero_nat) inter_empty, rw union_empty, exact hK,
end
lemma card_empty_add {κ : Set} (hκ : κ.is_cardinal) : card_add ∅ κ = κ :=
begin
rw card_add_comm (nat_is_cardinal zero_nat) hκ, exact card_add_empty hκ,
end
lemma T6J_a2 {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : κ.card_add (μ.card_add one) = (κ.card_add μ).card_add one :=
card_add_assoc hκ hμ (nat_is_cardinal one_nat)
lemma card_mul_empty {κ : Set} (hκ : κ.is_cardinal) : κ.card_mul ∅ = ∅ :=
begin
rcases hκ with ⟨K, hK⟩,
rw ←card_mul_spec hK (card_nat zero_nat), rw prod_empty_eq_empty, exact card_nat zero_nat,
end
lemma T6J_m2 {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : κ.card_mul (μ.card_add one) = (κ.card_mul μ).card_add κ :=
begin
rw card_mul_add hκ hμ (nat_is_cardinal one_nat), congr,
rcases hκ with ⟨K, hK⟩, rw ←card_mul_spec hK (card_nat one_nat), rw ←hK,
rw [one, succ, union_empty], exact same_card,
end
lemma card_exp_empty {κ : Set} (hκ : κ.is_cardinal) : κ.card_exp ∅ = one :=
begin
rcases hκ with ⟨K, hK⟩, rw ←card_exp_spec hK (card_nat zero_nat), rw ex2,
have h : {∅} = one, rw [one, succ, union_empty],
rw h, exact card_nat one_nat,
end
--set_option pp.notation false
lemma T6J_e2 {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : κ.card_exp (μ.card_add one) = (κ.card_exp μ).card_mul κ :=
begin
rw card_exp_add hκ hμ (nat_is_cardinal one_nat), congr,
rcases hκ with ⟨K, hK⟩, rw [←card_exp_spec hK (card_nat one_nat), ←hK, card_equiv],
let f : Set := pair_sep_eq (one.into_funs K) K (λ g, g.fun_value ∅),
have hfun : f.is_function := pair_sep_eq_is_fun,
have hdom : f.dom = one.into_funs K, apply pair_sep_eq_dom_eq,
intros g hg, rw mem_into_funs at hg, apply hg.right.right, apply fun_value_def'' hg.left, rw [hg.right.left, one], exact self_mem_succ,
have hran : f.ran = K, apply pair_sep_eq_ran_eq, intros x hx, use {(∅ : Set).pair x}, rw mem_into_funs,
rw [one, succ, union_empty], refine ⟨single_pair_into hx, _⟩,
symmetry, exact single_pair_fun_value,
have hoto : f.one_to_one, apply pair_sep_eq_oto, intros g hg g' hg' he, rw Set.mem_into_funs at hg hg',
apply fun_ext hg.left hg'.left,
rw [hg.right.left, hg'.right.left],
intros x hx, rw [hg.right.left, one, succ, union_empty, mem_singleton] at hx, rw hx, exact he,
exact ⟨_, ⟨hfun, hdom, hran⟩, hoto⟩,
end
lemma card_singleton {x : Set} : card {x} = one :=
begin
rw [←card_nat one_nat, card_equiv, one, succ, union_empty],
exact singleton_equin,
end
lemma card_insert {A x : Set} (xA : x ∉ A) : (insert x A).card = A.card.card_add one :=
begin
have h : insert x A = {x} ∪ A,
simp only [←ext_iff, mem_insert, mem_union, mem_singleton, forall_const, iff_self],
rw [h, union_comm], apply card_add_spec rfl card_singleton, rw eq_empty,
intros z zAx, rw [mem_inter, mem_singleton] at zAx, rcases zAx with ⟨zA, zx⟩, subst zx,
exact xA zA,
end
lemma card_add_one_eq_succ {n : Set} (hn : n.finite_cardinal) : n.card_add one = n.succ :=
begin
rcases hn with ⟨N, hf, hN⟩, have hn := (card_finite hf).left, rw hN at hn,
have h : card {n} = one, rw [←card_nat one_nat, card_equiv, one, succ, union_empty], exact singleton_equin,
rw [←card_add_spec (card_nat hn) h, union_comm, ←succ],
exact card_nat (nat_induct.succ_closed hn),
simp only [eq_empty, mem_inter, mem_singleton],
rintros k ⟨hk, he⟩, rw he at hk, exact nat_not_mem_self hn hk,
end
-- Theorem 6J
theorem card_add_eq_ord_add {m : Set} (hm : m.finite_cardinal) {n : Set} (hn : n.finite_cardinal) : m.card_add n = m + n :=
begin
rw finite_cardinal_iff_nat at hm hn, revert n, apply induction,
rw [card_add_empty (nat_is_cardinal hm), add_base hm],
intros k hk hi,
have hk' : k.finite_cardinal, rw finite_cardinal_iff_nat, exact hk,
nth_rewrite 0 ←card_add_one_eq_succ hk',
rw [T6J_a2 (nat_is_cardinal hm) (nat_is_cardinal hk), hi],
have hmk : (m + k).finite_cardinal, rw finite_cardinal_iff_nat, exact add_into_nat hm hk,
rw [card_add_one_eq_succ hmk, add_ind hm hk],
end
lemma eq_union_of_card_succ {A n : Set} (nω : n ∈ ω) (Acard : A.card = n.succ) : ∃ B x : Set, A = B ∪ {x} ∧ B.card = n ∧ x ∈ A ∧ x ∉ B :=
begin
have Ane : A ≠ ∅, intro Ae, subst Ae,
rw [card_nat zero_nat] at Acard, exact succ_neq_empty Acard.symm,
obtain ⟨x, xA⟩ := inhabited_of_ne_empty Ane,
refine ⟨A \ {x}, x, (diff_singleton_union_eq xA).symm, _, xA, _⟩,
have Afin : A.is_finite, rw finite_iff, exact ⟨_, nat_induct.succ_closed nω, Acard⟩,
have fin : (A \ {x}).is_finite := subset_finite_of_finite Afin subset_diff,
rw finite_iff at fin, rcases fin with ⟨m, mω, Axm⟩, rw Axm,
apply cancel_add_right mω nω one_nat,
have onefin : one.finite_cardinal, rw finite_cardinal_iff_nat, exact one_nat,
have nfin : n.finite_cardinal, rw finite_cardinal_iff_nat, exact nω,
have mfin : m.finite_cardinal, rw finite_cardinal_iff_nat, exact mω,
rw [←card_add_eq_ord_add mfin onefin, ←card_add_eq_ord_add nfin onefin, card_add_one_eq_succ nfin],
rw [←Axm, ←@card_singleton x, card_add_comm ⟨_, rfl⟩ ⟨_, rfl⟩, ←card_add_spec rfl rfl self_inter_diff_empty],
rw [union_comm, diff_singleton_union_eq xA, Acard],
intro xAx, rw [mem_diff, mem_singleton] at xAx, exact xAx.right rfl,
end
theorem card_mul_eq_ord_mul {m : Set} (hm : m.finite_cardinal) {n : Set} (hn : n.finite_cardinal) : m.card_mul n = m * n :=
begin
rw finite_cardinal_iff_nat at hm hn, revert n, apply induction,
rw [card_mul_empty (nat_is_cardinal hm), mul_base hm],
intros k hk hi,
have hm' : m.finite_cardinal, rw finite_cardinal_iff_nat, exact hm,
have hk' : k.finite_cardinal, rw finite_cardinal_iff_nat, exact hk,
nth_rewrite 0 ←card_add_one_eq_succ hk',
rw [T6J_m2 (nat_is_cardinal hm) (nat_is_cardinal hk), hi],
have hmk : (m * k).finite_cardinal, rw finite_cardinal_iff_nat, exact mul_into_nat hm hk,
rw [card_add_eq_ord_add hmk hm', mul_ind hm hk],
end
theorem card_exp_eq_ord_exp {m : Set} (hm : m.finite_cardinal) {n : Set} (hn : n.finite_cardinal) : m.card_exp n = m ^ n :=
begin
rw finite_cardinal_iff_nat at hm hn, revert n, apply induction,
rw [card_exp_empty (nat_is_cardinal hm), exp_base hm],
intros k hk hi,
have hm' : m.finite_cardinal, rw finite_cardinal_iff_nat, exact hm,
have hk' : k.finite_cardinal, rw finite_cardinal_iff_nat, exact hk,
nth_rewrite 0 ←card_add_one_eq_succ hk',
rw [T6J_e2 (nat_is_cardinal hm) (nat_is_cardinal hk), hi],
have hmk : (m ^ k).finite_cardinal, rw finite_cardinal_iff_nat, exact exp_into_nat hm hk,
rw [card_mul_eq_ord_mul hmk hm', exp_ind hm hk],
end
lemma card_mul_fin_of_fin {κ : Set} (κfin : κ.finite_cardinal) {μ : Set} (μfin : μ.finite_cardinal) : (κ.card_mul μ).finite_cardinal :=
begin
rw [finite_cardinal_iff_nat, card_mul_eq_ord_mul κfin μfin],
rw finite_cardinal_iff_nat at κfin μfin, exact mul_into_nat κfin μfin,
end
-- example 8, page 142
theorem card_add_self_eq_two_mul_self {κ : Set} (hκ : κ.is_cardinal) : κ.card_add κ = two.card_mul κ :=
begin
rw [card_mul_comm (nat_is_cardinal two_nat) hκ, two, succ_eq_add_one one_nat],
have one_fin : one.finite_cardinal, rw finite_cardinal_iff_nat, exact one_nat,
rw [←card_add_eq_ord_add one_fin one_fin, card_mul_add hκ (nat_is_cardinal one_nat) (nat_is_cardinal one_nat)],
rw [card_mul_one_eq_self hκ],
end
-- Corollary 6K
theorem union_finite_of_finite {A : Set} (hA : A.is_finite) {B : Set} (hB : B.is_finite) : (A ∪ B).is_finite :=
begin
rw union_eq_union_diff,
have hB' : (B \ A).is_finite := subset_finite_of_finite hB subset_diff,
have hdisj : A ∩ (B \ A) = ∅ := self_inter_diff_empty,
rw finite_iff at *, rcases hA with ⟨n, hn, hA⟩, rcases hB' with ⟨m, hm, hB'⟩, refine ⟨n + m, add_into_nat hn hm, _⟩,
rw card_add_spec hA hB' hdisj, apply card_add_eq_ord_add,
rw finite_cardinal_iff_nat, exact hn,
rw finite_cardinal_iff_nat, exact hm,
end
theorem prod_finite_of_finite {A : Set} (hA : A.is_finite) {B : Set} (hB : B.is_finite) : (A.prod B).is_finite :=
begin
rw finite_iff at *, rcases hA with ⟨n, hn, hA⟩, rcases hB with ⟨m, hm, hB⟩, refine ⟨n * m, mul_into_nat hn hm, _⟩,
rw card_mul_spec hA hB, apply card_mul_eq_ord_mul,
rw finite_cardinal_iff_nat, exact hn,
rw finite_cardinal_iff_nat, exact hm,
end
theorem into_funs_finite_of_finite {A : Set} (hA : A.is_finite) {B : Set} (hB : B.is_finite) : (B.into_funs A).is_finite :=
begin
rw finite_iff at *, rcases hA with ⟨n, hn, hA⟩, rcases hB with ⟨m, hm, hB⟩, refine ⟨n ^ m, exp_into_nat hn hm, _⟩,
rw card_exp_spec hA hB, apply card_exp_eq_ord_exp,
rw finite_cardinal_iff_nat, exact hn,
rw finite_cardinal_iff_nat, exact hm,
end
lemma dominates_self {A : Set} : A ≼ A := ⟨A.id, id_into, id_oto⟩
lemma dominated_sub {A B : Set} (h : A ⊆ B) : A ≼ B := ⟨A.id, into_of_into_ran_sub h id_into, id_oto⟩
lemma dominated_of_equin_of_dominated {K₁ K₂ : Set} (hK : K₂.equinumerous K₁) {L₁ L₂ : Set} (hL : L₁.equinumerous L₂) (h : K₁ ≼ L₁) : (K₂ ≼ L₂) :=
begin
rcases hK with ⟨F, Fonto, Foto⟩, rcases hL with ⟨G, Gonto, Goto⟩, rcases h with ⟨D, Dinto, Doto⟩,
let H : Set := G.comp (D.comp F),
exact ⟨H, comp_into_fun (comp_into_fun (into_of_onto Fonto) Dinto) (into_of_onto Gonto),
comp_one_to_one Goto (comp_one_to_one Doto Foto)⟩,
end
lemma dominated_iff_equin {K₁ K₂ : Set} (hK : K₁.equinumerous K₂) {L₁ L₂ : Set} (hL : L₁.equinumerous L₂) : K₁ ≼ L₁ ↔ K₂ ≼ L₂ :=
⟨λ h, dominated_of_equin_of_dominated (equin_symm hK) hL h, λ h, dominated_of_equin_of_dominated hK (equin_symm hL) h⟩
def card_le (κ μ : Set) : Prop := ∀ ⦃K : Set⦄, K.card = κ → ∀ ⦃M : Set⦄, M.card = μ → K ≼ M
lemma card_le_iff_equin {κ K : Set} (hK : K.card = κ) {μ M : Set} (hM : M.card = μ) : κ.card_le μ ↔ K ≼ M :=
begin
split,
{ intro h, exact h hK hM, },
{ intros h K' hK' M' hM', apply dominated_of_equin_of_dominated _ _ h,
rw [←card_equiv, hK, hK'],
rw [←card_equiv, hM, hM'], },
end
lemma card_le_iff_equin' {K L : Set} : K.card.card_le L.card ↔ K ≼ L :=
⟨λ h, (card_le_iff_equin rfl rfl).mp h, λ h, (card_le_iff_equin rfl rfl).mpr h⟩
def card_lt (κ μ : Set) : Prop := κ.card_le μ ∧ κ ≠ μ
lemma card_lt_iff {K L : Set} : K.card.card_lt L.card ↔ K ≼ L ∧ K ≉ L :=
by simp only [card_lt, card_le_iff_equin', ←card_equiv]
lemma card_le_iff {κ μ : Set} : κ.card_le μ ↔ κ.card_lt μ ∨ κ = μ :=
begin
let P : Prop := κ = μ,
rw [card_lt, and_or_distrib_right, or_comm (¬ P) _, (iff_true (P ∨ ¬P)).mpr (classical.em P), and_true], split,
intro h, exact or.inl h,
rintro (h|h),
exact h,
intros K hK M hM, rw [←hK, ←hM] at h, rw dominated_iff, use M, refine ⟨subset_self, _⟩,
rw ←card_equiv, exact h,
end
lemma card_le_of_subset {A B : Set} (hAB : A ⊆ B) : A.card.card_le B.card :=
begin
rw card_le_iff_equin rfl rfl, exact ⟨A.id, into_of_into_ran_sub hAB id_into, id_oto⟩,
end
lemma exists_sets_of_card_le {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (h : κ.card_le μ) :
∃ K M : Set, K ⊆ M ∧ K.card = κ ∧ M.card = μ :=
begin
rcases hκ with ⟨K, hK⟩, rcases hμ with ⟨M, hM⟩,
have hd : K ≼ M, rw [←card_le_iff_equin rfl rfl, hK, hM], exact h,
rcases hd with ⟨f, finto, foto⟩,
refine ⟨f.ran, M, finto.right.right, _, hM⟩,
rw [←hK, card_equiv], apply equin_symm, exact ⟨f, ⟨finto.left, finto.right.left, rfl⟩, foto⟩,
end
lemma exists_equin_subset_of_dominated {A B : Set} (h : A ≼ B) : ∃ K : Set, K ⊆ B ∧ K ≈ A :=
begin
rcases h with ⟨f, finto, foto⟩,
exact ⟨f.ran, finto.right.right, equin_symm ⟨f, ⟨finto.left, finto.right.left, rfl⟩, foto⟩⟩,
end
lemma finite_of_dominated_by_finite {B : Set} (hB : B.is_finite) {A : Set} (hAB : A ≼ B) : A.is_finite :=
begin
obtain ⟨K, hKB, hKA⟩ := exists_equin_subset_of_dominated hAB,
exact finite_of_equin_finite (subset_finite_of_finite hB hKB) hKA,
end
lemma infinite_of_dominates_infinite {A : Set} (hA : ¬ A.is_finite) {B : Set} (hAB : A ≼ B) : ¬ B.is_finite :=
begin
intro hfin, apply hA, exact finite_of_dominated_by_finite hfin hAB,
end
local attribute [instance] classical.prop_decidable
lemma zero_card_le {κ : Set} (hκ : κ.is_cardinal) : card_le ∅ κ :=
begin
rcases hκ with ⟨K, hK⟩, rw [←hK, ←card_nat zero_nat], apply card_le_of_subset,
intros z hz, exfalso, exact mem_empty _ hz,
end
lemma finite_card_lt_aleph_null {n : Set} (hn : n.finite_cardinal) : n.card_lt (card ω) :=
begin
rw finite_cardinal_iff_nat at hn, rw [←card_nat hn, card_lt], split,
apply card_le_of_subset, exact subset_nat_of_mem_nat hn,
intro h, apply nat_infinite, rw card_equiv at h, exact ⟨_, hn, equin_symm h⟩,
end
lemma finite_card_lt_aleph_null' {X : Set} (Xfin : X.is_finite) : X.card.card_lt (card ω) :=
finite_card_lt_aleph_null ⟨_, Xfin, rfl⟩
lemma finite_card_le_iff_le {m : Set} (hm : m.finite_cardinal) {n : Set} (hn : n.finite_cardinal) : m.card_le n ↔ m ≤ n :=
begin
split,
{ intro h,
rw finite_cardinal_iff_nat at hn hm,
rw [←card_nat hm, ←card_nat hn, card_le_iff_equin'] at h,
apply le_of_not_lt hn hm, intro hnm, rw ←nat_ssub_iff_mem hn hm at hnm,
rcases h with ⟨f, finto, foto⟩,
exact pigeonhole'' (ssub_of_sub_of_ssub finto.right.right hnm) ⟨f, onto_ran_of_into finto, foto⟩ (nat_finite hm), },
{ intro h,
rw finite_cardinal_iff_nat at hn hm,
rw ←nat_sub_iff_le hm hn at h,
rw [←card_nat hm, ←card_nat hn],
exact card_le_of_subset h, },
end
lemma finite_card_lt_iff_lt {m : Set} (hm : m.finite_cardinal) {n : Set.{u}} (hn : n.finite_cardinal) : m.card_lt n ↔ m ∈ n :=
begin
have nω : n ∈ nat.{u}, rwa ←finite_cardinal_iff_nat,
simp only [lt_iff' nω, card_lt], exact and_congr_left' (finite_card_le_iff_le hm hn),
end
lemma card_lt_exp {κ : Set} (hκ : κ.is_cardinal) : card_lt κ (card_exp two κ) :=
begin
rcases hκ with ⟨K, hK⟩, rw [←hK, ←card_power, card_lt_iff], split,
let f := pair_sep_eq K K.powerset (λ x, {x}),
have finto : f.into_fun K K.powerset, apply pair_sep_eq_into, intros x hx,
simp only [mem_powerset], intros z hz, rw mem_singleton at hz, rw hz, exact hx,
have foto : f.one_to_one, apply pair_sep_eq_oto, intros x hx x' hx' he,
rw ←ext_iff at he, simp only [mem_singleton] at he, specialize he x, rw ←he,
exact ⟨f, finto, foto⟩,
exact not_equin_powerset,
end
lemma card_le_refl {κ : Set} : κ.card_le κ :=
begin
intros K hK M hM, rw [←hM, card_equiv] at hK, rw dominated_iff, exact ⟨_, subset_self, hK⟩,
end
lemma card_le_trans {κ μ : Set} (hμ : μ.is_cardinal) (hκμ : κ.card_le μ) {ν : Set} (hμν : μ.card_le ν) : κ.card_le ν :=
begin
rcases hμ with ⟨M, hM⟩, intros K hK N hN, specialize hκμ hK hM, specialize hμν hM hN,
rcases hκμ with ⟨f, finto, foto⟩, rcases hμν with ⟨g, ginto, goto⟩,
exact ⟨g.comp f, comp_into_fun finto ginto, comp_one_to_one goto foto⟩,
end
-- Schröer-Bernstein Theorem part a
lemma equin_of_dom_of_dom {A B : Set} (hAB : A ≼ B) (hBA : B ≼ A) : A ≈ B :=
begin
rcases hAB with ⟨f, finto, foto⟩, rcases hBA with ⟨g, ginto, goto⟩,
let C : ℕ → Set := @nat.rec (λ n, Set) (A \ g.ran) (λ _ C, g.img (f.img C)),
have hnz : ∀ {x}, x ∈ A → ¬ (∃ n, x ∈ C n) → x ∈ g.ran, intros x hx hc,
have hnz : x ∉ A \ g.ran, intro hz, exact hc ⟨0, hz⟩,
rw [mem_diff] at hnz, apply by_contradiction, intro hngr, exact hnz ⟨hx, hngr⟩,
have Csub : ∀ {n}, C n ⊆ A, intro n, induction n with n ih,
{ exact subset_diff, },
{ exact subset_trans img_subset_ran ginto.right.right, },
let h' : Set → Set := (λ x, if ∃ n, x ∈ C n then f.fun_value x else g.inv.fun_value x),
let h := pair_sep_eq A B h',
have hfun := pair_sep_eq_is_fun,
have hdom : h.dom = A, apply pair_sep_eq_dom_eq, intros x hx,
by_cases hc : ∃ n, x ∈ C n,
{ dsimp [h'], simp only [hc, if_true], apply finto.right.right, apply fun_value_def'' finto.left,
rw finto.right.left, exact hx, },
{ dsimp [h'], simp only [hc, if_false, ←ginto.right.left, ←T3E_b],
apply fun_value_def'',
rw T3F_a, exact goto,
rw T3E_a, exact hnz hx hc, },
have hoto : h.one_to_one, apply pair_sep_eq_oto,
have hb : ∀ {x}, x ∈ A → (∃ n, x ∈ C n) → ∀ {x'}, x' ∈ A → (¬ ∃ n, x' ∈ C n) → h' x = h' x' → x = x',
intros x hx hc x' hx' hc' he,
dsimp [h'] at he, simp only [hc, hc', if_true, if_false] at he,
rcases hc with ⟨n, hc⟩,
have hf : f.fun_value x ∈ f.img (C n), refine fun_value_mem_img finto.left _ hc,
rw finto.right.left, exact Csub,
rw he at hf, rw mem_img' finto.left at hf, rcases hf with ⟨x'', hc'', he'⟩,
have he'' : g.fun_value (g.inv.fun_value x') = g.fun_value (f.fun_value x''), rw he',
rw ←T3H_c ginto.left (T3F_a.mpr goto) at he'', rw eq_inv_id ginto.left goto at he'',
rw id_value (hnz hx' hc') at he'', exfalso, apply hc', use n.succ,
have h' : f.img (C n) ⊆ g.dom, rw ginto.right.left, exact subset_trans img_subset_ran finto.right.right,
have h'' : C n ⊆ f.dom, rw finto.right.left, exact Csub,
simp only [mem_img' ginto.left h', mem_img' finto.left h''],
refine ⟨f.fun_value x'', ⟨_, hc'', rfl⟩, he''⟩,
have h''' : g.inv.ran ⊆ g.dom, rw [T3E_b, ginto.right.left], exact subset_self,
rw [dom_comp h''', T3E_a], exact hnz hx' hc',
rw finto.right.left, exact Csub,
intros x hx x' hx' he,
by_cases hc : (∃ n, x ∈ C n);
by_cases hc' : ∃ n, x' ∈ C n,
{ dsimp [h'] at he, simp only [hc, hc', if_true] at he, rw [←finto.right.left] at hx hx',
exact from_one_to_one finto.left foto hx hx' he, },
{ exact hb hx hc hx' hc' he, },
{ symmetry, exact hb hx' hc' hx hc he.symm, },
{ dsimp [h'] at he, simp only [hc, hc', if_false] at he,
apply from_one_to_one (T3F_a.mpr goto) ((T3F_b ginto.left.left).mp ginto.left),
rw T3E_a, exact hnz hx hc,
rw T3E_a, exact hnz hx' hc',
exact he, },
have hran : h.ran = B, apply pair_sep_eq_ran_eq, intros y hy,
by_cases hc : ∃ n, y ∈ f.img (C n),
{ rcases hc with ⟨n, hc⟩,
have Csub' : C n ⊆ f.dom, rw finto.right.left, exact Csub,
simp only [mem_img' finto.left Csub'] at hc,
rcases hc with ⟨x, hx, hc⟩, refine ⟨x, Csub hx, _⟩,
dsimp [h'], simp only [exists.intro n hx, if_true], exact hc, },
{ refine ⟨g.fun_value y, _, _⟩,
apply ginto.right.right, apply fun_value_def'' ginto.left, rw ginto.right.left, exact hy,
have hne : ¬ ∃ n, g.fun_value y ∈ C n, rintro ⟨n, hn⟩,
cases n with n,
rw mem_diff at hn, apply hn.right, apply fun_value_def'' ginto.left, rw ginto.right.left, exact hy,
have hfimg : f.img (C n) ⊆ g.dom, rw ginto.right.left, exact subset_trans img_subset_ran finto.right.right,
rw mem_img' ginto.left hfimg at hn, rcases hn with ⟨y', hy', he⟩, apply hc, use n,
suffices he' : y = y',
rw he', exact hy',
refine from_one_to_one ginto.left goto _ _ he,
rw ginto.right.left, exact hy,
rw ginto.right.left, exact (subset_trans img_subset_ran finto.right.right) hy',
dsimp [h'], simp only [hne, if_false],
rw [←T3H_c (T3F_a.mpr goto) ginto.left, eq_id ginto.left goto, ginto.right.left, id_value hy],
rw [dom_comp, ginto.right.left], exact hy,
rw T3E_a, exact subset_self, },
exact ⟨_, ⟨hfun, hdom, hran⟩, hoto⟩,
end
-- Schröer-Bernstein Theorem part b
lemma card_eq_of_le_of_le {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hκμ : κ.card_le μ) (hμκ : μ.card_le κ) : κ = μ :=
begin
rcases hκ with ⟨K, hK⟩, rcases hμ with ⟨M, hM⟩, rw [←hK, ←hM, card_equiv],
apply equin_of_dom_of_dom (hκμ hK hM) (hμκ hM hK),
end
lemma card_lt_trans {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hκμ : κ.card_lt μ) {ν : Set} (hμν : μ.card_lt ν) : κ.card_lt ν :=
begin
rcases hκμ with ⟨κlμ, κeμ⟩, rcases hμν with ⟨μlν, μeν⟩,
refine ⟨card_le_trans hμ κlμ μlν, λ κeν, _⟩,
subst κeν, apply κeμ, exact card_eq_of_le_of_le hκ hμ κlμ μlν,
end
lemma not_card_lt_cycle {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) : ¬ (κ.card_lt μ ∧ μ.card_lt κ) :=
λ h, (card_lt_trans hκ hμ h.left h.right).right rfl
lemma card_lt_of_le_of_lt {κ : Set} (κcard : κ.is_cardinal) {μ : Set} (μcard : μ.is_cardinal) (κμ : κ.card_le μ) {ν : Set} (μν : μ.card_lt ν) : κ.card_lt ν :=
begin
rw card_le_iff at κμ, cases κμ,
exact card_lt_trans κcard μcard κμ μν,
subst κμ, exact μν,
end
-- Too lazy to do all of theorem 6L
-- Theorem 6L part a
theorem card_add_le_of_le_left {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hκμ : κ.card_le μ)
{ν : Set} (hν : ν.is_cardinal) : (κ.card_add ν).card_le (μ.card_add ν) :=
begin
rcases hκ with ⟨K, hK⟩,
rcases hμ with ⟨M, hM⟩,
rcases hν with ⟨N, hN⟩,
let M' := M.prod {∅},
let N' := N.prod {one},
have hM' : M'.card = μ, rw ←hM, exact same_card,
have hN' : N'.card = ν, rw ←hN, exact same_card,
have hdisj : M' ∩ N' = ∅ := disj zero_ne_one,
rw [←hK, ←hM', card_le_iff_equin', dominated_iff] at hκμ,
rcases hκμ with ⟨K', hKM', hK'⟩,
have hdisj' : K' ∩ N' = ∅, rw eq_empty, intros x hx, rw mem_inter at hx,
apply mem_empty x, rw ←hdisj, rw mem_inter, exact ⟨hKM' hx.left, hx.right⟩,
rw [←card_equiv, hK] at hK',
rw [←card_add_spec hK'.symm hN' hdisj', ←card_add_spec hM' hN' hdisj],
apply card_le_of_subset, apply union_subset_of_subset_of_subset,
exact subset_trans hKM' subset_union_left,
exact subset_union_right,
end
theorem card_add_le_of_le_right {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hκμ : κ.card_le μ)
{ν : Set} (hν : ν.is_cardinal) : (ν.card_add κ).card_le (ν.card_add μ) :=
begin
rw [card_add_comm hν hκ, card_add_comm hν hμ], exact card_add_le_of_le_left hκ hμ hκμ hν,
end
-- Theorem 6L part b
theorem card_mul_le_of_le_left {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hκμ : κ.card_le μ)
{ν : Set} (hν : ν.is_cardinal) : (κ.card_mul ν).card_le (μ.card_mul ν) :=
begin
obtain ⟨K, M, hKM, hK, hM⟩ := exists_sets_of_card_le hκ hμ hκμ,
rcases hν with ⟨N, hN⟩,
rw [←card_mul_spec hK hN, ←card_mul_spec hM hN],
exact card_le_of_subset (prod_subset_of_subset_of_subset hKM subset_self),
end
theorem card_mul_le_of_le_right {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hκμ : κ.card_le μ)
{ν : Set} (hν : ν.is_cardinal) : (ν.card_mul κ).card_le (ν.card_mul μ) :=
begin
rw [card_mul_comm hν hκ, card_mul_comm hν hμ], exact card_mul_le_of_le_left hκ hμ hκμ hν,
end
-- Theorem 6L part c
theorem card_exp_le_of_le {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hκμ : κ.card_le μ)
{ν : Set} (hν : ν.is_cardinal) : (κ.card_exp ν).card_le (μ.card_exp ν) :=
begin
obtain ⟨K, M, hKM, hK, hM⟩ := exists_sets_of_card_le hκ hμ hκμ,
rcases hν with ⟨N, hN⟩,
rw [←card_exp_spec hK hN, ←card_exp_spec hM hN],
apply card_le_of_subset, intros f hf, rw mem_into_funs at *,
exact ⟨hf.left, hf.right.left, subset_trans hf.right.right hKM⟩,
end
-- excercise 15
theorem not_exists_dominators : ¬ ∃ K : Set, ∀ A : Set, ∃ B : Set, B ∈ K ∧ A ≼ B :=
begin
rintro ⟨K, h⟩, apply @not_equin_powerset K.Union, apply equin_of_dom_of_dom,
rw dominated_iff_equin equin_refl powerset_equinumerous_into_funs,
rw ←card_le_iff_equin', rw card_exp_spec rfl rfl, rw card_le_iff, left,
rw card_nat two_nat, exact card_lt_exp ⟨_, rfl⟩,
specialize h K.Union.powerset, rcases h with ⟨B, hBK, hB⟩,
rw ←card_le_iff_equin', rw ←card_le_iff_equin' at hB,
refine card_le_trans ⟨_, rfl⟩ hB _,
rw card_le_iff_equin',
exact dominated_sub (subset_Union_of_mem hBK),
end
lemma Union_chain_is_function {𝓑 : Set} (hch : 𝓑.is_chain) (hf : ∀ {f : Set}, f ∈ 𝓑 → f.is_function) : 𝓑.Union.is_function :=
begin
rw is_function_iff, split,
intros b hb, rw mem_Union at hb, rcases hb with ⟨B, hB𝓑, hbB⟩, specialize hf hB𝓑,
replace hf := hf.left, exact hf _ hbB,
intros x y y' hxy hxy', simp only [mem_Union, exists_prop] at hxy hxy',
rcases hxy with ⟨Z, hZ𝓑, hxyZ⟩, rcases hxy' with ⟨Z', hZ𝓑', hxyZ'⟩,
specialize hch hZ𝓑 hZ𝓑', cases hch,
specialize hf hZ𝓑', rw is_function_iff at hf, exact hf.right _ _ _ (hch hxyZ) hxyZ',
specialize hf hZ𝓑, rw is_function_iff at hf, exact hf.right _ _ _ hxyZ (hch hxyZ'),
end
lemma Union_chain_onto {X : Set} (Xch : X.is_chain) (Xf : ∀ ⦃f : Set⦄, f ∈ X → f.is_function) :
X.Union.onto_fun (repl_img dom X).Union (repl_img ran X).Union :=
begin
refine ⟨Union_chain_is_function Xch Xf, _, _⟩,
symmetry, apply dom_Union_eq_Union_dom, intro x,
simp only [mem_Union, exists_prop, mem_repl_img, ←exists_and_distrib_right, and_assoc],
rw exists_comm, simp only [exists_and_distrib_left, exists_eq_left, and_comm],
symmetry, apply ran_Union_eq_Union_ran, intro y,
simp only [mem_Union, exists_prop, mem_repl_img, ←exists_and_distrib_right, and_assoc],
rw exists_comm, simp only [exists_and_distrib_left, exists_eq_left, and_comm],
end
lemma Union_chain_fun_value {X : Set} (Xch : X.is_chain) (Xf : ∀ ⦃f : Set⦄, f ∈ X → f.is_function)
{f : Set} (fX : f ∈ X) {x : Set} (xf : x ∈ f.dom) : X.Union.fun_value x = f.fun_value x :=
begin
symmetry, apply fun_value_def (Union_chain_is_function Xch Xf),
rw mem_Union, exact ⟨_, fX, fun_value_def' (Xf fX) xf⟩,
end
lemma Union_chain_oto {𝓑 : Set} (hch : 𝓑.is_chain) (hf : ∀ {f : Set}, f ∈ 𝓑 → f.one_to_one) : 𝓑.Union.one_to_one :=
begin
rw one_to_one_iff, intros y x x' hxy hxy', rw mem_Union at hxy hxy',
rcases hxy with ⟨B, hB𝓑, hxyB⟩, rcases hxy' with ⟨B', hB𝓑', hxyB'⟩,
specialize hch hB𝓑 hB𝓑', cases hch,
replace hB𝓑' := hf hB𝓑', rw one_to_one_iff at hB𝓑',
exact hB𝓑' (hch hxyB) hxyB',
replace hB𝓑 := hf hB𝓑, rw one_to_one_iff at hB𝓑,
exact hB𝓑 hxyB (hch hxyB'),
end
theorem choice_equiv_6_1 : Axiom_of_choice_VI.{u} → Axiom_of_choice_I.{u} :=
begin
dsimp [Axiom_of_choice_VI, Axiom_of_choice_I], intros ax6 R hR,
let 𝓐 : Set := {f ∈ R.powerset | f.is_function},
have huncl : ∀ 𝓑 : Set, 𝓑.is_chain → 𝓑 ⊆ 𝓐 → 𝓑.Union ∈ 𝓐,
intros 𝓑 hch h𝓑𝓐, simp only [mem_sep, mem_powerset], split,
apply Union_subset_of_subset_powerset, intros B hB,
have h : B ∈ 𝓐 := h𝓑𝓐 hB,
rw Set.mem_sep at h, exact h.left,
apply Union_chain_is_function hch, intros f hf, specialize h𝓑𝓐 hf, rw mem_sep at h𝓑𝓐, exact h𝓑𝓐.right,
specialize ax6 _ huncl, rcases ax6 with ⟨F, hf𝓐, hmax⟩, rw [mem_sep, mem_powerset] at hf𝓐,
refine ⟨_, hf𝓐.right, hf𝓐.left, _⟩, apply ext, intros x, split,
intro hx, rw mem_dom at *, rcases hx with ⟨y, hxy⟩, exact ⟨_, hf𝓐.left hxy⟩,
intro hx, apply classical.by_contradiction, intro hnx, rw mem_dom at hx, rcases hx with ⟨y, hxy⟩,
let F' := F ∪ {x.pair y},
apply hmax F',
rw [mem_sep, mem_powerset], split,
apply union_subset_of_subset_of_subset hf𝓐.left,
intros z hz, rw mem_singleton at hz, subst hz, exact hxy,
apply union_singleton_is_fun hf𝓐.right hnx,
intros he,
have hxyF' : x.pair y ∈ F', rw [mem_union, mem_singleton], right, refl,
rw he at hxyF', apply hnx, rw mem_dom, exact ⟨_, hxyF'⟩,
exact subset_union_left,
end
theorem choice_equiv_6_5 : Axiom_of_choice_VI.{u} → Axiom_of_choice_V.{u} :=
begin
dsimp [Axiom_of_choice_VI, Axiom_of_choice_V], intros ax6 C D,
let 𝓐 : Set := {f ∈ (C.prod D).powerset | f.is_function ∧ f.one_to_one},
have h𝓐 : ∀ {f}, f ∈ 𝓐 ↔ f ⊆ C.prod D ∧ f.is_function ∧ f.one_to_one,
simp only [mem_sep, mem_powerset, iff_self, implies_true_iff],
have h𝓐' : ∀ {f : Set}, f ∈ 𝓐 → f.dom ⊆ C ∧ f.ran ⊆ D, intros f hf, rw h𝓐 at hf, split,
intros x hx, rw mem_dom at hx, rcases hx with ⟨y, hxy⟩,
have hxy' : x.pair y ∈ C.prod D := hf.left hxy,
rw pair_mem_prod at hxy', exact hxy'.left,
intros y hy, rw mem_ran at hy, rcases hy with ⟨x, hxy⟩,
have hxy' : x.pair y ∈ C.prod D := hf.left hxy,
rw pair_mem_prod at hxy', exact hxy'.right,
have huncl : ∀ 𝓑 : Set, 𝓑.is_chain → 𝓑 ⊆ 𝓐 → 𝓑.Union ∈ 𝓐,
intros 𝓑 hch 𝓑𝓐, rw h𝓐, split,
intros z hz, rw mem_Union at hz, rcases hz with ⟨B, hB𝓑, hzB⟩, specialize 𝓑𝓐 hB𝓑, rw h𝓐 at 𝓑𝓐,
exact 𝓑𝓐.left hzB,
split,
apply Union_chain_is_function hch, intros f hf, specialize 𝓑𝓐 hf, rw h𝓐 at 𝓑𝓐, exact 𝓑𝓐.right.left,
apply Union_chain_oto hch, intros f hf, specialize 𝓑𝓐 hf, rw h𝓐 at 𝓑𝓐, exact 𝓑𝓐.right.right,
specialize ax6 _ huncl, rcases ax6 with ⟨F, hF𝓐, hmax⟩,
specialize h𝓐' hF𝓐, rw h𝓐 at hF𝓐,
suffices h : C ⊆ F.dom ∨ D ⊆ F.ran, cases h,
left, refine ⟨_, ⟨hF𝓐.right.left, _, h𝓐'.right⟩, hF𝓐.right.right⟩,
rw eq_iff_subset_and_subset, exact ⟨h𝓐'.left, h⟩,
right, refine ⟨F.inv, ⟨_, _, _⟩, _⟩,
rw T3F_a, exact hF𝓐.right.right,
rw [T3E_a, eq_iff_subset_and_subset], exact ⟨h𝓐'.right, h⟩,
rw T3E_b, exact h𝓐'.left,
rw ←(T3F_b hF𝓐.right.left.left), exact hF𝓐.right.left,
apply classical.by_contradiction, intro hns,
simp only [not_or_distrib, subset_def, not_forall] at hns,
rcases hns with ⟨⟨c, hcC, hnc⟩, d, hdD, hnd⟩,
let F' : Set := F ∪ {c.pair d},
apply hmax F',
rw h𝓐, split,
apply union_subset_of_subset_of_subset hF𝓐.left, simp only [subset_def, mem_singleton],
intros z hz, subst hz, rw pair_mem_prod, exact ⟨hcC, hdD⟩,
split,
exact union_singleton_is_fun hF𝓐.right.left hnc,
exact union_singleton_one_to_one hF𝓐.right.right hnd,
intros he,
have hcdF' : c.pair d ∈ F', rw [mem_union, mem_singleton], right, refl,
rw he at hcdF', apply hnc, rw mem_dom, exact ⟨_, hcdF'⟩,
exact subset_union_left,
end
-- Theorem 6M completed
theorem choice_equiv_all : list.tfae [
Axiom_of_choice_I.{u},
Axiom_of_choice_II.{u},
Axiom_of_choice_III.{u},
Axiom_of_choice_IV.{u},
Axiom_of_choice_V.{u},
Axiom_of_choice_VI.{u},
WO.{u}] :=
begin
tfae_have : 1 → 2, refine list.tfae_prf choice_equiv _ _, finish, finish,
tfae_have : 2 → 4, refine list.tfae_prf choice_equiv _ _, finish, finish,
tfae_have : 4 → 3, refine list.tfae_prf choice_equiv _ _, finish, finish,
tfae_have : 3 → 1, refine list.tfae_prf choice_equiv _ _, finish, finish,
tfae_have : 6 → 1, exact choice_equiv_6_1,
tfae_have : 6 → 5, exact choice_equiv_6_5,
tfae_have : 3 → 7, exact choice_equiv_3_WO,
tfae_have : 5 → 7, exact choice_equiv_5_WO,
tfae_have : 7 → 6, exact choice_equiv_WO_6,
tfae_finish,
end
lemma ax_ch_6 : Axiom_of_choice_VI :=
begin
refine list.tfae_prf choice_equiv_all _ _ @ax_ch_3, finish, finish,
end
lemma ax_ch_5 : Axiom_of_choice_V :=
begin
refine list.tfae_prf choice_equiv_all _ _ @ax_ch_3, finish, finish,
end
lemma dominates_of_onto_fun {A B : Set} (he : ∃ f : Set, f.onto_fun A B) : B.dominated A :=
begin
rcases he with ⟨f, fonto⟩,
obtain ⟨g, ginto, hc⟩ := (T3J_b (into_of_onto fonto)).mpr fonto,
exact ⟨g, ginto, one_to_one_of_has_left_inv ginto ⟨_, into_of_onto fonto, hc⟩⟩,
end
lemma exists_onto_of_dominated {A B : Set} (hbne : B.inhab) (hd : B ≼ A) : ∃ g : Set, g.onto_fun A B :=
begin
rcases hd with ⟨f, finto, foto⟩, rw ←T3J_a finto hbne at foto,
rcases foto with ⟨g, ginto, gc⟩, use g, rw ←T3J_b ginto, exact ⟨_, finto, gc⟩,
end
lemma dominated_iff_exists_onto_fun {A B : Set} (hbne : B.inhab) : B ≼ A ↔ ∃ f : Set, f.onto_fun A B :=
⟨λ h, exists_onto_of_dominated hbne h, λ h, dominates_of_onto_fun h⟩
lemma nonempty_diff_of_finite_subset_of_inf {A : Set} (hA : ¬ A.is_finite) {B : Set} (hB : B.is_finite) (hBA : B ⊆ A) : A \ B ≠ ∅ :=
begin
intro he, simp only [eq_empty, mem_diff, not_and_distrib, ←imp_iff_not_or, not_not, ←subset_def] at he,
have he' : A = B, rw eq_iff_subset_and_subset, exact ⟨he, hBA⟩,
subst he', exact hA hB,
end
lemma singleton_finite {x : Set} : is_finite {x} :=
begin
refine ⟨one, one_nat, _⟩,
dsimp [one, succ], rw [union_empty],
exact singleton_equin,
end
-- Theorem 6N part a
theorem omega_least_infinite_set {A : Set.{u}} (hA : ¬ A.is_finite) : ω ≼ A :=
begin
let P : Set := {x ∈ A.powerset | x.is_finite},
have hP : P ⊆ A.powerset, intros x hx, rw [mem_sep] at hx, exact hx.left,
obtain ⟨F, Ffun, Fdom, hF⟩ := @ax_ch_3 A,
have Fran : F.ran ⊆ A, intros y hy, rw mem_ran at hy, rcases hy with ⟨x, hxy⟩,
have hd : x ∈ F.dom, rw mem_dom, exact ⟨_, hxy⟩,
specialize hF _ hd, rw [Fdom, mem_sep, mem_powerset] at hd, apply hd.left,
rw fun_value_def Ffun hxy, exact hF,
let hrec : Set := pair_sep_eq P P (λ a, a ∪ {F.fun_value (A \ a)}),
let h : Set := P.rec_fun ∅ hrec,
have hesA : ∅ ∈ P, rw [mem_sep, mem_powerset], refine ⟨_, _, zero_nat, equin_refl⟩, intros x hx, exfalso, exact mem_empty _ hx,
have hrecinto : hrec.into_fun P P, apply pair_sep_eq_into,
intros a ha, rw [mem_sep, mem_powerset] at *, refine ⟨union_subset_of_subset_of_subset ha.left _, _⟩,
intros x hx, rw mem_singleton at hx, subst hx,
have hd : A \ a ∈ F.dom, rw [Fdom, mem_sep, mem_powerset], refine ⟨subset_diff, _⟩,
apply nonempty_diff_of_finite_subset_of_inf hA ha.right ha.left,
specialize hF _ hd, rw mem_diff at hF, exact hF.left,
apply union_finite_of_finite ha.right singleton_finite,
have hh : ∀ {n : Set.{u}}, n ∈ (ω : Set.{u}) → (h.fun_value n) ⊆ A ∧ (h.fun_value n).is_finite, refine @induction _ _ _,
rw (recursion_thm hesA hrecinto).left, rw [mem_sep, mem_powerset] at hesA, exact hesA,
intros n hn hi, rw (recursion_thm hesA hrecinto).right _ hn,
have hd : h.fun_value n ∈ hrec.dom, rw [hrecinto.right.left, mem_sep, mem_powerset], exact hi,
rw pair_sep_eq_fun_value hd, refine ⟨union_subset_of_subset_of_subset hi.left _, union_finite_of_finite hi.right singleton_finite⟩,
intros x hx, rw mem_singleton at hx, subst hx, apply Fran, apply fun_value_def'' Ffun,
rw [Fdom, mem_sep, mem_powerset], refine ⟨subset_diff, nonempty_diff_of_finite_subset_of_inf hA hi.right hi.left⟩,
let g : Set := pair_sep_eq ω A (λ n, F.fun_value (A \ h.fun_value n)),
refine ⟨g, pair_sep_eq_into _, pair_sep_eq_oto _⟩,
intros n hn, apply Fran, apply fun_value_def'' Ffun, rw [Fdom, mem_sep, mem_powerset],
refine ⟨subset_diff, nonempty_diff_of_finite_subset_of_inf hA (hh hn).right (hh hn).left⟩,
have hs : ∀ {n : Set.{u}}, n ∈ (ω : Set.{u}) → ∀ {k : Set.{u}}, k ∈ (ω : Set.{u}) → h.fun_value n ⊆ h.fun_value (n + k),
intros n hn, apply @induction (λ k, h.fun_value n ⊆ h.fun_value (n + k)),
rw [add_base hn], exact subset_self,
intros k hk ih,
have hnknat : (n + k) ∈ (ω : Set.{u}) := add_into_nat hn hk,
rw [add_ind hn hk, (recursion_thm hesA hrecinto).right _ hnknat],
have hd : h.fun_value (n + k) ∈ hrec.dom, rw [hrecinto.right.left, mem_sep, mem_powerset], exact hh hnknat,
rw pair_sep_eq_fun_value hd, exact subset_union_of_subset ih,
have hlt : ∀ {n : Set.{u}}, n ∈ (ω : Set.{u}) → ∀ {m : Set.{u}}, m ∈ (ω : Set.{u}) → n ∈ m → F.fun_value (A \ h.fun_value n) ≠ F.fun_value (A \ h.fun_value m),
intros n hn m hm hnm he,
rw [mem_iff_succ_le hn hm, le_iff_exists (nat_induct.succ_closed hn) hm] at hnm,
rcases hnm with ⟨p, hp, hnpm⟩,
specialize hs (nat_induct.succ_closed hn) hp, rw hnpm at hs,
have hf : F.fun_value (A \ h.fun_value n) ∈ h.fun_value m, apply hs,
rw (recursion_thm hesA hrecinto).right _ hn,
have hd : h.fun_value n ∈ hrec.dom, rw [hrecinto.right.left, mem_sep, mem_powerset], exact hh hn,
rw [pair_sep_eq_fun_value hd, mem_union, mem_singleton], right, refl,
have hf' : F.fun_value (A \ h.fun_value m) ∉ h.fun_value m,
have hd : A \ h.fun_value m ∈ F.dom, rw [Fdom, mem_sep, mem_powerset],
refine ⟨subset_diff, nonempty_diff_of_finite_subset_of_inf hA (hh hm).right (hh hm).left⟩,
specialize hF _ hd, rw [mem_diff] at hF, exact hF.right,
change F.fun_value (A \ h.fun_value n) = F.fun_value (A \ h.fun_value m) at he,
rw he at hf, exact hf' hf,
intros n hn m hm he, apply classical.by_contradiction, intro hne,
cases nat_order_conn hn hm hne with hnm hmn,
exact hlt hn hm hnm he,
exact hlt hm hn hmn he.symm,
end
-- Theorem 6N part b
theorem aleph_null_least_infinite_cardinal {κ : Set} (hκ : κ.is_cardinal) (hinf : ¬ κ.finite_cardinal) : card_le (card ω) κ :=
begin
rcases hκ with ⟨K, hK⟩, rw ←hK, rw card_le_iff_equin',
apply omega_least_infinite_set, intro hf, exact hinf ⟨_, hf, hK⟩,
end
lemma equin_omega_of_inf_subset {A : Set} (hA : ¬ A.is_finite) (hA' : A ⊆ ω) : A ≈ ω :=
equin_of_dom_of_dom (dominated_sub hA') (omega_least_infinite_set hA)
lemma exists_sub_card_alpeh_null_of_inf {κ : Set} (hκ : ¬ κ.finite_cardinal) {B : Set} (hB : B.card = κ) : ∃ A : Set, A ⊆ B ∧ A.card = card ω :=
begin
have Binf : ¬ B.is_finite, intro fin, apply hκ, exact ⟨_, fin, hB⟩,
have h := omega_least_infinite_set Binf,
obtain ⟨A, hAB, hA⟩ := exists_equin_subset_of_dominated h,
rw ←card_equiv at hA,
exact ⟨_, hAB, hA⟩,
end
lemma card_lt_aleph_null_iff_finite {κ : Set} (hκ : κ.is_cardinal) : κ.card_lt (card ω) ↔ κ.finite_cardinal :=
begin
split,
intros hlt, apply classical.by_contradiction, intro hnf, apply hlt.right,
apply card_eq_of_le_of_le hκ ⟨_, rfl⟩,
exact hlt.left,
exact aleph_null_least_infinite_cardinal hκ hnf,
intro hf, exact finite_card_lt_aleph_null hf,
end
lemma card_inf_of_ge_inf {κ : Set} (κcard : κ.is_cardinal) (κfin : ¬ κ.finite_cardinal)
{μ : Set} (μcard : μ.is_cardinal) (κμ : κ.card_le μ) : ¬ μ.finite_cardinal :=
begin
intro μfin, apply κfin,
rw ←card_lt_aleph_null_iff_finite κcard,
rw ←card_lt_aleph_null_iff_finite μcard at μfin,
exact card_lt_of_le_of_lt κcard μcard κμ μfin,
end
-- Corollary 6G, different proof
theorem subset_finite_of_finite' {A : Set.{u}} (hA : A.is_finite) {B : Set} (hBA : B ⊆ A) : B.is_finite :=
begin
rcases hA with ⟨n, hn, hAn⟩,
have hBn : B.card.card_le n.card, rw ←card_equiv at hAn, rw ←hAn, rw card_le_iff_equin', exact dominated_sub hBA,
have hnal : n.card.card_lt (card ω), apply finite_card_lt_aleph_null, exact ⟨_, nat_finite hn, rfl⟩,
refine one_finite_all_finite _ rfl, rw ←card_lt_aleph_null_iff_finite ⟨_, rfl⟩, split,
exact card_le_trans ⟨n, rfl⟩ hBn hnal.left,
intro he, apply hnal.right, apply card_eq_of_le_of_le ⟨_, rfl⟩ ⟨_, rfl⟩ hnal.left,
rw ←he, exact hBn,
end
-- Corollary 6P
theorem infinite_iff_equin_proper_subset_self {A : Set} : ¬ A.is_finite ↔ ∃ B : Set, B ⊂ A ∧ A ≈ B :=
begin
split,
intro hinf,
obtain ⟨f, finto, foto⟩ := omega_least_infinite_set hinf,
let L := (f.comp succ_fun).comp f.inv,
let R := (A \ f.ran).id,
let g := L ∪ R,
let B : Set := A \ {f.fun_value ∅},
refine ⟨B, _, _⟩,
rw ssubset_iff, refine ⟨subset_diff, _⟩,
intro he, rw ←ext_iff at he, simp only [and_iff_left_iff_imp, mem_diff, not_forall, mem_singleton] at he,
refine he (f.fun_value ∅) _ rfl,
apply finto.right.right, apply fun_value_def'' finto.left, rw finto.right.left, exact zero_nat,
have ranL : L.ran = f.ran \ {f.fun_value ∅},
have h : (f.comp succ_fun).dom ⊆ f.inv.ran,
have h' : succ_fun.ran ⊆ f.dom, rw [succ_fun_ran, finto.right.left], exact subset_diff,
rw [dom_comp h', T3E_b, finto.right.left, succ_fun_into_fun.right.left], exact subset_self,
rw [ran_comp h, ran_comp_complex foto, finto.right.left, succ_fun_ran],
have h' : {∅} ⊆ ω, intros x hx, rw [mem_singleton] at hx, subst hx, exact zero_nat,
rw [diff_diff_eq_self_of_subset h'],
have h'' : ∅ ∈ f.dom, rw finto.right.left, exact zero_nat,
rw img_singleton_eq finto.left h'',
refine ⟨g, _, _⟩,
have compfun : (f.comp succ_fun).is_function := T3H_a finto.left succ_fun_into_fun.left,
have finvfun : f.inv.is_function := T3F_a.mpr foto,
have domL : L.dom = f.ran,
have h : f.inv.ran ⊆ (f.comp succ_fun).dom,
have h' : succ_fun.ran ⊆ f.dom, rw [succ_fun_ran, finto.right.left], exact subset_diff,
rw [dom_comp h', T3E_b, finto.right.left, succ_fun_into_fun.right.left], exact subset_self,
rw [dom_comp h, T3E_a],
have gonto : g.onto_fun (L.dom ∪ R.dom) (L.ran ∪ R.ran),
apply union_fun (T3H_a compfun finvfun) id_is_function,
rw [eq_empty, domL, id_into.right.left], intros y hy, rw [mem_inter, mem_diff] at hy,
exact hy.right.right hy.left,
rw [domL, id_into.right.left] at gonto,
have h : f.ran ∪ A \ f.ran = A, rw eq_iff_subset_and_subset,
refine ⟨union_subset_of_subset_of_subset finto.right.right subset_diff, _⟩,
intros x hx, rw [mem_union, mem_diff],
by_cases hc : x ∈ f.ran,
left, exact hc,
right, exact ⟨hx, hc⟩,
rw h at gonto,
have ranL : L.ran = f.ran \ {f.fun_value ∅},
have h : (f.comp succ_fun).dom ⊆ f.inv.ran,
have h' : succ_fun.ran ⊆ f.dom, rw [succ_fun_ran, finto.right.left], exact subset_diff,
rw [dom_comp h', T3E_b, finto.right.left, succ_fun_into_fun.right.left], exact subset_self,
rw [ran_comp h, ran_comp_complex foto, finto.right.left, succ_fun_ran],
have h' : {∅} ⊆ ω, intros x hx, rw [mem_singleton] at hx, subst hx, exact zero_nat,
rw [diff_diff_eq_self_of_subset h'],
have h'' : ∅ ∈ f.dom, rw finto.right.left, exact zero_nat,
rw img_singleton_eq finto.left h'',
rw [ranL, id_onto.right.right] at gonto,
have h' : f.ran \ {f.fun_value ∅} ∪ A \ f.ran = B, apply ext,
simp only [mem_diff, mem_singleton, mem_union], intro y, split,
rintro (⟨hy, hny⟩|⟨hy, hny⟩),
exact ⟨finto.right.right hy, hny⟩,
refine ⟨hy, _⟩, intro hy', apply hny, subst hy', apply fun_value_def'' finto.left, rw finto.right.left, exact zero_nat,
rintro ⟨hy, hny⟩, by_cases hc : y ∈ f.ran,
left, exact ⟨hc, hny⟩,
right, exact ⟨hy, hc⟩,
rw h' at gonto, exact gonto,
refine union_one_to_one _ id_oto _,
rw [←T3F_a, T3I, T3E_c finto.left.left, T3I], apply T3H_a finto.left, apply T3H_a,
rw T3F_a, exact succ_one_to_one,
rw T3F_a, exact foto,
rw [ranL, id_onto.right.right, eq_empty], simp only [mem_inter, mem_diff, mem_singleton],
rintros y ⟨⟨hy, hny⟩, hA, hnf⟩, exact hnf hy,
rintro ⟨B, hBA, heq⟩, exact pigeonhole'' hBA heq,
end
-- I skipped some of the section on countable sets
def countable (A : Set) : Prop := A ≼ ω
lemma countable_card {A : Set} : A.card.card_le (card ω) ↔ A.countable :=
begin
rw [card_le_iff_equin', countable],
end
lemma countable_iff {A : Set} : A.countable ↔ A.is_finite ∨ A.card = card ω :=
by rw [←countable_card, card_le_iff, card_lt_aleph_null_iff_finite ⟨_, rfl⟩, card_finite_iff_finite]
lemma card_lt_of_not_le {K M : Set} (h : ¬ K.card.card_le M.card) : M.card.card_lt K.card :=
begin
rw card_lt_iff, split,
cases ax_ch_5 K M with hKM hMK,
exfalso, apply h, rw card_le_iff_equin', exact hKM,
exact hMK,
intro he, apply h, rw ←card_equiv at he, rw card_le_iff, right, exact he.symm,
end
lemma nat_le_inf {n : Set} (hn : n ∈ ω) {K : Set} (hK : ¬ K.is_finite) : n.card_le K.card :=
begin
apply card_le_trans ⟨ω, rfl⟩,
have h : n.card_lt (card ω), rw card_lt_aleph_null_iff_finite ⟨_, card_nat hn⟩,
rw finite_cardinal_iff_nat, exact hn,
exact h.left,
apply aleph_null_least_infinite_cardinal ⟨_, rfl⟩, rw card_finite_iff_finite, exact hK,
end
lemma nat_le_inf' {n : Set} (hn : n ∈ ω) {κ : Set} (hκ : κ.is_cardinal) (hinf : ¬ κ.finite_cardinal) : n.card_le κ :=
begin
rcases hκ with ⟨K, hK⟩, rw ←hK, apply nat_le_inf hn, rw ←card_finite_iff_finite, rw hK, exact hinf,
end
lemma finite_le_infinite {K : Set} (hK : K.is_finite) {M : Set} (hM : ¬ M.is_finite) : K.card.card_le M.card :=
begin
rw finite_iff at hK, rcases hK with ⟨n, hn, he⟩, rw he, exact nat_le_inf hn hM,
end
lemma finite_le_infinite' {κ : Set} (hκ : κ.is_cardinal) (hfin : κ.finite_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hinf : ¬ μ.finite_cardinal) : κ.card_le μ :=
begin
rcases hκ with ⟨K, hK⟩, rcases hμ with ⟨M, hM⟩, rw [←hK] at *,
rw ←hM at hinf, rw ←hM, rw card_finite_iff_finite at *, exact finite_le_infinite hfin hinf,
end
lemma mul_infinite_card_eq_self {κ : Set.{u}} (hκ : κ.is_cardinal) (hinf : ¬ κ.finite_cardinal) : κ.card_mul κ = κ :=
begin
rcases hκ with ⟨B, hB⟩,
let H : Set := {f ∈ ((B.prod B).prod B).powerset | f = ∅ ∨ ∃ A : Set, ¬ A.is_finite ∧ A ⊆ B ∧ (A.prod A).correspondence A f},
have hH : ∀ {f : Set}, f ∈ H ↔ f = ∅ ∨ ∃ A : Set, ¬ A.is_finite ∧ A ⊆ B ∧ (A.prod A).correspondence A f,
simp only [mem_powerset, and_imp, forall_eq_or_imp, mem_sep, and_iff_right_iff_imp, exists_imp_distrib],
refine ⟨empty_subset, _⟩, rintros f A hAinf hAB ⟨fonto, foto⟩, refine subset_trans _ (prod_subset_of_subset_of_subset (prod_subset_of_subset_of_subset hAB hAB) hAB),
rw [←fonto.right.left, ←fonto.right.right, ←rel_sub_dom_ran], exact fonto.left.left,
have hch : ∀ C : Set, C.is_chain → C ⊆ H → C.Union ∈ H, intros C hch hCH,
by_cases case : ∃ h, h ∈ C ∧ h ≠ ∅,
rcases case with ⟨h, hh, hhne⟩, rw hH, right,
let A := {R ∈ B.powerset | ∃ f : Set, f ∈ C ∧ R = f.ran}.Union,
have hA : ∀ ⦃y⦄, y ∈ A ↔ ∃ f : Set, y ∈ f.ran ∧ f ∈ C,
simp only [mem_powerset, exists_prop, mem_Union, mem_sep, mem_ran], intro y, split,
rintro ⟨A, ⟨hA, f, hf, he⟩, hy⟩, subst he, rw mem_ran at hy, exact ⟨_, hy, hf⟩,
rintro ⟨f, hy, hf⟩, rw ←mem_ran at hy,
have h : f ∈ H := hCH hf,
rw hH at h, rcases h with (hf|⟨A, -, hAB, fonto, -⟩),
subst hf, rw [ran_empty_eq_empty] at hy, exfalso, exact mem_empty _ hy,
refine ⟨_, ⟨_, _, hf, rfl⟩, hy⟩, rw fonto.right.right, exact hAB,
have hAeq : A = C.Union.ran := ran_Union_eq_Union_ran hA,
let D := {D ∈ (B.prod B).powerset | ∃ f : Set, f ∈ C ∧ D = f.dom}.Union,
have hD : ∀ ⦃x⦄, x ∈ D ↔ ∃ f : Set, x ∈ f.dom ∧ f ∈ C,
simp only [mem_Union, mem_sep, mem_powerset, exists_prop, mem_dom], intro x, split,
rintro ⟨X, ⟨hX, f, hf, he⟩, hx⟩, subst he, rw mem_dom at hx, exact ⟨_, hx, hf⟩,
rintro ⟨f, hx, hf⟩, rw ←mem_dom at hx,
have h : f ∈ H := hCH hf,
rw hH at h, rcases h with (hf|⟨A, -, hAB, fonto, -⟩),
subst hf, rw [dom_empty_eq_empty] at hx, exfalso, exact mem_empty _ hx,
refine ⟨_, ⟨_, _, hf, rfl⟩, hx⟩, rw fonto.right.left, exact prod_subset_of_subset_of_subset hAB hAB,
have hDeq : D = C.Union.dom := dom_Union_eq_Union_dom hD,
refine ⟨A, _, _, ⟨_, _, hAeq.symm⟩, _⟩,
{ have hhC := hCH hh,
rw hH at hhC, rcases hhC with (hemp|⟨A', hA'inf, hA'B, honto, hoto⟩),
exfalso, exact hhne hemp,
intro hAfin, apply hA'inf,
have hA'subA : A' ⊆ A, rw ←honto.right.right, intros y hy, rw hA, exact ⟨_, hy, hh⟩,
exact subset_finite_of_finite hAfin hA'subA, },
{ intros y hy, rw hA at hy, rcases hy with ⟨f, hy, hf⟩,
replace hf := hCH hf, rw hH at hf, rcases hf with (hf|⟨A, -, hAB, fonto, -⟩),
subst hf, rw [ran_empty_eq_empty] at hy, exfalso, exact mem_empty _ hy,
rw fonto.right.right at hy, exact hAB hy, },
{ apply Union_chain_is_function hch, intros f hf,
replace hf := hCH hf, rw hH at hf, rcases hf with (hf|⟨A, -, -, fonto, -⟩),
subst hf, exact empty_fun,
exact fonto.left, },
{ apply ext, intro z, split,
rw [←hDeq, hD], rintro ⟨f, hz, hf⟩,
have hf' := hCH hf, rw hH at hf', rcases hf' with (hf'|⟨X, Xinf, hXB, fonto, foto⟩),
subst hf', rw dom_empty_eq_empty at hz, exfalso, exact mem_empty _ hz,
simp only [fonto.right.left, mem_prod, exists_prop] at hz, rcases hz with ⟨a₁, ha₁, a₂, ha₂, he⟩, subst he,
simp only [pair_mem_prod, hA], rw ←fonto.right.right at ha₁ ha₂,
exact ⟨⟨_, ha₁, hf⟩, _, ha₂, hf⟩,
simp only [mem_prod, exists_prop, hA],
have hpart : ∀ {f₁ : Set.{u}}, f₁ ∈ C → ∀ {f₂}, f₂ ∈ C → f₁ ⊆ f₂ → ∀ {a₁ : Set}, a₁ ∈ f₁.ran ∪ f₂.ran → ∀ {a₂}, a₂ ∈ f₁.ran ∪ f₂.ran → a₁.pair a₂ ∈ C.Union.dom,
intros f₁ hf₁ f₂ hf₂ hf a₁ ha₁ a₂ ha₂,
have hf₂' := hCH hf₂, rw hH at hf₂', rcases hf₂' with (hf₂'|⟨X, Xinf, hXB, fonto, foto⟩),
subst hf₂', rw [ran_empty_eq_empty, union_empty, mem_ran] at ha₂, rcases ha₂ with ⟨x, ha₂⟩, exfalso, exact mem_empty _ (hf ha₂),
rw [←hDeq, hD], refine ⟨f₂, _, hf₂⟩, rw [fonto.right.left, pair_mem_prod],
replace ha₁ := union_subset_of_subset_of_subset (ran_subset_of_subset hf) subset_self ha₁,
replace ha₂ := union_subset_of_subset_of_subset (ran_subset_of_subset hf) subset_self ha₂,
rw fonto.right.right at ha₁ ha₂, exact ⟨ha₁, ha₂⟩,
rintro ⟨a₁, ⟨f₁, ha₁, hf₁⟩, a₂, ⟨f₂, ha₂, hf₂⟩, he⟩, subst he,
replace ha₁ : a₁ ∈ f₁.ran ∪ f₂.ran, rw mem_union, left, exact ha₁,
replace ha₂ : a₂ ∈ f₁.ran ∪ f₂.ran, rw mem_union, right, exact ha₂,
cases hch hf₁ hf₂ with hf hf,
exact hpart hf₁ hf₂ hf ha₁ ha₂,
rw union_comm at ha₁ ha₂,
exact hpart hf₂ hf₁ hf ha₁ ha₂, },
{ apply Union_chain_oto hch, intros f hf,
replace hf := hCH hf, rw hH at hf, rcases hf with (hf|⟨-, -, -, -, foto⟩),
subst hf, exact empty_oto,
exact foto, },
rw hH, left, rw eq_empty, intros z hz, apply case, rw mem_Union at hz,
rcases hz with ⟨f, hf, hz⟩, refine ⟨_, hf, _⟩, exact ne_empty_of_inhabited _ ⟨_, hz⟩,
obtain ⟨f₀, hf₀, hmax⟩ := ax_ch_6 _ hch,
rw hH at hf₀, cases hf₀,
obtain ⟨A, hAB, hA⟩ := exists_sub_card_alpeh_null_of_inf hinf hB,
have hAprodA := aleph_mul_aleph_eq_aleph,
rw [←hA, ←card_mul_spec rfl rfl, card_equiv] at hAprodA, rcases hAprodA with ⟨g, gcorr⟩,
have gH : g ∈ H, rw hH, right, refine ⟨_, _, hAB, gcorr⟩, rw [←card_finite_iff_finite, hA], exact aleph_null_infinite_cardinal,
have Ainhab : A.inhab, rw card_equiv at hA, replace hA := equin_symm hA,
rcases hA with ⟨f, fonto, foto⟩, use f.fun_value ∅, rw ←fonto.right.right,
apply fun_value_def'' fonto.left, rw fonto.right.left, exact zero_nat,
rcases Ainhab with ⟨a, ha⟩,
exfalso, subst hf₀, refine hmax _ gH _ empty_subset,
apply ne_empty_of_inhabited, use (pair a a).pair (g.fun_value (a.pair a)),
apply fun_value_def' gcorr.onto.left, rw [gcorr.onto.right.left, pair_mem_prod], exact ⟨ha, ha⟩,
rcases hf₀ with ⟨A₀, hAinf, hAB, fcorr⟩,
let μ := A₀.card,
have μpμ : μ.card_mul μ = μ, rw [←card_mul_spec rfl rfl, card_equiv], exact ⟨_, fcorr⟩,
have hlt : (B \ A₀).card.card_lt μ, apply card_lt_of_not_le, intro hle,
rw card_le_iff_equin' at hle,
obtain ⟨D, hDBA, hDA⟩ := exists_equin_subset_of_dominated hle,
rw ←card_equiv at hDA,
have hdisj : A₀ ∩ D = ∅, rw eq_empty, intros x hx, rw mem_inter at hx,
specialize hDBA hx.right, rw mem_diff at hDBA, exact hDBA.right hx.left,
have hmpm : μ.card_add μ = μ,
rw [card_add_self_eq_two_mul_self ⟨_, rfl⟩],
apply card_eq_of_le_of_le (mul_cardinal (nat_is_cardinal two_nat) ⟨_, rfl⟩) ⟨_, rfl⟩,
change (two.card_mul μ).card_le μ,
nth_rewrite 1 ←μpμ, refine card_mul_le_of_le_left (nat_is_cardinal two_nat) ⟨_, rfl⟩ _ ⟨_, rfl⟩,
have two_le_a : two.card_le (card ω), rw card_le_iff, left, apply finite_card_lt_aleph_null,
rw finite_cardinal_iff_nat, exact two_nat,
refine card_le_trans ⟨_, rfl⟩ two_le_a _, apply aleph_null_least_infinite_cardinal ⟨_, rfl⟩,
rw card_finite_iff_finite, exact hAinf,
nth_rewrite 0 ←card_mul_one_eq_self ⟨_, rfl⟩,
rw card_mul_comm ⟨_, rfl⟩ (nat_is_cardinal one_nat),
refine card_mul_le_of_le_left (nat_is_cardinal one_nat) (nat_is_cardinal two_nat) _ ⟨_, rfl⟩,
have one_fin : one.finite_cardinal, rw finite_cardinal_iff_nat, exact one_nat,
have two_fin : two.finite_cardinal, rw finite_cardinal_iff_nat, exact two_nat,
rw [finite_card_le_iff_le one_fin two_fin, le_iff, two],
left, exact self_mem_succ,
have cardAD : (A₀ ∪ D).card = μ, rw card_add_spec rfl hDA hdisj, exact hmpm,
have hext : ((D.prod A₀) ∪ ((A₀.prod D) ∪ (D.prod D))).card = D.card,
have hdisj' : A₀.prod D ∩ D.prod D = ∅, rw rel_eq_empty (inter_rel_is_rel prod_is_rel),
simp only [eq_empty, mem_inter] at hdisj,
simp only [pair_mem_prod, mem_inter], rintros x y ⟨⟨hx, hy⟩, hx', hy'⟩, exact hdisj _ ⟨hx, hx'⟩,
have hdisj'' : D.prod A₀ ∩ (A₀.prod D ∪ D.prod D) = ∅, rw rel_eq_empty (inter_rel_is_rel prod_is_rel),
simp only [eq_empty, mem_inter] at hdisj,
simp only [pair_mem_prod, mem_inter, mem_union], rintros x y ⟨⟨hx, hy⟩, (⟨hx', hy'⟩|⟨hx', hy'⟩)⟩,
exact hdisj _ ⟨hy, hy'⟩,
exact hdisj _ ⟨hy, hy'⟩,
rw [card_add_spec rfl rfl hdisj'', card_add_spec rfl rfl hdisj'],
simp only [card_mul_spec rfl rfl, hDA],
change (μ.card_mul μ).card_add ((μ.card_mul μ).card_add (μ.card_mul μ)) = μ,
simp only [μpμ, hmpm],
rw card_equiv at hext, rcases hext with ⟨g, gcorr⟩,
have fgonto : (f₀ ∪ g).onto_fun ((A₀ ∪ D).prod (A₀ ∪ D)) (A₀ ∪ D),
simp only [union_prod, prod_union],
simp only [←@union_assoc (A₀.prod A₀) (D.prod A₀) ((A₀.prod D) ∪ (D.prod D))],
rw [←fcorr.onto.right.left, ←gcorr.onto.right.left, ←fcorr.onto.right.right, ←gcorr.onto.right.right],
apply union_fun fcorr.onto.left gcorr.onto.left,
rw [fcorr.onto.right.left, gcorr.onto.right.left],
rw rel_eq_empty (inter_rel_is_rel prod_is_rel),
intros x y hxy, simp only [mem_inter, mem_union, pair_mem_prod] at hxy,
rw eq_empty at hdisj, simp only [mem_inter] at hdisj,
rcases hxy with ⟨⟨hx', hy'⟩,(⟨hx, hy⟩|⟨hx, hy⟩|⟨hx, hy⟩)⟩,
exact hdisj _ ⟨hx', hx⟩,
exact hdisj _ ⟨hy', hy⟩,
exact hdisj _ ⟨hx', hx⟩,
have fgH : f₀ ∪ g ∈ H, rw hH, right, refine ⟨A₀ ∪ D, _, _, _⟩,
rw [←card_finite_iff_finite, cardAD, card_finite_iff_finite], exact hAinf,
apply union_subset_of_subset_of_subset hAB,
intros x hx, specialize hDBA hx, rw mem_diff at hDBA, exact hDBA.left,
split,
exact fgonto,
apply union_one_to_one fcorr.oto gcorr.oto, rw [fcorr.onto.right.right, gcorr.onto.right.right],
exact hdisj,
have Dinhab : D.inhab,
have a_le_D : card_le (card ω) D.card, apply aleph_null_least_infinite_cardinal ⟨_, rfl⟩,
rw [hDA, card_finite_iff_finite], exact hAinf,
rw card_le_iff_equin' at a_le_D, rcases a_le_D with ⟨f, finto, foto⟩,
use f.fun_value ∅, apply finto.right.right, apply fun_value_def'' finto.left,
rw finto.right.left, exact zero_nat,
rcases Dinhab with ⟨d, hd⟩,
have fgnef : f₀ ∪ g ≠ f₀, intro he,
have hd' : d ∈ (f₀ ∪ g).ran, rw [fgonto.right.right, mem_union], right, exact hd,
rw [he, fcorr.onto.right.right] at hd', simp only [eq_empty, mem_inter] at hdisj,
exact hdisj _ ⟨hd', hd⟩,
exact hmax _ fgH fgnef subset_union_left,
have kem : κ = μ, symmetry, apply card_eq_of_le_of_le ⟨_, rfl⟩ ⟨_, hB⟩,
rw ←hB, exact card_le_of_subset hAB,
rw [←hB, ←union_diff_eq_self_of_subset hAB, card_add_spec rfl rfl self_inter_diff_empty],
change (A₀.card.card_add (B \ A₀).card).card_le μ, rw ←μpμ, apply card_le_trans (mul_cardinal (nat_is_cardinal two_nat) ⟨A₀, rfl⟩),
rw ←card_add_self_eq_two_mul_self ⟨_, rfl⟩, exact card_add_le_of_le_right ⟨_, rfl⟩ ⟨_, rfl⟩ hlt.left ⟨_, rfl⟩,
exact card_mul_le_of_le_left ⟨_, card_nat two_nat⟩ ⟨_, rfl⟩ (nat_le_inf two_nat hAinf) ⟨_, rfl⟩,
rw kem, exact μpμ,
end
lemma add_infinite_card_eq_self {κ : Set.{u}} (hκ : κ.is_cardinal) (hinf : ¬ κ.finite_cardinal) : κ.card_add κ = κ :=
begin
rw [card_add_self_eq_two_mul_self hκ],
apply card_eq_of_le_of_le (mul_cardinal (nat_is_cardinal two_nat) hκ) hκ,
nth_rewrite 1 ←mul_infinite_card_eq_self hκ hinf,
refine card_mul_le_of_le_left (nat_is_cardinal two_nat) hκ _ hκ,
have two_le_a : two.card_le (card ω), rw card_le_iff, left, apply finite_card_lt_aleph_null,
rw finite_cardinal_iff_nat, exact two_nat,
refine card_le_trans ⟨_, rfl⟩ two_le_a (aleph_null_least_infinite_cardinal hκ hinf),
nth_rewrite 0 ←card_mul_one_eq_self hκ,
rw card_mul_comm hκ (nat_is_cardinal one_nat),
refine card_mul_le_of_le_left (nat_is_cardinal one_nat) (nat_is_cardinal two_nat) _ hκ,
have one_fin : one.finite_cardinal, rw finite_cardinal_iff_nat, exact one_nat,
have two_fin : two.finite_cardinal, rw finite_cardinal_iff_nat, exact two_nat,
rw [finite_card_le_iff_le one_fin two_fin, le_iff, two],
left, exact self_mem_succ,
end
lemma card_add_eq_right_of_le {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hinf : ¬ μ.finite_cardinal) (hκμ : κ.card_le μ) : κ.card_add μ = μ :=
begin
apply card_eq_of_le_of_le (add_cardinal hκ hμ) hμ,
nth_rewrite 1 ←add_infinite_card_eq_self hμ hinf,
exact card_add_le_of_le_left hκ hμ hκμ hμ,
nth_rewrite 0 ←card_empty_add hμ, refine card_add_le_of_le_left (nat_is_cardinal zero_nat) hκ _ hμ,
exact zero_card_le hκ,
end
lemma card_add_eq_left_of_le {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (hinf : ¬ μ.finite_cardinal) (hκμ : κ.card_le μ) : μ.card_add κ = μ :=
begin
rw card_add_comm hμ hκ, exact card_add_eq_right_of_le hκ hμ hinf hκμ,
end
lemma card_diff_from_inf {K : Set} (hinf : ¬ K.is_finite) {M : Set} (hMK : M ⊆ K) (hMK' : M.card.card_lt K.card) : (K \ M).card = K.card :=
begin
have he : K.card = (M ∪ K \ M).card, rw union_diff_eq_self_of_subset hMK,
rw card_add_spec rfl rfl self_inter_diff_empty at he,
by_cases hcase : M.is_finite,
have hKM : ¬ (K \ M).is_finite, intro hfin, rw finite_iff at *,
rcases hcase with ⟨n, hn, hM⟩, rcases hfin with ⟨m, hm, hKM⟩, rw [hM, hKM] at he,
apply hinf, rw he, refine ⟨n + m, add_into_nat hn hm, _⟩,
apply card_add_eq_ord_add,
rw finite_cardinal_iff_nat, exact hn,
rw finite_cardinal_iff_nat, exact hm,
have hKM' : ¬ (K \ M).card.finite_cardinal, intro hfin, rw card_finite_iff_finite at hfin,
exact hKM hfin,
have he' : M.card.card_add (K \ M).card = (K \ M).card,
apply card_add_eq_right_of_le ⟨_, rfl⟩ ⟨_, rfl⟩ hKM', exact finite_le_infinite hcase hKM,
rw he' at he, exact he.symm,
cases ax_ch_5 M (K \ M),
have hKMfin : ¬ (K \ M).is_finite := infinite_of_dominates_infinite hcase h,
have he' : M.card.card_add (K \ M).card = (K \ M).card,
apply card_add_eq_right_of_le ⟨_, rfl⟩ ⟨_, rfl⟩,
rw card_finite_iff_finite, exact hKMfin,
rw ←card_le_iff_equin' at h, exact h,
rw he' at he, exact he.symm,
have he' : M.card.card_add (K \ M).card = M.card,
apply card_add_eq_left_of_le ⟨_, rfl⟩ ⟨_, rfl⟩,
rw card_finite_iff_finite, exact hcase,
rw ←card_le_iff_equin' at h, exact h,
rw he' at he, exfalso, exact hMK'.right he.symm,
end
lemma card_exp_self_eq_pow_self {κ : Set} (hκ : κ.is_cardinal) (hinf : ¬ κ.finite_cardinal) : κ.card_exp κ = two.card_exp κ :=
begin
have two_card : two.is_cardinal := nat_is_cardinal two_nat,
apply card_eq_of_le_of_le (exp_cardinal hκ hκ) (exp_cardinal two_card hκ),
nth_rewrite 2 ←mul_infinite_card_eq_self hκ hinf, rw ←card_exp_exp two_card hκ hκ,
exact card_exp_le_of_le hκ (exp_cardinal two_card hκ) (card_le_iff.mpr (or.inl (card_lt_exp hκ))) hκ,
refine card_exp_le_of_le two_card hκ (finite_le_infinite' two_card _ hκ hinf) hκ,
rw finite_cardinal_iff_nat, exact two_nat,
end
lemma card_fin_of_le_fin {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (μfin : μ.finite_cardinal) (κμ : κ.card_le μ) : κ.finite_cardinal :=
classical.by_contradiction (λ κinf, card_inf_of_ge_inf hκ κinf (fin_card_is_card μfin) κμ μfin)
lemma inf_card_not_empty {κ : Set} (hκ : κ.is_cardinal) (hinf : ¬ κ.finite_cardinal) : κ ≠ ∅ :=
begin
intro κz, subst κz, rw [←card_nat zero_nat, card_finite_iff_finite] at hinf,
exact hinf (nat_finite zero_nat),
end
lemma card_not_empty_iff_ge_one {κ : Set} (hκ : κ.is_cardinal) : κ ≠ ∅ ↔ one.card_le κ :=
begin
split,
intro κz, rcases hκ with ⟨K, hK⟩, subst hK,
have Kz : K ≠ ∅, intro Kz, subst Kz, exact κz (card_nat zero_nat),
obtain ⟨x, xK⟩ := inhabited_of_ne_empty Kz,
rw ←@card_singleton x, apply card_le_of_subset, intro z, rw mem_singleton, intro zx, subst zx, exact xK,
intros h κz, subst κz,
have o : one ∈ ω := one_nat,
have z : ∅ ∈ ω := zero_nat,
rw ←finite_cardinal_iff_nat at o z,
rw finite_card_le_iff_le o z at h, cases h,
exact mem_empty _ h,
apply mem_empty ∅, nth_rewrite 1 ←h, exact zero_lt_one,
end
lemma card_mul_lt_mul {κ : Set} (hκ : κ.is_cardinal) {μ : Set} (hμ : μ.is_cardinal) (κμ : κ.card_lt μ) :
(κ.card_mul κ).card_lt (μ.card_mul μ) :=
begin
by_cases μfin : μ.finite_cardinal,
have κfin := card_fin_of_le_fin hκ μfin κμ.left,
rw [finite_card_lt_iff_lt (card_mul_fin_of_fin κfin κfin) (card_mul_fin_of_fin μfin μfin),
card_mul_eq_ord_mul κfin κfin, card_mul_eq_ord_mul μfin μfin],
rw finite_card_lt_iff_lt κfin μfin at κμ,
rw finite_cardinal_iff_nat at μfin,
apply mul_lt_mul_of_lt' μfin κμ,
by_cases κz : κ = ∅,
subst κz, rwa [card_mul_empty (nat_is_cardinal zero_nat), mul_infinite_card_eq_self hμ μfin],
refine ⟨card_le_trans (mul_cardinal hμ hκ) (card_mul_le_of_le_left hκ hμ κμ.left hκ) (card_mul_le_of_le_right hκ hμ κμ.left hμ), λ h, _⟩,
have κκ : κ.card_le (κ.card_mul κ),
nth_rewrite 0 ←card_mul_one_eq_self hκ,
change κ ≠ ∅ at κz, rw card_not_empty_iff_ge_one hκ at κz,
exact card_mul_le_of_le_right (nat_is_cardinal one_nat) hκ κz hκ,
rw card_le_iff at κκ, cases κκ, rotate,
rw [κκ, h, mul_infinite_card_eq_self hμ μfin] at κμ, exact κμ.right rfl,
have κfin : κ.finite_cardinal, apply classical.by_contradiction, intro κinf,
rw mul_infinite_card_eq_self hκ κinf at κκ, exact κκ.right rfl,
apply μfin, rw [←mul_infinite_card_eq_self hμ μfin, ←h], exact card_mul_fin_of_fin κfin κfin,
end
end Set
|
55e662733a75513284f44ee37215c1c9b1956375 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/data/set/intervals/order_iso.lean | 5aa3d325ec02bed0e0ea1c4157117c5a5c2387fc | [
"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 | 3,190 | 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, Rémy Degenne
-/
import data.set.intervals.basic
import order.hom.set
/-!
# Lemmas about images of intervals under order isomorphisms.
-/
variables {α β : Type*}
open set
namespace order_iso
section preorder
variables [preorder α] [preorder β]
@[simp] lemma preimage_Iic (e : α ≃o β) (b : β) : e ⁻¹' (Iic b) = Iic (e.symm b) :=
by { ext x, simp [← e.le_iff_le] }
@[simp] lemma preimage_Ici (e : α ≃o β) (b : β) : e ⁻¹' (Ici b) = Ici (e.symm b) :=
by { ext x, simp [← e.le_iff_le] }
@[simp] lemma preimage_Iio (e : α ≃o β) (b : β) : e ⁻¹' (Iio b) = Iio (e.symm b) :=
by { ext x, simp [← e.lt_iff_lt] }
@[simp] lemma preimage_Ioi (e : α ≃o β) (b : β) : e ⁻¹' (Ioi b) = Ioi (e.symm b) :=
by { ext x, simp [← e.lt_iff_lt] }
@[simp] lemma preimage_Icc (e : α ≃o β) (a b : β) : e ⁻¹' (Icc a b) = Icc (e.symm a) (e.symm b) :=
by simp [← Ici_inter_Iic]
@[simp] lemma preimage_Ico (e : α ≃o β) (a b : β) : e ⁻¹' (Ico a b) = Ico (e.symm a) (e.symm b) :=
by simp [← Ici_inter_Iio]
@[simp] lemma preimage_Ioc (e : α ≃o β) (a b : β) : e ⁻¹' (Ioc a b) = Ioc (e.symm a) (e.symm b) :=
by simp [← Ioi_inter_Iic]
@[simp] lemma preimage_Ioo (e : α ≃o β) (a b : β) : e ⁻¹' (Ioo a b) = Ioo (e.symm a) (e.symm b) :=
by simp [← Ioi_inter_Iio]
@[simp] lemma image_Iic (e : α ≃o β) (a : α) : e '' (Iic a) = Iic (e a) :=
by rw [e.image_eq_preimage, e.symm.preimage_Iic, e.symm_symm]
@[simp] lemma image_Ici (e : α ≃o β) (a : α) : e '' (Ici a) = Ici (e a) :=
e.dual.image_Iic a
@[simp] lemma image_Iio (e : α ≃o β) (a : α) : e '' (Iio a) = Iio (e a) :=
by rw [e.image_eq_preimage, e.symm.preimage_Iio, e.symm_symm]
@[simp] lemma image_Ioi (e : α ≃o β) (a : α) : e '' (Ioi a) = Ioi (e a) :=
e.dual.image_Iio a
@[simp] lemma image_Ioo (e : α ≃o β) (a b : α) : e '' (Ioo a b) = Ioo (e a) (e b) :=
by rw [e.image_eq_preimage, e.symm.preimage_Ioo, e.symm_symm]
@[simp] lemma image_Ioc (e : α ≃o β) (a b : α) : e '' (Ioc a b) = Ioc (e a) (e b) :=
by rw [e.image_eq_preimage, e.symm.preimage_Ioc, e.symm_symm]
@[simp] lemma image_Ico (e : α ≃o β) (a b : α) : e '' (Ico a b) = Ico (e a) (e b) :=
by rw [e.image_eq_preimage, e.symm.preimage_Ico, e.symm_symm]
@[simp] lemma image_Icc (e : α ≃o β) (a b : α) : e '' (Icc a b) = Icc (e a) (e b) :=
by rw [e.image_eq_preimage, e.symm.preimage_Icc, e.symm_symm]
end preorder
/-- Order isomorphism between `Iic (⊤ : α)` and `α` when `α` has a top element -/
def Iic_top [preorder α] [order_top α] : set.Iic (⊤ : α) ≃o α :=
{ map_rel_iff' := λ x y, by refl,
.. (@equiv.subtype_univ_equiv α (set.Iic (⊤ : α)) (λ x, le_top)), }
/-- Order isomorphism between `Ici (⊥ : α)` and `α` when `α` has a bottom element -/
def Ici_bot [preorder α] [order_bot α] : set.Ici (⊥ : α) ≃o α :=
{ map_rel_iff' := λ x y, by refl,
.. (@equiv.subtype_univ_equiv α (set.Ici (⊥ : α)) (λ x, bot_le)) }
end order_iso
|
90f46cfa7815e2846436701c8cb19f410a595519 | d6124c8dbe5661dcc5b8c9da0a56fbf1f0480ad6 | /Papyrus/GenericValueRef.lean | 973c6743de920fd372fe599f2a97e1766f451865 | [
"Apache-2.0"
] | permissive | xubaiw/lean4-papyrus | c3fbbf8ba162eb5f210155ae4e20feb2d32c8182 | 02e82973a5badda26fc0f9fd15b3d37e2eb309e0 | refs/heads/master | 1,691,425,756,824 | 1,632,122,825,000 | 1,632,123,075,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 2,525 | lean | import Papyrus.FFI
import Papyrus.IR.TypeRefs
namespace Papyrus
/--
An opaque type representing an external
[GenericValue](https://llvm.org/doxygen/structllvm_1_1GenericValue.html).
-/
constant Llvm.GenericValue : Type := Unit
/--
A reference to an external LLVM
[GenericValue](https://llvm.org/doxygen/structllvm_1_1GenericValue.html).
-/
def GenericValueRef := OwnedPtr Llvm.GenericValue
namespace GenericValueRef
/--
Create a integer generic of the given width with the given `Int` value.
The value will be truncated and/or extended as necessary to make it fit.
-/
@[extern "papyrus_generic_value_of_int"]
constant ofInt (numBits : UInt32) (value : @& Int) : IO GenericValueRef
/-- Get the value of this generic as an `Int` by treating its integer bits as signed. -/
@[extern "papyrus_generic_value_to_int"]
constant toInt (self : @& GenericValueRef) : IO Int
/--
Create a integer generic of the given width with the given `Nat` value.
The value will be truncated and/or extended as necessary to make it fit.
-/
@[extern "papyrus_generic_value_of_nat"]
constant ofNat (numBits : UInt32) (value : @& Nat) : IO GenericValueRef
/-- Get the integer value of this generic as a `Nat` by treating its integer bits as unsigned. -/
@[extern "papyrus_generic_value_to_nat"]
constant toNat (self : @& GenericValueRef) : IO Nat
/-- Create a `double` generic from a `Float`. -/
@[extern "papyrus_generic_value_of_float"]
constant ofFloat (value : @& Float) : IO GenericValueRef
/-- Get the `double` value of this generic as a `Float`. -/
@[extern "papyrus_generic_value_to_float"]
constant toFloat (self : @& GenericValueRef) : IO Float
/-- Create an aggregate generic from an `Array`. -/
@[extern "papyrus_generic_value_of_array"]
constant ofArray (value : @& Array GenericValueRef) : IO GenericValueRef
/-- Get the aggregate value of this generic as an `Array`. -/
@[extern "papyrus_generic_value_to_array"]
constant toArray (self : @& GenericValueRef) : IO (Array GenericValueRef)
end GenericValueRef
namespace IntegerTypeRef
/-- Get a reference to a generic of this type with the value of `Int`. -/
def getGenericValueOfInt (value : @& Int) (self : @& IntegerTypeRef) : IO GenericValueRef := do
GenericValueRef.ofInt (← self.getBitWidth) value
/-- Get a reference to a generic of this type with the value of `Nat`. -/
constant getGenericValueOfNat (value : @& Nat) (self : @& IntegerTypeRef) : IO GenericValueRef := do
GenericValueRef.ofNat (← self.getBitWidth) value
end IntegerTypeRef
|
ab4667065f4c9674d4eface53cc7b85d40aaf3ea | 57c233acf9386e610d99ed20ef139c5f97504ba3 | /src/field_theory/perfect_closure.lean | a6b9f51f10c1b2a292967a9e36593439997d1189 | [
"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 | 17,388 | lean | /-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Yury Kudryashov
-/
import algebra.char_p.basic
import data.equiv.ring
import algebra.group_with_zero.power
import algebra.iterate_hom
/-!
# The perfect closure of a field
-/
universes u v
open function
section defs
variables (R : Type u) [comm_semiring R] (p : ℕ) [fact p.prime] [char_p R p]
/-- A perfect ring is a ring of characteristic p that has p-th root. -/
class perfect_ring : Type u :=
(pth_root' : R → R)
(frobenius_pth_root' : ∀ x, frobenius R p (pth_root' x) = x)
(pth_root_frobenius' : ∀ x, pth_root' (frobenius R p x) = x)
/-- Frobenius automorphism of a perfect ring. -/
def frobenius_equiv [perfect_ring R p] : R ≃+* R :=
{ inv_fun := perfect_ring.pth_root' p,
left_inv := perfect_ring.pth_root_frobenius',
right_inv := perfect_ring.frobenius_pth_root',
.. frobenius R p }
/-- `p`-th root of an element in a `perfect_ring` as a `ring_hom`. -/
def pth_root [perfect_ring R p] : R →+* R :=
(frobenius_equiv R p).symm
end defs
section
variables {R : Type u} [comm_semiring R] {S : Type v} [comm_semiring S] (f : R →* S) (g : R →+* S)
{p : ℕ} [fact p.prime] [char_p R p] [perfect_ring R p] [char_p S p] [perfect_ring S p]
@[simp] lemma coe_frobenius_equiv : ⇑(frobenius_equiv R p) = frobenius R p := rfl
@[simp] lemma coe_frobenius_equiv_symm : ⇑(frobenius_equiv R p).symm = pth_root R p := rfl
@[simp] theorem frobenius_pth_root (x : R) : frobenius R p (pth_root R p x) = x :=
(frobenius_equiv R p).apply_symm_apply x
@[simp] theorem pth_root_pow_p (x : R) : pth_root R p x ^ p = x :=
frobenius_pth_root x
@[simp] theorem pth_root_frobenius (x : R) : pth_root R p (frobenius R p x) = x :=
(frobenius_equiv R p).symm_apply_apply x
@[simp] theorem pth_root_pow_p' (x : R) : pth_root R p (x ^ p) = x :=
pth_root_frobenius x
theorem left_inverse_pth_root_frobenius : left_inverse (pth_root R p) (frobenius R p) :=
pth_root_frobenius
theorem right_inverse_pth_root_frobenius : function.right_inverse (pth_root R p) (frobenius R p) :=
frobenius_pth_root
theorem commute_frobenius_pth_root : function.commute (frobenius R p) (pth_root R p) :=
λ x, (frobenius_pth_root x).trans (pth_root_frobenius x).symm
theorem eq_pth_root_iff {x y : R} : x = pth_root R p y ↔ frobenius R p x = y :=
(frobenius_equiv R p).to_equiv.eq_symm_apply
theorem pth_root_eq_iff {x y : R} : pth_root R p x = y ↔ x = frobenius R p y :=
(frobenius_equiv R p).to_equiv.symm_apply_eq
theorem monoid_hom.map_pth_root (x : R) : f (pth_root R p x) = pth_root S p (f x) :=
eq_pth_root_iff.2 $ by rw [← f.map_frobenius, frobenius_pth_root]
theorem monoid_hom.map_iterate_pth_root (x : R) (n : ℕ) :
f (pth_root R p^[n] x) = (pth_root S p^[n] (f x)) :=
semiconj.iterate_right f.map_pth_root n x
theorem ring_hom.map_pth_root (x : R) :
g (pth_root R p x) = pth_root S p (g x) :=
g.to_monoid_hom.map_pth_root x
theorem ring_hom.map_iterate_pth_root (x : R) (n : ℕ) :
g (pth_root R p^[n] x) = (pth_root S p^[n] (g x)) :=
g.to_monoid_hom.map_iterate_pth_root x n
variables (p)
lemma injective_pow_p {x y : R} (hxy : x ^ p = y ^ p) : x = y :=
left_inverse_pth_root_frobenius.injective hxy
end
section
variables (K : Type u) [comm_ring K] (p : ℕ) [fact p.prime] [char_p K p]
/-- `perfect_closure K p` is the quotient by this relation. -/
@[mk_iff] inductive perfect_closure.r : (ℕ × K) → (ℕ × K) → Prop
| intro : ∀ n x, perfect_closure.r (n, x) (n+1, frobenius K p x)
/-- The perfect closure is the smallest extension that makes frobenius surjective. -/
def perfect_closure : Type u := quot (perfect_closure.r K p)
end
namespace perfect_closure
variables (K : Type u)
section ring
variables [comm_ring K] (p : ℕ) [fact p.prime] [char_p K p]
/-- Constructor for `perfect_closure`. -/
def mk (x : ℕ × K) : perfect_closure K p := quot.mk (r K p) x
@[simp] lemma quot_mk_eq_mk (x : ℕ × K) :
(quot.mk (r K p) x : perfect_closure K p) = mk K p x := rfl
variables {K p}
/-- Lift a function `ℕ × K → L` to a function on `perfect_closure K p`. -/
@[elab_as_eliminator]
def lift_on {L : Type*} (x : perfect_closure K p) (f : ℕ × K → L)
(hf : ∀ x y, r K p x y → f x = f y) : L :=
quot.lift_on x f hf
@[simp] lemma lift_on_mk {L : Sort*} (f : ℕ × K → L)
(hf : ∀ x y, r K p x y → f x = f y) (x : ℕ × K) :
(mk K p x).lift_on f hf = f x :=
rfl
@[elab_as_eliminator]
lemma induction_on (x : perfect_closure K p) {q : perfect_closure K p → Prop}
(h : ∀ x, q (mk K p x)) : q x :=
quot.induction_on x h
variables (K p)
private lemma mul_aux_left (x1 x2 y : ℕ × K) (H : r K p x1 x2) :
mk K p (x1.1 + y.1, ((frobenius K p)^[y.1] x1.2) * ((frobenius K p)^[x1.1] y.2)) =
mk K p (x2.1 + y.1, ((frobenius K p)^[y.1] x2.2) * ((frobenius K p)^[x2.1] y.2)) :=
match x1, x2, H with
| _, _, r.intro n x := quot.sound $ by rw [← iterate_succ_apply, iterate_succ',
iterate_succ', ← frobenius_mul, nat.succ_add]; apply r.intro
end
private lemma mul_aux_right (x y1 y2 : ℕ × K) (H : r K p y1 y2) :
mk K p (x.1 + y1.1, ((frobenius K p)^[y1.1] x.2) * ((frobenius K p)^[x.1] y1.2)) =
mk K p (x.1 + y2.1, ((frobenius K p)^[y2.1] x.2) * ((frobenius K p)^[x.1] y2.2)) :=
match y1, y2, H with
| _, _, r.intro n y := quot.sound $ by rw [← iterate_succ_apply, iterate_succ',
iterate_succ', ← frobenius_mul]; apply r.intro
end
instance : has_mul (perfect_closure K p) :=
⟨quot.lift (λ x:ℕ×K, quot.lift (λ y:ℕ×K, mk K p
(x.1 + y.1, ((frobenius K p)^[y.1] x.2) * ((frobenius K p)^[x.1] y.2))) (mul_aux_right K p x))
(λ x1 x2 (H : r K p x1 x2), funext $ λ e, quot.induction_on e $ λ y,
mul_aux_left K p x1 x2 y H)⟩
@[simp] lemma mk_mul_mk (x y : ℕ × K) :
mk K p x * mk K p y = mk K p
(x.1 + y.1, ((frobenius K p)^[y.1] x.2) * ((frobenius K p)^[x.1] y.2)) :=
rfl
instance : comm_monoid (perfect_closure K p) :=
{ mul_assoc := λ e f g, quot.induction_on e $ λ ⟨m, x⟩, quot.induction_on f $ λ ⟨n, y⟩,
quot.induction_on g $ λ ⟨s, z⟩, congr_arg (quot.mk _) $
by simp only [add_assoc, mul_assoc, ring_hom.iterate_map_mul,
← iterate_add_apply, add_comm, add_left_comm],
one := mk K p (0, 1),
one_mul := λ e, quot.induction_on e (λ ⟨n, x⟩, congr_arg (quot.mk _) $
by simp only [ring_hom.iterate_map_one, iterate_zero_apply, one_mul, zero_add]),
mul_one := λ e, quot.induction_on e (λ ⟨n, x⟩, congr_arg (quot.mk _) $
by simp only [ring_hom.iterate_map_one, iterate_zero_apply, mul_one, add_zero]),
mul_comm := λ e f, quot.induction_on e (λ ⟨m, x⟩, quot.induction_on f (λ ⟨n, y⟩,
congr_arg (quot.mk _) $ by simp only [add_comm, mul_comm])),
.. (infer_instance : has_mul (perfect_closure K p)) }
lemma one_def : (1 : perfect_closure K p) = mk K p (0, 1) := rfl
instance : inhabited (perfect_closure K p) := ⟨1⟩
private lemma add_aux_left (x1 x2 y : ℕ × K) (H : r K p x1 x2) :
mk K p (x1.1 + y.1, ((frobenius K p)^[y.1] x1.2) + ((frobenius K p)^[x1.1] y.2)) =
mk K p (x2.1 + y.1, ((frobenius K p)^[y.1] x2.2) + ((frobenius K p)^[x2.1] y.2)) :=
match x1, x2, H with
| _, _, r.intro n x := quot.sound $ by rw [← iterate_succ_apply, iterate_succ',
iterate_succ', ← frobenius_add, nat.succ_add]; apply r.intro
end
private lemma add_aux_right (x y1 y2 : ℕ × K) (H : r K p y1 y2) :
mk K p (x.1 + y1.1, ((frobenius K p)^[y1.1] x.2) + ((frobenius K p)^[x.1] y1.2)) =
mk K p (x.1 + y2.1, ((frobenius K p)^[y2.1] x.2) + ((frobenius K p)^[x.1] y2.2)) :=
match y1, y2, H with
| _, _, r.intro n y := quot.sound $ by rw [← iterate_succ_apply, iterate_succ',
iterate_succ', ← frobenius_add]; apply r.intro
end
instance : has_add (perfect_closure K p) :=
⟨quot.lift (λ x:ℕ×K, quot.lift (λ y:ℕ×K, mk K p
(x.1 + y.1, ((frobenius K p)^[y.1] x.2) + ((frobenius K p)^[x.1] y.2))) (add_aux_right K p x))
(λ x1 x2 (H : r K p x1 x2), funext $ λ e, quot.induction_on e $ λ y,
add_aux_left K p x1 x2 y H)⟩
@[simp] lemma mk_add_mk (x y : ℕ × K) :
mk K p x + mk K p y =
mk K p (x.1 + y.1, ((frobenius K p)^[y.1] x.2) + ((frobenius K p)^[x.1] y.2)) := rfl
instance : has_neg (perfect_closure K p) :=
⟨quot.lift (λ x:ℕ×K, mk K p (x.1, -x.2)) (λ x y (H : r K p x y), match x, y, H with
| _, _, r.intro n x := quot.sound $ by rw ← frobenius_neg; apply r.intro
end)⟩
@[simp] lemma neg_mk (x : ℕ × K) : - mk K p x = mk K p (x.1, -x.2) := rfl
instance : has_zero (perfect_closure K p) := ⟨mk K p (0, 0)⟩
lemma zero_def : (0 : perfect_closure K p) = mk K p (0, 0) := rfl
theorem mk_zero (n : ℕ) : mk K p (n, 0) = 0 :=
by induction n with n ih; [refl, rw ← ih]; symmetry; apply quot.sound;
have := r.intro n (0:K); rwa [frobenius_zero K p] at this
theorem r.sound (m n : ℕ) (x y : K) (H : frobenius K p^[m] x = y) :
mk K p (n, x) = mk K p (m + n, y) :=
by subst H; induction m with m ih; [simp only [zero_add, iterate_zero_apply],
rw [ih, nat.succ_add, iterate_succ']]; apply quot.sound; apply r.intro
instance : comm_ring (perfect_closure K p) :=
{ add_assoc := λ e f g, quot.induction_on e $ λ ⟨m, x⟩, quot.induction_on f $ λ ⟨n, y⟩,
quot.induction_on g $ λ ⟨s, z⟩, congr_arg (quot.mk _) $
by simp only [ring_hom.iterate_map_add, ← iterate_add_apply, add_assoc, add_comm s _],
zero := 0,
zero_add := λ e, quot.induction_on e (λ ⟨n, x⟩, congr_arg (quot.mk _) $
by simp only [ring_hom.iterate_map_zero, iterate_zero_apply, zero_add]),
add_zero := λ e, quot.induction_on e (λ ⟨n, x⟩, congr_arg (quot.mk _) $
by simp only [ring_hom.iterate_map_zero, iterate_zero_apply, add_zero]),
sub_eq_add_neg := λ a b, rfl,
add_left_neg := λ e, by exact quot.induction_on e (λ ⟨n, x⟩,
by simp only [quot_mk_eq_mk, neg_mk, mk_add_mk,
ring_hom.iterate_map_neg, add_left_neg, mk_zero]),
add_comm := λ e f, quot.induction_on e (λ ⟨m, x⟩, quot.induction_on f (λ ⟨n, y⟩,
congr_arg (quot.mk _) $ by simp only [add_comm])),
left_distrib := λ e f g, quot.induction_on e $ λ ⟨m, x⟩, quot.induction_on f $ λ ⟨n, y⟩,
quot.induction_on g $ λ ⟨s, z⟩, show quot.mk _ _ = quot.mk _ _,
by simp only [add_assoc, add_comm, add_left_comm]; apply r.sound;
simp only [ring_hom.iterate_map_mul, ring_hom.iterate_map_add,
← iterate_add_apply, mul_add, add_comm, add_left_comm],
right_distrib := λ e f g, quot.induction_on e $ λ ⟨m, x⟩, quot.induction_on f $ λ ⟨n, y⟩,
quot.induction_on g $ λ ⟨s, z⟩, show quot.mk _ _ = quot.mk _ _,
by simp only [add_assoc, add_comm _ s, add_left_comm _ s]; apply r.sound;
simp only [ring_hom.iterate_map_mul, ring_hom.iterate_map_add,
← iterate_add_apply, add_mul, add_comm, add_left_comm],
.. (infer_instance : has_add (perfect_closure K p)),
.. (infer_instance : has_neg (perfect_closure K p)),
.. (infer_instance : comm_monoid (perfect_closure K p)) }
theorem eq_iff' (x y : ℕ × K) : mk K p x = mk K p y ↔
∃ z, (frobenius K p^[y.1 + z] x.2) = (frobenius K p^[x.1 + z] y.2) :=
begin
split,
{ intro H,
replace H := quot.exact _ H,
induction H,
case eqv_gen.rel : x y H
{ cases H with n x, exact ⟨0, rfl⟩ },
case eqv_gen.refl : H
{ exact ⟨0, rfl⟩ },
case eqv_gen.symm : x y H ih
{ cases ih with w ih, exact ⟨w, ih.symm⟩ },
case eqv_gen.trans : x y z H1 H2 ih1 ih2
{ cases ih1 with z1 ih1,
cases ih2 with z2 ih2,
existsi z2+(y.1+z1),
rw [← add_assoc, iterate_add_apply, ih1],
rw [← iterate_add_apply, add_comm, iterate_add_apply, ih2],
rw [← iterate_add_apply],
simp only [add_comm, add_left_comm] } },
intro H,
cases x with m x,
cases y with n y,
cases H with z H, dsimp only at H,
rw [r.sound K p (n+z) m x _ rfl, r.sound K p (m+z) n y _ rfl, H],
rw [add_assoc, add_comm, add_comm z]
end
theorem nat_cast (n x : ℕ) : (x : perfect_closure K p) = mk K p (n, x) :=
begin
induction n with n ih,
{ induction x with x ih, {refl},
rw [nat.cast_succ, nat.cast_succ, ih], refl },
rw ih, apply quot.sound,
conv {congr, skip, skip, rw ← frobenius_nat_cast K p x},
apply r.intro
end
theorem int_cast (x : ℤ) : (x : perfect_closure K p) = mk K p (0, x) :=
by induction x; simp only [int.cast_of_nat, int.cast_neg_succ_of_nat, nat_cast K p 0]; refl
theorem nat_cast_eq_iff (x y : ℕ) : (x : perfect_closure K p) = y ↔ (x : K) = y :=
begin
split; intro H,
{ rw [nat_cast K p 0, nat_cast K p 0, eq_iff'] at H,
cases H with z H,
simpa only [zero_add, iterate_fixed (frobenius_nat_cast K p _)] using H },
rw [nat_cast K p 0, nat_cast K p 0, H]
end
instance : char_p (perfect_closure K p) p :=
begin
constructor, intro x, rw ← char_p.cast_eq_zero_iff K,
rw [← nat.cast_zero, nat_cast_eq_iff, nat.cast_zero]
end
theorem frobenius_mk (x : ℕ × K) :
(frobenius (perfect_closure K p) p : perfect_closure K p → perfect_closure K p)
(mk K p x) = mk _ _ (x.1, x.2^p) :=
begin
simp only [frobenius_def], cases x with n x, dsimp only,
suffices : ∀ p':ℕ, mk K p (n, x) ^ p' = mk K p (n, x ^ p'),
{ apply this },
intro p, induction p with p ih,
case nat.zero { apply r.sound, rw [(frobenius _ _).iterate_map_one, pow_zero] },
case nat.succ
{ rw [pow_succ, ih],
symmetry,
apply r.sound,
simp only [pow_succ, (frobenius _ _).iterate_map_mul] }
end
/-- Embedding of `K` into `perfect_closure K p` -/
def of : K →+* perfect_closure K p :=
{ to_fun := λ x, mk _ _ (0, x),
map_one' := rfl,
map_mul' := λ x y, rfl,
map_zero' := rfl,
map_add' := λ x y, rfl }
lemma of_apply (x : K) : of K p x = mk _ _ (0, x) := rfl
end ring
theorem eq_iff [comm_ring K] [is_domain K] (p : ℕ) [fact p.prime] [char_p K p]
(x y : ℕ × K) : quot.mk (r K p) x = quot.mk (r K p) y ↔
(frobenius K p^[y.1] x.2) = (frobenius K p^[x.1] y.2) :=
(eq_iff' K p x y).trans ⟨λ ⟨z, H⟩, (frobenius_inj K p).iterate z $
by simpa only [add_comm, iterate_add] using H,
λ H, ⟨0, H⟩⟩
section field
variables [field K] (p : ℕ) [fact p.prime] [char_p K p]
instance : has_inv (perfect_closure K p) :=
⟨quot.lift (λ x:ℕ×K, quot.mk (r K p) (x.1, x.2⁻¹)) (λ x y (H : r K p x y), match x, y, H with
| _, _, r.intro n x := quot.sound $ by { simp only [frobenius_def], rw ← inv_pow₀, apply r.intro }
end)⟩
instance : field (perfect_closure K p) :=
{ exists_pair_ne := ⟨0, 1, λ H, zero_ne_one ((eq_iff _ _ _ _).1 H)⟩,
mul_inv_cancel := λ e, induction_on e $ λ ⟨m, x⟩ H,
have _ := mt (eq_iff _ _ _ _).2 H, (eq_iff _ _ _ _).2
(by simp only [(frobenius _ _).iterate_map_one, (frobenius K p).iterate_map_zero,
iterate_zero_apply, ← (frobenius _ p).iterate_map_mul] at this ⊢;
rw [mul_inv_cancel this, (frobenius _ _).iterate_map_one]),
inv_zero := congr_arg (quot.mk (r K p)) (by rw [inv_zero]),
.. (infer_instance : has_inv (perfect_closure K p)),
.. (infer_instance : comm_ring (perfect_closure K p)) }
instance : perfect_ring (perfect_closure K p) p :=
{ pth_root' := λ e, lift_on e (λ x, mk K p (x.1 + 1, x.2)) (λ x y H,
match x, y, H with
| _, _, r.intro n x := quot.sound (r.intro _ _)
end),
frobenius_pth_root' := λ e, induction_on e (λ ⟨n, x⟩,
by { simp only [lift_on_mk, frobenius_mk], exact (quot.sound $ r.intro _ _).symm }),
pth_root_frobenius' := λ e, induction_on e (λ ⟨n, x⟩,
by { simp only [lift_on_mk, frobenius_mk], exact (quot.sound $ r.intro _ _).symm }) }
theorem eq_pth_root (x : ℕ × K) :
mk K p x = (pth_root (perfect_closure K p) p^[x.1] (of K p x.2)) :=
begin
rcases x with ⟨m, x⟩,
induction m with m ih, {refl},
rw [iterate_succ_apply', ← ih]; refl
end
/-- Given a field `K` of characteristic `p` and a perfect ring `L` of the same characteristic,
any homomorphism `K →+* L` can be lifted to `perfect_closure K p`. -/
def lift (L : Type v) [comm_semiring L] [char_p L p] [perfect_ring L p] :
(K →+* L) ≃ (perfect_closure K p →+* L) :=
begin
have := left_inverse_pth_root_frobenius.iterate,
refine_struct { .. },
field to_fun { intro f,
refine_struct { .. },
field to_fun { refine λ e, lift_on e (λ x, pth_root L p^[x.1] (f x.2)) _,
rintro a b ⟨n⟩,
simp only [f.map_frobenius, iterate_succ_apply, pth_root_frobenius] },
field map_one' { exact f.map_one },
field map_zero' { exact f.map_zero },
field map_mul' { rintro ⟨x⟩ ⟨y⟩,
simp only [quot_mk_eq_mk, lift_on_mk, mk_mul_mk, ring_hom.map_iterate_frobenius,
ring_hom.iterate_map_mul, ring_hom.map_mul],
rw [iterate_add_apply, this _ _, add_comm, iterate_add_apply, this _ _] },
field map_add' { rintro ⟨x⟩ ⟨y⟩,
simp only [quot_mk_eq_mk, lift_on_mk, mk_add_mk, ring_hom.map_iterate_frobenius,
ring_hom.iterate_map_add, ring_hom.map_add],
rw [iterate_add_apply, this _ _, add_comm x.1, iterate_add_apply, this _ _] } },
field inv_fun { exact λ f, f.comp (of K p) },
field left_inv { intro f, ext x, refl },
field right_inv { intro f, ext ⟨x⟩,
simp only [ring_hom.coe_mk, quot_mk_eq_mk, ring_hom.comp_apply, lift_on_mk],
rw [eq_pth_root, ring_hom.map_iterate_pth_root] }
end
end field
end perfect_closure
|
6760f6defe495e1a20e46764ab68ac57c201cc06 | 5d166a16ae129621cb54ca9dde86c275d7d2b483 | /tests/lean/unfold_crash.lean | 18a14db2f5dce42f992e689aced747dc3a23a872 | [
"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 | 298 | lean | --
open nat tactic
example (a b : nat) : a = succ b → a = b + 1 :=
by do
H ← intro `H,
try (dunfold_at [`nat.succ] H),
dunfold [`add, `has_add.add, `has_one.one, `nat.add, `one],
trace_state,
t ← target,
expected ← to_expr ```(a = succ b),
guard (t = expected),
assumption
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.