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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32a79ca67b1681b4a9a5a329329628ecef8ac780 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/1760.lean | 4399bcf006a52e16ef9bd0a017744ed6f274b14d | [
"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 | 122 | lean | section
parameter big_type : Type 1
parameter x : big_type
parameter f {A : Type} : A → bool
def foo : bool := f x
end
|
027d6df176a8ea798c713d9c85506621b6f36cab | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/topology/fiber_bundle/trivialization.lean | 5efdcb77912b004af48ea9439f07f890ecb13b3a | [
"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 | 31,315 | lean | /-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import data.bundle
import topology.algebra.order.field
import topology.local_homeomorph
/-!
# Trivializations
## Main definitions
### Basic definitions
* `trivialization F p` : structure extending local homeomorphisms, defining a local
trivialization of a topological space `Z` with projection `p` and fiber `F`.
* `pretrivialization F proj` : trivialization as a local equivalence, mainly used when the
topology on the total space has not yet been defined.
### Operations on bundles
We provide the following operations on `trivialization`s.
* `trivialization.comp_homeomorph`: given a local trivialization `e` of a fiber bundle
`p : Z → B` and a homeomorphism `h : Z' ≃ₜ Z`, returns a local trivialization of the fiber bundle
`p ∘ h`.
## Implementation notes
Previously, in mathlib, there was a structure `topological_vector_bundle.trivialization` which
extended another structure `topological_fibre_bundle.trivialization` by a linearity hypothesis. As
of PR #17359, we have changed this to a single structure `trivialization` (no namespace), together
with a mixin class `trivialization.is_linear`.
This permits all the *data* of a vector bundle to be held at the level of fibre bundles, so that the
same trivializations can underlie an object's structure as (say) a vector bundle over `ℂ` and as a
vector bundle over `ℝ`, as well as its structure simply as a fibre bundle.
This might be a little surprising, given the general trend of the library to ever-increased
bundling. But in this case the typical motivation for more bundling does not apply: there is no
algebraic or order structure on the whole type of linear (say) trivializations of a bundle.
Indeed, since trivializations only have meaning on their base sets (taking junk values outside), the
type of linear trivializations is not even particularly well-behaved.
-/
open topological_space filter set bundle
open_locale topological_space classical bundle
variables {ι : Type*} {B : Type*} {F : Type*} {E : B → Type*}
variables (F) {Z : Type*} [topological_space B] [topological_space F] {proj : Z → B}
/-- This structure contains the information left for a local trivialization (which is implemented
below as `trivialization F proj`) if the total space has not been given a topology, but we
have a topology on both the fiber and the base space. Through the construction
`topological_fiber_prebundle F proj` it will be possible to promote a
`pretrivialization F proj` to a `trivialization F proj`. -/
@[ext, nolint has_nonempty_instance]
structure pretrivialization (proj : Z → B) extends local_equiv Z (B × F) :=
(open_target : is_open target)
(base_set : set B)
(open_base_set : is_open base_set)
(source_eq : source = proj ⁻¹' base_set)
(target_eq : target = base_set ×ˢ univ)
(proj_to_fun : ∀ p ∈ source, (to_fun p).1 = proj p)
namespace pretrivialization
instance : has_coe_to_fun (pretrivialization F proj) (λ _, Z → (B × F)) := ⟨λ e, e.to_fun⟩
variables {F} (e : pretrivialization F proj) {x : Z}
@[simp, mfld_simps] lemma coe_coe : ⇑e.to_local_equiv = e := rfl
@[simp, mfld_simps] lemma coe_fst (ex : x ∈ e.source) : (e x).1 = proj x := e.proj_to_fun x ex
lemma mem_source : x ∈ e.source ↔ proj x ∈ e.base_set := by rw [e.source_eq, mem_preimage]
lemma coe_fst' (ex : proj x ∈ e.base_set) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex)
protected lemma eq_on : eq_on (prod.fst ∘ e) proj e.source := λ x hx, e.coe_fst hx
lemma mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x := prod.ext (e.coe_fst ex).symm rfl
lemma mk_proj_snd' (ex : proj x ∈ e.base_set) : (proj x, (e x).2) = e x :=
prod.ext (e.coe_fst' ex).symm rfl
/-- Composition of inverse and coercion from the subtype of the target. -/
def set_symm : e.target → Z := e.target.restrict e.to_local_equiv.symm
lemma mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.base_set :=
by rw [e.target_eq, prod_univ, mem_preimage]
lemma proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.to_local_equiv.symm x) = x.1 :=
begin
have := (e.coe_fst (e.to_local_equiv.map_target hx)).symm,
rwa [← e.coe_coe, e.to_local_equiv.right_inv hx] at this
end
lemma proj_symm_apply' {b : B} {x : F} (hx : b ∈ e.base_set) :
proj (e.to_local_equiv.symm (b, x)) = b :=
e.proj_symm_apply (e.mem_target.2 hx)
lemma proj_surj_on_base_set [nonempty F] : set.surj_on proj e.source e.base_set :=
λ b hb, let ⟨y⟩ := ‹nonempty F› in ⟨e.to_local_equiv.symm (b, y),
e.to_local_equiv.map_target $ e.mem_target.2 hb, e.proj_symm_apply' hb⟩
lemma apply_symm_apply {x : B × F} (hx : x ∈ e.target) : e (e.to_local_equiv.symm x) = x :=
e.to_local_equiv.right_inv hx
lemma apply_symm_apply' {b : B} {x : F} (hx : b ∈ e.base_set) :
e (e.to_local_equiv.symm (b, x)) = (b, x) :=
e.apply_symm_apply (e.mem_target.2 hx)
lemma symm_apply_apply {x : Z} (hx : x ∈ e.source) : e.to_local_equiv.symm (e x) = x :=
e.to_local_equiv.left_inv hx
@[simp, mfld_simps] lemma symm_apply_mk_proj {x : Z} (ex : x ∈ e.source) :
e.to_local_equiv.symm (proj x, (e x).2) = x :=
by rw [← e.coe_fst ex, prod.mk.eta, ← e.coe_coe, e.to_local_equiv.left_inv ex]
@[simp, mfld_simps] lemma preimage_symm_proj_base_set :
(e.to_local_equiv.symm ⁻¹' (proj ⁻¹' e.base_set)) ∩ e.target = e.target :=
begin
refine inter_eq_right_iff_subset.mpr (λ x hx, _),
simp only [mem_preimage, local_equiv.inv_fun_as_coe, e.proj_symm_apply hx],
exact e.mem_target.mp hx,
end
@[simp, mfld_simps] lemma preimage_symm_proj_inter (s : set B) :
(e.to_local_equiv.symm ⁻¹' (proj ⁻¹' s)) ∩ e.base_set ×ˢ univ = (s ∩ e.base_set) ×ˢ univ :=
begin
ext ⟨x, y⟩,
suffices : x ∈ e.base_set → (proj (e.to_local_equiv.symm (x, y)) ∈ s ↔ x ∈ s),
by simpa only [prod_mk_mem_set_prod_eq, mem_inter_iff, and_true, mem_univ, and.congr_left_iff],
intro h,
rw [e.proj_symm_apply' h]
end
lemma target_inter_preimage_symm_source_eq (e f : pretrivialization F proj) :
f.target ∩ (f.to_local_equiv.symm) ⁻¹' e.source = (e.base_set ∩ f.base_set) ×ˢ univ :=
by rw [inter_comm, f.target_eq, e.source_eq, f.preimage_symm_proj_inter]
lemma trans_source (e f : pretrivialization F proj) :
(f.to_local_equiv.symm.trans e.to_local_equiv).source = (e.base_set ∩ f.base_set) ×ˢ univ :=
by rw [local_equiv.trans_source, local_equiv.symm_source, e.target_inter_preimage_symm_source_eq]
lemma symm_trans_symm (e e' : pretrivialization F proj) :
(e.to_local_equiv.symm.trans e'.to_local_equiv).symm =
e'.to_local_equiv.symm.trans e.to_local_equiv :=
by rw [local_equiv.trans_symm_eq_symm_trans_symm, local_equiv.symm_symm]
lemma symm_trans_source_eq (e e' : pretrivialization F proj) :
(e.to_local_equiv.symm.trans e'.to_local_equiv).source = (e.base_set ∩ e'.base_set) ×ˢ univ :=
by rw [local_equiv.trans_source, e'.source_eq, local_equiv.symm_source, e.target_eq, inter_comm,
e.preimage_symm_proj_inter, inter_comm]
lemma symm_trans_target_eq (e e' : pretrivialization F proj) :
(e.to_local_equiv.symm.trans e'.to_local_equiv).target = (e.base_set ∩ e'.base_set) ×ˢ univ :=
by rw [← local_equiv.symm_source, symm_trans_symm, symm_trans_source_eq, inter_comm]
variables {B F} (e' : pretrivialization F (π E)) {x' : total_space E} {b : B} {y : E b}
lemma coe_mem_source : ↑y ∈ e'.source ↔ b ∈ e'.base_set := e'.mem_source
@[simp, mfld_simps] lemma coe_coe_fst (hb : b ∈ e'.base_set) : (e' y).1 = b :=
e'.coe_fst (e'.mem_source.2 hb)
lemma mk_mem_target {x : B} {y : F} : (x, y) ∈ e'.target ↔ x ∈ e'.base_set :=
e'.mem_target
lemma symm_coe_proj {x : B} {y : F} (e' : pretrivialization F (π E)) (h : x ∈ e'.base_set) :
(e'.to_local_equiv.symm (x, y)).1 = x :=
e'.proj_symm_apply' h
section has_zero
variables [∀ x, has_zero (E x)]
/-- A fiberwise inverse to `e`. This is the function `F → E b` that induces a local inverse
`B × F → total_space E` of `e` on `e.base_set`. It is defined to be `0` outside `e.base_set`. -/
protected noncomputable def symm (e : pretrivialization F (π E)) (b : B) (y : F) : E b :=
if hb : b ∈ e.base_set
then cast (congr_arg E (e.proj_symm_apply' hb)) (e.to_local_equiv.symm (b, y)).2
else 0
lemma symm_apply (e : pretrivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :
e.symm b y = cast (congr_arg E (e.symm_coe_proj hb)) (e.to_local_equiv.symm (b, y)).2 :=
dif_pos hb
lemma symm_apply_of_not_mem (e : pretrivialization F (π E)) {b : B} (hb : b ∉ e.base_set) (y : F) :
e.symm b y = 0 :=
dif_neg hb
lemma coe_symm_of_not_mem (e : pretrivialization F (π E)) {b : B} (hb : b ∉ e.base_set) :
(e.symm b : F → E b) = 0 :=
funext $ λ y, dif_neg hb
lemma mk_symm (e : pretrivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :
total_space_mk b (e.symm b y) = e.to_local_equiv.symm (b, y) :=
by rw [e.symm_apply hb, total_space.mk_cast, total_space.eta]
lemma symm_proj_apply (e : pretrivialization F (π E)) (z : total_space E)
(hz : z.proj ∈ e.base_set) : e.symm z.proj (e z).2 = z.2 :=
by rw [e.symm_apply hz, cast_eq_iff_heq, e.mk_proj_snd' hz,
e.symm_apply_apply (e.mem_source.mpr hz)]
lemma symm_apply_apply_mk (e : pretrivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : E b) :
e.symm b (e (total_space_mk b y)).2 = y :=
e.symm_proj_apply (total_space_mk b y) hb
lemma apply_mk_symm (e : pretrivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :
e (total_space_mk b (e.symm b y)) = (b, y) :=
by rw [e.mk_symm hb, e.apply_symm_apply (e.mk_mem_target.mpr hb)]
end has_zero
end pretrivialization
variables [topological_space Z] [topological_space (total_space E)]
/--
A structure extending local homeomorphisms, defining a local trivialization of a projection
`proj : Z → B` with fiber `F`, as a local homeomorphism between `Z` and `B × F` defined between two
sets of the form `proj ⁻¹' base_set` and `base_set × F`, acting trivially on the first coordinate.
-/
@[ext, nolint has_nonempty_instance]
structure trivialization (proj : Z → B)
extends local_homeomorph Z (B × F) :=
(base_set : set B)
(open_base_set : is_open base_set)
(source_eq : source = proj ⁻¹' base_set)
(target_eq : target = base_set ×ˢ univ)
(proj_to_fun : ∀ p ∈ source, (to_local_homeomorph p).1 = proj p)
namespace trivialization
variables {F} (e : trivialization F proj) {x : Z}
/-- Natural identification as a `pretrivialization`. -/
def to_pretrivialization : pretrivialization F proj := { ..e }
instance : has_coe_to_fun (trivialization F proj) (λ _, Z → B × F) := ⟨λ e, e.to_fun⟩
instance : has_coe (trivialization F proj) (pretrivialization F proj) :=
⟨to_pretrivialization⟩
lemma to_pretrivialization_injective :
function.injective (λ e : trivialization F proj, e.to_pretrivialization) :=
by { intros e e', rw [pretrivialization.ext_iff, trivialization.ext_iff,
← local_homeomorph.to_local_equiv_injective.eq_iff], exact id }
@[simp, mfld_simps] lemma coe_coe : ⇑e.to_local_homeomorph = e := rfl
@[simp, mfld_simps] lemma coe_fst (ex : x ∈ e.source) : (e x).1 = proj x := e.proj_to_fun x ex
protected lemma eq_on : eq_on (prod.fst ∘ e) proj e.source := λ x hx, e.coe_fst hx
lemma mem_source : x ∈ e.source ↔ proj x ∈ e.base_set := by rw [e.source_eq, mem_preimage]
lemma coe_fst' (ex : proj x ∈ e.base_set) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex)
lemma mk_proj_snd (ex : x ∈ e.source) : (proj x, (e x).2) = e x := prod.ext (e.coe_fst ex).symm rfl
lemma mk_proj_snd' (ex : proj x ∈ e.base_set) : (proj x, (e x).2) = e x :=
prod.ext (e.coe_fst' ex).symm rfl
lemma source_inter_preimage_target_inter (s : set (B × F)) :
e.source ∩ (e ⁻¹' (e.target ∩ s)) = e.source ∩ (e ⁻¹' s) :=
e.to_local_homeomorph.source_inter_preimage_target_inter s
@[simp, mfld_simps] lemma coe_mk (e : local_homeomorph Z (B × F)) (i j k l m) (x : Z) :
(trivialization.mk e i j k l m : trivialization F proj) x = e x := rfl
lemma mem_target {x : B × F} : x ∈ e.target ↔ x.1 ∈ e.base_set :=
e.to_pretrivialization.mem_target
lemma map_target {x : B × F} (hx : x ∈ e.target) : e.to_local_homeomorph.symm x ∈ e.source :=
e.to_local_homeomorph.map_target hx
lemma proj_symm_apply {x : B × F} (hx : x ∈ e.target) : proj (e.to_local_homeomorph.symm x) = x.1 :=
e.to_pretrivialization.proj_symm_apply hx
lemma proj_symm_apply' {b : B} {x : F}
(hx : b ∈ e.base_set) : proj (e.to_local_homeomorph.symm (b, x)) = b :=
e.to_pretrivialization.proj_symm_apply' hx
lemma proj_surj_on_base_set [nonempty F] : set.surj_on proj e.source e.base_set :=
e.to_pretrivialization.proj_surj_on_base_set
lemma apply_symm_apply {x : B × F} (hx : x ∈ e.target) : e (e.to_local_homeomorph.symm x) = x :=
e.to_local_homeomorph.right_inv hx
lemma apply_symm_apply'
{b : B} {x : F} (hx : b ∈ e.base_set) : e (e.to_local_homeomorph.symm (b, x)) = (b, x) :=
e.to_pretrivialization.apply_symm_apply' hx
@[simp, mfld_simps] lemma symm_apply_mk_proj (ex : x ∈ e.source) :
e.to_local_homeomorph.symm (proj x, (e x).2) = x :=
e.to_pretrivialization.symm_apply_mk_proj ex
lemma symm_trans_source_eq (e e' : trivialization F proj) :
(e.to_local_equiv.symm.trans e'.to_local_equiv).source = (e.base_set ∩ e'.base_set) ×ˢ univ :=
pretrivialization.symm_trans_source_eq e.to_pretrivialization e'
lemma symm_trans_target_eq (e e' : trivialization F proj) :
(e.to_local_equiv.symm.trans e'.to_local_equiv).target = (e.base_set ∩ e'.base_set) ×ˢ univ :=
pretrivialization.symm_trans_target_eq e.to_pretrivialization e'
lemma coe_fst_eventually_eq_proj (ex : x ∈ e.source) : prod.fst ∘ e =ᶠ[𝓝 x] proj :=
mem_nhds_iff.2 ⟨e.source, λ y hy, e.coe_fst hy, e.open_source, ex⟩
lemma coe_fst_eventually_eq_proj' (ex : proj x ∈ e.base_set) : prod.fst ∘ e =ᶠ[𝓝 x] proj :=
e.coe_fst_eventually_eq_proj (e.mem_source.2 ex)
lemma map_proj_nhds (ex : x ∈ e.source) : map proj (𝓝 x) = 𝓝 (proj x) :=
by rw [← e.coe_fst ex, ← map_congr (e.coe_fst_eventually_eq_proj ex), ← map_map, ← e.coe_coe,
e.to_local_homeomorph.map_nhds_eq ex, map_fst_nhds]
lemma preimage_subset_source {s : set B} (hb : s ⊆ e.base_set) : proj ⁻¹' s ⊆ e.source :=
λ p hp, e.mem_source.mpr (hb hp)
lemma image_preimage_eq_prod_univ {s : set B} (hb : s ⊆ e.base_set) :
e '' (proj ⁻¹' s) = s ×ˢ univ :=
subset.antisymm (image_subset_iff.mpr (λ p hp,
⟨(e.proj_to_fun p (e.preimage_subset_source hb hp)).symm ▸ hp, trivial⟩)) (λ p hp,
let hp' : p ∈ e.target := e.mem_target.mpr (hb hp.1) in
⟨e.inv_fun p, mem_preimage.mpr ((e.proj_symm_apply hp').symm ▸ hp.1), e.apply_symm_apply hp'⟩)
/-- The preimage of a subset of the base set is homeomorphic to the product with the fiber. -/
def preimage_homeomorph {s : set B} (hb : s ⊆ e.base_set) : proj ⁻¹' s ≃ₜ s × F :=
(e.to_local_homeomorph.homeomorph_of_image_subset_source (e.preimage_subset_source hb)
(e.image_preimage_eq_prod_univ hb)).trans
((homeomorph.set.prod s univ).trans ((homeomorph.refl s).prod_congr (homeomorph.set.univ F)))
@[simp] lemma preimage_homeomorph_apply {s : set B} (hb : s ⊆ e.base_set) (p : proj ⁻¹' s) :
e.preimage_homeomorph hb p = (⟨proj p, p.2⟩, (e p).2) :=
prod.ext (subtype.ext (e.proj_to_fun p (e.mem_source.mpr (hb p.2)))) rfl
@[simp] lemma preimage_homeomorph_symm_apply {s : set B} (hb : s ⊆ e.base_set) (p : s × F) :
(e.preimage_homeomorph hb).symm p = ⟨e.symm (p.1, p.2), ((e.preimage_homeomorph hb).symm p).2⟩ :=
rfl
/-- The source is homeomorphic to the product of the base set with the fiber. -/
def source_homeomorph_base_set_prod : e.source ≃ₜ e.base_set × F :=
(homeomorph.set_congr e.source_eq).trans (e.preimage_homeomorph subset_rfl)
@[simp] lemma source_homeomorph_base_set_prod_apply (p : e.source) :
e.source_homeomorph_base_set_prod p = (⟨proj p, e.mem_source.mp p.2⟩, (e p).2) :=
e.preimage_homeomorph_apply subset_rfl ⟨p, e.mem_source.mp p.2⟩
@[simp] lemma source_homeomorph_base_set_prod_symm_apply (p : e.base_set × F) :
e.source_homeomorph_base_set_prod.symm p =
⟨e.symm (p.1, p.2), (e.source_homeomorph_base_set_prod.symm p).2⟩ :=
rfl
/-- Each fiber of a trivialization is homeomorphic to the specified fiber. -/
def preimage_singleton_homeomorph {b : B} (hb : b ∈ e.base_set) : proj ⁻¹' {b} ≃ₜ F :=
(e.preimage_homeomorph (set.singleton_subset_iff.mpr hb)).trans (((homeomorph.homeomorph_of_unique
({b} : set B) punit).prod_congr (homeomorph.refl F)).trans (homeomorph.punit_prod F))
@[simp] lemma preimage_singleton_homeomorph_apply {b : B} (hb : b ∈ e.base_set)
(p : proj ⁻¹' {b}) : e.preimage_singleton_homeomorph hb p = (e p).2 :=
rfl
@[simp] lemma preimage_singleton_homeomorph_symm_apply {b : B} (hb : b ∈ e.base_set) (p : F) :
(e.preimage_singleton_homeomorph hb).symm p =
⟨e.symm (b, p), by rw [mem_preimage, e.proj_symm_apply' hb, mem_singleton_iff]⟩ :=
rfl
/-- In the domain of a bundle trivialization, the projection is continuous-/
lemma continuous_at_proj (ex : x ∈ e.source) : continuous_at proj x :=
(e.map_proj_nhds ex).le
/-- Composition of a `trivialization` and a `homeomorph`. -/
protected def comp_homeomorph {Z' : Type*} [topological_space Z'] (h : Z' ≃ₜ Z) :
trivialization F (proj ∘ h) :=
{ to_local_homeomorph := h.to_local_homeomorph.trans e.to_local_homeomorph,
base_set := e.base_set,
open_base_set := e.open_base_set,
source_eq := by simp [e.source_eq, preimage_preimage],
target_eq := by simp [e.target_eq],
proj_to_fun := λ p hp,
have hp : h p ∈ e.source, by simpa using hp,
by simp [hp] }
/-- Read off the continuity of a function `f : Z → X` at `z : Z` by transferring via a
trivialization of `Z` containing `z`. -/
lemma continuous_at_of_comp_right {X : Type*} [topological_space X] {f : Z → X} {z : Z}
(e : trivialization F proj) (he : proj z ∈ e.base_set)
(hf : continuous_at (f ∘ e.to_local_equiv.symm) (e z)) :
continuous_at f z :=
begin
have hez : z ∈ e.to_local_equiv.symm.target,
{ rw [local_equiv.symm_target, e.mem_source],
exact he },
rwa [e.to_local_homeomorph.symm.continuous_at_iff_continuous_at_comp_right hez,
local_homeomorph.symm_symm]
end
/-- Read off the continuity of a function `f : X → Z` at `x : X` by transferring via a
trivialization of `Z` containing `f x`. -/
lemma continuous_at_of_comp_left {X : Type*} [topological_space X] {f : X → Z} {x : X}
(e : trivialization F proj) (hf_proj : continuous_at (proj ∘ f) x) (he : proj (f x) ∈ e.base_set)
(hf : continuous_at (e ∘ f) x) :
continuous_at f x :=
begin
rw e.to_local_homeomorph.continuous_at_iff_continuous_at_comp_left,
{ exact hf },
rw [e.source_eq, ← preimage_comp],
exact hf_proj.preimage_mem_nhds (e.open_base_set.mem_nhds he),
end
variables {E} (e' : trivialization F (π E)) {x' : total_space E} {b : B} {y : E b}
protected lemma continuous_on : continuous_on e' e'.source := e'.continuous_to_fun
lemma coe_mem_source : ↑y ∈ e'.source ↔ b ∈ e'.base_set := e'.mem_source
lemma open_target : is_open e'.target :=
by { rw e'.target_eq, exact e'.open_base_set.prod is_open_univ }
@[simp, mfld_simps] lemma coe_coe_fst (hb : b ∈ e'.base_set) : (e' y).1 = b :=
e'.coe_fst (e'.mem_source.2 hb)
lemma mk_mem_target {y : F} : (b, y) ∈ e'.target ↔ b ∈ e'.base_set :=
e'.to_pretrivialization.mem_target
lemma symm_apply_apply {x : total_space E} (hx : x ∈ e'.source) :
e'.to_local_homeomorph.symm (e' x) = x :=
e'.to_local_equiv.left_inv hx
@[simp, mfld_simps] lemma symm_coe_proj {x : B} {y : F}
(e : trivialization F (π E)) (h : x ∈ e.base_set) :
(e.to_local_homeomorph.symm (x, y)).1 = x := e.proj_symm_apply' h
section has_zero
variables [∀ x, has_zero (E x)]
/-- A fiberwise inverse to `e'`. The function `F → E x` that induces a local inverse
`B × F → total_space E` of `e'` on `e'.base_set`. It is defined to be `0` outside `e'.base_set`. -/
protected noncomputable def symm (e : trivialization F (π E)) (b : B) (y : F) : E b :=
e.to_pretrivialization.symm b y
lemma symm_apply (e : trivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :
e.symm b y = cast (congr_arg E (e.symm_coe_proj hb)) (e.to_local_homeomorph.symm (b, y)).2 :=
dif_pos hb
lemma symm_apply_of_not_mem (e : trivialization F (π E)) {b : B} (hb : b ∉ e.base_set) (y : F) :
e.symm b y = 0 :=
dif_neg hb
lemma mk_symm (e : trivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :
total_space_mk b (e.symm b y) = e.to_local_homeomorph.symm (b, y) :=
e.to_pretrivialization.mk_symm hb y
lemma symm_proj_apply (e : trivialization F (π E)) (z : total_space E)
(hz : z.proj ∈ e.base_set) : e.symm z.proj (e z).2 = z.2 :=
e.to_pretrivialization.symm_proj_apply z hz
lemma symm_apply_apply_mk (e : trivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : E b) :
e.symm b (e (total_space_mk b y)).2 = y :=
e.symm_proj_apply (total_space_mk b y) hb
lemma apply_mk_symm (e : trivialization F (π E)) {b : B} (hb : b ∈ e.base_set) (y : F) :
e (total_space_mk b (e.symm b y)) = (b, y) :=
e.to_pretrivialization.apply_mk_symm hb y
lemma continuous_on_symm (e : trivialization F (π E)) :
continuous_on (λ z : B × F, total_space_mk z.1 (e.symm z.1 z.2)) (e.base_set ×ˢ univ) :=
begin
have : ∀ (z : B × F) (hz : z ∈ e.base_set ×ˢ (univ : set F)),
total_space_mk z.1 (e.symm z.1 z.2) = e.to_local_homeomorph.symm z,
{ rintro x ⟨hx : x.1 ∈ e.base_set, _⟩, simp_rw [e.mk_symm hx, prod.mk.eta] },
refine continuous_on.congr _ this,
rw [← e.target_eq],
exact e.to_local_homeomorph.continuous_on_symm
end
end has_zero
/-- If `e` is a `trivialization` of `proj : Z → B` with fiber `F` and `h` is a homeomorphism
`F ≃ₜ F'`, then `e.trans_fiber_homeomorph h` is the trivialization of `proj` with the fiber `F'`
that sends `p : Z` to `((e p).1, h (e p).2)`. -/
def trans_fiber_homeomorph {F' : Type*} [topological_space F']
(e : trivialization F proj) (h : F ≃ₜ F') : trivialization F' proj :=
{ to_local_homeomorph := e.to_local_homeomorph.trans_homeomorph $ (homeomorph.refl _).prod_congr h,
base_set := e.base_set,
open_base_set := e.open_base_set,
source_eq := e.source_eq,
target_eq := by simp [e.target_eq, prod_univ, preimage_preimage],
proj_to_fun := e.proj_to_fun }
@[simp] lemma trans_fiber_homeomorph_apply {F' : Type*} [topological_space F']
(e : trivialization F proj) (h : F ≃ₜ F') (x : Z) :
e.trans_fiber_homeomorph h x = ((e x).1, h (e x).2) :=
rfl
/-- Coordinate transformation in the fiber induced by a pair of bundle trivializations. See also
`trivialization.coord_change_homeomorph` for a version bundled as `F ≃ₜ F`. -/
def coord_change (e₁ e₂ : trivialization F proj) (b : B) (x : F) : F :=
(e₂ $ e₁.to_local_homeomorph.symm (b, x)).2
lemma mk_coord_change
(e₁ e₂ : trivialization F proj) {b : B}
(h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) (x : F) :
(b, e₁.coord_change e₂ b x) = e₂ (e₁.to_local_homeomorph.symm (b, x)) :=
begin
refine prod.ext _ rfl,
rw [e₂.coe_fst', ← e₁.coe_fst', e₁.apply_symm_apply' h₁],
{ rwa [e₁.proj_symm_apply' h₁] },
{ rwa [e₁.proj_symm_apply' h₁] }
end
lemma coord_change_apply_snd
(e₁ e₂ : trivialization F proj) {p : Z}
(h : proj p ∈ e₁.base_set) :
e₁.coord_change e₂ (proj p) (e₁ p).snd = (e₂ p).snd :=
by rw [coord_change, e₁.symm_apply_mk_proj (e₁.mem_source.2 h)]
lemma coord_change_same_apply
(e : trivialization F proj) {b : B} (h : b ∈ e.base_set) (x : F) :
e.coord_change e b x = x :=
by rw [coord_change, e.apply_symm_apply' h]
lemma coord_change_same
(e : trivialization F proj) {b : B} (h : b ∈ e.base_set) :
e.coord_change e b = id :=
funext $ e.coord_change_same_apply h
lemma coord_change_coord_change
(e₁ e₂ e₃ : trivialization F proj) {b : B}
(h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) (x : F) :
e₂.coord_change e₃ b (e₁.coord_change e₂ b x) = e₁.coord_change e₃ b x :=
begin
rw [coord_change, e₁.mk_coord_change _ h₁ h₂, ← e₂.coe_coe,
e₂.to_local_homeomorph.left_inv, coord_change],
rwa [e₂.mem_source, e₁.proj_symm_apply' h₁]
end
lemma continuous_coord_change (e₁ e₂ : trivialization F proj) {b : B}
(h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) :
continuous (e₁.coord_change e₂ b) :=
begin
refine continuous_snd.comp (e₂.to_local_homeomorph.continuous_on.comp_continuous
(e₁.to_local_homeomorph.continuous_on_symm.comp_continuous _ _) _),
{ exact continuous_const.prod_mk continuous_id },
{ exact λ x, e₁.mem_target.2 h₁ },
{ intro x,
rwa [e₂.mem_source, e₁.proj_symm_apply' h₁] }
end
/-- Coordinate transformation in the fiber induced by a pair of bundle trivializations,
as a homeomorphism. -/
protected def coord_change_homeomorph
(e₁ e₂ : trivialization F proj) {b : B} (h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) :
F ≃ₜ F :=
{ to_fun := e₁.coord_change e₂ b,
inv_fun := e₂.coord_change e₁ b,
left_inv := λ x, by simp only [*, coord_change_coord_change, coord_change_same_apply],
right_inv := λ x, by simp only [*, coord_change_coord_change, coord_change_same_apply],
continuous_to_fun := e₁.continuous_coord_change e₂ h₁ h₂,
continuous_inv_fun := e₂.continuous_coord_change e₁ h₂ h₁ }
@[simp] lemma coord_change_homeomorph_coe
(e₁ e₂ : trivialization F proj) {b : B} (h₁ : b ∈ e₁.base_set) (h₂ : b ∈ e₂.base_set) :
⇑(e₁.coord_change_homeomorph e₂ h₁ h₂) = e₁.coord_change e₂ b :=
rfl
variables {F} {B' : Type*} [topological_space B']
lemma is_image_preimage_prod (e : trivialization F proj) (s : set B) :
e.to_local_homeomorph.is_image (proj ⁻¹' s) (s ×ˢ univ) :=
λ x hx, by simp [e.coe_fst', hx]
/-- Restrict a `trivialization` to an open set in the base. `-/
protected def restr_open (e : trivialization F proj) (s : set B)
(hs : is_open s) : trivialization F proj :=
{ to_local_homeomorph := ((e.is_image_preimage_prod s).symm.restr
(is_open.inter e.open_target (hs.prod is_open_univ))).symm,
base_set := e.base_set ∩ s,
open_base_set := is_open.inter e.open_base_set hs,
source_eq := by simp [e.source_eq],
target_eq := by simp [e.target_eq, prod_univ],
proj_to_fun := λ p hp, e.proj_to_fun p hp.1 }
section piecewise
lemma frontier_preimage (e : trivialization F proj) (s : set B) :
e.source ∩ frontier (proj ⁻¹' s) = proj ⁻¹' (e.base_set ∩ frontier s) :=
by rw [← (e.is_image_preimage_prod s).frontier.preimage_eq, frontier_prod_univ_eq,
(e.is_image_preimage_prod _).preimage_eq, e.source_eq, preimage_inter]
/-- Given two bundle trivializations `e`, `e'` of `proj : Z → B` and a set `s : set B` such that
the base sets of `e` and `e'` intersect `frontier s` on the same set and `e p = e' p` whenever
`proj p ∈ e.base_set ∩ frontier s`, `e.piecewise e' s Hs Heq` is the bundle trivialization over
`set.ite s e.base_set e'.base_set` that is equal to `e` on `proj ⁻¹ s` and is equal to `e'`
otherwise. -/
noncomputable def piecewise (e e' : trivialization F proj) (s : set B)
(Hs : e.base_set ∩ frontier s = e'.base_set ∩ frontier s)
(Heq : eq_on e e' $ proj ⁻¹' (e.base_set ∩ frontier s)) :
trivialization F proj :=
{ to_local_homeomorph := e.to_local_homeomorph.piecewise e'.to_local_homeomorph
(proj ⁻¹' s) (s ×ˢ univ) (e.is_image_preimage_prod s) (e'.is_image_preimage_prod s)
(by rw [e.frontier_preimage, e'.frontier_preimage, Hs])
(by rwa e.frontier_preimage),
base_set := s.ite e.base_set e'.base_set,
open_base_set := e.open_base_set.ite e'.open_base_set Hs,
source_eq := by simp [e.source_eq, e'.source_eq],
target_eq := by simp [e.target_eq, e'.target_eq, prod_univ],
proj_to_fun := by rintro p (⟨he, hs⟩|⟨he, hs⟩); simp * }
/-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z → B`
over a linearly ordered base `B` and a point `a ∈ e.base_set ∩ e'.base_set` such that
`e` equals `e'` on `proj ⁻¹' {a}`, `e.piecewise_le_of_eq e' a He He' Heq` is the bundle
trivialization over `set.ite (Iic a) e.base_set e'.base_set` that is equal to `e` on points `p`
such that `proj p ≤ a` and is equal to `e'` otherwise. -/
noncomputable def piecewise_le_of_eq [linear_order B] [order_topology B]
(e e' : trivialization F proj) (a : B) (He : a ∈ e.base_set) (He' : a ∈ e'.base_set)
(Heq : ∀ p, proj p = a → e p = e' p) :
trivialization F proj :=
e.piecewise e' (Iic a)
(set.ext $ λ x, and.congr_left_iff.2 $ λ hx,
by simp [He, He', mem_singleton_iff.1 (frontier_Iic_subset _ hx)])
(λ p hp, Heq p $ frontier_Iic_subset _ hp.2)
/-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z → B` over a
linearly ordered base `B` and a point `a ∈ e.base_set ∩ e'.base_set`, `e.piecewise_le e' a He He'`
is the bundle trivialization over `set.ite (Iic a) e.base_set e'.base_set` that is equal to `e` on
points `p` such that `proj p ≤ a` and is equal to `((e' p).1, h (e' p).2)` otherwise, where
`h = `e'.coord_change_homeomorph e _ _` is the homeomorphism of the fiber such that
`h (e' p).2 = (e p).2` whenever `e p = a`. -/
noncomputable def piecewise_le [linear_order B] [order_topology B]
(e e' : trivialization F proj) (a : B) (He : a ∈ e.base_set) (He' : a ∈ e'.base_set) :
trivialization F proj :=
e.piecewise_le_of_eq (e'.trans_fiber_homeomorph (e'.coord_change_homeomorph e He' He))
a He He' $ by { unfreezingI {rintro p rfl },
ext1,
{ simp [e.coe_fst', e'.coe_fst', *] },
{ simp [e'.coord_change_apply_snd, *] } }
/-- Given two bundle trivializations `e`, `e'` over disjoint sets, `e.disjoint_union e' H` is the
bundle trivialization over the union of the base sets that agrees with `e` and `e'` over their
base sets. -/
noncomputable def disjoint_union (e e' : trivialization F proj)
(H : disjoint e.base_set e'.base_set) :
trivialization F proj :=
{ to_local_homeomorph := e.to_local_homeomorph.disjoint_union e'.to_local_homeomorph
(by { rw [e.source_eq, e'.source_eq], exact H.preimage _, })
(by { rw [e.target_eq, e'.target_eq, disjoint_iff_inf_le],
intros x hx, exact H.le_bot ⟨hx.1.1, hx.2.1⟩ }),
base_set := e.base_set ∪ e'.base_set,
open_base_set := is_open.union e.open_base_set e'.open_base_set,
source_eq := congr_arg2 (∪) e.source_eq e'.source_eq,
target_eq := (congr_arg2 (∪) e.target_eq e'.target_eq).trans union_prod.symm,
proj_to_fun :=
begin
rintro p (hp|hp'),
{ show (e.source.piecewise e e' p).1 = proj p,
rw [piecewise_eq_of_mem, e.coe_fst]; exact hp },
{ show (e.source.piecewise e e' p).1 = proj p,
rw [piecewise_eq_of_not_mem, e'.coe_fst hp'],
simp only [e.source_eq, e'.source_eq] at hp' ⊢,
exact λ h, H.le_bot ⟨h, hp'⟩ }
end }
end piecewise
end trivialization
|
f99e59863b0b4d1f873ade349869c21026a5fdd6 | 3dd1b66af77106badae6edb1c4dea91a146ead30 | /tests/lean/t9.lean | c43d1d457315bc44a9412d807c8d01f136fb8e75 | [
"Apache-2.0"
] | permissive | silky/lean | 79c20c15c93feef47bb659a2cc139b26f3614642 | df8b88dca2f8da1a422cb618cd476ef5be730546 | refs/heads/master | 1,610,737,587,697 | 1,406,574,534,000 | 1,406,574,534,000 | 22,362,176 | 1 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 380 | lean | precedence `+` : 65
precedence `*` : 75
precedence `=` : 50
precedence `≃` : 50
variable N : Type.{1}
variable a : N
variable b : N
variable add : N → N → N
variable mul : N → N → N
namespace foo
infixl + := add
infixl * := mul
check a+b*a
end
-- Notation is not avaiable outside the namespace
check a+b*a
namespace foo
-- Notation is restored
check a+b*a
end
|
8f6f6df05825e52ba531a3b5872354a32cd5e73f | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/lean/csimpAttrAppend.lean | 4c6754757943519f96063c22636dfa83b1f07f68 | [
"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 | 98 | lean | set_option trace.compiler.ir.init true
def f (as bs cs : List Nat) : List Nat :=
as ++ bs ++ cs
|
34c38c8a1f2c4699ba19ea9992c065cb18440acb | 26ac254ecb57ffcb886ff709cf018390161a9225 | /src/set_theory/ordinal.lean | 1bdf007746952444cd08a85628b14d1477c3ee60 | [
"Apache-2.0"
] | permissive | eric-wieser/mathlib | 42842584f584359bbe1fc8b88b3ff937c8acd72d | d0df6b81cd0920ad569158c06a3fd5abb9e63301 | refs/heads/master | 1,669,546,404,255 | 1,595,254,668,000 | 1,595,254,668,000 | 281,173,504 | 0 | 0 | Apache-2.0 | 1,595,263,582,000 | 1,595,263,581,000 | null | UTF-8 | Lean | false | false | 147,440 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
-/
import set_theory.cardinal
import tactic.omega
/-!
# Ordinal arithmetic
Ordinals are defined as equivalences of well-ordered sets by order isomorphism.
-/
noncomputable theory
open function cardinal set equiv
open_locale classical cardinal
universes u v w
variables {α : Type*} {β : Type*} {γ : Type*}
{r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
/-- If `r` is a relation on `α` and `s` in a relation on `β`, then `f : r ≼i s` is an order
embedding whose range is an initial segment. That is, whenever `b < f a` in `β` then `b` is in the
range of `f`. -/
structure initial_seg {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) extends r ≼o s :=
(init : ∀ a b, s b (to_order_embedding a) → ∃ a', to_order_embedding a' = b)
local infix ` ≼i `:25 := initial_seg
namespace initial_seg
instance : has_coe (r ≼i s) (r ≼o s) := ⟨initial_seg.to_order_embedding⟩
instance : has_coe_to_fun (r ≼i s) := ⟨λ _, α → β, λ f x, (f : r ≼o s) x⟩
@[simp] theorem coe_fn_mk (f : r ≼o s) (o) :
(@initial_seg.mk _ _ r s f o : α → β) = f := rfl
@[simp] theorem coe_fn_to_order_embedding (f : r ≼i s) : (f.to_order_embedding : α → β) = f := rfl
@[simp] theorem coe_coe_fn (f : r ≼i s) : ((f : r ≼o s) : α → β) = f := rfl
theorem init' (f : r ≼i s) {a : α} {b : β} : s b (f a) → ∃ a', f a' = b :=
f.init _ _
theorem init_iff (f : r ≼i s) {a : α} {b : β} : s b (f a) ↔ ∃ a', f a' = b ∧ r a' a :=
⟨λ h, let ⟨a', e⟩ := f.init' h in ⟨a', e, (f : r ≼o s).ord.2 (e.symm ▸ h)⟩,
λ ⟨a', e, h⟩, e ▸ (f : r ≼o s).ord.1 h⟩
/-- An order isomorphism is an initial segment -/
def of_iso (f : r ≃o s) : r ≼i s :=
⟨f, λ a b h, ⟨f.symm b, order_iso.apply_symm_apply f _⟩⟩
/-- The identity function shows that `≼i` is reflexive -/
@[refl] protected def refl (r : α → α → Prop) : r ≼i r :=
⟨order_embedding.refl _, λ a b h, ⟨_, rfl⟩⟩
/-- Composition of functions shows that `≼i` is transitive -/
@[trans] protected def trans (f : r ≼i s) (g : s ≼i t) : r ≼i t :=
⟨f.1.trans g.1, λ a c h, begin
simp at h ⊢,
rcases g.2 _ _ h with ⟨b, rfl⟩, have h := g.1.ord.2 h,
rcases f.2 _ _ h with ⟨a', rfl⟩, exact ⟨a', rfl⟩
end⟩
@[simp] theorem refl_apply (x : α) : initial_seg.refl r x = x := rfl
@[simp] theorem trans_apply (f : r ≼i s) (g : s ≼i t) (a : α) : (f.trans g) a = g (f a) := rfl
theorem unique_of_extensional [is_extensional β s] :
well_founded r → subsingleton (r ≼i s) | ⟨h⟩ :=
⟨λ f g, begin
suffices : (f : α → β) = g, { cases f, cases g,
congr, exact order_embedding.coe_fn_inj this },
funext a, have := h a, induction this with a H IH,
refine @is_extensional.ext _ s _ _ _ (λ x, ⟨λ h, _, λ h, _⟩),
{ rcases f.init_iff.1 h with ⟨y, rfl, h'⟩,
rw IH _ h', exact (g : r ≼o s).ord.1 h' },
{ rcases g.init_iff.1 h with ⟨y, rfl, h'⟩,
rw ← IH _ h', exact (f : r ≼o s).ord.1 h' }
end⟩
instance [is_well_order β s] : subsingleton (r ≼i s) :=
⟨λ a, @subsingleton.elim _ (unique_of_extensional
(@order_embedding.well_founded _ _ r s a is_well_order.wf)) a⟩
protected theorem eq [is_well_order β s] (f g : r ≼i s) (a) : f a = g a :=
by rw subsingleton.elim f g
theorem antisymm.aux [is_well_order α r] (f : r ≼i s) (g : s ≼i r) : left_inverse g f :=
initial_seg.eq (f.trans g) (initial_seg.refl _)
/-- If we have order embeddings between `α` and `β` whose images are initial segments, and `β`
is a well-order then `α` and `β` are order-isomorphic. -/
def antisymm [is_well_order β s] (f : r ≼i s) (g : s ≼i r) : r ≃o s :=
by haveI := f.to_order_embedding.is_well_order; exact
⟨⟨f, g, antisymm.aux f g, antisymm.aux g f⟩, f.ord'⟩
@[simp] theorem antisymm_to_fun [is_well_order β s]
(f : r ≼i s) (g : s ≼i r) : (antisymm f g : α → β) = f := rfl
@[simp] theorem antisymm_symm [is_well_order α r] [is_well_order β s]
(f : r ≼i s) (g : s ≼i r) : (antisymm f g).symm = antisymm g f :=
order_iso.coe_fn_injective rfl
theorem eq_or_principal [is_well_order β s] (f : r ≼i s) :
surjective f ∨ ∃ b, ∀ x, s x b ↔ ∃ y, f y = x :=
or_iff_not_imp_right.2 $ λ h b,
acc.rec_on (is_well_order.wf.apply b : acc s b) $ λ x H IH,
not_forall_not.1 $ λ hn,
h ⟨x, λ y, ⟨(IH _), λ ⟨a, e⟩, by rw ← e; exact
(trichotomous _ _).resolve_right
(not_or (hn a) (λ hl, not_exists.2 hn (f.init' hl)))⟩⟩
/-- Restrict the codomain of an initial segment -/
def cod_restrict (p : set β) (f : r ≼i s) (H : ∀ a, f a ∈ p) : r ≼i subrel s p :=
⟨order_embedding.cod_restrict p f H, λ a ⟨b, m⟩ (h : s b (f a)),
let ⟨a', e⟩ := f.init' h in ⟨a', by clear _let_match; subst e; refl⟩⟩
@[simp] theorem cod_restrict_apply (p) (f : r ≼i s) (H a) : cod_restrict p f H a = ⟨f a, H a⟩ := rfl
def le_add (r : α → α → Prop) (s : β → β → Prop) : r ≼i sum.lex r s :=
⟨⟨⟨sum.inl, λ _ _, sum.inl.inj⟩, λ a b, sum.lex_inl_inl.symm⟩,
λ a b, by cases b; [exact λ _, ⟨_, rfl⟩, exact false.elim ∘ sum.lex_inr_inl]⟩
@[simp] theorem le_add_apply (r : α → α → Prop) (s : β → β → Prop)
(a) : le_add r s a = sum.inl a := rfl
end initial_seg
structure principal_seg {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) extends r ≼o s :=
(top : β)
(down : ∀ b, s b top ↔ ∃ a, to_order_embedding a = b)
local infix ` ≺i `:25 := principal_seg
namespace principal_seg
instance : has_coe (r ≺i s) (r ≼o s) := ⟨principal_seg.to_order_embedding⟩
instance : has_coe_to_fun (r ≺i s) := ⟨λ _, α → β, λ f, f⟩
@[simp] theorem coe_fn_mk (f : r ≼o s) (t o) :
(@principal_seg.mk _ _ r s f t o : α → β) = f := rfl
@[simp] theorem coe_fn_to_order_embedding (f : r ≺i s) : (f.to_order_embedding : α → β) = f := rfl
@[simp] theorem coe_coe_fn (f : r ≺i s) : ((f : r ≼o s) : α → β) = f := rfl
theorem down' (f : r ≺i s) {b : β} : s b f.top ↔ ∃ a, f a = b :=
f.down _
theorem lt_top (f : r ≺i s) (a : α) : s (f a) f.top :=
f.down'.2 ⟨_, rfl⟩
theorem init [is_trans β s] (f : r ≺i s) {a : α} {b : β} (h : s b (f a)) : ∃ a', f a' = b :=
f.down'.1 $ trans h $ f.lt_top _
instance has_coe_initial_seg [is_trans β s] : has_coe (r ≺i s) (r ≼i s) :=
⟨λ f, ⟨f.to_order_embedding, λ a b, f.init⟩⟩
theorem coe_coe_fn' [is_trans β s] (f : r ≺i s) : ((f : r ≼i s) : α → β) = f := rfl
theorem init_iff [is_trans β s] (f : r ≺i s) {a : α} {b : β} :
s b (f a) ↔ ∃ a', f a' = b ∧ r a' a :=
@initial_seg.init_iff α β r s f a b
theorem irrefl (r : α → α → Prop) [is_well_order α r] (f : r ≺i r) : false :=
begin
have := f.lt_top f.top,
rw [show f f.top = f.top, from
initial_seg.eq ↑f (initial_seg.refl r) f.top] at this,
exact irrefl _ this
end
def lt_le (f : r ≺i s) (g : s ≼i t) : r ≺i t :=
⟨@order_embedding.trans _ _ _ r s t f g, g f.top, λ a,
by simp only [g.init_iff, f.down', exists_and_distrib_left.symm,
exists_swap, order_embedding.trans_apply, exists_eq_right']; refl⟩
@[simp] theorem lt_le_apply (f : r ≺i s) (g : s ≼i t) (a : α) : (f.lt_le g) a = g (f a) :=
order_embedding.trans_apply _ _ _
@[simp] theorem lt_le_top (f : r ≺i s) (g : s ≼i t) : (f.lt_le g).top = g f.top := rfl
@[trans] protected def trans [is_trans γ t] (f : r ≺i s) (g : s ≺i t) : r ≺i t :=
lt_le f g
@[simp] theorem trans_apply [is_trans γ t] (f : r ≺i s) (g : s ≺i t) (a : α) :
(f.trans g) a = g (f a) :=
lt_le_apply _ _ _
@[simp] theorem trans_top [is_trans γ t] (f : r ≺i s) (g : s ≺i t) :
(f.trans g).top = g f.top := rfl
def equiv_lt (f : r ≃o s) (g : s ≺i t) : r ≺i t :=
⟨@order_embedding.trans _ _ _ r s t f g, g.top, λ c,
suffices (∃ (a : β), g a = c) ↔ ∃ (a : α), g (f a) = c, by simpa [g.down],
⟨λ ⟨b, h⟩, ⟨f.symm b, by simp only [h, order_iso.apply_symm_apply, order_iso.coe_coe_fn]⟩,
λ ⟨a, h⟩, ⟨f a, h⟩⟩⟩
def lt_equiv {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
(f : principal_seg r s) (g : s ≃o t) : principal_seg r t :=
⟨@order_embedding.trans _ _ _ r s t f g, g f.top,
begin
intro x,
rw [← g.apply_symm_apply x, ← g.ord, f.down', exists_congr],
intro y, exact ⟨congr_arg g, λ h, g.to_equiv.bijective.1 h⟩
end⟩
@[simp] theorem equiv_lt_apply (f : r ≃o s) (g : s ≺i t) (a : α) : (equiv_lt f g) a = g (f a) :=
order_embedding.trans_apply _ _ _
@[simp] theorem equiv_lt_top (f : r ≃o s) (g : s ≺i t) : (equiv_lt f g).top = g.top := rfl
instance [is_well_order β s] : subsingleton (r ≺i s) :=
⟨λ f g, begin
have ef : (f : α → β) = g,
{ show ((f : r ≼i s) : α → β) = g,
rw @subsingleton.elim _ _ (f : r ≼i s) g, refl },
have et : f.top = g.top,
{ refine @is_extensional.ext _ s _ _ _ (λ x, _),
simp only [f.down, g.down, ef, coe_fn_to_order_embedding] },
cases f, cases g,
have := order_embedding.coe_fn_inj ef; congr'
end⟩
theorem top_eq [is_well_order γ t]
(e : r ≃o s) (f : r ≺i t) (g : s ≺i t) : f.top = g.top :=
by rw subsingleton.elim f (principal_seg.equiv_lt e g); refl
lemma top_lt_top {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
[is_well_order γ t]
(f : principal_seg r s) (g : principal_seg s t) (h : principal_seg r t) : t h.top g.top :=
by { rw [subsingleton.elim h (f.trans g)], apply principal_seg.lt_top }
/-- Any element of a well order yields a principal segment -/
def of_element {α : Type*} (r : α → α → Prop) (a : α) : subrel r {b | r b a} ≺i r :=
⟨subrel.order_embedding _ _, a, λ b,
⟨λ h, ⟨⟨_, h⟩, rfl⟩, λ ⟨⟨_, h⟩, rfl⟩, h⟩⟩
@[simp] theorem of_element_apply {α : Type*} (r : α → α → Prop) (a : α) (b) :
of_element r a b = b.1 := rfl
@[simp] theorem of_element_top {α : Type*} (r : α → α → Prop) (a : α) :
(of_element r a).top = a := rfl
/-- Restrict the codomain of a principal segment -/
def cod_restrict (p : set β) (f : r ≺i s)
(H : ∀ a, f a ∈ p) (H₂ : f.top ∈ p) : r ≺i subrel s p :=
⟨order_embedding.cod_restrict p f H, ⟨f.top, H₂⟩, λ ⟨b, h⟩,
f.down'.trans $ exists_congr $ λ a,
show (⟨f a, H a⟩ : p).1 = _ ↔ _, from ⟨subtype.eq, congr_arg _⟩⟩
@[simp]
theorem cod_restrict_apply (p) (f : r ≺i s) (H H₂ a) : cod_restrict p f H H₂ a = ⟨f a, H a⟩ := rfl
@[simp]
theorem cod_restrict_top (p) (f : r ≺i s) (H H₂) : (cod_restrict p f H H₂).top = ⟨f.top, H₂⟩ := rfl
end principal_seg
def initial_seg.lt_or_eq [is_well_order β s] (f : r ≼i s) :
(r ≺i s) ⊕ (r ≃o s) :=
if h : surjective f then sum.inr (order_iso.of_surjective f h) else
have h' : _, from (initial_seg.eq_or_principal f).resolve_left h,
sum.inl ⟨f, classical.some h', classical.some_spec h'⟩
theorem initial_seg.lt_or_eq_apply_left [is_well_order β s]
(f : r ≼i s) (g : r ≺i s) (a : α) : g a = f a :=
@initial_seg.eq α β r s _ g f a
theorem initial_seg.lt_or_eq_apply_right [is_well_order β s]
(f : r ≼i s) (g : r ≃o s) (a : α) : g a = f a :=
initial_seg.eq (initial_seg.of_iso g) f a
def initial_seg.le_lt [is_well_order β s] [is_trans γ t] (f : r ≼i s) (g : s ≺i t) : r ≺i t :=
match f.lt_or_eq with
| sum.inl f' := f'.trans g
| sum.inr f' := principal_seg.equiv_lt f' g
end
@[simp] theorem initial_seg.le_lt_apply [is_well_order β s] [is_trans γ t]
(f : r ≼i s) (g : s ≺i t) (a : α) : (f.le_lt g) a = g (f a) :=
begin
delta initial_seg.le_lt, cases h : f.lt_or_eq with f' f',
{ simp only [principal_seg.trans_apply, f.lt_or_eq_apply_left] },
{ simp only [principal_seg.equiv_lt_apply, f.lt_or_eq_apply_right] }
end
namespace order_embedding
def collapse_F [is_well_order β s] (f : r ≼o s) : Π a, {b // ¬ s (f a) b} :=
(order_embedding.well_founded f $ is_well_order.wf).fix $ λ a IH, begin
let S := {b | ∀ a h, s (IH a h).1 b},
have : f a ∈ S, from λ a' h, ((trichotomous _ _)
.resolve_left $ λ h', (IH a' h).2 $ trans (f.ord.1 h) h')
.resolve_left $ λ h', (IH a' h).2 $ h' ▸ f.ord.1 h,
exact ⟨is_well_order.wf.min S ⟨_, this⟩,
is_well_order.wf.not_lt_min _ _ this⟩
end
theorem collapse_F.lt [is_well_order β s] (f : r ≼o s) {a : α}
: ∀ {a'}, r a' a → s (collapse_F f a').1 (collapse_F f a).1 :=
show (collapse_F f a).1 ∈ {b | ∀ a' (h : r a' a), s (collapse_F f a').1 b}, begin
unfold collapse_F, rw well_founded.fix_eq,
apply well_founded.min_mem _ _
end
theorem collapse_F.not_lt [is_well_order β s] (f : r ≼o s) (a : α)
{b} (h : ∀ a' (h : r a' a), s (collapse_F f a').1 b) : ¬ s b (collapse_F f a).1 :=
begin
unfold collapse_F, rw well_founded.fix_eq,
exact well_founded.not_lt_min _ _ _
(show b ∈ {b | ∀ a' (h : r a' a), s (collapse_F f a').1 b}, from h)
end
/-- Construct an initial segment from an order embedding. -/
def collapse [is_well_order β s] (f : r ≼o s) : r ≼i s :=
by haveI := order_embedding.is_well_order f; exact
⟨order_embedding.of_monotone
(λ a, (collapse_F f a).1) (λ a b, collapse_F.lt f),
λ a b, acc.rec_on (is_well_order.wf.apply b : acc s b) (λ b H IH a h, begin
let S := {a | ¬ s (collapse_F f a).1 b},
have : S.nonempty := ⟨_, asymm h⟩,
existsi (is_well_order.wf : well_founded r).min S this,
refine ((@trichotomous _ s _ _ _).resolve_left _).resolve_right _,
{ exact (is_well_order.wf : well_founded r).min_mem S this },
{ refine collapse_F.not_lt f _ (λ a' h', _),
by_contradiction hn,
exact is_well_order.wf.not_lt_min S this hn h' }
end) a⟩
theorem collapse_apply [is_well_order β s] (f : r ≼o s)
(a) : collapse f a = (collapse_F f a).1 := rfl
end order_embedding
section well_ordering_thm
parameter {σ : Type u}
open function
theorem nonempty_embedding_to_cardinal : nonempty (σ ↪ cardinal.{u}) :=
embedding.total.resolve_left $ λ ⟨⟨f, hf⟩⟩,
let g : σ → cardinal.{u} := inv_fun f in
let ⟨x, (hx : g x = 2 ^ sum g)⟩ := inv_fun_surjective hf (2 ^ sum g) in
have g x ≤ sum g, from le_sum.{u u} g x,
not_le_of_gt (by rw hx; exact cantor _) this
/-- An embedding of any type to the set of cardinals. -/
def embedding_to_cardinal : σ ↪ cardinal.{u} := classical.choice nonempty_embedding_to_cardinal
/-- The relation whose existence is given by the well-ordering theorem -/
def well_ordering_rel : σ → σ → Prop := embedding_to_cardinal ⁻¹'o (<)
instance well_ordering_rel.is_well_order : is_well_order σ well_ordering_rel :=
(order_embedding.preimage _ _).is_well_order
end well_ordering_thm
structure Well_order : Type (u+1) :=
(α : Type u)
(r : α → α → Prop)
(wo : is_well_order α r)
attribute [instance] Well_order.wo
namespace Well_order
instance : inhabited Well_order := ⟨⟨pempty, _, empty_relation.is_well_order⟩⟩
end Well_order
instance ordinal.is_equivalent : setoid Well_order :=
{ r := λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≃o s),
iseqv := ⟨λ⟨α, r, _⟩, ⟨order_iso.refl _⟩,
λ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨e⟩, ⟨e.symm⟩,
λ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨e₁⟩ ⟨e₂⟩, ⟨e₁.trans e₂⟩⟩ }
/-- `ordinal.{u}` is the type of well orders in `Type u`,
quotient by order isomorphism. -/
def ordinal : Type (u + 1) := quotient ordinal.is_equivalent
namespace ordinal
/-- The order type of a well order is an ordinal. -/
def type (r : α → α → Prop) [wo : is_well_order α r] : ordinal :=
⟦⟨α, r, wo⟩⟧
/-- The order type of an element inside a well order. -/
def typein (r : α → α → Prop) [is_well_order α r] (a : α) : ordinal :=
type (subrel r {b | r b a})
theorem type_def (r : α → α → Prop) [wo : is_well_order α r] :
@eq ordinal ⟦⟨α, r, wo⟩⟧ (type r) := rfl
@[simp] theorem type_def' (r : α → α → Prop) [is_well_order α r] {wo} :
@eq ordinal ⟦⟨α, r, wo⟩⟧ (type r) := rfl
theorem type_eq {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r = type s ↔ nonempty (r ≃o s) := quotient.eq
@[simp] lemma type_out (o : ordinal) : type o.out.r = o :=
by { refine eq.trans _ (by rw [←quotient.out_eq o]), cases quotient.out o, refl }
@[elab_as_eliminator] theorem induction_on {C : ordinal → Prop}
(o : ordinal) (H : ∀ α r [is_well_order α r], C (type r)) : C o :=
quot.induction_on o $ λ ⟨α, r, wo⟩, @H α r wo
/-- Ordinal less-equal is defined such that
well orders `r` and `s` satisfy `type r ≤ type s` if there exists
a function embedding `r` as an initial segment of `s`. -/
protected def le (a b : ordinal) : Prop :=
quotient.lift_on₂ a b (λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≼i s)) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
propext ⟨
λ ⟨h⟩, ⟨(initial_seg.of_iso f.symm).trans $
h.trans (initial_seg.of_iso g)⟩,
λ ⟨h⟩, ⟨(initial_seg.of_iso f).trans $
h.trans (initial_seg.of_iso g.symm)⟩⟩
instance : has_le ordinal := ⟨ordinal.le⟩
theorem type_le {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r ≤ type s ↔ nonempty (r ≼i s) := iff.rfl
theorem type_le' {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] : type r ≤ type s ↔ nonempty (r ≼o s) :=
⟨λ ⟨f⟩, ⟨f⟩, λ ⟨f⟩, ⟨f.collapse⟩⟩
/-- Ordinal less-than is defined such that
well orders `r` and `s` satisfy `type r < type s` if there exists
a function embedding `r` as a principal segment of `s`. -/
def lt (a b : ordinal) : Prop :=
quotient.lift_on₂ a b (λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≺i s)) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
by exactI propext ⟨
λ ⟨h⟩, ⟨principal_seg.equiv_lt f.symm $
h.lt_le (initial_seg.of_iso g)⟩,
λ ⟨h⟩, ⟨principal_seg.equiv_lt f $
h.lt_le (initial_seg.of_iso g.symm)⟩⟩
instance : has_lt ordinal := ⟨ordinal.lt⟩
@[simp] theorem type_lt {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r < type s ↔ nonempty (r ≺i s) := iff.rfl
instance : partial_order ordinal :=
{ le := (≤),
lt := (<),
le_refl := quot.ind $ by exact λ ⟨α, r, wo⟩, ⟨initial_seg.refl _⟩,
le_trans := λ a b c, quotient.induction_on₃ a b c $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ ⟨g⟩, ⟨f.trans g⟩,
lt_iff_le_not_le := λ a b, quotient.induction_on₂ a b $
λ ⟨α, r, _⟩ ⟨β, s, _⟩, by exactI
⟨λ ⟨f⟩, ⟨⟨f⟩, λ ⟨g⟩, (f.lt_le g).irrefl _⟩,
λ ⟨⟨f⟩, h⟩, sum.rec_on f.lt_or_eq (λ g, ⟨g⟩)
(λ g, (h ⟨initial_seg.of_iso g.symm⟩).elim)⟩,
le_antisymm := λ x b, show x ≤ b → b ≤ x → x = b, from
quotient.induction_on₂ x b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨h₁⟩ ⟨h₂⟩,
by exactI quot.sound ⟨initial_seg.antisymm h₁ h₂⟩ }
def initial_seg_out {α β : ordinal} (h : α ≤ β) : initial_seg α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice
end
def principal_seg_out {α β : ordinal} (h : α < β) : principal_seg α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice
end
def order_iso_out {α β : ordinal} (h : α = β) : order_iso α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice ∘ quotient.exact
end
theorem typein_lt_type (r : α → α → Prop) [is_well_order α r]
(a : α) : typein r a < type r :=
⟨principal_seg.of_element _ _⟩
@[simp] theorem typein_top {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : r ≺i s) :
typein s f.top = type r :=
eq.symm $ quot.sound ⟨order_iso.of_surjective
(order_embedding.cod_restrict _ f f.lt_top)
(λ ⟨a, h⟩, by rcases f.down'.1 h with ⟨b, rfl⟩; exact ⟨b, rfl⟩)⟩
@[simp] theorem typein_apply {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : r ≼i s) (a : α) :
ordinal.typein s (f a) = ordinal.typein r a :=
eq.symm $ quotient.sound ⟨order_iso.of_surjective
(order_embedding.cod_restrict _
((subrel.order_embedding _ _).trans f)
(λ ⟨x, h⟩, by rw [order_embedding.trans_apply]; exact f.to_order_embedding.ord.1 h))
(λ ⟨y, h⟩, by rcases f.init' h with ⟨a, rfl⟩;
exact ⟨⟨a, f.to_order_embedding.ord.2 h⟩, subtype.eq $ order_embedding.trans_apply _ _ _⟩)⟩
@[simp] theorem typein_lt_typein (r : α → α → Prop) [is_well_order α r]
{a b : α} : typein r a < typein r b ↔ r a b :=
⟨λ ⟨f⟩, begin
have : f.top.1 = a,
{ let f' := principal_seg.of_element r a,
let g' := f.trans (principal_seg.of_element r b),
have : g'.top = f'.top, {rw subsingleton.elim f' g'},
exact this },
rw ← this, exact f.top.2
end, λ h, ⟨principal_seg.cod_restrict _
(principal_seg.of_element r a)
(λ x, @trans _ r _ _ _ _ x.2 h) h⟩⟩
theorem typein_surj (r : α → α → Prop) [is_well_order α r]
{o} (h : o < type r) : ∃ a, typein r a = o :=
induction_on o (λ β s _ ⟨f⟩, by exactI ⟨f.top, typein_top _⟩) h
lemma typein_injective (r : α → α → Prop) [is_well_order α r] : injective (typein r) :=
injective_of_increasing r (<) (typein r) (λ x y, (typein_lt_typein r).2)
theorem typein_inj (r : α → α → Prop) [is_well_order α r]
{a b} : typein r a = typein r b ↔ a = b :=
injective.eq_iff (typein_injective r)
/-- `enum r o h` is the `o`-th element of `α` ordered by `r`.
That is, `enum` maps an initial segment of the ordinals, those
less than the order type of `r`, to the elements of `α`. -/
def enum (r : α → α → Prop) [is_well_order α r] (o) : o < type r → α :=
quot.rec_on o (λ ⟨β, s, _⟩ h, (classical.choice h).top) $
λ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨h⟩, begin
resetI, refine funext (λ (H₂ : type t < type r), _),
have H₁ : type s < type r, {rwa type_eq.2 ⟨h⟩},
have : ∀ {o e} (H : o < type r), @@eq.rec
(λ (o : ordinal), o < type r → α)
(λ (h : type s < type r), (classical.choice h).top)
e H = (classical.choice H₁).top, {intros, subst e},
exact (this H₂).trans (principal_seg.top_eq h
(classical.choice H₁) (classical.choice H₂))
end
theorem enum_type {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : s ≺i r)
{h : type s < type r} : enum r (type s) h = f.top :=
principal_seg.top_eq (order_iso.refl _) _ _
@[simp] theorem enum_typein (r : α → α → Prop) [is_well_order α r] (a : α)
{h : typein r a < type r} : enum r (typein r a) h = a :=
enum_type (principal_seg.of_element r a)
@[simp] theorem typein_enum (r : α → α → Prop) [is_well_order α r]
{o} (h : o < type r) : typein r (enum r o h) = o :=
let ⟨a, e⟩ := typein_surj r h in
by clear _let_match; subst e; rw enum_typein
def typein_iso (r : α → α → Prop) [is_well_order α r] : r ≃o subrel (<) (< type r) :=
⟨⟨λ x, ⟨typein r x, typein_lt_type r x⟩, λ x, enum r x.1 x.2, λ y, enum_typein r y,
λ ⟨y, hy⟩, subtype.eq (typein_enum r hy)⟩,
λ a b, (typein_lt_typein r).symm⟩
theorem enum_lt {r : α → α → Prop} [is_well_order α r]
{o₁ o₂ : ordinal} (h₁ : o₁ < type r) (h₂ : o₂ < type r) :
r (enum r o₁ h₁) (enum r o₂ h₂) ↔ o₁ < o₂ :=
by rw [← typein_lt_typein r, typein_enum, typein_enum]
lemma order_iso_enum' {α β : Type u} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s]
(f : order_iso r s) (o : ordinal) : ∀(hr : o < type r) (hs : o < type s),
f (enum r o hr) = enum s o hs :=
begin
refine induction_on o _, rintros γ t wo ⟨g⟩ ⟨h⟩,
resetI, rw [enum_type g, enum_type (principal_seg.lt_equiv g f)], refl
end
lemma order_iso_enum {α β : Type u} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s]
(f : order_iso r s) (o : ordinal) (hr : o < type r) :
f (enum r o hr) =
enum s o (by {convert hr using 1, apply quotient.sound, exact ⟨f.symm⟩ }) :=
order_iso_enum' _ _ _ _
theorem wf : @well_founded ordinal (<) :=
⟨λ a, induction_on a $ λ α r wo, by exactI
suffices ∀ a, acc (<) (typein r a), from
⟨_, λ o h, let ⟨a, e⟩ := typein_surj r h in e ▸ this a⟩,
λ a, acc.rec_on (wo.wf.apply a) $ λ x H IH, ⟨_, λ o h, begin
rcases typein_surj r (lt_trans h (typein_lt_type r _)) with ⟨b, rfl⟩,
exact IH _ ((typein_lt_typein r).1 h)
end⟩⟩
instance : has_well_founded ordinal := ⟨(<), wf⟩
/-- The cardinal of an ordinal is the cardinal of any
set with that order type. -/
def card (o : ordinal) : cardinal :=
quot.lift_on o (λ ⟨α, r, _⟩, mk α) $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨e⟩, quotient.sound ⟨e.to_equiv⟩
@[simp] theorem card_type (r : α → α → Prop) [is_well_order α r] :
card (type r) = mk α := rfl
lemma card_typein {r : α → α → Prop} [wo : is_well_order α r] (x : α) :
mk {y // r y x} = (typein r x).card := rfl
theorem card_le_card {o₁ o₂ : ordinal} : o₁ ≤ o₂ → card o₁ ≤ card o₂ :=
induction_on o₁ $ λ α r _, induction_on o₂ $ λ β s _ ⟨⟨⟨f, _⟩, _⟩⟩, ⟨f⟩
instance : has_zero ordinal :=
⟨⟦⟨pempty, empty_relation, by apply_instance⟩⟧⟩
instance : inhabited ordinal := ⟨0⟩
theorem zero_eq_type_empty : 0 = @type empty empty_relation _ :=
quotient.sound ⟨⟨empty_equiv_pempty.symm, λ _ _, iff.rfl⟩⟩
@[simp] theorem card_zero : card 0 = 0 := rfl
theorem zero_le (o : ordinal) : 0 ≤ o :=
induction_on o $ λ α r _,
⟨⟨⟨embedding.of_not_nonempty $ λ ⟨a⟩, a.elim,
λ a, a.elim⟩, λ a, a.elim⟩⟩
@[simp] theorem le_zero {o : ordinal} : o ≤ 0 ↔ o = 0 :=
by simp only [le_antisymm_iff, zero_le, and_true]
theorem pos_iff_ne_zero {o : ordinal} : 0 < o ↔ o ≠ 0 :=
by simp only [lt_iff_le_and_ne, zero_le, true_and, ne.def, eq_comm]
instance : has_one ordinal :=
⟨⟦⟨punit, empty_relation, by apply_instance⟩⟧⟩
theorem one_eq_type_unit : 1 = @type unit empty_relation _ :=
quotient.sound ⟨⟨punit_equiv_punit, λ _ _, iff.rfl⟩⟩
@[simp] theorem card_one : card 1 = 1 := rfl
instance : has_add ordinal.{u} :=
⟨λo₁ o₂, quotient.lift_on₂ o₁ o₂
(λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, ⟦⟨α ⊕ β, sum.lex r s, by exactI sum.lex.is_well_order⟩⟧
: Well_order → Well_order → ordinal) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
quot.sound ⟨order_iso.sum_lex_congr f g⟩⟩
@[simp] theorem type_add {α β : Type u} (r : α → α → Prop) (s : β → β → Prop)
[is_well_order α r] [is_well_order β s] : type r + type s = type (sum.lex r s) := rfl
/-- The ordinal successor is the smallest ordinal larger than `o`.
It is defined as `o + 1`. -/
def succ (o : ordinal) : ordinal := o + 1
theorem succ_eq_add_one (o) : succ o = o + 1 := rfl
theorem lt_succ_self (o : ordinal.{u}) : o < succ o :=
induction_on o $ λ α r _, ⟨⟨⟨⟨λ x, sum.inl x, λ _ _, sum.inl.inj⟩,
λ _ _, sum.lex_inl_inl.symm⟩,
sum.inr punit.star, λ b, sum.rec_on b
(λ x, ⟨λ _, ⟨x, rfl⟩, λ _, sum.lex.sep _ _⟩)
(λ x, sum.lex_inr_inr.trans ⟨false.elim, λ ⟨x, H⟩, sum.inl_ne_inr H⟩)⟩⟩
theorem succ_pos (o : ordinal) : 0 < succ o :=
lt_of_le_of_lt (zero_le _) (lt_succ_self _)
theorem succ_ne_zero (o : ordinal) : succ o ≠ 0 :=
ne_of_gt $ succ_pos o
theorem succ_le {a b : ordinal} : succ a ≤ b ↔ a < b :=
⟨lt_of_lt_of_le (lt_succ_self _),
induction_on a $ λ α r hr, induction_on b $ λ β s hs ⟨⟨f, t, hf⟩⟩, begin
refine ⟨⟨@order_embedding.of_monotone (α ⊕ punit) β _ _
(@sum.lex.is_well_order _ _ _ _ hr _).1.1
(@is_asymm_of_is_trans_of_is_irrefl _ _ hs.1.2.2 hs.1.2.1)
(sum.rec _ _) (λ a b, _), λ a b, _⟩⟩,
{ exact f }, { exact λ _, t },
{ rcases a with a|_; rcases b with b|_,
{ simpa only [sum.lex_inl_inl] using f.ord.1 },
{ intro _, rw hf, exact ⟨_, rfl⟩ },
{ exact false.elim ∘ sum.lex_inr_inl },
{ exact false.elim ∘ sum.lex_inr_inr.1 } },
{ rcases a with a|_,
{ intro h, have := @principal_seg.init _ _ _ _ hs.1.2.2 ⟨f, t, hf⟩ _ _ h,
cases this with w h, exact ⟨sum.inl w, h⟩ },
{ intro h, cases (hf b).1 h with w h, exact ⟨sum.inl w, h⟩ } }
end⟩
@[simp] theorem card_add (o₁ o₂ : ordinal) : card (o₁ + o₂) = card o₁ + card o₂ :=
induction_on o₁ $ λ α r _, induction_on o₂ $ λ β s _, rfl
@[simp] theorem card_succ (o : ordinal) : card (succ o) = card o + 1 :=
by simp only [succ, card_add, card_one]
@[simp] theorem card_nat (n : ℕ) : card.{u} n = n :=
by induction n; [refl, simp only [card_add, card_one, nat.cast_succ, *]]
theorem nat_cast_succ (n : ℕ) : (succ n : ordinal) = n.succ := rfl
instance : add_monoid ordinal.{u} :=
{ add := (+),
zero := 0,
zero_add := λ o, induction_on o $ λ α r _, eq.symm $ quotient.sound
⟨⟨(pempty_sum α).symm, λ a b, sum.lex_inr_inr.symm⟩⟩,
add_zero := λ o, induction_on o $ λ α r _, eq.symm $ quotient.sound
⟨⟨(sum_pempty α).symm, λ a b, sum.lex_inl_inl.symm⟩⟩,
add_assoc := λ o₁ o₂ o₃, quotient.induction_on₃ o₁ o₂ o₃ $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩, quot.sound
⟨⟨sum_assoc _ _ _, λ a b,
begin rcases a with ⟨a|a⟩|a; rcases b with ⟨b|b⟩|b;
simp only [sum_assoc_apply_in1, sum_assoc_apply_in2, sum_assoc_apply_in3,
sum.lex_inl_inl, sum.lex_inr_inr, sum.lex.sep, sum.lex_inr_inl] end⟩⟩ }
theorem add_succ (o₁ o₂ : ordinal) : o₁ + succ o₂ = succ (o₁ + o₂) :=
(add_assoc _ _ _).symm
@[simp] theorem succ_zero : succ 0 = 1 := zero_add _
theorem one_le_iff_pos {o : ordinal} : 1 ≤ o ↔ 0 < o :=
by rw [← succ_zero, succ_le]
theorem one_le_iff_ne_zero {o : ordinal} : 1 ≤ o ↔ o ≠ 0 :=
by rw [one_le_iff_pos, pos_iff_ne_zero]
theorem add_le_add_left {a b : ordinal} : a ≤ b → ∀ c, c + a ≤ c + b :=
induction_on a $ λ α₁ r₁ _, induction_on b $ λ α₂ r₂ _ ⟨⟨⟨f, fo⟩, fi⟩⟩ c,
induction_on c $ λ β s _,
⟨⟨⟨(embedding.refl _).sum_map f,
λ a b, match a, b with
| sum.inl a, sum.inl b := sum.lex_inl_inl.trans sum.lex_inl_inl.symm
| sum.inl a, sum.inr b := by apply iff_of_true; apply sum.lex.sep
| sum.inr a, sum.inl b := by apply iff_of_false; exact sum.lex_inr_inl
| sum.inr a, sum.inr b := sum.lex_inr_inr.trans $ fo.trans sum.lex_inr_inr.symm
end⟩,
λ a b H, match a, b, H with
| _, sum.inl b, _ := ⟨sum.inl b, rfl⟩
| sum.inl a, sum.inr b, H := (sum.lex_inr_inl H).elim
| sum.inr a, sum.inr b, H := let ⟨w, h⟩ := fi _ _ (sum.lex_inr_inr.1 H) in
⟨sum.inr w, congr_arg sum.inr h⟩
end⟩⟩
theorem le_add_right (a b : ordinal) : a ≤ a + b :=
by simpa only [add_zero] using add_le_add_left (zero_le b) a
theorem add_le_add_iff_left (a) {b c : ordinal} : a + b ≤ a + c ↔ b ≤ c :=
⟨induction_on a $ λ α r hr, induction_on b $ λ β₁ s₁ hs₁, induction_on c $ λ β₂ s₂ hs₂ ⟨f⟩, ⟨
have fl : ∀ a, f (sum.inl a) = sum.inl a := λ a,
by simpa only [initial_seg.trans_apply, initial_seg.le_add_apply]
using @initial_seg.eq _ _ _ _ (@sum.lex.is_well_order _ _ _ _ hr hs₂)
((initial_seg.le_add r s₁).trans f) (initial_seg.le_add r s₂) a,
have ∀ b, {b' // f (sum.inr b) = sum.inr b'}, begin
intro b, cases e : f (sum.inr b),
{ rw ← fl at e, have := f.inj' e, contradiction },
{ exact ⟨_, rfl⟩ }
end,
let g (b) := (this b).1 in
have fr : ∀ b, f (sum.inr b) = sum.inr (g b), from λ b, (this b).2,
⟨⟨⟨g, λ x y h, by injection f.inj'
(by rw [fr, fr, h] : f (sum.inr x) = f (sum.inr y))⟩,
λ a b, by simpa only [sum.lex_inr_inr, fr, order_embedding.coe_fn_to_embedding,
initial_seg.coe_fn_to_order_embedding, function.embedding.coe_fn_mk]
using @order_embedding.ord _ _ _ _ f.to_order_embedding (sum.inr a) (sum.inr b)⟩,
λ a b H, begin
rcases f.init' (by rw fr; exact sum.lex_inr_inr.2 H) with ⟨a'|a', h⟩,
{ rw fl at h, cases h },
{ rw fr at h, exact ⟨a', sum.inr.inj h⟩ }
end⟩⟩,
λ h, add_le_add_left h _⟩
theorem add_left_cancel (a) {b c : ordinal} : a + b = a + c ↔ b = c :=
by simp only [le_antisymm_iff, add_le_add_iff_left]
/-- The universe lift operation for ordinals, which embeds `ordinal.{u}` as
a proper initial segment of `ordinal.{v}` for `v > u`. -/
def lift (o : ordinal.{u}) : ordinal.{max u v} :=
quotient.lift_on o (λ ⟨α, r, wo⟩,
@type _ _ (@order_embedding.is_well_order _ _ (@equiv.ulift.{u v} α ⁻¹'o r) r
(order_iso.preimage equiv.ulift.{u v} r) wo)) $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨f⟩,
quot.sound ⟨(order_iso.preimage equiv.ulift r).trans $
f.trans (order_iso.preimage equiv.ulift s).symm⟩
theorem lift_type {α} (r : α → α → Prop) [is_well_order α r] :
∃ wo', lift (type r) = @type _ (@equiv.ulift.{u v} α ⁻¹'o r) wo' :=
⟨_, rfl⟩
theorem lift_umax : lift.{u (max u v)} = lift.{u v} :=
funext $ λ a, induction_on a $ λ α r _,
quotient.sound ⟨(order_iso.preimage equiv.ulift r).trans (order_iso.preimage equiv.ulift r).symm⟩
theorem lift_id' (a : ordinal) : lift a = a :=
induction_on a $ λ α r _,
quotient.sound ⟨order_iso.preimage equiv.ulift r⟩
@[simp] theorem lift_id : ∀ a, lift.{u u} a = a := lift_id'.{u u}
@[simp]
theorem lift_lift (a : ordinal) : lift.{(max u v) w} (lift.{u v} a) = lift.{u (max v w)} a :=
induction_on a $ λ α r _,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans $
(order_iso.preimage equiv.ulift _).trans (order_iso.preimage equiv.ulift _).symm⟩
theorem lift_type_le {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) ≤ lift.{v (max u w)} (type s) ↔ nonempty (r ≼i s) :=
⟨λ ⟨f⟩, ⟨(initial_seg.of_iso (order_iso.preimage equiv.ulift r).symm).trans $
f.trans (initial_seg.of_iso (order_iso.preimage equiv.ulift s))⟩,
λ ⟨f⟩, ⟨(initial_seg.of_iso (order_iso.preimage equiv.ulift r)).trans $
f.trans (initial_seg.of_iso (order_iso.preimage equiv.ulift s).symm)⟩⟩
theorem lift_type_eq {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) = lift.{v (max u w)} (type s) ↔ nonempty (r ≃o s) :=
quotient.eq.trans
⟨λ ⟨f⟩, ⟨(order_iso.preimage equiv.ulift r).symm.trans $
f.trans (order_iso.preimage equiv.ulift s)⟩,
λ ⟨f⟩, ⟨(order_iso.preimage equiv.ulift r).trans $
f.trans (order_iso.preimage equiv.ulift s).symm⟩⟩
theorem lift_type_lt {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) < lift.{v (max u w)} (type s) ↔ nonempty (r ≺i s) :=
by haveI := @order_embedding.is_well_order _ _ (@equiv.ulift.{u (max v w)} α ⁻¹'o r)
r (order_iso.preimage equiv.ulift.{u (max v w)} r) _;
haveI := @order_embedding.is_well_order _ _ (@equiv.ulift.{v (max u w)} β ⁻¹'o s)
s (order_iso.preimage equiv.ulift.{v (max u w)} s) _; exact
⟨λ ⟨f⟩, ⟨(f.equiv_lt (order_iso.preimage equiv.ulift r).symm).lt_le
(initial_seg.of_iso (order_iso.preimage equiv.ulift s))⟩,
λ ⟨f⟩, ⟨(f.equiv_lt (order_iso.preimage equiv.ulift r)).lt_le
(initial_seg.of_iso (order_iso.preimage equiv.ulift s).symm)⟩⟩
@[simp] theorem lift_le {a b : ordinal} : lift.{u v} a ≤ lift b ↔ a ≤ b :=
induction_on a $ λ α r _, induction_on b $ λ β s _,
by rw ← lift_umax; exactI lift_type_le
@[simp] theorem lift_inj {a b : ordinal} : lift a = lift b ↔ a = b :=
by simp only [le_antisymm_iff, lift_le]
@[simp] theorem lift_lt {a b : ordinal} : lift a < lift b ↔ a < b :=
by simp only [lt_iff_le_not_le, lift_le]
@[simp] theorem lift_zero : lift 0 = 0 :=
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
⟨pempty_equiv_pempty, λ a b, iff.rfl⟩⟩
theorem zero_eq_lift_type_empty : 0 = lift.{0 u} (@type empty empty_relation _) :=
by rw [← zero_eq_type_empty, lift_zero]
@[simp] theorem lift_one : lift 1 = 1 :=
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
⟨punit_equiv_punit, λ a b, iff.rfl⟩⟩
theorem one_eq_lift_type_unit : 1 = lift.{0 u} (@type unit empty_relation _) :=
by rw [← one_eq_type_unit, lift_one]
@[simp] theorem lift_add (a b) : lift (a + b) = lift a + lift b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
(order_iso.sum_lex_congr (order_iso.preimage equiv.ulift _)
(order_iso.preimage equiv.ulift _)).symm⟩
@[simp] theorem lift_succ (a) : lift (succ a) = succ (lift a) :=
by unfold succ; simp only [lift_add, lift_one]
@[simp] theorem lift_card (a) : (card a).lift = card (lift a) :=
induction_on a $ λ α r _, rfl
theorem lift_down' {a : cardinal.{u}} {b : ordinal.{max u v}}
(h : card b ≤ a.lift) : ∃ a', lift a' = b :=
let ⟨c, e⟩ := cardinal.lift_down h in
quotient.induction_on c (λ α, induction_on b $ λ β s _ e', begin
resetI,
rw [mk_def, card_type, ← cardinal.lift_id'.{(max u v) u} (mk β),
← cardinal.lift_umax.{u v}, lift_mk_eq.{u (max u v) (max u v)}] at e',
cases e' with f,
have g := order_iso.preimage f s,
haveI := (g : ⇑f ⁻¹'o s ≼o s).is_well_order,
have := lift_type_eq.{u (max u v) (max u v)}.2 ⟨g⟩,
rw [lift_id, lift_umax.{u v}] at this,
exact ⟨_, this⟩
end) e
theorem lift_down {a : ordinal.{u}} {b : ordinal.{max u v}}
(h : b ≤ lift a) : ∃ a', lift a' = b :=
@lift_down' (card a) _ (by rw lift_card; exact card_le_card h)
theorem le_lift_iff {a : ordinal.{u}} {b : ordinal.{max u v}} :
b ≤ lift a ↔ ∃ a', lift a' = b ∧ a' ≤ a :=
⟨λ h, let ⟨a', e⟩ := lift_down h in ⟨a', e, lift_le.1 $ e.symm ▸ h⟩,
λ ⟨a', e, h⟩, e ▸ lift_le.2 h⟩
theorem lt_lift_iff {a : ordinal.{u}} {b : ordinal.{max u v}} :
b < lift a ↔ ∃ a', lift a' = b ∧ a' < a :=
⟨λ h, let ⟨a', e⟩ := lift_down (le_of_lt h) in
⟨a', e, lift_lt.1 $ e.symm ▸ h⟩,
λ ⟨a', e, h⟩, e ▸ lift_lt.2 h⟩
/-- `ω` is the first infinite ordinal, defined as the order type of `ℕ`. -/
def omega : ordinal.{u} := lift $ @type ℕ (<) _
localized "notation `ω` := ordinal.omega.{0}" in ordinal
theorem card_omega : card omega = cardinal.omega := rfl
@[simp] theorem lift_omega : lift omega = omega := lift_lift _
theorem add_le_add_right {a b : ordinal} : a ≤ b → ∀ c, a + c ≤ b + c :=
induction_on a $ λ α₁ r₁ hr₁, induction_on b $ λ α₂ r₂ hr₂ ⟨⟨⟨f, fo⟩, fi⟩⟩ c,
induction_on c $ λ β s hs, (@type_le' _ _ _ _
(@sum.lex.is_well_order _ _ _ _ hr₁ hs)
(@sum.lex.is_well_order _ _ _ _ hr₂ hs)).2
⟨⟨f.sum_map (embedding.refl _), λ a b, begin
split; intro H,
{ cases H; constructor; [rwa ← fo, assumption] },
{ cases a with a a; cases b with b b; cases H; constructor; [rwa fo, assumption] }
end⟩⟩
theorem le_add_left (a b : ordinal) : a ≤ b + a :=
by simpa only [zero_add] using add_le_add_right (zero_le b) a
theorem le_total (a b : ordinal) : a ≤ b ∨ b ≤ a :=
match lt_or_eq_of_le (le_add_left b a), lt_or_eq_of_le (le_add_right a b) with
| or.inr h, _ := by rw h; exact or.inl (le_add_right _ _)
| _, or.inr h := by rw h; exact or.inr (le_add_left _ _)
| or.inl h₁, or.inl h₂ := induction_on a (λ α₁ r₁ _,
induction_on b $ λ α₂ r₂ _ ⟨f⟩ ⟨g⟩, begin
resetI,
rw [← typein_top f, ← typein_top g, le_iff_lt_or_eq,
le_iff_lt_or_eq, typein_lt_typein, typein_lt_typein],
rcases trichotomous_of (sum.lex r₁ r₂) g.top f.top with h|h|h;
[exact or.inl (or.inl h), {left, right, rw h}, exact or.inr (or.inl h)]
end) h₁ h₂
end
instance : decidable_linear_order ordinal :=
{ le_total := le_total,
decidable_le := classical.dec_rel _,
..ordinal.partial_order }
@[simp] lemma typein_le_typein (r : α → α → Prop) [is_well_order α r] {x x' : α} :
typein r x ≤ typein r x' ↔ ¬r x' x :=
by rw [←not_lt, typein_lt_typein]
lemma enum_le_enum (r : α → α → Prop) [is_well_order α r] {o o' : ordinal}
(ho : o < type r) (ho' : o' < type r) : ¬r (enum r o' ho') (enum r o ho) ↔ o ≤ o' :=
by rw [←@not_lt _ _ o' o, enum_lt ho']
theorem lt_succ {a b : ordinal} : a < succ b ↔ a ≤ b :=
by rw [← not_le, succ_le, not_lt]
theorem add_lt_add_iff_left (a) {b c : ordinal} : a + b < a + c ↔ b < c :=
by rw [← not_le, ← not_le, add_le_add_iff_left]
theorem lt_of_add_lt_add_right {a b c : ordinal} : a + b < c + b → a < c :=
lt_imp_lt_of_le_imp_le (λ h, add_le_add_right h _)
@[simp] theorem succ_lt_succ {a b : ordinal} : succ a < succ b ↔ a < b :=
by rw [lt_succ, succ_le]
@[simp] theorem succ_le_succ {a b : ordinal} : succ a ≤ succ b ↔ a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 succ_lt_succ
theorem succ_inj {a b : ordinal} : succ a = succ b ↔ a = b :=
by simp only [le_antisymm_iff, succ_le_succ]
theorem add_le_add_iff_right {a b : ordinal} (n : ℕ) : a + n ≤ b + n ↔ a ≤ b :=
by induction n with n ih; [rw [nat.cast_zero, add_zero, add_zero],
rw [← nat_cast_succ, add_succ, add_succ, succ_le_succ, ih]]
theorem add_right_cancel {a b : ordinal} (n : ℕ) : a + n = b + n ↔ a = b :=
by simp only [le_antisymm_iff, add_le_add_iff_right]
@[simp] theorem card_eq_zero {o} : card o = 0 ↔ o = 0 :=
⟨induction_on o $ λ α r _ h, begin
refine le_antisymm (le_of_not_lt $
λ hn, ne_zero_iff_nonempty.2 _ h) (zero_le _),
rw [← succ_le, succ_zero] at hn, cases hn with f,
exact ⟨f punit.star⟩
end, λ e, by simp only [e, card_zero]⟩
theorem type_ne_zero_iff_nonempty [is_well_order α r] : type r ≠ 0 ↔ nonempty α :=
(not_congr (@card_eq_zero (type r))).symm.trans ne_zero_iff_nonempty
@[simp] theorem type_eq_zero_iff_empty [is_well_order α r] : type r = 0 ↔ ¬ nonempty α :=
(not_iff_comm.1 type_ne_zero_iff_nonempty).symm
protected lemma one_ne_zero : (1 : ordinal) ≠ 0 :=
type_ne_zero_iff_nonempty.2 ⟨punit.star⟩
instance : nontrivial ordinal.{u} :=
⟨⟨1, 0, ordinal.one_ne_zero⟩⟩
theorem zero_lt_one : (0 : ordinal) < 1 :=
lt_iff_le_and_ne.2 ⟨zero_le _, ne.symm $ ordinal.one_ne_zero⟩
/-- The ordinal predecessor of `o` is `o'` if `o = succ o'`,
and `o` otherwise. -/
def pred (o : ordinal.{u}) : ordinal.{u} :=
if h : ∃ a, o = succ a then classical.some h else o
@[simp] theorem pred_succ (o) : pred (succ o) = o :=
by have h : ∃ a, succ o = succ a := ⟨_, rfl⟩;
simpa only [pred, dif_pos h] using (succ_inj.1 $ classical.some_spec h).symm
theorem pred_le_self (o) : pred o ≤ o :=
if h : ∃ a, o = succ a then let ⟨a, e⟩ := h in
by rw [e, pred_succ]; exact le_of_lt (lt_succ_self _)
else by rw [pred, dif_neg h]
theorem pred_eq_iff_not_succ {o} : pred o = o ↔ ¬ ∃ a, o = succ a :=
⟨λ e ⟨a, e'⟩, by rw [e', pred_succ] at e; exact ne_of_lt (lt_succ_self _) e,
λ h, dif_neg h⟩
theorem pred_lt_iff_is_succ {o} : pred o < o ↔ ∃ a, o = succ a :=
iff.trans (by simp only [le_antisymm_iff, pred_le_self, true_and, not_le])
(iff_not_comm.1 pred_eq_iff_not_succ).symm
theorem succ_pred_iff_is_succ {o} : succ (pred o) = o ↔ ∃ a, o = succ a :=
⟨λ e, ⟨_, e.symm⟩, λ ⟨a, e⟩, by simp only [e, pred_succ]⟩
theorem succ_lt_of_not_succ {o} (h : ¬ ∃ a, o = succ a) {b} : succ b < o ↔ b < o :=
⟨lt_trans (lt_succ_self _), λ l,
lt_of_le_of_ne (succ_le.2 l) (λ e, h ⟨_, e.symm⟩)⟩
theorem lt_pred {a b} : a < pred b ↔ succ a < b :=
if h : ∃ a, b = succ a then let ⟨c, e⟩ := h in
by rw [e, pred_succ, succ_lt_succ]
else by simp only [pred, dif_neg h, succ_lt_of_not_succ h]
theorem pred_le {a b} : pred a ≤ b ↔ a ≤ succ b :=
le_iff_le_iff_lt_iff_lt.2 lt_pred
@[simp] theorem lift_is_succ {o} : (∃ a, lift o = succ a) ↔ (∃ a, o = succ a) :=
⟨λ ⟨a, h⟩,
let ⟨b, e⟩ := lift_down $ show a ≤ lift o, from le_of_lt $
h.symm ▸ lt_succ_self _ in
⟨b, lift_inj.1 $ by rw [h, ← e, lift_succ]⟩,
λ ⟨a, h⟩, ⟨lift a, by simp only [h, lift_succ]⟩⟩
@[simp] theorem lift_pred (o) : lift (pred o) = pred (lift o) :=
if h : ∃ a, o = succ a then
by cases h with a e; simp only [e, pred_succ, lift_succ]
else by rw [pred_eq_iff_not_succ.2 h,
pred_eq_iff_not_succ.2 (mt lift_is_succ.1 h)]
/-- A limit ordinal is an ordinal which is not zero and not a successor. -/
def is_limit (o : ordinal) : Prop := o ≠ 0 ∧ ∀ a < o, succ a < o
theorem not_zero_is_limit : ¬ is_limit 0
| ⟨h, _⟩ := h rfl
theorem not_succ_is_limit (o) : ¬ is_limit (succ o)
| ⟨_, h⟩ := lt_irrefl _ (h _ (lt_succ_self _))
theorem not_succ_of_is_limit {o} (h : is_limit o) : ¬ ∃ a, o = succ a
| ⟨a, e⟩ := not_succ_is_limit a (e ▸ h)
theorem succ_lt_of_is_limit {o} (h : is_limit o) {a} : succ a < o ↔ a < o :=
⟨lt_trans (lt_succ_self _), h.2 _⟩
theorem le_succ_of_is_limit {o} (h : is_limit o) {a} : o ≤ succ a ↔ o ≤ a :=
le_iff_le_iff_lt_iff_lt.2 $ succ_lt_of_is_limit h
theorem limit_le {o} (h : is_limit o) {a} : o ≤ a ↔ ∀ x < o, x ≤ a :=
⟨λ h x l, le_trans (le_of_lt l) h,
λ H, (le_succ_of_is_limit h).1 $ le_of_not_lt $ λ hn,
not_lt_of_le (H _ hn) (lt_succ_self _)⟩
theorem lt_limit {o} (h : is_limit o) {a} : a < o ↔ ∃ x < o, a < x :=
by simpa only [not_ball, not_le] using not_congr (@limit_le _ h a)
@[simp] theorem lift_is_limit (o) : is_limit (lift o) ↔ is_limit o :=
and_congr (not_congr $ by simpa only [lift_zero] using @lift_inj o 0)
⟨λ H a h, lift_lt.1 $ by simpa only [lift_succ] using H _ (lift_lt.2 h),
λ H a h, let ⟨a', e⟩ := lift_down (le_of_lt h) in
by rw [← e, ← lift_succ, lift_lt];
rw [← e, lift_lt] at h; exact H a' h⟩
theorem is_limit.pos {o : ordinal} (h : is_limit o) : 0 < o :=
lt_of_le_of_ne (zero_le _) h.1.symm
theorem is_limit.one_lt {o : ordinal} (h : is_limit o) : 1 < o :=
by simpa only [succ_zero] using h.2 _ h.pos
theorem is_limit.nat_lt {o : ordinal} (h : is_limit o) : ∀ n : ℕ, (n : ordinal) < o
| 0 := h.pos
| (n+1) := h.2 _ (is_limit.nat_lt n)
theorem zero_or_succ_or_limit (o : ordinal) :
o = 0 ∨ (∃ a, o = succ a) ∨ is_limit o :=
if o0 : o = 0 then or.inl o0 else
if h : ∃ a, o = succ a then or.inr (or.inl h) else
or.inr $ or.inr ⟨o0, λ a, (succ_lt_of_not_succ h).2⟩
instance : is_well_order ordinal (<) := ⟨wf⟩
@[elab_as_eliminator] def limit_rec_on {C : ordinal → Sort*}
(o : ordinal) (H₁ : C 0) (H₂ : ∀ o, C o → C (succ o))
(H₃ : ∀ o, is_limit o → (∀ o' < o, C o') → C o) : C o :=
wf.fix (λ o IH,
if o0 : o = 0 then by rw o0; exact H₁ else
if h : ∃ a, o = succ a then
by rw ← succ_pred_iff_is_succ.2 h; exact
H₂ _ (IH _ $ pred_lt_iff_is_succ.2 h)
else H₃ _ ⟨o0, λ a, (succ_lt_of_not_succ h).2⟩ IH) o
@[simp] theorem limit_rec_on_zero {C} (H₁ H₂ H₃) : @limit_rec_on C 0 H₁ H₂ H₃ = H₁ :=
by rw [limit_rec_on, well_founded.fix_eq, dif_pos rfl]; refl
@[simp] theorem limit_rec_on_succ {C} (o H₁ H₂ H₃) :
@limit_rec_on C (succ o) H₁ H₂ H₃ = H₂ o (@limit_rec_on C o H₁ H₂ H₃) :=
begin
have h : ∃ a, succ o = succ a := ⟨_, rfl⟩,
rw [limit_rec_on, well_founded.fix_eq,
dif_neg (succ_ne_zero o), dif_pos h],
generalize : limit_rec_on._proof_2 (succ o) h = h₂,
generalize : limit_rec_on._proof_3 (succ o) h = h₃,
revert h₂ h₃, generalize e : pred (succ o) = o', intros,
rw pred_succ at e, subst o', refl
end
@[simp] theorem limit_rec_on_limit {C} (o H₁ H₂ H₃ h) :
@limit_rec_on C o H₁ H₂ H₃ = H₃ o h (λ x h, @limit_rec_on C x H₁ H₂ H₃) :=
by rw [limit_rec_on, well_founded.fix_eq,
dif_neg h.1, dif_neg (not_succ_of_is_limit h)]; refl
lemma has_succ_of_is_limit {α} {r : α → α → Prop} [wo : is_well_order α r]
(h : (type r).is_limit) (x : α) : ∃y, r x y :=
begin
use enum r (typein r x).succ (h.2 _ (typein_lt_type r x)),
convert (enum_lt (typein_lt_type r x) _).mpr (lt_succ_self _), rw [enum_typein]
end
lemma type_subrel_lt (o : ordinal.{u}) :
type (subrel (<) {o' : ordinal | o' < o}) = ordinal.lift.{u u+1} o :=
begin
refine quotient.induction_on o _,
rintro ⟨α, r, wo⟩, resetI, apply quotient.sound,
constructor, symmetry, refine (order_iso.preimage equiv.ulift r).trans (typein_iso r)
end
lemma mk_initial_seg (o : ordinal.{u}) :
#{o' : ordinal | o' < o} = cardinal.lift.{u u+1} o.card :=
by rw [lift_card, ←type_subrel_lt, card_type]
/-- A normal ordinal function is a strictly increasing function which is
order-continuous. -/
def is_normal (f : ordinal → ordinal) : Prop :=
(∀ o, f o < f (succ o)) ∧ ∀ o, is_limit o → ∀ a, f o ≤ a ↔ ∀ b < o, f b ≤ a
theorem is_normal.limit_le {f} (H : is_normal f) : ∀ {o}, is_limit o →
∀ {a}, f o ≤ a ↔ ∀ b < o, f b ≤ a := H.2
theorem is_normal.limit_lt {f} (H : is_normal f) {o} (h : is_limit o) {a} :
a < f o ↔ ∃ b < o, a < f b :=
not_iff_not.1 $ by simpa only [exists_prop, not_exists, not_and, not_lt] using H.2 _ h a
theorem is_normal.lt_iff {f} (H : is_normal f) {a b} : f a < f b ↔ a < b :=
strict_mono.lt_iff_lt $ λ a b,
limit_rec_on b (not.elim (not_lt_of_le $ zero_le _))
(λ b IH h, (lt_or_eq_of_le (lt_succ.1 h)).elim
(λ h, lt_trans (IH h) (H.1 _))
(λ e, e ▸ H.1 _))
(λ b l IH h, lt_of_lt_of_le (H.1 a)
((H.2 _ l _).1 (le_refl _) _ (l.2 _ h)))
theorem is_normal.le_iff {f} (H : is_normal f) {a b} : f a ≤ f b ↔ a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 H.lt_iff
theorem is_normal.inj {f} (H : is_normal f) {a b} : f a = f b ↔ a = b :=
by simp only [le_antisymm_iff, H.le_iff]
theorem is_normal.le_self {f} (H : is_normal f) (a) : a ≤ f a :=
limit_rec_on a (zero_le _)
(λ a IH, succ_le.2 $ lt_of_le_of_lt IH (H.1 _))
(λ a l IH, (limit_le l).2 $ λ b h,
le_trans (IH b h) $ H.le_iff.2 $ le_of_lt h)
theorem is_normal.le_set {f} (H : is_normal f) (p : ordinal → Prop)
(p0 : ∃ x, p x) (S)
(H₂ : ∀ o, S ≤ o ↔ ∀ a, p a → a ≤ o) {o} :
f S ≤ o ↔ ∀ a, p a → f a ≤ o :=
⟨λ h a pa, le_trans (H.le_iff.2 ((H₂ _).1 (le_refl _) _ pa)) h,
λ h, begin
revert H₂, apply limit_rec_on S,
{ intro H₂,
cases p0 with x px,
have := le_zero.1 ((H₂ _).1 (zero_le _) _ px),
rw this at px, exact h _ px },
{ intros S _ H₂,
rcases not_ball.1 (mt (H₂ S).2 $ not_le_of_lt $ lt_succ_self _) with ⟨a, h₁, h₂⟩,
exact le_trans (H.le_iff.2 $ succ_le.2 $ not_le.1 h₂) (h _ h₁) },
{ intros S L _ H₂, apply (H.2 _ L _).2, intros a h',
rcases not_ball.1 (mt (H₂ a).2 (not_le.2 h')) with ⟨b, h₁, h₂⟩,
exact le_trans (H.le_iff.2 $ le_of_lt $ not_le.1 h₂) (h _ h₁) }
end⟩
theorem is_normal.le_set' {f} (H : is_normal f) (p : α → Prop) (g : α → ordinal)
(p0 : ∃ x, p x) (S)
(H₂ : ∀ o, S ≤ o ↔ ∀ a, p a → g a ≤ o) {o} :
f S ≤ o ↔ ∀ a, p a → f (g a) ≤ o :=
(H.le_set (λ x, ∃ y, p y ∧ x = g y)
(let ⟨x, px⟩ := p0 in ⟨_, _, px, rfl⟩) _
(λ o, (H₂ o).trans ⟨λ H a ⟨y, h1, h2⟩, h2.symm ▸ H y h1,
λ H a h1, H (g a) ⟨a, h1, rfl⟩⟩)).trans
⟨λ H a h, H (g a) ⟨a, h, rfl⟩, λ H a ⟨y, h1, h2⟩, h2.symm ▸ H y h1⟩
theorem is_normal.refl : is_normal id :=
⟨λ x, lt_succ_self _, λ o l a, limit_le l⟩
theorem is_normal.trans {f g} (H₁ : is_normal f) (H₂ : is_normal g) :
is_normal (λ x, f (g x)) :=
⟨λ x, H₁.lt_iff.2 (H₂.1 _),
λ o l a, H₁.le_set' (< o) g ⟨_, l.pos⟩ _ (λ c, H₂.2 _ l _)⟩
theorem is_normal.is_limit {f} (H : is_normal f) {o} (l : is_limit o) :
is_limit (f o) :=
⟨ne_of_gt $ lt_of_le_of_lt (zero_le _) $ H.lt_iff.2 l.pos,
λ a h, let ⟨b, h₁, h₂⟩ := (H.limit_lt l).1 h in
lt_of_le_of_lt (succ_le.2 h₂) (H.lt_iff.2 h₁)⟩
theorem add_le_of_limit {a b c : ordinal.{u}}
(h : is_limit b) : a + b ≤ c ↔ ∀ b' < b, a + b' ≤ c :=
⟨λ h b' l, le_trans (add_le_add_left (le_of_lt l) _) h,
λ H, le_of_not_lt $
induction_on a (λ α r _, induction_on b $ λ β s _ h H l, begin
resetI,
suffices : ∀ x : β, sum.lex r s (sum.inr x) (enum _ _ l),
{ cases enum _ _ l with x x,
{ cases this (enum s 0 h.pos) },
{ exact irrefl _ (this _) } },
intros x,
rw [← typein_lt_typein (sum.lex r s), typein_enum],
have := H _ (h.2 _ (typein_lt_type s x)),
rw [add_succ, succ_le] at this,
refine lt_of_le_of_lt (type_le'.2
⟨order_embedding.of_monotone (λ a, _) (λ a b, _)⟩) this,
{ rcases a with ⟨a | b, h⟩,
{ exact sum.inl a },
{ exact sum.inr ⟨b, by cases h; assumption⟩ } },
{ rcases a with ⟨a | a, h₁⟩; rcases b with ⟨b | b, h₂⟩; cases h₁; cases h₂;
rintro ⟨⟩; constructor; assumption }
end) h H⟩
theorem add_is_normal (a : ordinal) : is_normal ((+) a) :=
⟨λ b, (add_lt_add_iff_left a).2 (lt_succ_self _),
λ b l c, add_le_of_limit l⟩
theorem add_is_limit (a) {b} : is_limit b → is_limit (a + b) :=
(add_is_normal a).is_limit
def typein.principal_seg {α : Type u} (r : α → α → Prop) [is_well_order α r] :
@principal_seg α ordinal.{u} r (<) :=
⟨order_embedding.of_monotone (typein r)
(λ a b, (typein_lt_typein r).2), type r, λ b,
⟨λ h, ⟨enum r _ h, typein_enum r h⟩,
λ ⟨a, e⟩, e ▸ typein_lt_type _ _⟩⟩
@[simp] theorem typein.principal_seg_coe (r : α → α → Prop) [is_well_order α r] :
(typein.principal_seg r : α → ordinal) = typein r := rfl
/-- The minimal element of a nonempty family of ordinals -/
def min {ι} (I : nonempty ι) (f : ι → ordinal) : ordinal :=
wf.min (set.range f) (let ⟨i⟩ := I in ⟨_, set.mem_range_self i⟩)
theorem min_eq {ι} (I) (f : ι → ordinal) : ∃ i, min I f = f i :=
let ⟨i, e⟩ := wf.min_mem (set.range f) _ in ⟨i, e.symm⟩
theorem min_le {ι I} (f : ι → ordinal) (i) : min I f ≤ f i :=
le_of_not_gt $ wf.not_lt_min (set.range f) _ (set.mem_range_self i)
theorem le_min {ι I} {f : ι → ordinal} {a} : a ≤ min I f ↔ ∀ i, a ≤ f i :=
⟨λ h i, le_trans h (min_le _ _),
λ h, let ⟨i, e⟩ := min_eq I f in e.symm ▸ h i⟩
/-- The minimal element of a nonempty set of ordinals -/
def omin (S : set ordinal.{u}) (H : ∃ x, x ∈ S) : ordinal.{u} :=
@min.{(u+2) u} S (let ⟨x, px⟩ := H in ⟨⟨x, px⟩⟩) subtype.val
theorem omin_mem (S H) : omin S H ∈ S :=
let ⟨⟨i, h⟩, e⟩ := @min_eq S _ _ in
(show omin S H = i, from e).symm ▸ h
theorem le_omin {S H a} : a ≤ omin S H ↔ ∀ i ∈ S, a ≤ i :=
le_min.trans set_coe.forall
theorem omin_le {S H i} (h : i ∈ S) : omin S H ≤ i :=
le_omin.1 (le_refl _) _ h
@[simp] theorem lift_min {ι} (I) (f : ι → ordinal) : lift (min I f) = min I (lift ∘ f) :=
le_antisymm (le_min.2 $ λ a, lift_le.2 $ min_le _ a) $
let ⟨i, e⟩ := min_eq I (lift ∘ f) in
by rw e; exact lift_le.2 (le_min.2 $ λ j, lift_le.1 $
by have := min_le (lift ∘ f) j; rwa e at this)
def lift.initial_seg : @initial_seg ordinal.{u} ordinal.{max u v} (<) (<) :=
⟨⟨⟨lift.{u v}, λ a b, lift_inj.1⟩, λ a b, lift_lt.symm⟩,
λ a b h, lift_down (le_of_lt h)⟩
@[simp] theorem lift.initial_seg_coe : (lift.initial_seg : ordinal → ordinal) = lift := rfl
/-- `univ.{u v}` is the order type of the ordinals of `Type u` as a member
of `ordinal.{v}` (when `u < v`). It is an inaccessible cardinal. -/
def univ := lift.{(u+1) v} (@type ordinal.{u} (<) _)
theorem univ_id : univ.{u (u+1)} = @type ordinal.{u} (<) _ := lift_id _
@[simp] theorem lift_univ : lift.{_ w} univ.{u v} = univ.{u (max v w)} := lift_lift _
theorem univ_umax : univ.{u (max (u+1) v)} = univ.{u v} := congr_fun lift_umax _
def lift.principal_seg : @principal_seg ordinal.{u} ordinal.{max (u+1) v} (<) (<) :=
⟨↑lift.initial_seg.{u (max (u+1) v)}, univ.{u v}, begin
refine λ b, induction_on b _, introsI β s _,
rw [univ, ← lift_umax], split; intro h,
{ rw ← lift_id (type s) at h ⊢,
cases lift_type_lt.1 h with f, cases f with f a hf,
existsi a, revert hf,
apply induction_on a, introsI α r _ hf,
refine lift_type_eq.{u (max (u+1) v) (max (u+1) v)}.2
⟨(order_iso.of_surjective (order_embedding.of_monotone _ _) _).symm⟩,
{ exact λ b, enum r (f b) ((hf _).2 ⟨_, rfl⟩) },
{ refine λ a b h, (typein_lt_typein r).1 _,
rw [typein_enum, typein_enum],
exact f.ord.1 h },
{ intro a', cases (hf _).1 (typein_lt_type _ a') with b e,
existsi b, simp, simp [e] } },
{ cases h with a e, rw [← e],
apply induction_on a, introsI α r _,
exact lift_type_lt.{u (u+1) (max (u+1) v)}.2
⟨typein.principal_seg r⟩ }
end⟩
@[simp] theorem lift.principal_seg_coe :
(lift.principal_seg.{u v} : ordinal → ordinal) = lift.{u (max (u+1) v)} := rfl
@[simp] theorem lift.principal_seg_top : lift.principal_seg.top = univ := rfl
theorem lift.principal_seg_top' :
lift.principal_seg.{u (u+1)}.top = @type ordinal.{u} (<) _ :=
by simp only [lift.principal_seg_top, univ_id]
/-- `a - b` is the unique ordinal satisfying
`b + (a - b) = a` when `b ≤ a`. -/
def sub (a b : ordinal.{u}) : ordinal.{u} :=
omin {o | a ≤ b+o} ⟨a, le_add_left _ _⟩
instance : has_sub ordinal := ⟨sub⟩
theorem le_add_sub (a b : ordinal) : a ≤ b + (a - b) :=
omin_mem {o | a ≤ b+o} _
theorem sub_le {a b c : ordinal} : a - b ≤ c ↔ a ≤ b + c :=
⟨λ h, le_trans (le_add_sub a b) (add_le_add_left h _),
λ h, omin_le h⟩
theorem lt_sub {a b c : ordinal} : a < b - c ↔ c + a < b :=
lt_iff_lt_of_le_iff_le sub_le
theorem add_sub_cancel (a b : ordinal) : a + b - a = b :=
le_antisymm (sub_le.2 $ le_refl _)
((add_le_add_iff_left a).1 $ le_add_sub _ _)
theorem sub_eq_of_add_eq {a b c : ordinal} (h : a + b = c) : c - a = b :=
h ▸ add_sub_cancel _ _
theorem sub_le_self (a b : ordinal) : a - b ≤ a :=
sub_le.2 $ le_add_left _ _
theorem add_sub_cancel_of_le {a b : ordinal} (h : b ≤ a) : b + (a - b) = a :=
le_antisymm begin
rcases zero_or_succ_or_limit (a-b) with e|⟨c,e⟩|l,
{ simp only [e, add_zero, h] },
{ rw [e, add_succ, succ_le, ← lt_sub, e], apply lt_succ_self },
{ exact (add_le_of_limit l).2 (λ c l, le_of_lt (lt_sub.1 l)) }
end (le_add_sub _ _)
@[simp] theorem sub_zero (a : ordinal) : a - 0 = a :=
by simpa only [zero_add] using add_sub_cancel 0 a
@[simp] theorem zero_sub (a : ordinal) : 0 - a = 0 :=
by rw ← le_zero; apply sub_le_self
@[simp] theorem sub_self (a : ordinal) : a - a = 0 :=
by simpa only [add_zero] using add_sub_cancel a 0
theorem sub_eq_zero_iff_le {a b : ordinal} : a - b = 0 ↔ a ≤ b :=
⟨λ h, by simpa only [h, add_zero] using le_add_sub a b,
λ h, by rwa [← le_zero, sub_le, add_zero]⟩
theorem sub_sub (a b c : ordinal) : a - b - c = a - (b + c) :=
eq_of_forall_ge_iff $ λ d, by rw [sub_le, sub_le, sub_le, add_assoc]
theorem add_sub_add_cancel (a b c : ordinal) : a + b - (a + c) = b - c :=
by rw [← sub_sub, add_sub_cancel]
theorem sub_is_limit {a b} (l : is_limit a) (h : b < a) : is_limit (a - b) :=
⟨ne_of_gt $ lt_sub.2 $ by rwa add_zero,
λ c h, by rw [lt_sub, add_succ]; exact l.2 _ (lt_sub.1 h)⟩
@[simp] theorem one_add_omega : 1 + omega.{u} = omega :=
begin
refine le_antisymm _ (le_add_left _ _),
rw [omega, one_eq_lift_type_unit, ← lift_add, lift_le, type_add],
have : is_well_order unit empty_relation := by apply_instance,
refine ⟨order_embedding.collapse (order_embedding.of_monotone _ _)⟩,
{ apply sum.rec, exact λ _, 0, exact nat.succ },
{ intros a b, cases a; cases b; intro H; cases H with _ _ H _ _ H;
[cases H, exact nat.succ_pos _, exact nat.succ_lt_succ H] }
end
@[simp, priority 990]
theorem one_add_of_omega_le {o} (h : omega ≤ o) : 1 + o = o :=
by rw [← add_sub_cancel_of_le h, ← add_assoc, one_add_omega]
instance : monoid ordinal.{u} :=
{ mul := λ a b, quotient.lift_on₂ a b
(λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, ⟦⟨β × α, prod.lex s r, by exactI prod.lex.is_well_order⟩⟧
: Well_order → Well_order → ordinal) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
quot.sound ⟨order_iso.prod_lex_congr g f⟩,
one := 1,
mul_assoc := λ a b c, quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩,
eq.symm $ quotient.sound ⟨⟨prod_assoc _ _ _, λ a b, begin
rcases a with ⟨⟨a₁, a₂⟩, a₃⟩,
rcases b with ⟨⟨b₁, b₂⟩, b₃⟩,
simp [prod.lex_def, and_or_distrib_left, or_assoc, and_assoc]
end⟩⟩,
mul_one := λ a, induction_on a $ λ α r _, quotient.sound
⟨⟨punit_prod _, λ a b, by rcases a with ⟨⟨⟨⟩⟩, a⟩; rcases b with ⟨⟨⟨⟩⟩, b⟩;
simp only [prod.lex_def, empty_relation, false_or];
simp only [eq_self_iff_true, true_and]; refl⟩⟩,
one_mul := λ a, induction_on a $ λ α r _, quotient.sound
⟨⟨prod_punit _, λ a b, by rcases a with ⟨a, ⟨⟨⟩⟩⟩; rcases b with ⟨b, ⟨⟨⟩⟩⟩;
simp only [prod.lex_def, empty_relation, and_false, or_false]; refl⟩⟩ }
@[simp] theorem type_mul {α β : Type u} (r : α → α → Prop) (s : β → β → Prop)
[is_well_order α r] [is_well_order β s] : type r * type s = type (prod.lex s r) := rfl
@[simp] theorem lift_mul (a b) : lift (a * b) = lift a * lift b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
(order_iso.prod_lex_congr (order_iso.preimage equiv.ulift _)
(order_iso.preimage equiv.ulift _)).symm⟩
@[simp] theorem card_mul (a b) : card (a * b) = card a * card b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
mul_comm (mk β) (mk α)
@[simp] theorem mul_zero (a : ordinal) : a * 0 = 0 :=
induction_on a $ λ α _ _, by exactI
type_eq_zero_iff_empty.2 (λ ⟨⟨e, _⟩⟩, e.elim)
@[simp] theorem zero_mul (a : ordinal) : 0 * a = 0 :=
induction_on a $ λ α _ _, by exactI
type_eq_zero_iff_empty.2 (λ ⟨⟨_, e⟩⟩, e.elim)
theorem mul_add (a b c : ordinal) : a * (b + c) = a * b + a * c :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩,
quotient.sound ⟨⟨sum_prod_distrib _ _ _, begin
rintro ⟨a₁|a₁, a₂⟩ ⟨b₁|b₁, b₂⟩; simp only [prod.lex_def,
sum.lex_inl_inl, sum.lex.sep, sum.lex_inr_inl, sum.lex_inr_inr,
sum_prod_distrib_apply_left, sum_prod_distrib_apply_right];
simp only [sum.inl.inj_iff, true_or, false_and, false_or]
end⟩⟩
@[simp] theorem mul_add_one (a b : ordinal) : a * (b + 1) = a * b + a :=
by simp only [mul_add, mul_one]
@[simp] theorem mul_succ (a b : ordinal) : a * succ b = a * b + a := mul_add_one _ _
theorem mul_le_mul_left {a b} (c : ordinal) : a ≤ b → c * a ≤ c * b :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩, begin
resetI,
refine type_le'.2 ⟨order_embedding.of_monotone
(λ a, (f a.1, a.2))
(λ a b h, _)⟩, clear_,
cases h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h',
{ exact prod.lex.left _ _ (f.to_order_embedding.ord.1 h') },
{ exact prod.lex.right _ h' }
end
theorem mul_le_mul_right {a b} (c : ordinal) : a ≤ b → a * c ≤ b * c :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩, begin
resetI,
refine type_le'.2 ⟨order_embedding.of_monotone
(λ a, (a.1, f a.2))
(λ a b h, _)⟩,
cases h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h',
{ exact prod.lex.left _ _ h' },
{ exact prod.lex.right _ (f.to_order_embedding.ord.1 h') }
end
theorem mul_le_mul {a b c d : ordinal} (h₁ : a ≤ c) (h₂ : b ≤ d) : a * b ≤ c * d :=
le_trans (mul_le_mul_left _ h₂) (mul_le_mul_right _ h₁)
private lemma mul_le_of_limit_aux {α β r s} [is_well_order α r] [is_well_order β s]
{c} (h : is_limit (type s)) (H : ∀ b' < type s, type r * b' ≤ c)
(l : c < type r * type s) : false :=
begin
suffices : ∀ a b, prod.lex s r (b, a) (enum _ _ l),
{ cases enum _ _ l with b a, exact irrefl _ (this _ _) },
intros a b,
rw [← typein_lt_typein (prod.lex s r), typein_enum],
have := H _ (h.2 _ (typein_lt_type s b)),
rw [mul_succ] at this,
have := lt_of_lt_of_le ((add_lt_add_iff_left _).2
(typein_lt_type _ a)) this,
refine lt_of_le_of_lt _ this,
refine (type_le'.2 _),
constructor,
refine order_embedding.of_monotone (λ a, _) (λ a b, _),
{ rcases a with ⟨⟨b', a'⟩, h⟩,
by_cases e : b = b',
{ refine sum.inr ⟨a', _⟩,
subst e, cases h with _ _ _ _ h _ _ _ h,
{ exact (irrefl _ h).elim },
{ exact h } },
{ refine sum.inl (⟨b', _⟩, a'),
cases h with _ _ _ _ h _ _ _ h,
{ exact h }, { exact (e rfl).elim } } },
{ rcases a with ⟨⟨b₁, a₁⟩, h₁⟩,
rcases b with ⟨⟨b₂, a₂⟩, h₂⟩,
intro h, by_cases e₁ : b = b₁; by_cases e₂ : b = b₂,
{ substs b₁ b₂,
simpa only [subrel_val, prod.lex_def, @irrefl _ s _ b, true_and, false_or, eq_self_iff_true,
dif_pos, sum.lex_inr_inr] using h },
{ subst b₁,
simp only [subrel_val, prod.lex_def, e₂, prod.lex_def, dif_pos, subrel_val, eq_self_iff_true,
or_false, dif_neg, not_false_iff, sum.lex_inr_inl, false_and] at h ⊢,
cases h₂; [exact asymm h h₂_h, exact e₂ rfl] },
{ simp only [e₂, dif_pos, eq_self_iff_true, dif_neg e₁, not_false_iff, sum.lex.sep] },
{ simpa only [dif_neg e₁, dif_neg e₂, prod.lex_def, subrel_val, subtype.mk_eq_mk,
sum.lex_inl_inl] using h } }
end
theorem mul_le_of_limit {a b c : ordinal.{u}}
(h : is_limit b) : a * b ≤ c ↔ ∀ b' < b, a * b' ≤ c :=
⟨λ h b' l, le_trans (mul_le_mul_left _ (le_of_lt l)) h,
λ H, le_of_not_lt $ induction_on a (λ α r _, induction_on b $ λ β s _,
by exactI mul_le_of_limit_aux) h H⟩
theorem mul_is_normal {a : ordinal} (h : 0 < a) : is_normal ((*) a) :=
⟨λ b, by rw mul_succ; simpa only [add_zero] using (add_lt_add_iff_left (a*b)).2 h,
λ b l c, mul_le_of_limit l⟩
theorem lt_mul_of_limit {a b c : ordinal.{u}}
(h : is_limit c) : a < b * c ↔ ∃ c' < c, a < b * c' :=
by simpa only [not_ball, not_le] using not_congr (@mul_le_of_limit b c a h)
theorem mul_lt_mul_iff_left {a b c : ordinal} (a0 : 0 < a) : a * b < a * c ↔ b < c :=
(mul_is_normal a0).lt_iff
theorem mul_le_mul_iff_left {a b c : ordinal} (a0 : 0 < a) : a * b ≤ a * c ↔ b ≤ c :=
(mul_is_normal a0).le_iff
theorem mul_lt_mul_of_pos_left {a b c : ordinal}
(h : a < b) (c0 : 0 < c) : c * a < c * b :=
(mul_lt_mul_iff_left c0).2 h
theorem mul_pos {a b : ordinal} (h₁ : 0 < a) (h₂ : 0 < b) : 0 < a * b :=
by simpa only [mul_zero] using mul_lt_mul_of_pos_left h₂ h₁
theorem mul_ne_zero {a b : ordinal} : a ≠ 0 → b ≠ 0 → a * b ≠ 0 :=
by simpa only [pos_iff_ne_zero] using mul_pos
theorem le_of_mul_le_mul_left {a b c : ordinal}
(h : c * a ≤ c * b) (h0 : 0 < c) : a ≤ b :=
le_imp_le_of_lt_imp_lt (λ h', mul_lt_mul_of_pos_left h' h0) h
theorem mul_right_inj {a b c : ordinal} (a0 : 0 < a) : a * b = a * c ↔ b = c :=
(mul_is_normal a0).inj
theorem mul_is_limit {a b : ordinal}
(a0 : 0 < a) : is_limit b → is_limit (a * b) :=
(mul_is_normal a0).is_limit
theorem mul_is_limit_left {a b : ordinal}
(l : is_limit a) (b0 : 0 < b) : is_limit (a * b) :=
begin
rcases zero_or_succ_or_limit b with rfl|⟨b,rfl⟩|lb,
{ exact (lt_irrefl _).elim b0 },
{ rw mul_succ, exact add_is_limit _ l },
{ exact mul_is_limit l.pos lb }
end
protected lemma div_aux (a b : ordinal.{u}) (h : b ≠ 0) : set.nonempty {o | a < b * succ o} :=
⟨a, succ_le.1 $
by simpa only [succ_zero, one_mul]
using mul_le_mul_right (succ a) (succ_le.2 (pos_iff_ne_zero.2 h))⟩
/-- `a / b` is the unique ordinal `o` satisfying
`a = b * o + o'` with `o' < b`. -/
protected def div (a b : ordinal.{u}) : ordinal.{u} :=
if h : b = 0 then 0 else omin {o | a < b * succ o} (ordinal.div_aux a b h)
instance : has_div ordinal := ⟨ordinal.div⟩
@[simp] theorem div_zero (a : ordinal) : a / 0 = 0 := dif_pos rfl
lemma div_def (a) {b : ordinal} (h : b ≠ 0) :
a / b = omin {o | a < b * succ o} (ordinal.div_aux a b h) := dif_neg h
theorem lt_mul_succ_div (a) {b : ordinal} (h : b ≠ 0) : a < b * succ (a / b) :=
by rw div_def a h; exact omin_mem {o | a < b * succ o} _
theorem lt_mul_div_add (a) {b : ordinal} (h : b ≠ 0) : a < b * (a / b) + b :=
by simpa only [mul_succ] using lt_mul_succ_div a h
theorem div_le {a b c : ordinal} (b0 : b ≠ 0) : a / b ≤ c ↔ a < b * succ c :=
⟨λ h, lt_of_lt_of_le (lt_mul_succ_div a b0) (mul_le_mul_left _ $ succ_le_succ.2 h),
λ h, by rw div_def a b0; exact omin_le h⟩
theorem lt_div {a b c : ordinal} (c0 : c ≠ 0) : a < b / c ↔ c * succ a ≤ b :=
by rw [← not_le, div_le c0, not_lt]
theorem le_div {a b c : ordinal} (c0 : c ≠ 0) :
a ≤ b / c ↔ c * a ≤ b :=
begin
apply limit_rec_on a,
{ simp only [mul_zero, zero_le] },
{ intros, rw [succ_le, lt_div c0] },
{ simp only [mul_le_of_limit, limit_le, iff_self, forall_true_iff] {contextual := tt} }
end
theorem div_lt {a b c : ordinal} (b0 : b ≠ 0) :
a / b < c ↔ a < b * c :=
lt_iff_lt_of_le_iff_le $ le_div b0
theorem div_le_of_le_mul {a b c : ordinal} (h : a ≤ b * c) : a / b ≤ c :=
if b0 : b = 0 then by simp only [b0, div_zero, zero_le] else
(div_le b0).2 $ lt_of_le_of_lt h $
mul_lt_mul_of_pos_left (lt_succ_self _) (pos_iff_ne_zero.2 b0)
theorem mul_lt_of_lt_div {a b c : ordinal} : a < b / c → c * a < b :=
lt_imp_lt_of_le_imp_le div_le_of_le_mul
@[simp] theorem zero_div (a : ordinal) : 0 / a = 0 :=
le_zero.1 $ div_le_of_le_mul $ zero_le _
theorem mul_div_le (a b : ordinal) : b * (a / b) ≤ a :=
if b0 : b = 0 then by simp only [b0, zero_mul, zero_le] else (le_div b0).1 (le_refl _)
theorem mul_add_div (a) {b : ordinal} (b0 : b ≠ 0) (c) : (b * a + c) / b = a + c / b :=
begin
apply le_antisymm,
{ apply (div_le b0).2,
rw [mul_succ, mul_add, add_assoc, add_lt_add_iff_left],
apply lt_mul_div_add _ b0 },
{ rw [le_div b0, mul_add, add_le_add_iff_left],
apply mul_div_le }
end
theorem div_eq_zero_of_lt {a b : ordinal} (h : a < b) : a / b = 0 :=
by rw [← le_zero, div_le $ pos_iff_ne_zero.1 $ lt_of_le_of_lt (zero_le _) h];
simpa only [succ_zero, mul_one] using h
@[simp] theorem mul_div_cancel (a) {b : ordinal} (b0 : b ≠ 0) : b * a / b = a :=
by simpa only [add_zero, zero_div] using mul_add_div a b0 0
@[simp] theorem div_one (a : ordinal) : a / 1 = a :=
by simpa only [one_mul] using mul_div_cancel a ordinal.one_ne_zero
@[simp] theorem div_self {a : ordinal} (h : a ≠ 0) : a / a = 1 :=
by simpa only [mul_one] using mul_div_cancel 1 h
theorem mul_sub (a b c : ordinal) : a * (b - c) = a * b - a * c :=
if a0 : a = 0 then by simp only [a0, zero_mul, sub_self] else
eq_of_forall_ge_iff $ λ d,
by rw [sub_le, ← le_div a0, sub_le, ← le_div a0, mul_add_div _ a0]
theorem is_limit_add_iff {a b} : is_limit (a + b) ↔ is_limit b ∨ (b = 0 ∧ is_limit a) :=
begin
split; intro h,
{ by_cases h' : b = 0,
{ rw [h', add_zero] at h, right, exact ⟨h', h⟩ },
left, rw [←add_sub_cancel a b], apply sub_is_limit h,
suffices : a + 0 < a + b, simpa only [add_zero],
rwa [add_lt_add_iff_left, pos_iff_ne_zero] },
rcases h with h|⟨rfl, h⟩, exact add_is_limit a h, simpa only [add_zero]
end
/-- Divisibility is defined by right multiplication:
`a ∣ b` if there exists `c` such that `b = a * c`. -/
instance : has_dvd ordinal := ⟨λ a b, ∃ c, b = a * c⟩
theorem dvd_def {a b : ordinal} : a ∣ b ↔ ∃ c, b = a * c := iff.rfl
theorem dvd_mul (a b : ordinal) : a ∣ a * b := ⟨_, rfl⟩
theorem dvd_trans : ∀ {a b c : ordinal}, a ∣ b → b ∣ c → a ∣ c
| a _ _ ⟨b, rfl⟩ ⟨c, rfl⟩ := ⟨b * c, mul_assoc _ _ _⟩
theorem dvd_mul_of_dvd {a b : ordinal} (c) (h : a ∣ b) : a ∣ b * c :=
dvd_trans h (dvd_mul _ _)
theorem dvd_add_iff : ∀ {a b c : ordinal}, a ∣ b → (a ∣ b + c ↔ a ∣ c)
| a _ c ⟨b, rfl⟩ :=
⟨λ ⟨d, e⟩, ⟨d - b, by rw [mul_sub, ← e, add_sub_cancel]⟩,
λ ⟨d, e⟩, by rw [e, ← mul_add]; apply dvd_mul⟩
theorem dvd_add {a b c : ordinal} (h₁ : a ∣ b) : a ∣ c → a ∣ b + c :=
(dvd_add_iff h₁).2
theorem dvd_zero (a : ordinal) : a ∣ 0 := ⟨_, (mul_zero _).symm⟩
theorem zero_dvd {a : ordinal} : 0 ∣ a ↔ a = 0 :=
⟨λ ⟨h, e⟩, by simp only [e, zero_mul], λ e, e.symm ▸ dvd_zero _⟩
theorem one_dvd (a : ordinal) : 1 ∣ a := ⟨a, (one_mul _).symm⟩
theorem div_mul_cancel : ∀ {a b : ordinal}, a ≠ 0 → a ∣ b → a * (b / a) = b
| a _ a0 ⟨b, rfl⟩ := by rw [mul_div_cancel _ a0]
theorem le_of_dvd : ∀ {a b : ordinal}, b ≠ 0 → a ∣ b → a ≤ b
| a _ b0 ⟨b, rfl⟩ := by simpa only [mul_one] using mul_le_mul_left a
(one_le_iff_ne_zero.2 (λ h : b = 0, by simpa only [h, mul_zero] using b0))
theorem dvd_antisymm {a b : ordinal} (h₁ : a ∣ b) (h₂ : b ∣ a) : a = b :=
if a0 : a = 0 then by subst a; exact (zero_dvd.1 h₁).symm else
if b0 : b = 0 then by subst b; exact zero_dvd.1 h₂ else
le_antisymm (le_of_dvd b0 h₁) (le_of_dvd a0 h₂)
/-- `a % b` is the unique ordinal `o'` satisfying
`a = b * o + o'` with `o' < b`. -/
instance : has_mod ordinal := ⟨λ a b, a - b * (a / b)⟩
theorem mod_def (a b : ordinal) : a % b = a - b * (a / b) := rfl
@[simp] theorem mod_zero (a : ordinal) : a % 0 = a :=
by simp only [mod_def, div_zero, zero_mul, sub_zero]
theorem mod_eq_of_lt {a b : ordinal} (h : a < b) : a % b = a :=
by simp only [mod_def, div_eq_zero_of_lt h, mul_zero, sub_zero]
@[simp] theorem zero_mod (b : ordinal) : 0 % b = 0 :=
by simp only [mod_def, zero_div, mul_zero, sub_self]
theorem div_add_mod (a b : ordinal) : b * (a / b) + a % b = a :=
add_sub_cancel_of_le $ mul_div_le _ _
theorem mod_lt (a) {b : ordinal} (h : b ≠ 0) : a % b < b :=
(add_lt_add_iff_left (b * (a / b))).1 $
by rw div_add_mod; exact lt_mul_div_add a h
@[simp] theorem mod_self (a : ordinal) : a % a = 0 :=
if a0 : a = 0 then by simp only [a0, zero_mod] else
by simp only [mod_def, div_self a0, mul_one, sub_self]
@[simp] theorem mod_one (a : ordinal) : a % 1 = 0 :=
by simp only [mod_def, div_one, one_mul, sub_self]
end ordinal
namespace cardinal
open ordinal
/-- The ordinal corresponding to a cardinal `c` is the least ordinal
whose cardinal is `c`. -/
def ord (c : cardinal) : ordinal :=
begin
let ι := λ α, {r // is_well_order α r},
have : Π α, ι α := λ α, ⟨well_ordering_rel, by apply_instance⟩,
let F := λ α, ordinal.min ⟨this _⟩ (λ i:ι α, ⟦⟨α, i.1, i.2⟩⟧),
refine quot.lift_on c F _,
suffices : ∀ {α β}, α ≈ β → F α ≤ F β,
from λ α β h, le_antisymm (this h) (this (setoid.symm h)),
intros α β h, cases h with f, refine ordinal.le_min.2 (λ i, _),
haveI := @order_embedding.is_well_order _ _
(f ⁻¹'o i.1) _ ↑(order_iso.preimage f i.1) i.2,
rw ← show type (f ⁻¹'o i.1) = ⟦⟨β, i.1, i.2⟩⟧, from
quot.sound ⟨order_iso.preimage f i.1⟩,
exact ordinal.min_le (λ i:ι α, ⟦⟨α, i.1, i.2⟩⟧) ⟨_, _⟩
end
@[nolint def_lemma doc_blame] -- TODO: This should be a theorem but Lean fails to synthesize the placeholder
def ord_eq_min (α : Type u) : ord (mk α) =
@ordinal.min _ _ (λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) := rfl
theorem ord_eq (α) : ∃ (r : α → α → Prop) [wo : is_well_order α r],
ord (mk α) = @type α r wo :=
let ⟨⟨r, wo⟩, h⟩ := @ordinal.min_eq {r // is_well_order α r}
⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) in
⟨r, wo, h⟩
theorem ord_le_type (r : α → α → Prop) [is_well_order α r] : ord (mk α) ≤ ordinal.type r :=
@ordinal.min_le {r // is_well_order α r}
⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) ⟨r, _⟩
theorem ord_le {c o} : ord c ≤ o ↔ c ≤ o.card :=
quotient.induction_on c $ λ α, induction_on o $ λ β s _,
let ⟨r, _, e⟩ := ord_eq α in begin
resetI, simp only [mk_def, card_type], split; intro h,
{ rw e at h, exact let ⟨f⟩ := h in ⟨f.to_embedding⟩ },
{ cases h with f,
have g := order_embedding.preimage f s,
haveI := order_embedding.is_well_order g,
exact le_trans (ord_le_type _) (type_le'.2 ⟨g⟩) }
end
theorem lt_ord {c o} : o < ord c ↔ o.card < c :=
by rw [← not_le, ← not_le, ord_le]
@[simp] theorem card_ord (c) : (ord c).card = c :=
quotient.induction_on c $ λ α,
let ⟨r, _, e⟩ := ord_eq α in by simp only [mk_def, e, card_type]
theorem ord_card_le (o : ordinal) : o.card.ord ≤ o :=
ord_le.2 (le_refl _)
lemma lt_ord_succ_card (o : ordinal) : o < o.card.succ.ord :=
by { rw [lt_ord], apply cardinal.lt_succ_self }
@[simp] theorem ord_le_ord {c₁ c₂} : ord c₁ ≤ ord c₂ ↔ c₁ ≤ c₂ :=
by simp only [ord_le, card_ord]
@[simp] theorem ord_lt_ord {c₁ c₂} : ord c₁ < ord c₂ ↔ c₁ < c₂ :=
by simp only [lt_ord, card_ord]
@[simp] theorem ord_zero : ord 0 = 0 :=
le_antisymm (ord_le.2 $ zero_le _) (ordinal.zero_le _)
@[simp] theorem ord_nat (n : ℕ) : ord n = n :=
le_antisymm (ord_le.2 $ by simp only [card_nat]) $ begin
induction n with n IH,
{ apply ordinal.zero_le },
{ exact (@ordinal.succ_le n _).2 (lt_of_le_of_lt IH $
ord_lt_ord.2 $ nat_cast_lt.2 (nat.lt_succ_self n)) }
end
@[simp] theorem lift_ord (c) : (ord c).lift = ord (lift c) :=
eq_of_forall_ge_iff $ λ o, le_iff_le_iff_lt_iff_lt.2 $ begin
split; intro h,
{ rcases ordinal.lt_lift_iff.1 h with ⟨a, e, h⟩,
rwa [← e, lt_ord, ← lift_card, lift_lt, ← lt_ord] },
{ rw lt_ord at h,
rcases lift_down' (le_of_lt h) with ⟨o, rfl⟩,
rw [← lift_card, lift_lt] at h,
rwa [ordinal.lift_lt, lt_ord] }
end
lemma mk_ord_out (c : cardinal) : mk c.ord.out.α = c :=
by rw [←card_type c.ord.out.r, type_out, card_ord]
lemma card_typein_lt (r : α → α → Prop) [is_well_order α r] (x : α)
(h : ord (mk α) = type r) : card (typein r x) < mk α :=
by { rw [←ord_lt_ord, h], refine lt_of_le_of_lt (ord_card_le _) (typein_lt_type r x) }
lemma card_typein_out_lt (c : cardinal) (x : c.ord.out.α) : card (typein c.ord.out.r x) < c :=
by { convert card_typein_lt c.ord.out.r x _, rw [mk_ord_out], rw [type_out, mk_ord_out] }
lemma ord_injective : injective ord :=
by { intros c c' h, rw [←card_ord c, ←card_ord c', h] }
def ord.order_embedding : @order_embedding cardinal ordinal (<) (<) :=
order_embedding.of_monotone cardinal.ord $ λ a b, cardinal.ord_lt_ord.2
@[simp] theorem ord.order_embedding_coe :
(ord.order_embedding : cardinal → ordinal) = ord := rfl
/-- The cardinal `univ` is the cardinality of ordinal `univ`, or
equivalently the cardinal of `ordinal.{u}`, or `cardinal.{u}`,
as an element of `cardinal.{v}` (when `u < v`). -/
def univ := lift.{(u+1) v} (mk ordinal)
theorem univ_id : univ.{u (u+1)} = mk ordinal := lift_id _
@[simp] theorem lift_univ : lift.{_ w} univ.{u v} = univ.{u (max v w)} := lift_lift _
theorem univ_umax : univ.{u (max (u+1) v)} = univ.{u v} := congr_fun lift_umax _
theorem lift_lt_univ (c : cardinal) : lift.{u (u+1)} c < univ.{u (u+1)} :=
by simpa only [lift.principal_seg_coe, lift_ord, lift_succ, ord_le, succ_le] using le_of_lt
(lift.principal_seg.{u (u+1)}.lt_top (succ c).ord)
theorem lift_lt_univ' (c : cardinal) : lift.{u (max (u+1) v)} c < univ.{u v} :=
by simpa only [lift_lift, lift_univ, univ_umax] using
lift_lt.{_ (max (u+1) v)}.2 (lift_lt_univ c)
@[simp] theorem ord_univ : ord univ.{u v} = ordinal.univ.{u v} :=
le_antisymm (ord_card_le _) $ le_of_forall_lt $ λ o h,
lt_ord.2 begin
rcases lift.principal_seg.{u v}.down'.1
(by simpa only [lift.principal_seg_coe] using h) with ⟨o', rfl⟩,
simp only [lift.principal_seg_coe], rw [← lift_card],
apply lift_lt_univ'
end
theorem lt_univ {c} : c < univ.{u (u+1)} ↔ ∃ c', c = lift.{u (u+1)} c' :=
⟨λ h, begin
have := ord_lt_ord.2 h,
rw ord_univ at this,
cases lift.principal_seg.{u (u+1)}.down'.1
(by simpa only [lift.principal_seg_top]) with o e,
have := card_ord c,
rw [← e, lift.principal_seg_coe, ← lift_card] at this,
exact ⟨_, this.symm⟩
end, λ ⟨c', e⟩, e.symm ▸ lift_lt_univ _⟩
theorem lt_univ' {c} : c < univ.{u v} ↔ ∃ c', c = lift.{u (max (u+1) v)} c' :=
⟨λ h, let ⟨a, e, h'⟩ := lt_lift_iff.1 h in begin
rw [← univ_id] at h',
rcases lt_univ.{u}.1 h' with ⟨c', rfl⟩,
exact ⟨c', by simp only [e.symm, lift_lift]⟩
end, λ ⟨c', e⟩, e.symm ▸ lift_lt_univ' _⟩
end cardinal
namespace ordinal
@[simp] theorem card_univ : card univ = cardinal.univ := rfl
/-- The supremum of a family of ordinals -/
def sup {ι} (f : ι → ordinal) : ordinal :=
omin {c | ∀ i, f i ≤ c}
⟨(sup (cardinal.succ ∘ card ∘ f)).ord, λ i, le_of_lt $
cardinal.lt_ord.2 (lt_of_lt_of_le (cardinal.lt_succ_self _) (le_sup _ _))⟩
theorem le_sup {ι} (f : ι → ordinal) : ∀ i, f i ≤ sup f :=
omin_mem {c | ∀ i, f i ≤ c} _
theorem sup_le {ι} {f : ι → ordinal} {a} : sup f ≤ a ↔ ∀ i, f i ≤ a :=
⟨λ h i, le_trans (le_sup _ _) h, λ h, omin_le h⟩
theorem lt_sup {ι} {f : ι → ordinal} {a} : a < sup f ↔ ∃ i, a < f i :=
by simpa only [not_forall, not_le] using not_congr (@sup_le _ f a)
theorem is_normal.sup {f} (H : is_normal f)
{ι} {g : ι → ordinal} (h : nonempty ι) : f (sup g) = sup (f ∘ g) :=
eq_of_forall_ge_iff $ λ a,
by rw [sup_le, comp, H.le_set' (λ_:ι, true) g (let ⟨i⟩ := h in ⟨i, ⟨⟩⟩)];
intros; simp only [sup_le, true_implies_iff]
theorem sup_ord {ι} (f : ι → cardinal) : sup (λ i, (f i).ord) = (cardinal.sup f).ord :=
eq_of_forall_ge_iff $ λ a, by simp only [sup_le, cardinal.ord_le, cardinal.sup_le]
lemma sup_succ {ι} (f : ι → ordinal) : sup (λ i, succ (f i)) ≤ succ (sup f) :=
by { rw [ordinal.sup_le], intro i, rw ordinal.succ_le_succ, apply ordinal.le_sup }
lemma unbounded_range_of_sup_ge {α β : Type u} (r : α → α → Prop) [is_well_order α r] (f : β → α)
(h : sup.{u u} (typein r ∘ f) ≥ type r) : unbounded r (range f) :=
begin
apply (not_bounded_iff _).mp, rintro ⟨x, hx⟩, apply not_lt_of_ge h,
refine lt_of_le_of_lt _ (typein_lt_type r x), rw [sup_le], intro y,
apply le_of_lt, rw typein_lt_typein, apply hx, apply mem_range_self
end
/-- The supremum of a family of ordinals indexed by the set
of ordinals less than some `o : ordinal.{u}`.
(This is not a special case of `sup` over the subtype,
because `{a // a < o} : Type (u+1)` and `sup` only works over
families in `Type u`.) -/
def bsup (o : ordinal.{u}) : (Π a < o, ordinal.{max u v}) → ordinal.{max u v} :=
match o, o.out, o.out_eq with
| _, ⟨α, r, _⟩, rfl, f := by exactI sup (λ a, f (typein r a) (typein_lt_type _ _))
end
theorem bsup_le {o f a} : bsup.{u v} o f ≤ a ↔ ∀ i h, f i h ≤ a :=
match o, o.out, o.out_eq, f :
∀ o w (e : ⟦w⟧ = o) (f : Π (a : ordinal.{u}), a < o → ordinal.{(max u v)}),
bsup._match_1 o w e f ≤ a ↔ ∀ i h, f i h ≤ a with
| _, ⟨α, r, _⟩, rfl, f := by rw [bsup._match_1, sup_le]; exactI
⟨λ H i h, by simpa only [typein_enum] using H (enum r i h), λ H b, H _ _⟩
end
theorem bsup_type (r : α → α → Prop) [is_well_order α r] (f) :
bsup (type r) f = sup (λ a, f (typein r a) (typein_lt_type _ _)) :=
eq_of_forall_ge_iff $ λ o,
by rw [bsup_le, sup_le]; exact
⟨λ H b, H _ _, λ H i h, by simpa only [typein_enum] using H (enum r i h)⟩
theorem le_bsup {o} (f : Π a < o, ordinal) (i h) : f i h ≤ bsup o f :=
bsup_le.1 (le_refl _) _ _
theorem lt_bsup {o : ordinal} {f : Π a < o, ordinal}
(hf : ∀{a a'} (ha : a < o) (ha' : a' < o), a < a' → f a ha < f a' ha')
(ho : o.is_limit) (i h) : f i h < bsup o f :=
lt_of_lt_of_le (hf _ _ $ lt_succ_self i) (le_bsup f i.succ $ ho.2 _ h)
theorem bsup_id {o} (ho : is_limit o) : bsup.{u u} o (λ x _, x) = o :=
begin
apply le_antisymm, rw [bsup_le], intro i, apply le_of_lt,
rw [←not_lt], intro h, apply lt_irrefl (bsup.{u u} o (λ x _, x)),
apply lt_of_le_of_lt _ (lt_bsup _ ho _ h), refl, intros, assumption
end
theorem is_normal.bsup {f} (H : is_normal f)
{o : ordinal} : ∀ (g : Π a < o, ordinal) (h : o ≠ 0),
f (bsup o g) = bsup o (λ a h, f (g a h)) :=
induction_on o $ λ α r _ g h,
by resetI; rw [bsup_type,
H.sup (type_ne_zero_iff_nonempty.1 h), bsup_type]
theorem is_normal.bsup_eq {f} (H : is_normal f) {o : ordinal} (h : is_limit o) :
bsup.{u} o (λx _, f x) = f o :=
by { rw [←is_normal.bsup.{u u} H (λ x _, x) h.1, bsup_id h] }
/-- The ordinal exponential, defined by transfinite recursion. -/
def power (a b : ordinal) : ordinal :=
if a = 0 then 1 - b else
limit_rec_on b 1 (λ _ IH, IH * a) (λ b _, bsup.{u u} b)
instance : has_pow ordinal ordinal := ⟨power⟩
local infixr ^ := @pow ordinal ordinal ordinal.has_pow
theorem zero_power' (a : ordinal) : 0 ^ a = 1 - a :=
by simp only [pow, power, if_pos rfl]
@[simp] theorem zero_power {a : ordinal} (a0 : a ≠ 0) : 0 ^ a = 0 :=
by rwa [zero_power', sub_eq_zero_iff_le, one_le_iff_ne_zero]
@[simp] theorem power_zero (a : ordinal) : a ^ 0 = 1 :=
by by_cases a = 0; [simp only [pow, power, if_pos h, sub_zero],
simp only [pow, power, if_neg h, limit_rec_on_zero]]
@[simp] theorem power_succ (a b : ordinal) : a ^ succ b = a ^ b * a :=
if h : a = 0 then by subst a; simp only [zero_power (succ_ne_zero _), mul_zero]
else by simp only [pow, power, limit_rec_on_succ, if_neg h]
theorem power_limit {a b : ordinal} (a0 : a ≠ 0) (h : is_limit b) :
a ^ b = bsup.{u u} b (λ c _, a ^ c) :=
by simp only [pow, power, if_neg a0]; rw limit_rec_on_limit _ _ _ _ h; refl
theorem power_le_of_limit {a b c : ordinal} (a0 : a ≠ 0) (h : is_limit b) :
a ^ b ≤ c ↔ ∀ b' < b, a ^ b' ≤ c :=
by rw [power_limit a0 h, bsup_le]
theorem lt_power_of_limit {a b c : ordinal} (b0 : b ≠ 0) (h : is_limit c) :
a < b ^ c ↔ ∃ c' < c, a < b ^ c' :=
by rw [← not_iff_not, not_exists]; simp only [not_lt, power_le_of_limit b0 h, exists_prop, not_and]
@[simp] theorem power_one (a : ordinal) : a ^ 1 = a :=
by rw [← succ_zero, power_succ]; simp only [power_zero, one_mul]
@[simp] theorem one_power (a : ordinal) : 1 ^ a = 1 :=
begin
apply limit_rec_on a,
{ simp only [power_zero] },
{ intros _ ih, simp only [power_succ, ih, mul_one] },
refine λ b l IH, eq_of_forall_ge_iff (λ c, _),
rw [power_le_of_limit ordinal.one_ne_zero l],
exact ⟨λ H, by simpa only [power_zero] using H 0 l.pos,
λ H b' h, by rwa IH _ h⟩,
end
theorem power_pos {a : ordinal} (b)
(a0 : 0 < a) : 0 < a ^ b :=
begin
have h0 : 0 < a ^ 0, {simp only [power_zero, zero_lt_one]},
apply limit_rec_on b,
{ exact h0 },
{ intros b IH, rw [power_succ],
exact mul_pos IH a0 },
{ exact λ b l _, (lt_power_of_limit (pos_iff_ne_zero.1 a0) l).2
⟨0, l.pos, h0⟩ },
end
theorem power_ne_zero {a : ordinal} (b)
(a0 : a ≠ 0) : a ^ b ≠ 0 :=
pos_iff_ne_zero.1 $ power_pos b $ pos_iff_ne_zero.2 a0
theorem power_is_normal {a : ordinal} (h : 1 < a) : is_normal ((^) a) :=
have a0 : 0 < a, from lt_trans zero_lt_one h,
⟨λ b, by simpa only [mul_one, power_succ] using
(mul_lt_mul_iff_left (power_pos b a0)).2 h,
λ b l c, power_le_of_limit (ne_of_gt a0) l⟩
theorem power_lt_power_iff_right {a b c : ordinal}
(a1 : 1 < a) : a ^ b < a ^ c ↔ b < c :=
(power_is_normal a1).lt_iff
theorem power_le_power_iff_right {a b c : ordinal}
(a1 : 1 < a) : a ^ b ≤ a ^ c ↔ b ≤ c :=
(power_is_normal a1).le_iff
theorem power_right_inj {a b c : ordinal}
(a1 : 1 < a) : a ^ b = a ^ c ↔ b = c :=
(power_is_normal a1).inj
theorem power_is_limit {a b : ordinal}
(a1 : 1 < a) : is_limit b → is_limit (a ^ b) :=
(power_is_normal a1).is_limit
theorem power_is_limit_left {a b : ordinal}
(l : is_limit a) (hb : b ≠ 0) : is_limit (a ^ b) :=
begin
rcases zero_or_succ_or_limit b with e|⟨b,rfl⟩|l',
{ exact absurd e hb },
{ rw power_succ,
exact mul_is_limit (power_pos _ l.pos) l },
{ exact power_is_limit l.one_lt l' }
end
theorem power_le_power_right {a b c : ordinal}
(h₁ : 0 < a) (h₂ : b ≤ c) : a ^ b ≤ a ^ c :=
begin
cases lt_or_eq_of_le (one_le_iff_pos.2 h₁) with h₁ h₁,
{ exact (power_le_power_iff_right h₁).2 h₂ },
{ subst a, simp only [one_power] }
end
theorem power_le_power_left {a b : ordinal} (c)
(ab : a ≤ b) : a ^ c ≤ b ^ c :=
begin
by_cases a0 : a = 0,
{ subst a, by_cases c0 : c = 0,
{ subst c, simp only [power_zero] },
{ simp only [zero_power c0, zero_le] } },
{ apply limit_rec_on c,
{ simp only [power_zero] },
{ intros c IH, simpa only [power_succ] using mul_le_mul IH ab },
{ exact λ c l IH, (power_le_of_limit a0 l).2
(λ b' h, le_trans (IH _ h) (power_le_power_right
(lt_of_lt_of_le (pos_iff_ne_zero.2 a0) ab) (le_of_lt h))) } }
end
theorem le_power_self {a : ordinal} (b) (a1 : 1 < a) : b ≤ a ^ b :=
(power_is_normal a1).le_self _
theorem power_lt_power_left_of_succ {a b c : ordinal}
(ab : a < b) : a ^ succ c < b ^ succ c :=
by rw [power_succ, power_succ]; exact
lt_of_le_of_lt
(mul_le_mul_right _ $ power_le_power_left _ $ le_of_lt ab)
(mul_lt_mul_of_pos_left ab (power_pos _ (lt_of_le_of_lt (zero_le _) ab)))
theorem power_add (a b c : ordinal) : a ^ (b + c) = a ^ b * a ^ c :=
begin
by_cases a0 : a = 0,
{ subst a,
by_cases c0 : c = 0, {simp only [c0, add_zero, power_zero, mul_one]},
have : b+c ≠ 0 := ne_of_gt (lt_of_lt_of_le
(pos_iff_ne_zero.2 c0) (le_add_left _ _)),
simp only [zero_power c0, zero_power this, mul_zero] },
cases eq_or_lt_of_le (one_le_iff_ne_zero.2 a0) with a1 a1,
{ subst a1, simp only [one_power, mul_one] },
apply limit_rec_on c,
{ simp only [add_zero, power_zero, mul_one] },
{ intros c IH,
rw [add_succ, power_succ, IH, power_succ, mul_assoc] },
{ intros c l IH,
refine eq_of_forall_ge_iff (λ d, (((power_is_normal a1).trans
(add_is_normal b)).limit_le l).trans _),
simp only [IH] {contextual := tt},
exact (((mul_is_normal $ power_pos b (pos_iff_ne_zero.2 a0)).trans
(power_is_normal a1)).limit_le l).symm }
end
theorem power_dvd_power (a) {b c : ordinal}
(h : b ≤ c) : a ^ b ∣ a ^ c :=
by rw [← add_sub_cancel_of_le h, power_add]; apply dvd_mul
theorem power_dvd_power_iff {a b c : ordinal}
(a1 : 1 < a) : a ^ b ∣ a ^ c ↔ b ≤ c :=
⟨λ h, le_of_not_lt $ λ hn,
not_le_of_lt ((power_lt_power_iff_right a1).2 hn) $
le_of_dvd (power_ne_zero _ $ one_le_iff_ne_zero.1 $ le_of_lt a1) h,
power_dvd_power _⟩
theorem power_mul (a b c : ordinal) : a ^ (b * c) = (a ^ b) ^ c :=
begin
by_cases b0 : b = 0, {simp only [b0, zero_mul, power_zero, one_power]},
by_cases a0 : a = 0,
{ subst a,
by_cases c0 : c = 0, {simp only [c0, mul_zero, power_zero]},
simp only [zero_power b0, zero_power c0, zero_power (mul_ne_zero b0 c0)] },
cases eq_or_lt_of_le (one_le_iff_ne_zero.2 a0) with a1 a1,
{ subst a1, simp only [one_power] },
apply limit_rec_on c,
{ simp only [mul_zero, power_zero] },
{ intros c IH,
rw [mul_succ, power_add, IH, power_succ] },
{ intros c l IH,
refine eq_of_forall_ge_iff (λ d, (((power_is_normal a1).trans
(mul_is_normal (pos_iff_ne_zero.2 b0))).limit_le l).trans _),
simp only [IH] {contextual := tt},
exact (power_le_of_limit (power_ne_zero _ a0) l).symm }
end
/-- The ordinal logarithm is the solution `u` to the equation
`x = b ^ u * v + w` where `v < b` and `w < b`. -/
def log (b : ordinal) (x : ordinal) : ordinal :=
if h : 1 < b then pred $
omin {o | x < b^o} ⟨succ x, succ_le.1 (le_power_self _ h)⟩
else 0
@[simp] theorem log_not_one_lt {b : ordinal} (b1 : ¬ 1 < b) (x : ordinal) : log b x = 0 :=
by simp only [log, dif_neg b1]
theorem log_def {b : ordinal} (b1 : 1 < b) (x : ordinal) : log b x =
pred (omin {o | x < b^o} (log._proof_1 b x b1)) :=
by simp only [log, dif_pos b1]
@[simp] theorem log_zero (b : ordinal) : log b 0 = 0 :=
if b1 : 1 < b then
by rw [log_def b1, ← le_zero, pred_le];
apply omin_le; change 0<b^succ 0;
rw [succ_zero, power_one];
exact lt_trans zero_lt_one b1
else by simp only [log_not_one_lt b1]
theorem succ_log_def {b x : ordinal} (b1 : 1 < b) (x0 : 0 < x) : succ (log b x) =
omin {o | x < b^o} (log._proof_1 b x b1) :=
begin
let t := omin {o | x < b^o} (log._proof_1 b x b1),
have : x < b ^ t := omin_mem {o | x < b^o} _,
rcases zero_or_succ_or_limit t with h|h|h,
{ refine (not_lt_of_le (one_le_iff_pos.2 x0) _).elim,
simpa only [h, power_zero] },
{ rw [show log b x = pred t, from log_def b1 x,
succ_pred_iff_is_succ.2 h] },
{ rcases (lt_power_of_limit (ne_of_gt $ lt_trans zero_lt_one b1) h).1 this with ⟨a, h₁, h₂⟩,
exact (not_le_of_lt h₁).elim (le_omin.1 (le_refl t) a h₂) }
end
theorem lt_power_succ_log {b : ordinal} (b1 : 1 < b) (x : ordinal) :
x < b ^ succ (log b x) :=
begin
cases lt_or_eq_of_le (zero_le x) with x0 x0,
{ rw [succ_log_def b1 x0], exact omin_mem {o | x < b^o} _ },
{ subst x, apply power_pos _ (lt_trans zero_lt_one b1) }
end
theorem power_log_le (b) {x : ordinal} (x0 : 0 < x) :
b ^ log b x ≤ x :=
begin
by_cases b0 : b = 0,
{ rw [b0, zero_power'],
refine le_trans (sub_le_self _ _) (one_le_iff_pos.2 x0) },
cases lt_or_eq_of_le (one_le_iff_ne_zero.2 b0) with b1 b1,
{ refine le_of_not_lt (λ h, not_le_of_lt (lt_succ_self (log b x)) _),
have := @omin_le {o | x < b^o} _ _ h,
rwa ← succ_log_def b1 x0 at this },
{ rw [← b1, one_power], exact one_le_iff_pos.2 x0 }
end
theorem le_log {b x c : ordinal} (b1 : 1 < b) (x0 : 0 < x) :
c ≤ log b x ↔ b ^ c ≤ x :=
⟨λ h, le_trans ((power_le_power_iff_right b1).2 h) (power_log_le b x0),
λ h, le_of_not_lt $ λ hn,
not_le_of_lt (lt_power_succ_log b1 x) $
le_trans ((power_le_power_iff_right b1).2 (succ_le.2 hn)) h⟩
theorem log_lt {b x c : ordinal} (b1 : 1 < b) (x0 : 0 < x) :
log b x < c ↔ x < b ^ c :=
lt_iff_lt_of_le_iff_le (le_log b1 x0)
theorem log_le_log (b) {x y : ordinal} (xy : x ≤ y) :
log b x ≤ log b y :=
if x0 : x = 0 then by simp only [x0, log_zero, zero_le] else
have x0 : 0 < x, from pos_iff_ne_zero.2 x0,
if b1 : 1 < b then
(le_log b1 (lt_of_lt_of_le x0 xy)).2 $ le_trans (power_log_le _ x0) xy
else by simp only [log_not_one_lt b1, zero_le]
theorem log_le_self (b x : ordinal) : log b x ≤ x :=
if x0 : x = 0 then by simp only [x0, log_zero, zero_le] else
if b1 : 1 < b then
le_trans (le_power_self _ b1) (power_log_le b (pos_iff_ne_zero.2 x0))
else by simp only [log_not_one_lt b1, zero_le]
@[simp] theorem nat_cast_mul {m n : ℕ} : ((m * n : ℕ) : ordinal) = m * n :=
by induction n with n IH; [simp only [nat.cast_zero, nat.mul_zero, mul_zero],
rw [nat.mul_succ, nat.cast_add, IH, nat.cast_succ, mul_add_one]]
@[simp] theorem nat_cast_power {m n : ℕ} : ((pow m n : ℕ) : ordinal) = m ^ n :=
by induction n with n IH; [simp only [nat.pow_zero, nat.cast_zero, power_zero, nat.cast_one],
rw [nat.pow_succ, nat_cast_mul, IH, nat.cast_succ, ← succ_eq_add_one, power_succ]]
@[simp] theorem nat_cast_le {m n : ℕ} : (m : ordinal) ≤ n ↔ m ≤ n :=
by rw [← cardinal.ord_nat, ← cardinal.ord_nat,
cardinal.ord_le_ord, cardinal.nat_cast_le]
@[simp] theorem nat_cast_lt {m n : ℕ} : (m : ordinal) < n ↔ m < n :=
by simp only [lt_iff_le_not_le, nat_cast_le]
@[simp] theorem nat_cast_inj {m n : ℕ} : (m : ordinal) = n ↔ m = n :=
by simp only [le_antisymm_iff, nat_cast_le]
@[simp] theorem nat_cast_eq_zero {n : ℕ} : (n : ordinal) = 0 ↔ n = 0 :=
@nat_cast_inj n 0
theorem nat_cast_ne_zero {n : ℕ} : (n : ordinal) ≠ 0 ↔ n ≠ 0 :=
not_congr nat_cast_eq_zero
@[simp] theorem nat_cast_pos {n : ℕ} : (0 : ordinal) < n ↔ 0 < n :=
@nat_cast_lt 0 n
@[simp] theorem nat_cast_sub {m n : ℕ} : ((m - n : ℕ) : ordinal) = m - n :=
(_root_.le_total m n).elim
(λ h, by rw [nat.sub_eq_zero_iff_le.2 h, sub_eq_zero_iff_le.2 (nat_cast_le.2 h)]; refl)
(λ h, (add_left_cancel n).1 $ by rw [← nat.cast_add,
nat.add_sub_cancel' h, add_sub_cancel_of_le (nat_cast_le.2 h)])
@[simp] theorem nat_cast_div {m n : ℕ} : ((m / n : ℕ) : ordinal) = m / n :=
if n0 : n = 0 then by simp only [n0, nat.div_zero, nat.cast_zero, div_zero] else
have n0':_, from nat_cast_ne_zero.2 n0,
le_antisymm
(by rw [le_div n0', ← nat_cast_mul, nat_cast_le, mul_comm];
apply nat.div_mul_le_self)
(by rw [div_le n0', succ, ← nat.cast_succ, ← nat_cast_mul,
nat_cast_lt, mul_comm, ← nat.div_lt_iff_lt_mul _ _ (nat.pos_of_ne_zero n0)];
apply nat.lt_succ_self)
@[simp] theorem nat_cast_mod {m n : ℕ} : ((m % n : ℕ) : ordinal) = m % n :=
by rw [← add_left_cancel (n*(m/n)), div_add_mod, ← nat_cast_div, ← nat_cast_mul, ← nat.cast_add,
add_comm, nat.mod_add_div]
@[simp] theorem nat_le_card {o} {n : ℕ} : (n : cardinal) ≤ card o ↔ (n : ordinal) ≤ o :=
⟨λ h, by rwa [← cardinal.ord_le, cardinal.ord_nat] at h,
λ h, card_nat n ▸ card_le_card h⟩
@[simp] theorem nat_lt_card {o} {n : ℕ} : (n : cardinal) < card o ↔ (n : ordinal) < o :=
by rw [← succ_le, ← cardinal.succ_le, ← cardinal.nat_succ, nat_le_card]; refl
@[simp] theorem card_lt_nat {o} {n : ℕ} : card o < n ↔ o < n :=
lt_iff_lt_of_le_iff_le nat_le_card
@[simp] theorem card_le_nat {o} {n : ℕ} : card o ≤ n ↔ o ≤ n :=
le_iff_le_iff_lt_iff_lt.2 nat_lt_card
@[simp] theorem card_eq_nat {o} {n : ℕ} : card o = n ↔ o = n :=
by simp only [le_antisymm_iff, card_le_nat, nat_le_card]
@[simp] theorem type_fin (n : ℕ) : @type (fin n) (<) _ = n :=
by rw [← card_eq_nat, card_type, mk_fin]
@[simp] theorem lift_nat_cast (n : ℕ) : lift n = n :=
by induction n with n ih; [simp only [nat.cast_zero, lift_zero],
simp only [nat.cast_succ, lift_add, ih, lift_one]]
theorem lift_type_fin (n : ℕ) : lift (@type (fin n) (<) _) = n :=
by simp only [type_fin, lift_nat_cast]
theorem fintype_card (r : α → α → Prop) [is_well_order α r] [fintype α] : type r = fintype.card α :=
by rw [← card_eq_nat, card_type, fintype_card]
end ordinal
namespace cardinal
open ordinal
@[simp] theorem ord_omega : ord.{u} omega = ordinal.omega :=
le_antisymm (ord_le.2 $ le_refl _) $
le_of_forall_lt $ λ o h, begin
rcases ordinal.lt_lift_iff.1 h with ⟨o, rfl, h'⟩,
rw [lt_ord, ← lift_card, ← lift_omega.{0 u},
lift_lt, ← typein_enum (<) h'],
exact lt_omega_iff_fintype.2 ⟨set.fintype_lt_nat _⟩
end
@[simp] theorem add_one_of_omega_le {c} (h : omega ≤ c) : c + 1 = c :=
by rw [add_comm, ← card_ord c, ← card_one,
← card_add, one_add_of_omega_le];
rwa [← ord_omega, ord_le_ord]
end cardinal
namespace ordinal
theorem lt_omega {o : ordinal.{u}} : o < omega ↔ ∃ n : ℕ, o = n :=
by rw [← cardinal.ord_omega, cardinal.lt_ord, lt_omega]; simp only [card_eq_nat]
theorem nat_lt_omega (n : ℕ) : (n : ordinal) < omega :=
lt_omega.2 ⟨_, rfl⟩
theorem omega_pos : 0 < omega := nat_lt_omega 0
theorem omega_ne_zero : omega ≠ 0 := ne_of_gt omega_pos
theorem one_lt_omega : 1 < omega := by simpa only [nat.cast_one] using nat_lt_omega 1
theorem omega_is_limit : is_limit omega :=
⟨omega_ne_zero, λ o h,
let ⟨n, e⟩ := lt_omega.1 h in
by rw [e]; exact nat_lt_omega (n+1)⟩
theorem omega_le {o : ordinal.{u}} : omega ≤ o ↔ ∀ n : ℕ, (n : ordinal) ≤ o :=
⟨λ h n, le_trans (le_of_lt (nat_lt_omega _)) h,
λ H, le_of_forall_lt $ λ a h,
let ⟨n, e⟩ := lt_omega.1 h in
by rw [e, ← succ_le]; exact H (n+1)⟩
theorem nat_lt_limit {o} (h : is_limit o) : ∀ n : ℕ, (n : ordinal) < o
| 0 := lt_of_le_of_ne (zero_le o) h.1.symm
| (n+1) := h.2 _ (nat_lt_limit n)
theorem omega_le_of_is_limit {o} (h : is_limit o) : omega ≤ o :=
omega_le.2 $ λ n, le_of_lt $ nat_lt_limit h n
theorem add_omega {a : ordinal} (h : a < omega) : a + omega = omega :=
begin
rcases lt_omega.1 h with ⟨n, rfl⟩,
clear h, induction n with n IH,
{ rw [nat.cast_zero, zero_add] },
{ rw [nat.cast_succ, add_assoc, one_add_of_omega_le (le_refl _), IH] }
end
theorem add_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a + b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat.cast_add]; apply nat_lt_omega
end
theorem mul_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a * b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat_cast_mul]; apply nat_lt_omega
end
theorem is_limit_iff_omega_dvd {a : ordinal} : is_limit a ↔ a ≠ 0 ∧ omega ∣ a :=
begin
refine ⟨λ l, ⟨l.1, ⟨a / omega, le_antisymm _ (mul_div_le _ _)⟩⟩, λ h, _⟩,
{ refine (limit_le l).2 (λ x hx, le_of_lt _),
rw [← div_lt omega_ne_zero, ← succ_le, le_div omega_ne_zero,
mul_succ, add_le_of_limit omega_is_limit],
intros b hb,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
exact le_trans (add_le_add_right (mul_div_le _ _) _)
(le_of_lt $ lt_sub.1 $ nat_lt_limit (sub_is_limit l hx) _) },
{ rcases h with ⟨a0, b, rfl⟩,
refine mul_is_limit_left omega_is_limit
(pos_iff_ne_zero.2 $ mt _ a0),
intro e, simp only [e, mul_zero] }
end
local infixr ^ := @pow ordinal ordinal ordinal.has_pow
theorem power_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a ^ b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat_cast_power]; apply nat_lt_omega
end
theorem add_omega_power {a b : ordinal} (h : a < omega ^ b) : a + omega ^ b = omega ^ b :=
begin
refine le_antisymm _ (le_add_left _ _),
revert h, apply limit_rec_on b,
{ intro h, rw [power_zero, ← succ_zero, lt_succ, le_zero] at h,
rw [h, zero_add] },
{ intros b _ h, rw [power_succ] at h,
rcases (lt_mul_of_limit omega_is_limit).1 h with ⟨x, xo, ax⟩,
refine le_trans (add_le_add_right (le_of_lt ax) _) _,
rw [power_succ, ← mul_add, add_omega xo] },
{ intros b l IH h, rcases (lt_power_of_limit omega_ne_zero l).1 h with ⟨x, xb, ax⟩,
refine (((add_is_normal a).trans (power_is_normal one_lt_omega))
.limit_le l).2 (λ y yb, _),
let z := max x y,
have := IH z (max_lt xb yb)
(lt_of_lt_of_le ax $ power_le_power_right omega_pos (le_max_left _ _)),
exact le_trans (add_le_add_left (power_le_power_right omega_pos (le_max_right _ _)) _)
(le_trans this (power_le_power_right omega_pos $ le_of_lt $ max_lt xb yb)) }
end
theorem add_lt_omega_power {a b c : ordinal} (h₁ : a < omega ^ c) (h₂ : b < omega ^ c) :
a + b < omega ^ c :=
by rwa [← add_omega_power h₁, add_lt_add_iff_left]
theorem add_absorp {a b c : ordinal} (h₁ : a < omega ^ b) (h₂ : omega ^ b ≤ c) : a + c = c :=
by rw [← add_sub_cancel_of_le h₂, ← add_assoc, add_omega_power h₁]
theorem add_absorp_iff {o : ordinal} (o0 : o > 0) : (∀ a < o, a + o = o) ↔ ∃ a, o = omega ^ a :=
⟨λ H, ⟨log omega o, begin
refine ((lt_or_eq_of_le (power_log_le _ o0))
.resolve_left $ λ h, _).symm,
have := H _ h,
have := lt_power_succ_log one_lt_omega o,
rw [power_succ, lt_mul_of_limit omega_is_limit] at this,
rcases this with ⟨a, ao, h'⟩,
rcases lt_omega.1 ao with ⟨n, rfl⟩, clear ao,
revert h', apply not_lt_of_le,
suffices e : omega ^ log omega o * ↑n + o = o,
{ simpa only [e] using le_add_right (omega ^ log omega o * ↑n) o },
induction n with n IH, {simp only [nat.cast_zero, mul_zero, zero_add]},
simp only [nat.cast_succ, mul_add_one, add_assoc, this, IH]
end⟩,
λ ⟨b, e⟩, e.symm ▸ λ a, add_omega_power⟩
theorem add_mul_limit_aux {a b c : ordinal} (ba : b + a = a)
(l : is_limit c)
(IH : ∀ c' < c, (a + b) * succ c' = a * succ c' + b) :
(a + b) * c = a * c :=
le_antisymm
((mul_le_of_limit l).2 $ λ c' h, begin
apply le_trans (mul_le_mul_left _ (le_of_lt $ lt_succ_self _)),
rw IH _ h,
apply le_trans (add_le_add_left _ _),
{ rw ← mul_succ, exact mul_le_mul_left _ (succ_le.2 $ l.2 _ h) },
{ rw ← ba, exact le_add_right _ _ }
end)
(mul_le_mul_right _ (le_add_right _ _))
theorem add_mul_succ {a b : ordinal} (c) (ba : b + a = a) :
(a + b) * succ c = a * succ c + b :=
begin
apply limit_rec_on c,
{ simp only [succ_zero, mul_one] },
{ intros c IH,
rw [mul_succ, IH, ← add_assoc, add_assoc _ b, ba, ← mul_succ] },
{ intros c l IH,
have := add_mul_limit_aux ba l IH,
rw [mul_succ, add_mul_limit_aux ba l IH, mul_succ, add_assoc] }
end
theorem add_mul_limit {a b c : ordinal} (ba : b + a = a)
(l : is_limit c) : (a + b) * c = a * c :=
add_mul_limit_aux ba l (λ c' _, add_mul_succ c' ba)
theorem mul_omega {a : ordinal} (a0 : 0 < a) (ha : a < omega) : a * omega = omega :=
le_antisymm
((mul_le_of_limit omega_is_limit).2 $ λ b hb, le_of_lt (mul_lt_omega ha hb))
(by simpa only [one_mul] using mul_le_mul_right omega (one_le_iff_pos.2 a0))
theorem mul_lt_omega_power {a b c : ordinal}
(c0 : 0 < c) (ha : a < omega ^ c) (hb : b < omega) : a * b < omega ^ c :=
if b0 : b = 0 then by simp only [b0, mul_zero, power_pos _ omega_pos] else begin
rcases zero_or_succ_or_limit c with rfl|⟨c,rfl⟩|l,
{ exact (lt_irrefl _).elim c0 },
{ rw power_succ at ha,
rcases ((mul_is_normal $ power_pos _ omega_pos).limit_lt
omega_is_limit).1 ha with ⟨n, hn, an⟩,
refine lt_of_le_of_lt (mul_le_mul_right _ (le_of_lt an)) _,
rw [power_succ, mul_assoc, mul_lt_mul_iff_left (power_pos _ omega_pos)],
exact mul_lt_omega hn hb },
{ rcases ((power_is_normal one_lt_omega).limit_lt l).1 ha with ⟨x, hx, ax⟩,
refine lt_of_le_of_lt (mul_le_mul (le_of_lt ax) (le_of_lt hb)) _,
rw [← power_succ, power_lt_power_iff_right one_lt_omega],
exact l.2 _ hx }
end
theorem mul_omega_dvd {a : ordinal}
(a0 : 0 < a) (ha : a < omega) : ∀ {b}, omega ∣ b → a * b = b
| _ ⟨b, rfl⟩ := by rw [← mul_assoc, mul_omega a0 ha]
theorem mul_omega_power_power {a b : ordinal} (a0 : 0 < a) (h : a < omega ^ omega ^ b) :
a * omega ^ omega ^ b = omega ^ omega ^ b :=
begin
by_cases b0 : b = 0, {rw [b0, power_zero, power_one] at h ⊢, exact mul_omega a0 h},
refine le_antisymm _ (by simpa only [one_mul] using mul_le_mul_right (omega^omega^b) (one_le_iff_pos.2 a0)),
rcases (lt_power_of_limit omega_ne_zero (power_is_limit_left omega_is_limit b0)).1 h
with ⟨x, xb, ax⟩,
refine le_trans (mul_le_mul_right _ (le_of_lt ax)) _,
rw [← power_add, add_omega_power xb]
end
theorem power_omega {a : ordinal} (a1 : 1 < a) (h : a < omega) : a ^ omega = omega :=
le_antisymm
((power_le_of_limit (one_le_iff_ne_zero.1 $ le_of_lt a1) omega_is_limit).2
(λ b hb, le_of_lt (power_lt_omega h hb)))
(le_power_self _ a1)
theorem CNF_aux {b o : ordinal} (b0 : b ≠ 0) (o0 : o ≠ 0) :
o % b ^ log b o < o :=
lt_of_lt_of_le
(mod_lt _ $ power_ne_zero _ b0)
(power_log_le _ $ pos_iff_ne_zero.2 o0)
@[elab_as_eliminator] noncomputable def CNF_rec {b : ordinal} (b0 : b ≠ 0)
{C : ordinal → Sort*}
(H0 : C 0)
(H : ∀ o, o ≠ 0 → o % b ^ log b o < o → C (o % b ^ log b o) → C o)
: ∀ o, C o
| o :=
if o0 : o = 0 then by rw o0; exact H0 else
have _, from CNF_aux b0 o0,
H o o0 this (CNF_rec (o % b ^ log b o))
using_well_founded {dec_tac := `[assumption]}
@[simp] theorem CNF_rec_zero {b} (b0) {C H0 H} : @CNF_rec b b0 C H0 H 0 = H0 :=
by rw [CNF_rec, dif_pos rfl]; refl
@[simp] theorem CNF_rec_ne_zero {b} (b0) {C H0 H o} (o0) :
@CNF_rec b b0 C H0 H o = H o o0 (CNF_aux b0 o0) (@CNF_rec b b0 C H0 H _) :=
by rw [CNF_rec, dif_neg o0]
/-- The Cantor normal form of an ordinal is the list of coefficients
in the base-`b` expansion of `o`.
CNF b (b ^ u₁ * v₁ + b ^ u₂ * v₂) = [(u₁, v₁), (u₂, v₂)] -/
def CNF (b := omega) (o : ordinal) : list (ordinal × ordinal) :=
if b0 : b = 0 then [] else
CNF_rec b0 [] (λ o o0 h IH, (log b o, o / b ^ log b o) :: IH) o
@[simp] theorem zero_CNF (o) : CNF 0 o = [] :=
dif_pos rfl
@[simp] theorem CNF_zero (b) : CNF b 0 = [] :=
if b0 : b = 0 then dif_pos b0 else
(dif_neg b0).trans $ CNF_rec_zero _
theorem CNF_ne_zero {b o : ordinal} (b0 : b ≠ 0) (o0 : o ≠ 0) :
CNF b o = (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o) :=
by unfold CNF; rw [dif_neg b0, dif_neg b0, CNF_rec_ne_zero b0 o0]
theorem one_CNF {o : ordinal} (o0 : o ≠ 0) :
CNF 1 o = [(0, o)] :=
by rw [CNF_ne_zero ordinal.one_ne_zero o0, log_not_one_lt (lt_irrefl _), power_zero, mod_one,
CNF_zero, div_one]
theorem CNF_foldr {b : ordinal} (b0 : b ≠ 0) (o) :
(CNF b o).foldr (λ p r, b ^ p.1 * p.2 + r) 0 = o :=
CNF_rec b0 (by rw CNF_zero; refl)
(λ o o0 h IH, by rw [CNF_ne_zero b0 o0, list.foldr_cons, IH, div_add_mod]) o
theorem CNF_pairwise_aux (b := omega) (o) :
(∀ p ∈ CNF b o, prod.fst p ≤ log b o) ∧
(CNF b o).pairwise (λ p q, q.1 < p.1) :=
begin
by_cases b0 : b = 0,
{ simp only [b0, zero_CNF, list.pairwise.nil, and_true], exact λ _, false.elim },
cases lt_or_eq_of_le (one_le_iff_ne_zero.2 b0) with b1 b1,
{ refine CNF_rec b0 _ _ o,
{ simp only [CNF_zero, list.pairwise.nil, and_true], exact λ _, false.elim },
intros o o0 H IH, cases IH with IH₁ IH₂,
simp only [CNF_ne_zero b0 o0, list.forall_mem_cons, list.pairwise_cons, IH₂, and_true],
refine ⟨⟨le_refl _, λ p m, _⟩, λ p m, _⟩,
{ exact le_trans (IH₁ p m) (log_le_log _ $ le_of_lt H) },
{ refine lt_of_le_of_lt (IH₁ p m) ((log_lt b1 _).2 _),
{ rw pos_iff_ne_zero, intro e,
rw e at m, simpa only [CNF_zero] using m },
{ exact mod_lt _ (power_ne_zero _ b0) } } },
{ by_cases o0 : o = 0,
{ simp only [o0, CNF_zero, list.pairwise.nil, and_true], exact λ _, false.elim },
rw [← b1, one_CNF o0],
simp only [list.mem_singleton, log_not_one_lt (lt_irrefl _), forall_eq, le_refl, true_and, list.pairwise_singleton] }
end
theorem CNF_pairwise (b := omega) (o) :
(CNF b o).pairwise (λ p q, prod.fst q < p.1) :=
(CNF_pairwise_aux _ _).2
theorem CNF_fst_le_log (b := omega) (o) :
∀ p ∈ CNF b o, prod.fst p ≤ log b o :=
(CNF_pairwise_aux _ _).1
theorem CNF_fst_le (b := omega) (o) (p ∈ CNF b o) : prod.fst p ≤ o :=
le_trans (CNF_fst_le_log _ _ p H) (log_le_self _ _)
theorem CNF_snd_lt {b : ordinal} (b1 : 1 < b) (o) :
∀ p ∈ CNF b o, prod.snd p < b :=
begin
have b0 := ne_of_gt (lt_trans zero_lt_one b1),
refine CNF_rec b0 (λ _, by rw [CNF_zero]; exact false.elim) _ o,
intros o o0 H IH,
simp only [CNF_ne_zero b0 o0, list.mem_cons_iff, list.forall_mem_cons', iff_true_intro IH, and_true],
rw [div_lt (power_ne_zero _ b0), ← power_succ],
exact lt_power_succ_log b1 _,
end
theorem CNF_sorted (b := omega) (o) :
((CNF b o).map prod.fst).sorted (>) :=
by rw [list.sorted, list.pairwise_map]; exact CNF_pairwise b o
/-- The next fixed point function, the least fixed point of the
normal function `f` above `a`. -/
def nfp (f : ordinal → ordinal) (a : ordinal) :=
sup (λ n : ℕ, f^[n] a)
theorem iterate_le_nfp (f a n) : f^[n] a ≤ nfp f a :=
le_sup _ n
theorem le_nfp_self (f a) : a ≤ nfp f a :=
iterate_le_nfp f a 0
theorem is_normal.lt_nfp {f} (H : is_normal f) {a b} :
f b < nfp f a ↔ b < nfp f a :=
lt_sup.trans $ iff.trans
(by exact
⟨λ ⟨n, h⟩, ⟨n, lt_of_le_of_lt (H.le_self _) h⟩,
λ ⟨n, h⟩, ⟨n+1, by rw iterate_succ'; exact H.lt_iff.2 h⟩⟩)
lt_sup.symm
theorem is_normal.nfp_le {f} (H : is_normal f) {a b} :
nfp f a ≤ f b ↔ nfp f a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 H.lt_nfp
theorem is_normal.nfp_le_fp {f} (H : is_normal f) {a b}
(ab : a ≤ b) (h : f b ≤ b) : nfp f a ≤ b :=
sup_le.2 $ λ i, begin
induction i with i IH generalizing a, {exact ab},
exact IH (le_trans (H.le_iff.2 ab) h),
end
theorem is_normal.nfp_fp {f} (H : is_normal f) (a) : f (nfp f a) = nfp f a :=
begin
refine le_antisymm _ (H.le_self _),
cases le_or_lt (f a) a with aa aa,
{ rwa le_antisymm (H.nfp_le_fp (le_refl _) aa) (le_nfp_self _ _) },
rcases zero_or_succ_or_limit (nfp f a) with e|⟨b, e⟩|l,
{ refine @le_trans _ _ _ (f a) _ (H.le_iff.2 _) (iterate_le_nfp f a 1),
simp only [e, zero_le] },
{ have : f b < nfp f a := H.lt_nfp.2 (by simp only [e, lt_succ_self]),
rw [e, lt_succ] at this,
have ab : a ≤ b,
{ rw [← lt_succ, ← e],
exact lt_of_lt_of_le aa (iterate_le_nfp f a 1) },
refine le_trans (H.le_iff.2 (H.nfp_le_fp ab this))
(le_trans this (le_of_lt _)),
simp only [e, lt_succ_self] },
{ exact (H.2 _ l _).2 (λ b h, le_of_lt (H.lt_nfp.2 h)) }
end
theorem is_normal.le_nfp {f} (H : is_normal f) {a b} :
f b ≤ nfp f a ↔ b ≤ nfp f a :=
⟨le_trans (H.le_self _), λ h,
by simpa only [H.nfp_fp] using H.le_iff.2 h⟩
theorem nfp_eq_self {f : ordinal → ordinal} {a} (h : f a = a) : nfp f a = a :=
le_antisymm (sup_le.mpr $ λ i, by rw [iterate_fixed h]) (le_nfp_self f a)
/-- The derivative of a normal function `f` is
the sequence of fixed points of `f`. -/
def deriv (f : ordinal → ordinal) (o : ordinal) : ordinal :=
limit_rec_on o (nfp f 0)
(λ a IH, nfp f (succ IH))
(λ a l, bsup.{u u} a)
@[simp] theorem deriv_zero (f) : deriv f 0 = nfp f 0 := limit_rec_on_zero _ _ _
@[simp] theorem deriv_succ (f o) : deriv f (succ o) = nfp f (succ (deriv f o)) :=
limit_rec_on_succ _ _ _ _
theorem deriv_limit (f) {o} : is_limit o →
deriv f o = bsup.{u u} o (λ a _, deriv f a) :=
limit_rec_on_limit _ _ _ _
theorem deriv_is_normal (f) : is_normal (deriv f) :=
⟨λ o, by rw [deriv_succ, ← succ_le]; apply le_nfp_self,
λ o l a, by rw [deriv_limit _ l, bsup_le]⟩
theorem is_normal.deriv_fp {f} (H : is_normal f) (o) : f (deriv.{u} f o) = deriv f o :=
begin
apply limit_rec_on o,
{ rw [deriv_zero, H.nfp_fp] },
{ intros o ih, rw [deriv_succ, H.nfp_fp] },
intros o l IH,
rw [deriv_limit _ l, is_normal.bsup.{u u u} H _ l.1],
refine eq_of_forall_ge_iff (λ c, _),
simp only [bsup_le, IH] {contextual:=tt}
end
theorem is_normal.fp_iff_deriv {f} (H : is_normal f)
{a} : f a ≤ a ↔ ∃ o, a = deriv f o :=
⟨λ ha, begin
suffices : ∀ o (_:a ≤ deriv f o), ∃ o, a = deriv f o,
from this a ((deriv_is_normal _).le_self _),
intro o, apply limit_rec_on o,
{ intros h₁,
refine ⟨0, le_antisymm h₁ _⟩,
rw deriv_zero,
exact H.nfp_le_fp (zero_le _) ha },
{ intros o IH h₁,
cases le_or_lt a (deriv f o), {exact IH h},
refine ⟨succ o, le_antisymm h₁ _⟩,
rw deriv_succ,
exact H.nfp_le_fp (succ_le.2 h) ha },
{ intros o l IH h₁,
cases eq_or_lt_of_le h₁, {exact ⟨_, h⟩},
rw [deriv_limit _ l, ← not_le, bsup_le, not_ball] at h,
exact let ⟨o', h, hl⟩ := h in IH o' h (le_of_not_le hl) }
end, λ ⟨o, e⟩, e.symm ▸ le_of_eq (H.deriv_fp _)⟩
end ordinal
namespace cardinal
section using_ordinals
open ordinal
theorem ord_is_limit {c} (co : omega ≤ c) : (ord c).is_limit :=
begin
refine ⟨λ h, omega_ne_zero _, λ a, lt_imp_lt_of_le_imp_le _⟩,
{ rw [← ordinal.le_zero, ord_le] at h,
simpa only [card_zero, le_zero] using le_trans co h },
{ intro h, rw [ord_le] at h ⊢,
rwa [← @add_one_of_omega_le (card a), ← card_succ],
rw [← ord_le, ← le_succ_of_is_limit, ord_le],
{ exact le_trans co h },
{ rw ord_omega, exact omega_is_limit } }
end
def aleph_idx.initial_seg : @initial_seg cardinal ordinal (<) (<) :=
@order_embedding.collapse cardinal ordinal (<) (<) _ cardinal.ord.order_embedding
/-- The `aleph'` index function, which gives the ordinal index of a cardinal.
(The `aleph'` part is because unlike `aleph` this counts also the
finite stages. So `aleph_idx n = n`, `aleph_idx ω = ω`,
`aleph_idx ℵ₁ = ω + 1` and so on.) -/
def aleph_idx : cardinal → ordinal := aleph_idx.initial_seg
@[simp] theorem aleph_idx.initial_seg_coe :
(aleph_idx.initial_seg : cardinal → ordinal) = aleph_idx := rfl
@[simp] theorem aleph_idx_lt {a b} : aleph_idx a < aleph_idx b ↔ a < b :=
aleph_idx.initial_seg.to_order_embedding.ord.symm
@[simp] theorem aleph_idx_le {a b} : aleph_idx a ≤ aleph_idx b ↔ a ≤ b :=
by rw [← not_lt, ← not_lt, aleph_idx_lt]
theorem aleph_idx.init {a b} : b < aleph_idx a → ∃ c, aleph_idx c = b :=
aleph_idx.initial_seg.init _ _
def aleph_idx.order_iso : @order_iso cardinal.{u} ordinal.{u} (<) (<) :=
@order_iso.of_surjective cardinal.{u} ordinal.{u} (<) (<) aleph_idx.initial_seg.{u} $
(initial_seg.eq_or_principal aleph_idx.initial_seg.{u}).resolve_right $
λ ⟨o, e⟩, begin
have : ∀ c, aleph_idx c < o := λ c, (e _).2 ⟨_, rfl⟩,
refine ordinal.induction_on o _ this, introsI α r _ h,
let s := sup.{u u} (λ a:α, inv_fun aleph_idx (ordinal.typein r a)),
apply not_le_of_gt (lt_succ_self s),
have I : injective aleph_idx := aleph_idx.initial_seg.to_embedding.injective,
simpa only [typein_enum, left_inverse_inv_fun I (succ s)] using
le_sup.{u u} (λ a, inv_fun aleph_idx (ordinal.typein r a))
(ordinal.enum r _ (h (succ s))),
end
@[simp] theorem aleph_idx.order_iso_coe :
(aleph_idx.order_iso : cardinal → ordinal) = aleph_idx := rfl
@[simp] theorem type_cardinal : @ordinal.type cardinal (<) _ = ordinal.univ.{u (u+1)} :=
by rw ordinal.univ_id; exact quotient.sound ⟨aleph_idx.order_iso⟩
@[simp] theorem mk_cardinal : mk cardinal = univ.{u (u+1)} :=
by simpa only [card_type, card_univ] using congr_arg card type_cardinal
def aleph'.order_iso := cardinal.aleph_idx.order_iso.symm
/-- The `aleph'` function gives the cardinals listed by their ordinal
index, and is the inverse of `aleph_idx`.
`aleph' n = n`, `aleph' ω = ω`, `aleph' (ω + 1) = ℵ₁, etc. -/
def aleph' : ordinal → cardinal := aleph'.order_iso
@[simp] theorem aleph'.order_iso_coe :
(aleph'.order_iso : ordinal → cardinal) = aleph' := rfl
@[simp] theorem aleph'_lt {o₁ o₂ : ordinal.{u}} : aleph' o₁ < aleph' o₂ ↔ o₁ < o₂ :=
aleph'.order_iso.ord.symm
@[simp] theorem aleph'_le {o₁ o₂ : ordinal.{u}} : aleph' o₁ ≤ aleph' o₂ ↔ o₁ ≤ o₂ :=
le_iff_le_iff_lt_iff_lt.2 aleph'_lt
@[simp] theorem aleph'_aleph_idx (c : cardinal.{u}) : aleph' c.aleph_idx = c :=
cardinal.aleph_idx.order_iso.to_equiv.symm_apply_apply c
@[simp] theorem aleph_idx_aleph' (o : ordinal.{u}) : (aleph' o).aleph_idx = o :=
cardinal.aleph_idx.order_iso.to_equiv.apply_symm_apply o
@[simp] theorem aleph'_zero : aleph' 0 = 0 :=
by rw [← le_zero, ← aleph'_aleph_idx 0, aleph'_le];
apply ordinal.zero_le
@[simp] theorem aleph'_succ {o : ordinal.{u}} : aleph' o.succ = (aleph' o).succ :=
le_antisymm
(cardinal.aleph_idx_le.1 $
by rw [aleph_idx_aleph', ordinal.succ_le, ← aleph'_lt, aleph'_aleph_idx];
apply cardinal.lt_succ_self)
(cardinal.succ_le.2 $ aleph'_lt.2 $ ordinal.lt_succ_self _)
@[simp] theorem aleph'_nat : ∀ n : ℕ, aleph' n = n
| 0 := aleph'_zero
| (n+1) := show aleph' (ordinal.succ n) = n.succ,
by rw [aleph'_succ, aleph'_nat, nat_succ]
theorem aleph'_le_of_limit {o : ordinal.{u}} (l : o.is_limit) {c} :
aleph' o ≤ c ↔ ∀ o' < o, aleph' o' ≤ c :=
⟨λ h o' h', le_trans (aleph'_le.2 $ le_of_lt h') h,
λ h, begin
rw [← aleph'_aleph_idx c, aleph'_le, ordinal.limit_le l],
intros x h',
rw [← aleph'_le, aleph'_aleph_idx],
exact h _ h'
end⟩
@[simp] theorem aleph'_omega : aleph' ordinal.omega = omega :=
eq_of_forall_ge_iff $ λ c, begin
simp only [aleph'_le_of_limit omega_is_limit, ordinal.lt_omega, exists_imp_distrib, omega_le],
exact forall_swap.trans (forall_congr $ λ n, by simp only [forall_eq, aleph'_nat]),
end
/-- aleph' and aleph_idx form an equivalence between `ordinal` and `cardinal` -/
@[simp] def aleph'_equiv : ordinal ≃ cardinal :=
⟨aleph', aleph_idx, aleph_idx_aleph', aleph'_aleph_idx⟩
/-- The `aleph` function gives the infinite cardinals listed by their
ordinal index. `aleph 0 = ω`, `aleph 1 = succ ω` is the first
uncountable cardinal, and so on. -/
def aleph (o : ordinal) : cardinal := aleph' (ordinal.omega + o)
@[simp] theorem aleph_lt {o₁ o₂ : ordinal.{u}} : aleph o₁ < aleph o₂ ↔ o₁ < o₂ :=
aleph'_lt.trans (ordinal.add_lt_add_iff_left _)
@[simp] theorem aleph_le {o₁ o₂ : ordinal.{u}} : aleph o₁ ≤ aleph o₂ ↔ o₁ ≤ o₂ :=
le_iff_le_iff_lt_iff_lt.2 aleph_lt
@[simp] theorem aleph_succ {o : ordinal.{u}} : aleph o.succ = (aleph o).succ :=
by rw [aleph, ordinal.add_succ, aleph'_succ]; refl
@[simp] theorem aleph_zero : aleph 0 = omega :=
by simp only [aleph, add_zero, aleph'_omega]
theorem omega_le_aleph' {o : ordinal} : omega ≤ aleph' o ↔ ordinal.omega ≤ o :=
by rw [← aleph'_omega, aleph'_le]
theorem omega_le_aleph (o : ordinal) : omega ≤ aleph o :=
by rw [aleph, omega_le_aleph']; apply ordinal.le_add_right
theorem ord_aleph_is_limit (o : ordinal) : is_limit (aleph o).ord :=
ord_is_limit $ omega_le_aleph _
theorem exists_aleph {c : cardinal} : omega ≤ c ↔ ∃ o, c = aleph o :=
⟨λ h, ⟨aleph_idx c - ordinal.omega,
by rw [aleph, ordinal.add_sub_cancel_of_le, aleph'_aleph_idx];
rwa [← omega_le_aleph', aleph'_aleph_idx]⟩,
λ ⟨o, e⟩, e.symm ▸ omega_le_aleph _⟩
theorem aleph'_is_normal : is_normal (ord ∘ aleph') :=
⟨λ o, ord_lt_ord.2 $ aleph'_lt.2 $ ordinal.lt_succ_self _,
λ o l a, by simp only [ord_le, aleph'_le_of_limit l]⟩
theorem aleph_is_normal : is_normal (ord ∘ aleph) :=
aleph'_is_normal.trans $ add_is_normal ordinal.omega
/- properties of mul -/
theorem mul_eq_self {c : cardinal} (h : omega ≤ c) : c * c = c :=
begin
refine le_antisymm _
(by simpa only [mul_one] using mul_le_mul_left c (le_trans (le_of_lt one_lt_omega) h)),
refine acc.rec_on (cardinal.wf.apply c) (λ c _,
quotient.induction_on c $ λ α IH ol, _) h,
rcases ord_eq α with ⟨r, wo, e⟩, resetI,
letI := decidable_linear_order_of_STO' r,
haveI : is_well_order α (<) := wo,
let g : α × α → α := λ p, max p.1 p.2,
let f : α × α ↪ ordinal × (α × α) :=
⟨λ p:α×α, (typein (<) (g p), p), λ p q, congr_arg prod.snd⟩,
let s := f ⁻¹'o (prod.lex (<) (prod.lex (<) (<))),
haveI : is_well_order _ s := (order_embedding.preimage _ _).is_well_order,
suffices : type s ≤ type r, {exact card_le_card this},
refine le_of_forall_lt (λ o h, _),
rcases typein_surj s h with ⟨p, rfl⟩,
rw [← e, lt_ord],
refine lt_of_le_of_lt (_ : _ ≤ card (typein (<) (g p)).succ * card (typein (<) (g p)).succ) _,
{ have : {q|s q p} ⊆ (insert (g p) {x | x < (g p)}).prod (insert (g p) {x | x < (g p)}),
{ intros q h,
simp only [s, embedding.coe_fn_mk, order.preimage, typein_lt_typein, prod.lex_def, typein_inj] at h,
exact max_le_iff.1 (le_iff_lt_or_eq.2 $ h.imp_right and.left) },
suffices H : (insert (g p) {x | r x (g p)} : set α) ≃ ({x | r x (g p)} ⊕ punit),
{ exact ⟨(set.embedding_of_subset _ _ this).trans
((equiv.set.prod _ _).trans (H.prod_congr H)).to_embedding⟩ },
refine (equiv.set.insert _).trans
((equiv.refl _).sum_congr punit_equiv_punit),
apply @irrefl _ r },
cases lt_or_ge (card (typein (<) (g p)).succ) omega with qo qo,
{ exact lt_of_lt_of_le (mul_lt_omega qo qo) ol },
{ suffices, {exact lt_of_le_of_lt (IH _ this qo) this},
rw ← lt_ord, apply (ord_is_limit ol).2,
rw [mk_def, e], apply typein_lt_type }
end
end using_ordinals
theorem mul_eq_max {a b : cardinal} (ha : omega ≤ a) (hb : omega ≤ b) : a * b = max a b :=
le_antisymm
(mul_eq_self (le_trans ha (le_max_left a b)) ▸
mul_le_mul (le_max_left _ _) (le_max_right _ _)) $
max_le
(by simpa only [mul_one] using mul_le_mul_left a (le_trans (le_of_lt one_lt_omega) hb))
(by simpa only [one_mul] using mul_le_mul_right b (le_trans (le_of_lt one_lt_omega) ha))
theorem mul_lt_of_lt {a b c : cardinal} (hc : omega ≤ c)
(h1 : a < c) (h2 : b < c) : a * b < c :=
lt_of_le_of_lt (mul_le_mul (le_max_left a b) (le_max_right a b)) $
(lt_or_le (max a b) omega).elim
(λ h, lt_of_lt_of_le (mul_lt_omega h h) hc)
(λ h, by rw mul_eq_self h; exact max_lt h1 h2)
lemma mul_le_max_of_omega_le_left {a b : cardinal} (h : omega ≤ a) : a * b ≤ max a b :=
begin
convert mul_le_mul (le_max_left a b) (le_max_right a b), rw [mul_eq_self],
refine le_trans h (le_max_left a b)
end
lemma mul_eq_max_of_omega_le_left {a b : cardinal} (h : omega ≤ a) (h' : b ≠ 0) : a * b = max a b :=
begin
apply le_antisymm, apply mul_le_max_of_omega_le_left h,
cases le_or_gt omega b with hb hb, rw [mul_eq_max h hb],
have : b ≤ a, exact le_trans (le_of_lt hb) h,
rw [max_eq_left this], convert mul_le_mul_left _ (one_le_iff_ne_zero.mpr h'), rw [mul_one],
end
lemma mul_eq_left {a b : cardinal} (ha : omega ≤ a) (hb : b ≤ a) (hb' : b ≠ 0) : a * b = a :=
by { rw [mul_eq_max_of_omega_le_left ha hb', max_eq_left hb] }
lemma mul_eq_right {a b : cardinal} (hb : omega ≤ b) (ha : a ≤ b) (ha' : a ≠ 0) : a * b = b :=
by { rw [mul_comm, mul_eq_left hb ha ha'] }
lemma le_mul_left {a b : cardinal} (h : b ≠ 0) : a ≤ b * a :=
by { convert mul_le_mul_right _ (one_le_iff_ne_zero.mpr h), rw [one_mul] }
lemma le_mul_right {a b : cardinal} (h : b ≠ 0) : a ≤ a * b :=
by { rw [mul_comm], exact le_mul_left h }
lemma mul_eq_left_iff {a b : cardinal} : a * b = a ↔ ((max omega b ≤ a ∧ b ≠ 0) ∨ b = 1 ∨ a = 0) :=
begin
rw [max_le_iff], split,
{ intro h,
cases (le_or_lt omega a) with ha ha,
{ have : a ≠ 0, { rintro rfl, exact not_lt_of_le ha omega_pos },
left, use ha,
{ rw [← not_lt], intro hb, apply ne_of_gt _ h, refine lt_of_lt_of_le hb (le_mul_left this) },
{ rintro rfl, apply this, rw [_root_.mul_zero] at h, subst h }},
right, by_cases h2a : a = 0, { right, exact h2a },
have hb : b ≠ 0, { rintro rfl, apply h2a, rw [mul_zero] at h, subst h },
left, rw [← h, mul_lt_omega_iff, lt_omega, lt_omega] at ha,
rcases ha with rfl|rfl|⟨⟨n, rfl⟩, ⟨m, rfl⟩⟩, contradiction, contradiction,
rw [← ne] at h2a, rw [← one_le_iff_ne_zero] at h2a hb, norm_cast at h2a hb h ⊢,
apply le_antisymm _ hb, rw [← not_lt], intro h2b,
apply ne_of_gt _ h, rw [gt], conv_lhs { rw [← mul_one n] },
rwa [mul_lt_mul_left], apply nat.lt_of_succ_le h2a },
{ rintro (⟨⟨ha, hab⟩, hb⟩|rfl|rfl),
{ rw [mul_eq_max_of_omega_le_left ha hb, max_eq_left hab] },
all_goals {simp}}
end
/- properties of add -/
theorem add_eq_self {c : cardinal} (h : omega ≤ c) : c + c = c :=
le_antisymm
(by simpa only [nat.cast_bit0, nat.cast_one, mul_eq_self h, two_mul] using
mul_le_mul_right c (le_trans (le_of_lt $ nat_lt_omega 2) h))
(le_add_left c c)
theorem add_eq_max {a b : cardinal} (ha : omega ≤ a) : a + b = max a b :=
le_antisymm
(add_eq_self (le_trans ha (le_max_left a b)) ▸
add_le_add (le_max_left _ _) (le_max_right _ _)) $
max_le (le_add_right _ _) (le_add_left _ _)
theorem add_lt_of_lt {a b c : cardinal} (hc : omega ≤ c)
(h1 : a < c) (h2 : b < c) : a + b < c :=
lt_of_le_of_lt (add_le_add (le_max_left a b) (le_max_right a b)) $
(lt_or_le (max a b) omega).elim
(λ h, lt_of_lt_of_le (add_lt_omega h h) hc)
(λ h, by rw add_eq_self h; exact max_lt h1 h2)
lemma eq_of_add_eq_of_omega_le {a b c : cardinal} (h : a + b = c) (ha : a < c) (hc : omega ≤ c) :
b = c :=
begin
apply le_antisymm,
{ rw [← h], apply cardinal.le_add_left },
rw[← not_lt], intro hb,
have : a + b < c := add_lt_of_lt hc ha hb,
simpa [h, lt_irrefl] using this
end
lemma add_eq_left {a b : cardinal} (ha : omega ≤ a) (hb : b ≤ a) : a + b = a :=
by { rw [add_eq_max ha, max_eq_left hb] }
lemma add_eq_right {a b : cardinal} (hb : omega ≤ b) (ha : a ≤ b) : a + b = b :=
by { rw [add_comm, add_eq_left hb ha] }
lemma add_eq_left_iff {a b : cardinal} : a + b = a ↔ (max omega b ≤ a ∨ b = 0) :=
begin
rw [max_le_iff], split,
{ intro h, cases (le_or_lt omega a) with ha ha,
{ left, use ha, rw [← not_lt], intro hb, apply ne_of_gt _ h,
exact lt_of_lt_of_le hb (le_add_left b a) },
right, rw [← h, add_lt_omega_iff, lt_omega, lt_omega] at ha,
rcases ha with ⟨⟨n, rfl⟩, ⟨m, rfl⟩⟩, norm_cast at h ⊢,
rw [← add_right_inj, h, add_zero] },
{ rintro (⟨h1, h2⟩|h3), rw [add_eq_max h1, max_eq_left h2], rw [h3, add_zero] }
end
lemma add_eq_right_iff {a b : cardinal} : a + b = b ↔ (max omega a ≤ b ∨ a = 0) :=
by { rw [add_comm, add_eq_left_iff] }
lemma add_one_eq {a : cardinal} (ha : omega ≤ a) : a + 1 = a :=
have 1 ≤ a, from le_trans (le_of_lt one_lt_omega) ha,
add_eq_left ha this
protected lemma eq_of_add_eq_add_left {a b c : cardinal} (h : a + b = a + c) (ha : a < omega) :
b = c :=
begin
cases le_or_lt omega b with hb hb,
{ have : a < b := lt_of_lt_of_le ha hb,
rw [add_eq_right hb (le_of_lt this), eq_comm] at h,
rw [eq_of_add_eq_of_omega_le h this hb] },
{ have hc : c < omega,
{ rw [← not_le], intro hc,
apply lt_irrefl omega, apply lt_of_le_of_lt (le_trans hc (le_add_left _ a)),
rw [← h], apply add_lt_omega ha hb },
rw [lt_omega] at *,
rcases ha with ⟨n, rfl⟩, rcases hb with ⟨m, rfl⟩, rcases hc with ⟨k, rfl⟩,
norm_cast at h ⊢, apply add_left_cancel h }
end
protected lemma eq_of_add_eq_add_right {a b c : cardinal} (h : a + b = c + b) (hb : b < omega) :
a = c :=
by { rw [add_comm a b, add_comm c b] at h, exact cardinal.eq_of_add_eq_add_left h hb }
/- properties about power -/
theorem pow_le {κ μ : cardinal.{u}} (H1 : omega ≤ κ) (H2 : μ < omega) : κ ^ μ ≤ κ :=
let ⟨n, H3⟩ := lt_omega.1 H2 in
H3.symm ▸ (quotient.induction_on κ (λ α H1, nat.rec_on n
(le_of_lt $ lt_of_lt_of_le (by rw [nat.cast_zero, power_zero];
from one_lt_omega) H1)
(λ n ih, trans_rel_left _
(by rw [nat.cast_succ, power_add, power_one];
from mul_le_mul_right _ ih)
(mul_eq_self H1))) H1)
lemma power_self_eq {c : cardinal} (h : omega ≤ c) : c ^ c = 2 ^ c :=
begin
apply le_antisymm,
{ apply le_trans (power_le_power_right $ le_of_lt $ cantor c), rw [power_mul, mul_eq_self h] },
{ convert power_le_power_right (le_trans (le_of_lt $ nat_lt_omega 2) h), apply nat.cast_two.symm }
end
lemma power_nat_le {c : cardinal.{u}} {n : ℕ} (h : omega ≤ c) : c ^ (n : cardinal.{u}) ≤ c :=
pow_le h (nat_lt_omega n)
lemma powerlt_omega {c : cardinal} (h : omega ≤ c) : c ^< omega = c :=
begin
apply le_antisymm,
{ rw [powerlt_le], intro c', rw [lt_omega], rintro ⟨n, rfl⟩, apply power_nat_le h },
convert le_powerlt one_lt_omega, rw [power_one]
end
lemma powerlt_omega_le (c : cardinal) : c ^< omega ≤ max c omega :=
begin
cases le_or_gt omega c,
{ rw [powerlt_omega h], apply le_max_left },
rw [powerlt_le], intros c' hc',
refine le_trans (le_of_lt $ power_lt_omega h hc') (le_max_right _ _)
end
/- compute cardinality of various types -/
theorem mk_list_eq_mk {α : Type u} (H1 : omega ≤ mk α) : mk (list α) = mk α :=
eq.symm $ le_antisymm ⟨⟨λ x, [x], λ x y H, (list.cons.inj H).1⟩⟩ $
calc mk (list α)
= sum (λ n : ℕ, mk α ^ (n : cardinal.{u})) : mk_list_eq_sum_pow α
... ≤ sum (λ n : ℕ, mk α) : sum_le_sum _ _ $ λ n, pow_le H1 $ nat_lt_omega n
... = sum (λ n : ulift.{u} ℕ, mk α) : quotient.sound
⟨@sigma_congr_left _ _ (λ _, quotient.out (mk α)) equiv.ulift.symm⟩
... = omega * mk α : sum_const _ _
... = max (omega) (mk α) : mul_eq_max (le_refl _) H1
... = mk α : max_eq_right H1
lemma mk_bounded_set_le_of_omega_le (α : Type u) (c : cardinal) (hα : omega ≤ mk α) :
mk {t : set α // mk t ≤ c} ≤ mk α ^ c :=
begin
refine le_trans _ (by rw [←add_one_eq hα]), refine quotient.induction_on c _, clear c, intro β,
fapply mk_le_of_surjective,
{ intro f, use sum.inl ⁻¹' range f,
refine le_trans (mk_preimage_of_injective _ _ (λ x y, sum.inl.inj)) _,
apply mk_range_le },
rintro ⟨s, ⟨g⟩⟩,
use λ y, if h : ∃(x : s), g x = y then sum.inl (classical.some h).val else sum.inr ⟨⟩,
apply subtype.eq, ext,
split,
{ rintro ⟨y, h⟩, dsimp only at h, by_cases h' : ∃ (z : s), g z = y,
{ rw [dif_pos h'] at h, cases sum.inl.inj h, exact (classical.some h').2 },
{ rw [dif_neg h'] at h, cases h }},
{ intro h, have : ∃(z : s), g z = g ⟨x, h⟩, exact ⟨⟨x, h⟩, rfl⟩,
use g ⟨x, h⟩, dsimp only, rw [dif_pos this], congr',
suffices : classical.some this = ⟨x, h⟩, exact congr_arg subtype.val this,
apply g.2, exact classical.some_spec this }
end
lemma mk_bounded_set_le (α : Type u) (c : cardinal) :
mk {t : set α // mk t ≤ c} ≤ max (mk α) omega ^ c :=
begin
transitivity mk {t : set (ulift.{u} nat ⊕ α) // mk t ≤ c},
{ refine ⟨embedding.subtype_map _ _⟩, apply embedding.image,
use sum.inr, apply sum.inr.inj, intros s hs, exact le_trans mk_image_le hs },
refine le_trans
(mk_bounded_set_le_of_omega_le (ulift.{u} nat ⊕ α) c (le_add_right omega (mk α))) _,
rw [max_comm, ←add_eq_max]; refl
end
lemma mk_bounded_subset_le {α : Type u} (s : set α) (c : cardinal.{u}) :
mk {t : set α // t ⊆ s ∧ mk t ≤ c} ≤ max (mk s) omega ^ c :=
begin
refine le_trans _ (mk_bounded_set_le s c),
refine ⟨embedding.cod_restrict _ _ _⟩,
use λ t, coe ⁻¹' t.1,
{ rintros ⟨t, ht1, ht2⟩ ⟨t', h1t', h2t'⟩ h, apply subtype.eq, dsimp only at h ⊢,
refine (preimage_eq_preimage' _ _).1 h; rw [subtype.range_coe]; assumption },
rintro ⟨t, h1t, h2t⟩, exact le_trans (mk_preimage_of_injective _ _ subtype.val_injective) h2t
end
/- compl -/
lemma mk_compl_of_omega_le {α : Type*} (s : set α) (h : omega ≤ #α) (h2 : #s < #α) :
#(sᶜ : set α) = #α :=
by { refine eq_of_add_eq_of_omega_le _ h2 h, exact mk_sum_compl s }
lemma mk_compl_finset_of_omega_le {α : Type*} (s : finset α) (h : omega ≤ #α) :
#((↑s)ᶜ : set α) = #α :=
by { apply mk_compl_of_omega_le _ h, exact lt_of_lt_of_le (finset_card_lt_omega s) h }
lemma mk_compl_eq_mk_compl_infinite {α : Type*} {s t : set α} (h : omega ≤ #α) (hs : #s < #α)
(ht : #t < #α) : #(sᶜ : set α) = #(tᶜ : set α) :=
by { rw [mk_compl_of_omega_le s h hs, mk_compl_of_omega_le t h ht] }
lemma mk_compl_eq_mk_compl_finite_lift {α : Type u} {β : Type v} {s : set α} {t : set β}
(hα : #α < omega) (h1 : lift.{u (max v w)} (#α) = lift.{v (max u w)} (#β))
(h2 : lift.{u (max v w)} (#s) = lift.{v (max u w)} (#t)) :
lift.{u (max v w)} (#(sᶜ : set α)) = lift.{v (max u w)} (#(tᶜ : set β)) :=
begin
have hα' := hα, have h1' := h1,
rw [← mk_sum_compl s, ← mk_sum_compl t] at h1,
rw [← mk_sum_compl s, add_lt_omega_iff] at hα,
lift #s to ℕ using hα.1 with n hn,
lift #(sᶜ : set α) to ℕ using hα.2 with m hm,
have : #(tᶜ : set β) < omega,
{ refine lt_of_le_of_lt (mk_subtype_le _) _,
rw [← lift_lt, lift_omega, ← h1', ← lift_omega.{u (max v w)}, lift_lt], exact hα' },
lift #(tᶜ : set β) to ℕ using this with k hk,
simp [nat_eq_lift_eq_iff] at h2, rw [nat_eq_lift_eq_iff.{v (max u w)}] at h2,
simp [h2.symm] at h1 ⊢, norm_cast at h1, simp at h1, exact h1
end
lemma mk_compl_eq_mk_compl_finite {α β : Type u} {s : set α} {t : set β}
(hα : #α < omega) (h1 : #α = #β) (h : #s = #t) : #(sᶜ : set α) = #(tᶜ : set β) :=
by { rw [← lift_inj], apply mk_compl_eq_mk_compl_finite_lift hα; rw [lift_inj]; assumption }
lemma mk_compl_eq_mk_compl_finite_same {α : Type*} {s t : set α} (hα : #α < omega)
(h : #s = #t) : #(sᶜ : set α) = #(tᶜ : set α) :=
mk_compl_eq_mk_compl_finite hα rfl h
/- extend an injection to an equiv -/
theorem extend_function {α β : Type*} {s : set α} (f : s ↪ β)
(h : nonempty ((sᶜ : set α) ≃ ((range f)ᶜ : set β))) :
∃ (g : α ≃ β), ∀ x : s, g x = f x :=
begin
intros, have := h, cases this with g,
let h : α ≃ β := (set.sum_compl (s : set α)).symm.trans
((sum_congr (equiv.set.range f f.2) g).trans
(set.sum_compl (range f))),
refine ⟨h, _⟩, rintro ⟨x, hx⟩, simp [set.sum_compl_symm_apply_of_mem, hx]
end
theorem extend_function_finite {α β : Type*} {s : set α} (f : s ↪ β)
(hs : #α < omega) (h : nonempty (α ≃ β)) : ∃ (g : α ≃ β), ∀ x : s, g x = f x :=
begin
apply extend_function f,
have := h, cases this with g,
rw [← lift_mk_eq] at h,
rw [←lift_mk_eq, mk_compl_eq_mk_compl_finite_lift hs h],
rw [mk_range_eq_lift], exact f.2
end
theorem extend_function_of_lt {α β : Type*} {s : set α} (f : s ↪ β) (hs : #s < #α)
(h : nonempty (α ≃ β)) : ∃ (g : α ≃ β), ∀ x : s, g x = f x :=
begin
cases (le_or_lt omega (#α)) with hα hα,
{ apply extend_function f, have := h, cases this with g, rw [← lift_mk_eq] at h,
cases cardinal.eq.mp (mk_compl_of_omega_le s hα hs) with g2,
cases cardinal.eq.mp (mk_compl_of_omega_le (range f) _ _) with g3,
{ constructor, exact g2.trans (g.trans g3.symm) },
{ rw [← lift_le, ← h], refine le_trans _ (lift_le.mpr hα), simp },
rwa [← lift_lt, ← h, mk_range_eq_lift, lift_lt], exact f.2 },
{ exact extend_function_finite f hα h }
end
section bit
/-!
This section proves inequalities for `bit0` and `bit1`, enabling `simp` to solve inequalities
for numeral cardinals. The complexity of the resulting algorithm is not good, as in some cases
`simp` reduces an inequality to a disjunction of two situations, depending on whether a cardinal
is finite or infinite. Since the evaluation of the branches is not lazy, this is bad. It is good
enough for practical situations, though.
For specific numbers, these inequalities could also be deduced from the corresponding
inequalities of natural numbers using `norm_cast`:
```
example : (37 : cardinal) < 42 :=
by { norm_cast, norm_num }
```
-/
@[simp] lemma bit0_ne_zero (a : cardinal) : ¬bit0 a = 0 ↔ ¬a = 0 :=
by simp [bit0]
@[simp] lemma bit1_ne_zero (a : cardinal) : ¬bit1 a = 0 :=
by simp [bit1]
@[simp] lemma zero_lt_bit0 (a : cardinal) : 0 < bit0 a ↔ 0 < a :=
by { rw ←not_iff_not, simp [bit0], }
@[simp] lemma zero_lt_bit1 (a : cardinal) : 0 < bit1 a :=
lt_of_lt_of_le zero_lt_one (le_add_left _ _)
@[simp] lemma one_le_bit0 (a : cardinal) : 1 ≤ bit0 a ↔ 0 < a :=
⟨λ h, (zero_lt_bit0 a).mp (lt_of_lt_of_le zero_lt_one h),
λ h, le_trans (one_le_iff_pos.mpr h) (le_add_left a a)⟩
@[simp] lemma one_le_bit1 (a : cardinal) : 1 ≤ bit1 a :=
le_add_left _ _
theorem bit0_eq_self {c : cardinal} (h : omega ≤ c) : bit0 c = c :=
add_eq_self h
@[simp] theorem bit0_lt_omega {c : cardinal} : bit0 c < omega ↔ c < omega :=
by simp [bit0, add_lt_omega_iff]
@[simp] theorem omega_le_bit0 {c : cardinal} : omega ≤ bit0 c ↔ omega ≤ c :=
by { rw ← not_iff_not, simp }
@[simp] theorem bit1_eq_self_iff {c : cardinal} : bit1 c = c ↔ omega ≤ c :=
begin
by_cases h : omega ≤ c,
{ simp only [bit1, bit0_eq_self h, h, eq_self_iff_true, add_one_of_omega_le] },
{ simp only [h, iff_false],
apply ne_of_gt,
rcases lt_omega.1 (not_le.1 h) with ⟨n, rfl⟩,
norm_cast,
dsimp [bit1, bit0],
omega }
end
@[simp] theorem bit1_lt_omega {c : cardinal} : bit1 c < omega ↔ c < omega :=
by simp [bit1, bit0, add_lt_omega_iff, one_lt_omega]
@[simp] theorem omega_le_bit1 {c : cardinal} : omega ≤ bit1 c ↔ omega ≤ c :=
by { rw ← not_iff_not, simp }
@[simp] lemma bit0_le_bit0 {a b : cardinal} : bit0 a ≤ bit0 b ↔ a ≤ b :=
begin
by_cases ha : omega ≤ a; by_cases hb : omega ≤ b,
{ rw [bit0_eq_self ha, bit0_eq_self hb] },
{ rw bit0_eq_self ha,
have I1 : ¬ (a ≤ b),
{ assume h, apply hb, exact le_trans ha h },
have I2 : ¬ (a ≤ bit0 b),
{ assume h,
have A : bit0 b < omega, by simpa using hb,
exact lt_irrefl _ (lt_of_lt_of_le (lt_of_lt_of_le A ha) h) },
simp [I1, I2] },
{ rw [bit0_eq_self hb],
simp only [not_le] at ha,
have I1 : a ≤ b := le_of_lt (lt_of_lt_of_le ha hb),
have I2 : bit0 a ≤ b := le_trans (le_of_lt (bit0_lt_omega.2 ha)) hb,
simp [I1, I2] },
{ simp at ha hb,
rcases lt_omega.1 ha with ⟨m, rfl⟩,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
norm_cast,
simp }
end
@[simp] lemma bit0_le_bit1 {a b : cardinal} : bit0 a ≤ bit1 b ↔ a ≤ b :=
begin
by_cases ha : omega ≤ a; by_cases hb : omega ≤ b,
{ rw [bit0_eq_self ha, bit1_eq_self_iff.2 hb], },
{ rw bit0_eq_self ha,
have I1 : ¬ (a ≤ b),
{ assume h, apply hb, exact le_trans ha h },
have I2 : ¬ (a ≤ bit1 b),
{ assume h,
have A : bit1 b < omega, by simpa using hb,
exact lt_irrefl _ (lt_of_lt_of_le (lt_of_lt_of_le A ha) h) },
simp [I1, I2] },
{ rw [bit1_eq_self_iff.2 hb],
simp only [not_le] at ha,
have I1 : a ≤ b := le_of_lt (lt_of_lt_of_le ha hb),
have I2 : bit0 a ≤ b := le_trans (le_of_lt (bit0_lt_omega.2 ha)) hb,
simp [I1, I2] },
{ simp at ha hb,
rcases lt_omega.1 ha with ⟨m, rfl⟩,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
norm_cast,
simp }
end
@[simp] lemma bit1_le_bit1 {a b : cardinal} : bit1 a ≤ bit1 b ↔ a ≤ b :=
begin
split,
{ assume h,
apply bit0_le_bit1.1 (le_trans ((bit0 a).le_add_right 1) h) },
{ assume h,
calc a + a + 1 ≤ a + b + 1 : add_le_add_right 1 (add_le_add_left a h)
... ≤ b + b + 1 : add_le_add_right 1 (add_le_add_right b h) }
end
@[simp] lemma bit1_le_bit0 {a b : cardinal} : bit1 a ≤ bit0 b ↔ (a < b ∨ (a ≤ b ∧ omega ≤ a)) :=
begin
by_cases ha : omega ≤ a; by_cases hb : omega ≤ b,
{ simp only [bit1_eq_self_iff.mpr ha, bit0_eq_self hb, ha, and_true],
refine ⟨λ h, or.inr h, λ h, _⟩,
cases h,
{ exact le_of_lt h },
{ exact h } },
{ rw bit1_eq_self_iff.2 ha,
have I1 : ¬ (a ≤ b),
{ assume h, apply hb, exact le_trans ha h },
have I2 : ¬ (a ≤ bit0 b),
{ assume h,
have A : bit0 b < omega, by simpa using hb,
exact lt_irrefl _ (lt_of_lt_of_le (lt_of_lt_of_le A ha) h) },
simp [I1, I2, le_of_not_ge I1] },
{ rw [bit0_eq_self hb],
simp only [not_le] at ha,
have I1 : a < b := lt_of_lt_of_le ha hb,
have I2 : bit1 a ≤ b := le_trans (le_of_lt (bit1_lt_omega.2 ha)) hb,
simp [I1, I2] },
{ simp at ha hb,
rcases lt_omega.1 ha with ⟨m, rfl⟩,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
norm_cast,
simp [not_le.mpr ha], }
end
@[simp] lemma bit0_lt_bit0 {a b : cardinal} : bit0 a < bit0 b ↔ a < b :=
begin
by_cases ha : omega ≤ a; by_cases hb : omega ≤ b,
{ rw [bit0_eq_self ha, bit0_eq_self hb] },
{ rw bit0_eq_self ha,
have I1 : ¬ (a < b),
{ assume h, apply hb, exact le_trans ha (le_of_lt h) },
have I2 : ¬ (a < bit0 b),
{ assume h,
have A : bit0 b < omega, by simpa using hb,
exact lt_irrefl _ (lt_trans (lt_of_lt_of_le A ha) h) },
simp [I1, I2] },
{ rw [bit0_eq_self hb],
simp only [not_le] at ha,
have I1 : a < b := lt_of_lt_of_le ha hb,
have I2 : bit0 a < b := lt_of_lt_of_le (bit0_lt_omega.2 ha) hb,
simp [I1, I2] },
{ simp at ha hb,
rcases lt_omega.1 ha with ⟨m, rfl⟩,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
norm_cast,
simp }
end
@[simp] lemma bit1_lt_bit0 {a b : cardinal} : bit1 a < bit0 b ↔ a < b :=
begin
by_cases ha : omega ≤ a; by_cases hb : omega ≤ b,
{ rw [bit1_eq_self_iff.2 ha, bit0_eq_self hb], },
{ rw bit1_eq_self_iff.2 ha,
have I1 : ¬ (a < b),
{ assume h, apply hb, exact le_of_lt (lt_of_le_of_lt ha h) },
have I2 : ¬ (a < bit0 b),
{ assume h,
have A : bit0 b < omega, by simpa using hb,
exact lt_irrefl _ (lt_trans (lt_of_lt_of_le A ha) h) },
simp [I1, I2] },
{ rw [bit0_eq_self hb],
simp only [not_le] at ha,
have I1 : a < b := (lt_of_lt_of_le ha hb),
have I2 : bit1 a < b := lt_of_lt_of_le (bit1_lt_omega.2 ha) hb,
simp [I1, I2] },
{ simp at ha hb,
rcases lt_omega.1 ha with ⟨m, rfl⟩,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
norm_cast,
simp }
end
@[simp] lemma bit1_lt_bit1 {a b : cardinal} : bit1 a < bit1 b ↔ a < b :=
begin
by_cases ha : omega ≤ a; by_cases hb : omega ≤ b,
{ rw [bit1_eq_self_iff.2 ha, bit1_eq_self_iff.2 hb], },
{ rw bit1_eq_self_iff.2 ha,
have I1 : ¬ (a < b),
{ assume h, apply hb, exact le_of_lt (lt_of_le_of_lt ha h) },
have I2 : ¬ (a < bit1 b),
{ assume h,
have A : bit1 b < omega, by simpa using hb,
exact lt_irrefl _ (lt_trans (lt_of_lt_of_le A ha) h) },
simp [I1, I2] },
{ rw [bit1_eq_self_iff.2 hb],
simp only [not_le] at ha,
have I1 : a < b := (lt_of_lt_of_le ha hb),
have I2 : bit1 a < b := lt_of_lt_of_le (bit1_lt_omega.2 ha) hb,
simp [I1, I2] },
{ simp at ha hb,
rcases lt_omega.1 ha with ⟨m, rfl⟩,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
norm_cast,
simp }
end
@[simp] lemma bit0_lt_bit1 {a b : cardinal} : bit0 a < bit1 b ↔ (a < b ∨ (a ≤ b ∧ a < omega)) :=
begin
by_cases ha : omega ≤ a; by_cases hb : omega ≤ b,
{ simp [bit0_eq_self ha, bit1_eq_self_iff.2 hb, not_lt.mpr ha] },
{ rw bit0_eq_self ha,
have I1 : ¬ (a < b),
{ assume h, apply hb, exact le_of_lt (lt_of_le_of_lt ha h) },
have I2 : ¬ (a < bit1 b),
{ assume h,
have A : bit1 b < omega, by simpa using hb,
exact lt_irrefl _ (lt_trans (lt_of_lt_of_le A ha) h) },
simp [I1, I2, not_lt.mpr ha] },
{ rw [bit1_eq_self_iff.2 hb],
simp only [not_le] at ha,
have I1 : a < b := (lt_of_lt_of_le ha hb),
have I2 : bit0 a < b := lt_of_lt_of_le (bit0_lt_omega.2 ha) hb,
simp [I1, I2] },
{ simp at ha hb,
rcases lt_omega.1 ha with ⟨m, rfl⟩,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
norm_cast,
simp only [ha, and_true, nat.bit0_lt_bit1_iff],
refine ⟨λ h, or.inr h, λ h, _⟩,
cases h,
{ exact le_of_lt h },
{ exact h } }
end
lemma one_lt_two : (1 : cardinal) < 2 :=
-- This strategy works generally to prove inequalities between numerals in `cardinality`.
by { norm_cast, norm_num }
@[simp] lemma one_lt_bit0 {a : cardinal} : 1 < bit0 a ↔ 0 < a :=
by simp [← bit1_zero]
@[simp] lemma one_lt_bit1 (a : cardinal) : 1 < bit1 a ↔ 0 < a :=
by simp [← bit1_zero]
@[simp] lemma one_le_one : (1 : cardinal) ≤ 1 :=
le_refl _
end bit
end cardinal
|
008e4bd79a0bb4e4af8dd4917981f4d250a86165 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/simpperf/pre3000.lean | 65fa5212c0ff3038312f95476f138d63870c5803 | [
"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 | 262,530 | lean | axiom f (x : Prop) : Prop
axiom g0 (x : Prop) : Prop
axiom g1 (x : Prop) : Prop
axiom g2 (x : Prop) : Prop
axiom g3 (x : Prop) : Prop
axiom g4 (x : Prop) : Prop
axiom g5 (x : Prop) : Prop
axiom g6 (x : Prop) : Prop
axiom g7 (x : Prop) : Prop
axiom g8 (x : Prop) : Prop
axiom g9 (x : Prop) : Prop
axiom g10 (x : Prop) : Prop
axiom g11 (x : Prop) : Prop
axiom g12 (x : Prop) : Prop
axiom g13 (x : Prop) : Prop
axiom g14 (x : Prop) : Prop
axiom g15 (x : Prop) : Prop
axiom g16 (x : Prop) : Prop
axiom g17 (x : Prop) : Prop
axiom g18 (x : Prop) : Prop
axiom g19 (x : Prop) : Prop
axiom g20 (x : Prop) : Prop
axiom g21 (x : Prop) : Prop
axiom g22 (x : Prop) : Prop
axiom g23 (x : Prop) : Prop
axiom g24 (x : Prop) : Prop
axiom g25 (x : Prop) : Prop
axiom g26 (x : Prop) : Prop
axiom g27 (x : Prop) : Prop
axiom g28 (x : Prop) : Prop
axiom g29 (x : Prop) : Prop
axiom g30 (x : Prop) : Prop
axiom g31 (x : Prop) : Prop
axiom g32 (x : Prop) : Prop
axiom g33 (x : Prop) : Prop
axiom g34 (x : Prop) : Prop
axiom g35 (x : Prop) : Prop
axiom g36 (x : Prop) : Prop
axiom g37 (x : Prop) : Prop
axiom g38 (x : Prop) : Prop
axiom g39 (x : Prop) : Prop
axiom g40 (x : Prop) : Prop
axiom g41 (x : Prop) : Prop
axiom g42 (x : Prop) : Prop
axiom g43 (x : Prop) : Prop
axiom g44 (x : Prop) : Prop
axiom g45 (x : Prop) : Prop
axiom g46 (x : Prop) : Prop
axiom g47 (x : Prop) : Prop
axiom g48 (x : Prop) : Prop
axiom g49 (x : Prop) : Prop
axiom g50 (x : Prop) : Prop
axiom g51 (x : Prop) : Prop
axiom g52 (x : Prop) : Prop
axiom g53 (x : Prop) : Prop
axiom g54 (x : Prop) : Prop
axiom g55 (x : Prop) : Prop
axiom g56 (x : Prop) : Prop
axiom g57 (x : Prop) : Prop
axiom g58 (x : Prop) : Prop
axiom g59 (x : Prop) : Prop
axiom g60 (x : Prop) : Prop
axiom g61 (x : Prop) : Prop
axiom g62 (x : Prop) : Prop
axiom g63 (x : Prop) : Prop
axiom g64 (x : Prop) : Prop
axiom g65 (x : Prop) : Prop
axiom g66 (x : Prop) : Prop
axiom g67 (x : Prop) : Prop
axiom g68 (x : Prop) : Prop
axiom g69 (x : Prop) : Prop
axiom g70 (x : Prop) : Prop
axiom g71 (x : Prop) : Prop
axiom g72 (x : Prop) : Prop
axiom g73 (x : Prop) : Prop
axiom g74 (x : Prop) : Prop
axiom g75 (x : Prop) : Prop
axiom g76 (x : Prop) : Prop
axiom g77 (x : Prop) : Prop
axiom g78 (x : Prop) : Prop
axiom g79 (x : Prop) : Prop
axiom g80 (x : Prop) : Prop
axiom g81 (x : Prop) : Prop
axiom g82 (x : Prop) : Prop
axiom g83 (x : Prop) : Prop
axiom g84 (x : Prop) : Prop
axiom g85 (x : Prop) : Prop
axiom g86 (x : Prop) : Prop
axiom g87 (x : Prop) : Prop
axiom g88 (x : Prop) : Prop
axiom g89 (x : Prop) : Prop
axiom g90 (x : Prop) : Prop
axiom g91 (x : Prop) : Prop
axiom g92 (x : Prop) : Prop
axiom g93 (x : Prop) : Prop
axiom g94 (x : Prop) : Prop
axiom g95 (x : Prop) : Prop
axiom g96 (x : Prop) : Prop
axiom g97 (x : Prop) : Prop
axiom g98 (x : Prop) : Prop
axiom g99 (x : Prop) : Prop
axiom g100 (x : Prop) : Prop
axiom g101 (x : Prop) : Prop
axiom g102 (x : Prop) : Prop
axiom g103 (x : Prop) : Prop
axiom g104 (x : Prop) : Prop
axiom g105 (x : Prop) : Prop
axiom g106 (x : Prop) : Prop
axiom g107 (x : Prop) : Prop
axiom g108 (x : Prop) : Prop
axiom g109 (x : Prop) : Prop
axiom g110 (x : Prop) : Prop
axiom g111 (x : Prop) : Prop
axiom g112 (x : Prop) : Prop
axiom g113 (x : Prop) : Prop
axiom g114 (x : Prop) : Prop
axiom g115 (x : Prop) : Prop
axiom g116 (x : Prop) : Prop
axiom g117 (x : Prop) : Prop
axiom g118 (x : Prop) : Prop
axiom g119 (x : Prop) : Prop
axiom g120 (x : Prop) : Prop
axiom g121 (x : Prop) : Prop
axiom g122 (x : Prop) : Prop
axiom g123 (x : Prop) : Prop
axiom g124 (x : Prop) : Prop
axiom g125 (x : Prop) : Prop
axiom g126 (x : Prop) : Prop
axiom g127 (x : Prop) : Prop
axiom g128 (x : Prop) : Prop
axiom g129 (x : Prop) : Prop
axiom g130 (x : Prop) : Prop
axiom g131 (x : Prop) : Prop
axiom g132 (x : Prop) : Prop
axiom g133 (x : Prop) : Prop
axiom g134 (x : Prop) : Prop
axiom g135 (x : Prop) : Prop
axiom g136 (x : Prop) : Prop
axiom g137 (x : Prop) : Prop
axiom g138 (x : Prop) : Prop
axiom g139 (x : Prop) : Prop
axiom g140 (x : Prop) : Prop
axiom g141 (x : Prop) : Prop
axiom g142 (x : Prop) : Prop
axiom g143 (x : Prop) : Prop
axiom g144 (x : Prop) : Prop
axiom g145 (x : Prop) : Prop
axiom g146 (x : Prop) : Prop
axiom g147 (x : Prop) : Prop
axiom g148 (x : Prop) : Prop
axiom g149 (x : Prop) : Prop
axiom g150 (x : Prop) : Prop
axiom g151 (x : Prop) : Prop
axiom g152 (x : Prop) : Prop
axiom g153 (x : Prop) : Prop
axiom g154 (x : Prop) : Prop
axiom g155 (x : Prop) : Prop
axiom g156 (x : Prop) : Prop
axiom g157 (x : Prop) : Prop
axiom g158 (x : Prop) : Prop
axiom g159 (x : Prop) : Prop
axiom g160 (x : Prop) : Prop
axiom g161 (x : Prop) : Prop
axiom g162 (x : Prop) : Prop
axiom g163 (x : Prop) : Prop
axiom g164 (x : Prop) : Prop
axiom g165 (x : Prop) : Prop
axiom g166 (x : Prop) : Prop
axiom g167 (x : Prop) : Prop
axiom g168 (x : Prop) : Prop
axiom g169 (x : Prop) : Prop
axiom g170 (x : Prop) : Prop
axiom g171 (x : Prop) : Prop
axiom g172 (x : Prop) : Prop
axiom g173 (x : Prop) : Prop
axiom g174 (x : Prop) : Prop
axiom g175 (x : Prop) : Prop
axiom g176 (x : Prop) : Prop
axiom g177 (x : Prop) : Prop
axiom g178 (x : Prop) : Prop
axiom g179 (x : Prop) : Prop
axiom g180 (x : Prop) : Prop
axiom g181 (x : Prop) : Prop
axiom g182 (x : Prop) : Prop
axiom g183 (x : Prop) : Prop
axiom g184 (x : Prop) : Prop
axiom g185 (x : Prop) : Prop
axiom g186 (x : Prop) : Prop
axiom g187 (x : Prop) : Prop
axiom g188 (x : Prop) : Prop
axiom g189 (x : Prop) : Prop
axiom g190 (x : Prop) : Prop
axiom g191 (x : Prop) : Prop
axiom g192 (x : Prop) : Prop
axiom g193 (x : Prop) : Prop
axiom g194 (x : Prop) : Prop
axiom g195 (x : Prop) : Prop
axiom g196 (x : Prop) : Prop
axiom g197 (x : Prop) : Prop
axiom g198 (x : Prop) : Prop
axiom g199 (x : Prop) : Prop
axiom g200 (x : Prop) : Prop
axiom g201 (x : Prop) : Prop
axiom g202 (x : Prop) : Prop
axiom g203 (x : Prop) : Prop
axiom g204 (x : Prop) : Prop
axiom g205 (x : Prop) : Prop
axiom g206 (x : Prop) : Prop
axiom g207 (x : Prop) : Prop
axiom g208 (x : Prop) : Prop
axiom g209 (x : Prop) : Prop
axiom g210 (x : Prop) : Prop
axiom g211 (x : Prop) : Prop
axiom g212 (x : Prop) : Prop
axiom g213 (x : Prop) : Prop
axiom g214 (x : Prop) : Prop
axiom g215 (x : Prop) : Prop
axiom g216 (x : Prop) : Prop
axiom g217 (x : Prop) : Prop
axiom g218 (x : Prop) : Prop
axiom g219 (x : Prop) : Prop
axiom g220 (x : Prop) : Prop
axiom g221 (x : Prop) : Prop
axiom g222 (x : Prop) : Prop
axiom g223 (x : Prop) : Prop
axiom g224 (x : Prop) : Prop
axiom g225 (x : Prop) : Prop
axiom g226 (x : Prop) : Prop
axiom g227 (x : Prop) : Prop
axiom g228 (x : Prop) : Prop
axiom g229 (x : Prop) : Prop
axiom g230 (x : Prop) : Prop
axiom g231 (x : Prop) : Prop
axiom g232 (x : Prop) : Prop
axiom g233 (x : Prop) : Prop
axiom g234 (x : Prop) : Prop
axiom g235 (x : Prop) : Prop
axiom g236 (x : Prop) : Prop
axiom g237 (x : Prop) : Prop
axiom g238 (x : Prop) : Prop
axiom g239 (x : Prop) : Prop
axiom g240 (x : Prop) : Prop
axiom g241 (x : Prop) : Prop
axiom g242 (x : Prop) : Prop
axiom g243 (x : Prop) : Prop
axiom g244 (x : Prop) : Prop
axiom g245 (x : Prop) : Prop
axiom g246 (x : Prop) : Prop
axiom g247 (x : Prop) : Prop
axiom g248 (x : Prop) : Prop
axiom g249 (x : Prop) : Prop
axiom g250 (x : Prop) : Prop
axiom g251 (x : Prop) : Prop
axiom g252 (x : Prop) : Prop
axiom g253 (x : Prop) : Prop
axiom g254 (x : Prop) : Prop
axiom g255 (x : Prop) : Prop
axiom g256 (x : Prop) : Prop
axiom g257 (x : Prop) : Prop
axiom g258 (x : Prop) : Prop
axiom g259 (x : Prop) : Prop
axiom g260 (x : Prop) : Prop
axiom g261 (x : Prop) : Prop
axiom g262 (x : Prop) : Prop
axiom g263 (x : Prop) : Prop
axiom g264 (x : Prop) : Prop
axiom g265 (x : Prop) : Prop
axiom g266 (x : Prop) : Prop
axiom g267 (x : Prop) : Prop
axiom g268 (x : Prop) : Prop
axiom g269 (x : Prop) : Prop
axiom g270 (x : Prop) : Prop
axiom g271 (x : Prop) : Prop
axiom g272 (x : Prop) : Prop
axiom g273 (x : Prop) : Prop
axiom g274 (x : Prop) : Prop
axiom g275 (x : Prop) : Prop
axiom g276 (x : Prop) : Prop
axiom g277 (x : Prop) : Prop
axiom g278 (x : Prop) : Prop
axiom g279 (x : Prop) : Prop
axiom g280 (x : Prop) : Prop
axiom g281 (x : Prop) : Prop
axiom g282 (x : Prop) : Prop
axiom g283 (x : Prop) : Prop
axiom g284 (x : Prop) : Prop
axiom g285 (x : Prop) : Prop
axiom g286 (x : Prop) : Prop
axiom g287 (x : Prop) : Prop
axiom g288 (x : Prop) : Prop
axiom g289 (x : Prop) : Prop
axiom g290 (x : Prop) : Prop
axiom g291 (x : Prop) : Prop
axiom g292 (x : Prop) : Prop
axiom g293 (x : Prop) : Prop
axiom g294 (x : Prop) : Prop
axiom g295 (x : Prop) : Prop
axiom g296 (x : Prop) : Prop
axiom g297 (x : Prop) : Prop
axiom g298 (x : Prop) : Prop
axiom g299 (x : Prop) : Prop
axiom g300 (x : Prop) : Prop
axiom g301 (x : Prop) : Prop
axiom g302 (x : Prop) : Prop
axiom g303 (x : Prop) : Prop
axiom g304 (x : Prop) : Prop
axiom g305 (x : Prop) : Prop
axiom g306 (x : Prop) : Prop
axiom g307 (x : Prop) : Prop
axiom g308 (x : Prop) : Prop
axiom g309 (x : Prop) : Prop
axiom g310 (x : Prop) : Prop
axiom g311 (x : Prop) : Prop
axiom g312 (x : Prop) : Prop
axiom g313 (x : Prop) : Prop
axiom g314 (x : Prop) : Prop
axiom g315 (x : Prop) : Prop
axiom g316 (x : Prop) : Prop
axiom g317 (x : Prop) : Prop
axiom g318 (x : Prop) : Prop
axiom g319 (x : Prop) : Prop
axiom g320 (x : Prop) : Prop
axiom g321 (x : Prop) : Prop
axiom g322 (x : Prop) : Prop
axiom g323 (x : Prop) : Prop
axiom g324 (x : Prop) : Prop
axiom g325 (x : Prop) : Prop
axiom g326 (x : Prop) : Prop
axiom g327 (x : Prop) : Prop
axiom g328 (x : Prop) : Prop
axiom g329 (x : Prop) : Prop
axiom g330 (x : Prop) : Prop
axiom g331 (x : Prop) : Prop
axiom g332 (x : Prop) : Prop
axiom g333 (x : Prop) : Prop
axiom g334 (x : Prop) : Prop
axiom g335 (x : Prop) : Prop
axiom g336 (x : Prop) : Prop
axiom g337 (x : Prop) : Prop
axiom g338 (x : Prop) : Prop
axiom g339 (x : Prop) : Prop
axiom g340 (x : Prop) : Prop
axiom g341 (x : Prop) : Prop
axiom g342 (x : Prop) : Prop
axiom g343 (x : Prop) : Prop
axiom g344 (x : Prop) : Prop
axiom g345 (x : Prop) : Prop
axiom g346 (x : Prop) : Prop
axiom g347 (x : Prop) : Prop
axiom g348 (x : Prop) : Prop
axiom g349 (x : Prop) : Prop
axiom g350 (x : Prop) : Prop
axiom g351 (x : Prop) : Prop
axiom g352 (x : Prop) : Prop
axiom g353 (x : Prop) : Prop
axiom g354 (x : Prop) : Prop
axiom g355 (x : Prop) : Prop
axiom g356 (x : Prop) : Prop
axiom g357 (x : Prop) : Prop
axiom g358 (x : Prop) : Prop
axiom g359 (x : Prop) : Prop
axiom g360 (x : Prop) : Prop
axiom g361 (x : Prop) : Prop
axiom g362 (x : Prop) : Prop
axiom g363 (x : Prop) : Prop
axiom g364 (x : Prop) : Prop
axiom g365 (x : Prop) : Prop
axiom g366 (x : Prop) : Prop
axiom g367 (x : Prop) : Prop
axiom g368 (x : Prop) : Prop
axiom g369 (x : Prop) : Prop
axiom g370 (x : Prop) : Prop
axiom g371 (x : Prop) : Prop
axiom g372 (x : Prop) : Prop
axiom g373 (x : Prop) : Prop
axiom g374 (x : Prop) : Prop
axiom g375 (x : Prop) : Prop
axiom g376 (x : Prop) : Prop
axiom g377 (x : Prop) : Prop
axiom g378 (x : Prop) : Prop
axiom g379 (x : Prop) : Prop
axiom g380 (x : Prop) : Prop
axiom g381 (x : Prop) : Prop
axiom g382 (x : Prop) : Prop
axiom g383 (x : Prop) : Prop
axiom g384 (x : Prop) : Prop
axiom g385 (x : Prop) : Prop
axiom g386 (x : Prop) : Prop
axiom g387 (x : Prop) : Prop
axiom g388 (x : Prop) : Prop
axiom g389 (x : Prop) : Prop
axiom g390 (x : Prop) : Prop
axiom g391 (x : Prop) : Prop
axiom g392 (x : Prop) : Prop
axiom g393 (x : Prop) : Prop
axiom g394 (x : Prop) : Prop
axiom g395 (x : Prop) : Prop
axiom g396 (x : Prop) : Prop
axiom g397 (x : Prop) : Prop
axiom g398 (x : Prop) : Prop
axiom g399 (x : Prop) : Prop
axiom g400 (x : Prop) : Prop
axiom g401 (x : Prop) : Prop
axiom g402 (x : Prop) : Prop
axiom g403 (x : Prop) : Prop
axiom g404 (x : Prop) : Prop
axiom g405 (x : Prop) : Prop
axiom g406 (x : Prop) : Prop
axiom g407 (x : Prop) : Prop
axiom g408 (x : Prop) : Prop
axiom g409 (x : Prop) : Prop
axiom g410 (x : Prop) : Prop
axiom g411 (x : Prop) : Prop
axiom g412 (x : Prop) : Prop
axiom g413 (x : Prop) : Prop
axiom g414 (x : Prop) : Prop
axiom g415 (x : Prop) : Prop
axiom g416 (x : Prop) : Prop
axiom g417 (x : Prop) : Prop
axiom g418 (x : Prop) : Prop
axiom g419 (x : Prop) : Prop
axiom g420 (x : Prop) : Prop
axiom g421 (x : Prop) : Prop
axiom g422 (x : Prop) : Prop
axiom g423 (x : Prop) : Prop
axiom g424 (x : Prop) : Prop
axiom g425 (x : Prop) : Prop
axiom g426 (x : Prop) : Prop
axiom g427 (x : Prop) : Prop
axiom g428 (x : Prop) : Prop
axiom g429 (x : Prop) : Prop
axiom g430 (x : Prop) : Prop
axiom g431 (x : Prop) : Prop
axiom g432 (x : Prop) : Prop
axiom g433 (x : Prop) : Prop
axiom g434 (x : Prop) : Prop
axiom g435 (x : Prop) : Prop
axiom g436 (x : Prop) : Prop
axiom g437 (x : Prop) : Prop
axiom g438 (x : Prop) : Prop
axiom g439 (x : Prop) : Prop
axiom g440 (x : Prop) : Prop
axiom g441 (x : Prop) : Prop
axiom g442 (x : Prop) : Prop
axiom g443 (x : Prop) : Prop
axiom g444 (x : Prop) : Prop
axiom g445 (x : Prop) : Prop
axiom g446 (x : Prop) : Prop
axiom g447 (x : Prop) : Prop
axiom g448 (x : Prop) : Prop
axiom g449 (x : Prop) : Prop
axiom g450 (x : Prop) : Prop
axiom g451 (x : Prop) : Prop
axiom g452 (x : Prop) : Prop
axiom g453 (x : Prop) : Prop
axiom g454 (x : Prop) : Prop
axiom g455 (x : Prop) : Prop
axiom g456 (x : Prop) : Prop
axiom g457 (x : Prop) : Prop
axiom g458 (x : Prop) : Prop
axiom g459 (x : Prop) : Prop
axiom g460 (x : Prop) : Prop
axiom g461 (x : Prop) : Prop
axiom g462 (x : Prop) : Prop
axiom g463 (x : Prop) : Prop
axiom g464 (x : Prop) : Prop
axiom g465 (x : Prop) : Prop
axiom g466 (x : Prop) : Prop
axiom g467 (x : Prop) : Prop
axiom g468 (x : Prop) : Prop
axiom g469 (x : Prop) : Prop
axiom g470 (x : Prop) : Prop
axiom g471 (x : Prop) : Prop
axiom g472 (x : Prop) : Prop
axiom g473 (x : Prop) : Prop
axiom g474 (x : Prop) : Prop
axiom g475 (x : Prop) : Prop
axiom g476 (x : Prop) : Prop
axiom g477 (x : Prop) : Prop
axiom g478 (x : Prop) : Prop
axiom g479 (x : Prop) : Prop
axiom g480 (x : Prop) : Prop
axiom g481 (x : Prop) : Prop
axiom g482 (x : Prop) : Prop
axiom g483 (x : Prop) : Prop
axiom g484 (x : Prop) : Prop
axiom g485 (x : Prop) : Prop
axiom g486 (x : Prop) : Prop
axiom g487 (x : Prop) : Prop
axiom g488 (x : Prop) : Prop
axiom g489 (x : Prop) : Prop
axiom g490 (x : Prop) : Prop
axiom g491 (x : Prop) : Prop
axiom g492 (x : Prop) : Prop
axiom g493 (x : Prop) : Prop
axiom g494 (x : Prop) : Prop
axiom g495 (x : Prop) : Prop
axiom g496 (x : Prop) : Prop
axiom g497 (x : Prop) : Prop
axiom g498 (x : Prop) : Prop
axiom g499 (x : Prop) : Prop
axiom g500 (x : Prop) : Prop
axiom g501 (x : Prop) : Prop
axiom g502 (x : Prop) : Prop
axiom g503 (x : Prop) : Prop
axiom g504 (x : Prop) : Prop
axiom g505 (x : Prop) : Prop
axiom g506 (x : Prop) : Prop
axiom g507 (x : Prop) : Prop
axiom g508 (x : Prop) : Prop
axiom g509 (x : Prop) : Prop
axiom g510 (x : Prop) : Prop
axiom g511 (x : Prop) : Prop
axiom g512 (x : Prop) : Prop
axiom g513 (x : Prop) : Prop
axiom g514 (x : Prop) : Prop
axiom g515 (x : Prop) : Prop
axiom g516 (x : Prop) : Prop
axiom g517 (x : Prop) : Prop
axiom g518 (x : Prop) : Prop
axiom g519 (x : Prop) : Prop
axiom g520 (x : Prop) : Prop
axiom g521 (x : Prop) : Prop
axiom g522 (x : Prop) : Prop
axiom g523 (x : Prop) : Prop
axiom g524 (x : Prop) : Prop
axiom g525 (x : Prop) : Prop
axiom g526 (x : Prop) : Prop
axiom g527 (x : Prop) : Prop
axiom g528 (x : Prop) : Prop
axiom g529 (x : Prop) : Prop
axiom g530 (x : Prop) : Prop
axiom g531 (x : Prop) : Prop
axiom g532 (x : Prop) : Prop
axiom g533 (x : Prop) : Prop
axiom g534 (x : Prop) : Prop
axiom g535 (x : Prop) : Prop
axiom g536 (x : Prop) : Prop
axiom g537 (x : Prop) : Prop
axiom g538 (x : Prop) : Prop
axiom g539 (x : Prop) : Prop
axiom g540 (x : Prop) : Prop
axiom g541 (x : Prop) : Prop
axiom g542 (x : Prop) : Prop
axiom g543 (x : Prop) : Prop
axiom g544 (x : Prop) : Prop
axiom g545 (x : Prop) : Prop
axiom g546 (x : Prop) : Prop
axiom g547 (x : Prop) : Prop
axiom g548 (x : Prop) : Prop
axiom g549 (x : Prop) : Prop
axiom g550 (x : Prop) : Prop
axiom g551 (x : Prop) : Prop
axiom g552 (x : Prop) : Prop
axiom g553 (x : Prop) : Prop
axiom g554 (x : Prop) : Prop
axiom g555 (x : Prop) : Prop
axiom g556 (x : Prop) : Prop
axiom g557 (x : Prop) : Prop
axiom g558 (x : Prop) : Prop
axiom g559 (x : Prop) : Prop
axiom g560 (x : Prop) : Prop
axiom g561 (x : Prop) : Prop
axiom g562 (x : Prop) : Prop
axiom g563 (x : Prop) : Prop
axiom g564 (x : Prop) : Prop
axiom g565 (x : Prop) : Prop
axiom g566 (x : Prop) : Prop
axiom g567 (x : Prop) : Prop
axiom g568 (x : Prop) : Prop
axiom g569 (x : Prop) : Prop
axiom g570 (x : Prop) : Prop
axiom g571 (x : Prop) : Prop
axiom g572 (x : Prop) : Prop
axiom g573 (x : Prop) : Prop
axiom g574 (x : Prop) : Prop
axiom g575 (x : Prop) : Prop
axiom g576 (x : Prop) : Prop
axiom g577 (x : Prop) : Prop
axiom g578 (x : Prop) : Prop
axiom g579 (x : Prop) : Prop
axiom g580 (x : Prop) : Prop
axiom g581 (x : Prop) : Prop
axiom g582 (x : Prop) : Prop
axiom g583 (x : Prop) : Prop
axiom g584 (x : Prop) : Prop
axiom g585 (x : Prop) : Prop
axiom g586 (x : Prop) : Prop
axiom g587 (x : Prop) : Prop
axiom g588 (x : Prop) : Prop
axiom g589 (x : Prop) : Prop
axiom g590 (x : Prop) : Prop
axiom g591 (x : Prop) : Prop
axiom g592 (x : Prop) : Prop
axiom g593 (x : Prop) : Prop
axiom g594 (x : Prop) : Prop
axiom g595 (x : Prop) : Prop
axiom g596 (x : Prop) : Prop
axiom g597 (x : Prop) : Prop
axiom g598 (x : Prop) : Prop
axiom g599 (x : Prop) : Prop
axiom g600 (x : Prop) : Prop
axiom g601 (x : Prop) : Prop
axiom g602 (x : Prop) : Prop
axiom g603 (x : Prop) : Prop
axiom g604 (x : Prop) : Prop
axiom g605 (x : Prop) : Prop
axiom g606 (x : Prop) : Prop
axiom g607 (x : Prop) : Prop
axiom g608 (x : Prop) : Prop
axiom g609 (x : Prop) : Prop
axiom g610 (x : Prop) : Prop
axiom g611 (x : Prop) : Prop
axiom g612 (x : Prop) : Prop
axiom g613 (x : Prop) : Prop
axiom g614 (x : Prop) : Prop
axiom g615 (x : Prop) : Prop
axiom g616 (x : Prop) : Prop
axiom g617 (x : Prop) : Prop
axiom g618 (x : Prop) : Prop
axiom g619 (x : Prop) : Prop
axiom g620 (x : Prop) : Prop
axiom g621 (x : Prop) : Prop
axiom g622 (x : Prop) : Prop
axiom g623 (x : Prop) : Prop
axiom g624 (x : Prop) : Prop
axiom g625 (x : Prop) : Prop
axiom g626 (x : Prop) : Prop
axiom g627 (x : Prop) : Prop
axiom g628 (x : Prop) : Prop
axiom g629 (x : Prop) : Prop
axiom g630 (x : Prop) : Prop
axiom g631 (x : Prop) : Prop
axiom g632 (x : Prop) : Prop
axiom g633 (x : Prop) : Prop
axiom g634 (x : Prop) : Prop
axiom g635 (x : Prop) : Prop
axiom g636 (x : Prop) : Prop
axiom g637 (x : Prop) : Prop
axiom g638 (x : Prop) : Prop
axiom g639 (x : Prop) : Prop
axiom g640 (x : Prop) : Prop
axiom g641 (x : Prop) : Prop
axiom g642 (x : Prop) : Prop
axiom g643 (x : Prop) : Prop
axiom g644 (x : Prop) : Prop
axiom g645 (x : Prop) : Prop
axiom g646 (x : Prop) : Prop
axiom g647 (x : Prop) : Prop
axiom g648 (x : Prop) : Prop
axiom g649 (x : Prop) : Prop
axiom g650 (x : Prop) : Prop
axiom g651 (x : Prop) : Prop
axiom g652 (x : Prop) : Prop
axiom g653 (x : Prop) : Prop
axiom g654 (x : Prop) : Prop
axiom g655 (x : Prop) : Prop
axiom g656 (x : Prop) : Prop
axiom g657 (x : Prop) : Prop
axiom g658 (x : Prop) : Prop
axiom g659 (x : Prop) : Prop
axiom g660 (x : Prop) : Prop
axiom g661 (x : Prop) : Prop
axiom g662 (x : Prop) : Prop
axiom g663 (x : Prop) : Prop
axiom g664 (x : Prop) : Prop
axiom g665 (x : Prop) : Prop
axiom g666 (x : Prop) : Prop
axiom g667 (x : Prop) : Prop
axiom g668 (x : Prop) : Prop
axiom g669 (x : Prop) : Prop
axiom g670 (x : Prop) : Prop
axiom g671 (x : Prop) : Prop
axiom g672 (x : Prop) : Prop
axiom g673 (x : Prop) : Prop
axiom g674 (x : Prop) : Prop
axiom g675 (x : Prop) : Prop
axiom g676 (x : Prop) : Prop
axiom g677 (x : Prop) : Prop
axiom g678 (x : Prop) : Prop
axiom g679 (x : Prop) : Prop
axiom g680 (x : Prop) : Prop
axiom g681 (x : Prop) : Prop
axiom g682 (x : Prop) : Prop
axiom g683 (x : Prop) : Prop
axiom g684 (x : Prop) : Prop
axiom g685 (x : Prop) : Prop
axiom g686 (x : Prop) : Prop
axiom g687 (x : Prop) : Prop
axiom g688 (x : Prop) : Prop
axiom g689 (x : Prop) : Prop
axiom g690 (x : Prop) : Prop
axiom g691 (x : Prop) : Prop
axiom g692 (x : Prop) : Prop
axiom g693 (x : Prop) : Prop
axiom g694 (x : Prop) : Prop
axiom g695 (x : Prop) : Prop
axiom g696 (x : Prop) : Prop
axiom g697 (x : Prop) : Prop
axiom g698 (x : Prop) : Prop
axiom g699 (x : Prop) : Prop
axiom g700 (x : Prop) : Prop
axiom g701 (x : Prop) : Prop
axiom g702 (x : Prop) : Prop
axiom g703 (x : Prop) : Prop
axiom g704 (x : Prop) : Prop
axiom g705 (x : Prop) : Prop
axiom g706 (x : Prop) : Prop
axiom g707 (x : Prop) : Prop
axiom g708 (x : Prop) : Prop
axiom g709 (x : Prop) : Prop
axiom g710 (x : Prop) : Prop
axiom g711 (x : Prop) : Prop
axiom g712 (x : Prop) : Prop
axiom g713 (x : Prop) : Prop
axiom g714 (x : Prop) : Prop
axiom g715 (x : Prop) : Prop
axiom g716 (x : Prop) : Prop
axiom g717 (x : Prop) : Prop
axiom g718 (x : Prop) : Prop
axiom g719 (x : Prop) : Prop
axiom g720 (x : Prop) : Prop
axiom g721 (x : Prop) : Prop
axiom g722 (x : Prop) : Prop
axiom g723 (x : Prop) : Prop
axiom g724 (x : Prop) : Prop
axiom g725 (x : Prop) : Prop
axiom g726 (x : Prop) : Prop
axiom g727 (x : Prop) : Prop
axiom g728 (x : Prop) : Prop
axiom g729 (x : Prop) : Prop
axiom g730 (x : Prop) : Prop
axiom g731 (x : Prop) : Prop
axiom g732 (x : Prop) : Prop
axiom g733 (x : Prop) : Prop
axiom g734 (x : Prop) : Prop
axiom g735 (x : Prop) : Prop
axiom g736 (x : Prop) : Prop
axiom g737 (x : Prop) : Prop
axiom g738 (x : Prop) : Prop
axiom g739 (x : Prop) : Prop
axiom g740 (x : Prop) : Prop
axiom g741 (x : Prop) : Prop
axiom g742 (x : Prop) : Prop
axiom g743 (x : Prop) : Prop
axiom g744 (x : Prop) : Prop
axiom g745 (x : Prop) : Prop
axiom g746 (x : Prop) : Prop
axiom g747 (x : Prop) : Prop
axiom g748 (x : Prop) : Prop
axiom g749 (x : Prop) : Prop
axiom g750 (x : Prop) : Prop
axiom g751 (x : Prop) : Prop
axiom g752 (x : Prop) : Prop
axiom g753 (x : Prop) : Prop
axiom g754 (x : Prop) : Prop
axiom g755 (x : Prop) : Prop
axiom g756 (x : Prop) : Prop
axiom g757 (x : Prop) : Prop
axiom g758 (x : Prop) : Prop
axiom g759 (x : Prop) : Prop
axiom g760 (x : Prop) : Prop
axiom g761 (x : Prop) : Prop
axiom g762 (x : Prop) : Prop
axiom g763 (x : Prop) : Prop
axiom g764 (x : Prop) : Prop
axiom g765 (x : Prop) : Prop
axiom g766 (x : Prop) : Prop
axiom g767 (x : Prop) : Prop
axiom g768 (x : Prop) : Prop
axiom g769 (x : Prop) : Prop
axiom g770 (x : Prop) : Prop
axiom g771 (x : Prop) : Prop
axiom g772 (x : Prop) : Prop
axiom g773 (x : Prop) : Prop
axiom g774 (x : Prop) : Prop
axiom g775 (x : Prop) : Prop
axiom g776 (x : Prop) : Prop
axiom g777 (x : Prop) : Prop
axiom g778 (x : Prop) : Prop
axiom g779 (x : Prop) : Prop
axiom g780 (x : Prop) : Prop
axiom g781 (x : Prop) : Prop
axiom g782 (x : Prop) : Prop
axiom g783 (x : Prop) : Prop
axiom g784 (x : Prop) : Prop
axiom g785 (x : Prop) : Prop
axiom g786 (x : Prop) : Prop
axiom g787 (x : Prop) : Prop
axiom g788 (x : Prop) : Prop
axiom g789 (x : Prop) : Prop
axiom g790 (x : Prop) : Prop
axiom g791 (x : Prop) : Prop
axiom g792 (x : Prop) : Prop
axiom g793 (x : Prop) : Prop
axiom g794 (x : Prop) : Prop
axiom g795 (x : Prop) : Prop
axiom g796 (x : Prop) : Prop
axiom g797 (x : Prop) : Prop
axiom g798 (x : Prop) : Prop
axiom g799 (x : Prop) : Prop
axiom g800 (x : Prop) : Prop
axiom g801 (x : Prop) : Prop
axiom g802 (x : Prop) : Prop
axiom g803 (x : Prop) : Prop
axiom g804 (x : Prop) : Prop
axiom g805 (x : Prop) : Prop
axiom g806 (x : Prop) : Prop
axiom g807 (x : Prop) : Prop
axiom g808 (x : Prop) : Prop
axiom g809 (x : Prop) : Prop
axiom g810 (x : Prop) : Prop
axiom g811 (x : Prop) : Prop
axiom g812 (x : Prop) : Prop
axiom g813 (x : Prop) : Prop
axiom g814 (x : Prop) : Prop
axiom g815 (x : Prop) : Prop
axiom g816 (x : Prop) : Prop
axiom g817 (x : Prop) : Prop
axiom g818 (x : Prop) : Prop
axiom g819 (x : Prop) : Prop
axiom g820 (x : Prop) : Prop
axiom g821 (x : Prop) : Prop
axiom g822 (x : Prop) : Prop
axiom g823 (x : Prop) : Prop
axiom g824 (x : Prop) : Prop
axiom g825 (x : Prop) : Prop
axiom g826 (x : Prop) : Prop
axiom g827 (x : Prop) : Prop
axiom g828 (x : Prop) : Prop
axiom g829 (x : Prop) : Prop
axiom g830 (x : Prop) : Prop
axiom g831 (x : Prop) : Prop
axiom g832 (x : Prop) : Prop
axiom g833 (x : Prop) : Prop
axiom g834 (x : Prop) : Prop
axiom g835 (x : Prop) : Prop
axiom g836 (x : Prop) : Prop
axiom g837 (x : Prop) : Prop
axiom g838 (x : Prop) : Prop
axiom g839 (x : Prop) : Prop
axiom g840 (x : Prop) : Prop
axiom g841 (x : Prop) : Prop
axiom g842 (x : Prop) : Prop
axiom g843 (x : Prop) : Prop
axiom g844 (x : Prop) : Prop
axiom g845 (x : Prop) : Prop
axiom g846 (x : Prop) : Prop
axiom g847 (x : Prop) : Prop
axiom g848 (x : Prop) : Prop
axiom g849 (x : Prop) : Prop
axiom g850 (x : Prop) : Prop
axiom g851 (x : Prop) : Prop
axiom g852 (x : Prop) : Prop
axiom g853 (x : Prop) : Prop
axiom g854 (x : Prop) : Prop
axiom g855 (x : Prop) : Prop
axiom g856 (x : Prop) : Prop
axiom g857 (x : Prop) : Prop
axiom g858 (x : Prop) : Prop
axiom g859 (x : Prop) : Prop
axiom g860 (x : Prop) : Prop
axiom g861 (x : Prop) : Prop
axiom g862 (x : Prop) : Prop
axiom g863 (x : Prop) : Prop
axiom g864 (x : Prop) : Prop
axiom g865 (x : Prop) : Prop
axiom g866 (x : Prop) : Prop
axiom g867 (x : Prop) : Prop
axiom g868 (x : Prop) : Prop
axiom g869 (x : Prop) : Prop
axiom g870 (x : Prop) : Prop
axiom g871 (x : Prop) : Prop
axiom g872 (x : Prop) : Prop
axiom g873 (x : Prop) : Prop
axiom g874 (x : Prop) : Prop
axiom g875 (x : Prop) : Prop
axiom g876 (x : Prop) : Prop
axiom g877 (x : Prop) : Prop
axiom g878 (x : Prop) : Prop
axiom g879 (x : Prop) : Prop
axiom g880 (x : Prop) : Prop
axiom g881 (x : Prop) : Prop
axiom g882 (x : Prop) : Prop
axiom g883 (x : Prop) : Prop
axiom g884 (x : Prop) : Prop
axiom g885 (x : Prop) : Prop
axiom g886 (x : Prop) : Prop
axiom g887 (x : Prop) : Prop
axiom g888 (x : Prop) : Prop
axiom g889 (x : Prop) : Prop
axiom g890 (x : Prop) : Prop
axiom g891 (x : Prop) : Prop
axiom g892 (x : Prop) : Prop
axiom g893 (x : Prop) : Prop
axiom g894 (x : Prop) : Prop
axiom g895 (x : Prop) : Prop
axiom g896 (x : Prop) : Prop
axiom g897 (x : Prop) : Prop
axiom g898 (x : Prop) : Prop
axiom g899 (x : Prop) : Prop
axiom g900 (x : Prop) : Prop
axiom g901 (x : Prop) : Prop
axiom g902 (x : Prop) : Prop
axiom g903 (x : Prop) : Prop
axiom g904 (x : Prop) : Prop
axiom g905 (x : Prop) : Prop
axiom g906 (x : Prop) : Prop
axiom g907 (x : Prop) : Prop
axiom g908 (x : Prop) : Prop
axiom g909 (x : Prop) : Prop
axiom g910 (x : Prop) : Prop
axiom g911 (x : Prop) : Prop
axiom g912 (x : Prop) : Prop
axiom g913 (x : Prop) : Prop
axiom g914 (x : Prop) : Prop
axiom g915 (x : Prop) : Prop
axiom g916 (x : Prop) : Prop
axiom g917 (x : Prop) : Prop
axiom g918 (x : Prop) : Prop
axiom g919 (x : Prop) : Prop
axiom g920 (x : Prop) : Prop
axiom g921 (x : Prop) : Prop
axiom g922 (x : Prop) : Prop
axiom g923 (x : Prop) : Prop
axiom g924 (x : Prop) : Prop
axiom g925 (x : Prop) : Prop
axiom g926 (x : Prop) : Prop
axiom g927 (x : Prop) : Prop
axiom g928 (x : Prop) : Prop
axiom g929 (x : Prop) : Prop
axiom g930 (x : Prop) : Prop
axiom g931 (x : Prop) : Prop
axiom g932 (x : Prop) : Prop
axiom g933 (x : Prop) : Prop
axiom g934 (x : Prop) : Prop
axiom g935 (x : Prop) : Prop
axiom g936 (x : Prop) : Prop
axiom g937 (x : Prop) : Prop
axiom g938 (x : Prop) : Prop
axiom g939 (x : Prop) : Prop
axiom g940 (x : Prop) : Prop
axiom g941 (x : Prop) : Prop
axiom g942 (x : Prop) : Prop
axiom g943 (x : Prop) : Prop
axiom g944 (x : Prop) : Prop
axiom g945 (x : Prop) : Prop
axiom g946 (x : Prop) : Prop
axiom g947 (x : Prop) : Prop
axiom g948 (x : Prop) : Prop
axiom g949 (x : Prop) : Prop
axiom g950 (x : Prop) : Prop
axiom g951 (x : Prop) : Prop
axiom g952 (x : Prop) : Prop
axiom g953 (x : Prop) : Prop
axiom g954 (x : Prop) : Prop
axiom g955 (x : Prop) : Prop
axiom g956 (x : Prop) : Prop
axiom g957 (x : Prop) : Prop
axiom g958 (x : Prop) : Prop
axiom g959 (x : Prop) : Prop
axiom g960 (x : Prop) : Prop
axiom g961 (x : Prop) : Prop
axiom g962 (x : Prop) : Prop
axiom g963 (x : Prop) : Prop
axiom g964 (x : Prop) : Prop
axiom g965 (x : Prop) : Prop
axiom g966 (x : Prop) : Prop
axiom g967 (x : Prop) : Prop
axiom g968 (x : Prop) : Prop
axiom g969 (x : Prop) : Prop
axiom g970 (x : Prop) : Prop
axiom g971 (x : Prop) : Prop
axiom g972 (x : Prop) : Prop
axiom g973 (x : Prop) : Prop
axiom g974 (x : Prop) : Prop
axiom g975 (x : Prop) : Prop
axiom g976 (x : Prop) : Prop
axiom g977 (x : Prop) : Prop
axiom g978 (x : Prop) : Prop
axiom g979 (x : Prop) : Prop
axiom g980 (x : Prop) : Prop
axiom g981 (x : Prop) : Prop
axiom g982 (x : Prop) : Prop
axiom g983 (x : Prop) : Prop
axiom g984 (x : Prop) : Prop
axiom g985 (x : Prop) : Prop
axiom g986 (x : Prop) : Prop
axiom g987 (x : Prop) : Prop
axiom g988 (x : Prop) : Prop
axiom g989 (x : Prop) : Prop
axiom g990 (x : Prop) : Prop
axiom g991 (x : Prop) : Prop
axiom g992 (x : Prop) : Prop
axiom g993 (x : Prop) : Prop
axiom g994 (x : Prop) : Prop
axiom g995 (x : Prop) : Prop
axiom g996 (x : Prop) : Prop
axiom g997 (x : Prop) : Prop
axiom g998 (x : Prop) : Prop
axiom g999 (x : Prop) : Prop
axiom g1000 (x : Prop) : Prop
axiom g1001 (x : Prop) : Prop
axiom g1002 (x : Prop) : Prop
axiom g1003 (x : Prop) : Prop
axiom g1004 (x : Prop) : Prop
axiom g1005 (x : Prop) : Prop
axiom g1006 (x : Prop) : Prop
axiom g1007 (x : Prop) : Prop
axiom g1008 (x : Prop) : Prop
axiom g1009 (x : Prop) : Prop
axiom g1010 (x : Prop) : Prop
axiom g1011 (x : Prop) : Prop
axiom g1012 (x : Prop) : Prop
axiom g1013 (x : Prop) : Prop
axiom g1014 (x : Prop) : Prop
axiom g1015 (x : Prop) : Prop
axiom g1016 (x : Prop) : Prop
axiom g1017 (x : Prop) : Prop
axiom g1018 (x : Prop) : Prop
axiom g1019 (x : Prop) : Prop
axiom g1020 (x : Prop) : Prop
axiom g1021 (x : Prop) : Prop
axiom g1022 (x : Prop) : Prop
axiom g1023 (x : Prop) : Prop
axiom g1024 (x : Prop) : Prop
axiom g1025 (x : Prop) : Prop
axiom g1026 (x : Prop) : Prop
axiom g1027 (x : Prop) : Prop
axiom g1028 (x : Prop) : Prop
axiom g1029 (x : Prop) : Prop
axiom g1030 (x : Prop) : Prop
axiom g1031 (x : Prop) : Prop
axiom g1032 (x : Prop) : Prop
axiom g1033 (x : Prop) : Prop
axiom g1034 (x : Prop) : Prop
axiom g1035 (x : Prop) : Prop
axiom g1036 (x : Prop) : Prop
axiom g1037 (x : Prop) : Prop
axiom g1038 (x : Prop) : Prop
axiom g1039 (x : Prop) : Prop
axiom g1040 (x : Prop) : Prop
axiom g1041 (x : Prop) : Prop
axiom g1042 (x : Prop) : Prop
axiom g1043 (x : Prop) : Prop
axiom g1044 (x : Prop) : Prop
axiom g1045 (x : Prop) : Prop
axiom g1046 (x : Prop) : Prop
axiom g1047 (x : Prop) : Prop
axiom g1048 (x : Prop) : Prop
axiom g1049 (x : Prop) : Prop
axiom g1050 (x : Prop) : Prop
axiom g1051 (x : Prop) : Prop
axiom g1052 (x : Prop) : Prop
axiom g1053 (x : Prop) : Prop
axiom g1054 (x : Prop) : Prop
axiom g1055 (x : Prop) : Prop
axiom g1056 (x : Prop) : Prop
axiom g1057 (x : Prop) : Prop
axiom g1058 (x : Prop) : Prop
axiom g1059 (x : Prop) : Prop
axiom g1060 (x : Prop) : Prop
axiom g1061 (x : Prop) : Prop
axiom g1062 (x : Prop) : Prop
axiom g1063 (x : Prop) : Prop
axiom g1064 (x : Prop) : Prop
axiom g1065 (x : Prop) : Prop
axiom g1066 (x : Prop) : Prop
axiom g1067 (x : Prop) : Prop
axiom g1068 (x : Prop) : Prop
axiom g1069 (x : Prop) : Prop
axiom g1070 (x : Prop) : Prop
axiom g1071 (x : Prop) : Prop
axiom g1072 (x : Prop) : Prop
axiom g1073 (x : Prop) : Prop
axiom g1074 (x : Prop) : Prop
axiom g1075 (x : Prop) : Prop
axiom g1076 (x : Prop) : Prop
axiom g1077 (x : Prop) : Prop
axiom g1078 (x : Prop) : Prop
axiom g1079 (x : Prop) : Prop
axiom g1080 (x : Prop) : Prop
axiom g1081 (x : Prop) : Prop
axiom g1082 (x : Prop) : Prop
axiom g1083 (x : Prop) : Prop
axiom g1084 (x : Prop) : Prop
axiom g1085 (x : Prop) : Prop
axiom g1086 (x : Prop) : Prop
axiom g1087 (x : Prop) : Prop
axiom g1088 (x : Prop) : Prop
axiom g1089 (x : Prop) : Prop
axiom g1090 (x : Prop) : Prop
axiom g1091 (x : Prop) : Prop
axiom g1092 (x : Prop) : Prop
axiom g1093 (x : Prop) : Prop
axiom g1094 (x : Prop) : Prop
axiom g1095 (x : Prop) : Prop
axiom g1096 (x : Prop) : Prop
axiom g1097 (x : Prop) : Prop
axiom g1098 (x : Prop) : Prop
axiom g1099 (x : Prop) : Prop
axiom g1100 (x : Prop) : Prop
axiom g1101 (x : Prop) : Prop
axiom g1102 (x : Prop) : Prop
axiom g1103 (x : Prop) : Prop
axiom g1104 (x : Prop) : Prop
axiom g1105 (x : Prop) : Prop
axiom g1106 (x : Prop) : Prop
axiom g1107 (x : Prop) : Prop
axiom g1108 (x : Prop) : Prop
axiom g1109 (x : Prop) : Prop
axiom g1110 (x : Prop) : Prop
axiom g1111 (x : Prop) : Prop
axiom g1112 (x : Prop) : Prop
axiom g1113 (x : Prop) : Prop
axiom g1114 (x : Prop) : Prop
axiom g1115 (x : Prop) : Prop
axiom g1116 (x : Prop) : Prop
axiom g1117 (x : Prop) : Prop
axiom g1118 (x : Prop) : Prop
axiom g1119 (x : Prop) : Prop
axiom g1120 (x : Prop) : Prop
axiom g1121 (x : Prop) : Prop
axiom g1122 (x : Prop) : Prop
axiom g1123 (x : Prop) : Prop
axiom g1124 (x : Prop) : Prop
axiom g1125 (x : Prop) : Prop
axiom g1126 (x : Prop) : Prop
axiom g1127 (x : Prop) : Prop
axiom g1128 (x : Prop) : Prop
axiom g1129 (x : Prop) : Prop
axiom g1130 (x : Prop) : Prop
axiom g1131 (x : Prop) : Prop
axiom g1132 (x : Prop) : Prop
axiom g1133 (x : Prop) : Prop
axiom g1134 (x : Prop) : Prop
axiom g1135 (x : Prop) : Prop
axiom g1136 (x : Prop) : Prop
axiom g1137 (x : Prop) : Prop
axiom g1138 (x : Prop) : Prop
axiom g1139 (x : Prop) : Prop
axiom g1140 (x : Prop) : Prop
axiom g1141 (x : Prop) : Prop
axiom g1142 (x : Prop) : Prop
axiom g1143 (x : Prop) : Prop
axiom g1144 (x : Prop) : Prop
axiom g1145 (x : Prop) : Prop
axiom g1146 (x : Prop) : Prop
axiom g1147 (x : Prop) : Prop
axiom g1148 (x : Prop) : Prop
axiom g1149 (x : Prop) : Prop
axiom g1150 (x : Prop) : Prop
axiom g1151 (x : Prop) : Prop
axiom g1152 (x : Prop) : Prop
axiom g1153 (x : Prop) : Prop
axiom g1154 (x : Prop) : Prop
axiom g1155 (x : Prop) : Prop
axiom g1156 (x : Prop) : Prop
axiom g1157 (x : Prop) : Prop
axiom g1158 (x : Prop) : Prop
axiom g1159 (x : Prop) : Prop
axiom g1160 (x : Prop) : Prop
axiom g1161 (x : Prop) : Prop
axiom g1162 (x : Prop) : Prop
axiom g1163 (x : Prop) : Prop
axiom g1164 (x : Prop) : Prop
axiom g1165 (x : Prop) : Prop
axiom g1166 (x : Prop) : Prop
axiom g1167 (x : Prop) : Prop
axiom g1168 (x : Prop) : Prop
axiom g1169 (x : Prop) : Prop
axiom g1170 (x : Prop) : Prop
axiom g1171 (x : Prop) : Prop
axiom g1172 (x : Prop) : Prop
axiom g1173 (x : Prop) : Prop
axiom g1174 (x : Prop) : Prop
axiom g1175 (x : Prop) : Prop
axiom g1176 (x : Prop) : Prop
axiom g1177 (x : Prop) : Prop
axiom g1178 (x : Prop) : Prop
axiom g1179 (x : Prop) : Prop
axiom g1180 (x : Prop) : Prop
axiom g1181 (x : Prop) : Prop
axiom g1182 (x : Prop) : Prop
axiom g1183 (x : Prop) : Prop
axiom g1184 (x : Prop) : Prop
axiom g1185 (x : Prop) : Prop
axiom g1186 (x : Prop) : Prop
axiom g1187 (x : Prop) : Prop
axiom g1188 (x : Prop) : Prop
axiom g1189 (x : Prop) : Prop
axiom g1190 (x : Prop) : Prop
axiom g1191 (x : Prop) : Prop
axiom g1192 (x : Prop) : Prop
axiom g1193 (x : Prop) : Prop
axiom g1194 (x : Prop) : Prop
axiom g1195 (x : Prop) : Prop
axiom g1196 (x : Prop) : Prop
axiom g1197 (x : Prop) : Prop
axiom g1198 (x : Prop) : Prop
axiom g1199 (x : Prop) : Prop
axiom g1200 (x : Prop) : Prop
axiom g1201 (x : Prop) : Prop
axiom g1202 (x : Prop) : Prop
axiom g1203 (x : Prop) : Prop
axiom g1204 (x : Prop) : Prop
axiom g1205 (x : Prop) : Prop
axiom g1206 (x : Prop) : Prop
axiom g1207 (x : Prop) : Prop
axiom g1208 (x : Prop) : Prop
axiom g1209 (x : Prop) : Prop
axiom g1210 (x : Prop) : Prop
axiom g1211 (x : Prop) : Prop
axiom g1212 (x : Prop) : Prop
axiom g1213 (x : Prop) : Prop
axiom g1214 (x : Prop) : Prop
axiom g1215 (x : Prop) : Prop
axiom g1216 (x : Prop) : Prop
axiom g1217 (x : Prop) : Prop
axiom g1218 (x : Prop) : Prop
axiom g1219 (x : Prop) : Prop
axiom g1220 (x : Prop) : Prop
axiom g1221 (x : Prop) : Prop
axiom g1222 (x : Prop) : Prop
axiom g1223 (x : Prop) : Prop
axiom g1224 (x : Prop) : Prop
axiom g1225 (x : Prop) : Prop
axiom g1226 (x : Prop) : Prop
axiom g1227 (x : Prop) : Prop
axiom g1228 (x : Prop) : Prop
axiom g1229 (x : Prop) : Prop
axiom g1230 (x : Prop) : Prop
axiom g1231 (x : Prop) : Prop
axiom g1232 (x : Prop) : Prop
axiom g1233 (x : Prop) : Prop
axiom g1234 (x : Prop) : Prop
axiom g1235 (x : Prop) : Prop
axiom g1236 (x : Prop) : Prop
axiom g1237 (x : Prop) : Prop
axiom g1238 (x : Prop) : Prop
axiom g1239 (x : Prop) : Prop
axiom g1240 (x : Prop) : Prop
axiom g1241 (x : Prop) : Prop
axiom g1242 (x : Prop) : Prop
axiom g1243 (x : Prop) : Prop
axiom g1244 (x : Prop) : Prop
axiom g1245 (x : Prop) : Prop
axiom g1246 (x : Prop) : Prop
axiom g1247 (x : Prop) : Prop
axiom g1248 (x : Prop) : Prop
axiom g1249 (x : Prop) : Prop
axiom g1250 (x : Prop) : Prop
axiom g1251 (x : Prop) : Prop
axiom g1252 (x : Prop) : Prop
axiom g1253 (x : Prop) : Prop
axiom g1254 (x : Prop) : Prop
axiom g1255 (x : Prop) : Prop
axiom g1256 (x : Prop) : Prop
axiom g1257 (x : Prop) : Prop
axiom g1258 (x : Prop) : Prop
axiom g1259 (x : Prop) : Prop
axiom g1260 (x : Prop) : Prop
axiom g1261 (x : Prop) : Prop
axiom g1262 (x : Prop) : Prop
axiom g1263 (x : Prop) : Prop
axiom g1264 (x : Prop) : Prop
axiom g1265 (x : Prop) : Prop
axiom g1266 (x : Prop) : Prop
axiom g1267 (x : Prop) : Prop
axiom g1268 (x : Prop) : Prop
axiom g1269 (x : Prop) : Prop
axiom g1270 (x : Prop) : Prop
axiom g1271 (x : Prop) : Prop
axiom g1272 (x : Prop) : Prop
axiom g1273 (x : Prop) : Prop
axiom g1274 (x : Prop) : Prop
axiom g1275 (x : Prop) : Prop
axiom g1276 (x : Prop) : Prop
axiom g1277 (x : Prop) : Prop
axiom g1278 (x : Prop) : Prop
axiom g1279 (x : Prop) : Prop
axiom g1280 (x : Prop) : Prop
axiom g1281 (x : Prop) : Prop
axiom g1282 (x : Prop) : Prop
axiom g1283 (x : Prop) : Prop
axiom g1284 (x : Prop) : Prop
axiom g1285 (x : Prop) : Prop
axiom g1286 (x : Prop) : Prop
axiom g1287 (x : Prop) : Prop
axiom g1288 (x : Prop) : Prop
axiom g1289 (x : Prop) : Prop
axiom g1290 (x : Prop) : Prop
axiom g1291 (x : Prop) : Prop
axiom g1292 (x : Prop) : Prop
axiom g1293 (x : Prop) : Prop
axiom g1294 (x : Prop) : Prop
axiom g1295 (x : Prop) : Prop
axiom g1296 (x : Prop) : Prop
axiom g1297 (x : Prop) : Prop
axiom g1298 (x : Prop) : Prop
axiom g1299 (x : Prop) : Prop
axiom g1300 (x : Prop) : Prop
axiom g1301 (x : Prop) : Prop
axiom g1302 (x : Prop) : Prop
axiom g1303 (x : Prop) : Prop
axiom g1304 (x : Prop) : Prop
axiom g1305 (x : Prop) : Prop
axiom g1306 (x : Prop) : Prop
axiom g1307 (x : Prop) : Prop
axiom g1308 (x : Prop) : Prop
axiom g1309 (x : Prop) : Prop
axiom g1310 (x : Prop) : Prop
axiom g1311 (x : Prop) : Prop
axiom g1312 (x : Prop) : Prop
axiom g1313 (x : Prop) : Prop
axiom g1314 (x : Prop) : Prop
axiom g1315 (x : Prop) : Prop
axiom g1316 (x : Prop) : Prop
axiom g1317 (x : Prop) : Prop
axiom g1318 (x : Prop) : Prop
axiom g1319 (x : Prop) : Prop
axiom g1320 (x : Prop) : Prop
axiom g1321 (x : Prop) : Prop
axiom g1322 (x : Prop) : Prop
axiom g1323 (x : Prop) : Prop
axiom g1324 (x : Prop) : Prop
axiom g1325 (x : Prop) : Prop
axiom g1326 (x : Prop) : Prop
axiom g1327 (x : Prop) : Prop
axiom g1328 (x : Prop) : Prop
axiom g1329 (x : Prop) : Prop
axiom g1330 (x : Prop) : Prop
axiom g1331 (x : Prop) : Prop
axiom g1332 (x : Prop) : Prop
axiom g1333 (x : Prop) : Prop
axiom g1334 (x : Prop) : Prop
axiom g1335 (x : Prop) : Prop
axiom g1336 (x : Prop) : Prop
axiom g1337 (x : Prop) : Prop
axiom g1338 (x : Prop) : Prop
axiom g1339 (x : Prop) : Prop
axiom g1340 (x : Prop) : Prop
axiom g1341 (x : Prop) : Prop
axiom g1342 (x : Prop) : Prop
axiom g1343 (x : Prop) : Prop
axiom g1344 (x : Prop) : Prop
axiom g1345 (x : Prop) : Prop
axiom g1346 (x : Prop) : Prop
axiom g1347 (x : Prop) : Prop
axiom g1348 (x : Prop) : Prop
axiom g1349 (x : Prop) : Prop
axiom g1350 (x : Prop) : Prop
axiom g1351 (x : Prop) : Prop
axiom g1352 (x : Prop) : Prop
axiom g1353 (x : Prop) : Prop
axiom g1354 (x : Prop) : Prop
axiom g1355 (x : Prop) : Prop
axiom g1356 (x : Prop) : Prop
axiom g1357 (x : Prop) : Prop
axiom g1358 (x : Prop) : Prop
axiom g1359 (x : Prop) : Prop
axiom g1360 (x : Prop) : Prop
axiom g1361 (x : Prop) : Prop
axiom g1362 (x : Prop) : Prop
axiom g1363 (x : Prop) : Prop
axiom g1364 (x : Prop) : Prop
axiom g1365 (x : Prop) : Prop
axiom g1366 (x : Prop) : Prop
axiom g1367 (x : Prop) : Prop
axiom g1368 (x : Prop) : Prop
axiom g1369 (x : Prop) : Prop
axiom g1370 (x : Prop) : Prop
axiom g1371 (x : Prop) : Prop
axiom g1372 (x : Prop) : Prop
axiom g1373 (x : Prop) : Prop
axiom g1374 (x : Prop) : Prop
axiom g1375 (x : Prop) : Prop
axiom g1376 (x : Prop) : Prop
axiom g1377 (x : Prop) : Prop
axiom g1378 (x : Prop) : Prop
axiom g1379 (x : Prop) : Prop
axiom g1380 (x : Prop) : Prop
axiom g1381 (x : Prop) : Prop
axiom g1382 (x : Prop) : Prop
axiom g1383 (x : Prop) : Prop
axiom g1384 (x : Prop) : Prop
axiom g1385 (x : Prop) : Prop
axiom g1386 (x : Prop) : Prop
axiom g1387 (x : Prop) : Prop
axiom g1388 (x : Prop) : Prop
axiom g1389 (x : Prop) : Prop
axiom g1390 (x : Prop) : Prop
axiom g1391 (x : Prop) : Prop
axiom g1392 (x : Prop) : Prop
axiom g1393 (x : Prop) : Prop
axiom g1394 (x : Prop) : Prop
axiom g1395 (x : Prop) : Prop
axiom g1396 (x : Prop) : Prop
axiom g1397 (x : Prop) : Prop
axiom g1398 (x : Prop) : Prop
axiom g1399 (x : Prop) : Prop
axiom g1400 (x : Prop) : Prop
axiom g1401 (x : Prop) : Prop
axiom g1402 (x : Prop) : Prop
axiom g1403 (x : Prop) : Prop
axiom g1404 (x : Prop) : Prop
axiom g1405 (x : Prop) : Prop
axiom g1406 (x : Prop) : Prop
axiom g1407 (x : Prop) : Prop
axiom g1408 (x : Prop) : Prop
axiom g1409 (x : Prop) : Prop
axiom g1410 (x : Prop) : Prop
axiom g1411 (x : Prop) : Prop
axiom g1412 (x : Prop) : Prop
axiom g1413 (x : Prop) : Prop
axiom g1414 (x : Prop) : Prop
axiom g1415 (x : Prop) : Prop
axiom g1416 (x : Prop) : Prop
axiom g1417 (x : Prop) : Prop
axiom g1418 (x : Prop) : Prop
axiom g1419 (x : Prop) : Prop
axiom g1420 (x : Prop) : Prop
axiom g1421 (x : Prop) : Prop
axiom g1422 (x : Prop) : Prop
axiom g1423 (x : Prop) : Prop
axiom g1424 (x : Prop) : Prop
axiom g1425 (x : Prop) : Prop
axiom g1426 (x : Prop) : Prop
axiom g1427 (x : Prop) : Prop
axiom g1428 (x : Prop) : Prop
axiom g1429 (x : Prop) : Prop
axiom g1430 (x : Prop) : Prop
axiom g1431 (x : Prop) : Prop
axiom g1432 (x : Prop) : Prop
axiom g1433 (x : Prop) : Prop
axiom g1434 (x : Prop) : Prop
axiom g1435 (x : Prop) : Prop
axiom g1436 (x : Prop) : Prop
axiom g1437 (x : Prop) : Prop
axiom g1438 (x : Prop) : Prop
axiom g1439 (x : Prop) : Prop
axiom g1440 (x : Prop) : Prop
axiom g1441 (x : Prop) : Prop
axiom g1442 (x : Prop) : Prop
axiom g1443 (x : Prop) : Prop
axiom g1444 (x : Prop) : Prop
axiom g1445 (x : Prop) : Prop
axiom g1446 (x : Prop) : Prop
axiom g1447 (x : Prop) : Prop
axiom g1448 (x : Prop) : Prop
axiom g1449 (x : Prop) : Prop
axiom g1450 (x : Prop) : Prop
axiom g1451 (x : Prop) : Prop
axiom g1452 (x : Prop) : Prop
axiom g1453 (x : Prop) : Prop
axiom g1454 (x : Prop) : Prop
axiom g1455 (x : Prop) : Prop
axiom g1456 (x : Prop) : Prop
axiom g1457 (x : Prop) : Prop
axiom g1458 (x : Prop) : Prop
axiom g1459 (x : Prop) : Prop
axiom g1460 (x : Prop) : Prop
axiom g1461 (x : Prop) : Prop
axiom g1462 (x : Prop) : Prop
axiom g1463 (x : Prop) : Prop
axiom g1464 (x : Prop) : Prop
axiom g1465 (x : Prop) : Prop
axiom g1466 (x : Prop) : Prop
axiom g1467 (x : Prop) : Prop
axiom g1468 (x : Prop) : Prop
axiom g1469 (x : Prop) : Prop
axiom g1470 (x : Prop) : Prop
axiom g1471 (x : Prop) : Prop
axiom g1472 (x : Prop) : Prop
axiom g1473 (x : Prop) : Prop
axiom g1474 (x : Prop) : Prop
axiom g1475 (x : Prop) : Prop
axiom g1476 (x : Prop) : Prop
axiom g1477 (x : Prop) : Prop
axiom g1478 (x : Prop) : Prop
axiom g1479 (x : Prop) : Prop
axiom g1480 (x : Prop) : Prop
axiom g1481 (x : Prop) : Prop
axiom g1482 (x : Prop) : Prop
axiom g1483 (x : Prop) : Prop
axiom g1484 (x : Prop) : Prop
axiom g1485 (x : Prop) : Prop
axiom g1486 (x : Prop) : Prop
axiom g1487 (x : Prop) : Prop
axiom g1488 (x : Prop) : Prop
axiom g1489 (x : Prop) : Prop
axiom g1490 (x : Prop) : Prop
axiom g1491 (x : Prop) : Prop
axiom g1492 (x : Prop) : Prop
axiom g1493 (x : Prop) : Prop
axiom g1494 (x : Prop) : Prop
axiom g1495 (x : Prop) : Prop
axiom g1496 (x : Prop) : Prop
axiom g1497 (x : Prop) : Prop
axiom g1498 (x : Prop) : Prop
axiom g1499 (x : Prop) : Prop
axiom g1500 (x : Prop) : Prop
axiom g1501 (x : Prop) : Prop
axiom g1502 (x : Prop) : Prop
axiom g1503 (x : Prop) : Prop
axiom g1504 (x : Prop) : Prop
axiom g1505 (x : Prop) : Prop
axiom g1506 (x : Prop) : Prop
axiom g1507 (x : Prop) : Prop
axiom g1508 (x : Prop) : Prop
axiom g1509 (x : Prop) : Prop
axiom g1510 (x : Prop) : Prop
axiom g1511 (x : Prop) : Prop
axiom g1512 (x : Prop) : Prop
axiom g1513 (x : Prop) : Prop
axiom g1514 (x : Prop) : Prop
axiom g1515 (x : Prop) : Prop
axiom g1516 (x : Prop) : Prop
axiom g1517 (x : Prop) : Prop
axiom g1518 (x : Prop) : Prop
axiom g1519 (x : Prop) : Prop
axiom g1520 (x : Prop) : Prop
axiom g1521 (x : Prop) : Prop
axiom g1522 (x : Prop) : Prop
axiom g1523 (x : Prop) : Prop
axiom g1524 (x : Prop) : Prop
axiom g1525 (x : Prop) : Prop
axiom g1526 (x : Prop) : Prop
axiom g1527 (x : Prop) : Prop
axiom g1528 (x : Prop) : Prop
axiom g1529 (x : Prop) : Prop
axiom g1530 (x : Prop) : Prop
axiom g1531 (x : Prop) : Prop
axiom g1532 (x : Prop) : Prop
axiom g1533 (x : Prop) : Prop
axiom g1534 (x : Prop) : Prop
axiom g1535 (x : Prop) : Prop
axiom g1536 (x : Prop) : Prop
axiom g1537 (x : Prop) : Prop
axiom g1538 (x : Prop) : Prop
axiom g1539 (x : Prop) : Prop
axiom g1540 (x : Prop) : Prop
axiom g1541 (x : Prop) : Prop
axiom g1542 (x : Prop) : Prop
axiom g1543 (x : Prop) : Prop
axiom g1544 (x : Prop) : Prop
axiom g1545 (x : Prop) : Prop
axiom g1546 (x : Prop) : Prop
axiom g1547 (x : Prop) : Prop
axiom g1548 (x : Prop) : Prop
axiom g1549 (x : Prop) : Prop
axiom g1550 (x : Prop) : Prop
axiom g1551 (x : Prop) : Prop
axiom g1552 (x : Prop) : Prop
axiom g1553 (x : Prop) : Prop
axiom g1554 (x : Prop) : Prop
axiom g1555 (x : Prop) : Prop
axiom g1556 (x : Prop) : Prop
axiom g1557 (x : Prop) : Prop
axiom g1558 (x : Prop) : Prop
axiom g1559 (x : Prop) : Prop
axiom g1560 (x : Prop) : Prop
axiom g1561 (x : Prop) : Prop
axiom g1562 (x : Prop) : Prop
axiom g1563 (x : Prop) : Prop
axiom g1564 (x : Prop) : Prop
axiom g1565 (x : Prop) : Prop
axiom g1566 (x : Prop) : Prop
axiom g1567 (x : Prop) : Prop
axiom g1568 (x : Prop) : Prop
axiom g1569 (x : Prop) : Prop
axiom g1570 (x : Prop) : Prop
axiom g1571 (x : Prop) : Prop
axiom g1572 (x : Prop) : Prop
axiom g1573 (x : Prop) : Prop
axiom g1574 (x : Prop) : Prop
axiom g1575 (x : Prop) : Prop
axiom g1576 (x : Prop) : Prop
axiom g1577 (x : Prop) : Prop
axiom g1578 (x : Prop) : Prop
axiom g1579 (x : Prop) : Prop
axiom g1580 (x : Prop) : Prop
axiom g1581 (x : Prop) : Prop
axiom g1582 (x : Prop) : Prop
axiom g1583 (x : Prop) : Prop
axiom g1584 (x : Prop) : Prop
axiom g1585 (x : Prop) : Prop
axiom g1586 (x : Prop) : Prop
axiom g1587 (x : Prop) : Prop
axiom g1588 (x : Prop) : Prop
axiom g1589 (x : Prop) : Prop
axiom g1590 (x : Prop) : Prop
axiom g1591 (x : Prop) : Prop
axiom g1592 (x : Prop) : Prop
axiom g1593 (x : Prop) : Prop
axiom g1594 (x : Prop) : Prop
axiom g1595 (x : Prop) : Prop
axiom g1596 (x : Prop) : Prop
axiom g1597 (x : Prop) : Prop
axiom g1598 (x : Prop) : Prop
axiom g1599 (x : Prop) : Prop
axiom g1600 (x : Prop) : Prop
axiom g1601 (x : Prop) : Prop
axiom g1602 (x : Prop) : Prop
axiom g1603 (x : Prop) : Prop
axiom g1604 (x : Prop) : Prop
axiom g1605 (x : Prop) : Prop
axiom g1606 (x : Prop) : Prop
axiom g1607 (x : Prop) : Prop
axiom g1608 (x : Prop) : Prop
axiom g1609 (x : Prop) : Prop
axiom g1610 (x : Prop) : Prop
axiom g1611 (x : Prop) : Prop
axiom g1612 (x : Prop) : Prop
axiom g1613 (x : Prop) : Prop
axiom g1614 (x : Prop) : Prop
axiom g1615 (x : Prop) : Prop
axiom g1616 (x : Prop) : Prop
axiom g1617 (x : Prop) : Prop
axiom g1618 (x : Prop) : Prop
axiom g1619 (x : Prop) : Prop
axiom g1620 (x : Prop) : Prop
axiom g1621 (x : Prop) : Prop
axiom g1622 (x : Prop) : Prop
axiom g1623 (x : Prop) : Prop
axiom g1624 (x : Prop) : Prop
axiom g1625 (x : Prop) : Prop
axiom g1626 (x : Prop) : Prop
axiom g1627 (x : Prop) : Prop
axiom g1628 (x : Prop) : Prop
axiom g1629 (x : Prop) : Prop
axiom g1630 (x : Prop) : Prop
axiom g1631 (x : Prop) : Prop
axiom g1632 (x : Prop) : Prop
axiom g1633 (x : Prop) : Prop
axiom g1634 (x : Prop) : Prop
axiom g1635 (x : Prop) : Prop
axiom g1636 (x : Prop) : Prop
axiom g1637 (x : Prop) : Prop
axiom g1638 (x : Prop) : Prop
axiom g1639 (x : Prop) : Prop
axiom g1640 (x : Prop) : Prop
axiom g1641 (x : Prop) : Prop
axiom g1642 (x : Prop) : Prop
axiom g1643 (x : Prop) : Prop
axiom g1644 (x : Prop) : Prop
axiom g1645 (x : Prop) : Prop
axiom g1646 (x : Prop) : Prop
axiom g1647 (x : Prop) : Prop
axiom g1648 (x : Prop) : Prop
axiom g1649 (x : Prop) : Prop
axiom g1650 (x : Prop) : Prop
axiom g1651 (x : Prop) : Prop
axiom g1652 (x : Prop) : Prop
axiom g1653 (x : Prop) : Prop
axiom g1654 (x : Prop) : Prop
axiom g1655 (x : Prop) : Prop
axiom g1656 (x : Prop) : Prop
axiom g1657 (x : Prop) : Prop
axiom g1658 (x : Prop) : Prop
axiom g1659 (x : Prop) : Prop
axiom g1660 (x : Prop) : Prop
axiom g1661 (x : Prop) : Prop
axiom g1662 (x : Prop) : Prop
axiom g1663 (x : Prop) : Prop
axiom g1664 (x : Prop) : Prop
axiom g1665 (x : Prop) : Prop
axiom g1666 (x : Prop) : Prop
axiom g1667 (x : Prop) : Prop
axiom g1668 (x : Prop) : Prop
axiom g1669 (x : Prop) : Prop
axiom g1670 (x : Prop) : Prop
axiom g1671 (x : Prop) : Prop
axiom g1672 (x : Prop) : Prop
axiom g1673 (x : Prop) : Prop
axiom g1674 (x : Prop) : Prop
axiom g1675 (x : Prop) : Prop
axiom g1676 (x : Prop) : Prop
axiom g1677 (x : Prop) : Prop
axiom g1678 (x : Prop) : Prop
axiom g1679 (x : Prop) : Prop
axiom g1680 (x : Prop) : Prop
axiom g1681 (x : Prop) : Prop
axiom g1682 (x : Prop) : Prop
axiom g1683 (x : Prop) : Prop
axiom g1684 (x : Prop) : Prop
axiom g1685 (x : Prop) : Prop
axiom g1686 (x : Prop) : Prop
axiom g1687 (x : Prop) : Prop
axiom g1688 (x : Prop) : Prop
axiom g1689 (x : Prop) : Prop
axiom g1690 (x : Prop) : Prop
axiom g1691 (x : Prop) : Prop
axiom g1692 (x : Prop) : Prop
axiom g1693 (x : Prop) : Prop
axiom g1694 (x : Prop) : Prop
axiom g1695 (x : Prop) : Prop
axiom g1696 (x : Prop) : Prop
axiom g1697 (x : Prop) : Prop
axiom g1698 (x : Prop) : Prop
axiom g1699 (x : Prop) : Prop
axiom g1700 (x : Prop) : Prop
axiom g1701 (x : Prop) : Prop
axiom g1702 (x : Prop) : Prop
axiom g1703 (x : Prop) : Prop
axiom g1704 (x : Prop) : Prop
axiom g1705 (x : Prop) : Prop
axiom g1706 (x : Prop) : Prop
axiom g1707 (x : Prop) : Prop
axiom g1708 (x : Prop) : Prop
axiom g1709 (x : Prop) : Prop
axiom g1710 (x : Prop) : Prop
axiom g1711 (x : Prop) : Prop
axiom g1712 (x : Prop) : Prop
axiom g1713 (x : Prop) : Prop
axiom g1714 (x : Prop) : Prop
axiom g1715 (x : Prop) : Prop
axiom g1716 (x : Prop) : Prop
axiom g1717 (x : Prop) : Prop
axiom g1718 (x : Prop) : Prop
axiom g1719 (x : Prop) : Prop
axiom g1720 (x : Prop) : Prop
axiom g1721 (x : Prop) : Prop
axiom g1722 (x : Prop) : Prop
axiom g1723 (x : Prop) : Prop
axiom g1724 (x : Prop) : Prop
axiom g1725 (x : Prop) : Prop
axiom g1726 (x : Prop) : Prop
axiom g1727 (x : Prop) : Prop
axiom g1728 (x : Prop) : Prop
axiom g1729 (x : Prop) : Prop
axiom g1730 (x : Prop) : Prop
axiom g1731 (x : Prop) : Prop
axiom g1732 (x : Prop) : Prop
axiom g1733 (x : Prop) : Prop
axiom g1734 (x : Prop) : Prop
axiom g1735 (x : Prop) : Prop
axiom g1736 (x : Prop) : Prop
axiom g1737 (x : Prop) : Prop
axiom g1738 (x : Prop) : Prop
axiom g1739 (x : Prop) : Prop
axiom g1740 (x : Prop) : Prop
axiom g1741 (x : Prop) : Prop
axiom g1742 (x : Prop) : Prop
axiom g1743 (x : Prop) : Prop
axiom g1744 (x : Prop) : Prop
axiom g1745 (x : Prop) : Prop
axiom g1746 (x : Prop) : Prop
axiom g1747 (x : Prop) : Prop
axiom g1748 (x : Prop) : Prop
axiom g1749 (x : Prop) : Prop
axiom g1750 (x : Prop) : Prop
axiom g1751 (x : Prop) : Prop
axiom g1752 (x : Prop) : Prop
axiom g1753 (x : Prop) : Prop
axiom g1754 (x : Prop) : Prop
axiom g1755 (x : Prop) : Prop
axiom g1756 (x : Prop) : Prop
axiom g1757 (x : Prop) : Prop
axiom g1758 (x : Prop) : Prop
axiom g1759 (x : Prop) : Prop
axiom g1760 (x : Prop) : Prop
axiom g1761 (x : Prop) : Prop
axiom g1762 (x : Prop) : Prop
axiom g1763 (x : Prop) : Prop
axiom g1764 (x : Prop) : Prop
axiom g1765 (x : Prop) : Prop
axiom g1766 (x : Prop) : Prop
axiom g1767 (x : Prop) : Prop
axiom g1768 (x : Prop) : Prop
axiom g1769 (x : Prop) : Prop
axiom g1770 (x : Prop) : Prop
axiom g1771 (x : Prop) : Prop
axiom g1772 (x : Prop) : Prop
axiom g1773 (x : Prop) : Prop
axiom g1774 (x : Prop) : Prop
axiom g1775 (x : Prop) : Prop
axiom g1776 (x : Prop) : Prop
axiom g1777 (x : Prop) : Prop
axiom g1778 (x : Prop) : Prop
axiom g1779 (x : Prop) : Prop
axiom g1780 (x : Prop) : Prop
axiom g1781 (x : Prop) : Prop
axiom g1782 (x : Prop) : Prop
axiom g1783 (x : Prop) : Prop
axiom g1784 (x : Prop) : Prop
axiom g1785 (x : Prop) : Prop
axiom g1786 (x : Prop) : Prop
axiom g1787 (x : Prop) : Prop
axiom g1788 (x : Prop) : Prop
axiom g1789 (x : Prop) : Prop
axiom g1790 (x : Prop) : Prop
axiom g1791 (x : Prop) : Prop
axiom g1792 (x : Prop) : Prop
axiom g1793 (x : Prop) : Prop
axiom g1794 (x : Prop) : Prop
axiom g1795 (x : Prop) : Prop
axiom g1796 (x : Prop) : Prop
axiom g1797 (x : Prop) : Prop
axiom g1798 (x : Prop) : Prop
axiom g1799 (x : Prop) : Prop
axiom g1800 (x : Prop) : Prop
axiom g1801 (x : Prop) : Prop
axiom g1802 (x : Prop) : Prop
axiom g1803 (x : Prop) : Prop
axiom g1804 (x : Prop) : Prop
axiom g1805 (x : Prop) : Prop
axiom g1806 (x : Prop) : Prop
axiom g1807 (x : Prop) : Prop
axiom g1808 (x : Prop) : Prop
axiom g1809 (x : Prop) : Prop
axiom g1810 (x : Prop) : Prop
axiom g1811 (x : Prop) : Prop
axiom g1812 (x : Prop) : Prop
axiom g1813 (x : Prop) : Prop
axiom g1814 (x : Prop) : Prop
axiom g1815 (x : Prop) : Prop
axiom g1816 (x : Prop) : Prop
axiom g1817 (x : Prop) : Prop
axiom g1818 (x : Prop) : Prop
axiom g1819 (x : Prop) : Prop
axiom g1820 (x : Prop) : Prop
axiom g1821 (x : Prop) : Prop
axiom g1822 (x : Prop) : Prop
axiom g1823 (x : Prop) : Prop
axiom g1824 (x : Prop) : Prop
axiom g1825 (x : Prop) : Prop
axiom g1826 (x : Prop) : Prop
axiom g1827 (x : Prop) : Prop
axiom g1828 (x : Prop) : Prop
axiom g1829 (x : Prop) : Prop
axiom g1830 (x : Prop) : Prop
axiom g1831 (x : Prop) : Prop
axiom g1832 (x : Prop) : Prop
axiom g1833 (x : Prop) : Prop
axiom g1834 (x : Prop) : Prop
axiom g1835 (x : Prop) : Prop
axiom g1836 (x : Prop) : Prop
axiom g1837 (x : Prop) : Prop
axiom g1838 (x : Prop) : Prop
axiom g1839 (x : Prop) : Prop
axiom g1840 (x : Prop) : Prop
axiom g1841 (x : Prop) : Prop
axiom g1842 (x : Prop) : Prop
axiom g1843 (x : Prop) : Prop
axiom g1844 (x : Prop) : Prop
axiom g1845 (x : Prop) : Prop
axiom g1846 (x : Prop) : Prop
axiom g1847 (x : Prop) : Prop
axiom g1848 (x : Prop) : Prop
axiom g1849 (x : Prop) : Prop
axiom g1850 (x : Prop) : Prop
axiom g1851 (x : Prop) : Prop
axiom g1852 (x : Prop) : Prop
axiom g1853 (x : Prop) : Prop
axiom g1854 (x : Prop) : Prop
axiom g1855 (x : Prop) : Prop
axiom g1856 (x : Prop) : Prop
axiom g1857 (x : Prop) : Prop
axiom g1858 (x : Prop) : Prop
axiom g1859 (x : Prop) : Prop
axiom g1860 (x : Prop) : Prop
axiom g1861 (x : Prop) : Prop
axiom g1862 (x : Prop) : Prop
axiom g1863 (x : Prop) : Prop
axiom g1864 (x : Prop) : Prop
axiom g1865 (x : Prop) : Prop
axiom g1866 (x : Prop) : Prop
axiom g1867 (x : Prop) : Prop
axiom g1868 (x : Prop) : Prop
axiom g1869 (x : Prop) : Prop
axiom g1870 (x : Prop) : Prop
axiom g1871 (x : Prop) : Prop
axiom g1872 (x : Prop) : Prop
axiom g1873 (x : Prop) : Prop
axiom g1874 (x : Prop) : Prop
axiom g1875 (x : Prop) : Prop
axiom g1876 (x : Prop) : Prop
axiom g1877 (x : Prop) : Prop
axiom g1878 (x : Prop) : Prop
axiom g1879 (x : Prop) : Prop
axiom g1880 (x : Prop) : Prop
axiom g1881 (x : Prop) : Prop
axiom g1882 (x : Prop) : Prop
axiom g1883 (x : Prop) : Prop
axiom g1884 (x : Prop) : Prop
axiom g1885 (x : Prop) : Prop
axiom g1886 (x : Prop) : Prop
axiom g1887 (x : Prop) : Prop
axiom g1888 (x : Prop) : Prop
axiom g1889 (x : Prop) : Prop
axiom g1890 (x : Prop) : Prop
axiom g1891 (x : Prop) : Prop
axiom g1892 (x : Prop) : Prop
axiom g1893 (x : Prop) : Prop
axiom g1894 (x : Prop) : Prop
axiom g1895 (x : Prop) : Prop
axiom g1896 (x : Prop) : Prop
axiom g1897 (x : Prop) : Prop
axiom g1898 (x : Prop) : Prop
axiom g1899 (x : Prop) : Prop
axiom g1900 (x : Prop) : Prop
axiom g1901 (x : Prop) : Prop
axiom g1902 (x : Prop) : Prop
axiom g1903 (x : Prop) : Prop
axiom g1904 (x : Prop) : Prop
axiom g1905 (x : Prop) : Prop
axiom g1906 (x : Prop) : Prop
axiom g1907 (x : Prop) : Prop
axiom g1908 (x : Prop) : Prop
axiom g1909 (x : Prop) : Prop
axiom g1910 (x : Prop) : Prop
axiom g1911 (x : Prop) : Prop
axiom g1912 (x : Prop) : Prop
axiom g1913 (x : Prop) : Prop
axiom g1914 (x : Prop) : Prop
axiom g1915 (x : Prop) : Prop
axiom g1916 (x : Prop) : Prop
axiom g1917 (x : Prop) : Prop
axiom g1918 (x : Prop) : Prop
axiom g1919 (x : Prop) : Prop
axiom g1920 (x : Prop) : Prop
axiom g1921 (x : Prop) : Prop
axiom g1922 (x : Prop) : Prop
axiom g1923 (x : Prop) : Prop
axiom g1924 (x : Prop) : Prop
axiom g1925 (x : Prop) : Prop
axiom g1926 (x : Prop) : Prop
axiom g1927 (x : Prop) : Prop
axiom g1928 (x : Prop) : Prop
axiom g1929 (x : Prop) : Prop
axiom g1930 (x : Prop) : Prop
axiom g1931 (x : Prop) : Prop
axiom g1932 (x : Prop) : Prop
axiom g1933 (x : Prop) : Prop
axiom g1934 (x : Prop) : Prop
axiom g1935 (x : Prop) : Prop
axiom g1936 (x : Prop) : Prop
axiom g1937 (x : Prop) : Prop
axiom g1938 (x : Prop) : Prop
axiom g1939 (x : Prop) : Prop
axiom g1940 (x : Prop) : Prop
axiom g1941 (x : Prop) : Prop
axiom g1942 (x : Prop) : Prop
axiom g1943 (x : Prop) : Prop
axiom g1944 (x : Prop) : Prop
axiom g1945 (x : Prop) : Prop
axiom g1946 (x : Prop) : Prop
axiom g1947 (x : Prop) : Prop
axiom g1948 (x : Prop) : Prop
axiom g1949 (x : Prop) : Prop
axiom g1950 (x : Prop) : Prop
axiom g1951 (x : Prop) : Prop
axiom g1952 (x : Prop) : Prop
axiom g1953 (x : Prop) : Prop
axiom g1954 (x : Prop) : Prop
axiom g1955 (x : Prop) : Prop
axiom g1956 (x : Prop) : Prop
axiom g1957 (x : Prop) : Prop
axiom g1958 (x : Prop) : Prop
axiom g1959 (x : Prop) : Prop
axiom g1960 (x : Prop) : Prop
axiom g1961 (x : Prop) : Prop
axiom g1962 (x : Prop) : Prop
axiom g1963 (x : Prop) : Prop
axiom g1964 (x : Prop) : Prop
axiom g1965 (x : Prop) : Prop
axiom g1966 (x : Prop) : Prop
axiom g1967 (x : Prop) : Prop
axiom g1968 (x : Prop) : Prop
axiom g1969 (x : Prop) : Prop
axiom g1970 (x : Prop) : Prop
axiom g1971 (x : Prop) : Prop
axiom g1972 (x : Prop) : Prop
axiom g1973 (x : Prop) : Prop
axiom g1974 (x : Prop) : Prop
axiom g1975 (x : Prop) : Prop
axiom g1976 (x : Prop) : Prop
axiom g1977 (x : Prop) : Prop
axiom g1978 (x : Prop) : Prop
axiom g1979 (x : Prop) : Prop
axiom g1980 (x : Prop) : Prop
axiom g1981 (x : Prop) : Prop
axiom g1982 (x : Prop) : Prop
axiom g1983 (x : Prop) : Prop
axiom g1984 (x : Prop) : Prop
axiom g1985 (x : Prop) : Prop
axiom g1986 (x : Prop) : Prop
axiom g1987 (x : Prop) : Prop
axiom g1988 (x : Prop) : Prop
axiom g1989 (x : Prop) : Prop
axiom g1990 (x : Prop) : Prop
axiom g1991 (x : Prop) : Prop
axiom g1992 (x : Prop) : Prop
axiom g1993 (x : Prop) : Prop
axiom g1994 (x : Prop) : Prop
axiom g1995 (x : Prop) : Prop
axiom g1996 (x : Prop) : Prop
axiom g1997 (x : Prop) : Prop
axiom g1998 (x : Prop) : Prop
axiom g1999 (x : Prop) : Prop
axiom g2000 (x : Prop) : Prop
axiom g2001 (x : Prop) : Prop
axiom g2002 (x : Prop) : Prop
axiom g2003 (x : Prop) : Prop
axiom g2004 (x : Prop) : Prop
axiom g2005 (x : Prop) : Prop
axiom g2006 (x : Prop) : Prop
axiom g2007 (x : Prop) : Prop
axiom g2008 (x : Prop) : Prop
axiom g2009 (x : Prop) : Prop
axiom g2010 (x : Prop) : Prop
axiom g2011 (x : Prop) : Prop
axiom g2012 (x : Prop) : Prop
axiom g2013 (x : Prop) : Prop
axiom g2014 (x : Prop) : Prop
axiom g2015 (x : Prop) : Prop
axiom g2016 (x : Prop) : Prop
axiom g2017 (x : Prop) : Prop
axiom g2018 (x : Prop) : Prop
axiom g2019 (x : Prop) : Prop
axiom g2020 (x : Prop) : Prop
axiom g2021 (x : Prop) : Prop
axiom g2022 (x : Prop) : Prop
axiom g2023 (x : Prop) : Prop
axiom g2024 (x : Prop) : Prop
axiom g2025 (x : Prop) : Prop
axiom g2026 (x : Prop) : Prop
axiom g2027 (x : Prop) : Prop
axiom g2028 (x : Prop) : Prop
axiom g2029 (x : Prop) : Prop
axiom g2030 (x : Prop) : Prop
axiom g2031 (x : Prop) : Prop
axiom g2032 (x : Prop) : Prop
axiom g2033 (x : Prop) : Prop
axiom g2034 (x : Prop) : Prop
axiom g2035 (x : Prop) : Prop
axiom g2036 (x : Prop) : Prop
axiom g2037 (x : Prop) : Prop
axiom g2038 (x : Prop) : Prop
axiom g2039 (x : Prop) : Prop
axiom g2040 (x : Prop) : Prop
axiom g2041 (x : Prop) : Prop
axiom g2042 (x : Prop) : Prop
axiom g2043 (x : Prop) : Prop
axiom g2044 (x : Prop) : Prop
axiom g2045 (x : Prop) : Prop
axiom g2046 (x : Prop) : Prop
axiom g2047 (x : Prop) : Prop
axiom g2048 (x : Prop) : Prop
axiom g2049 (x : Prop) : Prop
axiom g2050 (x : Prop) : Prop
axiom g2051 (x : Prop) : Prop
axiom g2052 (x : Prop) : Prop
axiom g2053 (x : Prop) : Prop
axiom g2054 (x : Prop) : Prop
axiom g2055 (x : Prop) : Prop
axiom g2056 (x : Prop) : Prop
axiom g2057 (x : Prop) : Prop
axiom g2058 (x : Prop) : Prop
axiom g2059 (x : Prop) : Prop
axiom g2060 (x : Prop) : Prop
axiom g2061 (x : Prop) : Prop
axiom g2062 (x : Prop) : Prop
axiom g2063 (x : Prop) : Prop
axiom g2064 (x : Prop) : Prop
axiom g2065 (x : Prop) : Prop
axiom g2066 (x : Prop) : Prop
axiom g2067 (x : Prop) : Prop
axiom g2068 (x : Prop) : Prop
axiom g2069 (x : Prop) : Prop
axiom g2070 (x : Prop) : Prop
axiom g2071 (x : Prop) : Prop
axiom g2072 (x : Prop) : Prop
axiom g2073 (x : Prop) : Prop
axiom g2074 (x : Prop) : Prop
axiom g2075 (x : Prop) : Prop
axiom g2076 (x : Prop) : Prop
axiom g2077 (x : Prop) : Prop
axiom g2078 (x : Prop) : Prop
axiom g2079 (x : Prop) : Prop
axiom g2080 (x : Prop) : Prop
axiom g2081 (x : Prop) : Prop
axiom g2082 (x : Prop) : Prop
axiom g2083 (x : Prop) : Prop
axiom g2084 (x : Prop) : Prop
axiom g2085 (x : Prop) : Prop
axiom g2086 (x : Prop) : Prop
axiom g2087 (x : Prop) : Prop
axiom g2088 (x : Prop) : Prop
axiom g2089 (x : Prop) : Prop
axiom g2090 (x : Prop) : Prop
axiom g2091 (x : Prop) : Prop
axiom g2092 (x : Prop) : Prop
axiom g2093 (x : Prop) : Prop
axiom g2094 (x : Prop) : Prop
axiom g2095 (x : Prop) : Prop
axiom g2096 (x : Prop) : Prop
axiom g2097 (x : Prop) : Prop
axiom g2098 (x : Prop) : Prop
axiom g2099 (x : Prop) : Prop
axiom g2100 (x : Prop) : Prop
axiom g2101 (x : Prop) : Prop
axiom g2102 (x : Prop) : Prop
axiom g2103 (x : Prop) : Prop
axiom g2104 (x : Prop) : Prop
axiom g2105 (x : Prop) : Prop
axiom g2106 (x : Prop) : Prop
axiom g2107 (x : Prop) : Prop
axiom g2108 (x : Prop) : Prop
axiom g2109 (x : Prop) : Prop
axiom g2110 (x : Prop) : Prop
axiom g2111 (x : Prop) : Prop
axiom g2112 (x : Prop) : Prop
axiom g2113 (x : Prop) : Prop
axiom g2114 (x : Prop) : Prop
axiom g2115 (x : Prop) : Prop
axiom g2116 (x : Prop) : Prop
axiom g2117 (x : Prop) : Prop
axiom g2118 (x : Prop) : Prop
axiom g2119 (x : Prop) : Prop
axiom g2120 (x : Prop) : Prop
axiom g2121 (x : Prop) : Prop
axiom g2122 (x : Prop) : Prop
axiom g2123 (x : Prop) : Prop
axiom g2124 (x : Prop) : Prop
axiom g2125 (x : Prop) : Prop
axiom g2126 (x : Prop) : Prop
axiom g2127 (x : Prop) : Prop
axiom g2128 (x : Prop) : Prop
axiom g2129 (x : Prop) : Prop
axiom g2130 (x : Prop) : Prop
axiom g2131 (x : Prop) : Prop
axiom g2132 (x : Prop) : Prop
axiom g2133 (x : Prop) : Prop
axiom g2134 (x : Prop) : Prop
axiom g2135 (x : Prop) : Prop
axiom g2136 (x : Prop) : Prop
axiom g2137 (x : Prop) : Prop
axiom g2138 (x : Prop) : Prop
axiom g2139 (x : Prop) : Prop
axiom g2140 (x : Prop) : Prop
axiom g2141 (x : Prop) : Prop
axiom g2142 (x : Prop) : Prop
axiom g2143 (x : Prop) : Prop
axiom g2144 (x : Prop) : Prop
axiom g2145 (x : Prop) : Prop
axiom g2146 (x : Prop) : Prop
axiom g2147 (x : Prop) : Prop
axiom g2148 (x : Prop) : Prop
axiom g2149 (x : Prop) : Prop
axiom g2150 (x : Prop) : Prop
axiom g2151 (x : Prop) : Prop
axiom g2152 (x : Prop) : Prop
axiom g2153 (x : Prop) : Prop
axiom g2154 (x : Prop) : Prop
axiom g2155 (x : Prop) : Prop
axiom g2156 (x : Prop) : Prop
axiom g2157 (x : Prop) : Prop
axiom g2158 (x : Prop) : Prop
axiom g2159 (x : Prop) : Prop
axiom g2160 (x : Prop) : Prop
axiom g2161 (x : Prop) : Prop
axiom g2162 (x : Prop) : Prop
axiom g2163 (x : Prop) : Prop
axiom g2164 (x : Prop) : Prop
axiom g2165 (x : Prop) : Prop
axiom g2166 (x : Prop) : Prop
axiom g2167 (x : Prop) : Prop
axiom g2168 (x : Prop) : Prop
axiom g2169 (x : Prop) : Prop
axiom g2170 (x : Prop) : Prop
axiom g2171 (x : Prop) : Prop
axiom g2172 (x : Prop) : Prop
axiom g2173 (x : Prop) : Prop
axiom g2174 (x : Prop) : Prop
axiom g2175 (x : Prop) : Prop
axiom g2176 (x : Prop) : Prop
axiom g2177 (x : Prop) : Prop
axiom g2178 (x : Prop) : Prop
axiom g2179 (x : Prop) : Prop
axiom g2180 (x : Prop) : Prop
axiom g2181 (x : Prop) : Prop
axiom g2182 (x : Prop) : Prop
axiom g2183 (x : Prop) : Prop
axiom g2184 (x : Prop) : Prop
axiom g2185 (x : Prop) : Prop
axiom g2186 (x : Prop) : Prop
axiom g2187 (x : Prop) : Prop
axiom g2188 (x : Prop) : Prop
axiom g2189 (x : Prop) : Prop
axiom g2190 (x : Prop) : Prop
axiom g2191 (x : Prop) : Prop
axiom g2192 (x : Prop) : Prop
axiom g2193 (x : Prop) : Prop
axiom g2194 (x : Prop) : Prop
axiom g2195 (x : Prop) : Prop
axiom g2196 (x : Prop) : Prop
axiom g2197 (x : Prop) : Prop
axiom g2198 (x : Prop) : Prop
axiom g2199 (x : Prop) : Prop
axiom g2200 (x : Prop) : Prop
axiom g2201 (x : Prop) : Prop
axiom g2202 (x : Prop) : Prop
axiom g2203 (x : Prop) : Prop
axiom g2204 (x : Prop) : Prop
axiom g2205 (x : Prop) : Prop
axiom g2206 (x : Prop) : Prop
axiom g2207 (x : Prop) : Prop
axiom g2208 (x : Prop) : Prop
axiom g2209 (x : Prop) : Prop
axiom g2210 (x : Prop) : Prop
axiom g2211 (x : Prop) : Prop
axiom g2212 (x : Prop) : Prop
axiom g2213 (x : Prop) : Prop
axiom g2214 (x : Prop) : Prop
axiom g2215 (x : Prop) : Prop
axiom g2216 (x : Prop) : Prop
axiom g2217 (x : Prop) : Prop
axiom g2218 (x : Prop) : Prop
axiom g2219 (x : Prop) : Prop
axiom g2220 (x : Prop) : Prop
axiom g2221 (x : Prop) : Prop
axiom g2222 (x : Prop) : Prop
axiom g2223 (x : Prop) : Prop
axiom g2224 (x : Prop) : Prop
axiom g2225 (x : Prop) : Prop
axiom g2226 (x : Prop) : Prop
axiom g2227 (x : Prop) : Prop
axiom g2228 (x : Prop) : Prop
axiom g2229 (x : Prop) : Prop
axiom g2230 (x : Prop) : Prop
axiom g2231 (x : Prop) : Prop
axiom g2232 (x : Prop) : Prop
axiom g2233 (x : Prop) : Prop
axiom g2234 (x : Prop) : Prop
axiom g2235 (x : Prop) : Prop
axiom g2236 (x : Prop) : Prop
axiom g2237 (x : Prop) : Prop
axiom g2238 (x : Prop) : Prop
axiom g2239 (x : Prop) : Prop
axiom g2240 (x : Prop) : Prop
axiom g2241 (x : Prop) : Prop
axiom g2242 (x : Prop) : Prop
axiom g2243 (x : Prop) : Prop
axiom g2244 (x : Prop) : Prop
axiom g2245 (x : Prop) : Prop
axiom g2246 (x : Prop) : Prop
axiom g2247 (x : Prop) : Prop
axiom g2248 (x : Prop) : Prop
axiom g2249 (x : Prop) : Prop
axiom g2250 (x : Prop) : Prop
axiom g2251 (x : Prop) : Prop
axiom g2252 (x : Prop) : Prop
axiom g2253 (x : Prop) : Prop
axiom g2254 (x : Prop) : Prop
axiom g2255 (x : Prop) : Prop
axiom g2256 (x : Prop) : Prop
axiom g2257 (x : Prop) : Prop
axiom g2258 (x : Prop) : Prop
axiom g2259 (x : Prop) : Prop
axiom g2260 (x : Prop) : Prop
axiom g2261 (x : Prop) : Prop
axiom g2262 (x : Prop) : Prop
axiom g2263 (x : Prop) : Prop
axiom g2264 (x : Prop) : Prop
axiom g2265 (x : Prop) : Prop
axiom g2266 (x : Prop) : Prop
axiom g2267 (x : Prop) : Prop
axiom g2268 (x : Prop) : Prop
axiom g2269 (x : Prop) : Prop
axiom g2270 (x : Prop) : Prop
axiom g2271 (x : Prop) : Prop
axiom g2272 (x : Prop) : Prop
axiom g2273 (x : Prop) : Prop
axiom g2274 (x : Prop) : Prop
axiom g2275 (x : Prop) : Prop
axiom g2276 (x : Prop) : Prop
axiom g2277 (x : Prop) : Prop
axiom g2278 (x : Prop) : Prop
axiom g2279 (x : Prop) : Prop
axiom g2280 (x : Prop) : Prop
axiom g2281 (x : Prop) : Prop
axiom g2282 (x : Prop) : Prop
axiom g2283 (x : Prop) : Prop
axiom g2284 (x : Prop) : Prop
axiom g2285 (x : Prop) : Prop
axiom g2286 (x : Prop) : Prop
axiom g2287 (x : Prop) : Prop
axiom g2288 (x : Prop) : Prop
axiom g2289 (x : Prop) : Prop
axiom g2290 (x : Prop) : Prop
axiom g2291 (x : Prop) : Prop
axiom g2292 (x : Prop) : Prop
axiom g2293 (x : Prop) : Prop
axiom g2294 (x : Prop) : Prop
axiom g2295 (x : Prop) : Prop
axiom g2296 (x : Prop) : Prop
axiom g2297 (x : Prop) : Prop
axiom g2298 (x : Prop) : Prop
axiom g2299 (x : Prop) : Prop
axiom g2300 (x : Prop) : Prop
axiom g2301 (x : Prop) : Prop
axiom g2302 (x : Prop) : Prop
axiom g2303 (x : Prop) : Prop
axiom g2304 (x : Prop) : Prop
axiom g2305 (x : Prop) : Prop
axiom g2306 (x : Prop) : Prop
axiom g2307 (x : Prop) : Prop
axiom g2308 (x : Prop) : Prop
axiom g2309 (x : Prop) : Prop
axiom g2310 (x : Prop) : Prop
axiom g2311 (x : Prop) : Prop
axiom g2312 (x : Prop) : Prop
axiom g2313 (x : Prop) : Prop
axiom g2314 (x : Prop) : Prop
axiom g2315 (x : Prop) : Prop
axiom g2316 (x : Prop) : Prop
axiom g2317 (x : Prop) : Prop
axiom g2318 (x : Prop) : Prop
axiom g2319 (x : Prop) : Prop
axiom g2320 (x : Prop) : Prop
axiom g2321 (x : Prop) : Prop
axiom g2322 (x : Prop) : Prop
axiom g2323 (x : Prop) : Prop
axiom g2324 (x : Prop) : Prop
axiom g2325 (x : Prop) : Prop
axiom g2326 (x : Prop) : Prop
axiom g2327 (x : Prop) : Prop
axiom g2328 (x : Prop) : Prop
axiom g2329 (x : Prop) : Prop
axiom g2330 (x : Prop) : Prop
axiom g2331 (x : Prop) : Prop
axiom g2332 (x : Prop) : Prop
axiom g2333 (x : Prop) : Prop
axiom g2334 (x : Prop) : Prop
axiom g2335 (x : Prop) : Prop
axiom g2336 (x : Prop) : Prop
axiom g2337 (x : Prop) : Prop
axiom g2338 (x : Prop) : Prop
axiom g2339 (x : Prop) : Prop
axiom g2340 (x : Prop) : Prop
axiom g2341 (x : Prop) : Prop
axiom g2342 (x : Prop) : Prop
axiom g2343 (x : Prop) : Prop
axiom g2344 (x : Prop) : Prop
axiom g2345 (x : Prop) : Prop
axiom g2346 (x : Prop) : Prop
axiom g2347 (x : Prop) : Prop
axiom g2348 (x : Prop) : Prop
axiom g2349 (x : Prop) : Prop
axiom g2350 (x : Prop) : Prop
axiom g2351 (x : Prop) : Prop
axiom g2352 (x : Prop) : Prop
axiom g2353 (x : Prop) : Prop
axiom g2354 (x : Prop) : Prop
axiom g2355 (x : Prop) : Prop
axiom g2356 (x : Prop) : Prop
axiom g2357 (x : Prop) : Prop
axiom g2358 (x : Prop) : Prop
axiom g2359 (x : Prop) : Prop
axiom g2360 (x : Prop) : Prop
axiom g2361 (x : Prop) : Prop
axiom g2362 (x : Prop) : Prop
axiom g2363 (x : Prop) : Prop
axiom g2364 (x : Prop) : Prop
axiom g2365 (x : Prop) : Prop
axiom g2366 (x : Prop) : Prop
axiom g2367 (x : Prop) : Prop
axiom g2368 (x : Prop) : Prop
axiom g2369 (x : Prop) : Prop
axiom g2370 (x : Prop) : Prop
axiom g2371 (x : Prop) : Prop
axiom g2372 (x : Prop) : Prop
axiom g2373 (x : Prop) : Prop
axiom g2374 (x : Prop) : Prop
axiom g2375 (x : Prop) : Prop
axiom g2376 (x : Prop) : Prop
axiom g2377 (x : Prop) : Prop
axiom g2378 (x : Prop) : Prop
axiom g2379 (x : Prop) : Prop
axiom g2380 (x : Prop) : Prop
axiom g2381 (x : Prop) : Prop
axiom g2382 (x : Prop) : Prop
axiom g2383 (x : Prop) : Prop
axiom g2384 (x : Prop) : Prop
axiom g2385 (x : Prop) : Prop
axiom g2386 (x : Prop) : Prop
axiom g2387 (x : Prop) : Prop
axiom g2388 (x : Prop) : Prop
axiom g2389 (x : Prop) : Prop
axiom g2390 (x : Prop) : Prop
axiom g2391 (x : Prop) : Prop
axiom g2392 (x : Prop) : Prop
axiom g2393 (x : Prop) : Prop
axiom g2394 (x : Prop) : Prop
axiom g2395 (x : Prop) : Prop
axiom g2396 (x : Prop) : Prop
axiom g2397 (x : Prop) : Prop
axiom g2398 (x : Prop) : Prop
axiom g2399 (x : Prop) : Prop
axiom g2400 (x : Prop) : Prop
axiom g2401 (x : Prop) : Prop
axiom g2402 (x : Prop) : Prop
axiom g2403 (x : Prop) : Prop
axiom g2404 (x : Prop) : Prop
axiom g2405 (x : Prop) : Prop
axiom g2406 (x : Prop) : Prop
axiom g2407 (x : Prop) : Prop
axiom g2408 (x : Prop) : Prop
axiom g2409 (x : Prop) : Prop
axiom g2410 (x : Prop) : Prop
axiom g2411 (x : Prop) : Prop
axiom g2412 (x : Prop) : Prop
axiom g2413 (x : Prop) : Prop
axiom g2414 (x : Prop) : Prop
axiom g2415 (x : Prop) : Prop
axiom g2416 (x : Prop) : Prop
axiom g2417 (x : Prop) : Prop
axiom g2418 (x : Prop) : Prop
axiom g2419 (x : Prop) : Prop
axiom g2420 (x : Prop) : Prop
axiom g2421 (x : Prop) : Prop
axiom g2422 (x : Prop) : Prop
axiom g2423 (x : Prop) : Prop
axiom g2424 (x : Prop) : Prop
axiom g2425 (x : Prop) : Prop
axiom g2426 (x : Prop) : Prop
axiom g2427 (x : Prop) : Prop
axiom g2428 (x : Prop) : Prop
axiom g2429 (x : Prop) : Prop
axiom g2430 (x : Prop) : Prop
axiom g2431 (x : Prop) : Prop
axiom g2432 (x : Prop) : Prop
axiom g2433 (x : Prop) : Prop
axiom g2434 (x : Prop) : Prop
axiom g2435 (x : Prop) : Prop
axiom g2436 (x : Prop) : Prop
axiom g2437 (x : Prop) : Prop
axiom g2438 (x : Prop) : Prop
axiom g2439 (x : Prop) : Prop
axiom g2440 (x : Prop) : Prop
axiom g2441 (x : Prop) : Prop
axiom g2442 (x : Prop) : Prop
axiom g2443 (x : Prop) : Prop
axiom g2444 (x : Prop) : Prop
axiom g2445 (x : Prop) : Prop
axiom g2446 (x : Prop) : Prop
axiom g2447 (x : Prop) : Prop
axiom g2448 (x : Prop) : Prop
axiom g2449 (x : Prop) : Prop
axiom g2450 (x : Prop) : Prop
axiom g2451 (x : Prop) : Prop
axiom g2452 (x : Prop) : Prop
axiom g2453 (x : Prop) : Prop
axiom g2454 (x : Prop) : Prop
axiom g2455 (x : Prop) : Prop
axiom g2456 (x : Prop) : Prop
axiom g2457 (x : Prop) : Prop
axiom g2458 (x : Prop) : Prop
axiom g2459 (x : Prop) : Prop
axiom g2460 (x : Prop) : Prop
axiom g2461 (x : Prop) : Prop
axiom g2462 (x : Prop) : Prop
axiom g2463 (x : Prop) : Prop
axiom g2464 (x : Prop) : Prop
axiom g2465 (x : Prop) : Prop
axiom g2466 (x : Prop) : Prop
axiom g2467 (x : Prop) : Prop
axiom g2468 (x : Prop) : Prop
axiom g2469 (x : Prop) : Prop
axiom g2470 (x : Prop) : Prop
axiom g2471 (x : Prop) : Prop
axiom g2472 (x : Prop) : Prop
axiom g2473 (x : Prop) : Prop
axiom g2474 (x : Prop) : Prop
axiom g2475 (x : Prop) : Prop
axiom g2476 (x : Prop) : Prop
axiom g2477 (x : Prop) : Prop
axiom g2478 (x : Prop) : Prop
axiom g2479 (x : Prop) : Prop
axiom g2480 (x : Prop) : Prop
axiom g2481 (x : Prop) : Prop
axiom g2482 (x : Prop) : Prop
axiom g2483 (x : Prop) : Prop
axiom g2484 (x : Prop) : Prop
axiom g2485 (x : Prop) : Prop
axiom g2486 (x : Prop) : Prop
axiom g2487 (x : Prop) : Prop
axiom g2488 (x : Prop) : Prop
axiom g2489 (x : Prop) : Prop
axiom g2490 (x : Prop) : Prop
axiom g2491 (x : Prop) : Prop
axiom g2492 (x : Prop) : Prop
axiom g2493 (x : Prop) : Prop
axiom g2494 (x : Prop) : Prop
axiom g2495 (x : Prop) : Prop
axiom g2496 (x : Prop) : Prop
axiom g2497 (x : Prop) : Prop
axiom g2498 (x : Prop) : Prop
axiom g2499 (x : Prop) : Prop
axiom g2500 (x : Prop) : Prop
axiom g2501 (x : Prop) : Prop
axiom g2502 (x : Prop) : Prop
axiom g2503 (x : Prop) : Prop
axiom g2504 (x : Prop) : Prop
axiom g2505 (x : Prop) : Prop
axiom g2506 (x : Prop) : Prop
axiom g2507 (x : Prop) : Prop
axiom g2508 (x : Prop) : Prop
axiom g2509 (x : Prop) : Prop
axiom g2510 (x : Prop) : Prop
axiom g2511 (x : Prop) : Prop
axiom g2512 (x : Prop) : Prop
axiom g2513 (x : Prop) : Prop
axiom g2514 (x : Prop) : Prop
axiom g2515 (x : Prop) : Prop
axiom g2516 (x : Prop) : Prop
axiom g2517 (x : Prop) : Prop
axiom g2518 (x : Prop) : Prop
axiom g2519 (x : Prop) : Prop
axiom g2520 (x : Prop) : Prop
axiom g2521 (x : Prop) : Prop
axiom g2522 (x : Prop) : Prop
axiom g2523 (x : Prop) : Prop
axiom g2524 (x : Prop) : Prop
axiom g2525 (x : Prop) : Prop
axiom g2526 (x : Prop) : Prop
axiom g2527 (x : Prop) : Prop
axiom g2528 (x : Prop) : Prop
axiom g2529 (x : Prop) : Prop
axiom g2530 (x : Prop) : Prop
axiom g2531 (x : Prop) : Prop
axiom g2532 (x : Prop) : Prop
axiom g2533 (x : Prop) : Prop
axiom g2534 (x : Prop) : Prop
axiom g2535 (x : Prop) : Prop
axiom g2536 (x : Prop) : Prop
axiom g2537 (x : Prop) : Prop
axiom g2538 (x : Prop) : Prop
axiom g2539 (x : Prop) : Prop
axiom g2540 (x : Prop) : Prop
axiom g2541 (x : Prop) : Prop
axiom g2542 (x : Prop) : Prop
axiom g2543 (x : Prop) : Prop
axiom g2544 (x : Prop) : Prop
axiom g2545 (x : Prop) : Prop
axiom g2546 (x : Prop) : Prop
axiom g2547 (x : Prop) : Prop
axiom g2548 (x : Prop) : Prop
axiom g2549 (x : Prop) : Prop
axiom g2550 (x : Prop) : Prop
axiom g2551 (x : Prop) : Prop
axiom g2552 (x : Prop) : Prop
axiom g2553 (x : Prop) : Prop
axiom g2554 (x : Prop) : Prop
axiom g2555 (x : Prop) : Prop
axiom g2556 (x : Prop) : Prop
axiom g2557 (x : Prop) : Prop
axiom g2558 (x : Prop) : Prop
axiom g2559 (x : Prop) : Prop
axiom g2560 (x : Prop) : Prop
axiom g2561 (x : Prop) : Prop
axiom g2562 (x : Prop) : Prop
axiom g2563 (x : Prop) : Prop
axiom g2564 (x : Prop) : Prop
axiom g2565 (x : Prop) : Prop
axiom g2566 (x : Prop) : Prop
axiom g2567 (x : Prop) : Prop
axiom g2568 (x : Prop) : Prop
axiom g2569 (x : Prop) : Prop
axiom g2570 (x : Prop) : Prop
axiom g2571 (x : Prop) : Prop
axiom g2572 (x : Prop) : Prop
axiom g2573 (x : Prop) : Prop
axiom g2574 (x : Prop) : Prop
axiom g2575 (x : Prop) : Prop
axiom g2576 (x : Prop) : Prop
axiom g2577 (x : Prop) : Prop
axiom g2578 (x : Prop) : Prop
axiom g2579 (x : Prop) : Prop
axiom g2580 (x : Prop) : Prop
axiom g2581 (x : Prop) : Prop
axiom g2582 (x : Prop) : Prop
axiom g2583 (x : Prop) : Prop
axiom g2584 (x : Prop) : Prop
axiom g2585 (x : Prop) : Prop
axiom g2586 (x : Prop) : Prop
axiom g2587 (x : Prop) : Prop
axiom g2588 (x : Prop) : Prop
axiom g2589 (x : Prop) : Prop
axiom g2590 (x : Prop) : Prop
axiom g2591 (x : Prop) : Prop
axiom g2592 (x : Prop) : Prop
axiom g2593 (x : Prop) : Prop
axiom g2594 (x : Prop) : Prop
axiom g2595 (x : Prop) : Prop
axiom g2596 (x : Prop) : Prop
axiom g2597 (x : Prop) : Prop
axiom g2598 (x : Prop) : Prop
axiom g2599 (x : Prop) : Prop
axiom g2600 (x : Prop) : Prop
axiom g2601 (x : Prop) : Prop
axiom g2602 (x : Prop) : Prop
axiom g2603 (x : Prop) : Prop
axiom g2604 (x : Prop) : Prop
axiom g2605 (x : Prop) : Prop
axiom g2606 (x : Prop) : Prop
axiom g2607 (x : Prop) : Prop
axiom g2608 (x : Prop) : Prop
axiom g2609 (x : Prop) : Prop
axiom g2610 (x : Prop) : Prop
axiom g2611 (x : Prop) : Prop
axiom g2612 (x : Prop) : Prop
axiom g2613 (x : Prop) : Prop
axiom g2614 (x : Prop) : Prop
axiom g2615 (x : Prop) : Prop
axiom g2616 (x : Prop) : Prop
axiom g2617 (x : Prop) : Prop
axiom g2618 (x : Prop) : Prop
axiom g2619 (x : Prop) : Prop
axiom g2620 (x : Prop) : Prop
axiom g2621 (x : Prop) : Prop
axiom g2622 (x : Prop) : Prop
axiom g2623 (x : Prop) : Prop
axiom g2624 (x : Prop) : Prop
axiom g2625 (x : Prop) : Prop
axiom g2626 (x : Prop) : Prop
axiom g2627 (x : Prop) : Prop
axiom g2628 (x : Prop) : Prop
axiom g2629 (x : Prop) : Prop
axiom g2630 (x : Prop) : Prop
axiom g2631 (x : Prop) : Prop
axiom g2632 (x : Prop) : Prop
axiom g2633 (x : Prop) : Prop
axiom g2634 (x : Prop) : Prop
axiom g2635 (x : Prop) : Prop
axiom g2636 (x : Prop) : Prop
axiom g2637 (x : Prop) : Prop
axiom g2638 (x : Prop) : Prop
axiom g2639 (x : Prop) : Prop
axiom g2640 (x : Prop) : Prop
axiom g2641 (x : Prop) : Prop
axiom g2642 (x : Prop) : Prop
axiom g2643 (x : Prop) : Prop
axiom g2644 (x : Prop) : Prop
axiom g2645 (x : Prop) : Prop
axiom g2646 (x : Prop) : Prop
axiom g2647 (x : Prop) : Prop
axiom g2648 (x : Prop) : Prop
axiom g2649 (x : Prop) : Prop
axiom g2650 (x : Prop) : Prop
axiom g2651 (x : Prop) : Prop
axiom g2652 (x : Prop) : Prop
axiom g2653 (x : Prop) : Prop
axiom g2654 (x : Prop) : Prop
axiom g2655 (x : Prop) : Prop
axiom g2656 (x : Prop) : Prop
axiom g2657 (x : Prop) : Prop
axiom g2658 (x : Prop) : Prop
axiom g2659 (x : Prop) : Prop
axiom g2660 (x : Prop) : Prop
axiom g2661 (x : Prop) : Prop
axiom g2662 (x : Prop) : Prop
axiom g2663 (x : Prop) : Prop
axiom g2664 (x : Prop) : Prop
axiom g2665 (x : Prop) : Prop
axiom g2666 (x : Prop) : Prop
axiom g2667 (x : Prop) : Prop
axiom g2668 (x : Prop) : Prop
axiom g2669 (x : Prop) : Prop
axiom g2670 (x : Prop) : Prop
axiom g2671 (x : Prop) : Prop
axiom g2672 (x : Prop) : Prop
axiom g2673 (x : Prop) : Prop
axiom g2674 (x : Prop) : Prop
axiom g2675 (x : Prop) : Prop
axiom g2676 (x : Prop) : Prop
axiom g2677 (x : Prop) : Prop
axiom g2678 (x : Prop) : Prop
axiom g2679 (x : Prop) : Prop
axiom g2680 (x : Prop) : Prop
axiom g2681 (x : Prop) : Prop
axiom g2682 (x : Prop) : Prop
axiom g2683 (x : Prop) : Prop
axiom g2684 (x : Prop) : Prop
axiom g2685 (x : Prop) : Prop
axiom g2686 (x : Prop) : Prop
axiom g2687 (x : Prop) : Prop
axiom g2688 (x : Prop) : Prop
axiom g2689 (x : Prop) : Prop
axiom g2690 (x : Prop) : Prop
axiom g2691 (x : Prop) : Prop
axiom g2692 (x : Prop) : Prop
axiom g2693 (x : Prop) : Prop
axiom g2694 (x : Prop) : Prop
axiom g2695 (x : Prop) : Prop
axiom g2696 (x : Prop) : Prop
axiom g2697 (x : Prop) : Prop
axiom g2698 (x : Prop) : Prop
axiom g2699 (x : Prop) : Prop
axiom g2700 (x : Prop) : Prop
axiom g2701 (x : Prop) : Prop
axiom g2702 (x : Prop) : Prop
axiom g2703 (x : Prop) : Prop
axiom g2704 (x : Prop) : Prop
axiom g2705 (x : Prop) : Prop
axiom g2706 (x : Prop) : Prop
axiom g2707 (x : Prop) : Prop
axiom g2708 (x : Prop) : Prop
axiom g2709 (x : Prop) : Prop
axiom g2710 (x : Prop) : Prop
axiom g2711 (x : Prop) : Prop
axiom g2712 (x : Prop) : Prop
axiom g2713 (x : Prop) : Prop
axiom g2714 (x : Prop) : Prop
axiom g2715 (x : Prop) : Prop
axiom g2716 (x : Prop) : Prop
axiom g2717 (x : Prop) : Prop
axiom g2718 (x : Prop) : Prop
axiom g2719 (x : Prop) : Prop
axiom g2720 (x : Prop) : Prop
axiom g2721 (x : Prop) : Prop
axiom g2722 (x : Prop) : Prop
axiom g2723 (x : Prop) : Prop
axiom g2724 (x : Prop) : Prop
axiom g2725 (x : Prop) : Prop
axiom g2726 (x : Prop) : Prop
axiom g2727 (x : Prop) : Prop
axiom g2728 (x : Prop) : Prop
axiom g2729 (x : Prop) : Prop
axiom g2730 (x : Prop) : Prop
axiom g2731 (x : Prop) : Prop
axiom g2732 (x : Prop) : Prop
axiom g2733 (x : Prop) : Prop
axiom g2734 (x : Prop) : Prop
axiom g2735 (x : Prop) : Prop
axiom g2736 (x : Prop) : Prop
axiom g2737 (x : Prop) : Prop
axiom g2738 (x : Prop) : Prop
axiom g2739 (x : Prop) : Prop
axiom g2740 (x : Prop) : Prop
axiom g2741 (x : Prop) : Prop
axiom g2742 (x : Prop) : Prop
axiom g2743 (x : Prop) : Prop
axiom g2744 (x : Prop) : Prop
axiom g2745 (x : Prop) : Prop
axiom g2746 (x : Prop) : Prop
axiom g2747 (x : Prop) : Prop
axiom g2748 (x : Prop) : Prop
axiom g2749 (x : Prop) : Prop
axiom g2750 (x : Prop) : Prop
axiom g2751 (x : Prop) : Prop
axiom g2752 (x : Prop) : Prop
axiom g2753 (x : Prop) : Prop
axiom g2754 (x : Prop) : Prop
axiom g2755 (x : Prop) : Prop
axiom g2756 (x : Prop) : Prop
axiom g2757 (x : Prop) : Prop
axiom g2758 (x : Prop) : Prop
axiom g2759 (x : Prop) : Prop
axiom g2760 (x : Prop) : Prop
axiom g2761 (x : Prop) : Prop
axiom g2762 (x : Prop) : Prop
axiom g2763 (x : Prop) : Prop
axiom g2764 (x : Prop) : Prop
axiom g2765 (x : Prop) : Prop
axiom g2766 (x : Prop) : Prop
axiom g2767 (x : Prop) : Prop
axiom g2768 (x : Prop) : Prop
axiom g2769 (x : Prop) : Prop
axiom g2770 (x : Prop) : Prop
axiom g2771 (x : Prop) : Prop
axiom g2772 (x : Prop) : Prop
axiom g2773 (x : Prop) : Prop
axiom g2774 (x : Prop) : Prop
axiom g2775 (x : Prop) : Prop
axiom g2776 (x : Prop) : Prop
axiom g2777 (x : Prop) : Prop
axiom g2778 (x : Prop) : Prop
axiom g2779 (x : Prop) : Prop
axiom g2780 (x : Prop) : Prop
axiom g2781 (x : Prop) : Prop
axiom g2782 (x : Prop) : Prop
axiom g2783 (x : Prop) : Prop
axiom g2784 (x : Prop) : Prop
axiom g2785 (x : Prop) : Prop
axiom g2786 (x : Prop) : Prop
axiom g2787 (x : Prop) : Prop
axiom g2788 (x : Prop) : Prop
axiom g2789 (x : Prop) : Prop
axiom g2790 (x : Prop) : Prop
axiom g2791 (x : Prop) : Prop
axiom g2792 (x : Prop) : Prop
axiom g2793 (x : Prop) : Prop
axiom g2794 (x : Prop) : Prop
axiom g2795 (x : Prop) : Prop
axiom g2796 (x : Prop) : Prop
axiom g2797 (x : Prop) : Prop
axiom g2798 (x : Prop) : Prop
axiom g2799 (x : Prop) : Prop
axiom g2800 (x : Prop) : Prop
axiom g2801 (x : Prop) : Prop
axiom g2802 (x : Prop) : Prop
axiom g2803 (x : Prop) : Prop
axiom g2804 (x : Prop) : Prop
axiom g2805 (x : Prop) : Prop
axiom g2806 (x : Prop) : Prop
axiom g2807 (x : Prop) : Prop
axiom g2808 (x : Prop) : Prop
axiom g2809 (x : Prop) : Prop
axiom g2810 (x : Prop) : Prop
axiom g2811 (x : Prop) : Prop
axiom g2812 (x : Prop) : Prop
axiom g2813 (x : Prop) : Prop
axiom g2814 (x : Prop) : Prop
axiom g2815 (x : Prop) : Prop
axiom g2816 (x : Prop) : Prop
axiom g2817 (x : Prop) : Prop
axiom g2818 (x : Prop) : Prop
axiom g2819 (x : Prop) : Prop
axiom g2820 (x : Prop) : Prop
axiom g2821 (x : Prop) : Prop
axiom g2822 (x : Prop) : Prop
axiom g2823 (x : Prop) : Prop
axiom g2824 (x : Prop) : Prop
axiom g2825 (x : Prop) : Prop
axiom g2826 (x : Prop) : Prop
axiom g2827 (x : Prop) : Prop
axiom g2828 (x : Prop) : Prop
axiom g2829 (x : Prop) : Prop
axiom g2830 (x : Prop) : Prop
axiom g2831 (x : Prop) : Prop
axiom g2832 (x : Prop) : Prop
axiom g2833 (x : Prop) : Prop
axiom g2834 (x : Prop) : Prop
axiom g2835 (x : Prop) : Prop
axiom g2836 (x : Prop) : Prop
axiom g2837 (x : Prop) : Prop
axiom g2838 (x : Prop) : Prop
axiom g2839 (x : Prop) : Prop
axiom g2840 (x : Prop) : Prop
axiom g2841 (x : Prop) : Prop
axiom g2842 (x : Prop) : Prop
axiom g2843 (x : Prop) : Prop
axiom g2844 (x : Prop) : Prop
axiom g2845 (x : Prop) : Prop
axiom g2846 (x : Prop) : Prop
axiom g2847 (x : Prop) : Prop
axiom g2848 (x : Prop) : Prop
axiom g2849 (x : Prop) : Prop
axiom g2850 (x : Prop) : Prop
axiom g2851 (x : Prop) : Prop
axiom g2852 (x : Prop) : Prop
axiom g2853 (x : Prop) : Prop
axiom g2854 (x : Prop) : Prop
axiom g2855 (x : Prop) : Prop
axiom g2856 (x : Prop) : Prop
axiom g2857 (x : Prop) : Prop
axiom g2858 (x : Prop) : Prop
axiom g2859 (x : Prop) : Prop
axiom g2860 (x : Prop) : Prop
axiom g2861 (x : Prop) : Prop
axiom g2862 (x : Prop) : Prop
axiom g2863 (x : Prop) : Prop
axiom g2864 (x : Prop) : Prop
axiom g2865 (x : Prop) : Prop
axiom g2866 (x : Prop) : Prop
axiom g2867 (x : Prop) : Prop
axiom g2868 (x : Prop) : Prop
axiom g2869 (x : Prop) : Prop
axiom g2870 (x : Prop) : Prop
axiom g2871 (x : Prop) : Prop
axiom g2872 (x : Prop) : Prop
axiom g2873 (x : Prop) : Prop
axiom g2874 (x : Prop) : Prop
axiom g2875 (x : Prop) : Prop
axiom g2876 (x : Prop) : Prop
axiom g2877 (x : Prop) : Prop
axiom g2878 (x : Prop) : Prop
axiom g2879 (x : Prop) : Prop
axiom g2880 (x : Prop) : Prop
axiom g2881 (x : Prop) : Prop
axiom g2882 (x : Prop) : Prop
axiom g2883 (x : Prop) : Prop
axiom g2884 (x : Prop) : Prop
axiom g2885 (x : Prop) : Prop
axiom g2886 (x : Prop) : Prop
axiom g2887 (x : Prop) : Prop
axiom g2888 (x : Prop) : Prop
axiom g2889 (x : Prop) : Prop
axiom g2890 (x : Prop) : Prop
axiom g2891 (x : Prop) : Prop
axiom g2892 (x : Prop) : Prop
axiom g2893 (x : Prop) : Prop
axiom g2894 (x : Prop) : Prop
axiom g2895 (x : Prop) : Prop
axiom g2896 (x : Prop) : Prop
axiom g2897 (x : Prop) : Prop
axiom g2898 (x : Prop) : Prop
axiom g2899 (x : Prop) : Prop
axiom g2900 (x : Prop) : Prop
axiom g2901 (x : Prop) : Prop
axiom g2902 (x : Prop) : Prop
axiom g2903 (x : Prop) : Prop
axiom g2904 (x : Prop) : Prop
axiom g2905 (x : Prop) : Prop
axiom g2906 (x : Prop) : Prop
axiom g2907 (x : Prop) : Prop
axiom g2908 (x : Prop) : Prop
axiom g2909 (x : Prop) : Prop
axiom g2910 (x : Prop) : Prop
axiom g2911 (x : Prop) : Prop
axiom g2912 (x : Prop) : Prop
axiom g2913 (x : Prop) : Prop
axiom g2914 (x : Prop) : Prop
axiom g2915 (x : Prop) : Prop
axiom g2916 (x : Prop) : Prop
axiom g2917 (x : Prop) : Prop
axiom g2918 (x : Prop) : Prop
axiom g2919 (x : Prop) : Prop
axiom g2920 (x : Prop) : Prop
axiom g2921 (x : Prop) : Prop
axiom g2922 (x : Prop) : Prop
axiom g2923 (x : Prop) : Prop
axiom g2924 (x : Prop) : Prop
axiom g2925 (x : Prop) : Prop
axiom g2926 (x : Prop) : Prop
axiom g2927 (x : Prop) : Prop
axiom g2928 (x : Prop) : Prop
axiom g2929 (x : Prop) : Prop
axiom g2930 (x : Prop) : Prop
axiom g2931 (x : Prop) : Prop
axiom g2932 (x : Prop) : Prop
axiom g2933 (x : Prop) : Prop
axiom g2934 (x : Prop) : Prop
axiom g2935 (x : Prop) : Prop
axiom g2936 (x : Prop) : Prop
axiom g2937 (x : Prop) : Prop
axiom g2938 (x : Prop) : Prop
axiom g2939 (x : Prop) : Prop
axiom g2940 (x : Prop) : Prop
axiom g2941 (x : Prop) : Prop
axiom g2942 (x : Prop) : Prop
axiom g2943 (x : Prop) : Prop
axiom g2944 (x : Prop) : Prop
axiom g2945 (x : Prop) : Prop
axiom g2946 (x : Prop) : Prop
axiom g2947 (x : Prop) : Prop
axiom g2948 (x : Prop) : Prop
axiom g2949 (x : Prop) : Prop
axiom g2950 (x : Prop) : Prop
axiom g2951 (x : Prop) : Prop
axiom g2952 (x : Prop) : Prop
axiom g2953 (x : Prop) : Prop
axiom g2954 (x : Prop) : Prop
axiom g2955 (x : Prop) : Prop
axiom g2956 (x : Prop) : Prop
axiom g2957 (x : Prop) : Prop
axiom g2958 (x : Prop) : Prop
axiom g2959 (x : Prop) : Prop
axiom g2960 (x : Prop) : Prop
axiom g2961 (x : Prop) : Prop
axiom g2962 (x : Prop) : Prop
axiom g2963 (x : Prop) : Prop
axiom g2964 (x : Prop) : Prop
axiom g2965 (x : Prop) : Prop
axiom g2966 (x : Prop) : Prop
axiom g2967 (x : Prop) : Prop
axiom g2968 (x : Prop) : Prop
axiom g2969 (x : Prop) : Prop
axiom g2970 (x : Prop) : Prop
axiom g2971 (x : Prop) : Prop
axiom g2972 (x : Prop) : Prop
axiom g2973 (x : Prop) : Prop
axiom g2974 (x : Prop) : Prop
axiom g2975 (x : Prop) : Prop
axiom g2976 (x : Prop) : Prop
axiom g2977 (x : Prop) : Prop
axiom g2978 (x : Prop) : Prop
axiom g2979 (x : Prop) : Prop
axiom g2980 (x : Prop) : Prop
axiom g2981 (x : Prop) : Prop
axiom g2982 (x : Prop) : Prop
axiom g2983 (x : Prop) : Prop
axiom g2984 (x : Prop) : Prop
axiom g2985 (x : Prop) : Prop
axiom g2986 (x : Prop) : Prop
axiom g2987 (x : Prop) : Prop
axiom g2988 (x : Prop) : Prop
axiom g2989 (x : Prop) : Prop
axiom g2990 (x : Prop) : Prop
axiom g2991 (x : Prop) : Prop
axiom g2992 (x : Prop) : Prop
axiom g2993 (x : Prop) : Prop
axiom g2994 (x : Prop) : Prop
axiom g2995 (x : Prop) : Prop
axiom g2996 (x : Prop) : Prop
axiom g2997 (x : Prop) : Prop
axiom g2998 (x : Prop) : Prop
axiom g2999 (x : Prop) : Prop
@[simp] axiom s0 (x : Prop) : f (g1 x) = f (g0 x)
@[simp] axiom s1 (x : Prop) : f (g2 x) = f (g1 x)
@[simp] axiom s2 (x : Prop) : f (g3 x) = f (g2 x)
@[simp] axiom s3 (x : Prop) : f (g4 x) = f (g3 x)
@[simp] axiom s4 (x : Prop) : f (g5 x) = f (g4 x)
@[simp] axiom s5 (x : Prop) : f (g6 x) = f (g5 x)
@[simp] axiom s6 (x : Prop) : f (g7 x) = f (g6 x)
@[simp] axiom s7 (x : Prop) : f (g8 x) = f (g7 x)
@[simp] axiom s8 (x : Prop) : f (g9 x) = f (g8 x)
@[simp] axiom s9 (x : Prop) : f (g10 x) = f (g9 x)
@[simp] axiom s10 (x : Prop) : f (g11 x) = f (g10 x)
@[simp] axiom s11 (x : Prop) : f (g12 x) = f (g11 x)
@[simp] axiom s12 (x : Prop) : f (g13 x) = f (g12 x)
@[simp] axiom s13 (x : Prop) : f (g14 x) = f (g13 x)
@[simp] axiom s14 (x : Prop) : f (g15 x) = f (g14 x)
@[simp] axiom s15 (x : Prop) : f (g16 x) = f (g15 x)
@[simp] axiom s16 (x : Prop) : f (g17 x) = f (g16 x)
@[simp] axiom s17 (x : Prop) : f (g18 x) = f (g17 x)
@[simp] axiom s18 (x : Prop) : f (g19 x) = f (g18 x)
@[simp] axiom s19 (x : Prop) : f (g20 x) = f (g19 x)
@[simp] axiom s20 (x : Prop) : f (g21 x) = f (g20 x)
@[simp] axiom s21 (x : Prop) : f (g22 x) = f (g21 x)
@[simp] axiom s22 (x : Prop) : f (g23 x) = f (g22 x)
@[simp] axiom s23 (x : Prop) : f (g24 x) = f (g23 x)
@[simp] axiom s24 (x : Prop) : f (g25 x) = f (g24 x)
@[simp] axiom s25 (x : Prop) : f (g26 x) = f (g25 x)
@[simp] axiom s26 (x : Prop) : f (g27 x) = f (g26 x)
@[simp] axiom s27 (x : Prop) : f (g28 x) = f (g27 x)
@[simp] axiom s28 (x : Prop) : f (g29 x) = f (g28 x)
@[simp] axiom s29 (x : Prop) : f (g30 x) = f (g29 x)
@[simp] axiom s30 (x : Prop) : f (g31 x) = f (g30 x)
@[simp] axiom s31 (x : Prop) : f (g32 x) = f (g31 x)
@[simp] axiom s32 (x : Prop) : f (g33 x) = f (g32 x)
@[simp] axiom s33 (x : Prop) : f (g34 x) = f (g33 x)
@[simp] axiom s34 (x : Prop) : f (g35 x) = f (g34 x)
@[simp] axiom s35 (x : Prop) : f (g36 x) = f (g35 x)
@[simp] axiom s36 (x : Prop) : f (g37 x) = f (g36 x)
@[simp] axiom s37 (x : Prop) : f (g38 x) = f (g37 x)
@[simp] axiom s38 (x : Prop) : f (g39 x) = f (g38 x)
@[simp] axiom s39 (x : Prop) : f (g40 x) = f (g39 x)
@[simp] axiom s40 (x : Prop) : f (g41 x) = f (g40 x)
@[simp] axiom s41 (x : Prop) : f (g42 x) = f (g41 x)
@[simp] axiom s42 (x : Prop) : f (g43 x) = f (g42 x)
@[simp] axiom s43 (x : Prop) : f (g44 x) = f (g43 x)
@[simp] axiom s44 (x : Prop) : f (g45 x) = f (g44 x)
@[simp] axiom s45 (x : Prop) : f (g46 x) = f (g45 x)
@[simp] axiom s46 (x : Prop) : f (g47 x) = f (g46 x)
@[simp] axiom s47 (x : Prop) : f (g48 x) = f (g47 x)
@[simp] axiom s48 (x : Prop) : f (g49 x) = f (g48 x)
@[simp] axiom s49 (x : Prop) : f (g50 x) = f (g49 x)
@[simp] axiom s50 (x : Prop) : f (g51 x) = f (g50 x)
@[simp] axiom s51 (x : Prop) : f (g52 x) = f (g51 x)
@[simp] axiom s52 (x : Prop) : f (g53 x) = f (g52 x)
@[simp] axiom s53 (x : Prop) : f (g54 x) = f (g53 x)
@[simp] axiom s54 (x : Prop) : f (g55 x) = f (g54 x)
@[simp] axiom s55 (x : Prop) : f (g56 x) = f (g55 x)
@[simp] axiom s56 (x : Prop) : f (g57 x) = f (g56 x)
@[simp] axiom s57 (x : Prop) : f (g58 x) = f (g57 x)
@[simp] axiom s58 (x : Prop) : f (g59 x) = f (g58 x)
@[simp] axiom s59 (x : Prop) : f (g60 x) = f (g59 x)
@[simp] axiom s60 (x : Prop) : f (g61 x) = f (g60 x)
@[simp] axiom s61 (x : Prop) : f (g62 x) = f (g61 x)
@[simp] axiom s62 (x : Prop) : f (g63 x) = f (g62 x)
@[simp] axiom s63 (x : Prop) : f (g64 x) = f (g63 x)
@[simp] axiom s64 (x : Prop) : f (g65 x) = f (g64 x)
@[simp] axiom s65 (x : Prop) : f (g66 x) = f (g65 x)
@[simp] axiom s66 (x : Prop) : f (g67 x) = f (g66 x)
@[simp] axiom s67 (x : Prop) : f (g68 x) = f (g67 x)
@[simp] axiom s68 (x : Prop) : f (g69 x) = f (g68 x)
@[simp] axiom s69 (x : Prop) : f (g70 x) = f (g69 x)
@[simp] axiom s70 (x : Prop) : f (g71 x) = f (g70 x)
@[simp] axiom s71 (x : Prop) : f (g72 x) = f (g71 x)
@[simp] axiom s72 (x : Prop) : f (g73 x) = f (g72 x)
@[simp] axiom s73 (x : Prop) : f (g74 x) = f (g73 x)
@[simp] axiom s74 (x : Prop) : f (g75 x) = f (g74 x)
@[simp] axiom s75 (x : Prop) : f (g76 x) = f (g75 x)
@[simp] axiom s76 (x : Prop) : f (g77 x) = f (g76 x)
@[simp] axiom s77 (x : Prop) : f (g78 x) = f (g77 x)
@[simp] axiom s78 (x : Prop) : f (g79 x) = f (g78 x)
@[simp] axiom s79 (x : Prop) : f (g80 x) = f (g79 x)
@[simp] axiom s80 (x : Prop) : f (g81 x) = f (g80 x)
@[simp] axiom s81 (x : Prop) : f (g82 x) = f (g81 x)
@[simp] axiom s82 (x : Prop) : f (g83 x) = f (g82 x)
@[simp] axiom s83 (x : Prop) : f (g84 x) = f (g83 x)
@[simp] axiom s84 (x : Prop) : f (g85 x) = f (g84 x)
@[simp] axiom s85 (x : Prop) : f (g86 x) = f (g85 x)
@[simp] axiom s86 (x : Prop) : f (g87 x) = f (g86 x)
@[simp] axiom s87 (x : Prop) : f (g88 x) = f (g87 x)
@[simp] axiom s88 (x : Prop) : f (g89 x) = f (g88 x)
@[simp] axiom s89 (x : Prop) : f (g90 x) = f (g89 x)
@[simp] axiom s90 (x : Prop) : f (g91 x) = f (g90 x)
@[simp] axiom s91 (x : Prop) : f (g92 x) = f (g91 x)
@[simp] axiom s92 (x : Prop) : f (g93 x) = f (g92 x)
@[simp] axiom s93 (x : Prop) : f (g94 x) = f (g93 x)
@[simp] axiom s94 (x : Prop) : f (g95 x) = f (g94 x)
@[simp] axiom s95 (x : Prop) : f (g96 x) = f (g95 x)
@[simp] axiom s96 (x : Prop) : f (g97 x) = f (g96 x)
@[simp] axiom s97 (x : Prop) : f (g98 x) = f (g97 x)
@[simp] axiom s98 (x : Prop) : f (g99 x) = f (g98 x)
@[simp] axiom s99 (x : Prop) : f (g100 x) = f (g99 x)
@[simp] axiom s100 (x : Prop) : f (g101 x) = f (g100 x)
@[simp] axiom s101 (x : Prop) : f (g102 x) = f (g101 x)
@[simp] axiom s102 (x : Prop) : f (g103 x) = f (g102 x)
@[simp] axiom s103 (x : Prop) : f (g104 x) = f (g103 x)
@[simp] axiom s104 (x : Prop) : f (g105 x) = f (g104 x)
@[simp] axiom s105 (x : Prop) : f (g106 x) = f (g105 x)
@[simp] axiom s106 (x : Prop) : f (g107 x) = f (g106 x)
@[simp] axiom s107 (x : Prop) : f (g108 x) = f (g107 x)
@[simp] axiom s108 (x : Prop) : f (g109 x) = f (g108 x)
@[simp] axiom s109 (x : Prop) : f (g110 x) = f (g109 x)
@[simp] axiom s110 (x : Prop) : f (g111 x) = f (g110 x)
@[simp] axiom s111 (x : Prop) : f (g112 x) = f (g111 x)
@[simp] axiom s112 (x : Prop) : f (g113 x) = f (g112 x)
@[simp] axiom s113 (x : Prop) : f (g114 x) = f (g113 x)
@[simp] axiom s114 (x : Prop) : f (g115 x) = f (g114 x)
@[simp] axiom s115 (x : Prop) : f (g116 x) = f (g115 x)
@[simp] axiom s116 (x : Prop) : f (g117 x) = f (g116 x)
@[simp] axiom s117 (x : Prop) : f (g118 x) = f (g117 x)
@[simp] axiom s118 (x : Prop) : f (g119 x) = f (g118 x)
@[simp] axiom s119 (x : Prop) : f (g120 x) = f (g119 x)
@[simp] axiom s120 (x : Prop) : f (g121 x) = f (g120 x)
@[simp] axiom s121 (x : Prop) : f (g122 x) = f (g121 x)
@[simp] axiom s122 (x : Prop) : f (g123 x) = f (g122 x)
@[simp] axiom s123 (x : Prop) : f (g124 x) = f (g123 x)
@[simp] axiom s124 (x : Prop) : f (g125 x) = f (g124 x)
@[simp] axiom s125 (x : Prop) : f (g126 x) = f (g125 x)
@[simp] axiom s126 (x : Prop) : f (g127 x) = f (g126 x)
@[simp] axiom s127 (x : Prop) : f (g128 x) = f (g127 x)
@[simp] axiom s128 (x : Prop) : f (g129 x) = f (g128 x)
@[simp] axiom s129 (x : Prop) : f (g130 x) = f (g129 x)
@[simp] axiom s130 (x : Prop) : f (g131 x) = f (g130 x)
@[simp] axiom s131 (x : Prop) : f (g132 x) = f (g131 x)
@[simp] axiom s132 (x : Prop) : f (g133 x) = f (g132 x)
@[simp] axiom s133 (x : Prop) : f (g134 x) = f (g133 x)
@[simp] axiom s134 (x : Prop) : f (g135 x) = f (g134 x)
@[simp] axiom s135 (x : Prop) : f (g136 x) = f (g135 x)
@[simp] axiom s136 (x : Prop) : f (g137 x) = f (g136 x)
@[simp] axiom s137 (x : Prop) : f (g138 x) = f (g137 x)
@[simp] axiom s138 (x : Prop) : f (g139 x) = f (g138 x)
@[simp] axiom s139 (x : Prop) : f (g140 x) = f (g139 x)
@[simp] axiom s140 (x : Prop) : f (g141 x) = f (g140 x)
@[simp] axiom s141 (x : Prop) : f (g142 x) = f (g141 x)
@[simp] axiom s142 (x : Prop) : f (g143 x) = f (g142 x)
@[simp] axiom s143 (x : Prop) : f (g144 x) = f (g143 x)
@[simp] axiom s144 (x : Prop) : f (g145 x) = f (g144 x)
@[simp] axiom s145 (x : Prop) : f (g146 x) = f (g145 x)
@[simp] axiom s146 (x : Prop) : f (g147 x) = f (g146 x)
@[simp] axiom s147 (x : Prop) : f (g148 x) = f (g147 x)
@[simp] axiom s148 (x : Prop) : f (g149 x) = f (g148 x)
@[simp] axiom s149 (x : Prop) : f (g150 x) = f (g149 x)
@[simp] axiom s150 (x : Prop) : f (g151 x) = f (g150 x)
@[simp] axiom s151 (x : Prop) : f (g152 x) = f (g151 x)
@[simp] axiom s152 (x : Prop) : f (g153 x) = f (g152 x)
@[simp] axiom s153 (x : Prop) : f (g154 x) = f (g153 x)
@[simp] axiom s154 (x : Prop) : f (g155 x) = f (g154 x)
@[simp] axiom s155 (x : Prop) : f (g156 x) = f (g155 x)
@[simp] axiom s156 (x : Prop) : f (g157 x) = f (g156 x)
@[simp] axiom s157 (x : Prop) : f (g158 x) = f (g157 x)
@[simp] axiom s158 (x : Prop) : f (g159 x) = f (g158 x)
@[simp] axiom s159 (x : Prop) : f (g160 x) = f (g159 x)
@[simp] axiom s160 (x : Prop) : f (g161 x) = f (g160 x)
@[simp] axiom s161 (x : Prop) : f (g162 x) = f (g161 x)
@[simp] axiom s162 (x : Prop) : f (g163 x) = f (g162 x)
@[simp] axiom s163 (x : Prop) : f (g164 x) = f (g163 x)
@[simp] axiom s164 (x : Prop) : f (g165 x) = f (g164 x)
@[simp] axiom s165 (x : Prop) : f (g166 x) = f (g165 x)
@[simp] axiom s166 (x : Prop) : f (g167 x) = f (g166 x)
@[simp] axiom s167 (x : Prop) : f (g168 x) = f (g167 x)
@[simp] axiom s168 (x : Prop) : f (g169 x) = f (g168 x)
@[simp] axiom s169 (x : Prop) : f (g170 x) = f (g169 x)
@[simp] axiom s170 (x : Prop) : f (g171 x) = f (g170 x)
@[simp] axiom s171 (x : Prop) : f (g172 x) = f (g171 x)
@[simp] axiom s172 (x : Prop) : f (g173 x) = f (g172 x)
@[simp] axiom s173 (x : Prop) : f (g174 x) = f (g173 x)
@[simp] axiom s174 (x : Prop) : f (g175 x) = f (g174 x)
@[simp] axiom s175 (x : Prop) : f (g176 x) = f (g175 x)
@[simp] axiom s176 (x : Prop) : f (g177 x) = f (g176 x)
@[simp] axiom s177 (x : Prop) : f (g178 x) = f (g177 x)
@[simp] axiom s178 (x : Prop) : f (g179 x) = f (g178 x)
@[simp] axiom s179 (x : Prop) : f (g180 x) = f (g179 x)
@[simp] axiom s180 (x : Prop) : f (g181 x) = f (g180 x)
@[simp] axiom s181 (x : Prop) : f (g182 x) = f (g181 x)
@[simp] axiom s182 (x : Prop) : f (g183 x) = f (g182 x)
@[simp] axiom s183 (x : Prop) : f (g184 x) = f (g183 x)
@[simp] axiom s184 (x : Prop) : f (g185 x) = f (g184 x)
@[simp] axiom s185 (x : Prop) : f (g186 x) = f (g185 x)
@[simp] axiom s186 (x : Prop) : f (g187 x) = f (g186 x)
@[simp] axiom s187 (x : Prop) : f (g188 x) = f (g187 x)
@[simp] axiom s188 (x : Prop) : f (g189 x) = f (g188 x)
@[simp] axiom s189 (x : Prop) : f (g190 x) = f (g189 x)
@[simp] axiom s190 (x : Prop) : f (g191 x) = f (g190 x)
@[simp] axiom s191 (x : Prop) : f (g192 x) = f (g191 x)
@[simp] axiom s192 (x : Prop) : f (g193 x) = f (g192 x)
@[simp] axiom s193 (x : Prop) : f (g194 x) = f (g193 x)
@[simp] axiom s194 (x : Prop) : f (g195 x) = f (g194 x)
@[simp] axiom s195 (x : Prop) : f (g196 x) = f (g195 x)
@[simp] axiom s196 (x : Prop) : f (g197 x) = f (g196 x)
@[simp] axiom s197 (x : Prop) : f (g198 x) = f (g197 x)
@[simp] axiom s198 (x : Prop) : f (g199 x) = f (g198 x)
@[simp] axiom s199 (x : Prop) : f (g200 x) = f (g199 x)
@[simp] axiom s200 (x : Prop) : f (g201 x) = f (g200 x)
@[simp] axiom s201 (x : Prop) : f (g202 x) = f (g201 x)
@[simp] axiom s202 (x : Prop) : f (g203 x) = f (g202 x)
@[simp] axiom s203 (x : Prop) : f (g204 x) = f (g203 x)
@[simp] axiom s204 (x : Prop) : f (g205 x) = f (g204 x)
@[simp] axiom s205 (x : Prop) : f (g206 x) = f (g205 x)
@[simp] axiom s206 (x : Prop) : f (g207 x) = f (g206 x)
@[simp] axiom s207 (x : Prop) : f (g208 x) = f (g207 x)
@[simp] axiom s208 (x : Prop) : f (g209 x) = f (g208 x)
@[simp] axiom s209 (x : Prop) : f (g210 x) = f (g209 x)
@[simp] axiom s210 (x : Prop) : f (g211 x) = f (g210 x)
@[simp] axiom s211 (x : Prop) : f (g212 x) = f (g211 x)
@[simp] axiom s212 (x : Prop) : f (g213 x) = f (g212 x)
@[simp] axiom s213 (x : Prop) : f (g214 x) = f (g213 x)
@[simp] axiom s214 (x : Prop) : f (g215 x) = f (g214 x)
@[simp] axiom s215 (x : Prop) : f (g216 x) = f (g215 x)
@[simp] axiom s216 (x : Prop) : f (g217 x) = f (g216 x)
@[simp] axiom s217 (x : Prop) : f (g218 x) = f (g217 x)
@[simp] axiom s218 (x : Prop) : f (g219 x) = f (g218 x)
@[simp] axiom s219 (x : Prop) : f (g220 x) = f (g219 x)
@[simp] axiom s220 (x : Prop) : f (g221 x) = f (g220 x)
@[simp] axiom s221 (x : Prop) : f (g222 x) = f (g221 x)
@[simp] axiom s222 (x : Prop) : f (g223 x) = f (g222 x)
@[simp] axiom s223 (x : Prop) : f (g224 x) = f (g223 x)
@[simp] axiom s224 (x : Prop) : f (g225 x) = f (g224 x)
@[simp] axiom s225 (x : Prop) : f (g226 x) = f (g225 x)
@[simp] axiom s226 (x : Prop) : f (g227 x) = f (g226 x)
@[simp] axiom s227 (x : Prop) : f (g228 x) = f (g227 x)
@[simp] axiom s228 (x : Prop) : f (g229 x) = f (g228 x)
@[simp] axiom s229 (x : Prop) : f (g230 x) = f (g229 x)
@[simp] axiom s230 (x : Prop) : f (g231 x) = f (g230 x)
@[simp] axiom s231 (x : Prop) : f (g232 x) = f (g231 x)
@[simp] axiom s232 (x : Prop) : f (g233 x) = f (g232 x)
@[simp] axiom s233 (x : Prop) : f (g234 x) = f (g233 x)
@[simp] axiom s234 (x : Prop) : f (g235 x) = f (g234 x)
@[simp] axiom s235 (x : Prop) : f (g236 x) = f (g235 x)
@[simp] axiom s236 (x : Prop) : f (g237 x) = f (g236 x)
@[simp] axiom s237 (x : Prop) : f (g238 x) = f (g237 x)
@[simp] axiom s238 (x : Prop) : f (g239 x) = f (g238 x)
@[simp] axiom s239 (x : Prop) : f (g240 x) = f (g239 x)
@[simp] axiom s240 (x : Prop) : f (g241 x) = f (g240 x)
@[simp] axiom s241 (x : Prop) : f (g242 x) = f (g241 x)
@[simp] axiom s242 (x : Prop) : f (g243 x) = f (g242 x)
@[simp] axiom s243 (x : Prop) : f (g244 x) = f (g243 x)
@[simp] axiom s244 (x : Prop) : f (g245 x) = f (g244 x)
@[simp] axiom s245 (x : Prop) : f (g246 x) = f (g245 x)
@[simp] axiom s246 (x : Prop) : f (g247 x) = f (g246 x)
@[simp] axiom s247 (x : Prop) : f (g248 x) = f (g247 x)
@[simp] axiom s248 (x : Prop) : f (g249 x) = f (g248 x)
@[simp] axiom s249 (x : Prop) : f (g250 x) = f (g249 x)
@[simp] axiom s250 (x : Prop) : f (g251 x) = f (g250 x)
@[simp] axiom s251 (x : Prop) : f (g252 x) = f (g251 x)
@[simp] axiom s252 (x : Prop) : f (g253 x) = f (g252 x)
@[simp] axiom s253 (x : Prop) : f (g254 x) = f (g253 x)
@[simp] axiom s254 (x : Prop) : f (g255 x) = f (g254 x)
@[simp] axiom s255 (x : Prop) : f (g256 x) = f (g255 x)
@[simp] axiom s256 (x : Prop) : f (g257 x) = f (g256 x)
@[simp] axiom s257 (x : Prop) : f (g258 x) = f (g257 x)
@[simp] axiom s258 (x : Prop) : f (g259 x) = f (g258 x)
@[simp] axiom s259 (x : Prop) : f (g260 x) = f (g259 x)
@[simp] axiom s260 (x : Prop) : f (g261 x) = f (g260 x)
@[simp] axiom s261 (x : Prop) : f (g262 x) = f (g261 x)
@[simp] axiom s262 (x : Prop) : f (g263 x) = f (g262 x)
@[simp] axiom s263 (x : Prop) : f (g264 x) = f (g263 x)
@[simp] axiom s264 (x : Prop) : f (g265 x) = f (g264 x)
@[simp] axiom s265 (x : Prop) : f (g266 x) = f (g265 x)
@[simp] axiom s266 (x : Prop) : f (g267 x) = f (g266 x)
@[simp] axiom s267 (x : Prop) : f (g268 x) = f (g267 x)
@[simp] axiom s268 (x : Prop) : f (g269 x) = f (g268 x)
@[simp] axiom s269 (x : Prop) : f (g270 x) = f (g269 x)
@[simp] axiom s270 (x : Prop) : f (g271 x) = f (g270 x)
@[simp] axiom s271 (x : Prop) : f (g272 x) = f (g271 x)
@[simp] axiom s272 (x : Prop) : f (g273 x) = f (g272 x)
@[simp] axiom s273 (x : Prop) : f (g274 x) = f (g273 x)
@[simp] axiom s274 (x : Prop) : f (g275 x) = f (g274 x)
@[simp] axiom s275 (x : Prop) : f (g276 x) = f (g275 x)
@[simp] axiom s276 (x : Prop) : f (g277 x) = f (g276 x)
@[simp] axiom s277 (x : Prop) : f (g278 x) = f (g277 x)
@[simp] axiom s278 (x : Prop) : f (g279 x) = f (g278 x)
@[simp] axiom s279 (x : Prop) : f (g280 x) = f (g279 x)
@[simp] axiom s280 (x : Prop) : f (g281 x) = f (g280 x)
@[simp] axiom s281 (x : Prop) : f (g282 x) = f (g281 x)
@[simp] axiom s282 (x : Prop) : f (g283 x) = f (g282 x)
@[simp] axiom s283 (x : Prop) : f (g284 x) = f (g283 x)
@[simp] axiom s284 (x : Prop) : f (g285 x) = f (g284 x)
@[simp] axiom s285 (x : Prop) : f (g286 x) = f (g285 x)
@[simp] axiom s286 (x : Prop) : f (g287 x) = f (g286 x)
@[simp] axiom s287 (x : Prop) : f (g288 x) = f (g287 x)
@[simp] axiom s288 (x : Prop) : f (g289 x) = f (g288 x)
@[simp] axiom s289 (x : Prop) : f (g290 x) = f (g289 x)
@[simp] axiom s290 (x : Prop) : f (g291 x) = f (g290 x)
@[simp] axiom s291 (x : Prop) : f (g292 x) = f (g291 x)
@[simp] axiom s292 (x : Prop) : f (g293 x) = f (g292 x)
@[simp] axiom s293 (x : Prop) : f (g294 x) = f (g293 x)
@[simp] axiom s294 (x : Prop) : f (g295 x) = f (g294 x)
@[simp] axiom s295 (x : Prop) : f (g296 x) = f (g295 x)
@[simp] axiom s296 (x : Prop) : f (g297 x) = f (g296 x)
@[simp] axiom s297 (x : Prop) : f (g298 x) = f (g297 x)
@[simp] axiom s298 (x : Prop) : f (g299 x) = f (g298 x)
@[simp] axiom s299 (x : Prop) : f (g300 x) = f (g299 x)
@[simp] axiom s300 (x : Prop) : f (g301 x) = f (g300 x)
@[simp] axiom s301 (x : Prop) : f (g302 x) = f (g301 x)
@[simp] axiom s302 (x : Prop) : f (g303 x) = f (g302 x)
@[simp] axiom s303 (x : Prop) : f (g304 x) = f (g303 x)
@[simp] axiom s304 (x : Prop) : f (g305 x) = f (g304 x)
@[simp] axiom s305 (x : Prop) : f (g306 x) = f (g305 x)
@[simp] axiom s306 (x : Prop) : f (g307 x) = f (g306 x)
@[simp] axiom s307 (x : Prop) : f (g308 x) = f (g307 x)
@[simp] axiom s308 (x : Prop) : f (g309 x) = f (g308 x)
@[simp] axiom s309 (x : Prop) : f (g310 x) = f (g309 x)
@[simp] axiom s310 (x : Prop) : f (g311 x) = f (g310 x)
@[simp] axiom s311 (x : Prop) : f (g312 x) = f (g311 x)
@[simp] axiom s312 (x : Prop) : f (g313 x) = f (g312 x)
@[simp] axiom s313 (x : Prop) : f (g314 x) = f (g313 x)
@[simp] axiom s314 (x : Prop) : f (g315 x) = f (g314 x)
@[simp] axiom s315 (x : Prop) : f (g316 x) = f (g315 x)
@[simp] axiom s316 (x : Prop) : f (g317 x) = f (g316 x)
@[simp] axiom s317 (x : Prop) : f (g318 x) = f (g317 x)
@[simp] axiom s318 (x : Prop) : f (g319 x) = f (g318 x)
@[simp] axiom s319 (x : Prop) : f (g320 x) = f (g319 x)
@[simp] axiom s320 (x : Prop) : f (g321 x) = f (g320 x)
@[simp] axiom s321 (x : Prop) : f (g322 x) = f (g321 x)
@[simp] axiom s322 (x : Prop) : f (g323 x) = f (g322 x)
@[simp] axiom s323 (x : Prop) : f (g324 x) = f (g323 x)
@[simp] axiom s324 (x : Prop) : f (g325 x) = f (g324 x)
@[simp] axiom s325 (x : Prop) : f (g326 x) = f (g325 x)
@[simp] axiom s326 (x : Prop) : f (g327 x) = f (g326 x)
@[simp] axiom s327 (x : Prop) : f (g328 x) = f (g327 x)
@[simp] axiom s328 (x : Prop) : f (g329 x) = f (g328 x)
@[simp] axiom s329 (x : Prop) : f (g330 x) = f (g329 x)
@[simp] axiom s330 (x : Prop) : f (g331 x) = f (g330 x)
@[simp] axiom s331 (x : Prop) : f (g332 x) = f (g331 x)
@[simp] axiom s332 (x : Prop) : f (g333 x) = f (g332 x)
@[simp] axiom s333 (x : Prop) : f (g334 x) = f (g333 x)
@[simp] axiom s334 (x : Prop) : f (g335 x) = f (g334 x)
@[simp] axiom s335 (x : Prop) : f (g336 x) = f (g335 x)
@[simp] axiom s336 (x : Prop) : f (g337 x) = f (g336 x)
@[simp] axiom s337 (x : Prop) : f (g338 x) = f (g337 x)
@[simp] axiom s338 (x : Prop) : f (g339 x) = f (g338 x)
@[simp] axiom s339 (x : Prop) : f (g340 x) = f (g339 x)
@[simp] axiom s340 (x : Prop) : f (g341 x) = f (g340 x)
@[simp] axiom s341 (x : Prop) : f (g342 x) = f (g341 x)
@[simp] axiom s342 (x : Prop) : f (g343 x) = f (g342 x)
@[simp] axiom s343 (x : Prop) : f (g344 x) = f (g343 x)
@[simp] axiom s344 (x : Prop) : f (g345 x) = f (g344 x)
@[simp] axiom s345 (x : Prop) : f (g346 x) = f (g345 x)
@[simp] axiom s346 (x : Prop) : f (g347 x) = f (g346 x)
@[simp] axiom s347 (x : Prop) : f (g348 x) = f (g347 x)
@[simp] axiom s348 (x : Prop) : f (g349 x) = f (g348 x)
@[simp] axiom s349 (x : Prop) : f (g350 x) = f (g349 x)
@[simp] axiom s350 (x : Prop) : f (g351 x) = f (g350 x)
@[simp] axiom s351 (x : Prop) : f (g352 x) = f (g351 x)
@[simp] axiom s352 (x : Prop) : f (g353 x) = f (g352 x)
@[simp] axiom s353 (x : Prop) : f (g354 x) = f (g353 x)
@[simp] axiom s354 (x : Prop) : f (g355 x) = f (g354 x)
@[simp] axiom s355 (x : Prop) : f (g356 x) = f (g355 x)
@[simp] axiom s356 (x : Prop) : f (g357 x) = f (g356 x)
@[simp] axiom s357 (x : Prop) : f (g358 x) = f (g357 x)
@[simp] axiom s358 (x : Prop) : f (g359 x) = f (g358 x)
@[simp] axiom s359 (x : Prop) : f (g360 x) = f (g359 x)
@[simp] axiom s360 (x : Prop) : f (g361 x) = f (g360 x)
@[simp] axiom s361 (x : Prop) : f (g362 x) = f (g361 x)
@[simp] axiom s362 (x : Prop) : f (g363 x) = f (g362 x)
@[simp] axiom s363 (x : Prop) : f (g364 x) = f (g363 x)
@[simp] axiom s364 (x : Prop) : f (g365 x) = f (g364 x)
@[simp] axiom s365 (x : Prop) : f (g366 x) = f (g365 x)
@[simp] axiom s366 (x : Prop) : f (g367 x) = f (g366 x)
@[simp] axiom s367 (x : Prop) : f (g368 x) = f (g367 x)
@[simp] axiom s368 (x : Prop) : f (g369 x) = f (g368 x)
@[simp] axiom s369 (x : Prop) : f (g370 x) = f (g369 x)
@[simp] axiom s370 (x : Prop) : f (g371 x) = f (g370 x)
@[simp] axiom s371 (x : Prop) : f (g372 x) = f (g371 x)
@[simp] axiom s372 (x : Prop) : f (g373 x) = f (g372 x)
@[simp] axiom s373 (x : Prop) : f (g374 x) = f (g373 x)
@[simp] axiom s374 (x : Prop) : f (g375 x) = f (g374 x)
@[simp] axiom s375 (x : Prop) : f (g376 x) = f (g375 x)
@[simp] axiom s376 (x : Prop) : f (g377 x) = f (g376 x)
@[simp] axiom s377 (x : Prop) : f (g378 x) = f (g377 x)
@[simp] axiom s378 (x : Prop) : f (g379 x) = f (g378 x)
@[simp] axiom s379 (x : Prop) : f (g380 x) = f (g379 x)
@[simp] axiom s380 (x : Prop) : f (g381 x) = f (g380 x)
@[simp] axiom s381 (x : Prop) : f (g382 x) = f (g381 x)
@[simp] axiom s382 (x : Prop) : f (g383 x) = f (g382 x)
@[simp] axiom s383 (x : Prop) : f (g384 x) = f (g383 x)
@[simp] axiom s384 (x : Prop) : f (g385 x) = f (g384 x)
@[simp] axiom s385 (x : Prop) : f (g386 x) = f (g385 x)
@[simp] axiom s386 (x : Prop) : f (g387 x) = f (g386 x)
@[simp] axiom s387 (x : Prop) : f (g388 x) = f (g387 x)
@[simp] axiom s388 (x : Prop) : f (g389 x) = f (g388 x)
@[simp] axiom s389 (x : Prop) : f (g390 x) = f (g389 x)
@[simp] axiom s390 (x : Prop) : f (g391 x) = f (g390 x)
@[simp] axiom s391 (x : Prop) : f (g392 x) = f (g391 x)
@[simp] axiom s392 (x : Prop) : f (g393 x) = f (g392 x)
@[simp] axiom s393 (x : Prop) : f (g394 x) = f (g393 x)
@[simp] axiom s394 (x : Prop) : f (g395 x) = f (g394 x)
@[simp] axiom s395 (x : Prop) : f (g396 x) = f (g395 x)
@[simp] axiom s396 (x : Prop) : f (g397 x) = f (g396 x)
@[simp] axiom s397 (x : Prop) : f (g398 x) = f (g397 x)
@[simp] axiom s398 (x : Prop) : f (g399 x) = f (g398 x)
@[simp] axiom s399 (x : Prop) : f (g400 x) = f (g399 x)
@[simp] axiom s400 (x : Prop) : f (g401 x) = f (g400 x)
@[simp] axiom s401 (x : Prop) : f (g402 x) = f (g401 x)
@[simp] axiom s402 (x : Prop) : f (g403 x) = f (g402 x)
@[simp] axiom s403 (x : Prop) : f (g404 x) = f (g403 x)
@[simp] axiom s404 (x : Prop) : f (g405 x) = f (g404 x)
@[simp] axiom s405 (x : Prop) : f (g406 x) = f (g405 x)
@[simp] axiom s406 (x : Prop) : f (g407 x) = f (g406 x)
@[simp] axiom s407 (x : Prop) : f (g408 x) = f (g407 x)
@[simp] axiom s408 (x : Prop) : f (g409 x) = f (g408 x)
@[simp] axiom s409 (x : Prop) : f (g410 x) = f (g409 x)
@[simp] axiom s410 (x : Prop) : f (g411 x) = f (g410 x)
@[simp] axiom s411 (x : Prop) : f (g412 x) = f (g411 x)
@[simp] axiom s412 (x : Prop) : f (g413 x) = f (g412 x)
@[simp] axiom s413 (x : Prop) : f (g414 x) = f (g413 x)
@[simp] axiom s414 (x : Prop) : f (g415 x) = f (g414 x)
@[simp] axiom s415 (x : Prop) : f (g416 x) = f (g415 x)
@[simp] axiom s416 (x : Prop) : f (g417 x) = f (g416 x)
@[simp] axiom s417 (x : Prop) : f (g418 x) = f (g417 x)
@[simp] axiom s418 (x : Prop) : f (g419 x) = f (g418 x)
@[simp] axiom s419 (x : Prop) : f (g420 x) = f (g419 x)
@[simp] axiom s420 (x : Prop) : f (g421 x) = f (g420 x)
@[simp] axiom s421 (x : Prop) : f (g422 x) = f (g421 x)
@[simp] axiom s422 (x : Prop) : f (g423 x) = f (g422 x)
@[simp] axiom s423 (x : Prop) : f (g424 x) = f (g423 x)
@[simp] axiom s424 (x : Prop) : f (g425 x) = f (g424 x)
@[simp] axiom s425 (x : Prop) : f (g426 x) = f (g425 x)
@[simp] axiom s426 (x : Prop) : f (g427 x) = f (g426 x)
@[simp] axiom s427 (x : Prop) : f (g428 x) = f (g427 x)
@[simp] axiom s428 (x : Prop) : f (g429 x) = f (g428 x)
@[simp] axiom s429 (x : Prop) : f (g430 x) = f (g429 x)
@[simp] axiom s430 (x : Prop) : f (g431 x) = f (g430 x)
@[simp] axiom s431 (x : Prop) : f (g432 x) = f (g431 x)
@[simp] axiom s432 (x : Prop) : f (g433 x) = f (g432 x)
@[simp] axiom s433 (x : Prop) : f (g434 x) = f (g433 x)
@[simp] axiom s434 (x : Prop) : f (g435 x) = f (g434 x)
@[simp] axiom s435 (x : Prop) : f (g436 x) = f (g435 x)
@[simp] axiom s436 (x : Prop) : f (g437 x) = f (g436 x)
@[simp] axiom s437 (x : Prop) : f (g438 x) = f (g437 x)
@[simp] axiom s438 (x : Prop) : f (g439 x) = f (g438 x)
@[simp] axiom s439 (x : Prop) : f (g440 x) = f (g439 x)
@[simp] axiom s440 (x : Prop) : f (g441 x) = f (g440 x)
@[simp] axiom s441 (x : Prop) : f (g442 x) = f (g441 x)
@[simp] axiom s442 (x : Prop) : f (g443 x) = f (g442 x)
@[simp] axiom s443 (x : Prop) : f (g444 x) = f (g443 x)
@[simp] axiom s444 (x : Prop) : f (g445 x) = f (g444 x)
@[simp] axiom s445 (x : Prop) : f (g446 x) = f (g445 x)
@[simp] axiom s446 (x : Prop) : f (g447 x) = f (g446 x)
@[simp] axiom s447 (x : Prop) : f (g448 x) = f (g447 x)
@[simp] axiom s448 (x : Prop) : f (g449 x) = f (g448 x)
@[simp] axiom s449 (x : Prop) : f (g450 x) = f (g449 x)
@[simp] axiom s450 (x : Prop) : f (g451 x) = f (g450 x)
@[simp] axiom s451 (x : Prop) : f (g452 x) = f (g451 x)
@[simp] axiom s452 (x : Prop) : f (g453 x) = f (g452 x)
@[simp] axiom s453 (x : Prop) : f (g454 x) = f (g453 x)
@[simp] axiom s454 (x : Prop) : f (g455 x) = f (g454 x)
@[simp] axiom s455 (x : Prop) : f (g456 x) = f (g455 x)
@[simp] axiom s456 (x : Prop) : f (g457 x) = f (g456 x)
@[simp] axiom s457 (x : Prop) : f (g458 x) = f (g457 x)
@[simp] axiom s458 (x : Prop) : f (g459 x) = f (g458 x)
@[simp] axiom s459 (x : Prop) : f (g460 x) = f (g459 x)
@[simp] axiom s460 (x : Prop) : f (g461 x) = f (g460 x)
@[simp] axiom s461 (x : Prop) : f (g462 x) = f (g461 x)
@[simp] axiom s462 (x : Prop) : f (g463 x) = f (g462 x)
@[simp] axiom s463 (x : Prop) : f (g464 x) = f (g463 x)
@[simp] axiom s464 (x : Prop) : f (g465 x) = f (g464 x)
@[simp] axiom s465 (x : Prop) : f (g466 x) = f (g465 x)
@[simp] axiom s466 (x : Prop) : f (g467 x) = f (g466 x)
@[simp] axiom s467 (x : Prop) : f (g468 x) = f (g467 x)
@[simp] axiom s468 (x : Prop) : f (g469 x) = f (g468 x)
@[simp] axiom s469 (x : Prop) : f (g470 x) = f (g469 x)
@[simp] axiom s470 (x : Prop) : f (g471 x) = f (g470 x)
@[simp] axiom s471 (x : Prop) : f (g472 x) = f (g471 x)
@[simp] axiom s472 (x : Prop) : f (g473 x) = f (g472 x)
@[simp] axiom s473 (x : Prop) : f (g474 x) = f (g473 x)
@[simp] axiom s474 (x : Prop) : f (g475 x) = f (g474 x)
@[simp] axiom s475 (x : Prop) : f (g476 x) = f (g475 x)
@[simp] axiom s476 (x : Prop) : f (g477 x) = f (g476 x)
@[simp] axiom s477 (x : Prop) : f (g478 x) = f (g477 x)
@[simp] axiom s478 (x : Prop) : f (g479 x) = f (g478 x)
@[simp] axiom s479 (x : Prop) : f (g480 x) = f (g479 x)
@[simp] axiom s480 (x : Prop) : f (g481 x) = f (g480 x)
@[simp] axiom s481 (x : Prop) : f (g482 x) = f (g481 x)
@[simp] axiom s482 (x : Prop) : f (g483 x) = f (g482 x)
@[simp] axiom s483 (x : Prop) : f (g484 x) = f (g483 x)
@[simp] axiom s484 (x : Prop) : f (g485 x) = f (g484 x)
@[simp] axiom s485 (x : Prop) : f (g486 x) = f (g485 x)
@[simp] axiom s486 (x : Prop) : f (g487 x) = f (g486 x)
@[simp] axiom s487 (x : Prop) : f (g488 x) = f (g487 x)
@[simp] axiom s488 (x : Prop) : f (g489 x) = f (g488 x)
@[simp] axiom s489 (x : Prop) : f (g490 x) = f (g489 x)
@[simp] axiom s490 (x : Prop) : f (g491 x) = f (g490 x)
@[simp] axiom s491 (x : Prop) : f (g492 x) = f (g491 x)
@[simp] axiom s492 (x : Prop) : f (g493 x) = f (g492 x)
@[simp] axiom s493 (x : Prop) : f (g494 x) = f (g493 x)
@[simp] axiom s494 (x : Prop) : f (g495 x) = f (g494 x)
@[simp] axiom s495 (x : Prop) : f (g496 x) = f (g495 x)
@[simp] axiom s496 (x : Prop) : f (g497 x) = f (g496 x)
@[simp] axiom s497 (x : Prop) : f (g498 x) = f (g497 x)
@[simp] axiom s498 (x : Prop) : f (g499 x) = f (g498 x)
@[simp] axiom s499 (x : Prop) : f (g500 x) = f (g499 x)
@[simp] axiom s500 (x : Prop) : f (g501 x) = f (g500 x)
@[simp] axiom s501 (x : Prop) : f (g502 x) = f (g501 x)
@[simp] axiom s502 (x : Prop) : f (g503 x) = f (g502 x)
@[simp] axiom s503 (x : Prop) : f (g504 x) = f (g503 x)
@[simp] axiom s504 (x : Prop) : f (g505 x) = f (g504 x)
@[simp] axiom s505 (x : Prop) : f (g506 x) = f (g505 x)
@[simp] axiom s506 (x : Prop) : f (g507 x) = f (g506 x)
@[simp] axiom s507 (x : Prop) : f (g508 x) = f (g507 x)
@[simp] axiom s508 (x : Prop) : f (g509 x) = f (g508 x)
@[simp] axiom s509 (x : Prop) : f (g510 x) = f (g509 x)
@[simp] axiom s510 (x : Prop) : f (g511 x) = f (g510 x)
@[simp] axiom s511 (x : Prop) : f (g512 x) = f (g511 x)
@[simp] axiom s512 (x : Prop) : f (g513 x) = f (g512 x)
@[simp] axiom s513 (x : Prop) : f (g514 x) = f (g513 x)
@[simp] axiom s514 (x : Prop) : f (g515 x) = f (g514 x)
@[simp] axiom s515 (x : Prop) : f (g516 x) = f (g515 x)
@[simp] axiom s516 (x : Prop) : f (g517 x) = f (g516 x)
@[simp] axiom s517 (x : Prop) : f (g518 x) = f (g517 x)
@[simp] axiom s518 (x : Prop) : f (g519 x) = f (g518 x)
@[simp] axiom s519 (x : Prop) : f (g520 x) = f (g519 x)
@[simp] axiom s520 (x : Prop) : f (g521 x) = f (g520 x)
@[simp] axiom s521 (x : Prop) : f (g522 x) = f (g521 x)
@[simp] axiom s522 (x : Prop) : f (g523 x) = f (g522 x)
@[simp] axiom s523 (x : Prop) : f (g524 x) = f (g523 x)
@[simp] axiom s524 (x : Prop) : f (g525 x) = f (g524 x)
@[simp] axiom s525 (x : Prop) : f (g526 x) = f (g525 x)
@[simp] axiom s526 (x : Prop) : f (g527 x) = f (g526 x)
@[simp] axiom s527 (x : Prop) : f (g528 x) = f (g527 x)
@[simp] axiom s528 (x : Prop) : f (g529 x) = f (g528 x)
@[simp] axiom s529 (x : Prop) : f (g530 x) = f (g529 x)
@[simp] axiom s530 (x : Prop) : f (g531 x) = f (g530 x)
@[simp] axiom s531 (x : Prop) : f (g532 x) = f (g531 x)
@[simp] axiom s532 (x : Prop) : f (g533 x) = f (g532 x)
@[simp] axiom s533 (x : Prop) : f (g534 x) = f (g533 x)
@[simp] axiom s534 (x : Prop) : f (g535 x) = f (g534 x)
@[simp] axiom s535 (x : Prop) : f (g536 x) = f (g535 x)
@[simp] axiom s536 (x : Prop) : f (g537 x) = f (g536 x)
@[simp] axiom s537 (x : Prop) : f (g538 x) = f (g537 x)
@[simp] axiom s538 (x : Prop) : f (g539 x) = f (g538 x)
@[simp] axiom s539 (x : Prop) : f (g540 x) = f (g539 x)
@[simp] axiom s540 (x : Prop) : f (g541 x) = f (g540 x)
@[simp] axiom s541 (x : Prop) : f (g542 x) = f (g541 x)
@[simp] axiom s542 (x : Prop) : f (g543 x) = f (g542 x)
@[simp] axiom s543 (x : Prop) : f (g544 x) = f (g543 x)
@[simp] axiom s544 (x : Prop) : f (g545 x) = f (g544 x)
@[simp] axiom s545 (x : Prop) : f (g546 x) = f (g545 x)
@[simp] axiom s546 (x : Prop) : f (g547 x) = f (g546 x)
@[simp] axiom s547 (x : Prop) : f (g548 x) = f (g547 x)
@[simp] axiom s548 (x : Prop) : f (g549 x) = f (g548 x)
@[simp] axiom s549 (x : Prop) : f (g550 x) = f (g549 x)
@[simp] axiom s550 (x : Prop) : f (g551 x) = f (g550 x)
@[simp] axiom s551 (x : Prop) : f (g552 x) = f (g551 x)
@[simp] axiom s552 (x : Prop) : f (g553 x) = f (g552 x)
@[simp] axiom s553 (x : Prop) : f (g554 x) = f (g553 x)
@[simp] axiom s554 (x : Prop) : f (g555 x) = f (g554 x)
@[simp] axiom s555 (x : Prop) : f (g556 x) = f (g555 x)
@[simp] axiom s556 (x : Prop) : f (g557 x) = f (g556 x)
@[simp] axiom s557 (x : Prop) : f (g558 x) = f (g557 x)
@[simp] axiom s558 (x : Prop) : f (g559 x) = f (g558 x)
@[simp] axiom s559 (x : Prop) : f (g560 x) = f (g559 x)
@[simp] axiom s560 (x : Prop) : f (g561 x) = f (g560 x)
@[simp] axiom s561 (x : Prop) : f (g562 x) = f (g561 x)
@[simp] axiom s562 (x : Prop) : f (g563 x) = f (g562 x)
@[simp] axiom s563 (x : Prop) : f (g564 x) = f (g563 x)
@[simp] axiom s564 (x : Prop) : f (g565 x) = f (g564 x)
@[simp] axiom s565 (x : Prop) : f (g566 x) = f (g565 x)
@[simp] axiom s566 (x : Prop) : f (g567 x) = f (g566 x)
@[simp] axiom s567 (x : Prop) : f (g568 x) = f (g567 x)
@[simp] axiom s568 (x : Prop) : f (g569 x) = f (g568 x)
@[simp] axiom s569 (x : Prop) : f (g570 x) = f (g569 x)
@[simp] axiom s570 (x : Prop) : f (g571 x) = f (g570 x)
@[simp] axiom s571 (x : Prop) : f (g572 x) = f (g571 x)
@[simp] axiom s572 (x : Prop) : f (g573 x) = f (g572 x)
@[simp] axiom s573 (x : Prop) : f (g574 x) = f (g573 x)
@[simp] axiom s574 (x : Prop) : f (g575 x) = f (g574 x)
@[simp] axiom s575 (x : Prop) : f (g576 x) = f (g575 x)
@[simp] axiom s576 (x : Prop) : f (g577 x) = f (g576 x)
@[simp] axiom s577 (x : Prop) : f (g578 x) = f (g577 x)
@[simp] axiom s578 (x : Prop) : f (g579 x) = f (g578 x)
@[simp] axiom s579 (x : Prop) : f (g580 x) = f (g579 x)
@[simp] axiom s580 (x : Prop) : f (g581 x) = f (g580 x)
@[simp] axiom s581 (x : Prop) : f (g582 x) = f (g581 x)
@[simp] axiom s582 (x : Prop) : f (g583 x) = f (g582 x)
@[simp] axiom s583 (x : Prop) : f (g584 x) = f (g583 x)
@[simp] axiom s584 (x : Prop) : f (g585 x) = f (g584 x)
@[simp] axiom s585 (x : Prop) : f (g586 x) = f (g585 x)
@[simp] axiom s586 (x : Prop) : f (g587 x) = f (g586 x)
@[simp] axiom s587 (x : Prop) : f (g588 x) = f (g587 x)
@[simp] axiom s588 (x : Prop) : f (g589 x) = f (g588 x)
@[simp] axiom s589 (x : Prop) : f (g590 x) = f (g589 x)
@[simp] axiom s590 (x : Prop) : f (g591 x) = f (g590 x)
@[simp] axiom s591 (x : Prop) : f (g592 x) = f (g591 x)
@[simp] axiom s592 (x : Prop) : f (g593 x) = f (g592 x)
@[simp] axiom s593 (x : Prop) : f (g594 x) = f (g593 x)
@[simp] axiom s594 (x : Prop) : f (g595 x) = f (g594 x)
@[simp] axiom s595 (x : Prop) : f (g596 x) = f (g595 x)
@[simp] axiom s596 (x : Prop) : f (g597 x) = f (g596 x)
@[simp] axiom s597 (x : Prop) : f (g598 x) = f (g597 x)
@[simp] axiom s598 (x : Prop) : f (g599 x) = f (g598 x)
@[simp] axiom s599 (x : Prop) : f (g600 x) = f (g599 x)
@[simp] axiom s600 (x : Prop) : f (g601 x) = f (g600 x)
@[simp] axiom s601 (x : Prop) : f (g602 x) = f (g601 x)
@[simp] axiom s602 (x : Prop) : f (g603 x) = f (g602 x)
@[simp] axiom s603 (x : Prop) : f (g604 x) = f (g603 x)
@[simp] axiom s604 (x : Prop) : f (g605 x) = f (g604 x)
@[simp] axiom s605 (x : Prop) : f (g606 x) = f (g605 x)
@[simp] axiom s606 (x : Prop) : f (g607 x) = f (g606 x)
@[simp] axiom s607 (x : Prop) : f (g608 x) = f (g607 x)
@[simp] axiom s608 (x : Prop) : f (g609 x) = f (g608 x)
@[simp] axiom s609 (x : Prop) : f (g610 x) = f (g609 x)
@[simp] axiom s610 (x : Prop) : f (g611 x) = f (g610 x)
@[simp] axiom s611 (x : Prop) : f (g612 x) = f (g611 x)
@[simp] axiom s612 (x : Prop) : f (g613 x) = f (g612 x)
@[simp] axiom s613 (x : Prop) : f (g614 x) = f (g613 x)
@[simp] axiom s614 (x : Prop) : f (g615 x) = f (g614 x)
@[simp] axiom s615 (x : Prop) : f (g616 x) = f (g615 x)
@[simp] axiom s616 (x : Prop) : f (g617 x) = f (g616 x)
@[simp] axiom s617 (x : Prop) : f (g618 x) = f (g617 x)
@[simp] axiom s618 (x : Prop) : f (g619 x) = f (g618 x)
@[simp] axiom s619 (x : Prop) : f (g620 x) = f (g619 x)
@[simp] axiom s620 (x : Prop) : f (g621 x) = f (g620 x)
@[simp] axiom s621 (x : Prop) : f (g622 x) = f (g621 x)
@[simp] axiom s622 (x : Prop) : f (g623 x) = f (g622 x)
@[simp] axiom s623 (x : Prop) : f (g624 x) = f (g623 x)
@[simp] axiom s624 (x : Prop) : f (g625 x) = f (g624 x)
@[simp] axiom s625 (x : Prop) : f (g626 x) = f (g625 x)
@[simp] axiom s626 (x : Prop) : f (g627 x) = f (g626 x)
@[simp] axiom s627 (x : Prop) : f (g628 x) = f (g627 x)
@[simp] axiom s628 (x : Prop) : f (g629 x) = f (g628 x)
@[simp] axiom s629 (x : Prop) : f (g630 x) = f (g629 x)
@[simp] axiom s630 (x : Prop) : f (g631 x) = f (g630 x)
@[simp] axiom s631 (x : Prop) : f (g632 x) = f (g631 x)
@[simp] axiom s632 (x : Prop) : f (g633 x) = f (g632 x)
@[simp] axiom s633 (x : Prop) : f (g634 x) = f (g633 x)
@[simp] axiom s634 (x : Prop) : f (g635 x) = f (g634 x)
@[simp] axiom s635 (x : Prop) : f (g636 x) = f (g635 x)
@[simp] axiom s636 (x : Prop) : f (g637 x) = f (g636 x)
@[simp] axiom s637 (x : Prop) : f (g638 x) = f (g637 x)
@[simp] axiom s638 (x : Prop) : f (g639 x) = f (g638 x)
@[simp] axiom s639 (x : Prop) : f (g640 x) = f (g639 x)
@[simp] axiom s640 (x : Prop) : f (g641 x) = f (g640 x)
@[simp] axiom s641 (x : Prop) : f (g642 x) = f (g641 x)
@[simp] axiom s642 (x : Prop) : f (g643 x) = f (g642 x)
@[simp] axiom s643 (x : Prop) : f (g644 x) = f (g643 x)
@[simp] axiom s644 (x : Prop) : f (g645 x) = f (g644 x)
@[simp] axiom s645 (x : Prop) : f (g646 x) = f (g645 x)
@[simp] axiom s646 (x : Prop) : f (g647 x) = f (g646 x)
@[simp] axiom s647 (x : Prop) : f (g648 x) = f (g647 x)
@[simp] axiom s648 (x : Prop) : f (g649 x) = f (g648 x)
@[simp] axiom s649 (x : Prop) : f (g650 x) = f (g649 x)
@[simp] axiom s650 (x : Prop) : f (g651 x) = f (g650 x)
@[simp] axiom s651 (x : Prop) : f (g652 x) = f (g651 x)
@[simp] axiom s652 (x : Prop) : f (g653 x) = f (g652 x)
@[simp] axiom s653 (x : Prop) : f (g654 x) = f (g653 x)
@[simp] axiom s654 (x : Prop) : f (g655 x) = f (g654 x)
@[simp] axiom s655 (x : Prop) : f (g656 x) = f (g655 x)
@[simp] axiom s656 (x : Prop) : f (g657 x) = f (g656 x)
@[simp] axiom s657 (x : Prop) : f (g658 x) = f (g657 x)
@[simp] axiom s658 (x : Prop) : f (g659 x) = f (g658 x)
@[simp] axiom s659 (x : Prop) : f (g660 x) = f (g659 x)
@[simp] axiom s660 (x : Prop) : f (g661 x) = f (g660 x)
@[simp] axiom s661 (x : Prop) : f (g662 x) = f (g661 x)
@[simp] axiom s662 (x : Prop) : f (g663 x) = f (g662 x)
@[simp] axiom s663 (x : Prop) : f (g664 x) = f (g663 x)
@[simp] axiom s664 (x : Prop) : f (g665 x) = f (g664 x)
@[simp] axiom s665 (x : Prop) : f (g666 x) = f (g665 x)
@[simp] axiom s666 (x : Prop) : f (g667 x) = f (g666 x)
@[simp] axiom s667 (x : Prop) : f (g668 x) = f (g667 x)
@[simp] axiom s668 (x : Prop) : f (g669 x) = f (g668 x)
@[simp] axiom s669 (x : Prop) : f (g670 x) = f (g669 x)
@[simp] axiom s670 (x : Prop) : f (g671 x) = f (g670 x)
@[simp] axiom s671 (x : Prop) : f (g672 x) = f (g671 x)
@[simp] axiom s672 (x : Prop) : f (g673 x) = f (g672 x)
@[simp] axiom s673 (x : Prop) : f (g674 x) = f (g673 x)
@[simp] axiom s674 (x : Prop) : f (g675 x) = f (g674 x)
@[simp] axiom s675 (x : Prop) : f (g676 x) = f (g675 x)
@[simp] axiom s676 (x : Prop) : f (g677 x) = f (g676 x)
@[simp] axiom s677 (x : Prop) : f (g678 x) = f (g677 x)
@[simp] axiom s678 (x : Prop) : f (g679 x) = f (g678 x)
@[simp] axiom s679 (x : Prop) : f (g680 x) = f (g679 x)
@[simp] axiom s680 (x : Prop) : f (g681 x) = f (g680 x)
@[simp] axiom s681 (x : Prop) : f (g682 x) = f (g681 x)
@[simp] axiom s682 (x : Prop) : f (g683 x) = f (g682 x)
@[simp] axiom s683 (x : Prop) : f (g684 x) = f (g683 x)
@[simp] axiom s684 (x : Prop) : f (g685 x) = f (g684 x)
@[simp] axiom s685 (x : Prop) : f (g686 x) = f (g685 x)
@[simp] axiom s686 (x : Prop) : f (g687 x) = f (g686 x)
@[simp] axiom s687 (x : Prop) : f (g688 x) = f (g687 x)
@[simp] axiom s688 (x : Prop) : f (g689 x) = f (g688 x)
@[simp] axiom s689 (x : Prop) : f (g690 x) = f (g689 x)
@[simp] axiom s690 (x : Prop) : f (g691 x) = f (g690 x)
@[simp] axiom s691 (x : Prop) : f (g692 x) = f (g691 x)
@[simp] axiom s692 (x : Prop) : f (g693 x) = f (g692 x)
@[simp] axiom s693 (x : Prop) : f (g694 x) = f (g693 x)
@[simp] axiom s694 (x : Prop) : f (g695 x) = f (g694 x)
@[simp] axiom s695 (x : Prop) : f (g696 x) = f (g695 x)
@[simp] axiom s696 (x : Prop) : f (g697 x) = f (g696 x)
@[simp] axiom s697 (x : Prop) : f (g698 x) = f (g697 x)
@[simp] axiom s698 (x : Prop) : f (g699 x) = f (g698 x)
@[simp] axiom s699 (x : Prop) : f (g700 x) = f (g699 x)
@[simp] axiom s700 (x : Prop) : f (g701 x) = f (g700 x)
@[simp] axiom s701 (x : Prop) : f (g702 x) = f (g701 x)
@[simp] axiom s702 (x : Prop) : f (g703 x) = f (g702 x)
@[simp] axiom s703 (x : Prop) : f (g704 x) = f (g703 x)
@[simp] axiom s704 (x : Prop) : f (g705 x) = f (g704 x)
@[simp] axiom s705 (x : Prop) : f (g706 x) = f (g705 x)
@[simp] axiom s706 (x : Prop) : f (g707 x) = f (g706 x)
@[simp] axiom s707 (x : Prop) : f (g708 x) = f (g707 x)
@[simp] axiom s708 (x : Prop) : f (g709 x) = f (g708 x)
@[simp] axiom s709 (x : Prop) : f (g710 x) = f (g709 x)
@[simp] axiom s710 (x : Prop) : f (g711 x) = f (g710 x)
@[simp] axiom s711 (x : Prop) : f (g712 x) = f (g711 x)
@[simp] axiom s712 (x : Prop) : f (g713 x) = f (g712 x)
@[simp] axiom s713 (x : Prop) : f (g714 x) = f (g713 x)
@[simp] axiom s714 (x : Prop) : f (g715 x) = f (g714 x)
@[simp] axiom s715 (x : Prop) : f (g716 x) = f (g715 x)
@[simp] axiom s716 (x : Prop) : f (g717 x) = f (g716 x)
@[simp] axiom s717 (x : Prop) : f (g718 x) = f (g717 x)
@[simp] axiom s718 (x : Prop) : f (g719 x) = f (g718 x)
@[simp] axiom s719 (x : Prop) : f (g720 x) = f (g719 x)
@[simp] axiom s720 (x : Prop) : f (g721 x) = f (g720 x)
@[simp] axiom s721 (x : Prop) : f (g722 x) = f (g721 x)
@[simp] axiom s722 (x : Prop) : f (g723 x) = f (g722 x)
@[simp] axiom s723 (x : Prop) : f (g724 x) = f (g723 x)
@[simp] axiom s724 (x : Prop) : f (g725 x) = f (g724 x)
@[simp] axiom s725 (x : Prop) : f (g726 x) = f (g725 x)
@[simp] axiom s726 (x : Prop) : f (g727 x) = f (g726 x)
@[simp] axiom s727 (x : Prop) : f (g728 x) = f (g727 x)
@[simp] axiom s728 (x : Prop) : f (g729 x) = f (g728 x)
@[simp] axiom s729 (x : Prop) : f (g730 x) = f (g729 x)
@[simp] axiom s730 (x : Prop) : f (g731 x) = f (g730 x)
@[simp] axiom s731 (x : Prop) : f (g732 x) = f (g731 x)
@[simp] axiom s732 (x : Prop) : f (g733 x) = f (g732 x)
@[simp] axiom s733 (x : Prop) : f (g734 x) = f (g733 x)
@[simp] axiom s734 (x : Prop) : f (g735 x) = f (g734 x)
@[simp] axiom s735 (x : Prop) : f (g736 x) = f (g735 x)
@[simp] axiom s736 (x : Prop) : f (g737 x) = f (g736 x)
@[simp] axiom s737 (x : Prop) : f (g738 x) = f (g737 x)
@[simp] axiom s738 (x : Prop) : f (g739 x) = f (g738 x)
@[simp] axiom s739 (x : Prop) : f (g740 x) = f (g739 x)
@[simp] axiom s740 (x : Prop) : f (g741 x) = f (g740 x)
@[simp] axiom s741 (x : Prop) : f (g742 x) = f (g741 x)
@[simp] axiom s742 (x : Prop) : f (g743 x) = f (g742 x)
@[simp] axiom s743 (x : Prop) : f (g744 x) = f (g743 x)
@[simp] axiom s744 (x : Prop) : f (g745 x) = f (g744 x)
@[simp] axiom s745 (x : Prop) : f (g746 x) = f (g745 x)
@[simp] axiom s746 (x : Prop) : f (g747 x) = f (g746 x)
@[simp] axiom s747 (x : Prop) : f (g748 x) = f (g747 x)
@[simp] axiom s748 (x : Prop) : f (g749 x) = f (g748 x)
@[simp] axiom s749 (x : Prop) : f (g750 x) = f (g749 x)
@[simp] axiom s750 (x : Prop) : f (g751 x) = f (g750 x)
@[simp] axiom s751 (x : Prop) : f (g752 x) = f (g751 x)
@[simp] axiom s752 (x : Prop) : f (g753 x) = f (g752 x)
@[simp] axiom s753 (x : Prop) : f (g754 x) = f (g753 x)
@[simp] axiom s754 (x : Prop) : f (g755 x) = f (g754 x)
@[simp] axiom s755 (x : Prop) : f (g756 x) = f (g755 x)
@[simp] axiom s756 (x : Prop) : f (g757 x) = f (g756 x)
@[simp] axiom s757 (x : Prop) : f (g758 x) = f (g757 x)
@[simp] axiom s758 (x : Prop) : f (g759 x) = f (g758 x)
@[simp] axiom s759 (x : Prop) : f (g760 x) = f (g759 x)
@[simp] axiom s760 (x : Prop) : f (g761 x) = f (g760 x)
@[simp] axiom s761 (x : Prop) : f (g762 x) = f (g761 x)
@[simp] axiom s762 (x : Prop) : f (g763 x) = f (g762 x)
@[simp] axiom s763 (x : Prop) : f (g764 x) = f (g763 x)
@[simp] axiom s764 (x : Prop) : f (g765 x) = f (g764 x)
@[simp] axiom s765 (x : Prop) : f (g766 x) = f (g765 x)
@[simp] axiom s766 (x : Prop) : f (g767 x) = f (g766 x)
@[simp] axiom s767 (x : Prop) : f (g768 x) = f (g767 x)
@[simp] axiom s768 (x : Prop) : f (g769 x) = f (g768 x)
@[simp] axiom s769 (x : Prop) : f (g770 x) = f (g769 x)
@[simp] axiom s770 (x : Prop) : f (g771 x) = f (g770 x)
@[simp] axiom s771 (x : Prop) : f (g772 x) = f (g771 x)
@[simp] axiom s772 (x : Prop) : f (g773 x) = f (g772 x)
@[simp] axiom s773 (x : Prop) : f (g774 x) = f (g773 x)
@[simp] axiom s774 (x : Prop) : f (g775 x) = f (g774 x)
@[simp] axiom s775 (x : Prop) : f (g776 x) = f (g775 x)
@[simp] axiom s776 (x : Prop) : f (g777 x) = f (g776 x)
@[simp] axiom s777 (x : Prop) : f (g778 x) = f (g777 x)
@[simp] axiom s778 (x : Prop) : f (g779 x) = f (g778 x)
@[simp] axiom s779 (x : Prop) : f (g780 x) = f (g779 x)
@[simp] axiom s780 (x : Prop) : f (g781 x) = f (g780 x)
@[simp] axiom s781 (x : Prop) : f (g782 x) = f (g781 x)
@[simp] axiom s782 (x : Prop) : f (g783 x) = f (g782 x)
@[simp] axiom s783 (x : Prop) : f (g784 x) = f (g783 x)
@[simp] axiom s784 (x : Prop) : f (g785 x) = f (g784 x)
@[simp] axiom s785 (x : Prop) : f (g786 x) = f (g785 x)
@[simp] axiom s786 (x : Prop) : f (g787 x) = f (g786 x)
@[simp] axiom s787 (x : Prop) : f (g788 x) = f (g787 x)
@[simp] axiom s788 (x : Prop) : f (g789 x) = f (g788 x)
@[simp] axiom s789 (x : Prop) : f (g790 x) = f (g789 x)
@[simp] axiom s790 (x : Prop) : f (g791 x) = f (g790 x)
@[simp] axiom s791 (x : Prop) : f (g792 x) = f (g791 x)
@[simp] axiom s792 (x : Prop) : f (g793 x) = f (g792 x)
@[simp] axiom s793 (x : Prop) : f (g794 x) = f (g793 x)
@[simp] axiom s794 (x : Prop) : f (g795 x) = f (g794 x)
@[simp] axiom s795 (x : Prop) : f (g796 x) = f (g795 x)
@[simp] axiom s796 (x : Prop) : f (g797 x) = f (g796 x)
@[simp] axiom s797 (x : Prop) : f (g798 x) = f (g797 x)
@[simp] axiom s798 (x : Prop) : f (g799 x) = f (g798 x)
@[simp] axiom s799 (x : Prop) : f (g800 x) = f (g799 x)
@[simp] axiom s800 (x : Prop) : f (g801 x) = f (g800 x)
@[simp] axiom s801 (x : Prop) : f (g802 x) = f (g801 x)
@[simp] axiom s802 (x : Prop) : f (g803 x) = f (g802 x)
@[simp] axiom s803 (x : Prop) : f (g804 x) = f (g803 x)
@[simp] axiom s804 (x : Prop) : f (g805 x) = f (g804 x)
@[simp] axiom s805 (x : Prop) : f (g806 x) = f (g805 x)
@[simp] axiom s806 (x : Prop) : f (g807 x) = f (g806 x)
@[simp] axiom s807 (x : Prop) : f (g808 x) = f (g807 x)
@[simp] axiom s808 (x : Prop) : f (g809 x) = f (g808 x)
@[simp] axiom s809 (x : Prop) : f (g810 x) = f (g809 x)
@[simp] axiom s810 (x : Prop) : f (g811 x) = f (g810 x)
@[simp] axiom s811 (x : Prop) : f (g812 x) = f (g811 x)
@[simp] axiom s812 (x : Prop) : f (g813 x) = f (g812 x)
@[simp] axiom s813 (x : Prop) : f (g814 x) = f (g813 x)
@[simp] axiom s814 (x : Prop) : f (g815 x) = f (g814 x)
@[simp] axiom s815 (x : Prop) : f (g816 x) = f (g815 x)
@[simp] axiom s816 (x : Prop) : f (g817 x) = f (g816 x)
@[simp] axiom s817 (x : Prop) : f (g818 x) = f (g817 x)
@[simp] axiom s818 (x : Prop) : f (g819 x) = f (g818 x)
@[simp] axiom s819 (x : Prop) : f (g820 x) = f (g819 x)
@[simp] axiom s820 (x : Prop) : f (g821 x) = f (g820 x)
@[simp] axiom s821 (x : Prop) : f (g822 x) = f (g821 x)
@[simp] axiom s822 (x : Prop) : f (g823 x) = f (g822 x)
@[simp] axiom s823 (x : Prop) : f (g824 x) = f (g823 x)
@[simp] axiom s824 (x : Prop) : f (g825 x) = f (g824 x)
@[simp] axiom s825 (x : Prop) : f (g826 x) = f (g825 x)
@[simp] axiom s826 (x : Prop) : f (g827 x) = f (g826 x)
@[simp] axiom s827 (x : Prop) : f (g828 x) = f (g827 x)
@[simp] axiom s828 (x : Prop) : f (g829 x) = f (g828 x)
@[simp] axiom s829 (x : Prop) : f (g830 x) = f (g829 x)
@[simp] axiom s830 (x : Prop) : f (g831 x) = f (g830 x)
@[simp] axiom s831 (x : Prop) : f (g832 x) = f (g831 x)
@[simp] axiom s832 (x : Prop) : f (g833 x) = f (g832 x)
@[simp] axiom s833 (x : Prop) : f (g834 x) = f (g833 x)
@[simp] axiom s834 (x : Prop) : f (g835 x) = f (g834 x)
@[simp] axiom s835 (x : Prop) : f (g836 x) = f (g835 x)
@[simp] axiom s836 (x : Prop) : f (g837 x) = f (g836 x)
@[simp] axiom s837 (x : Prop) : f (g838 x) = f (g837 x)
@[simp] axiom s838 (x : Prop) : f (g839 x) = f (g838 x)
@[simp] axiom s839 (x : Prop) : f (g840 x) = f (g839 x)
@[simp] axiom s840 (x : Prop) : f (g841 x) = f (g840 x)
@[simp] axiom s841 (x : Prop) : f (g842 x) = f (g841 x)
@[simp] axiom s842 (x : Prop) : f (g843 x) = f (g842 x)
@[simp] axiom s843 (x : Prop) : f (g844 x) = f (g843 x)
@[simp] axiom s844 (x : Prop) : f (g845 x) = f (g844 x)
@[simp] axiom s845 (x : Prop) : f (g846 x) = f (g845 x)
@[simp] axiom s846 (x : Prop) : f (g847 x) = f (g846 x)
@[simp] axiom s847 (x : Prop) : f (g848 x) = f (g847 x)
@[simp] axiom s848 (x : Prop) : f (g849 x) = f (g848 x)
@[simp] axiom s849 (x : Prop) : f (g850 x) = f (g849 x)
@[simp] axiom s850 (x : Prop) : f (g851 x) = f (g850 x)
@[simp] axiom s851 (x : Prop) : f (g852 x) = f (g851 x)
@[simp] axiom s852 (x : Prop) : f (g853 x) = f (g852 x)
@[simp] axiom s853 (x : Prop) : f (g854 x) = f (g853 x)
@[simp] axiom s854 (x : Prop) : f (g855 x) = f (g854 x)
@[simp] axiom s855 (x : Prop) : f (g856 x) = f (g855 x)
@[simp] axiom s856 (x : Prop) : f (g857 x) = f (g856 x)
@[simp] axiom s857 (x : Prop) : f (g858 x) = f (g857 x)
@[simp] axiom s858 (x : Prop) : f (g859 x) = f (g858 x)
@[simp] axiom s859 (x : Prop) : f (g860 x) = f (g859 x)
@[simp] axiom s860 (x : Prop) : f (g861 x) = f (g860 x)
@[simp] axiom s861 (x : Prop) : f (g862 x) = f (g861 x)
@[simp] axiom s862 (x : Prop) : f (g863 x) = f (g862 x)
@[simp] axiom s863 (x : Prop) : f (g864 x) = f (g863 x)
@[simp] axiom s864 (x : Prop) : f (g865 x) = f (g864 x)
@[simp] axiom s865 (x : Prop) : f (g866 x) = f (g865 x)
@[simp] axiom s866 (x : Prop) : f (g867 x) = f (g866 x)
@[simp] axiom s867 (x : Prop) : f (g868 x) = f (g867 x)
@[simp] axiom s868 (x : Prop) : f (g869 x) = f (g868 x)
@[simp] axiom s869 (x : Prop) : f (g870 x) = f (g869 x)
@[simp] axiom s870 (x : Prop) : f (g871 x) = f (g870 x)
@[simp] axiom s871 (x : Prop) : f (g872 x) = f (g871 x)
@[simp] axiom s872 (x : Prop) : f (g873 x) = f (g872 x)
@[simp] axiom s873 (x : Prop) : f (g874 x) = f (g873 x)
@[simp] axiom s874 (x : Prop) : f (g875 x) = f (g874 x)
@[simp] axiom s875 (x : Prop) : f (g876 x) = f (g875 x)
@[simp] axiom s876 (x : Prop) : f (g877 x) = f (g876 x)
@[simp] axiom s877 (x : Prop) : f (g878 x) = f (g877 x)
@[simp] axiom s878 (x : Prop) : f (g879 x) = f (g878 x)
@[simp] axiom s879 (x : Prop) : f (g880 x) = f (g879 x)
@[simp] axiom s880 (x : Prop) : f (g881 x) = f (g880 x)
@[simp] axiom s881 (x : Prop) : f (g882 x) = f (g881 x)
@[simp] axiom s882 (x : Prop) : f (g883 x) = f (g882 x)
@[simp] axiom s883 (x : Prop) : f (g884 x) = f (g883 x)
@[simp] axiom s884 (x : Prop) : f (g885 x) = f (g884 x)
@[simp] axiom s885 (x : Prop) : f (g886 x) = f (g885 x)
@[simp] axiom s886 (x : Prop) : f (g887 x) = f (g886 x)
@[simp] axiom s887 (x : Prop) : f (g888 x) = f (g887 x)
@[simp] axiom s888 (x : Prop) : f (g889 x) = f (g888 x)
@[simp] axiom s889 (x : Prop) : f (g890 x) = f (g889 x)
@[simp] axiom s890 (x : Prop) : f (g891 x) = f (g890 x)
@[simp] axiom s891 (x : Prop) : f (g892 x) = f (g891 x)
@[simp] axiom s892 (x : Prop) : f (g893 x) = f (g892 x)
@[simp] axiom s893 (x : Prop) : f (g894 x) = f (g893 x)
@[simp] axiom s894 (x : Prop) : f (g895 x) = f (g894 x)
@[simp] axiom s895 (x : Prop) : f (g896 x) = f (g895 x)
@[simp] axiom s896 (x : Prop) : f (g897 x) = f (g896 x)
@[simp] axiom s897 (x : Prop) : f (g898 x) = f (g897 x)
@[simp] axiom s898 (x : Prop) : f (g899 x) = f (g898 x)
@[simp] axiom s899 (x : Prop) : f (g900 x) = f (g899 x)
@[simp] axiom s900 (x : Prop) : f (g901 x) = f (g900 x)
@[simp] axiom s901 (x : Prop) : f (g902 x) = f (g901 x)
@[simp] axiom s902 (x : Prop) : f (g903 x) = f (g902 x)
@[simp] axiom s903 (x : Prop) : f (g904 x) = f (g903 x)
@[simp] axiom s904 (x : Prop) : f (g905 x) = f (g904 x)
@[simp] axiom s905 (x : Prop) : f (g906 x) = f (g905 x)
@[simp] axiom s906 (x : Prop) : f (g907 x) = f (g906 x)
@[simp] axiom s907 (x : Prop) : f (g908 x) = f (g907 x)
@[simp] axiom s908 (x : Prop) : f (g909 x) = f (g908 x)
@[simp] axiom s909 (x : Prop) : f (g910 x) = f (g909 x)
@[simp] axiom s910 (x : Prop) : f (g911 x) = f (g910 x)
@[simp] axiom s911 (x : Prop) : f (g912 x) = f (g911 x)
@[simp] axiom s912 (x : Prop) : f (g913 x) = f (g912 x)
@[simp] axiom s913 (x : Prop) : f (g914 x) = f (g913 x)
@[simp] axiom s914 (x : Prop) : f (g915 x) = f (g914 x)
@[simp] axiom s915 (x : Prop) : f (g916 x) = f (g915 x)
@[simp] axiom s916 (x : Prop) : f (g917 x) = f (g916 x)
@[simp] axiom s917 (x : Prop) : f (g918 x) = f (g917 x)
@[simp] axiom s918 (x : Prop) : f (g919 x) = f (g918 x)
@[simp] axiom s919 (x : Prop) : f (g920 x) = f (g919 x)
@[simp] axiom s920 (x : Prop) : f (g921 x) = f (g920 x)
@[simp] axiom s921 (x : Prop) : f (g922 x) = f (g921 x)
@[simp] axiom s922 (x : Prop) : f (g923 x) = f (g922 x)
@[simp] axiom s923 (x : Prop) : f (g924 x) = f (g923 x)
@[simp] axiom s924 (x : Prop) : f (g925 x) = f (g924 x)
@[simp] axiom s925 (x : Prop) : f (g926 x) = f (g925 x)
@[simp] axiom s926 (x : Prop) : f (g927 x) = f (g926 x)
@[simp] axiom s927 (x : Prop) : f (g928 x) = f (g927 x)
@[simp] axiom s928 (x : Prop) : f (g929 x) = f (g928 x)
@[simp] axiom s929 (x : Prop) : f (g930 x) = f (g929 x)
@[simp] axiom s930 (x : Prop) : f (g931 x) = f (g930 x)
@[simp] axiom s931 (x : Prop) : f (g932 x) = f (g931 x)
@[simp] axiom s932 (x : Prop) : f (g933 x) = f (g932 x)
@[simp] axiom s933 (x : Prop) : f (g934 x) = f (g933 x)
@[simp] axiom s934 (x : Prop) : f (g935 x) = f (g934 x)
@[simp] axiom s935 (x : Prop) : f (g936 x) = f (g935 x)
@[simp] axiom s936 (x : Prop) : f (g937 x) = f (g936 x)
@[simp] axiom s937 (x : Prop) : f (g938 x) = f (g937 x)
@[simp] axiom s938 (x : Prop) : f (g939 x) = f (g938 x)
@[simp] axiom s939 (x : Prop) : f (g940 x) = f (g939 x)
@[simp] axiom s940 (x : Prop) : f (g941 x) = f (g940 x)
@[simp] axiom s941 (x : Prop) : f (g942 x) = f (g941 x)
@[simp] axiom s942 (x : Prop) : f (g943 x) = f (g942 x)
@[simp] axiom s943 (x : Prop) : f (g944 x) = f (g943 x)
@[simp] axiom s944 (x : Prop) : f (g945 x) = f (g944 x)
@[simp] axiom s945 (x : Prop) : f (g946 x) = f (g945 x)
@[simp] axiom s946 (x : Prop) : f (g947 x) = f (g946 x)
@[simp] axiom s947 (x : Prop) : f (g948 x) = f (g947 x)
@[simp] axiom s948 (x : Prop) : f (g949 x) = f (g948 x)
@[simp] axiom s949 (x : Prop) : f (g950 x) = f (g949 x)
@[simp] axiom s950 (x : Prop) : f (g951 x) = f (g950 x)
@[simp] axiom s951 (x : Prop) : f (g952 x) = f (g951 x)
@[simp] axiom s952 (x : Prop) : f (g953 x) = f (g952 x)
@[simp] axiom s953 (x : Prop) : f (g954 x) = f (g953 x)
@[simp] axiom s954 (x : Prop) : f (g955 x) = f (g954 x)
@[simp] axiom s955 (x : Prop) : f (g956 x) = f (g955 x)
@[simp] axiom s956 (x : Prop) : f (g957 x) = f (g956 x)
@[simp] axiom s957 (x : Prop) : f (g958 x) = f (g957 x)
@[simp] axiom s958 (x : Prop) : f (g959 x) = f (g958 x)
@[simp] axiom s959 (x : Prop) : f (g960 x) = f (g959 x)
@[simp] axiom s960 (x : Prop) : f (g961 x) = f (g960 x)
@[simp] axiom s961 (x : Prop) : f (g962 x) = f (g961 x)
@[simp] axiom s962 (x : Prop) : f (g963 x) = f (g962 x)
@[simp] axiom s963 (x : Prop) : f (g964 x) = f (g963 x)
@[simp] axiom s964 (x : Prop) : f (g965 x) = f (g964 x)
@[simp] axiom s965 (x : Prop) : f (g966 x) = f (g965 x)
@[simp] axiom s966 (x : Prop) : f (g967 x) = f (g966 x)
@[simp] axiom s967 (x : Prop) : f (g968 x) = f (g967 x)
@[simp] axiom s968 (x : Prop) : f (g969 x) = f (g968 x)
@[simp] axiom s969 (x : Prop) : f (g970 x) = f (g969 x)
@[simp] axiom s970 (x : Prop) : f (g971 x) = f (g970 x)
@[simp] axiom s971 (x : Prop) : f (g972 x) = f (g971 x)
@[simp] axiom s972 (x : Prop) : f (g973 x) = f (g972 x)
@[simp] axiom s973 (x : Prop) : f (g974 x) = f (g973 x)
@[simp] axiom s974 (x : Prop) : f (g975 x) = f (g974 x)
@[simp] axiom s975 (x : Prop) : f (g976 x) = f (g975 x)
@[simp] axiom s976 (x : Prop) : f (g977 x) = f (g976 x)
@[simp] axiom s977 (x : Prop) : f (g978 x) = f (g977 x)
@[simp] axiom s978 (x : Prop) : f (g979 x) = f (g978 x)
@[simp] axiom s979 (x : Prop) : f (g980 x) = f (g979 x)
@[simp] axiom s980 (x : Prop) : f (g981 x) = f (g980 x)
@[simp] axiom s981 (x : Prop) : f (g982 x) = f (g981 x)
@[simp] axiom s982 (x : Prop) : f (g983 x) = f (g982 x)
@[simp] axiom s983 (x : Prop) : f (g984 x) = f (g983 x)
@[simp] axiom s984 (x : Prop) : f (g985 x) = f (g984 x)
@[simp] axiom s985 (x : Prop) : f (g986 x) = f (g985 x)
@[simp] axiom s986 (x : Prop) : f (g987 x) = f (g986 x)
@[simp] axiom s987 (x : Prop) : f (g988 x) = f (g987 x)
@[simp] axiom s988 (x : Prop) : f (g989 x) = f (g988 x)
@[simp] axiom s989 (x : Prop) : f (g990 x) = f (g989 x)
@[simp] axiom s990 (x : Prop) : f (g991 x) = f (g990 x)
@[simp] axiom s991 (x : Prop) : f (g992 x) = f (g991 x)
@[simp] axiom s992 (x : Prop) : f (g993 x) = f (g992 x)
@[simp] axiom s993 (x : Prop) : f (g994 x) = f (g993 x)
@[simp] axiom s994 (x : Prop) : f (g995 x) = f (g994 x)
@[simp] axiom s995 (x : Prop) : f (g996 x) = f (g995 x)
@[simp] axiom s996 (x : Prop) : f (g997 x) = f (g996 x)
@[simp] axiom s997 (x : Prop) : f (g998 x) = f (g997 x)
@[simp] axiom s998 (x : Prop) : f (g999 x) = f (g998 x)
@[simp] axiom s999 (x : Prop) : f (g1000 x) = f (g999 x)
@[simp] axiom s1000 (x : Prop) : f (g1001 x) = f (g1000 x)
@[simp] axiom s1001 (x : Prop) : f (g1002 x) = f (g1001 x)
@[simp] axiom s1002 (x : Prop) : f (g1003 x) = f (g1002 x)
@[simp] axiom s1003 (x : Prop) : f (g1004 x) = f (g1003 x)
@[simp] axiom s1004 (x : Prop) : f (g1005 x) = f (g1004 x)
@[simp] axiom s1005 (x : Prop) : f (g1006 x) = f (g1005 x)
@[simp] axiom s1006 (x : Prop) : f (g1007 x) = f (g1006 x)
@[simp] axiom s1007 (x : Prop) : f (g1008 x) = f (g1007 x)
@[simp] axiom s1008 (x : Prop) : f (g1009 x) = f (g1008 x)
@[simp] axiom s1009 (x : Prop) : f (g1010 x) = f (g1009 x)
@[simp] axiom s1010 (x : Prop) : f (g1011 x) = f (g1010 x)
@[simp] axiom s1011 (x : Prop) : f (g1012 x) = f (g1011 x)
@[simp] axiom s1012 (x : Prop) : f (g1013 x) = f (g1012 x)
@[simp] axiom s1013 (x : Prop) : f (g1014 x) = f (g1013 x)
@[simp] axiom s1014 (x : Prop) : f (g1015 x) = f (g1014 x)
@[simp] axiom s1015 (x : Prop) : f (g1016 x) = f (g1015 x)
@[simp] axiom s1016 (x : Prop) : f (g1017 x) = f (g1016 x)
@[simp] axiom s1017 (x : Prop) : f (g1018 x) = f (g1017 x)
@[simp] axiom s1018 (x : Prop) : f (g1019 x) = f (g1018 x)
@[simp] axiom s1019 (x : Prop) : f (g1020 x) = f (g1019 x)
@[simp] axiom s1020 (x : Prop) : f (g1021 x) = f (g1020 x)
@[simp] axiom s1021 (x : Prop) : f (g1022 x) = f (g1021 x)
@[simp] axiom s1022 (x : Prop) : f (g1023 x) = f (g1022 x)
@[simp] axiom s1023 (x : Prop) : f (g1024 x) = f (g1023 x)
@[simp] axiom s1024 (x : Prop) : f (g1025 x) = f (g1024 x)
@[simp] axiom s1025 (x : Prop) : f (g1026 x) = f (g1025 x)
@[simp] axiom s1026 (x : Prop) : f (g1027 x) = f (g1026 x)
@[simp] axiom s1027 (x : Prop) : f (g1028 x) = f (g1027 x)
@[simp] axiom s1028 (x : Prop) : f (g1029 x) = f (g1028 x)
@[simp] axiom s1029 (x : Prop) : f (g1030 x) = f (g1029 x)
@[simp] axiom s1030 (x : Prop) : f (g1031 x) = f (g1030 x)
@[simp] axiom s1031 (x : Prop) : f (g1032 x) = f (g1031 x)
@[simp] axiom s1032 (x : Prop) : f (g1033 x) = f (g1032 x)
@[simp] axiom s1033 (x : Prop) : f (g1034 x) = f (g1033 x)
@[simp] axiom s1034 (x : Prop) : f (g1035 x) = f (g1034 x)
@[simp] axiom s1035 (x : Prop) : f (g1036 x) = f (g1035 x)
@[simp] axiom s1036 (x : Prop) : f (g1037 x) = f (g1036 x)
@[simp] axiom s1037 (x : Prop) : f (g1038 x) = f (g1037 x)
@[simp] axiom s1038 (x : Prop) : f (g1039 x) = f (g1038 x)
@[simp] axiom s1039 (x : Prop) : f (g1040 x) = f (g1039 x)
@[simp] axiom s1040 (x : Prop) : f (g1041 x) = f (g1040 x)
@[simp] axiom s1041 (x : Prop) : f (g1042 x) = f (g1041 x)
@[simp] axiom s1042 (x : Prop) : f (g1043 x) = f (g1042 x)
@[simp] axiom s1043 (x : Prop) : f (g1044 x) = f (g1043 x)
@[simp] axiom s1044 (x : Prop) : f (g1045 x) = f (g1044 x)
@[simp] axiom s1045 (x : Prop) : f (g1046 x) = f (g1045 x)
@[simp] axiom s1046 (x : Prop) : f (g1047 x) = f (g1046 x)
@[simp] axiom s1047 (x : Prop) : f (g1048 x) = f (g1047 x)
@[simp] axiom s1048 (x : Prop) : f (g1049 x) = f (g1048 x)
@[simp] axiom s1049 (x : Prop) : f (g1050 x) = f (g1049 x)
@[simp] axiom s1050 (x : Prop) : f (g1051 x) = f (g1050 x)
@[simp] axiom s1051 (x : Prop) : f (g1052 x) = f (g1051 x)
@[simp] axiom s1052 (x : Prop) : f (g1053 x) = f (g1052 x)
@[simp] axiom s1053 (x : Prop) : f (g1054 x) = f (g1053 x)
@[simp] axiom s1054 (x : Prop) : f (g1055 x) = f (g1054 x)
@[simp] axiom s1055 (x : Prop) : f (g1056 x) = f (g1055 x)
@[simp] axiom s1056 (x : Prop) : f (g1057 x) = f (g1056 x)
@[simp] axiom s1057 (x : Prop) : f (g1058 x) = f (g1057 x)
@[simp] axiom s1058 (x : Prop) : f (g1059 x) = f (g1058 x)
@[simp] axiom s1059 (x : Prop) : f (g1060 x) = f (g1059 x)
@[simp] axiom s1060 (x : Prop) : f (g1061 x) = f (g1060 x)
@[simp] axiom s1061 (x : Prop) : f (g1062 x) = f (g1061 x)
@[simp] axiom s1062 (x : Prop) : f (g1063 x) = f (g1062 x)
@[simp] axiom s1063 (x : Prop) : f (g1064 x) = f (g1063 x)
@[simp] axiom s1064 (x : Prop) : f (g1065 x) = f (g1064 x)
@[simp] axiom s1065 (x : Prop) : f (g1066 x) = f (g1065 x)
@[simp] axiom s1066 (x : Prop) : f (g1067 x) = f (g1066 x)
@[simp] axiom s1067 (x : Prop) : f (g1068 x) = f (g1067 x)
@[simp] axiom s1068 (x : Prop) : f (g1069 x) = f (g1068 x)
@[simp] axiom s1069 (x : Prop) : f (g1070 x) = f (g1069 x)
@[simp] axiom s1070 (x : Prop) : f (g1071 x) = f (g1070 x)
@[simp] axiom s1071 (x : Prop) : f (g1072 x) = f (g1071 x)
@[simp] axiom s1072 (x : Prop) : f (g1073 x) = f (g1072 x)
@[simp] axiom s1073 (x : Prop) : f (g1074 x) = f (g1073 x)
@[simp] axiom s1074 (x : Prop) : f (g1075 x) = f (g1074 x)
@[simp] axiom s1075 (x : Prop) : f (g1076 x) = f (g1075 x)
@[simp] axiom s1076 (x : Prop) : f (g1077 x) = f (g1076 x)
@[simp] axiom s1077 (x : Prop) : f (g1078 x) = f (g1077 x)
@[simp] axiom s1078 (x : Prop) : f (g1079 x) = f (g1078 x)
@[simp] axiom s1079 (x : Prop) : f (g1080 x) = f (g1079 x)
@[simp] axiom s1080 (x : Prop) : f (g1081 x) = f (g1080 x)
@[simp] axiom s1081 (x : Prop) : f (g1082 x) = f (g1081 x)
@[simp] axiom s1082 (x : Prop) : f (g1083 x) = f (g1082 x)
@[simp] axiom s1083 (x : Prop) : f (g1084 x) = f (g1083 x)
@[simp] axiom s1084 (x : Prop) : f (g1085 x) = f (g1084 x)
@[simp] axiom s1085 (x : Prop) : f (g1086 x) = f (g1085 x)
@[simp] axiom s1086 (x : Prop) : f (g1087 x) = f (g1086 x)
@[simp] axiom s1087 (x : Prop) : f (g1088 x) = f (g1087 x)
@[simp] axiom s1088 (x : Prop) : f (g1089 x) = f (g1088 x)
@[simp] axiom s1089 (x : Prop) : f (g1090 x) = f (g1089 x)
@[simp] axiom s1090 (x : Prop) : f (g1091 x) = f (g1090 x)
@[simp] axiom s1091 (x : Prop) : f (g1092 x) = f (g1091 x)
@[simp] axiom s1092 (x : Prop) : f (g1093 x) = f (g1092 x)
@[simp] axiom s1093 (x : Prop) : f (g1094 x) = f (g1093 x)
@[simp] axiom s1094 (x : Prop) : f (g1095 x) = f (g1094 x)
@[simp] axiom s1095 (x : Prop) : f (g1096 x) = f (g1095 x)
@[simp] axiom s1096 (x : Prop) : f (g1097 x) = f (g1096 x)
@[simp] axiom s1097 (x : Prop) : f (g1098 x) = f (g1097 x)
@[simp] axiom s1098 (x : Prop) : f (g1099 x) = f (g1098 x)
@[simp] axiom s1099 (x : Prop) : f (g1100 x) = f (g1099 x)
@[simp] axiom s1100 (x : Prop) : f (g1101 x) = f (g1100 x)
@[simp] axiom s1101 (x : Prop) : f (g1102 x) = f (g1101 x)
@[simp] axiom s1102 (x : Prop) : f (g1103 x) = f (g1102 x)
@[simp] axiom s1103 (x : Prop) : f (g1104 x) = f (g1103 x)
@[simp] axiom s1104 (x : Prop) : f (g1105 x) = f (g1104 x)
@[simp] axiom s1105 (x : Prop) : f (g1106 x) = f (g1105 x)
@[simp] axiom s1106 (x : Prop) : f (g1107 x) = f (g1106 x)
@[simp] axiom s1107 (x : Prop) : f (g1108 x) = f (g1107 x)
@[simp] axiom s1108 (x : Prop) : f (g1109 x) = f (g1108 x)
@[simp] axiom s1109 (x : Prop) : f (g1110 x) = f (g1109 x)
@[simp] axiom s1110 (x : Prop) : f (g1111 x) = f (g1110 x)
@[simp] axiom s1111 (x : Prop) : f (g1112 x) = f (g1111 x)
@[simp] axiom s1112 (x : Prop) : f (g1113 x) = f (g1112 x)
@[simp] axiom s1113 (x : Prop) : f (g1114 x) = f (g1113 x)
@[simp] axiom s1114 (x : Prop) : f (g1115 x) = f (g1114 x)
@[simp] axiom s1115 (x : Prop) : f (g1116 x) = f (g1115 x)
@[simp] axiom s1116 (x : Prop) : f (g1117 x) = f (g1116 x)
@[simp] axiom s1117 (x : Prop) : f (g1118 x) = f (g1117 x)
@[simp] axiom s1118 (x : Prop) : f (g1119 x) = f (g1118 x)
@[simp] axiom s1119 (x : Prop) : f (g1120 x) = f (g1119 x)
@[simp] axiom s1120 (x : Prop) : f (g1121 x) = f (g1120 x)
@[simp] axiom s1121 (x : Prop) : f (g1122 x) = f (g1121 x)
@[simp] axiom s1122 (x : Prop) : f (g1123 x) = f (g1122 x)
@[simp] axiom s1123 (x : Prop) : f (g1124 x) = f (g1123 x)
@[simp] axiom s1124 (x : Prop) : f (g1125 x) = f (g1124 x)
@[simp] axiom s1125 (x : Prop) : f (g1126 x) = f (g1125 x)
@[simp] axiom s1126 (x : Prop) : f (g1127 x) = f (g1126 x)
@[simp] axiom s1127 (x : Prop) : f (g1128 x) = f (g1127 x)
@[simp] axiom s1128 (x : Prop) : f (g1129 x) = f (g1128 x)
@[simp] axiom s1129 (x : Prop) : f (g1130 x) = f (g1129 x)
@[simp] axiom s1130 (x : Prop) : f (g1131 x) = f (g1130 x)
@[simp] axiom s1131 (x : Prop) : f (g1132 x) = f (g1131 x)
@[simp] axiom s1132 (x : Prop) : f (g1133 x) = f (g1132 x)
@[simp] axiom s1133 (x : Prop) : f (g1134 x) = f (g1133 x)
@[simp] axiom s1134 (x : Prop) : f (g1135 x) = f (g1134 x)
@[simp] axiom s1135 (x : Prop) : f (g1136 x) = f (g1135 x)
@[simp] axiom s1136 (x : Prop) : f (g1137 x) = f (g1136 x)
@[simp] axiom s1137 (x : Prop) : f (g1138 x) = f (g1137 x)
@[simp] axiom s1138 (x : Prop) : f (g1139 x) = f (g1138 x)
@[simp] axiom s1139 (x : Prop) : f (g1140 x) = f (g1139 x)
@[simp] axiom s1140 (x : Prop) : f (g1141 x) = f (g1140 x)
@[simp] axiom s1141 (x : Prop) : f (g1142 x) = f (g1141 x)
@[simp] axiom s1142 (x : Prop) : f (g1143 x) = f (g1142 x)
@[simp] axiom s1143 (x : Prop) : f (g1144 x) = f (g1143 x)
@[simp] axiom s1144 (x : Prop) : f (g1145 x) = f (g1144 x)
@[simp] axiom s1145 (x : Prop) : f (g1146 x) = f (g1145 x)
@[simp] axiom s1146 (x : Prop) : f (g1147 x) = f (g1146 x)
@[simp] axiom s1147 (x : Prop) : f (g1148 x) = f (g1147 x)
@[simp] axiom s1148 (x : Prop) : f (g1149 x) = f (g1148 x)
@[simp] axiom s1149 (x : Prop) : f (g1150 x) = f (g1149 x)
@[simp] axiom s1150 (x : Prop) : f (g1151 x) = f (g1150 x)
@[simp] axiom s1151 (x : Prop) : f (g1152 x) = f (g1151 x)
@[simp] axiom s1152 (x : Prop) : f (g1153 x) = f (g1152 x)
@[simp] axiom s1153 (x : Prop) : f (g1154 x) = f (g1153 x)
@[simp] axiom s1154 (x : Prop) : f (g1155 x) = f (g1154 x)
@[simp] axiom s1155 (x : Prop) : f (g1156 x) = f (g1155 x)
@[simp] axiom s1156 (x : Prop) : f (g1157 x) = f (g1156 x)
@[simp] axiom s1157 (x : Prop) : f (g1158 x) = f (g1157 x)
@[simp] axiom s1158 (x : Prop) : f (g1159 x) = f (g1158 x)
@[simp] axiom s1159 (x : Prop) : f (g1160 x) = f (g1159 x)
@[simp] axiom s1160 (x : Prop) : f (g1161 x) = f (g1160 x)
@[simp] axiom s1161 (x : Prop) : f (g1162 x) = f (g1161 x)
@[simp] axiom s1162 (x : Prop) : f (g1163 x) = f (g1162 x)
@[simp] axiom s1163 (x : Prop) : f (g1164 x) = f (g1163 x)
@[simp] axiom s1164 (x : Prop) : f (g1165 x) = f (g1164 x)
@[simp] axiom s1165 (x : Prop) : f (g1166 x) = f (g1165 x)
@[simp] axiom s1166 (x : Prop) : f (g1167 x) = f (g1166 x)
@[simp] axiom s1167 (x : Prop) : f (g1168 x) = f (g1167 x)
@[simp] axiom s1168 (x : Prop) : f (g1169 x) = f (g1168 x)
@[simp] axiom s1169 (x : Prop) : f (g1170 x) = f (g1169 x)
@[simp] axiom s1170 (x : Prop) : f (g1171 x) = f (g1170 x)
@[simp] axiom s1171 (x : Prop) : f (g1172 x) = f (g1171 x)
@[simp] axiom s1172 (x : Prop) : f (g1173 x) = f (g1172 x)
@[simp] axiom s1173 (x : Prop) : f (g1174 x) = f (g1173 x)
@[simp] axiom s1174 (x : Prop) : f (g1175 x) = f (g1174 x)
@[simp] axiom s1175 (x : Prop) : f (g1176 x) = f (g1175 x)
@[simp] axiom s1176 (x : Prop) : f (g1177 x) = f (g1176 x)
@[simp] axiom s1177 (x : Prop) : f (g1178 x) = f (g1177 x)
@[simp] axiom s1178 (x : Prop) : f (g1179 x) = f (g1178 x)
@[simp] axiom s1179 (x : Prop) : f (g1180 x) = f (g1179 x)
@[simp] axiom s1180 (x : Prop) : f (g1181 x) = f (g1180 x)
@[simp] axiom s1181 (x : Prop) : f (g1182 x) = f (g1181 x)
@[simp] axiom s1182 (x : Prop) : f (g1183 x) = f (g1182 x)
@[simp] axiom s1183 (x : Prop) : f (g1184 x) = f (g1183 x)
@[simp] axiom s1184 (x : Prop) : f (g1185 x) = f (g1184 x)
@[simp] axiom s1185 (x : Prop) : f (g1186 x) = f (g1185 x)
@[simp] axiom s1186 (x : Prop) : f (g1187 x) = f (g1186 x)
@[simp] axiom s1187 (x : Prop) : f (g1188 x) = f (g1187 x)
@[simp] axiom s1188 (x : Prop) : f (g1189 x) = f (g1188 x)
@[simp] axiom s1189 (x : Prop) : f (g1190 x) = f (g1189 x)
@[simp] axiom s1190 (x : Prop) : f (g1191 x) = f (g1190 x)
@[simp] axiom s1191 (x : Prop) : f (g1192 x) = f (g1191 x)
@[simp] axiom s1192 (x : Prop) : f (g1193 x) = f (g1192 x)
@[simp] axiom s1193 (x : Prop) : f (g1194 x) = f (g1193 x)
@[simp] axiom s1194 (x : Prop) : f (g1195 x) = f (g1194 x)
@[simp] axiom s1195 (x : Prop) : f (g1196 x) = f (g1195 x)
@[simp] axiom s1196 (x : Prop) : f (g1197 x) = f (g1196 x)
@[simp] axiom s1197 (x : Prop) : f (g1198 x) = f (g1197 x)
@[simp] axiom s1198 (x : Prop) : f (g1199 x) = f (g1198 x)
@[simp] axiom s1199 (x : Prop) : f (g1200 x) = f (g1199 x)
@[simp] axiom s1200 (x : Prop) : f (g1201 x) = f (g1200 x)
@[simp] axiom s1201 (x : Prop) : f (g1202 x) = f (g1201 x)
@[simp] axiom s1202 (x : Prop) : f (g1203 x) = f (g1202 x)
@[simp] axiom s1203 (x : Prop) : f (g1204 x) = f (g1203 x)
@[simp] axiom s1204 (x : Prop) : f (g1205 x) = f (g1204 x)
@[simp] axiom s1205 (x : Prop) : f (g1206 x) = f (g1205 x)
@[simp] axiom s1206 (x : Prop) : f (g1207 x) = f (g1206 x)
@[simp] axiom s1207 (x : Prop) : f (g1208 x) = f (g1207 x)
@[simp] axiom s1208 (x : Prop) : f (g1209 x) = f (g1208 x)
@[simp] axiom s1209 (x : Prop) : f (g1210 x) = f (g1209 x)
@[simp] axiom s1210 (x : Prop) : f (g1211 x) = f (g1210 x)
@[simp] axiom s1211 (x : Prop) : f (g1212 x) = f (g1211 x)
@[simp] axiom s1212 (x : Prop) : f (g1213 x) = f (g1212 x)
@[simp] axiom s1213 (x : Prop) : f (g1214 x) = f (g1213 x)
@[simp] axiom s1214 (x : Prop) : f (g1215 x) = f (g1214 x)
@[simp] axiom s1215 (x : Prop) : f (g1216 x) = f (g1215 x)
@[simp] axiom s1216 (x : Prop) : f (g1217 x) = f (g1216 x)
@[simp] axiom s1217 (x : Prop) : f (g1218 x) = f (g1217 x)
@[simp] axiom s1218 (x : Prop) : f (g1219 x) = f (g1218 x)
@[simp] axiom s1219 (x : Prop) : f (g1220 x) = f (g1219 x)
@[simp] axiom s1220 (x : Prop) : f (g1221 x) = f (g1220 x)
@[simp] axiom s1221 (x : Prop) : f (g1222 x) = f (g1221 x)
@[simp] axiom s1222 (x : Prop) : f (g1223 x) = f (g1222 x)
@[simp] axiom s1223 (x : Prop) : f (g1224 x) = f (g1223 x)
@[simp] axiom s1224 (x : Prop) : f (g1225 x) = f (g1224 x)
@[simp] axiom s1225 (x : Prop) : f (g1226 x) = f (g1225 x)
@[simp] axiom s1226 (x : Prop) : f (g1227 x) = f (g1226 x)
@[simp] axiom s1227 (x : Prop) : f (g1228 x) = f (g1227 x)
@[simp] axiom s1228 (x : Prop) : f (g1229 x) = f (g1228 x)
@[simp] axiom s1229 (x : Prop) : f (g1230 x) = f (g1229 x)
@[simp] axiom s1230 (x : Prop) : f (g1231 x) = f (g1230 x)
@[simp] axiom s1231 (x : Prop) : f (g1232 x) = f (g1231 x)
@[simp] axiom s1232 (x : Prop) : f (g1233 x) = f (g1232 x)
@[simp] axiom s1233 (x : Prop) : f (g1234 x) = f (g1233 x)
@[simp] axiom s1234 (x : Prop) : f (g1235 x) = f (g1234 x)
@[simp] axiom s1235 (x : Prop) : f (g1236 x) = f (g1235 x)
@[simp] axiom s1236 (x : Prop) : f (g1237 x) = f (g1236 x)
@[simp] axiom s1237 (x : Prop) : f (g1238 x) = f (g1237 x)
@[simp] axiom s1238 (x : Prop) : f (g1239 x) = f (g1238 x)
@[simp] axiom s1239 (x : Prop) : f (g1240 x) = f (g1239 x)
@[simp] axiom s1240 (x : Prop) : f (g1241 x) = f (g1240 x)
@[simp] axiom s1241 (x : Prop) : f (g1242 x) = f (g1241 x)
@[simp] axiom s1242 (x : Prop) : f (g1243 x) = f (g1242 x)
@[simp] axiom s1243 (x : Prop) : f (g1244 x) = f (g1243 x)
@[simp] axiom s1244 (x : Prop) : f (g1245 x) = f (g1244 x)
@[simp] axiom s1245 (x : Prop) : f (g1246 x) = f (g1245 x)
@[simp] axiom s1246 (x : Prop) : f (g1247 x) = f (g1246 x)
@[simp] axiom s1247 (x : Prop) : f (g1248 x) = f (g1247 x)
@[simp] axiom s1248 (x : Prop) : f (g1249 x) = f (g1248 x)
@[simp] axiom s1249 (x : Prop) : f (g1250 x) = f (g1249 x)
@[simp] axiom s1250 (x : Prop) : f (g1251 x) = f (g1250 x)
@[simp] axiom s1251 (x : Prop) : f (g1252 x) = f (g1251 x)
@[simp] axiom s1252 (x : Prop) : f (g1253 x) = f (g1252 x)
@[simp] axiom s1253 (x : Prop) : f (g1254 x) = f (g1253 x)
@[simp] axiom s1254 (x : Prop) : f (g1255 x) = f (g1254 x)
@[simp] axiom s1255 (x : Prop) : f (g1256 x) = f (g1255 x)
@[simp] axiom s1256 (x : Prop) : f (g1257 x) = f (g1256 x)
@[simp] axiom s1257 (x : Prop) : f (g1258 x) = f (g1257 x)
@[simp] axiom s1258 (x : Prop) : f (g1259 x) = f (g1258 x)
@[simp] axiom s1259 (x : Prop) : f (g1260 x) = f (g1259 x)
@[simp] axiom s1260 (x : Prop) : f (g1261 x) = f (g1260 x)
@[simp] axiom s1261 (x : Prop) : f (g1262 x) = f (g1261 x)
@[simp] axiom s1262 (x : Prop) : f (g1263 x) = f (g1262 x)
@[simp] axiom s1263 (x : Prop) : f (g1264 x) = f (g1263 x)
@[simp] axiom s1264 (x : Prop) : f (g1265 x) = f (g1264 x)
@[simp] axiom s1265 (x : Prop) : f (g1266 x) = f (g1265 x)
@[simp] axiom s1266 (x : Prop) : f (g1267 x) = f (g1266 x)
@[simp] axiom s1267 (x : Prop) : f (g1268 x) = f (g1267 x)
@[simp] axiom s1268 (x : Prop) : f (g1269 x) = f (g1268 x)
@[simp] axiom s1269 (x : Prop) : f (g1270 x) = f (g1269 x)
@[simp] axiom s1270 (x : Prop) : f (g1271 x) = f (g1270 x)
@[simp] axiom s1271 (x : Prop) : f (g1272 x) = f (g1271 x)
@[simp] axiom s1272 (x : Prop) : f (g1273 x) = f (g1272 x)
@[simp] axiom s1273 (x : Prop) : f (g1274 x) = f (g1273 x)
@[simp] axiom s1274 (x : Prop) : f (g1275 x) = f (g1274 x)
@[simp] axiom s1275 (x : Prop) : f (g1276 x) = f (g1275 x)
@[simp] axiom s1276 (x : Prop) : f (g1277 x) = f (g1276 x)
@[simp] axiom s1277 (x : Prop) : f (g1278 x) = f (g1277 x)
@[simp] axiom s1278 (x : Prop) : f (g1279 x) = f (g1278 x)
@[simp] axiom s1279 (x : Prop) : f (g1280 x) = f (g1279 x)
@[simp] axiom s1280 (x : Prop) : f (g1281 x) = f (g1280 x)
@[simp] axiom s1281 (x : Prop) : f (g1282 x) = f (g1281 x)
@[simp] axiom s1282 (x : Prop) : f (g1283 x) = f (g1282 x)
@[simp] axiom s1283 (x : Prop) : f (g1284 x) = f (g1283 x)
@[simp] axiom s1284 (x : Prop) : f (g1285 x) = f (g1284 x)
@[simp] axiom s1285 (x : Prop) : f (g1286 x) = f (g1285 x)
@[simp] axiom s1286 (x : Prop) : f (g1287 x) = f (g1286 x)
@[simp] axiom s1287 (x : Prop) : f (g1288 x) = f (g1287 x)
@[simp] axiom s1288 (x : Prop) : f (g1289 x) = f (g1288 x)
@[simp] axiom s1289 (x : Prop) : f (g1290 x) = f (g1289 x)
@[simp] axiom s1290 (x : Prop) : f (g1291 x) = f (g1290 x)
@[simp] axiom s1291 (x : Prop) : f (g1292 x) = f (g1291 x)
@[simp] axiom s1292 (x : Prop) : f (g1293 x) = f (g1292 x)
@[simp] axiom s1293 (x : Prop) : f (g1294 x) = f (g1293 x)
@[simp] axiom s1294 (x : Prop) : f (g1295 x) = f (g1294 x)
@[simp] axiom s1295 (x : Prop) : f (g1296 x) = f (g1295 x)
@[simp] axiom s1296 (x : Prop) : f (g1297 x) = f (g1296 x)
@[simp] axiom s1297 (x : Prop) : f (g1298 x) = f (g1297 x)
@[simp] axiom s1298 (x : Prop) : f (g1299 x) = f (g1298 x)
@[simp] axiom s1299 (x : Prop) : f (g1300 x) = f (g1299 x)
@[simp] axiom s1300 (x : Prop) : f (g1301 x) = f (g1300 x)
@[simp] axiom s1301 (x : Prop) : f (g1302 x) = f (g1301 x)
@[simp] axiom s1302 (x : Prop) : f (g1303 x) = f (g1302 x)
@[simp] axiom s1303 (x : Prop) : f (g1304 x) = f (g1303 x)
@[simp] axiom s1304 (x : Prop) : f (g1305 x) = f (g1304 x)
@[simp] axiom s1305 (x : Prop) : f (g1306 x) = f (g1305 x)
@[simp] axiom s1306 (x : Prop) : f (g1307 x) = f (g1306 x)
@[simp] axiom s1307 (x : Prop) : f (g1308 x) = f (g1307 x)
@[simp] axiom s1308 (x : Prop) : f (g1309 x) = f (g1308 x)
@[simp] axiom s1309 (x : Prop) : f (g1310 x) = f (g1309 x)
@[simp] axiom s1310 (x : Prop) : f (g1311 x) = f (g1310 x)
@[simp] axiom s1311 (x : Prop) : f (g1312 x) = f (g1311 x)
@[simp] axiom s1312 (x : Prop) : f (g1313 x) = f (g1312 x)
@[simp] axiom s1313 (x : Prop) : f (g1314 x) = f (g1313 x)
@[simp] axiom s1314 (x : Prop) : f (g1315 x) = f (g1314 x)
@[simp] axiom s1315 (x : Prop) : f (g1316 x) = f (g1315 x)
@[simp] axiom s1316 (x : Prop) : f (g1317 x) = f (g1316 x)
@[simp] axiom s1317 (x : Prop) : f (g1318 x) = f (g1317 x)
@[simp] axiom s1318 (x : Prop) : f (g1319 x) = f (g1318 x)
@[simp] axiom s1319 (x : Prop) : f (g1320 x) = f (g1319 x)
@[simp] axiom s1320 (x : Prop) : f (g1321 x) = f (g1320 x)
@[simp] axiom s1321 (x : Prop) : f (g1322 x) = f (g1321 x)
@[simp] axiom s1322 (x : Prop) : f (g1323 x) = f (g1322 x)
@[simp] axiom s1323 (x : Prop) : f (g1324 x) = f (g1323 x)
@[simp] axiom s1324 (x : Prop) : f (g1325 x) = f (g1324 x)
@[simp] axiom s1325 (x : Prop) : f (g1326 x) = f (g1325 x)
@[simp] axiom s1326 (x : Prop) : f (g1327 x) = f (g1326 x)
@[simp] axiom s1327 (x : Prop) : f (g1328 x) = f (g1327 x)
@[simp] axiom s1328 (x : Prop) : f (g1329 x) = f (g1328 x)
@[simp] axiom s1329 (x : Prop) : f (g1330 x) = f (g1329 x)
@[simp] axiom s1330 (x : Prop) : f (g1331 x) = f (g1330 x)
@[simp] axiom s1331 (x : Prop) : f (g1332 x) = f (g1331 x)
@[simp] axiom s1332 (x : Prop) : f (g1333 x) = f (g1332 x)
@[simp] axiom s1333 (x : Prop) : f (g1334 x) = f (g1333 x)
@[simp] axiom s1334 (x : Prop) : f (g1335 x) = f (g1334 x)
@[simp] axiom s1335 (x : Prop) : f (g1336 x) = f (g1335 x)
@[simp] axiom s1336 (x : Prop) : f (g1337 x) = f (g1336 x)
@[simp] axiom s1337 (x : Prop) : f (g1338 x) = f (g1337 x)
@[simp] axiom s1338 (x : Prop) : f (g1339 x) = f (g1338 x)
@[simp] axiom s1339 (x : Prop) : f (g1340 x) = f (g1339 x)
@[simp] axiom s1340 (x : Prop) : f (g1341 x) = f (g1340 x)
@[simp] axiom s1341 (x : Prop) : f (g1342 x) = f (g1341 x)
@[simp] axiom s1342 (x : Prop) : f (g1343 x) = f (g1342 x)
@[simp] axiom s1343 (x : Prop) : f (g1344 x) = f (g1343 x)
@[simp] axiom s1344 (x : Prop) : f (g1345 x) = f (g1344 x)
@[simp] axiom s1345 (x : Prop) : f (g1346 x) = f (g1345 x)
@[simp] axiom s1346 (x : Prop) : f (g1347 x) = f (g1346 x)
@[simp] axiom s1347 (x : Prop) : f (g1348 x) = f (g1347 x)
@[simp] axiom s1348 (x : Prop) : f (g1349 x) = f (g1348 x)
@[simp] axiom s1349 (x : Prop) : f (g1350 x) = f (g1349 x)
@[simp] axiom s1350 (x : Prop) : f (g1351 x) = f (g1350 x)
@[simp] axiom s1351 (x : Prop) : f (g1352 x) = f (g1351 x)
@[simp] axiom s1352 (x : Prop) : f (g1353 x) = f (g1352 x)
@[simp] axiom s1353 (x : Prop) : f (g1354 x) = f (g1353 x)
@[simp] axiom s1354 (x : Prop) : f (g1355 x) = f (g1354 x)
@[simp] axiom s1355 (x : Prop) : f (g1356 x) = f (g1355 x)
@[simp] axiom s1356 (x : Prop) : f (g1357 x) = f (g1356 x)
@[simp] axiom s1357 (x : Prop) : f (g1358 x) = f (g1357 x)
@[simp] axiom s1358 (x : Prop) : f (g1359 x) = f (g1358 x)
@[simp] axiom s1359 (x : Prop) : f (g1360 x) = f (g1359 x)
@[simp] axiom s1360 (x : Prop) : f (g1361 x) = f (g1360 x)
@[simp] axiom s1361 (x : Prop) : f (g1362 x) = f (g1361 x)
@[simp] axiom s1362 (x : Prop) : f (g1363 x) = f (g1362 x)
@[simp] axiom s1363 (x : Prop) : f (g1364 x) = f (g1363 x)
@[simp] axiom s1364 (x : Prop) : f (g1365 x) = f (g1364 x)
@[simp] axiom s1365 (x : Prop) : f (g1366 x) = f (g1365 x)
@[simp] axiom s1366 (x : Prop) : f (g1367 x) = f (g1366 x)
@[simp] axiom s1367 (x : Prop) : f (g1368 x) = f (g1367 x)
@[simp] axiom s1368 (x : Prop) : f (g1369 x) = f (g1368 x)
@[simp] axiom s1369 (x : Prop) : f (g1370 x) = f (g1369 x)
@[simp] axiom s1370 (x : Prop) : f (g1371 x) = f (g1370 x)
@[simp] axiom s1371 (x : Prop) : f (g1372 x) = f (g1371 x)
@[simp] axiom s1372 (x : Prop) : f (g1373 x) = f (g1372 x)
@[simp] axiom s1373 (x : Prop) : f (g1374 x) = f (g1373 x)
@[simp] axiom s1374 (x : Prop) : f (g1375 x) = f (g1374 x)
@[simp] axiom s1375 (x : Prop) : f (g1376 x) = f (g1375 x)
@[simp] axiom s1376 (x : Prop) : f (g1377 x) = f (g1376 x)
@[simp] axiom s1377 (x : Prop) : f (g1378 x) = f (g1377 x)
@[simp] axiom s1378 (x : Prop) : f (g1379 x) = f (g1378 x)
@[simp] axiom s1379 (x : Prop) : f (g1380 x) = f (g1379 x)
@[simp] axiom s1380 (x : Prop) : f (g1381 x) = f (g1380 x)
@[simp] axiom s1381 (x : Prop) : f (g1382 x) = f (g1381 x)
@[simp] axiom s1382 (x : Prop) : f (g1383 x) = f (g1382 x)
@[simp] axiom s1383 (x : Prop) : f (g1384 x) = f (g1383 x)
@[simp] axiom s1384 (x : Prop) : f (g1385 x) = f (g1384 x)
@[simp] axiom s1385 (x : Prop) : f (g1386 x) = f (g1385 x)
@[simp] axiom s1386 (x : Prop) : f (g1387 x) = f (g1386 x)
@[simp] axiom s1387 (x : Prop) : f (g1388 x) = f (g1387 x)
@[simp] axiom s1388 (x : Prop) : f (g1389 x) = f (g1388 x)
@[simp] axiom s1389 (x : Prop) : f (g1390 x) = f (g1389 x)
@[simp] axiom s1390 (x : Prop) : f (g1391 x) = f (g1390 x)
@[simp] axiom s1391 (x : Prop) : f (g1392 x) = f (g1391 x)
@[simp] axiom s1392 (x : Prop) : f (g1393 x) = f (g1392 x)
@[simp] axiom s1393 (x : Prop) : f (g1394 x) = f (g1393 x)
@[simp] axiom s1394 (x : Prop) : f (g1395 x) = f (g1394 x)
@[simp] axiom s1395 (x : Prop) : f (g1396 x) = f (g1395 x)
@[simp] axiom s1396 (x : Prop) : f (g1397 x) = f (g1396 x)
@[simp] axiom s1397 (x : Prop) : f (g1398 x) = f (g1397 x)
@[simp] axiom s1398 (x : Prop) : f (g1399 x) = f (g1398 x)
@[simp] axiom s1399 (x : Prop) : f (g1400 x) = f (g1399 x)
@[simp] axiom s1400 (x : Prop) : f (g1401 x) = f (g1400 x)
@[simp] axiom s1401 (x : Prop) : f (g1402 x) = f (g1401 x)
@[simp] axiom s1402 (x : Prop) : f (g1403 x) = f (g1402 x)
@[simp] axiom s1403 (x : Prop) : f (g1404 x) = f (g1403 x)
@[simp] axiom s1404 (x : Prop) : f (g1405 x) = f (g1404 x)
@[simp] axiom s1405 (x : Prop) : f (g1406 x) = f (g1405 x)
@[simp] axiom s1406 (x : Prop) : f (g1407 x) = f (g1406 x)
@[simp] axiom s1407 (x : Prop) : f (g1408 x) = f (g1407 x)
@[simp] axiom s1408 (x : Prop) : f (g1409 x) = f (g1408 x)
@[simp] axiom s1409 (x : Prop) : f (g1410 x) = f (g1409 x)
@[simp] axiom s1410 (x : Prop) : f (g1411 x) = f (g1410 x)
@[simp] axiom s1411 (x : Prop) : f (g1412 x) = f (g1411 x)
@[simp] axiom s1412 (x : Prop) : f (g1413 x) = f (g1412 x)
@[simp] axiom s1413 (x : Prop) : f (g1414 x) = f (g1413 x)
@[simp] axiom s1414 (x : Prop) : f (g1415 x) = f (g1414 x)
@[simp] axiom s1415 (x : Prop) : f (g1416 x) = f (g1415 x)
@[simp] axiom s1416 (x : Prop) : f (g1417 x) = f (g1416 x)
@[simp] axiom s1417 (x : Prop) : f (g1418 x) = f (g1417 x)
@[simp] axiom s1418 (x : Prop) : f (g1419 x) = f (g1418 x)
@[simp] axiom s1419 (x : Prop) : f (g1420 x) = f (g1419 x)
@[simp] axiom s1420 (x : Prop) : f (g1421 x) = f (g1420 x)
@[simp] axiom s1421 (x : Prop) : f (g1422 x) = f (g1421 x)
@[simp] axiom s1422 (x : Prop) : f (g1423 x) = f (g1422 x)
@[simp] axiom s1423 (x : Prop) : f (g1424 x) = f (g1423 x)
@[simp] axiom s1424 (x : Prop) : f (g1425 x) = f (g1424 x)
@[simp] axiom s1425 (x : Prop) : f (g1426 x) = f (g1425 x)
@[simp] axiom s1426 (x : Prop) : f (g1427 x) = f (g1426 x)
@[simp] axiom s1427 (x : Prop) : f (g1428 x) = f (g1427 x)
@[simp] axiom s1428 (x : Prop) : f (g1429 x) = f (g1428 x)
@[simp] axiom s1429 (x : Prop) : f (g1430 x) = f (g1429 x)
@[simp] axiom s1430 (x : Prop) : f (g1431 x) = f (g1430 x)
@[simp] axiom s1431 (x : Prop) : f (g1432 x) = f (g1431 x)
@[simp] axiom s1432 (x : Prop) : f (g1433 x) = f (g1432 x)
@[simp] axiom s1433 (x : Prop) : f (g1434 x) = f (g1433 x)
@[simp] axiom s1434 (x : Prop) : f (g1435 x) = f (g1434 x)
@[simp] axiom s1435 (x : Prop) : f (g1436 x) = f (g1435 x)
@[simp] axiom s1436 (x : Prop) : f (g1437 x) = f (g1436 x)
@[simp] axiom s1437 (x : Prop) : f (g1438 x) = f (g1437 x)
@[simp] axiom s1438 (x : Prop) : f (g1439 x) = f (g1438 x)
@[simp] axiom s1439 (x : Prop) : f (g1440 x) = f (g1439 x)
@[simp] axiom s1440 (x : Prop) : f (g1441 x) = f (g1440 x)
@[simp] axiom s1441 (x : Prop) : f (g1442 x) = f (g1441 x)
@[simp] axiom s1442 (x : Prop) : f (g1443 x) = f (g1442 x)
@[simp] axiom s1443 (x : Prop) : f (g1444 x) = f (g1443 x)
@[simp] axiom s1444 (x : Prop) : f (g1445 x) = f (g1444 x)
@[simp] axiom s1445 (x : Prop) : f (g1446 x) = f (g1445 x)
@[simp] axiom s1446 (x : Prop) : f (g1447 x) = f (g1446 x)
@[simp] axiom s1447 (x : Prop) : f (g1448 x) = f (g1447 x)
@[simp] axiom s1448 (x : Prop) : f (g1449 x) = f (g1448 x)
@[simp] axiom s1449 (x : Prop) : f (g1450 x) = f (g1449 x)
@[simp] axiom s1450 (x : Prop) : f (g1451 x) = f (g1450 x)
@[simp] axiom s1451 (x : Prop) : f (g1452 x) = f (g1451 x)
@[simp] axiom s1452 (x : Prop) : f (g1453 x) = f (g1452 x)
@[simp] axiom s1453 (x : Prop) : f (g1454 x) = f (g1453 x)
@[simp] axiom s1454 (x : Prop) : f (g1455 x) = f (g1454 x)
@[simp] axiom s1455 (x : Prop) : f (g1456 x) = f (g1455 x)
@[simp] axiom s1456 (x : Prop) : f (g1457 x) = f (g1456 x)
@[simp] axiom s1457 (x : Prop) : f (g1458 x) = f (g1457 x)
@[simp] axiom s1458 (x : Prop) : f (g1459 x) = f (g1458 x)
@[simp] axiom s1459 (x : Prop) : f (g1460 x) = f (g1459 x)
@[simp] axiom s1460 (x : Prop) : f (g1461 x) = f (g1460 x)
@[simp] axiom s1461 (x : Prop) : f (g1462 x) = f (g1461 x)
@[simp] axiom s1462 (x : Prop) : f (g1463 x) = f (g1462 x)
@[simp] axiom s1463 (x : Prop) : f (g1464 x) = f (g1463 x)
@[simp] axiom s1464 (x : Prop) : f (g1465 x) = f (g1464 x)
@[simp] axiom s1465 (x : Prop) : f (g1466 x) = f (g1465 x)
@[simp] axiom s1466 (x : Prop) : f (g1467 x) = f (g1466 x)
@[simp] axiom s1467 (x : Prop) : f (g1468 x) = f (g1467 x)
@[simp] axiom s1468 (x : Prop) : f (g1469 x) = f (g1468 x)
@[simp] axiom s1469 (x : Prop) : f (g1470 x) = f (g1469 x)
@[simp] axiom s1470 (x : Prop) : f (g1471 x) = f (g1470 x)
@[simp] axiom s1471 (x : Prop) : f (g1472 x) = f (g1471 x)
@[simp] axiom s1472 (x : Prop) : f (g1473 x) = f (g1472 x)
@[simp] axiom s1473 (x : Prop) : f (g1474 x) = f (g1473 x)
@[simp] axiom s1474 (x : Prop) : f (g1475 x) = f (g1474 x)
@[simp] axiom s1475 (x : Prop) : f (g1476 x) = f (g1475 x)
@[simp] axiom s1476 (x : Prop) : f (g1477 x) = f (g1476 x)
@[simp] axiom s1477 (x : Prop) : f (g1478 x) = f (g1477 x)
@[simp] axiom s1478 (x : Prop) : f (g1479 x) = f (g1478 x)
@[simp] axiom s1479 (x : Prop) : f (g1480 x) = f (g1479 x)
@[simp] axiom s1480 (x : Prop) : f (g1481 x) = f (g1480 x)
@[simp] axiom s1481 (x : Prop) : f (g1482 x) = f (g1481 x)
@[simp] axiom s1482 (x : Prop) : f (g1483 x) = f (g1482 x)
@[simp] axiom s1483 (x : Prop) : f (g1484 x) = f (g1483 x)
@[simp] axiom s1484 (x : Prop) : f (g1485 x) = f (g1484 x)
@[simp] axiom s1485 (x : Prop) : f (g1486 x) = f (g1485 x)
@[simp] axiom s1486 (x : Prop) : f (g1487 x) = f (g1486 x)
@[simp] axiom s1487 (x : Prop) : f (g1488 x) = f (g1487 x)
@[simp] axiom s1488 (x : Prop) : f (g1489 x) = f (g1488 x)
@[simp] axiom s1489 (x : Prop) : f (g1490 x) = f (g1489 x)
@[simp] axiom s1490 (x : Prop) : f (g1491 x) = f (g1490 x)
@[simp] axiom s1491 (x : Prop) : f (g1492 x) = f (g1491 x)
@[simp] axiom s1492 (x : Prop) : f (g1493 x) = f (g1492 x)
@[simp] axiom s1493 (x : Prop) : f (g1494 x) = f (g1493 x)
@[simp] axiom s1494 (x : Prop) : f (g1495 x) = f (g1494 x)
@[simp] axiom s1495 (x : Prop) : f (g1496 x) = f (g1495 x)
@[simp] axiom s1496 (x : Prop) : f (g1497 x) = f (g1496 x)
@[simp] axiom s1497 (x : Prop) : f (g1498 x) = f (g1497 x)
@[simp] axiom s1498 (x : Prop) : f (g1499 x) = f (g1498 x)
@[simp] axiom s1499 (x : Prop) : f (g1500 x) = f (g1499 x)
@[simp] axiom s1500 (x : Prop) : f (g1501 x) = f (g1500 x)
@[simp] axiom s1501 (x : Prop) : f (g1502 x) = f (g1501 x)
@[simp] axiom s1502 (x : Prop) : f (g1503 x) = f (g1502 x)
@[simp] axiom s1503 (x : Prop) : f (g1504 x) = f (g1503 x)
@[simp] axiom s1504 (x : Prop) : f (g1505 x) = f (g1504 x)
@[simp] axiom s1505 (x : Prop) : f (g1506 x) = f (g1505 x)
@[simp] axiom s1506 (x : Prop) : f (g1507 x) = f (g1506 x)
@[simp] axiom s1507 (x : Prop) : f (g1508 x) = f (g1507 x)
@[simp] axiom s1508 (x : Prop) : f (g1509 x) = f (g1508 x)
@[simp] axiom s1509 (x : Prop) : f (g1510 x) = f (g1509 x)
@[simp] axiom s1510 (x : Prop) : f (g1511 x) = f (g1510 x)
@[simp] axiom s1511 (x : Prop) : f (g1512 x) = f (g1511 x)
@[simp] axiom s1512 (x : Prop) : f (g1513 x) = f (g1512 x)
@[simp] axiom s1513 (x : Prop) : f (g1514 x) = f (g1513 x)
@[simp] axiom s1514 (x : Prop) : f (g1515 x) = f (g1514 x)
@[simp] axiom s1515 (x : Prop) : f (g1516 x) = f (g1515 x)
@[simp] axiom s1516 (x : Prop) : f (g1517 x) = f (g1516 x)
@[simp] axiom s1517 (x : Prop) : f (g1518 x) = f (g1517 x)
@[simp] axiom s1518 (x : Prop) : f (g1519 x) = f (g1518 x)
@[simp] axiom s1519 (x : Prop) : f (g1520 x) = f (g1519 x)
@[simp] axiom s1520 (x : Prop) : f (g1521 x) = f (g1520 x)
@[simp] axiom s1521 (x : Prop) : f (g1522 x) = f (g1521 x)
@[simp] axiom s1522 (x : Prop) : f (g1523 x) = f (g1522 x)
@[simp] axiom s1523 (x : Prop) : f (g1524 x) = f (g1523 x)
@[simp] axiom s1524 (x : Prop) : f (g1525 x) = f (g1524 x)
@[simp] axiom s1525 (x : Prop) : f (g1526 x) = f (g1525 x)
@[simp] axiom s1526 (x : Prop) : f (g1527 x) = f (g1526 x)
@[simp] axiom s1527 (x : Prop) : f (g1528 x) = f (g1527 x)
@[simp] axiom s1528 (x : Prop) : f (g1529 x) = f (g1528 x)
@[simp] axiom s1529 (x : Prop) : f (g1530 x) = f (g1529 x)
@[simp] axiom s1530 (x : Prop) : f (g1531 x) = f (g1530 x)
@[simp] axiom s1531 (x : Prop) : f (g1532 x) = f (g1531 x)
@[simp] axiom s1532 (x : Prop) : f (g1533 x) = f (g1532 x)
@[simp] axiom s1533 (x : Prop) : f (g1534 x) = f (g1533 x)
@[simp] axiom s1534 (x : Prop) : f (g1535 x) = f (g1534 x)
@[simp] axiom s1535 (x : Prop) : f (g1536 x) = f (g1535 x)
@[simp] axiom s1536 (x : Prop) : f (g1537 x) = f (g1536 x)
@[simp] axiom s1537 (x : Prop) : f (g1538 x) = f (g1537 x)
@[simp] axiom s1538 (x : Prop) : f (g1539 x) = f (g1538 x)
@[simp] axiom s1539 (x : Prop) : f (g1540 x) = f (g1539 x)
@[simp] axiom s1540 (x : Prop) : f (g1541 x) = f (g1540 x)
@[simp] axiom s1541 (x : Prop) : f (g1542 x) = f (g1541 x)
@[simp] axiom s1542 (x : Prop) : f (g1543 x) = f (g1542 x)
@[simp] axiom s1543 (x : Prop) : f (g1544 x) = f (g1543 x)
@[simp] axiom s1544 (x : Prop) : f (g1545 x) = f (g1544 x)
@[simp] axiom s1545 (x : Prop) : f (g1546 x) = f (g1545 x)
@[simp] axiom s1546 (x : Prop) : f (g1547 x) = f (g1546 x)
@[simp] axiom s1547 (x : Prop) : f (g1548 x) = f (g1547 x)
@[simp] axiom s1548 (x : Prop) : f (g1549 x) = f (g1548 x)
@[simp] axiom s1549 (x : Prop) : f (g1550 x) = f (g1549 x)
@[simp] axiom s1550 (x : Prop) : f (g1551 x) = f (g1550 x)
@[simp] axiom s1551 (x : Prop) : f (g1552 x) = f (g1551 x)
@[simp] axiom s1552 (x : Prop) : f (g1553 x) = f (g1552 x)
@[simp] axiom s1553 (x : Prop) : f (g1554 x) = f (g1553 x)
@[simp] axiom s1554 (x : Prop) : f (g1555 x) = f (g1554 x)
@[simp] axiom s1555 (x : Prop) : f (g1556 x) = f (g1555 x)
@[simp] axiom s1556 (x : Prop) : f (g1557 x) = f (g1556 x)
@[simp] axiom s1557 (x : Prop) : f (g1558 x) = f (g1557 x)
@[simp] axiom s1558 (x : Prop) : f (g1559 x) = f (g1558 x)
@[simp] axiom s1559 (x : Prop) : f (g1560 x) = f (g1559 x)
@[simp] axiom s1560 (x : Prop) : f (g1561 x) = f (g1560 x)
@[simp] axiom s1561 (x : Prop) : f (g1562 x) = f (g1561 x)
@[simp] axiom s1562 (x : Prop) : f (g1563 x) = f (g1562 x)
@[simp] axiom s1563 (x : Prop) : f (g1564 x) = f (g1563 x)
@[simp] axiom s1564 (x : Prop) : f (g1565 x) = f (g1564 x)
@[simp] axiom s1565 (x : Prop) : f (g1566 x) = f (g1565 x)
@[simp] axiom s1566 (x : Prop) : f (g1567 x) = f (g1566 x)
@[simp] axiom s1567 (x : Prop) : f (g1568 x) = f (g1567 x)
@[simp] axiom s1568 (x : Prop) : f (g1569 x) = f (g1568 x)
@[simp] axiom s1569 (x : Prop) : f (g1570 x) = f (g1569 x)
@[simp] axiom s1570 (x : Prop) : f (g1571 x) = f (g1570 x)
@[simp] axiom s1571 (x : Prop) : f (g1572 x) = f (g1571 x)
@[simp] axiom s1572 (x : Prop) : f (g1573 x) = f (g1572 x)
@[simp] axiom s1573 (x : Prop) : f (g1574 x) = f (g1573 x)
@[simp] axiom s1574 (x : Prop) : f (g1575 x) = f (g1574 x)
@[simp] axiom s1575 (x : Prop) : f (g1576 x) = f (g1575 x)
@[simp] axiom s1576 (x : Prop) : f (g1577 x) = f (g1576 x)
@[simp] axiom s1577 (x : Prop) : f (g1578 x) = f (g1577 x)
@[simp] axiom s1578 (x : Prop) : f (g1579 x) = f (g1578 x)
@[simp] axiom s1579 (x : Prop) : f (g1580 x) = f (g1579 x)
@[simp] axiom s1580 (x : Prop) : f (g1581 x) = f (g1580 x)
@[simp] axiom s1581 (x : Prop) : f (g1582 x) = f (g1581 x)
@[simp] axiom s1582 (x : Prop) : f (g1583 x) = f (g1582 x)
@[simp] axiom s1583 (x : Prop) : f (g1584 x) = f (g1583 x)
@[simp] axiom s1584 (x : Prop) : f (g1585 x) = f (g1584 x)
@[simp] axiom s1585 (x : Prop) : f (g1586 x) = f (g1585 x)
@[simp] axiom s1586 (x : Prop) : f (g1587 x) = f (g1586 x)
@[simp] axiom s1587 (x : Prop) : f (g1588 x) = f (g1587 x)
@[simp] axiom s1588 (x : Prop) : f (g1589 x) = f (g1588 x)
@[simp] axiom s1589 (x : Prop) : f (g1590 x) = f (g1589 x)
@[simp] axiom s1590 (x : Prop) : f (g1591 x) = f (g1590 x)
@[simp] axiom s1591 (x : Prop) : f (g1592 x) = f (g1591 x)
@[simp] axiom s1592 (x : Prop) : f (g1593 x) = f (g1592 x)
@[simp] axiom s1593 (x : Prop) : f (g1594 x) = f (g1593 x)
@[simp] axiom s1594 (x : Prop) : f (g1595 x) = f (g1594 x)
@[simp] axiom s1595 (x : Prop) : f (g1596 x) = f (g1595 x)
@[simp] axiom s1596 (x : Prop) : f (g1597 x) = f (g1596 x)
@[simp] axiom s1597 (x : Prop) : f (g1598 x) = f (g1597 x)
@[simp] axiom s1598 (x : Prop) : f (g1599 x) = f (g1598 x)
@[simp] axiom s1599 (x : Prop) : f (g1600 x) = f (g1599 x)
@[simp] axiom s1600 (x : Prop) : f (g1601 x) = f (g1600 x)
@[simp] axiom s1601 (x : Prop) : f (g1602 x) = f (g1601 x)
@[simp] axiom s1602 (x : Prop) : f (g1603 x) = f (g1602 x)
@[simp] axiom s1603 (x : Prop) : f (g1604 x) = f (g1603 x)
@[simp] axiom s1604 (x : Prop) : f (g1605 x) = f (g1604 x)
@[simp] axiom s1605 (x : Prop) : f (g1606 x) = f (g1605 x)
@[simp] axiom s1606 (x : Prop) : f (g1607 x) = f (g1606 x)
@[simp] axiom s1607 (x : Prop) : f (g1608 x) = f (g1607 x)
@[simp] axiom s1608 (x : Prop) : f (g1609 x) = f (g1608 x)
@[simp] axiom s1609 (x : Prop) : f (g1610 x) = f (g1609 x)
@[simp] axiom s1610 (x : Prop) : f (g1611 x) = f (g1610 x)
@[simp] axiom s1611 (x : Prop) : f (g1612 x) = f (g1611 x)
@[simp] axiom s1612 (x : Prop) : f (g1613 x) = f (g1612 x)
@[simp] axiom s1613 (x : Prop) : f (g1614 x) = f (g1613 x)
@[simp] axiom s1614 (x : Prop) : f (g1615 x) = f (g1614 x)
@[simp] axiom s1615 (x : Prop) : f (g1616 x) = f (g1615 x)
@[simp] axiom s1616 (x : Prop) : f (g1617 x) = f (g1616 x)
@[simp] axiom s1617 (x : Prop) : f (g1618 x) = f (g1617 x)
@[simp] axiom s1618 (x : Prop) : f (g1619 x) = f (g1618 x)
@[simp] axiom s1619 (x : Prop) : f (g1620 x) = f (g1619 x)
@[simp] axiom s1620 (x : Prop) : f (g1621 x) = f (g1620 x)
@[simp] axiom s1621 (x : Prop) : f (g1622 x) = f (g1621 x)
@[simp] axiom s1622 (x : Prop) : f (g1623 x) = f (g1622 x)
@[simp] axiom s1623 (x : Prop) : f (g1624 x) = f (g1623 x)
@[simp] axiom s1624 (x : Prop) : f (g1625 x) = f (g1624 x)
@[simp] axiom s1625 (x : Prop) : f (g1626 x) = f (g1625 x)
@[simp] axiom s1626 (x : Prop) : f (g1627 x) = f (g1626 x)
@[simp] axiom s1627 (x : Prop) : f (g1628 x) = f (g1627 x)
@[simp] axiom s1628 (x : Prop) : f (g1629 x) = f (g1628 x)
@[simp] axiom s1629 (x : Prop) : f (g1630 x) = f (g1629 x)
@[simp] axiom s1630 (x : Prop) : f (g1631 x) = f (g1630 x)
@[simp] axiom s1631 (x : Prop) : f (g1632 x) = f (g1631 x)
@[simp] axiom s1632 (x : Prop) : f (g1633 x) = f (g1632 x)
@[simp] axiom s1633 (x : Prop) : f (g1634 x) = f (g1633 x)
@[simp] axiom s1634 (x : Prop) : f (g1635 x) = f (g1634 x)
@[simp] axiom s1635 (x : Prop) : f (g1636 x) = f (g1635 x)
@[simp] axiom s1636 (x : Prop) : f (g1637 x) = f (g1636 x)
@[simp] axiom s1637 (x : Prop) : f (g1638 x) = f (g1637 x)
@[simp] axiom s1638 (x : Prop) : f (g1639 x) = f (g1638 x)
@[simp] axiom s1639 (x : Prop) : f (g1640 x) = f (g1639 x)
@[simp] axiom s1640 (x : Prop) : f (g1641 x) = f (g1640 x)
@[simp] axiom s1641 (x : Prop) : f (g1642 x) = f (g1641 x)
@[simp] axiom s1642 (x : Prop) : f (g1643 x) = f (g1642 x)
@[simp] axiom s1643 (x : Prop) : f (g1644 x) = f (g1643 x)
@[simp] axiom s1644 (x : Prop) : f (g1645 x) = f (g1644 x)
@[simp] axiom s1645 (x : Prop) : f (g1646 x) = f (g1645 x)
@[simp] axiom s1646 (x : Prop) : f (g1647 x) = f (g1646 x)
@[simp] axiom s1647 (x : Prop) : f (g1648 x) = f (g1647 x)
@[simp] axiom s1648 (x : Prop) : f (g1649 x) = f (g1648 x)
@[simp] axiom s1649 (x : Prop) : f (g1650 x) = f (g1649 x)
@[simp] axiom s1650 (x : Prop) : f (g1651 x) = f (g1650 x)
@[simp] axiom s1651 (x : Prop) : f (g1652 x) = f (g1651 x)
@[simp] axiom s1652 (x : Prop) : f (g1653 x) = f (g1652 x)
@[simp] axiom s1653 (x : Prop) : f (g1654 x) = f (g1653 x)
@[simp] axiom s1654 (x : Prop) : f (g1655 x) = f (g1654 x)
@[simp] axiom s1655 (x : Prop) : f (g1656 x) = f (g1655 x)
@[simp] axiom s1656 (x : Prop) : f (g1657 x) = f (g1656 x)
@[simp] axiom s1657 (x : Prop) : f (g1658 x) = f (g1657 x)
@[simp] axiom s1658 (x : Prop) : f (g1659 x) = f (g1658 x)
@[simp] axiom s1659 (x : Prop) : f (g1660 x) = f (g1659 x)
@[simp] axiom s1660 (x : Prop) : f (g1661 x) = f (g1660 x)
@[simp] axiom s1661 (x : Prop) : f (g1662 x) = f (g1661 x)
@[simp] axiom s1662 (x : Prop) : f (g1663 x) = f (g1662 x)
@[simp] axiom s1663 (x : Prop) : f (g1664 x) = f (g1663 x)
@[simp] axiom s1664 (x : Prop) : f (g1665 x) = f (g1664 x)
@[simp] axiom s1665 (x : Prop) : f (g1666 x) = f (g1665 x)
@[simp] axiom s1666 (x : Prop) : f (g1667 x) = f (g1666 x)
@[simp] axiom s1667 (x : Prop) : f (g1668 x) = f (g1667 x)
@[simp] axiom s1668 (x : Prop) : f (g1669 x) = f (g1668 x)
@[simp] axiom s1669 (x : Prop) : f (g1670 x) = f (g1669 x)
@[simp] axiom s1670 (x : Prop) : f (g1671 x) = f (g1670 x)
@[simp] axiom s1671 (x : Prop) : f (g1672 x) = f (g1671 x)
@[simp] axiom s1672 (x : Prop) : f (g1673 x) = f (g1672 x)
@[simp] axiom s1673 (x : Prop) : f (g1674 x) = f (g1673 x)
@[simp] axiom s1674 (x : Prop) : f (g1675 x) = f (g1674 x)
@[simp] axiom s1675 (x : Prop) : f (g1676 x) = f (g1675 x)
@[simp] axiom s1676 (x : Prop) : f (g1677 x) = f (g1676 x)
@[simp] axiom s1677 (x : Prop) : f (g1678 x) = f (g1677 x)
@[simp] axiom s1678 (x : Prop) : f (g1679 x) = f (g1678 x)
@[simp] axiom s1679 (x : Prop) : f (g1680 x) = f (g1679 x)
@[simp] axiom s1680 (x : Prop) : f (g1681 x) = f (g1680 x)
@[simp] axiom s1681 (x : Prop) : f (g1682 x) = f (g1681 x)
@[simp] axiom s1682 (x : Prop) : f (g1683 x) = f (g1682 x)
@[simp] axiom s1683 (x : Prop) : f (g1684 x) = f (g1683 x)
@[simp] axiom s1684 (x : Prop) : f (g1685 x) = f (g1684 x)
@[simp] axiom s1685 (x : Prop) : f (g1686 x) = f (g1685 x)
@[simp] axiom s1686 (x : Prop) : f (g1687 x) = f (g1686 x)
@[simp] axiom s1687 (x : Prop) : f (g1688 x) = f (g1687 x)
@[simp] axiom s1688 (x : Prop) : f (g1689 x) = f (g1688 x)
@[simp] axiom s1689 (x : Prop) : f (g1690 x) = f (g1689 x)
@[simp] axiom s1690 (x : Prop) : f (g1691 x) = f (g1690 x)
@[simp] axiom s1691 (x : Prop) : f (g1692 x) = f (g1691 x)
@[simp] axiom s1692 (x : Prop) : f (g1693 x) = f (g1692 x)
@[simp] axiom s1693 (x : Prop) : f (g1694 x) = f (g1693 x)
@[simp] axiom s1694 (x : Prop) : f (g1695 x) = f (g1694 x)
@[simp] axiom s1695 (x : Prop) : f (g1696 x) = f (g1695 x)
@[simp] axiom s1696 (x : Prop) : f (g1697 x) = f (g1696 x)
@[simp] axiom s1697 (x : Prop) : f (g1698 x) = f (g1697 x)
@[simp] axiom s1698 (x : Prop) : f (g1699 x) = f (g1698 x)
@[simp] axiom s1699 (x : Prop) : f (g1700 x) = f (g1699 x)
@[simp] axiom s1700 (x : Prop) : f (g1701 x) = f (g1700 x)
@[simp] axiom s1701 (x : Prop) : f (g1702 x) = f (g1701 x)
@[simp] axiom s1702 (x : Prop) : f (g1703 x) = f (g1702 x)
@[simp] axiom s1703 (x : Prop) : f (g1704 x) = f (g1703 x)
@[simp] axiom s1704 (x : Prop) : f (g1705 x) = f (g1704 x)
@[simp] axiom s1705 (x : Prop) : f (g1706 x) = f (g1705 x)
@[simp] axiom s1706 (x : Prop) : f (g1707 x) = f (g1706 x)
@[simp] axiom s1707 (x : Prop) : f (g1708 x) = f (g1707 x)
@[simp] axiom s1708 (x : Prop) : f (g1709 x) = f (g1708 x)
@[simp] axiom s1709 (x : Prop) : f (g1710 x) = f (g1709 x)
@[simp] axiom s1710 (x : Prop) : f (g1711 x) = f (g1710 x)
@[simp] axiom s1711 (x : Prop) : f (g1712 x) = f (g1711 x)
@[simp] axiom s1712 (x : Prop) : f (g1713 x) = f (g1712 x)
@[simp] axiom s1713 (x : Prop) : f (g1714 x) = f (g1713 x)
@[simp] axiom s1714 (x : Prop) : f (g1715 x) = f (g1714 x)
@[simp] axiom s1715 (x : Prop) : f (g1716 x) = f (g1715 x)
@[simp] axiom s1716 (x : Prop) : f (g1717 x) = f (g1716 x)
@[simp] axiom s1717 (x : Prop) : f (g1718 x) = f (g1717 x)
@[simp] axiom s1718 (x : Prop) : f (g1719 x) = f (g1718 x)
@[simp] axiom s1719 (x : Prop) : f (g1720 x) = f (g1719 x)
@[simp] axiom s1720 (x : Prop) : f (g1721 x) = f (g1720 x)
@[simp] axiom s1721 (x : Prop) : f (g1722 x) = f (g1721 x)
@[simp] axiom s1722 (x : Prop) : f (g1723 x) = f (g1722 x)
@[simp] axiom s1723 (x : Prop) : f (g1724 x) = f (g1723 x)
@[simp] axiom s1724 (x : Prop) : f (g1725 x) = f (g1724 x)
@[simp] axiom s1725 (x : Prop) : f (g1726 x) = f (g1725 x)
@[simp] axiom s1726 (x : Prop) : f (g1727 x) = f (g1726 x)
@[simp] axiom s1727 (x : Prop) : f (g1728 x) = f (g1727 x)
@[simp] axiom s1728 (x : Prop) : f (g1729 x) = f (g1728 x)
@[simp] axiom s1729 (x : Prop) : f (g1730 x) = f (g1729 x)
@[simp] axiom s1730 (x : Prop) : f (g1731 x) = f (g1730 x)
@[simp] axiom s1731 (x : Prop) : f (g1732 x) = f (g1731 x)
@[simp] axiom s1732 (x : Prop) : f (g1733 x) = f (g1732 x)
@[simp] axiom s1733 (x : Prop) : f (g1734 x) = f (g1733 x)
@[simp] axiom s1734 (x : Prop) : f (g1735 x) = f (g1734 x)
@[simp] axiom s1735 (x : Prop) : f (g1736 x) = f (g1735 x)
@[simp] axiom s1736 (x : Prop) : f (g1737 x) = f (g1736 x)
@[simp] axiom s1737 (x : Prop) : f (g1738 x) = f (g1737 x)
@[simp] axiom s1738 (x : Prop) : f (g1739 x) = f (g1738 x)
@[simp] axiom s1739 (x : Prop) : f (g1740 x) = f (g1739 x)
@[simp] axiom s1740 (x : Prop) : f (g1741 x) = f (g1740 x)
@[simp] axiom s1741 (x : Prop) : f (g1742 x) = f (g1741 x)
@[simp] axiom s1742 (x : Prop) : f (g1743 x) = f (g1742 x)
@[simp] axiom s1743 (x : Prop) : f (g1744 x) = f (g1743 x)
@[simp] axiom s1744 (x : Prop) : f (g1745 x) = f (g1744 x)
@[simp] axiom s1745 (x : Prop) : f (g1746 x) = f (g1745 x)
@[simp] axiom s1746 (x : Prop) : f (g1747 x) = f (g1746 x)
@[simp] axiom s1747 (x : Prop) : f (g1748 x) = f (g1747 x)
@[simp] axiom s1748 (x : Prop) : f (g1749 x) = f (g1748 x)
@[simp] axiom s1749 (x : Prop) : f (g1750 x) = f (g1749 x)
@[simp] axiom s1750 (x : Prop) : f (g1751 x) = f (g1750 x)
@[simp] axiom s1751 (x : Prop) : f (g1752 x) = f (g1751 x)
@[simp] axiom s1752 (x : Prop) : f (g1753 x) = f (g1752 x)
@[simp] axiom s1753 (x : Prop) : f (g1754 x) = f (g1753 x)
@[simp] axiom s1754 (x : Prop) : f (g1755 x) = f (g1754 x)
@[simp] axiom s1755 (x : Prop) : f (g1756 x) = f (g1755 x)
@[simp] axiom s1756 (x : Prop) : f (g1757 x) = f (g1756 x)
@[simp] axiom s1757 (x : Prop) : f (g1758 x) = f (g1757 x)
@[simp] axiom s1758 (x : Prop) : f (g1759 x) = f (g1758 x)
@[simp] axiom s1759 (x : Prop) : f (g1760 x) = f (g1759 x)
@[simp] axiom s1760 (x : Prop) : f (g1761 x) = f (g1760 x)
@[simp] axiom s1761 (x : Prop) : f (g1762 x) = f (g1761 x)
@[simp] axiom s1762 (x : Prop) : f (g1763 x) = f (g1762 x)
@[simp] axiom s1763 (x : Prop) : f (g1764 x) = f (g1763 x)
@[simp] axiom s1764 (x : Prop) : f (g1765 x) = f (g1764 x)
@[simp] axiom s1765 (x : Prop) : f (g1766 x) = f (g1765 x)
@[simp] axiom s1766 (x : Prop) : f (g1767 x) = f (g1766 x)
@[simp] axiom s1767 (x : Prop) : f (g1768 x) = f (g1767 x)
@[simp] axiom s1768 (x : Prop) : f (g1769 x) = f (g1768 x)
@[simp] axiom s1769 (x : Prop) : f (g1770 x) = f (g1769 x)
@[simp] axiom s1770 (x : Prop) : f (g1771 x) = f (g1770 x)
@[simp] axiom s1771 (x : Prop) : f (g1772 x) = f (g1771 x)
@[simp] axiom s1772 (x : Prop) : f (g1773 x) = f (g1772 x)
@[simp] axiom s1773 (x : Prop) : f (g1774 x) = f (g1773 x)
@[simp] axiom s1774 (x : Prop) : f (g1775 x) = f (g1774 x)
@[simp] axiom s1775 (x : Prop) : f (g1776 x) = f (g1775 x)
@[simp] axiom s1776 (x : Prop) : f (g1777 x) = f (g1776 x)
@[simp] axiom s1777 (x : Prop) : f (g1778 x) = f (g1777 x)
@[simp] axiom s1778 (x : Prop) : f (g1779 x) = f (g1778 x)
@[simp] axiom s1779 (x : Prop) : f (g1780 x) = f (g1779 x)
@[simp] axiom s1780 (x : Prop) : f (g1781 x) = f (g1780 x)
@[simp] axiom s1781 (x : Prop) : f (g1782 x) = f (g1781 x)
@[simp] axiom s1782 (x : Prop) : f (g1783 x) = f (g1782 x)
@[simp] axiom s1783 (x : Prop) : f (g1784 x) = f (g1783 x)
@[simp] axiom s1784 (x : Prop) : f (g1785 x) = f (g1784 x)
@[simp] axiom s1785 (x : Prop) : f (g1786 x) = f (g1785 x)
@[simp] axiom s1786 (x : Prop) : f (g1787 x) = f (g1786 x)
@[simp] axiom s1787 (x : Prop) : f (g1788 x) = f (g1787 x)
@[simp] axiom s1788 (x : Prop) : f (g1789 x) = f (g1788 x)
@[simp] axiom s1789 (x : Prop) : f (g1790 x) = f (g1789 x)
@[simp] axiom s1790 (x : Prop) : f (g1791 x) = f (g1790 x)
@[simp] axiom s1791 (x : Prop) : f (g1792 x) = f (g1791 x)
@[simp] axiom s1792 (x : Prop) : f (g1793 x) = f (g1792 x)
@[simp] axiom s1793 (x : Prop) : f (g1794 x) = f (g1793 x)
@[simp] axiom s1794 (x : Prop) : f (g1795 x) = f (g1794 x)
@[simp] axiom s1795 (x : Prop) : f (g1796 x) = f (g1795 x)
@[simp] axiom s1796 (x : Prop) : f (g1797 x) = f (g1796 x)
@[simp] axiom s1797 (x : Prop) : f (g1798 x) = f (g1797 x)
@[simp] axiom s1798 (x : Prop) : f (g1799 x) = f (g1798 x)
@[simp] axiom s1799 (x : Prop) : f (g1800 x) = f (g1799 x)
@[simp] axiom s1800 (x : Prop) : f (g1801 x) = f (g1800 x)
@[simp] axiom s1801 (x : Prop) : f (g1802 x) = f (g1801 x)
@[simp] axiom s1802 (x : Prop) : f (g1803 x) = f (g1802 x)
@[simp] axiom s1803 (x : Prop) : f (g1804 x) = f (g1803 x)
@[simp] axiom s1804 (x : Prop) : f (g1805 x) = f (g1804 x)
@[simp] axiom s1805 (x : Prop) : f (g1806 x) = f (g1805 x)
@[simp] axiom s1806 (x : Prop) : f (g1807 x) = f (g1806 x)
@[simp] axiom s1807 (x : Prop) : f (g1808 x) = f (g1807 x)
@[simp] axiom s1808 (x : Prop) : f (g1809 x) = f (g1808 x)
@[simp] axiom s1809 (x : Prop) : f (g1810 x) = f (g1809 x)
@[simp] axiom s1810 (x : Prop) : f (g1811 x) = f (g1810 x)
@[simp] axiom s1811 (x : Prop) : f (g1812 x) = f (g1811 x)
@[simp] axiom s1812 (x : Prop) : f (g1813 x) = f (g1812 x)
@[simp] axiom s1813 (x : Prop) : f (g1814 x) = f (g1813 x)
@[simp] axiom s1814 (x : Prop) : f (g1815 x) = f (g1814 x)
@[simp] axiom s1815 (x : Prop) : f (g1816 x) = f (g1815 x)
@[simp] axiom s1816 (x : Prop) : f (g1817 x) = f (g1816 x)
@[simp] axiom s1817 (x : Prop) : f (g1818 x) = f (g1817 x)
@[simp] axiom s1818 (x : Prop) : f (g1819 x) = f (g1818 x)
@[simp] axiom s1819 (x : Prop) : f (g1820 x) = f (g1819 x)
@[simp] axiom s1820 (x : Prop) : f (g1821 x) = f (g1820 x)
@[simp] axiom s1821 (x : Prop) : f (g1822 x) = f (g1821 x)
@[simp] axiom s1822 (x : Prop) : f (g1823 x) = f (g1822 x)
@[simp] axiom s1823 (x : Prop) : f (g1824 x) = f (g1823 x)
@[simp] axiom s1824 (x : Prop) : f (g1825 x) = f (g1824 x)
@[simp] axiom s1825 (x : Prop) : f (g1826 x) = f (g1825 x)
@[simp] axiom s1826 (x : Prop) : f (g1827 x) = f (g1826 x)
@[simp] axiom s1827 (x : Prop) : f (g1828 x) = f (g1827 x)
@[simp] axiom s1828 (x : Prop) : f (g1829 x) = f (g1828 x)
@[simp] axiom s1829 (x : Prop) : f (g1830 x) = f (g1829 x)
@[simp] axiom s1830 (x : Prop) : f (g1831 x) = f (g1830 x)
@[simp] axiom s1831 (x : Prop) : f (g1832 x) = f (g1831 x)
@[simp] axiom s1832 (x : Prop) : f (g1833 x) = f (g1832 x)
@[simp] axiom s1833 (x : Prop) : f (g1834 x) = f (g1833 x)
@[simp] axiom s1834 (x : Prop) : f (g1835 x) = f (g1834 x)
@[simp] axiom s1835 (x : Prop) : f (g1836 x) = f (g1835 x)
@[simp] axiom s1836 (x : Prop) : f (g1837 x) = f (g1836 x)
@[simp] axiom s1837 (x : Prop) : f (g1838 x) = f (g1837 x)
@[simp] axiom s1838 (x : Prop) : f (g1839 x) = f (g1838 x)
@[simp] axiom s1839 (x : Prop) : f (g1840 x) = f (g1839 x)
@[simp] axiom s1840 (x : Prop) : f (g1841 x) = f (g1840 x)
@[simp] axiom s1841 (x : Prop) : f (g1842 x) = f (g1841 x)
@[simp] axiom s1842 (x : Prop) : f (g1843 x) = f (g1842 x)
@[simp] axiom s1843 (x : Prop) : f (g1844 x) = f (g1843 x)
@[simp] axiom s1844 (x : Prop) : f (g1845 x) = f (g1844 x)
@[simp] axiom s1845 (x : Prop) : f (g1846 x) = f (g1845 x)
@[simp] axiom s1846 (x : Prop) : f (g1847 x) = f (g1846 x)
@[simp] axiom s1847 (x : Prop) : f (g1848 x) = f (g1847 x)
@[simp] axiom s1848 (x : Prop) : f (g1849 x) = f (g1848 x)
@[simp] axiom s1849 (x : Prop) : f (g1850 x) = f (g1849 x)
@[simp] axiom s1850 (x : Prop) : f (g1851 x) = f (g1850 x)
@[simp] axiom s1851 (x : Prop) : f (g1852 x) = f (g1851 x)
@[simp] axiom s1852 (x : Prop) : f (g1853 x) = f (g1852 x)
@[simp] axiom s1853 (x : Prop) : f (g1854 x) = f (g1853 x)
@[simp] axiom s1854 (x : Prop) : f (g1855 x) = f (g1854 x)
@[simp] axiom s1855 (x : Prop) : f (g1856 x) = f (g1855 x)
@[simp] axiom s1856 (x : Prop) : f (g1857 x) = f (g1856 x)
@[simp] axiom s1857 (x : Prop) : f (g1858 x) = f (g1857 x)
@[simp] axiom s1858 (x : Prop) : f (g1859 x) = f (g1858 x)
@[simp] axiom s1859 (x : Prop) : f (g1860 x) = f (g1859 x)
@[simp] axiom s1860 (x : Prop) : f (g1861 x) = f (g1860 x)
@[simp] axiom s1861 (x : Prop) : f (g1862 x) = f (g1861 x)
@[simp] axiom s1862 (x : Prop) : f (g1863 x) = f (g1862 x)
@[simp] axiom s1863 (x : Prop) : f (g1864 x) = f (g1863 x)
@[simp] axiom s1864 (x : Prop) : f (g1865 x) = f (g1864 x)
@[simp] axiom s1865 (x : Prop) : f (g1866 x) = f (g1865 x)
@[simp] axiom s1866 (x : Prop) : f (g1867 x) = f (g1866 x)
@[simp] axiom s1867 (x : Prop) : f (g1868 x) = f (g1867 x)
@[simp] axiom s1868 (x : Prop) : f (g1869 x) = f (g1868 x)
@[simp] axiom s1869 (x : Prop) : f (g1870 x) = f (g1869 x)
@[simp] axiom s1870 (x : Prop) : f (g1871 x) = f (g1870 x)
@[simp] axiom s1871 (x : Prop) : f (g1872 x) = f (g1871 x)
@[simp] axiom s1872 (x : Prop) : f (g1873 x) = f (g1872 x)
@[simp] axiom s1873 (x : Prop) : f (g1874 x) = f (g1873 x)
@[simp] axiom s1874 (x : Prop) : f (g1875 x) = f (g1874 x)
@[simp] axiom s1875 (x : Prop) : f (g1876 x) = f (g1875 x)
@[simp] axiom s1876 (x : Prop) : f (g1877 x) = f (g1876 x)
@[simp] axiom s1877 (x : Prop) : f (g1878 x) = f (g1877 x)
@[simp] axiom s1878 (x : Prop) : f (g1879 x) = f (g1878 x)
@[simp] axiom s1879 (x : Prop) : f (g1880 x) = f (g1879 x)
@[simp] axiom s1880 (x : Prop) : f (g1881 x) = f (g1880 x)
@[simp] axiom s1881 (x : Prop) : f (g1882 x) = f (g1881 x)
@[simp] axiom s1882 (x : Prop) : f (g1883 x) = f (g1882 x)
@[simp] axiom s1883 (x : Prop) : f (g1884 x) = f (g1883 x)
@[simp] axiom s1884 (x : Prop) : f (g1885 x) = f (g1884 x)
@[simp] axiom s1885 (x : Prop) : f (g1886 x) = f (g1885 x)
@[simp] axiom s1886 (x : Prop) : f (g1887 x) = f (g1886 x)
@[simp] axiom s1887 (x : Prop) : f (g1888 x) = f (g1887 x)
@[simp] axiom s1888 (x : Prop) : f (g1889 x) = f (g1888 x)
@[simp] axiom s1889 (x : Prop) : f (g1890 x) = f (g1889 x)
@[simp] axiom s1890 (x : Prop) : f (g1891 x) = f (g1890 x)
@[simp] axiom s1891 (x : Prop) : f (g1892 x) = f (g1891 x)
@[simp] axiom s1892 (x : Prop) : f (g1893 x) = f (g1892 x)
@[simp] axiom s1893 (x : Prop) : f (g1894 x) = f (g1893 x)
@[simp] axiom s1894 (x : Prop) : f (g1895 x) = f (g1894 x)
@[simp] axiom s1895 (x : Prop) : f (g1896 x) = f (g1895 x)
@[simp] axiom s1896 (x : Prop) : f (g1897 x) = f (g1896 x)
@[simp] axiom s1897 (x : Prop) : f (g1898 x) = f (g1897 x)
@[simp] axiom s1898 (x : Prop) : f (g1899 x) = f (g1898 x)
@[simp] axiom s1899 (x : Prop) : f (g1900 x) = f (g1899 x)
@[simp] axiom s1900 (x : Prop) : f (g1901 x) = f (g1900 x)
@[simp] axiom s1901 (x : Prop) : f (g1902 x) = f (g1901 x)
@[simp] axiom s1902 (x : Prop) : f (g1903 x) = f (g1902 x)
@[simp] axiom s1903 (x : Prop) : f (g1904 x) = f (g1903 x)
@[simp] axiom s1904 (x : Prop) : f (g1905 x) = f (g1904 x)
@[simp] axiom s1905 (x : Prop) : f (g1906 x) = f (g1905 x)
@[simp] axiom s1906 (x : Prop) : f (g1907 x) = f (g1906 x)
@[simp] axiom s1907 (x : Prop) : f (g1908 x) = f (g1907 x)
@[simp] axiom s1908 (x : Prop) : f (g1909 x) = f (g1908 x)
@[simp] axiom s1909 (x : Prop) : f (g1910 x) = f (g1909 x)
@[simp] axiom s1910 (x : Prop) : f (g1911 x) = f (g1910 x)
@[simp] axiom s1911 (x : Prop) : f (g1912 x) = f (g1911 x)
@[simp] axiom s1912 (x : Prop) : f (g1913 x) = f (g1912 x)
@[simp] axiom s1913 (x : Prop) : f (g1914 x) = f (g1913 x)
@[simp] axiom s1914 (x : Prop) : f (g1915 x) = f (g1914 x)
@[simp] axiom s1915 (x : Prop) : f (g1916 x) = f (g1915 x)
@[simp] axiom s1916 (x : Prop) : f (g1917 x) = f (g1916 x)
@[simp] axiom s1917 (x : Prop) : f (g1918 x) = f (g1917 x)
@[simp] axiom s1918 (x : Prop) : f (g1919 x) = f (g1918 x)
@[simp] axiom s1919 (x : Prop) : f (g1920 x) = f (g1919 x)
@[simp] axiom s1920 (x : Prop) : f (g1921 x) = f (g1920 x)
@[simp] axiom s1921 (x : Prop) : f (g1922 x) = f (g1921 x)
@[simp] axiom s1922 (x : Prop) : f (g1923 x) = f (g1922 x)
@[simp] axiom s1923 (x : Prop) : f (g1924 x) = f (g1923 x)
@[simp] axiom s1924 (x : Prop) : f (g1925 x) = f (g1924 x)
@[simp] axiom s1925 (x : Prop) : f (g1926 x) = f (g1925 x)
@[simp] axiom s1926 (x : Prop) : f (g1927 x) = f (g1926 x)
@[simp] axiom s1927 (x : Prop) : f (g1928 x) = f (g1927 x)
@[simp] axiom s1928 (x : Prop) : f (g1929 x) = f (g1928 x)
@[simp] axiom s1929 (x : Prop) : f (g1930 x) = f (g1929 x)
@[simp] axiom s1930 (x : Prop) : f (g1931 x) = f (g1930 x)
@[simp] axiom s1931 (x : Prop) : f (g1932 x) = f (g1931 x)
@[simp] axiom s1932 (x : Prop) : f (g1933 x) = f (g1932 x)
@[simp] axiom s1933 (x : Prop) : f (g1934 x) = f (g1933 x)
@[simp] axiom s1934 (x : Prop) : f (g1935 x) = f (g1934 x)
@[simp] axiom s1935 (x : Prop) : f (g1936 x) = f (g1935 x)
@[simp] axiom s1936 (x : Prop) : f (g1937 x) = f (g1936 x)
@[simp] axiom s1937 (x : Prop) : f (g1938 x) = f (g1937 x)
@[simp] axiom s1938 (x : Prop) : f (g1939 x) = f (g1938 x)
@[simp] axiom s1939 (x : Prop) : f (g1940 x) = f (g1939 x)
@[simp] axiom s1940 (x : Prop) : f (g1941 x) = f (g1940 x)
@[simp] axiom s1941 (x : Prop) : f (g1942 x) = f (g1941 x)
@[simp] axiom s1942 (x : Prop) : f (g1943 x) = f (g1942 x)
@[simp] axiom s1943 (x : Prop) : f (g1944 x) = f (g1943 x)
@[simp] axiom s1944 (x : Prop) : f (g1945 x) = f (g1944 x)
@[simp] axiom s1945 (x : Prop) : f (g1946 x) = f (g1945 x)
@[simp] axiom s1946 (x : Prop) : f (g1947 x) = f (g1946 x)
@[simp] axiom s1947 (x : Prop) : f (g1948 x) = f (g1947 x)
@[simp] axiom s1948 (x : Prop) : f (g1949 x) = f (g1948 x)
@[simp] axiom s1949 (x : Prop) : f (g1950 x) = f (g1949 x)
@[simp] axiom s1950 (x : Prop) : f (g1951 x) = f (g1950 x)
@[simp] axiom s1951 (x : Prop) : f (g1952 x) = f (g1951 x)
@[simp] axiom s1952 (x : Prop) : f (g1953 x) = f (g1952 x)
@[simp] axiom s1953 (x : Prop) : f (g1954 x) = f (g1953 x)
@[simp] axiom s1954 (x : Prop) : f (g1955 x) = f (g1954 x)
@[simp] axiom s1955 (x : Prop) : f (g1956 x) = f (g1955 x)
@[simp] axiom s1956 (x : Prop) : f (g1957 x) = f (g1956 x)
@[simp] axiom s1957 (x : Prop) : f (g1958 x) = f (g1957 x)
@[simp] axiom s1958 (x : Prop) : f (g1959 x) = f (g1958 x)
@[simp] axiom s1959 (x : Prop) : f (g1960 x) = f (g1959 x)
@[simp] axiom s1960 (x : Prop) : f (g1961 x) = f (g1960 x)
@[simp] axiom s1961 (x : Prop) : f (g1962 x) = f (g1961 x)
@[simp] axiom s1962 (x : Prop) : f (g1963 x) = f (g1962 x)
@[simp] axiom s1963 (x : Prop) : f (g1964 x) = f (g1963 x)
@[simp] axiom s1964 (x : Prop) : f (g1965 x) = f (g1964 x)
@[simp] axiom s1965 (x : Prop) : f (g1966 x) = f (g1965 x)
@[simp] axiom s1966 (x : Prop) : f (g1967 x) = f (g1966 x)
@[simp] axiom s1967 (x : Prop) : f (g1968 x) = f (g1967 x)
@[simp] axiom s1968 (x : Prop) : f (g1969 x) = f (g1968 x)
@[simp] axiom s1969 (x : Prop) : f (g1970 x) = f (g1969 x)
@[simp] axiom s1970 (x : Prop) : f (g1971 x) = f (g1970 x)
@[simp] axiom s1971 (x : Prop) : f (g1972 x) = f (g1971 x)
@[simp] axiom s1972 (x : Prop) : f (g1973 x) = f (g1972 x)
@[simp] axiom s1973 (x : Prop) : f (g1974 x) = f (g1973 x)
@[simp] axiom s1974 (x : Prop) : f (g1975 x) = f (g1974 x)
@[simp] axiom s1975 (x : Prop) : f (g1976 x) = f (g1975 x)
@[simp] axiom s1976 (x : Prop) : f (g1977 x) = f (g1976 x)
@[simp] axiom s1977 (x : Prop) : f (g1978 x) = f (g1977 x)
@[simp] axiom s1978 (x : Prop) : f (g1979 x) = f (g1978 x)
@[simp] axiom s1979 (x : Prop) : f (g1980 x) = f (g1979 x)
@[simp] axiom s1980 (x : Prop) : f (g1981 x) = f (g1980 x)
@[simp] axiom s1981 (x : Prop) : f (g1982 x) = f (g1981 x)
@[simp] axiom s1982 (x : Prop) : f (g1983 x) = f (g1982 x)
@[simp] axiom s1983 (x : Prop) : f (g1984 x) = f (g1983 x)
@[simp] axiom s1984 (x : Prop) : f (g1985 x) = f (g1984 x)
@[simp] axiom s1985 (x : Prop) : f (g1986 x) = f (g1985 x)
@[simp] axiom s1986 (x : Prop) : f (g1987 x) = f (g1986 x)
@[simp] axiom s1987 (x : Prop) : f (g1988 x) = f (g1987 x)
@[simp] axiom s1988 (x : Prop) : f (g1989 x) = f (g1988 x)
@[simp] axiom s1989 (x : Prop) : f (g1990 x) = f (g1989 x)
@[simp] axiom s1990 (x : Prop) : f (g1991 x) = f (g1990 x)
@[simp] axiom s1991 (x : Prop) : f (g1992 x) = f (g1991 x)
@[simp] axiom s1992 (x : Prop) : f (g1993 x) = f (g1992 x)
@[simp] axiom s1993 (x : Prop) : f (g1994 x) = f (g1993 x)
@[simp] axiom s1994 (x : Prop) : f (g1995 x) = f (g1994 x)
@[simp] axiom s1995 (x : Prop) : f (g1996 x) = f (g1995 x)
@[simp] axiom s1996 (x : Prop) : f (g1997 x) = f (g1996 x)
@[simp] axiom s1997 (x : Prop) : f (g1998 x) = f (g1997 x)
@[simp] axiom s1998 (x : Prop) : f (g1999 x) = f (g1998 x)
@[simp] axiom s1999 (x : Prop) : f (g2000 x) = f (g1999 x)
@[simp] axiom s2000 (x : Prop) : f (g2001 x) = f (g2000 x)
@[simp] axiom s2001 (x : Prop) : f (g2002 x) = f (g2001 x)
@[simp] axiom s2002 (x : Prop) : f (g2003 x) = f (g2002 x)
@[simp] axiom s2003 (x : Prop) : f (g2004 x) = f (g2003 x)
@[simp] axiom s2004 (x : Prop) : f (g2005 x) = f (g2004 x)
@[simp] axiom s2005 (x : Prop) : f (g2006 x) = f (g2005 x)
@[simp] axiom s2006 (x : Prop) : f (g2007 x) = f (g2006 x)
@[simp] axiom s2007 (x : Prop) : f (g2008 x) = f (g2007 x)
@[simp] axiom s2008 (x : Prop) : f (g2009 x) = f (g2008 x)
@[simp] axiom s2009 (x : Prop) : f (g2010 x) = f (g2009 x)
@[simp] axiom s2010 (x : Prop) : f (g2011 x) = f (g2010 x)
@[simp] axiom s2011 (x : Prop) : f (g2012 x) = f (g2011 x)
@[simp] axiom s2012 (x : Prop) : f (g2013 x) = f (g2012 x)
@[simp] axiom s2013 (x : Prop) : f (g2014 x) = f (g2013 x)
@[simp] axiom s2014 (x : Prop) : f (g2015 x) = f (g2014 x)
@[simp] axiom s2015 (x : Prop) : f (g2016 x) = f (g2015 x)
@[simp] axiom s2016 (x : Prop) : f (g2017 x) = f (g2016 x)
@[simp] axiom s2017 (x : Prop) : f (g2018 x) = f (g2017 x)
@[simp] axiom s2018 (x : Prop) : f (g2019 x) = f (g2018 x)
@[simp] axiom s2019 (x : Prop) : f (g2020 x) = f (g2019 x)
@[simp] axiom s2020 (x : Prop) : f (g2021 x) = f (g2020 x)
@[simp] axiom s2021 (x : Prop) : f (g2022 x) = f (g2021 x)
@[simp] axiom s2022 (x : Prop) : f (g2023 x) = f (g2022 x)
@[simp] axiom s2023 (x : Prop) : f (g2024 x) = f (g2023 x)
@[simp] axiom s2024 (x : Prop) : f (g2025 x) = f (g2024 x)
@[simp] axiom s2025 (x : Prop) : f (g2026 x) = f (g2025 x)
@[simp] axiom s2026 (x : Prop) : f (g2027 x) = f (g2026 x)
@[simp] axiom s2027 (x : Prop) : f (g2028 x) = f (g2027 x)
@[simp] axiom s2028 (x : Prop) : f (g2029 x) = f (g2028 x)
@[simp] axiom s2029 (x : Prop) : f (g2030 x) = f (g2029 x)
@[simp] axiom s2030 (x : Prop) : f (g2031 x) = f (g2030 x)
@[simp] axiom s2031 (x : Prop) : f (g2032 x) = f (g2031 x)
@[simp] axiom s2032 (x : Prop) : f (g2033 x) = f (g2032 x)
@[simp] axiom s2033 (x : Prop) : f (g2034 x) = f (g2033 x)
@[simp] axiom s2034 (x : Prop) : f (g2035 x) = f (g2034 x)
@[simp] axiom s2035 (x : Prop) : f (g2036 x) = f (g2035 x)
@[simp] axiom s2036 (x : Prop) : f (g2037 x) = f (g2036 x)
@[simp] axiom s2037 (x : Prop) : f (g2038 x) = f (g2037 x)
@[simp] axiom s2038 (x : Prop) : f (g2039 x) = f (g2038 x)
@[simp] axiom s2039 (x : Prop) : f (g2040 x) = f (g2039 x)
@[simp] axiom s2040 (x : Prop) : f (g2041 x) = f (g2040 x)
@[simp] axiom s2041 (x : Prop) : f (g2042 x) = f (g2041 x)
@[simp] axiom s2042 (x : Prop) : f (g2043 x) = f (g2042 x)
@[simp] axiom s2043 (x : Prop) : f (g2044 x) = f (g2043 x)
@[simp] axiom s2044 (x : Prop) : f (g2045 x) = f (g2044 x)
@[simp] axiom s2045 (x : Prop) : f (g2046 x) = f (g2045 x)
@[simp] axiom s2046 (x : Prop) : f (g2047 x) = f (g2046 x)
@[simp] axiom s2047 (x : Prop) : f (g2048 x) = f (g2047 x)
@[simp] axiom s2048 (x : Prop) : f (g2049 x) = f (g2048 x)
@[simp] axiom s2049 (x : Prop) : f (g2050 x) = f (g2049 x)
@[simp] axiom s2050 (x : Prop) : f (g2051 x) = f (g2050 x)
@[simp] axiom s2051 (x : Prop) : f (g2052 x) = f (g2051 x)
@[simp] axiom s2052 (x : Prop) : f (g2053 x) = f (g2052 x)
@[simp] axiom s2053 (x : Prop) : f (g2054 x) = f (g2053 x)
@[simp] axiom s2054 (x : Prop) : f (g2055 x) = f (g2054 x)
@[simp] axiom s2055 (x : Prop) : f (g2056 x) = f (g2055 x)
@[simp] axiom s2056 (x : Prop) : f (g2057 x) = f (g2056 x)
@[simp] axiom s2057 (x : Prop) : f (g2058 x) = f (g2057 x)
@[simp] axiom s2058 (x : Prop) : f (g2059 x) = f (g2058 x)
@[simp] axiom s2059 (x : Prop) : f (g2060 x) = f (g2059 x)
@[simp] axiom s2060 (x : Prop) : f (g2061 x) = f (g2060 x)
@[simp] axiom s2061 (x : Prop) : f (g2062 x) = f (g2061 x)
@[simp] axiom s2062 (x : Prop) : f (g2063 x) = f (g2062 x)
@[simp] axiom s2063 (x : Prop) : f (g2064 x) = f (g2063 x)
@[simp] axiom s2064 (x : Prop) : f (g2065 x) = f (g2064 x)
@[simp] axiom s2065 (x : Prop) : f (g2066 x) = f (g2065 x)
@[simp] axiom s2066 (x : Prop) : f (g2067 x) = f (g2066 x)
@[simp] axiom s2067 (x : Prop) : f (g2068 x) = f (g2067 x)
@[simp] axiom s2068 (x : Prop) : f (g2069 x) = f (g2068 x)
@[simp] axiom s2069 (x : Prop) : f (g2070 x) = f (g2069 x)
@[simp] axiom s2070 (x : Prop) : f (g2071 x) = f (g2070 x)
@[simp] axiom s2071 (x : Prop) : f (g2072 x) = f (g2071 x)
@[simp] axiom s2072 (x : Prop) : f (g2073 x) = f (g2072 x)
@[simp] axiom s2073 (x : Prop) : f (g2074 x) = f (g2073 x)
@[simp] axiom s2074 (x : Prop) : f (g2075 x) = f (g2074 x)
@[simp] axiom s2075 (x : Prop) : f (g2076 x) = f (g2075 x)
@[simp] axiom s2076 (x : Prop) : f (g2077 x) = f (g2076 x)
@[simp] axiom s2077 (x : Prop) : f (g2078 x) = f (g2077 x)
@[simp] axiom s2078 (x : Prop) : f (g2079 x) = f (g2078 x)
@[simp] axiom s2079 (x : Prop) : f (g2080 x) = f (g2079 x)
@[simp] axiom s2080 (x : Prop) : f (g2081 x) = f (g2080 x)
@[simp] axiom s2081 (x : Prop) : f (g2082 x) = f (g2081 x)
@[simp] axiom s2082 (x : Prop) : f (g2083 x) = f (g2082 x)
@[simp] axiom s2083 (x : Prop) : f (g2084 x) = f (g2083 x)
@[simp] axiom s2084 (x : Prop) : f (g2085 x) = f (g2084 x)
@[simp] axiom s2085 (x : Prop) : f (g2086 x) = f (g2085 x)
@[simp] axiom s2086 (x : Prop) : f (g2087 x) = f (g2086 x)
@[simp] axiom s2087 (x : Prop) : f (g2088 x) = f (g2087 x)
@[simp] axiom s2088 (x : Prop) : f (g2089 x) = f (g2088 x)
@[simp] axiom s2089 (x : Prop) : f (g2090 x) = f (g2089 x)
@[simp] axiom s2090 (x : Prop) : f (g2091 x) = f (g2090 x)
@[simp] axiom s2091 (x : Prop) : f (g2092 x) = f (g2091 x)
@[simp] axiom s2092 (x : Prop) : f (g2093 x) = f (g2092 x)
@[simp] axiom s2093 (x : Prop) : f (g2094 x) = f (g2093 x)
@[simp] axiom s2094 (x : Prop) : f (g2095 x) = f (g2094 x)
@[simp] axiom s2095 (x : Prop) : f (g2096 x) = f (g2095 x)
@[simp] axiom s2096 (x : Prop) : f (g2097 x) = f (g2096 x)
@[simp] axiom s2097 (x : Prop) : f (g2098 x) = f (g2097 x)
@[simp] axiom s2098 (x : Prop) : f (g2099 x) = f (g2098 x)
@[simp] axiom s2099 (x : Prop) : f (g2100 x) = f (g2099 x)
@[simp] axiom s2100 (x : Prop) : f (g2101 x) = f (g2100 x)
@[simp] axiom s2101 (x : Prop) : f (g2102 x) = f (g2101 x)
@[simp] axiom s2102 (x : Prop) : f (g2103 x) = f (g2102 x)
@[simp] axiom s2103 (x : Prop) : f (g2104 x) = f (g2103 x)
@[simp] axiom s2104 (x : Prop) : f (g2105 x) = f (g2104 x)
@[simp] axiom s2105 (x : Prop) : f (g2106 x) = f (g2105 x)
@[simp] axiom s2106 (x : Prop) : f (g2107 x) = f (g2106 x)
@[simp] axiom s2107 (x : Prop) : f (g2108 x) = f (g2107 x)
@[simp] axiom s2108 (x : Prop) : f (g2109 x) = f (g2108 x)
@[simp] axiom s2109 (x : Prop) : f (g2110 x) = f (g2109 x)
@[simp] axiom s2110 (x : Prop) : f (g2111 x) = f (g2110 x)
@[simp] axiom s2111 (x : Prop) : f (g2112 x) = f (g2111 x)
@[simp] axiom s2112 (x : Prop) : f (g2113 x) = f (g2112 x)
@[simp] axiom s2113 (x : Prop) : f (g2114 x) = f (g2113 x)
@[simp] axiom s2114 (x : Prop) : f (g2115 x) = f (g2114 x)
@[simp] axiom s2115 (x : Prop) : f (g2116 x) = f (g2115 x)
@[simp] axiom s2116 (x : Prop) : f (g2117 x) = f (g2116 x)
@[simp] axiom s2117 (x : Prop) : f (g2118 x) = f (g2117 x)
@[simp] axiom s2118 (x : Prop) : f (g2119 x) = f (g2118 x)
@[simp] axiom s2119 (x : Prop) : f (g2120 x) = f (g2119 x)
@[simp] axiom s2120 (x : Prop) : f (g2121 x) = f (g2120 x)
@[simp] axiom s2121 (x : Prop) : f (g2122 x) = f (g2121 x)
@[simp] axiom s2122 (x : Prop) : f (g2123 x) = f (g2122 x)
@[simp] axiom s2123 (x : Prop) : f (g2124 x) = f (g2123 x)
@[simp] axiom s2124 (x : Prop) : f (g2125 x) = f (g2124 x)
@[simp] axiom s2125 (x : Prop) : f (g2126 x) = f (g2125 x)
@[simp] axiom s2126 (x : Prop) : f (g2127 x) = f (g2126 x)
@[simp] axiom s2127 (x : Prop) : f (g2128 x) = f (g2127 x)
@[simp] axiom s2128 (x : Prop) : f (g2129 x) = f (g2128 x)
@[simp] axiom s2129 (x : Prop) : f (g2130 x) = f (g2129 x)
@[simp] axiom s2130 (x : Prop) : f (g2131 x) = f (g2130 x)
@[simp] axiom s2131 (x : Prop) : f (g2132 x) = f (g2131 x)
@[simp] axiom s2132 (x : Prop) : f (g2133 x) = f (g2132 x)
@[simp] axiom s2133 (x : Prop) : f (g2134 x) = f (g2133 x)
@[simp] axiom s2134 (x : Prop) : f (g2135 x) = f (g2134 x)
@[simp] axiom s2135 (x : Prop) : f (g2136 x) = f (g2135 x)
@[simp] axiom s2136 (x : Prop) : f (g2137 x) = f (g2136 x)
@[simp] axiom s2137 (x : Prop) : f (g2138 x) = f (g2137 x)
@[simp] axiom s2138 (x : Prop) : f (g2139 x) = f (g2138 x)
@[simp] axiom s2139 (x : Prop) : f (g2140 x) = f (g2139 x)
@[simp] axiom s2140 (x : Prop) : f (g2141 x) = f (g2140 x)
@[simp] axiom s2141 (x : Prop) : f (g2142 x) = f (g2141 x)
@[simp] axiom s2142 (x : Prop) : f (g2143 x) = f (g2142 x)
@[simp] axiom s2143 (x : Prop) : f (g2144 x) = f (g2143 x)
@[simp] axiom s2144 (x : Prop) : f (g2145 x) = f (g2144 x)
@[simp] axiom s2145 (x : Prop) : f (g2146 x) = f (g2145 x)
@[simp] axiom s2146 (x : Prop) : f (g2147 x) = f (g2146 x)
@[simp] axiom s2147 (x : Prop) : f (g2148 x) = f (g2147 x)
@[simp] axiom s2148 (x : Prop) : f (g2149 x) = f (g2148 x)
@[simp] axiom s2149 (x : Prop) : f (g2150 x) = f (g2149 x)
@[simp] axiom s2150 (x : Prop) : f (g2151 x) = f (g2150 x)
@[simp] axiom s2151 (x : Prop) : f (g2152 x) = f (g2151 x)
@[simp] axiom s2152 (x : Prop) : f (g2153 x) = f (g2152 x)
@[simp] axiom s2153 (x : Prop) : f (g2154 x) = f (g2153 x)
@[simp] axiom s2154 (x : Prop) : f (g2155 x) = f (g2154 x)
@[simp] axiom s2155 (x : Prop) : f (g2156 x) = f (g2155 x)
@[simp] axiom s2156 (x : Prop) : f (g2157 x) = f (g2156 x)
@[simp] axiom s2157 (x : Prop) : f (g2158 x) = f (g2157 x)
@[simp] axiom s2158 (x : Prop) : f (g2159 x) = f (g2158 x)
@[simp] axiom s2159 (x : Prop) : f (g2160 x) = f (g2159 x)
@[simp] axiom s2160 (x : Prop) : f (g2161 x) = f (g2160 x)
@[simp] axiom s2161 (x : Prop) : f (g2162 x) = f (g2161 x)
@[simp] axiom s2162 (x : Prop) : f (g2163 x) = f (g2162 x)
@[simp] axiom s2163 (x : Prop) : f (g2164 x) = f (g2163 x)
@[simp] axiom s2164 (x : Prop) : f (g2165 x) = f (g2164 x)
@[simp] axiom s2165 (x : Prop) : f (g2166 x) = f (g2165 x)
@[simp] axiom s2166 (x : Prop) : f (g2167 x) = f (g2166 x)
@[simp] axiom s2167 (x : Prop) : f (g2168 x) = f (g2167 x)
@[simp] axiom s2168 (x : Prop) : f (g2169 x) = f (g2168 x)
@[simp] axiom s2169 (x : Prop) : f (g2170 x) = f (g2169 x)
@[simp] axiom s2170 (x : Prop) : f (g2171 x) = f (g2170 x)
@[simp] axiom s2171 (x : Prop) : f (g2172 x) = f (g2171 x)
@[simp] axiom s2172 (x : Prop) : f (g2173 x) = f (g2172 x)
@[simp] axiom s2173 (x : Prop) : f (g2174 x) = f (g2173 x)
@[simp] axiom s2174 (x : Prop) : f (g2175 x) = f (g2174 x)
@[simp] axiom s2175 (x : Prop) : f (g2176 x) = f (g2175 x)
@[simp] axiom s2176 (x : Prop) : f (g2177 x) = f (g2176 x)
@[simp] axiom s2177 (x : Prop) : f (g2178 x) = f (g2177 x)
@[simp] axiom s2178 (x : Prop) : f (g2179 x) = f (g2178 x)
@[simp] axiom s2179 (x : Prop) : f (g2180 x) = f (g2179 x)
@[simp] axiom s2180 (x : Prop) : f (g2181 x) = f (g2180 x)
@[simp] axiom s2181 (x : Prop) : f (g2182 x) = f (g2181 x)
@[simp] axiom s2182 (x : Prop) : f (g2183 x) = f (g2182 x)
@[simp] axiom s2183 (x : Prop) : f (g2184 x) = f (g2183 x)
@[simp] axiom s2184 (x : Prop) : f (g2185 x) = f (g2184 x)
@[simp] axiom s2185 (x : Prop) : f (g2186 x) = f (g2185 x)
@[simp] axiom s2186 (x : Prop) : f (g2187 x) = f (g2186 x)
@[simp] axiom s2187 (x : Prop) : f (g2188 x) = f (g2187 x)
@[simp] axiom s2188 (x : Prop) : f (g2189 x) = f (g2188 x)
@[simp] axiom s2189 (x : Prop) : f (g2190 x) = f (g2189 x)
@[simp] axiom s2190 (x : Prop) : f (g2191 x) = f (g2190 x)
@[simp] axiom s2191 (x : Prop) : f (g2192 x) = f (g2191 x)
@[simp] axiom s2192 (x : Prop) : f (g2193 x) = f (g2192 x)
@[simp] axiom s2193 (x : Prop) : f (g2194 x) = f (g2193 x)
@[simp] axiom s2194 (x : Prop) : f (g2195 x) = f (g2194 x)
@[simp] axiom s2195 (x : Prop) : f (g2196 x) = f (g2195 x)
@[simp] axiom s2196 (x : Prop) : f (g2197 x) = f (g2196 x)
@[simp] axiom s2197 (x : Prop) : f (g2198 x) = f (g2197 x)
@[simp] axiom s2198 (x : Prop) : f (g2199 x) = f (g2198 x)
@[simp] axiom s2199 (x : Prop) : f (g2200 x) = f (g2199 x)
@[simp] axiom s2200 (x : Prop) : f (g2201 x) = f (g2200 x)
@[simp] axiom s2201 (x : Prop) : f (g2202 x) = f (g2201 x)
@[simp] axiom s2202 (x : Prop) : f (g2203 x) = f (g2202 x)
@[simp] axiom s2203 (x : Prop) : f (g2204 x) = f (g2203 x)
@[simp] axiom s2204 (x : Prop) : f (g2205 x) = f (g2204 x)
@[simp] axiom s2205 (x : Prop) : f (g2206 x) = f (g2205 x)
@[simp] axiom s2206 (x : Prop) : f (g2207 x) = f (g2206 x)
@[simp] axiom s2207 (x : Prop) : f (g2208 x) = f (g2207 x)
@[simp] axiom s2208 (x : Prop) : f (g2209 x) = f (g2208 x)
@[simp] axiom s2209 (x : Prop) : f (g2210 x) = f (g2209 x)
@[simp] axiom s2210 (x : Prop) : f (g2211 x) = f (g2210 x)
@[simp] axiom s2211 (x : Prop) : f (g2212 x) = f (g2211 x)
@[simp] axiom s2212 (x : Prop) : f (g2213 x) = f (g2212 x)
@[simp] axiom s2213 (x : Prop) : f (g2214 x) = f (g2213 x)
@[simp] axiom s2214 (x : Prop) : f (g2215 x) = f (g2214 x)
@[simp] axiom s2215 (x : Prop) : f (g2216 x) = f (g2215 x)
@[simp] axiom s2216 (x : Prop) : f (g2217 x) = f (g2216 x)
@[simp] axiom s2217 (x : Prop) : f (g2218 x) = f (g2217 x)
@[simp] axiom s2218 (x : Prop) : f (g2219 x) = f (g2218 x)
@[simp] axiom s2219 (x : Prop) : f (g2220 x) = f (g2219 x)
@[simp] axiom s2220 (x : Prop) : f (g2221 x) = f (g2220 x)
@[simp] axiom s2221 (x : Prop) : f (g2222 x) = f (g2221 x)
@[simp] axiom s2222 (x : Prop) : f (g2223 x) = f (g2222 x)
@[simp] axiom s2223 (x : Prop) : f (g2224 x) = f (g2223 x)
@[simp] axiom s2224 (x : Prop) : f (g2225 x) = f (g2224 x)
@[simp] axiom s2225 (x : Prop) : f (g2226 x) = f (g2225 x)
@[simp] axiom s2226 (x : Prop) : f (g2227 x) = f (g2226 x)
@[simp] axiom s2227 (x : Prop) : f (g2228 x) = f (g2227 x)
@[simp] axiom s2228 (x : Prop) : f (g2229 x) = f (g2228 x)
@[simp] axiom s2229 (x : Prop) : f (g2230 x) = f (g2229 x)
@[simp] axiom s2230 (x : Prop) : f (g2231 x) = f (g2230 x)
@[simp] axiom s2231 (x : Prop) : f (g2232 x) = f (g2231 x)
@[simp] axiom s2232 (x : Prop) : f (g2233 x) = f (g2232 x)
@[simp] axiom s2233 (x : Prop) : f (g2234 x) = f (g2233 x)
@[simp] axiom s2234 (x : Prop) : f (g2235 x) = f (g2234 x)
@[simp] axiom s2235 (x : Prop) : f (g2236 x) = f (g2235 x)
@[simp] axiom s2236 (x : Prop) : f (g2237 x) = f (g2236 x)
@[simp] axiom s2237 (x : Prop) : f (g2238 x) = f (g2237 x)
@[simp] axiom s2238 (x : Prop) : f (g2239 x) = f (g2238 x)
@[simp] axiom s2239 (x : Prop) : f (g2240 x) = f (g2239 x)
@[simp] axiom s2240 (x : Prop) : f (g2241 x) = f (g2240 x)
@[simp] axiom s2241 (x : Prop) : f (g2242 x) = f (g2241 x)
@[simp] axiom s2242 (x : Prop) : f (g2243 x) = f (g2242 x)
@[simp] axiom s2243 (x : Prop) : f (g2244 x) = f (g2243 x)
@[simp] axiom s2244 (x : Prop) : f (g2245 x) = f (g2244 x)
@[simp] axiom s2245 (x : Prop) : f (g2246 x) = f (g2245 x)
@[simp] axiom s2246 (x : Prop) : f (g2247 x) = f (g2246 x)
@[simp] axiom s2247 (x : Prop) : f (g2248 x) = f (g2247 x)
@[simp] axiom s2248 (x : Prop) : f (g2249 x) = f (g2248 x)
@[simp] axiom s2249 (x : Prop) : f (g2250 x) = f (g2249 x)
@[simp] axiom s2250 (x : Prop) : f (g2251 x) = f (g2250 x)
@[simp] axiom s2251 (x : Prop) : f (g2252 x) = f (g2251 x)
@[simp] axiom s2252 (x : Prop) : f (g2253 x) = f (g2252 x)
@[simp] axiom s2253 (x : Prop) : f (g2254 x) = f (g2253 x)
@[simp] axiom s2254 (x : Prop) : f (g2255 x) = f (g2254 x)
@[simp] axiom s2255 (x : Prop) : f (g2256 x) = f (g2255 x)
@[simp] axiom s2256 (x : Prop) : f (g2257 x) = f (g2256 x)
@[simp] axiom s2257 (x : Prop) : f (g2258 x) = f (g2257 x)
@[simp] axiom s2258 (x : Prop) : f (g2259 x) = f (g2258 x)
@[simp] axiom s2259 (x : Prop) : f (g2260 x) = f (g2259 x)
@[simp] axiom s2260 (x : Prop) : f (g2261 x) = f (g2260 x)
@[simp] axiom s2261 (x : Prop) : f (g2262 x) = f (g2261 x)
@[simp] axiom s2262 (x : Prop) : f (g2263 x) = f (g2262 x)
@[simp] axiom s2263 (x : Prop) : f (g2264 x) = f (g2263 x)
@[simp] axiom s2264 (x : Prop) : f (g2265 x) = f (g2264 x)
@[simp] axiom s2265 (x : Prop) : f (g2266 x) = f (g2265 x)
@[simp] axiom s2266 (x : Prop) : f (g2267 x) = f (g2266 x)
@[simp] axiom s2267 (x : Prop) : f (g2268 x) = f (g2267 x)
@[simp] axiom s2268 (x : Prop) : f (g2269 x) = f (g2268 x)
@[simp] axiom s2269 (x : Prop) : f (g2270 x) = f (g2269 x)
@[simp] axiom s2270 (x : Prop) : f (g2271 x) = f (g2270 x)
@[simp] axiom s2271 (x : Prop) : f (g2272 x) = f (g2271 x)
@[simp] axiom s2272 (x : Prop) : f (g2273 x) = f (g2272 x)
@[simp] axiom s2273 (x : Prop) : f (g2274 x) = f (g2273 x)
@[simp] axiom s2274 (x : Prop) : f (g2275 x) = f (g2274 x)
@[simp] axiom s2275 (x : Prop) : f (g2276 x) = f (g2275 x)
@[simp] axiom s2276 (x : Prop) : f (g2277 x) = f (g2276 x)
@[simp] axiom s2277 (x : Prop) : f (g2278 x) = f (g2277 x)
@[simp] axiom s2278 (x : Prop) : f (g2279 x) = f (g2278 x)
@[simp] axiom s2279 (x : Prop) : f (g2280 x) = f (g2279 x)
@[simp] axiom s2280 (x : Prop) : f (g2281 x) = f (g2280 x)
@[simp] axiom s2281 (x : Prop) : f (g2282 x) = f (g2281 x)
@[simp] axiom s2282 (x : Prop) : f (g2283 x) = f (g2282 x)
@[simp] axiom s2283 (x : Prop) : f (g2284 x) = f (g2283 x)
@[simp] axiom s2284 (x : Prop) : f (g2285 x) = f (g2284 x)
@[simp] axiom s2285 (x : Prop) : f (g2286 x) = f (g2285 x)
@[simp] axiom s2286 (x : Prop) : f (g2287 x) = f (g2286 x)
@[simp] axiom s2287 (x : Prop) : f (g2288 x) = f (g2287 x)
@[simp] axiom s2288 (x : Prop) : f (g2289 x) = f (g2288 x)
@[simp] axiom s2289 (x : Prop) : f (g2290 x) = f (g2289 x)
@[simp] axiom s2290 (x : Prop) : f (g2291 x) = f (g2290 x)
@[simp] axiom s2291 (x : Prop) : f (g2292 x) = f (g2291 x)
@[simp] axiom s2292 (x : Prop) : f (g2293 x) = f (g2292 x)
@[simp] axiom s2293 (x : Prop) : f (g2294 x) = f (g2293 x)
@[simp] axiom s2294 (x : Prop) : f (g2295 x) = f (g2294 x)
@[simp] axiom s2295 (x : Prop) : f (g2296 x) = f (g2295 x)
@[simp] axiom s2296 (x : Prop) : f (g2297 x) = f (g2296 x)
@[simp] axiom s2297 (x : Prop) : f (g2298 x) = f (g2297 x)
@[simp] axiom s2298 (x : Prop) : f (g2299 x) = f (g2298 x)
@[simp] axiom s2299 (x : Prop) : f (g2300 x) = f (g2299 x)
@[simp] axiom s2300 (x : Prop) : f (g2301 x) = f (g2300 x)
@[simp] axiom s2301 (x : Prop) : f (g2302 x) = f (g2301 x)
@[simp] axiom s2302 (x : Prop) : f (g2303 x) = f (g2302 x)
@[simp] axiom s2303 (x : Prop) : f (g2304 x) = f (g2303 x)
@[simp] axiom s2304 (x : Prop) : f (g2305 x) = f (g2304 x)
@[simp] axiom s2305 (x : Prop) : f (g2306 x) = f (g2305 x)
@[simp] axiom s2306 (x : Prop) : f (g2307 x) = f (g2306 x)
@[simp] axiom s2307 (x : Prop) : f (g2308 x) = f (g2307 x)
@[simp] axiom s2308 (x : Prop) : f (g2309 x) = f (g2308 x)
@[simp] axiom s2309 (x : Prop) : f (g2310 x) = f (g2309 x)
@[simp] axiom s2310 (x : Prop) : f (g2311 x) = f (g2310 x)
@[simp] axiom s2311 (x : Prop) : f (g2312 x) = f (g2311 x)
@[simp] axiom s2312 (x : Prop) : f (g2313 x) = f (g2312 x)
@[simp] axiom s2313 (x : Prop) : f (g2314 x) = f (g2313 x)
@[simp] axiom s2314 (x : Prop) : f (g2315 x) = f (g2314 x)
@[simp] axiom s2315 (x : Prop) : f (g2316 x) = f (g2315 x)
@[simp] axiom s2316 (x : Prop) : f (g2317 x) = f (g2316 x)
@[simp] axiom s2317 (x : Prop) : f (g2318 x) = f (g2317 x)
@[simp] axiom s2318 (x : Prop) : f (g2319 x) = f (g2318 x)
@[simp] axiom s2319 (x : Prop) : f (g2320 x) = f (g2319 x)
@[simp] axiom s2320 (x : Prop) : f (g2321 x) = f (g2320 x)
@[simp] axiom s2321 (x : Prop) : f (g2322 x) = f (g2321 x)
@[simp] axiom s2322 (x : Prop) : f (g2323 x) = f (g2322 x)
@[simp] axiom s2323 (x : Prop) : f (g2324 x) = f (g2323 x)
@[simp] axiom s2324 (x : Prop) : f (g2325 x) = f (g2324 x)
@[simp] axiom s2325 (x : Prop) : f (g2326 x) = f (g2325 x)
@[simp] axiom s2326 (x : Prop) : f (g2327 x) = f (g2326 x)
@[simp] axiom s2327 (x : Prop) : f (g2328 x) = f (g2327 x)
@[simp] axiom s2328 (x : Prop) : f (g2329 x) = f (g2328 x)
@[simp] axiom s2329 (x : Prop) : f (g2330 x) = f (g2329 x)
@[simp] axiom s2330 (x : Prop) : f (g2331 x) = f (g2330 x)
@[simp] axiom s2331 (x : Prop) : f (g2332 x) = f (g2331 x)
@[simp] axiom s2332 (x : Prop) : f (g2333 x) = f (g2332 x)
@[simp] axiom s2333 (x : Prop) : f (g2334 x) = f (g2333 x)
@[simp] axiom s2334 (x : Prop) : f (g2335 x) = f (g2334 x)
@[simp] axiom s2335 (x : Prop) : f (g2336 x) = f (g2335 x)
@[simp] axiom s2336 (x : Prop) : f (g2337 x) = f (g2336 x)
@[simp] axiom s2337 (x : Prop) : f (g2338 x) = f (g2337 x)
@[simp] axiom s2338 (x : Prop) : f (g2339 x) = f (g2338 x)
@[simp] axiom s2339 (x : Prop) : f (g2340 x) = f (g2339 x)
@[simp] axiom s2340 (x : Prop) : f (g2341 x) = f (g2340 x)
@[simp] axiom s2341 (x : Prop) : f (g2342 x) = f (g2341 x)
@[simp] axiom s2342 (x : Prop) : f (g2343 x) = f (g2342 x)
@[simp] axiom s2343 (x : Prop) : f (g2344 x) = f (g2343 x)
@[simp] axiom s2344 (x : Prop) : f (g2345 x) = f (g2344 x)
@[simp] axiom s2345 (x : Prop) : f (g2346 x) = f (g2345 x)
@[simp] axiom s2346 (x : Prop) : f (g2347 x) = f (g2346 x)
@[simp] axiom s2347 (x : Prop) : f (g2348 x) = f (g2347 x)
@[simp] axiom s2348 (x : Prop) : f (g2349 x) = f (g2348 x)
@[simp] axiom s2349 (x : Prop) : f (g2350 x) = f (g2349 x)
@[simp] axiom s2350 (x : Prop) : f (g2351 x) = f (g2350 x)
@[simp] axiom s2351 (x : Prop) : f (g2352 x) = f (g2351 x)
@[simp] axiom s2352 (x : Prop) : f (g2353 x) = f (g2352 x)
@[simp] axiom s2353 (x : Prop) : f (g2354 x) = f (g2353 x)
@[simp] axiom s2354 (x : Prop) : f (g2355 x) = f (g2354 x)
@[simp] axiom s2355 (x : Prop) : f (g2356 x) = f (g2355 x)
@[simp] axiom s2356 (x : Prop) : f (g2357 x) = f (g2356 x)
@[simp] axiom s2357 (x : Prop) : f (g2358 x) = f (g2357 x)
@[simp] axiom s2358 (x : Prop) : f (g2359 x) = f (g2358 x)
@[simp] axiom s2359 (x : Prop) : f (g2360 x) = f (g2359 x)
@[simp] axiom s2360 (x : Prop) : f (g2361 x) = f (g2360 x)
@[simp] axiom s2361 (x : Prop) : f (g2362 x) = f (g2361 x)
@[simp] axiom s2362 (x : Prop) : f (g2363 x) = f (g2362 x)
@[simp] axiom s2363 (x : Prop) : f (g2364 x) = f (g2363 x)
@[simp] axiom s2364 (x : Prop) : f (g2365 x) = f (g2364 x)
@[simp] axiom s2365 (x : Prop) : f (g2366 x) = f (g2365 x)
@[simp] axiom s2366 (x : Prop) : f (g2367 x) = f (g2366 x)
@[simp] axiom s2367 (x : Prop) : f (g2368 x) = f (g2367 x)
@[simp] axiom s2368 (x : Prop) : f (g2369 x) = f (g2368 x)
@[simp] axiom s2369 (x : Prop) : f (g2370 x) = f (g2369 x)
@[simp] axiom s2370 (x : Prop) : f (g2371 x) = f (g2370 x)
@[simp] axiom s2371 (x : Prop) : f (g2372 x) = f (g2371 x)
@[simp] axiom s2372 (x : Prop) : f (g2373 x) = f (g2372 x)
@[simp] axiom s2373 (x : Prop) : f (g2374 x) = f (g2373 x)
@[simp] axiom s2374 (x : Prop) : f (g2375 x) = f (g2374 x)
@[simp] axiom s2375 (x : Prop) : f (g2376 x) = f (g2375 x)
@[simp] axiom s2376 (x : Prop) : f (g2377 x) = f (g2376 x)
@[simp] axiom s2377 (x : Prop) : f (g2378 x) = f (g2377 x)
@[simp] axiom s2378 (x : Prop) : f (g2379 x) = f (g2378 x)
@[simp] axiom s2379 (x : Prop) : f (g2380 x) = f (g2379 x)
@[simp] axiom s2380 (x : Prop) : f (g2381 x) = f (g2380 x)
@[simp] axiom s2381 (x : Prop) : f (g2382 x) = f (g2381 x)
@[simp] axiom s2382 (x : Prop) : f (g2383 x) = f (g2382 x)
@[simp] axiom s2383 (x : Prop) : f (g2384 x) = f (g2383 x)
@[simp] axiom s2384 (x : Prop) : f (g2385 x) = f (g2384 x)
@[simp] axiom s2385 (x : Prop) : f (g2386 x) = f (g2385 x)
@[simp] axiom s2386 (x : Prop) : f (g2387 x) = f (g2386 x)
@[simp] axiom s2387 (x : Prop) : f (g2388 x) = f (g2387 x)
@[simp] axiom s2388 (x : Prop) : f (g2389 x) = f (g2388 x)
@[simp] axiom s2389 (x : Prop) : f (g2390 x) = f (g2389 x)
@[simp] axiom s2390 (x : Prop) : f (g2391 x) = f (g2390 x)
@[simp] axiom s2391 (x : Prop) : f (g2392 x) = f (g2391 x)
@[simp] axiom s2392 (x : Prop) : f (g2393 x) = f (g2392 x)
@[simp] axiom s2393 (x : Prop) : f (g2394 x) = f (g2393 x)
@[simp] axiom s2394 (x : Prop) : f (g2395 x) = f (g2394 x)
@[simp] axiom s2395 (x : Prop) : f (g2396 x) = f (g2395 x)
@[simp] axiom s2396 (x : Prop) : f (g2397 x) = f (g2396 x)
@[simp] axiom s2397 (x : Prop) : f (g2398 x) = f (g2397 x)
@[simp] axiom s2398 (x : Prop) : f (g2399 x) = f (g2398 x)
@[simp] axiom s2399 (x : Prop) : f (g2400 x) = f (g2399 x)
@[simp] axiom s2400 (x : Prop) : f (g2401 x) = f (g2400 x)
@[simp] axiom s2401 (x : Prop) : f (g2402 x) = f (g2401 x)
@[simp] axiom s2402 (x : Prop) : f (g2403 x) = f (g2402 x)
@[simp] axiom s2403 (x : Prop) : f (g2404 x) = f (g2403 x)
@[simp] axiom s2404 (x : Prop) : f (g2405 x) = f (g2404 x)
@[simp] axiom s2405 (x : Prop) : f (g2406 x) = f (g2405 x)
@[simp] axiom s2406 (x : Prop) : f (g2407 x) = f (g2406 x)
@[simp] axiom s2407 (x : Prop) : f (g2408 x) = f (g2407 x)
@[simp] axiom s2408 (x : Prop) : f (g2409 x) = f (g2408 x)
@[simp] axiom s2409 (x : Prop) : f (g2410 x) = f (g2409 x)
@[simp] axiom s2410 (x : Prop) : f (g2411 x) = f (g2410 x)
@[simp] axiom s2411 (x : Prop) : f (g2412 x) = f (g2411 x)
@[simp] axiom s2412 (x : Prop) : f (g2413 x) = f (g2412 x)
@[simp] axiom s2413 (x : Prop) : f (g2414 x) = f (g2413 x)
@[simp] axiom s2414 (x : Prop) : f (g2415 x) = f (g2414 x)
@[simp] axiom s2415 (x : Prop) : f (g2416 x) = f (g2415 x)
@[simp] axiom s2416 (x : Prop) : f (g2417 x) = f (g2416 x)
@[simp] axiom s2417 (x : Prop) : f (g2418 x) = f (g2417 x)
@[simp] axiom s2418 (x : Prop) : f (g2419 x) = f (g2418 x)
@[simp] axiom s2419 (x : Prop) : f (g2420 x) = f (g2419 x)
@[simp] axiom s2420 (x : Prop) : f (g2421 x) = f (g2420 x)
@[simp] axiom s2421 (x : Prop) : f (g2422 x) = f (g2421 x)
@[simp] axiom s2422 (x : Prop) : f (g2423 x) = f (g2422 x)
@[simp] axiom s2423 (x : Prop) : f (g2424 x) = f (g2423 x)
@[simp] axiom s2424 (x : Prop) : f (g2425 x) = f (g2424 x)
@[simp] axiom s2425 (x : Prop) : f (g2426 x) = f (g2425 x)
@[simp] axiom s2426 (x : Prop) : f (g2427 x) = f (g2426 x)
@[simp] axiom s2427 (x : Prop) : f (g2428 x) = f (g2427 x)
@[simp] axiom s2428 (x : Prop) : f (g2429 x) = f (g2428 x)
@[simp] axiom s2429 (x : Prop) : f (g2430 x) = f (g2429 x)
@[simp] axiom s2430 (x : Prop) : f (g2431 x) = f (g2430 x)
@[simp] axiom s2431 (x : Prop) : f (g2432 x) = f (g2431 x)
@[simp] axiom s2432 (x : Prop) : f (g2433 x) = f (g2432 x)
@[simp] axiom s2433 (x : Prop) : f (g2434 x) = f (g2433 x)
@[simp] axiom s2434 (x : Prop) : f (g2435 x) = f (g2434 x)
@[simp] axiom s2435 (x : Prop) : f (g2436 x) = f (g2435 x)
@[simp] axiom s2436 (x : Prop) : f (g2437 x) = f (g2436 x)
@[simp] axiom s2437 (x : Prop) : f (g2438 x) = f (g2437 x)
@[simp] axiom s2438 (x : Prop) : f (g2439 x) = f (g2438 x)
@[simp] axiom s2439 (x : Prop) : f (g2440 x) = f (g2439 x)
@[simp] axiom s2440 (x : Prop) : f (g2441 x) = f (g2440 x)
@[simp] axiom s2441 (x : Prop) : f (g2442 x) = f (g2441 x)
@[simp] axiom s2442 (x : Prop) : f (g2443 x) = f (g2442 x)
@[simp] axiom s2443 (x : Prop) : f (g2444 x) = f (g2443 x)
@[simp] axiom s2444 (x : Prop) : f (g2445 x) = f (g2444 x)
@[simp] axiom s2445 (x : Prop) : f (g2446 x) = f (g2445 x)
@[simp] axiom s2446 (x : Prop) : f (g2447 x) = f (g2446 x)
@[simp] axiom s2447 (x : Prop) : f (g2448 x) = f (g2447 x)
@[simp] axiom s2448 (x : Prop) : f (g2449 x) = f (g2448 x)
@[simp] axiom s2449 (x : Prop) : f (g2450 x) = f (g2449 x)
@[simp] axiom s2450 (x : Prop) : f (g2451 x) = f (g2450 x)
@[simp] axiom s2451 (x : Prop) : f (g2452 x) = f (g2451 x)
@[simp] axiom s2452 (x : Prop) : f (g2453 x) = f (g2452 x)
@[simp] axiom s2453 (x : Prop) : f (g2454 x) = f (g2453 x)
@[simp] axiom s2454 (x : Prop) : f (g2455 x) = f (g2454 x)
@[simp] axiom s2455 (x : Prop) : f (g2456 x) = f (g2455 x)
@[simp] axiom s2456 (x : Prop) : f (g2457 x) = f (g2456 x)
@[simp] axiom s2457 (x : Prop) : f (g2458 x) = f (g2457 x)
@[simp] axiom s2458 (x : Prop) : f (g2459 x) = f (g2458 x)
@[simp] axiom s2459 (x : Prop) : f (g2460 x) = f (g2459 x)
@[simp] axiom s2460 (x : Prop) : f (g2461 x) = f (g2460 x)
@[simp] axiom s2461 (x : Prop) : f (g2462 x) = f (g2461 x)
@[simp] axiom s2462 (x : Prop) : f (g2463 x) = f (g2462 x)
@[simp] axiom s2463 (x : Prop) : f (g2464 x) = f (g2463 x)
@[simp] axiom s2464 (x : Prop) : f (g2465 x) = f (g2464 x)
@[simp] axiom s2465 (x : Prop) : f (g2466 x) = f (g2465 x)
@[simp] axiom s2466 (x : Prop) : f (g2467 x) = f (g2466 x)
@[simp] axiom s2467 (x : Prop) : f (g2468 x) = f (g2467 x)
@[simp] axiom s2468 (x : Prop) : f (g2469 x) = f (g2468 x)
@[simp] axiom s2469 (x : Prop) : f (g2470 x) = f (g2469 x)
@[simp] axiom s2470 (x : Prop) : f (g2471 x) = f (g2470 x)
@[simp] axiom s2471 (x : Prop) : f (g2472 x) = f (g2471 x)
@[simp] axiom s2472 (x : Prop) : f (g2473 x) = f (g2472 x)
@[simp] axiom s2473 (x : Prop) : f (g2474 x) = f (g2473 x)
@[simp] axiom s2474 (x : Prop) : f (g2475 x) = f (g2474 x)
@[simp] axiom s2475 (x : Prop) : f (g2476 x) = f (g2475 x)
@[simp] axiom s2476 (x : Prop) : f (g2477 x) = f (g2476 x)
@[simp] axiom s2477 (x : Prop) : f (g2478 x) = f (g2477 x)
@[simp] axiom s2478 (x : Prop) : f (g2479 x) = f (g2478 x)
@[simp] axiom s2479 (x : Prop) : f (g2480 x) = f (g2479 x)
@[simp] axiom s2480 (x : Prop) : f (g2481 x) = f (g2480 x)
@[simp] axiom s2481 (x : Prop) : f (g2482 x) = f (g2481 x)
@[simp] axiom s2482 (x : Prop) : f (g2483 x) = f (g2482 x)
@[simp] axiom s2483 (x : Prop) : f (g2484 x) = f (g2483 x)
@[simp] axiom s2484 (x : Prop) : f (g2485 x) = f (g2484 x)
@[simp] axiom s2485 (x : Prop) : f (g2486 x) = f (g2485 x)
@[simp] axiom s2486 (x : Prop) : f (g2487 x) = f (g2486 x)
@[simp] axiom s2487 (x : Prop) : f (g2488 x) = f (g2487 x)
@[simp] axiom s2488 (x : Prop) : f (g2489 x) = f (g2488 x)
@[simp] axiom s2489 (x : Prop) : f (g2490 x) = f (g2489 x)
@[simp] axiom s2490 (x : Prop) : f (g2491 x) = f (g2490 x)
@[simp] axiom s2491 (x : Prop) : f (g2492 x) = f (g2491 x)
@[simp] axiom s2492 (x : Prop) : f (g2493 x) = f (g2492 x)
@[simp] axiom s2493 (x : Prop) : f (g2494 x) = f (g2493 x)
@[simp] axiom s2494 (x : Prop) : f (g2495 x) = f (g2494 x)
@[simp] axiom s2495 (x : Prop) : f (g2496 x) = f (g2495 x)
@[simp] axiom s2496 (x : Prop) : f (g2497 x) = f (g2496 x)
@[simp] axiom s2497 (x : Prop) : f (g2498 x) = f (g2497 x)
@[simp] axiom s2498 (x : Prop) : f (g2499 x) = f (g2498 x)
@[simp] axiom s2499 (x : Prop) : f (g2500 x) = f (g2499 x)
@[simp] axiom s2500 (x : Prop) : f (g2501 x) = f (g2500 x)
@[simp] axiom s2501 (x : Prop) : f (g2502 x) = f (g2501 x)
@[simp] axiom s2502 (x : Prop) : f (g2503 x) = f (g2502 x)
@[simp] axiom s2503 (x : Prop) : f (g2504 x) = f (g2503 x)
@[simp] axiom s2504 (x : Prop) : f (g2505 x) = f (g2504 x)
@[simp] axiom s2505 (x : Prop) : f (g2506 x) = f (g2505 x)
@[simp] axiom s2506 (x : Prop) : f (g2507 x) = f (g2506 x)
@[simp] axiom s2507 (x : Prop) : f (g2508 x) = f (g2507 x)
@[simp] axiom s2508 (x : Prop) : f (g2509 x) = f (g2508 x)
@[simp] axiom s2509 (x : Prop) : f (g2510 x) = f (g2509 x)
@[simp] axiom s2510 (x : Prop) : f (g2511 x) = f (g2510 x)
@[simp] axiom s2511 (x : Prop) : f (g2512 x) = f (g2511 x)
@[simp] axiom s2512 (x : Prop) : f (g2513 x) = f (g2512 x)
@[simp] axiom s2513 (x : Prop) : f (g2514 x) = f (g2513 x)
@[simp] axiom s2514 (x : Prop) : f (g2515 x) = f (g2514 x)
@[simp] axiom s2515 (x : Prop) : f (g2516 x) = f (g2515 x)
@[simp] axiom s2516 (x : Prop) : f (g2517 x) = f (g2516 x)
@[simp] axiom s2517 (x : Prop) : f (g2518 x) = f (g2517 x)
@[simp] axiom s2518 (x : Prop) : f (g2519 x) = f (g2518 x)
@[simp] axiom s2519 (x : Prop) : f (g2520 x) = f (g2519 x)
@[simp] axiom s2520 (x : Prop) : f (g2521 x) = f (g2520 x)
@[simp] axiom s2521 (x : Prop) : f (g2522 x) = f (g2521 x)
@[simp] axiom s2522 (x : Prop) : f (g2523 x) = f (g2522 x)
@[simp] axiom s2523 (x : Prop) : f (g2524 x) = f (g2523 x)
@[simp] axiom s2524 (x : Prop) : f (g2525 x) = f (g2524 x)
@[simp] axiom s2525 (x : Prop) : f (g2526 x) = f (g2525 x)
@[simp] axiom s2526 (x : Prop) : f (g2527 x) = f (g2526 x)
@[simp] axiom s2527 (x : Prop) : f (g2528 x) = f (g2527 x)
@[simp] axiom s2528 (x : Prop) : f (g2529 x) = f (g2528 x)
@[simp] axiom s2529 (x : Prop) : f (g2530 x) = f (g2529 x)
@[simp] axiom s2530 (x : Prop) : f (g2531 x) = f (g2530 x)
@[simp] axiom s2531 (x : Prop) : f (g2532 x) = f (g2531 x)
@[simp] axiom s2532 (x : Prop) : f (g2533 x) = f (g2532 x)
@[simp] axiom s2533 (x : Prop) : f (g2534 x) = f (g2533 x)
@[simp] axiom s2534 (x : Prop) : f (g2535 x) = f (g2534 x)
@[simp] axiom s2535 (x : Prop) : f (g2536 x) = f (g2535 x)
@[simp] axiom s2536 (x : Prop) : f (g2537 x) = f (g2536 x)
@[simp] axiom s2537 (x : Prop) : f (g2538 x) = f (g2537 x)
@[simp] axiom s2538 (x : Prop) : f (g2539 x) = f (g2538 x)
@[simp] axiom s2539 (x : Prop) : f (g2540 x) = f (g2539 x)
@[simp] axiom s2540 (x : Prop) : f (g2541 x) = f (g2540 x)
@[simp] axiom s2541 (x : Prop) : f (g2542 x) = f (g2541 x)
@[simp] axiom s2542 (x : Prop) : f (g2543 x) = f (g2542 x)
@[simp] axiom s2543 (x : Prop) : f (g2544 x) = f (g2543 x)
@[simp] axiom s2544 (x : Prop) : f (g2545 x) = f (g2544 x)
@[simp] axiom s2545 (x : Prop) : f (g2546 x) = f (g2545 x)
@[simp] axiom s2546 (x : Prop) : f (g2547 x) = f (g2546 x)
@[simp] axiom s2547 (x : Prop) : f (g2548 x) = f (g2547 x)
@[simp] axiom s2548 (x : Prop) : f (g2549 x) = f (g2548 x)
@[simp] axiom s2549 (x : Prop) : f (g2550 x) = f (g2549 x)
@[simp] axiom s2550 (x : Prop) : f (g2551 x) = f (g2550 x)
@[simp] axiom s2551 (x : Prop) : f (g2552 x) = f (g2551 x)
@[simp] axiom s2552 (x : Prop) : f (g2553 x) = f (g2552 x)
@[simp] axiom s2553 (x : Prop) : f (g2554 x) = f (g2553 x)
@[simp] axiom s2554 (x : Prop) : f (g2555 x) = f (g2554 x)
@[simp] axiom s2555 (x : Prop) : f (g2556 x) = f (g2555 x)
@[simp] axiom s2556 (x : Prop) : f (g2557 x) = f (g2556 x)
@[simp] axiom s2557 (x : Prop) : f (g2558 x) = f (g2557 x)
@[simp] axiom s2558 (x : Prop) : f (g2559 x) = f (g2558 x)
@[simp] axiom s2559 (x : Prop) : f (g2560 x) = f (g2559 x)
@[simp] axiom s2560 (x : Prop) : f (g2561 x) = f (g2560 x)
@[simp] axiom s2561 (x : Prop) : f (g2562 x) = f (g2561 x)
@[simp] axiom s2562 (x : Prop) : f (g2563 x) = f (g2562 x)
@[simp] axiom s2563 (x : Prop) : f (g2564 x) = f (g2563 x)
@[simp] axiom s2564 (x : Prop) : f (g2565 x) = f (g2564 x)
@[simp] axiom s2565 (x : Prop) : f (g2566 x) = f (g2565 x)
@[simp] axiom s2566 (x : Prop) : f (g2567 x) = f (g2566 x)
@[simp] axiom s2567 (x : Prop) : f (g2568 x) = f (g2567 x)
@[simp] axiom s2568 (x : Prop) : f (g2569 x) = f (g2568 x)
@[simp] axiom s2569 (x : Prop) : f (g2570 x) = f (g2569 x)
@[simp] axiom s2570 (x : Prop) : f (g2571 x) = f (g2570 x)
@[simp] axiom s2571 (x : Prop) : f (g2572 x) = f (g2571 x)
@[simp] axiom s2572 (x : Prop) : f (g2573 x) = f (g2572 x)
@[simp] axiom s2573 (x : Prop) : f (g2574 x) = f (g2573 x)
@[simp] axiom s2574 (x : Prop) : f (g2575 x) = f (g2574 x)
@[simp] axiom s2575 (x : Prop) : f (g2576 x) = f (g2575 x)
@[simp] axiom s2576 (x : Prop) : f (g2577 x) = f (g2576 x)
@[simp] axiom s2577 (x : Prop) : f (g2578 x) = f (g2577 x)
@[simp] axiom s2578 (x : Prop) : f (g2579 x) = f (g2578 x)
@[simp] axiom s2579 (x : Prop) : f (g2580 x) = f (g2579 x)
@[simp] axiom s2580 (x : Prop) : f (g2581 x) = f (g2580 x)
@[simp] axiom s2581 (x : Prop) : f (g2582 x) = f (g2581 x)
@[simp] axiom s2582 (x : Prop) : f (g2583 x) = f (g2582 x)
@[simp] axiom s2583 (x : Prop) : f (g2584 x) = f (g2583 x)
@[simp] axiom s2584 (x : Prop) : f (g2585 x) = f (g2584 x)
@[simp] axiom s2585 (x : Prop) : f (g2586 x) = f (g2585 x)
@[simp] axiom s2586 (x : Prop) : f (g2587 x) = f (g2586 x)
@[simp] axiom s2587 (x : Prop) : f (g2588 x) = f (g2587 x)
@[simp] axiom s2588 (x : Prop) : f (g2589 x) = f (g2588 x)
@[simp] axiom s2589 (x : Prop) : f (g2590 x) = f (g2589 x)
@[simp] axiom s2590 (x : Prop) : f (g2591 x) = f (g2590 x)
@[simp] axiom s2591 (x : Prop) : f (g2592 x) = f (g2591 x)
@[simp] axiom s2592 (x : Prop) : f (g2593 x) = f (g2592 x)
@[simp] axiom s2593 (x : Prop) : f (g2594 x) = f (g2593 x)
@[simp] axiom s2594 (x : Prop) : f (g2595 x) = f (g2594 x)
@[simp] axiom s2595 (x : Prop) : f (g2596 x) = f (g2595 x)
@[simp] axiom s2596 (x : Prop) : f (g2597 x) = f (g2596 x)
@[simp] axiom s2597 (x : Prop) : f (g2598 x) = f (g2597 x)
@[simp] axiom s2598 (x : Prop) : f (g2599 x) = f (g2598 x)
@[simp] axiom s2599 (x : Prop) : f (g2600 x) = f (g2599 x)
@[simp] axiom s2600 (x : Prop) : f (g2601 x) = f (g2600 x)
@[simp] axiom s2601 (x : Prop) : f (g2602 x) = f (g2601 x)
@[simp] axiom s2602 (x : Prop) : f (g2603 x) = f (g2602 x)
@[simp] axiom s2603 (x : Prop) : f (g2604 x) = f (g2603 x)
@[simp] axiom s2604 (x : Prop) : f (g2605 x) = f (g2604 x)
@[simp] axiom s2605 (x : Prop) : f (g2606 x) = f (g2605 x)
@[simp] axiom s2606 (x : Prop) : f (g2607 x) = f (g2606 x)
@[simp] axiom s2607 (x : Prop) : f (g2608 x) = f (g2607 x)
@[simp] axiom s2608 (x : Prop) : f (g2609 x) = f (g2608 x)
@[simp] axiom s2609 (x : Prop) : f (g2610 x) = f (g2609 x)
@[simp] axiom s2610 (x : Prop) : f (g2611 x) = f (g2610 x)
@[simp] axiom s2611 (x : Prop) : f (g2612 x) = f (g2611 x)
@[simp] axiom s2612 (x : Prop) : f (g2613 x) = f (g2612 x)
@[simp] axiom s2613 (x : Prop) : f (g2614 x) = f (g2613 x)
@[simp] axiom s2614 (x : Prop) : f (g2615 x) = f (g2614 x)
@[simp] axiom s2615 (x : Prop) : f (g2616 x) = f (g2615 x)
@[simp] axiom s2616 (x : Prop) : f (g2617 x) = f (g2616 x)
@[simp] axiom s2617 (x : Prop) : f (g2618 x) = f (g2617 x)
@[simp] axiom s2618 (x : Prop) : f (g2619 x) = f (g2618 x)
@[simp] axiom s2619 (x : Prop) : f (g2620 x) = f (g2619 x)
@[simp] axiom s2620 (x : Prop) : f (g2621 x) = f (g2620 x)
@[simp] axiom s2621 (x : Prop) : f (g2622 x) = f (g2621 x)
@[simp] axiom s2622 (x : Prop) : f (g2623 x) = f (g2622 x)
@[simp] axiom s2623 (x : Prop) : f (g2624 x) = f (g2623 x)
@[simp] axiom s2624 (x : Prop) : f (g2625 x) = f (g2624 x)
@[simp] axiom s2625 (x : Prop) : f (g2626 x) = f (g2625 x)
@[simp] axiom s2626 (x : Prop) : f (g2627 x) = f (g2626 x)
@[simp] axiom s2627 (x : Prop) : f (g2628 x) = f (g2627 x)
@[simp] axiom s2628 (x : Prop) : f (g2629 x) = f (g2628 x)
@[simp] axiom s2629 (x : Prop) : f (g2630 x) = f (g2629 x)
@[simp] axiom s2630 (x : Prop) : f (g2631 x) = f (g2630 x)
@[simp] axiom s2631 (x : Prop) : f (g2632 x) = f (g2631 x)
@[simp] axiom s2632 (x : Prop) : f (g2633 x) = f (g2632 x)
@[simp] axiom s2633 (x : Prop) : f (g2634 x) = f (g2633 x)
@[simp] axiom s2634 (x : Prop) : f (g2635 x) = f (g2634 x)
@[simp] axiom s2635 (x : Prop) : f (g2636 x) = f (g2635 x)
@[simp] axiom s2636 (x : Prop) : f (g2637 x) = f (g2636 x)
@[simp] axiom s2637 (x : Prop) : f (g2638 x) = f (g2637 x)
@[simp] axiom s2638 (x : Prop) : f (g2639 x) = f (g2638 x)
@[simp] axiom s2639 (x : Prop) : f (g2640 x) = f (g2639 x)
@[simp] axiom s2640 (x : Prop) : f (g2641 x) = f (g2640 x)
@[simp] axiom s2641 (x : Prop) : f (g2642 x) = f (g2641 x)
@[simp] axiom s2642 (x : Prop) : f (g2643 x) = f (g2642 x)
@[simp] axiom s2643 (x : Prop) : f (g2644 x) = f (g2643 x)
@[simp] axiom s2644 (x : Prop) : f (g2645 x) = f (g2644 x)
@[simp] axiom s2645 (x : Prop) : f (g2646 x) = f (g2645 x)
@[simp] axiom s2646 (x : Prop) : f (g2647 x) = f (g2646 x)
@[simp] axiom s2647 (x : Prop) : f (g2648 x) = f (g2647 x)
@[simp] axiom s2648 (x : Prop) : f (g2649 x) = f (g2648 x)
@[simp] axiom s2649 (x : Prop) : f (g2650 x) = f (g2649 x)
@[simp] axiom s2650 (x : Prop) : f (g2651 x) = f (g2650 x)
@[simp] axiom s2651 (x : Prop) : f (g2652 x) = f (g2651 x)
@[simp] axiom s2652 (x : Prop) : f (g2653 x) = f (g2652 x)
@[simp] axiom s2653 (x : Prop) : f (g2654 x) = f (g2653 x)
@[simp] axiom s2654 (x : Prop) : f (g2655 x) = f (g2654 x)
@[simp] axiom s2655 (x : Prop) : f (g2656 x) = f (g2655 x)
@[simp] axiom s2656 (x : Prop) : f (g2657 x) = f (g2656 x)
@[simp] axiom s2657 (x : Prop) : f (g2658 x) = f (g2657 x)
@[simp] axiom s2658 (x : Prop) : f (g2659 x) = f (g2658 x)
@[simp] axiom s2659 (x : Prop) : f (g2660 x) = f (g2659 x)
@[simp] axiom s2660 (x : Prop) : f (g2661 x) = f (g2660 x)
@[simp] axiom s2661 (x : Prop) : f (g2662 x) = f (g2661 x)
@[simp] axiom s2662 (x : Prop) : f (g2663 x) = f (g2662 x)
@[simp] axiom s2663 (x : Prop) : f (g2664 x) = f (g2663 x)
@[simp] axiom s2664 (x : Prop) : f (g2665 x) = f (g2664 x)
@[simp] axiom s2665 (x : Prop) : f (g2666 x) = f (g2665 x)
@[simp] axiom s2666 (x : Prop) : f (g2667 x) = f (g2666 x)
@[simp] axiom s2667 (x : Prop) : f (g2668 x) = f (g2667 x)
@[simp] axiom s2668 (x : Prop) : f (g2669 x) = f (g2668 x)
@[simp] axiom s2669 (x : Prop) : f (g2670 x) = f (g2669 x)
@[simp] axiom s2670 (x : Prop) : f (g2671 x) = f (g2670 x)
@[simp] axiom s2671 (x : Prop) : f (g2672 x) = f (g2671 x)
@[simp] axiom s2672 (x : Prop) : f (g2673 x) = f (g2672 x)
@[simp] axiom s2673 (x : Prop) : f (g2674 x) = f (g2673 x)
@[simp] axiom s2674 (x : Prop) : f (g2675 x) = f (g2674 x)
@[simp] axiom s2675 (x : Prop) : f (g2676 x) = f (g2675 x)
@[simp] axiom s2676 (x : Prop) : f (g2677 x) = f (g2676 x)
@[simp] axiom s2677 (x : Prop) : f (g2678 x) = f (g2677 x)
@[simp] axiom s2678 (x : Prop) : f (g2679 x) = f (g2678 x)
@[simp] axiom s2679 (x : Prop) : f (g2680 x) = f (g2679 x)
@[simp] axiom s2680 (x : Prop) : f (g2681 x) = f (g2680 x)
@[simp] axiom s2681 (x : Prop) : f (g2682 x) = f (g2681 x)
@[simp] axiom s2682 (x : Prop) : f (g2683 x) = f (g2682 x)
@[simp] axiom s2683 (x : Prop) : f (g2684 x) = f (g2683 x)
@[simp] axiom s2684 (x : Prop) : f (g2685 x) = f (g2684 x)
@[simp] axiom s2685 (x : Prop) : f (g2686 x) = f (g2685 x)
@[simp] axiom s2686 (x : Prop) : f (g2687 x) = f (g2686 x)
@[simp] axiom s2687 (x : Prop) : f (g2688 x) = f (g2687 x)
@[simp] axiom s2688 (x : Prop) : f (g2689 x) = f (g2688 x)
@[simp] axiom s2689 (x : Prop) : f (g2690 x) = f (g2689 x)
@[simp] axiom s2690 (x : Prop) : f (g2691 x) = f (g2690 x)
@[simp] axiom s2691 (x : Prop) : f (g2692 x) = f (g2691 x)
@[simp] axiom s2692 (x : Prop) : f (g2693 x) = f (g2692 x)
@[simp] axiom s2693 (x : Prop) : f (g2694 x) = f (g2693 x)
@[simp] axiom s2694 (x : Prop) : f (g2695 x) = f (g2694 x)
@[simp] axiom s2695 (x : Prop) : f (g2696 x) = f (g2695 x)
@[simp] axiom s2696 (x : Prop) : f (g2697 x) = f (g2696 x)
@[simp] axiom s2697 (x : Prop) : f (g2698 x) = f (g2697 x)
@[simp] axiom s2698 (x : Prop) : f (g2699 x) = f (g2698 x)
@[simp] axiom s2699 (x : Prop) : f (g2700 x) = f (g2699 x)
@[simp] axiom s2700 (x : Prop) : f (g2701 x) = f (g2700 x)
@[simp] axiom s2701 (x : Prop) : f (g2702 x) = f (g2701 x)
@[simp] axiom s2702 (x : Prop) : f (g2703 x) = f (g2702 x)
@[simp] axiom s2703 (x : Prop) : f (g2704 x) = f (g2703 x)
@[simp] axiom s2704 (x : Prop) : f (g2705 x) = f (g2704 x)
@[simp] axiom s2705 (x : Prop) : f (g2706 x) = f (g2705 x)
@[simp] axiom s2706 (x : Prop) : f (g2707 x) = f (g2706 x)
@[simp] axiom s2707 (x : Prop) : f (g2708 x) = f (g2707 x)
@[simp] axiom s2708 (x : Prop) : f (g2709 x) = f (g2708 x)
@[simp] axiom s2709 (x : Prop) : f (g2710 x) = f (g2709 x)
@[simp] axiom s2710 (x : Prop) : f (g2711 x) = f (g2710 x)
@[simp] axiom s2711 (x : Prop) : f (g2712 x) = f (g2711 x)
@[simp] axiom s2712 (x : Prop) : f (g2713 x) = f (g2712 x)
@[simp] axiom s2713 (x : Prop) : f (g2714 x) = f (g2713 x)
@[simp] axiom s2714 (x : Prop) : f (g2715 x) = f (g2714 x)
@[simp] axiom s2715 (x : Prop) : f (g2716 x) = f (g2715 x)
@[simp] axiom s2716 (x : Prop) : f (g2717 x) = f (g2716 x)
@[simp] axiom s2717 (x : Prop) : f (g2718 x) = f (g2717 x)
@[simp] axiom s2718 (x : Prop) : f (g2719 x) = f (g2718 x)
@[simp] axiom s2719 (x : Prop) : f (g2720 x) = f (g2719 x)
@[simp] axiom s2720 (x : Prop) : f (g2721 x) = f (g2720 x)
@[simp] axiom s2721 (x : Prop) : f (g2722 x) = f (g2721 x)
@[simp] axiom s2722 (x : Prop) : f (g2723 x) = f (g2722 x)
@[simp] axiom s2723 (x : Prop) : f (g2724 x) = f (g2723 x)
@[simp] axiom s2724 (x : Prop) : f (g2725 x) = f (g2724 x)
@[simp] axiom s2725 (x : Prop) : f (g2726 x) = f (g2725 x)
@[simp] axiom s2726 (x : Prop) : f (g2727 x) = f (g2726 x)
@[simp] axiom s2727 (x : Prop) : f (g2728 x) = f (g2727 x)
@[simp] axiom s2728 (x : Prop) : f (g2729 x) = f (g2728 x)
@[simp] axiom s2729 (x : Prop) : f (g2730 x) = f (g2729 x)
@[simp] axiom s2730 (x : Prop) : f (g2731 x) = f (g2730 x)
@[simp] axiom s2731 (x : Prop) : f (g2732 x) = f (g2731 x)
@[simp] axiom s2732 (x : Prop) : f (g2733 x) = f (g2732 x)
@[simp] axiom s2733 (x : Prop) : f (g2734 x) = f (g2733 x)
@[simp] axiom s2734 (x : Prop) : f (g2735 x) = f (g2734 x)
@[simp] axiom s2735 (x : Prop) : f (g2736 x) = f (g2735 x)
@[simp] axiom s2736 (x : Prop) : f (g2737 x) = f (g2736 x)
@[simp] axiom s2737 (x : Prop) : f (g2738 x) = f (g2737 x)
@[simp] axiom s2738 (x : Prop) : f (g2739 x) = f (g2738 x)
@[simp] axiom s2739 (x : Prop) : f (g2740 x) = f (g2739 x)
@[simp] axiom s2740 (x : Prop) : f (g2741 x) = f (g2740 x)
@[simp] axiom s2741 (x : Prop) : f (g2742 x) = f (g2741 x)
@[simp] axiom s2742 (x : Prop) : f (g2743 x) = f (g2742 x)
@[simp] axiom s2743 (x : Prop) : f (g2744 x) = f (g2743 x)
@[simp] axiom s2744 (x : Prop) : f (g2745 x) = f (g2744 x)
@[simp] axiom s2745 (x : Prop) : f (g2746 x) = f (g2745 x)
@[simp] axiom s2746 (x : Prop) : f (g2747 x) = f (g2746 x)
@[simp] axiom s2747 (x : Prop) : f (g2748 x) = f (g2747 x)
@[simp] axiom s2748 (x : Prop) : f (g2749 x) = f (g2748 x)
@[simp] axiom s2749 (x : Prop) : f (g2750 x) = f (g2749 x)
@[simp] axiom s2750 (x : Prop) : f (g2751 x) = f (g2750 x)
@[simp] axiom s2751 (x : Prop) : f (g2752 x) = f (g2751 x)
@[simp] axiom s2752 (x : Prop) : f (g2753 x) = f (g2752 x)
@[simp] axiom s2753 (x : Prop) : f (g2754 x) = f (g2753 x)
@[simp] axiom s2754 (x : Prop) : f (g2755 x) = f (g2754 x)
@[simp] axiom s2755 (x : Prop) : f (g2756 x) = f (g2755 x)
@[simp] axiom s2756 (x : Prop) : f (g2757 x) = f (g2756 x)
@[simp] axiom s2757 (x : Prop) : f (g2758 x) = f (g2757 x)
@[simp] axiom s2758 (x : Prop) : f (g2759 x) = f (g2758 x)
@[simp] axiom s2759 (x : Prop) : f (g2760 x) = f (g2759 x)
@[simp] axiom s2760 (x : Prop) : f (g2761 x) = f (g2760 x)
@[simp] axiom s2761 (x : Prop) : f (g2762 x) = f (g2761 x)
@[simp] axiom s2762 (x : Prop) : f (g2763 x) = f (g2762 x)
@[simp] axiom s2763 (x : Prop) : f (g2764 x) = f (g2763 x)
@[simp] axiom s2764 (x : Prop) : f (g2765 x) = f (g2764 x)
@[simp] axiom s2765 (x : Prop) : f (g2766 x) = f (g2765 x)
@[simp] axiom s2766 (x : Prop) : f (g2767 x) = f (g2766 x)
@[simp] axiom s2767 (x : Prop) : f (g2768 x) = f (g2767 x)
@[simp] axiom s2768 (x : Prop) : f (g2769 x) = f (g2768 x)
@[simp] axiom s2769 (x : Prop) : f (g2770 x) = f (g2769 x)
@[simp] axiom s2770 (x : Prop) : f (g2771 x) = f (g2770 x)
@[simp] axiom s2771 (x : Prop) : f (g2772 x) = f (g2771 x)
@[simp] axiom s2772 (x : Prop) : f (g2773 x) = f (g2772 x)
@[simp] axiom s2773 (x : Prop) : f (g2774 x) = f (g2773 x)
@[simp] axiom s2774 (x : Prop) : f (g2775 x) = f (g2774 x)
@[simp] axiom s2775 (x : Prop) : f (g2776 x) = f (g2775 x)
@[simp] axiom s2776 (x : Prop) : f (g2777 x) = f (g2776 x)
@[simp] axiom s2777 (x : Prop) : f (g2778 x) = f (g2777 x)
@[simp] axiom s2778 (x : Prop) : f (g2779 x) = f (g2778 x)
@[simp] axiom s2779 (x : Prop) : f (g2780 x) = f (g2779 x)
@[simp] axiom s2780 (x : Prop) : f (g2781 x) = f (g2780 x)
@[simp] axiom s2781 (x : Prop) : f (g2782 x) = f (g2781 x)
@[simp] axiom s2782 (x : Prop) : f (g2783 x) = f (g2782 x)
@[simp] axiom s2783 (x : Prop) : f (g2784 x) = f (g2783 x)
@[simp] axiom s2784 (x : Prop) : f (g2785 x) = f (g2784 x)
@[simp] axiom s2785 (x : Prop) : f (g2786 x) = f (g2785 x)
@[simp] axiom s2786 (x : Prop) : f (g2787 x) = f (g2786 x)
@[simp] axiom s2787 (x : Prop) : f (g2788 x) = f (g2787 x)
@[simp] axiom s2788 (x : Prop) : f (g2789 x) = f (g2788 x)
@[simp] axiom s2789 (x : Prop) : f (g2790 x) = f (g2789 x)
@[simp] axiom s2790 (x : Prop) : f (g2791 x) = f (g2790 x)
@[simp] axiom s2791 (x : Prop) : f (g2792 x) = f (g2791 x)
@[simp] axiom s2792 (x : Prop) : f (g2793 x) = f (g2792 x)
@[simp] axiom s2793 (x : Prop) : f (g2794 x) = f (g2793 x)
@[simp] axiom s2794 (x : Prop) : f (g2795 x) = f (g2794 x)
@[simp] axiom s2795 (x : Prop) : f (g2796 x) = f (g2795 x)
@[simp] axiom s2796 (x : Prop) : f (g2797 x) = f (g2796 x)
@[simp] axiom s2797 (x : Prop) : f (g2798 x) = f (g2797 x)
@[simp] axiom s2798 (x : Prop) : f (g2799 x) = f (g2798 x)
@[simp] axiom s2799 (x : Prop) : f (g2800 x) = f (g2799 x)
@[simp] axiom s2800 (x : Prop) : f (g2801 x) = f (g2800 x)
@[simp] axiom s2801 (x : Prop) : f (g2802 x) = f (g2801 x)
@[simp] axiom s2802 (x : Prop) : f (g2803 x) = f (g2802 x)
@[simp] axiom s2803 (x : Prop) : f (g2804 x) = f (g2803 x)
@[simp] axiom s2804 (x : Prop) : f (g2805 x) = f (g2804 x)
@[simp] axiom s2805 (x : Prop) : f (g2806 x) = f (g2805 x)
@[simp] axiom s2806 (x : Prop) : f (g2807 x) = f (g2806 x)
@[simp] axiom s2807 (x : Prop) : f (g2808 x) = f (g2807 x)
@[simp] axiom s2808 (x : Prop) : f (g2809 x) = f (g2808 x)
@[simp] axiom s2809 (x : Prop) : f (g2810 x) = f (g2809 x)
@[simp] axiom s2810 (x : Prop) : f (g2811 x) = f (g2810 x)
@[simp] axiom s2811 (x : Prop) : f (g2812 x) = f (g2811 x)
@[simp] axiom s2812 (x : Prop) : f (g2813 x) = f (g2812 x)
@[simp] axiom s2813 (x : Prop) : f (g2814 x) = f (g2813 x)
@[simp] axiom s2814 (x : Prop) : f (g2815 x) = f (g2814 x)
@[simp] axiom s2815 (x : Prop) : f (g2816 x) = f (g2815 x)
@[simp] axiom s2816 (x : Prop) : f (g2817 x) = f (g2816 x)
@[simp] axiom s2817 (x : Prop) : f (g2818 x) = f (g2817 x)
@[simp] axiom s2818 (x : Prop) : f (g2819 x) = f (g2818 x)
@[simp] axiom s2819 (x : Prop) : f (g2820 x) = f (g2819 x)
@[simp] axiom s2820 (x : Prop) : f (g2821 x) = f (g2820 x)
@[simp] axiom s2821 (x : Prop) : f (g2822 x) = f (g2821 x)
@[simp] axiom s2822 (x : Prop) : f (g2823 x) = f (g2822 x)
@[simp] axiom s2823 (x : Prop) : f (g2824 x) = f (g2823 x)
@[simp] axiom s2824 (x : Prop) : f (g2825 x) = f (g2824 x)
@[simp] axiom s2825 (x : Prop) : f (g2826 x) = f (g2825 x)
@[simp] axiom s2826 (x : Prop) : f (g2827 x) = f (g2826 x)
@[simp] axiom s2827 (x : Prop) : f (g2828 x) = f (g2827 x)
@[simp] axiom s2828 (x : Prop) : f (g2829 x) = f (g2828 x)
@[simp] axiom s2829 (x : Prop) : f (g2830 x) = f (g2829 x)
@[simp] axiom s2830 (x : Prop) : f (g2831 x) = f (g2830 x)
@[simp] axiom s2831 (x : Prop) : f (g2832 x) = f (g2831 x)
@[simp] axiom s2832 (x : Prop) : f (g2833 x) = f (g2832 x)
@[simp] axiom s2833 (x : Prop) : f (g2834 x) = f (g2833 x)
@[simp] axiom s2834 (x : Prop) : f (g2835 x) = f (g2834 x)
@[simp] axiom s2835 (x : Prop) : f (g2836 x) = f (g2835 x)
@[simp] axiom s2836 (x : Prop) : f (g2837 x) = f (g2836 x)
@[simp] axiom s2837 (x : Prop) : f (g2838 x) = f (g2837 x)
@[simp] axiom s2838 (x : Prop) : f (g2839 x) = f (g2838 x)
@[simp] axiom s2839 (x : Prop) : f (g2840 x) = f (g2839 x)
@[simp] axiom s2840 (x : Prop) : f (g2841 x) = f (g2840 x)
@[simp] axiom s2841 (x : Prop) : f (g2842 x) = f (g2841 x)
@[simp] axiom s2842 (x : Prop) : f (g2843 x) = f (g2842 x)
@[simp] axiom s2843 (x : Prop) : f (g2844 x) = f (g2843 x)
@[simp] axiom s2844 (x : Prop) : f (g2845 x) = f (g2844 x)
@[simp] axiom s2845 (x : Prop) : f (g2846 x) = f (g2845 x)
@[simp] axiom s2846 (x : Prop) : f (g2847 x) = f (g2846 x)
@[simp] axiom s2847 (x : Prop) : f (g2848 x) = f (g2847 x)
@[simp] axiom s2848 (x : Prop) : f (g2849 x) = f (g2848 x)
@[simp] axiom s2849 (x : Prop) : f (g2850 x) = f (g2849 x)
@[simp] axiom s2850 (x : Prop) : f (g2851 x) = f (g2850 x)
@[simp] axiom s2851 (x : Prop) : f (g2852 x) = f (g2851 x)
@[simp] axiom s2852 (x : Prop) : f (g2853 x) = f (g2852 x)
@[simp] axiom s2853 (x : Prop) : f (g2854 x) = f (g2853 x)
@[simp] axiom s2854 (x : Prop) : f (g2855 x) = f (g2854 x)
@[simp] axiom s2855 (x : Prop) : f (g2856 x) = f (g2855 x)
@[simp] axiom s2856 (x : Prop) : f (g2857 x) = f (g2856 x)
@[simp] axiom s2857 (x : Prop) : f (g2858 x) = f (g2857 x)
@[simp] axiom s2858 (x : Prop) : f (g2859 x) = f (g2858 x)
@[simp] axiom s2859 (x : Prop) : f (g2860 x) = f (g2859 x)
@[simp] axiom s2860 (x : Prop) : f (g2861 x) = f (g2860 x)
@[simp] axiom s2861 (x : Prop) : f (g2862 x) = f (g2861 x)
@[simp] axiom s2862 (x : Prop) : f (g2863 x) = f (g2862 x)
@[simp] axiom s2863 (x : Prop) : f (g2864 x) = f (g2863 x)
@[simp] axiom s2864 (x : Prop) : f (g2865 x) = f (g2864 x)
@[simp] axiom s2865 (x : Prop) : f (g2866 x) = f (g2865 x)
@[simp] axiom s2866 (x : Prop) : f (g2867 x) = f (g2866 x)
@[simp] axiom s2867 (x : Prop) : f (g2868 x) = f (g2867 x)
@[simp] axiom s2868 (x : Prop) : f (g2869 x) = f (g2868 x)
@[simp] axiom s2869 (x : Prop) : f (g2870 x) = f (g2869 x)
@[simp] axiom s2870 (x : Prop) : f (g2871 x) = f (g2870 x)
@[simp] axiom s2871 (x : Prop) : f (g2872 x) = f (g2871 x)
@[simp] axiom s2872 (x : Prop) : f (g2873 x) = f (g2872 x)
@[simp] axiom s2873 (x : Prop) : f (g2874 x) = f (g2873 x)
@[simp] axiom s2874 (x : Prop) : f (g2875 x) = f (g2874 x)
@[simp] axiom s2875 (x : Prop) : f (g2876 x) = f (g2875 x)
@[simp] axiom s2876 (x : Prop) : f (g2877 x) = f (g2876 x)
@[simp] axiom s2877 (x : Prop) : f (g2878 x) = f (g2877 x)
@[simp] axiom s2878 (x : Prop) : f (g2879 x) = f (g2878 x)
@[simp] axiom s2879 (x : Prop) : f (g2880 x) = f (g2879 x)
@[simp] axiom s2880 (x : Prop) : f (g2881 x) = f (g2880 x)
@[simp] axiom s2881 (x : Prop) : f (g2882 x) = f (g2881 x)
@[simp] axiom s2882 (x : Prop) : f (g2883 x) = f (g2882 x)
@[simp] axiom s2883 (x : Prop) : f (g2884 x) = f (g2883 x)
@[simp] axiom s2884 (x : Prop) : f (g2885 x) = f (g2884 x)
@[simp] axiom s2885 (x : Prop) : f (g2886 x) = f (g2885 x)
@[simp] axiom s2886 (x : Prop) : f (g2887 x) = f (g2886 x)
@[simp] axiom s2887 (x : Prop) : f (g2888 x) = f (g2887 x)
@[simp] axiom s2888 (x : Prop) : f (g2889 x) = f (g2888 x)
@[simp] axiom s2889 (x : Prop) : f (g2890 x) = f (g2889 x)
@[simp] axiom s2890 (x : Prop) : f (g2891 x) = f (g2890 x)
@[simp] axiom s2891 (x : Prop) : f (g2892 x) = f (g2891 x)
@[simp] axiom s2892 (x : Prop) : f (g2893 x) = f (g2892 x)
@[simp] axiom s2893 (x : Prop) : f (g2894 x) = f (g2893 x)
@[simp] axiom s2894 (x : Prop) : f (g2895 x) = f (g2894 x)
@[simp] axiom s2895 (x : Prop) : f (g2896 x) = f (g2895 x)
@[simp] axiom s2896 (x : Prop) : f (g2897 x) = f (g2896 x)
@[simp] axiom s2897 (x : Prop) : f (g2898 x) = f (g2897 x)
@[simp] axiom s2898 (x : Prop) : f (g2899 x) = f (g2898 x)
@[simp] axiom s2899 (x : Prop) : f (g2900 x) = f (g2899 x)
@[simp] axiom s2900 (x : Prop) : f (g2901 x) = f (g2900 x)
@[simp] axiom s2901 (x : Prop) : f (g2902 x) = f (g2901 x)
@[simp] axiom s2902 (x : Prop) : f (g2903 x) = f (g2902 x)
@[simp] axiom s2903 (x : Prop) : f (g2904 x) = f (g2903 x)
@[simp] axiom s2904 (x : Prop) : f (g2905 x) = f (g2904 x)
@[simp] axiom s2905 (x : Prop) : f (g2906 x) = f (g2905 x)
@[simp] axiom s2906 (x : Prop) : f (g2907 x) = f (g2906 x)
@[simp] axiom s2907 (x : Prop) : f (g2908 x) = f (g2907 x)
@[simp] axiom s2908 (x : Prop) : f (g2909 x) = f (g2908 x)
@[simp] axiom s2909 (x : Prop) : f (g2910 x) = f (g2909 x)
@[simp] axiom s2910 (x : Prop) : f (g2911 x) = f (g2910 x)
@[simp] axiom s2911 (x : Prop) : f (g2912 x) = f (g2911 x)
@[simp] axiom s2912 (x : Prop) : f (g2913 x) = f (g2912 x)
@[simp] axiom s2913 (x : Prop) : f (g2914 x) = f (g2913 x)
@[simp] axiom s2914 (x : Prop) : f (g2915 x) = f (g2914 x)
@[simp] axiom s2915 (x : Prop) : f (g2916 x) = f (g2915 x)
@[simp] axiom s2916 (x : Prop) : f (g2917 x) = f (g2916 x)
@[simp] axiom s2917 (x : Prop) : f (g2918 x) = f (g2917 x)
@[simp] axiom s2918 (x : Prop) : f (g2919 x) = f (g2918 x)
@[simp] axiom s2919 (x : Prop) : f (g2920 x) = f (g2919 x)
@[simp] axiom s2920 (x : Prop) : f (g2921 x) = f (g2920 x)
@[simp] axiom s2921 (x : Prop) : f (g2922 x) = f (g2921 x)
@[simp] axiom s2922 (x : Prop) : f (g2923 x) = f (g2922 x)
@[simp] axiom s2923 (x : Prop) : f (g2924 x) = f (g2923 x)
@[simp] axiom s2924 (x : Prop) : f (g2925 x) = f (g2924 x)
@[simp] axiom s2925 (x : Prop) : f (g2926 x) = f (g2925 x)
@[simp] axiom s2926 (x : Prop) : f (g2927 x) = f (g2926 x)
@[simp] axiom s2927 (x : Prop) : f (g2928 x) = f (g2927 x)
@[simp] axiom s2928 (x : Prop) : f (g2929 x) = f (g2928 x)
@[simp] axiom s2929 (x : Prop) : f (g2930 x) = f (g2929 x)
@[simp] axiom s2930 (x : Prop) : f (g2931 x) = f (g2930 x)
@[simp] axiom s2931 (x : Prop) : f (g2932 x) = f (g2931 x)
@[simp] axiom s2932 (x : Prop) : f (g2933 x) = f (g2932 x)
@[simp] axiom s2933 (x : Prop) : f (g2934 x) = f (g2933 x)
@[simp] axiom s2934 (x : Prop) : f (g2935 x) = f (g2934 x)
@[simp] axiom s2935 (x : Prop) : f (g2936 x) = f (g2935 x)
@[simp] axiom s2936 (x : Prop) : f (g2937 x) = f (g2936 x)
@[simp] axiom s2937 (x : Prop) : f (g2938 x) = f (g2937 x)
@[simp] axiom s2938 (x : Prop) : f (g2939 x) = f (g2938 x)
@[simp] axiom s2939 (x : Prop) : f (g2940 x) = f (g2939 x)
@[simp] axiom s2940 (x : Prop) : f (g2941 x) = f (g2940 x)
@[simp] axiom s2941 (x : Prop) : f (g2942 x) = f (g2941 x)
@[simp] axiom s2942 (x : Prop) : f (g2943 x) = f (g2942 x)
@[simp] axiom s2943 (x : Prop) : f (g2944 x) = f (g2943 x)
@[simp] axiom s2944 (x : Prop) : f (g2945 x) = f (g2944 x)
@[simp] axiom s2945 (x : Prop) : f (g2946 x) = f (g2945 x)
@[simp] axiom s2946 (x : Prop) : f (g2947 x) = f (g2946 x)
@[simp] axiom s2947 (x : Prop) : f (g2948 x) = f (g2947 x)
@[simp] axiom s2948 (x : Prop) : f (g2949 x) = f (g2948 x)
@[simp] axiom s2949 (x : Prop) : f (g2950 x) = f (g2949 x)
@[simp] axiom s2950 (x : Prop) : f (g2951 x) = f (g2950 x)
@[simp] axiom s2951 (x : Prop) : f (g2952 x) = f (g2951 x)
@[simp] axiom s2952 (x : Prop) : f (g2953 x) = f (g2952 x)
@[simp] axiom s2953 (x : Prop) : f (g2954 x) = f (g2953 x)
@[simp] axiom s2954 (x : Prop) : f (g2955 x) = f (g2954 x)
@[simp] axiom s2955 (x : Prop) : f (g2956 x) = f (g2955 x)
@[simp] axiom s2956 (x : Prop) : f (g2957 x) = f (g2956 x)
@[simp] axiom s2957 (x : Prop) : f (g2958 x) = f (g2957 x)
@[simp] axiom s2958 (x : Prop) : f (g2959 x) = f (g2958 x)
@[simp] axiom s2959 (x : Prop) : f (g2960 x) = f (g2959 x)
@[simp] axiom s2960 (x : Prop) : f (g2961 x) = f (g2960 x)
@[simp] axiom s2961 (x : Prop) : f (g2962 x) = f (g2961 x)
@[simp] axiom s2962 (x : Prop) : f (g2963 x) = f (g2962 x)
@[simp] axiom s2963 (x : Prop) : f (g2964 x) = f (g2963 x)
@[simp] axiom s2964 (x : Prop) : f (g2965 x) = f (g2964 x)
@[simp] axiom s2965 (x : Prop) : f (g2966 x) = f (g2965 x)
@[simp] axiom s2966 (x : Prop) : f (g2967 x) = f (g2966 x)
@[simp] axiom s2967 (x : Prop) : f (g2968 x) = f (g2967 x)
@[simp] axiom s2968 (x : Prop) : f (g2969 x) = f (g2968 x)
@[simp] axiom s2969 (x : Prop) : f (g2970 x) = f (g2969 x)
@[simp] axiom s2970 (x : Prop) : f (g2971 x) = f (g2970 x)
@[simp] axiom s2971 (x : Prop) : f (g2972 x) = f (g2971 x)
@[simp] axiom s2972 (x : Prop) : f (g2973 x) = f (g2972 x)
@[simp] axiom s2973 (x : Prop) : f (g2974 x) = f (g2973 x)
@[simp] axiom s2974 (x : Prop) : f (g2975 x) = f (g2974 x)
@[simp] axiom s2975 (x : Prop) : f (g2976 x) = f (g2975 x)
@[simp] axiom s2976 (x : Prop) : f (g2977 x) = f (g2976 x)
@[simp] axiom s2977 (x : Prop) : f (g2978 x) = f (g2977 x)
@[simp] axiom s2978 (x : Prop) : f (g2979 x) = f (g2978 x)
@[simp] axiom s2979 (x : Prop) : f (g2980 x) = f (g2979 x)
@[simp] axiom s2980 (x : Prop) : f (g2981 x) = f (g2980 x)
@[simp] axiom s2981 (x : Prop) : f (g2982 x) = f (g2981 x)
@[simp] axiom s2982 (x : Prop) : f (g2983 x) = f (g2982 x)
@[simp] axiom s2983 (x : Prop) : f (g2984 x) = f (g2983 x)
@[simp] axiom s2984 (x : Prop) : f (g2985 x) = f (g2984 x)
@[simp] axiom s2985 (x : Prop) : f (g2986 x) = f (g2985 x)
@[simp] axiom s2986 (x : Prop) : f (g2987 x) = f (g2986 x)
@[simp] axiom s2987 (x : Prop) : f (g2988 x) = f (g2987 x)
@[simp] axiom s2988 (x : Prop) : f (g2989 x) = f (g2988 x)
@[simp] axiom s2989 (x : Prop) : f (g2990 x) = f (g2989 x)
@[simp] axiom s2990 (x : Prop) : f (g2991 x) = f (g2990 x)
@[simp] axiom s2991 (x : Prop) : f (g2992 x) = f (g2991 x)
@[simp] axiom s2992 (x : Prop) : f (g2993 x) = f (g2992 x)
@[simp] axiom s2993 (x : Prop) : f (g2994 x) = f (g2993 x)
@[simp] axiom s2994 (x : Prop) : f (g2995 x) = f (g2994 x)
@[simp] axiom s2995 (x : Prop) : f (g2996 x) = f (g2995 x)
@[simp] axiom s2996 (x : Prop) : f (g2997 x) = f (g2996 x)
@[simp] axiom s2997 (x : Prop) : f (g2998 x) = f (g2997 x)
@[simp] axiom s2998 (x : Prop) : f (g2999 x) = f (g2998 x)
|
abf6243a1af34ab9468365b4e1d8f412c7da41b6 | bdb33f8b7ea65f7705fc342a178508e2722eb851 | /data/analysis/topology.lean | 63ecb3015265123b89825b8dbf70bb792fdb250e | [
"Apache-2.0"
] | permissive | rwbarton/mathlib | 939ae09bf8d6eb1331fc2f7e067d39567e10e33d | c13c5ea701bb1eec057e0a242d9f480a079105e9 | refs/heads/master | 1,584,015,335,862 | 1,524,142,167,000 | 1,524,142,167,000 | 130,614,171 | 0 | 0 | Apache-2.0 | 1,548,902,667,000 | 1,524,437,371,000 | Lean | UTF-8 | Lean | false | false | 8,440 | lean | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
Computational realization of topological spaces (experimental).
-/
import analysis.topology.topological_space data.analysis.filter
open set
open filter (hiding realizer)
/-- A `ctop α σ` is a realization of a topology (basis) on `α`,
represented by a type `σ` together with operations for the top element and
the intersection operation. -/
structure ctop (α σ : Type*) :=
(f : σ → set α)
(top : α → σ)
(top_mem : ∀ x : α, x ∈ f (top x))
(inter : Π a b (x : α), x ∈ f a ∩ f b → σ)
(inter_mem : ∀ a b x h, x ∈ f (inter a b x h))
(inter_sub : ∀ a b x h, f (inter a b x h) ⊆ f a ∩ f b)
variables {α : Type*} {β : Type*} {σ : Type*} {τ : Type*}
namespace ctop
section
variables (F : ctop α σ)
instance : has_coe_to_fun (ctop α σ) := ⟨_, ctop.f⟩
@[simp] theorem coe_mk (f T h₁ I h₂ h₃ a) : (@ctop.mk α σ f T h₁ I h₂ h₃) a = f a := rfl
/-- Map a ctop to an equivalent representation type. -/
def of_equiv (E : σ ≃ τ) : ctop α σ → ctop α τ
| ⟨f, T, h₁, I, h₂, h₃⟩ :=
{ f := λ a, f (E.symm a),
top := λ x, E (T x),
top_mem := λ x, by simpa using h₁ x,
inter := λ a b x h, E (I (E.symm a) (E.symm b) x h),
inter_mem := λ a b x h, by simpa using h₂ (E.symm a) (E.symm b) x h,
inter_sub := λ a b x h, by simpa using h₃ (E.symm a) (E.symm b) x h }
@[simp] theorem of_equiv_val (E : σ ≃ τ) (F : ctop α σ) (a : τ) :
F.of_equiv E a = F (E.symm a) := by cases F; refl
end
instance to_topsp (F : ctop α σ) : topological_space α :=
topological_space.generate_from (set.range F.f)
theorem to_topsp_is_topological_basis (F : ctop α σ) :
@topological_space.is_topological_basis _ F.to_topsp (set.range F.f) :=
⟨λ u ⟨a, e₁⟩ v ⟨b, e₂⟩, e₁ ▸ e₂ ▸
λ x h, ⟨_, ⟨_, rfl⟩, F.inter_mem a b x h, F.inter_sub a b x h⟩,
eq_univ_iff_forall.2 $ λ x, ⟨_, ⟨_, rfl⟩, F.top_mem x⟩, rfl⟩
@[simp] theorem mem_nhds_to_topsp (F : ctop α σ) {s : set α} {a : α} :
s ∈ (@nhds _ F.to_topsp a).sets ↔ ∃ b, a ∈ F b ∧ F b ⊆ s :=
(@topological_space.mem_nhds_of_is_topological_basis
_ F.to_topsp _ _ _ F.to_topsp_is_topological_basis).trans $
⟨λ ⟨_, ⟨x, rfl⟩, h⟩, ⟨x, h⟩, λ ⟨x, h⟩, ⟨_, ⟨x, rfl⟩, h⟩⟩
end ctop
/-- A `ctop` realizer for the topological space `T` is a `ctop`
which generates `T`. -/
structure ctop.realizer (α) [T : topological_space α] :=
(σ : Type*)
(F : ctop α σ)
(eq : F.to_topsp = T)
open ctop
protected def ctop.to_realizer (F : ctop α σ) : @ctop.realizer _ F.to_topsp :=
@ctop.realizer.mk _ F.to_topsp σ F rfl
namespace ctop.realizer
protected theorem is_basis [T : topological_space α] (F : realizer α) :
topological_space.is_topological_basis (set.range F.F.f) :=
by have := to_topsp_is_topological_basis F.F; rwa F.eq at this
protected theorem mem_nhds [T : topological_space α] (F : realizer α) {s : set α} {a : α} :
s ∈ (nhds a).sets ↔ ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=
by have := mem_nhds_to_topsp F.F; rwa F.eq at this
theorem is_open_iff [topological_space α] (F : realizer α) {s : set α} :
is_open s ↔ ∀ a ∈ s, ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=
is_open_iff_mem_nhds.trans $ ball_congr $ λ a h, F.mem_nhds
theorem is_closed_iff [topological_space α] (F : realizer α) {s : set α} :
is_closed s ↔ ∀ a, (∀ b, a ∈ F.F b → ∃ z, z ∈ F.F b ∩ s) → a ∈ s :=
F.is_open_iff.trans $ forall_congr $ λ a,
show (a ∉ s → (∃ (b : F.σ), a ∈ F.F b ∧ ∀ z ∈ F.F b, z ∉ s)) ↔ _,
by haveI := classical.prop_decidable; rw [not_imp_comm];
simp [not_exists, not_and, not_forall, and_comm]
theorem mem_interior_iff [topological_space α] (F : realizer α) {s : set α} {a : α} :
a ∈ interior s ↔ ∃ b, a ∈ F.F b ∧ F.F b ⊆ s :=
mem_interior_iff_mem_nhds.trans F.mem_nhds
protected theorem is_open [topological_space α] (F : realizer α) (s : F.σ) : is_open (F.F s) :=
is_open_iff_nhds.2 $ λ a m, by simpa using F.mem_nhds.2 ⟨s, m, subset.refl _⟩
theorem ext' [T : topological_space α] {σ : Type*} {F : ctop α σ}
(H : ∀ a s, s ∈ (nhds a).sets ↔ ∃ b, a ∈ F b ∧ F b ⊆ s) :
F.to_topsp = T :=
topological_space_eq $ funext $ λ s, begin
have : ∀ T s, @topological_space.is_open _ T s ↔ _ := @is_open_iff_mem_nhds α,
rw [this, this],
apply congr_arg (λ f : α → filter α, ∀ a ∈ s, s ∈ (f a).sets),
funext a, apply filter_eq, apply set.ext, intro x,
rw [mem_nhds_to_topsp, H]
end
theorem ext [T : topological_space α] {σ : Type*} {F : ctop α σ}
(H₁ : ∀ a, is_open (F a))
(H₂ : ∀ a s, s ∈ (nhds a).sets → ∃ b, a ∈ F b ∧ F b ⊆ s) :
F.to_topsp = T :=
ext' $ λ a s, ⟨H₂ a s, λ ⟨b, h₁, h₂⟩, mem_nhds_sets_iff.2 ⟨_, h₂, H₁ _, h₁⟩⟩
variable [topological_space α]
protected def id : realizer α := ⟨{x:set α // is_open x},
{ f := subtype.val,
top := λ _, ⟨univ, is_open_univ⟩,
top_mem := mem_univ,
inter := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a h₃, ⟨_, is_open_inter h₁ h₂⟩,
inter_mem := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a, id,
inter_sub := λ ⟨x, h₁⟩ ⟨y, h₂⟩ a h₃, subset.refl _ },
ext subtype.property $ λ x s h,
let ⟨t, h, o, m⟩ := mem_nhds_sets_iff.1 h in ⟨⟨t, o⟩, m, h⟩⟩
def of_equiv (F : realizer α) (E : F.σ ≃ τ) : realizer α :=
⟨τ, F.F.of_equiv E, ext' (λ a s, F.mem_nhds.trans $
⟨λ ⟨s, h⟩, ⟨E s, by simpa using h⟩, λ ⟨t, h⟩, ⟨E.symm t, by simpa using h⟩⟩)⟩
@[simp] theorem of_equiv_σ (F : realizer α) (E : F.σ ≃ τ) : (F.of_equiv E).σ = τ := rfl
@[simp] theorem of_equiv_F (F : realizer α) (E : F.σ ≃ τ) (s : τ) :
(F.of_equiv E).F s = F.F (E.symm s) := by delta of_equiv; simp
protected def nhds (F : realizer α) (a : α) : (nhds a).realizer :=
⟨{s : F.σ // a ∈ F.F s},
{ f := λ s, F.F s.1,
pt := ⟨_, F.F.top_mem a⟩,
inf := λ ⟨x, h₁⟩ ⟨y, h₂⟩, ⟨_, F.F.inter_mem x y a ⟨h₁, h₂⟩⟩,
inf_le_left := λ ⟨x, h₁⟩ ⟨y, h₂⟩ z h, (F.F.inter_sub x y a ⟨h₁, h₂⟩ h).1,
inf_le_right := λ ⟨x, h₁⟩ ⟨y, h₂⟩ z h, (F.F.inter_sub x y a ⟨h₁, h₂⟩ h).2 },
filter_eq $ set.ext $ λ x,
⟨λ ⟨⟨s, as⟩, h⟩, mem_nhds_sets_iff.2 ⟨_, h, F.is_open _, as⟩,
λ h, let ⟨s, h, as⟩ := F.mem_nhds.1 h in ⟨⟨s, h⟩, as⟩⟩⟩
@[simp] theorem nhds_σ (m : α → β) (F : realizer α) (a : α) :
(F.nhds a).σ = {s : F.σ // a ∈ F.F s} := rfl
@[simp] theorem nhds_F (m : α → β) (F : realizer α) (a : α) (s) :
(F.nhds a).F s = F.F s.1 := rfl
theorem tendsto_nhds_iff {m : β → α} {f : filter β} (F : f.realizer) (R : realizer α) {a : α} :
tendsto m f (nhds a) ↔ ∀ t, a ∈ R.F t → ∃ s, ∀ x ∈ F.F s, m x ∈ R.F t :=
(F.tendsto_iff _ (R.nhds a)).trans subtype.forall
end ctop.realizer
structure locally_finite.realizer [topological_space α] (F : realizer α) (f : β → set α) :=
(bas : ∀ a, {s // a ∈ F.F s})
(sets : ∀ x:α, fintype {i | f i ∩ F.F (bas x) ≠ ∅})
theorem locally_finite.realizer.to_locally_finite [topological_space α]
{F : realizer α} {f : β → set α} (R : locally_finite.realizer F f) :
locally_finite f :=
λ a, ⟨_, F.mem_nhds.2
⟨(R.bas a).1, (R.bas a).2, subset.refl _⟩, ⟨R.sets a⟩⟩
theorem locally_finite_iff_exists_realizer [topological_space α]
(F : realizer α) {f : β → set α} : locally_finite f ↔ nonempty (locally_finite.realizer F f) :=
⟨λ h, let ⟨g, h₁⟩ := classical.axiom_of_choice h,
⟨g₂, h₂⟩ := classical.axiom_of_choice (λ x,
show ∃ (b : F.σ), x ∈ (F.F) b ∧ (F.F) b ⊆ g x, from
let ⟨h, h'⟩ := h₁ x in F.mem_nhds.1 h) in
⟨⟨λ x, ⟨g₂ x, (h₂ x).1⟩, λ x, finite.fintype $
let ⟨h, h'⟩ := h₁ x in finite_subset h' $ λ i,
subset_ne_empty (inter_subset_inter_left _ (h₂ x).2)⟩⟩,
λ ⟨R⟩, R.to_locally_finite⟩
def compact.realizer [topological_space α] (R : realizer α) (s : set α) :=
∀ {f : filter α} (F : f.realizer) (x : F.σ), f ≠ ⊥ →
F.F x ⊆ s → {a // a∈s ∧ nhds a ⊓ f ≠ ⊥}
|
33b028b1be31e87581b4c75d23605505233edbed | 6ad8da447296224074f89883744bc6a4752b6ea3 | /TestPkg1.lean | cf62532b342493c0f1d045dcca1bf1fb96c5a1e1 | [] | no_license | Kha/testpkg1 | e2cec4151b2aac878e97a7e7b77a06096d681f30 | ba955dd1023013686e4c5a7ed78344b7a5891e6a | refs/heads/master | 1,674,396,169,083 | 1,606,925,138,000 | 1,606,925,138,000 | 317,916,288 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 23 | lean | def subject := "world"
|
731081e2bfae3697ae42cd46f3e1e7db9bb2ac3b | 57aec6ee746bc7e3a3dd5e767e53bd95beb82f6d | /src/Lean/Server/FileSource.lean | 755f49127cd93602f57edd8cc23191a6d25781d2 | [
"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 | 2,827 | lean | /-
Copyright (c) 2020 Marc Huisinga. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Marc Huisinga
-/
import Lean.Data.Lsp
namespace Lean
namespace Lsp
class FileSource (α : Type) where
fileSource : α → DocumentUri
export FileSource (fileSource)
instance Location.hasFileSource : FileSource Location :=
⟨fun l => l.uri⟩
instance TextDocumentIdentifier.hasFileSource : FileSource TextDocumentIdentifier :=
⟨fun i => i.uri⟩
instance VersionedTextDocumentIdentifier.hasFileSource : FileSource VersionedTextDocumentIdentifier :=
⟨fun i => i.uri⟩
instance TextDocumentEdit.hasFileSource : FileSource TextDocumentEdit :=
⟨fun e => fileSource e.textDocument⟩
instance TextDocumentItem.hasFileSource : FileSource TextDocumentItem :=
⟨fun i => i.uri⟩
instance TextDocumentPositionParams.hasFileSource : FileSource TextDocumentPositionParams :=
⟨fun p => fileSource p.textDocument⟩
instance DidOpenTextDocumentParams.hasFileSource : FileSource DidOpenTextDocumentParams :=
⟨fun p => fileSource p.textDocument⟩
instance DidChangeTextDocumentParams.hasFileSource : FileSource DidChangeTextDocumentParams :=
⟨fun p => fileSource p.textDocument⟩
instance DidCloseTextDocumentParams.hasFileSource : FileSource DidCloseTextDocumentParams :=
⟨fun p => fileSource p.textDocument⟩
instance CompletionParams.hasFileSource : FileSource CompletionParams :=
⟨fun h => fileSource h.toTextDocumentPositionParams⟩
instance HoverParams.hasFileSource : FileSource HoverParams :=
⟨fun h => fileSource h.toTextDocumentPositionParams⟩
instance DeclarationParams.hasFileSource : FileSource DeclarationParams :=
⟨fun h => fileSource h.toTextDocumentPositionParams⟩
instance DefinitionParams.hasFileSource : FileSource DefinitionParams :=
⟨fun h => fileSource h.toTextDocumentPositionParams⟩
instance TypeDefinitionParams.hasFileSource : FileSource TypeDefinitionParams :=
⟨fun h => fileSource h.toTextDocumentPositionParams⟩
instance WaitForDiagnosticsParams.hasFileSource : FileSource WaitForDiagnosticsParams :=
⟨fun p => p.uri⟩
instance DocumentHighlightParams.hasFileSource : FileSource DocumentHighlightParams :=
⟨fun h => fileSource h.toTextDocumentPositionParams⟩
instance DocumentSymbolParams.hasFileSource : FileSource DocumentSymbolParams :=
⟨fun p => fileSource p.textDocument⟩
instance SemanticTokensParams.hasFileSource : FileSource SemanticTokensParams :=
⟨fun p => fileSource p.textDocument⟩
instance SemanticTokensRangeParams.hasFileSource : FileSource SemanticTokensRangeParams :=
⟨fun p => fileSource p.textDocument⟩
instance PlainGoalParams.hasFileSource : FileSource PlainGoalParams :=
⟨fun p => fileSource p.textDocument⟩
end Lsp
end Lean
|
2870de284fb98a3633e0ac1458a668eb89c62029 | 159fed64bfae88f3b6a6166836d6278f953bcbf9 | /Structure/Generic/Lemmas/CategoryTheoryLemmas.lean | 20367e11c98690451146a96dfb1eeef76e9e2910 | [
"MIT"
] | permissive | SReichelt/lean4-experiments | 3e56830c8b2fbe3814eda071c48e3c8810d254a8 | ff55357a01a34a91bf670d712637480089085ee4 | refs/heads/main | 1,683,977,454,907 | 1,622,991,121,000 | 1,622,991,121,000 | 340,765,677 | 2 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 17,081 | lean | #exit
import Structure.Generic.Axioms
import Structure.Generic.DerivedFunctors
import mathlib4_experiments.Data.Equiv.Basic
open GeneralizedRelation
set_option autoBoundImplicitLocal false
universes u v w
namespace GeneralizedProperty
def ConstProp (α : Sort u) {V : Universe} {β : V} (c : β) : GeneralizedProperty α V := λ _ => β
namespace ConstProp
variable (α : Sort u) {V : Universe} {β : V} (c : β)
instance hasInst : HasInst (ConstProp α c) := ⟨λ _ => c⟩
end ConstProp
end GeneralizedProperty
namespace GeneralizedRelation
def ConstRel (α : Sort u) {V : Universe} {β : V} (c : β) : GeneralizedRelation α V := λ _ _ => β
namespace ConstRel
variable (α : Sort u) {V : Universe} {β : V} (c : β)
instance hasRefl : HasRefl (ConstRel α c) := ⟨λ _ => c⟩
variable [HasInternalFunctors V] [HasAffineFunOp V]
instance hasSymm : HasSymm (ConstRel α c) := ⟨HasLinearFunOp.idFun β⟩
instance hasTrans : HasTrans (ConstRel α c) := ⟨HasAffineFunOp.constFun β (HasLinearFunOp.idFun β)⟩
instance isPreorder : IsPreorder (ConstRel α c) := ⟨⟩
instance isEquivalence : IsEquivalence (ConstRel α c) := ⟨⟩
@[simp] theorem symmEq {a₁ a₂ : α} : (hasSymm α c).symm' (a := a₁) (b := a₂) c = c :=
HasLinearFunOp.idFun.eff β c
@[simp] theorem transEq {a₁ a₂ a₃ : α} : (hasTrans α c).trans' (a := a₁) (b := a₂) (c := a₃) c c = c :=
let h₁ := congrArg HasInternalFunctors.funCoe (HasAffineFunOp.constFun.eff β (HasLinearFunOp.idFun β) c);
Eq.trans (congrFun h₁ c) (HasLinearFunOp.idFun.eff β c)
end ConstRel
end GeneralizedRelation
open GeneralizedRelation
-- TODO: Should we use actual abstract equivalence here?
structure Iff' {U : Universe} [HasInternalFunctors U] (α β : U) where
(mp : α ⟶ β)
(mpr : β ⟶ α)
infix:20 " ⟷' " => Iff'
section Morphisms
variable {α : Sort u} {U : Universe} [HasInternalFunctors U] [he : HasFunctorialEquivalences U]
[HasLinearFunOp he.equivUniverse] {R : GeneralizedRelation α U}
instance : HasFunctorialArrows U := HasFunctorialEquivalences.toHasFunctorialArrows U
open IsCompositionRelation
namespace IsCompositionRelation
variable [HasTrans R] [IsCompositionRelation R]
def comp_congrArg {a b c : α} {f₁ f₂ : R a b} {g₁ g₂ : R b c} : f₁ ≃ f₂ ⟶ g₁ ≃ g₂ ⟶ g₁ • f₁ ≃ g₂ • f₂ :=
he.equivCongr ⊙ HasFunctorialEquivalences.equiv_congrArg U HasTrans.trans
def comp_congrArg_left {a b c : α} {f : R a b} {g₁ g₂ : R b c} : g₁ ≃ g₂ ⟶ g₁ • f ≃ g₂ • f :=
HasFunctorialEquivalences.equiv_congrArg U (HasTrans.trans ⟮f⟯)
def comp_congrArg_right {a b c : α} {f₁ f₂ : R a b} {g : R b c} : f₁ ≃ f₂ ⟶ g • f₁ ≃ g • f₂ :=
HasLinearFunOp.swapFun comp_congrArg (HasRefl.refl g)
def comp_subst {a b c : α} {f₁ f₂ : R a b} {g₁ g₂ : R b c} {e : R a c} : f₁ ≃ f₂ ⟶ g₁ ≃ g₂ ⟶ g₂ • f₂ ≃ e ⟶ g₁ • f₁ ≃ e :=
HasLinearFunOp.compFun₂ comp_congrArg HasTrans.trans
def comp_subst' {a b c : α} {f₁ f₂ : R a b} {g₁ g₂ : R b c} {e : R a c} : f₁ ≃ f₂ ⟶ g₁ ≃ g₂ ⟶ e ≃ g₁ • f₁ ⟶ e ≃ g₂ • f₂ :=
HasLinearFunOp.compFun₂ comp_congrArg HasTrans.revTrans
def comp_subst_left {a b c : α} (f : R a b) {g₁ g₂ : R b c} {e : R a c} : g₁ ≃ g₂ ⟶ g₂ • f ≃ e ⟶ g₁ • f ≃ e :=
HasTrans.trans ⊙ comp_congrArg_left
def comp_subst_left' {a b c : α} (f : R a b) {g₁ g₂ : R b c} {e : R a c} : g₁ ≃ g₂ ⟶ e ≃ g₁ • f ⟶ e ≃ g₂ • f :=
HasTrans.revTrans ⊙ comp_congrArg_left
def comp_subst_right {a b c : α} {f₁ f₂ : R a b} (g : R b c) {e : R a c} : f₁ ≃ f₂ ⟶ g • f₂ ≃ e ⟶ g • f₁ ≃ e :=
HasTrans.trans ⊙ comp_congrArg_right
def comp_subst_right' {a b c : α} {f₁ f₂ : R a b} (g : R b c) {e : R a c} : f₁ ≃ f₂ ⟶ e ≃ g • f₁ ⟶ e ≃ g • f₂ :=
HasTrans.revTrans ⊙ comp_congrArg_right
def applyAssocLR_left {a b c d : α} {f : R a b} {g : R b c} {h : R c d} {e : R a d} : (h • g) • f ≃ e ⟶ h • (g • f) ≃ e :=
HasTrans.trans ⟮assocRL f g h⟯
def applyAssocRL_left {a b c d : α} {f : R a b} {g : R b c} {h : R c d} {e : R a d} : h • (g • f) ≃ e ⟶ (h • g) • f ≃ e :=
HasTrans.trans ⟮assocLR f g h⟯
def applyAssocLR_right {a b c d : α} {f : R a b} {g : R b c} {h : R c d} {e : R a d} : e ≃ (h • g) • f ⟶ e ≃ h • (g • f) :=
HasTrans.revTrans'' (assocLR f g h)
def applyAssocRL_right {a b c d : α} {f : R a b} {g : R b c} {h : R c d} {e : R a d} : e ≃ h • (g • f) ⟶ e ≃ (h • g) • f :=
HasTrans.revTrans'' (assocRL f g h)
def applyAssocLR {a β₁ β₂ γ₁ γ₂ d : α} {f₁ : R a β₁} {f₂ : R a β₂} {g₁ : R β₁ γ₁} {g₂ : R β₂ γ₂} {h₁ : R γ₁ d} {h₂ : R γ₂ d} :
(h₁ • g₁) • f₁ ≃ (h₂ • g₂) • f₂ ⟶ h₁ • (g₁ • f₁) ≃ h₂ • (g₂ • f₂) :=
applyAssocLR_right ⊙ applyAssocLR_left
def applyAssocRL {a β₁ β₂ γ₁ γ₂ d : α} {f₁ : R a β₁} {f₂ : R a β₂} {g₁ : R β₁ γ₁} {g₂ : R β₂ γ₂} {h₁ : R γ₁ d} {h₂ : R γ₂ d} :
h₁ • (g₁ • f₁) ≃ h₂ • (g₂ • f₂) ⟶ (h₁ • g₁) • f₁ ≃ (h₂ • g₂) • f₂ :=
applyAssocRL_right ⊙ applyAssocRL_left
end IsCompositionRelation
namespace IsMorphismRelation
variable [IsPreorder R] [IsMorphismRelation R]
def leftCancelId {a b : α} (f : R a b) {e : R b b} : e ≃ ident R b ⟶ e • f ≃ f :=
HasLinearFunOp.swapFun (comp_subst_left f) (leftId f)
def rightCancelId {a b : α} (f : R a b) {e : R a a} : e ≃ ident R a ⟶ f • e ≃ f :=
HasLinearFunOp.swapFun (comp_subst_right f) (rightId f)
end IsMorphismRelation
open IsMorphismRelation
namespace IsIsomorphismRelation
variable [IsEquivalence R] [IsIsomorphismRelation R]
def inv_congrArg {a b : α} {f₁ f₂ : R a b} : f₁ ≃ f₂ ⟶ f₁⁻¹ ≃ f₂⁻¹ :=
HasFunctorialEquivalences.equiv_congrArg U HasSymm.symm
def inv_subst {a b : α} {f₁ f₂ : R a b} {e : R b a} : f₁ ≃ f₂ ⟶ f₂⁻¹ ≃ e ⟶ f₁⁻¹ ≃ e :=
HasTrans.trans ⊙ inv_congrArg
def inv_subst' {a b : α} {f₁ f₂ : R a b} {e : R b a} : f₁ ≃ f₂ ⟶ e ≃ f₁⁻¹ ⟶ e ≃ f₂⁻¹ :=
HasTrans.revTrans ⊙ inv_congrArg
def leftCancel' {a b c : α} (f : R a b) (g : R b c) : (g⁻¹ • g) • f ≃ f := (leftCancelId f) (leftInv g)
def leftCancel {a b c : α} (f : R a b) (g : R b c) : g⁻¹ • (g • f) ≃ f := applyAssocLR_left ⟮leftCancel' f g⟯
def leftCancelInv' {a b c : α} (f : R a b) (g : R c b) : (g • g⁻¹) • f ≃ f := (leftCancelId f) (rightInv g)
def leftCancelInv {a b c : α} (f : R a b) (g : R c b) : g • (g⁻¹ • f) ≃ f := applyAssocLR_left ⟮leftCancelInv' f g⟯
def rightCancel' {a b c : α} (f : R a b) (g : R c a) : f • (g • g⁻¹) ≃ f := (rightCancelId f) (rightInv g)
def rightCancel {a b c : α} (f : R a b) (g : R c a) : (f • g) • g⁻¹ ≃ f := applyAssocRL_left ⟮rightCancel' f g⟯
def rightCancelInv' {a b c : α} (f : R a b) (g : R a c) : f • (g⁻¹ • g) ≃ f := (rightCancelId f) (leftInv g)
def rightCancelInv {a b c : α} (f : R a b) (g : R a c) : (f • g⁻¹) • g ≃ f := applyAssocRL_left ⟮rightCancelInv' f g⟯
def leftMulInv {a b c : α} (f₁ : R a b) (f₂ : R a c) (g : R b c) : g • f₁ ≃ f₂ ⟷' f₁ ≃ g⁻¹ • f₂ :=
⟨HasLinearFunOp.swapFun (comp_subst_right' g⁻¹) (HasSymm.symm' (leftCancel f₁ g)),
HasLinearFunOp.swapFun (comp_subst_right g) (leftCancelInv f₂ g)⟩
def leftMulInv' {a b c : α} (f₁ : R a b) (f₂ : R a c) (g : R c b) : g⁻¹ • f₁ ≃ f₂ ⟷' f₁ ≃ g • f₂ :=
⟨HasLinearFunOp.swapFun (comp_subst_right' g) (HasSymm.symm' (leftCancelInv f₁ g)),
HasLinearFunOp.swapFun (comp_subst_right g⁻¹) (leftCancel f₂ g)⟩
def leftMul {a b c : α} (f₁ f₂ : R a b) (g : R b c) : g • f₁ ≃ g • f₂ ⟷' f₁ ≃ f₂ :=
⟨HasTrans.revTrans'' (leftCancel f₂ g) ⊙ (leftMulInv f₁ (g • f₂) g).mp, comp_congrArg_right⟩
def rightMulInv {a b c : α} (f₁ : R a c) (f₂ : R b c) (g : R b a) : f₁ • g ≃ f₂ ⟷' f₁ ≃ f₂ • g⁻¹ :=
⟨HasLinearFunOp.swapFun (comp_subst_left' g⁻¹) (HasSymm.symm' (rightCancel f₁ g)),
HasLinearFunOp.swapFun (comp_subst_left g) (rightCancelInv f₂ g)⟩
def rightMulInv' {a b c : α} (f₁ : R a c) (f₂ : R b c) (g : R a b) : f₁ • g⁻¹ ≃ f₂ ⟷' f₁ ≃ f₂ • g :=
⟨HasLinearFunOp.swapFun (comp_subst_left' g) (HasSymm.symm' (rightCancelInv f₁ g)),
HasLinearFunOp.swapFun (comp_subst_left g⁻¹) (rightCancel f₂ g)⟩
def rightMul {a b c : α} (f₁ f₂ : R a b) (g : R c a) : f₁ • g ≃ f₂ • g ⟷' f₁ ≃ f₂ :=
⟨HasTrans.revTrans'' (rightCancel f₂ g) ⊙ (rightMulInv f₁ (f₂ • g) g).mp, comp_congrArg_left⟩
def eqInvIffInvEq {a b : α} (f : R a b) (g : R b a) : f ≃ g⁻¹ ⟷' f⁻¹ ≃ g :=
⟨HasLinearFunOp.swapFun inv_subst (invInv g),
HasLinearFunOp.swapFun inv_subst' (HasSymm.symm' (invInv f))⟩
def eqIffEqInv {a b : α} (f₁ f₂ : R a b) : f₁⁻¹ ≃ f₂⁻¹ ⟷' f₁ ≃ f₂ :=
⟨HasTrans.revTrans'' (invInv f₂) ⊙ (eqInvIffInvEq f₁ f₂⁻¹).mpr, inv_congrArg⟩
def leftRightMul {a b c d : α} (f₁ : R a b) (f₂ : R a c) (g₁ : R b d) (g₂ : R c d) :
g₂⁻¹ • g₁ ≃ f₂ • f₁⁻¹ ⟷' g₁ • f₁ ≃ g₂ • f₂ :=
⟨(leftMulInv' (g₁ • f₁) f₂ g₂).mp ⊙ applyAssocLR_left ⊙ (rightMulInv (g₂⁻¹ • g₁) f₂ f₁).mpr,
(leftMulInv' g₁ (f₂ • f₁⁻¹) g₂).mpr ⊙ applyAssocLR_right ⊙ (rightMulInv g₁ (g₂ • f₂) f₁).mp⟩
def swapInv {a b c d : α} (f₁ : R a b) (f₂ : R c d) (g₁ : R d b) (g₂ : R c a) :
g₁⁻¹ • f₁ ≃ f₂ • g₂⁻¹ ⟶ f₁⁻¹ • g₁ ≃ g₂ • f₂⁻¹ :=
(leftRightMul f₂ g₂ g₁ f₁).mpr ⊙ HasSymm.symm ⊙ (leftRightMul g₂ f₂ f₁ g₁).mp
def swapInv' {a b c d : α} (f₁ : R a b) (f₂ : R c d) (g₁ : R d b) (g₂ : R c a) :
f₂ • g₂⁻¹ ≃ g₁⁻¹ • f₁ ⟶ g₂ • f₂⁻¹ ≃ f₁⁻¹ • g₁ :=
HasSymm.symm ⊙ swapInv f₁ f₂ g₁ g₂ ⊙ HasSymm.symm
end IsIsomorphismRelation
open IsIsomorphismRelation
end Morphisms
section Functors
variable {α : Sort u}
namespace idFun
variable {U : Universe} [HasInstanceArrows U] [HasExternalFunctors U U]
[HasIdFun U] (R : GeneralizedRelation α U)
instance isReflFunctor [HasRefl R] : IsReflFunctor R R (HasIdFun.idFun' _) :=
⟨λ a => HasRefl.refl (ident R a)⟩
variable [HasInternalFunctors U]
instance isSymmFunctor [HasSymm R] : IsSymmFunctor R R (HasIdFun.idFun' _) :=
⟨λ f => HasRefl.refl f⁻¹⟩
instance isTransFunctor [HasTrans R] : IsTransFunctor R R (HasIdFun.idFun' _) :=
⟨λ f g => HasRefl.refl (g • f)⟩
instance isPreorderFunctor [IsPreorder R] : IsPreorderFunctor R R (HasIdFun.idFun' _) := ⟨⟩
instance isEquivalenceFunctor [IsEquivalence R] : IsEquivalenceFunctor R R (HasIdFun.idFun' _) := ⟨⟩
end idFun
namespace constFun
variable {U V : Universe} [HasInstanceArrows V] [HasExternalFunctors U V]
[HasConstFun U V] (R : GeneralizedRelation α U) {β : V} (c : β)
def idArrow : c ⇝ c := ident (HasInstanceArrows.Arrow β) c
instance isReflFunctor [HasRefl R] : IsReflFunctor R (ConstRel α c) (HasConstFun.constFun' _ c) :=
⟨λ _ => idArrow c⟩
variable [HasInternalFunctors U] [HasInternalFunctors V] [HasAffineFunOp V]
instance isSymmFunctor [HasSymm R] : IsSymmFunctor R (ConstRel α c) (HasConstFun.constFun' _ c) :=
⟨λ _ => Eq.ndrec (motive := λ b : β => ⌈c ⇝ b⌉) (idArrow c) (Eq.symm (ConstRel.symmEq α c))⟩
instance isTransFunctor [HasTrans R] : IsTransFunctor R (ConstRel α c) (HasConstFun.constFun' _ c) :=
⟨λ _ _ => Eq.ndrec (motive := λ b : β => ⌈c ⇝ b⌉) (idArrow c) (Eq.symm (ConstRel.transEq α c))⟩
instance isPreorderFunctor [IsPreorder R] : IsPreorderFunctor R (ConstRel α c) (HasConstFun.constFun' _ c) := ⟨⟩
instance isEquivalenceFunctor [IsEquivalence R] : IsEquivalenceFunctor R (ConstRel α c) (HasConstFun.constFun' _ c) := ⟨⟩
end constFun
namespace compFun
variable {U V W : Universe} [hV : HasInstanceArrows V] [hW : HasInstanceArrows W]
[HasExternalFunctors U V] [HasExternalFunctors V W] [HasExternalFunctors U W]
[HasExternalFunctors hV.arrowUniverse hW.arrowUniverse] [HasArrowCongrArg V W]
[HasCompFun U V W]
{R : GeneralizedRelation α U} {S : GeneralizedRelation α V} {T : GeneralizedRelation α W}
(F : BaseFunctor R S) (G : BaseFunctor S T)
instance isReflFunctor [HasRefl R] [HasRefl S] [HasRefl T] [hF : IsReflFunctor R S F] [hG : IsReflFunctor S T G] :
IsReflFunctor R T (G ⊙' F) :=
⟨λ a => let e₁ : G (F (ident R a)) ⇝ G (ident S a) := HasArrowCongrArg.arrowCongrArg G (hF.respectsRefl a);
let e₂ : G (ident S a) ⇝ ident T a := hG.respectsRefl a;
HasTrans.trans' e₁ e₂⟩
variable [HasInternalFunctors U] [HasInternalFunctors V] [HasInternalFunctors W]
instance isSymmFunctor [HasSymm R] [HasSymm S] [HasSymm T] [hF : IsSymmFunctor R S F] [hG : IsSymmFunctor S T G] :
IsSymmFunctor R T (G ⊙' F) :=
⟨λ f => let e₁ : G (F f⁻¹) ⇝ G (F f)⁻¹ := HasArrowCongrArg.arrowCongrArg G (hF.respectsSymm f);
let e₂ : G (F f)⁻¹ ⇝ (G (F f))⁻¹ := hG.respectsSymm (F f);
HasTrans.trans' e₁ e₂⟩
instance isTransFunctor [HasTrans R] [HasTrans S] [HasTrans T] [hF : IsTransFunctor R S F] [hG : IsTransFunctor S T G] :
IsTransFunctor R T (G ⊙' F) :=
⟨λ f g => let e₁ : G (F (g • f)) ⇝ G (F g • F f) := HasArrowCongrArg.arrowCongrArg G (hF.respectsTrans f g);
let e₂ : G (F g • F f) ⇝ G (F g) • G (F f) := hG.respectsTrans (F f) (F g);
HasTrans.trans' e₁ e₂⟩
instance isPreorderFunctor [IsPreorder R] [IsPreorder S] [IsPreorder T] [IsPreorderFunctor R S F] [IsPreorderFunctor S T G] :
IsPreorderFunctor R T (G ⊙' F) := ⟨⟩
instance isEquivalenceFunctor [IsEquivalence R] [IsEquivalence S] [IsEquivalence T] [IsEquivalenceFunctor R S F] [IsEquivalenceFunctor S T G] :
IsEquivalenceFunctor R T (G ⊙' F) := ⟨⟩
end compFun
end Functors
section NaturalTransformations
variable {α : Sort u} {V W : Universe} [HasInternalFunctors W] [hW : HasFunctorialEquivalences W] [HasExternalFunctors V W]
{β : Sort w} (R : GeneralizedRelation α V) (S : GeneralizedRelation β W)
instance : HasFunctorialArrows W := hW.toHasFunctorialArrows W
namespace IsNaturalTransformation
def refl [IsPreorder S] [h : IsMorphismRelation S] {mF : α → β}
(F : ∀ {a b}, R a b ⟶' S (mF a) (mF b)) :
IsNatural R S F F (λ a => ident S (mF a)) :=
⟨λ f => HasTrans.trans' (h.rightId (F f)) (HasSymm.symm' (h.leftId (F f)))⟩
variable [HasLinearFunOp hW.equivUniverse]
def symm [IsEquivalence S] [h : IsIsomorphismRelation S] {mF mG : α → β}
(F : ∀ {a b}, R a b ⟶' S (mF a) (mF b)) (G : ∀ {a b}, R a b ⟶' S (mG a) (mG b))
(n : ∀ a, S (mF a) (mG a)) [hn : IsNatural R S F G n] :
IsNatural R S G F (λ a => (n a)⁻¹) :=
⟨λ {a b} f => HasSymm.symm' ((IsIsomorphismRelation.leftRightMul (n a) (F f) (G f) (n b)).mpr (hn.nat f))⟩
def trans [HasTrans S] [h : IsCompositionRelation S] {mF mG mH : α → β}
(F : ∀ {a b}, R a b ⟶' S (mF a) (mF b)) (G : ∀ {a b}, R a b ⟶' S (mG a) (mG b)) (H : ∀ {a b}, R a b ⟶' S (mH a) (mH b))
(nFG : ∀ a, S (mF a) (mG a)) (nGH : ∀ a, S (mG a) (mH a))
[hnFG : IsNatural R S F G nFG] [hnGH : IsNatural R S G H nGH] :
IsNatural R S F H (λ a => nGH a • nFG a) :=
⟨λ {a b} f => let e₁ := IsCompositionRelation.applyAssocLR_left ⟮IsCompositionRelation.comp_congrArg_left (f := nFG a) (hnGH.nat f)⟯;
let e₂ := IsCompositionRelation.applyAssocRL ⟮IsCompositionRelation.comp_congrArg_right (g := nGH b) (hnFG.nat f)⟯;
HasTrans.trans' e₁ e₂⟩
end IsNaturalTransformation
end NaturalTransformations
|
f64d7908f2b39df83217f673cdbee8729dbf6f87 | e16d4df4c2baa34ab203178cea2c27905a3b63d3 | /src/day3.lean | f7920f625b49e52b7055e2dd6987857d1fcb3687 | [] | no_license | jembishop/advent-of-code-2020 | ea29eecb7f1d676dc1fd34b1a66efdbd23248aec | 32fd5bc28e7c178277e85dc034b55fce6dd4afce | refs/heads/main | 1,675,354,147,711 | 1,608,705,139,000 | 1,608,705,139,000 | 317,705,877 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,754 | lean | import system.io
import data.vector
import data.zmod.basic
import utils
open io
open list
def tree_p : char → option bool
| '#' := some true
| '.' := some false
| _ := none
def WIDTH : ℕ := 31
def tree_line := vector bool WIDTH
def parse_line : string → option tree_line
| s := do
let mapped : list (option bool) := tree_p <$> s.data,
uw ← (monad.sequence mapped),
from_list uw
def parse : string → option (list tree_line)
| s := monad.sequence (functor.map parse_line (list.filter (≠"") (s.split (='\n'))))
instance : has_to_string tree_line
:= ⟨λ x: tree_line, x.val.to_string⟩
instance {n : ℕ} : has_to_string (zmod n) := ⟨λ x , to_string x.val⟩
def is_tree : ℕ → tree_line → bool
| n tl := let modW : zmod WIDTH := n in tl.nth modW
def enumerate_h {α} : ℕ → list α → list (ℕ × α)
| n [] := []
| n (x::xs) := (n, x) :: (enumerate_h (n + 1) xs)
def enumerate {α} : list α → list (prod ℕ α)
| l := enumerate_h 0 l
def position : ℕ → ℕ → ℕ
| grad y := grad*y
def hits : ℕ × ℕ → list tree_line → ℕ
| (step, grad) tls := length $ filter id $ map
(λt: prod ℕ tree_line,
is_tree (position grad (t.1/step)) t.2 )
(filter (λt : prod ℕ tree_line, t.1 % step = 0) (enumerate tls))
def productl : list ℕ → ℕ := list.foldr (*) 1
def many_hits : list (ℕ × ℕ) → list tree_line → ℕ
| hs tls := productl $ map (λ h, hits h tls) hs
def main : io unit := do
contents ← fs.read_file "inputs/day3.txt",
let parsed := parse contents.to_string,
put_str_ln $ to_string $ (hits (1, 3)) <$> parsed,
put_str_ln $ to_string $
(many_hits [(1, 1), (1, 3), (1, 5), (1, 7), (2, 1)]) <$> parsed |
62032b87d182b5ed8feb9b9c0bff5ee83a97c709 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/Lean3Lib/init/data/option/basic_auto.lean | 72c250333bfbcb1344394157602606a8984f29fd | [] | 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 | 2,764 | lean | /-
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.logic
import Mathlib.Lean3Lib.init.control.monad
import Mathlib.Lean3Lib.init.control.alternative
universes u v u_1 u_2
namespace Mathlib
namespace option
def to_monad {m : Type → Type} [Monad m] [alternative m] {A : Type} : Option A → m A := sorry
def get_or_else {α : Type u} : Option α → α → α := sorry
def is_some {α : Type u} : Option α → Bool := sorry
def is_none {α : Type u} : Option α → Bool := sorry
def get {α : Type u} {o : Option α} : ↥(is_some o) → α := sorry
def rhoare {α : Type u} : Bool → α → Option α := sorry
def lhoare {α : Type u} : α → Option α → α := sorry
infixr:1 "|>" => Mathlib.option.rhoare
infixr:1 "<|" => Mathlib.option.lhoare
protected def bind {α : Type u} {β : Type v} : Option α → (α → Option β) → Option β := sorry
protected def map {α : Type u_1} {β : Type u_2} (f : α → β) (o : Option α) : Option β :=
option.bind o (some ∘ f)
theorem map_id {α : Type u_1} : option.map id = id := sorry
protected instance monad : Monad Option :=
{ toApplicative :=
{ toFunctor :=
{ map := option.map, mapConst := fun (α β : Type u_1) => option.map ∘ function.const β },
toPure := { pure := some },
toSeq :=
{ seq :=
fun (α β : Type u_1) (f : Option (α → β)) (x : Option α) =>
option.bind f fun (_x : α → β) => option.map _x x },
toSeqLeft :=
{ seqLeft :=
fun (α β : Type u_1) (a : Option α) (b : Option β) =>
(fun (α β : Type u_1) (f : Option (α → β)) (x : Option α) =>
option.bind f fun (_x : α → β) => option.map _x x)
β α (option.map (function.const β) a) b },
toSeqRight :=
{ seqRight :=
fun (α β : Type u_1) (a : Option α) (b : Option β) =>
(fun (α β : Type u_1) (f : Option (α → β)) (x : Option α) =>
option.bind f fun (_x : α → β) => option.map _x x)
β β (option.map (function.const α id) a) b } },
toBind := { bind := option.bind } }
protected def orelse {α : Type u} : Option α → Option α → Option α := sorry
protected instance alternative : alternative Option := alternative.mk none
end option
protected instance option.inhabited (α : Type u) : Inhabited (Option α) := { default := none }
protected instance option.decidable_eq {α : Type u} [d : DecidableEq α] : DecidableEq (Option α) :=
sorry
end Mathlib |
e52dfc6f4197e29c6c494c824bbaf5e73d6e4b23 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/data/nat/order/basic.lean | bf22ba6b30e1ba32b6cc0207ef1c79f86784a144 | [
"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 | 23,738 | lean | /-
Copyright (c) 2014 Floris van Doorn (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Leonardo de Moura, Jeremy Avigad, Mario Carneiro
-/
import algebra.order.ring.canonical
import data.nat.basic
/-!
# The natural numbers as a linearly ordered commutative semiring
We also have a variety of lemmas which have been deferred from `data.nat.basic` because it is
easier to prove them with this ordered semiring instance available.
You may find that some theorems can be moved back to `data.nat.basic` by modifying their proofs.
-/
universes u v
/-! ### instances -/
instance nat.order_bot : order_bot ℕ :=
{ bot := 0, bot_le := nat.zero_le }
instance : linear_ordered_comm_semiring ℕ :=
{ lt := nat.lt,
add_le_add_left := @nat.add_le_add_left,
le_of_add_le_add_left := @nat.le_of_add_le_add_left,
zero_le_one := nat.le_of_lt (nat.zero_lt_succ 0),
mul_lt_mul_of_pos_left := @nat.mul_lt_mul_of_pos_left,
mul_lt_mul_of_pos_right := @nat.mul_lt_mul_of_pos_right,
decidable_eq := nat.decidable_eq,
exists_pair_ne := ⟨0, 1, ne_of_lt nat.zero_lt_one⟩,
..nat.comm_semiring, ..nat.linear_order }
instance : linear_ordered_comm_monoid_with_zero ℕ :=
{ mul_le_mul_left := λ a b h c, nat.mul_le_mul_left c h,
..nat.linear_ordered_comm_semiring,
..(infer_instance : comm_monoid_with_zero ℕ)}
/-! Extra instances to short-circuit type class resolution and ensure computability -/
-- Not using `infer_instance` avoids `classical.choice` in the following two
instance : linear_ordered_semiring ℕ := infer_instance
instance : strict_ordered_semiring ℕ := infer_instance
instance : strict_ordered_comm_semiring ℕ := infer_instance
instance : ordered_semiring ℕ := strict_ordered_semiring.to_ordered_semiring'
instance : ordered_comm_semiring ℕ := strict_ordered_comm_semiring.to_ordered_comm_semiring'
instance : linear_ordered_cancel_add_comm_monoid ℕ := infer_instance
instance : canonically_ordered_comm_semiring ℕ :=
{ exists_add_of_le := λ a b h, (nat.le.dest h).imp $ λ _, eq.symm,
le_self_add := nat.le_add_right,
eq_zero_or_eq_zero_of_mul_eq_zero := λ a b, nat.eq_zero_of_mul_eq_zero,
.. nat.nontrivial,
.. nat.order_bot,
.. (infer_instance : ordered_add_comm_monoid ℕ),
.. (infer_instance : linear_ordered_semiring ℕ),
.. (infer_instance : comm_semiring ℕ) }
instance : canonically_linear_ordered_add_monoid ℕ :=
{ .. (infer_instance : canonically_ordered_add_monoid ℕ),
.. nat.linear_order }
variables {m n k l : ℕ}
namespace nat
/-! ### Equalities and inequalities involving zero and one -/
lemma one_le_iff_ne_zero : 1 ≤ n ↔ n ≠ 0 :=
(show 1 ≤ n ↔ 0 < n, from iff.rfl).trans pos_iff_ne_zero
lemma one_lt_iff_ne_zero_and_ne_one : ∀ {n : ℕ}, 1 < n ↔ n ≠ 0 ∧ n ≠ 1
| 0 := dec_trivial
| 1 := dec_trivial
| (n+2) := dec_trivial
protected theorem mul_ne_zero (n0 : n ≠ 0) (m0 : m ≠ 0) : n * m ≠ 0
| nm := (eq_zero_of_mul_eq_zero nm).elim n0 m0
@[simp] protected theorem mul_eq_zero : m * n = 0 ↔ m = 0 ∨ n = 0 :=
iff.intro eq_zero_of_mul_eq_zero (by simp [or_imp_distrib] {contextual := tt})
@[simp] protected theorem zero_eq_mul : 0 = m * n ↔ m = 0 ∨ n = 0 :=
by rw [eq_comm, nat.mul_eq_zero]
lemma eq_zero_of_double_le (h : 2 * n ≤ n) : n = 0 :=
add_right_eq_self.mp $ le_antisymm ((two_mul n).symm.trans_le h) le_add_self
lemma eq_zero_of_mul_le (hb : 2 ≤ n) (h : n * m ≤ m) : m = 0 :=
eq_zero_of_double_le $ le_trans (nat.mul_le_mul_right _ hb) h
lemma zero_max : max 0 n = n := max_eq_right (zero_le _)
@[simp] lemma min_eq_zero_iff : min m n = 0 ↔ m = 0 ∨ n = 0 :=
begin
split,
{ intro h,
cases le_total m n with H H,
{ simpa [H] using or.inl h },
{ simpa [H] using or.inr h } },
{ rintro (rfl|rfl);
simp }
end
@[simp] lemma max_eq_zero_iff : max m n = 0 ↔ m = 0 ∧ n = 0 :=
begin
split,
{ intro h,
cases le_total m n with H H,
{ simp only [H, max_eq_right] at h,
exact ⟨le_antisymm (H.trans h.le) (zero_le _), h⟩ },
{ simp only [H, max_eq_left] at h,
exact ⟨h, le_antisymm (H.trans h.le) (zero_le _)⟩ } },
{ rintro ⟨rfl, rfl⟩,
simp }
end
lemma add_eq_max_iff : m + n = max m n ↔ m = 0 ∨ n = 0 :=
begin
rw ←min_eq_zero_iff,
cases le_total m n with H H;
simp [H]
end
lemma add_eq_min_iff : m + n = min m n ↔ m = 0 ∧ n = 0 :=
begin
rw ←max_eq_zero_iff,
cases le_total m n with H H;
simp [H]
end
lemma one_le_of_lt (h : n < m) : 1 ≤ m := lt_of_le_of_lt (nat.zero_le _) h
theorem eq_one_of_mul_eq_one_right (H : m * n = 1) : m = 1 := eq_one_of_dvd_one ⟨n, H.symm⟩
theorem eq_one_of_mul_eq_one_left (H : m * n = 1) : n = 1 :=
eq_one_of_mul_eq_one_right (by rwa mul_comm)
/-! ### `succ` -/
lemma two_le_iff : ∀ n, 2 ≤ n ↔ n ≠ 0 ∧ n ≠ 1
| 0 := by simp
| 1 := by simp
| (n+2) := by simp
@[simp] lemma lt_one_iff {n : ℕ} : n < 1 ↔ n = 0 :=
lt_succ_iff.trans nonpos_iff_eq_zero
/-! ### `add` -/
theorem add_pos_left {m : ℕ} (h : 0 < m) (n : ℕ) : 0 < m + n :=
calc
m + n > 0 + n : nat.add_lt_add_right h n
... = n : nat.zero_add n
... ≥ 0 : zero_le n
theorem add_pos_right (m : ℕ) {n : ℕ} (h : 0 < n) : 0 < m + n :=
begin rw add_comm, exact add_pos_left h m end
theorem add_pos_iff_pos_or_pos (m n : ℕ) : 0 < m + n ↔ 0 < m ∨ 0 < n :=
iff.intro
begin
intro h,
cases m with m,
{simp [zero_add] at h, exact or.inr h},
exact or.inl (succ_pos _)
end
begin
intro h, cases h with mpos npos,
{ apply add_pos_left mpos },
apply add_pos_right _ npos
end
lemma add_eq_one_iff : m + n = 1 ↔ m = 0 ∧ n = 1 ∨ m = 1 ∧ n = 0 :=
by cases n; simp [succ_eq_add_one, ← add_assoc, succ_inj']
lemma add_eq_two_iff : m + n = 2 ↔ m = 0 ∧ n = 2 ∨ m = 1 ∧ n = 1 ∨ m = 2 ∧ n = 0 :=
by cases n; simp [(succ_ne_zero 1).symm, succ_eq_add_one, ← add_assoc, succ_inj', add_eq_one_iff]
lemma add_eq_three_iff :
m + n = 3 ↔ m = 0 ∧ n = 3 ∨ m = 1 ∧ n = 2 ∨ m = 2 ∧ n = 1 ∨ m = 3 ∧ n = 0 :=
by cases n; simp [(succ_ne_zero 1).symm, succ_eq_add_one, ← add_assoc, succ_inj', add_eq_two_iff]
theorem le_add_one_iff : m ≤ n + 1 ↔ m ≤ n ∨ m = n + 1 :=
⟨λ h,
match nat.eq_or_lt_of_le h with
| or.inl h := or.inr h
| or.inr h := or.inl $ nat.le_of_succ_le_succ h
end,
or.rec (λ h, le_trans h $ nat.le_add_right _ _) le_of_eq⟩
lemma le_and_le_add_one_iff : n ≤ m ∧ m ≤ n + 1 ↔ m = n ∨ m = n + 1 :=
begin
rw [le_add_one_iff, and_or_distrib_left, ←le_antisymm_iff, eq_comm, and_iff_right_of_imp],
rintro rfl,
exact n.le_succ
end
lemma add_succ_lt_add (hab : m < n) (hcd : k < l) : m + k + 1 < n + l :=
begin
rw add_assoc,
exact add_lt_add_of_lt_of_le hab (nat.succ_le_iff.2 hcd)
end
/-! ### `pred` -/
lemma pred_le_iff : pred m ≤ n ↔ m ≤ succ n :=
⟨le_succ_of_pred_le, by { cases m, { exact λ _, zero_le n }, exact le_of_succ_le_succ }⟩
/-! ### `sub`
Most lemmas come from the `has_ordered_sub` instance on `ℕ`. -/
instance : has_ordered_sub ℕ :=
begin
constructor,
intros m n k,
induction n with n ih generalizing k,
{ simp },
{ simp only [sub_succ, add_succ, succ_add, ih, pred_le_iff] }
end
lemma lt_pred_iff : n < pred m ↔ succ n < m := show n < m - 1 ↔ n + 1 < m, from lt_tsub_iff_right
lemma lt_of_lt_pred (h : m < n - 1) : m < n := lt_of_succ_lt (lt_pred_iff.1 h)
lemma le_or_le_of_add_eq_add_pred (h : k + l = m + n - 1) : m ≤ k ∨ n ≤ l :=
begin
cases le_or_lt m k with h' h'; [left, right],
{ exact h' },
{ replace h' := add_lt_add_right h' l, rw h at h',
cases n.eq_zero_or_pos with hn hn, { rw hn, exact zero_le l },
rw [m.add_sub_assoc hn, add_lt_add_iff_left] at h',
exact nat.le_of_pred_lt h' },
end
/-- A version of `nat.sub_succ` in the form `_ - 1` instead of `nat.pred _`. -/
lemma sub_succ' (m n : ℕ) : m - n.succ = m - n - 1 := rfl
/-! ### `mul` -/
lemma mul_eq_one_iff : ∀ {m n : ℕ}, m * n = 1 ↔ m = 1 ∧ n = 1
| 0 0 := dec_trivial
| 0 1 := dec_trivial
| 1 0 := dec_trivial
| (m+2) 0 := by simp
| 0 (n+2) := by simp
| (m+1) (n+1) := ⟨
λ h, by simp only [add_mul, mul_add, mul_add, one_mul, mul_one,
(add_assoc _ _ _).symm, nat.succ_inj', add_eq_zero_iff] at h; simp [h.1.2, h.2],
λ h, by simp only [h, mul_one]⟩
lemma succ_mul_pos (m : ℕ) (hn : 0 < n) : 0 < (succ m) * n := mul_pos (succ_pos m) hn
theorem mul_self_le_mul_self (h : m ≤ n) : m * m ≤ n * n := mul_le_mul h h (zero_le _) (zero_le _)
theorem mul_self_lt_mul_self : Π {m n : ℕ}, m < n → m * m < n * n
| 0 n h := mul_pos h h
| (succ m) n h := mul_lt_mul h (le_of_lt h) (succ_pos _) (zero_le _)
theorem mul_self_le_mul_self_iff : m ≤ n ↔ m * m ≤ n * n :=
⟨mul_self_le_mul_self, le_imp_le_of_lt_imp_lt mul_self_lt_mul_self⟩
theorem mul_self_lt_mul_self_iff : m < n ↔ m * m < n * n :=
le_iff_le_iff_lt_iff_lt.1 mul_self_le_mul_self_iff
theorem le_mul_self : Π (n : ℕ), n ≤ n * n
| 0 := le_rfl
| (n+1) := by simp
lemma le_mul_of_pos_left (h : 0 < n) : m ≤ n * m :=
begin
conv {to_lhs, rw [← one_mul(m)]},
exact mul_le_mul_of_nonneg_right h.nat_succ_le dec_trivial,
end
lemma le_mul_of_pos_right (h : 0 < n) : m ≤ m * n :=
begin
conv {to_lhs, rw [← mul_one(m)]},
exact mul_le_mul_of_nonneg_left h.nat_succ_le dec_trivial,
end
theorem mul_self_inj : m * m = n * n ↔ m = n :=
le_antisymm_iff.trans (le_antisymm_iff.trans
(and_congr mul_self_le_mul_self_iff mul_self_le_mul_self_iff)).symm
lemma le_add_pred_of_pos (n : ℕ) {i : ℕ} (hi : i ≠ 0) : n ≤ i + (n - 1) :=
begin
refine le_trans _ (add_tsub_le_assoc),
simp [add_comm, nat.add_sub_assoc, one_le_iff_ne_zero.2 hi]
end
/-!
### Recursion and induction principles
This section is here due to dependencies -- the lemmas here require some of the lemmas
proved above, and some of the results in later sections depend on the definitions in this section.
-/
/-- Given a predicate on two naturals `P : ℕ → ℕ → Prop`, `P a b` is true for all `a < b` if
`P (a + 1) (a + 1)` is true for all `a`, `P 0 (b + 1)` is true for all `b` and for all
`a < b`, `P (a + 1) b` is true and `P a (b + 1)` is true implies `P (a + 1) (b + 1)` is true. -/
@[elab_as_eliminator]
lemma diag_induction (P : ℕ → ℕ → Prop) (ha : ∀ a, P (a + 1) (a + 1)) (hb : ∀ b, P 0 (b + 1))
(hd : ∀ a b, a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)) :
∀ a b, a < b → P a b
| 0 (b + 1) h := hb _
| (a + 1) (b + 1) h :=
begin
apply hd _ _ ((add_lt_add_iff_right _).1 h),
{ have : a + 1 = b ∨ a + 1 < b,
{ rwa [← le_iff_eq_or_lt, ← nat.lt_succ_iff] },
rcases this with rfl | _,
{ exact ha _ },
apply diag_induction (a + 1) b this },
apply diag_induction a (b + 1),
apply lt_of_le_of_lt (nat.le_succ _) h,
end
using_well_founded { rel_tac := λ _ _, `[exact ⟨_, measure_wf (λ p, p.1 + p.2.1)⟩] }
/-- A subset of `ℕ` containing `k : ℕ` and closed under `nat.succ` contains every `n ≥ k`. -/
lemma set_induction_bounded {S : set ℕ} (hk : k ∈ S) (h_ind: ∀ k : ℕ, k ∈ S → k + 1 ∈ S)
(hnk : k ≤ n) : n ∈ S :=
@le_rec_on (λ n, n ∈ S) k n hnk h_ind hk
/-- A subset of `ℕ` containing zero and closed under `nat.succ` contains all of `ℕ`. -/
lemma set_induction {S : set ℕ} (hb : 0 ∈ S) (h_ind: ∀ k : ℕ, k ∈ S → k + 1 ∈ S) (n : ℕ) : n ∈ S :=
set_induction_bounded hb h_ind (zero_le n)
/-! ### `div` -/
protected lemma div_le_of_le_mul' (h : m ≤ k * n) : m / k ≤ n :=
(nat.eq_zero_or_pos k).elim
(λ k0, by rw [k0, nat.div_zero]; apply zero_le)
(λ k0, (mul_le_mul_left k0).1 $
calc k * (m / k)
≤ m % k + k * (m / k) : nat.le_add_left _ _
... = m : mod_add_div _ _
... ≤ k * n : h)
protected lemma div_le_self' (m n : ℕ) : m / n ≤ m :=
(nat.eq_zero_or_pos n).elim
(λ n0, by rw [n0, nat.div_zero]; apply zero_le)
(λ n0, nat.div_le_of_le_mul' $ calc
m = 1 * m : (one_mul _).symm
... ≤ n * m : nat.mul_le_mul_right _ n0)
protected lemma div_lt_of_lt_mul (h : m < n * k) : m / n < k :=
lt_of_mul_lt_mul_left
(calc n * (m / n) ≤ m % n + n * (m / n) : nat.le_add_left _ _
... = m : mod_add_div _ _
... < n * k : h)
(nat.zero_le n)
lemma eq_zero_of_le_div (hn : 2 ≤ n) (h : m ≤ m / n) : m = 0 :=
eq_zero_of_mul_le hn $
by rw mul_comm; exact (nat.le_div_iff_mul_le' (lt_of_lt_of_le dec_trivial hn)).1 h
lemma div_mul_div_le_div (m n k : ℕ) : ((m / k) * n) / m ≤ n / k :=
if hm0 : m = 0 then by simp [hm0]
else calc m / k * n / m ≤ n * m / k / m :
nat.div_le_div_right (by rw [mul_comm];
exact mul_div_le_mul_div_assoc _ _ _)
... = n / k : by rw [nat.div_div_eq_div_mul, mul_comm n, mul_comm k,
nat.mul_div_mul _ _ (nat.pos_of_ne_zero hm0)]
lemma eq_zero_of_le_half (h : n ≤ n / 2) : n = 0 := eq_zero_of_le_div le_rfl h
lemma mul_div_mul_comm_of_dvd_dvd (hmk : k ∣ m) (hnl : l ∣ n) : m * n / (k * l) = m / k * (n / l) :=
begin
rcases k.eq_zero_or_pos with rfl | hk0, { simp },
rcases l.eq_zero_or_pos with rfl | hl0, { simp },
obtain ⟨_, rfl⟩ := hmk,
obtain ⟨_, rfl⟩ := hnl,
rw [mul_mul_mul_comm, nat.mul_div_cancel_left _ hk0, nat.mul_div_cancel_left _ hl0,
nat.mul_div_cancel_left _ (mul_pos hk0 hl0)]
end
/-! ### `mod`, `dvd` -/
lemma two_mul_odd_div_two (hn : n % 2 = 1) : 2 * (n / 2) = n - 1 :=
by conv {to_rhs, rw [← nat.mod_add_div n 2, hn, add_tsub_cancel_left]}
lemma div_dvd_of_dvd (h : n ∣ m) : (m / n) ∣ m := ⟨n, (nat.div_mul_cancel h).symm⟩
protected lemma div_div_self (h : n ∣ m) (hm : m ≠ 0) : m / (m / n) = n :=
begin
rcases h with ⟨_, rfl⟩,
rw mul_ne_zero_iff at hm,
rw [mul_div_right _ (nat.pos_of_ne_zero hm.1), mul_div_left _ (nat.pos_of_ne_zero hm.2)]
end
lemma mod_mul_right_div_self (m n k : ℕ) : m % (n * k) / n = (m / n) % k :=
begin
rcases nat.eq_zero_or_pos n with rfl|hn, { simp },
rcases nat.eq_zero_or_pos k with rfl|hk, { simp },
conv_rhs { rw ← mod_add_div m (n * k) },
rw [mul_assoc, add_mul_div_left _ _ hn, add_mul_mod_self_left,
mod_eq_of_lt (nat.div_lt_of_lt_mul (mod_lt _ (mul_pos hn hk)))]
end
lemma mod_mul_left_div_self (m n k : ℕ) : m % (k * n) / n = (m / n) % k :=
by rw [mul_comm k, mod_mul_right_div_self]
lemma not_dvd_of_pos_of_lt (h1 : 0 < n) (h2 : n < m) : ¬ m ∣ n :=
begin
rintros ⟨k, rfl⟩,
rcases nat.eq_zero_or_pos k with (rfl | hk),
{ exact lt_irrefl 0 h1 },
{ exact not_lt.2 (le_mul_of_pos_right hk) h2 },
end
/-- If `m` and `n` are equal mod `k`, `m - n` is zero mod `k`. -/
lemma sub_mod_eq_zero_of_mod_eq (h : m % k = n % k) : (m - n) % k = 0 :=
by rw [←nat.mod_add_div m k, ←nat.mod_add_div n k, ←h, tsub_add_eq_tsub_tsub, add_tsub_cancel_left,
←mul_tsub, nat.mul_mod_right]
@[simp] lemma one_mod (n : ℕ) : 1 % (n + 2) = 1 := nat.mod_eq_of_lt (add_lt_add_right n.succ_pos 1)
lemma dvd_sub_mod (k : ℕ) : n ∣ (k - (k % n)) :=
⟨k / n, tsub_eq_of_eq_add_rev (nat.mod_add_div k n).symm⟩
lemma add_mod_eq_ite :
(m + n) % k = if k ≤ m % k + n % k then m % k + n % k - k else m % k + n % k :=
begin
cases k, { simp },
rw nat.add_mod,
split_ifs with h,
{ rw [nat.mod_eq_sub_mod h, nat.mod_eq_of_lt],
exact (tsub_lt_iff_right h).mpr
(nat.add_lt_add (m.mod_lt k.zero_lt_succ) (n.mod_lt k.zero_lt_succ)) },
{ exact nat.mod_eq_of_lt (lt_of_not_ge h) }
end
lemma div_mul_div_comm (hmn : n ∣ m) (hkl : l ∣ k) : (m / n) * (k / l) = (m * k) / (n * l) :=
have exi1 : ∃ x, m = n * x, from hmn,
have exi2 : ∃ y, k = l * y, from hkl,
if hn : n = 0 then by simp [hn]
else have 0 < n, from nat.pos_of_ne_zero hn,
if hl : l = 0 then by simp [hl]
else have 0 < l, from nat.pos_of_ne_zero hl,
begin
cases exi1 with x hx, cases exi2 with y hy,
rw [hx, hy, nat.mul_div_cancel_left, nat.mul_div_cancel_left],
symmetry,
apply nat.div_eq_of_eq_mul_left,
apply mul_pos,
repeat {assumption},
cc
end
lemma div_eq_self : m / n = m ↔ m = 0 ∨ n = 1 :=
begin
split,
{ intro,
cases n,
{ simp * at * },
{ cases n,
{ right, refl },
{ left,
have : m / (n + 2) ≤ m / 2 := div_le_div_left (by simp) dec_trivial,
refine eq_zero_of_le_half _,
simp * at * } } },
{ rintros (rfl|rfl); simp }
end
lemma div_eq_sub_mod_div : m / n = (m - m % n) / n :=
begin
by_cases n0 : n = 0,
{ rw [n0, nat.div_zero, nat.div_zero] },
{ rw [← mod_add_div m n] { occs := occurrences.pos [2] },
rw [add_tsub_cancel_left, mul_div_right _ (nat.pos_of_ne_zero n0)] }
end
/-- `m` is not divisible by `n` if it is between `n * k` and `n * (k + 1)` for some `k`. -/
lemma not_dvd_of_between_consec_multiples (h1 : n * k < m) (h2 : m < n * (k + 1)) : ¬ n ∣ m :=
begin
rintro ⟨d, rfl⟩,
exact monotone.ne_of_lt_of_lt_nat (covariant.monotone_of_const n) k h1 h2 d rfl
end
/-! ### `find` -/
section find
variables {p q : ℕ → Prop} [decidable_pred p] [decidable_pred q]
@[simp] lemma find_pos (h : ∃ n : ℕ, p n) : 0 < nat.find h ↔ ¬ p 0 :=
by rw [pos_iff_ne_zero, ne, nat.find_eq_zero]
lemma find_add {hₘ : ∃ m, p (m + n)} {hₙ : ∃ n, p n} (hn : n ≤ nat.find hₙ) :
nat.find hₘ + n = nat.find hₙ :=
begin
refine ((le_find_iff _ _).2 (λ m hm hpm, hm.not_le _)).antisymm _,
{ have hnm : n ≤ m := hn.trans (find_le hpm),
refine add_le_of_le_tsub_right_of_le hnm (find_le _),
rwa tsub_add_cancel_of_le hnm },
{ rw ←tsub_le_iff_right,
refine (le_find_iff _ _).2 (λ m hm hpm, hm.not_le _),
rw tsub_le_iff_right,
exact find_le hpm }
end
end find
/-! ### `find_greatest` -/
section find_greatest
variables {P Q : ℕ → Prop} [decidable_pred P]
lemma find_greatest_eq_iff :
nat.find_greatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ (∀ ⦃n⦄, m < n → n ≤ k → ¬P n) :=
begin
induction k with k ihk generalizing m,
{ rw [eq_comm, iff.comm],
simp only [nonpos_iff_eq_zero, ne.def, and_iff_left_iff_imp, find_greatest_zero],
rintro rfl,
exact ⟨λ h, (h rfl).elim, λ n hlt heq, (hlt.ne heq.symm).elim⟩ },
{ by_cases hk : P (k + 1),
{ rw [find_greatest_eq hk], split,
{ rintro rfl,
exact ⟨le_rfl, λ _, hk, λ n hlt hle, (hlt.not_le hle).elim⟩ },
{ rintros ⟨hle, h0, hm⟩,
rcases decidable.eq_or_lt_of_le hle with rfl|hlt,
exacts [rfl, (hm hlt le_rfl hk).elim] } },
{ rw [find_greatest_of_not hk, ihk],
split,
{ rintros ⟨hle, hP, hm⟩,
refine ⟨hle.trans k.le_succ, hP, λ n hlt hle, _⟩,
rcases decidable.eq_or_lt_of_le hle with rfl|hlt',
exacts [hk, hm hlt $ lt_succ_iff.1 hlt'] },
{ rintros ⟨hle, hP, hm⟩,
refine ⟨lt_succ_iff.1 (hle.lt_of_ne _), hP, λ n hlt hle, hm hlt (hle.trans k.le_succ)⟩,
rintro rfl,
exact hk (hP k.succ_ne_zero) } } }
end
lemma find_greatest_eq_zero_iff : nat.find_greatest P k = 0 ↔ ∀ ⦃n⦄, 0 < n → n ≤ k → ¬P n :=
by simp [find_greatest_eq_iff]
lemma find_greatest_spec (hmb : m ≤ n) (hm : P m) : P (nat.find_greatest P n) :=
begin
by_cases h : nat.find_greatest P n = 0,
{ cases m, { rwa h },
exact ((find_greatest_eq_zero_iff.1 h) m.zero_lt_succ hmb hm).elim },
{ exact (find_greatest_eq_iff.1 rfl).2.1 h }
end
lemma find_greatest_le (n : ℕ) : nat.find_greatest P n ≤ n := (find_greatest_eq_iff.1 rfl).1
lemma le_find_greatest (hmb : m ≤ n) (hm : P m) : m ≤ nat.find_greatest P n :=
le_of_not_lt $ λ hlt, (find_greatest_eq_iff.1 rfl).2.2 hlt hmb hm
lemma find_greatest_mono_right (P : ℕ → Prop) [decidable_pred P] : monotone (nat.find_greatest P) :=
begin
refine monotone_nat_of_le_succ (λ n, _),
rw [find_greatest_succ],
split_ifs,
{ exact (find_greatest_le n).trans (le_succ _) },
{ refl }
end
lemma find_greatest_mono_left [decidable_pred Q] (hPQ : P ≤ Q) :
nat.find_greatest P ≤ nat.find_greatest Q :=
begin
intro n,
induction n with n hn,
{ refl },
by_cases P (n + 1),
{ rw [find_greatest_eq h, find_greatest_eq (hPQ _ h)] },
{ rw find_greatest_of_not h,
exact hn.trans (nat.find_greatest_mono_right _ $ le_succ _) }
end
lemma find_greatest_mono [decidable_pred Q] (hPQ : P ≤ Q) (hmn : m ≤ n) :
nat.find_greatest P m ≤ nat.find_greatest Q n :=
(nat.find_greatest_mono_right _ hmn).trans $ find_greatest_mono_left hPQ _
lemma find_greatest_is_greatest (hk : nat.find_greatest P n < k) (hkb : k ≤ n) : ¬ P k :=
(find_greatest_eq_iff.1 rfl).2.2 hk hkb
lemma find_greatest_of_ne_zero (h : nat.find_greatest P n = m) (h0 : m ≠ 0) : P m :=
(find_greatest_eq_iff.1 h).2.1 h0
end find_greatest
/-! ### `bit0` and `bit1` -/
protected theorem bit0_le {n m : ℕ} (h : n ≤ m) : bit0 n ≤ bit0 m := add_le_add h h
protected theorem bit1_le {n m : ℕ} (h : n ≤ m) : bit1 n ≤ bit1 m := succ_le_succ (add_le_add h h)
theorem bit_le : ∀ (b : bool) {m n : ℕ}, m ≤ n → bit b m ≤ bit b n
| tt _ _ h := nat.bit1_le h
| ff _ _ h := nat.bit0_le h
theorem bit0_le_bit : ∀ (b) {m n : ℕ}, m ≤ n → bit0 m ≤ bit b n
| tt _ _ h := le_of_lt $ nat.bit0_lt_bit1 h
| ff _ _ h := nat.bit0_le h
theorem bit_le_bit1 : ∀ (b) {m n : ℕ}, m ≤ n → bit b m ≤ bit1 n
| ff _ _ h := le_of_lt $ nat.bit0_lt_bit1 h
| tt _ _ h := nat.bit1_le h
theorem bit_lt_bit0 : ∀ (b) {m n : ℕ}, m < n → bit b m < bit0 n
| tt _ _ h := nat.bit1_lt_bit0 h
| ff _ _ h := nat.bit0_lt h
theorem bit_lt_bit (a b) (h : m < n) : bit a m < bit b n :=
lt_of_lt_of_le (bit_lt_bit0 _ h) (bit0_le_bit _ le_rfl)
@[simp] lemma bit0_le_bit1_iff : bit0 m ≤ bit1 n ↔ m ≤ n :=
⟨λ h, by rwa [← nat.lt_succ_iff, n.bit1_eq_succ_bit0, ← n.bit0_succ_eq,
bit0_lt_bit0, nat.lt_succ_iff] at h, λ h, le_of_lt (nat.bit0_lt_bit1 h)⟩
@[simp] lemma bit0_lt_bit1_iff : bit0 m < bit1 n ↔ m ≤ n :=
⟨λ h, bit0_le_bit1_iff.1 (le_of_lt h), nat.bit0_lt_bit1⟩
@[simp] lemma bit1_le_bit0_iff : bit1 m ≤ bit0 n ↔ m < n :=
⟨λ h, by rwa [m.bit1_eq_succ_bit0, succ_le_iff, bit0_lt_bit0] at h,
λ h, le_of_lt (nat.bit1_lt_bit0 h)⟩
@[simp] lemma bit1_lt_bit0_iff : bit1 m < bit0 n ↔ m < n :=
⟨λ h, bit1_le_bit0_iff.1 (le_of_lt h), nat.bit1_lt_bit0⟩
@[simp] lemma one_le_bit0_iff : 1 ≤ bit0 n ↔ 0 < n :=
by { convert bit1_le_bit0_iff, refl, }
@[simp] lemma one_lt_bit0_iff : 1 < bit0 n ↔ 1 ≤ n :=
by { convert bit1_lt_bit0_iff, refl, }
@[simp] lemma bit_le_bit_iff : ∀ {b : bool}, bit b m ≤ bit b n ↔ m ≤ n
| ff := bit0_le_bit0
| tt := bit1_le_bit1
@[simp] lemma bit_lt_bit_iff : ∀ {b : bool}, bit b m < bit b n ↔ m < n
| ff := bit0_lt_bit0
| tt := bit1_lt_bit1
@[simp] lemma bit_le_bit1_iff : ∀ {b : bool}, bit b m ≤ bit1 n ↔ m ≤ n
| ff := bit0_le_bit1_iff
| tt := bit1_le_bit1
/-! ### decidability of predicates -/
instance decidable_lo_hi (lo hi : ℕ) (P : ℕ → Prop) [H : decidable_pred P] :
decidable (∀x, lo ≤ x → x < hi → P x) :=
decidable_of_iff (∀ x < hi - lo, P (lo + x))
⟨λal x hl hh, by { have := al (x - lo) ((tsub_lt_tsub_iff_right hl).mpr hh),
rwa [add_tsub_cancel_of_le hl] at this, },
λal x h, al _ (nat.le_add_right _ _) (lt_tsub_iff_left.mp h)⟩
instance decidable_lo_hi_le (lo hi : ℕ) (P : ℕ → Prop) [H : decidable_pred P] :
decidable (∀x, lo ≤ x → x ≤ hi → P x) :=
decidable_of_iff (∀x, lo ≤ x → x < hi + 1 → P x) $
ball_congr $ λ x hl, imp_congr lt_succ_iff iff.rfl
end nat
|
6c13c149342e0a94487b2483fa60537858b63cb8 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/tactic/fin_cases_auto.lean | 6289fdb610b1c0e02a529cd0da8382be95e2b836 | [] | 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,652 | lean | /-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Scott Morrison
Case bashing:
* on `x ∈ A`, for `A : finset α` or `A : list α`, or
* on `x : A`, with `[fintype A]`.
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.fintype.basic
import Mathlib.tactic.norm_num
import Mathlib.PostPort
namespace Mathlib
namespace tactic
/-- Checks that the expression looks like `x ∈ A` for `A : finset α`, `multiset α` or `A : list α`,
and returns the type α. -/
/--
`expr_list_to_list_expr` converts an `expr` of type `list α`
to a list of `expr`s each with type `α`.
TODO: this should be moved, and possibly duplicates an existing definition.
-/
/--
`fin_cases_at with_list e` performs case analysis on `e : α`, where `α` is a fintype.
The optional list of expressions `with_list` provides descriptions for the cases of `e`,
for example, to display nats as `n.succ` instead of `n+1`.
These should be defeq to and in the same order as the terms in the enumeration of `α`.
-/
namespace interactive
/--
`fin_cases h` performs case analysis on a hypothesis of the form
`h : A`, where `[fintype A]` is available, or
`h ∈ A`, where `A : finset X`, `A : multiset X` or `A : list X`.
`fin_cases *` performs case analysis on all suitable hypotheses.
As an example, in
```
example (f : ℕ → Prop) (p : fin 3) (h0 : f 0) (h1 : f 1) (h2 : f 2) : f p.val :=
begin
fin_cases *; simp,
all_goals { assumption }
end
```
after `fin_cases p; simp`, there are three goals, `f 0`, `f 1`, and `f 2`.
-/
end interactive
end Mathlib |
52f169ff56cba75db4c6b4cfcce0d564ac85a52d | fa02ed5a3c9c0adee3c26887a16855e7841c668b | /src/data/nat/pairing.lean | 8fad07d48f584cd8f71cac25e26088923a903f6b | [
"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,316 | 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, Mario Carneiro
-/
import data.nat.sqrt
import data.set.lattice
/-!
# Naturals pairing function
This file defines a pairing function for the naturals as follows:
0 1 4 9 16
2 3 5 10 17
6 7 8 11 18
12 13 14 15 19
20 21 22 23 24
It has the advantage of being monotone in both directions and sending `⟦0, n^2 - 1⟧` to
`⟦0, n - 1⟧²`.
-/
open prod decidable function
namespace nat
/-- Pairing function for the natural numbers. -/
def mkpair (a b : ℕ) : ℕ :=
if a < b then b*b + a else a*a + a + b
/-- Unpairing function for the natural numbers. -/
def unpair (n : ℕ) : ℕ × ℕ :=
let s := sqrt n in
if n - s*s < s then (n - s*s, s) else (s, n - s*s - s)
@[simp] theorem mkpair_unpair (n : ℕ) : mkpair (unpair n).1 (unpair n).2 = n :=
let s := sqrt n in begin
dsimp [unpair], change sqrt n with s,
have sm : s * s + (n - s * s) = n := nat.add_sub_cancel' (sqrt_le _),
by_cases h : n - s * s < s; simp [h, mkpair],
{ exact sm },
{ have hl : n - s*s - s ≤ s :=
nat.sub_le_left_of_le_add (nat.sub_le_left_of_le_add $
by rw ← add_assoc; apply sqrt_le_add),
suffices : s * s + (s + (n - s * s - s)) = n, {simpa [not_lt_of_ge hl, add_assoc]},
rwa [nat.add_sub_cancel' (le_of_not_gt h)] }
end
theorem mkpair_unpair' {n a b} (H : unpair n = (a, b)) : mkpair a b = n :=
by simpa [H] using mkpair_unpair n
@[simp] theorem unpair_mkpair (a b : ℕ) : unpair (mkpair a b) = (a, b) :=
begin
by_cases a < b; simp [h, mkpair],
{ show unpair (b * b + a) = (a, b),
have be : sqrt (b * b + a) = b,
{ rw sqrt_add_eq, exact le_trans (le_of_lt h) (le_add_left _ _) },
simp [unpair, be, nat.add_sub_cancel, h] },
{ show unpair (a * a + a + b) = (a, b),
have ae : sqrt (a * a + (a + b)) = a,
{ rw sqrt_add_eq, exact add_le_add_left (le_of_not_gt h) _ },
simp [unpair, ae, not_lt_zero, add_assoc] }
end
lemma surjective_unpair : surjective unpair :=
λ ⟨m, n⟩, ⟨mkpair m n, unpair_mkpair m n⟩
theorem unpair_lt {n : ℕ} (n1 : 1 ≤ n) : (unpair n).1 < n :=
let s := sqrt n in begin
simp [unpair], change sqrt n with s,
by_cases h : n - s * s < s; simp [h],
{ exact lt_of_lt_of_le h (sqrt_le_self _) },
{ simp at h,
have s0 : 0 < s := sqrt_pos.2 n1,
exact lt_of_le_of_lt h (nat.sub_lt_self n1 (mul_pos s0 s0)) }
end
@[simp] lemma unpair_zero : unpair 0 = 0 :=
by { rw unpair, simp }
theorem unpair_left_le : ∀ (n : ℕ), (unpair n).1 ≤ n
| 0 := by simp
| (n+1) := le_of_lt (unpair_lt (nat.succ_pos _))
theorem left_le_mkpair (a b : ℕ) : a ≤ mkpair a b :=
by simpa using unpair_left_le (mkpair a b)
theorem right_le_mkpair (a b : ℕ) : b ≤ mkpair a b :=
begin
by_cases h : a < b; simp [mkpair, h],
exact le_trans (le_mul_self _) (le_add_right _ _)
end
theorem unpair_right_le (n : ℕ) : (unpair n).2 ≤ n :=
by simpa using right_le_mkpair n.unpair.1 n.unpair.2
theorem mkpair_lt_mkpair_left {a₁ a₂} (b) (h : a₁ < a₂) : mkpair a₁ b < mkpair a₂ b :=
begin
by_cases h₁ : a₁ < b; simp [mkpair, h₁, add_assoc],
{ by_cases h₂ : a₂ < b; simp [mkpair, h₂, h],
simp at h₂,
apply add_lt_add_of_le_of_lt,
exact mul_self_le_mul_self h₂,
exact lt_add_right _ _ _ h },
{ simp at h₁,
simp [not_lt_of_gt (lt_of_le_of_lt h₁ h)],
apply add_lt_add,
exact mul_self_lt_mul_self h,
apply add_lt_add_right; assumption }
end
theorem mkpair_lt_mkpair_right (a) {b₁ b₂} (h : b₁ < b₂) : mkpair a b₁ < mkpair a b₂ :=
begin
by_cases h₁ : a < b₁; simp [mkpair, h₁, add_assoc],
{ simp [mkpair, lt_trans h₁ h, h],
exact mul_self_lt_mul_self h },
{ by_cases h₂ : a < b₂; simp [mkpair, h₂, h],
simp at h₁,
rw [add_comm, add_comm _ a, add_assoc, add_lt_add_iff_left],
rwa [add_comm, ← sqrt_lt, sqrt_add_eq],
exact le_trans h₁ (le_add_left _ _) }
end
end nat
open nat
namespace set
lemma Union_unpair_prod {α β} {s : ℕ → set α} {t : ℕ → set β} :
(⋃ n : ℕ, (s n.unpair.fst).prod (t n.unpair.snd)) = (⋃ n, s n).prod (⋃ n, t n) :=
by { rw [← Union_prod], convert surjective_unpair.Union_comp _, refl }
end set
|
c56eded3ac755185dd11d5f36fd19b3400538a3c | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/ring_theory/polynomial/default.lean | c8fd4bbc3c6e863c9d832564544a3d932f2b9c3e | [] | 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 | 148 | lean | import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.ring_theory.polynomial.basic
import Mathlib.PostPort
namespace Mathlib
|
c865d905300159a087a5a82801a2865303bcfba1 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/run/IO3.lean | 5b279d218e2a6492aac8a96dd2663d6879cdcaa1 | [
"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 | 218 | lean | import system.io
open io
def main : io unit :=
do { l ← get_line,
if l = "hello" then
put_str "you have typed hello\n"
else
do {put_str "you did not type hello\n", put_str "-----------\n"} }
|
7cb05ec7ae2c981ae6d6f092c6f98f728a5bd7b5 | 958488bc7f3c2044206e0358e56d7690b6ae696c | /lean/structure.lean | d1e544dd3c5d9f6998af7dcf20e546d863dab705 | [] | no_license | possientis/Prog | a08eec1c1b121c2fd6c70a8ae89e2fbef952adb4 | d4b3debc37610a88e0dac3ac5914903604fd1d1f | refs/heads/master | 1,692,263,717,723 | 1,691,757,179,000 | 1,691,757,179,000 | 40,361,602 | 3 | 0 | null | 1,679,896,438,000 | 1,438,953,859,000 | Coq | UTF-8 | Lean | false | false | 1,964 | lean | structure Point (α : Type) :=
mk :: (x : α) (y : α)
--#check Point
--#check @Point.rec_on
--#check @Point.x
--#check @Point.y
--#print prefix Point
--#reduce Point.x (Point.mk 10 20)
--#reduce Point.y (Point.mk 10 20)
open Point
example (α : Type) (a b : α) : x (mk a b) = a := rfl
example (α : Type) (a b : α) : x {x := a, y := b} = a := rfl
example (α : Type) (a b : α) : y (mk a b) = b := rfl
example (α : Type) (a b : α) : y {x := a, y := b} = b := rfl
def p : Point ℕ := {x := 10, y := 20} -- mk 10 20
--#check p.x
--#reduce p.x
--#reduce p.y
structure Prod (α : Type) (β : Type) : Type := (pr₁ : α) (pr₂ : β)
--#check @Prod.mk
namespace Point
def add (p q : Point ℕ) : Point ℕ := {x := p.x + q.x, y := p.y + q.y}
end Point
--#check Point.add
def q : Point ℕ := { x := 15, y := 20}
--#reduce p.add q
open Point
--#reduce add p q
def Point.smul (n : ℕ) (p : Point ℕ) : Point ℕ := {x := n * p.x, y := n * p.y}
--#reduce p.smul 3
--#check @list.map
def xs : list ℕ := [1, 2, 3]
def f : ℕ → ℕ := λ n, n * n
--#reduce xs.map f
--#reduce list.map f xs
--#eval xs.map f
--#eval list.map f xs
--3 ways of making things polymorphic over universe level
universe u
structure Point1 (α : Type u) : Type u :=
mk :: (x : α) (y : α)
structure {v} Point2 (α : Type v) :=
mk :: (x : α) (y : α)
structure Point3 (α : Type _) :=
mk :: (x : α) (y : α)
--#check @Point1
--#check @Point2
--#check @Point3
-- max 1 u : result can never be a Prop = Type 0 (I thought Type 0 = Sort 1 and Prop = Sort 0)
structure {v} Prod1 (α : Type v) (β : Type v) : Type (max 1 v) :=
mk :: (pr1 : α) (pr2 : β)
set_option pp.universes true -- forces Lean to display universes
--#check @Prod1.mk
-- using anonymous constructor
structure {v} Prod2 (α : Type v) (β : Type v) : Type (max 1 v) :=
(pr1 : α) (pr2 : β)
example : Prod2 ℕ ℕ := ⟨1,2⟩
--#check (⟨1,2⟩ : Prod2 ℕ ℕ)
|
a644318324445da416e2343a4063af4e170517a0 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/algebra/gcd_monoid/div.lean | 2c7616974c314378584138ec950d900dd5eb05d8 | [
"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,155 | lean | /-
Copyright (c) 2022 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import algebra.gcd_monoid.finset
import algebra.gcd_monoid.basic
import ring_theory.int.basic
import ring_theory.polynomial.content
/-!
# Basic results about setwise gcds on normalized gcd monoid with a division.
## Main results
* `finset.nat.gcd_div_eq_one`: given a nonempty finset `s` and a function `f` from `s` to
`ℕ`, if `d = s.gcd`, then the `gcd` of `(f i) / d` equals `1`.
* `finset.int.gcd_div_eq_one`: given a nonempty finset `s` and a function `f` from `s` to
`ℤ`, if `d = s.gcd`, then the `gcd` of `(f i) / d` equals `1`.
* `finset.polynomial.gcd_div_eq_one`: given a nonempty finset `s` and a function `f` from
`s` to `K[X]`, if `d = s.gcd`, then the `gcd` of `(f i) / d` equals `1`.
## TODO
Add a typeclass to state these results uniformly.
-/
namespace finset
namespace nat
/-- Given a nonempty finset `s` and a function `f` from `s` to `ℕ`, if `d = s.gcd`,
then the `gcd` of `(f i) / d` is equal to `1`. -/
theorem gcd_div_eq_one {β : Type*} {f : β → ℕ} (s : finset β) {x : β} (hx : x ∈ s)
(hfz : f x ≠ 0) : s.gcd (λ b, f b / s.gcd f) = 1 :=
begin
obtain ⟨g, he, hg⟩ := finset.extract_gcd f ⟨x, hx⟩,
refine (finset.gcd_congr rfl $ λ a ha, _).trans hg,
rw [he a ha, nat.mul_div_cancel_left],
exact nat.pos_of_ne_zero (mt finset.gcd_eq_zero_iff.1 (λ h, hfz $ h x hx)),
end
theorem gcd_div_id_eq_one {s : finset ℕ} {x : ℕ} (hx : x ∈ s) (hnz : x ≠ 0) :
s.gcd (λ b, b / s.gcd id) = 1 :=
gcd_div_eq_one s hx hnz
end nat
namespace int
/-- Given a nonempty finset `s` and a function `f` from `s` to `ℤ`, if `d = s.gcd`,
then the `gcd` of `(f i) / d` is equal to `1`. -/
theorem gcd_div_eq_one {β : Type*} {f : β → ℤ} (s : finset β) {x : β} (hx : x ∈ s)
(hfz : f x ≠ 0) : s.gcd (λ b, f b / s.gcd f) = 1 :=
begin
obtain ⟨g, he, hg⟩ := finset.extract_gcd f ⟨x, hx⟩,
refine (finset.gcd_congr rfl $ λ a ha, _).trans hg,
rw [he a ha, int.mul_div_cancel_left],
exact mt finset.gcd_eq_zero_iff.1 (λ h, hfz $ h x hx),
end
theorem gcd_div_id_eq_one {s : finset ℤ} {x : ℤ} (hx : x ∈ s) (hnz : x ≠ 0) :
s.gcd (λ b, b / s.gcd id) = 1 :=
gcd_div_eq_one s hx hnz
end int
namespace polynomial
open_locale polynomial classical
noncomputable theory
variables {K : Type*} [field K]
/-- Given a nonempty finset `s` and a function `f` from `s` to `K[X]`, if `d = s.gcd f`,
then the `gcd` of `(f i) / d` is equal to `1`. -/
theorem gcd_div_eq_one {β : Type*} {f : β → K[X]} (s : finset β) {x : β} (hx : x ∈ s)
(hfz : f x ≠ 0) : s.gcd (λ b, f b / s.gcd f) = 1 :=
begin
obtain ⟨g, he, hg⟩ := finset.extract_gcd f ⟨x, hx⟩,
refine (finset.gcd_congr rfl $ λ a ha, _).trans hg,
rw [he a ha, euclidean_domain.mul_div_cancel_left],
exact mt finset.gcd_eq_zero_iff.1 (λ h, hfz $ h x hx),
end
theorem gcd_div_id_eq_one {s : finset K[X]} {x : K[X]} (hx : x ∈ s) (hnz : x ≠ 0) :
s.gcd (λ b, b / s.gcd id) = 1 :=
gcd_div_eq_one s hx hnz
end polynomial
end finset
|
7c4026a7f448b9758fa46049279c7da447174f35 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/lean/run/2074.lean | 7d81ea356c701b2e3b581f64905ca0ec5777f806 | [
"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,963 | lean | class NonUnitalNonAssocSemiring (α : Type u)
class NonUnitalSemiring (α : Type u) extends NonUnitalNonAssocSemiring α
class Semiring (α : Type u) extends NonUnitalSemiring α
class NonUnitalCommSemiring (α : Type u) extends NonUnitalSemiring α
class CommSemiring (R : Type u) extends Semiring R
class NonUnitalNonAssocRing (α : Type u) extends NonUnitalNonAssocSemiring α
class NonUnitalRing (α : Type _) extends NonUnitalNonAssocRing α, NonUnitalSemiring α
class Ring (R : Type u) extends Semiring R
class NonUnitalCommRing (α : Type u) extends NonUnitalRing α
class CommRing (α : Type u) extends Ring α
instance (priority := 100) NonUnitalCommRing.toNonUnitalCommSemiring [s : NonUnitalCommRing α] :
NonUnitalCommSemiring α :=
{ s with }
instance (priority := 100) CommRing.toCommSemiring [s : CommRing α] : CommSemiring α :=
{ s with }
instance (priority := 100) CommSemiring.toNonUnitalCommSemiring [s : CommSemiring α] :
NonUnitalCommSemiring α :=
{ s with }
instance (priority := 100) CommRing.toNonUnitalCommRing [s : CommRing α] : NonUnitalCommRing α :=
{ s with }
class StarRing' (R : Type _) [NonUnitalSemiring R]
def starGizmo [CommSemiring R] [StarRing' R] : R → R := id
theorem starGizmo_foo [CommRing R] [StarRing' R] (x : R) : starGizmo x = x := rfl
namespace ReidMWE
class A (α : Type u)
class B (α : Type u) extends A α
class C (α : Type u) extends B α
class D (α : Type u) extends B α
class E (α : Type u) extends C α, D α
class F (α : Type u) extends A α
class G (α : Type u) extends F α, B α
class H (α : Type u) extends C α
class I (α : Type u) extends G α, D α
class J (α : Type u) extends H α, I α, E α
class StarRing' (R : Type 0) [B R]
def starGizmo [E R] [StarRing' R] : R → R := id
theorem starGizmo_foo [J R] [StarRing' R] (x : R) : starGizmo x = x := rfl
theorem T (i : J R) : (@D.toB.{0} R (@E.toD.{0} R (@J.toE.{0} R i))) = i.toB := rfl
|
8a03dda41bbdc41d4a2e33ed00aa973b61d6875b | bbecf0f1968d1fba4124103e4f6b55251d08e9c4 | /src/algebra/lie/classical.lean | cf92304dcce18dbc09f277b8731f1333b63b8816 | [
"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 | 13,718 | lean | /-
Copyright (c) 2020 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import algebra.invertible
import algebra.lie.skew_adjoint
import algebra.lie.abelian
import linear_algebra.matrix.trace
import linear_algebra.matrix.transvection
import data.matrix.basis
/-!
# Classical Lie algebras
This file is the place to find definitions and basic properties of the classical Lie algebras:
* Aₗ = sl(l+1)
* Bₗ ≃ so(l+1, l) ≃ so(2l+1)
* Cₗ = sp(l)
* Dₗ ≃ so(l, l) ≃ so(2l)
## Main definitions
* `lie_algebra.special_linear.sl`
* `lie_algebra.symplectic.sp`
* `lie_algebra.orthogonal.so`
* `lie_algebra.orthogonal.so'`
* `lie_algebra.orthogonal.so_indefinite_equiv`
* `lie_algebra.orthogonal.type_D`
* `lie_algebra.orthogonal.type_B`
* `lie_algebra.orthogonal.type_D_equiv_so'`
* `lie_algebra.orthogonal.type_B_equiv_so'`
## Implementation notes
### Matrices or endomorphisms
Given a finite type and a commutative ring, the corresponding square matrices are equivalent to the
endomorphisms of the corresponding finite-rank free module as Lie algebras, see `lie_equiv_matrix'`.
We can thus define the classical Lie algebras as Lie subalgebras either of matrices or of
endomorphisms. We have opted for the former. At the time of writing (August 2020) it is unclear
which approach should be preferred so the choice should be assumed to be somewhat arbitrary.
### Diagonal quadratic form or diagonal Cartan subalgebra
For the algebras of type `B` and `D`, there are two natural definitions. For example since the
the `2l × 2l` matrix:
$$
J = \left[\begin{array}{cc}
0_l & 1_l\\
1_l & 0_l
\end{array}\right]
$$
defines a symmetric bilinear form equivalent to that defined by the identity matrix `I`, we can
define the algebras of type `D` to be the Lie subalgebra of skew-adjoint matrices either for `J` or
for `I`. Both definitions have their advantages (in particular the `J`-skew-adjoint matrices define
a Lie algebra for which the diagonal matrices form a Cartan subalgebra) and so we provide both.
We thus also provide equivalences `type_D_equiv_so'`, `so_indefinite_equiv` which show the two
definitions are equivalent. Similarly for the algebras of type `B`.
## Tags
classical lie algebra, special linear, symplectic, orthogonal
-/
universes u₁ u₂
namespace lie_algebra
open matrix
open_locale matrix
variables (n p q l : Type*) (R : Type u₂)
variables [decidable_eq n] [decidable_eq p] [decidable_eq q] [decidable_eq l]
variables [comm_ring R]
@[simp] lemma matrix_trace_commutator_zero [fintype n] (X Y : matrix n n R) :
matrix.trace n R R ⁅X, Y⁆ = 0 :=
calc _ = matrix.trace n R R (X ⬝ Y) - matrix.trace n R R (Y ⬝ X) : linear_map.map_sub _ _ _
... = matrix.trace n R R (X ⬝ Y) - matrix.trace n R R (X ⬝ Y) :
congr_arg (λ x, _ - x) (matrix.trace_mul_comm X Y)
... = 0 : sub_self _
namespace special_linear
/-- The special linear Lie algebra: square matrices of trace zero. -/
def sl [fintype n] : lie_subalgebra R (matrix n n R) :=
{ lie_mem' := λ X Y _ _, linear_map.mem_ker.2 $ matrix_trace_commutator_zero _ _ _ _,
..linear_map.ker (matrix.trace n R R) }
lemma sl_bracket [fintype n] (A B : sl n R) : ⁅A, B⁆.val = A.val ⬝ B.val - B.val ⬝ A.val := rfl
section elementary_basis
variables {n} [fintype n] (i j : n)
/-- When j ≠ i, the elementary matrices are elements of sl n R, in fact they are part of a natural
basis of sl n R. -/
def Eb (h : j ≠ i) : sl n R :=
⟨matrix.std_basis_matrix i j (1 : R),
show matrix.std_basis_matrix i j (1 : R) ∈ linear_map.ker (matrix.trace n R R),
from matrix.std_basis_matrix.trace_zero i j (1 : R) h⟩
@[simp] lemma Eb_val (h : j ≠ i) : (Eb R i j h).val = matrix.std_basis_matrix i j 1 := rfl
end elementary_basis
lemma sl_non_abelian [fintype n] [nontrivial R] (h : 1 < fintype.card n) :
¬is_lie_abelian ↥(sl n R) :=
begin
rcases fintype.exists_pair_of_one_lt_card h with ⟨j, i, hij⟩,
let A := Eb R i j hij,
let B := Eb R j i hij.symm,
intros c,
have c' : A.val ⬝ B.val = B.val ⬝ A.val, by { rw [← sub_eq_zero, ← sl_bracket, c.trivial], refl },
simpa [std_basis_matrix, matrix.mul_apply, hij] using congr_fun (congr_fun c' i) i,
end
end special_linear
namespace symplectic
/-- The matrix defining the canonical skew-symmetric bilinear form. -/
def J : matrix (l ⊕ l) (l ⊕ l) R := matrix.from_blocks 0 (-1) 1 0
/-- The symplectic Lie algebra: skew-adjoint matrices with respect to the canonical skew-symmetric
bilinear form. -/
def sp [fintype l] : lie_subalgebra R (matrix (l ⊕ l) (l ⊕ l) R) :=
skew_adjoint_matrices_lie_subalgebra (J l R)
end symplectic
namespace orthogonal
/-- The definite orthogonal Lie subalgebra: skew-adjoint matrices with respect to the symmetric
bilinear form defined by the identity matrix. -/
def so [fintype n] : lie_subalgebra R (matrix n n R) :=
skew_adjoint_matrices_lie_subalgebra (1 : matrix n n R)
@[simp] lemma mem_so [fintype n] (A : matrix n n R) : A ∈ so n R ↔ Aᵀ = -A :=
begin
erw mem_skew_adjoint_matrices_submodule,
simp only [matrix.is_skew_adjoint, matrix.is_adjoint_pair, matrix.mul_one, matrix.one_mul],
end
/-- The indefinite diagonal matrix with `p` 1s and `q` -1s. -/
def indefinite_diagonal : matrix (p ⊕ q) (p ⊕ q) R :=
matrix.diagonal $ sum.elim (λ _, 1) (λ _, -1)
/-- The indefinite orthogonal Lie subalgebra: skew-adjoint matrices with respect to the symmetric
bilinear form defined by the indefinite diagonal matrix. -/
def so' [fintype p] [fintype q] : lie_subalgebra R (matrix (p ⊕ q) (p ⊕ q) R) :=
skew_adjoint_matrices_lie_subalgebra $ indefinite_diagonal p q R
/-- A matrix for transforming the indefinite diagonal bilinear form into the definite one, provided
the parameter `i` is a square root of -1. -/
def Pso (i : R) : matrix (p ⊕ q) (p ⊕ q) R :=
matrix.diagonal $ sum.elim (λ _, 1) (λ _, i)
variables [fintype p] [fintype q]
lemma Pso_inv {i : R} (hi : i*i = -1) : (Pso p q R i) * (Pso p q R (-i)) = 1 :=
begin
ext x y, rcases x; rcases y,
{ -- x y : p
by_cases h : x = y; simp [Pso, indefinite_diagonal, h], },
{ -- x : p, y : q
simp [Pso, indefinite_diagonal], },
{ -- x : q, y : p
simp [Pso, indefinite_diagonal], },
{ -- x y : q
by_cases h : x = y; simp [Pso, indefinite_diagonal, h, hi], },
end
lemma is_unit_Pso {i : R} (hi : i*i = -1) : is_unit (Pso p q R i) :=
⟨{ val := Pso p q R i,
inv := Pso p q R (-i),
val_inv := Pso_inv p q R hi,
inv_val := by { apply matrix.nonsing_inv_left_right, exact Pso_inv p q R hi, }, },
rfl⟩
lemma indefinite_diagonal_transform {i : R} (hi : i*i = -1) :
(Pso p q R i)ᵀ ⬝ (indefinite_diagonal p q R) ⬝ (Pso p q R i) = 1 :=
begin
ext x y, rcases x; rcases y,
{ -- x y : p
by_cases h : x = y; simp [Pso, indefinite_diagonal, h], },
{ -- x : p, y : q
simp [Pso, indefinite_diagonal], },
{ -- x : q, y : p
simp [Pso, indefinite_diagonal], },
{ -- x y : q
by_cases h : x = y; simp [Pso, indefinite_diagonal, h, hi], },
end
/-- An equivalence between the indefinite and definite orthogonal Lie algebras, over a ring
containing a square root of -1. -/
noncomputable def so_indefinite_equiv {i : R} (hi : i*i = -1) : so' p q R ≃ₗ⁅R⁆ so (p ⊕ q) R :=
begin
apply (skew_adjoint_matrices_lie_subalgebra_equiv
(indefinite_diagonal p q R) (Pso p q R i) (is_unit_Pso p q R hi)).trans,
apply lie_equiv.of_eq,
ext A, rw indefinite_diagonal_transform p q R hi, refl,
end
lemma so_indefinite_equiv_apply {i : R} (hi : i*i = -1) (A : so' p q R) :
(so_indefinite_equiv p q R hi A : matrix (p ⊕ q) (p ⊕ q) R) =
(Pso p q R i)⁻¹ ⬝ (A : matrix (p ⊕ q) (p ⊕ q) R) ⬝ (Pso p q R i) :=
by erw [lie_equiv.trans_apply, lie_equiv.of_eq_apply,
skew_adjoint_matrices_lie_subalgebra_equiv_apply]
/-- A matrix defining a canonical even-rank symmetric bilinear form.
It looks like this as a `2l x 2l` matrix of `l x l` blocks:
[ 0 1 ]
[ 1 0 ]
-/
def JD : matrix (l ⊕ l) (l ⊕ l) R := matrix.from_blocks 0 1 1 0
/-- The classical Lie algebra of type D as a Lie subalgebra of matrices associated to the matrix
`JD`. -/
def type_D [fintype l] := skew_adjoint_matrices_lie_subalgebra (JD l R)
/-- A matrix transforming the bilinear form defined by the matrix `JD` into a split-signature
diagonal matrix.
It looks like this as a `2l x 2l` matrix of `l x l` blocks:
[ 1 -1 ]
[ 1 1 ]
-/
def PD : matrix (l ⊕ l) (l ⊕ l) R := matrix.from_blocks 1 (-1) 1 1
/-- The split-signature diagonal matrix. -/
def S := indefinite_diagonal l l R
lemma S_as_blocks : S l R = matrix.from_blocks 1 0 0 (-1) :=
begin
rw [← matrix.diagonal_one, matrix.diagonal_neg, matrix.from_blocks_diagonal],
refl,
end
lemma JD_transform [fintype l] : (PD l R)ᵀ ⬝ (JD l R) ⬝ (PD l R) = (2 : R) • (S l R) :=
begin
have h : (PD l R)ᵀ ⬝ (JD l R) = matrix.from_blocks 1 1 1 (-1) := by
{ simp [PD, JD, matrix.from_blocks_transpose, matrix.from_blocks_multiply], },
erw [h, S_as_blocks, matrix.from_blocks_multiply, matrix.from_blocks_smul],
congr; simp [two_smul],
end
lemma PD_inv [fintype l] [invertible (2 : R)] : (PD l R) * (⅟(2 : R) • (PD l R)ᵀ) = 1 :=
begin
have h : ⅟(2 : R) • (1 : matrix l l R) + ⅟(2 : R) • 1 = 1 := by
rw [← smul_add, ← (two_smul R _), smul_smul, inv_of_mul_self, one_smul],
erw [matrix.from_blocks_transpose, matrix.from_blocks_smul, matrix.mul_eq_mul,
matrix.from_blocks_multiply],
simp [h],
end
lemma is_unit_PD [fintype l] [invertible (2 : R)] : is_unit (PD l R) :=
⟨{ val := PD l R,
inv := ⅟(2 : R) • (PD l R)ᵀ,
val_inv := PD_inv l R,
inv_val := by { apply matrix.nonsing_inv_left_right, exact PD_inv l R, }, },
rfl⟩
/-- An equivalence between two possible definitions of the classical Lie algebra of type D. -/
noncomputable def type_D_equiv_so' [fintype l] [invertible (2 : R)] :
type_D l R ≃ₗ⁅R⁆ so' l l R :=
begin
apply (skew_adjoint_matrices_lie_subalgebra_equiv (JD l R) (PD l R) (is_unit_PD l R)).trans,
apply lie_equiv.of_eq,
ext A,
rw [JD_transform, ← coe_unit_of_invertible (2 : R), ←units.smul_def, lie_subalgebra.mem_coe,
mem_skew_adjoint_matrices_lie_subalgebra_unit_smul],
refl,
end
/-- A matrix defining a canonical odd-rank symmetric bilinear form.
It looks like this as a `(2l+1) x (2l+1)` matrix of blocks:
[ 2 0 0 ]
[ 0 0 1 ]
[ 0 1 0 ]
where sizes of the blocks are:
[`1 x 1` `1 x l` `1 x l`]
[`l x 1` `l x l` `l x l`]
[`l x 1` `l x l` `l x l`]
-/
def JB := matrix.from_blocks ((2 : R) • 1 : matrix unit unit R) 0 0 (JD l R)
/-- The classical Lie algebra of type B as a Lie subalgebra of matrices associated to the matrix
`JB`. -/
def type_B [fintype l] := skew_adjoint_matrices_lie_subalgebra(JB l R)
/-- A matrix transforming the bilinear form defined by the matrix `JB` into an
almost-split-signature diagonal matrix.
It looks like this as a `(2l+1) x (2l+1)` matrix of blocks:
[ 1 0 0 ]
[ 0 1 -1 ]
[ 0 1 1 ]
where sizes of the blocks are:
[`1 x 1` `1 x l` `1 x l`]
[`l x 1` `l x l` `l x l`]
[`l x 1` `l x l` `l x l`]
-/
def PB := matrix.from_blocks (1 : matrix unit unit R) 0 0 (PD l R)
variable [fintype l]
lemma PB_inv [invertible (2 : R)] : (PB l R) * (matrix.from_blocks 1 0 0 (PD l R)⁻¹) = 1 :=
begin
simp [PB, matrix.from_blocks_multiply, (PD l R).mul_nonsing_inv, is_unit_PD,
← (PD l R).is_unit_iff_is_unit_det]
end
lemma is_unit_PB [invertible (2 : R)] : is_unit (PB l R) :=
⟨{ val := PB l R,
inv := matrix.from_blocks 1 0 0 (PD l R)⁻¹,
val_inv := PB_inv l R,
inv_val := by { apply matrix.nonsing_inv_left_right, exact PB_inv l R, }, },
rfl⟩
lemma JB_transform : (PB l R)ᵀ ⬝ (JB l R) ⬝ (PB l R) = (2 : R) • matrix.from_blocks 1 0 0 (S l R) :=
by simp [PB, JB, JD_transform, matrix.from_blocks_transpose, matrix.from_blocks_multiply,
matrix.from_blocks_smul]
lemma indefinite_diagonal_assoc :
indefinite_diagonal (unit ⊕ l) l R =
matrix.reindex_lie_equiv (equiv.sum_assoc unit l l).symm
(matrix.from_blocks 1 0 0 (indefinite_diagonal l l R)) :=
begin
ext i j,
rcases i with ⟨⟨i₁ | i₂⟩ | i₃⟩;
rcases j with ⟨⟨j₁ | j₂⟩ | j₃⟩;
simp only [indefinite_diagonal, matrix.diagonal, equiv.sum_assoc_apply_in1,
matrix.reindex_lie_equiv_apply, matrix.minor_apply, equiv.symm_symm, matrix.reindex_apply,
sum.elim_inl, if_true, eq_self_iff_true, matrix.one_apply_eq, matrix.from_blocks_apply₁₁,
dmatrix.zero_apply, equiv.sum_assoc_apply_in2, if_false, matrix.from_blocks_apply₁₂,
matrix.from_blocks_apply₂₁, matrix.from_blocks_apply₂₂, equiv.sum_assoc_apply_in3,
sum.elim_inr];
congr,
end
/-- An equivalence between two possible definitions of the classical Lie algebra of type B. -/
noncomputable def type_B_equiv_so' [invertible (2 : R)] :
type_B l R ≃ₗ⁅R⁆ so' (unit ⊕ l) l R :=
begin
apply (skew_adjoint_matrices_lie_subalgebra_equiv (JB l R) (PB l R) (is_unit_PB l R)).trans,
symmetry,
apply (skew_adjoint_matrices_lie_subalgebra_equiv_transpose
(indefinite_diagonal (unit ⊕ l) l R)
(matrix.reindex_alg_equiv _ (equiv.sum_assoc punit l l)) (matrix.transpose_reindex _ _)).trans,
apply lie_equiv.of_eq,
ext A,
rw [JB_transform, ← coe_unit_of_invertible (2 : R), ←units.smul_def, lie_subalgebra.mem_coe,
lie_subalgebra.mem_coe, mem_skew_adjoint_matrices_lie_subalgebra_unit_smul],
simpa [indefinite_diagonal_assoc],
end
end orthogonal
end lie_algebra
|
0aae9f14b489d062347be180e99dd772a9663701 | fcf3ffa92a3847189ca669cb18b34ef6b2ec2859 | /src/world6/level6.lean | ece67728cfdb4ae577d1b7873fea1faf872c8d14 | [
"Apache-2.0"
] | permissive | nomoid/lean-proofs | 4a80a97888699dee42b092b7b959b22d9aa0c066 | b9f03a24623d1a1d111d6c2bbf53c617e2596d6a | refs/heads/master | 1,674,955,317,080 | 1,607,475,706,000 | 1,607,475,706,000 | 314,104,281 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 214 | lean | example (P Q R : Type) : (P → (Q → R)) → ((P → Q) → (P → R)) :=
begin
intro f,
intro g,
intro p,
apply f,
{
exact p,
},
{
apply g,
exact p,
}
end
|
cfc1d48717589c0dcb703b984f1c75bf8361f35c | 130c49f47783503e462c16b2eff31933442be6ff | /stage0/src/Lean/Data/Parsec.lean | b7ab019d02c3558d8b06bfddccc5b510618b4fe6 | [
"Apache-2.0"
] | permissive | Hazel-Brown/lean4 | 8aa5860e282435ffc30dcdfccd34006c59d1d39c | 79e6732fc6bbf5af831b76f310f9c488d44e7a16 | refs/heads/master | 1,689,218,208,951 | 1,629,736,869,000 | 1,629,736,896,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 4,240 | lean |
/-
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Dany Fabian
-/
namespace Lean
namespace Parsec
inductive ParseResult (α : Type) where
| success (pos : String.Iterator) (res : α)
| error (pos : String.Iterator) (err : String)
deriving Repr
end Parsec
def Parsec (α : Type) : Type := String.Iterator → Lean.Parsec.ParseResult α
namespace Parsec
open ParseResult
instance (α : Type) : Inhabited (Parsec α) :=
⟨λ it => error it ""⟩
@[inline]
protected def pure (a : α) : Parsec α := λ it =>
success it a
@[inline]
def bind {α β : Type} (f : Parsec α) (g : α → Parsec β) : Parsec β := λ it =>
match f it with
| success rem a => g a rem
| error pos msg => error pos msg
instance : Monad Parsec :=
{ pure := Parsec.pure, bind }
@[inline]
def fail (msg : String) : Parsec α := fun it =>
error it msg
@[inline]
def orElse (p q : Parsec α) : Parsec α := fun it =>
match p it with
| success rem a => success rem a
| error rem err =>
if it = rem then q it else error rem err
@[inline]
def attempt (p : Parsec α) : Parsec α := λ it =>
match p it with
| success rem res => success rem res
| error _ err => error it err
instance : Alternative Parsec :=
{ failure := fail "", orElse }
def expectedEndOfInput := "expected end of input"
@[inline]
def eof : Parsec Unit := fun it =>
if it.hasNext then
error it expectedEndOfInput
else
success it ()
@[inline]
partial def manyCore (p : Parsec α) (acc : Array α) : Parsec $ Array α :=
(do manyCore p (acc.push $ ←p))
<|> pure acc
@[inline]
def many (p : Parsec α) : Parsec $ Array α := manyCore p #[]
@[inline]
def many1 (p : Parsec α) : Parsec $ Array α := do manyCore p #[←p]
@[inline]
partial def manyCharsCore (p : Parsec Char) (acc : String) : Parsec String :=
(do manyCharsCore p (acc.push $ ←p))
<|> pure acc
@[inline]
def manyChars (p : Parsec Char) : Parsec String := manyCharsCore p ""
@[inline]
def many1Chars (p : Parsec Char) : Parsec String := do manyCharsCore p (←p).toString
def pstring (s : String) : Parsec String := λ it =>
let substr := it.extract (it.forward s.length)
if substr = s then
success (it.forward s.length) substr
else
error it s!"expected: {s}"
@[inline]
def skipString (s : String) : Parsec Unit := pstring s *> pure ()
def unexpectedEndOfInput := "unexpected end of input"
@[inline]
def anyChar : Parsec Char := λ it =>
if it.hasNext then success it.next it.curr else error it unexpectedEndOfInput
@[inline]
def pchar (c : Char) : Parsec Char := attempt do
if (←anyChar) = c then pure c else fail s!"expected: '{c}'"
@[inline]
def skipChar (c : Char) : Parsec Unit := pchar c *> pure ()
@[inline]
def digit : Parsec Char := attempt do
let c ← anyChar
if '0' ≤ c ∧ c ≤ '9' then c else fail s!"digit expected"
@[inline]
def hexDigit : Parsec Char := attempt do
let c ← anyChar
if ('0' ≤ c ∧ c ≤ '9')
∨ ('a' ≤ c ∧ c ≤ 'a')
∨ ('A' ≤ c ∧ c ≤ 'A') then c else fail s!"hex digit expected"
@[inline]
def asciiLetter : Parsec Char := attempt do
let c ← anyChar
if ('A' ≤ c ∧ c ≤ 'Z') ∨ ('a' ≤ c ∧ c ≤ 'z') then c else fail s!"ASCII letter expected"
@[inline]
def satisfy (p : Char → Bool) : Parsec Char := attempt do
let c ← anyChar
if p c then c else fail "condition not satisfied"
@[inline]
def notFollowedBy (p : Parsec α) : Parsec Unit := λ it =>
match p it with
| success _ _ => error it ""
| error _ _ => success it ()
partial def skipWs (it : String.Iterator) : String.Iterator :=
if it.hasNext then
let c := it.curr
if c = '\u0009' ∨ c = '\u000a' ∨ c = '\u000d' ∨ c = '\u0020' then
skipWs it.next
else
it
else
it
@[inline]
def peek? : Parsec (Option Char) := fun it =>
if it.hasNext then
success it it.curr
else
success it none
@[inline]
def peek! : Parsec Char := do
let some c ← peek? | fail unexpectedEndOfInput
c
@[inline]
def skip : Parsec Unit := fun it =>
success it.next ()
@[inline]
def ws : Parsec Unit := fun it =>
success (skipWs it) ()
end Parsec
|
945586962e919681250dff7fab5660a6dcf5b429 | 0a354201ce5d10ac9334623ab4426a02ba66d8d2 | /src/obviously.lean | 9118ac6b3b372416ccf0ed902f8c21ba15381db0 | [] | no_license | khoek/leancache-example | e09c85d88013968ccab9f01855aa2b7805031f96 | 5c55bb5a792c6a711ab12e6e6d2c7118d99a936c | refs/heads/master | 1,587,379,301,297 | 1,549,096,088,000 | 1,549,096,088,000 | 168,796,024 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 584 | lean | import tidy.tidy
import tactic.tcache
import category_theory.natural_isomorphism
import category_theory.products
import category_theory.types
import category_theory.fully_faithful
import category_theory.yoneda
import category_theory.limits.cones
import category_theory.equivalence
open category_theory
suggestion category_theory
attribute [elim] full.preimage
attribute [forward] faithful.injectivity
attribute [search] yoneda.obj_map_id
attribute [search] equivalence.fun_inv_map equivalence.inv_fun_map
is_equivalence.fun_inv_map is_equivalence.inv_fun_map |
67c9ee78abc7efa646cef04c13a9ec7ce9a48256 | efce24474b28579aba3272fdb77177dc2b11d7aa | /src/homotopy_theory/formal/weak_equivalences/definitions.lean | 40a223fea3c7730d062d5e8dd34e930e474d164f | [
"Apache-2.0"
] | permissive | rwbarton/lean-homotopy-theory | cff499f24268d60e1c546e7c86c33f58c62888ed | 39e1b4ea1ed1b0eca2f68bc64162dde6a6396dee | refs/heads/lean-3.4.2 | 1,622,711,883,224 | 1,598,550,958,000 | 1,598,550,958,000 | 136,023,667 | 12 | 6 | Apache-2.0 | 1,573,187,573,000 | 1,528,116,262,000 | Lean | UTF-8 | Lean | false | false | 5,963 | lean | import category_theory.base
import category_theory.replete
open category_theory
open category_theory.category
local notation f ` ∘ `:80 g:80 := g ≫ f
universes v u
namespace homotopy_theory.weak_equivalences
class has_weak_equivalences (C : Type u) [category C] :=
(is_weq : Π ⦃a b : C⦄, (a ⟶ b) → Prop)
def is_weq {C : Type u} [category C] [has_weak_equivalences C] ⦃a b : C⦄ (f : a ⟶ b) :=
has_weak_equivalences.is_weq f
-- TODO: should this be a Prop mix-in?
class category_with_weak_equivalences (C : Type u) [category.{v} C]
extends has_weak_equivalences C :=
[weq_replete_wide : replete_wide_subcategory.{v} C is_weq]
(weq_of_comp_weq_left : ∀ ⦃a b c : C⦄ {f : a ⟶ b} {g : b ⟶ c},
is_weq f → is_weq (g ∘ f) → is_weq g)
(weq_of_comp_weq_right : ∀ ⦃a b c : C⦄ {f : a ⟶ b} {g : b ⟶ c},
is_weq g → is_weq (g ∘ f) → is_weq f)
instance (C : Type u) [category.{v} C] [category_with_weak_equivalences C] :
replete_wide_subcategory.{v} C is_weq :=
category_with_weak_equivalences.weq_replete_wide
section
variables {C : Type u} [category.{v} C] [category_with_weak_equivalences C]
lemma weq_id (a : C) : is_weq (𝟙 a) := mem_id a
lemma weq_comp {a b c : C} {f : a ⟶ b} {g : b ⟶ c} :
is_weq f → is_weq g → is_weq (g ∘ f) := mem_comp
lemma weq_iso {a b : C} (i : a ≅ b) : is_weq i.hom := mem_iso i
lemma weq_iff_weq_inv {a b : C} {f : a ⟶ b} {g : b ⟶ a} (h : f ≫ g = 𝟙 _) :
is_weq f ↔ is_weq g :=
begin
split; intro H;
{ have : is_weq (g ∘ f) := by convert weq_id _,
apply category_with_weak_equivalences.weq_of_comp_weq_left H this <|>
apply category_with_weak_equivalences.weq_of_comp_weq_right H this }
end
end
-- The two-out-of-six property.
class homotopical_category (C : Type u) [category.{v} C]
extends category_with_weak_equivalences C :=
(two_out_of_six : ∀ ⦃a b c d : C⦄ {f : a ⟶ b} {g : b ⟶ c} {h : c ⟶ d},
is_weq (h ∘ g) → is_weq (g ∘ f) → is_weq g)
section
variables {C : Type u} [category.{v} C] [homotopical_category C]
lemma weq_two_out_of_six_g {a b c d : C} {f : a ⟶ b} {g : b ⟶ c} {h : c ⟶ d}
(hg : is_weq (h ∘ g)) (gf : is_weq (g ∘ f)) : is_weq g :=
homotopical_category.two_out_of_six hg gf
lemma weq_two_out_of_six_f {a b c d : C} {f : a ⟶ b} {g : b ⟶ c} {h : c ⟶ d}
(hg : is_weq (h ∘ g)) (gf : is_weq (g ∘ f)) : is_weq f :=
have wg : is_weq g := weq_two_out_of_six_g hg gf,
category_with_weak_equivalences.weq_of_comp_weq_right wg gf
lemma weq_two_out_of_six_h {a b c d : C} {f : a ⟶ b} {g : b ⟶ c} {h : c ⟶ d}
(hg : is_weq (h ∘ g)) (gf : is_weq (g ∘ f)) : is_weq h :=
have wg : is_weq g := weq_two_out_of_six_g hg gf,
category_with_weak_equivalences.weq_of_comp_weq_left wg hg
end
section isomorphisms
variables {C : Type u} [category.{v} C]
def is_iso ⦃a b : C⦄ (f : a ⟶ b) : Prop := ∃ i : a ≅ b, i.hom = f
lemma iso_iso ⦃a b : C⦄ (i : a ≅ b) : is_iso i.hom := ⟨i, rfl⟩
lemma iso_comp ⦃a b c : C⦄ {f : a ⟶ b} {g : b ⟶ c} :
is_iso f → is_iso g → is_iso (g ∘ f) :=
assume ⟨i, hi⟩ ⟨j, hj⟩, ⟨i.trans j, by rw [←hi, ←hj]; refl⟩
lemma iso_of_comp_iso_left ⦃a b c : C⦄ {f : a ⟶ b} {g : b ⟶ c} :
is_iso f → is_iso (g ∘ f) → is_iso g :=
assume ⟨i, hi⟩ ⟨j, hj⟩,
⟨i.symm.trans j, show j.hom ∘ i.inv = g, by rw [hj, ←hi]; simp⟩
lemma iso_of_comp_iso_right ⦃a b c : C⦄ {f : a ⟶ b} {g : b ⟶ c} :
is_iso g → is_iso (g ∘ f) → is_iso f :=
assume ⟨i, hi⟩ ⟨j, hj⟩,
⟨j.trans i.symm, show i.inv ∘ j.hom = f, by rw [hj, ←hi]; simp⟩
lemma iso_two_out_of_six ⦃a b c d : C⦄ {f : a ⟶ b} {g : b ⟶ c} {h : c ⟶ d} :
is_iso (h ∘ g) → is_iso (g ∘ f) → is_iso g :=
assume ⟨i, hi⟩ ⟨j, hj⟩,
let g' := i.inv ∘ h in
have g'g : g' ∘ g = 𝟙 _, by rw [←assoc, ←hi]; simp,
let g'' := f ∘ j.inv in
have gg'' : g ∘ g'' = 𝟙 _, by rw [assoc, ←hj]; simp,
have g' = g'', from calc
g' = g' ∘ (g ∘ g'') : by rw gg''; simp
... = (g' ∘ g) ∘ g'' : by simp
... = g'' : by rw g'g; simp; refl,
⟨⟨g, g', g'g, by rw this; exact gg''⟩, rfl⟩
instance is_iso.replete_wide_subcategory : replete_wide_subcategory.{v} C is_iso :=
replete_wide_subcategory.mk' iso_iso iso_comp
def isomorphisms_as_weak_equivalences : category_with_weak_equivalences C :=
{ is_weq := is_iso,
weq_of_comp_weq_left := iso_of_comp_iso_left,
weq_of_comp_weq_right := iso_of_comp_iso_right }
def isomorphisms_as_homotopical_category : homotopical_category C :=
{ two_out_of_six := iso_two_out_of_six,
.. isomorphisms_as_weak_equivalences }
end isomorphisms
section preimage
-- TODO: generalize to different universes?
variables {C D : Type u} [category.{v} C] [category.{v} D]
variables (F : C ↝ D)
def preimage_weq (weqD : has_weak_equivalences D) : has_weak_equivalences C :=
{ is_weq := λ a b f, is_weq (F &> f) }
instance preimage_weq.replete_wide_subcategory [weqD : category_with_weak_equivalences D] :
replete_wide_subcategory.{v} C (preimage_weq F weqD.to_has_weak_equivalences).is_weq :=
replete_wide_subcategory.mk'
(λ a b i, weq_iso (F.map_iso i))
(λ a b c f g hf hg, show is_weq (F &> (g ∘ f)),
by rw F.map_comp; exact weq_comp hf hg)
def preimage_with_weak_equivalences [weqD : category_with_weak_equivalences D] :
category_with_weak_equivalences C :=
{ to_has_weak_equivalences := preimage_weq F weqD.to_has_weak_equivalences,
weq_of_comp_weq_left := λ a b c f g hf hgf, begin
change is_weq (F &> (g ∘ f)) at hgf, rw F.map_comp at hgf,
exact category_with_weak_equivalences.weq_of_comp_weq_left hf hgf
end,
weq_of_comp_weq_right := λ a b c f g hg hgf, begin
change is_weq (F &> (g ∘ f)) at hgf, rw F.map_comp at hgf,
exact category_with_weak_equivalences.weq_of_comp_weq_right hg hgf
end }
end preimage
end homotopy_theory.weak_equivalences
|
4aa99ec36b4e92473bba9ba7dca6e6077b8f04fc | 842b7df4a999c5c50bbd215b8617dd705e43c2e1 | /nat_num_game/src/Advanced_Proposition_World/adv_prop_wrld10.lean | 786c97f260adc5ec237269da749f7c8a5189d35a | [] | no_license | Samyak-Surti/LeanCode | 1c245631f74b00057d20483c8ac75916e8643b14 | 944eac3e5f43e2614ed246083b97fbdf24181d83 | refs/heads/master | 1,669,023,730,828 | 1,595,534,784,000 | 1,595,534,784,000 | 282,037,186 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 84 | lean | lemma contrapositive2 (P Q : Prop) : (¬ Q → ¬ P) → (P → Q) :=
begin
end |
b0ac38d42dc2f0934c5884d98a52f7dcbaa999f0 | ec62863c729b7eedee77b86d974f2c529fa79d25 | /9/b.lean | 5092e80e6ceec7e6857b061ad4ea3a85d32d1226 | [] | no_license | rwbarton/advent-of-lean-4 | 2ac9b17ba708f66051e3d8cd694b0249bc433b65 | 417c7e2718253ba7148c0279fcb251b6fc291477 | refs/heads/main | 1,675,917,092,057 | 1,609,864,581,000 | 1,609,864,581,000 | 317,700,289 | 24 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,006 | lean | def bufSize : Nat := 25
def isPairSum (xs : List Nat) (y : Nat) : Bool := do
for x₁ in xs do
for x₂ in xs do
if x₁ ≠ x₂ && x₁ + x₂ == y then return true
return false
def firstBad (xs : List Nat) : Nat := do
let mut old := xs.take bufSize
for x in xs.drop bufSize do
if ! isPairSum old x then return x
old := old.drop 1 ++ [x]
panic! "no solution"
def psums_aux : List Nat → Nat → List Nat
| [], s => [s]
| (x :: xs), s => s :: psums_aux xs (x + s)
def asRange (xs : List Nat) (tgt : Nat) : Nat × Nat := do
let psums := (psums_aux xs 0).toArray
for i in [0:psums.size] do
for j in [0:psums.size] do
if psums.get! j - psums.get! i == tgt
then let xs' : List Nat := (xs.take j).drop i
return (xs'.foldl Nat.min tgt, xs'.foldl Nat.max 0)
panic! "no solution"
def main : IO Unit := do
let input ← IO.FS.lines "a.in"
let xs := input.toList.map String.toNat!
let target := firstBad xs
let ⟨mn, mx⟩ := asRange xs target
IO.print s!"{mn + mx}\n"
|
aca7ac2a73c74185f73ef8cb707d0f0634275316 | 95dcf8dea2baf2b4b0a60d438f27c35ae3dd3990 | /src/ring_theory/algebra_operations.lean | 2dea6076c7c2a5bf185b3c5c15b9652b16722903 | [
"Apache-2.0"
] | permissive | uniformity1/mathlib | 829341bad9dfa6d6be9adaacb8086a8a492e85a4 | dd0e9bd8f2e5ec267f68e72336f6973311909105 | refs/heads/master | 1,588,592,015,670 | 1,554,219,842,000 | 1,554,219,842,000 | 179,110,702 | 0 | 0 | Apache-2.0 | 1,554,220,076,000 | 1,554,220,076,000 | null | UTF-8 | Lean | false | false | 5,086 | lean | /-
Copyright (c) 2019 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
Multiplication of submodules of an algebra.
-/
import ring_theory.algebra ring_theory.noetherian
universes u v
open lattice submodule
namespace algebra
variables {R : Type u} [comm_ring R]
section ring
variables {A : Type v} [ring A] [algebra R A]
set_option class.instance_max_depth 50
instance : has_mul (submodule R A) :=
⟨λ M N, ⨆ s : M, N.map $ algebra.lmul R A s.1⟩
set_option class.instance_max_depth 32
variables (S T : set A) {M N P Q : submodule R A} {m n : A}
theorem mul_mem_mul (hm : m ∈ M) (hn : n ∈ N) : m * n ∈ M * N :=
(le_supr _ ⟨m, hm⟩ : _ ≤ M * N) ⟨n, hn, rfl⟩
theorem mul_le : M * N ≤ P ↔ ∀ (m ∈ M) (n ∈ N), m * n ∈ P :=
⟨λ H m hm n hn, H $ mul_mem_mul hm hn,
λ H, supr_le $ λ ⟨m, hm⟩, map_le_iff_le_comap.2 $ λ n hn, H m hm n hn⟩
@[elab_as_eliminator] protected theorem mul_induction_on
{C : A → Prop} {r : A} (hr : r ∈ M * N)
(hm : ∀ (m ∈ M) (n ∈ N), C (m * n))
(h0 : C 0) (ha : ∀ x y, C x → C y → C (x + y))
(hs : ∀ (r : R) x, C x → C (r • x)) : C r :=
(@mul_le _ _ _ _ _ _ _ ⟨C, h0, ha, hs⟩).2 hm hr
variables R
theorem span_mul_span : span R S * span R T = span R ((S.prod T).image (λ p, p.1 * p.2)) :=
le_antisymm
(mul_le.2 $ λ x1 hx1 x2 hx2, span_induction hx1
(λ y1 hy1, span_induction hx2
(λ y2 hy2, subset_span ⟨(y1, y2), ⟨hy1, hy2⟩, rfl⟩)
((mul_zero y1).symm ▸ zero_mem _)
(λ r1 r2, (mul_add y1 r1 r2).symm ▸ add_mem _)
(λ s r, (algebra.mul_smul_comm s y1 r).symm ▸ smul_mem _ _))
((zero_mul x2).symm ▸ zero_mem _)
(λ r1 r2, (add_mul r1 r2 x2).symm ▸ add_mem _)
(λ s r, (algebra.smul_mul_assoc s r x2).symm ▸ smul_mem _ _))
(span_le.2 (set.image_subset_iff.2 $ λ ⟨x1, x2⟩ ⟨hx1, hx2⟩,
mul_mem_mul (subset_span hx1) (subset_span hx2)))
variables {R}
theorem fg_mul (hm : M.fg) (hn : N.fg) : (M * N).fg :=
let ⟨m, hf1, hm⟩ := fg_def.1 hm, ⟨n, hf2, hn⟩ := fg_def.1 hn in
fg_def.2 ⟨(m.prod n).image (λ p, p.1 * p.2),
set.finite_image _ (set.finite_prod hf1 hf2),
span_mul_span R m n ▸ hm ▸ hn ▸ rfl⟩
variables (M N P Q)
set_option class.instance_max_depth 50
protected theorem mul_assoc : (M * N) * P = M * (N * P) :=
le_antisymm (mul_le.2 $ λ mn hmn p hp, suffices M * N ≤ (M * (N * P)).comap ((algebra.lmul R A).flip p), from this hmn,
mul_le.2 $ λ m hm n hn, show m * n * p ∈ M * (N * P), from
(mul_assoc m n p).symm ▸ mul_mem_mul hm (mul_mem_mul hn hp))
(mul_le.2 $ λ m hm np hnp, suffices N * P ≤ (M * N * P).comap (algebra.lmul R A m), from this hnp,
mul_le.2 $ λ n hn p hp, show m * (n * p) ∈ M * N * P, from
mul_assoc m n p ▸ mul_mem_mul (mul_mem_mul hm hn) hp)
set_option class.instance_max_depth 32
@[simp] theorem mul_bot : M * ⊥ = ⊥ :=
eq_bot_iff.2 $ mul_le.2 $ λ m hm n hn, by rw [submodule.mem_bot] at hn ⊢; rw [hn, mul_zero]
@[simp] theorem bot_mul : ⊥ * M = ⊥ :=
eq_bot_iff.2 $ mul_le.2 $ λ m hm n hn, by rw [submodule.mem_bot] at hm ⊢; rw [hm, zero_mul]
variables {M N P Q}
@[mono] theorem mul_le_mul (hmp : M ≤ P) (hnq : N ≤ Q) : M * N ≤ P * Q :=
mul_le.2 $ λ m hm n hn, mul_mem_mul (hmp hm) (hnq hn)
theorem mul_le_mul_left (h : M ≤ N) : M * P ≤ N * P :=
mul_le_mul h (le_refl P)
theorem mul_le_mul_right (h : N ≤ P) : M * N ≤ M * P :=
mul_le_mul (le_refl M) h
variables (M N P)
theorem mul_sup : M * (N ⊔ P) = M * N ⊔ M * P :=
le_antisymm (mul_le.2 $ λ m hm np hnp, let ⟨n, hn, p, hp, hnp⟩ := mem_sup.1 hnp in
mem_sup.2 ⟨_, mul_mem_mul hm hn, _, mul_mem_mul hm hp, hnp ▸ (mul_add m n p).symm⟩)
(sup_le (mul_le_mul_right le_sup_left) (mul_le_mul_right le_sup_right))
theorem sup_mul : (M ⊔ N) * P = M * P ⊔ N * P :=
le_antisymm (mul_le.2 $ λ mn hmn p hp, let ⟨m, hm, n, hn, hmn⟩ := mem_sup.1 hmn in
mem_sup.2 ⟨_, mul_mem_mul hm hp, _, mul_mem_mul hn hp, hmn ▸ (add_mul m n p).symm⟩)
(sup_le (mul_le_mul_left le_sup_left) (mul_le_mul_left le_sup_right))
variables {M N P}
instance : semigroup (submodule R A) :=
{ mul := (*),
mul_assoc := algebra.mul_assoc }
instance : mul_zero_class (submodule R A) :=
{ zero_mul := bot_mul,
mul_zero := mul_bot,
.. submodule.add_comm_monoid, .. algebra.semigroup }
instance : distrib (submodule R A) :=
{ left_distrib := mul_sup,
right_distrib := sup_mul,
.. submodule.add_comm_monoid, .. algebra.semigroup }
end ring
section comm_ring
variables {A : Type v} [comm_ring A] [algebra R A]
variables {M N : submodule R A} {m n : A}
theorem mul_mem_mul_rev (hm : m ∈ M) (hn : n ∈ N) : n * m ∈ M * N :=
mul_comm m n ▸ mul_mem_mul hm hn
variables (M N)
protected theorem mul_comm : M * N = N * M :=
le_antisymm (mul_le.2 $ λ r hrm s hsn, mul_mem_mul_rev hsn hrm)
(mul_le.2 $ λ r hrn s hsm, mul_mem_mul_rev hsm hrn)
instance : comm_semigroup (submodule R A) :=
{ mul_comm := algebra.mul_comm,
.. algebra.semigroup }
end comm_ring
end algebra
|
fecb9b063f72e0a6b0c54df8c6d94843ca106f61 | c86b74188c4b7a462728b1abd659ab4e5828dd61 | /src/Lean/Elab/Command.lean | 950cbe45c8b32de629f3e1e2a513904b5a782ba5 | [
"Apache-2.0"
] | permissive | cwb96/lean4 | 75e1f92f1ba98bbaa6b34da644b3dfab2ce7bf89 | b48831cda76e64f13dd1c0edde7ba5fb172ed57a | refs/heads/master | 1,686,347,881,407 | 1,624,483,842,000 | 1,624,483,842,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 27,832 | 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.Parser.Command
import Lean.ResolveName
import Lean.Meta.Reduce
import Lean.Elab.Log
import Lean.Elab.Term
import Lean.Elab.Binders
import Lean.Elab.SyntheticMVars
import Lean.Elab.DeclModifiers
import Lean.Elab.InfoTree
import Lean.Elab.Open
import Lean.Elab.SetOption
namespace Lean.Elab.Command
structure Scope where
header : String
opts : Options := {}
currNamespace : Name := Name.anonymous
openDecls : List OpenDecl := []
levelNames : List Name := []
/-- section variables as `bracketedBinder`s -/
varDecls : Array Syntax := #[]
/-- Globally unique internal identifiers for the `varDecls` -/
varUIds : Array Name := #[]
deriving Inhabited
structure State where
env : Environment
messages : MessageLog := {}
scopes : List Scope := [{ header := "" }]
nextMacroScope : Nat := firstFrontendMacroScope + 1
maxRecDepth : Nat
nextInstIdx : Nat := 1 -- for generating anonymous instance names
ngen : NameGenerator := {}
infoState : InfoState := {}
traceState : TraceState := {}
deriving Inhabited
structure Context where
fileName : String
fileMap : FileMap
currRecDepth : Nat := 0
cmdPos : String.Pos := 0
macroStack : MacroStack := []
currMacroScope : MacroScope := firstFrontendMacroScope
ref : Syntax := Syntax.missing
abbrev CommandElabCoreM (ε) := ReaderT Context $ StateRefT State $ EIO ε
abbrev CommandElabM := CommandElabCoreM Exception
abbrev CommandElab := Syntax → CommandElabM Unit
abbrev Linter := Syntax → CommandElabM Unit
-- Make the compiler generate specialized `pure`/`bind` so we do not have to optimize through the
-- whole monad stack at every use site. May eventually be covered by `deriving`.
instance : Monad CommandElabM := { inferInstanceAs (Monad CommandElabM) with }
def mkState (env : Environment) (messages : MessageLog := {}) (opts : Options := {}) : State := {
env := env
messages := messages
scopes := [{ header := "", opts := opts }]
maxRecDepth := maxRecDepth.get opts
}
/- Linters should be loadable as plugins, so store in a global IO ref instead of an attribute managed by the
environment (which only contains `import`ed objects). -/
builtin_initialize lintersRef : IO.Ref (Array Linter) ← IO.mkRef #[]
def addLinter (l : Linter) : IO Unit := do
let ls ← lintersRef.get
lintersRef.set (ls.push l)
instance : MonadInfoTree CommandElabM where
getInfoState := return (← get).infoState
modifyInfoState f := modify fun s => { s with infoState := f s.infoState }
instance : MonadEnv CommandElabM where
getEnv := do pure (← get).env
modifyEnv f := modify fun s => { s with env := f s.env }
instance : MonadOptions CommandElabM where
getOptions := do pure (← get).scopes.head!.opts
protected def getRef : CommandElabM Syntax :=
return (← read).ref
instance : AddMessageContext CommandElabM where
addMessageContext := addMessageContextPartial
instance : MonadRef CommandElabM where
getRef := Command.getRef
withRef ref x := withReader (fun ctx => { ctx with ref := ref }) x
instance : MonadTrace CommandElabM where
getTraceState := return (← get).traceState
modifyTraceState f := modify fun s => { s with traceState := f s.traceState }
instance : AddErrorMessageContext CommandElabM where
add ref msg := do
let ctx ← read
let ref := getBetterRef ref ctx.macroStack
let msg ← addMessageContext msg
let msg ← addMacroStack msg ctx.macroStack
return (ref, msg)
def mkMessageAux (ctx : Context) (ref : Syntax) (msgData : MessageData) (severity : MessageSeverity) : Message :=
mkMessageCore ctx.fileName ctx.fileMap msgData severity (ref.getPos?.getD ctx.cmdPos)
private def mkCoreContext (ctx : Context) (s : State) (heartbeats : Nat) : Core.Context :=
let scope := s.scopes.head!
{ options := scope.opts
currRecDepth := ctx.currRecDepth
maxRecDepth := s.maxRecDepth
ref := ctx.ref
currNamespace := scope.currNamespace
openDecls := scope.openDecls
initHeartbeats := heartbeats }
def liftCoreM {α} (x : CoreM α) : CommandElabM α := do
let s ← get
let ctx ← read
let heartbeats ← IO.getNumHeartbeats (ε := Exception)
let Eα := Except Exception α
let x : CoreM Eα := try let a ← x; pure <| Except.ok a catch ex => pure <| Except.error ex
let x : EIO Exception (Eα × Core.State) := (ReaderT.run x (mkCoreContext ctx s heartbeats)).run { env := s.env, ngen := s.ngen }
let (ea, coreS) ← liftM x
modify fun s => { s with env := coreS.env, ngen := coreS.ngen }
match ea with
| Except.ok a => pure a
| Except.error e => throw e
private def ioErrorToMessage (ctx : Context) (ref : Syntax) (err : IO.Error) : Message :=
let ref := getBetterRef ref ctx.macroStack
mkMessageAux ctx ref (toString err) MessageSeverity.error
@[inline] def liftEIO {α} (x : EIO Exception α) : CommandElabM α := liftM x
@[inline] def liftIO {α} (x : IO α) : CommandElabM α := do
let ctx ← read
IO.toEIO (fun (ex : IO.Error) => Exception.error ctx.ref ex.toString) x
instance : MonadLiftT IO CommandElabM where
monadLift := liftIO
def getScope : CommandElabM Scope := do pure (← get).scopes.head!
instance : MonadResolveName CommandElabM where
getCurrNamespace := return (← getScope).currNamespace
getOpenDecls := return (← getScope).openDecls
instance : MonadLog CommandElabM where
getRef := getRef
getFileMap := return (← read).fileMap
getFileName := return (← read).fileName
logMessage msg := do
let currNamespace ← getCurrNamespace
let openDecls ← getOpenDecls
let msg := { msg with data := MessageData.withNamingContext { currNamespace := currNamespace, openDecls := openDecls } msg.data }
modify fun s => { s with messages := s.messages.add msg }
def runLinters (stx : Syntax) : CommandElabM Unit := do
let linters ← lintersRef.get
unless linters.isEmpty do
for linter in linters do
let savedState ← get
try
linter stx
catch ex =>
logException ex
finally
modify fun s => { savedState with messages := s.messages }
protected def getCurrMacroScope : CommandElabM Nat := do pure (← read).currMacroScope
protected def getMainModule : CommandElabM Name := do pure (← getEnv).mainModule
@[inline] protected def withFreshMacroScope {α} (x : CommandElabM α) : CommandElabM α := do
let fresh ← modifyGet (fun st => (st.nextMacroScope, { st with nextMacroScope := st.nextMacroScope + 1 }))
withReader (fun ctx => { ctx with currMacroScope := fresh }) x
instance : MonadQuotation CommandElabM where
getCurrMacroScope := Command.getCurrMacroScope
getMainModule := Command.getMainModule
withFreshMacroScope := Command.withFreshMacroScope
unsafe def mkCommandElabAttributeUnsafe : IO (KeyedDeclsAttribute CommandElab) :=
mkElabAttribute CommandElab `Lean.Elab.Command.commandElabAttribute `builtinCommandElab `commandElab `Lean.Parser.Command `Lean.Elab.Command.CommandElab "command"
@[implementedBy mkCommandElabAttributeUnsafe]
constant mkCommandElabAttribute : IO (KeyedDeclsAttribute CommandElab)
builtin_initialize commandElabAttribute : KeyedDeclsAttribute CommandElab ← mkCommandElabAttribute
private def addTraceAsMessagesCore (ctx : Context) (log : MessageLog) (traceState : TraceState) : MessageLog :=
traceState.traces.foldl (init := log) fun (log : MessageLog) traceElem =>
let ref := replaceRef traceElem.ref ctx.ref;
let pos := ref.getPos?.getD 0;
log.add (mkMessageCore ctx.fileName ctx.fileMap traceElem.msg MessageSeverity.information pos)
private def addTraceAsMessages : CommandElabM Unit := do
let ctx ← read
modify fun s => { s with
messages := addTraceAsMessagesCore ctx s.messages s.traceState
traceState.traces := {}
}
private def mkInfoTree (elaborator : Name) (stx : Syntax) (trees : Std.PersistentArray InfoTree) : CommandElabM InfoTree := do
let ctx ← read
let s ← get
let scope := s.scopes.head!
let tree := InfoTree.node (Info.ofCommandInfo { elaborator, stx }) trees
let tree := InfoTree.context {
env := s.env, fileMap := ctx.fileMap, mctx := {}, currNamespace := scope.currNamespace, openDecls := scope.openDecls, options := scope.opts
} tree
trace[Elab.info] ← tree.format
return tree
private def elabCommandUsing (s : State) (stx : Syntax) : List (KeyedDeclsAttribute.AttributeEntry CommandElab) → CommandElabM Unit
| [] => throwError "unexpected syntax{indentD stx}"
| (elabFn::elabFns) =>
catchInternalId unsupportedSyntaxExceptionId
(do
withInfoTreeContext (mkInfoTree := mkInfoTree elabFn.decl stx) <| elabFn.value stx
addTraceAsMessages)
(fun _ => do set s; addTraceAsMessages; elabCommandUsing s stx elabFns)
/- Elaborate `x` with `stx` on the macro stack -/
@[inline] def withMacroExpansion {α} (beforeStx afterStx : Syntax) (x : CommandElabM α) : CommandElabM α :=
withReader (fun ctx => { ctx with macroStack := { before := beforeStx, after := afterStx } :: ctx.macroStack }) x
instance : MonadMacroAdapter CommandElabM where
getCurrMacroScope := getCurrMacroScope
getNextMacroScope := return (← get).nextMacroScope
setNextMacroScope next := modify fun s => { s with nextMacroScope := next }
instance : MonadRecDepth CommandElabM where
withRecDepth d x := withReader (fun ctx => { ctx with currRecDepth := d }) x
getRecDepth := return (← read).currRecDepth
getMaxRecDepth := return (← get).maxRecDepth
register_builtin_option showPartialSyntaxErrors : Bool := {
defValue := false
descr := "show elaboration errors from partial syntax trees (i.e. after parser recovery)"
}
@[inline] def withLogging (x : CommandElabM Unit) : CommandElabM Unit := do
try
x
catch ex => match ex with
| Exception.error _ _ => logException ex
| Exception.internal id _ =>
if isAbortExceptionId id then
pure ()
else
let idName ← liftIO <| id.getName;
logError m!"internal exception {idName}"
builtin_initialize registerTraceClass `Elab.command
partial def elabCommand (stx : Syntax) : CommandElabM Unit := do
let initMsgs ← modifyGet fun st => (st.messages, { st with messages := {} })
withLogging <| withRef stx <| withIncRecDepth <| withFreshMacroScope do
runLinters stx
match stx with
| Syntax.node k args =>
if k == nullKind then
-- list of commands => elaborate in order
-- The parser will only ever return a single command at a time, but syntax quotations can return multiple ones
args.forM elabCommand
else do
trace `Elab.command fun _ => stx;
let s ← get
match (← liftMacroM <| expandMacroImpl? s.env stx) with
| some (decl, stxNew) =>
withInfoTreeContext (mkInfoTree := mkInfoTree decl stx) do
withMacroExpansion stx stxNew do
elabCommand stxNew
| _ =>
match commandElabAttribute.getEntries s.env k with
| [] => throwError "elaboration function for '{k}' has not been implemented"
| elabFns => elabCommandUsing s stx elabFns
| _ => throwError "unexpected command"
let mut msgs ← (← get).messages
-- `stx.hasMissing` should imply `initMsgs.hasErrors`, but the latter should be cheaper to check in general
if !showPartialSyntaxErrors.get (← getOptions) && initMsgs.hasErrors && stx.hasMissing then
-- discard elaboration errors, except for a few important and unlikely misleading ones, on parse error
msgs := ⟨msgs.msgs.filter fun msg =>
msg.data.hasTag `Elab.synthPlaceholder || msg.data.hasTag `Tactic.unsolvedGoals⟩
modify ({ · with messages := initMsgs ++ msgs })
/-- Adapt a syntax transformation to a regular, command-producing elaborator. -/
def adaptExpander (exp : Syntax → CommandElabM Syntax) : CommandElab := fun stx => do
let stx' ← exp stx
withMacroExpansion stx stx' <| elabCommand stx'
private def getVarDecls (s : State) : Array Syntax :=
s.scopes.head!.varDecls
instance {α} : Inhabited (CommandElabM α) where
default := throw arbitrary
private def mkMetaContext : Meta.Context := {
config := { foApprox := true, ctxApprox := true, quasiPatternApprox := true }
}
def getBracketedBinderIds : Syntax → Array Name
| `(bracketedBinder|($ids* $[: $ty?]? $(annot?)?)) => ids.map Syntax.getId
| `(bracketedBinder|{$ids* $[: $ty?]?}) => ids.map Syntax.getId
| `(bracketedBinder|[$id : $ty]) => #[id.getId]
| `(bracketedBinder|[$ty]) => #[Name.anonymous]
| _ => #[]
private def mkTermContext (ctx : Context) (s : State) (declName? : Option Name) : Term.Context := do
let scope := s.scopes.head!
let mut sectionVars := {}
for id in scope.varDecls.concatMap getBracketedBinderIds, uid in scope.varUIds do
sectionVars := sectionVars.insert id uid
{ macroStack := ctx.macroStack
fileName := ctx.fileName
fileMap := ctx.fileMap
currMacroScope := ctx.currMacroScope
declName? := declName?
sectionVars := sectionVars }
private def mkTermState (scope : Scope) (s : State) : Term.State := {
messages := {}
levelNames := scope.levelNames
infoState.enabled := s.infoState.enabled
}
def liftTermElabM {α} (declName? : Option Name) (x : TermElabM α) : CommandElabM α := do
let ctx ← read
let s ← get
let heartbeats ← IO.getNumHeartbeats (ε := Exception)
-- dbg_trace "heartbeats: {heartbeats}"
let scope := s.scopes.head!
-- We execute `x` with an empty message log. Thus, `x` cannot modify/view messages produced by previous commands.
-- This is useful for implementing `runTermElabM` where we use `Term.resetMessageLog`
let x : TermElabM _ := withSaveInfoContext x
let x : MetaM _ := (observing x).run (mkTermContext ctx s declName?) (mkTermState scope s)
let x : CoreM _ := x.run mkMetaContext {}
let x : EIO _ _ := x.run (mkCoreContext ctx s heartbeats) { env := s.env, ngen := s.ngen, nextMacroScope := s.nextMacroScope }
let (((ea, termS), metaS), coreS) ← liftEIO x
modify fun s => { s with
env := coreS.env
messages := addTraceAsMessagesCore ctx (s.messages ++ termS.messages) coreS.traceState
nextMacroScope := coreS.nextMacroScope
ngen := coreS.ngen
infoState.trees := s.infoState.trees.append termS.infoState.trees
}
match ea with
| Except.ok a => pure a
| Except.error ex => throw ex
@[inline] def runTermElabM {α} (declName? : Option Name) (elabFn : Array Expr → TermElabM α) : CommandElabM α := do
let scope ← getScope
liftTermElabM declName? <|
Term.withAutoBoundImplicit <|
Term.elabBinders scope.varDecls fun xs => do
-- We need to synthesize postponed terms because this is a checkpoint for the auto-bound implicit feature
-- If we don't use this checkpoint here, then auto-bound implicits in the postponed terms will not be handled correctly.
Term.synthesizeSyntheticMVarsNoPostponing
let mut sectionFVars := {}
for uid in scope.varUIds, x in xs do
sectionFVars := sectionFVars.insert uid x
withReader ({ · with sectionFVars := sectionFVars }) do
-- We don't want to store messages produced when elaborating `(getVarDecls s)` because they have already been saved when we elaborated the `variable`(s) command.
-- So, we use `Term.resetMessageLog`.
Term.resetMessageLog
let xs ← Term.addAutoBoundImplicits xs
Term.withoutAutoBoundImplicit <| elabFn xs
@[inline] def catchExceptions (x : CommandElabM Unit) : CommandElabCoreM Empty Unit := fun ctx ref =>
EIO.catchExceptions (withLogging x ctx ref) (fun _ => pure ())
private def liftAttrM {α} (x : AttrM α) : CommandElabM α := do
liftCoreM x
private def addScope (isNewNamespace : Bool) (header : String) (newNamespace : Name) : CommandElabM Unit := do
modify fun s => { s with
env := s.env.registerNamespace newNamespace,
scopes := { s.scopes.head! with header := header, currNamespace := newNamespace } :: s.scopes
}
pushScope
if isNewNamespace then
activateScoped newNamespace
private def addScopes (isNewNamespace : Bool) : Name → CommandElabM Unit
| Name.anonymous => pure ()
| Name.str p header _ => do
addScopes isNewNamespace p
let currNamespace ← getCurrNamespace
addScope isNewNamespace header (if isNewNamespace then Name.mkStr currNamespace header else currNamespace)
| _ => throwError "invalid scope"
private def addNamespace (header : Name) : CommandElabM Unit :=
addScopes (isNewNamespace := true) header
@[builtinCommandElab «namespace»] def elabNamespace : CommandElab := fun stx =>
match stx with
| `(namespace $n) => addNamespace n.getId
| _ => throwUnsupportedSyntax
@[builtinCommandElab «section»] def elabSection : CommandElab := fun stx =>
match stx with
| `(section $header:ident) => addScopes (isNewNamespace := false) header.getId
| `(section) => do let currNamespace ← getCurrNamespace; addScope (isNewNamespace := false) "" currNamespace
| _ => throwUnsupportedSyntax
def getScopes : CommandElabM (List Scope) := do
pure (← get).scopes
private def checkAnonymousScope : List Scope → Bool
| { header := "", .. } :: _ => true
| _ => false
private def checkEndHeader : Name → List Scope → Bool
| Name.anonymous, _ => true
| Name.str p s _, { header := h, .. } :: scopes => h == s && checkEndHeader p scopes
| _, _ => false
private def popScopes (numScopes : Nat) : CommandElabM Unit :=
for i in [0:numScopes] do
popScope
@[builtinCommandElab «end»] def elabEnd : CommandElab := fun stx => do
let header? := (stx.getArg 1).getOptionalIdent?;
let endSize := match header? with
| none => 1
| some n => n.getNumParts
let scopes ← getScopes
if endSize < scopes.length then
modify fun s => { s with scopes := s.scopes.drop endSize }
popScopes endSize
else -- we keep "root" scope
let n := (← get).scopes.length - 1
modify fun s => { s with scopes := s.scopes.drop n }
popScopes n
throwError "invalid 'end', insufficient scopes"
match header? with
| none =>
unless checkAnonymousScope scopes do
throwError "invalid 'end', name is missing"
| some header =>
unless checkEndHeader header scopes do
addCompletionInfo <| CompletionInfo.endSection stx (scopes.map fun scope => scope.header)
throwError "invalid 'end', name mismatch"
@[inline] def withNamespace {α} (ns : Name) (elabFn : CommandElabM α) : CommandElabM α := do
addNamespace ns
let a ← elabFn
modify fun s => { s with scopes := s.scopes.drop ns.getNumParts }
pure a
@[specialize] def modifyScope (f : Scope → Scope) : CommandElabM Unit :=
modify fun s => { s with
scopes := match s.scopes with
| h::t => f h :: t
| [] => unreachable!
}
def getLevelNames : CommandElabM (List Name) :=
return (← getScope).levelNames
def addUnivLevel (idStx : Syntax) : CommandElabM Unit := withRef idStx do
let id := idStx.getId
let levelNames ← getLevelNames
if levelNames.elem id then
throwAlreadyDeclaredUniverseLevel id
else
modifyScope fun scope => { scope with levelNames := id :: scope.levelNames }
partial def elabChoiceAux (cmds : Array Syntax) (i : Nat) : CommandElabM Unit :=
if h : i < cmds.size then
let cmd := cmds.get ⟨i, h⟩;
catchInternalId unsupportedSyntaxExceptionId
(elabCommand cmd)
(fun ex => elabChoiceAux cmds (i+1))
else
throwUnsupportedSyntax
@[builtinCommandElab choice] def elbChoice : CommandElab := fun stx =>
elabChoiceAux stx.getArgs 0
@[builtinCommandElab «universe»] def elabUniverse : CommandElab := fun n => do
addUnivLevel n[1]
@[builtinCommandElab «universes»] def elabUniverses : CommandElab := fun n => do
n[1].forArgsM addUnivLevel
@[builtinCommandElab «init_quot»] def elabInitQuot : CommandElab := fun stx => do
match (← getEnv).addDecl Declaration.quotDecl with
| Except.ok env => setEnv env
| Except.error ex => throwError (ex.toMessageData (← getOptions))
@[builtinCommandElab «export»] def elabExport : CommandElab := fun stx => do
-- `stx` is of the form (Command.export "export" <namespace> "(" (null <ids>*) ")")
let id := stx[1].getId
let ns ← resolveNamespace id
let currNamespace ← getCurrNamespace
if ns == currNamespace then throwError "invalid 'export', self export"
let env ← getEnv
let ids := stx[3].getArgs
let aliases ← ids.foldlM (init := []) fun (aliases : List (Name × Name)) (idStx : Syntax) => do
let id := idStx.getId
let declName := ns ++ id
if env.contains declName then
pure <| (currNamespace ++ id, declName) :: aliases
else
withRef idStx <| logUnknownDecl declName
pure aliases
modify fun s => { s with env := aliases.foldl (init := s.env) fun env p => addAlias env p.1 p.2 }
@[builtinCommandElab «open»] def elabOpen : CommandElab := fun n => do
let openDecls ← elabOpenDecl n[1]
modifyScope fun scope => { scope with openDecls := openDecls }
@[builtinCommandElab «variable»] def elabVariable : CommandElab
| `(variable $binders*) => do
-- Try to elaborate `binders` for sanity checking
runTermElabM none fun _ => Term.withAutoBoundImplicit <|
Term.elabBinders binders fun _ => pure ()
let varUIds ← binders.concatMap getBracketedBinderIds |>.mapM (withFreshMacroScope ∘ MonadQuotation.addMacroScope)
modifyScope fun scope => { scope with varDecls := scope.varDecls ++ binders, varUIds := scope.varUIds ++ varUIds }
| _ => throwUnsupportedSyntax
open Meta
@[builtinCommandElab Lean.Parser.Command.check] def elabCheck : CommandElab
| `(#check%$tk $term) => withoutModifyingEnv $ runTermElabM (some `_check) fun _ => do
let e ← Term.elabTerm term none
Term.synthesizeSyntheticMVarsNoPostponing
let (e, _) ← Term.levelMVarToParam (← instantiateMVars e)
let type ← inferType e
unless e.isSyntheticSorry do
logInfoAt tk m!"{e} : {type}"
| _ => throwUnsupportedSyntax
@[builtinCommandElab Lean.Parser.Command.reduce] def elabReduce : CommandElab
| `(#reduce%$tk $term) => withoutModifyingEnv <| runTermElabM (some `_check) fun _ => do
let e ← Term.elabTerm term none
Term.synthesizeSyntheticMVarsNoPostponing
let (e, _) ← Term.levelMVarToParam (← instantiateMVars e)
-- TODO: add options or notation for setting the following parameters
withTheReader Core.Context (fun ctx => { ctx with options := ctx.options.setBool `smartUnfolding false }) do
let e ← withTransparency (mode := TransparencyMode.all) <| reduce e (skipProofs := false) (skipTypes := false)
logInfoAt tk e
| _ => throwUnsupportedSyntax
def hasNoErrorMessages : CommandElabM Bool := do
return !(← get).messages.hasErrors
def failIfSucceeds (x : CommandElabM Unit) : CommandElabM Unit := do
let resetMessages : CommandElabM MessageLog := do
let s ← get
let messages := s.messages;
modify fun s => { s with messages := {} };
pure messages
let restoreMessages (prevMessages : MessageLog) : CommandElabM Unit := do
modify fun s => { s with messages := prevMessages ++ s.messages.errorsToWarnings }
let prevMessages ← resetMessages
let succeeded ←
try
x
hasNoErrorMessages
catch
| ex@(Exception.error _ _) => do logException ex; pure false
| Exception.internal id _ => do logError (← id.getName); pure false
finally
restoreMessages prevMessages
if succeeded then
throwError "unexpected success"
@[builtinCommandElab «check_failure»] def elabCheckFailure : CommandElab
| `(#check_failure $term) => do
failIfSucceeds <| elabCheck (← `(#check $term))
| _ => throwUnsupportedSyntax
unsafe def elabEvalUnsafe : CommandElab
| `(#eval%$tk $term) => do
let n := `_eval
let ctx ← read
let addAndCompile (value : Expr) : TermElabM Unit := do
let type ← inferType value
let decl := Declaration.defnDecl {
name := n
levelParams := []
type := type
value := value
hints := ReducibilityHints.opaque
safety := DefinitionSafety.unsafe
}
Term.ensureNoUnassignedMVars decl
addAndCompile decl
let elabMetaEval : CommandElabM Unit := runTermElabM (some n) fun _ => do
let e ← Term.elabTerm term none
Term.synthesizeSyntheticMVarsNoPostponing
let e ← withLocalDeclD `env (mkConst ``Lean.Environment) fun env =>
withLocalDeclD `opts (mkConst ``Lean.Options) fun opts => do
let e ← mkAppM ``Lean.runMetaEval #[env, opts, e];
mkLambdaFVars #[env, opts] e
let env ← getEnv
let opts ← getOptions
let act ← try addAndCompile e; evalConst (Environment → Options → IO (String × Except IO.Error Environment)) n finally setEnv env
let (out, res) ← act env opts -- we execute `act` using the environment
logInfoAt tk out
match res with
| Except.error e => throwError e.toString
| Except.ok env => do setEnv env; pure ()
let elabEval : CommandElabM Unit := runTermElabM (some n) fun _ => do
-- fall back to non-meta eval if MetaEval hasn't been defined yet
-- modify e to `runEval e`
let e ← Term.elabTerm term none
let e := mkSimpleThunk e
Term.synthesizeSyntheticMVarsNoPostponing
let e ← mkAppM ``Lean.runEval #[e]
let env ← getEnv
let act ← try addAndCompile e; evalConst (IO (String × Except IO.Error Unit)) n finally setEnv env
let (out, res) ← liftM (m := IO) act
logInfoAt tk out
match res with
| Except.error e => throwError e.toString
| Except.ok _ => pure ()
if (← getEnv).contains ``Lean.MetaEval then do
elabMetaEval
else
elabEval
| _ => throwUnsupportedSyntax
@[builtinCommandElab «eval», implementedBy elabEvalUnsafe]
constant elabEval : CommandElab
@[builtinCommandElab «synth»] def elabSynth : CommandElab := fun stx => do
let term := stx[1]
withoutModifyingEnv <| runTermElabM `_synth_cmd fun _ => do
let inst ← Term.elabTerm term none
Term.synthesizeSyntheticMVarsNoPostponing
let inst ← instantiateMVars inst
let val ← synthInstance inst
logInfo val
pure ()
@[builtinCommandElab «set_option»] def elabSetOption : CommandElab := fun stx => do
let options ← Elab.elabSetOption stx[1] stx[2]
modify fun s => { s with maxRecDepth := maxRecDepth.get options }
modifyScope fun scope => { scope with opts := options }
@[builtinMacro Lean.Parser.Command.«in»] def expandInCmd : Macro := fun stx => do
let cmd₁ := stx[0]
let cmd₂ := stx[2]
`(section $cmd₁:command $cmd₂:command end)
def expandDeclId (declId : Syntax) (modifiers : Modifiers) : CommandElabM ExpandDeclIdResult := do
let currNamespace ← getCurrNamespace
let currLevelNames ← getLevelNames
Lean.Elab.expandDeclId currNamespace currLevelNames declId modifiers
end Elab.Command
export Elab.Command (Linter addLinter)
end Lean
|
145de59f151e7c04c8b66d34078a36cdc5d83d08 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/data/set/intervals/instances.lean | b70ae02eee13ed425041dee9bd4860cac544b28a | [
"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 | 10,162 | lean | /-
Copyright (c) 2022 Stuart Presnell. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Stuart Presnell, Eric Wieser, Yaël Dillies, Patrick Massot, Scott Morrison
-/
import algebra.group_power.order
import algebra.ring.regular
/-!
# Algebraic instances for unit intervals
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
For suitably structured underlying type `α`, we exhibit the structure of
the unit intervals (`set.Icc`, `set.Ioc`, `set.Ioc`, and `set.Ioo`) from `0` to `1`.
Note: Instances for the interval `Ici 0` are dealt with in `algebra/order/nonneg.lean`.
## Main definitions
The strongest typeclass provided on each interval is:
* `set.Icc.cancel_comm_monoid_with_zero`
* `set.Ico.comm_semigroup`
* `set.Ioc.comm_monoid`
* `set.Ioo.comm_semigroup`
## TODO
* algebraic instances for intervals -1 to 1
* algebraic instances for `Ici 1`
* algebraic instances for `(Ioo (-1) 1)ᶜ`
* provide `has_distrib_neg` instances where applicable
* prove versions of `mul_le_{left,right}` for other intervals
* prove versions of the lemmas in `topology/unit_interval` with `ℝ` generalized to
some arbitrary ordered semiring
-/
open set
variables {α : Type*}
section ordered_semiring
variables [ordered_semiring α]
/-! ### Instances for `↥(set.Icc 0 1)` -/
namespace set.Icc
instance has_zero : has_zero (Icc (0:α) 1) := { zero := ⟨0, left_mem_Icc.2 zero_le_one⟩ }
instance has_one : has_one (Icc (0:α) 1) := { one := ⟨1, right_mem_Icc.2 zero_le_one⟩ }
@[simp, norm_cast] lemma coe_zero : ↑(0 : Icc (0:α) 1) = (0 : α) := rfl
@[simp, norm_cast] lemma coe_one : ↑(1 : Icc (0:α) 1) = (1 : α) := rfl
@[simp] lemma mk_zero (h : (0 : α) ∈ Icc (0 : α) 1) : (⟨0, h⟩ : Icc (0:α) 1) = 0 := rfl
@[simp] lemma mk_one (h : (1 : α) ∈ Icc (0 : α) 1) : (⟨1, h⟩ : Icc (0:α) 1) = 1 := rfl
@[simp, norm_cast] lemma coe_eq_zero {x : Icc (0:α) 1} : (x : α) = 0 ↔ x = 0 :=
by { symmetry, exact subtype.ext_iff }
lemma coe_ne_zero {x : Icc (0:α) 1} : (x : α) ≠ 0 ↔ x ≠ 0 :=
not_iff_not.mpr coe_eq_zero
@[simp, norm_cast] lemma coe_eq_one {x : Icc (0:α) 1} : (x : α) = 1 ↔ x = 1 :=
by { symmetry, exact subtype.ext_iff }
lemma coe_ne_one {x : Icc (0:α) 1} : (x : α) ≠ 1 ↔ x ≠ 1 :=
not_iff_not.mpr coe_eq_one
lemma coe_nonneg (x : Icc (0:α) 1) : 0 ≤ (x : α) := x.2.1
lemma coe_le_one (x : Icc (0:α) 1) : (x : α) ≤ 1 := x.2.2
/-- like `coe_nonneg`, but with the inequality in `Icc (0:α) 1`. -/
lemma nonneg {t : Icc (0:α) 1} : 0 ≤ t := t.2.1
/-- like `coe_le_one`, but with the inequality in `Icc (0:α) 1`. -/
lemma le_one {t : Icc (0:α) 1} : t ≤ 1 := t.2.2
instance has_mul : has_mul (Icc (0:α) 1) :=
{ mul := λ p q, ⟨p*q, ⟨mul_nonneg p.2.1 q.2.1, mul_le_one p.2.2 q.2.1 q.2.2⟩⟩ }
instance has_pow : has_pow (Icc (0:α) 1) ℕ :=
{ pow := λ p n, ⟨p.1 ^ n, ⟨pow_nonneg p.2.1 n, pow_le_one n p.2.1 p.2.2⟩⟩ }
@[simp, norm_cast] lemma coe_mul (x y : Icc (0:α) 1) : ↑(x * y) = (x * y : α) := rfl
@[simp, norm_cast] lemma coe_pow (x : Icc (0:α) 1) (n : ℕ) : ↑(x ^ n) = (x ^ n : α) := rfl
lemma mul_le_left {x y : Icc (0:α) 1} : x * y ≤ x :=
(mul_le_mul_of_nonneg_left y.2.2 x.2.1).trans_eq (mul_one x)
lemma mul_le_right {x y : Icc (0:α) 1} : x * y ≤ y :=
(mul_le_mul_of_nonneg_right x.2.2 y.2.1).trans_eq (one_mul y)
instance monoid_with_zero : monoid_with_zero (Icc (0:α) 1) :=
subtype.coe_injective.monoid_with_zero _ coe_zero coe_one coe_mul coe_pow
instance comm_monoid_with_zero {α : Type*} [ordered_comm_semiring α] :
comm_monoid_with_zero (Icc (0:α) 1) :=
subtype.coe_injective.comm_monoid_with_zero _ coe_zero coe_one coe_mul coe_pow
instance cancel_monoid_with_zero {α : Type*} [ordered_ring α] [no_zero_divisors α] :
cancel_monoid_with_zero (Icc (0:α) 1) :=
@function.injective.cancel_monoid_with_zero α _ no_zero_divisors.to_cancel_monoid_with_zero
_ _ _ _ coe subtype.coe_injective coe_zero coe_one coe_mul coe_pow
instance cancel_comm_monoid_with_zero {α : Type*} [ordered_comm_ring α] [no_zero_divisors α] :
cancel_comm_monoid_with_zero (Icc (0:α) 1) :=
@function.injective.cancel_comm_monoid_with_zero α _
no_zero_divisors.to_cancel_comm_monoid_with_zero
_ _ _ _ coe subtype.coe_injective coe_zero coe_one coe_mul coe_pow
variables {β : Type*} [ordered_ring β]
lemma one_sub_mem {t : β} (ht : t ∈ Icc (0:β) 1) : 1 - t ∈ Icc (0:β) 1 :=
by { rw mem_Icc at *, exact ⟨sub_nonneg.2 ht.2, (sub_le_self_iff _).2 ht.1⟩ }
lemma mem_iff_one_sub_mem {t : β} : t ∈ Icc (0:β) 1 ↔ 1 - t ∈ Icc (0:β) 1 :=
⟨one_sub_mem, λ h, (sub_sub_cancel 1 t) ▸ one_sub_mem h⟩
lemma one_sub_nonneg (x : Icc (0:β) 1) : 0 ≤ 1 - (x : β) := by simpa using x.2.2
lemma one_sub_le_one (x : Icc (0:β) 1) : 1 - (x : β) ≤ 1 := by simpa using x.2.1
end set.Icc
/-! ### Instances for `↥(set.Ico 0 1)` -/
namespace set.Ico
instance has_zero [nontrivial α] : has_zero (Ico (0:α) 1) :=
{ zero := ⟨0, left_mem_Ico.2 zero_lt_one⟩ }
@[simp, norm_cast] lemma coe_zero [nontrivial α] : ↑(0 : Ico (0:α) 1) = (0 : α) := rfl
@[simp] lemma mk_zero [nontrivial α] (h : (0 : α) ∈ Ico (0 : α) 1) : (⟨0, h⟩ : Ico (0:α) 1) = 0 :=
rfl
@[simp, norm_cast] lemma coe_eq_zero [nontrivial α] {x : Ico (0:α) 1} : (x : α) = 0 ↔ x = 0 :=
by { symmetry, exact subtype.ext_iff }
lemma coe_ne_zero [nontrivial α] {x : Ico (0:α) 1} : (x : α) ≠ 0 ↔ x ≠ 0 :=
not_iff_not.mpr coe_eq_zero
lemma coe_nonneg (x : Ico (0:α) 1) : 0 ≤ (x : α) := x.2.1
lemma coe_lt_one (x : Ico (0:α) 1) : (x : α) < 1 := x.2.2
/-- like `coe_nonneg`, but with the inequality in `Ico (0:α) 1`. -/
lemma nonneg [nontrivial α] {t : Ico (0:α) 1} : 0 ≤ t := t.2.1
instance has_mul : has_mul (Ico (0:α) 1) :=
{ mul := λ p q, ⟨p*q, ⟨mul_nonneg p.2.1 q.2.1,
mul_lt_one_of_nonneg_of_lt_one_right p.2.2.le q.2.1 q.2.2⟩⟩ }
@[simp, norm_cast] lemma coe_mul (x y : Ico (0:α) 1) : ↑(x * y) = (x * y : α) := rfl
instance semigroup : semigroup (Ico (0:α) 1) :=
subtype.coe_injective.semigroup _ coe_mul
instance comm_semigroup {α : Type*} [ordered_comm_semiring α] : comm_semigroup (Ico (0:α) 1) :=
subtype.coe_injective.comm_semigroup _ coe_mul
end set.Ico
end ordered_semiring
variables [strict_ordered_semiring α]
/-! ### Instances for `↥(set.Ioc 0 1)` -/
namespace set.Ioc
instance has_one [nontrivial α] : has_one (Ioc (0:α) 1) := { one := ⟨1, ⟨zero_lt_one, le_refl 1⟩⟩ }
@[simp, norm_cast] lemma coe_one [nontrivial α] : ↑(1 : Ioc (0:α) 1) = (1 : α) := rfl
@[simp] lemma mk_one [nontrivial α] (h : (1 : α) ∈ Ioc (0 : α) 1) : (⟨1, h⟩ : Ioc (0:α) 1) = 1 :=
rfl
@[simp, norm_cast] lemma coe_eq_one [nontrivial α] {x : Ioc (0:α) 1} : (x : α) = 1 ↔ x = 1 :=
by { symmetry, exact subtype.ext_iff }
lemma coe_ne_one [nontrivial α] {x : Ioc (0:α) 1} : (x : α) ≠ 1 ↔ x ≠ 1 :=
not_iff_not.mpr coe_eq_one
lemma coe_pos (x : Ioc (0:α) 1) : 0 < (x : α) := x.2.1
lemma coe_le_one (x : Ioc (0:α) 1) : (x : α) ≤ 1 := x.2.2
/-- like `coe_le_one`, but with the inequality in `Ioc (0:α) 1`. -/
lemma le_one [nontrivial α] {t : Ioc (0:α) 1} : t ≤ 1 := t.2.2
instance has_mul : has_mul (Ioc (0:α) 1) :=
{ mul := λ p q, ⟨p.1 * q.1, ⟨mul_pos p.2.1 q.2.1, mul_le_one p.2.2 (le_of_lt q.2.1) q.2.2⟩⟩ }
instance has_pow : has_pow (Ioc (0:α) 1) ℕ :=
{ pow := λ p n, ⟨p.1 ^ n, ⟨pow_pos p.2.1 n, pow_le_one n (le_of_lt p.2.1) p.2.2⟩⟩ }
@[simp, norm_cast] lemma coe_mul (x y : Ioc (0:α) 1) : ↑(x * y) = (x * y : α) := rfl
@[simp, norm_cast] lemma coe_pow (x : Ioc (0:α) 1) (n : ℕ) : ↑(x ^ n) = (x ^ n : α) := rfl
instance semigroup : semigroup (Ioc (0:α) 1) :=
subtype.coe_injective.semigroup _ coe_mul
instance monoid [nontrivial α] : monoid (Ioc (0:α) 1) :=
subtype.coe_injective.monoid _ coe_one coe_mul coe_pow
instance comm_semigroup {α : Type*} [strict_ordered_comm_semiring α] :
comm_semigroup (Ioc (0:α) 1) :=
subtype.coe_injective.comm_semigroup _ coe_mul
instance comm_monoid {α : Type*} [strict_ordered_comm_semiring α] [nontrivial α] :
comm_monoid (Ioc (0:α) 1) :=
subtype.coe_injective.comm_monoid _ coe_one coe_mul coe_pow
instance cancel_monoid {α : Type*} [strict_ordered_ring α] [is_domain α] :
cancel_monoid (Ioc (0:α) 1) :=
{ mul_left_cancel := λ a b c h,
subtype.ext $ mul_left_cancel₀ a.prop.1.ne' $ (congr_arg subtype.val h : _),
mul_right_cancel := λ a b c h,
subtype.ext $ mul_right_cancel₀ b.prop.1.ne' $ (congr_arg subtype.val h : _),
..set.Ioc.monoid}
instance cancel_comm_monoid {α : Type*} [strict_ordered_comm_ring α] [is_domain α] :
cancel_comm_monoid (Ioc (0:α) 1) :=
{ ..set.Ioc.cancel_monoid, ..set.Ioc.comm_monoid }
end set.Ioc
/-! ### Instances for `↥(set.Ioo 0 1)` -/
namespace set.Ioo
lemma pos (x : Ioo (0:α) 1) : 0 < (x : α) := x.2.1
lemma lt_one (x : Ioo (0:α) 1) : (x : α) < 1 := x.2.2
instance has_mul : has_mul (Ioo (0:α) 1) := { mul := λ p q, ⟨p.1 * q.1, ⟨mul_pos p.2.1 q.2.1,
mul_lt_one_of_nonneg_of_lt_one_right p.2.2.le q.2.1.le q.2.2⟩⟩ }
@[simp, norm_cast] lemma coe_mul (x y : Ioo (0:α) 1) : ↑(x * y) = (x * y : α) := rfl
instance semigroup : semigroup (Ioo (0:α) 1) :=
subtype.coe_injective.semigroup _ coe_mul
instance comm_semigroup {α : Type*} [strict_ordered_comm_semiring α] :
comm_semigroup (Ioo (0:α) 1) :=
subtype.coe_injective.comm_semigroup _ coe_mul
variables {β : Type*} [ordered_ring β]
lemma one_sub_mem {t : β} (ht : t ∈ Ioo (0:β) 1) : 1 - t ∈ Ioo (0:β) 1 :=
begin
rw mem_Ioo at *,
refine ⟨sub_pos.2 ht.2, _⟩,
exact lt_of_le_of_ne ((sub_le_self_iff 1).2 ht.1.le) (mt sub_eq_self.mp ht.1.ne'),
end
lemma mem_iff_one_sub_mem {t : β} : t ∈ Ioo (0:β) 1 ↔ 1 - t ∈ Ioo (0:β) 1 :=
⟨one_sub_mem, λ h, (sub_sub_cancel 1 t) ▸ one_sub_mem h⟩
lemma one_minus_pos (x : Ioo (0:β) 1) : 0 < 1 - (x : β) := by simpa using x.2.2
lemma one_minus_lt_one (x : Ioo (0:β) 1) : 1 - (x : β) < 1 := by simpa using x.2.1
end set.Ioo
|
dd7e931e781a848b882b3fdb03e2dc5327c7b2fc | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/linear_algebra/orientation.lean | bb3a10db1967210b6ccae8fe53280261385e142e | [
"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 | 11,638 | lean | /-
Copyright (c) 2021 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import linear_algebra.ray
import linear_algebra.determinant
/-!
# Orientations of modules
This file defines orientations of modules.
## Main definitions
* `orientation` is a type synonym for `module.ray` for the case where the module is that of
alternating maps from a module to its underlying ring. An orientation may be associated with an
alternating map or with a basis.
* `module.oriented` is a type class for a choice of orientation of a module that is considered
the positive orientation.
## Implementation notes
`orientation` is defined for an arbitrary index type, but the main intended use case is when
that index type is a `fintype` and there exists a basis of the same cardinality.
## References
* https://en.wikipedia.org/wiki/Orientation_(vector_space)
-/
noncomputable theory
open_locale big_operators
section ordered_comm_semiring
variables (R : Type*) [ordered_comm_semiring R]
variables (M : Type*) [add_comm_monoid M] [module R M]
variables {N : Type*} [add_comm_monoid N] [module R N]
variables (ι : Type*) [decidable_eq ι]
/-- An orientation of a module, intended to be used when `ι` is a `fintype` with the same
cardinality as a basis. -/
abbreviation orientation := module.ray R (alternating_map R M R ι)
/-- A type class fixing an orientation of a module. -/
class module.oriented :=
(positive_orientation : orientation R M ι)
variables {R M}
/-- An equivalence between modules implies an equivalence between orientations. -/
def orientation.map (e : M ≃ₗ[R] N) : orientation R M ι ≃ orientation R N ι :=
module.ray.map $ alternating_map.dom_lcongr R R ι R e
@[simp] lemma orientation.map_apply (e : M ≃ₗ[R] N) (v : alternating_map R M R ι)
(hv : v ≠ 0) :
orientation.map ι e (ray_of_ne_zero _ v hv) = ray_of_ne_zero _ (v.comp_linear_map e.symm)
(mt (v.comp_linear_equiv_eq_zero_iff e.symm).mp hv) := rfl
@[simp] lemma orientation.map_refl :
(orientation.map ι $ linear_equiv.refl R M) = equiv.refl _ :=
by rw [orientation.map, alternating_map.dom_lcongr_refl, module.ray.map_refl]
@[simp] lemma orientation.map_symm (e : M ≃ₗ[R] N) :
(orientation.map ι e).symm = orientation.map ι e.symm := rfl
end ordered_comm_semiring
section ordered_comm_ring
variables {R : Type*} [ordered_comm_ring R]
variables {M N : Type*} [add_comm_group M] [add_comm_group N] [module R M] [module R N]
namespace basis
variables {ι : Type*} [decidable_eq ι]
/-- The value of `orientation.map` when the index type has the cardinality of a basis, in terms
of `f.det`. -/
lemma map_orientation_eq_det_inv_smul [finite ι] (e : basis ι R M)
(x : orientation R M ι) (f : M ≃ₗ[R] M) : orientation.map ι f x = (f.det)⁻¹ • x :=
begin
casesI nonempty_fintype ι,
induction x using module.ray.ind with g hg,
rw [orientation.map_apply, smul_ray_of_ne_zero, ray_eq_iff, units.smul_def,
(g.comp_linear_map ↑f.symm).eq_smul_basis_det e, g.eq_smul_basis_det e,
alternating_map.comp_linear_map_apply, alternating_map.smul_apply, basis.det_comp,
basis.det_self, mul_one, smul_eq_mul, mul_comm, mul_smul, linear_equiv.coe_inv_det],
end
variables [fintype ι]
/-- The orientation given by a basis. -/
protected def orientation [nontrivial R] (e : basis ι R M) : orientation R M ι :=
ray_of_ne_zero R _ e.det_ne_zero
lemma orientation_map [nontrivial R] (e : basis ι R M)
(f : M ≃ₗ[R] N) : (e.map f).orientation = orientation.map ι f e.orientation :=
by simp_rw [basis.orientation, orientation.map_apply, basis.det_map']
/-- The orientation given by a basis derived using `units_smul`, in terms of the product of those
units. -/
lemma orientation_units_smul [nontrivial R] (e : basis ι R M) (w : ι → units R) :
(e.units_smul w).orientation = (∏ i, w i)⁻¹ • e.orientation :=
begin
rw [basis.orientation, basis.orientation, smul_ray_of_ne_zero, ray_eq_iff,
e.det.eq_smul_basis_det (e.units_smul w), det_units_smul, units.smul_def, smul_smul],
norm_cast,
simp
end
end basis
end ordered_comm_ring
section linear_ordered_comm_ring
variables {R : Type*} [linear_ordered_comm_ring R]
variables {M : Type*} [add_comm_group M] [module R M]
variables {ι : Type*} [decidable_eq ι]
namespace basis
variables [fintype ι]
/-- The orientations given by two bases are equal if and only if the determinant of one basis
with respect to the other is positive. -/
lemma orientation_eq_iff_det_pos (e₁ e₂ : basis ι R M) :
e₁.orientation = e₂.orientation ↔ 0 < e₁.det e₂ :=
calc e₁.orientation = e₂.orientation ↔ same_ray R e₁.det e₂.det : ray_eq_iff _ _
... ↔ same_ray R (e₁.det e₂ • e₂.det) e₂.det : by rw [← e₁.det.eq_smul_basis_det e₂]
... ↔ 0 < e₁.det e₂ : same_ray_smul_left_iff_of_ne e₂.det_ne_zero (e₁.is_unit_det e₂).ne_zero
/-- Given a basis, any orientation equals the orientation given by that basis or its negation. -/
lemma orientation_eq_or_eq_neg (e : basis ι R M) (x : orientation R M ι) :
x = e.orientation ∨ x = -e.orientation :=
begin
induction x using module.ray.ind with x hx,
rw ← x.map_basis_ne_zero_iff e at hx,
rwa [basis.orientation, ray_eq_iff, neg_ray_of_ne_zero, ray_eq_iff, x.eq_smul_basis_det e,
same_ray_neg_smul_left_iff_of_ne e.det_ne_zero hx,
same_ray_smul_left_iff_of_ne e.det_ne_zero hx, lt_or_lt_iff_ne, ne_comm]
end
/-- Given a basis, an orientation equals the negation of that given by that basis if and only
if it does not equal that given by that basis. -/
lemma orientation_ne_iff_eq_neg (e : basis ι R M) (x : orientation R M ι) :
x ≠ e.orientation ↔ x = -e.orientation :=
⟨λ h, (e.orientation_eq_or_eq_neg x).resolve_left h,
λ h, h.symm ▸ (module.ray.ne_neg_self e.orientation).symm⟩
/-- Composing a basis with a linear equiv gives the same orientation if and only if the
determinant is positive. -/
lemma orientation_comp_linear_equiv_eq_iff_det_pos (e : basis ι R M) (f : M ≃ₗ[R] M) :
(e.map f).orientation = e.orientation ↔ 0 < (f : M →ₗ[R] M).det :=
by rw [orientation_map, e.map_orientation_eq_det_inv_smul, units_inv_smul, units_smul_eq_self_iff,
linear_equiv.coe_det]
/-- Composing a basis with a linear equiv gives the negation of that orientation if and only if
the determinant is negative. -/
lemma orientation_comp_linear_equiv_eq_neg_iff_det_neg (e : basis ι R M) (f : M ≃ₗ[R] M) :
(e.map f).orientation = -e.orientation ↔ (f : M →ₗ[R] M).det < 0 :=
by rw [orientation_map, e.map_orientation_eq_det_inv_smul, units_inv_smul, units_smul_eq_neg_iff,
linear_equiv.coe_det]
/-- Negating a single basis vector (represented using `units_smul`) negates the corresponding
orientation. -/
@[simp] lemma orientation_neg_single [nontrivial R] (e : basis ι R M) (i : ι) :
(e.units_smul (function.update 1 i (-1))).orientation = -e.orientation :=
begin
rw [orientation_units_smul, finset.prod_update_of_mem (finset.mem_univ _)],
simp
end
/-- Given a basis and an orientation, return a basis giving that orientation: either the original
basis, or one constructed by negating a single (arbitrary) basis vector. -/
def adjust_to_orientation [nontrivial R] [nonempty ι] (e : basis ι R M) (x : orientation R M ι) :
basis ι R M :=
by haveI := classical.dec_eq (orientation R M ι); exact if e.orientation = x then e else
(e.units_smul (function.update 1 (classical.arbitrary ι) (-1)))
/-- `adjust_to_orientation` gives a basis with the required orientation. -/
@[simp] lemma orientation_adjust_to_orientation [nontrivial R] [nonempty ι] (e : basis ι R M)
(x : orientation R M ι) : (e.adjust_to_orientation x).orientation = x :=
begin
rw adjust_to_orientation,
split_ifs with h,
{ exact h },
{ rw [orientation_neg_single, eq_comm, ←orientation_ne_iff_eq_neg, ne_comm],
exact h }
end
/-- Every basis vector from `adjust_to_orientation` is either that from the original basis or its
negation. -/
lemma adjust_to_orientation_apply_eq_or_eq_neg [nontrivial R] [nonempty ι] (e : basis ι R M)
(x : orientation R M ι) (i : ι) :
e.adjust_to_orientation x i = e i ∨ e.adjust_to_orientation x i = -(e i) :=
begin
rw adjust_to_orientation,
split_ifs with h,
{ simp },
{ by_cases hi : i = classical.arbitrary ι;
simp [units_smul_apply, hi] }
end
end basis
end linear_ordered_comm_ring
section linear_ordered_field
variables {R : Type*} [linear_ordered_field R]
variables {M : Type*} [add_comm_group M] [module R M]
variables {ι : Type*} [decidable_eq ι]
namespace orientation
variables [fintype ι] [finite_dimensional R M]
open finite_dimensional
/-- If the index type has cardinality equal to the finite dimension, any two orientations are
equal or negations. -/
lemma eq_or_eq_neg (x₁ x₂ : orientation R M ι) (h : fintype.card ι = finrank R M) :
x₁ = x₂ ∨ x₁ = -x₂ :=
begin
have e := (fin_basis R M).reindex (fintype.equiv_fin_of_card_eq h).symm,
rcases e.orientation_eq_or_eq_neg x₁ with h₁|h₁;
rcases e.orientation_eq_or_eq_neg x₂ with h₂|h₂;
simp [h₁, h₂]
end
/-- If the index type has cardinality equal to the finite dimension, an orientation equals the
negation of another orientation if and only if they are not equal. -/
lemma ne_iff_eq_neg (x₁ x₂ : orientation R M ι) (h : fintype.card ι = finrank R M) :
x₁ ≠ x₂ ↔ x₁ = -x₂ :=
⟨λ hn, (eq_or_eq_neg x₁ x₂ h).resolve_left hn, λ he, he.symm ▸ (module.ray.ne_neg_self x₂).symm⟩
/-- The value of `orientation.map` when the index type has cardinality equal to the finite
dimension, in terms of `f.det`. -/
lemma map_eq_det_inv_smul (x : orientation R M ι) (f : M ≃ₗ[R] M)
(h : fintype.card ι = finrank R M) :
orientation.map ι f x = (f.det)⁻¹ • x :=
begin
have e := (fin_basis R M).reindex (fintype.equiv_fin_of_card_eq h).symm,
exact e.map_orientation_eq_det_inv_smul x f
end
/-- If the index type has cardinality equal to the finite dimension, composing an alternating
map with the same linear equiv on each argument gives the same orientation if and only if the
determinant is positive. -/
lemma map_eq_iff_det_pos (x : orientation R M ι) (f : M ≃ₗ[R] M)
(h : fintype.card ι = finrank R M) :
orientation.map ι f x = x ↔ 0 < (f : M →ₗ[R] M).det :=
by rw [map_eq_det_inv_smul _ _ h, units_inv_smul, units_smul_eq_self_iff, linear_equiv.coe_det]
/-- If the index type has cardinality equal to the finite dimension, composing an alternating
map with the same linear equiv on each argument gives the negation of that orientation if and
only if the determinant is negative. -/
lemma map_eq_neg_iff_det_neg (x : orientation R M ι) (f : M ≃ₗ[R] M)
(h : fintype.card ι = finrank R M) :
orientation.map ι f x = -x ↔ (f : M →ₗ[R] M).det < 0 :=
by rw [map_eq_det_inv_smul _ _ h, units_inv_smul, units_smul_eq_neg_iff, linear_equiv.coe_det]
/-- If the index type has cardinality equal to the finite dimension, a basis with the given
orientation. -/
def some_basis [nonempty ι] (x : orientation R M ι) (h : fintype.card ι = finrank R M) :
basis ι R M :=
((fin_basis R M).reindex (fintype.equiv_fin_of_card_eq h).symm).adjust_to_orientation x
/-- `some_basis` gives a basis with the required orientation. -/
@[simp] lemma some_basis_orientation [nonempty ι] (x : orientation R M ι)
(h : fintype.card ι = finrank R M) : (x.some_basis h).orientation = x :=
basis.orientation_adjust_to_orientation _ _
end orientation
end linear_ordered_field
|
fb1f78f7b160309ba8c11aa5c4ddf8491b600bc6 | c777c32c8e484e195053731103c5e52af26a25d1 | /src/analysis/special_functions/trigonometric/arctan_deriv.lean | d36c11cf4d688d1a4bcdb20c54d1ec85fa564c6a | [
"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 | 7,614 | lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import analysis.special_functions.trigonometric.arctan
import analysis.special_functions.trigonometric.complex_deriv
/-!
# Derivatives of the `tan` and `arctan` functions.
Continuity and derivatives of the tangent and arctangent functions.
-/
noncomputable theory
namespace real
open set filter
open_locale topology real
lemma has_strict_deriv_at_tan {x : ℝ} (h : cos x ≠ 0) :
has_strict_deriv_at tan (1 / (cos x)^2) x :=
by exact_mod_cast (complex.has_strict_deriv_at_tan (by exact_mod_cast h)).real_of_complex
lemma has_deriv_at_tan {x : ℝ} (h : cos x ≠ 0) :
has_deriv_at tan (1 / (cos x)^2) x :=
by exact_mod_cast (complex.has_deriv_at_tan (by exact_mod_cast h)).real_of_complex
lemma tendsto_abs_tan_of_cos_eq_zero {x : ℝ} (hx : cos x = 0) :
tendsto (λ x, abs (tan x)) (𝓝[≠] x) at_top :=
begin
have hx : complex.cos x = 0, by exact_mod_cast hx,
simp only [← complex.abs_of_real, complex.of_real_tan],
refine (complex.tendsto_abs_tan_of_cos_eq_zero hx).comp _,
refine tendsto.inf complex.continuous_of_real.continuous_at _,
exact tendsto_principal_principal.2 (λ y, mt complex.of_real_inj.1)
end
lemma tendsto_abs_tan_at_top (k : ℤ) :
tendsto (λ x, abs (tan x)) (𝓝[≠] ((2 * k + 1) * π / 2)) at_top :=
tendsto_abs_tan_of_cos_eq_zero $ cos_eq_zero_iff.2 ⟨k, rfl⟩
lemma continuous_at_tan {x : ℝ} : continuous_at tan x ↔ cos x ≠ 0 :=
begin
refine ⟨λ hc h₀, _, λ h, (has_deriv_at_tan h).continuous_at⟩,
exact not_tendsto_nhds_of_tendsto_at_top (tendsto_abs_tan_of_cos_eq_zero h₀) _
(hc.norm.tendsto.mono_left inf_le_left)
end
lemma differentiable_at_tan {x : ℝ} : differentiable_at ℝ tan x ↔ cos x ≠ 0 :=
⟨λ h, continuous_at_tan.1 h.continuous_at, λ h, (has_deriv_at_tan h).differentiable_at⟩
@[simp] lemma deriv_tan (x : ℝ) : deriv tan x = 1 / (cos x)^2 :=
if h : cos x = 0 then
have ¬differentiable_at ℝ tan x := mt differentiable_at_tan.1 (not_not.2 h),
by simp [deriv_zero_of_not_differentiable_at this, h, sq]
else (has_deriv_at_tan h).deriv
@[simp] lemma cont_diff_at_tan {n x} : cont_diff_at ℝ n tan x ↔ cos x ≠ 0 :=
⟨λ h, continuous_at_tan.1 h.continuous_at,
λ h, (complex.cont_diff_at_tan.2 $ by exact_mod_cast h).real_of_complex⟩
lemma has_deriv_at_tan_of_mem_Ioo {x : ℝ} (h : x ∈ Ioo (-(π/2):ℝ) (π/2)) :
has_deriv_at tan (1 / (cos x)^2) x :=
has_deriv_at_tan (cos_pos_of_mem_Ioo h).ne'
lemma differentiable_at_tan_of_mem_Ioo {x : ℝ} (h : x ∈ Ioo (-(π/2):ℝ) (π/2)) :
differentiable_at ℝ tan x :=
(has_deriv_at_tan_of_mem_Ioo h).differentiable_at
lemma has_strict_deriv_at_arctan (x : ℝ) : has_strict_deriv_at arctan (1 / (1 + x^2)) x :=
have A : cos (arctan x) ≠ 0 := (cos_arctan_pos x).ne',
by simpa [cos_sq_arctan]
using tan_local_homeomorph.has_strict_deriv_at_symm trivial (by simpa) (has_strict_deriv_at_tan A)
lemma has_deriv_at_arctan (x : ℝ) : has_deriv_at arctan (1 / (1 + x^2)) x :=
(has_strict_deriv_at_arctan x).has_deriv_at
lemma differentiable_at_arctan (x : ℝ) : differentiable_at ℝ arctan x :=
(has_deriv_at_arctan x).differentiable_at
lemma differentiable_arctan : differentiable ℝ arctan := differentiable_at_arctan
@[simp] lemma deriv_arctan : deriv arctan = (λ x, 1 / (1 + x^2)) :=
funext $ λ x, (has_deriv_at_arctan x).deriv
lemma cont_diff_arctan {n : ℕ∞} : cont_diff ℝ n arctan :=
cont_diff_iff_cont_diff_at.2 $ λ x,
have cos (arctan x) ≠ 0 := (cos_arctan_pos x).ne',
tan_local_homeomorph.cont_diff_at_symm_deriv (by simpa) trivial (has_deriv_at_tan this)
(cont_diff_at_tan.2 this)
end real
section
/-!
### Lemmas for derivatives of the composition of `real.arctan` with a differentiable function
In this section we register lemmas for the derivatives of the composition of `real.arctan` with a
differentiable function, for standalone use and use with `simp`. -/
open real
section deriv
variables {f : ℝ → ℝ} {f' x : ℝ} {s : set ℝ}
lemma has_strict_deriv_at.arctan (hf : has_strict_deriv_at f f' x) :
has_strict_deriv_at (λ x, arctan (f x)) ((1 / (1 + (f x)^2)) * f') x :=
(real.has_strict_deriv_at_arctan (f x)).comp x hf
lemma has_deriv_at.arctan (hf : has_deriv_at f f' x) :
has_deriv_at (λ x, arctan (f x)) ((1 / (1 + (f x)^2)) * f') x :=
(real.has_deriv_at_arctan (f x)).comp x hf
lemma has_deriv_within_at.arctan (hf : has_deriv_within_at f f' s x) :
has_deriv_within_at (λ x, arctan (f x)) ((1 / (1 + (f x)^2)) * f') s x :=
(real.has_deriv_at_arctan (f x)).comp_has_deriv_within_at x hf
lemma deriv_within_arctan (hf : differentiable_within_at ℝ f s x)
(hxs : unique_diff_within_at ℝ s x) :
deriv_within (λ x, arctan (f x)) s x = (1 / (1 + (f x)^2)) * (deriv_within f s x) :=
hf.has_deriv_within_at.arctan.deriv_within hxs
@[simp] lemma deriv_arctan (hc : differentiable_at ℝ f x) :
deriv (λ x, arctan (f x)) x = (1 / (1 + (f x)^2)) * (deriv f x) :=
hc.has_deriv_at.arctan.deriv
end deriv
section fderiv
variables {E : Type*} [normed_add_comm_group E] [normed_space ℝ E] {f : E → ℝ} {f' : E →L[ℝ] ℝ}
{x : E} {s : set E} {n : ℕ∞}
lemma has_strict_fderiv_at.arctan (hf : has_strict_fderiv_at f f' x) :
has_strict_fderiv_at (λ x, arctan (f x)) ((1 / (1 + (f x)^2)) • f') x :=
(has_strict_deriv_at_arctan (f x)).comp_has_strict_fderiv_at x hf
lemma has_fderiv_at.arctan (hf : has_fderiv_at f f' x) :
has_fderiv_at (λ x, arctan (f x)) ((1 / (1 + (f x)^2)) • f') x :=
(has_deriv_at_arctan (f x)).comp_has_fderiv_at x hf
lemma has_fderiv_within_at.arctan (hf : has_fderiv_within_at f f' s x) :
has_fderiv_within_at (λ x, arctan (f x)) ((1 / (1 + (f x)^2)) • f') s x :=
(has_deriv_at_arctan (f x)).comp_has_fderiv_within_at x hf
lemma fderiv_within_arctan (hf : differentiable_within_at ℝ f s x)
(hxs : unique_diff_within_at ℝ s x) :
fderiv_within ℝ (λ x, arctan (f x)) s x = (1 / (1 + (f x)^2)) • (fderiv_within ℝ f s x) :=
hf.has_fderiv_within_at.arctan.fderiv_within hxs
@[simp] lemma fderiv_arctan (hc : differentiable_at ℝ f x) :
fderiv ℝ (λ x, arctan (f x)) x = (1 / (1 + (f x)^2)) • (fderiv ℝ f x) :=
hc.has_fderiv_at.arctan.fderiv
lemma differentiable_within_at.arctan (hf : differentiable_within_at ℝ f s x) :
differentiable_within_at ℝ (λ x, real.arctan (f x)) s x :=
hf.has_fderiv_within_at.arctan.differentiable_within_at
@[simp] lemma differentiable_at.arctan (hc : differentiable_at ℝ f x) :
differentiable_at ℝ (λ x, arctan (f x)) x :=
hc.has_fderiv_at.arctan.differentiable_at
lemma differentiable_on.arctan (hc : differentiable_on ℝ f s) :
differentiable_on ℝ (λ x, arctan (f x)) s :=
λ x h, (hc x h).arctan
@[simp] lemma differentiable.arctan (hc : differentiable ℝ f) :
differentiable ℝ (λ x, arctan (f x)) :=
λ x, (hc x).arctan
lemma cont_diff_at.arctan (h : cont_diff_at ℝ n f x) :
cont_diff_at ℝ n (λ x, arctan (f x)) x :=
cont_diff_arctan.cont_diff_at.comp x h
lemma cont_diff.arctan (h : cont_diff ℝ n f) :
cont_diff ℝ n (λ x, arctan (f x)) :=
cont_diff_arctan.comp h
lemma cont_diff_within_at.arctan (h : cont_diff_within_at ℝ n f s x) :
cont_diff_within_at ℝ n (λ x, arctan (f x)) s x :=
cont_diff_arctan.comp_cont_diff_within_at h
lemma cont_diff_on.arctan (h : cont_diff_on ℝ n f s) :
cont_diff_on ℝ n (λ x, arctan (f x)) s :=
cont_diff_arctan.comp_cont_diff_on h
end fderiv
end
|
e40db65e5ef000f28916c37fd3688e0ed413d8e2 | e2fc96178628c7451e998a0db2b73877d0648be5 | /src/classes/unrestricted/closure_properties/star.lean | eeea5f8edb7f91d397915c6935d0eec0ccbd1e83 | [
"BSD-2-Clause"
] | permissive | madvorak/grammars | cd324ae19b28f7b8be9c3ad010ef7bf0fabe5df2 | 1447343a45fcb7821070f1e20b57288d437323a6 | refs/heads/main | 1,692,383,644,884 | 1,692,032,429,000 | 1,692,032,429,000 | 453,948,141 | 7 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 119,971 | lean | import classes.unrestricted.basics.lifting
import classes.unrestricted.closure_properties.concatenation
import utilities.written_by_others.trim_assoc
-- new nonterminal type
private def nn (N : Type) : Type :=
N ⊕ fin 3
-- new symbol type
private def ns (T N : Type) : Type :=
symbol T (nn N)
variables {T : Type}
section specific_symbols
private def Z {N : Type} : ns T N := symbol.nonterminal (sum.inr 0)
private def H {N : Type} : ns T N := symbol.nonterminal (sum.inr 1) -- denoted by `#` in the pdf
private def R {N : Type} : ns T N := symbol.nonterminal (sum.inr 2)
private def S {g : grammar T} : ns T g.nt := symbol.nonterminal (sum.inl g.initial)
private lemma Z_neq_H {N : Type} : Z ≠ @H T N :=
begin
intro ass,
have imposs := sum.inr.inj (symbol.nonterminal.inj ass),
exact fin.zero_ne_one imposs,
end
private lemma Z_neq_R {N : Type} : Z ≠ @R T N :=
begin
intro ass,
have imposs := sum.inr.inj (symbol.nonterminal.inj ass),
have zero_ne_two : (0 : fin 3) ≠ (2 : fin 3), dec_trivial,
exact zero_ne_two imposs,
end
private lemma H_neq_R {N : Type} : H ≠ @R T N :=
begin
intro ass,
have imposs := sum.inr.inj (symbol.nonterminal.inj ass),
have one_ne_two : (1 : fin 3) ≠ (2 : fin 3), dec_trivial,
exact one_ne_two imposs,
end
end specific_symbols
section construction
private def wrap_sym {N : Type} : symbol T N → ns T N
| (symbol.terminal t) := symbol.terminal t
| (symbol.nonterminal n) := symbol.nonterminal (sum.inl n)
private def wrap_gr {N : Type} (r : grule T N) : grule T (nn N) :=
grule.mk
(list.map wrap_sym r.input_L)
(sum.inl r.input_N)
(list.map wrap_sym r.input_R)
(list.map wrap_sym r.output_string)
private def rules_that_scan_terminals (g : grammar T) : list (grule T (nn g.nt)) :=
list.map (λ t, grule.mk
[] (sum.inr 2) [symbol.terminal t] [symbol.terminal t, R]
) (all_used_terminals g)
-- based on `/informal/KleeneStar.pdf`
private def star_grammar (g : grammar T) : grammar T :=
grammar.mk (nn g.nt) (sum.inr 0) (
grule.mk [] (sum.inr 0) [] [Z, S, H] ::
grule.mk [] (sum.inr 0) [] [R, H] ::
grule.mk [] (sum.inr 2) [H] [R] ::
grule.mk [] (sum.inr 2) [H] [] ::
list.map wrap_gr g.rules ++
rules_that_scan_terminals g
)
end construction
section easy_direction
private lemma short_induction {g : grammar T} {w : list (list T)}
(ass : ∀ wᵢ ∈ w.reverse, grammar_generates g wᵢ) :
grammar_derives (star_grammar g) [Z] (Z ::
list.join (list.map (++ [H]) (list.map (list.map symbol.terminal) w.reverse))
) ∧
∀ p ∈ w, ∀ t ∈ p, symbol.terminal t ∈ list.join (list.map grule.output_string g.rules) :=
begin
induction w with v x ih,
{
split,
{
apply grammar_deri_self,
},
{
intros p pin,
exfalso,
exact list.not_mem_nil p pin,
},
},
have vx_reverse : (v :: x).reverse = x.reverse ++ [v],
{
apply list.reverse_cons,
},
rw vx_reverse at *,
specialize ih (by {
intros wᵢ in_reversed,
apply ass,
apply list.mem_append_left,
exact in_reversed,
}),
specialize ass v (by {
apply list.mem_append_right,
apply list.mem_singleton_self,
}),
unfold grammar_generates at ass,
split,
{
apply grammar_deri_of_tran_deri,
{
use (star_grammar g).rules.nth_le 0 (by dec_trivial),
split,
{
apply list.nth_le_mem,
},
use [[], []],
split;
refl,
},
rw [list.nil_append, list.append_nil, list.map_append, list.map_append],
change grammar_derives (star_grammar g) [Z, S, H] _,
have ih_plus := grammar_deri_with_postfix ([S, H] : list (symbol T (star_grammar g).nt)) ih.left,
apply grammar_deri_of_deri_deri ih_plus,
have ass_lifted : grammar_derives (star_grammar g) [S] (list.map symbol.terminal v),
{
clear_except ass,
have wrap_eq_lift : @wrap_sym T g.nt = lift_symbol_ sum.inl,
{
ext,
cases x;
refl,
},
let lifted_g : lifted_grammar_ T :=
lifted_grammar_.mk g (star_grammar g) sum.inl sum.get_left (by {
intros x y hyp,
exact sum.inl.inj hyp,
}) (by {
intros x y hyp,
cases x,
{
cases y,
{
simp only [sum.get_left] at hyp,
left,
congr,
exact hyp,
},
{
simp only [sum.get_left] at hyp,
exfalso,
exact hyp,
},
},
{
cases y,
{
simp only [sum.get_left] at hyp,
exfalso,
exact hyp,
},
{
right,
refl,
},
},
}) (by {
intro x,
refl,
}) (by {
intros r rin,
apply list.mem_cons_of_mem,
apply list.mem_cons_of_mem,
apply list.mem_cons_of_mem,
apply list.mem_cons_of_mem,
apply list.mem_append_left,
rw list.mem_map,
use r,
split,
{
exact rin,
},
unfold wrap_gr,
unfold lift_rule_,
unfold lift_string_,
rw wrap_eq_lift,
}) (by {
rintros r ⟨rin, n, nrn⟩,
iterate 4 {
cases rin,
{
exfalso,
rw rin at nrn,
exact sum.no_confusion nrn,
},
},
change r ∈ list.map wrap_gr g.rules ++ rules_that_scan_terminals g at rin,
rw list.mem_append at rin,
cases rin,
{
clear_except rin wrap_eq_lift,
rw list.mem_map at rin,
rcases rin with ⟨r₀, rin₀, r_of_r₀⟩,
use r₀,
split,
{
exact rin₀,
},
convert r_of_r₀,
unfold lift_rule_,
unfold wrap_gr,
unfold lift_string_,
rw wrap_eq_lift,
},
{
exfalso,
unfold rules_that_scan_terminals at rin,
rw list.mem_map at rin,
rcases rin with ⟨t, tin, r_of_tg⟩,
rw ←r_of_tg at nrn,
exact sum.no_confusion nrn,
},
}),
convert_to
grammar_derives lifted_g.g
[symbol.nonterminal (sum.inl g.initial)]
(lift_string_ lifted_g.lift_nt (list.map symbol.terminal v)),
{
unfold lift_string_,
rw list.map_map,
congr,
},
exact lift_deri_ lifted_g ass,
},
have ass_postf := grammar_deri_with_postfix ([H] : list (symbol T (star_grammar g).nt)) ass_lifted,
rw list.join_append,
rw ←list.cons_append,
apply grammar_deri_with_prefix,
rw list.map_map,
rw list.map_singleton,
rw list.join_singleton,
change grammar_derives (star_grammar g) [S, H] (list.map symbol.terminal v ++ [H]),
convert ass_postf,
},
{
intros p pin t tin,
cases pin,
{
rw pin at tin,
clear pin,
have stin : symbol.terminal t ∈ list.map symbol.terminal v,
{
rw list.mem_map,
use t,
split,
{
exact tin,
},
{
refl,
},
},
cases grammar_generates_only_legit_terminals ass stin with rule_exists imposs,
{
rcases rule_exists with ⟨r, rin, stirn⟩,
rw list.mem_join,
use r.output_string,
split,
{
rw list.mem_map,
use r,
split,
{
exact rin,
},
{
refl,
},
},
{
exact stirn,
},
},
{
exfalso,
exact symbol.no_confusion imposs,
}
},
{
exact ih.right p pin t tin,
}
},
end
private lemma terminal_scan_ind {g : grammar T} {w : list (list T)} (n : ℕ) (n_lt_wl : n ≤ w.length)
(terminals : ∀ v ∈ w, ∀ t ∈ v, symbol.terminal t ∈ list.join (list.map grule.output_string g.rules)) :
grammar_derives (star_grammar g)
((list.map (λ u, list.map symbol.terminal u) (list.take (w.length - n) w)).join ++ [R] ++
(list.map (λ v, [H] ++ list.map symbol.terminal v) (list.drop (w.length - n) w)).join ++ [H])
(list.map symbol.terminal w.join ++ [R, H]) :=
begin
induction n with k ih,
{
rw nat.sub_zero,
rw list.drop_length,
rw list.map_nil,
rw list.join,
rw list.append_nil,
rw list.take_length,
rw list.map_join,
rw list.append_assoc,
apply grammar_deri_self,
},
specialize ih (nat.le_of_succ_le n_lt_wl),
apply grammar_deri_of_deri_deri _ ih,
clear ih,
have wlk_succ : w.length - k = (w.length - k.succ).succ,
{
omega,
},
have lt_wl : w.length - k.succ < w.length,
{
omega,
},
have split_ldw :
list.drop (w.length - k.succ) w =
(w.nth (w.length - k.succ)).to_list ++ list.drop (w.length - k) w,
{
rw wlk_succ,
generalize substit : w.length - k.succ = q,
rw substit at lt_wl,
rw ←list.take_append_drop q w,
rw list.nth_append_right,
swap, {
apply list.length_take_le,
},
have eq_q : (list.take q w).length = q,
{
rw list.length_take,
exact min_eq_left_of_lt lt_wl,
},
rw eq_q,
rw nat.sub_self,
have drop_q_succ :
list.drop q.succ (list.take q w ++ list.drop q w) = list.drop 1 (list.drop q w),
{
rw list.drop_drop,
rw list.take_append_drop,
rw add_comm,
},
rw [drop_q_succ, list.drop_left' eq_q, list.drop_drop],
rw ←list.take_append_drop (1 + q) w,
have q_lt : q < (list.take (1 + q) w).length,
{
rw list.length_take,
exact lt_min (lt_one_add q) lt_wl,
},
rw list.drop_append_of_le_length (le_of_lt q_lt),
apply congr_arg2,
{
rw list.nth_append,
swap, {
rw list.length_drop,
exact nat.sub_pos_of_lt q_lt,
},
rw list.nth_drop,
rw add_zero,
rw list.nth_take (lt_one_add q),
rw add_comm,
rw list_drop_take_succ lt_wl,
rw list.nth_le_nth lt_wl,
refl,
},
{
rw list.take_append_drop,
},
},
apply grammar_deri_with_postfix,
rw [split_ldw, list.map_append, list.join_append, ←list.append_assoc],
apply grammar_deri_with_postfix,
rw [wlk_succ, list.take_succ, list.map_append, list.join_append, list.append_assoc, list.append_assoc],
apply grammar_deri_with_prefix,
clear_except terminals lt_wl,
specialize terminals (w.nth_le (w.length - k.succ) lt_wl) (list.nth_le_mem w (w.length - k.succ) lt_wl),
rw list.nth_le_nth lt_wl,
unfold option.to_list,
rw [list.map_singleton, list.join_singleton, ←list.map_join, list.join_singleton],
apply grammar_deri_of_tran_deri,
{
use (star_grammar g).rules.nth_le 2 (by dec_trivial),
split_ile,
use [[], list.map symbol.terminal (w.nth_le (w.length - k.succ) lt_wl)],
split;
refl,
},
rw list.nil_append,
have scan_segment : ∀ m : ℕ, m ≤ (w.nth_le (w.length - k.succ) lt_wl).length →
grammar_derives (star_grammar g)
([R] ++ list.map symbol.terminal (w.nth_le (w.length - k.succ) lt_wl))
(list.map symbol.terminal (list.take m (w.nth_le (w.length - k.succ) lt_wl)) ++
([R] ++ list.map symbol.terminal (list.drop m (w.nth_le (w.length - k.succ) lt_wl)))),
{
intros m small,
induction m with n ih,
{
rw ←list.append_assoc,
convert grammar_deri_self,
},
apply grammar_deri_of_deri_tran (ih (nat.le_of_succ_le small)),
rw nat.succ_le_iff at small,
use ⟨[], (sum.inr 2), [symbol.terminal (list.nth_le (w.nth_le (w.length - k.succ) lt_wl) n small)],
[symbol.terminal (list.nth_le (w.nth_le (w.length - k.succ) lt_wl) n small), R]⟩,
split,
{
iterate 4 {
apply list.mem_cons_of_mem,
},
apply list.mem_append_right,
unfold rules_that_scan_terminals,
rw list.mem_map,
use list.nth_le (w.nth_le (w.length - k.succ) lt_wl) n small,
split,
{
unfold all_used_terminals,
rw list.mem_filter_map,
use (w.nth_le (w.length - k.succ) lt_wl).nth_le n small,
split,
{
apply terminals,
apply list.nth_le_mem,
},
{
refl,
},
},
{
refl,
},
},
use list.map symbol.terminal (list.take n (w.nth_le (w.length - k.succ) lt_wl)),
use list.map symbol.terminal (list.drop n.succ (w.nth_le (w.length - k.succ) lt_wl)),
dsimp only,
split,
{
trim,
rw list.nil_append,
rw list.append_assoc,
apply congr_arg2,
{
refl,
},
rw ←list.take_append_drop 1 (list.map symbol.terminal (list.drop n (w.nth_le (w.length - k.succ) lt_wl))),
apply congr_arg2,
{
rw ←list.map_take,
rw list_take_one_drop,
rw list.map_singleton,
},
{
rw ←list.map_drop,
rw list.drop_drop,
rw add_comm,
},
},
{
rw list.take_succ,
rw list.map_append,
trim,
rw list.nth_le_nth small,
refl,
},
},
convert scan_segment (w.nth_le (w.length - k.succ) lt_wl).length (by refl),
{
rw list.take_length,
},
{
rw list.drop_length,
rw list.map_nil,
refl,
},
end
private lemma terminal_scan_aux {g : grammar T} {w : list (list T)}
(terminals : ∀ v ∈ w, ∀ t ∈ v, symbol.terminal t ∈ list.join (list.map grule.output_string g.rules)) :
grammar_derives (star_grammar g)
([R] ++ (list.map (λ v, [H] ++ v) (list.map (list.map symbol.terminal) w)).join ++ [H])
(list.map symbol.terminal w.join ++ [R, H]) :=
begin
rw list.map_map,
convert terminal_scan_ind w.length (by refl) terminals,
{
rw nat.sub_self,
rw list.take_zero,
refl,
},
{
rw nat.sub_self,
refl,
},
end
end easy_direction
section hard_direction
lemma zero_of_not_ge_one {n : ℕ} (not_pos : ¬ (n ≥ 1)) : n = 0 :=
begin
push_neg at not_pos,
rwa nat.lt_one_iff at not_pos,
end
lemma length_ge_one_of_not_nil {α : Type*} {l : list α} (lnn : l ≠ []) : l.length ≥ 1 :=
begin
by_contradiction contra,
have llz := zero_of_not_ge_one contra,
rw list.length_eq_zero at llz,
exact lnn llz,
end
private lemma nat_eq_tech {a b c : ℕ} (b_lt_c : b < c) (ass : c = a.succ + c - b.succ) :
a = b :=
begin
omega,
end
private lemma wrap_never_outputs_nt_inr {N : Type} {a : symbol T N} (i : fin 3) :
wrap_sym a ≠ symbol.nonterminal (sum.inr i) :=
begin
cases a;
unfold wrap_sym,
{
apply symbol.no_confusion,
},
intro contr,
have inl_eq_inr := symbol.nonterminal.inj contr,
exact sum.no_confusion inl_eq_inr,
end
private lemma wrap_never_outputs_Z {N : Type} {a : symbol T N} :
wrap_sym a ≠ Z :=
begin
exact wrap_never_outputs_nt_inr 0,
end
private lemma wrap_never_outputs_H {N : Type} {a : symbol T N} :
wrap_sym a ≠ H :=
begin
exact wrap_never_outputs_nt_inr 1,
end
private lemma wrap_never_outputs_R {N : Type} {a : symbol T N} :
wrap_sym a ≠ R :=
begin
exact wrap_never_outputs_nt_inr 2,
end
private lemma map_wrap_never_contains_nt_inr {N : Type} {l : list (symbol T N)} (i : fin 3) :
symbol.nonterminal (sum.inr i) ∉ list.map wrap_sym l :=
begin
intro contra,
rw list.mem_map at contra,
rcases contra with ⟨s, -, imposs⟩,
exact wrap_never_outputs_nt_inr i imposs,
end
private lemma map_wrap_never_contains_Z {N : Type} {l : list (symbol T N)} :
Z ∉ list.map wrap_sym l :=
begin
exact map_wrap_never_contains_nt_inr 0,
end
private lemma map_wrap_never_contains_H {N : Type} {l : list (symbol T N)} :
H ∉ list.map wrap_sym l :=
begin
exact map_wrap_never_contains_nt_inr 1,
end
private lemma map_wrap_never_contains_R {N : Type} {l : list (symbol T N)} :
R ∉ list.map wrap_sym l :=
begin
exact map_wrap_never_contains_nt_inr 2,
end
private lemma wrap_sym_inj {N : Type} {a b : symbol T N} (wrap_eq : wrap_sym a = wrap_sym b) :
a = b :=
begin
cases a,
{
cases b,
{
congr,
exact symbol.terminal.inj wrap_eq,
},
{
exfalso,
exact symbol.no_confusion wrap_eq,
},
},
{
cases b,
{
exfalso,
exact symbol.no_confusion wrap_eq,
},
{
congr,
unfold wrap_sym at wrap_eq,
exact sum.inl.inj (symbol.nonterminal.inj wrap_eq),
},
},
end
private lemma wrap_str_inj {N : Type} {x y : list (symbol T N)}
(wrap_eqs : list.map wrap_sym x = list.map wrap_sym y) :
x = y :=
begin
ext1,
have eqnth := congr_arg (λ l, list.nth l n) wrap_eqs,
dsimp only at eqnth,
rw list.nth_map at eqnth,
rw list.nth_map at eqnth,
cases x.nth n with xₙ,
{
cases y.nth n with yₙ,
{
refl,
},
{
exfalso,
exact option.no_confusion eqnth,
},
},
{
cases y.nth n with yₙ,
{
exfalso,
exact option.no_confusion eqnth,
},
{
congr,
apply wrap_sym_inj,
rw option.map_some' at eqnth,
rw option.map_some' at eqnth,
exact option.some.inj eqnth,
},
},
end
private lemma H_not_in_rule_input {g : grammar T} {r : grule T g.nt} :
H ∉ list.map wrap_sym r.input_L ++ [symbol.nonterminal (sum.inl r.input_N)] ++
list.map wrap_sym r.input_R :=
begin
intro contra,
rw list.mem_append at contra,
cases contra,
swap, {
exact map_wrap_never_contains_H contra,
},
rw list.mem_append at contra,
cases contra,
{
exact map_wrap_never_contains_H contra,
},
{
rw list.mem_singleton at contra,
have imposs := symbol.nonterminal.inj contra,
exact sum.no_confusion imposs,
},
end
private lemma snsri_not_in_join_mpHmmw {g : grammar T} {x : list (list (symbol T g.nt))} {i : fin 3}
(snsri_neq_H : symbol.nonterminal (sum.inr i) ≠ @H T g.nt) :
symbol.nonterminal (sum.inr i) ∉ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)) :=
begin
intro contra,
rw list.mem_join at contra,
rw list.map_map at contra,
rcases contra with ⟨l, l_in, in_l⟩,
rw list.mem_map at l_in,
rcases l_in with ⟨y, -, eq_l⟩,
rw ←eq_l at in_l,
rw function.comp_app at in_l,
rw list.mem_append at in_l,
cases in_l,
{
exact map_wrap_never_contains_nt_inr i in_l,
},
{
rw list.mem_singleton at in_l,
exact snsri_neq_H in_l,
},
end
private lemma Z_not_in_join_mpHmmw {g : grammar T} {x : list (list (symbol T g.nt))} :
Z ∉ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)) :=
begin
exact snsri_not_in_join_mpHmmw Z_neq_H,
end
private lemma R_not_in_join_mpHmmw {g : grammar T} {x : list (list (symbol T g.nt))} :
R ∉ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)) :=
begin
exact snsri_not_in_join_mpHmmw H_neq_R.symm,
end
private lemma zero_Rs_in_the_long_part {g : grammar T} {x : list (list (symbol T g.nt))} [decidable_eq (ns T g.nt)] :
list.count_in (list.map (++ [H]) (list.map (list.map wrap_sym) x)).join R = 0 :=
begin
exact list.count_in_zero_of_notin R_not_in_join_mpHmmw,
end
private lemma cases_1_and_2_and_3a_match_aux {g : grammar T} {r₀ : grule T g.nt}
{x : list (list (symbol T g.nt))} {u v : list (ns T g.nt)} (xnn : x ≠ [])
(hyp : (list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x))) =
u ++ list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++
list.map wrap_sym r₀.input_R ++ v) :
∃ m : ℕ, ∃ u₁ v₁ : list (symbol T g.nt),
u = list.join (list.map (++ [H]) (list.take m (list.map (list.map wrap_sym) x))) ++ list.map wrap_sym u₁
∧ list.nth x m = some (u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁) ∧
v = list.map wrap_sym v₁ ++ [H] ++
list.join (list.map (++ [H]) (list.drop m.succ (list.map (list.map wrap_sym) x))) :=
begin
have hypp :
(list.map (++ [H]) (list.map (list.map wrap_sym) x)).join =
u ++ (
list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ list.map wrap_sym r₀.input_R
) ++ v,
{
simpa [list.append_assoc] using hyp,
},
have mid_brack : ∀ u', ∀ v',
u' ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v' =
u' ++ (r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R) ++ v',
{
intros,
simp only [list.append_assoc],
},
simp_rw mid_brack,
clear hyp mid_brack,
classical,
have count_Hs := congr_arg (λ l, list.count_in l H) hypp,
dsimp only at count_Hs,
rw list.count_in_append at count_Hs,
rw list.count_in_append at count_Hs,
rw list.count_in_zero_of_notin H_not_in_rule_input at count_Hs,
rw add_zero at count_Hs,
rw [list.count_in_join, list.map_map, list.map_map] at count_Hs,
have lens := congr_arg list.length hypp,
rw list.length_append_append at lens,
rw list.length_append_append at lens,
rw list.length_singleton at lens,
have ul_lt : u.length < list.length (list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x))),
{
clear_except lens,
linarith,
},
rcases list.take_join_of_lt ul_lt with ⟨m, k, mlt, klt, init_ul⟩,
have vnn : v ≠ [],
{
by_contradiction v_nil,
rw [v_nil, list.append_nil] at hypp,
clear_except hypp xnn,
have hlast := congr_arg (λ l : list (ns T g.nt), l.reverse.nth 0) hypp,
dsimp only at hlast,
rw [list.reverse_join, list.reverse_append, list.reverse_append_append, list.reverse_singleton] at hlast,
have hhh : some H = ((list.map wrap_sym r₀.input_R).reverse ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ (list.map wrap_sym r₀.input_L).reverse ++ u.reverse).nth 0,
{
convert hlast,
rw list.map_map,
change some H = (list.map (λ l, list.reverse (l ++ [H])) (list.map (list.map wrap_sym) x)).reverse.join.nth 0,
simp_rw list.reverse_append,
rw list.map_map,
change some H = (list.map (λ l, [H].reverse ++ (list.map wrap_sym l).reverse) x).reverse.join.nth 0,
rw ←list.map_reverse,
have xrnn : x.reverse ≠ [],
{
intro xr_nil,
rw list.reverse_eq_iff at xr_nil,
exact xnn xr_nil,
},
cases x.reverse with d l,
{
exfalso,
exact xrnn rfl,
},
rw [list.map_cons, list.join, list.append_assoc],
rw list.nth_append,
swap, {
rw list.length_reverse,
rw list.length_singleton,
exact one_pos,
},
rw list.reverse_singleton,
refl,
},
rw ←list.map_reverse at hhh,
cases r₀.input_R.reverse,
{
rw [list.map_nil, list.nil_append] at hhh,
simp only [list.nth, list.cons_append] at hhh,
exact sum.no_confusion (symbol.nonterminal.inj hhh),
},
{
simp only [list.nth, list.map_cons, list.cons_append] at hhh,
exact wrap_never_outputs_H hhh.symm,
},
},
have urrrl_lt :
list.length (u ++ (
list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ list.map wrap_sym r₀.input_R
)) <
list.length (list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x))),
{
have vl_pos : v.length > 0,
{
exact list.length_pos_of_ne_nil vnn,
},
clear_except lens vl_pos,
rw list.length_append,
rw list.length_append_append,
rw list.length_singleton,
linarith,
},
rcases list.drop_join_of_lt urrrl_lt with ⟨m', k', mlt', klt', last_vl⟩,
have mxl : m < x.length,
{
rw list.length_map at mlt,
rw list.length_map at mlt,
exact mlt,
},
have mxl' : m' < x.length,
{
rw list.length_map at mlt',
rw list.length_map at mlt',
exact mlt',
},
have mxlmm : m < (list.map (list.map wrap_sym) x).length,
{
rwa list.length_map,
},
have mxlmm' : m' < (list.map (list.map wrap_sym) x).length,
{
rwa list.length_map,
},
use [m, list.take k (x.nth_le m mxl), list.drop k' (x.nth_le m' mxl')],
have hyp_u := congr_arg (list.take u.length) hypp,
rw list.append_assoc at hyp_u,
rw list.take_left at hyp_u,
rw init_ul at hyp_u,
rw list.nth_le_map at hyp_u,
swap, {
exact mxlmm,
},
rw list.take_append_of_le_length at hyp_u,
swap, {
rw list.nth_le_map at klt,
swap, {
exact mxlmm,
},
rw list.length_append at klt,
rw list.length_singleton at klt,
rw list.nth_le_map at klt ⊢,
iterate 2 {
swap, {
exact mxl,
},
},
rw list.length_map at klt ⊢,
rw nat.lt_succ_iff at klt,
exact klt,
},
rw ←hyp_u at count_Hs,
have hyp_v :=
congr_arg (list.drop (list.length (u ++ (
list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ list.map wrap_sym r₀.input_R
)))) hypp,
rw list.drop_left at hyp_v,
rw last_vl at hyp_v,
rw list.nth_le_map at hyp_v,
swap, {
exact mxlmm',
},
rw list.drop_append_of_le_length at hyp_v,
swap, {
rw list.nth_le_map at klt',
swap, {
exact mxlmm',
},
rw list.length_append at klt',
rw list.length_singleton at klt',
rw list.nth_le_map at klt' ⊢,
iterate 2 {
swap, {
exact mxl',
},
},
rw list.length_map at klt' ⊢,
rw nat.lt_succ_iff at klt',
exact klt',
},
rw ←hyp_v at count_Hs,
have mm : m = m',
{
clear_except count_Hs mxl mxl' klt klt',
rw [
list.count_in_append, list.count_in_append, list.map_map,
list.count_in_join, ←list.map_take, list.map_map,
list.count_in_join, ←list.map_drop, list.map_map
] at count_Hs,
change
(list.map (λ w, list.count_in (list.map wrap_sym w ++ [H]) H) x).sum =
(list.map (λ w, list.count_in (list.map wrap_sym w ++ [H]) H) (list.take m x)).sum + _ +
(_ + (list.map (λ w, list.count_in (list.map wrap_sym w ++ [H]) H) (list.drop m'.succ x)).sum)
at count_Hs,
simp_rw list.count_in_append at count_Hs,
have inside_wrap : ∀ y : list (symbol T g.nt), (list.map wrap_sym y).count_in H = 0,
{
intro,
rw list.count_in_zero_of_notin,
apply map_wrap_never_contains_H,
},
have inside_one : ∀ z : list (symbol T g.nt),
(list.map wrap_sym z).count_in (@H T g.nt) + [@H T g.nt].count_in (@H T g.nt) = 1,
{
intro,
rw list.count_in_singleton_eq H,
rw inside_wrap,
},
simp_rw inside_one at count_Hs,
repeat {
rw [list.map_const, list.sum_const_nat, one_mul] at count_Hs,
},
rw [list.length_take, list.length_drop, list.nth_le_map', list.nth_le_map'] at count_Hs,
rw min_eq_left (le_of_lt mxl) at count_Hs,
have inside_take : (list.take k (list.map wrap_sym (x.nth_le m mxl))).count_in H = 0,
{
rw ←list.map_take,
rw inside_wrap,
},
have inside_drop : (list.drop k' (list.map wrap_sym (x.nth_le m' mxl'))).count_in H + [H].count_in H = 1,
{
rw ←list.map_drop,
rw inside_wrap,
rw list.count_in_singleton_eq (@H T g.nt),
},
rw [inside_take, inside_drop] at count_Hs,
rw [add_zero, ←add_assoc, ←nat.add_sub_assoc] at count_Hs,
swap, {
rwa nat.succ_le_iff,
},
exact nat_eq_tech mxl' count_Hs,
},
rw ←mm at *,
split,
{
symmetry,
convert hyp_u,
{
rw list.map_take,
},
{
rw list.map_take,
rw list.nth_le_map,
},
},
split,
swap, {
symmetry,
convert hyp_v,
{
rw list.map_drop,
rw list.nth_le_map,
},
{
rw list.map_drop,
rw mm,
},
},
rw [←hyp_u, ←hyp_v] at hypp,
have mltx : m < x.length,
{
rw list.length_map at mlt,
rw list.length_map at mlt,
exact mlt,
},
have xxx : x = x.take m ++ [x.nth_le m mltx] ++ x.drop m.succ,
{
rw list.append_assoc,
rw list.singleton_append,
rw list.cons_nth_le_drop_succ,
rw list.take_append_drop,
},
have hyppp :
(list.map (++ [H]) (list.map (list.map wrap_sym) (x.take m ++ [x.nth_le m mltx] ++ x.drop m.succ))).join =
(list.take m (list.map (++ [H]) (list.map (list.map wrap_sym) x))).join ++
list.take k ((list.map (list.map wrap_sym) x).nth_le m mxlmm) ++
(list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ list.map wrap_sym r₀.input_R) ++
(list.drop k' ((list.map (list.map wrap_sym) x).nth_le m mxlmm) ++ [H] ++
(list.drop m.succ (list.map (++ [H]) (list.map (list.map wrap_sym) x))).join),
{
convert hypp,
exact xxx.symm,
},
clear_except hyppp mm,
rw [
list.map_append_append, list.map_append_append,
list.join_append_append,
list.append_assoc, list.append_assoc, list.append_assoc, list.append_assoc, list.append_assoc, list.append_assoc,
list.map_take, list.map_take,
list.append_right_inj,
←list.append_assoc, ←list.append_assoc, ←list.append_assoc, ←list.append_assoc, ←list.append_assoc,
list.map_drop, list.map_drop,
list.append_left_inj,
list.map_singleton, list.map_singleton, list.join_singleton,
list.append_left_inj
] at hyppp,
rw list.nth_le_nth mltx,
apply congr_arg,
apply wrap_str_inj,
rw hyppp,
rw list.map_append_append,
rw list.map_take,
rw list.nth_le_map,
swap, {
exact mltx,
},
rw list.map_drop,
rw list.map_append_append,
rw list.map_singleton,
rw ←list.append_assoc,
rw ←list.append_assoc,
apply congr_arg2,
{
refl,
},
congr,
exact mm,
end
private lemma case_1_match_rule {g : grammar T} {r₀ : grule T g.nt}
{x : list (list (symbol T g.nt))} {u v : list (ns T g.nt)}
(hyp : Z :: (list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x))) =
u ++ list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++
list.map wrap_sym r₀.input_R ++ v) :
∃ m : ℕ, ∃ u₁ v₁ : list (symbol T g.nt),
u = Z :: list.join (list.map (++ [H]) (list.take m (list.map (list.map wrap_sym) x))) ++ list.map wrap_sym u₁
∧ list.nth x m = some (u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁) ∧
v = list.map wrap_sym v₁ ++ [H] ++
list.join (list.map (++ [H]) (list.drop m.succ (list.map (list.map wrap_sym) x))) :=
begin
by_cases is_x_nil : x = [],
{
exfalso,
rw [is_x_nil, list.map_nil, list.map_nil, list.join] at hyp,
have hyp_len := congr_arg list.length hyp,
rw list.length_singleton at hyp_len,
repeat {
rw list.length_append at hyp_len,
},
rw list.length_singleton at hyp_len,
have left_nil : u ++ list.map wrap_sym r₀.input_L = [],
{
rw ←list.length_eq_zero,
rw list.length_append,
omega,
},
have right_nil : list.map wrap_sym r₀.input_R ++ v = [],
{
rw ←list.length_eq_zero,
rw list.length_append,
omega,
},
rw [left_nil, list.nil_append, list.append_assoc, right_nil, list.append_nil] at hyp,
have imposs := list.head_eq_of_cons_eq hyp,
unfold Z at imposs,
rw symbol.nonterminal.inj_eq at imposs,
exact sum.no_confusion imposs,
},
have unn : u ≠ [],
{
by_contradiction u_nil,
rw [u_nil, list.nil_append] at hyp,
cases r₀.input_L with d l,
{
rw [list.map_nil, list.nil_append] at hyp,
have imposs := list.head_eq_of_cons_eq hyp,
have inr_eq_inl := symbol.nonterminal.inj imposs,
exact sum.no_confusion inr_eq_inl,
},
{
rw list.map_cons at hyp,
have imposs := list.head_eq_of_cons_eq hyp,
cases d,
{
unfold wrap_sym at imposs,
exact symbol.no_confusion imposs,
},
{
unfold wrap_sym at imposs,
have inr_eq_inl := symbol.nonterminal.inj imposs,
exact sum.no_confusion inr_eq_inl,
},
},
},
have hypr := congr_arg list.tail hyp,
rw list.tail at hypr,
repeat {
rw list.append_assoc at hypr,
},
rw list.tail_append_of_ne_nil _ _ unn at hypr,
repeat {
rw ←list.append_assoc at hypr,
},
rcases cases_1_and_2_and_3a_match_aux is_x_nil hypr with ⟨m, u₁, v₁, u_eq, xm_eq, v_eq⟩,
use [m, u₁, v₁],
split,
{
cases u with d l,
{
exfalso,
exact unn rfl,
},
have headZ : d = Z,
{
repeat {
rw list.cons_append at hyp,
},
exact list.head_eq_of_cons_eq hyp.symm,
},
rw headZ,
rw list.tail at u_eq,
rw u_eq,
apply list.cons_append,
},
split,
{
exact xm_eq,
},
{
exact v_eq,
},
end
private lemma star_case_1 {g : grammar T} {α α' : list (ns T g.nt)}
(orig : grammar_transforms (star_grammar g) α α')
(hyp : ∃ x : list (list (symbol T g.nt)),
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α = [Z] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) :
(∃ x : list (list (symbol T g.nt)),
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α' = [Z] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) ∨
(∃ x : list (list (symbol T g.nt)),
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α' = [R, H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) :=
begin
rcases hyp with ⟨x, valid, cat⟩,
have no_R_in_alpha : R ∉ α,
{
intro contr,
rw cat at contr,
clear_except contr,
rw list.mem_append at contr,
cases contr,
{
rw list.mem_singleton at contr,
exact Z_neq_R.symm contr,
},
{
exact R_not_in_join_mpHmmw contr,
},
},
rw cat at *,
clear cat,
rcases orig with ⟨r, rin, u, v, bef, aft⟩,
cases rin,
{
left,
rw rin at *,
clear rin,
dsimp only at *,
rw [list.append_nil, list.append_nil] at bef,
use ([symbol.nonterminal g.initial] :: x),
split,
{
intros xᵢ xin,
cases xin,
{
rw xin,
apply grammar_deri_self,
},
{
exact valid xᵢ xin,
},
},
have u_nil : u = [],
{
clear_except bef,
rw ←list.length_eq_zero,
by_contradiction,
have ul_pos : 0 < u.length,
{
rwa pos_iff_ne_zero,
},
clear h,
have bef_tail := congr_arg list.tail bef,
cases u with d l,
{
rw list.length at ul_pos,
exact nat.lt_irrefl 0 ul_pos,
},
{
have Z_in_tail : Z ∈ l ++ [symbol.nonterminal (sum.inr 0)] ++ v,
{
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_singleton_self,
},
rw [list.singleton_append, list.tail_cons, list.cons_append, list.cons_append, list.tail_cons] at bef_tail,
rw ←bef_tail at Z_in_tail,
exact Z_not_in_join_mpHmmw Z_in_tail,
},
},
have v_rest : v = list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)),
{
rw u_nil at bef,
convert congr_arg list.tail bef.symm,
},
rw aft,
rw [u_nil, v_rest],
rw [list.nil_append, list.map_cons],
refl,
},
cases rin,
{
right,
rw rin at *,
clear rin,
dsimp only at *,
rw [list.append_nil, list.append_nil] at bef,
use x,
split,
{
exact valid,
},
have u_nil : u = [],
{
clear_except bef,
rw ←list.length_eq_zero,
by_contradiction,
have ul_pos : 0 < u.length,
{
rwa pos_iff_ne_zero,
},
clear h,
have bef_tail := congr_arg list.tail bef,
cases u with d l,
{
rw list.length at ul_pos,
exact nat.lt_irrefl 0 ul_pos,
},
{
have Z_in_tail : Z ∈ l ++ [symbol.nonterminal (sum.inr 0)] ++ v,
{
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_singleton_self,
},
rw [list.singleton_append, list.tail_cons, list.cons_append, list.cons_append, list.tail_cons] at bef_tail,
rw ←bef_tail at Z_in_tail,
exact Z_not_in_join_mpHmmw Z_in_tail,
},
},
have v_rest : v = list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)),
{
rw u_nil at bef,
convert congr_arg list.tail bef.symm,
},
rw aft,
rw [u_nil, v_rest],
refl,
},
iterate 2 {
cases rin,
{
exfalso,
apply no_R_in_alpha,
rw bef,
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_right,
rw list.mem_singleton,
rw rin,
refl,
},
},
have rin' : r ∈ rules_that_scan_terminals g ∨ r ∈ list.map wrap_gr g.rules,
{
rw or_comm,
rwa ←list.mem_append,
},
clear rin,
cases rin',
{
exfalso,
apply no_R_in_alpha,
rw bef,
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_right,
rw list.mem_singleton,
unfold rules_that_scan_terminals at rin',
rw list.mem_map at rin',
rcases rin' with ⟨t, -, form⟩,
rw ←form,
refl,
},
left,
rw list.mem_map at rin',
rcases rin' with ⟨r₀, orig_in, wrap_orig⟩,
unfold wrap_gr at wrap_orig,
rw ←wrap_orig at *,
clear wrap_orig,
dsimp only at *,
rcases case_1_match_rule bef with ⟨m, u₁, v₁, u_eq, xm_eq, v_eq⟩,
clear bef,
rw [u_eq, v_eq] at aft,
use (list.take m x ++ [u₁ ++ r₀.output_string ++ v₁] ++ list.drop m.succ x),
split,
{
intros xᵢ xiin,
rw list.mem_append_append at xiin,
cases xiin,
{
apply valid,
exact list.mem_of_mem_take xiin,
},
cases xiin,
swap, {
apply valid,
exact list.mem_of_mem_drop xiin,
},
rw list.mem_singleton at xiin,
rw xiin,
have last_step :
grammar_transforms g
(u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁)
(u₁ ++ r₀.output_string ++ v₁),
{
use r₀,
split,
{
exact orig_in,
},
use [u₁, v₁],
split;
refl,
},
apply grammar_deri_of_deri_tran _ last_step,
apply valid (u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁),
exact list.nth_mem xm_eq,
},
rw list.singleton_append,
rw aft,
repeat {
rw list.cons_append,
},
apply congr_arg2,
{
refl,
},
repeat {
rw list.map_append,
},
rw list.join_append_append,
repeat {
rw list.append_assoc,
},
apply congr_arg2,
{
rw ←list.map_take,
},
repeat {
rw ←list.append_assoc,
},
apply congr_arg2,
swap, {
rw ←list.map_drop,
},
rw [
list.map_singleton, list.map_singleton, list.join_singleton,
list.map_append, list.map_append
],
end
private lemma uv_nil_of_RH_eq {g : grammar T} {u v : list (ns T g.nt)}
(ass : [R, H] = u ++ [] ++ [symbol.nonterminal (sum.inr 2)] ++ [H] ++ v) :
u = [] ∧ v = [] :=
begin
rw list.append_nil at ass,
have lens := congr_arg list.length ass,
simp only [list.length_append, list.length, zero_add] at lens,
split;
{
rw ←list.length_eq_zero,
omega,
},
end
private lemma u_nil_when_RH {g : grammar T} {x : list (list (symbol T g.nt))} {u v : list (ns T g.nt)}
(ass :
[R, H] ++ (list.map (++ [H]) (list.map (list.map wrap_sym) x)).join =
u ++ [] ++ [symbol.nonterminal (sum.inr 2)] ++ [H] ++ v
) :
u = [] :=
begin
cases u with d l,
{
refl,
},
rw list.append_nil at ass,
exfalso,
by_cases d = R,
{
rw h at ass,
clear h,
classical,
have imposs, { dsimp_result { exact congr_arg (λ c : list (ns T g.nt), list.count_in c R) ass } },
repeat {
rw list.count_in_append at imposs,
},
repeat {
rw list.count_in_cons at imposs,
},
repeat {
rw list.count_in_nil at imposs,
},
have one_imposs : 1 + (0 + 0) + 0 = 1 + list.count_in l R + (1 + 0) + (0 + 0) + list.count_in v R,
{
convert imposs,
{
norm_num,
},
{
simp [H_neq_R],
},
{
symmetry,
apply zero_Rs_in_the_long_part,
},
{
norm_num,
},
{
simp [R],
},
{
simp [H_neq_R],
},
},
clear_except one_imposs,
repeat {
rw add_zero at one_imposs,
},
linarith,
},
{
apply h,
clear h,
have impos := congr_fun (congr_arg list.nth ass) 0,
iterate 4 {
rw list.nth_append at impos,
swap, {
norm_num,
},
},
rw list.nth at impos,
rw list.nth at impos,
exact (option.some.inj impos).symm,
},
end
private lemma case_2_match_rule {g : grammar T} {r₀ : grule T g.nt}
{x : list (list (symbol T g.nt))} {u v : list (ns T g.nt)}
(hyp : R :: H :: (list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x))) =
u ++ list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++
list.map wrap_sym r₀.input_R ++ v) :
∃ m : ℕ, ∃ u₁ v₁ : list (symbol T g.nt),
u = R :: H :: list.join (list.map (++ [H]) (list.take m (list.map (list.map wrap_sym) x))) ++ list.map wrap_sym u₁
∧ list.nth x m = some (u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁) ∧
v = list.map wrap_sym v₁ ++ [H] ++
list.join (list.map (++ [H]) (list.drop m.succ (list.map (list.map wrap_sym) x))) :=
begin
by_cases is_x_nil : x = [],
{
exfalso,
rw [is_x_nil, list.map_nil, list.map_nil, list.join] at hyp,
have imposs : symbol.nonterminal (sum.inl r₀.input_N) = R ∨ symbol.nonterminal (sum.inl r₀.input_N) = H,
{
simpa using congr_arg (λ l, symbol.nonterminal (sum.inl r₀.input_N) ∈ l) hyp,
},
cases imposs;
exact sum.no_confusion (symbol.nonterminal.inj imposs),
},
have unn : u ≠ [],
{
by_contradiction u_nil,
rw [u_nil, list.nil_append] at hyp,
cases r₀.input_L with d l,
{
rw [list.map_nil, list.nil_append] at hyp,
have imposs := list.head_eq_of_cons_eq hyp,
have inr_eq_inl := symbol.nonterminal.inj imposs,
exact sum.no_confusion inr_eq_inl,
},
{
rw list.map_cons at hyp,
have imposs := list.head_eq_of_cons_eq hyp,
cases d,
{
unfold wrap_sym at imposs,
exact symbol.no_confusion imposs,
},
{
unfold wrap_sym at imposs,
have inr_eq_inl := symbol.nonterminal.inj imposs,
exact sum.no_confusion inr_eq_inl,
},
},
},
have hypt := congr_arg list.tail hyp,
rw list.tail at hypt,
repeat {
rw list.append_assoc at hypt,
},
rw list.tail_append_of_ne_nil _ _ unn at hypt,
have utnn : u.tail ≠ [],
{
by_contradiction ut_nil,
rw [ut_nil, list.nil_append] at hypt,
cases r₀.input_L with d l,
{
rw [list.map_nil, list.nil_append] at hypt,
have imposs := list.head_eq_of_cons_eq hypt,
have inr_eq_inl := symbol.nonterminal.inj imposs,
exact sum.no_confusion inr_eq_inl,
},
{
rw list.map_cons at hypt,
have imposs := list.head_eq_of_cons_eq hypt,
cases d,
{
unfold wrap_sym at imposs,
exact symbol.no_confusion imposs,
},
{
unfold wrap_sym at imposs,
have inr_eq_inl := symbol.nonterminal.inj imposs,
exact sum.no_confusion inr_eq_inl,
},
},
},
have hyptt := congr_arg list.tail hypt,
rw list.tail at hyptt,
rw list.tail_append_of_ne_nil _ _ utnn at hyptt,
repeat {
rw ←list.append_assoc at hyptt,
},
rcases cases_1_and_2_and_3a_match_aux is_x_nil hyptt with ⟨m, u₁, v₁, u_eq, xm_eq, v_eq⟩,
use [m, u₁, v₁],
split,
{
cases u with d l,
{
exfalso,
exact unn rfl,
},
have headR : d = R,
{
repeat {
rw list.cons_append at hyp,
},
exact list.head_eq_of_cons_eq hyp.symm,
},
rw list.tail at u_eq,
rw list.tail at hypt,
cases l with d' l',
{
exfalso,
exact utnn rfl,
},
have tailHead : d' = H,
{
repeat {
rw list.cons_append at hypt,
},
exact list.head_eq_of_cons_eq hypt.symm,
},
rw list.tail at u_eq,
rw [headR, tailHead, u_eq, list.cons_append, list.cons_append],
},
split,
{
exact xm_eq,
},
{
exact v_eq,
},
end
private lemma star_case_2 {g : grammar T} {α α' : list (symbol T (star_grammar g).nt)}
(orig : grammar_transforms (star_grammar g) α α')
(hyp : ∃ x : list (list (symbol T g.nt)),
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α = [R, H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) :
(∃ x : list (list (symbol T g.nt)),
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α' = [R, H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) ∨
(∃ w : list (list T), ∃ β : list T, ∃ γ : list (symbol T g.nt), ∃ x : list (list (symbol T g.nt)),
(∀ wᵢ ∈ w, grammar_generates g wᵢ) ∧
(grammar_derives g [symbol.nonterminal g.initial] (list.map symbol.terminal β ++ γ)) ∧
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α' = list.map symbol.terminal (list.join w) ++ list.map symbol.terminal β ++ [R] ++
list.map wrap_sym γ ++ [H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) ∨
(∃ u : list T, u ∈ language.star (grammar_language g) ∧ α' = list.map symbol.terminal u) ∨
(∃ σ : list (symbol T g.nt), α' = list.map wrap_sym σ ++ [R]) ∨
(∃ ω : list (ns T g.nt), α' = ω ++ [H]) ∧ Z ∉ α' ∧ R ∉ α' :=
begin
rcases hyp with ⟨x, valid, cat⟩,
have no_Z_in_alpha : Z ∉ α,
{
intro contr,
rw cat at contr,
clear_except contr,
rw list.mem_append at contr,
cases contr,
{
cases contr,
{
exact Z_neq_R contr,
},
{
apply Z_neq_H,
rw ←list.mem_singleton,
exact contr,
},
},
{
exact Z_not_in_join_mpHmmw contr,
},
},
rw cat at *,
clear cat,
rcases orig with ⟨r, rin, u, v, bef, aft⟩,
iterate 2 {
cases rin,
{
exfalso,
apply no_Z_in_alpha,
rw bef,
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_right,
rw list.mem_singleton,
rw rin,
refl,
},
},
cases rin,
{
cases x with x₀ L,
{
right, right, right,
rw [list.map_nil, list.map_nil, list.join, list.append_nil] at bef,
have empty_string : u = [] ∧ v = [],
{
rw rin at bef,
exact uv_nil_of_RH_eq bef,
},
rw [empty_string.left, list.nil_append, empty_string.right, list.append_nil] at aft,
use list.nil,
rw aft,
rw [list.map_nil, list.nil_append],
rw rin,
},
{
right, left,
use [[], [], x₀, L],
split,
{
intros wᵢ wiin,
exfalso,
rw list.mem_nil_iff at wiin,
exact wiin,
},
split,
{
rw [list.map_nil, list.nil_append],
exact valid x₀ (list.mem_cons_self x₀ L),
},
split,
{
intros xᵢ xiin,
exact valid xᵢ (list.mem_cons_of_mem x₀ xiin),
},
rw aft,
rw [list.map_nil, list.append_nil, list.join, list.map_nil, list.nil_append],
rw rin at bef ⊢,
dsimp only at bef ⊢,
have u_nil := u_nil_when_RH bef,
rw [u_nil, list.nil_append] at bef ⊢,
have eq_v := list.append_inj_right bef (by refl),
rw ←eq_v,
rw [list.map_cons, list.map_cons, list.join],
rw [←list.append_assoc, ←list.append_assoc],
},
},
cases rin,
{
cases x with x₀ L,
{
right, right, left,
rw [list.map_nil, list.map_nil, list.join, list.append_nil] at bef,
have empty_string : u = [] ∧ v = [],
{
rw rin at bef,
exact uv_nil_of_RH_eq bef,
},
rw [empty_string.left, list.nil_append, empty_string.right, list.append_nil] at aft,
use list.nil,
split,
{
use list.nil,
split,
{
refl,
},
{
intros y imposs,
exfalso,
exact list.not_mem_nil y imposs,
},
},
{
rw aft,
rw list.map_nil,
rw rin,
},
},
{
right, right, right, right,
rw rin at bef,
dsimp only at bef,
have u_nil := u_nil_when_RH bef,
rw [u_nil, list.nil_append] at bef,
have v_eq := eq.symm (list.append_inj_right bef (by refl)),
rw [
u_nil, list.nil_append, v_eq, rin, list.nil_append,
list.map_cons, list.map_cons, list.join,
list.append_assoc, list.append_join_append, ←list.append_assoc
] at aft,
split,
{
use list.map wrap_sym x₀ ++ (list.map (λ l, [H] ++ l) (list.map (list.map wrap_sym) L)).join,
rw aft,
trim,
},
rw [list.append_assoc, ←list.append_join_append] at aft,
rw aft,
split;
intro contra;
rw list.mem_append at contra,
{
cases contra,
{
exact map_wrap_never_contains_Z contra,
},
cases contra,
{
exact Z_neq_H contra,
},
{
exact Z_not_in_join_mpHmmw contra,
},
},
{
cases contra,
{
exact map_wrap_never_contains_R contra,
},
cases contra,
{
exact H_neq_R contra.symm,
},
{
exact R_not_in_join_mpHmmw contra,
},
},
},
},
have rin' : r ∈ rules_that_scan_terminals g ∨ r ∈ list.map wrap_gr g.rules,
{
rw or_comm,
rwa ←list.mem_append,
},
clear rin,
cases rin',
{
exfalso,
unfold rules_that_scan_terminals at rin',
rw list.mem_map at rin',
rcases rin' with ⟨t, -, form⟩,
rw ←form at bef,
dsimp only at bef,
rw list.append_nil at bef,
have u_nil : u = [],
{
cases u with d l,
{
refl,
},
exfalso,
repeat {
rw list.cons_append at bef,
},
rw list.nil_append at bef,
have btail := list.tail_eq_of_cons_eq bef,
have imposs := congr_arg (λ l, R ∈ l) btail,
dsimp only at imposs,
apply false_of_true_eq_false,
convert imposs.symm,
{
rw [eq_iff_iff, true_iff],
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_singleton_self,
},
{
rw [eq_iff_iff, false_iff],
intro hyp,
rw list.mem_cons_iff at hyp,
cases hyp,
{
exact H_neq_R hyp.symm,
},
rw list.mem_join at hyp,
rcases hyp with ⟨p, pin, Rinp⟩,
rw list.mem_map at pin,
rcases pin with ⟨q, qin, eq_p⟩,
rw ←eq_p at Rinp,
rw list.mem_append at Rinp,
cases Rinp,
{
rw list.mem_map at qin,
rcases qin with ⟨p', -, eq_q⟩,
rw ←eq_q at Rinp,
exact map_wrap_never_contains_R Rinp,
},
{
rw list.mem_singleton at Rinp,
exact H_neq_R Rinp.symm,
},
},
},
rw [u_nil, list.nil_append] at bef,
have second_symbol := congr_fun (congr_arg list.nth bef) 1,
rw list.nth_append at second_symbol,
swap, {
rw [list.length_cons, list.length_singleton],
exact lt_add_one 1,
},
rw list.nth_append at second_symbol,
swap, {
rw [list.length_append, list.length_singleton, list.length_singleton],
exact lt_add_one 1,
},
rw list.singleton_append at second_symbol,
repeat {
rw list.nth at second_symbol,
},
exact symbol.no_confusion (option.some.inj second_symbol),
},
left,
rw list.mem_map at rin',
rcases rin' with ⟨r₀, orig_in, wrap_orig⟩,
unfold wrap_gr at wrap_orig,
rw ←wrap_orig at *,
clear wrap_orig,
dsimp only at bef,
rcases case_2_match_rule bef with ⟨m, u₁, v₁, u_eq, xm_eq, v_eq⟩,
clear bef,
rw [u_eq, v_eq] at aft,
use (list.take m x ++ [u₁ ++ r₀.output_string ++ v₁] ++ list.drop m.succ x),
split,
{
intros xᵢ xiin,
rw list.mem_append_append at xiin,
cases xiin,
{
apply valid,
exact list.mem_of_mem_take xiin,
},
cases xiin,
swap, {
apply valid,
exact list.mem_of_mem_drop xiin,
},
rw list.mem_singleton at xiin,
rw xiin,
have last_step :
grammar_transforms g
(u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁)
(u₁ ++ r₀.output_string ++ v₁),
{
use r₀,
split,
{
exact orig_in,
},
use [u₁, v₁],
split;
refl,
},
apply grammar_deri_of_deri_tran _ last_step,
apply valid (u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁),
exact list.nth_mem xm_eq,
},
rw aft,
repeat {
rw list.cons_append,
},
apply congr_arg2,
{
refl,
},
repeat {
rw list.map_append,
},
rw list.join_append_append,
repeat {
rw list.append_assoc,
},
apply congr_arg2,
{
refl,
},
rw list.nil_append,
apply congr_arg2,
{
rw ←list.map_take,
refl,
},
simp [list.map, list.join, list.singleton_append, list.map_append, list.append_assoc, list.map_map, list.map_drop],
end
private lemma case_3_ni_wb {g : grammar T} {w : list (list T)} {β : list T} {i : fin 3} :
@symbol.nonterminal T (nn g.nt) (sum.inr i) ∉
list.map (@symbol.terminal T (nn g.nt)) w.join ++ list.map (@symbol.terminal T (nn g.nt)) β :=
begin
intro contra,
rw list.mem_append at contra,
cases contra;
{
rw list.mem_map at contra,
rcases contra with ⟨t, -, imposs⟩,
exact symbol.no_confusion imposs,
},
end
private lemma case_3_ni_u {g : grammar T}
{w : list (list T)} {β : list T} {γ : list (symbol T g.nt)}
{x : list (list (symbol T g.nt))} {u v : list (ns T g.nt)} {s : ns T g.nt}
(ass :
list.map symbol.terminal w.join ++ list.map symbol.terminal β ++ [R] ++ list.map wrap_sym γ ++ [H] ++
(list.map (++ [H]) (list.map (list.map wrap_sym) x)).join =
u ++ [R] ++ [s] ++ v
) :
R ∉ u :=
begin
intro R_in_u,
classical,
have count_R := congr_arg (λ l, list.count_in l R) ass,
dsimp only at count_R,
repeat {
rw list.count_in_append at count_R,
},
have R_ni_wb : R ∉ list.map symbol.terminal w.join ++ list.map symbol.terminal β,
{
apply @case_3_ni_wb T g,
},
rw list.count_in_singleton_eq at count_R,
rw [list.count_in_singleton_neq H_neq_R, add_zero] at count_R,
rw ←list.count_in_append at count_R,
rw [list.count_in_zero_of_notin R_ni_wb, zero_add] at count_R,
rw [list.count_in_zero_of_notin map_wrap_never_contains_R, add_zero] at count_R,
rw [zero_Rs_in_the_long_part, add_zero] at count_R,
have ucR_pos := list.count_in_pos_of_in R_in_u,
clear_except count_R ucR_pos,
linarith,
end
private lemma case_3_u_eq_left_side {g : grammar T}
{w : list (list T)} {β : list T} {γ : list (symbol T g.nt)}
{x : list (list (symbol T g.nt))} {u v : list (ns T g.nt)} {s : ns T g.nt}
(ass :
list.map symbol.terminal w.join ++ list.map symbol.terminal β ++ [R] ++ list.map wrap_sym γ ++ [H] ++
list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)) =
u ++ [symbol.nonterminal (sum.inr 2)] ++ [s] ++ v
) :
u = list.map symbol.terminal w.join ++ list.map (@symbol.terminal T (nn g.nt)) β :=
begin
have R_ni_u : R ∉ u,
{
exact case_3_ni_u ass,
},
have R_ni_wb : R ∉ list.map symbol.terminal w.join ++ list.map symbol.terminal β,
{
apply @case_3_ni_wb T g,
},
repeat {
rw list.append_assoc at ass,
},
convert congr_arg (list.take u.length) ass.symm,
{
rw list.take_left,
},
rw ←list.append_assoc,
rw list.take_left',
{
classical,
have index_of_first_R := congr_arg (list.index_of R) ass,
rw list.index_of_append_of_notin R_ni_u at index_of_first_R,
rw @list.singleton_append _ _ ([s] ++ v) at index_of_first_R,
rw [←R, list.index_of_cons_self, add_zero] at index_of_first_R,
rw [←list.append_assoc, list.index_of_append_of_notin R_ni_wb] at index_of_first_R,
rw [list.singleton_append, list.index_of_cons_self, add_zero] at index_of_first_R,
exact index_of_first_R,
},
end
private lemma case_3_gamma_nil {g : grammar T}
{w : list (list T)} {β : list T} {γ : list (symbol T g.nt)}
{x : list (list (symbol T g.nt))} {u v : list (ns T g.nt)}
(ass :
list.map symbol.terminal w.join ++ list.map symbol.terminal β ++ [symbol.nonterminal (sum.inr 2)] ++
list.map wrap_sym γ ++ [H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)) =
u ++ [symbol.nonterminal (sum.inr 2)] ++ [H] ++ v
) :
γ = [] :=
begin
have R_ni_wb : R ∉ list.map symbol.terminal w.join ++ list.map symbol.terminal β,
{
apply @case_3_ni_wb T g,
},
have H_ni_wb : H ∉ list.map symbol.terminal w.join ++ list.map symbol.terminal β,
{
apply @case_3_ni_wb T g,
},
have H_ni_wbrg : H ∉
list.map (@symbol.terminal T (nn g.nt)) w.join ++ list.map symbol.terminal β ++
[symbol.nonterminal (sum.inr 2)] ++ list.map wrap_sym γ,
{
intro contra,
rw list.mem_append at contra,
cases contra,
swap, {
exact map_wrap_never_contains_H contra,
},
rw list.mem_append at contra,
cases contra,
{
exact H_ni_wb contra,
},
{
rw list.mem_singleton at contra,
exact H_neq_R contra,
},
},
have R_ni_u : @symbol.nonterminal T (nn g.nt) (sum.inr 2) ∉ u,
{
exact case_3_ni_u ass,
},
have H_ni_u : H ∉ u,
{
rw case_3_u_eq_left_side ass,
exact H_ni_wb,
},
classical,
have first_R := congr_arg (list.index_of R) ass,
have first_H := congr_arg (list.index_of H) ass,
repeat {
rw list.append_assoc (list.map symbol.terminal w.join ++ list.map symbol.terminal β) at first_R,
},
rw list.append_assoc
(list.map symbol.terminal w.join ++ list.map symbol.terminal β ++
[symbol.nonterminal (sum.inr 2)] ++ list.map wrap_sym γ)
at first_H,
rw list.index_of_append_of_notin R_ni_wb at first_R,
rw list.index_of_append_of_notin H_ni_wbrg at first_H,
rw [list.cons_append, list.cons_append, list.cons_append, R, list.index_of_cons_self, add_zero] at first_R,
rw [list.cons_append, list.index_of_cons_self, add_zero] at first_H,
rw [list.append_assoc u, list.append_assoc u] at first_R first_H,
rw list.index_of_append_of_notin R_ni_u at first_R,
rw list.index_of_append_of_notin H_ni_u at first_H,
rw [list.append_assoc _ [H], list.singleton_append, list.index_of_cons_self, add_zero] at first_R,
rw [list.append_assoc _ [H], list.singleton_append, ←R, list.index_of_cons_ne _ H_neq_R] at first_H,
rw [list.singleton_append, H, list.index_of_cons_self] at first_H,
rw ←first_R at first_H,
clear_except first_H,
repeat {
rw list.length_append at first_H,
},
rw list.length_singleton at first_H,
rw ←add_zero ((list.map symbol.terminal w.join).length + (list.map symbol.terminal β).length + 1) at first_H,
rw add_right_inj at first_H,
rw list.length_map at first_H,
rw list.length_eq_zero at first_H,
exact first_H,
end
private lemma case_3_v_nil {g : grammar T}
{w : list (list T)} {β : list T} {u v : list (ns T g.nt)}
(ass :
list.map symbol.terminal w.join ++ list.map symbol.terminal β ++ [R] ++ [H] =
u ++ [symbol.nonterminal (sum.inr 2)] ++ [H] ++ v
) :
v = [] :=
begin
have rev := congr_arg list.reverse ass,
repeat {
rw list.reverse_append at rev,
},
repeat {
rw list.reverse_singleton at rev,
},
rw ←list.reverse_eq_nil,
cases v.reverse with d l,
{
refl,
},
exfalso,
rw list.singleton_append at rev,
have brt := list.tail_eq_of_cons_eq rev,
have brtt := congr_arg list.tail brt,
rw list.singleton_append at brtt,
rw list.tail_cons at brtt,
cases l with e l',
{
change
(list.map symbol.terminal β).reverse ++ (list.map symbol.terminal w.join).reverse =
[symbol.nonterminal (sum.inr 2)] ++ u.reverse
at brtt,
have imposs := congr_arg (λ a, R ∈ a) brtt,
dsimp only at imposs,
apply false_of_true_eq_false,
convert imposs.symm,
{
rw [eq_iff_iff, true_iff],
apply list.mem_append_left,
apply list.mem_singleton_self,
},
{
rw [eq_iff_iff, false_iff],
rw list.mem_append,
push_neg,
split;
{
rw list.mem_reverse,
rw list.mem_map,
push_neg,
intros t trash,
apply symbol.no_confusion,
},
},
},
{
change _ = _ ++ _ at brtt,
have imposs := congr_arg (λ a, H ∈ a) brtt,
dsimp only at imposs,
apply false_of_true_eq_false,
convert imposs.symm,
{
rw [eq_iff_iff, true_iff],
apply list.mem_append_right,
apply list.mem_append_left,
apply list.mem_singleton_self,
},
{
rw [eq_iff_iff, false_iff],
rw list.mem_append,
push_neg,
split;
{
rw list.mem_reverse,
rw list.mem_map,
push_neg,
intros t trash,
apply symbol.no_confusion,
},
},
},
end
private lemma case_3_false_of_wbr_eq_urz {g : grammar T} {r₀ : grule T g.nt}
{w : list (list T)} {β : list T} {u z : list (ns T g.nt)}
(contradictory_equality :
list.map symbol.terminal w.join ++ list.map symbol.terminal β ++ [R] =
u ++ list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ z) :
false :=
begin
apply false_of_true_eq_false,
convert congr_arg ((∈) (symbol.nonterminal (sum.inl r₀.input_N))) contradictory_equality.symm,
{
rw [eq_iff_iff, true_iff],
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_singleton_self,
},
{
rw [eq_iff_iff, false_iff],
intro hyp_N_in,
rw list.mem_append at hyp_N_in,
cases hyp_N_in,
swap, {
rw list.mem_singleton at hyp_N_in,
exact sum.no_confusion (symbol.nonterminal.inj hyp_N_in),
},
rw list.mem_append at hyp_N_in,
cases hyp_N_in;
{
rw list.mem_map at hyp_N_in,
rcases hyp_N_in with ⟨t, -, impos⟩,
exact symbol.no_confusion impos,
},
},
end
private lemma case_3_match_rule {g : grammar T} {r₀ : grule T g.nt}
{x : list (list (symbol T g.nt))} {u v : list (ns T g.nt)}
{w : list (list T)} {β : list T} {γ : list (symbol T g.nt)}
(hyp :
list.map symbol.terminal (list.join w) ++ list.map symbol.terminal β ++ [R] ++
list.map wrap_sym γ ++ [H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)) =
u ++ list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++
list.map wrap_sym r₀.input_R ++ v) :
(∃ m : ℕ, ∃ u₁ v₁ : list (symbol T g.nt),
u = list.map symbol.terminal (list.join w) ++ list.map symbol.terminal β ++
[R] ++ list.map wrap_sym γ ++ [H] ++
list.join (list.map (++ [H]) (list.take m (list.map (list.map wrap_sym) x))) ++ list.map wrap_sym u₁
∧ list.nth x m = some (u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁) ∧
v = list.map wrap_sym v₁ ++ [H] ++
list.join (list.map (++ [H]) (list.drop m.succ (list.map (list.map wrap_sym) x)))) ∨
(∃ u₁ v₁ : list (symbol T g.nt),
u = list.map symbol.terminal (list.join w) ++ list.map symbol.terminal β ++ [R] ++ list.map wrap_sym u₁
∧ γ = u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁ ∧
v = list.map wrap_sym v₁ ++ [H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x))) :=
begin
repeat {
rw list.append_assoc u at hyp,
},
rw list.append_eq_append_iff at hyp,
cases hyp,
{
rcases hyp with ⟨u', u_eq, xj_eq⟩,
left,
repeat {
rw ←list.append_assoc at xj_eq,
},
by_cases is_x_nil : x = [],
{
exfalso,
rw [is_x_nil, list.map_nil, list.map_nil, list.join] at xj_eq,
have imposs := congr_arg list.length xj_eq,
rw list.length at imposs,
rw list.length_append_append at imposs,
rw list.length_append_append at imposs,
rw list.length_singleton at imposs,
clear_except imposs,
linarith,
},
rcases cases_1_and_2_and_3a_match_aux is_x_nil xj_eq with ⟨m, u₁, v₁, u'_eq, xm_eq, v_eq⟩,
use [m, u₁, v₁],
split,
{
rw u_eq,
rw u'_eq,
rw ←list.append_assoc,
},
split,
{
exact xm_eq,
},
{
exact v_eq,
},
},
{
rcases hyp with ⟨v', left_half, right_half⟩,
have very_middle :
[symbol.nonterminal (sum.inl r₀.input_N)] = list.map wrap_sym [symbol.nonterminal r₀.input_N],
{
rw list.map_singleton,
refl,
},
cases x with x₀ xₗ,
{
rw [list.map_nil, list.map_nil, list.join, list.append_nil] at right_half,
rw ←right_half at left_half,
have backwards := congr_arg list.reverse left_half,
clear right_half left_half,
right,
repeat {
rw list.reverse_append at backwards,
},
rw [list.reverse_singleton, list.singleton_append] at backwards,
rw ←list.reverse_reverse v,
cases v.reverse with e z,
{
exfalso,
rw list.nil_append at backwards,
rw ←list.map_reverse _ r₀.input_R at backwards,
cases r₀.input_R.reverse with d l,
{
rw [list.map_nil, list.nil_append] at backwards,
rw list.reverse_singleton (symbol.nonterminal (sum.inl r₀.input_N)) at backwards,
rw list.singleton_append at backwards,
have imposs := list.head_eq_of_cons_eq backwards,
exact sum.no_confusion (symbol.nonterminal.inj imposs),
},
{
rw [list.map_cons, list.cons_append, list.cons_append] at backwards,
have imposs := list.head_eq_of_cons_eq backwards,
exact wrap_never_outputs_H imposs.symm,
},
},
rw [list.cons_append, list.cons_append, list.cons.inj_eq] at backwards,
cases backwards with He backward,
rw ←He at *,
clear He e,
have forward := congr_arg list.reverse backward,
clear backward,
repeat {
rw list.reverse_append at forward,
},
repeat {
rw list.reverse_reverse at forward,
},
rw ←list.append_assoc at forward,
rw list.append_eq_append_iff at forward,
cases forward,
swap, {
exfalso,
rcases forward with ⟨a, imposs, -⟩,
rw list.append_assoc u at imposs,
rw list.append_assoc _ (list.map wrap_sym r₀.input_R) at imposs,
rw ←list.append_assoc u at imposs,
rw ←list.append_assoc u at imposs,
exact case_3_false_of_wbr_eq_urz imposs,
},
rcases forward with ⟨a', left_side, gamma_is⟩,
repeat {
rw ←list.append_assoc at left_side,
},
rw list.append_eq_append_iff at left_side,
cases left_side,
{
exfalso,
rcases left_side with ⟨a, imposs, -⟩,
exact case_3_false_of_wbr_eq_urz imposs,
},
rcases left_side with ⟨c', the_left, the_a'⟩,
rw the_a' at gamma_is,
clear the_a' a',
rw list.append_assoc at the_left,
rw list.append_assoc at the_left,
rw list.append_eq_append_iff at the_left,
cases the_left,
{
exfalso,
rcases the_left with ⟨a, -, imposs⟩,
apply false_of_true_eq_false,
convert congr_arg ((∈) R) imposs.symm,
{
rw [eq_iff_iff, true_iff],
apply list.mem_append_right,
apply list.mem_append_left,
apply list.mem_singleton_self,
},
{
rw [eq_iff_iff, false_iff],
rw list.mem_append,
push_neg,
split,
{
rw list.mem_map,
push_neg,
intros,
apply wrap_never_outputs_R,
},
{
rw list.mem_singleton,
intro impos,
exact sum.no_confusion (symbol.nonterminal.inj impos),
},
},
},
rcases the_left with ⟨u₀, u_eq, rule_side⟩,
rw u_eq at *,
clear u_eq u,
have zr_eq : z.reverse = list.drop (c' ++ list.map wrap_sym r₀.input_R).length (list.map wrap_sym γ),
{
have gamma_suffix := congr_arg (list.drop (c' ++ list.map wrap_sym r₀.input_R).length) gamma_is,
rw list.drop_left at gamma_suffix,
exact gamma_suffix.symm,
},
cases u₀ with d l,
{
exfalso,
rw list.nil_append at rule_side,
cases r₀.input_L with d l,
{
rw [list.map_nil, list.nil_append] at rule_side,
have imposs := list.head_eq_of_cons_eq rule_side,
exact sum.no_confusion (symbol.nonterminal.inj imposs),
},
{
rw [list.map_cons, list.cons_append] at rule_side,
have imposs := list.head_eq_of_cons_eq rule_side,
exact wrap_never_outputs_R imposs.symm,
},
},
rw [list.singleton_append, list.cons_append, list.cons.inj_eq] at rule_side,
cases rule_side with Rd c'_eq,
rw ←Rd at *,
clear Rd d,
rw c'_eq at gamma_is,
use [list.take l.length γ, list.drop (c' ++ list.map wrap_sym r₀.input_R).length γ],
split,
{
rw ←list.singleton_append,
have l_from_gamma := congr_arg (list.take l.length) gamma_is,
repeat {
rw list.append_assoc at l_from_gamma,
},
rw list.take_left at l_from_gamma,
rw list.map_take,
rw l_from_gamma,
rw ←list.append_assoc,
},
split,
{
rw c'_eq,
convert_to list.take l.length γ ++ list.drop l.length γ = _,
{
symmetry,
apply list.take_append_drop,
},
trim,
rw zr_eq at gamma_is,
rw c'_eq at gamma_is,
repeat {
rw list.append_assoc at gamma_is,
},
have gamma_minus_initial_l := congr_arg (list.drop l.length) gamma_is,
rw [list.drop_left, very_middle, ←list.map_drop, ←list.map_drop] at gamma_minus_initial_l,
repeat {
rw ←list.map_append at gamma_minus_initial_l,
},
rw wrap_str_inj gamma_minus_initial_l,
trim,
repeat {
rw list.length_append,
},
repeat {
rw list.length_map,
},
repeat {
rw list.length_append,
},
repeat {
rw list.length_singleton,
},
repeat {
rw add_assoc,
},
},
{
rw [list.map_nil, list.map_nil, list.join, list.append_nil],
rw [list.reverse_cons, zr_eq],
rw list.map_drop,
},
},
by_cases is_v'_nil : v' = [],
{
rw [is_v'_nil, list.nil_append] at right_half,
rw [is_v'_nil, list.append_nil] at left_half,
left,
use [0, [], list.drop (r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R).length x₀],
rw [list.map_cons, list.map_cons, list.join] at right_half,
split,
{
rw [list.map_nil, list.append_nil],
rw [list.take_zero, list.map_nil, list.join, list.append_nil],
exact left_half.symm,
},
have lengths_trivi :
list.length (
list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ list.map wrap_sym r₀.input_R
) =
list.length (r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R),
{
rw [very_middle, ←list.map_append_append],
apply list.length_map,
},
have len_rᵢ_le_len_x₀ :
(r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R).length ≤ (list.map wrap_sym x₀).length,
{
classical,
have first_H := congr_arg (list.index_of H) right_half,
rw [list.append_assoc _ [H], list.index_of_append_of_notin map_wrap_never_contains_H] at first_H,
rw [list.singleton_append, list.index_of_cons_self, add_zero] at first_H,
rw [very_middle, ←list.map_append_append, list.index_of_append_of_notin map_wrap_never_contains_H] at first_H,
rw list.length_map at first_H,
exact nat.le.intro first_H,
},
split,
{
rw list.nth,
apply congr_arg,
rw list.nil_append,
convert_to x₀ =
list.take (r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R).length x₀ ++
list.drop (r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R).length x₀,
{
trim,
apply wrap_str_inj,
rw list.map_append_append,
have right_left :=
congr_arg (list.take (r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R).length) right_half,
rw list.take_left' lengths_trivi at right_left,
rw [←very_middle, right_left],
rw list.append_assoc _ [H],
rw list.take_append_of_le_length len_rᵢ_le_len_x₀,
rw list.map_take,
},
rw list.take_append_drop,
},
{
rw [list.map_cons, list.drop_one, list.tail_cons],
have right_right :=
congr_arg (list.drop (r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R).length) right_half,
rw list.drop_left' lengths_trivi at right_right,
rw right_right,
rw list.append_assoc _ [H],
rw list.drop_append_of_le_length len_rᵢ_le_len_x₀,
rw list.map_drop,
rw list.append_assoc _ [H],
refl,
},
},
right,
obtain ⟨z, v'_eq⟩ : ∃ z, v' =
list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ list.map wrap_sym r₀.input_R ++ z,
{
obtain ⟨v'', without_final_H⟩ : ∃ v'', v' = v'' ++ [H],
{
rw list.append_eq_append_iff at left_half,
cases left_half,
{
rcases left_half with ⟨a', -, matters⟩,
use list.nil,
cases a' with d l,
{
rw list.nil_append at matters ⊢,
exact matters.symm,
},
{
exfalso,
have imposs := congr_arg list.length matters,
rw [list.length_singleton, list.length_append, list.length_cons] at imposs,
have right_pos := length_ge_one_of_not_nil is_v'_nil,
clear_except imposs right_pos,
linarith,
},
},
{
rcases left_half with ⟨c', -, v_c'⟩,
exact ⟨c', v_c'⟩,
},
},
rw without_final_H at right_half,
rw list.append_assoc v'' at right_half,
have key_prop :
list.length (
list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ list.map wrap_sym r₀.input_R
) ≤
v''.length,
{
classical,
have first_H := congr_arg (list.index_of H) right_half,
rw [very_middle, ←list.map_append_append, list.index_of_append_of_notin map_wrap_never_contains_H] at first_H,
have H_not_in_v'' : H ∉ v'',
{
rw [without_final_H, ←list.append_assoc] at left_half,
intro contra,
apply false_of_true_eq_false,
convert congr_arg ((∈) H) (list.append_right_cancel left_half).symm,
{
rw [eq_iff_iff, true_iff],
exact list.mem_append_right _ contra,
},
{
clear_except,
rw [eq_iff_iff, false_iff],
intro contr,
iterate 3 {
rw list.mem_append at contr,
cases contr,
},
iterate 2 {
rw list.mem_map at contr,
rcases contr with ⟨t, -, impos⟩,
exact symbol.no_confusion impos,
},
{
rw list.mem_singleton at contr,
exact H_neq_R contr,
},
{
rw list.mem_map at contr,
rcases contr with ⟨s, -, imposs⟩,
exact wrap_never_outputs_H imposs,
},
},
},
rw list.index_of_append_of_notin H_not_in_v'' at first_H,
rw [list.singleton_append, list.index_of_cons_self, add_zero] at first_H,
rw [very_middle, ←list.map_append_append],
exact nat.le.intro first_H,
},
obtain ⟨n, key_prop'⟩ := nat.le.dest key_prop,
have right_take := congr_arg (list.take v''.length) right_half,
rw list.take_left at right_take,
rw ←key_prop' at right_take,
rw list.take_append at right_take,
use list.take n v ++ [H],
rw without_final_H,
rw ←right_take,
repeat {
rw ←list.append_assoc,
},
},
rw v'_eq at right_half,
rw list.append_assoc _ z at right_half,
rw list.append_right_inj at right_half,
rw v'_eq at left_half,
obtain ⟨u₁, v₁, gamma_parts, z_eq⟩ : ∃ u₁, ∃ v₁,
list.map wrap_sym γ =
list.map wrap_sym u₁ ++ (
list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++ list.map wrap_sym r₀.input_R
) ++ list.map wrap_sym v₁ ∧
z = list.map wrap_sym v₁ ++ [H],
{
repeat {
rw ←list.append_assoc at left_half,
},
rw list.append_assoc _ (list.map wrap_sym γ) at left_half,
rw list.append_assoc _ _ z at left_half,
rw list.append_eq_append_iff at left_half,
cases left_half,
swap, {
exfalso,
rcases left_half with ⟨c', imposs, -⟩,
exact case_3_false_of_wbr_eq_urz imposs,
},
rcases left_half with ⟨a', lhl, lhr⟩,
have lhl' := congr_arg list.reverse lhl,
repeat {
rw list.reverse_append at lhl',
},
rw list.reverse_singleton at lhl',
rw ←list.reverse_reverse a' at lhr,
cases a'.reverse with d' l',
{
exfalso,
rw list.nil_append at lhl',
rw [list.singleton_append, list.reverse_singleton, list.singleton_append] at lhl',
have imposs := list.head_eq_of_cons_eq lhl',
exact sum.no_confusion (symbol.nonterminal.inj imposs),
},
rw list.singleton_append at lhl',
rw list.cons_append at lhl',
rw list.cons.inj_eq at lhl',
cases lhl' with eq_d' lhl'',
rw ←eq_d' at lhr,
clear eq_d' d',
rw ←list.append_assoc l' at lhl'',
rw list.append_eq_append_iff at lhl'',
cases lhl'',
swap, {
exfalso,
rcases lhl'' with ⟨c'', imposs, -⟩,
rw list.reverse_singleton at imposs,
apply false_of_true_eq_false,
convert congr_arg ((∈) R) imposs.symm,
{
rw [eq_iff_iff, true_iff],
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_singleton_self,
},
{
rw [eq_iff_iff, false_iff],
rw list.mem_reverse,
apply map_wrap_never_contains_R,
},
},
rcases lhl'' with ⟨b', lhlr', lhll'⟩,
rw list.reverse_singleton at lhlr',
have lhlr := congr_arg list.reverse lhlr',
rw [list.reverse_append, list.reverse_append, list.reverse_reverse] at lhlr,
rw [list.reverse_singleton, list.singleton_append] at lhlr,
rw ←list.reverse_reverse b' at lhll',
cases b'.reverse with d'' l'',
{
exfalso,
rw list.nil_append at lhlr,
cases r₀.input_L with d l,
{
rw list.map_nil at lhlr,
exact list.no_confusion lhlr,
},
rw list.map_cons at lhlr,
have imposs := list.head_eq_of_cons_eq lhlr,
exact wrap_never_outputs_R imposs.symm,
},
rw list.cons_append at lhlr,
rw list.cons.inj_eq at lhlr,
cases lhlr with eq_d'' lve,
rw ←eq_d'' at lhll',
clear eq_d'' d'',
have lhll := congr_arg list.reverse lhll',
rw [list.reverse_reverse, list.reverse_append, list.reverse_reverse, list.reverse_append,
list.reverse_reverse, list.reverse_reverse] at lhll,
rw lhll at *,
clear lhll u,
rw list.reverse_cons at lhr,
rw lve at lhr,
use list.take l''.length γ,
use list.drop (l''
++ list.map wrap_sym r₀.input_L
++ [symbol.nonterminal (sum.inl r₀.input_N)]
++ list.map wrap_sym r₀.input_R
).length γ,
have z_expr : z =
list.map wrap_sym (
list.drop (l''
++ list.map wrap_sym r₀.input_L
++ [symbol.nonterminal (sum.inl r₀.input_N)]
++ list.map wrap_sym r₀.input_R
).length γ
) ++ [H],
{
have lhdr :=
congr_arg
(list.drop (l''
++ list.map wrap_sym r₀.input_L
++ [symbol.nonterminal (sum.inl r₀.input_N)]
++ list.map wrap_sym r₀.input_R
).length) lhr,
rw list.drop_append_of_le_length at lhdr,
{
rw [list.map_drop, lhdr, ←list.append_assoc, list.drop_left],
},
have lhr' := congr_arg list.reverse lhr,
repeat {
rw list.reverse_append at lhr',
},
rw list.reverse_singleton at lhr',
cases z.reverse with d l,
{
exfalso,
rw [list.nil_append, list.singleton_append] at lhr',
rw ←list.map_reverse _ r₀.input_R at lhr',
cases r₀.input_R.reverse with dᵣ lᵣ,
{
rw [list.map_nil, list.nil_append, list.reverse_singleton, list.singleton_append] at lhr',
have imposs := list.head_eq_of_cons_eq lhr',
exact sum.no_confusion (symbol.nonterminal.inj imposs),
},
{
rw [list.map_cons, list.cons_append] at lhr',
have imposs := list.head_eq_of_cons_eq lhr',
exact wrap_never_outputs_H imposs.symm,
},
},
repeat {
rw list.length_append,
},
have contra_len := congr_arg list.length lhr',
repeat {
rw list.length_append at contra_len,
},
repeat {
rw list.length_reverse at contra_len,
},
repeat {
rw list.length_singleton at contra_len,
},
rw list.length_cons at contra_len,
rw list.length_singleton,
clear_except contra_len,
linarith,
},
split,
swap, {
exact z_expr,
},
rw z_expr at lhr,
have gamma_expr : list.map wrap_sym γ =
l'' ++ list.map wrap_sym r₀.input_L ++ [symbol.nonterminal (sum.inl r₀.input_N)] ++
(list.map wrap_sym r₀.input_R ++
(list.map wrap_sym
(list.drop (l''
++ list.map wrap_sym r₀.input_L
++ [symbol.nonterminal (sum.inl r₀.input_N)]
++ list.map wrap_sym r₀.input_R
).length γ))),
{
repeat {
rw ←list.append_assoc at lhr,
},
repeat {
rw ←list.append_assoc,
},
exact list.append_right_cancel lhr,
},
rw gamma_expr,
trim,
have almost := congr_arg (list.take l''.length) gamma_expr.symm,
repeat {
rw list.append_assoc at almost,
},
rw list.take_left at almost,
rw list.map_take,
exact almost,
},
use [u₁, v₁],
split, swap, split,
{
apply wrap_str_inj,
rwa [
very_middle, ←list.map_append_append, ←list.map_append_append,
←list.append_assoc, ←list.append_assoc
] at gamma_parts,
},
{
rwa z_eq at right_half,
},
rw gamma_parts at left_half,
rw list.append_assoc (list.map wrap_sym u₁) at left_half,
rw ←list.append_assoc _ (list.map wrap_sym u₁) at left_half,
rw list.append_assoc _ _ [H] at left_half,
have left_left := congr_arg (list.take u.length) left_half,
rw list.take_left at left_left,
rw list.take_left' at left_left,
{
exact left_left.symm,
},
have lh_len := congr_arg list.length left_half,
repeat {
rw list.length_append at lh_len,
},
repeat {
rw list.length_singleton at lh_len,
},
have cut_off_end : z.length = (list.map wrap_sym v₁).length + 1,
{
simpa using congr_arg list.length z_eq,
},
rw cut_off_end at lh_len,
repeat {
rw list.length_append,
},
rw list.length_singleton,
repeat {
rw add_assoc at lh_len,
},
iterate 3 {
rw ←add_assoc at lh_len,
},
rwa add_left_inj at lh_len,
},
end
private lemma star_case_3 {g : grammar T} {α α' : list (ns T g.nt)}
(orig : grammar_transforms (star_grammar g) α α')
(hyp : ∃ w : list (list T), ∃ β : list T, ∃ γ : list (symbol T g.nt), ∃ x : list (list (symbol T g.nt)),
(∀ wᵢ ∈ w, grammar_generates g wᵢ) ∧
(grammar_derives g [symbol.nonterminal g.initial] (list.map symbol.terminal β ++ γ)) ∧
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α = list.map symbol.terminal (list.join w) ++ list.map symbol.terminal β ++ [R] ++
list.map wrap_sym γ ++ [H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) :
(∃ w : list (list T), ∃ β : list T, ∃ γ : list (symbol T g.nt), ∃ x : list (list (symbol T g.nt)),
(∀ wᵢ ∈ w, grammar_generates g wᵢ) ∧
(grammar_derives g [symbol.nonterminal g.initial] (list.map symbol.terminal β ++ γ)) ∧
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α' = list.map symbol.terminal (list.join w) ++ list.map symbol.terminal β ++ [R] ++
list.map wrap_sym γ ++ [H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) ∨
(∃ u : list T, u ∈ language.star (grammar_language g) ∧ α' = list.map symbol.terminal u) ∨
(∃ σ : list (symbol T g.nt), α' = list.map wrap_sym σ ++ [R]) ∨
(∃ ω : list (ns T g.nt), α' = ω ++ [H]) ∧ Z ∉ α' ∧ R ∉ α' :=
begin
rcases hyp with ⟨w, β, γ, x, valid_w, valid_middle, valid_x, cat⟩,
have no_Z_in_alpha : Z ∉ α,
{
intro contr,
rw cat at contr,
clear_except contr,
repeat {
rw list.mem_append at contr,
},
iterate 5 {
cases contr,
},
any_goals {
rw list.mem_map at contr,
rcases contr with ⟨s, -, imposs⟩,
},
{
exact symbol.no_confusion imposs,
},
{
exact symbol.no_confusion imposs,
},
{
rw list.mem_singleton at contr,
exact Z_neq_R contr,
},
{
exact wrap_never_outputs_Z imposs,
},
{
rw list.mem_singleton at contr,
exact Z_neq_H contr,
},
{
exact Z_not_in_join_mpHmmw contr,
},
},
rw cat at *,
clear cat,
rcases orig with ⟨r, rin, u, v, bef, aft⟩,
iterate 2 {
cases rin,
{
exfalso,
apply no_Z_in_alpha,
rw bef,
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_right,
rw list.mem_singleton,
rw rin,
refl,
},
},
cases rin,
{
rw rin at bef aft,
dsimp only at bef aft,
rw list.append_nil at bef,
have gamma_nil_here := case_3_gamma_nil bef,
cases x with x₀ L,
{
right, right, left,
rw [gamma_nil_here, list.map_nil, list.append_nil] at bef,
rw [list.map_nil, list.map_nil, list.join, list.append_nil] at bef,
have v_nil := case_3_v_nil bef,
rw [v_nil, list.append_nil] at bef aft,
use list.map symbol.terminal w.join ++ list.map symbol.terminal β,
rw aft,
have bef_minus_H := list.append_right_cancel bef,
have bef_minus_RH := list.append_right_cancel bef_minus_H,
rw ←bef_minus_RH,
rw [list.map_append, list.map_map, list.map_map],
refl,
},
{
left,
use [w ++ [β], x₀, L],
split,
{
intros wᵢ wiin,
rw list.mem_append at wiin,
cases wiin,
{
exact valid_w wᵢ wiin,
},
{
rw list.mem_singleton at wiin,
rw wiin,
rw [gamma_nil_here, list.append_nil] at valid_middle,
exact valid_middle,
},
},
split,
{
rw [list.map_nil, list.nil_append],
exact valid_x x₀ (list.mem_cons_self x₀ L),
},
split,
{
intros xᵢ xiin,
exact valid_x xᵢ (list.mem_cons_of_mem x₀ xiin),
},
rw [list.map_nil, list.append_nil],
rw aft,
have u_eq : u = list.map (@symbol.terminal T (nn g.nt)) w.join ++ list.map (@symbol.terminal T (nn g.nt)) β,
{
exact case_3_u_eq_left_side bef,
},
have v_eq : v = list.join (list.map (++ [H]) (list.map (list.map wrap_sym) (x₀ :: L))),
{
rw u_eq at bef,
rw [gamma_nil_here, list.map_nil, list.append_nil] at bef,
exact (list.append_left_cancel bef).symm,
},
rw [u_eq, v_eq],
rw [list.join_append, list.map_append, list.join_singleton],
rw [list.map_cons, list.map_cons, list.join],
rw [←list.append_assoc, ←list.append_assoc],
refl,
},
},
cases rin,
{
rw rin at bef aft,
dsimp only at bef aft,
rw list.append_nil at bef aft,
have gamma_nil_here := case_3_gamma_nil bef,
rw ←list.reverse_reverse x at *,
cases x.reverse with xₘ L,
{
right, left,
rw [gamma_nil_here, list.map_nil, list.append_nil] at bef,
rw [list.reverse_nil, list.map_nil, list.map_nil, list.join, list.append_nil] at bef,
have v_nil := case_3_v_nil bef,
rw [v_nil, list.append_nil] at bef aft,
use list.join w ++ β,
split,
{
use w ++ [β],
split,
{
rw list.join_append,
rw list.join_singleton,
},
{
intros y y_in,
rw list.mem_append at y_in,
cases y_in,
{
exact valid_w y y_in,
},
{
rw list.mem_singleton at y_in,
rw y_in,
rw [gamma_nil_here, list.append_nil] at valid_middle,
exact valid_middle,
},
},
},
{
rw aft,
have bef_minus_H := list.append_right_cancel bef,
have bef_minus_RH := list.append_right_cancel bef_minus_H,
rw ←bef_minus_RH,
rw list.map_append,
},
},
{
right, right, right,
rw list.reverse_cons at bef,
rw aft,
have Z_ni_wb : Z ∉ list.map (@symbol.terminal T (nn g.nt)) w.join ++ list.map symbol.terminal β,
{
apply case_3_ni_wb,
},
have R_ni_wb : R ∉ list.map (@symbol.terminal T (nn g.nt)) w.join ++ list.map symbol.terminal β,
{
apply case_3_ni_wb,
},
have u_eq : u = list.map (@symbol.terminal T (nn g.nt)) w.join ++ list.map symbol.terminal β,
{
exact case_3_u_eq_left_side bef,
},
have v_eq : v = list.join (list.map (++ [H]) (list.map (list.map wrap_sym) (L.reverse ++ [xₘ]))),
{
rw u_eq at bef,
rw [gamma_nil_here, list.map_nil, list.append_nil] at bef,
exact (list.append_left_cancel bef).symm,
},
rw [u_eq, v_eq],
split,
{
use list.map symbol.terminal w.join ++ list.map symbol.terminal β ++
list.join (list.map (++ [H]) (list.map (list.map wrap_sym) L.reverse)) ++ list.map wrap_sym xₘ,
rw [
list.map_append, list.map_append, list.join_append,
list.map_singleton, list.map_singleton, list.join_singleton,
←list.append_assoc, ←list.append_assoc
], refl,
},
split,
{
intro contra,
rw list.mem_append at contra,
cases contra,
{
exact Z_ni_wb contra,
},
{
exact Z_not_in_join_mpHmmw contra,
},
},
{
intro contra,
rw list.mem_append at contra,
cases contra,
{
exact R_ni_wb contra,
},
{
exact R_not_in_join_mpHmmw contra,
},
},
},
},
have rin' : r ∈ rules_that_scan_terminals g ∨ r ∈ list.map wrap_gr g.rules,
{
rw or_comm,
rwa ←list.mem_append,
},
clear rin,
cases rin',
{
left,
unfold rules_that_scan_terminals at rin',
rw list.mem_map at rin',
rcases rin' with ⟨t, -, r_is⟩,
rw ←r_is at bef aft,
dsimp only at bef aft,
rw list.append_nil at bef,
have u_matches : u = list.map (@symbol.terminal T (nn g.nt)) w.join ++ list.map symbol.terminal β,
{
exact case_3_u_eq_left_side bef,
},
have tv_matches :
[symbol.terminal t] ++ v =
list.map wrap_sym γ ++ [H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)),
{
rw u_matches at bef,
repeat {
rw list.append_assoc at bef,
},
have almost := list.append_left_cancel (list.append_left_cancel (list.append_left_cancel bef)),
rw ←list.append_assoc at almost,
exact almost.symm,
},
cases γ with a δ,
{
exfalso,
rw [list.map_nil, list.nil_append, list.singleton_append, list.singleton_append] at tv_matches,
have t_matches := list.head_eq_of_cons_eq tv_matches,
exact symbol.no_confusion t_matches,
},
rw [list.singleton_append, list.map_cons, list.cons_append, list.cons_append] at tv_matches,
use [w, β ++ [t], δ, x],
split,
{
exact valid_w,
},
split,
{
have t_matches' := list.head_eq_of_cons_eq tv_matches,
cases a;
unfold wrap_sym at t_matches',
{
have t_eq_a := symbol.terminal.inj t_matches',
rw [t_eq_a, list.map_append, list.map_singleton, list.append_assoc, list.singleton_append],
exact valid_middle,
},
{
exfalso,
exact symbol.no_confusion t_matches',
},
},
split,
{
exact valid_x,
},
rw aft,
rw u_matches,
rw [list.map_append, list.map_singleton],
have v_matches := list.tail_eq_of_cons_eq tv_matches,
rw v_matches,
simp [list.append_assoc],
},
left,
rw list.mem_map at rin',
rcases rin' with ⟨r₀, orig_in, wrap_orig⟩,
unfold wrap_gr at wrap_orig,
rw ←wrap_orig at *,
clear wrap_orig,
cases case_3_match_rule bef,
{
rcases h with ⟨m, u₁, v₁, u_eq, xm_eq, v_eq⟩,
clear bef,
dsimp only at aft,
rw [u_eq, v_eq] at aft,
use w,
use β,
use γ,
use (list.take m x ++ [u₁ ++ r₀.output_string ++ v₁] ++ list.drop m.succ x),
split,
{
exact valid_w,
},
split,
{
exact valid_middle,
},
split,
{
intros xᵢ xiin,
rw list.mem_append_append at xiin,
cases xiin,
{
apply valid_x,
exact list.mem_of_mem_take xiin,
},
cases xiin,
swap, {
apply valid_x,
exact list.mem_of_mem_drop xiin,
},
{
rw list.mem_singleton at xiin,
rw xiin,
have last_step :
grammar_transforms g
(u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁)
(u₁ ++ r₀.output_string ++ v₁),
{
use r₀,
split,
{
exact orig_in,
},
use [u₁, v₁],
split;
refl,
},
apply grammar_deri_of_deri_tran _ last_step,
apply valid_x (u₁ ++ r₀.input_L ++ [symbol.nonterminal r₀.input_N] ++ r₀.input_R ++ v₁),
exact list.nth_mem xm_eq,
},
},
{
rw aft,
trim,
rw [
list.map_append_append,
list.map_append_append,
list.join_append_append,
←list.map_take,
←list.map_drop,
list.map_singleton,
list.map_singleton,
list.join_singleton,
list.map_append_append,
←list.append_assoc,
←list.append_assoc,
←list.append_assoc
],
},
},
{
rcases h with ⟨u₁, v₁, u_eq, γ_eq, v_eq⟩,
clear bef,
dsimp only at aft,
rw [u_eq, v_eq] at aft,
use w,
use β,
use u₁ ++ r₀.output_string ++ v₁,
use x,
split,
{
exact valid_w,
},
split,
{
apply grammar_deri_of_deri_tran valid_middle,
rw γ_eq,
use r₀,
split,
{
exact orig_in,
},
use [list.map symbol.terminal β ++ u₁, v₁],
split,
repeat {
rw ←list.append_assoc,
},
},
split,
{
exact valid_x,
},
{
rw aft,
trim,
rw list.map_append_append,
},
},
end
private lemma star_case_4 {g : grammar T} {α α' : list (ns T g.nt)}
(orig : grammar_transforms (star_grammar g) α α')
(hyp : ∃ u : list T, u ∈ (grammar_language g).star ∧ α = list.map symbol.terminal u) :
false :=
begin
rcases hyp with ⟨w, -, alpha_of_w⟩,
rw alpha_of_w at orig,
rcases orig with ⟨r, -, u, v, bef, -⟩,
simpa using congr_arg (λ l, symbol.nonterminal r.input_N ∈ l) bef,
end
private lemma star_case_5 {g : grammar T} {α α' : list (ns T g.nt)}
(orig : grammar_transforms (star_grammar g) α α')
(hyp : ∃ σ : list (symbol T g.nt), α = list.map wrap_sym σ ++ [R]) :
(∃ σ : list (symbol T g.nt), α' = list.map wrap_sym σ ++ [R]) :=
begin
rcases hyp with ⟨w, ends_with_R⟩,
rcases orig with ⟨r, rin, u, v, bef, aft⟩,
rw ends_with_R at bef,
clear ends_with_R,
iterate 2 {
cases rin,
{
exfalso,
rw rin at bef,
simp only [list.append_nil] at bef,
have imposs := congr_arg (λ l, Z ∈ l) bef,
simp only [list.mem_append] at imposs,
rw list.mem_singleton at imposs,
rw list.mem_singleton at imposs,
apply false_of_true_eq_false,
convert imposs.symm,
{
unfold Z,
rw [eq_self_iff_true, or_true, true_or],
},
{
rw [eq_iff_iff, false_iff],
push_neg,
split,
{
apply map_wrap_never_contains_Z,
},
{
exact Z_neq_R,
},
},
},
},
iterate 2 {
cases rin,
{
exfalso,
rw rin at bef,
dsimp only at bef,
rw list.append_nil at bef,
have rev := congr_arg list.reverse bef,
repeat {
rw list.reverse_append at rev,
},
repeat {
rw list.reverse_singleton at rev,
},
rw list.singleton_append at rev,
cases v.reverse with d l,
{
rw list.nil_append at rev,
rw list.singleton_append at rev,
have tails := list.tail_eq_of_cons_eq rev,
rw ←list.map_reverse at tails,
cases w.reverse with d' l',
{
rw list.map_nil at tails,
have imposs := congr_arg list.length tails,
rw [list.length, list.length_append, list.length_singleton] at imposs,
clear_except imposs,
linarith,
},
{
rw list.map_cons at tails,
rw list.singleton_append at tails,
have heads := list.head_eq_of_cons_eq tails,
exact wrap_never_outputs_R heads,
},
},
{
have tails := list.tail_eq_of_cons_eq rev,
have H_in_tails := congr_arg (λ l, H ∈ l) tails,
dsimp only at H_in_tails,
rw list.mem_reverse at H_in_tails,
apply false_of_true_eq_false,
convert H_in_tails.symm,
{
rw [eq_iff_iff, true_iff],
apply list.mem_append_right,
apply list.mem_append_left,
apply list.mem_singleton_self,
},
{
rw [eq_iff_iff, false_iff],
intro hyp_H_in,
exact map_wrap_never_contains_H hyp_H_in,
},
},
},
},
change r ∈ list.map wrap_gr g.rules ++ rules_that_scan_terminals g at rin,
rw list.mem_append at rin,
cases rin,
{
rw list.mem_map at rin,
rcases rin with ⟨r₀, -, r_of_r₀⟩,
rw list.append_eq_append_iff at bef,
cases bef,
{
rcases bef with ⟨x, ur_eq, singleR⟩,
by_cases is_x_nil : x = [],
{
have v_is_R : v = [R],
{
rw [is_x_nil, list.nil_append] at singleR,
exact singleR.symm,
},
rw v_is_R at aft,
rw [is_x_nil, list.append_nil] at ur_eq,
have u_from_w : u = list.take u.length (list.map wrap_sym w),
{ -- do not extract out of `cases bef`
repeat {
rw list.append_assoc at ur_eq,
},
have tak := congr_arg (list.take u.length) ur_eq,
rw list.take_left at tak,
exact tak,
},
rw ←list.map_take at u_from_w,
rw u_from_w at aft,
rw ←r_of_r₀ at aft,
dsimp only [wrap_gr] at aft,
use list.take u.length w ++ r₀.output_string,
rw list.map_append,
exact aft,
},
{
exfalso,
have x_is_R : x = [R],
{
by_cases is_v_nil : v = [],
{
rw [is_v_nil, list.append_nil] at singleR,
exact singleR.symm,
},
{
exfalso,
have imposs := congr_arg list.length singleR,
rw list.length_singleton at imposs,
rw list.length_append at imposs,
have xl_ge_one := length_ge_one_of_not_nil is_x_nil,
have vl_ge_one := length_ge_one_of_not_nil is_v_nil,
clear_except imposs xl_ge_one vl_ge_one,
linarith,
},
},
rw x_is_R at ur_eq,
have ru_eq := congr_arg list.reverse ur_eq,
repeat {
rw list.reverse_append at ru_eq,
},
repeat {
rw list.reverse_singleton at ru_eq,
rw list.singleton_append at ru_eq,
},
rw ←r_of_r₀ at ru_eq,
dsimp only [wrap_gr, R] at ru_eq,
rw ←list.map_reverse at ru_eq,
cases r₀.input_R.reverse with d l,
{
rw [list.map_nil, list.nil_append] at ru_eq,
have imposs := list.head_eq_of_cons_eq ru_eq,
exact sum.no_confusion (symbol.nonterminal.inj imposs),
},
{
have imposs := list.head_eq_of_cons_eq ru_eq,
cases d;
unfold wrap_sym at imposs,
{
exact symbol.no_confusion imposs,
},
{
exact sum.no_confusion (symbol.nonterminal.inj imposs),
},
},
},
},
{
rcases bef with ⟨y, w_eq, v_eq⟩,
have u_from_w : u = list.take u.length (list.map wrap_sym w),
{ -- do not extract out of `cases bef`
repeat {
rw list.append_assoc at w_eq,
},
have tak := congr_arg (list.take u.length) w_eq,
rw list.take_left at tak,
exact tak.symm,
},
have y_from_w :
y = list.drop (u ++ r.input_L ++ [symbol.nonterminal r.input_N] ++ r.input_R).length (list.map wrap_sym w),
{
have drp := congr_arg (list.drop (u ++ r.input_L ++ [symbol.nonterminal r.input_N] ++ r.input_R).length) w_eq,
rw list.drop_left at drp,
exact drp.symm,
},
-- weird that `u_from_w` and `y_from_w` did not unify their type parameters in the same way
rw u_from_w at aft,
rw y_from_w at v_eq,
rw v_eq at aft,
use list.take u.length w ++ r₀.output_string ++
list.drop (u ++ r.input_L ++ [symbol.nonterminal r.input_N] ++ r.input_R).length w,
rw list.map_append_append,
rw list.map_take,
rw list.map_drop,
rw aft,
trim, -- fails to identify `list.take u.length (list.map wrap_sym w)` of defin-equal type parameters
rw ←r_of_r₀,
dsimp only [wrap_gr],
refl, -- outside level `(symbol T (star_grammar g).nt) = (ns T g.nt) = (symbol T (nn g.nt))`
},
},
{
exfalso,
unfold rules_that_scan_terminals at rin,
rw list.mem_map at rin,
rcases rin with ⟨t, -, eq_r⟩,
rw ←eq_r at bef,
clear eq_r,
dsimp only at bef,
rw list.append_nil at bef,
have rev := congr_arg list.reverse bef,
repeat {
rw list.reverse_append at rev,
},
repeat {
rw list.reverse_singleton at rev,
},
rw list.singleton_append at rev,
cases v.reverse with d l,
{
rw list.nil_append at rev,
rw list.singleton_append at rev,
have tails := list.tail_eq_of_cons_eq rev,
rw ←list.map_reverse at tails,
cases w.reverse with d' l',
{
rw list.map_nil at tails,
have imposs := congr_arg list.length tails,
rw [list.length, list.length_append, list.length_singleton] at imposs,
clear_except imposs,
linarith,
},
{
rw list.map_cons at tails,
rw list.singleton_append at tails,
have heads := list.head_eq_of_cons_eq tails,
exact wrap_never_outputs_R heads,
},
},
{
have tails := list.tail_eq_of_cons_eq rev,
have R_in_tails := congr_arg (λ l, R ∈ l) tails,
dsimp only at R_in_tails,
rw list.mem_reverse at R_in_tails,
apply false_of_true_eq_false,
convert R_in_tails.symm,
{
rw [eq_iff_iff, true_iff],
apply list.mem_append_right,
apply list.mem_append_right,
apply list.mem_append_left,
apply list.mem_singleton_self,
},
{
rw [eq_iff_iff, false_iff],
intro hyp_R_in,
exact map_wrap_never_contains_R hyp_R_in,
},
},
},
end
private lemma star_case_6 {g : grammar T} {α α' : list (ns T g.nt)}
(orig : grammar_transforms (star_grammar g) α α')
(hyp : (∃ ω : list (ns T g.nt), α = ω ++ [H]) ∧ Z ∉ α ∧ R ∉ α) :
(∃ ω : list (ns T g.nt), α' = ω ++ [H]) ∧ Z ∉ α' ∧ R ∉ α' :=
begin
rcases hyp with ⟨⟨w, ends_with_H⟩, no_Z, no_R⟩,
rcases orig with ⟨r, rin, u, v, bef, aft⟩,
iterate 2 {
cases rin,
{
exfalso,
rw rin at bef,
simp only [list.append_nil] at bef,
rw bef at no_Z,
apply no_Z,
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_singleton_self,
},
},
iterate 2 {
cases rin,
{
exfalso,
rw rin at bef,
dsimp only at bef,
rw list.append_nil at bef,
rw bef at no_R,
apply no_R,
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_singleton_self,
},
},
change r ∈ list.map wrap_gr g.rules ++ rules_that_scan_terminals g at rin,
rw list.mem_append at rin,
cases rin,
{
rw ends_with_H at bef,
rw list.mem_map at rin,
rcases rin with ⟨r₀, -, r_of_r₀⟩,
split,
swap, {
split,
{
rw aft,
intro contra,
rw list.mem_append at contra,
rw list.mem_append at contra,
cases contra,
swap, {
apply no_Z,
rw ends_with_H,
rw bef,
rw list.mem_append,
right,
exact contra,
},
cases contra,
{
apply no_Z,
rw ends_with_H,
rw bef,
repeat {
rw list.append_assoc,
},
rw list.mem_append,
left,
exact contra,
},
rw ←r_of_r₀ at contra,
unfold wrap_gr at contra,
rw list.mem_map at contra,
rcases contra with ⟨s, -, imposs⟩,
cases s,
{
unfold wrap_sym at imposs,
exact symbol.no_confusion imposs,
},
{
unfold wrap_sym at imposs,
unfold Z at imposs,
rw symbol.nonterminal.inj_eq at imposs,
exact sum.no_confusion imposs,
},
},
{
rw aft,
intro contra,
rw list.mem_append at contra,
rw list.mem_append at contra,
cases contra,
swap, {
apply no_R,
rw ends_with_H,
rw bef,
rw list.mem_append,
right,
exact contra,
},
cases contra,
{
apply no_R,
rw ends_with_H,
rw bef,
repeat {
rw list.append_assoc,
},
rw list.mem_append,
left,
exact contra,
},
rw ←r_of_r₀ at contra,
unfold wrap_gr at contra,
rw list.mem_map at contra,
rcases contra with ⟨s, -, imposs⟩,
cases s,
{
unfold wrap_sym at imposs,
exact symbol.no_confusion imposs,
},
{
unfold wrap_sym at imposs,
unfold R at imposs,
rw symbol.nonterminal.inj_eq at imposs,
exact sum.no_confusion imposs,
},
},
},
use u ++ r.output_string ++ v.take (v.length - 1),
rw aft,
trim,
have vlnn : v.length ≥ 1,
{
by_contradiction contra,
have v_nil := zero_of_not_ge_one contra,
rw list.length_eq_zero at v_nil,
rw v_nil at bef,
rw ←r_of_r₀ at bef,
rw list.append_nil at bef,
unfold wrap_gr at bef,
have rev := congr_arg list.reverse bef,
clear_except rev,
repeat {
rw list.reverse_append at rev,
},
rw ←list.map_reverse _ r₀.input_R at rev,
rw list.reverse_singleton at rev,
cases r₀.input_R.reverse with d l,
{
have H_eq_N : H = symbol.nonterminal (sum.inl r₀.input_N),
{
rw [list.map_nil, list.nil_append,
list.reverse_singleton, list.singleton_append, list.singleton_append,
list.cons.inj_eq] at rev,
exact rev.left,
},
unfold H at H_eq_N,
have inr_eq_inl := symbol.nonterminal.inj H_eq_N,
exact sum.no_confusion inr_eq_inl,
},
{
rw list.map_cons at rev,
have H_is : H = wrap_sym d,
{
rw [list.singleton_append, list.cons_append, list.cons.inj_eq] at rev,
exact rev.left,
},
unfold H at H_is,
cases d;
unfold wrap_sym at H_is,
{
exact symbol.no_confusion H_is,
},
{
rw symbol.nonterminal.inj_eq at H_is,
exact sum.no_confusion H_is,
},
},
},
convert_to list.take (v.length - 1) v ++ list.drop (v.length - 1) v = list.take (v.length - 1) v ++ [H],
{
rw list.take_append_drop,
},
trim,
have bef_rev := congr_arg list.reverse bef,
repeat {
rw list.reverse_append at bef_rev,
},
have bef_rev_tak := congr_arg (list.take 1) bef_rev,
rw list.take_left' at bef_rev_tak,
swap, {
rw list.length_reverse,
apply list.length_singleton,
},
rw list.take_append_of_le_length at bef_rev_tak,
swap, {
rw list.length_reverse,
exact vlnn,
},
rw list.reverse_take _ vlnn at bef_rev_tak,
rw list.reverse_eq_iff at bef_rev_tak,
rw list.reverse_reverse at bef_rev_tak,
exact bef_rev_tak.symm,
},
{
exfalso,
unfold rules_that_scan_terminals at rin,
rw list.mem_map at rin,
rcases rin with ⟨t, -, eq_r⟩,
rw ←eq_r at bef,
dsimp only at bef,
rw list.append_nil at bef,
rw bef at no_R,
apply no_R,
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_singleton_self,
},
end
private lemma star_induction {g : grammar T} {α : list (ns T g.nt)}
(ass : grammar_derives (star_grammar g) [Z] α) :
(∃ x : list (list (symbol T g.nt)),
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α = [Z] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) ∨
(∃ x : list (list (symbol T g.nt)),
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α = [R, H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) ∨
(∃ w : list (list T), ∃ β : list T, ∃ γ : list (symbol T g.nt), ∃ x : list (list (symbol T g.nt)),
(∀ wᵢ ∈ w, grammar_generates g wᵢ) ∧
(grammar_derives g [symbol.nonterminal g.initial] (list.map symbol.terminal β ++ γ)) ∧
(∀ xᵢ ∈ x, grammar_derives g [symbol.nonterminal g.initial] xᵢ) ∧
(α = list.map symbol.terminal (list.join w) ++ list.map symbol.terminal β ++ [R] ++
list.map wrap_sym γ ++ [H] ++ list.join (list.map (++ [H]) (list.map (list.map wrap_sym) x)))) ∨
(∃ u : list T, u ∈ language.star (grammar_language g) ∧ α = list.map symbol.terminal u) ∨
(∃ σ : list (symbol T g.nt), α = list.map wrap_sym σ ++ [R]) ∨
(∃ ω : list (ns T g.nt), α = ω ++ [H]) ∧ Z ∉ α ∧ R ∉ α :=
begin
induction ass with a b trash orig ih,
{
left,
use list.nil,
split,
{
intros y imposs,
exfalso,
exact list.not_mem_nil y imposs,
},
{
refl,
},
},
cases ih,
{
rw ←or_assoc,
left,
exact star_case_1 orig ih,
},
cases ih,
{
right,
exact star_case_2 orig ih,
},
cases ih,
{
right, right,
exact star_case_3 orig ih,
},
cases ih,
{
exfalso,
exact star_case_4 orig ih,
},
cases ih,
{
right, right, right, right, left,
exact star_case_5 orig ih,
},
{
right, right, right, right, right,
exact star_case_6 orig ih,
},
end
end hard_direction
/-- The class of recursively-enumerable languages is closed under the Kleene star. -/
theorem RE_of_star_RE (L : language T) :
is_RE L → is_RE L.star :=
begin
rintro ⟨g, hg⟩,
use star_grammar g,
apply set.eq_of_subset_of_subset,
{
-- prove `L.star ⊇` here
intros w hyp,
unfold grammar_language at hyp,
rw set.mem_set_of_eq at hyp,
have result := star_induction hyp,
clear hyp,
cases result,
{
exfalso,
rcases result with ⟨x, -, contr⟩,
cases w with d l,
{
tauto,
},
rw list.map_cons at contr,
have terminal_eq_Z : symbol.terminal d = Z,
{
exact list.head_eq_of_cons_eq contr,
},
exact symbol.no_confusion terminal_eq_Z,
},
cases result,
{
exfalso,
rcases result with ⟨x, -, contr⟩,
cases w with d l,
{
tauto,
},
rw list.map_cons at contr,
have terminal_eq_R : symbol.terminal d = R,
{
exact list.head_eq_of_cons_eq contr,
},
exact symbol.no_confusion terminal_eq_R,
},
cases result,
{
exfalso,
rcases result with ⟨α, β, γ, x, -, -, -, contr⟩,
have output_contains_R : R ∈ list.map symbol.terminal w,
{
rw contr,
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_left,
apply list.mem_append_right,
apply list.mem_cons_self,
},
rw list.mem_map at output_contains_R,
rcases output_contains_R with ⟨t, -, terminal_eq_R⟩,
exact symbol.no_confusion terminal_eq_R,
},
cases result,
{
rcases result with ⟨u, win, map_eq_map⟩,
have w_eq_u : w = u,
{
have st_inj : function.injective (@symbol.terminal T (star_grammar g).nt),
{
apply symbol.terminal.inj,
},
rw ←list.map_injective_iff at st_inj,
exact st_inj map_eq_map,
},
rw [w_eq_u, ←hg],
exact win,
},
cases result,
{
exfalso,
cases result with σ contr,
have last_symbols := congr_fun (congr_arg list.nth (congr_arg list.reverse contr)) 0,
rw [
←list.map_reverse,
list.reverse_append,
list.reverse_singleton,
list.singleton_append,
list.nth,
list.nth_map
] at last_symbols,
cases w.reverse.nth 0,
{
rw option.map_none' at last_symbols,
exact option.no_confusion last_symbols,
},
{
rw option.map_some' at last_symbols,
have terminal_eq_R := option.some.inj last_symbols,
exact symbol.no_confusion terminal_eq_R,
},
},
{
exfalso,
rcases result with ⟨⟨ω, contr⟩, -⟩,
have last_symbols := congr_fun (congr_arg list.nth (congr_arg list.reverse contr)) 0,
rw [
←list.map_reverse,
list.reverse_append,
list.reverse_singleton,
list.singleton_append,
list.nth,
list.nth_map
] at last_symbols,
cases w.reverse.nth 0,
{
rw option.map_none' at last_symbols,
exact option.no_confusion last_symbols,
},
{
rw option.map_some' at last_symbols,
have terminal_eq_H := option.some.inj last_symbols,
exact symbol.no_confusion terminal_eq_H,
},
},
},
{
-- prove `L.star ⊆` here
intros p ass,
unfold grammar_language,
rw language.star at ass,
rw set.mem_set_of_eq at ⊢ ass,
rcases ass with ⟨w, w_join, parts_in_L⟩,
let v := w.reverse,
have v_reverse : v.reverse = w,
{
apply list.reverse_reverse,
},
rw ←v_reverse at *,
rw w_join,
clear w_join p,
unfold grammar_generates,
rw ←hg at parts_in_L,
cases short_induction parts_in_L with derived terminated,
apply grammar_deri_of_deri_deri derived,
apply grammar_deri_of_tran_deri,
{
use (star_grammar g).rules.nth_le 1 (by dec_trivial),
split,
{
apply list.nth_le_mem,
},
use [[], (list.map (++ [H]) (list.map (list.map symbol.terminal) v.reverse)).join],
split,
{
rw list.reverse_reverse,
refl,
},
{
refl, -- binds the implicit argument of `grammar_deri_of_tran_deri`
},
},
rw list.nil_append,
rw v_reverse,
have final_step :
grammar_transforms (star_grammar g)
(list.map symbol.terminal w.join ++ [R, H])
(list.map symbol.terminal w.join),
{
use (star_grammar g).rules.nth_le 3 (by dec_trivial),
split_ile,
use [list.map symbol.terminal w.join, list.nil],
split,
{
trim,
},
{
have out_nil : ((star_grammar g).rules.nth_le 3 _).output_string = [],
{
refl,
},
rw [list.append_nil, out_nil, list.append_nil],
},
},
apply grammar_deri_of_deri_tran _ final_step,
convert_to
grammar_derives (star_grammar g)
([R] ++ ([H] ++ (list.map (++ [H]) (list.map (list.map symbol.terminal) w)).join))
(list.map symbol.terminal w.join ++ [R, H]),
have rebracket :
[H] ++ (list.map (++ [H]) (list.map (list.map symbol.terminal) w)).join =
(list.map (λ v, [H] ++ v) (list.map (list.map symbol.terminal) w)).join ++ [H],
{
apply list.append_join_append,
},
rw rebracket,
apply terminal_scan_aux,
intros v vin t tin,
rw ←list.mem_reverse at vin,
exact terminated v vin t tin,
},
end
|
26de8b66620979f04d129883763cac33bededa52 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /src/Lean/Elab/Command.lean | 4cb79e5c5db0e3c3c1bea4772006661a8bf6d4fd | [
"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 | 21,333 | 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.Elab.Binders
import Lean.Elab.SyntheticMVars
namespace Lean.Elab.Command
structure Scope where
header : String
opts : Options := {}
currNamespace : Name := Name.anonymous
openDecls : List OpenDecl := []
levelNames : List Name := []
/-- section variables -/
varDecls : Array (TSyntax ``Parser.Term.bracketedBinder) := #[]
/-- Globally unique internal identifiers for the `varDecls` -/
varUIds : Array Name := #[]
/-- noncomputable sections automatically add the `noncomputable` modifier to any declaration we cannot generate code for. -/
isNoncomputable : Bool := false
deriving Inhabited
structure State where
env : Environment
messages : MessageLog := {}
scopes : List Scope := [{ header := "" }]
nextMacroScope : Nat := firstFrontendMacroScope + 1
maxRecDepth : Nat
nextInstIdx : Nat := 1 -- for generating anonymous instance names
ngen : NameGenerator := {}
infoState : InfoState := {}
traceState : TraceState := {}
deriving Nonempty
structure Context where
fileName : String
fileMap : FileMap
currRecDepth : Nat := 0
cmdPos : String.Pos := 0
macroStack : MacroStack := []
currMacroScope : MacroScope := firstFrontendMacroScope
ref : Syntax := Syntax.missing
tacticCache? : Option (IO.Ref Tactic.Cache)
abbrev CommandElabCoreM (ε) := ReaderT Context $ StateRefT State $ EIO ε
abbrev CommandElabM := CommandElabCoreM Exception
abbrev CommandElab := Syntax → CommandElabM Unit
structure Linter where
run : Syntax → CommandElabM Unit
name : Name := by exact decl_name%
/-
Make the compiler generate specialized `pure`/`bind` so we do not have to optimize through the
whole monad stack at every use site. May eventually be covered by `deriving`.
Remark: see comment at TermElabM
-/
@[always_inline]
instance : Monad CommandElabM := let i := inferInstanceAs (Monad CommandElabM); { pure := i.pure, bind := i.bind }
def mkState (env : Environment) (messages : MessageLog := {}) (opts : Options := {}) : State := {
env := env
messages := messages
scopes := [{ header := "", opts := opts }]
maxRecDepth := maxRecDepth.get opts
}
/- Linters should be loadable as plugins, so store in a global IO ref instead of an attribute managed by the
environment (which only contains `import`ed objects). -/
builtin_initialize lintersRef : IO.Ref (Array Linter) ← IO.mkRef #[]
builtin_initialize registerTraceClass `Elab.lint
def addLinter (l : Linter) : IO Unit := do
let ls ← lintersRef.get
lintersRef.set (ls.push l)
instance : MonadInfoTree CommandElabM where
getInfoState := return (← get).infoState
modifyInfoState f := modify fun s => { s with infoState := f s.infoState }
instance : MonadEnv CommandElabM where
getEnv := do pure (← get).env
modifyEnv f := modify fun s => { s with env := f s.env }
@[always_inline]
instance : MonadOptions CommandElabM where
getOptions := do pure (← get).scopes.head!.opts
protected def getRef : CommandElabM Syntax :=
return (← read).ref
instance : AddMessageContext CommandElabM where
addMessageContext := addMessageContextPartial
instance : MonadRef CommandElabM where
getRef := Command.getRef
withRef ref x := withReader (fun ctx => { ctx with ref := ref }) x
instance : MonadTrace CommandElabM where
getTraceState := return (← get).traceState
modifyTraceState f := modify fun s => { s with traceState := f s.traceState }
instance : AddErrorMessageContext CommandElabM where
add ref msg := do
let ctx ← read
let ref := getBetterRef ref ctx.macroStack
let msg ← addMessageContext msg
let msg ← addMacroStack msg ctx.macroStack
return (ref, msg)
def mkMessageAux (ctx : Context) (ref : Syntax) (msgData : MessageData) (severity : MessageSeverity) : Message :=
let pos := ref.getPos?.getD ctx.cmdPos
let endPos := ref.getTailPos?.getD pos
mkMessageCore ctx.fileName ctx.fileMap msgData severity pos endPos
private def mkCoreContext (ctx : Context) (s : State) (heartbeats : Nat) : Core.Context :=
let scope := s.scopes.head!
{ fileName := ctx.fileName
fileMap := ctx.fileMap
options := scope.opts
currRecDepth := ctx.currRecDepth
maxRecDepth := s.maxRecDepth
ref := ctx.ref
currNamespace := scope.currNamespace
openDecls := scope.openDecls
initHeartbeats := heartbeats
currMacroScope := ctx.currMacroScope }
private def addTraceAsMessagesCore (ctx : Context) (log : MessageLog) (traceState : TraceState) : MessageLog := Id.run do
if traceState.traces.isEmpty then return log
let mut traces : HashMap (String.Pos × String.Pos) (Array MessageData) := ∅
for traceElem in traceState.traces do
let ref := replaceRef traceElem.ref ctx.ref
let pos := ref.getPos?.getD 0
let endPos := ref.getTailPos?.getD pos
traces := traces.insert (pos, endPos) <| traces.findD (pos, endPos) #[] |>.push traceElem.msg
let mut log := log
let traces' := traces.toArray.qsort fun ((a, _), _) ((b, _), _) => a < b
for ((pos, endPos), traceMsg) in traces' do
log := log.add <| mkMessageCore ctx.fileName ctx.fileMap (.joinSep traceMsg.toList "\n") .information pos endPos
return log
private def addTraceAsMessages : CommandElabM Unit := do
let ctx ← read
modify fun s => { s with
messages := addTraceAsMessagesCore ctx s.messages s.traceState
traceState.traces := {}
}
def liftCoreM (x : CoreM α) : CommandElabM α := do
let s ← get
let ctx ← read
let heartbeats ← IO.getNumHeartbeats
let Eα := Except Exception α
let x : CoreM Eα := try let a ← x; pure <| Except.ok a catch ex => pure <| Except.error ex
let x : EIO Exception (Eα × Core.State) := (ReaderT.run x (mkCoreContext ctx s heartbeats)).run { env := s.env, ngen := s.ngen, traceState := s.traceState, messages := {}, infoState.enabled := s.infoState.enabled }
let (ea, coreS) ← liftM x
modify fun s => { s with
env := coreS.env
ngen := coreS.ngen
messages := s.messages ++ coreS.messages
traceState.traces := coreS.traceState.traces.map fun t => { t with ref := replaceRef t.ref ctx.ref }
infoState.trees := s.infoState.trees.append coreS.infoState.trees
}
match ea with
| Except.ok a => pure a
| Except.error e => throw e
private def ioErrorToMessage (ctx : Context) (ref : Syntax) (err : IO.Error) : Message :=
let ref := getBetterRef ref ctx.macroStack
mkMessageAux ctx ref (toString err) MessageSeverity.error
@[inline] def liftEIO {α} (x : EIO Exception α) : CommandElabM α := liftM x
@[inline] def liftIO {α} (x : IO α) : CommandElabM α := do
let ctx ← read
IO.toEIO (fun (ex : IO.Error) => Exception.error ctx.ref ex.toString) x
instance : MonadLiftT IO CommandElabM where
monadLift := liftIO
def getScope : CommandElabM Scope := do pure (← get).scopes.head!
instance : MonadResolveName CommandElabM where
getCurrNamespace := return (← getScope).currNamespace
getOpenDecls := return (← getScope).openDecls
instance : MonadLog CommandElabM where
getRef := getRef
getFileMap := return (← read).fileMap
getFileName := return (← read).fileName
hasErrors := return (← get).messages.hasErrors
logMessage msg := do
let currNamespace ← getCurrNamespace
let openDecls ← getOpenDecls
let msg := { msg with data := MessageData.withNamingContext { currNamespace := currNamespace, openDecls := openDecls } msg.data }
modify fun s => { s with messages := s.messages.add msg }
def runLinters (stx : Syntax) : CommandElabM Unit := do
profileitM Exception "linting" (← getOptions) do
withTraceNode `Elab.lint (fun _ => return m!"running linters") do
let linters ← lintersRef.get
unless linters.isEmpty do
for linter in linters do
withTraceNode `Elab.lint (fun _ => return m!"running linter: {linter.name}") do
let savedState ← get
try
linter.run stx
catch ex =>
logException ex
finally
modify fun s => { savedState with messages := s.messages }
protected def getCurrMacroScope : CommandElabM Nat := do pure (← read).currMacroScope
protected def getMainModule : CommandElabM Name := do pure (← getEnv).mainModule
protected def withFreshMacroScope {α} (x : CommandElabM α) : CommandElabM α := do
let fresh ← modifyGet (fun st => (st.nextMacroScope, { st with nextMacroScope := st.nextMacroScope + 1 }))
withReader (fun ctx => { ctx with currMacroScope := fresh }) x
instance : MonadQuotation CommandElabM where
getCurrMacroScope := Command.getCurrMacroScope
getMainModule := Command.getMainModule
withFreshMacroScope := Command.withFreshMacroScope
unsafe def mkCommandElabAttributeUnsafe (ref : Name) : IO (KeyedDeclsAttribute CommandElab) :=
mkElabAttribute CommandElab `builtin_command_elab `command_elab `Lean.Parser.Command `Lean.Elab.Command.CommandElab "command" ref
@[implemented_by mkCommandElabAttributeUnsafe]
opaque mkCommandElabAttribute (ref : Name) : IO (KeyedDeclsAttribute CommandElab)
builtin_initialize commandElabAttribute : KeyedDeclsAttribute CommandElab ← mkCommandElabAttribute decl_name%
private def mkInfoTree (elaborator : Name) (stx : Syntax) (trees : PersistentArray InfoTree) : CommandElabM InfoTree := do
let ctx ← read
let s ← get
let scope := s.scopes.head!
let tree := InfoTree.node (Info.ofCommandInfo { elaborator, stx }) trees
return InfoTree.context {
env := s.env, fileMap := ctx.fileMap, mctx := {}, currNamespace := scope.currNamespace,
openDecls := scope.openDecls, options := scope.opts, ngen := s.ngen
} tree
private def elabCommandUsing (s : State) (stx : Syntax) : List (KeyedDeclsAttribute.AttributeEntry CommandElab) → CommandElabM Unit
| [] => withInfoTreeContext (mkInfoTree := mkInfoTree `no_elab stx) <| throwError "unexpected syntax{indentD stx}"
| (elabFn::elabFns) =>
catchInternalId unsupportedSyntaxExceptionId
(withInfoTreeContext (mkInfoTree := mkInfoTree elabFn.declName stx) <| elabFn.value stx)
(fun _ => do set s; elabCommandUsing s stx elabFns)
/-- Elaborate `x` with `stx` on the macro stack -/
def withMacroExpansion {α} (beforeStx afterStx : Syntax) (x : CommandElabM α) : CommandElabM α :=
withInfoContext (mkInfo := pure <| .ofMacroExpansionInfo { stx := beforeStx, output := afterStx, lctx := .empty }) do
withReader (fun ctx => { ctx with macroStack := { before := beforeStx, after := afterStx } :: ctx.macroStack }) x
instance : MonadMacroAdapter CommandElabM where
getCurrMacroScope := getCurrMacroScope
getNextMacroScope := return (← get).nextMacroScope
setNextMacroScope next := modify fun s => { s with nextMacroScope := next }
instance : MonadRecDepth CommandElabM where
withRecDepth d x := withReader (fun ctx => { ctx with currRecDepth := d }) x
getRecDepth := return (← read).currRecDepth
getMaxRecDepth := return (← get).maxRecDepth
register_builtin_option showPartialSyntaxErrors : Bool := {
defValue := false
descr := "show elaboration errors from partial syntax trees (i.e. after parser recovery)"
}
builtin_initialize registerTraceClass `Elab.command
partial def elabCommand (stx : Syntax) : CommandElabM Unit := do
withLogging <| withRef stx <| withIncRecDepth <| withFreshMacroScope do
match stx with
| Syntax.node _ k args =>
if k == nullKind then
-- list of commands => elaborate in order
-- The parser will only ever return a single command at a time, but syntax quotations can return multiple ones
args.forM elabCommand
else withTraceNode `Elab.command (fun _ => return stx) do
let s ← get
match (← liftMacroM <| expandMacroImpl? s.env stx) with
| some (decl, stxNew?) =>
withInfoTreeContext (mkInfoTree := mkInfoTree decl stx) do
let stxNew ← liftMacroM <| liftExcept stxNew?
withMacroExpansion stx stxNew do
elabCommand stxNew
| _ =>
match commandElabAttribute.getEntries s.env k with
| [] =>
withInfoTreeContext (mkInfoTree := mkInfoTree `no_elab stx) <|
throwError "elaboration function for '{k}' has not been implemented"
| elabFns => elabCommandUsing s stx elabFns
| _ =>
withInfoTreeContext (mkInfoTree := mkInfoTree `no_elab stx) <|
throwError "unexpected command"
builtin_initialize registerTraceClass `Elab.input
/--
`elabCommand` wrapper that should be used for the initial invocation, not for recursive calls after
macro expansion etc.
-/
def elabCommandTopLevel (stx : Syntax) : CommandElabM Unit := withRef stx do profileitM Exception "elaboration" (← getOptions) do
let initMsgs ← modifyGet fun st => (st.messages, { st with messages := {} })
let initInfoTrees ← getResetInfoTrees
-- We should *not* factor out `elabCommand`'s `withLogging` to here since it would make its error
-- recovery more coarse. In particular, If `c` in `set_option ... in $c` fails, the remaining
-- `end` command of the `in` macro would be skipped and the option would be leaked to the outside!
elabCommand stx
withLogging do
runLinters stx
-- note the order: first process current messages & info trees, then add back old messages & trees,
-- then convert new traces to messages
let mut msgs := (← get).messages
-- `stx.hasMissing` should imply `initMsgs.hasErrors`, but the latter should be cheaper to check in general
if !showPartialSyntaxErrors.get (← getOptions) && initMsgs.hasErrors && stx.hasMissing then
-- discard elaboration errors, except for a few important and unlikely misleading ones, on parse error
msgs := ⟨msgs.msgs.filter fun msg =>
msg.data.hasTag (fun tag => tag == `Elab.synthPlaceholder || tag == `Tactic.unsolvedGoals || (`_traceMsg).isSuffixOf tag)⟩
for tree in (← getInfoTrees) do
trace[Elab.info] (← tree.format)
modify fun st => { st with
messages := initMsgs ++ msgs
infoState := { st.infoState with trees := initInfoTrees ++ st.infoState.trees }
}
addTraceAsMessages
/-- Adapt a syntax transformation to a regular, command-producing elaborator. -/
def adaptExpander (exp : Syntax → CommandElabM Syntax) : CommandElab := fun stx => do
let stx' ← exp stx
withMacroExpansion stx stx' <| elabCommand stx'
private def getVarDecls (s : State) : Array Syntax :=
s.scopes.head!.varDecls
instance {α} : Inhabited (CommandElabM α) where
default := throw default
private def mkMetaContext : Meta.Context := {
config := { foApprox := true, ctxApprox := true, quasiPatternApprox := true }
}
open Lean.Parser.Term in
/-- Return identifier names in the given bracketed binder. -/
def getBracketedBinderIds : Syntax → Array Name
| `(bracketedBinderF|($ids* $[: $ty?]? $(_annot?)?)) => ids.map Syntax.getId
| `(bracketedBinderF|{$ids* $[: $ty?]?}) => ids.map Syntax.getId
| `(bracketedBinderF|[$id : $_]) => #[id.getId]
| `(bracketedBinderF|[$_]) => #[Name.anonymous]
| _ => #[]
private def mkTermContext (ctx : Context) (s : State) : Term.Context := Id.run do
let scope := s.scopes.head!
let mut sectionVars := {}
for id in scope.varDecls.concatMap getBracketedBinderIds, uid in scope.varUIds do
sectionVars := sectionVars.insert id uid
{ macroStack := ctx.macroStack
sectionVars := sectionVars
isNoncomputableSection := scope.isNoncomputable
tacticCache? := ctx.tacticCache? }
/--
Lift the `TermElabM` monadic action `x` into a `CommandElabM` monadic action.
Note that `x` is executed with an empty message log. Thus, `x` cannot modify/view messages produced by
previous commands.
If you need to access the free variables corresponding to the ones declared using the `variable` command,
consider using `runTermElabM`.
Recall that `TermElabM` actions can automatically lift `MetaM` and `CoreM` actions.
Example:
```
import Lean
open Lean Elab Command Meta
def printExpr (e : Expr) : MetaM Unit := do
IO.println s!"{← ppExpr e} : {← ppExpr (← inferType e)}"
#eval
liftTermElabM do
printExpr (mkConst ``Nat)
```
-/
def liftTermElabM (x : TermElabM α) : CommandElabM α := do
let ctx ← read
let s ← get
let heartbeats ← IO.getNumHeartbeats
-- dbg_trace "heartbeats: {heartbeats}"
let scope := s.scopes.head!
-- We execute `x` with an empty message log. Thus, `x` cannot modify/view messages produced by previous commands.
-- This is useful for implementing `runTermElabM` where we use `Term.resetMessageLog`
let x : TermElabM _ := withSaveInfoContext x
let x : MetaM _ := (observing x).run (mkTermContext ctx s) { levelNames := scope.levelNames }
let x : CoreM _ := x.run mkMetaContext {}
let x : EIO _ _ := x.run (mkCoreContext ctx s heartbeats) { env := s.env, ngen := s.ngen, nextMacroScope := s.nextMacroScope, infoState.enabled := s.infoState.enabled, traceState := s.traceState }
let (((ea, _), _), coreS) ← liftEIO x
modify fun s => { s with
env := coreS.env
nextMacroScope := coreS.nextMacroScope
ngen := coreS.ngen
infoState.trees := s.infoState.trees.append coreS.infoState.trees
traceState.traces := coreS.traceState.traces.map fun t => { t with ref := replaceRef t.ref ctx.ref }
messages := s.messages ++ coreS.messages
}
match ea with
| Except.ok a => pure a
| Except.error ex => throw ex
/--
Execute the monadic action `elabFn xs` as a `CommandElabM` monadic action, where `xs` are free variables
corresponding to all active scoped variables declared using the `variable` command.
This method is similar to `liftTermElabM`, but it elaborates all scoped variables declared using the `variable`
command.
Example:
```
import Lean
open Lean Elab Command Meta
variable {α : Type u} {f : α → α}
variable (n : Nat)
#eval
runTermElabM fun xs => do
for x in xs do
IO.println s!"{← ppExpr x} : {← ppExpr (← inferType x)}"
```
-/
def runTermElabM (elabFn : Array Expr → TermElabM α) : CommandElabM α := do
let scope ← getScope
liftTermElabM <|
Term.withAutoBoundImplicit <|
Term.elabBinders scope.varDecls fun xs => do
-- We need to synthesize postponed terms because this is a checkpoint for the auto-bound implicit feature
-- If we don't use this checkpoint here, then auto-bound implicits in the postponed terms will not be handled correctly.
Term.synthesizeSyntheticMVarsNoPostponing
let mut sectionFVars := {}
for uid in scope.varUIds, x in xs do
sectionFVars := sectionFVars.insert uid x
withReader ({ · with sectionFVars := sectionFVars }) do
-- We don't want to store messages produced when elaborating `(getVarDecls s)` because they have already been saved when we elaborated the `variable`(s) command.
-- So, we use `Core.resetMessageLog`.
Core.resetMessageLog
let someType := mkSort levelZero
Term.addAutoBoundImplicits' xs someType fun xs _ =>
Term.withoutAutoBoundImplicit <| elabFn xs
@[inline] def catchExceptions (x : CommandElabM Unit) : CommandElabCoreM Empty Unit := fun ctx ref =>
EIO.catchExceptions (withLogging x ctx ref) (fun _ => pure ())
private def liftAttrM {α} (x : AttrM α) : CommandElabM α := do
liftCoreM x
def getScopes : CommandElabM (List Scope) := do
pure (← get).scopes
def modifyScope (f : Scope → Scope) : CommandElabM Unit :=
modify fun s => { s with
scopes := match s.scopes with
| h::t => f h :: t
| [] => unreachable!
}
def withScope (f : Scope → Scope) (x : CommandElabM α) : CommandElabM α := do
match (← get).scopes with
| [] => x
| h :: t =>
try
modify fun s => { s with scopes := f h :: t }
x
finally
modify fun s => { s with scopes := h :: t }
def getLevelNames : CommandElabM (List Name) :=
return (← getScope).levelNames
def addUnivLevel (idStx : Syntax) : CommandElabM Unit := withRef idStx do
let id := idStx.getId
let levelNames ← getLevelNames
if levelNames.elem id then
throwAlreadyDeclaredUniverseLevel id
else
modifyScope fun scope => { scope with levelNames := id :: scope.levelNames }
def expandDeclId (declId : Syntax) (modifiers : Modifiers) : CommandElabM ExpandDeclIdResult := do
let currNamespace ← getCurrNamespace
let currLevelNames ← getLevelNames
let r ← Elab.expandDeclId currNamespace currLevelNames declId modifiers
for id in (← getScope).varDecls.concatMap getBracketedBinderIds do
if id == r.shortName then
throwError "invalid declaration name '{r.shortName}', there is a section variable with the same name"
return r
end Elab.Command
export Elab.Command (Linter addLinter)
end Lean
|
2ffd578f3aa8605a22db9ecb3fa97160ff7ab550 | a6f55abce20abcd06e718cb3e5fba7bf8a230fa1 | /topic/animal.lean | 776c7d39e0737be0dbf2a2d572c46f1eb3e130aa | [] | no_license | sonna0909/abc | b8a53e906d4d000d1f2347173a1cd4221757fabf | ff7b4c621cdf6d53937f2d1b6def28de2085a2aa | refs/heads/master | 1,599,114,664,248 | 1,573,634,309,000 | 1,573,634,309,000 | 219,406,484 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 6,987 | lean | [
{
"key": "chicken",
"title": "Chicken",
"spelling": "/'tʃikin/",
"subs": [
{
"key": "chicken1",
"title": "This is the chicken",
"spelling": ""
}
]
},
{
"key": "duck",
"title": "Duck",
"spelling": "/dʌk/",
"subs": [
{
"key": "duck1",
"title": "That is the duck",
"spelling": ""
}
]
},
{
"key": "fish",
"title": "Fish",
"spelling": "/fiʃ/",
"subs": [
{
"key": "3_fishes",
"title": "There are 3 fishes ",
"spelling": ""
}
]
},
{
"key": "bear",
"title": "Bear",
"spelling": "/beər/",
"subs": [
{
"key": "bear1",
"title": "This is the bear",
"spelling": ""
}
]
},
{
"key": "elephant",
"title": "Elephant",
"spelling": "/ˈelɪfənt/",
"subs": [
{
"key": "elephant1",
"title": "This is the elephant",
"spelling": ""
}
]
},
{
"key": "fox",
"title": "Fox",
"spelling": "/fɑːks/",
"subs": [
{
"key": "fox1",
"title": "That is the fox",
"spelling": ""
}
]
},
{
"key": "giraffe",
"title": "Giraffe",
"spelling": "/dʒə.ˈræf/",
"subs": [
{
"key": "giraffe1",
"title": "This is the giraffe",
"spelling": ""
}
]
},
{
"key": "hippopotamus",
"title": "Hippopotamus",
"spelling": "/ˌhɪpəˈpɑːtəməs/",
"subs": [
{
"key": "hippopotamus1",
"title": "This is the hippopotamus",
"spelling": ""
}
]
},
{
"key": "jaguar",
"title": "Jaguar",
"spelling": "/ˈdʒæɡjuər/",
"subs": [
{
"key": "2_jaguars",
"title": "There are 2 jaguars",
"spelling": ""
}
]
},
{
"key": "lion",
"title": "Lion",
"spelling": "/ˈlaɪən/",
"subs": [
{
"key": "lion1",
"title": "The lion is dancing",
"spelling": ""
}
]
},
{
"key": "porcupine",
"title": "Porcupine",
"spelling": "/ˈpɔːrkjupaɪn/",
"subs": [
{
"key": "porcupine1",
"title": "The porcupine is eating",
"spelling": ""
}
]
},
{
"key": "raccoon",
"title": "Raccoon",
"spelling": "/rækˈuːn/",
"subs": [
{
"key": "raccoon1",
"title": "There is the raccoon",
"spelling": ""
}
]
},
{
"key": "rhinoceros",
"title": "Rhinoceros",
"spelling": "/raɪˈnɒsərəs/",
"subs": [
{
"key": "rhinoceros1",
"title": "That is the rhinoceros",
"spelling": ""
}
]
},
{
"key": "squirrel",
"title": "Squirrel",
"spelling": "/ˈskwɜːrəl/",
"subs": [
{
"key": "squirrel1",
"title": "The squirrel is running",
"spelling": ""
}
]
},
{
"key": "alligator",
"title": "Alligator",
"spelling": "/ˈælɪɡeɪtər/",
"subs": [
{
"key": "alligator1",
"title": "This is the alligator",
"spelling": ""
}
]
},
{
"key": "bat",
"title": "Bat",
"spelling": "/bæt/",
"subs": [
{
"key": "bat1",
"title": "The bat is flying",
"spelling": ""
}
]
},
{
"key": "deer",
"title": "Deer",
"spelling": "/dɪər/",
"subs": [
{
"key": "3_deers",
"title": "There are 3 deers in the zoo",
"spelling": ""
}
]
},
{
"key": "wolf",
"title": "Wolf",
"spelling": "/wʊlf/",
"subs": [
{
"key": "wolf1",
"title": "The wolf is running",
"spelling": ""
}
]
},
{
"key": "dolphin",
"title": "Dolphin",
"spelling": "/ˈdɒlfɪn/",
"subs": [
{
"key": "dolphin1",
"title": "That is the dolphin",
"spelling": ""
}
]
},
{
"key": "shark",
"title": "Shark",
"spelling": "/ʃɑːk/",
"subs": [
{
"key": "shark1",
"title": "This is the shark",
"spelling": ""
}
]
},
{
"key": "penguin",
"title": "Penguin",
"spelling": "/ˈpeŋɡwɪn/",
"subs": [
{
"key": "10_penguins",
"title": "There are 10 penguins in desert",
"spelling": ""
}
]
},
{
"key": "turtle",
"title": "Turtle",
"spelling": "/ˈtɜːtl/",
"subs": [
{
"key": "turtle1",
"title": "The turtle is crawling ",
"spelling": ""
}
]
},
{
"key": "bee",
"title": "Bee",
"spelling": "/biː/",
"subs": [
{
"key": "bee1",
"title": "The bee is flying",
"spelling": ""
}
]
},
{
"key": "snake",
"title": "Snake",
"spelling": "/sneik/",
"subs": [
{
"key": "snake1",
"title": "The snake is crawling ",
"spelling": ""
}
]
},
{
"key": "camel",
"title": "Camel",
"spelling": "/ˈkæməl/",
"subs": [
{
"key": "camel1",
"title": "The camel is eating grass",
"spelling": ""
}
]
},
{
"key": "scorpion",
"title": "Scorpion",
"spelling": "/ˈskɔːrpiən/",
"subs": [
{
"key": "scorpionl",
"title": "This is the scorpion",
"spelling": ""
}
]
},
{
"key": "zebra",
"title": "Zebra",
"spelling": "/ˈzebrə/",
"subs": [
{
"key": "zebral1",
"title": "The zebral is grazing",
"spelling": ""
}
]
},
{
"key": "cow",
"title": "Cow",
"spelling": "/kaʊ/",
"subs": [
{
"key": "cow1",
"title": "The cow is grazing",
"spelling": ""
}
]
},
{
"key": "buffalo",
"title": "Buffalo",
"spelling": "/'bʌfəlou/",
"subs": [
{
"key": "3_buffalos",
"title": "There are 3 buffalos in the field ",
"spelling": ""
}
]
},
{
"key": "octopus",
"title": "Octopus",
"spelling": "/ˈɑːktəpəs/",
"subs": [
{
"key": "octopus1",
"title": "This is the octopus",
"spelling": ""
}
]
},
{
"key": "pufferfish",
"title": "pufferfish",
"spelling": "/ˈpʌfərfɪʃ/",
"subs": [
{
"key": "pufferfish1",
"title": "",
"spelling": ""
}
]
},
{
"key": "squid",
"title": "Squid",
"spelling": "/skwɪd/",
"subs": [
{
"key": "squid1",
"title": "That is the squid",
"spelling": ""
}
]
},
{
"key": "starfish",
"title": "Starfish",
"spelling": "/ˈstɑːrfɪʃ/",
"subs": [
{
"key": "starfish1",
"title": "This is starfish",
"spelling": ""
}
]
}
]
|
b35d1d01f58c1b67a6930fd831b5e3d10884c925 | dc06cc9775d64d571bf4778459ec6fde1f344116 | /src/set_theory/ordinal.lean | 6225820dc4de4ac3393069ae762141953c33e245 | [
"Apache-2.0"
] | permissive | mgubi/mathlib | 8c1ea39035776ad52cf189a7af8cc0eee7dea373 | 7c09ed5eec8434176fbc493e0115555ccc4c8f99 | refs/heads/master | 1,642,222,572,514 | 1,563,782,424,000 | 1,563,782,424,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 128,820 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
Ordinal arithmetic.
Ordinals are defined as equivalences of well-ordered sets by order isomorphism.
-/
import order.order_iso set_theory.cardinal data.sum
noncomputable theory
open function cardinal set
local attribute [instance] classical.prop_decidable
universes u v w
variables {α : Type*} {β : Type*} {γ : Type*}
{r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
structure initial_seg {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) extends r ≼o s :=
(init : ∀ a b, s b (to_order_embedding a) → ∃ a', to_order_embedding a' = b)
local infix ` ≼i `:25 := initial_seg
namespace initial_seg
instance : has_coe (r ≼i s) (r ≼o s) := ⟨initial_seg.to_order_embedding⟩
@[simp] theorem coe_fn_mk (f : r ≼o s) (o) :
(@initial_seg.mk _ _ r s f o : α → β) = f := rfl
@[simp] theorem coe_fn_to_order_embedding (f : r ≼i s) : (f.to_order_embedding : α → β) = f := rfl
theorem coe_coe_fn (f : r ≼i s) : ((f : r ≼o s) : α → β) = f := rfl
theorem init' (f : r ≼i s) {a : α} {b : β} : s b (f a) → ∃ a', f a' = b :=
f.init _ _
theorem init_iff (f : r ≼i s) {a : α} {b : β} : s b (f a) ↔ ∃ a', f a' = b ∧ r a' a :=
⟨λ h, let ⟨a', e⟩ := f.init' h in ⟨a', e, (f : r ≼o s).ord'.2 (e.symm ▸ h)⟩,
λ ⟨a', e, h⟩, e ▸ (f : r ≼o s).ord'.1 h⟩
/-- An order isomorphism is an initial segment -/
def of_iso (f : r ≃o s) : r ≼i s :=
⟨f, λ a b h, ⟨f.symm b, order_iso.apply_symm_apply f _⟩⟩
@[refl] protected def refl (r : α → α → Prop) : r ≼i r :=
⟨order_embedding.refl _, λ a b h, ⟨_, rfl⟩⟩
@[trans] protected def trans (f : r ≼i s) (g : s ≼i t) : r ≼i t :=
⟨f.1.trans g.1, λ a c h, begin
simp at h ⊢,
rcases g.2 _ _ h with ⟨b, rfl⟩, have h := g.1.ord'.2 h,
rcases f.2 _ _ h with ⟨a', rfl⟩, exact ⟨a', rfl⟩
end⟩
@[simp] theorem of_iso_apply (f : r ≃o s) (x : α) : of_iso f x = f x := rfl
@[simp] theorem refl_apply (x : α) : initial_seg.refl r x = x := rfl
@[simp] theorem trans_apply (f : r ≼i s) (g : s ≼i t) (a : α) : (f.trans g) a = g (f a) := rfl
theorem unique_of_extensional [is_extensional β s] :
well_founded r → subsingleton (r ≼i s) | ⟨h⟩ :=
⟨λ f g, begin
suffices : (f : α → β) = g, { cases f, cases g,
congr, exact order_embedding.eq_of_to_fun_eq this },
funext a, have := h a, induction this with a H IH,
refine @is_extensional.ext _ s _ _ _ (λ x, ⟨λ h, _, λ h, _⟩),
{ rcases f.init_iff.1 h with ⟨y, rfl, h'⟩,
rw IH _ h', exact (g : r ≼o s).ord'.1 h' },
{ rcases g.init_iff.1 h with ⟨y, rfl, h'⟩,
rw ← IH _ h', exact (f : r ≼o s).ord'.1 h' }
end⟩
instance [is_well_order β s] : subsingleton (r ≼i s) :=
⟨λ a, @subsingleton.elim _ (unique_of_extensional
(@order_embedding.well_founded _ _ r s a (is_well_order.wf s))) a⟩
protected theorem eq [is_well_order β s] (f g : r ≼i s) (a) : f a = g a :=
by rw subsingleton.elim f g
theorem antisymm.aux [is_well_order α r] (f : r ≼i s) (g : s ≼i r) : left_inverse g f :=
initial_seg.eq (f.trans g) (initial_seg.refl _)
def antisymm [is_well_order β s] (f : r ≼i s) (g : s ≼i r) : r ≃o s :=
by haveI := f.to_order_embedding.is_well_order; exact
⟨⟨f, g, antisymm.aux f g, antisymm.aux g f⟩, f.ord⟩
@[simp] theorem antisymm_to_fun [is_well_order β s]
(f : r ≼i s) (g : s ≼i r) : (antisymm f g : α → β) = f := rfl
@[simp] theorem antisymm_symm [is_well_order α r] [is_well_order β s]
(f : r ≼i s) (g : s ≼i r) : (antisymm f g).symm = antisymm g f :=
order_iso.eq_of_to_fun_eq rfl
theorem eq_or_principal [is_well_order β s] (f : r ≼i s) : surjective f ∨ ∃ b, ∀ x, s x b ↔ ∃ y, f y = x :=
or_iff_not_imp_right.2 $ λ h b,
acc.rec_on ((is_well_order.wf s).apply b) $ λ x H IH,
not_forall_not.1 $ λ hn,
h ⟨x, λ y, ⟨(IH _), λ ⟨a, e⟩, by rw ← e; exact
(trichotomous _ _).resolve_right
(not_or (hn a) (λ hl, not_exists.2 hn (f.init' hl)))⟩⟩
/-- Restrict the codomain of an initial segment -/
def cod_restrict (p : set β) (f : r ≼i s) (H : ∀ a, f a ∈ p) : r ≼i subrel s p :=
⟨order_embedding.cod_restrict p f H, λ a ⟨b, m⟩ (h : s b (f a)),
let ⟨a', e⟩ := f.init' h in ⟨a', by clear _let_match; subst e; refl⟩⟩
@[simp] theorem cod_restrict_apply (p) (f : r ≼i s) (H a) : cod_restrict p f H a = ⟨f a, H a⟩ := rfl
def le_add (r : α → α → Prop) (s : β → β → Prop) : r ≼i sum.lex r s :=
⟨⟨⟨sum.inl, λ _ _, sum.inl.inj⟩, λ a b, sum.lex_inl_inl.symm⟩,
λ a b, by cases b; [exact λ _, ⟨_, rfl⟩, exact false.elim ∘ sum.lex_inr_inl]⟩
@[simp] theorem le_add_apply (r : α → α → Prop) (s : β → β → Prop)
(a) : le_add r s a = sum.inl a := rfl
end initial_seg
structure principal_seg {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) extends r ≼o s :=
(top : β)
(down : ∀ b, s b top ↔ ∃ a, to_order_embedding a = b)
local infix ` ≺i `:25 := principal_seg
namespace principal_seg
instance : has_coe (r ≺i s) (r ≼o s) := ⟨principal_seg.to_order_embedding⟩
@[simp] theorem coe_fn_mk (f : r ≼o s) (t o) :
(@principal_seg.mk _ _ r s f t o : α → β) = f := rfl
@[simp] theorem coe_fn_to_order_embedding (f : r ≺i s) : (f.to_order_embedding : α → β) = f := rfl
theorem coe_coe_fn (f : r ≺i s) : ((f : r ≼o s) : α → β) = f := rfl
theorem down' (f : r ≺i s) {b : β} : s b f.top ↔ ∃ a, f a = b :=
f.down _
theorem lt_top (f : r ≺i s) (a : α) : s (f a) f.top :=
f.down'.2 ⟨_, rfl⟩
theorem init [is_trans β s] (f : r ≺i s) {a : α} {b : β} (h : s b (f a)) : ∃ a', f a' = b :=
f.down'.1 $ trans h $ f.lt_top _
instance has_coe_initial_seg [is_trans β s] : has_coe (r ≺i s) (r ≼i s) :=
⟨λ f, ⟨f.to_order_embedding, λ a b, f.init⟩⟩
theorem coe_coe_fn' [is_trans β s] (f : r ≺i s) : ((f : r ≼i s) : α → β) = f := rfl
theorem init_iff [is_trans β s] (f : r ≺i s) {a : α} {b : β} : s b (f a) ↔ ∃ a', f a' = b ∧ r a' a :=
initial_seg.init_iff f
theorem irrefl (r : α → α → Prop) [is_well_order α r] (f : r ≺i r) : false :=
begin
have := f.lt_top f.top,
rw [show f f.top = f.top, from
initial_seg.eq ↑f (initial_seg.refl r) f.top] at this,
exact irrefl _ this
end
def lt_le [is_trans β s] (f : r ≺i s) (g : s ≼i t) : r ≺i t :=
⟨@order_embedding.trans _ _ _ r s t f g, g f.top, λ a,
by simp only [g.init_iff, f.down', exists_and_distrib_left.symm,
exists_swap, order_embedding.trans_apply, exists_eq_right']; refl⟩
@[simp] theorem lt_le_apply [is_trans β s] [is_trans γ t] (f : r ≺i s) (g : s ≼i t) (a : α) : (f.lt_le g) a = g (f a) :=
order_embedding.trans_apply _ _ _
@[simp] theorem lt_le_top [is_trans β s] [is_trans γ t] (f : r ≺i s) (g : s ≼i t) : (f.lt_le g).top = g f.top := rfl
@[trans] protected def trans [is_trans β s] [is_trans γ t] (f : r ≺i s) (g : s ≺i t) : r ≺i t :=
lt_le f g
@[simp] theorem trans_apply [is_trans β s] [is_trans γ t] (f : r ≺i s) (g : s ≺i t) (a : α) : (f.trans g) a = g (f a) :=
lt_le_apply _ _ _
@[simp] theorem trans_top [is_trans β s] [is_trans γ t] (f : r ≺i s) (g : s ≺i t) : (f.trans g).top = g f.top := rfl
def equiv_lt [is_trans β s] [is_trans γ t] (f : r ≃o s) (g : s ≺i t) : r ≺i t :=
⟨@order_embedding.trans _ _ _ r s t f g, g.top, λ c,
by simp only [g.down', coe_fn_coe_base, order_embedding.trans_apply]; exact
⟨λ ⟨b, h⟩, ⟨f.symm b, by simp only [h, order_iso.apply_symm_apply, order_iso.coe_coe_fn]⟩, λ ⟨a, h⟩, ⟨f a, h⟩⟩⟩
def lt_equiv {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
[is_trans β s] [is_trans γ t] (f : principal_seg r s) (g : s ≃o t) : principal_seg r t :=
⟨@order_embedding.trans _ _ _ r s t f g, g f.top,
begin
intro x,
rw [←g.right_inv x],
simp only [order_iso.to_equiv_to_fun, coe_fn_coe_base, order_embedding.trans_apply],
rw [←order_iso.ord'' g, f.down', exists_congr],
intro y, exact ⟨congr_arg g, λ h, g.to_equiv.bijective.1 h⟩
end⟩
@[simp] theorem equiv_lt_apply [is_trans β s] [is_trans γ t] (f : r ≃o s) (g : s ≺i t) (a : α) : (equiv_lt f g) a = g (f a) :=
order_embedding.trans_apply _ _ _
@[simp] theorem equiv_lt_top [is_trans β s] [is_trans γ t] (f : r ≃o s) (g : s ≺i t) : (equiv_lt f g).top = g.top := rfl
instance [is_well_order β s] : subsingleton (r ≺i s) :=
⟨λ f g, begin
have ef : (f : α → β) = g,
{ show ((f : r ≼i s) : α → β) = g,
rw @subsingleton.elim _ _ (f : r ≼i s) g, refl },
have et : f.top = g.top,
{ refine @is_extensional.ext _ s _ _ _ (λ x, _),
simp only [f.down, g.down, ef, coe_fn_to_order_embedding] },
cases f, cases g,
have := order_embedding.eq_of_to_fun_eq ef; congr'
end⟩
theorem top_eq [is_well_order β s] [is_well_order γ t]
(e : r ≃o s) (f : r ≺i t) (g : s ≺i t) : f.top = g.top :=
by rw subsingleton.elim f (principal_seg.equiv_lt e g); refl
lemma top_lt_top {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
[is_trans β s] [is_well_order γ t]
(f : principal_seg r s) (g : principal_seg s t) (h : principal_seg r t) : t h.top g.top :=
by { rw [subsingleton.elim h (f.trans g)], apply principal_seg.lt_top }
/-- Any element of a well order yields a principal segment -/
def of_element {α : Type*} (r : α → α → Prop) [is_well_order α r] (a : α) :
subrel r {b | r b a} ≺i r :=
⟨subrel.order_embedding _ _, a, λ b,
⟨λ h, ⟨⟨_, h⟩, rfl⟩, λ ⟨⟨_, h⟩, rfl⟩, h⟩⟩
@[simp] theorem of_element_apply {α : Type*} (r : α → α → Prop) [is_well_order α r] (a : α) (b) :
of_element r a b = b.1 := rfl
@[simp] theorem of_element_top {α : Type*} (r : α → α → Prop) [is_well_order α r] (a : α) :
(of_element r a).top = a := rfl
/-- Restrict the codomain of a principal segment -/
def cod_restrict (p : set β) (f : r ≺i s)
(H : ∀ a, f a ∈ p) (H₂ : f.top ∈ p) : r ≺i subrel s p :=
⟨order_embedding.cod_restrict p f H, ⟨f.top, H₂⟩, λ ⟨b, h⟩,
f.down'.trans $ exists_congr $ λ a,
show (⟨f a, H a⟩ : p).1 = _ ↔ _, from ⟨subtype.eq, congr_arg _⟩⟩
@[simp] theorem cod_restrict_apply (p) (f : r ≺i s) (H H₂ a) : cod_restrict p f H H₂ a = ⟨f a, H a⟩ := rfl
@[simp] theorem cod_restrict_top (p) (f : r ≺i s) (H H₂) : (cod_restrict p f H H₂).top = ⟨f.top, H₂⟩ := rfl
end principal_seg
def initial_seg.lt_or_eq [is_well_order β s] (f : r ≼i s) :
(r ≺i s) ⊕ (r ≃o s) :=
if h : surjective f then sum.inr (order_iso.of_surjective f h) else
have h' : _, from (initial_seg.eq_or_principal f).resolve_left h,
sum.inl ⟨f, classical.some h', classical.some_spec h'⟩
@[simp] theorem initial_seg.lt_or_eq_apply_left [is_well_order β s]
(f : r ≼i s) {g} (h : f.lt_or_eq = sum.inl g) (a : α) : g a = f a :=
begin
unfold initial_seg.lt_or_eq at h,
by_cases sj : surjective f,
{ rw dif_pos sj at h, cases h },
{ rw dif_neg sj at h, cases h, refl }
end
@[simp] theorem initial_seg.lt_or_eq_apply_right [is_well_order β s]
(f : r ≼i s) {g} (h : f.lt_or_eq = sum.inr g) (a : α) : g a = f a :=
begin
unfold initial_seg.lt_or_eq at h,
by_cases sj : surjective f,
{rw dif_pos sj at h, cases h, refl},
{rw dif_neg sj at h, cases h}
end
def initial_seg.le_lt [is_well_order β s] [is_trans γ t] (f : r ≼i s) (g : s ≺i t) : r ≺i t :=
match f.lt_or_eq with
| sum.inl f' := f'.trans g
| sum.inr f' := principal_seg.equiv_lt f' g
end
@[simp] theorem initial_seg.le_lt_apply [is_well_order β s] [is_trans γ t]
(f : r ≼i s) (g : s ≺i t) (a : α) : (f.le_lt g) a = g (f a) :=
begin
delta initial_seg.le_lt, cases h : f.lt_or_eq with f' f',
{ simp only [principal_seg.trans_apply, f.lt_or_eq_apply_left h] },
{ simp only [principal_seg.equiv_lt_apply, f.lt_or_eq_apply_right h] }
end
namespace order_embedding
def collapse_F [is_well_order β s] (f : r ≼o s) : Π a, {b // ¬ s (f a) b} :=
(order_embedding.well_founded f $ is_well_order.wf s).fix $ λ a IH, begin
let S := {b | ∀ a h, s (IH a h).1 b},
have : f a ∈ S, from λ a' h, ((trichotomous _ _)
.resolve_left $ λ h', (IH a' h).2 $ trans (f.ord'.1 h) h')
.resolve_left $ λ h', (IH a' h).2 $ h' ▸ f.ord'.1 h,
exact ⟨(is_well_order.wf s).min S (set.ne_empty_of_mem this),
(is_well_order.wf s).not_lt_min _ _ this⟩
end
theorem collapse_F.lt [is_well_order β s] (f : r ≼o s) {a : α}
: ∀ {a'}, r a' a → s (collapse_F f a').1 (collapse_F f a).1 :=
show (collapse_F f a).1 ∈ {b | ∀ a' (h : r a' a), s (collapse_F f a').1 b}, begin
unfold collapse_F, rw well_founded.fix_eq,
apply well_founded.min_mem _ _
end
theorem collapse_F.not_lt [is_well_order β s] (f : r ≼o s) (a : α)
{b} (h : ∀ a' (h : r a' a), s (collapse_F f a').1 b) : ¬ s b (collapse_F f a).1 :=
begin
unfold collapse_F, rw well_founded.fix_eq,
exact well_founded.not_lt_min _ _ _
(show b ∈ {b | ∀ a' (h : r a' a), s (collapse_F f a').1 b}, from h)
end
/-- Construct an initial segment from an order embedding. -/
def collapse [is_well_order β s] (f : r ≼o s) : r ≼i s :=
by haveI := order_embedding.is_well_order f; exact
⟨order_embedding.of_monotone
(λ a, (collapse_F f a).1) (λ a b, collapse_F.lt f),
λ a b, acc.rec_on ((is_well_order.wf s).apply b) (λ b H IH a h, begin
let S := {a | ¬ s (collapse_F f a).1 b},
have : S ≠ ∅ := set.ne_empty_of_mem (asymm h),
existsi (is_well_order.wf r).min S this,
refine ((@trichotomous _ s _ _ _).resolve_left _).resolve_right _,
{ exact (is_well_order.wf r).min_mem S this },
{ refine collapse_F.not_lt f _ (λ a' h', _),
by_contradiction hn,
exact (is_well_order.wf r).not_lt_min S this hn h' }
end) a⟩
theorem collapse_apply [is_well_order β s] (f : r ≼o s)
(a) : collapse f a = (collapse_F f a).1 := rfl
end order_embedding
section well_ordering_thm
parameter {σ : Type u}
open function
noncomputable lemma embedding_to_cardinal : σ ↪ cardinal.{u} :=
classical.choice $ embedding.total.resolve_left $ λ ⟨⟨f, hf⟩⟩,
let g : σ → cardinal.{u} := inv_fun f in
let ⟨x, (hx : g x = 2 ^ sum g)⟩ := inv_fun_surjective hf (2 ^ sum g) in
have g x ≤ sum g, from le_sum.{u u} g x,
not_le_of_gt (by rw hx; exact cantor _) this
/-- The relation whose existence is given by the well-ordering theorem -/
def well_ordering_rel : σ → σ → Prop := embedding_to_cardinal ⁻¹'o (<)
instance well_ordering_rel.is_well_order : is_well_order σ well_ordering_rel :=
(order_embedding.preimage _ _).is_well_order
end well_ordering_thm
structure Well_order : Type (u+1) :=
(α : Type u)
(r : α → α → Prop)
(wo : is_well_order α r)
attribute [instance] Well_order.wo
instance ordinal.is_equivalent : setoid Well_order :=
{ r := λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≃o s),
iseqv := ⟨λ⟨α, r, _⟩, ⟨order_iso.refl _⟩,
λ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨e⟩, ⟨e.symm⟩,
λ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨e₁⟩ ⟨e₂⟩, ⟨e₁.trans e₂⟩⟩ }
/-- `ordinal.{u}` is the type of well orders in `Type u`,
quotient by order isomorphism. -/
def ordinal : Type (u + 1) := quotient ordinal.is_equivalent
namespace ordinal
/-- The order type of a well order is an ordinal. -/
def type (r : α → α → Prop) [wo : is_well_order α r] : ordinal :=
⟦⟨α, r, wo⟩⟧
/-- The order type of an element inside a well order. -/
def typein (r : α → α → Prop) [is_well_order α r] (a : α) : ordinal :=
type (subrel r {b | r b a})
theorem type_def (r : α → α → Prop) [wo : is_well_order α r] :
@eq ordinal ⟦⟨α, r, wo⟩⟧ (type r) := rfl
@[simp] theorem type_def' (r : α → α → Prop) [is_well_order α r] {wo} :
@eq ordinal ⟦⟨α, r, wo⟩⟧ (type r) := rfl
theorem type_eq {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r = type s ↔ nonempty (r ≃o s) := quotient.eq
@[simp] lemma type_out (o : ordinal) : type o.out.r = o :=
by { refine eq.trans _ (by rw [←quotient.out_eq o]), cases quotient.out o, refl }
@[elab_as_eliminator] theorem induction_on {C : ordinal → Prop}
(o : ordinal) (H : ∀ α r [is_well_order α r], C (type r)) : C o :=
quot.induction_on o $ λ ⟨α, r, wo⟩, @H α r wo
/-- Ordinal less-equal is defined such that
well orders `r` and `s` satisfy `type r ≤ type s` if there exists
a function embedding `r` as an initial segment of `s`. -/
protected def le (a b : ordinal) : Prop :=
quotient.lift_on₂ a b (λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≼i s)) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
propext ⟨
λ ⟨h⟩, ⟨(initial_seg.of_iso f.symm).trans $
h.trans (initial_seg.of_iso g)⟩,
λ ⟨h⟩, ⟨(initial_seg.of_iso f).trans $
h.trans (initial_seg.of_iso g.symm)⟩⟩
instance : has_le ordinal := ⟨ordinal.le⟩
theorem type_le {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r ≤ type s ↔ nonempty (r ≼i s) := iff.rfl
theorem type_le' {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] : type r ≤ type s ↔ nonempty (r ≼o s) :=
⟨λ ⟨f⟩, ⟨f⟩, λ ⟨f⟩, ⟨f.collapse⟩⟩
/-- Ordinal less-than is defined such that
well orders `r` and `s` satisfy `type r < type s` if there exists
a function embedding `r` as a principal segment of `s`. -/
def lt (a b : ordinal) : Prop :=
quotient.lift_on₂ a b (λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≺i s)) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
by exactI propext ⟨
λ ⟨h⟩, ⟨principal_seg.equiv_lt f.symm $
h.lt_le (initial_seg.of_iso g)⟩,
λ ⟨h⟩, ⟨principal_seg.equiv_lt f $
h.lt_le (initial_seg.of_iso g.symm)⟩⟩
instance : has_lt ordinal := ⟨ordinal.lt⟩
@[simp] theorem type_lt {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r < type s ↔ nonempty (r ≺i s) := iff.rfl
instance : partial_order ordinal :=
{ le := (≤),
lt := (<),
le_refl := quot.ind $ by exact λ ⟨α, r, wo⟩, ⟨initial_seg.refl _⟩,
le_trans := λ a b c, quotient.induction_on₃ a b c $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ ⟨g⟩, ⟨f.trans g⟩,
lt_iff_le_not_le := λ a b, quotient.induction_on₂ a b $
λ ⟨α, r, _⟩ ⟨β, s, _⟩, by exactI
⟨λ ⟨f⟩, ⟨⟨f⟩, λ ⟨g⟩, (f.lt_le g).irrefl _⟩,
λ ⟨⟨f⟩, h⟩, sum.rec_on f.lt_or_eq (λ g, ⟨g⟩)
(λ g, (h ⟨initial_seg.of_iso g.symm⟩).elim)⟩,
le_antisymm := λ x b, show x ≤ b → b ≤ x → x = b, from
quotient.induction_on₂ x b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨h₁⟩ ⟨h₂⟩,
by exactI quot.sound ⟨initial_seg.antisymm h₁ h₂⟩ }
def initial_seg_out {α β : ordinal} (h : α ≤ β) : initial_seg α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice
end
def principal_seg_out {α β : ordinal} (h : α < β) : principal_seg α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice
end
def order_iso_out {α β : ordinal} (h : α = β) : order_iso α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice ∘ quotient.exact
end
theorem typein_lt_type (r : α → α → Prop) [is_well_order α r]
(a : α) : typein r a < type r :=
⟨principal_seg.of_element _ _⟩
@[simp] theorem typein_top {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : r ≺i s) :
typein s f.top = type r :=
eq.symm $ quot.sound ⟨order_iso.of_surjective
(order_embedding.cod_restrict _ f f.lt_top)
(λ ⟨a, h⟩, by rcases f.down'.1 h with ⟨b, rfl⟩; exact ⟨b, rfl⟩)⟩
@[simp] theorem typein_apply {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : r ≼i s) (a : α) :
ordinal.typein s (f a) = ordinal.typein r a :=
eq.symm $ quotient.sound ⟨order_iso.of_surjective
(order_embedding.cod_restrict _
((subrel.order_embedding _ _).trans f)
(λ ⟨x, h⟩, by rw [order_embedding.trans_apply]; exact f.to_order_embedding.ord'.1 h))
(λ ⟨y, h⟩, by rcases f.init' h with ⟨a, rfl⟩;
exact ⟨⟨a, f.to_order_embedding.ord'.2 h⟩, subtype.eq $ order_embedding.trans_apply _ _ _⟩)⟩
@[simp] theorem typein_lt_typein (r : α → α → Prop) [is_well_order α r]
{a b : α} : typein r a < typein r b ↔ r a b :=
⟨λ ⟨f⟩, begin
have : f.top.1 = a,
{ let f' := principal_seg.of_element r a,
let g' := f.trans (principal_seg.of_element r b),
have : g'.top = f'.top, {rw subsingleton.elim f' g'},
exact this },
rw ← this, exact f.top.2
end, λ h, ⟨principal_seg.cod_restrict _
(principal_seg.of_element r a)
(λ x, @trans _ r _ _ _ _ x.2 h) h⟩⟩
theorem typein_surj (r : α → α → Prop) [is_well_order α r]
{o} (h : o < type r) : ∃ a, typein r a = o :=
induction_on o (λ β s _ ⟨f⟩, by exactI ⟨f.top, typein_top _⟩) h
lemma injective_typein (r : α → α → Prop) [is_well_order α r] : injective (typein r) :=
injective_of_increasing r (<) (typein r) (λ x y, (typein_lt_typein r).2)
theorem typein_inj (r : α → α → Prop) [is_well_order α r]
{a b} : typein r a = typein r b ↔ a = b :=
injective.eq_iff (injective_typein r)
/-- `enum r o h` is the `o`-th element of `α` ordered by `r`.
That is, `enum` maps an initial segment of the ordinals, those
less than the order type of `r`, to the elements of `α`. -/
def enum (r : α → α → Prop) [is_well_order α r] (o) : o < type r → α :=
quot.rec_on o (λ ⟨β, s, _⟩ h, (classical.choice h).top) $
λ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨h⟩, begin
resetI, refine funext (λ (H₂ : type t < type r), _),
have H₁ : type s < type r, {rwa type_eq.2 ⟨h⟩},
have : ∀ {o e} (H : o < type r), @@eq.rec
(λ (o : ordinal), o < type r → α)
(λ (h : type s < type r), (classical.choice h).top)
e H = (classical.choice H₁).top, {intros, subst e},
exact (this H₂).trans (principal_seg.top_eq h
(classical.choice H₁) (classical.choice H₂))
end
theorem enum_type {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : s ≺i r)
{h : type s < type r} : enum r (type s) h = f.top :=
principal_seg.top_eq (order_iso.refl _) _ _
@[simp] theorem enum_typein (r : α → α → Prop) [is_well_order α r] (a : α)
{h : typein r a < type r} : enum r (typein r a) h = a :=
enum_type (principal_seg.of_element r a)
@[simp] theorem typein_enum (r : α → α → Prop) [is_well_order α r]
{o} (h : o < type r) : typein r (enum r o h) = o :=
let ⟨a, e⟩ := typein_surj r h in
by clear _let_match; subst e; rw enum_typein
def typein_iso (r : α → α → Prop) [is_well_order α r] : r ≃o subrel (<) (< type r) :=
⟨⟨λ x, ⟨typein r x, typein_lt_type r x⟩, λ x, enum r x.1 x.2, λ y, enum_typein r y,
λ ⟨y, hy⟩, subtype.eq (typein_enum r hy)⟩,
λ a b, (typein_lt_typein r).symm⟩
theorem enum_lt {r : α → α → Prop} [is_well_order α r]
{o₁ o₂ : ordinal} (h₁ : o₁ < type r) (h₂ : o₂ < type r) :
r (enum r o₁ h₁) (enum r o₂ h₂) ↔ o₁ < o₂ :=
by rw [← typein_lt_typein r, typein_enum, typein_enum]
lemma order_iso_enum' {α β : Type u} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s]
(f : order_iso r s) (o : ordinal) : ∀(hr : o < type r) (hs : o < type s),
f (enum r o hr) = enum s o hs :=
begin
refine induction_on o _, rintros γ t wo ⟨g⟩ ⟨h⟩,
resetI, rw [enum_type g, enum_type (principal_seg.lt_equiv g f)], refl
end
lemma order_iso_enum {α β : Type u} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s]
(f : order_iso r s) (o : ordinal) (hr : o < type r) :
f (enum r o hr) =
enum s o (by {convert hr using 1, apply quotient.sound, exact ⟨f.symm⟩ }) :=
order_iso_enum' _ _ _ _
theorem wf : @well_founded ordinal (<) :=
⟨λ a, induction_on a $ λ α r wo, by exactI
suffices ∀ a, acc (<) (typein r a), from
⟨_, λ o h, let ⟨a, e⟩ := typein_surj r h in e ▸ this a⟩,
λ a, acc.rec_on (wo.wf.apply a) $ λ x H IH, ⟨_, λ o h, begin
rcases typein_surj r (lt_trans h (typein_lt_type r _)) with ⟨b, rfl⟩,
exact IH _ ((typein_lt_typein r).1 h)
end⟩⟩
instance : has_well_founded ordinal := ⟨(<), wf⟩
/-- The cardinal of an ordinal is the cardinal of any
set with that order type. -/
def card (o : ordinal) : cardinal :=
quot.lift_on o (λ ⟨α, r, _⟩, mk α) $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨e⟩, quotient.sound ⟨e.to_equiv⟩
@[simp] theorem card_type (r : α → α → Prop) [is_well_order α r] :
card (type r) = mk α := rfl
lemma card_typein {r : α → α → Prop} [wo : is_well_order α r] (x : α) :
mk {y // r y x} = (typein r x).card := rfl
theorem card_le_card {o₁ o₂ : ordinal} : o₁ ≤ o₂ → card o₁ ≤ card o₂ :=
induction_on o₁ $ λ α r _, induction_on o₂ $ λ β s _ ⟨⟨⟨f, _⟩, _⟩⟩, ⟨f⟩
instance : has_zero ordinal :=
⟨⟦⟨pempty, empty_relation, by apply_instance⟩⟧⟩
theorem zero_eq_type_empty : 0 = @type empty empty_relation _ :=
quotient.sound ⟨⟨equiv.empty_equiv_pempty.symm, λ _ _, iff.rfl⟩⟩
@[simp] theorem card_zero : card 0 = 0 := rfl
theorem zero_le (o : ordinal) : 0 ≤ o :=
induction_on o $ λ α r _,
⟨⟨⟨embedding.of_not_nonempty $ λ ⟨a⟩, a.elim,
λ a, a.elim⟩, λ a, a.elim⟩⟩
@[simp] theorem le_zero {o : ordinal} : o ≤ 0 ↔ o = 0 :=
by simp only [le_antisymm_iff, zero_le, and_true]
theorem pos_iff_ne_zero {o : ordinal} : 0 < o ↔ o ≠ 0 :=
by simp only [lt_iff_le_and_ne, zero_le, true_and, ne.def, eq_comm]
instance : has_one ordinal :=
⟨⟦⟨punit, empty_relation, by apply_instance⟩⟧⟩
theorem one_eq_type_unit : 1 = @type unit empty_relation _ :=
quotient.sound ⟨⟨equiv.punit_equiv_punit, λ _ _, iff.rfl⟩⟩
@[simp] theorem card_one : card 1 = 1 := rfl
instance : has_add ordinal.{u} :=
⟨λo₁ o₂, quotient.lift_on₂ o₁ o₂
(λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, ⟦⟨α ⊕ β, sum.lex r s, by exactI sum.lex.is_well_order⟩⟧
: Well_order → Well_order → ordinal) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
quot.sound ⟨order_iso.sum_lex_congr f g⟩⟩
@[simp] theorem type_add {α β : Type u} (r : α → α → Prop) (s : β → β → Prop)
[is_well_order α r] [is_well_order β s] : type r + type s = type (sum.lex r s) := rfl
/-- The ordinal successor is the smallest ordinal larger than `o`.
It is defined as `o + 1`. -/
def succ (o : ordinal) : ordinal := o + 1
theorem succ_eq_add_one (o) : succ o = o + 1 := rfl
theorem lt_succ_self (o : ordinal.{u}) : o < succ o :=
induction_on o $ λ α r _, ⟨⟨⟨⟨λ x, sum.inl x, λ _ _, sum.inl.inj⟩,
λ _ _, sum.lex_inl_inl.symm⟩,
sum.inr punit.star, λ b, sum.rec_on b
(λ x, ⟨λ _, ⟨x, rfl⟩, λ _, sum.lex.sep _ _ _ _⟩)
(λ x, sum.lex_inr_inr.trans ⟨false.elim, λ ⟨x, H⟩, sum.inl_ne_inr H⟩)⟩⟩
theorem succ_pos (o : ordinal) : 0 < succ o :=
lt_of_le_of_lt (zero_le _) (lt_succ_self _)
theorem succ_ne_zero (o : ordinal) : succ o ≠ 0 :=
ne_of_gt $ succ_pos o
theorem succ_le {a b : ordinal} : succ a ≤ b ↔ a < b :=
⟨lt_of_lt_of_le (lt_succ_self _),
induction_on a $ λ α r hr, induction_on b $ λ β s hs ⟨⟨f, t, hf⟩⟩, begin
refine ⟨⟨@order_embedding.of_monotone (α ⊕ punit) β _ _
(@sum.lex.is_well_order _ _ _ _ hr _).1.1
(@is_asymm_of_is_trans_of_is_irrefl _ _ hs.1.2.2 hs.1.2.1)
(sum.rec _ _) (λ a b, _), λ a b, _⟩⟩,
{ exact f }, { exact λ _, t },
{ rcases a with a|_; rcases b with b|_,
{ simpa only [sum.lex_inl_inl] using f.ord'.1 },
{ intro _, rw hf, exact ⟨_, rfl⟩ },
{ exact false.elim ∘ sum.lex_inr_inl },
{ exact false.elim ∘ sum.lex_inr_inr.1 } },
{ rcases a with a|_,
{ intro h, have := @principal_seg.init _ _ _ _ hs.1.2.2 ⟨f, t, hf⟩ _ _ h,
cases this with w h, exact ⟨sum.inl w, h⟩ },
{ intro h, cases (hf b).1 h with w h, exact ⟨sum.inl w, h⟩ } }
end⟩
@[simp] theorem card_add (o₁ o₂ : ordinal) : card (o₁ + o₂) = card o₁ + card o₂ :=
induction_on o₁ $ λ α r _, induction_on o₂ $ λ β s _, rfl
@[simp] theorem card_succ (o : ordinal) : card (succ o) = card o + 1 :=
by simp only [succ, card_add, card_one]
@[simp] theorem card_nat (n : ℕ) : card.{u} n = n :=
by induction n; [refl, simp only [card_add, card_one, nat.cast_succ, *]]
theorem nat_cast_succ (n : ℕ) : (succ n : ordinal) = n.succ := rfl
instance : add_monoid ordinal.{u} :=
{ add := (+),
zero := 0,
zero_add := λ o, induction_on o $ λ α r _, eq.symm $ quotient.sound
⟨⟨(equiv.pempty_sum α).symm, λ a b, sum.lex_inr_inr.symm⟩⟩,
add_zero := λ o, induction_on o $ λ α r _, eq.symm $ quotient.sound
⟨⟨(equiv.sum_pempty α).symm, λ a b, sum.lex_inl_inl.symm⟩⟩,
add_assoc := λ o₁ o₂ o₃, quotient.induction_on₃ o₁ o₂ o₃ $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩, quot.sound
⟨⟨equiv.sum_assoc _ _ _, λ a b,
begin rcases a with ⟨a|a⟩|a; rcases b with ⟨b|b⟩|b;
simp only [equiv.sum_assoc_apply_in1, equiv.sum_assoc_apply_in2, equiv.sum_assoc_apply_in3,
sum.lex_inl_inl, sum.lex_inr_inr, sum.lex.sep, sum.lex_inr_inl] end⟩⟩ }
theorem add_succ (o₁ o₂ : ordinal) : o₁ + succ o₂ = succ (o₁ + o₂) :=
(add_assoc _ _ _).symm
@[simp] theorem succ_zero : succ 0 = 1 := zero_add _
theorem one_le_iff_pos {o : ordinal} : 1 ≤ o ↔ 0 < o :=
by rw [← succ_zero, succ_le]
theorem one_le_iff_ne_zero {o : ordinal} : 1 ≤ o ↔ o ≠ 0 :=
by rw [one_le_iff_pos, pos_iff_ne_zero]
theorem add_le_add_left {a b : ordinal} : a ≤ b → ∀ c, c + a ≤ c + b :=
induction_on a $ λ α₁ r₁ _, induction_on b $ λ α₂ r₂ _ ⟨⟨⟨f, fo⟩, fi⟩⟩ c,
induction_on c $ λ β s _,
⟨⟨⟨(embedding.refl _).sum_congr f,
λ a b, match a, b with
| sum.inl a, sum.inl b := sum.lex_inl_inl.trans sum.lex_inl_inl.symm
| sum.inl a, sum.inr b := by apply iff_of_true; apply sum.lex.sep
| sum.inr a, sum.inl b := by apply iff_of_false; exact sum.lex_inr_inl
| sum.inr a, sum.inr b := sum.lex_inr_inr.trans $ fo.trans sum.lex_inr_inr.symm
end⟩,
λ a b H, match a, b, H with
| _, sum.inl b, _ := ⟨sum.inl b, rfl⟩
| sum.inl a, sum.inr b, H := (sum.lex_inr_inl H).elim
| sum.inr a, sum.inr b, H := let ⟨w, h⟩ := fi _ _ (sum.lex_inr_inr.1 H) in
⟨sum.inr w, congr_arg sum.inr h⟩
end⟩⟩
theorem le_add_right (a b : ordinal) : a ≤ a + b :=
by simpa only [add_zero] using add_le_add_left (zero_le b) a
theorem add_le_add_iff_left (a) {b c : ordinal} : a + b ≤ a + c ↔ b ≤ c :=
⟨induction_on a $ λ α r hr, induction_on b $ λ β₁ s₁ hs₁, induction_on c $ λ β₂ s₂ hs₂ ⟨f⟩, ⟨
have fl : ∀ a, f (sum.inl a) = sum.inl a := λ a,
by simpa only [initial_seg.trans_apply, initial_seg.le_add_apply]
using @initial_seg.eq _ _ _ _ (@sum.lex.is_well_order _ _ _ _ hr hs₂)
((initial_seg.le_add r s₁).trans f) (initial_seg.le_add r s₂) a,
have ∀ b, {b' // f (sum.inr b) = sum.inr b'}, begin
intro b, cases e : f (sum.inr b),
{ rw ← fl at e, have := f.inj e, contradiction },
{ exact ⟨_, rfl⟩ }
end,
let g (b) := (this b).1 in
have fr : ∀ b, f (sum.inr b) = sum.inr (g b), from λ b, (this b).2,
⟨⟨⟨g, λ x y h, by injection f.inj
(by rw [fr, fr, h] : f (sum.inr x) = f (sum.inr y))⟩,
λ a b, by simpa only [sum.lex_inr_inr, fr, order_embedding.coe_fn_to_embedding,
initial_seg.coe_fn_to_order_embedding, function.embedding.coe_fn_mk]
using @order_embedding.ord _ _ _ _ f.to_order_embedding (sum.inr a) (sum.inr b)⟩,
λ a b H, begin
rcases f.init' (by rw fr; exact sum.lex_inr_inr.2 H) with ⟨a'|a', h⟩,
{ rw fl at h, cases h },
{ rw fr at h, exact ⟨a', sum.inr.inj h⟩ }
end⟩⟩,
λ h, add_le_add_left h _⟩
theorem add_left_cancel (a) {b c : ordinal} : a + b = a + c ↔ b = c :=
by simp only [le_antisymm_iff, add_le_add_iff_left]
/-- The universe lift operation for ordinals, which embeds `ordinal.{u}` as
a proper initial segment of `ordinal.{v}` for `v > u`. -/
def lift (o : ordinal.{u}) : ordinal.{max u v} :=
quotient.lift_on o (λ ⟨α, r, wo⟩,
@type _ _ (@order_embedding.is_well_order _ _ (@equiv.ulift.{u v} α ⁻¹'o r) r
(order_iso.preimage equiv.ulift.{u v} r) wo)) $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨f⟩,
quot.sound ⟨(order_iso.preimage equiv.ulift r).trans $
f.trans (order_iso.preimage equiv.ulift s).symm⟩
theorem lift_type {α} (r : α → α → Prop) [is_well_order α r] :
∃ wo', lift (type r) = @type _ (@equiv.ulift.{u v} α ⁻¹'o r) wo' :=
⟨_, rfl⟩
theorem lift_umax : lift.{u (max u v)} = lift.{u v} :=
funext $ λ a, induction_on a $ λ α r _,
quotient.sound ⟨(order_iso.preimage equiv.ulift r).trans (order_iso.preimage equiv.ulift r).symm⟩
theorem lift_id' (a : ordinal) : lift a = a :=
induction_on a $ λ α r _,
quotient.sound ⟨order_iso.preimage equiv.ulift r⟩
@[simp] theorem lift_id : ∀ a, lift.{u u} a = a := lift_id'.{u u}
@[simp] theorem lift_lift (a : ordinal) : lift.{(max u v) w} (lift.{u v} a) = lift.{u (max v w)} a :=
induction_on a $ λ α r _,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans $
(order_iso.preimage equiv.ulift _).trans (order_iso.preimage equiv.ulift _).symm⟩
theorem lift_type_le {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) ≤ lift.{v (max u w)} (type s) ↔ nonempty (r ≼i s) :=
⟨λ ⟨f⟩, ⟨(initial_seg.of_iso (order_iso.preimage equiv.ulift r).symm).trans $
f.trans (initial_seg.of_iso (order_iso.preimage equiv.ulift s))⟩,
λ ⟨f⟩, ⟨(initial_seg.of_iso (order_iso.preimage equiv.ulift r)).trans $
f.trans (initial_seg.of_iso (order_iso.preimage equiv.ulift s).symm)⟩⟩
theorem lift_type_eq {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) = lift.{v (max u w)} (type s) ↔ nonempty (r ≃o s) :=
quotient.eq.trans
⟨λ ⟨f⟩, ⟨(order_iso.preimage equiv.ulift r).symm.trans $
f.trans (order_iso.preimage equiv.ulift s)⟩,
λ ⟨f⟩, ⟨(order_iso.preimage equiv.ulift r).trans $
f.trans (order_iso.preimage equiv.ulift s).symm⟩⟩
theorem lift_type_lt {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) < lift.{v (max u w)} (type s) ↔ nonempty (r ≺i s) :=
by haveI := @order_embedding.is_well_order _ _ (@equiv.ulift.{u (max v w)} α ⁻¹'o r)
r (order_iso.preimage equiv.ulift.{u (max v w)} r) _;
haveI := @order_embedding.is_well_order _ _ (@equiv.ulift.{v (max u w)} β ⁻¹'o s)
s (order_iso.preimage equiv.ulift.{v (max u w)} s) _; exact
⟨λ ⟨f⟩, ⟨(f.equiv_lt (order_iso.preimage equiv.ulift r).symm).lt_le
(initial_seg.of_iso (order_iso.preimage equiv.ulift s))⟩,
λ ⟨f⟩, ⟨(f.equiv_lt (order_iso.preimage equiv.ulift r)).lt_le
(initial_seg.of_iso (order_iso.preimage equiv.ulift s).symm)⟩⟩
@[simp] theorem lift_le {a b : ordinal} : lift.{u v} a ≤ lift b ↔ a ≤ b :=
induction_on a $ λ α r _, induction_on b $ λ β s _,
by rw ← lift_umax; exactI lift_type_le
@[simp] theorem lift_inj {a b : ordinal} : lift a = lift b ↔ a = b :=
by simp only [le_antisymm_iff, lift_le]
@[simp] theorem lift_lt {a b : ordinal} : lift a < lift b ↔ a < b :=
by simp only [lt_iff_le_not_le, lift_le]
@[simp] theorem lift_zero : lift 0 = 0 :=
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
⟨equiv.pempty_equiv_pempty, λ a b, iff.rfl⟩⟩
theorem zero_eq_lift_type_empty : 0 = lift.{0 u} (@type empty empty_relation _) :=
by rw [← zero_eq_type_empty, lift_zero]
@[simp] theorem lift_one : lift 1 = 1 :=
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
⟨equiv.punit_equiv_punit, λ a b, iff.rfl⟩⟩
theorem one_eq_lift_type_unit : 1 = lift.{0 u} (@type unit empty_relation _) :=
by rw [← one_eq_type_unit, lift_one]
@[simp] theorem lift_add (a b) : lift (a + b) = lift a + lift b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
(order_iso.sum_lex_congr (order_iso.preimage equiv.ulift _)
(order_iso.preimage equiv.ulift _)).symm⟩
@[simp] theorem lift_succ (a) : lift (succ a) = succ (lift a) :=
by unfold succ; simp only [lift_add, lift_one]
@[simp] theorem lift_card (a) : (card a).lift = card (lift a) :=
induction_on a $ λ α r _, rfl
theorem lift_down' {a : cardinal.{u}} {b : ordinal.{max u v}}
(h : card b ≤ a.lift) : ∃ a', lift a' = b :=
let ⟨c, e⟩ := cardinal.lift_down h in
quotient.induction_on c (λ α, induction_on b $ λ β s _ e', begin
resetI,
rw [mk_def, card_type, ← cardinal.lift_id'.{(max u v) u} (mk β),
← cardinal.lift_umax.{u v}, lift_mk_eq.{u (max u v) (max u v)}] at e',
cases e' with f,
have g := order_iso.preimage f s,
haveI := g.to_order_embedding.is_well_order,
have := lift_type_eq.{u (max u v) (max u v)}.2 ⟨g⟩,
rw [lift_id, lift_umax.{u v}] at this,
exact ⟨_, this⟩
end) e
theorem lift_down {a : ordinal.{u}} {b : ordinal.{max u v}}
(h : b ≤ lift a) : ∃ a', lift a' = b :=
@lift_down' (card a) _ (by rw lift_card; exact card_le_card h)
theorem le_lift_iff {a : ordinal.{u}} {b : ordinal.{max u v}} :
b ≤ lift a ↔ ∃ a', lift a' = b ∧ a' ≤ a :=
⟨λ h, let ⟨a', e⟩ := lift_down h in ⟨a', e, lift_le.1 $ e.symm ▸ h⟩,
λ ⟨a', e, h⟩, e ▸ lift_le.2 h⟩
theorem lt_lift_iff {a : ordinal.{u}} {b : ordinal.{max u v}} :
b < lift a ↔ ∃ a', lift a' = b ∧ a' < a :=
⟨λ h, let ⟨a', e⟩ := lift_down (le_of_lt h) in
⟨a', e, lift_lt.1 $ e.symm ▸ h⟩,
λ ⟨a', e, h⟩, e ▸ lift_lt.2 h⟩
/-- `ω` is the first infinite ordinal, defined as the order type of `ℕ`. -/
def omega : ordinal.{u} := lift $ @type ℕ (<) _
theorem card_omega : card omega = cardinal.omega := rfl
@[simp] theorem lift_omega : lift omega = omega := lift_lift _
theorem add_le_add_right {a b : ordinal} : a ≤ b → ∀ c, a + c ≤ b + c :=
induction_on a $ λ α₁ r₁ hr₁, induction_on b $ λ α₂ r₂ hr₂ ⟨⟨⟨f, fo⟩, fi⟩⟩ c,
induction_on c $ λ β s hs, (@type_le' _ _ _ _
(@sum.lex.is_well_order _ _ _ _ hr₁ hs)
(@sum.lex.is_well_order _ _ _ _ hr₂ hs)).2
⟨⟨embedding.sum_congr f (embedding.refl _), λ a b, begin
split; intro H,
{ cases H; constructor; [rwa ← fo, assumption] },
{ cases a with a a; cases b with b b; cases H; constructor; [rwa fo, assumption] }
end⟩⟩
theorem le_add_left (a b : ordinal) : a ≤ b + a :=
by simpa only [zero_add] using add_le_add_right (zero_le b) a
theorem le_total (a b : ordinal) : a ≤ b ∨ b ≤ a :=
match lt_or_eq_of_le (le_add_left b a), lt_or_eq_of_le (le_add_right a b) with
| or.inr h, _ := by rw h; exact or.inl (le_add_right _ _)
| _, or.inr h := by rw h; exact or.inr (le_add_left _ _)
| or.inl h₁, or.inl h₂ := induction_on a (λ α₁ r₁ _,
induction_on b $ λ α₂ r₂ _ ⟨f⟩ ⟨g⟩, begin
resetI,
rw [← typein_top f, ← typein_top g, le_iff_lt_or_eq,
le_iff_lt_or_eq, typein_lt_typein, typein_lt_typein],
rcases trichotomous_of (sum.lex r₁ r₂) g.top f.top with h|h|h;
[exact or.inl (or.inl h), {left, right, rw h}, exact or.inr (or.inl h)]
end) h₁ h₂
end
instance : decidable_linear_order ordinal :=
{ le_total := le_total,
decidable_le := classical.dec_rel _,
..ordinal.partial_order }
@[simp] lemma typein_le_typein (r : α → α → Prop) [is_well_order α r] {x x' : α} :
typein r x ≤ typein r x' ↔ ¬r x' x :=
by rw [←not_lt, typein_lt_typein]
lemma enum_le_enum (r : α → α → Prop) [is_well_order α r] {o o' : ordinal}
(ho : o < type r) (ho' : o' < type r) : ¬r (enum r o' ho') (enum r o ho) ↔ o ≤ o' :=
by rw [←@not_lt _ _ o' o, enum_lt ho']
theorem lt_succ {a b : ordinal} : a < succ b ↔ a ≤ b :=
by rw [← not_le, succ_le, not_lt]
theorem add_lt_add_iff_left (a) {b c : ordinal} : a + b < a + c ↔ b < c :=
by rw [← not_le, ← not_le, add_le_add_iff_left]
theorem lt_of_add_lt_add_right {a b c : ordinal} : a + b < c + b → a < c :=
lt_imp_lt_of_le_imp_le (λ h, add_le_add_right h _)
@[simp] theorem succ_lt_succ {a b : ordinal} : succ a < succ b ↔ a < b :=
by rw [lt_succ, succ_le]
@[simp] theorem succ_le_succ {a b : ordinal} : succ a ≤ succ b ↔ a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 succ_lt_succ
theorem succ_inj {a b : ordinal} : succ a = succ b ↔ a = b :=
by simp only [le_antisymm_iff, succ_le_succ]
theorem add_le_add_iff_right {a b : ordinal} (n : ℕ) : a + n ≤ b + n ↔ a ≤ b :=
by induction n with n ih; [rw [nat.cast_zero, add_zero, add_zero],
rw [← nat_cast_succ, add_succ, add_succ, succ_le_succ, ih]]
theorem add_right_cancel {a b : ordinal} (n : ℕ) : a + n = b + n ↔ a = b :=
by simp only [le_antisymm_iff, add_le_add_iff_right]
@[simp] theorem card_eq_zero {o} : card o = 0 ↔ o = 0 :=
⟨induction_on o $ λ α r _ h, begin
refine le_antisymm (le_of_not_lt $
λ hn, ne_zero_iff_nonempty.2 _ h) (zero_le _),
rw [← succ_le, succ_zero] at hn, cases hn with f,
exact ⟨f punit.star⟩
end, λ e, by simp only [e, card_zero]⟩
@[simp] theorem type_ne_zero_iff_nonempty [is_well_order α r] : type r ≠ 0 ↔ nonempty α :=
(not_congr (@card_eq_zero (type r))).symm.trans ne_zero_iff_nonempty
@[simp] theorem type_eq_zero_iff_empty [is_well_order α r] : type r = 0 ↔ ¬ nonempty α :=
(not_iff_comm.1 type_ne_zero_iff_nonempty).symm
instance : zero_ne_one_class ordinal.{u} :=
{ zero := 0, one := 1, zero_ne_one :=
ne.symm $ type_ne_zero_iff_nonempty.2 ⟨punit.star⟩ }
theorem zero_lt_one : (0 : ordinal) < 1 :=
lt_iff_le_and_ne.2 ⟨zero_le _, zero_ne_one⟩
/-- The ordinal predecessor of `o` is `o'` if `o = succ o'`,
and `o` otherwise. -/
def pred (o : ordinal.{u}) : ordinal.{u} :=
if h : ∃ a, o = succ a then classical.some h else o
@[simp] theorem pred_succ (o) : pred (succ o) = o :=
by have h : ∃ a, succ o = succ a := ⟨_, rfl⟩;
simpa only [pred, dif_pos h] using (succ_inj.1 $ classical.some_spec h).symm
theorem pred_le_self (o) : pred o ≤ o :=
if h : ∃ a, o = succ a then let ⟨a, e⟩ := h in
by rw [e, pred_succ]; exact le_of_lt (lt_succ_self _)
else by rw [pred, dif_neg h]
theorem pred_eq_iff_not_succ {o} : pred o = o ↔ ¬ ∃ a, o = succ a :=
⟨λ e ⟨a, e'⟩, by rw [e', pred_succ] at e; exact ne_of_lt (lt_succ_self _) e,
λ h, dif_neg h⟩
theorem pred_lt_iff_is_succ {o} : pred o < o ↔ ∃ a, o = succ a :=
iff.trans (by simp only [le_antisymm_iff, pred_le_self, true_and, not_le])
(iff_not_comm.1 pred_eq_iff_not_succ).symm
theorem succ_pred_iff_is_succ {o} : succ (pred o) = o ↔ ∃ a, o = succ a :=
⟨λ e, ⟨_, e.symm⟩, λ ⟨a, e⟩, by simp only [e, pred_succ]⟩
theorem succ_lt_of_not_succ {o} (h : ¬ ∃ a, o = succ a) {b} : succ b < o ↔ b < o :=
⟨lt_trans (lt_succ_self _), λ l,
lt_of_le_of_ne (succ_le.2 l) (λ e, h ⟨_, e.symm⟩)⟩
theorem lt_pred {a b} : a < pred b ↔ succ a < b :=
if h : ∃ a, b = succ a then let ⟨c, e⟩ := h in
by rw [e, pred_succ, succ_lt_succ]
else by simp only [pred, dif_neg h, succ_lt_of_not_succ h]
theorem pred_le {a b} : pred a ≤ b ↔ a ≤ succ b :=
le_iff_le_iff_lt_iff_lt.2 lt_pred
@[simp] theorem lift_is_succ {o} : (∃ a, lift o = succ a) ↔ (∃ a, o = succ a) :=
⟨λ ⟨a, h⟩,
let ⟨b, e⟩ := lift_down $ show a ≤ lift o, from le_of_lt $
h.symm ▸ lt_succ_self _ in
⟨b, lift_inj.1 $ by rw [h, ← e, lift_succ]⟩,
λ ⟨a, h⟩, ⟨lift a, by simp only [h, lift_succ]⟩⟩
@[simp] theorem lift_pred (o) : lift (pred o) = pred (lift o) :=
if h : ∃ a, o = succ a then
by cases h with a e; simp only [e, pred_succ, lift_succ]
else by rw [pred_eq_iff_not_succ.2 h,
pred_eq_iff_not_succ.2 (mt lift_is_succ.1 h)]
/-- A limit ordinal is an ordinal which is not zero and not a successor. -/
def is_limit (o : ordinal) : Prop := o ≠ 0 ∧ ∀ a < o, succ a < o
theorem not_zero_is_limit : ¬ is_limit 0
| ⟨h, _⟩ := h rfl
theorem not_succ_is_limit (o) : ¬ is_limit (succ o)
| ⟨_, h⟩ := lt_irrefl _ (h _ (lt_succ_self _))
theorem not_succ_of_is_limit {o} (h : is_limit o) : ¬ ∃ a, o = succ a
| ⟨a, e⟩ := not_succ_is_limit a (e ▸ h)
theorem succ_lt_of_is_limit {o} (h : is_limit o) {a} : succ a < o ↔ a < o :=
⟨lt_trans (lt_succ_self _), h.2 _⟩
theorem le_succ_of_is_limit {o} (h : is_limit o) {a} : o ≤ succ a ↔ o ≤ a :=
le_iff_le_iff_lt_iff_lt.2 $ succ_lt_of_is_limit h
theorem limit_le {o} (h : is_limit o) {a} : o ≤ a ↔ ∀ x < o, x ≤ a :=
⟨λ h x l, le_trans (le_of_lt l) h,
λ H, (le_succ_of_is_limit h).1 $ le_of_not_lt $ λ hn,
not_lt_of_le (H _ hn) (lt_succ_self _)⟩
theorem lt_limit {o} (h : is_limit o) {a} : a < o ↔ ∃ x < o, a < x :=
by simpa only [not_ball, not_le] using not_congr (@limit_le _ h a)
@[simp] theorem lift_is_limit (o) : is_limit (lift o) ↔ is_limit o :=
and_congr (not_congr $ by simpa only [lift_zero] using @lift_inj o 0)
⟨λ H a h, lift_lt.1 $ by simpa only [lift_succ] using H _ (lift_lt.2 h),
λ H a h, let ⟨a', e⟩ := lift_down (le_of_lt h) in
by rw [← e, ← lift_succ, lift_lt];
rw [← e, lift_lt] at h; exact H a' h⟩
theorem is_limit.pos {o : ordinal} (h : is_limit o) : 0 < o :=
lt_of_le_of_ne (zero_le _) h.1.symm
theorem is_limit.one_lt {o : ordinal} (h : is_limit o) : 1 < o :=
by simpa only [succ_zero] using h.2 _ h.pos
theorem is_limit.nat_lt {o : ordinal} (h : is_limit o) : ∀ n : ℕ, (n : ordinal) < o
| 0 := h.pos
| (n+1) := h.2 _ (is_limit.nat_lt n)
theorem zero_or_succ_or_limit (o : ordinal) :
o = 0 ∨ (∃ a, o = succ a) ∨ is_limit o :=
if o0 : o = 0 then or.inl o0 else
if h : ∃ a, o = succ a then or.inr (or.inl h) else
or.inr $ or.inr ⟨o0, λ a, (succ_lt_of_not_succ h).2⟩
instance : is_well_order ordinal (<) := ⟨wf⟩
@[elab_as_eliminator] def limit_rec_on {C : ordinal → Sort*}
(o : ordinal) (H₁ : C 0) (H₂ : ∀ o, C o → C (succ o))
(H₃ : ∀ o, is_limit o → (∀ o' < o, C o') → C o) : C o :=
wf.fix (λ o IH,
if o0 : o = 0 then by rw o0; exact H₁ else
if h : ∃ a, o = succ a then
by rw ← succ_pred_iff_is_succ.2 h; exact
H₂ _ (IH _ $ pred_lt_iff_is_succ.2 h)
else H₃ _ ⟨o0, λ a, (succ_lt_of_not_succ h).2⟩ IH) o
@[simp] theorem limit_rec_on_zero {C} (H₁ H₂ H₃) : @limit_rec_on C 0 H₁ H₂ H₃ = H₁ :=
by rw [limit_rec_on, well_founded.fix_eq, dif_pos rfl]; refl
@[simp] theorem limit_rec_on_succ {C} (o H₁ H₂ H₃) :
@limit_rec_on C (succ o) H₁ H₂ H₃ = H₂ o (@limit_rec_on C o H₁ H₂ H₃) :=
begin
have h : ∃ a, succ o = succ a := ⟨_, rfl⟩,
rw [limit_rec_on, well_founded.fix_eq,
dif_neg (succ_ne_zero o), dif_pos h],
generalize : limit_rec_on._proof_2 (succ o) h = h₂,
generalize : limit_rec_on._proof_3 (succ o) h = h₃,
revert h₂ h₃, generalize e : pred (succ o) = o', intros,
rw pred_succ at e, subst o', refl
end
@[simp] theorem limit_rec_on_limit {C} (o H₁ H₂ H₃ h) :
@limit_rec_on C o H₁ H₂ H₃ = H₃ o h (λ x h, @limit_rec_on C x H₁ H₂ H₃) :=
by rw [limit_rec_on, well_founded.fix_eq,
dif_neg h.1, dif_neg (not_succ_of_is_limit h)]; refl
lemma has_succ_of_is_limit {α} {r : α → α → Prop} [wo : is_well_order α r]
(h : (type r).is_limit) (x : α) : ∃y, r x y :=
begin
use enum r (typein r x).succ (h.2 _ (typein_lt_type r x)),
convert (enum_lt (typein_lt_type r x) _).mpr (lt_succ_self _), rw [enum_typein]
end
lemma type_subrel_lt (o : ordinal.{u}) :
type (subrel (<) {o' : ordinal | o' < o}) = ordinal.lift.{u u+1} o :=
begin
refine quotient.induction_on o _,
rintro ⟨α, r, wo⟩, resetI, apply quotient.sound,
constructor, symmetry, refine (order_iso.preimage equiv.ulift r).trans (typein_iso r)
end
lemma mk_initial_seg (o : ordinal.{u}) :
mk {o' : ordinal | o' < o} = cardinal.lift.{u u+1} o.card :=
by rw [lift_card, ←type_subrel_lt, card_type]
/-- A normal ordinal function is a strictly increasing function which is
order-continuous. -/
def is_normal (f : ordinal → ordinal) : Prop :=
(∀ o, f o < f (succ o)) ∧ ∀ o, is_limit o → ∀ a, f o ≤ a ↔ ∀ b < o, f b ≤ a
theorem is_normal.limit_le {f} (H : is_normal f) : ∀ {o}, is_limit o →
∀ {a}, f o ≤ a ↔ ∀ b < o, f b ≤ a := H.2
theorem is_normal.limit_lt {f} (H : is_normal f) {o} (h : is_limit o) {a} :
a < f o ↔ ∃ b < o, a < f b :=
not_iff_not.1 $ by simpa only [exists_prop, not_exists, not_and, not_lt] using H.2 _ h a
theorem is_normal.lt_iff {f} (H : is_normal f) {a b} : f a < f b ↔ a < b :=
strict_mono.lt_iff_lt $ λ a b,
limit_rec_on b (not.elim (not_lt_of_le $ zero_le _))
(λ b IH h, (lt_or_eq_of_le (lt_succ.1 h)).elim
(λ h, lt_trans (IH h) (H.1 _))
(λ e, e ▸ H.1 _))
(λ b l IH h, lt_of_lt_of_le (H.1 a)
((H.2 _ l _).1 (le_refl _) _ (l.2 _ h)))
theorem is_normal.le_iff {f} (H : is_normal f) {a b} : f a ≤ f b ↔ a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 H.lt_iff
theorem is_normal.inj {f} (H : is_normal f) {a b} : f a = f b ↔ a = b :=
by simp only [le_antisymm_iff, H.le_iff]
theorem is_normal.le_self {f} (H : is_normal f) (a) : a ≤ f a :=
limit_rec_on a (zero_le _)
(λ a IH, succ_le.2 $ lt_of_le_of_lt IH (H.1 _))
(λ a l IH, (limit_le l).2 $ λ b h,
le_trans (IH b h) $ H.le_iff.2 $ le_of_lt h)
theorem is_normal.le_set {f} (H : is_normal f) (p : ordinal → Prop)
(p0 : ∃ x, p x) (S)
(H₂ : ∀ o, S ≤ o ↔ ∀ a, p a → a ≤ o) {o} :
f S ≤ o ↔ ∀ a, p a → f a ≤ o :=
⟨λ h a pa, le_trans (H.le_iff.2 ((H₂ _).1 (le_refl _) _ pa)) h,
λ h, begin
revert H₂, apply limit_rec_on S,
{ intro H₂,
cases p0 with x px,
have := le_zero.1 ((H₂ _).1 (zero_le _) _ px),
rw this at px, exact h _ px },
{ intros S _ H₂,
rcases not_ball.1 (mt (H₂ S).2 $ not_le_of_lt $ lt_succ_self _) with ⟨a, h₁, h₂⟩,
exact le_trans (H.le_iff.2 $ succ_le.2 $ not_le.1 h₂) (h _ h₁) },
{ intros S L _ H₂, apply (H.2 _ L _).2, intros a h',
rcases not_ball.1 (mt (H₂ a).2 (not_le.2 h')) with ⟨b, h₁, h₂⟩,
exact le_trans (H.le_iff.2 $ le_of_lt $ not_le.1 h₂) (h _ h₁) }
end⟩
theorem is_normal.le_set' {f} (H : is_normal f) (p : α → Prop) (g : α → ordinal)
(p0 : ∃ x, p x) (S)
(H₂ : ∀ o, S ≤ o ↔ ∀ a, p a → g a ≤ o) {o} :
f S ≤ o ↔ ∀ a, p a → f (g a) ≤ o :=
(H.le_set (λ x, ∃ y, p y ∧ x = g y)
(let ⟨x, px⟩ := p0 in ⟨_, _, px, rfl⟩) _
(λ o, (H₂ o).trans ⟨λ H a ⟨y, h1, h2⟩, h2.symm ▸ H y h1,
λ H a h1, H (g a) ⟨a, h1, rfl⟩⟩)).trans
⟨λ H a h, H (g a) ⟨a, h, rfl⟩, λ H a ⟨y, h1, h2⟩, h2.symm ▸ H y h1⟩
theorem is_normal.refl : is_normal id :=
⟨λ x, lt_succ_self _, λ o l a, limit_le l⟩
theorem is_normal.trans {f g} (H₁ : is_normal f) (H₂ : is_normal g) :
is_normal (λ x, f (g x)) :=
⟨λ x, H₁.lt_iff.2 (H₂.1 _),
λ o l a, H₁.le_set' (< o) g ⟨_, l.pos⟩ _ (λ c, H₂.2 _ l _)⟩
theorem is_normal.is_limit {f} (H : is_normal f) {o} (l : is_limit o) :
is_limit (f o) :=
⟨ne_of_gt $ lt_of_le_of_lt (zero_le _) $ H.lt_iff.2 l.pos,
λ a h, let ⟨b, h₁, h₂⟩ := (H.limit_lt l).1 h in
lt_of_le_of_lt (succ_le.2 h₂) (H.lt_iff.2 h₁)⟩
theorem add_le_of_limit {a b c : ordinal.{u}}
(h : is_limit b) : a + b ≤ c ↔ ∀ b' < b, a + b' ≤ c :=
⟨λ h b' l, le_trans (add_le_add_left (le_of_lt l) _) h,
λ H, le_of_not_lt $
induction_on a (λ α r _, induction_on b $ λ β s _ h H l, begin
resetI,
suffices : ∀ x : β, sum.lex r s (sum.inr x) (enum _ _ l),
{ cases enum _ _ l with x x,
{ cases this (enum s 0 h.pos) },
{ exact irrefl _ (this _) } },
intros x,
rw [← typein_lt_typein (sum.lex r s), typein_enum],
have := H _ (h.2 _ (typein_lt_type s x)),
rw [add_succ, succ_le] at this,
refine lt_of_le_of_lt (type_le'.2
⟨order_embedding.of_monotone (λ a, _) (λ a b, _)⟩) this,
{ rcases a with ⟨a | b, h⟩,
{ exact sum.inl a },
{ exact sum.inr ⟨b, by cases h; assumption⟩ } },
{ rcases a with ⟨a | a, h₁⟩; rcases b with ⟨b | b, h₂⟩; cases h₁; cases h₂;
rintro ⟨⟩; constructor; assumption }
end) h H⟩
theorem add_is_normal (a : ordinal) : is_normal ((+) a) :=
⟨λ b, (add_lt_add_iff_left a).2 (lt_succ_self _),
λ b l c, add_le_of_limit l⟩
theorem add_is_limit (a) {b} : is_limit b → is_limit (a + b) :=
(add_is_normal a).is_limit
def typein.principal_seg {α : Type u} (r : α → α → Prop) [is_well_order α r] :
@principal_seg α ordinal.{u} r (<) :=
⟨order_embedding.of_monotone (typein r)
(λ a b, (typein_lt_typein r).2), type r, λ b,
⟨λ h, ⟨enum r _ h, typein_enum r h⟩,
λ ⟨a, e⟩, e ▸ typein_lt_type _ _⟩⟩
@[simp] theorem typein.principal_seg_coe (r : α → α → Prop) [is_well_order α r] :
(typein.principal_seg r : α → ordinal) = typein r := rfl
/-- The minimal element of a nonempty family of ordinals -/
def min {ι} (I : nonempty ι) (f : ι → ordinal) : ordinal :=
wf.min (set.range f) (let ⟨i⟩ := I in set.ne_empty_of_mem (set.mem_range_self i))
theorem min_eq {ι} (I) (f : ι → ordinal) : ∃ i, min I f = f i :=
let ⟨i, e⟩ := wf.min_mem (set.range f) _ in ⟨i, e.symm⟩
theorem min_le {ι I} (f : ι → ordinal) (i) : min I f ≤ f i :=
le_of_not_gt $ wf.not_lt_min (set.range f) _ (set.mem_range_self i)
theorem le_min {ι I} {f : ι → ordinal} {a} : a ≤ min I f ↔ ∀ i, a ≤ f i :=
⟨λ h i, le_trans h (min_le _ _),
λ h, let ⟨i, e⟩ := min_eq I f in e.symm ▸ h i⟩
/-- The minimal element of a nonempty set of ordinals -/
def omin (S : set ordinal.{u}) (H : ∃ x, x ∈ S) : ordinal.{u} :=
@min.{(u+2) u} S (let ⟨x, px⟩ := H in ⟨⟨x, px⟩⟩) subtype.val
theorem omin_mem (S H) : omin S H ∈ S :=
let ⟨⟨i, h⟩, e⟩ := @min_eq S _ _ in
(show omin S H = i, from e).symm ▸ h
theorem le_omin {S H a} : a ≤ omin S H ↔ ∀ i ∈ S, a ≤ i :=
le_min.trans set_coe.forall
theorem omin_le {S H i} (h : i ∈ S) : omin S H ≤ i :=
le_omin.1 (le_refl _) _ h
@[simp] theorem lift_min {ι} (I) (f : ι → ordinal) : lift (min I f) = min I (lift ∘ f) :=
le_antisymm (le_min.2 $ λ a, lift_le.2 $ min_le _ a) $
let ⟨i, e⟩ := min_eq I (lift ∘ f) in
by rw e; exact lift_le.2 (le_min.2 $ λ j, lift_le.1 $
by have := min_le (lift ∘ f) j; rwa e at this)
def lift.initial_seg : @initial_seg ordinal.{u} ordinal.{max u v} (<) (<) :=
⟨⟨⟨lift.{u v}, λ a b, lift_inj.1⟩, λ a b, lift_lt.symm⟩,
λ a b h, lift_down (le_of_lt h)⟩
@[simp] theorem lift.initial_seg_coe : (lift.initial_seg : ordinal → ordinal) = lift := rfl
/-- `univ.{u v}` is the order type of the ordinals of `Type u` as a member
of `ordinal.{v}` (when `u < v`). It is an inaccessible cardinal. -/
def univ := lift.{(u+1) v} (@type ordinal.{u} (<) _)
theorem univ_id : univ.{u (u+1)} = @type ordinal.{u} (<) _ := lift_id _
@[simp] theorem lift_univ : lift.{_ w} univ.{u v} = univ.{u (max v w)} := lift_lift _
theorem univ_umax : univ.{u (max (u+1) v)} = univ.{u v} := congr_fun lift_umax _
def lift.principal_seg : @principal_seg ordinal.{u} ordinal.{max (u+1) v} (<) (<) :=
⟨↑lift.initial_seg.{u (max (u+1) v)}, univ.{u v}, begin
refine λ b, induction_on b _, introsI β s _,
rw [univ, ← lift_umax], split; intro h,
{ rw ← lift_id (type s) at h ⊢,
cases lift_type_lt.1 h with f, cases f with f a hf,
existsi a, revert hf,
apply induction_on a, intros α r _ hf,
refine lift_type_eq.{u (max (u+1) v) (max (u+1) v)}.2
⟨(order_iso.of_surjective (order_embedding.of_monotone _ _) _).symm⟩,
{ exact λ b, enum r (f b) ((hf _).2 ⟨_, rfl⟩) },
{ refine λ a b h, (typein_lt_typein r).1 _,
rw [typein_enum, typein_enum],
exact f.ord'.1 h },
{ intro a', cases (hf _).1 (typein_lt_type _ a') with b e,
existsi b, simp, simp [e] } },
{ cases h with a e, rw [← e],
apply induction_on a, intros α r _,
exact lift_type_lt.{u (u+1) (max (u+1) v)}.2
⟨typein.principal_seg r⟩ }
end⟩
@[simp] theorem lift.principal_seg_coe :
(lift.principal_seg.{u v} : ordinal → ordinal) = lift.{u (max (u+1) v)} := rfl
@[simp] theorem lift.principal_seg_top : lift.principal_seg.top = univ := rfl
theorem lift.principal_seg_top' :
lift.principal_seg.{u (u+1)}.top = @type ordinal.{u} (<) _ :=
by simp only [lift.principal_seg_top, univ_id]
/-- `a - b` is the unique ordinal satisfying
`b + (a - b) = a` when `b ≤ a`. -/
def sub (a b : ordinal.{u}) : ordinal.{u} :=
omin {o | a ≤ b+o} ⟨a, le_add_left _ _⟩
instance : has_sub ordinal := ⟨sub⟩
theorem le_add_sub (a b : ordinal) : a ≤ b + (a - b) :=
omin_mem {o | a ≤ b+o} _
theorem sub_le {a b c : ordinal} : a - b ≤ c ↔ a ≤ b + c :=
⟨λ h, le_trans (le_add_sub a b) (add_le_add_left h _),
λ h, omin_le h⟩
theorem lt_sub {a b c : ordinal} : a < b - c ↔ c + a < b :=
lt_iff_lt_of_le_iff_le sub_le
theorem add_sub_cancel (a b : ordinal) : a + b - a = b :=
le_antisymm (sub_le.2 $ le_refl _)
((add_le_add_iff_left a).1 $ le_add_sub _ _)
theorem sub_eq_of_add_eq {a b c : ordinal} (h : a + b = c) : c - a = b :=
h ▸ add_sub_cancel _ _
theorem sub_le_self (a b : ordinal) : a - b ≤ a :=
sub_le.2 $ le_add_left _ _
theorem add_sub_cancel_of_le {a b : ordinal} (h : b ≤ a) : b + (a - b) = a :=
le_antisymm begin
rcases zero_or_succ_or_limit (a-b) with e|⟨c,e⟩|l,
{ simp only [e, add_zero, h] },
{ rw [e, add_succ, succ_le, ← lt_sub, e], apply lt_succ_self },
{ exact (add_le_of_limit l).2 (λ c l, le_of_lt (lt_sub.1 l)) }
end (le_add_sub _ _)
@[simp] theorem sub_zero (a : ordinal) : a - 0 = a :=
by simpa only [zero_add] using add_sub_cancel 0 a
@[simp] theorem zero_sub (a : ordinal) : 0 - a = 0 :=
by rw ← le_zero; apply sub_le_self
@[simp] theorem sub_self (a : ordinal) : a - a = 0 :=
by simpa only [add_zero] using add_sub_cancel a 0
theorem sub_eq_zero_iff_le {a b : ordinal} : a - b = 0 ↔ a ≤ b :=
⟨λ h, by simpa only [h, add_zero] using le_add_sub a b,
λ h, by rwa [← le_zero, sub_le, add_zero]⟩
theorem sub_sub (a b c : ordinal) : a - b - c = a - (b + c) :=
eq_of_forall_ge_iff $ λ d, by rw [sub_le, sub_le, sub_le, add_assoc]
theorem add_sub_add_cancel (a b c : ordinal) : a + b - (a + c) = b - c :=
by rw [← sub_sub, add_sub_cancel]
theorem sub_is_limit {a b} (l : is_limit a) (h : b < a) : is_limit (a - b) :=
⟨ne_of_gt $ lt_sub.2 $ by rwa add_zero,
λ c h, by rw [lt_sub, add_succ]; exact l.2 _ (lt_sub.1 h)⟩
@[simp] theorem one_add_omega : 1 + omega.{u} = omega :=
begin
refine le_antisymm _ (le_add_left _ _),
rw [omega, one_eq_lift_type_unit, ← lift_add, lift_le, type_add],
have : is_well_order unit empty_relation := by apply_instance,
refine ⟨order_embedding.collapse (order_embedding.of_monotone _ _)⟩,
{ apply sum.rec, exact λ _, 0, exact nat.succ },
{ intros a b, cases a; cases b; intro H; cases H with _ _ H _ _ H;
[cases H, exact nat.succ_pos _, exact nat.succ_lt_succ H] }
end
@[simp] theorem one_add_of_omega_le {o} (h : omega ≤ o) : 1 + o = o :=
by rw [← add_sub_cancel_of_le h, ← add_assoc, one_add_omega]
instance : monoid ordinal.{u} :=
{ mul := λ a b, quotient.lift_on₂ a b
(λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, ⟦⟨β × α, prod.lex s r, by exactI prod.lex.is_well_order⟩⟧
: Well_order → Well_order → ordinal) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
quot.sound ⟨order_iso.prod_lex_congr g f⟩,
one := 1,
mul_assoc := λ a b c, quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩,
eq.symm $ quotient.sound ⟨⟨equiv.prod_assoc _ _ _, λ a b, begin
rcases a with ⟨⟨a₁, a₂⟩, a₃⟩,
rcases b with ⟨⟨b₁, b₂⟩, b₃⟩,
simp [prod.lex_def, and_or_distrib_left, or_assoc, and_assoc]
end⟩⟩,
mul_one := λ a, induction_on a $ λ α r _, quotient.sound
⟨⟨equiv.punit_prod _, λ a b, by rcases a with ⟨⟨⟨⟩⟩, a⟩; rcases b with ⟨⟨⟨⟩⟩, b⟩;
simp only [prod.lex_def, empty_relation, false_or]; dsimp only;
simp only [eq_self_iff_true, true_and]; refl⟩⟩,
one_mul := λ a, induction_on a $ λ α r _, quotient.sound
⟨⟨equiv.prod_punit _, λ a b, by rcases a with ⟨a, ⟨⟨⟩⟩⟩; rcases b with ⟨b, ⟨⟨⟩⟩⟩;
simp only [prod.lex_def, empty_relation, and_false, or_false]; refl⟩⟩ }
@[simp] theorem type_mul {α β : Type u} (r : α → α → Prop) (s : β → β → Prop)
[is_well_order α r] [is_well_order β s] : type r * type s = type (prod.lex s r) := rfl
@[simp] theorem lift_mul (a b) : lift (a * b) = lift a * lift b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
(order_iso.prod_lex_congr (order_iso.preimage equiv.ulift _)
(order_iso.preimage equiv.ulift _)).symm⟩
@[simp] theorem card_mul (a b) : card (a * b) = card a * card b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
mul_comm (mk β) (mk α)
@[simp] theorem mul_zero (a : ordinal) : a * 0 = 0 :=
induction_on a $ λ α _ _, by exactI
type_eq_zero_iff_empty.2 (λ ⟨⟨e, _⟩⟩, e.elim)
@[simp] theorem zero_mul (a : ordinal) : 0 * a = 0 :=
induction_on a $ λ α _ _, by exactI
type_eq_zero_iff_empty.2 (λ ⟨⟨_, e⟩⟩, e.elim)
theorem mul_add (a b c : ordinal) : a * (b + c) = a * b + a * c :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩,
quotient.sound ⟨⟨equiv.sum_prod_distrib _ _ _, begin
rintro ⟨a₁|a₁, a₂⟩ ⟨b₁|b₁, b₂⟩; simp only [prod.lex_def,
sum.lex_inl_inl, sum.lex.sep, sum.lex_inr_inl, sum.lex_inr_inr,
equiv.sum_prod_distrib_apply_left, equiv.sum_prod_distrib_apply_right];
simp only [sum.inl.inj_iff, true_or, false_and, false_or]
end⟩⟩
@[simp] theorem mul_add_one (a b : ordinal) : a * (b + 1) = a * b + a :=
by simp only [mul_add, mul_one]
@[simp] theorem mul_succ (a b : ordinal) : a * succ b = a * b + a := mul_add_one _ _
theorem mul_le_mul_left {a b} (c : ordinal) : a ≤ b → c * a ≤ c * b :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩, begin
resetI,
refine type_le'.2 ⟨order_embedding.of_monotone
(λ a, (f a.1, a.2))
(λ a b h, _)⟩, clear_,
cases h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h',
{ exact prod.lex.left _ _ _ (f.to_order_embedding.ord'.1 h') },
{ exact prod.lex.right _ _ h' }
end
theorem mul_le_mul_right {a b} (c : ordinal) : a ≤ b → a * c ≤ b * c :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩, begin
resetI,
refine type_le'.2 ⟨order_embedding.of_monotone
(λ a, (a.1, f a.2))
(λ a b h, _)⟩,
cases h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h',
{ exact prod.lex.left _ _ _ h' },
{ exact prod.lex.right _ _ (f.to_order_embedding.ord'.1 h') }
end
theorem mul_le_mul {a b c d : ordinal} (h₁ : a ≤ c) (h₂ : b ≤ d) : a * b ≤ c * d :=
le_trans (mul_le_mul_left _ h₂) (mul_le_mul_right _ h₁)
private lemma mul_le_of_limit_aux {α β r s} [is_well_order α r] [is_well_order β s]
{c} (h : is_limit (type s)) (H : ∀ b' < type s, type r * b' ≤ c)
(l : c < type r * type s) : false :=
begin
suffices : ∀ a b, prod.lex s r (b, a) (enum _ _ l),
{ cases enum _ _ l with b a, exact irrefl _ (this _ _) },
intros a b,
rw [← typein_lt_typein (prod.lex s r), typein_enum],
have := H _ (h.2 _ (typein_lt_type s b)),
rw [mul_succ] at this,
have := lt_of_lt_of_le ((add_lt_add_iff_left _).2
(typein_lt_type _ a)) this,
refine lt_of_le_of_lt _ this,
refine (type_le'.2 _),
constructor,
refine order_embedding.of_monotone (λ a, _) (λ a b, _),
{ rcases a with ⟨⟨b', a'⟩, h⟩,
by_cases e : b = b',
{ refine sum.inr ⟨a', _⟩,
subst e, cases h with _ _ _ _ h _ _ _ h,
{ exact (irrefl _ h).elim },
{ exact h } },
{ refine sum.inl (⟨b', _⟩, a'),
cases h with _ _ _ _ h _ _ _ h,
{ exact h }, { exact (e rfl).elim } } },
{ rcases a with ⟨⟨b₁, a₁⟩, h₁⟩,
rcases b with ⟨⟨b₂, a₂⟩, h₂⟩,
intro h, by_cases e₁ : b = b₁; by_cases e₂ : b = b₂,
{ substs b₁ b₂, simpa only [subrel_val, prod.lex_def, @irrefl _ s _ b, true_and, false_or, eq_self_iff_true, dif_pos, sum.lex_inr_inr] using h },
{ subst b₁, simp only [subrel_val, prod.lex_def, e₂, prod.lex_def, dif_pos, subrel_val, eq_self_iff_true, or_false, dif_neg, not_false_iff, sum.lex_inr_inl, false_and] at h ⊢,
cases h₂; [exact asymm h h₂_h, exact e₂ rfl] },
{ simp only [e₂, dif_pos, eq_self_iff_true, dif_neg e₁, not_false_iff, sum.lex.sep] },
{ simpa only [dif_neg e₁, dif_neg e₂, prod.lex_def, subrel_val, subtype.mk_eq_mk, sum.lex_inl_inl] using h } }
end
theorem mul_le_of_limit {a b c : ordinal.{u}}
(h : is_limit b) : a * b ≤ c ↔ ∀ b' < b, a * b' ≤ c :=
⟨λ h b' l, le_trans (mul_le_mul_left _ (le_of_lt l)) h,
λ H, le_of_not_lt $ induction_on a (λ α r _, induction_on b $ λ β s _,
by exactI mul_le_of_limit_aux) h H⟩
theorem mul_is_normal {a : ordinal} (h : 0 < a) : is_normal ((*) a) :=
⟨λ b, by rw mul_succ; simpa only [add_zero] using (add_lt_add_iff_left (a*b)).2 h,
λ b l c, mul_le_of_limit l⟩
theorem lt_mul_of_limit {a b c : ordinal.{u}}
(h : is_limit c) : a < b * c ↔ ∃ c' < c, a < b * c' :=
by simpa only [not_ball, not_le] using not_congr (@mul_le_of_limit b c a h)
theorem mul_lt_mul_iff_left {a b c : ordinal} (a0 : 0 < a) : a * b < a * c ↔ b < c :=
(mul_is_normal a0).lt_iff
theorem mul_le_mul_iff_left {a b c : ordinal} (a0 : 0 < a) : a * b ≤ a * c ↔ b ≤ c :=
(mul_is_normal a0).le_iff
theorem mul_lt_mul_of_pos_left {a b c : ordinal}
(h : a < b) (c0 : 0 < c) : c * a < c * b :=
(mul_lt_mul_iff_left c0).2 h
theorem mul_pos {a b : ordinal} (h₁ : 0 < a) (h₂ : 0 < b) : 0 < a * b :=
by simpa only [mul_zero] using mul_lt_mul_of_pos_left h₂ h₁
theorem mul_ne_zero {a b : ordinal} : a ≠ 0 → b ≠ 0 → a * b ≠ 0 :=
by simpa only [pos_iff_ne_zero] using mul_pos
theorem le_of_mul_le_mul_left {a b c : ordinal}
(h : c * a ≤ c * b) (h0 : 0 < c) : a ≤ b :=
le_imp_le_of_lt_imp_lt (λ h', mul_lt_mul_of_pos_left h' h0) h
theorem mul_left_inj {a b c : ordinal} (a0 : 0 < a) : a * b = a * c ↔ b = c :=
(mul_is_normal a0).inj
theorem mul_is_limit {a b : ordinal}
(a0 : 0 < a) : is_limit b → is_limit (a * b) :=
(mul_is_normal a0).is_limit
theorem mul_is_limit_left {a b : ordinal}
(l : is_limit a) (b0 : 0 < b) : is_limit (a * b) :=
begin
rcases zero_or_succ_or_limit b with rfl|⟨b,rfl⟩|lb,
{ exact (lt_irrefl _).elim b0 },
{ rw mul_succ, exact add_is_limit _ l },
{ exact mul_is_limit l.pos lb }
end
/-- `a / b` is the unique ordinal `o` satisfying
`a = b * o + o'` with `o' < b`. -/
protected def div (a b : ordinal.{u}) : ordinal.{u} :=
if h : b = 0 then 0 else
omin {o | a < b * succ o} ⟨a, succ_le.1 $
by simpa only [succ_zero, one_mul] using mul_le_mul_right (succ a) (succ_le.2 (pos_iff_ne_zero.2 h))⟩
instance : has_div ordinal := ⟨ordinal.div⟩
@[simp] theorem div_zero (a : ordinal) : a / 0 = 0 := dif_pos rfl
def div_def (a) {b : ordinal} (h : b ≠ 0) : a / b =
omin {o | a < b * succ o} _ := dif_neg h
theorem lt_mul_succ_div (a) {b : ordinal} (h : b ≠ 0) : a < b * succ (a / b) :=
by rw div_def a h; exact omin_mem {o | a < b * succ o} _
theorem lt_mul_div_add (a) {b : ordinal} (h : b ≠ 0) : a < b * (a / b) + b :=
by simpa only [mul_succ] using lt_mul_succ_div a h
theorem div_le {a b c : ordinal} (b0 : b ≠ 0) : a / b ≤ c ↔ a < b * succ c :=
⟨λ h, lt_of_lt_of_le (lt_mul_succ_div a b0) (mul_le_mul_left _ $ succ_le_succ.2 h),
λ h, by rw div_def a b0; exact omin_le h⟩
theorem lt_div {a b c : ordinal} (c0 : c ≠ 0) : a < b / c ↔ c * succ a ≤ b :=
by rw [← not_le, div_le c0, not_lt]
theorem le_div {a b c : ordinal} (c0 : c ≠ 0) :
a ≤ b / c ↔ c * a ≤ b :=
begin
apply limit_rec_on a,
{ simp only [mul_zero, zero_le] },
{ intros, rw [succ_le, lt_div c0] },
{ simp only [mul_le_of_limit, limit_le, iff_self, forall_true_iff] {contextual := tt} }
end
theorem div_lt {a b c : ordinal} (b0 : b ≠ 0) :
a / b < c ↔ a < b * c :=
lt_iff_lt_of_le_iff_le $ le_div b0
theorem div_le_of_le_mul {a b c : ordinal} (h : a ≤ b * c) : a / b ≤ c :=
if b0 : b = 0 then by simp only [b0, div_zero, zero_le] else
(div_le b0).2 $ lt_of_le_of_lt h $
mul_lt_mul_of_pos_left (lt_succ_self _) (pos_iff_ne_zero.2 b0)
theorem mul_lt_of_lt_div {a b c : ordinal} : a < b / c → c * a < b :=
lt_imp_lt_of_le_imp_le div_le_of_le_mul
@[simp] theorem zero_div (a : ordinal) : 0 / a = 0 :=
le_zero.1 $ div_le_of_le_mul $ zero_le _
theorem mul_div_le (a b : ordinal) : b * (a / b) ≤ a :=
if b0 : b = 0 then by simp only [b0, zero_mul, zero_le] else (le_div b0).1 (le_refl _)
theorem mul_add_div (a) {b : ordinal} (b0 : b ≠ 0) (c) : (b * a + c) / b = a + c / b :=
begin
apply le_antisymm,
{ apply (div_le b0).2,
rw [mul_succ, mul_add, add_assoc, add_lt_add_iff_left],
apply lt_mul_div_add _ b0 },
{ rw [le_div b0, mul_add, add_le_add_iff_left],
apply mul_div_le }
end
theorem div_eq_zero_of_lt {a b : ordinal} (h : a < b) : a / b = 0 :=
by rw [← le_zero, div_le $ pos_iff_ne_zero.1 $ lt_of_le_of_lt (zero_le _) h];
simpa only [succ_zero, mul_one] using h
@[simp] theorem mul_div_cancel (a) {b : ordinal} (b0 : b ≠ 0) : b * a / b = a :=
by simpa only [add_zero, zero_div] using mul_add_div a b0 0
@[simp] theorem div_one (a : ordinal) : a / 1 = a :=
by simpa only [one_mul] using mul_div_cancel a one_ne_zero
@[simp] theorem div_self {a : ordinal} (h : a ≠ 0) : a / a = 1 :=
by simpa only [mul_one] using mul_div_cancel 1 h
theorem mul_sub (a b c : ordinal) : a * (b - c) = a * b - a * c :=
if a0 : a = 0 then by simp only [a0, zero_mul, sub_self] else
eq_of_forall_ge_iff $ λ d,
by rw [sub_le, ← le_div a0, sub_le, ← le_div a0, mul_add_div _ a0]
/-- Divisibility is defined by right multiplication:
`a ∣ b` if there exists `c` such that `b = a * c`. -/
instance : has_dvd ordinal := ⟨λ a b, ∃ c, b = a * c⟩
theorem dvd_def {a b : ordinal} : a ∣ b ↔ ∃ c, b = a * c := iff.rfl
theorem dvd_mul (a b : ordinal) : a ∣ a * b := ⟨_, rfl⟩
theorem dvd_trans : ∀ {a b c : ordinal}, a ∣ b → b ∣ c → a ∣ c
| a _ _ ⟨b, rfl⟩ ⟨c, rfl⟩ := ⟨b * c, mul_assoc _ _ _⟩
theorem dvd_mul_of_dvd {a b : ordinal} (c) (h : a ∣ b) : a ∣ b * c :=
dvd_trans h (dvd_mul _ _)
theorem dvd_add_iff : ∀ {a b c : ordinal}, a ∣ b → (a ∣ b + c ↔ a ∣ c)
| a _ c ⟨b, rfl⟩ :=
⟨λ ⟨d, e⟩, ⟨d - b, by rw [mul_sub, ← e, add_sub_cancel]⟩,
λ ⟨d, e⟩, by rw [e, ← mul_add]; apply dvd_mul⟩
theorem dvd_add {a b c : ordinal} (h₁ : a ∣ b) : a ∣ c → a ∣ b + c :=
(dvd_add_iff h₁).2
theorem dvd_zero (a : ordinal) : a ∣ 0 := ⟨_, (mul_zero _).symm⟩
theorem zero_dvd {a : ordinal} : 0 ∣ a ↔ a = 0 :=
⟨λ ⟨h, e⟩, by simp only [e, zero_mul], λ e, e.symm ▸ dvd_zero _⟩
theorem one_dvd (a : ordinal) : 1 ∣ a := ⟨a, (one_mul _).symm⟩
theorem div_mul_cancel : ∀ {a b : ordinal}, a ≠ 0 → a ∣ b → a * (b / a) = b
| a _ a0 ⟨b, rfl⟩ := by rw [mul_div_cancel _ a0]
theorem le_of_dvd : ∀ {a b : ordinal}, b ≠ 0 → a ∣ b → a ≤ b
| a _ b0 ⟨b, rfl⟩ := by simpa only [mul_one] using mul_le_mul_left a
(one_le_iff_ne_zero.2 (λ h : b = 0, by simpa only [h, mul_zero] using b0))
theorem dvd_antisymm {a b : ordinal} (h₁ : a ∣ b) (h₂ : b ∣ a) : a = b :=
if a0 : a = 0 then by subst a; exact (zero_dvd.1 h₁).symm else
if b0 : b = 0 then by subst b; exact zero_dvd.1 h₂ else
le_antisymm (le_of_dvd b0 h₁) (le_of_dvd a0 h₂)
/-- `a % b` is the unique ordinal `o'` satisfying
`a = b * o + o'` with `o' < b`. -/
instance : has_mod ordinal := ⟨λ a b, a - b * (a / b)⟩
theorem mod_def (a b : ordinal) : a % b = a - b * (a / b) := rfl
@[simp] theorem mod_zero (a : ordinal) : a % 0 = a :=
by simp only [mod_def, div_zero, zero_mul, sub_zero]
theorem mod_eq_of_lt {a b : ordinal} (h : a < b) : a % b = a :=
by simp only [mod_def, div_eq_zero_of_lt h, mul_zero, sub_zero]
@[simp] theorem zero_mod (b : ordinal) : 0 % b = 0 :=
by simp only [mod_def, zero_div, mul_zero, sub_self]
theorem div_add_mod (a b : ordinal) : b * (a / b) + a % b = a :=
add_sub_cancel_of_le $ mul_div_le _ _
theorem mod_lt (a) {b : ordinal} (h : b ≠ 0) : a % b < b :=
(add_lt_add_iff_left (b * (a / b))).1 $
by rw div_add_mod; exact lt_mul_div_add a h
@[simp] theorem mod_self (a : ordinal) : a % a = 0 :=
if a0 : a = 0 then by simp only [a0, zero_mod] else
by simp only [mod_def, div_self a0, mul_one, sub_self]
@[simp] theorem mod_one (a : ordinal) : a % 1 = 0 :=
by simp only [mod_def, div_one, one_mul, sub_self]
end ordinal
namespace cardinal
open ordinal
/-- The ordinal corresponding to a cardinal `c` is the least ordinal
whose cardinal is `c`. -/
def ord (c : cardinal) : ordinal :=
begin
let ι := λ α, {r // is_well_order α r},
have : Π α, ι α := λ α, ⟨well_ordering_rel, by apply_instance⟩,
let F := λ α, ordinal.min ⟨this _⟩ (λ i:ι α, ⟦⟨α, i.1, i.2⟩⟧),
refine quot.lift_on c F _,
suffices : ∀ {α β}, α ≈ β → F α ≤ F β,
from λ α β h, le_antisymm (this h) (this (setoid.symm h)),
intros α β h, cases h with f, refine ordinal.le_min.2 (λ i, _),
haveI := @order_embedding.is_well_order _ _
(f ⁻¹'o i.1) _ ↑(order_iso.preimage f i.1) i.2,
rw ← show type (f ⁻¹'o i.1) = ⟦⟨β, i.1, i.2⟩⟧, from
quot.sound ⟨order_iso.preimage f i.1⟩,
exact ordinal.min_le (λ i:ι α, ⟦⟨α, i.1, i.2⟩⟧) ⟨_, _⟩
end
def ord_eq_min (α : Type u) : ord (mk α) =
@ordinal.min _ _ (λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) := rfl
theorem ord_eq (α) : ∃ (r : α → α → Prop) [wo : is_well_order α r],
ord (mk α) = @type α r wo :=
let ⟨⟨r, wo⟩, h⟩ := @ordinal.min_eq {r // is_well_order α r}
⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) in
⟨r, wo, h⟩
theorem ord_le_type (r : α → α → Prop) [is_well_order α r] : ord (mk α) ≤ ordinal.type r :=
@ordinal.min_le {r // is_well_order α r}
⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) ⟨r, _⟩
theorem ord_le {c o} : ord c ≤ o ↔ c ≤ o.card :=
quotient.induction_on c $ λ α, induction_on o $ λ β s _,
let ⟨r, _, e⟩ := ord_eq α in begin
resetI, simp only [mk_def, card_type], split; intro h,
{ rw e at h, exact let ⟨f⟩ := h in ⟨f.to_embedding⟩ },
{ cases h with f,
have g := order_embedding.preimage f s,
haveI := order_embedding.is_well_order g,
exact le_trans (ord_le_type _) (type_le'.2 ⟨g⟩) }
end
theorem lt_ord {c o} : o < ord c ↔ o.card < c :=
by rw [← not_le, ← not_le, ord_le]
@[simp] theorem card_ord (c) : (ord c).card = c :=
quotient.induction_on c $ λ α,
let ⟨r, _, e⟩ := ord_eq α in by simp only [mk_def, e, card_type]
theorem ord_card_le (o : ordinal) : o.card.ord ≤ o :=
ord_le.2 (le_refl _)
lemma lt_ord_succ_card (o : ordinal) : o < o.card.succ.ord :=
by { rw [lt_ord], apply cardinal.lt_succ_self }
@[simp] theorem ord_le_ord {c₁ c₂} : ord c₁ ≤ ord c₂ ↔ c₁ ≤ c₂ :=
by simp only [ord_le, card_ord]
@[simp] theorem ord_lt_ord {c₁ c₂} : ord c₁ < ord c₂ ↔ c₁ < c₂ :=
by simp only [lt_ord, card_ord]
@[simp] theorem ord_zero : ord 0 = 0 :=
le_antisymm (ord_le.2 $ zero_le _) (ordinal.zero_le _)
@[simp] theorem ord_nat (n : ℕ) : ord n = n :=
le_antisymm (ord_le.2 $ by simp only [card_nat]) $ begin
induction n with n IH,
{ apply ordinal.zero_le },
{ exact (@ordinal.succ_le n _).2 (lt_of_le_of_lt IH $
ord_lt_ord.2 $ nat_cast_lt.2 (nat.lt_succ_self n)) }
end
@[simp] theorem lift_ord (c) : (ord c).lift = ord (lift c) :=
eq_of_forall_ge_iff $ λ o, le_iff_le_iff_lt_iff_lt.2 $ begin
split; intro h,
{ rcases ordinal.lt_lift_iff.1 h with ⟨a, e, h⟩,
rwa [← e, lt_ord, ← lift_card, lift_lt, ← lt_ord] },
{ rw lt_ord at h,
rcases lift_down' (le_of_lt h) with ⟨o, rfl⟩,
rw [← lift_card, lift_lt] at h,
rwa [ordinal.lift_lt, lt_ord] }
end
lemma mk_ord_out (c : cardinal) : mk c.ord.out.α = c :=
by rw [←card_type c.ord.out.r, type_out, card_ord]
lemma card_typein_lt (r : α → α → Prop) [is_well_order α r] (x : α)
(h : ord (mk α) = type r) : card (typein r x) < mk α :=
by { rw [←ord_lt_ord, h], refine lt_of_le_of_lt (ord_card_le _) (typein_lt_type r x) }
lemma card_typein_out_lt (c : cardinal) (x : c.ord.out.α) : card (typein c.ord.out.r x) < c :=
by { convert card_typein_lt c.ord.out.r x _, rw [mk_ord_out], rw [type_out, mk_ord_out] }
lemma ord_injective : injective ord :=
by { intros c c' h, rw [←card_ord c, ←card_ord c', h] }
def ord.order_embedding : @order_embedding cardinal ordinal (<) (<) :=
order_embedding.of_monotone cardinal.ord $ λ a b, cardinal.ord_lt_ord.2
@[simp] theorem ord.order_embedding_coe :
(ord.order_embedding : cardinal → ordinal) = ord := rfl
/-- The cardinal `univ` is the cardinality of ordinal `univ`, or
equivalently the cardinal of `ordinal.{u}`, or `cardinal.{u}`,
as an element of `cardinal.{v}` (when `u < v`). -/
def univ := lift.{(u+1) v} (mk ordinal)
theorem univ_id : univ.{u (u+1)} = mk ordinal := lift_id _
@[simp] theorem lift_univ : lift.{_ w} univ.{u v} = univ.{u (max v w)} := lift_lift _
theorem univ_umax : univ.{u (max (u+1) v)} = univ.{u v} := congr_fun lift_umax _
theorem lift_lt_univ (c : cardinal) : lift.{u (u+1)} c < univ.{u (u+1)} :=
by simpa only [lift.principal_seg_coe, lift_ord, lift_succ, ord_le, succ_le] using le_of_lt
(lift.principal_seg.{u (u+1)}.lt_top (succ c).ord)
theorem lift_lt_univ' (c : cardinal) : lift.{u (max (u+1) v)} c < univ.{u v} :=
by simpa only [lift_lift, lift_univ, univ_umax] using
lift_lt.{_ (max (u+1) v)}.2 (lift_lt_univ c)
@[simp] theorem ord_univ : ord univ.{u v} = ordinal.univ.{u v} :=
le_antisymm (ord_card_le _) $ le_of_forall_lt $ λ o h,
lt_ord.2 begin
rcases lift.principal_seg.{u v}.down'.1
(by simpa only [lift.principal_seg_coe] using h) with ⟨o', rfl⟩,
simp only [lift.principal_seg_coe], rw [← lift_card],
apply lift_lt_univ'
end
theorem lt_univ {c} : c < univ.{u (u+1)} ↔ ∃ c', c = lift.{u (u+1)} c' :=
⟨λ h, begin
have := ord_lt_ord.2 h,
rw ord_univ at this,
cases lift.principal_seg.{u (u+1)}.down'.1
(by simpa only [lift.principal_seg_top]) with o e,
have := card_ord c,
rw [← e, lift.principal_seg_coe, ← lift_card] at this,
exact ⟨_, this.symm⟩
end, λ ⟨c', e⟩, e.symm ▸ lift_lt_univ _⟩
theorem lt_univ' {c} : c < univ.{u v} ↔ ∃ c', c = lift.{u (max (u+1) v)} c' :=
⟨λ h, let ⟨a, e, h'⟩ := lt_lift_iff.1 h in begin
rw [← univ_id] at h',
rcases lt_univ.{u}.1 h' with ⟨c', rfl⟩,
exact ⟨c', by simp only [e.symm, lift_lift]⟩
end, λ ⟨c', e⟩, e.symm ▸ lift_lt_univ' _⟩
end cardinal
namespace ordinal
@[simp] theorem card_univ : card univ = cardinal.univ := rfl
/-- The supremum of a family of ordinals -/
def sup {ι} (f : ι → ordinal) : ordinal :=
omin {c | ∀ i, f i ≤ c}
⟨(sup (cardinal.succ ∘ card ∘ f)).ord, λ i, le_of_lt $
cardinal.lt_ord.2 (lt_of_lt_of_le (cardinal.lt_succ_self _) (le_sup _ _))⟩
theorem le_sup {ι} (f : ι → ordinal) : ∀ i, f i ≤ sup f :=
omin_mem {c | ∀ i, f i ≤ c} _
theorem sup_le {ι} {f : ι → ordinal} {a} : sup f ≤ a ↔ ∀ i, f i ≤ a :=
⟨λ h i, le_trans (le_sup _ _) h, λ h, omin_le h⟩
theorem lt_sup {ι} {f : ι → ordinal} {a} : a < sup f ↔ ∃ i, a < f i :=
by simpa only [not_forall, not_le] using not_congr (@sup_le _ f a)
theorem is_normal.sup {f} (H : is_normal f)
{ι} {g : ι → ordinal} (h : nonempty ι) : f (sup g) = sup (f ∘ g) :=
eq_of_forall_ge_iff $ λ a,
by rw [sup_le, comp, H.le_set' (λ_:ι, true) g (let ⟨i⟩ := h in ⟨i, ⟨⟩⟩)];
intros; simp only [sup_le, true_implies_iff]
theorem sup_ord {ι} (f : ι → cardinal) : sup (λ i, (f i).ord) = (cardinal.sup f).ord :=
eq_of_forall_ge_iff $ λ a, by simp only [sup_le, cardinal.ord_le, cardinal.sup_le]
lemma sup_succ {ι} (f : ι → ordinal) : sup (λ i, succ (f i)) ≤ succ (sup f) :=
by { rw [ordinal.sup_le], intro i, rw ordinal.succ_le_succ, apply ordinal.le_sup }
lemma unbounded_range_of_sup_ge {α β : Type u} (r : α → α → Prop) [is_well_order α r] (f : β → α)
(h : sup.{u u} (typein r ∘ f) ≥ type r) : unbounded r (range f) :=
begin
apply (not_bounded_iff _).mp, rintro ⟨x, hx⟩, apply not_lt_of_ge h,
refine lt_of_le_of_lt _ (typein_lt_type r x), rw [sup_le], intro y,
apply le_of_lt, rw typein_lt_typein, apply hx, apply mem_range_self
end
/-- The supremum of a family of ordinals indexed by the set
of ordinals less than some `o : ordinal.{u}`.
(This is not a special case of `sup` over the subtype,
because `{a // a < o} : Type (u+1)` and `sup` only works over
families in `Type u`.) -/
def bsup (o : ordinal.{u}) : (Π a < o, ordinal.{max u v}) → ordinal.{max u v} :=
match o, o.out, o.out_eq with
| _, ⟨α, r, _⟩, rfl, f := by exactI sup (λ a, f (typein r a) (typein_lt_type _ _))
end
theorem bsup_le {o f a} : bsup.{u v} o f ≤ a ↔ ∀ i h, f i h ≤ a :=
match o, o.out, o.out_eq, f :
∀ o w (e : ⟦w⟧ = o) (f : Π (a : ordinal.{u}), a < o → ordinal.{(max u v)}),
bsup._match_1 o w e f ≤ a ↔ ∀ i h, f i h ≤ a with
| _, ⟨α, r, _⟩, rfl, f := by rw [bsup._match_1, sup_le]; exactI
⟨λ H i h, by simpa only [typein_enum] using H (enum r i h), λ H b, H _ _⟩
end
theorem bsup_type (r : α → α → Prop) [is_well_order α r] (f) :
bsup (type r) f = sup (λ a, f (typein r a) (typein_lt_type _ _)) :=
eq_of_forall_ge_iff $ λ o,
by rw [bsup_le, sup_le]; exact
⟨λ H b, H _ _, λ H i h, by simpa only [typein_enum] using H (enum r i h)⟩
theorem le_bsup {o} (f : Π a < o, ordinal) (i h) : f i h ≤ bsup o f :=
bsup_le.1 (le_refl _) _ _
theorem is_normal.bsup {f} (H : is_normal f)
{o : ordinal} : ∀ (g : Π a < o, ordinal) (h : o ≠ 0),
f (bsup o g) = bsup o (λ a h, f (g a h)) :=
induction_on o $ λ α r _ g h,
by resetI; rw [bsup_type,
H.sup (type_ne_zero_iff_nonempty.1 h), bsup_type]
/-- The ordinal exponential, defined by transfinite recursion. -/
def power (a b : ordinal) : ordinal :=
if a = 0 then 1 - b else
limit_rec_on b 1 (λ _ IH, IH * a) (λ b _, bsup.{u u} b)
instance : has_pow ordinal ordinal := ⟨power⟩
local infixr ^ := @pow ordinal ordinal ordinal.has_pow
theorem zero_power' (a : ordinal) : 0 ^ a = 1 - a :=
by simp only [pow, power, if_pos rfl]
@[simp] theorem zero_power {a : ordinal} (a0 : a ≠ 0) : 0 ^ a = 0 :=
by rwa [zero_power', sub_eq_zero_iff_le, one_le_iff_ne_zero]
@[simp] theorem power_zero (a : ordinal) : a ^ 0 = 1 :=
by by_cases a = 0; [simp only [pow, power, if_pos h, sub_zero],
simp only [pow, power, if_neg h, limit_rec_on_zero]]
@[simp] theorem power_succ (a b : ordinal) : a ^ succ b = a ^ b * a :=
if h : a = 0 then by subst a; simp only [zero_power (succ_ne_zero _), mul_zero]
else by simp only [pow, power, limit_rec_on_succ, if_neg h]
theorem power_limit {a b : ordinal} (a0 : a ≠ 0) (h : is_limit b) :
a ^ b = bsup.{u u} b (λ c _, a ^ c) :=
by simp only [pow, power, if_neg a0]; rw limit_rec_on_limit _ _ _ _ h; refl
theorem power_le_of_limit {a b c : ordinal} (a0 : a ≠ 0) (h : is_limit b) :
a ^ b ≤ c ↔ ∀ b' < b, a ^ b' ≤ c :=
by rw [power_limit a0 h, bsup_le]
theorem lt_power_of_limit {a b c : ordinal} (b0 : b ≠ 0) (h : is_limit c) :
a < b ^ c ↔ ∃ c' < c, a < b ^ c' :=
by rw [← not_iff_not, not_exists]; simp only [not_lt, power_le_of_limit b0 h, exists_prop, not_and]
@[simp] theorem power_one (a : ordinal) : a ^ 1 = a :=
by rw [← succ_zero, power_succ]; simp only [power_zero, one_mul]
@[simp] theorem one_power (a : ordinal) : 1 ^ a = 1 :=
begin
apply limit_rec_on a,
{ simp only [power_zero] },
{ intros _ ih, simp only [power_succ, ih, mul_one] },
refine λ b l IH, eq_of_forall_ge_iff (λ c, _),
rw [power_le_of_limit one_ne_zero l],
exact ⟨λ H, by simpa only [power_zero] using H 0 l.pos,
λ H b' h, by rwa IH _ h⟩,
end
theorem power_pos {a : ordinal} (b)
(a0 : 0 < a) : 0 < a ^ b :=
begin
have h0 : 0 < a ^ 0, {simp only [power_zero, zero_lt_one]},
apply limit_rec_on b,
{ exact h0 },
{ intros b IH, rw [power_succ],
exact mul_pos IH a0 },
{ exact λ b l _, (lt_power_of_limit (pos_iff_ne_zero.1 a0) l).2
⟨0, l.pos, h0⟩ },
end
theorem power_ne_zero {a : ordinal} (b)
(a0 : a ≠ 0) : a ^ b ≠ 0 :=
pos_iff_ne_zero.1 $ power_pos b $ pos_iff_ne_zero.2 a0
theorem power_is_normal {a : ordinal} (h : 1 < a) : is_normal ((^) a) :=
have a0 : 0 < a, from lt_trans zero_lt_one h,
⟨λ b, by simpa only [mul_one, power_succ] using
(mul_lt_mul_iff_left (power_pos b a0)).2 h,
λ b l c, power_le_of_limit (ne_of_gt a0) l⟩
theorem power_lt_power_iff_right {a b c : ordinal}
(a1 : 1 < a) : a ^ b < a ^ c ↔ b < c :=
(power_is_normal a1).lt_iff
theorem power_le_power_iff_right {a b c : ordinal}
(a1 : 1 < a) : a ^ b ≤ a ^ c ↔ b ≤ c :=
(power_is_normal a1).le_iff
theorem power_right_inj {a b c : ordinal}
(a1 : 1 < a) : a ^ b = a ^ c ↔ b = c :=
(power_is_normal a1).inj
theorem power_is_limit {a b : ordinal}
(a1 : 1 < a) : is_limit b → is_limit (a ^ b) :=
(power_is_normal a1).is_limit
theorem power_is_limit_left {a b : ordinal}
(l : is_limit a) (hb : b ≠ 0) : is_limit (a ^ b) :=
begin
rcases zero_or_succ_or_limit b with e|⟨b,rfl⟩|l',
{ exact absurd e hb },
{ rw power_succ,
exact mul_is_limit (power_pos _ l.pos) l },
{ exact power_is_limit l.one_lt l' }
end
theorem power_le_power_right {a b c : ordinal}
(h₁ : 0 < a) (h₂ : b ≤ c) : a ^ b ≤ a ^ c :=
begin
cases lt_or_eq_of_le (one_le_iff_pos.2 h₁) with h₁ h₁,
{ exact (power_le_power_iff_right h₁).2 h₂ },
{ subst a, simp only [one_power] }
end
theorem power_le_power_left {a b : ordinal} (c)
(ab : a ≤ b) : a ^ c ≤ b ^ c :=
begin
by_cases a0 : a = 0,
{ subst a, by_cases c0 : c = 0,
{ subst c, simp only [power_zero] },
{ simp only [zero_power c0, zero_le] } },
{ apply limit_rec_on c,
{ simp only [power_zero] },
{ intros c IH, simpa only [power_succ] using mul_le_mul IH ab },
{ exact λ c l IH, (power_le_of_limit a0 l).2
(λ b' h, le_trans (IH _ h) (power_le_power_right
(lt_of_lt_of_le (pos_iff_ne_zero.2 a0) ab) (le_of_lt h))) } }
end
theorem le_power_self {a : ordinal} (b) (a1 : 1 < a) : b ≤ a ^ b :=
(power_is_normal a1).le_self _
theorem power_lt_power_left_of_succ {a b c : ordinal}
(ab : a < b) : a ^ succ c < b ^ succ c :=
by rw [power_succ, power_succ]; exact
lt_of_le_of_lt
(mul_le_mul_right _ $ power_le_power_left _ $ le_of_lt ab)
(mul_lt_mul_of_pos_left ab (power_pos _ (lt_of_le_of_lt (zero_le _) ab)))
theorem power_add (a b c : ordinal) : a ^ (b + c) = a ^ b * a ^ c :=
begin
by_cases a0 : a = 0,
{ subst a,
by_cases c0 : c = 0, {simp only [c0, add_zero, power_zero, mul_one]},
have : b+c ≠ 0 := ne_of_gt (lt_of_lt_of_le
(pos_iff_ne_zero.2 c0) (le_add_left _ _)),
simp only [zero_power c0, zero_power this, mul_zero] },
cases eq_or_lt_of_le (one_le_iff_ne_zero.2 a0) with a1 a1,
{ subst a1, simp only [one_power, mul_one] },
apply limit_rec_on c,
{ simp only [add_zero, power_zero, mul_one] },
{ intros c IH,
rw [add_succ, power_succ, IH, power_succ, mul_assoc] },
{ intros c l IH,
refine eq_of_forall_ge_iff (λ d, (((power_is_normal a1).trans
(add_is_normal b)).limit_le l).trans _),
simp only [IH] {contextual := tt},
exact (((mul_is_normal $ power_pos b (pos_iff_ne_zero.2 a0)).trans
(power_is_normal a1)).limit_le l).symm }
end
theorem power_dvd_power (a) {b c : ordinal}
(h : b ≤ c) : a ^ b ∣ a ^ c :=
by rw [← add_sub_cancel_of_le h, power_add]; apply dvd_mul
theorem power_dvd_power_iff {a b c : ordinal}
(a1 : 1 < a) : a ^ b ∣ a ^ c ↔ b ≤ c :=
⟨λ h, le_of_not_lt $ λ hn,
not_le_of_lt ((power_lt_power_iff_right a1).2 hn) $
le_of_dvd (power_ne_zero _ $ one_le_iff_ne_zero.1 $ le_of_lt a1) h,
power_dvd_power _⟩
theorem power_mul (a b c : ordinal) : a ^ (b * c) = (a ^ b) ^ c :=
begin
by_cases b0 : b = 0, {simp only [b0, zero_mul, power_zero, one_power]},
by_cases a0 : a = 0,
{ subst a,
by_cases c0 : c = 0, {simp only [c0, mul_zero, power_zero]},
simp only [zero_power b0, zero_power c0, zero_power (mul_ne_zero b0 c0)] },
cases eq_or_lt_of_le (one_le_iff_ne_zero.2 a0) with a1 a1,
{ subst a1, simp only [one_power] },
apply limit_rec_on c,
{ simp only [mul_zero, power_zero] },
{ intros c IH,
rw [mul_succ, power_add, IH, power_succ] },
{ intros c l IH,
refine eq_of_forall_ge_iff (λ d, (((power_is_normal a1).trans
(mul_is_normal (pos_iff_ne_zero.2 b0))).limit_le l).trans _),
simp only [IH] {contextual := tt},
exact (power_le_of_limit (power_ne_zero _ a0) l).symm }
end
/-- The ordinal logarithm is the solution `u` to the equation
`x = b ^ u * v + w` where `v < b` and `w < b`. -/
def log (b : ordinal) (x : ordinal) : ordinal :=
if h : 1 < b then pred $
omin {o | x < b^o} ⟨succ x, succ_le.1 (le_power_self _ h)⟩
else 0
@[simp] theorem log_not_one_lt {b : ordinal} (b1 : ¬ 1 < b) (x : ordinal) : log b x = 0 :=
by simp only [log, dif_neg b1]
theorem log_def {b : ordinal} (b1 : 1 < b) (x : ordinal) : log b x =
pred (omin {o | x < b^o} (log._proof_1 b x b1)) :=
by simp only [log, dif_pos b1]
@[simp] theorem log_zero (b : ordinal) : log b 0 = 0 :=
if b1 : 1 < b then
by rw [log_def b1, ← le_zero, pred_le];
apply omin_le; change 0<b^succ 0;
rw [succ_zero, power_one];
exact lt_trans zero_lt_one b1
else by simp only [log_not_one_lt b1]
theorem succ_log_def {b x : ordinal} (b1 : 1 < b) (x0 : 0 < x) : succ (log b x) =
omin {o | x < b^o} (log._proof_1 b x b1) :=
begin
let t := omin {o | x < b^o} (log._proof_1 b x b1),
have : x < b ^ t := omin_mem {o | x < b^o} _,
rcases zero_or_succ_or_limit t with h|h|h,
{ refine (not_lt_of_le (one_le_iff_pos.2 x0) _).elim,
simpa only [h, power_zero] },
{ rw [show log b x = pred t, from log_def b1 x,
succ_pred_iff_is_succ.2 h] },
{ rcases (lt_power_of_limit (ne_of_gt $ lt_trans zero_lt_one b1) h).1 this with ⟨a, h₁, h₂⟩,
exact (not_le_of_lt h₁).elim (le_omin.1 (le_refl t) a h₂) }
end
theorem lt_power_succ_log {b : ordinal} (b1 : 1 < b) (x : ordinal) :
x < b ^ succ (log b x) :=
begin
cases lt_or_eq_of_le (zero_le x) with x0 x0,
{ rw [succ_log_def b1 x0], exact omin_mem {o | x < b^o} _ },
{ subst x, apply power_pos _ (lt_trans zero_lt_one b1) }
end
theorem power_log_le (b) {x : ordinal} (x0 : 0 < x) :
b ^ log b x ≤ x :=
begin
by_cases b0 : b = 0,
{ rw [b0, zero_power'],
refine le_trans (sub_le_self _ _) (one_le_iff_pos.2 x0) },
cases lt_or_eq_of_le (one_le_iff_ne_zero.2 b0) with b1 b1,
{ refine le_of_not_lt (λ h, not_le_of_lt (lt_succ_self (log b x)) _),
have := @omin_le {o | x < b^o} _ _ h,
rwa ← succ_log_def b1 x0 at this },
{ rw [← b1, one_power], exact one_le_iff_pos.2 x0 }
end
theorem le_log {b x c : ordinal} (b1 : 1 < b) (x0 : 0 < x) :
c ≤ log b x ↔ b ^ c ≤ x :=
⟨λ h, le_trans ((power_le_power_iff_right b1).2 h) (power_log_le b x0),
λ h, le_of_not_lt $ λ hn,
not_le_of_lt (lt_power_succ_log b1 x) $
le_trans ((power_le_power_iff_right b1).2 (succ_le.2 hn)) h⟩
theorem log_lt {b x c : ordinal} (b1 : 1 < b) (x0 : 0 < x) :
log b x < c ↔ x < b ^ c :=
lt_iff_lt_of_le_iff_le (le_log b1 x0)
theorem log_le_log (b) {x y : ordinal} (xy : x ≤ y) :
log b x ≤ log b y :=
if x0 : x = 0 then by simp only [x0, log_zero, zero_le] else
have x0 : 0 < x, from pos_iff_ne_zero.2 x0,
if b1 : 1 < b then
(le_log b1 (lt_of_lt_of_le x0 xy)).2 $ le_trans (power_log_le _ x0) xy
else by simp only [log_not_one_lt b1, zero_le]
theorem log_le_self (b x : ordinal) : log b x ≤ x :=
if x0 : x = 0 then by simp only [x0, log_zero, zero_le] else
if b1 : 1 < b then
le_trans (le_power_self _ b1) (power_log_le b (pos_iff_ne_zero.2 x0))
else by simp only [log_not_one_lt b1, zero_le]
@[simp] theorem nat_cast_mul {m n : ℕ} : ((m * n : ℕ) : ordinal) = m * n :=
by induction n with n IH; [simp only [nat.cast_zero, nat.mul_zero, mul_zero],
rw [nat.mul_succ, nat.cast_add, IH, nat.cast_succ, mul_add_one]]
@[simp] theorem nat_cast_power {m n : ℕ} : ((pow m n : ℕ) : ordinal) = m ^ n :=
by induction n with n IH; [simp only [nat.pow_zero, nat.cast_zero, power_zero, nat.cast_one],
rw [nat.pow_succ, nat_cast_mul, IH, nat.cast_succ, ← succ_eq_add_one, power_succ]]
@[simp] theorem nat_cast_le {m n : ℕ} : (m : ordinal) ≤ n ↔ m ≤ n :=
by rw [← cardinal.ord_nat, ← cardinal.ord_nat,
cardinal.ord_le_ord, cardinal.nat_cast_le]
@[simp] theorem nat_cast_lt {m n : ℕ} : (m : ordinal) < n ↔ m < n :=
by simp only [lt_iff_le_not_le, nat_cast_le]
@[simp] theorem nat_cast_inj {m n : ℕ} : (m : ordinal) = n ↔ m = n :=
by simp only [le_antisymm_iff, nat_cast_le]
@[simp] theorem nat_cast_eq_zero {n : ℕ} : (n : ordinal) = 0 ↔ n = 0 :=
@nat_cast_inj n 0
@[simp] theorem nat_cast_ne_zero {n : ℕ} : (n : ordinal) ≠ 0 ↔ n ≠ 0 :=
not_congr nat_cast_eq_zero
@[simp] theorem nat_cast_pos {n : ℕ} : (0 : ordinal) < n ↔ 0 < n :=
@nat_cast_lt 0 n
@[simp] theorem nat_cast_sub {m n : ℕ} : ((m - n : ℕ) : ordinal) = m - n :=
(_root_.le_total m n).elim
(λ h, by rw [nat.sub_eq_zero_iff_le.2 h, sub_eq_zero_iff_le.2 (nat_cast_le.2 h)]; refl)
(λ h, (add_left_cancel n).1 $ by rw [← nat.cast_add,
nat.add_sub_cancel' h, add_sub_cancel_of_le (nat_cast_le.2 h)])
@[simp] theorem nat_cast_div {m n : ℕ} : ((m / n : ℕ) : ordinal) = m / n :=
if n0 : n = 0 then by simp only [n0, nat.div_zero, nat.cast_zero, div_zero] else
have n0':_, from nat_cast_ne_zero.2 n0,
le_antisymm
(by rw [le_div n0', ← nat_cast_mul, nat_cast_le, mul_comm];
apply nat.div_mul_le_self)
(by rw [div_le n0', succ, ← nat.cast_succ, ← nat_cast_mul,
nat_cast_lt, mul_comm, ← nat.div_lt_iff_lt_mul _ _ (nat.pos_of_ne_zero n0)];
apply nat.lt_succ_self)
@[simp] theorem nat_cast_mod {m n : ℕ} : ((m % n : ℕ) : ordinal) = m % n :=
by rw [← add_left_cancel (n*(m/n)), div_add_mod, ← nat_cast_div, ← nat_cast_mul, ← nat.cast_add,
add_comm, nat.mod_add_div]
@[simp] theorem nat_le_card {o} {n : ℕ} : (n : cardinal) ≤ card o ↔ (n : ordinal) ≤ o :=
⟨λ h, by rwa [← cardinal.ord_le, cardinal.ord_nat] at h,
λ h, card_nat n ▸ card_le_card h⟩
@[simp] theorem nat_lt_card {o} {n : ℕ} : (n : cardinal) < card o ↔ (n : ordinal) < o :=
by rw [← succ_le, ← cardinal.succ_le, cardinal.nat_succ, nat_le_card]; refl
@[simp] theorem card_lt_nat {o} {n : ℕ} : card o < n ↔ o < n :=
lt_iff_lt_of_le_iff_le nat_le_card
@[simp] theorem card_le_nat {o} {n : ℕ} : card o ≤ n ↔ o ≤ n :=
le_iff_le_iff_lt_iff_lt.2 nat_lt_card
@[simp] theorem card_eq_nat {o} {n : ℕ} : card o = n ↔ o = n :=
by simp only [le_antisymm_iff, card_le_nat, nat_le_card]
@[simp] theorem type_fin (n : ℕ) : @type (fin n) (<) _ = n :=
by rw [← card_eq_nat, card_type, mk_fin]
@[simp] theorem lift_nat_cast (n : ℕ) : lift n = n :=
by induction n with n ih; [simp only [nat.cast_zero, lift_zero],
simp only [nat.cast_succ, lift_add, ih, lift_one]]
theorem lift_type_fin (n : ℕ) : lift (@type (fin n) (<) _) = n :=
by simp only [type_fin, lift_nat_cast]
theorem fintype_card (r : α → α → Prop) [is_well_order α r] [fintype α] : type r = fintype.card α :=
by rw [← card_eq_nat, card_type, fintype_card]
end ordinal
namespace cardinal
open ordinal
@[simp] theorem ord_omega : ord.{u} omega = ordinal.omega :=
le_antisymm (ord_le.2 $ le_refl _) $
le_of_forall_lt $ λ o h, begin
rcases ordinal.lt_lift_iff.1 h with ⟨o, rfl, h'⟩,
rw [lt_ord, ← lift_card, ← lift_omega.{0 u},
lift_lt, ← typein_enum (<) h'],
exact lt_omega_iff_fintype.2 ⟨set.fintype_lt_nat _⟩
end
@[simp] theorem add_one_of_omega_le {c} (h : omega ≤ c) : c + 1 = c :=
by rw [add_comm, ← card_ord c, ← card_one,
← card_add, one_add_of_omega_le];
rwa [← ord_omega, ord_le_ord]
end cardinal
namespace ordinal
theorem lt_omega {o : ordinal.{u}} : o < omega ↔ ∃ n : ℕ, o = n :=
by rw [← cardinal.ord_omega, cardinal.lt_ord, lt_omega]; simp only [card_eq_nat]
theorem nat_lt_omega (n : ℕ) : (n : ordinal) < omega :=
lt_omega.2 ⟨_, rfl⟩
theorem omega_pos : 0 < omega := nat_lt_omega 0
theorem omega_ne_zero : omega ≠ 0 := ne_of_gt omega_pos
theorem one_lt_omega : 1 < omega := by simpa only [nat.cast_one] using nat_lt_omega 1
theorem omega_is_limit : is_limit omega :=
⟨omega_ne_zero, λ o h,
let ⟨n, e⟩ := lt_omega.1 h in
by rw [e]; exact nat_lt_omega (n+1)⟩
theorem omega_le {o : ordinal.{u}} : omega ≤ o ↔ ∀ n : ℕ, (n : ordinal) ≤ o :=
⟨λ h n, le_trans (le_of_lt (nat_lt_omega _)) h,
λ H, le_of_forall_lt $ λ a h,
let ⟨n, e⟩ := lt_omega.1 h in
by rw [e, ← succ_le]; exact H (n+1)⟩
theorem nat_lt_limit {o} (h : is_limit o) : ∀ n : ℕ, (n : ordinal) < o
| 0 := lt_of_le_of_ne (zero_le o) h.1.symm
| (n+1) := h.2 _ (nat_lt_limit n)
theorem omega_le_of_is_limit {o} (h : is_limit o) : omega ≤ o :=
omega_le.2 $ λ n, le_of_lt $ nat_lt_limit h n
theorem add_omega {a : ordinal} (h : a < omega) : a + omega = omega :=
begin
rcases lt_omega.1 h with ⟨n, rfl⟩,
clear h, induction n with n IH,
{ rw [nat.cast_zero, zero_add] },
{ rw [nat.cast_succ, add_assoc, one_add_of_omega_le (le_refl _), IH] }
end
theorem add_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a + b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat.cast_add]; apply nat_lt_omega
end
theorem mul_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a * b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat_cast_mul]; apply nat_lt_omega
end
theorem is_limit_iff_omega_dvd {a : ordinal} : is_limit a ↔ a ≠ 0 ∧ omega ∣ a :=
begin
refine ⟨λ l, ⟨l.1, ⟨a / omega, le_antisymm _ (mul_div_le _ _)⟩⟩, λ h, _⟩,
{ refine (limit_le l).2 (λ x hx, le_of_lt _),
rw [← div_lt omega_ne_zero, ← succ_le, le_div omega_ne_zero,
mul_succ, add_le_of_limit omega_is_limit],
intros b hb,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
exact le_trans (add_le_add_right (mul_div_le _ _) _)
(le_of_lt $ lt_sub.1 $ nat_lt_limit (sub_is_limit l hx) _) },
{ rcases h with ⟨a0, b, rfl⟩,
refine mul_is_limit_left omega_is_limit
(pos_iff_ne_zero.2 $ mt _ a0),
intro e, simp only [e, mul_zero] }
end
local infixr ^ := @pow ordinal ordinal ordinal.has_pow
theorem power_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a ^ b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat_cast_power]; apply nat_lt_omega
end
theorem add_omega_power {a b : ordinal} (h : a < omega ^ b) : a + omega ^ b = omega ^ b :=
begin
refine le_antisymm _ (le_add_left _ _),
revert h, apply limit_rec_on b,
{ intro h, rw [power_zero, ← succ_zero, lt_succ, le_zero] at h,
rw [h, zero_add] },
{ intros b _ h, rw [power_succ] at h,
rcases (lt_mul_of_limit omega_is_limit).1 h with ⟨x, xo, ax⟩,
refine le_trans (add_le_add_right (le_of_lt ax) _) _,
rw [power_succ, ← mul_add, add_omega xo] },
{ intros b l IH h, rcases (lt_power_of_limit omega_ne_zero l).1 h with ⟨x, xb, ax⟩,
refine (((add_is_normal a).trans (power_is_normal one_lt_omega))
.limit_le l).2 (λ y yb, _),
let z := max x y,
have := IH z (max_lt xb yb)
(lt_of_lt_of_le ax $ power_le_power_right omega_pos (le_max_left _ _)),
exact le_trans (add_le_add_left (power_le_power_right omega_pos (le_max_right _ _)) _)
(le_trans this (power_le_power_right omega_pos $ le_of_lt $ max_lt xb yb)) }
end
theorem add_lt_omega_power {a b c : ordinal} (h₁ : a < omega ^ c) (h₂ : b < omega ^ c) :
a + b < omega ^ c :=
by rwa [← add_omega_power h₁, add_lt_add_iff_left]
theorem add_absorp {a b c : ordinal} (h₁ : a < omega ^ b) (h₂ : omega ^ b ≤ c) : a + c = c :=
by rw [← add_sub_cancel_of_le h₂, ← add_assoc, add_omega_power h₁]
theorem add_absorp_iff {o : ordinal} (o0 : o > 0) : (∀ a < o, a + o = o) ↔ ∃ a, o = omega ^ a :=
⟨λ H, ⟨log omega o, begin
refine ((lt_or_eq_of_le (power_log_le _ o0))
.resolve_left $ λ h, _).symm,
have := H _ h,
have := lt_power_succ_log one_lt_omega o,
rw [power_succ, lt_mul_of_limit omega_is_limit] at this,
rcases this with ⟨a, ao, h'⟩,
rcases lt_omega.1 ao with ⟨n, rfl⟩, clear ao,
revert h', apply not_lt_of_le,
suffices e : omega ^ log omega o * ↑n + o = o,
{ simpa only [e] using le_add_right (omega ^ log omega o * ↑n) o },
induction n with n IH, {simp only [nat.cast_zero, mul_zero, zero_add]},
simp only [nat.cast_succ, mul_add_one, add_assoc, this, IH]
end⟩,
λ ⟨b, e⟩, e.symm ▸ λ a, add_omega_power⟩
theorem add_mul_limit_aux {a b c : ordinal} (ba : b + a = a)
(l : is_limit c)
(IH : ∀ c' < c, (a + b) * succ c' = a * succ c' + b) :
(a + b) * c = a * c :=
le_antisymm
((mul_le_of_limit l).2 $ λ c' h, begin
apply le_trans (mul_le_mul_left _ (le_of_lt $ lt_succ_self _)),
rw IH _ h,
apply le_trans (add_le_add_left _ _),
{ rw ← mul_succ, exact mul_le_mul_left _ (succ_le.2 $ l.2 _ h) },
{ rw ← ba, exact le_add_right _ _ }
end)
(mul_le_mul_right _ (le_add_right _ _))
theorem add_mul_succ {a b : ordinal} (c) (ba : b + a = a) :
(a + b) * succ c = a * succ c + b :=
begin
apply limit_rec_on c,
{ simp only [succ_zero, mul_one] },
{ intros c IH,
rw [mul_succ, IH, ← add_assoc, add_assoc _ b, ba, ← mul_succ] },
{ intros c l IH,
have := add_mul_limit_aux ba l IH,
rw [mul_succ, add_mul_limit_aux ba l IH, mul_succ, add_assoc] }
end
theorem add_mul_limit {a b c : ordinal} (ba : b + a = a)
(l : is_limit c) : (a + b) * c = a * c :=
add_mul_limit_aux ba l (λ c' _, add_mul_succ c' ba)
theorem mul_omega {a : ordinal} (a0 : 0 < a) (ha : a < omega) : a * omega = omega :=
le_antisymm
((mul_le_of_limit omega_is_limit).2 $ λ b hb, le_of_lt (mul_lt_omega ha hb))
(by simpa only [one_mul] using mul_le_mul_right omega (one_le_iff_pos.2 a0))
theorem mul_lt_omega_power {a b c : ordinal}
(c0 : 0 < c) (ha : a < omega ^ c) (hb : b < omega) : a * b < omega ^ c :=
if b0 : b = 0 then by simp only [b0, mul_zero, power_pos _ omega_pos] else begin
rcases zero_or_succ_or_limit c with rfl|⟨c,rfl⟩|l,
{ exact (lt_irrefl _).elim c0 },
{ rw power_succ at ha,
rcases ((mul_is_normal $ power_pos _ omega_pos).limit_lt
omega_is_limit).1 ha with ⟨n, hn, an⟩,
refine lt_of_le_of_lt (mul_le_mul_right _ (le_of_lt an)) _,
rw [power_succ, mul_assoc, mul_lt_mul_iff_left (power_pos _ omega_pos)],
exact mul_lt_omega hn hb },
{ rcases ((power_is_normal one_lt_omega).limit_lt l).1 ha with ⟨x, hx, ax⟩,
refine lt_of_le_of_lt (mul_le_mul (le_of_lt ax) (le_of_lt hb)) _,
rw [← power_succ, power_lt_power_iff_right one_lt_omega],
exact l.2 _ hx }
end
theorem mul_omega_dvd {a : ordinal}
(a0 : 0 < a) (ha : a < omega) : ∀ {b}, omega ∣ b → a * b = b
| _ ⟨b, rfl⟩ := by rw [← mul_assoc, mul_omega a0 ha]
theorem mul_omega_power_power {a b : ordinal} (a0 : 0 < a) (h : a < omega ^ omega ^ b) :
a * omega ^ omega ^ b = omega ^ omega ^ b :=
begin
by_cases b0 : b = 0, {rw [b0, power_zero, power_one] at h ⊢, exact mul_omega a0 h},
refine le_antisymm _ (by simpa only [one_mul] using mul_le_mul_right (omega^omega^b) (one_le_iff_pos.2 a0)),
rcases (lt_power_of_limit omega_ne_zero (power_is_limit_left omega_is_limit b0)).1 h
with ⟨x, xb, ax⟩,
refine le_trans (mul_le_mul_right _ (le_of_lt ax)) _,
rw [← power_add, add_omega_power xb]
end
theorem power_omega {a : ordinal} (a1 : 1 < a) (h : a < omega) : a ^ omega = omega :=
le_antisymm
((power_le_of_limit (one_le_iff_ne_zero.1 $ le_of_lt a1) omega_is_limit).2
(λ b hb, le_of_lt (power_lt_omega h hb)))
(le_power_self _ a1)
theorem CNF_aux {b o : ordinal} (b0 : b ≠ 0) (o0 : o ≠ 0) :
o % b ^ log b o < o :=
lt_of_lt_of_le
(mod_lt _ $ power_ne_zero _ b0)
(power_log_le _ $ pos_iff_ne_zero.2 o0)
@[elab_as_eliminator] noncomputable def CNF_rec {b : ordinal} (b0 : b ≠ 0)
{C : ordinal → Sort*}
(H0 : C 0)
(H : ∀ o, o ≠ 0 → o % b ^ log b o < o → C (o % b ^ log b o) → C o)
: ∀ o, C o
| o :=
if o0 : o = 0 then by rw o0; exact H0 else
have _, from CNF_aux b0 o0,
H o o0 this (CNF_rec (o % b ^ log b o))
using_well_founded {dec_tac := `[assumption]}
@[simp] theorem CNF_rec_zero {b} (b0) {C H0 H} : @CNF_rec b b0 C H0 H 0 = H0 :=
by rw [CNF_rec, dif_pos rfl]; refl
@[simp] theorem CNF_rec_ne_zero {b} (b0) {C H0 H o} (o0) :
@CNF_rec b b0 C H0 H o = H o o0 (CNF_aux b0 o0) (@CNF_rec b b0 C H0 H _) :=
by rw [CNF_rec, dif_neg o0]
/-- The Cantor normal form of an ordinal is the list of coefficients
in the base-`b` expansion of `o`.
CNF b (b ^ u₁ * v₁ + b ^ u₂ * v₂) = [(u₁, v₁), (u₂, v₂)] -/
def CNF (b := omega) (o : ordinal) : list (ordinal × ordinal) :=
if b0 : b = 0 then [] else
CNF_rec b0 [] (λ o o0 h IH, (log b o, o / b ^ log b o) :: IH) o
@[simp] theorem zero_CNF (o) : CNF 0 o = [] :=
dif_pos rfl
@[simp] theorem CNF_zero (b) : CNF b 0 = [] :=
if b0 : b = 0 then dif_pos b0 else
(dif_neg b0).trans $ CNF_rec_zero _
theorem CNF_ne_zero {b o : ordinal} (b0 : b ≠ 0) (o0 : o ≠ 0) :
CNF b o = (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o) :=
by unfold CNF; rw [dif_neg b0, dif_neg b0, CNF_rec_ne_zero b0 o0]
theorem one_CNF {o : ordinal} (o0 : o ≠ 0) :
CNF 1 o = [(0, o)] :=
by rw [CNF_ne_zero one_ne_zero o0, log_not_one_lt (lt_irrefl _), power_zero, mod_one, CNF_zero, div_one]
theorem CNF_foldr {b : ordinal} (b0 : b ≠ 0) (o) :
(CNF b o).foldr (λ p r, b ^ p.1 * p.2 + r) 0 = o :=
CNF_rec b0 (by rw CNF_zero; refl)
(λ o o0 h IH, by rw [CNF_ne_zero b0 o0, list.foldr_cons, IH, div_add_mod]) o
theorem CNF_pairwise_aux (b := omega) (o) :
(∀ p ∈ CNF b o, prod.fst p ≤ log b o) ∧
(CNF b o).pairwise (λ p q, q.1 < p.1) :=
begin
by_cases b0 : b = 0,
{ simp only [b0, zero_CNF, list.pairwise.nil, and_true], exact λ _, false.elim },
cases lt_or_eq_of_le (one_le_iff_ne_zero.2 b0) with b1 b1,
{ refine CNF_rec b0 _ _ o,
{ simp only [CNF_zero, list.pairwise.nil, and_true], exact λ _, false.elim },
intros o o0 H IH, cases IH with IH₁ IH₂,
simp only [CNF_ne_zero b0 o0, list.forall_mem_cons, list.pairwise_cons, IH₂, and_true],
refine ⟨⟨le_refl _, λ p m, _⟩, λ p m, _⟩,
{ exact le_trans (IH₁ p m) (log_le_log _ $ le_of_lt H) },
{ refine lt_of_le_of_lt (IH₁ p m) ((log_lt b1 _).2 _),
{ rw pos_iff_ne_zero, intro e,
rw e at m, simpa only [CNF_zero] using m },
{ exact mod_lt _ (power_ne_zero _ b0) } } },
{ by_cases o0 : o = 0,
{ simp only [o0, CNF_zero, list.pairwise.nil, and_true], exact λ _, false.elim },
rw [← b1, one_CNF o0],
simp only [list.mem_singleton, log_not_one_lt (lt_irrefl _), forall_eq, le_refl, true_and, list.pairwise_singleton] }
end
theorem CNF_pairwise (b := omega) (o) :
(CNF b o).pairwise (λ p q, prod.fst q < p.1) :=
(CNF_pairwise_aux _ _).2
theorem CNF_fst_le_log (b := omega) (o) :
∀ p ∈ CNF b o, prod.fst p ≤ log b o :=
(CNF_pairwise_aux _ _).1
theorem CNF_fst_le (b := omega) (o) (p ∈ CNF b o) : prod.fst p ≤ o :=
le_trans (CNF_fst_le_log _ _ p H) (log_le_self _ _)
theorem CNF_snd_lt {b : ordinal} (b1 : 1 < b) (o) :
∀ p ∈ CNF b o, prod.snd p < b :=
begin
have b0 := ne_of_gt (lt_trans zero_lt_one b1),
refine CNF_rec b0 (λ _, by rw [CNF_zero]; exact false.elim) _ o,
intros o o0 H IH,
simp only [CNF_ne_zero b0 o0, list.mem_cons_iff, list.forall_mem_cons', iff_true_intro IH, and_true],
rw [div_lt (power_ne_zero _ b0), ← power_succ],
exact lt_power_succ_log b1 _,
end
theorem CNF_sorted (b := omega) (o) :
((CNF b o).map prod.fst).sorted (>) :=
by rw [list.sorted, list.pairwise_map]; exact CNF_pairwise b o
/-- The next fixed point function, the least fixed point of the
normal function `f` above `a`. -/
def nfp (f : ordinal → ordinal) (a : ordinal) :=
sup (λ n : ℕ, f^[n] a)
theorem iterate_le_nfp (f a n) : f^[n] a ≤ nfp f a :=
le_sup _ n
theorem le_nfp_self (f a) : a ≤ nfp f a :=
iterate_le_nfp f a 0
theorem is_normal.lt_nfp {f} (H : is_normal f) {a b} :
f b < nfp f a ↔ b < nfp f a :=
lt_sup.trans $ iff.trans
(by exact
⟨λ ⟨n, h⟩, ⟨n, lt_of_le_of_lt (H.le_self _) h⟩,
λ ⟨n, h⟩, ⟨n+1, by rw nat.iterate_succ'; exact H.lt_iff.2 h⟩⟩)
lt_sup.symm
theorem is_normal.nfp_le {f} (H : is_normal f) {a b} :
nfp f a ≤ f b ↔ nfp f a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 H.lt_nfp
theorem is_normal.nfp_le_fp {f} (H : is_normal f) {a b}
(ab : a ≤ b) (h : f b ≤ b) : nfp f a ≤ b :=
sup_le.2 $ λ i, begin
induction i with i IH generalizing a, {exact ab},
exact IH (le_trans (H.le_iff.2 ab) h),
end
theorem is_normal.nfp_fp {f} (H : is_normal f) (a) : f (nfp f a) = nfp f a :=
begin
refine le_antisymm _ (H.le_self _),
cases le_or_lt (f a) a with aa aa,
{ rwa le_antisymm (H.nfp_le_fp (le_refl _) aa) (le_nfp_self _ _) },
rcases zero_or_succ_or_limit (nfp f a) with e|⟨b, e⟩|l,
{ refine @le_trans _ _ _ (f a) _ (H.le_iff.2 _) (iterate_le_nfp f a 1),
simp only [e, zero_le] },
{ have : f b < nfp f a := H.lt_nfp.2 (by simp only [e, lt_succ_self]),
rw [e, lt_succ] at this,
have ab : a ≤ b,
{ rw [← lt_succ, ← e],
exact lt_of_lt_of_le aa (iterate_le_nfp f a 1) },
refine le_trans (H.le_iff.2 (H.nfp_le_fp ab this))
(le_trans this (le_of_lt _)),
simp only [e, lt_succ_self] },
{ exact (H.2 _ l _).2 (λ b h, le_of_lt (H.lt_nfp.2 h)) }
end
theorem is_normal.le_nfp {f} (H : is_normal f) {a b} :
f b ≤ nfp f a ↔ b ≤ nfp f a :=
⟨le_trans (H.le_self _), λ h,
by simpa only [H.nfp_fp] using H.le_iff.2 h⟩
/-- The derivative of a normal function `f` is
the sequence of fixed points of `f`. -/
def deriv (f : ordinal → ordinal) (o : ordinal) : ordinal :=
limit_rec_on o (nfp f 0)
(λ a IH, nfp f (succ IH))
(λ a l, bsup.{u u} a)
@[simp] theorem deriv_zero (f) : deriv f 0 = nfp f 0 := limit_rec_on_zero _ _ _
@[simp] theorem deriv_succ (f o) : deriv f (succ o) = nfp f (succ (deriv f o)) :=
limit_rec_on_succ _ _ _ _
theorem deriv_limit (f) {o} : is_limit o →
deriv f o = bsup.{u u} o (λ a _, deriv f a) :=
limit_rec_on_limit _ _ _ _
theorem deriv_is_normal (f) : is_normal (deriv f) :=
⟨λ o, by rw [deriv_succ, ← succ_le]; apply le_nfp_self,
λ o l a, by rw [deriv_limit _ l, bsup_le]⟩
theorem is_normal.deriv_fp {f} (H : is_normal f) (o) : f (deriv.{u} f o) = deriv f o :=
begin
apply limit_rec_on o,
{ rw [deriv_zero, H.nfp_fp] },
{ intros o ih, rw [deriv_succ, H.nfp_fp] },
intros o l IH,
rw [deriv_limit _ l, is_normal.bsup.{u u u} H _ l.1],
refine eq_of_forall_ge_iff (λ c, _),
simp only [bsup_le, IH] {contextual:=tt}
end
theorem is_normal.fp_iff_deriv {f} (H : is_normal f)
{a} : f a ≤ a ↔ ∃ o, a = deriv f o :=
⟨λ ha, begin
suffices : ∀ o (_:a ≤ deriv f o), ∃ o, a = deriv f o,
from this a ((deriv_is_normal _).le_self _),
intro o, apply limit_rec_on o,
{ intros h₁,
refine ⟨0, le_antisymm h₁ _⟩,
rw deriv_zero,
exact H.nfp_le_fp (zero_le _) ha },
{ intros o IH h₁,
cases le_or_lt a (deriv f o), {exact IH h},
refine ⟨succ o, le_antisymm h₁ _⟩,
rw deriv_succ,
exact H.nfp_le_fp (succ_le.2 h) ha },
{ intros o l IH h₁,
cases eq_or_lt_of_le h₁, {exact ⟨_, h⟩},
rw [deriv_limit _ l, ← not_le, bsup_le, not_ball] at h,
exact let ⟨o', h, hl⟩ := h in IH o' h (le_of_not_le hl) }
end, λ ⟨o, e⟩, e.symm ▸ le_of_eq (H.deriv_fp _)⟩
end ordinal
namespace cardinal
open ordinal
theorem ord_is_limit {c} (co : omega ≤ c) : (ord c).is_limit :=
begin
refine ⟨λ h, omega_ne_zero _, λ a, lt_imp_lt_of_le_imp_le _⟩,
{ rw [← ordinal.le_zero, ord_le] at h,
simpa only [card_zero, le_zero] using le_trans co h },
{ intro h, rw [ord_le] at h ⊢,
rwa [← @add_one_of_omega_le (card a), ← card_succ],
rw [← ord_le, ← le_succ_of_is_limit, ord_le],
{ exact le_trans co h },
{ rw ord_omega, exact omega_is_limit } }
end
def aleph_idx.initial_seg : @initial_seg cardinal ordinal (<) (<) :=
@order_embedding.collapse cardinal ordinal (<) (<) _ cardinal.ord.order_embedding
/-- The `aleph'` index function, which gives the ordinal index of a cardinal.
(The `aleph'` part is because unlike `aleph` this counts also the
finite stages. So `aleph_idx n = n`, `aleph_idx ω = ω`,
`aleph_idx ℵ₁ = ω + 1` and so on.) -/
def aleph_idx : cardinal → ordinal := aleph_idx.initial_seg
@[simp] theorem aleph_idx.initial_seg_coe :
(aleph_idx.initial_seg : cardinal → ordinal) = aleph_idx := rfl
@[simp] theorem aleph_idx_lt {a b} : aleph_idx a < aleph_idx b ↔ a < b :=
aleph_idx.initial_seg.to_order_embedding.ord'.symm
@[simp] theorem aleph_idx_le {a b} : aleph_idx a ≤ aleph_idx b ↔ a ≤ b :=
by rw [← not_lt, ← not_lt, aleph_idx_lt]
theorem aleph_idx.init {a b} : b < aleph_idx a → ∃ c, aleph_idx c = b :=
aleph_idx.initial_seg.init _ _
def aleph_idx.order_iso : @order_iso cardinal.{u} ordinal.{u} (<) (<) :=
@order_iso.of_surjective cardinal.{u} ordinal.{u} (<) (<) aleph_idx.initial_seg.{u} $
(initial_seg.eq_or_principal aleph_idx.initial_seg.{u}).resolve_right $
λ ⟨o, e⟩, begin
have : ∀ c, aleph_idx c < o := λ c, (e _).2 ⟨_, rfl⟩,
refine ordinal.induction_on o _ this, introsI α r _ h,
let s := sup.{u u} (λ a:α, inv_fun aleph_idx (ordinal.typein r a)),
apply not_le_of_gt (lt_succ_self s),
have I : injective aleph_idx := aleph_idx.initial_seg.to_embedding.inj,
simpa only [typein_enum, left_inverse_inv_fun I (succ s)] using
le_sup.{u u} (λ a, inv_fun aleph_idx (ordinal.typein r a))
(ordinal.enum r _ (h (succ s))),
end
@[simp] theorem aleph_idx.order_iso_coe :
(aleph_idx.order_iso : cardinal → ordinal) = aleph_idx := rfl
@[simp] theorem type_cardinal : @ordinal.type cardinal (<) _ = ordinal.univ.{u (u+1)} :=
by rw ordinal.univ_id; exact quotient.sound ⟨aleph_idx.order_iso⟩
@[simp] theorem mk_cardinal : mk cardinal = univ.{u (u+1)} :=
by simpa only [card_type, card_univ] using congr_arg card type_cardinal
def aleph'.order_iso := cardinal.aleph_idx.order_iso.symm
/-- The `aleph'` function gives the cardinals listed by their ordinal
index, and is the inverse of `aleph_idx`.
`aleph' n = n`, `aleph' ω = ω`, `aleph' (ω + 1) = ℵ₁, etc. -/
def aleph' : ordinal → cardinal := aleph'.order_iso
@[simp] theorem aleph'.order_iso_coe :
(aleph'.order_iso : ordinal → cardinal) = aleph' := rfl
@[simp] theorem aleph'_lt {o₁ o₂ : ordinal.{u}} : aleph' o₁ < aleph' o₂ ↔ o₁ < o₂ :=
aleph'.order_iso.ord'.symm
@[simp] theorem aleph'_le {o₁ o₂ : ordinal.{u}} : aleph' o₁ ≤ aleph' o₂ ↔ o₁ ≤ o₂ :=
le_iff_le_iff_lt_iff_lt.2 aleph'_lt
@[simp] theorem aleph'_aleph_idx (c : cardinal.{u}) : aleph' c.aleph_idx = c :=
cardinal.aleph_idx.order_iso.to_equiv.symm_apply_apply c
@[simp] theorem aleph_idx_aleph' (o : ordinal.{u}) : (aleph' o).aleph_idx = o :=
cardinal.aleph_idx.order_iso.to_equiv.apply_symm_apply o
@[simp] theorem aleph'_zero : aleph' 0 = 0 :=
by rw [← le_zero, ← aleph'_aleph_idx 0, aleph'_le];
apply ordinal.zero_le
@[simp] theorem aleph'_succ {o : ordinal.{u}} : aleph' o.succ = (aleph' o).succ :=
le_antisymm
(cardinal.aleph_idx_le.1 $
by rw [aleph_idx_aleph', ordinal.succ_le, ← aleph'_lt, aleph'_aleph_idx];
apply cardinal.lt_succ_self)
(cardinal.succ_le.2 $ aleph'_lt.2 $ ordinal.lt_succ_self _)
@[simp] theorem aleph'_nat : ∀ n : ℕ, aleph' n = n
| 0 := aleph'_zero
| (n+1) := show aleph' (ordinal.succ n) = n.succ,
by rw [aleph'_succ, aleph'_nat, nat_succ]
theorem aleph'_le_of_limit {o : ordinal.{u}} (l : o.is_limit) {c} :
aleph' o ≤ c ↔ ∀ o' < o, aleph' o' ≤ c :=
⟨λ h o' h', le_trans (aleph'_le.2 $ le_of_lt h') h,
λ h, begin
rw [← aleph'_aleph_idx c, aleph'_le, ordinal.limit_le l],
intros x h',
rw [← aleph'_le, aleph'_aleph_idx],
exact h _ h'
end⟩
@[simp] theorem aleph'_omega : aleph' ordinal.omega = omega :=
eq_of_forall_ge_iff $ λ c, begin
simp only [aleph'_le_of_limit omega_is_limit, ordinal.lt_omega, exists_imp_distrib, omega_le],
exact forall_swap.trans (forall_congr $ λ n, by simp only [forall_eq, aleph'_nat]),
end
/-- The `aleph` function gives the infinite cardinals listed by their
ordinal index. `aleph 0 = ω`, `aleph 1 = succ ω` is the first
uncountable cardinal, and so on. -/
def aleph (o : ordinal) : cardinal := aleph' (ordinal.omega + o)
@[simp] theorem aleph_lt {o₁ o₂ : ordinal.{u}} : aleph o₁ < aleph o₂ ↔ o₁ < o₂ :=
aleph'_lt.trans (ordinal.add_lt_add_iff_left _)
@[simp] theorem aleph_le {o₁ o₂ : ordinal.{u}} : aleph o₁ ≤ aleph o₂ ↔ o₁ ≤ o₂ :=
le_iff_le_iff_lt_iff_lt.2 aleph_lt
@[simp] theorem aleph_succ {o : ordinal.{u}} : aleph o.succ = (aleph o).succ :=
by rw [aleph, ordinal.add_succ, aleph'_succ]; refl
@[simp] theorem aleph_zero : aleph 0 = omega :=
by simp only [aleph, add_zero, aleph'_omega]
theorem omega_le_aleph' {o : ordinal} : omega ≤ aleph' o ↔ ordinal.omega ≤ o :=
by rw [← aleph'_omega, aleph'_le]
theorem omega_le_aleph (o : ordinal) : omega ≤ aleph o :=
by rw [aleph, omega_le_aleph']; apply ordinal.le_add_right
theorem aleph_is_limit (o : ordinal) : is_limit (aleph o).ord :=
ord_is_limit $ omega_le_aleph _
theorem exists_aleph {c : cardinal} : omega ≤ c ↔ ∃ o, c = aleph o :=
⟨λ h, ⟨aleph_idx c - ordinal.omega,
by rw [aleph, ordinal.add_sub_cancel_of_le, aleph'_aleph_idx];
rwa [← omega_le_aleph', aleph'_aleph_idx]⟩,
λ ⟨o, e⟩, e.symm ▸ omega_le_aleph _⟩
theorem aleph'_is_normal : is_normal (ord ∘ aleph') :=
⟨λ o, ord_lt_ord.2 $ aleph'_lt.2 $ ordinal.lt_succ_self _,
λ o l a, by simp only [ord_le, aleph'_le_of_limit l]⟩
theorem aleph_is_normal : is_normal (ord ∘ aleph) :=
aleph'_is_normal.trans $ add_is_normal ordinal.omega
theorem mul_eq_self {c : cardinal} (h : omega ≤ c) : c * c = c :=
begin
refine le_antisymm _
(by simpa only [mul_one] using mul_le_mul_left c (le_trans (le_of_lt one_lt_omega) h)),
refine acc.rec_on (cardinal.wf.apply c) (λ c _,
quotient.induction_on c $ λ α IH ol, _) h,
rcases ord_eq α with ⟨r, wo, e⟩, resetI,
let := decidable_linear_order_of_STO' r,
have : is_well_order α (<) := wo,
let g : α × α → α := λ p, max p.1 p.2,
let f : α × α ↪ ordinal × (α × α) :=
⟨λ p:α×α, (typein (<) (g p), p), λ p q, congr_arg prod.snd⟩,
let s := f ⁻¹'o (prod.lex (<) (prod.lex (<) (<))),
have : is_well_order _ s := (order_embedding.preimage _ _).is_well_order,
suffices : type s ≤ type r, {exact card_le_card this},
refine le_of_forall_lt (λ o h, _),
rcases typein_surj s h with ⟨p, rfl⟩,
rw [← e, lt_ord],
refine lt_of_le_of_lt (_ : _ ≤ card (typein (<) (g p)).succ * card (typein (<) (g p)).succ) _,
{ have : {q|s q p} ⊆ (insert (g p) {x | x < (g p)}).prod (insert (g p) {x | x < (g p)}),
{ intros q h,
simp only [s, embedding.coe_fn_mk, order.preimage, typein_lt_typein, prod.lex_def, typein_inj] at h,
exact max_le_iff.1 (le_iff_lt_or_eq.2 $ h.imp_right and.left) },
suffices H : (insert (g p) {x | r x (g p)} : set α) ≃ ({x | r x (g p)} ⊕ punit),
{ exact ⟨(set.embedding_of_subset this).trans
((equiv.set.prod _ _).trans (H.prod_congr H)).to_embedding⟩ },
refine (equiv.set.insert _).trans
((equiv.refl _).sum_congr equiv.punit_equiv_punit),
apply @irrefl _ r },
cases lt_or_ge (card (typein (<) (g p)).succ) omega with qo qo,
{ exact lt_of_lt_of_le (mul_lt_omega qo qo) ol },
{ suffices, {exact lt_of_le_of_lt (IH _ this qo) this},
rw ← lt_ord, apply (ord_is_limit ol).2,
rw [mk_def, e], apply typein_lt_type }
end
theorem mul_eq_max {a b : cardinal} (ha : omega ≤ a) (hb : omega ≤ b) : a * b = max a b :=
le_antisymm
(mul_eq_self (le_trans ha (le_max_left a b)) ▸
mul_le_mul (le_max_left _ _) (le_max_right _ _)) $
max_le
(by simpa only [mul_one] using mul_le_mul_left a (le_trans (le_of_lt one_lt_omega) hb))
(by simpa only [one_mul] using mul_le_mul_right b (le_trans (le_of_lt one_lt_omega) ha))
theorem mul_lt_of_lt {a b c : cardinal} (hc : omega ≤ c)
(h1 : a < c) (h2 : b < c) : a * b < c :=
lt_of_le_of_lt (mul_le_mul (le_max_left a b) (le_max_right a b)) $
(lt_or_le (max a b) omega).elim
(λ h, lt_of_lt_of_le (mul_lt_omega h h) hc)
(λ h, by rw mul_eq_self h; exact max_lt h1 h2)
lemma mul_le_max_of_omega_le_left {a b : cardinal} (h : omega ≤ a) : a * b ≤ max a b :=
begin
convert mul_le_mul (le_max_left a b) (le_max_right a b), rw [mul_eq_self],
refine le_trans h (le_max_left a b)
end
lemma mul_eq_max_of_omega_le_left {a b : cardinal} (h : omega ≤ a) (h' : b ≠ 0) : a * b = max a b :=
begin
apply le_antisymm, apply mul_le_max_of_omega_le_left h,
cases le_or_gt omega b with hb hb, rw [mul_eq_max h hb],
have : b ≤ a, exact le_trans (le_of_lt hb) h,
rw [max_eq_left this], convert mul_le_mul_left _ (one_le_iff_ne_zero.mpr h'), rw [mul_one],
end
theorem add_eq_self {c : cardinal} (h : omega ≤ c) : c + c = c :=
le_antisymm
(by simpa only [nat.cast_bit0, nat.cast_one, mul_eq_self h, two_mul] using
mul_le_mul_right c (le_trans (le_of_lt $ nat_lt_omega 2) h))
(le_add_left c c)
theorem add_eq_max {a b : cardinal} (ha : omega ≤ a) : a + b = max a b :=
le_antisymm
(add_eq_self (le_trans ha (le_max_left a b)) ▸
add_le_add (le_max_left _ _) (le_max_right _ _)) $
max_le (le_add_right _ _) (le_add_left _ _)
theorem add_lt_of_lt {a b c : cardinal} (hc : omega ≤ c)
(h1 : a < c) (h2 : b < c) : a + b < c :=
lt_of_le_of_lt (add_le_add (le_max_left a b) (le_max_right a b)) $
(lt_or_le (max a b) omega).elim
(λ h, lt_of_lt_of_le (add_lt_omega h h) hc)
(λ h, by rw add_eq_self h; exact max_lt h1 h2)
lemma add_one_eq {a : cardinal} (ha : omega ≤ a) : a + 1 = a :=
have 1 ≤ a, from le_trans (le_of_lt one_lt_omega) ha,
by simp only [max_eq_left, add_eq_max, ha, this]
theorem pow_le {κ μ : cardinal.{u}} (H1 : omega ≤ κ) (H2 : μ < omega) : κ^μ ≤ κ :=
let ⟨n, H3⟩ := lt_omega.1 H2 in
H3.symm ▸ (quotient.induction_on κ (λ α H1, nat.rec_on n
(le_of_lt $ lt_of_lt_of_le (by rw [nat.cast_zero, power_zero];
from one_lt_omega) H1)
(λ n ih, trans_rel_left _
(by rw [nat.cast_succ, power_add, power_one];
from mul_le_mul_right _ ih)
(mul_eq_self H1))) H1)
lemma power_self_eq {c : cardinal} (h : omega ≤ c) : c ^ c = 2 ^ c :=
begin
apply le_antisymm,
{ apply le_trans (power_le_power_right $ le_of_lt $ cantor c), rw [power_mul, mul_eq_self h] },
{ convert power_le_power_right (le_trans (le_of_lt $ nat_lt_omega 2) h), apply nat.cast_two.symm }
end
lemma power_nat_le {c : cardinal.{u}} {n : ℕ} (h : omega ≤ c) : c ^ (n : cardinal.{u}) ≤ c :=
pow_le h (nat_lt_omega n)
lemma powerlt_omega {c : cardinal} (h : omega ≤ c) : c ^< omega = c :=
begin
apply le_antisymm,
{ rw [powerlt_le], intro c', rw [lt_omega], rintro ⟨n, rfl⟩, apply power_nat_le h },
convert le_powerlt one_lt_omega, rw [power_one]
end
lemma powerlt_omega_le (c : cardinal) : c ^< omega ≤ max c omega :=
begin
cases le_or_gt omega c,
{ rw [powerlt_omega h], apply le_max_left },
rw [powerlt_le], intros c' hc',
refine le_trans (le_of_lt $ power_lt_omega h hc') (le_max_right _ _)
end
theorem mk_list_eq_mk {α : Type u} (H1 : omega ≤ mk α) : mk (list α) = mk α :=
eq.symm $ le_antisymm ⟨⟨λ x, [x], λ x y H, (list.cons.inj H).1⟩⟩ $
calc mk (list α)
= sum (λ n : ℕ, mk α ^ (n : cardinal.{u})) : mk_list_eq_sum_pow α
... ≤ sum (λ n : ℕ, mk α) : sum_le_sum _ _ $ λ n, pow_le H1 $ nat_lt_omega n
... = sum (λ n : ulift.{u} ℕ, mk α) : quotient.sound
⟨@equiv.sigma_congr_left _ _ (λ _, quotient.out (mk α)) equiv.ulift.symm⟩
... = omega * mk α : sum_const _ _
... = max (omega) (mk α) : mul_eq_max (le_refl _) H1
... = mk α : max_eq_right H1
lemma mk_bounded_set_le_of_omega_le (α : Type u) (c : cardinal) (hα : omega ≤ mk α) :
mk {t : set α // mk t ≤ c} ≤ mk α ^ c :=
begin
refine le_trans _ (by rw [←add_one_eq hα]), refine quotient.induction_on c _, clear c, intro β,
fapply mk_le_of_surjective,
{ intro f, use sum.inl ⁻¹' range f,
refine le_trans (mk_preimage_of_injective _ _ (λ x y, sum.inl.inj)) _,
apply mk_range_le },
rintro ⟨s, ⟨g⟩⟩,
use λ y, if h : ∃(x : s), g x = y then sum.inl (classical.some h).val else sum.inr ⟨⟩,
apply subtype.eq, ext,
split,
{ rintro ⟨y, h⟩, dsimp only at h, by_cases h' : ∃ (z : s), g z = y,
{ rw [dif_pos h'] at h, cases sum.inl.inj h, exact (classical.some h').2 },
{ rw [dif_neg h'] at h, cases h }},
{ intro h, have : ∃(z : s), g z = g ⟨x, h⟩, exact ⟨⟨x, h⟩, rfl⟩,
use g ⟨x, h⟩, dsimp only, rw [dif_pos this], congr',
suffices : classical.some this = ⟨x, h⟩, exact congr_arg subtype.val this,
apply g.2, exact classical.some_spec this }
end
lemma mk_bounded_set_le (α : Type u) (c : cardinal) :
mk {t : set α // mk t ≤ c} ≤ max (mk α) omega ^ c :=
begin
transitivity mk {t : set (ulift.{u} nat ⊕ α) // mk t ≤ c},
{ refine ⟨embedding.subtype_map _ _⟩, apply embedding.image,
use sum.inr, apply sum.inr.inj, intros s hs, exact le_trans mk_image_le hs },
refine le_trans
(mk_bounded_set_le_of_omega_le (ulift.{u} nat ⊕ α) c (le_add_right omega (mk α))) _,
rw [max_comm, ←add_eq_max]; refl
end
lemma mk_bounded_subset_le {α : Type u} (s : set α) (c : cardinal.{u}) :
mk {t : set α // t ⊆ s ∧ mk t ≤ c} ≤ max (mk s) omega ^ c :=
begin
refine le_trans _ (mk_bounded_set_le s c),
refine ⟨embedding.cod_restrict _ _ _⟩,
use λ t, subtype.val ⁻¹' t.1,
{ rintros ⟨t, ht1, ht2⟩ ⟨t', h1t', h2t'⟩ h, apply subtype.eq, dsimp only at h ⊢,
refine (preimage_eq_preimage' _ _).1 h; rw [subtype.range_val]; assumption },
rintro ⟨t, h1t, h2t⟩, exact le_trans (mk_preimage_of_injective _ _ subtype.val_injective) h2t
end
end cardinal
|
9f3da44c83495cf2fd61035cd038b5ee85a2a076 | 07c6143268cfb72beccd1cc35735d424ebcb187b | /src/category_theory/eq_to_hom.lean | ef2c344a6ecd998930077a018380180960bd50ea | [
"Apache-2.0"
] | permissive | khoek/mathlib | bc49a842910af13a3c372748310e86467d1dc766 | aa55f8b50354b3e11ba64792dcb06cccb2d8ee28 | refs/heads/master | 1,588,232,063,837 | 1,587,304,803,000 | 1,587,304,803,000 | 176,688,517 | 0 | 0 | Apache-2.0 | 1,553,070,585,000 | 1,553,070,585,000 | null | UTF-8 | Lean | false | false | 2,771 | lean | /-
Copyright (c) 2018 Reid Barton. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Reid Barton, Scott Morrison
-/
import category_theory.isomorphism
import category_theory.functor_category
import category_theory.opposites
import tactic.reassoc_axiom
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} [𝒞 : category.{v} C]
include 𝒞
def eq_to_hom {X Y : C} (p : X = Y) : X ⟶ Y := by rw p; exact 𝟙 _
@[simp] lemma eq_to_hom_refl (X : C) (p : X = X) : eq_to_hom p = 𝟙 X := rfl
@[simp, reassoc] lemma eq_to_hom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) :
eq_to_hom p ≫ eq_to_hom q = eq_to_hom (p.trans q) :=
by cases p; cases q; simp
def eq_to_iso {X Y : C} (p : X = Y) : X ≅ Y :=
⟨eq_to_hom p, eq_to_hom p.symm, by simp, by simp⟩
@[simp] lemma eq_to_iso.hom {X Y : C} (p : X = Y) : (eq_to_iso p).hom = eq_to_hom p :=
rfl
@[simp] lemma eq_to_iso.inv {X Y : C} (p : X = Y) : (eq_to_iso p).inv = eq_to_hom p.symm :=
rfl
@[simp] lemma eq_to_iso_refl (X : C) (p : X = X) : eq_to_iso p = iso.refl X := rfl
@[simp] lemma eq_to_iso_trans {X Y Z : C} (p : X = Y) (q : Y = Z) :
eq_to_iso p ≪≫ eq_to_iso q = eq_to_iso (p.trans q) :=
by ext; simp
@[simp] lemma eq_to_hom_op (X Y : C) (h : X = Y) : (eq_to_hom h).op = eq_to_hom (congr_arg op h.symm) :=
begin
cases h,
refl
end
variables {D : Type u'} [𝒟 : category.{v'} D]
include 𝒟
namespace functor
/-- Proving equality between functors. This isn't an extensionality lemma,
because usually you don't really want to do this. -/
lemma ext {F G : C ⥤ D} (h_obj : ∀ X, F.obj X = G.obj X)
(h_map : ∀ X Y f, F.map f = eq_to_hom (h_obj X) ≫ G.map f ≫ eq_to_hom (h_obj Y).symm) :
F = G :=
begin
cases F with F_obj _ _ _, cases G with G_obj _ _ _,
have : F_obj = G_obj, by ext X; apply h_obj,
subst this,
congr,
funext X Y f,
simpa using h_map X Y f
end
-- Using equalities between functors.
lemma congr_obj {F G : C ⥤ D} (h : F = G) (X) : F.obj X = G.obj X :=
by subst h
lemma congr_hom {F G : C ⥤ D} (h : F = G) {X Y} (f : X ⟶ Y) :
F.map f = eq_to_hom (congr_obj h X) ≫ G.map f ≫ eq_to_hom (congr_obj h Y).symm :=
by subst h; simp
end functor
lemma eq_to_hom_map (F : C ⥤ D) {X Y : C} (p : X = Y) :
F.map (eq_to_hom p) = eq_to_hom (congr_arg F.obj p) :=
by cases p; simp
lemma eq_to_iso_map (F : C ⥤ D) {X Y : C} (p : X = Y) :
F.map_iso (eq_to_iso p) = eq_to_iso (congr_arg F.obj p) :=
by ext; cases p; simp
lemma eq_to_hom_app {F G : C ⥤ D} (h : F = G) (X : C) :
(eq_to_hom h : F ⟶ G).app X = eq_to_hom (functor.congr_obj h X) :=
by subst h; refl
end category_theory
|
fb4b2500c015730f74f960e45c02ece1d601de60 | 618003631150032a5676f229d13a079ac875ff77 | /src/topology/uniform_space/cauchy.lean | d6b196657f3e111fcf36b31096ef76119506e9d2 | [
"Apache-2.0"
] | permissive | awainverse/mathlib | 939b68c8486df66cfda64d327ad3d9165248c777 | ea76bd8f3ca0a8bf0a166a06a475b10663dec44a | refs/heads/master | 1,659,592,962,036 | 1,590,987,592,000 | 1,590,987,592,000 | 268,436,019 | 1 | 0 | Apache-2.0 | 1,590,990,500,000 | 1,590,990,500,000 | null | UTF-8 | Lean | false | false | 25,052 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import topology.uniform_space.basic
import topology.bases
import data.set.intervals
/-!
# Theory of Cauchy filters in uniform spaces. Complete uniform spaces. Totally bounded subsets.
-/
universes u v
open filter topological_space set classical
open_locale classical
variables {α : Type u} {β : Type v} [uniform_space α]
open_locale uniformity topological_space
/-- A filter `f` is Cauchy if for every entourage `r`, there exists an
`s ∈ f` such that `s × s ⊆ r`. This is a generalization of Cauchy
sequences, because if `a : ℕ → α` then the filter of sets containing
cofinitely many of the `a n` is Cauchy iff `a` is a Cauchy sequence. -/
def cauchy (f : filter α) := f ≠ ⊥ ∧ filter.prod f f ≤ (𝓤 α)
/-- A set `s` is called *complete*, if any Cauchy filter `f` such that `s ∈ f`
has a limit in `s` (formally, it satisfies `f ≤ 𝓝 x` for some `x ∈ s`). -/
def is_complete (s : set α) := ∀f, cauchy f → f ≤ principal s → ∃x∈s, f ≤ 𝓝 x
lemma filter.has_basis.cauchy_iff {p : β → Prop} {s : β → set (α × α)} (h : (𝓤 α).has_basis p s)
{f : filter α} :
cauchy f ↔ (f ≠ ⊥ ∧ (∀ i, p i → ∃ t ∈ f, ∀ x y ∈ t, (x, y) ∈ s i)) :=
and_congr iff.rfl $ (f.basis_sets.prod_self.le_basis_iff h).trans $
by simp only [subset_def, prod.forall, mem_prod_eq, and_imp, id]
lemma cauchy_iff' {f : filter α} :
cauchy f ↔ (f ≠ ⊥ ∧ (∀ s ∈ 𝓤 α, ∃t∈f, ∀ x y ∈ t, (x, y) ∈ s)) :=
(𝓤 α).basis_sets.cauchy_iff
lemma cauchy_iff {f : filter α} :
cauchy f ↔ (f ≠ ⊥ ∧ (∀ s ∈ 𝓤 α, ∃t∈f, (set.prod t t) ⊆ s)) :=
(𝓤 α).basis_sets.cauchy_iff.trans $
by simp only [subset_def, prod.forall, mem_prod_eq, and_imp, id]
lemma cauchy_map_iff {l : filter β} {f : β → α} :
cauchy (l.map f) ↔ (l ≠ ⊥ ∧ tendsto (λp:β×β, (f p.1, f p.2)) (l.prod l) (𝓤 α)) :=
by rw [cauchy, (≠), map_eq_bot_iff, prod_map_map_eq]; refl
lemma cauchy_downwards {f g : filter α} (h_c : cauchy f) (hg : g ≠ ⊥) (h_le : g ≤ f) : cauchy g :=
⟨hg, le_trans (filter.prod_mono h_le h_le) h_c.right⟩
lemma cauchy_nhds {a : α} : cauchy (𝓝 a) :=
⟨nhds_ne_bot,
calc filter.prod (𝓝 a) (𝓝 a) =
(𝓤 α).lift (λs:set (α×α), (𝓤 α).lift' (λt:set(α×α),
set.prod {y : α | (y, a) ∈ s} {y : α | (a, y) ∈ t})) : nhds_nhds_eq_uniformity_uniformity_prod
... ≤ (𝓤 α).lift' (λs:set (α×α), comp_rel s s) :
le_infi $ assume s, le_infi $ assume hs,
infi_le_of_le s $ infi_le_of_le hs $ infi_le_of_le s $ infi_le_of_le hs $
principal_mono.mpr $
assume ⟨x, y⟩ ⟨(hx : (x, a) ∈ s), (hy : (a, y) ∈ s)⟩, ⟨a, hx, hy⟩
... ≤ 𝓤 α : comp_le_uniformity⟩
lemma cauchy_pure {a : α} : cauchy (pure a) :=
cauchy_downwards cauchy_nhds pure_ne_bot (pure_le_nhds a)
/-- The common part of the proofs of `le_nhds_of_cauchy_adhp` and
`sequentially_complete.le_nhds_of_seq_tendsto_nhds`: if for any entourage `s`
one can choose a set `t ∈ f` of diameter `s` such that it contains a point `y`
with `(x, y) ∈ s`, then `f` converges to `x`. -/
lemma le_nhds_of_cauchy_adhp_aux {f : filter α} {x : α}
(adhs : ∀ s ∈ 𝓤 α, ∃ t ∈ f, (set.prod t t ⊆ s) ∧ ∃ y, (y ∈ t) ∧ (x, y) ∈ s) :
f ≤ 𝓝 x :=
begin
-- Consider a neighborhood `s` of `x`
assume s hs,
-- Take an entourage twice smaller than `s`
rcases comp_mem_uniformity_sets (mem_nhds_uniformity_iff_right.1 hs) with ⟨U, U_mem, hU⟩,
-- Take a set `t ∈ f`, `t × t ⊆ U`, and a point `y ∈ t` such that `(x, y) ∈ U`
rcases adhs U U_mem with ⟨t, t_mem, ht, y, hy, hxy⟩,
apply mem_sets_of_superset t_mem,
-- Given a point `z ∈ t`, we have `(x, y) ∈ U` and `(y, z) ∈ t × t ⊆ U`, hence `z ∈ s`
exact (λ z hz, hU (prod_mk_mem_comp_rel hxy (ht $ mk_mem_prod hy hz)) rfl)
end
/-- If `x` is an adherent (cluster) point for a Cauchy filter `f`, then it is a limit point
for `f`. -/
lemma le_nhds_of_cauchy_adhp {f : filter α} {x : α} (hf : cauchy f)
(adhs : f ⊓ 𝓝 x ≠ ⊥) : f ≤ 𝓝 x :=
le_nhds_of_cauchy_adhp_aux
begin
assume s hs,
-- Take `t ∈ f` such that `t × t ⊆ s`.
rcases (cauchy_iff.1 hf).2 s hs with ⟨t, t_mem, ht⟩,
use [t, t_mem, ht],
exact (forall_sets_nonempty_iff_ne_bot.2 adhs _
(inter_mem_inf_sets t_mem (mem_nhds_left x hs)))
end
lemma le_nhds_iff_adhp_of_cauchy {f : filter α} {x : α} (hf : cauchy f) :
f ≤ 𝓝 x ↔ f ⊓ 𝓝 x ≠ ⊥ :=
⟨assume h, left_eq_inf.2 h ▸ hf.left, le_nhds_of_cauchy_adhp hf⟩
lemma cauchy_map [uniform_space β] {f : filter α} {m : α → β}
(hm : uniform_continuous m) (hf : cauchy f) : cauchy (map m f) :=
⟨have f ≠ ⊥, from hf.left, by simp; assumption,
calc filter.prod (map m f) (map m f) =
map (λp:α×α, (m p.1, m p.2)) (filter.prod f f) : filter.prod_map_map_eq
... ≤ map (λp:α×α, (m p.1, m p.2)) (𝓤 α) : map_mono hf.right
... ≤ 𝓤 β : hm⟩
lemma cauchy_comap [uniform_space β] {f : filter β} {m : α → β}
(hm : comap (λp:α×α, (m p.1, m p.2)) (𝓤 β) ≤ 𝓤 α)
(hf : cauchy f) (hb : comap m f ≠ ⊥) : cauchy (comap m f) :=
⟨hb,
calc filter.prod (comap m f) (comap m f) =
comap (λp:α×α, (m p.1, m p.2)) (filter.prod f f) : filter.prod_comap_comap_eq
... ≤ comap (λp:α×α, (m p.1, m p.2)) (𝓤 β) : comap_mono hf.right
... ≤ 𝓤 α : hm⟩
/-- Cauchy sequences. Usually defined on ℕ, but often it is also useful to say that a function
defined on ℝ is Cauchy at +∞ to deduce convergence. Therefore, we define it in a type class that
is general enough to cover both ℕ and ℝ, which are the main motivating examples. -/
def cauchy_seq [semilattice_sup β] (u : β → α) := cauchy (at_top.map u)
lemma cauchy_seq_of_tendsto_nhds [semilattice_sup β] [nonempty β] (f : β → α) {x}
(hx : tendsto f at_top (𝓝 x)) :
cauchy_seq f :=
cauchy_downwards cauchy_nhds (map_ne_bot at_top_ne_bot) hx
lemma cauchy_seq_iff_tendsto [nonempty β] [semilattice_sup β] {u : β → α} :
cauchy_seq u ↔ tendsto (prod.map u u) at_top (𝓤 α) :=
cauchy_map_iff.trans $ (and_iff_right at_top_ne_bot).trans $
by simp only [prod_at_top_at_top_eq, prod.map_def]
/-- If a Cauchy sequence has a convergent subsequence, then it converges. -/
lemma tendsto_nhds_of_cauchy_seq_of_subseq
[semilattice_sup β] {u : β → α} (hu : cauchy_seq u)
{ι : Type*} {f : ι → β} {p : filter ι} (hp : p ≠ ⊥)
(hf : tendsto f p at_top) {a : α} (ha : tendsto (λ i, u (f i)) p (𝓝 a)) :
tendsto u at_top (𝓝 a) :=
begin
apply le_nhds_of_cauchy_adhp hu,
rw ← bot_lt_iff_ne_bot,
have : ⊥ < map (λ i, u (f i)) p ⊓ 𝓝 a,
by { rw [bot_lt_iff_ne_bot, inf_of_le_left ha], exact map_ne_bot hp },
exact lt_of_lt_of_le this (inf_le_inf_right _ (map_mono hf))
end
@[nolint ge_or_gt] -- see Note [nolint_ge]
lemma filter.has_basis.cauchy_seq_iff {γ} [nonempty β] [semilattice_sup β] {u : β → α}
{p : γ → Prop} {s : γ → set (α × α)} (h : (𝓤 α).has_basis p s) :
cauchy_seq u ↔ ∀ i, p i → ∃N, ∀m n≥N, (u m, u n) ∈ s i :=
begin
rw [cauchy_seq_iff_tendsto, ← prod_at_top_at_top_eq],
refine (at_top_basis.prod_self.tendsto_iff h).trans _,
simp only [exists_prop, true_and, maps_to, preimage, subset_def, prod.forall,
mem_prod_eq, mem_set_of_eq, mem_Ici, and_imp, prod.map]
end
@[nolint ge_or_gt] -- see Note [nolint_ge]
lemma filter.has_basis.cauchy_seq_iff' {γ} [nonempty β] [semilattice_sup β] {u : β → α}
{p : γ → Prop} {s : γ → set (α × α)} (H : (𝓤 α).has_basis p s) :
cauchy_seq u ↔ ∀ i, p i → ∃N, ∀n≥N, (u n, u N) ∈ s i :=
begin
refine H.cauchy_seq_iff.trans ⟨λ h i hi, _, λ h i hi, _⟩,
{ exact (h i hi).imp (λ N hN n hn, hN n N hn (le_refl N)) },
{ rcases comp_symm_of_uniformity (H.mem_of_mem hi) with ⟨t, ht, ht', hts⟩,
rcases H.mem_iff.1 ht with ⟨j, hj, hjt⟩,
refine (h j hj).imp (λ N hN m n hm hn, hts ⟨u N, hjt _, ht' $ hjt _⟩),
{ exact hN m hm },
{ exact hN n hn } }
end
lemma cauchy_seq_of_controlled [semilattice_sup β] [nonempty β]
(U : β → set (α × α)) (hU : ∀ s ∈ 𝓤 α, ∃ n, U n ⊆ s)
{f : β → α} (hf : ∀ {N m n : β}, N ≤ m → N ≤ n → (f m, f n) ∈ U N) :
cauchy_seq f :=
cauchy_seq_iff_tendsto.2
begin
assume s hs,
rw [mem_map, mem_at_top_sets],
cases hU s hs with N hN,
refine ⟨(N, N), λ mn hmn, _⟩,
cases mn with m n,
exact hN (hf hmn.1 hmn.2)
end
/-- A complete space is defined here using uniformities. A uniform space
is complete if every Cauchy filter converges. -/
class complete_space (α : Type u) [uniform_space α] : Prop :=
(complete : ∀{f:filter α}, cauchy f → ∃x, f ≤ 𝓝 x)
lemma complete_univ {α : Type u} [uniform_space α] [complete_space α] :
is_complete (univ : set α) :=
begin
assume f hf _,
rcases complete_space.complete hf with ⟨x, hx⟩,
exact ⟨x, mem_univ x, hx⟩
end
lemma cauchy_prod [uniform_space β] {f : filter α} {g : filter β} :
cauchy f → cauchy g → cauchy (filter.prod f g)
| ⟨f_proper, hf⟩ ⟨g_proper, hg⟩ := ⟨filter.prod_ne_bot.2 ⟨f_proper, g_proper⟩,
let p_α := λp:(α×β)×(α×β), (p.1.1, p.2.1), p_β := λp:(α×β)×(α×β), (p.1.2, p.2.2) in
suffices (f.prod f).comap p_α ⊓ (g.prod g).comap p_β ≤ (𝓤 α).comap p_α ⊓ (𝓤 β).comap p_β,
by simpa [uniformity_prod, filter.prod, filter.comap_inf, filter.comap_comap_comp, (∘),
inf_assoc, inf_comm, inf_left_comm],
inf_le_inf (filter.comap_mono hf) (filter.comap_mono hg)⟩
instance complete_space.prod [uniform_space β] [complete_space α] [complete_space β] :
complete_space (α × β) :=
{ complete := λ f hf,
let ⟨x1, hx1⟩ := complete_space.complete $ cauchy_map uniform_continuous_fst hf in
let ⟨x2, hx2⟩ := complete_space.complete $ cauchy_map uniform_continuous_snd hf in
⟨(x1, x2), by rw [nhds_prod_eq, filter.prod_def];
from filter.le_lift (λ s hs, filter.le_lift' $ λ t ht,
have H1 : prod.fst ⁻¹' s ∈ f.sets := hx1 hs,
have H2 : prod.snd ⁻¹' t ∈ f.sets := hx2 ht,
filter.inter_mem_sets H1 H2)⟩ }
/--If `univ` is complete, the space is a complete space -/
lemma complete_space_of_is_complete_univ (h : is_complete (univ : set α)) : complete_space α :=
⟨λ f hf, let ⟨x, _, hx⟩ := h f hf ((@principal_univ α).symm ▸ le_top) in ⟨x, hx⟩⟩
lemma complete_space_iff_is_complete_univ :
complete_space α ↔ is_complete (univ : set α) :=
⟨@complete_univ α _, complete_space_of_is_complete_univ⟩
lemma cauchy_iff_exists_le_nhds [complete_space α] {l : filter α} (hl : l ≠ ⊥) :
cauchy l ↔ (∃x, l ≤ 𝓝 x) :=
⟨complete_space.complete, assume ⟨x, hx⟩, cauchy_downwards cauchy_nhds hl hx⟩
lemma cauchy_map_iff_exists_tendsto [complete_space α] {l : filter β} {f : β → α}
(hl : l ≠ ⊥) : cauchy (l.map f) ↔ (∃x, tendsto f l (𝓝 x)) :=
cauchy_iff_exists_le_nhds (map_ne_bot hl)
/-- A Cauchy sequence in a complete space converges -/
theorem cauchy_seq_tendsto_of_complete [semilattice_sup β] [complete_space α]
{u : β → α} (H : cauchy_seq u) : ∃x, tendsto u at_top (𝓝 x) :=
complete_space.complete H
/-- If `K` is a complete subset, then any cauchy sequence in `K` converges to a point in `K` -/
lemma cauchy_seq_tendsto_of_is_complete [semilattice_sup β] {K : set α} (h₁ : is_complete K)
{u : β → α} (h₂ : ∀ n, u n ∈ K) (h₃ : cauchy_seq u) : ∃ v ∈ K, tendsto u at_top (𝓝 v) :=
h₁ _ h₃ $ le_principal_iff.2 $ mem_map_sets_iff.2 ⟨univ, univ_mem_sets,
by { simp only [image_univ], rintros _ ⟨n, rfl⟩, exact h₂ n }⟩
theorem le_nhds_lim_of_cauchy {α} [uniform_space α] [complete_space α]
[nonempty α] {f : filter α} (hf : cauchy f) : f ≤ 𝓝 (lim f) :=
lim_spec (complete_space.complete hf)
lemma is_complete_of_is_closed [complete_space α] {s : set α}
(h : is_closed s) : is_complete s :=
λ f cf fs, let ⟨x, hx⟩ := complete_space.complete cf in
⟨x, is_closed_iff_nhds.mp h x (ne_bot_of_le_ne_bot cf.left (le_inf hx fs)), hx⟩
/-- A set `s` is totally bounded if for every entourage `d` there is a finite
set of points `t` such that every element of `s` is `d`-near to some element of `t`. -/
def totally_bounded (s : set α) : Prop :=
∀d ∈ 𝓤 α, ∃t : set α, finite t ∧ s ⊆ (⋃y∈t, {x | (x,y) ∈ d})
theorem totally_bounded_iff_subset {s : set α} : totally_bounded s ↔
∀d ∈ 𝓤 α, ∃t ⊆ s, finite t ∧ s ⊆ (⋃y∈t, {x | (x,y) ∈ d}) :=
⟨λ H d hd, begin
rcases comp_symm_of_uniformity hd with ⟨r, hr, rs, rd⟩,
rcases H r hr with ⟨k, fk, ks⟩,
let u := {y ∈ k | ∃ x, x ∈ s ∧ (x, y) ∈ r},
let f : u → α := λ x, classical.some x.2.2,
have : ∀ x : u, f x ∈ s ∧ (f x, x.1) ∈ r := λ x, classical.some_spec x.2.2,
refine ⟨range f, _, _, _⟩,
{ exact range_subset_iff.2 (λ x, (this x).1) },
{ have : finite u := finite_subset fk (λ x h, h.1),
exact ⟨@set.fintype_range _ _ _ _ this.fintype⟩ },
{ intros x xs,
have := ks xs, simp at this,
rcases this with ⟨y, hy, xy⟩,
let z : coe_sort u := ⟨y, hy, x, xs, xy⟩,
exact mem_bUnion_iff.2 ⟨_, ⟨z, rfl⟩, rd $ mem_comp_rel.2 ⟨_, xy, rs (this z).2⟩⟩ }
end,
λ H d hd, let ⟨t, _, ht⟩ := H d hd in ⟨t, ht⟩⟩
lemma totally_bounded_subset {s₁ s₂ : set α} (hs : s₁ ⊆ s₂)
(h : totally_bounded s₂) : totally_bounded s₁ :=
assume d hd, let ⟨t, ht₁, ht₂⟩ := h d hd in ⟨t, ht₁, subset.trans hs ht₂⟩
lemma totally_bounded_empty : totally_bounded (∅ : set α) :=
λ d hd, ⟨∅, finite_empty, empty_subset _⟩
lemma totally_bounded_closure {s : set α} (h : totally_bounded s) :
totally_bounded (closure s) :=
assume t ht,
let ⟨t', ht', hct', htt'⟩ := mem_uniformity_is_closed ht, ⟨c, hcf, hc⟩ := h t' ht' in
⟨c, hcf,
calc closure s ⊆ closure (⋃ (y : α) (H : y ∈ c), {x : α | (x, y) ∈ t'}) : closure_mono hc
... = _ : closure_eq_of_is_closed $ is_closed_bUnion hcf $ assume i hi,
continuous_iff_is_closed.mp (continuous_id.prod_mk continuous_const) _ hct'
... ⊆ _ : bUnion_subset $ assume i hi, subset.trans (assume x, @htt' (x, i))
(subset_bUnion_of_mem hi)⟩
lemma totally_bounded_image [uniform_space β] {f : α → β} {s : set α}
(hf : uniform_continuous f) (hs : totally_bounded s) : totally_bounded (f '' s) :=
assume t ht,
have {p:α×α | (f p.1, f p.2) ∈ t} ∈ 𝓤 α,
from hf ht,
let ⟨c, hfc, hct⟩ := hs _ this in
⟨f '' c, finite_image f hfc,
begin
simp [image_subset_iff],
simp [subset_def] at hct,
intros x hx, simp,
exact hct x hx
end⟩
lemma cauchy_of_totally_bounded_of_ultrafilter {s : set α} {f : filter α}
(hs : totally_bounded s) (hf : is_ultrafilter f) (h : f ≤ principal s) : cauchy f :=
⟨hf.left, assume t ht,
let ⟨t', ht'₁, ht'_symm, ht'_t⟩ := comp_symm_of_uniformity ht in
let ⟨i, hi, hs_union⟩ := hs t' ht'₁ in
have (⋃y∈i, {x | (x,y) ∈ t'}) ∈ f.sets,
from mem_sets_of_superset (le_principal_iff.mp h) hs_union,
have ∃y∈i, {x | (x,y) ∈ t'} ∈ f.sets,
from mem_of_finite_Union_ultrafilter hf hi this,
let ⟨y, hy, hif⟩ := this in
have set.prod {x | (x,y) ∈ t'} {x | (x,y) ∈ t'} ⊆ comp_rel t' t',
from assume ⟨x₁, x₂⟩ ⟨(h₁ : (x₁, y) ∈ t'), (h₂ : (x₂, y) ∈ t')⟩,
⟨y, h₁, ht'_symm h₂⟩,
(filter.prod f f).sets_of_superset (prod_mem_prod hif hif) (subset.trans this ht'_t)⟩
lemma totally_bounded_iff_filter {s : set α} :
totally_bounded s ↔ (∀f, f ≠ ⊥ → f ≤ principal s → ∃c ≤ f, cauchy c) :=
⟨assume : totally_bounded s, assume f hf hs,
⟨ultrafilter_of f, ultrafilter_of_le,
cauchy_of_totally_bounded_of_ultrafilter this
(ultrafilter_ultrafilter_of hf) (le_trans ultrafilter_of_le hs)⟩,
assume h : ∀f, f ≠ ⊥ → f ≤ principal s → ∃c ≤ f, cauchy c, assume d hd,
classical.by_contradiction $ assume hs,
have hd_cover : ∀{t:set α}, finite t → ¬ s ⊆ (⋃y∈t, {x | (x,y) ∈ d}),
by simpa using hs,
let
f := ⨅t:{t : set α // finite t}, principal (s \ (⋃y∈t.val, {x | (x,y) ∈ d})),
⟨a, ha⟩ := (@ne_empty_iff_nonempty α s).1
(assume h, hd_cover finite_empty $ h.symm ▸ empty_subset _)
in
have f ≠ ⊥,
from infi_ne_bot_of_directed ⟨a⟩
(assume ⟨t₁, ht₁⟩ ⟨t₂, ht₂⟩, ⟨⟨t₁ ∪ t₂, finite_union ht₁ ht₂⟩,
principal_mono.mpr $ diff_subset_diff_right $ Union_subset_Union $
assume t, Union_subset_Union_const or.inl,
principal_mono.mpr $ diff_subset_diff_right $ Union_subset_Union $
assume t, Union_subset_Union_const or.inr⟩)
(assume ⟨t, ht⟩, by simp [diff_eq_empty]; exact hd_cover ht),
have f ≤ principal s, from infi_le_of_le ⟨∅, finite_empty⟩ $ by simp; exact subset.refl s,
let
⟨c, (hc₁ : c ≤ f), (hc₂ : cauchy c)⟩ := h f ‹f ≠ ⊥› this,
⟨m, hm, (hmd : set.prod m m ⊆ d)⟩ := (@mem_prod_same_iff α c d).mp $ hc₂.right hd
in
have c ≤ principal s, from le_trans ‹c ≤ f› this,
have m ∩ s ∈ c.sets, from inter_mem_sets hm $ le_principal_iff.mp this,
let ⟨y, hym, hys⟩ := nonempty_of_mem_sets hc₂.left this in
let ys := (⋃y'∈({y}:set α), {x | (x, y') ∈ d}) in
have m ⊆ ys,
from assume y' hy',
show y' ∈ (⋃y'∈({y}:set α), {x | (x, y') ∈ d}),
by simp; exact @hmd (y', y) ⟨hy', hym⟩,
have c ≤ principal (s - ys),
from le_trans hc₁ $ infi_le_of_le ⟨{y}, finite_singleton _⟩ $ le_refl _,
have (s - ys) ∩ (m ∩ s) ∈ c.sets,
from inter_mem_sets (le_principal_iff.mp this) ‹m ∩ s ∈ c.sets›,
have ∅ ∈ c.sets,
from c.sets_of_superset this $ assume x ⟨⟨hxs, hxys⟩, hxm, _⟩, hxys $ ‹m ⊆ ys› hxm,
hc₂.left $ empty_in_sets_eq_bot.mp this⟩
lemma totally_bounded_iff_ultrafilter {s : set α} :
totally_bounded s ↔ (∀f, is_ultrafilter f → f ≤ principal s → cauchy f) :=
⟨assume hs f, cauchy_of_totally_bounded_of_ultrafilter hs,
assume h, totally_bounded_iff_filter.mpr $ assume f hf hfs,
have cauchy (ultrafilter_of f),
from h (ultrafilter_of f) (ultrafilter_ultrafilter_of hf) (le_trans ultrafilter_of_le hfs),
⟨ultrafilter_of f, ultrafilter_of_le, this⟩⟩
lemma compact_iff_totally_bounded_complete {s : set α} :
compact s ↔ totally_bounded s ∧ is_complete s :=
⟨λ hs, ⟨totally_bounded_iff_ultrafilter.2 (λ f hf1 hf2,
let ⟨x, xs, fx⟩ := compact_iff_ultrafilter_le_nhds.1 hs f hf1 hf2 in
cauchy_downwards (cauchy_nhds) (hf1.1) fx),
λ f fc fs,
let ⟨a, as, fa⟩ := hs f fc.1 fs in
⟨a, as, le_nhds_of_cauchy_adhp fc fa⟩⟩,
λ ⟨ht, hc⟩, compact_iff_ultrafilter_le_nhds.2
(λf hf hfs, hc _ (totally_bounded_iff_ultrafilter.1 ht _ hf hfs) hfs)⟩
@[priority 100] -- see Note [lower instance priority]
instance complete_of_compact {α : Type u} [uniform_space α] [compact_space α] : complete_space α :=
⟨λf hf, by simpa [principal_univ] using (compact_iff_totally_bounded_complete.1 compact_univ).2 f hf⟩
lemma compact_of_totally_bounded_is_closed [complete_space α] {s : set α}
(ht : totally_bounded s) (hc : is_closed s) : compact s :=
(@compact_iff_totally_bounded_complete α _ s).2 ⟨ht, is_complete_of_is_closed hc⟩
/-!
### Sequentially complete space
In this section we prove that a uniform space is complete provided that it is sequentially complete
(i.e., any Cauchy sequence converges) and its uniformity filter admits a countable generating set.
In particular, this applies to (e)metric spaces, see the files `topology/metric_space/emetric_space`
and `topology/metric_space/basic`.
More precisely, we assume that there is a sequence of entourages `U_n` such that any other
entourage includes one of `U_n`. Then any Cauchy filter `f` generates a decreasing sequence of
sets `s_n ∈ f` such that `s_n × s_n ⊆ U_n`. Choose a sequence `x_n∈s_n`. It is easy to show
that this is a Cauchy sequence. If this sequence converges to some `a`, then `f ≤ 𝓝 a`. -/
namespace sequentially_complete
variables {f : filter α} (hf : cauchy f) {U : ℕ → set (α × α)}
(U_mem : ∀ n, U n ∈ 𝓤 α) (U_le : ∀ s ∈ 𝓤 α, ∃ n, U n ⊆ s)
open set finset
noncomputable theory
/-- An auxiliary sequence of sets approximating a Cauchy filter. -/
def set_seq_aux (n : ℕ) : {s : set α // ∃ (_ : s ∈ f), s.prod s ⊆ U n } :=
indefinite_description _ $ (cauchy_iff.1 hf).2 (U n) (U_mem n)
/-- Given a Cauchy filter `f` and a sequence `U` of entourages, `set_seq` provides
a sequence of monotonically decreasing sets `s n ∈ f` such that `(s n).prod (s n) ⊆ U`. -/
def set_seq (n : ℕ) : set α := ⋂ m ∈ Iic n, (set_seq_aux hf U_mem m).val
lemma set_seq_mem (n : ℕ) : set_seq hf U_mem n ∈ f :=
Inter_mem_sets (finite_le_nat n) (λ m _, (set_seq_aux hf U_mem m).2.fst)
lemma set_seq_mono ⦃m n : ℕ⦄ (h : m ≤ n) : set_seq hf U_mem n ⊆ set_seq hf U_mem m :=
bInter_subset_bInter_left (λ k hk, le_trans hk h)
lemma set_seq_sub_aux (n : ℕ) : set_seq hf U_mem n ⊆ set_seq_aux hf U_mem n :=
bInter_subset_of_mem right_mem_Iic
lemma set_seq_prod_subset {N m n} (hm : N ≤ m) (hn : N ≤ n) :
(set_seq hf U_mem m).prod (set_seq hf U_mem n) ⊆ U N :=
begin
assume p hp,
refine (set_seq_aux hf U_mem N).2.snd ⟨_, _⟩;
apply set_seq_sub_aux,
exact set_seq_mono hf U_mem hm hp.1,
exact set_seq_mono hf U_mem hn hp.2
end
/-- A sequence of points such that `seq n ∈ set_seq n`. Here `set_seq` is a monotonically
decreasing sequence of sets `set_seq n ∈ f` with diameters controlled by a given sequence
of entourages. -/
def seq (n : ℕ) : α := some $ nonempty_of_mem_sets hf.1 (set_seq_mem hf U_mem n)
lemma seq_mem (n : ℕ) : seq hf U_mem n ∈ set_seq hf U_mem n :=
some_spec $ nonempty_of_mem_sets hf.1 (set_seq_mem hf U_mem n)
lemma seq_pair_mem ⦃N m n : ℕ⦄ (hm : N ≤ m) (hn : N ≤ n) :
(seq hf U_mem m, seq hf U_mem n) ∈ U N :=
set_seq_prod_subset hf U_mem hm hn ⟨seq_mem hf U_mem m, seq_mem hf U_mem n⟩
include U_le
theorem seq_is_cauchy_seq : cauchy_seq $ seq hf U_mem :=
cauchy_seq_of_controlled U U_le $ seq_pair_mem hf U_mem
/-- If the sequence `sequentially_complete.seq` converges to `a`, then `f ≤ 𝓝 a`. -/
theorem le_nhds_of_seq_tendsto_nhds ⦃a : α⦄ (ha : tendsto (seq hf U_mem) at_top (𝓝 a)) :
f ≤ 𝓝 a :=
le_nhds_of_cauchy_adhp_aux
begin
assume s hs,
rcases U_le s hs with ⟨m, hm⟩,
rcases (tendsto_at_top' _ _).1 ha _ (mem_nhds_left a (U_mem m)) with ⟨n, hn⟩,
refine ⟨set_seq hf U_mem (max m n), set_seq_mem hf U_mem _, _,
seq hf U_mem (max m n), seq_mem hf U_mem _, _⟩,
{ have := le_max_left m n,
exact set.subset.trans (set_seq_prod_subset hf U_mem this this) hm },
{ exact hm (hn _ $ le_max_right m n) }
end
end sequentially_complete
namespace uniform_space
open sequentially_complete
variables (H : is_countably_generated (𝓤 α))
include H
/-- A uniform space is complete provided that (a) its uniformity filter has a countable basis;
(b) any sequence satisfying a "controlled" version of the Cauchy condition converges. -/
theorem complete_of_convergent_controlled_sequences (U : ℕ → set (α × α)) (U_mem : ∀ n, U n ∈ 𝓤 α)
(HU : ∀ u : ℕ → α, (∀ N m n, N ≤ m → N ≤ n → (u m, u n) ∈ U N) → ∃ a, tendsto u at_top (𝓝 a)) :
complete_space α :=
begin
rcases H.exists_antimono_seq' with ⟨U', U'_mono, hU'⟩,
have Hmem : ∀ n, U n ∩ U' n ∈ 𝓤 α,
from λ n, inter_mem_sets (U_mem n) (hU'.2 ⟨n, subset.refl _⟩),
refine ⟨λ f hf, (HU (seq hf Hmem) (λ N m n hm hn, _)).imp $
le_nhds_of_seq_tendsto_nhds _ _ (λ s hs, _)⟩,
{ rcases (hU'.1 hs) with ⟨N, hN⟩,
exact ⟨N, subset.trans (inter_subset_right _ _) hN⟩ },
{ exact inter_subset_left _ _ (seq_pair_mem hf Hmem hm hn) }
end
/-- A sequentially complete uniform space with a countable basis of the uniformity filter is
complete. -/
theorem complete_of_cauchy_seq_tendsto
(H' : ∀ u : ℕ → α, cauchy_seq u → ∃a, tendsto u at_top (𝓝 a)) :
complete_space α :=
let ⟨U', U'_mono, hU'⟩ := H.exists_antimono_seq' in
complete_of_convergent_controlled_sequences H U' (λ n, hU'.2 ⟨n, subset.refl _⟩)
(λ u hu, H' u $ cauchy_seq_of_controlled U' (λ s hs, hU'.1 hs) hu)
protected lemma first_countable_topology : first_countable_topology α :=
⟨λ a, by { rw nhds_eq_comap_uniformity, exact H.comap (prod.mk a) }⟩
end uniform_space
|
bfafb4c0036e76f44a70a056ac7936e6add3c8be | dd0f5513e11c52db157d2fcc8456d9401a6cd9da | /03_Propositions_and_Proofs.org.34.lean | 34476435ec808bd748ff3e9a08d7d9fa931b0b41 | [] | 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 | 168 | lean | /- page 43 -/
import standard
open classical
variable p : Prop
-- BEGIN
example (H : ¬¬p) : p :=
by_cases
(assume H1 : p, H1)
(assume H1 : ¬p, absurd H1 H)
-- END
|
d4eb990673e24b0079241fad2ddbdd7263774dd6 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/data/mv_polynomial/funext.lean | 980409a8de1e93d6ae148d49641fd0294cdc0a2c | [] | 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,461 | lean | /-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.polynomial.ring_division
import Mathlib.data.mv_polynomial.rename
import Mathlib.ring_theory.polynomial.basic
import Mathlib.PostPort
universes u_1 u_2
namespace Mathlib
/-!
## Function extensionality for multivariate polynomials
In this file we show that two multivariate polynomials over an infinite integral domain are equal
if they are equal upon evaluating them on an arbitrary assignment of the variables.
# Main declaration
* `mv_polynomial.funext`: two polynomials `φ ψ : mv_polynomial σ R`
over an infinite integral domain `R` are equal if `eval x φ = eval x ψ` for all `x : σ → R`.
-/
namespace mv_polynomial
/-- Two multivariate polynomials over an infinite integral domain are equal
if they are equal upon evaluating them on an arbitrary assignment of the variables. -/
theorem funext {R : Type u_1} [integral_domain R] [infinite R] {σ : Type u_2} {p : mv_polynomial σ R} {q : mv_polynomial σ R} (h : ∀ (x : σ → R), coe_fn (eval x) p = coe_fn (eval x) q) : p = q := sorry
theorem funext_iff {R : Type u_1} [integral_domain R] [infinite R] {σ : Type u_2} {p : mv_polynomial σ R} {q : mv_polynomial σ R} : p = q ↔ ∀ (x : σ → R), coe_fn (eval x) p = coe_fn (eval x) q := sorry
|
f15d01d9e373b3b61d76921c58d2245d79d8fd65 | 55c7fc2bf55d496ace18cd6f3376e12bb14c8cc5 | /src/algebra/category/CommRing/limits.lean | 36b3bc76c5ff9ae8714e26e8eaffceaece3def75 | [
"Apache-2.0"
] | permissive | dupuisf/mathlib | 62de4ec6544bf3b79086afd27b6529acfaf2c1bb | 8582b06b0a5d06c33ee07d0bdf7c646cae22cf36 | refs/heads/master | 1,669,494,854,016 | 1,595,692,409,000 | 1,595,692,409,000 | 272,046,630 | 0 | 0 | Apache-2.0 | 1,592,066,143,000 | 1,592,066,142,000 | null | UTF-8 | Lean | false | false | 4,844 | 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.CommRing.basic
import ring_theory.subring
import algebra.ring.pi
/-!
# The category of commutative rings has all limits
Further, these limits are preserved by the forgetful functor --- that is,
the underlying types are just the limits in the category of types.
## Further work
A lot of this should be generalised / automated, as it's quite common for concrete
categories that the forgetful functor preserves limits.
-/
open category_theory
open category_theory.limits
universe u
namespace CommRing
variables {J : Type u} [small_category J]
instance comm_ring_obj (F : J ⥤ CommRing) (j) :
comm_ring ((F ⋙ forget CommRing).obj j) :=
by { change comm_ring (F.obj j), apply_instance }
instance sections_submonoid (F : J ⥤ CommRing) :
is_submonoid (F ⋙ forget CommRing).sections :=
{ one_mem := λ j j' f,
begin
erw [functor.comp_map, forget_map_eq_coe, (F.map f).map_one],
refl
end,
mul_mem := λ a b ah bh j j' f,
begin
erw [functor.comp_map, forget_map_eq_coe, (F.map f).map_mul],
dsimp [functor.sections] at ah,
rw ah f,
dsimp [functor.sections] at bh,
rw bh f,
refl,
end }
instance sections_add_submonoid (F : J ⥤ CommRing) :
is_add_submonoid (F ⋙ forget CommRing).sections :=
{ zero_mem := λ j j' f,
begin
erw [functor.comp_map, forget_map_eq_coe, (F.map f).map_zero],
refl,
end,
add_mem := λ a b ah bh j j' f,
begin
erw [functor.comp_map, forget_map_eq_coe, (F.map f).map_add],
dsimp [functor.sections] at ah,
rw ah f,
dsimp [functor.sections] at bh,
rw bh f,
refl,
end }
instance sections_add_subgroup (F : J ⥤ CommRing) :
is_add_subgroup (F ⋙ forget CommRing).sections :=
{ neg_mem := λ a ah j j' f,
begin
erw [functor.comp_map, forget_map_eq_coe, (F.map f).map_neg],
dsimp [functor.sections] at ah,
rw ah f,
refl,
end,
..(CommRing.sections_add_submonoid F) }
instance sections_subring (F : J ⥤ CommRing) :
is_subring (F ⋙ forget CommRing).sections :=
{ ..(CommRing.sections_submonoid F),
..(CommRing.sections_add_subgroup F) }
instance limit_comm_ring (F : J ⥤ CommRing) :
comm_ring (limit (F ⋙ forget CommRing)) :=
@subtype.comm_ring ((Π (j : J), (F ⋙ forget _).obj j)) (by apply_instance) _
(by convert (CommRing.sections_subring F))
/-- `limit.π (F ⋙ forget CommRing) j` as a `ring_hom`. -/
def limit_π_ring_hom (F : J ⥤ CommRing) (j) :
limit (F ⋙ forget CommRing) →+* (F ⋙ forget CommRing).obj j :=
{ to_fun := limit.π (F ⋙ forget CommRing) j,
map_one' := by { simp only [types.types_limit_π], refl },
map_zero' := by { simp only [types.types_limit_π], refl },
map_mul' := λ x y, by { simp only [types.types_limit_π], refl },
map_add' := λ x y, by { simp only [types.types_limit_π], refl } }
namespace CommRing_has_limits
-- The next two definitions are used in the construction of `has_limits CommRing`.
-- After that, the limits should be constructed using the generic limits API,
-- e.g. `limit F`, `limit.cone F`, and `limit.is_limit F`.
/--
Construction of a limit cone in `CommRing`.
(Internal use only; use the limits API.)
-/
def limit (F : J ⥤ CommRing) : cone F :=
{ X := ⟨limit (F ⋙ forget _), by apply_instance⟩,
π :=
{ app := limit_π_ring_hom F,
naturality' := λ j j' f,
ring_hom.coe_inj ((limit.cone (F ⋙ forget _)).π.naturality f) } }
/--
Witness that the limit cone in `CommRing` is a limit cone.
(Internal use only; use the limits API.)
-/
def limit_is_limit (F : J ⥤ CommRing) : is_limit (limit F) :=
begin
refine is_limit.of_faithful
(forget CommRing) (limit.is_limit _)
(λ s, ⟨_, _, _, _, _⟩) (λ s, rfl); dsimp,
{ ext j, dsimp, rw (s.π.app j).map_one },
{ intros x y, ext j, dsimp, rw (s.π.app j).map_mul },
{ ext j, dsimp, rw (s.π.app j).map_zero, refl },
{ intros x y, ext j, dsimp, rw (s.π.app j).map_add, refl }
end
end CommRing_has_limits
open CommRing_has_limits
/-- The category of commutative rings has all limits. -/
instance CommRing_has_limits : has_limits CommRing :=
{ has_limits_of_shape := λ J 𝒥,
{ has_limit := λ F, by exactI
{ cone := limit F,
is_limit := limit_is_limit F } } }
/--
The forgetful functor from commutative rings to types preserves all limits. (That is, the underlying
types could have been computed instead as limits in the category of types.)
-/
instance forget_preserves_limits : preserves_limits (forget CommRing) :=
{ preserves_limits_of_shape := λ J 𝒥,
{ preserves_limit := λ F,
by exactI preserves_limit_of_preserves_limit_cone
(limit.is_limit F) (limit.is_limit (F ⋙ forget _)) } }
end CommRing
|
dc7a3af9dd67afdbdbf148b65341ee7891d5d521 | 9ad8d18fbe5f120c22b5e035bc240f711d2cbd7e | /src/undergraduate/MAS114/Semester 1/Q21.lean | b7d9c783fefcddd18fd6ae6d92b5890532fa0bff | [] | no_license | agusakov/lean_lib | c0e9cc29fc7d2518004e224376adeb5e69b5cc1a | f88d162da2f990b87c4d34f5f46bbca2bbc5948e | refs/heads/master | 1,642,141,461,087 | 1,557,395,798,000 | 1,557,395,798,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 4,012 | lean | import algebra.ring algebra.group_power data.zmod.basic data.nat.prime
import data.finset algebra.big_operators
import tactic.ring tactic.linarith
namespace MAS114
namespace exercises_1
namespace Q21
def u (n : ℕ) : ℕ := 2 ^ n
def a (n : ℕ) : ℕ := 2 ^ (u n) + 1
lemma u_ge_1 (n : ℕ) : u n ≥ 1 :=
by {
let e := @nat.pow_le_pow_of_le_right 2 dec_trivial 0 n (nat.zero_le n),
rw[nat.pow_zero] at e,
exact e,
}
lemma u_step (n : ℕ) : u (n + 1) = (u n) * 2 :=
by {dsimp[u],rw[nat.pow_succ],}
def a_pos (n : ℕ) : ℕ+ := ⟨a n,nat.zero_lt_succ _⟩
lemma a_step (n : ℕ) : a (n + 1) + 2 * (a n) = 2 + (a n) * (a n) :=
begin
have h : ∀ (x : ℕ), x ^ 2 + 1 + 2 * (x + 1)
= 2 + (x + 1) * (x + 1) := by {intro, ring,},
rw[a,a,u_step,nat.pow_mul,h (2 ^ (u n))],
end
lemma a_ge_3 (n : ℕ) : a n ≥ 3 :=
begin
let e := @nat.pow_le_pow_of_le_right 2 dec_trivial _ _ (u_ge_1 n),
rw[nat.pow_one] at e,
exact nat.succ_le_succ e,
end
lemma a_ne_1 (n : ℕ) : a n ≠ 1 := ne_of_gt (lt_trans dec_trivial (a_ge_3 n))
lemma a_odd (n : ℕ) : (a n) % 2 = 1 :=
begin
dsimp[a],
rw[← nat.add_sub_of_le (u_ge_1 n),nat.pow_add,nat.pow_one],
rw[add_comm _ 1,nat.add_mul_mod_self_left],
refl,
end
lemma a_mod_a : ∀ (n m : ℕ), a (n + m + 1) ≡ 2 [MOD (a n)]
| n 0 := begin
rw[add_zero n],
let e : (a (n + 1) + 2 * (a n)) % (a n) =
(2 + (a n) * (a n)) % (a n) :=
congr_arg (λ i, i % (a n)) (a_step n),
rw[nat.add_mul_mod_self_right] at e,
rw[nat.add_mul_mod_self_right] at e,
exact e,
end
| n (m + 1) := begin
rw[← (add_assoc n m 1)],
let e := a_step (n + m + 1),
replace e : (a (n + m + 1 + 1) + 2 * a (n + m + 1)) % (a n) =
(2 + a (n + m + 1) * a (n + m + 1)) % (a n) := by {rw[e]},
let ih := a_mod_a n m,
let ih1 : 2 * a (n + m + 1) ≡ 4 [MOD (a n)] :=
nat.modeq.modeq_mul rfl ih,
let ih2 : a (n + m + 1) * a (n + m + 1) ≡ 4 [MOD (a n)] :=
nat.modeq.modeq_mul ih ih,
let ih3 : a (n + m + 1 + 1) + 2 * a (n + m + 1) ≡
a (n + m + 1 + 1) + 4 [MOD (a n)] := nat.modeq.modeq_add rfl ih1,
let ih4 : 2 + a (n + m + 1) * a (n + m + 1) ≡ 2 + 4 [MOD (a n)] :=
nat.modeq.modeq_add rfl ih2,
let e1 := (ih3.symm.trans e).trans ih4,
exact nat.modeq.modeq_add_cancel_right rfl e1,
end
lemma a_coprime_aux (n m : ℕ) : nat.coprime (a n) (a (n + m + 1)) :=
begin
let u := a n,
let v := a (n + m + 1),
change (nat.gcd u v) = 1,
let q := v / u,
let r := v % u,
have e0 : r + u * q = v := nat.mod_add_div (a (n + m + 1)) (a n),
have e1 : r = 2 % (a n) := a_mod_a n m,
have e2 : 2 % (a n) = 2 := @nat.mod_eq_of_lt 2 (a n) (a_ge_3 n),
rw[e2] at e1,
have e3 : nat.gcd u v = nat.gcd r u := nat.gcd_rec u v,
rw[e1] at e3,
have e4 : nat.gcd 2 u = nat.gcd (u % 2) 2 := nat.gcd_rec 2 u,
have e5 : u % 2 = 1 := a_odd n,
rw[e5] at e4,
rw[e4] at e3,
exact e3
end
lemma a_coprime {n m : ℕ} : n ≠ m → nat.coprime (a n) (a m) :=
begin
rcases (lt_or_ge n m) with h,
{let k := m - n.succ,
have e0 : (n + 1) + k = m := nat.add_sub_of_le h,
have : (n + 1) + k = n + k + 1 := by ring,
rw[this] at e0,
rw[← e0],
intro,
exact a_coprime_aux n k,
},{
intro h0,
let h1 := lt_of_le_of_ne h h0.symm,
let k := n - m.succ,
have e0 : (m + 1) + k = n := nat.add_sub_of_le h1,
have : (m + 1) + k = m + k + 1 := by ring,
rw[this] at e0,
rw[← e0],
exact (a_coprime_aux m k).symm,
}
end
def b (n : ℕ) : ℕ := nat.min_fac (a n)
def b_prime (n : ℕ) : nat.prime (b n) := nat.min_fac_prime (a_ne_1 n)
lemma b_inj : function.injective b := begin
intros i j e0,
by_cases e1 : i = j,
{assumption},
{exfalso,
have e2 : nat.gcd (a i) (a j) = 1 := a_coprime e1,
have e3 : (b i) ∣ (a i) := nat.min_fac_dvd (a i),
have e4 : (b j) ∣ (a j) := nat.min_fac_dvd (a j),
rw[← e0] at e4,
let e5 := nat.dvd_gcd e3 e4,
rw[e2] at e5,
exact nat.prime.not_dvd_one (b_prime i) e5
}
end
end Q21
end exercises_1
end MAS114 |
871a2ad3e2d61d2c1e123f1bf6f69a6084d32a00 | bbecf0f1968d1fba4124103e4f6b55251d08e9c4 | /src/analysis/special_functions/exp_log.lean | da746bd2a6090d4968dbe5d98d32da992f8be858 | [
"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 | 38,027 | lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
-/
import analysis.calculus.inverse
import analysis.complex.real_deriv
import data.complex.exponential
/-!
# Complex and real exponential, real logarithm
## Main statements
This file establishes the basic analytical properties of the complex and real exponential functions
(continuity, differentiability, computation of the derivative).
It also contains the definition of the real logarithm function (as the inverse of the
exponential on `(0, +∞)`, extended to `ℝ` by setting `log (-x) = log x`) and its basic
properties (continuity, differentiability, formula for the derivative).
The complex logarithm is *not* defined in this file as it relies on trigonometric functions. See
instead `trigonometric.lean`.
## Tags
exp, log
-/
noncomputable theory
open finset filter metric asymptotics set function
open_locale classical topological_space
section continuity
namespace complex
variables {z y x : ℝ}
lemma exp_bound_sq (x z : ℂ) (hz : ∥z∥ ≤ 1) :
∥exp (x + z) - exp x - z • exp x∥ ≤ ∥exp x∥ * ∥z∥ ^ 2 :=
calc ∥exp (x + z) - exp x - z * exp x∥
= ∥exp x * (exp z - 1 - z)∥ : by { congr, rw [exp_add], ring }
... = ∥exp x∥ * ∥exp z - 1 - z∥ : normed_field.norm_mul _ _
... ≤ ∥exp x∥ * ∥z∥^2 : mul_le_mul_of_nonneg_left (abs_exp_sub_one_sub_id_le hz) (norm_nonneg _)
lemma locally_lipschitz_exp {r : ℝ} (hr_nonneg : 0 ≤ r) (hr_le : r ≤ 1) (x y : ℂ)
(hyx : ∥y - x∥ < r) :
∥exp y - exp x∥ ≤ (1 + r) * ∥exp x∥ * ∥y - x∥ :=
begin
have hy_eq : y = x + (y - x), by abel,
have hyx_sq_le : ∥y - x∥ ^ 2 ≤ r * ∥y - x∥,
{ rw pow_two,
exact mul_le_mul hyx.le le_rfl (norm_nonneg _) hr_nonneg, },
have h_sq : ∀ z, ∥z∥ ≤ 1 → ∥exp (x + z) - exp x∥ ≤ ∥z∥ * ∥exp x∥ + ∥exp x∥ * ∥z∥ ^ 2,
{ intros z hz,
have : ∥exp (x + z) - exp x - z • exp x∥ ≤ ∥exp x∥ * ∥z∥ ^ 2, from exp_bound_sq x z hz,
rw [← sub_le_iff_le_add', ← norm_smul z],
exact (norm_sub_norm_le _ _).trans this, },
calc ∥exp y - exp x∥ = ∥exp (x + (y - x)) - exp x∥ : by nth_rewrite 0 hy_eq
... ≤ ∥y - x∥ * ∥exp x∥ + ∥exp x∥ * ∥y - x∥ ^ 2 : h_sq (y - x) (hyx.le.trans hr_le)
... ≤ ∥y - x∥ * ∥exp x∥ + ∥exp x∥ * (r * ∥y - x∥) :
add_le_add_left (mul_le_mul le_rfl hyx_sq_le (sq_nonneg _) (norm_nonneg _)) _
... = (1 + r) * ∥exp x∥ * ∥y - x∥ : by ring,
end
@[continuity] lemma continuous_exp : continuous exp :=
continuous_iff_continuous_at.mpr $
λ x, continuous_at_of_locally_lipschitz zero_lt_one (2 * ∥exp x∥)
(locally_lipschitz_exp zero_le_one le_rfl x)
lemma continuous_on_exp {s : set ℂ} : continuous_on exp s :=
continuous_exp.continuous_on
end complex
section complex_continuous_exp_comp
variable {α : Type*}
open complex
lemma filter.tendsto.cexp {l : filter α} {f : α → ℂ} {z : ℂ} (hf : tendsto f l (𝓝 z)) :
tendsto (λ x, exp (f x)) l (𝓝 (exp z)) :=
(continuous_exp.tendsto _).comp hf
variables [topological_space α] {f : α → ℂ} {s : set α} {x : α}
lemma continuous_within_at.cexp (h : continuous_within_at f s x) :
continuous_within_at (λ y, exp (f y)) s x :=
h.cexp
lemma continuous_at.cexp (h : continuous_at f x) : continuous_at (λ y, exp (f y)) x :=
h.cexp
lemma continuous_on.cexp (h : continuous_on f s) : continuous_on (λ y, exp (f y)) s :=
λ x hx, (h x hx).cexp
lemma continuous.cexp (h : continuous f) : continuous (λ y, exp (f y)) :=
continuous_iff_continuous_at.2 $ λ x, h.continuous_at.cexp
end complex_continuous_exp_comp
namespace real
@[continuity] lemma continuous_exp : continuous exp :=
complex.continuous_re.comp (complex.continuous_exp.comp complex.continuous_of_real)
lemma continuous_on_exp {s : set ℝ} : continuous_on exp s :=
continuous_exp.continuous_on
end real
end continuity
namespace complex
/-- The complex exponential is everywhere differentiable, with the derivative `exp x`. -/
lemma has_deriv_at_exp (x : ℂ) : has_deriv_at exp (exp x) x :=
begin
rw has_deriv_at_iff_is_o_nhds_zero,
have : (1 : ℕ) < 2 := by norm_num,
refine (is_O.of_bound (∥exp x∥) _).trans_is_o (is_o_pow_id this),
filter_upwards [metric.ball_mem_nhds (0 : ℂ) zero_lt_one],
simp only [metric.mem_ball, dist_zero_right, normed_field.norm_pow],
exact λ z hz, exp_bound_sq x z hz.le,
end
lemma differentiable_exp : differentiable ℂ exp :=
λx, (has_deriv_at_exp x).differentiable_at
lemma differentiable_at_exp {x : ℂ} : differentiable_at ℂ exp x :=
differentiable_exp x
@[simp] lemma deriv_exp : deriv exp = exp :=
funext $ λ x, (has_deriv_at_exp x).deriv
@[simp] lemma iter_deriv_exp : ∀ n : ℕ, (deriv^[n] exp) = exp
| 0 := rfl
| (n+1) := by rw [iterate_succ_apply, deriv_exp, iter_deriv_exp n]
lemma times_cont_diff_exp : ∀ {n}, times_cont_diff ℂ n exp :=
begin
refine times_cont_diff_all_iff_nat.2 (λ n, _),
induction n with n ihn,
{ exact times_cont_diff_zero.2 continuous_exp },
{ rw times_cont_diff_succ_iff_deriv,
use differentiable_exp,
rwa deriv_exp }
end
lemma has_strict_deriv_at_exp (x : ℂ) : has_strict_deriv_at exp (exp x) x :=
times_cont_diff_exp.times_cont_diff_at.has_strict_deriv_at' (has_deriv_at_exp x) le_rfl
lemma has_strict_fderiv_at_exp_real (x : ℂ) :
has_strict_fderiv_at exp (exp x • (1 : ℂ →L[ℝ] ℂ)) x :=
(has_strict_deriv_at_exp x).complex_to_real_fderiv
lemma is_open_map_exp : is_open_map exp :=
open_map_of_strict_deriv has_strict_deriv_at_exp exp_ne_zero
end complex
section
variables {f : ℂ → ℂ} {f' x : ℂ} {s : set ℂ}
lemma has_strict_deriv_at.cexp (hf : has_strict_deriv_at f f' x) :
has_strict_deriv_at (λ x, complex.exp (f x)) (complex.exp (f x) * f') x :=
(complex.has_strict_deriv_at_exp (f x)).comp x hf
lemma has_deriv_at.cexp (hf : has_deriv_at f f' x) :
has_deriv_at (λ x, complex.exp (f x)) (complex.exp (f x) * f') x :=
(complex.has_deriv_at_exp (f x)).comp x hf
lemma has_deriv_within_at.cexp (hf : has_deriv_within_at f f' s x) :
has_deriv_within_at (λ x, complex.exp (f x)) (complex.exp (f x) * f') s x :=
(complex.has_deriv_at_exp (f x)).comp_has_deriv_within_at x hf
lemma deriv_within_cexp (hf : differentiable_within_at ℂ f s x)
(hxs : unique_diff_within_at ℂ s x) :
deriv_within (λx, complex.exp (f x)) s x = complex.exp (f x) * (deriv_within f s x) :=
hf.has_deriv_within_at.cexp.deriv_within hxs
@[simp] lemma deriv_cexp (hc : differentiable_at ℂ f x) :
deriv (λx, complex.exp (f x)) x = complex.exp (f x) * (deriv f x) :=
hc.has_deriv_at.cexp.deriv
end
section
variables {f : ℝ → ℂ} {f' : ℂ} {x : ℝ} {s : set ℝ}
open complex
lemma has_strict_deriv_at.cexp_real (h : has_strict_deriv_at f f' x) :
has_strict_deriv_at (λ x, exp (f x)) (exp (f x) * f') x :=
(has_strict_fderiv_at_exp_real (f x)).comp_has_strict_deriv_at x h
lemma has_deriv_at.cexp_real (h : has_deriv_at f f' x) :
has_deriv_at (λ x, exp (f x)) (exp (f x) * f') x :=
(has_strict_fderiv_at_exp_real (f x)).has_fderiv_at.comp_has_deriv_at x h
lemma has_deriv_within_at.cexp_real (h : has_deriv_within_at f f' s x) :
has_deriv_within_at (λ x, exp (f x)) (exp (f x) * f') s x :=
(has_strict_fderiv_at_exp_real (f x)).has_fderiv_at.comp_has_deriv_within_at x h
end
section
variables {E : Type*} [normed_group E] [normed_space ℂ E] {f : E → ℂ} {f' : E →L[ℂ] ℂ}
{x : E} {s : set E}
lemma has_strict_fderiv_at.cexp (hf : has_strict_fderiv_at f f' x) :
has_strict_fderiv_at (λ x, complex.exp (f x)) (complex.exp (f x) • f') x :=
(complex.has_strict_deriv_at_exp (f x)).comp_has_strict_fderiv_at x hf
lemma has_fderiv_within_at.cexp (hf : has_fderiv_within_at f f' s x) :
has_fderiv_within_at (λ x, complex.exp (f x)) (complex.exp (f x) • f') s x :=
(complex.has_deriv_at_exp (f x)).comp_has_fderiv_within_at x hf
lemma has_fderiv_at.cexp (hf : has_fderiv_at f f' x) :
has_fderiv_at (λ x, complex.exp (f x)) (complex.exp (f x) • f') x :=
has_fderiv_within_at_univ.1 $ hf.has_fderiv_within_at.cexp
lemma differentiable_within_at.cexp (hf : differentiable_within_at ℂ f s x) :
differentiable_within_at ℂ (λ x, complex.exp (f x)) s x :=
hf.has_fderiv_within_at.cexp.differentiable_within_at
@[simp] lemma differentiable_at.cexp (hc : differentiable_at ℂ f x) :
differentiable_at ℂ (λx, complex.exp (f x)) x :=
hc.has_fderiv_at.cexp.differentiable_at
lemma differentiable_on.cexp (hc : differentiable_on ℂ f s) :
differentiable_on ℂ (λx, complex.exp (f x)) s :=
λx h, (hc x h).cexp
@[simp] lemma differentiable.cexp (hc : differentiable ℂ f) :
differentiable ℂ (λx, complex.exp (f x)) :=
λx, (hc x).cexp
lemma times_cont_diff.cexp {n} (h : times_cont_diff ℂ n f) :
times_cont_diff ℂ n (λ x, complex.exp (f x)) :=
complex.times_cont_diff_exp.comp h
lemma times_cont_diff_at.cexp {n} (hf : times_cont_diff_at ℂ n f x) :
times_cont_diff_at ℂ n (λ x, complex.exp (f x)) x :=
complex.times_cont_diff_exp.times_cont_diff_at.comp x hf
lemma times_cont_diff_on.cexp {n} (hf : times_cont_diff_on ℂ n f s) :
times_cont_diff_on ℂ n (λ x, complex.exp (f x)) s :=
complex.times_cont_diff_exp.comp_times_cont_diff_on hf
lemma times_cont_diff_within_at.cexp {n} (hf : times_cont_diff_within_at ℂ n f s x) :
times_cont_diff_within_at ℂ n (λ x, complex.exp (f x)) s x :=
complex.times_cont_diff_exp.times_cont_diff_at.comp_times_cont_diff_within_at x hf
end
namespace real
variables {x y z : ℝ}
lemma has_strict_deriv_at_exp (x : ℝ) : has_strict_deriv_at exp (exp x) x :=
(complex.has_strict_deriv_at_exp x).real_of_complex
lemma has_deriv_at_exp (x : ℝ) : has_deriv_at exp (exp x) x :=
(complex.has_deriv_at_exp x).real_of_complex
lemma times_cont_diff_exp {n} : times_cont_diff ℝ n exp :=
complex.times_cont_diff_exp.real_of_complex
lemma differentiable_exp : differentiable ℝ exp :=
λx, (has_deriv_at_exp x).differentiable_at
lemma differentiable_at_exp : differentiable_at ℝ exp x :=
differentiable_exp x
@[simp] lemma deriv_exp : deriv exp = exp :=
funext $ λ x, (has_deriv_at_exp x).deriv
@[simp] lemma iter_deriv_exp : ∀ n : ℕ, (deriv^[n] exp) = exp
| 0 := rfl
| (n+1) := by rw [iterate_succ_apply, deriv_exp, iter_deriv_exp n]
end real
section
/-! Register lemmas for the derivatives of the composition of `real.exp` with a differentiable
function, for standalone use and use with `simp`. -/
variables {f : ℝ → ℝ} {f' x : ℝ} {s : set ℝ}
lemma has_strict_deriv_at.exp (hf : has_strict_deriv_at f f' x) :
has_strict_deriv_at (λ x, real.exp (f x)) (real.exp (f x) * f') x :=
(real.has_strict_deriv_at_exp (f x)).comp x hf
lemma has_deriv_at.exp (hf : has_deriv_at f f' x) :
has_deriv_at (λ x, real.exp (f x)) (real.exp (f x) * f') x :=
(real.has_deriv_at_exp (f x)).comp x hf
lemma has_deriv_within_at.exp (hf : has_deriv_within_at f f' s x) :
has_deriv_within_at (λ x, real.exp (f x)) (real.exp (f x) * f') s x :=
(real.has_deriv_at_exp (f x)).comp_has_deriv_within_at x hf
lemma deriv_within_exp (hf : differentiable_within_at ℝ f s x)
(hxs : unique_diff_within_at ℝ s x) :
deriv_within (λx, real.exp (f x)) s x = real.exp (f x) * (deriv_within f s x) :=
hf.has_deriv_within_at.exp.deriv_within hxs
@[simp] lemma deriv_exp (hc : differentiable_at ℝ f x) :
deriv (λx, real.exp (f x)) x = real.exp (f x) * (deriv f x) :=
hc.has_deriv_at.exp.deriv
end
section
/-! Register lemmas for the derivatives of the composition of `real.exp` with a differentiable
function, for standalone use and use with `simp`. -/
variables {E : Type*} [normed_group E] [normed_space ℝ E] {f : E → ℝ} {f' : E →L[ℝ] ℝ}
{x : E} {s : set E}
lemma times_cont_diff.exp {n} (hf : times_cont_diff ℝ n f) :
times_cont_diff ℝ n (λ x, real.exp (f x)) :=
real.times_cont_diff_exp.comp hf
lemma times_cont_diff_at.exp {n} (hf : times_cont_diff_at ℝ n f x) :
times_cont_diff_at ℝ n (λ x, real.exp (f x)) x :=
real.times_cont_diff_exp.times_cont_diff_at.comp x hf
lemma times_cont_diff_on.exp {n} (hf : times_cont_diff_on ℝ n f s) :
times_cont_diff_on ℝ n (λ x, real.exp (f x)) s :=
real.times_cont_diff_exp.comp_times_cont_diff_on hf
lemma times_cont_diff_within_at.exp {n} (hf : times_cont_diff_within_at ℝ n f s x) :
times_cont_diff_within_at ℝ n (λ x, real.exp (f x)) s x :=
real.times_cont_diff_exp.times_cont_diff_at.comp_times_cont_diff_within_at x hf
lemma has_fderiv_within_at.exp (hf : has_fderiv_within_at f f' s x) :
has_fderiv_within_at (λ x, real.exp (f x)) (real.exp (f x) • f') s x :=
(real.has_deriv_at_exp (f x)).comp_has_fderiv_within_at x hf
lemma has_fderiv_at.exp (hf : has_fderiv_at f f' x) :
has_fderiv_at (λ x, real.exp (f x)) (real.exp (f x) • f') x :=
(real.has_deriv_at_exp (f x)).comp_has_fderiv_at x hf
lemma has_strict_fderiv_at.exp (hf : has_strict_fderiv_at f f' x) :
has_strict_fderiv_at (λ x, real.exp (f x)) (real.exp (f x) • f') x :=
(real.has_strict_deriv_at_exp (f x)).comp_has_strict_fderiv_at x hf
lemma differentiable_within_at.exp (hf : differentiable_within_at ℝ f s x) :
differentiable_within_at ℝ (λ x, real.exp (f x)) s x :=
hf.has_fderiv_within_at.exp.differentiable_within_at
@[simp] lemma differentiable_at.exp (hc : differentiable_at ℝ f x) :
differentiable_at ℝ (λx, real.exp (f x)) x :=
hc.has_fderiv_at.exp.differentiable_at
lemma differentiable_on.exp (hc : differentiable_on ℝ f s) :
differentiable_on ℝ (λx, real.exp (f x)) s :=
λ x h, (hc x h).exp
@[simp] lemma differentiable.exp (hc : differentiable ℝ f) :
differentiable ℝ (λx, real.exp (f x)) :=
λ x, (hc x).exp
lemma fderiv_within_exp (hf : differentiable_within_at ℝ f s x)
(hxs : unique_diff_within_at ℝ s x) :
fderiv_within ℝ (λx, real.exp (f x)) s x = real.exp (f x) • (fderiv_within ℝ f s x) :=
hf.has_fderiv_within_at.exp.fderiv_within hxs
@[simp] lemma fderiv_exp (hc : differentiable_at ℝ f x) :
fderiv ℝ (λx, real.exp (f x)) x = real.exp (f x) • (fderiv ℝ f x) :=
hc.has_fderiv_at.exp.fderiv
end
namespace real
variables {x y z : ℝ}
/-- The real exponential function tends to `+∞` at `+∞`. -/
lemma tendsto_exp_at_top : tendsto exp at_top at_top :=
begin
have A : tendsto (λx:ℝ, x + 1) at_top at_top :=
tendsto_at_top_add_const_right at_top 1 tendsto_id,
have B : ∀ᶠ x in at_top, x + 1 ≤ exp x :=
eventually_at_top.2 ⟨0, λx hx, add_one_le_exp_of_nonneg hx⟩,
exact tendsto_at_top_mono' at_top B A
end
/-- The real exponential function tends to `0` at `-∞` or, equivalently, `exp(-x)` tends to `0`
at `+∞` -/
lemma tendsto_exp_neg_at_top_nhds_0 : tendsto (λx, exp (-x)) at_top (𝓝 0) :=
(tendsto_inv_at_top_zero.comp tendsto_exp_at_top).congr (λx, (exp_neg x).symm)
/-- The real exponential function tends to `1` at `0`. -/
lemma tendsto_exp_nhds_0_nhds_1 : tendsto exp (𝓝 0) (𝓝 1) :=
by { convert continuous_exp.tendsto 0, simp }
lemma tendsto_exp_at_bot : tendsto exp at_bot (𝓝 0) :=
(tendsto_exp_neg_at_top_nhds_0.comp tendsto_neg_at_bot_at_top).congr $
λ x, congr_arg exp $ neg_neg x
lemma tendsto_exp_at_bot_nhds_within : tendsto exp at_bot (𝓝[Ioi 0] 0) :=
tendsto_inf.2 ⟨tendsto_exp_at_bot, tendsto_principal.2 $ eventually_of_forall exp_pos⟩
/-- `real.exp` as an order isomorphism between `ℝ` and `(0, +∞)`. -/
def exp_order_iso : ℝ ≃o Ioi (0 : ℝ) :=
strict_mono.order_iso_of_surjective _ (exp_strict_mono.cod_restrict exp_pos) $
(continuous_subtype_mk _ continuous_exp).surjective
(by simp only [tendsto_Ioi_at_top, subtype.coe_mk, tendsto_exp_at_top])
(by simp [tendsto_exp_at_bot_nhds_within])
@[simp] lemma coe_exp_order_iso_apply (x : ℝ) : (exp_order_iso x : ℝ) = exp x := rfl
@[simp] lemma coe_comp_exp_order_iso : coe ∘ exp_order_iso = exp := rfl
@[simp] lemma range_exp : range exp = Ioi 0 :=
by rw [← coe_comp_exp_order_iso, range_comp, exp_order_iso.range_eq, image_univ, subtype.range_coe]
@[simp] lemma map_exp_at_top : map exp at_top = at_top :=
by rw [← coe_comp_exp_order_iso, ← filter.map_map, order_iso.map_at_top, map_coe_Ioi_at_top]
@[simp] lemma comap_exp_at_top : comap exp at_top = at_top :=
by rw [← map_exp_at_top, comap_map exp_injective, map_exp_at_top]
@[simp] lemma tendsto_exp_comp_at_top {α : Type*} {l : filter α} {f : α → ℝ} :
tendsto (λ x, exp (f x)) l at_top ↔ tendsto f l at_top :=
by rw [← tendsto_comap_iff, comap_exp_at_top]
lemma tendsto_comp_exp_at_top {α : Type*} {l : filter α} {f : ℝ → α} :
tendsto (λ x, f (exp x)) at_top l ↔ tendsto f at_top l :=
by rw [← tendsto_map'_iff, map_exp_at_top]
@[simp] lemma map_exp_at_bot : map exp at_bot = 𝓝[Ioi 0] 0 :=
by rw [← coe_comp_exp_order_iso, ← filter.map_map, exp_order_iso.map_at_bot, ← map_coe_Ioi_at_bot]
lemma comap_exp_nhds_within_Ioi_zero : comap exp (𝓝[Ioi 0] 0) = at_bot :=
by rw [← map_exp_at_bot, comap_map exp_injective]
lemma tendsto_comp_exp_at_bot {α : Type*} {l : filter α} {f : ℝ → α} :
tendsto (λ x, f (exp x)) at_bot l ↔ tendsto f (𝓝[Ioi 0] 0) l :=
by rw [← map_exp_at_bot, tendsto_map'_iff]
/-- The real logarithm function, equal to the inverse of the exponential for `x > 0`,
to `log |x|` for `x < 0`, and to `0` for `0`. We use this unconventional extension to
`(-∞, 0]` as it gives the formula `log (x * y) = log x + log y` for all nonzero `x` and `y`, and
the derivative of `log` is `1/x` away from `0`. -/
@[pp_nodot] noncomputable def log (x : ℝ) : ℝ :=
if hx : x = 0 then 0 else exp_order_iso.symm ⟨|x|, abs_pos.2 hx⟩
lemma log_of_ne_zero (hx : x ≠ 0) : log x = exp_order_iso.symm ⟨|x|, abs_pos.2 hx⟩ := dif_neg hx
lemma log_of_pos (hx : 0 < x) : log x = exp_order_iso.symm ⟨x, hx⟩ :=
by { rw [log_of_ne_zero hx.ne'], congr, exact abs_of_pos hx }
lemma exp_log_eq_abs (hx : x ≠ 0) : exp (log x) = |x| :=
by rw [log_of_ne_zero hx, ← coe_exp_order_iso_apply, order_iso.apply_symm_apply, subtype.coe_mk]
lemma exp_log (hx : 0 < x) : exp (log x) = x :=
by { rw exp_log_eq_abs hx.ne', exact abs_of_pos hx }
lemma exp_log_of_neg (hx : x < 0) : exp (log x) = -x :=
by { rw exp_log_eq_abs (ne_of_lt hx), exact abs_of_neg hx }
@[simp] lemma log_exp (x : ℝ) : log (exp x) = x :=
exp_injective $ exp_log (exp_pos x)
lemma surj_on_log : surj_on log (Ioi 0) univ :=
λ x _, ⟨exp x, exp_pos x, log_exp x⟩
lemma log_surjective : surjective log :=
λ x, ⟨exp x, log_exp x⟩
@[simp] lemma range_log : range log = univ :=
log_surjective.range_eq
@[simp] lemma log_zero : log 0 = 0 := dif_pos rfl
@[simp] lemma log_one : log 1 = 0 :=
exp_injective $ by rw [exp_log zero_lt_one, exp_zero]
@[simp] lemma log_abs (x : ℝ) : log (|x|) = log x :=
begin
by_cases h : x = 0,
{ simp [h] },
{ rw [← exp_eq_exp, exp_log_eq_abs h, exp_log_eq_abs (abs_pos.2 h).ne', abs_abs] }
end
@[simp] lemma log_neg_eq_log (x : ℝ) : log (-x) = log x :=
by rw [← log_abs x, ← log_abs (-x), abs_neg]
lemma surj_on_log' : surj_on log (Iio 0) univ :=
λ x _, ⟨-exp x, neg_lt_zero.2 $ exp_pos x, by rw [log_neg_eq_log, log_exp]⟩
lemma log_mul (hx : x ≠ 0) (hy : y ≠ 0) : log (x * y) = log x + log y :=
exp_injective $
by rw [exp_log_eq_abs (mul_ne_zero hx hy), exp_add, exp_log_eq_abs hx, exp_log_eq_abs hy, abs_mul]
lemma log_div (hx : x ≠ 0) (hy : y ≠ 0) : log (x / y) = log x - log y :=
exp_injective $
by rw [exp_log_eq_abs (div_ne_zero hx hy), exp_sub, exp_log_eq_abs hx, exp_log_eq_abs hy, abs_div]
@[simp] lemma log_inv (x : ℝ) : log (x⁻¹) = -log x :=
begin
by_cases hx : x = 0, { simp [hx] },
rw [← exp_eq_exp, exp_log_eq_abs (inv_ne_zero hx), exp_neg, exp_log_eq_abs hx, abs_inv]
end
lemma log_le_log (h : 0 < x) (h₁ : 0 < y) : real.log x ≤ real.log y ↔ x ≤ y :=
by rw [← exp_le_exp, exp_log h, exp_log h₁]
lemma log_lt_log (hx : 0 < x) : x < y → log x < log y :=
by { intro h, rwa [← exp_lt_exp, exp_log hx, exp_log (lt_trans hx h)] }
lemma log_lt_log_iff (hx : 0 < x) (hy : 0 < y) : log x < log y ↔ x < y :=
by { rw [← exp_lt_exp, exp_log hx, exp_log hy] }
lemma log_pos_iff (hx : 0 < x) : 0 < log x ↔ 1 < x :=
by { rw ← log_one, exact log_lt_log_iff zero_lt_one hx }
lemma log_pos (hx : 1 < x) : 0 < log x :=
(log_pos_iff (lt_trans zero_lt_one hx)).2 hx
lemma log_neg_iff (h : 0 < x) : log x < 0 ↔ x < 1 :=
by { rw ← log_one, exact log_lt_log_iff h zero_lt_one }
lemma log_neg (h0 : 0 < x) (h1 : x < 1) : log x < 0 := (log_neg_iff h0).2 h1
lemma log_nonneg_iff (hx : 0 < x) : 0 ≤ log x ↔ 1 ≤ x :=
by rw [← not_lt, log_neg_iff hx, not_lt]
lemma log_nonneg (hx : 1 ≤ x) : 0 ≤ log x :=
(log_nonneg_iff (zero_lt_one.trans_le hx)).2 hx
lemma log_nonpos_iff (hx : 0 < x) : log x ≤ 0 ↔ x ≤ 1 :=
by rw [← not_lt, log_pos_iff hx, not_lt]
lemma log_nonpos_iff' (hx : 0 ≤ x) : log x ≤ 0 ↔ x ≤ 1 :=
begin
rcases hx.eq_or_lt with (rfl|hx),
{ simp [le_refl, zero_le_one] },
exact log_nonpos_iff hx
end
lemma log_nonpos (hx : 0 ≤ x) (h'x : x ≤ 1) : log x ≤ 0 :=
(log_nonpos_iff' hx).2 h'x
lemma strict_mono_on_log : strict_mono_on log (set.Ioi 0) :=
λ x hx y hy hxy, log_lt_log hx hxy
lemma strict_anti_on_log : strict_anti_on log (set.Iio 0) :=
begin
rintros x (hx : x < 0) y (hy : y < 0) hxy,
rw [← log_abs y, ← log_abs x],
refine log_lt_log (abs_pos.2 hy.ne) _,
rwa [abs_of_neg hy, abs_of_neg hx, neg_lt_neg_iff]
end
lemma log_inj_on_pos : set.inj_on log (set.Ioi 0) :=
strict_mono_on_log.inj_on
lemma eq_one_of_pos_of_log_eq_zero {x : ℝ} (h₁ : 0 < x) (h₂ : log x = 0) : x = 1 :=
log_inj_on_pos (set.mem_Ioi.2 h₁) (set.mem_Ioi.2 zero_lt_one) (h₂.trans real.log_one.symm)
lemma log_ne_zero_of_pos_of_ne_one {x : ℝ} (hx_pos : 0 < x) (hx : x ≠ 1) : log x ≠ 0 :=
mt (eq_one_of_pos_of_log_eq_zero hx_pos) hx
/-- The real logarithm function tends to `+∞` at `+∞`. -/
lemma tendsto_log_at_top : tendsto log at_top at_top :=
tendsto_comp_exp_at_top.1 $ by simpa only [log_exp] using tendsto_id
lemma tendsto_log_nhds_within_zero : tendsto log (𝓝[{0}ᶜ] 0) at_bot :=
begin
rw [← (show _ = log, from funext log_abs)],
refine tendsto.comp _ tendsto_abs_nhds_within_zero,
simpa [← tendsto_comp_exp_at_bot] using tendsto_id
end
lemma continuous_on_log : continuous_on log {0}ᶜ :=
begin
rw [continuous_on_iff_continuous_restrict, restrict],
conv in (log _) { rw [log_of_ne_zero (show (x : ℝ) ≠ 0, from x.2)] },
exact exp_order_iso.symm.continuous.comp (continuous_subtype_mk _ continuous_subtype_coe.norm)
end
@[continuity] lemma continuous_log : continuous (λ x : {x : ℝ // x ≠ 0}, log x) :=
continuous_on_iff_continuous_restrict.1 $ continuous_on_log.mono $ λ x hx, hx
@[continuity] lemma continuous_log' : continuous (λ x : {x : ℝ // 0 < x}, log x) :=
continuous_on_iff_continuous_restrict.1 $ continuous_on_log.mono $ λ x hx, ne_of_gt hx
lemma continuous_at_log (hx : x ≠ 0) : continuous_at log x :=
(continuous_on_log x hx).continuous_at $ is_open.mem_nhds is_open_compl_singleton hx
@[simp] lemma continuous_at_log_iff : continuous_at log x ↔ x ≠ 0 :=
begin
refine ⟨_, continuous_at_log⟩,
rintros h rfl,
exact not_tendsto_nhds_of_tendsto_at_bot tendsto_log_nhds_within_zero _
(h.tendsto.mono_left inf_le_left)
end
lemma has_strict_deriv_at_log_of_pos (hx : 0 < x) : has_strict_deriv_at log x⁻¹ x :=
have has_strict_deriv_at log (exp $ log x)⁻¹ x,
from (has_strict_deriv_at_exp $ log x).of_local_left_inverse (continuous_at_log hx.ne')
(ne_of_gt $ exp_pos _) $ eventually.mono (lt_mem_nhds hx) @exp_log,
by rwa [exp_log hx] at this
lemma has_strict_deriv_at_log (hx : x ≠ 0) : has_strict_deriv_at log x⁻¹ x :=
begin
cases hx.lt_or_lt with hx hx,
{ convert (has_strict_deriv_at_log_of_pos (neg_pos.mpr hx)).comp x (has_strict_deriv_at_neg x),
{ ext y, exact (log_neg_eq_log y).symm },
{ field_simp [hx.ne] } },
{ exact has_strict_deriv_at_log_of_pos hx }
end
lemma has_deriv_at_log (hx : x ≠ 0) : has_deriv_at log x⁻¹ x :=
(has_strict_deriv_at_log hx).has_deriv_at
lemma differentiable_at_log (hx : x ≠ 0) : differentiable_at ℝ log x :=
(has_deriv_at_log hx).differentiable_at
lemma differentiable_on_log : differentiable_on ℝ log {0}ᶜ :=
λ x hx, (differentiable_at_log hx).differentiable_within_at
@[simp] lemma differentiable_at_log_iff : differentiable_at ℝ log x ↔ x ≠ 0 :=
⟨λ h, continuous_at_log_iff.1 h.continuous_at, differentiable_at_log⟩
lemma deriv_log (x : ℝ) : deriv log x = x⁻¹ :=
if hx : x = 0 then
by rw [deriv_zero_of_not_differentiable_at (mt differentiable_at_log_iff.1 (not_not.2 hx)), hx,
inv_zero]
else (has_deriv_at_log hx).deriv
@[simp] lemma deriv_log' : deriv log = has_inv.inv := funext deriv_log
lemma times_cont_diff_on_log {n : with_top ℕ} : times_cont_diff_on ℝ n log {0}ᶜ :=
begin
suffices : times_cont_diff_on ℝ ⊤ log {0}ᶜ, from this.of_le le_top,
refine (times_cont_diff_on_top_iff_deriv_of_open is_open_compl_singleton).2 _,
simp [differentiable_on_log, times_cont_diff_on_inv]
end
lemma times_cont_diff_at_log {n : with_top ℕ} : times_cont_diff_at ℝ n log x ↔ x ≠ 0 :=
⟨λ h, continuous_at_log_iff.1 h.continuous_at,
λ hx, (times_cont_diff_on_log x hx).times_cont_diff_at $
is_open.mem_nhds is_open_compl_singleton hx⟩
end real
section log_differentiable
open real
section continuity
variables {α : Type*}
lemma filter.tendsto.log {f : α → ℝ} {l : filter α} {x : ℝ} (h : tendsto f l (𝓝 x)) (hx : x ≠ 0) :
tendsto (λ x, log (f x)) l (𝓝 (log x)) :=
(continuous_at_log hx).tendsto.comp h
variables [topological_space α] {f : α → ℝ} {s : set α} {a : α}
lemma continuous.log (hf : continuous f) (h₀ : ∀ x, f x ≠ 0) : continuous (λ x, log (f x)) :=
continuous_on_log.comp_continuous hf h₀
lemma continuous_at.log (hf : continuous_at f a) (h₀ : f a ≠ 0) :
continuous_at (λ x, log (f x)) a :=
hf.log h₀
lemma continuous_within_at.log (hf : continuous_within_at f s a) (h₀ : f a ≠ 0) :
continuous_within_at (λ x, log (f x)) s a :=
hf.log h₀
lemma continuous_on.log (hf : continuous_on f s) (h₀ : ∀ x ∈ s, f x ≠ 0) :
continuous_on (λ x, log (f x)) s :=
λ x hx, (hf x hx).log (h₀ x hx)
end continuity
section deriv
variables {f : ℝ → ℝ} {x f' : ℝ} {s : set ℝ}
lemma has_deriv_within_at.log (hf : has_deriv_within_at f f' s x) (hx : f x ≠ 0) :
has_deriv_within_at (λ y, log (f y)) (f' / (f x)) s x :=
begin
rw div_eq_inv_mul,
exact (has_deriv_at_log hx).comp_has_deriv_within_at x hf
end
lemma has_deriv_at.log (hf : has_deriv_at f f' x) (hx : f x ≠ 0) :
has_deriv_at (λ y, log (f y)) (f' / f x) x :=
begin
rw ← has_deriv_within_at_univ at *,
exact hf.log hx
end
lemma has_strict_deriv_at.log (hf : has_strict_deriv_at f f' x) (hx : f x ≠ 0) :
has_strict_deriv_at (λ y, log (f y)) (f' / f x) x :=
begin
rw div_eq_inv_mul,
exact (has_strict_deriv_at_log hx).comp x hf
end
lemma deriv_within.log (hf : differentiable_within_at ℝ f s x) (hx : f x ≠ 0)
(hxs : unique_diff_within_at ℝ s x) :
deriv_within (λx, log (f x)) s x = (deriv_within f s x) / (f x) :=
(hf.has_deriv_within_at.log hx).deriv_within hxs
@[simp] lemma deriv.log (hf : differentiable_at ℝ f x) (hx : f x ≠ 0) :
deriv (λx, log (f x)) x = (deriv f x) / (f x) :=
(hf.has_deriv_at.log hx).deriv
end deriv
section fderiv
variables {E : Type*} [normed_group E] [normed_space ℝ E] {f : E → ℝ} {x : E} {f' : E →L[ℝ] ℝ}
{s : set E}
lemma has_fderiv_within_at.log (hf : has_fderiv_within_at f f' s x) (hx : f x ≠ 0) :
has_fderiv_within_at (λ x, log (f x)) ((f x)⁻¹ • f') s x :=
(has_deriv_at_log hx).comp_has_fderiv_within_at x hf
lemma has_fderiv_at.log (hf : has_fderiv_at f f' x) (hx : f x ≠ 0) :
has_fderiv_at (λ x, log (f x)) ((f x)⁻¹ • f') x :=
(has_deriv_at_log hx).comp_has_fderiv_at x hf
lemma has_strict_fderiv_at.log (hf : has_strict_fderiv_at f f' x) (hx : f x ≠ 0) :
has_strict_fderiv_at (λ x, log (f x)) ((f x)⁻¹ • f') x :=
(has_strict_deriv_at_log hx).comp_has_strict_fderiv_at x hf
lemma differentiable_within_at.log (hf : differentiable_within_at ℝ f s x) (hx : f x ≠ 0) :
differentiable_within_at ℝ (λx, log (f x)) s x :=
(hf.has_fderiv_within_at.log hx).differentiable_within_at
@[simp] lemma differentiable_at.log (hf : differentiable_at ℝ f x) (hx : f x ≠ 0) :
differentiable_at ℝ (λx, log (f x)) x :=
(hf.has_fderiv_at.log hx).differentiable_at
lemma times_cont_diff_at.log {n} (hf : times_cont_diff_at ℝ n f x) (hx : f x ≠ 0) :
times_cont_diff_at ℝ n (λ x, log (f x)) x :=
(times_cont_diff_at_log.2 hx).comp x hf
lemma times_cont_diff_within_at.log {n} (hf : times_cont_diff_within_at ℝ n f s x) (hx : f x ≠ 0) :
times_cont_diff_within_at ℝ n (λ x, log (f x)) s x :=
(times_cont_diff_at_log.2 hx).comp_times_cont_diff_within_at x hf
lemma times_cont_diff_on.log {n} (hf : times_cont_diff_on ℝ n f s) (hs : ∀ x ∈ s, f x ≠ 0) :
times_cont_diff_on ℝ n (λ x, log (f x)) s :=
λ x hx, (hf x hx).log (hs x hx)
lemma times_cont_diff.log {n} (hf : times_cont_diff ℝ n f) (h : ∀ x, f x ≠ 0) :
times_cont_diff ℝ n (λ x, log (f x)) :=
times_cont_diff_iff_times_cont_diff_at.2 $ λ x, hf.times_cont_diff_at.log (h x)
lemma differentiable_on.log (hf : differentiable_on ℝ f s) (hx : ∀ x ∈ s, f x ≠ 0) :
differentiable_on ℝ (λx, log (f x)) s :=
λx h, (hf x h).log (hx x h)
@[simp] lemma differentiable.log (hf : differentiable ℝ f) (hx : ∀ x, f x ≠ 0) :
differentiable ℝ (λx, log (f x)) :=
λx, (hf x).log (hx x)
lemma fderiv_within.log (hf : differentiable_within_at ℝ f s x) (hx : f x ≠ 0)
(hxs : unique_diff_within_at ℝ s x) :
fderiv_within ℝ (λx, log (f x)) s x = (f x)⁻¹ • fderiv_within ℝ f s x :=
(hf.has_fderiv_within_at.log hx).fderiv_within hxs
@[simp] lemma fderiv.log (hf : differentiable_at ℝ f x) (hx : f x ≠ 0) :
fderiv ℝ (λx, log (f x)) x = (f x)⁻¹ • fderiv ℝ f x :=
(hf.has_fderiv_at.log hx).fderiv
end fderiv
end log_differentiable
namespace real
/-- The function `exp(x)/x^n` tends to `+∞` at `+∞`, for any natural number `n` -/
lemma tendsto_exp_div_pow_at_top (n : ℕ) : tendsto (λx, exp x / x^n) at_top at_top :=
begin
refine (at_top_basis_Ioi.tendsto_iff (at_top_basis' 1)).2 (λ C hC₁, _),
have hC₀ : 0 < C, from zero_lt_one.trans_le hC₁,
have : 0 < (exp 1 * C)⁻¹ := inv_pos.2 (mul_pos (exp_pos _) hC₀),
obtain ⟨N, hN⟩ : ∃ N, ∀ k ≥ N, (↑k ^ n : ℝ) / exp 1 ^ k < (exp 1 * C)⁻¹ :=
eventually_at_top.1 ((tendsto_pow_const_div_const_pow_of_one_lt n
(one_lt_exp_iff.2 zero_lt_one)).eventually (gt_mem_nhds this)),
simp only [← exp_nat_mul, mul_one, div_lt_iff, exp_pos, ← div_eq_inv_mul] at hN,
refine ⟨N, trivial, λ x hx, _⟩, rw set.mem_Ioi at hx,
have hx₀ : 0 < x, from N.cast_nonneg.trans_lt hx,
rw [set.mem_Ici, le_div_iff (pow_pos hx₀ _), ← le_div_iff' hC₀],
calc x ^ n ≤ ⌈x⌉₊ ^ n : pow_le_pow_of_le_left hx₀.le (nat.le_ceil _) _
... ≤ exp ⌈x⌉₊ / (exp 1 * C) : (hN _ (nat.lt_ceil.2 hx).le).le
... ≤ exp (x + 1) / (exp 1 * C) : div_le_div_of_le (mul_pos (exp_pos _) hC₀).le
(exp_le_exp.2 $ (nat.ceil_lt_add_one hx₀.le).le)
... = exp x / C : by rw [add_comm, exp_add, mul_div_mul_left _ _ (exp_pos _).ne']
end
/-- The function `x^n * exp(-x)` tends to `0` at `+∞`, for any natural number `n`. -/
lemma tendsto_pow_mul_exp_neg_at_top_nhds_0 (n : ℕ) : tendsto (λx, x^n * exp (-x)) at_top (𝓝 0) :=
(tendsto_inv_at_top_zero.comp (tendsto_exp_div_pow_at_top n)).congr $ λx,
by rw [comp_app, inv_eq_one_div, div_div_eq_mul_div, one_mul, div_eq_mul_inv, exp_neg]
/-- The function `(b * exp x + c) / (x ^ n)` tends to `+∞` at `+∞`, for any positive natural number
`n` and any real numbers `b` and `c` such that `b` is positive. -/
lemma tendsto_mul_exp_add_div_pow_at_top (b c : ℝ) (n : ℕ) (hb : 0 < b) (hn : 1 ≤ n) :
tendsto (λ x, (b * (exp x) + c) / (x^n)) at_top at_top :=
begin
refine tendsto.congr' (eventually_eq_of_mem (Ioi_mem_at_top 0) _)
(((tendsto_exp_div_pow_at_top n).const_mul_at_top hb).at_top_add
((tendsto_pow_neg_at_top hn).mul (@tendsto_const_nhds _ _ _ c _))),
intros x hx,
simp only [fpow_neg x n],
ring,
end
/-- The function `(x ^ n) / (b * exp x + c)` tends to `0` at `+∞`, for any positive natural number
`n` and any real numbers `b` and `c` such that `b` is nonzero. -/
lemma tendsto_div_pow_mul_exp_add_at_top (b c : ℝ) (n : ℕ) (hb : 0 ≠ b) (hn : 1 ≤ n) :
tendsto (λ x, x^n / (b * (exp x) + c)) at_top (𝓝 0) :=
begin
have H : ∀ d e, 0 < d → tendsto (λ (x:ℝ), x^n / (d * (exp x) + e)) at_top (𝓝 0),
{ intros b' c' h,
convert (tendsto_mul_exp_add_div_pow_at_top b' c' n h hn).inv_tendsto_at_top ,
ext x,
simpa only [pi.inv_apply] using inv_div.symm },
cases lt_or_gt_of_ne hb,
{ exact H b c h },
{ convert (H (-b) (-c) (neg_pos.mpr h)).neg,
{ ext x,
field_simp,
rw [← neg_add (b * exp x) c, neg_div_neg_eq] },
{ exact neg_zero.symm } },
end
/-- The function `x * log (1 + t / x)` tends to `t` at `+∞`. -/
lemma tendsto_mul_log_one_plus_div_at_top (t : ℝ) :
tendsto (λ x, x * log (1 + t / x)) at_top (𝓝 t) :=
begin
have h₁ : tendsto (λ h, h⁻¹ * log (1 + t * h)) (𝓝[{0}ᶜ] 0) (𝓝 t),
{ simpa [has_deriv_at_iff_tendsto_slope] using
((has_deriv_at_const _ 1).add ((has_deriv_at_id (0 : ℝ)).const_mul t)).log (by simp) },
have h₂ : tendsto (λ x : ℝ, x⁻¹) at_top (𝓝[{0}ᶜ] 0) :=
tendsto_inv_at_top_zero'.mono_right (nhds_within_mono _ (λ x hx, (set.mem_Ioi.mp hx).ne')),
convert h₁.comp h₂,
ext,
field_simp [mul_comm],
end
open_locale big_operators
/-- A crude lemma estimating the difference between `log (1-x)` and its Taylor series at `0`,
where the main point of the bound is that it tends to `0`. The goal is to deduce the series
expansion of the logarithm, in `has_sum_pow_div_log_of_abs_lt_1`.
-/
lemma abs_log_sub_add_sum_range_le {x : ℝ} (h : |x| < 1) (n : ℕ) :
|((∑ i in range n, x^(i+1)/(i+1)) + log (1-x))| ≤ (|x|)^(n+1) / (1 - |x|) :=
begin
/- For the proof, we show that the derivative of the function to be estimated is small,
and then apply the mean value inequality. -/
let F : ℝ → ℝ := λ x, ∑ i in range n, x^(i+1)/(i+1) + log (1-x),
-- First step: compute the derivative of `F`
have A : ∀ y ∈ Ioo (-1 : ℝ) 1, deriv F y = - (y^n) / (1 - y),
{ assume y hy,
have : (∑ i in range n, (↑i + 1) * y ^ i / (↑i + 1)) = (∑ i in range n, y ^ i),
{ congr' with i,
have : (i : ℝ) + 1 ≠ 0 := ne_of_gt (nat.cast_add_one_pos i),
field_simp [this, mul_comm] },
field_simp [F, this, ← geom_sum_def, geom_sum_eq (ne_of_lt hy.2),
sub_ne_zero_of_ne (ne_of_gt hy.2), sub_ne_zero_of_ne (ne_of_lt hy.2)],
ring },
-- second step: show that the derivative of `F` is small
have B : ∀ y ∈ Icc (-|x|) (|x|), |deriv F y| ≤ |x|^n / (1 - |x|),
{ assume y hy,
have : y ∈ Ioo (-(1 : ℝ)) 1 := ⟨lt_of_lt_of_le (neg_lt_neg h) hy.1, lt_of_le_of_lt hy.2 h⟩,
calc |deriv F y| = | -(y^n) / (1 - y)| : by rw [A y this]
... ≤ |x|^n / (1 - |x|) :
begin
have : |y| ≤ |x| := abs_le.2 hy,
have : 0 < 1 - |x|, by linarith,
have : 1 - |x| ≤ |1 - y| := le_trans (by linarith [hy.2]) (le_abs_self _),
simp only [← pow_abs, abs_div, abs_neg],
apply_rules [div_le_div, pow_nonneg, abs_nonneg, pow_le_pow_of_le_left]
end },
-- third step: apply the mean value inequality
have C : ∥F x - F 0∥ ≤ (|x|^n / (1 - |x|)) * ∥x - 0∥,
{ have : ∀ y ∈ Icc (- |x|) (|x|), differentiable_at ℝ F y,
{ assume y hy,
have : 1 - y ≠ 0 := sub_ne_zero_of_ne (ne_of_gt (lt_of_le_of_lt hy.2 h)),
simp [F, this] },
apply convex.norm_image_sub_le_of_norm_deriv_le this B (convex_Icc _ _) _ _,
{ simpa using abs_nonneg x },
{ simp [le_abs_self x, neg_le.mp (neg_le_abs_self x)] } },
-- fourth step: conclude by massaging the inequality of the third step
simpa [F, norm_eq_abs, div_mul_eq_mul_div, pow_succ'] using C
end
/-- Power series expansion of the logarithm around `1`. -/
theorem has_sum_pow_div_log_of_abs_lt_1 {x : ℝ} (h : |x| < 1) :
has_sum (λ (n : ℕ), x ^ (n + 1) / (n + 1)) (-log (1 - x)) :=
begin
rw summable.has_sum_iff_tendsto_nat,
show tendsto (λ (n : ℕ), ∑ (i : ℕ) in range n, x ^ (i + 1) / (i + 1)) at_top (𝓝 (-log (1 - x))),
{ rw [tendsto_iff_norm_tendsto_zero],
simp only [norm_eq_abs, sub_neg_eq_add],
refine squeeze_zero (λ n, abs_nonneg _) (abs_log_sub_add_sum_range_le h) _,
suffices : tendsto (λ (t : ℕ), |x| ^ (t + 1) / (1 - |x|)) at_top
(𝓝 (|x| * 0 / (1 - |x|))), by simpa,
simp only [pow_succ],
refine (tendsto_const_nhds.mul _).div_const,
exact tendsto_pow_at_top_nhds_0_of_lt_1 (abs_nonneg _) h },
show summable (λ (n : ℕ), x ^ (n + 1) / (n + 1)),
{ refine summable_of_norm_bounded _ (summable_geometric_of_lt_1 (abs_nonneg _) h) (λ i, _),
calc ∥x ^ (i + 1) / (i + 1)∥
= |x| ^ (i+1) / (i+1) :
begin
have : (0 : ℝ) ≤ i + 1 := le_of_lt (nat.cast_add_one_pos i),
rw [norm_eq_abs, abs_div, ← pow_abs, abs_of_nonneg this],
end
... ≤ |x| ^ (i+1) / (0 + 1) :
begin
apply_rules [div_le_div_of_le_left, pow_nonneg, abs_nonneg, add_le_add_right,
i.cast_nonneg],
norm_num,
end
... ≤ |x| ^ i :
by simpa [pow_succ'] using mul_le_of_le_one_right (pow_nonneg (abs_nonneg x) i) (le_of_lt h) }
end
end real
|
c752162d67af11464354034cca192b488bca3bb7 | 302c785c90d40ad3d6be43d33bc6a558354cc2cf | /src/algebra/module/basic.lean | ac4e619b6c51623dafd858b6a387ac69634ac42f | [
"Apache-2.0"
] | permissive | ilitzroth/mathlib | ea647e67f1fdfd19a0f7bdc5504e8acec6180011 | 5254ef14e3465f6504306132fe3ba9cec9ffff16 | refs/heads/master | 1,680,086,661,182 | 1,617,715,647,000 | 1,617,715,647,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 22,299 | lean | /-
Copyright (c) 2015 Nathaniel Thomas. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro
-/
import algebra.big_operators.basic
import algebra.group.hom
import group_theory.group_action.group
import algebra.smul_with_zero
/-!
# Modules over a ring
In this file we define
* `semimodule R M` : an additive commutative monoid `M` is a `semimodule` over a
`semiring R` if for `r : R` and `x : M` their "scalar multiplication `r • x : M` is defined, and
the operation `•` satisfies some natural associativity and distributivity axioms similar to those
on a ring.
* `module R M` : same as `semimodule R M` but assumes that `R` is a `ring` and `M` is an
additive commutative group.
* `vector_space k M` : same as `semimodule k M` and `module k M` but assumes that `k` is a `field`
and `M` is an additive commutative group.
## Implementation notes
* `vector_space` and `module` are abbreviations for `semimodule R M`.
## Tags
semimodule, module, vector space
-/
open function
open_locale big_operators
universes u u' v w x y z
variables {R : Type u} {k : Type u'} {S : Type v} {M : Type w} {M₂ : Type x} {M₃ : Type y}
{ι : Type z}
/-- A semimodule is a generalization of vector spaces to a scalar semiring.
It consists of a scalar semiring `R` and an additive monoid of "vectors" `M`,
connected by a "scalar multiplication" operation `r • x : M`
(where `r : R` and `x : M`) with some natural associativity and
distributivity axioms similar to those on a ring. -/
@[protect_proj] class semimodule (R : Type u) (M : Type v) [semiring R]
[add_comm_monoid M] extends distrib_mul_action R M :=
(add_smul : ∀(r s : R) (x : M), (r + s) • x = r • x + s • x)
(zero_smul : ∀x : M, (0 : R) • x = 0)
section add_comm_monoid
variables [semiring R] [add_comm_monoid M] [semimodule R M] (r s : R) (x y : M)
/-- A semimodule over a semiring automatically inherits a `mul_action_with_zero` structure. -/
@[priority 100] -- see Note [lower instance priority]
instance semimodule.to_mul_action_with_zero :
mul_action_with_zero R M :=
{ smul_zero := smul_zero,
zero_smul := semimodule.zero_smul,
..(infer_instance : mul_action R M) }
theorem add_smul : (r + s) • x = r • x + s • x := semimodule.add_smul r s x
variables (R)
theorem two_smul : (2 : R) • x = x + x := by rw [bit0, add_smul, one_smul]
theorem two_smul' : (2 : R) • x = bit0 x := two_smul R x
/-- Pullback a `semimodule` structure along an injective additive monoid homomorphism. -/
protected def function.injective.semimodule [add_comm_monoid M₂] [has_scalar R M₂] (f : M₂ →+ M)
(hf : injective f) (smul : ∀ (c : R) x, f (c • x) = c • f x) :
semimodule R M₂ :=
{ smul := (•),
add_smul := λ c₁ c₂ x, hf $ by simp only [smul, f.map_add, add_smul],
zero_smul := λ x, hf $ by simp only [smul, zero_smul, f.map_zero],
.. hf.distrib_mul_action f smul }
/-- Pushforward a `semimodule` structure along a surjective additive monoid homomorphism. -/
protected def function.surjective.semimodule [add_comm_monoid M₂] [has_scalar R M₂] (f : M →+ M₂)
(hf : surjective f) (smul : ∀ (c : R) x, f (c • x) = c • f x) :
semimodule R M₂ :=
{ smul := (•),
add_smul := λ c₁ c₂ x, by { rcases hf x with ⟨x, rfl⟩,
simp only [add_smul, ← smul, ← f.map_add] },
zero_smul := λ x, by { rcases hf x with ⟨x, rfl⟩, simp only [← f.map_zero, ← smul, zero_smul] },
.. hf.distrib_mul_action f smul }
variables {R} (M)
/-- Compose a `semimodule` with a `ring_hom`, with action `f s • m` -/
def semimodule.comp_hom [semiring S] (f : S →+* R) :
semimodule S M :=
{ smul := (•) ∘ f,
add_smul := λ r s x, by simp [add_smul],
.. mul_action_with_zero.comp_hom M f.to_monoid_with_zero_hom,
.. distrib_mul_action.comp_hom M (f : S →* R) }
variables (R) (M)
/-- `(•)` as an `add_monoid_hom`. -/
def smul_add_hom : R →+ M →+ M :=
{ to_fun := const_smul_hom M,
map_zero' := add_monoid_hom.ext $ λ r, by simp,
map_add' := λ x y, add_monoid_hom.ext $ λ r, by simp [add_smul] }
variables {R M}
@[simp] lemma smul_add_hom_apply (r : R) (x : M) :
smul_add_hom R M r x = r • x := rfl
lemma semimodule.eq_zero_of_zero_eq_one (zero_eq_one : (0 : R) = 1) : x = 0 :=
by rw [←one_smul R x, ←zero_eq_one, zero_smul]
lemma list.sum_smul {l : list R} {x : M} : l.sum • x = (l.map (λ r, r • x)).sum :=
((smul_add_hom R M).flip x).map_list_sum l
lemma multiset.sum_smul {l : multiset R} {x : M} : l.sum • x = (l.map (λ r, r • x)).sum :=
((smul_add_hom R M).flip x).map_multiset_sum l
lemma finset.sum_smul {f : ι → R} {s : finset ι} {x : M} :
(∑ i in s, f i) • x = (∑ i in s, (f i) • x) :=
((smul_add_hom R M).flip x).map_sum f s
end add_comm_monoid
variables (R)
/-- An `add_comm_monoid` that is a `semimodule` over a `ring` carries a natural `add_comm_group`
structure. -/
def semimodule.add_comm_monoid_to_add_comm_group [ring R] [add_comm_monoid M] [semimodule R M] :
add_comm_group M :=
{ neg := λ a, (-1 : R) • a,
add_left_neg := λ a, show (-1 : R) • a + a = 0, by {
nth_rewrite 1 ← one_smul _ a,
rw [← add_smul, add_left_neg, zero_smul] },
..(infer_instance : add_comm_monoid M), }
variables {R}
section add_comm_group
variables (R M) [semiring R] [add_comm_group M]
/-- A structure containing most informations as in a semimodule, except the fields `zero_smul`
and `smul_zero`. As these fields can be deduced from the other ones when `M` is an `add_comm_group`,
this provides a way to construct a semimodule structure by checking less properties, in
`semimodule.of_core`. -/
@[nolint has_inhabited_instance]
structure semimodule.core extends has_scalar R M :=
(smul_add : ∀(r : R) (x y : M), r • (x + y) = r • x + r • y)
(add_smul : ∀(r s : R) (x : M), (r + s) • x = r • x + s • x)
(mul_smul : ∀(r s : R) (x : M), (r * s) • x = r • s • x)
(one_smul : ∀x : M, (1 : R) • x = x)
variables {R M}
/-- Define `semimodule` without proving `zero_smul` and `smul_zero` by using an auxiliary
structure `semimodule.core`, when the underlying space is an `add_comm_group`. -/
def semimodule.of_core (H : semimodule.core R M) : semimodule R M :=
by letI := H.to_has_scalar; exact
{ zero_smul := λ x, (add_monoid_hom.mk' (λ r : R, r • x) (λ r s, H.add_smul r s x)).map_zero,
smul_zero := λ r, (add_monoid_hom.mk' ((•) r) (H.smul_add r)).map_zero,
..H }
end add_comm_group
/--
Modules are defined as an `abbreviation` for semimodules,
if the base semiring is a ring.
(A previous definition made `module` a structure
defined to be `semimodule`.)
This has as advantage that modules are completely transparent
for type class inference, which means that all instances for semimodules
are immediately picked up for modules as well.
A cosmetic disadvantage is that one can not extend modules as such,
in definitions such as `normed_space`.
The solution is to extend `semimodule` instead.
-/
library_note "module definition"
/-- A module is the same as a semimodule, except the scalar semiring is actually
a ring.
This is the traditional generalization of spaces like `ℤ^n`, which have a natural
addition operation and a way to multiply them by elements of a ring, but no multiplication
operation between vectors. -/
abbreviation module (R : Type u) (M : Type v) [ring R] [add_comm_group M] :=
semimodule R M
/--
To prove two semimodule structures on a fixed `add_comm_monoid` agree,
it suffices to check the scalar multiplications agree.
-/
-- We'll later use this to show `semimodule ℕ M` and `module ℤ M` are subsingletons.
@[ext]
lemma semimodule_ext {R : Type*} [semiring R] {M : Type*} [add_comm_monoid M] (P Q : semimodule R M)
(w : ∀ (r : R) (m : M), by { haveI := P, exact r • m } = by { haveI := Q, exact r • m }) :
P = Q :=
begin
unfreezingI { rcases P with ⟨⟨⟨⟨P⟩⟩⟩⟩, rcases Q with ⟨⟨⟨⟨Q⟩⟩⟩⟩ },
congr,
funext r m,
exact w r m,
all_goals { apply proof_irrel_heq },
end
section module
variables [ring R] [add_comm_group M] [module R M] (r s : R) (x y : M)
@[simp] theorem neg_smul : -r • x = - (r • x) :=
eq_neg_of_add_eq_zero (by rw [← add_smul, add_left_neg, zero_smul])
variables (R)
theorem neg_one_smul (x : M) : (-1 : R) • x = -x := by simp
variables {R}
theorem sub_smul (r s : R) (y : M) : (r - s) • y = r • y - s • y :=
by simp [add_smul, sub_eq_add_neg]
end module
/-- A semimodule over a `subsingleton` semiring is a `subsingleton`. We cannot register this
as an instance because Lean has no way to guess `R`. -/
theorem semimodule.subsingleton (R M : Type*) [semiring R] [subsingleton R] [add_comm_monoid M]
[semimodule R M] :
subsingleton M :=
⟨λ x y, by rw [← one_smul R x, ← one_smul R y, subsingleton.elim (1:R) 0, zero_smul, zero_smul]⟩
@[priority 910] -- see Note [lower instance priority]
instance semiring.to_semimodule [semiring R] : semimodule R R :=
{ smul_add := mul_add,
add_smul := add_mul,
zero_smul := zero_mul,
smul_zero := mul_zero }
/-- A ring homomorphism `f : R →+* M` defines a module structure by `r • x = f r * x`. -/
def ring_hom.to_semimodule [semiring R] [semiring S] (f : R →+* S) : semimodule R S :=
{ smul := λ r x, f r * x,
smul_add := λ r x y, by unfold has_scalar.smul; rw [mul_add],
add_smul := λ r s x, by unfold has_scalar.smul; rw [f.map_add, add_mul],
mul_smul := λ r s x, by unfold has_scalar.smul; rw [f.map_mul, mul_assoc],
one_smul := λ x, show f 1 * x = _, by rw [f.map_one, one_mul],
zero_smul := λ x, show f 0 * x = 0, by rw [f.map_zero, zero_mul],
smul_zero := λ r, mul_zero (f r) }
/--
Vector spaces are defined as an `abbreviation` for semimodules,
if the base ring is a field.
(A previous definition made `vector_space` a structure
defined to be `module`.)
This has as advantage that vector spaces are completely transparent
for type class inference, which means that all instances for semimodules
are immediately picked up for vector spaces as well.
A cosmetic disadvantage is that one can not extend vector spaces as such,
in definitions such as `normed_space`.
The solution is to extend `semimodule` instead.
-/
library_note "vector space definition"
/-- A vector space is the same as a module, except the scalar ring is actually
a field. (This adds commutativity of the multiplication and existence of inverses.)
This is the traditional generalization of spaces like `ℝ^n`, which have a natural
addition operation and a way to multiply them by real numbers, but no multiplication
operation between vectors. -/
abbreviation vector_space (R : Type u) (M : Type v) [field R] [add_comm_group M] :=
semimodule R M
section add_comm_monoid
variables [semiring R] [add_comm_monoid M] [semimodule R M]
/-- The natural ℕ-semimodule structure on any `add_comm_monoid`. -/
-- We don't make this a global instance, as it results in too many instances,
-- and confusing ambiguity in the notation `n • x` when `n : ℕ`.
def add_comm_monoid.nat_semimodule : semimodule ℕ M :=
{ smul := nsmul,
smul_add := λ _ _ _, nsmul_add _ _ _,
add_smul := λ _ _ _, add_nsmul _ _ _,
mul_smul := λ _ _ _, mul_nsmul _ _ _,
one_smul := one_nsmul,
zero_smul := zero_nsmul,
smul_zero := nsmul_zero }
section
local attribute [instance] add_comm_monoid.nat_semimodule
/-- `nsmul` is defined as the `smul` action of `add_comm_monoid.nat_semimodule`. -/
lemma nsmul_def (n : ℕ) (x : M) :
n •ℕ x = n • x :=
rfl
end
section
variables (R)
/-- `nsmul` is equal to any other semimodule structure via a cast. -/
lemma nsmul_eq_smul_cast (n : ℕ) (b : M) :
n •ℕ b = (n : R) • b :=
begin
rw nsmul_def,
induction n with n ih,
{ rw [nat.cast_zero, zero_smul, zero_smul] },
{ rw [nat.succ_eq_add_one, nat.cast_succ, add_smul, add_smul, one_smul, ih, one_smul] }
end
end
/-- `nsmul` is equal to any `ℕ`-semimodule structure. -/
lemma nsmul_eq_smul [semimodule ℕ M] (n : ℕ) (b : M) : n •ℕ b = n • b :=
by rw [nsmul_eq_smul_cast ℕ, n.cast_id]
/-- All `ℕ`-semimodule structures are equal. -/
instance add_comm_monoid.nat_semimodule.subsingleton : subsingleton (semimodule ℕ M) :=
⟨λ P Q, by {
ext n,
rw [←nsmul_eq_smul, ←nsmul_eq_smul], }⟩
/-- Note this does not depend on the `nat_semimodule` definition above, to avoid issues when
diamonds occur in finding `semimodule ℕ M` instances. -/
instance add_comm_monoid.nat_is_scalar_tower [semimodule ℕ R] [semimodule ℕ M] :
is_scalar_tower ℕ R M :=
{ smul_assoc := λ n x y, nat.rec_on n
(by simp only [zero_smul])
(λ n ih, by simp only [nat.succ_eq_add_one, add_smul, one_smul, ih]) }
instance add_comm_monoid.nat_smul_comm_class [semimodule ℕ M] : smul_comm_class ℕ R M :=
{ smul_comm := λ n r m, nat.rec_on n
(by simp only [zero_smul, smul_zero])
(λ n ih, by simp only [nat.succ_eq_add_one, add_smul, one_smul, ←ih, smul_add]) }
-- `smul_comm_class.symm` is not registered as an instance, as it would cause a loop
instance add_comm_monoid.nat_smul_comm_class' [semimodule ℕ M] : smul_comm_class R ℕ M :=
smul_comm_class.symm _ _ _
end add_comm_monoid
section add_comm_group
variables [semiring S] [ring R] [add_comm_group M] [semimodule S M] [semimodule R M]
/-- The natural ℤ-module structure on any `add_comm_group`. -/
-- We don't immediately make this a global instance, as it results in too many instances,
-- and confusing ambiguity in the notation `n • x` when `n : ℤ`.
-- We do turn it into a global instance, but only at the end of this file,
-- and I remain dubious whether this is a good idea.
def add_comm_group.int_module : module ℤ M :=
{ smul := gsmul,
smul_add := λ _ _ _, gsmul_add _ _ _,
add_smul := λ _ _ _, add_gsmul _ _ _,
mul_smul := λ _ _ _, gsmul_mul _ _ _,
one_smul := one_gsmul,
zero_smul := zero_gsmul,
smul_zero := gsmul_zero }
section
local attribute [instance] add_comm_group.int_module
/-- `gsmul` is defined as the `smul` action of `add_comm_group.int_module`. -/
lemma gsmul_def (n : ℤ) (x : M) : gsmul n x = n • x := rfl
end
section
variables (R)
/-- `gsmul` is equal to any other module structure via a cast. -/
lemma gsmul_eq_smul_cast (n : ℤ) (b : M) : gsmul n b = (n : R) • b :=
begin
rw gsmul_def,
induction n using int.induction_on with p hp n hn,
{ rw [int.cast_zero, zero_smul, zero_smul] },
{ rw [int.cast_add, int.cast_one, add_smul, add_smul, one_smul, one_smul, hp] },
{ rw [int.cast_sub, int.cast_one, sub_smul, sub_smul, one_smul, one_smul, hn] },
end
end
/-- `gsmul` is equal to any `ℤ`-module structure. -/
lemma gsmul_eq_smul [semimodule ℤ M] (n : ℤ) (b : M) : n •ℤ b = n • b :=
by rw [gsmul_eq_smul_cast ℤ, n.cast_id]
/-- All `ℤ`-module structures are equal. -/
instance add_comm_group.int_module.subsingleton : subsingleton (semimodule ℤ M) :=
⟨λ P Q, by {
ext n,
rw [←gsmul_eq_smul, ←gsmul_eq_smul], }⟩
instance add_comm_group.int_is_scalar_tower [semimodule ℤ R] [semimodule ℤ M] :
is_scalar_tower ℤ R M :=
{ smul_assoc := λ n x y, int.induction_on n
(by simp only [zero_smul])
(λ n ih, by simp only [one_smul, add_smul, ih])
(λ n ih, by simp only [one_smul, sub_smul, ih]) }
instance add_comm_group.int_smul_comm_class [semimodule ℤ M] : smul_comm_class ℤ S M :=
{ smul_comm := λ n x y, int.induction_on n
(by simp only [zero_smul, smul_zero])
(λ n ih, by simp only [one_smul, add_smul, smul_add, ih])
(λ n ih, by simp only [one_smul, sub_smul, smul_sub, ih]) }
-- `smul_comm_class.symm` is not registered as an instance, as it would cause a loop
instance add_comm_group.int_smul_comm_class' [semimodule ℤ M] : smul_comm_class S ℤ M :=
smul_comm_class.symm _ _ _
end add_comm_group
namespace add_monoid_hom
-- We prove this without using the `add_comm_group.int_module` instance, so the `•`s here
-- come from whatever the local `module ℤ` structure actually is.
lemma map_int_module_smul
[add_comm_group M] [add_comm_group M₂]
[module ℤ M] [module ℤ M₂] (f : M →+ M₂) (x : ℤ) (a : M) : f (x • a) = x • f a :=
by simp only [←gsmul_eq_smul, f.map_gsmul]
lemma map_int_cast_smul
[ring R] [add_comm_group M] [add_comm_group M₂] [module R M] [module R M₂]
(f : M →+ M₂) (x : ℤ) (a : M) : f ((x : R) • a) = (x : R) • f a :=
by simp only [←gsmul_eq_smul_cast, f.map_gsmul]
lemma map_nat_cast_smul
[semiring R] [add_comm_monoid M] [add_comm_monoid M₂]
[semimodule R M] [semimodule R M₂] (f : M →+ M₂) (x : ℕ) (a : M) :
f ((x : R) • a) = (x : R) • f a :=
by simp only [←nsmul_eq_smul_cast, f.map_nsmul]
lemma map_rat_cast_smul {R : Type*} [division_ring R] [char_zero R]
{E : Type*} [add_comm_group E] [module R E] {F : Type*} [add_comm_group F] [module R F]
(f : E →+ F) (c : ℚ) (x : E) :
f ((c : R) • x) = (c : R) • f x :=
begin
have : ∀ (x : E) (n : ℕ), 0 < n → f (((n⁻¹ : ℚ) : R) • x) = ((n⁻¹ : ℚ) : R) • f x,
{ intros x n hn,
replace hn : (n : R) ≠ 0 := nat.cast_ne_zero.2 (ne_of_gt hn),
conv_rhs { congr, skip, rw [← one_smul R x, ← mul_inv_cancel hn, mul_smul] },
rw [f.map_nat_cast_smul, smul_smul, rat.cast_inv, rat.cast_coe_nat,
inv_mul_cancel hn, one_smul] },
refine c.num_denom_cases_on (λ m n hn hmn, _),
rw [rat.mk_eq_div, div_eq_mul_inv, rat.cast_mul, int.cast_coe_nat, mul_smul, mul_smul,
rat.cast_coe_int, f.map_int_cast_smul, this _ n hn]
end
lemma map_rat_module_smul {E : Type*} [add_comm_group E] [vector_space ℚ E]
{F : Type*} [add_comm_group F] [module ℚ F] (f : E →+ F) (c : ℚ) (x : E) :
f (c • x) = c • f x :=
rat.cast_id c ▸ f.map_rat_cast_smul c x
@[simp] lemma nat_smul_apply [add_monoid M] [add_comm_monoid M₂]
[semimodule ℕ (M →+ M₂)] [semimodule ℕ M₂]
(n : ℕ) (f : M →+ M₂) (a : M) :
(n • f) a = n • (f a) :=
begin
induction n with n IH,
{ simp only [zero_smul, zero_apply] },
{ simp only [nat.succ_eq_add_one, add_smul, IH, one_smul, add_apply] }
end
@[simp] lemma int_smul_apply [add_monoid M] [add_comm_group M₂]
[module ℤ (M →+ M₂)] [module ℤ M₂]
(n : ℤ) (f : M →+ M₂) (a : M) :
(n • f) a = n • (f a) :=
begin
apply int.induction_on' n 0,
{ simp only [zero_smul, zero_apply] },
all_goals
{ intros k hk IH,
simp only [add_smul, sub_smul, IH, one_smul, add_apply, sub_apply] }
end
end add_monoid_hom
section no_zero_smul_divisors
/-! ### `no_zero_smul_divisors`
This section defines the `no_zero_smul_divisors` class, and includes some tests
for the vanishing of elements (especially in modules over division rings).
-/
/-- `no_zero_smul_divisors R M` states that a scalar multiple is `0` only if either argument is `0`.
The main application of `no_zero_smul_divisors R M`, when `M` is a semimodule,
is the result `smul_eq_zero`: a scalar multiple is `0` iff either argument is `0`.
It is a generalization of the `no_zero_divisors` class to heterogeneous multiplication.
-/
class no_zero_smul_divisors (R M : Type*) [has_zero R] [has_zero M] [has_scalar R M] : Prop :=
(eq_zero_or_eq_zero_of_smul_eq_zero : ∀ {c : R} {x : M}, c • x = 0 → c = 0 ∨ x = 0)
export no_zero_smul_divisors (eq_zero_or_eq_zero_of_smul_eq_zero)
section semimodule
variables [semiring R] [add_comm_monoid M] [semimodule R M]
instance no_zero_smul_divisors.of_no_zero_divisors [no_zero_divisors R] :
no_zero_smul_divisors R R :=
⟨λ c x, no_zero_divisors.eq_zero_or_eq_zero_of_mul_eq_zero⟩
@[simp]
theorem smul_eq_zero [no_zero_smul_divisors R M] {c : R} {x : M} :
c • x = 0 ↔ c = 0 ∨ x = 0 :=
⟨eq_zero_or_eq_zero_of_smul_eq_zero,
λ h, h.elim (λ h, h.symm ▸ zero_smul R x) (λ h, h.symm ▸ smul_zero c)⟩
theorem smul_ne_zero [no_zero_smul_divisors R M] {c : R} {x : M} :
c • x ≠ 0 ↔ c ≠ 0 ∧ x ≠ 0 :=
by simp only [ne.def, smul_eq_zero, not_or_distrib]
section nat
variables (R) (M) [no_zero_smul_divisors R M] [semimodule ℕ M] [char_zero R]
include R
lemma nat.no_zero_smul_divisors : no_zero_smul_divisors ℕ M :=
⟨by { intros c x, rw [← nsmul_eq_smul, nsmul_eq_smul_cast R, smul_eq_zero], simp }⟩
variables {M}
lemma eq_zero_of_smul_two_eq_zero {v : M} (hv : 2 • v = 0) : v = 0 :=
by haveI := nat.no_zero_smul_divisors R M;
exact (smul_eq_zero.mp hv).resolve_left (by norm_num)
end nat
end semimodule
section add_comm_group -- `R` can still be a semiring here
variables [semiring R] [add_comm_group M] [semimodule R M]
lemma smul_injective [no_zero_smul_divisors R M] {c : R} (hc : c ≠ 0) :
function.injective (λ (x : M), c • x) :=
λ x y h, sub_eq_zero.mp ((smul_eq_zero.mp
(calc c • (x - y) = c • x - c • y : smul_sub c x y
... = 0 : sub_eq_zero.mpr h)).resolve_left hc)
section nat
variables (R) [no_zero_smul_divisors R M] [char_zero R]
include R
lemma eq_zero_of_eq_neg {v : M} (hv : v = - v) : v = 0 :=
begin
-- any semimodule will do
haveI : semimodule ℕ M := add_comm_monoid.nat_semimodule,
haveI := nat.no_zero_smul_divisors R M,
refine eq_zero_of_smul_two_eq_zero R _,
rw ←nsmul_eq_smul,
convert add_eq_zero_iff_eq_neg.mpr hv,
abel
end
end nat
end add_comm_group
section module
section nat
variables {R} [ring R] [add_comm_group M] [module R M] [no_zero_smul_divisors R M] [char_zero R]
lemma ne_neg_of_ne_zero [no_zero_divisors R] {v : R} (hv : v ≠ 0) : v ≠ -v :=
λ h, have semimodule ℕ R := add_comm_monoid.nat_semimodule, by exactI hv (eq_zero_of_eq_neg R h)
end nat
end module
section division_ring
variables [division_ring R] [add_comm_group M] [module R M]
@[priority 100] -- see note [lower instance priority]
instance no_zero_smul_divisors.of_division_ring : no_zero_smul_divisors R M :=
⟨λ c x h, or_iff_not_imp_left.2 $ λ hc, (units.mk0 c hc).smul_eq_zero.1 h⟩
end division_ring
end no_zero_smul_divisors
-- We finally turn on these instances globally. By doing this here, we ensure that none of the
-- lemmas about nat semimodules above are specific to these instances.
attribute [instance] add_comm_monoid.nat_semimodule add_comm_group.int_module
|
2ba632bfb251dfb231499694136bf0957c54f95f | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/tactic/noncomm_ring.lean | ff3e62df78bec45f9fa0d7b3cb3ce4625706a7e2 | [
"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,295 | lean | /-
Copyright (c) 2020 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Oliver Nash
-/
import tactic.abel
namespace tactic
namespace interactive
/-- A tactic for simplifying identities in not-necessarily-commutative rings.
An example:
```lean
example {R : Type*} [ring R] (a b c : R) : a * (b + c + c - b) = 2*a*c :=
by noncomm_ring
```
-/
meta def noncomm_ring :=
`[simp only [-- Expand everything out.
add_mul, mul_add, sub_eq_add_neg,
-- Right associate all products.
mul_assoc,
-- Expand powers to numerals.
pow_bit0, pow_bit1, pow_one,
-- Replace multiplication by numerals with `zsmul`.
bit0_mul, mul_bit0, bit1_mul, mul_bit1, one_mul, mul_one, zero_mul, mul_zero,
-- Pull `zsmul n` out the front so `abel` can see them.
mul_smul_comm, smul_mul_assoc,
-- Pull out negations.
neg_mul, mul_neg] {fail_if_unchanged := ff};
abel]
add_tactic_doc
{ name := "noncomm_ring",
category := doc_category.tactic,
decl_names := [`tactic.interactive.noncomm_ring],
tags := ["arithmetic", "simplification", "decision procedure"] }
end interactive
end tactic
|
f7dc5fc544267daa01b14b086fcb0a0608022403 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/category_theory/concrete_category/bundled_hom.lean | 8a4a02d426827277068f58b865c04f4f4ce1c6e8 | [] | 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 | 6,675 | lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Yury Kudryashov
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.category_theory.concrete_category.basic
import Mathlib.category_theory.concrete_category.bundled
import Mathlib.PostPort
universes u l
namespace Mathlib
/-!
# Category instances for algebraic structures that use bundled homs.
Many algebraic structures in Lean initially used unbundled homs (e.g. a bare function between types,
along with an `is_monoid_hom` typeclass), but the general trend is towards using bundled homs.
This file provides a basic infrastructure to define concrete categories using bundled homs, and
define forgetful functors between them.
-/
namespace category_theory
/-- Class for bundled homs. Note that the arguments order follows that of lemmas for `monoid_hom`.
This way we can use `⟨@monoid_hom.to_fun, @monoid_hom.id ...⟩` in an instance. -/
class bundled_hom {c : Type u → Type u} (hom : {α β : Type u} → c α → c β → Type u)
where
to_fun : {α β : Type u} → (Iα : c α) → (Iβ : c β) → hom Iα Iβ → α → β
id : {α : Type u} → (I : c α) → hom I I
comp : {α β γ : Type u} → (Iα : c α) → (Iβ : c β) → (Iγ : c γ) → hom Iβ Iγ → hom Iα Iβ → hom Iα Iγ
hom_ext : autoParam (∀ {α β : Type u} (Iα : c α) (Iβ : c β), function.injective (to_fun Iα Iβ))
(Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring "Mathlib.obviously")
(Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "obviously") [])
id_to_fun : autoParam (∀ {α : Type u} (I : c α), to_fun I I (id I) = id)
(Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring "Mathlib.obviously")
(Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "obviously") [])
comp_to_fun : autoParam
(∀ {α β γ : Type u} (Iα : c α) (Iβ : c β) (Iγ : c γ) (f : hom Iα Iβ) (g : hom Iβ Iγ),
to_fun Iα Iγ (comp Iα Iβ Iγ g f) = to_fun Iβ Iγ g ∘ to_fun Iα Iβ f)
(Lean.Syntax.ident Lean.SourceInfo.none (String.toSubstring "Mathlib.obviously")
(Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "obviously") [])
namespace bundled_hom
/-- Every `@bundled_hom c _` defines a category with objects in `bundled c`.
This instance generates the type-class problem `bundled_hom ?m` (which is why this is marked as
`[nolint]`). Currently that is not a problem, as there are almost no instances of `bundled_hom`. -/
protected instance category {c : Type u → Type u} (hom : {α β : Type u} → c α → c β → Type u) [𝒞 : bundled_hom hom] : category (bundled c) :=
category.mk
/-- A category given by `bundled_hom` is a concrete category.
This instance generates the type-class problem `bundled_hom ?m` (which is why this is marked as
`[nolint]`). Currently that is not a problem, as there are almost no instances of `bundled_hom`. -/
protected instance category_theory.bundled.category_theory.concrete_category {c : Type u → Type u} (hom : {α β : Type u} → c α → c β → Type u) [𝒞 : bundled_hom hom] : concrete_category (bundled c) :=
concrete_category.mk
(functor.mk (fun (X : bundled c) => ↥X)
fun (X Y : bundled c) (f : X ⟶ Y) => to_fun 𝒞 (bundled.str X) (bundled.str Y) f)
/-- A version of `has_forget₂.mk'` for categories defined using `@bundled_hom`. -/
def mk_has_forget₂ {c : Type u → Type u} {hom : {α β : Type u} → c α → c β → Type u} [𝒞 : bundled_hom hom] {d : Type u → Type u} {hom_d : {α β : Type u} → d α → d β → Type u} [bundled_hom hom_d] (obj : {α : Type u} → c α → d α) (map : {X Y : bundled c} → (X ⟶ Y) → (bundled.map obj X ⟶ bundled.map obj Y)) (h_map : ∀ {X Y : bundled c} (f : X ⟶ Y), ⇑(map f) = ⇑f) : has_forget₂ (bundled c) (bundled d) :=
has_forget₂.mk' (bundled.map obj) sorry map sorry
/--
The `hom` corresponding to first forgetting along `F`, then taking the `hom` associated to `c`.
For typical usage, see the construction of `CommMon` from `Mon`.
-/
def map_hom {c : Type u → Type u} (hom : {α β : Type u} → c α → c β → Type u) {d : Type u → Type u} (F : {α : Type u} → d α → c α) {α : Type u} {β : Type u} (Iα : d α) (Iβ : d β) :=
hom (F iα) (F iβ)
/--
Construct the `bundled_hom` induced by a map between type classes.
This is useful for building categories such as `CommMon` from `Mon`.
-/
def map {c : Type u → Type u} (hom : {α β : Type u} → c α → c β → Type u) [𝒞 : bundled_hom hom] {d : Type u → Type u} (F : {α : Type u} → d α → c α) : bundled_hom (map_hom hom F) :=
mk (fun (α β : Type u) (iα : d α) (iβ : d β) (f : map_hom hom F iα iβ) => to_fun 𝒞 (F iα) (F iβ) f)
(fun (α : Type u) (iα : d α) => id 𝒞 (F iα))
fun (α β γ : Type u) (iα : d α) (iβ : d β) (iγ : d γ) (f : map_hom hom F iβ iγ) (g : map_hom hom F iα iβ) =>
comp 𝒞 (F iα) (F iβ) (F iγ) f g
/--
We use the empty `parent_projection` class to label functions like `comm_monoid.to_monoid`,
which we would like to use to automatically construct `bundled_hom` instances from.
Once we've set up `Mon` as the category of bundled monoids,
this allows us to set up `CommMon` by defining an instance
```instance : parent_projection (comm_monoid.to_monoid) := ⟨⟩```
-/
class parent_projection {c : Type u → Type u} {d : Type u → Type u} (F : {α : Type u} → d α → c α)
where
protected instance bundled_hom_of_parent_projection {c : Type u → Type u} (hom : {α β : Type u} → c α → c β → Type u) [𝒞 : bundled_hom hom] {d : Type u → Type u} (F : {α : Type u} → d α → c α) [parent_projection F] : bundled_hom (map_hom hom F) :=
map hom F
protected instance forget₂ {c : Type u → Type u} (hom : {α β : Type u} → c α → c β → Type u) [𝒞 : bundled_hom hom] {d : Type u → Type u} (F : {α : Type u} → d α → c α) [parent_projection F] : has_forget₂ (bundled d) (bundled c) :=
has_forget₂.mk (functor.mk (fun (X : bundled d) => bundled.mk ↥X) fun (X Y : bundled d) (f : X ⟶ Y) => f)
protected instance forget₂_full {c : Type u → Type u} (hom : {α β : Type u} → c α → c β → Type u) [𝒞 : bundled_hom hom] {d : Type u → Type u} (F : {α : Type u} → d α → c α) [parent_projection F] : full (forget₂ (bundled d) (bundled c)) :=
full.mk
fun (X Y : bundled d)
(f : functor.obj (forget₂ (bundled d) (bundled c)) X ⟶ functor.obj (forget₂ (bundled d) (bundled c)) Y) => f
|
9a5de25c8aa9310db780b1252c24875520a3fbdf | 38ee9024fb5974f555fb578fcf5a5a7b71e669b5 | /Mathlib/Data/Nat/Gcd.lean | aefc7890ad8238ed0fe2db82a3c15d822a0fae87 | [
"Apache-2.0"
] | permissive | denayd/mathlib4 | 750e0dcd106554640a1ac701e51517501a574715 | 7f40a5c514066801ab3c6d431e9f405baa9b9c58 | refs/heads/master | 1,693,743,991,894 | 1,636,618,048,000 | 1,636,618,048,000 | 373,926,241 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 20,261 | lean | /-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura
-/
import Mathlib.Data.Nat.Basic
import Mathlib.Init.Dvd
/-!
# Definitions and properties of `gcd`, `lcm`, and `coprime`
-/
namespace Nat
--- TODO all of these dvd preliminaries belong elsewhere.
protected theorem dvd_mul_left (a b : ℕ) : a ∣ b * a := Exists.intro b (Nat.mul_comm b a)
protected theorem dvd_refl (a : ℕ) : a ∣ a := Exists.intro 1 (by simp)
protected theorem dvd_zero (a : ℕ) : a ∣ 0 := Exists.intro 0 (by simp)
protected theorem mul_dvd_mul : ∀ {a b c d : ℕ}, a ∣ b → c ∣ d → a * c ∣ b * d
| a, b, c, d, ⟨e, he⟩, ⟨f, hf⟩ => ⟨e * f, by rw [he, hf,
Nat.mul_assoc a _,
←Nat.mul_assoc e _,
Nat.mul_comm e c,
Nat.mul_assoc a c _,
Nat.mul_assoc c e _,]⟩
protected theorem mul_dvd_mul_left (a : ℕ) {b c : ℕ} (h : b ∣ c) : a * b ∣ a * c :=
Nat.mul_dvd_mul (Nat.dvd_refl a) h
protected theorem mul_dvd_mul_right {a b : ℕ} (h: a ∣ b) (c : ℕ) : a * c ∣ b * c :=
Nat.mul_dvd_mul h (Nat.dvd_refl c)
----
-- Here's where we get into the main gcd results
theorem gcd_rec (m n : ℕ) : gcd m n = gcd (n % m) m :=
match m with
| 0 => by have := (mod_zero n).symm
rwa [gcd_zero_right]
| pm + 1 => by simp [gcd_succ]
theorem gcd.induction
{P : ℕ → ℕ → Prop}
(m n : ℕ)
(H0 : ∀n, P 0 n)
(H1 : ∀ m n, 0 < m → P (n % m) m → P m n) :
P m n :=
@WellFounded.induction _ _ lt_wfRel.wf (λ m => ∀ n, P m n) m
(λ k IH =>
match k with
| 0 => H0
| pk+1 => λ n => H1 _ _ (succ_pos _) (IH _ (mod_lt _ (succ_pos _)) _) )
n
def lcm (m n : ℕ) : ℕ := m * n / gcd m n
@[reducible] def coprime (m n : ℕ) : Prop := gcd m n = 1
---
theorem gcd_dvd (m n : ℕ) : (gcd m n ∣ m) ∧ (gcd m n ∣ n) := by
induction m, n using gcd.induction with
| H0 n => exact And.intro (Exists.intro 0 (by simp))
(Exists.intro 1 (by simp))
| H1 m n mpos IH =>
let ⟨IH₁, IH₂⟩ := IH
exact And.intro (by rwa [gcd_rec])
(by rw [←gcd_rec] at IH₁
rw [←gcd_rec] at IH₂
exact (dvd_mod_iff IH₂).1 IH₁)
theorem gcd_dvd_left (m n : ℕ) : gcd m n ∣ m := (gcd_dvd m n).left
theorem gcd_dvd_right (m n : ℕ) : gcd m n ∣ n := (gcd_dvd m n).right
theorem gcd_le_left {m} (n) (h : 0 < m) : gcd m n ≤ m := le_of_dvd h $ gcd_dvd_left m n
theorem gcd_le_right {m} (n) (h : 0 < n) : gcd m n ≤ n := le_of_dvd h $ gcd_dvd_right m n
theorem dvd_gcd {m n k : ℕ} : k ∣ m → k ∣ n → k ∣ gcd m n := by
induction m, n using gcd.induction with
| H0 n => intros _ kn
rw [gcd_zero_left]
exact kn
| H1 m n mpos IH => intros H1 H2
rw [gcd_rec]
exact IH ((dvd_mod_iff H1).mpr H2) H1
theorem dvd_gcd_iff {m n k : ℕ} : k ∣ gcd m n ↔ k ∣ m ∧ k ∣ n :=
Iff.intro (λ h => And.intro (Nat.dvd_trans h (gcd_dvd m n).left) (Nat.dvd_trans h (gcd_dvd m n).right))
(λ h => dvd_gcd h.left h.right)
theorem gcd_comm (m n : ℕ) : gcd m n = gcd n m :=
dvd_antisymm
(dvd_gcd (gcd_dvd_right m n) (gcd_dvd_left m n))
(dvd_gcd (gcd_dvd_right n m) (gcd_dvd_left n m))
theorem gcd_eq_left_iff_dvd {m n :ℕ} : m ∣ n ↔ gcd m n = m :=
Iff.intro
(λ h => by rw [gcd_rec, mod_eq_zero_of_dvd h, gcd_zero_left])
(λ h => h ▸ gcd_dvd_right m n)
theorem gcd_eq_right_iff_dvd {m n : ℕ} : m ∣ n ↔ gcd n m = m :=
by rw [gcd_comm]
apply gcd_eq_left_iff_dvd
theorem gcd_assoc (m n k : ℕ) : gcd (gcd m n) k = gcd m (gcd n k) :=
dvd_antisymm
(dvd_gcd
(Nat.dvd_trans (gcd_dvd_left (gcd m n) k) (gcd_dvd_left m n))
(dvd_gcd (Nat.dvd_trans (gcd_dvd_left (gcd m n) k) (gcd_dvd_right m n))
(gcd_dvd_right (gcd m n) k)))
(dvd_gcd
(dvd_gcd (gcd_dvd_left m (gcd n k)) (Nat.dvd_trans (gcd_dvd_right m (gcd n k)) (gcd_dvd_left n k)))
(Nat.dvd_trans (gcd_dvd_right m (gcd n k)) (gcd_dvd_right n k)))
@[simp] theorem gcd_one_right (n : ℕ) : gcd n 1 = 1 :=
Eq.trans (gcd_comm n 1) $ gcd_one_left n
theorem gcd_mul_left (m n k : ℕ) : gcd (m * n) (m * k) = m * gcd n k := by
induction n, k using gcd.induction with
| H0 k => simp
| H1 n k npos IH => rwa [←mul_mod_mul_left, ←gcd_rec, ←gcd_rec] at IH
theorem gcd_mul_right (m n k : ℕ) : gcd (m * n) (k * n) = gcd m k * n :=
by rw [Nat.mul_comm m n, Nat.mul_comm k n, Nat.mul_comm (gcd m k) n, gcd_mul_left]
theorem gcd_pos_of_pos_left {m : ℕ} (n : ℕ) (mpos : 0 < m) : 0 < gcd m n :=
pos_of_dvd_of_pos (gcd_dvd_left m n) mpos
theorem gcd_pos_of_pos_right (m : ℕ) {n : ℕ} (npos : 0 < n) : 0 < gcd m n :=
pos_of_dvd_of_pos (gcd_dvd_right m n) npos
theorem eq_zero_of_gcd_eq_zero_left {m n : ℕ} (H : gcd m n = 0) : m = 0 :=
match eq_zero_or_pos m with
| Or.inl H0 => H0
| Or.inr H1 => absurd (Eq.symm H) (ne_of_lt (gcd_pos_of_pos_left _ H1))
theorem eq_zero_of_gcd_eq_zero_right {m n : ℕ} (H : gcd m n = 0) : n = 0 :=
by rw [gcd_comm] at H
exact eq_zero_of_gcd_eq_zero_left H
theorem gcd_div {m n k : ℕ} (H1 : k ∣ m) (H2 : k ∣ n) :
gcd (m / k) (n / k) = gcd m n / k :=
match eq_zero_or_pos k with
| Or.inl H0 => by rw [H0, Nat.div_zero, Nat.div_zero, Nat.div_zero, gcd_zero_right]
| Or.inr H3 =>
Nat.eq_of_mul_eq_mul_right H3 $ by rw [Nat.div_mul_cancel (dvd_gcd H1 H2), ←gcd_mul_right,
Nat.div_mul_cancel H1, Nat.div_mul_cancel H2]
theorem gcd_dvd_gcd_of_dvd_left {m k : ℕ} (n : ℕ) (H : m ∣ k) : gcd m n ∣ gcd k n :=
dvd_gcd (Nat.dvd_trans (gcd_dvd_left m n) H) (gcd_dvd_right m n)
theorem gcd_dvd_gcd_of_dvd_right {m k : ℕ} (n : ℕ) (H : m ∣ k) : gcd n m ∣ gcd n k :=
dvd_gcd (gcd_dvd_left n m) (Nat.dvd_trans (gcd_dvd_right n m) H)
theorem gcd_dvd_gcd_mul_left (m n k : ℕ) : gcd m n ∣ gcd (k * m) n :=
gcd_dvd_gcd_of_dvd_left _ (Nat.dvd_mul_left _ _)
theorem gcd_dvd_gcd_mul_right (m n k : ℕ) : gcd m n ∣ gcd (m * k) n :=
gcd_dvd_gcd_of_dvd_left _ (Nat.dvd_mul_right _ _)
theorem gcd_dvd_gcd_mul_left_right (m n k : ℕ) : gcd m n ∣ gcd m (k * n) :=
gcd_dvd_gcd_of_dvd_right _ (Nat.dvd_mul_left _ _)
theorem gcd_dvd_gcd_mul_right_right (m n k : ℕ) : gcd m n ∣ gcd m (n * k) :=
gcd_dvd_gcd_of_dvd_right _ (Nat.dvd_mul_right _ _)
theorem gcd_eq_left {m n : ℕ} (H : m ∣ n) : gcd m n = m :=
dvd_antisymm (gcd_dvd_left _ _) (dvd_gcd (Nat.dvd_refl _) H)
theorem gcd_eq_right {m n : ℕ} (H : n ∣ m) : gcd m n = n :=
by rw [gcd_comm, gcd_eq_left H]
@[simp] lemma gcd_mul_left_left (m n : ℕ) : gcd (m * n) n = n :=
dvd_antisymm (gcd_dvd_right _ _) (dvd_gcd (Nat.dvd_mul_left _ _) (Nat.dvd_refl _))
@[simp] lemma gcd_mul_left_right (m n : ℕ) : gcd n (m * n) = n :=
by rw [gcd_comm, gcd_mul_left_left]
@[simp] lemma gcd_mul_right_left (m n : ℕ) : gcd (n * m) n = n :=
by rw [Nat.mul_comm, gcd_mul_left_left]
@[simp] lemma gcd_mul_right_right (m n : ℕ) : gcd n (n * m) = n :=
by rw [gcd_comm, gcd_mul_right_left]
@[simp] lemma gcd_gcd_self_right_left (m n : ℕ) : gcd m (gcd m n) = gcd m n :=
dvd_antisymm (gcd_dvd_right _ _) (dvd_gcd (gcd_dvd_left _ _) (Nat.dvd_refl _))
@[simp] lemma gcd_gcd_self_right_right (m n : ℕ) : gcd m (gcd n m) = gcd n m :=
by rw [gcd_comm n m, gcd_gcd_self_right_left]
@[simp] lemma gcd_gcd_self_left_right (m n : ℕ) : gcd (gcd n m) m = gcd n m :=
by rw [gcd_comm, gcd_gcd_self_right_right]
@[simp] lemma gcd_gcd_self_left_left (m n : ℕ) : gcd (gcd m n) m = gcd m n :=
by rw [gcd_comm m n, gcd_gcd_self_left_right]
lemma gcd_add_mul_self (m n k : ℕ) : gcd m (n + k * m) = gcd m n :=
by simp [gcd_rec m (n + k * m), gcd_rec m n]
theorem gcd_eq_zero_iff {i j : ℕ} : gcd i j = 0 ↔ i = 0 ∧ j = 0 :=
Iff.intro
(λ h => ⟨eq_zero_of_gcd_eq_zero_left h, eq_zero_of_gcd_eq_zero_right h⟩)
(λ h => by rw [h.1, h.2]
exact Nat.gcd_zero_right _)
/-! ### `lcm` -/
theorem lcm_comm (m n : ℕ) : lcm m n = lcm n m :=
by have h1 : lcm m n = m * n / gcd m n := rfl
have h2 : lcm n m = n * m / gcd n m := rfl
rw [h1, h2, Nat.mul_comm n m, gcd_comm n m]
@[simp]
theorem lcm_zero_left (m : ℕ) : lcm 0 m = 0 :=
by have h : lcm 0 m = 0 * m / gcd 0 m := rfl
simp [h]
@[simp]
theorem lcm_zero_right (m : ℕ) : lcm m 0 = 0 := lcm_comm 0 m ▸ lcm_zero_left m
@[simp]
theorem lcm_one_left (m : ℕ) : lcm 1 m = m :=
by have h : lcm 1 m = 1 * m / gcd 1 m := rfl
simp [h]
@[simp]
theorem lcm_one_right (m : ℕ) : lcm m 1 = m := lcm_comm 1 m ▸ lcm_one_left m
@[simp]
theorem lcm_self (m : ℕ) : lcm m m = m :=
match eq_zero_or_pos m with
| Or.inl h => by rw [h, lcm_zero_left]
| Or.inr h => by have h1 : lcm m m = m * m / gcd m m := rfl
simp [h1, Nat.mul_div_cancel _ h]
theorem dvd_lcm_left (m n : ℕ) : m ∣ lcm m n :=
Exists.intro (n / gcd m n)
(by rw [← Nat.mul_div_assoc m (Nat.gcd_dvd_right m n)]
rfl)
theorem dvd_lcm_right (m n : ℕ) : n ∣ lcm m n :=
lcm_comm n m ▸ dvd_lcm_left n m
theorem gcd_mul_lcm (m n : ℕ) : gcd m n * lcm m n = m * n :=
by have h1 : lcm m n = m * n / gcd m n := rfl
rw [h1]
rw [Nat.mul_div_cancel' (Nat.dvd_trans (gcd_dvd_left m n) (Nat.dvd_mul_right m n))]
theorem lcm_dvd {m n k : ℕ} (H1 : m ∣ k) (H2 : n ∣ k) : lcm m n ∣ k :=
match eq_zero_or_pos k with
| Or.inl h => by rw [h]
exact Nat.dvd_zero _
| Or.inr kpos => Nat.dvd_of_mul_dvd_mul_left (gcd_pos_of_pos_left n (pos_of_dvd_of_pos H1 kpos)) $
by rw [gcd_mul_lcm, ←gcd_mul_right, Nat.mul_comm n k];
exact dvd_gcd (Nat.mul_dvd_mul_left _ H2) (Nat.mul_dvd_mul_right H1 _)
theorem lcm_assoc (m n k : ℕ) : lcm (lcm m n) k = lcm m (lcm n k) :=
dvd_antisymm
(lcm_dvd
(lcm_dvd (dvd_lcm_left m (lcm n k)) (Nat.dvd_trans (dvd_lcm_left n k) (dvd_lcm_right m (lcm n k))))
(Nat.dvd_trans (dvd_lcm_right n k) (dvd_lcm_right m (lcm n k))))
(lcm_dvd
(Nat.dvd_trans (dvd_lcm_left m n) (dvd_lcm_left (lcm m n) k))
(lcm_dvd (Nat.dvd_trans (dvd_lcm_right m n) (dvd_lcm_left (lcm m n) k))
(dvd_lcm_right (lcm m n) k)))
theorem lcm_ne_zero {m n : ℕ} (hm : m ≠ 0) (hn : n ≠ 0) : lcm m n ≠ 0 :=
by intro h
have h1 := gcd_mul_lcm m n
rw [h, Nat.mul_zero] at h1
match eq_zero_of_mul_eq_zero h1.symm with
| Or.inl hm1 => exact hm hm1
| Or.inr hn1 => exact hn hn1
/-!
### `coprime`
See also `nat.coprime_of_dvd` and `nat.coprime_of_dvd'` to prove `nat.coprime m n`.
-/
instance (m n : ℕ) : Decidable (coprime m n) :=
if h: gcd m n = 1 then isTrue h else isFalse h
theorem coprime_iff_gcd_eq_one {m n : ℕ} : coprime m n ↔ gcd m n = 1 := Iff.rfl
theorem coprime.gcd_eq_one {m n : ℕ} : coprime m n → gcd m n = 1 := id
theorem coprime.symm {m n : ℕ} : coprime n m → coprime m n := (gcd_comm m n).trans
theorem coprime_comm {m n : ℕ} : coprime n m ↔ coprime m n := ⟨coprime.symm, coprime.symm⟩
theorem coprime.dvd_of_dvd_mul_right {m n k : ℕ} (H1 : coprime k n) (H2 : k ∣ m * n) : k ∣ m :=
let t := dvd_gcd (Nat.dvd_mul_left k m) H2
by rwa [gcd_mul_left, H1.gcd_eq_one, Nat.mul_one] at t
theorem coprime.dvd_of_dvd_mul_left {m n k : ℕ} (H1 : coprime k m) (H2 : k ∣ m * n) : k ∣ n :=
by rw [Nat.mul_comm] at H2
exact H1.dvd_of_dvd_mul_right H2
theorem coprime.gcd_mul_left_cancel {k : ℕ} (m : ℕ) {n : ℕ} (H : coprime k n) :
gcd (k * m) n = gcd m n :=
let H1 : coprime (gcd (k * m) n) k :=
by have h1 : coprime (gcd (k * m) n) k = (gcd (gcd (k * m) n) k = 1) := rfl
rw [h1, Nat.gcd_assoc, H.symm.gcd_eq_one, gcd_one_right]
dvd_antisymm
(dvd_gcd (H1.dvd_of_dvd_mul_left (gcd_dvd_left _ _)) (gcd_dvd_right _ _))
(gcd_dvd_gcd_mul_left _ _ _)
theorem coprime.gcd_mul_right_cancel (m : ℕ) {k n : ℕ} (H : coprime k n) :
gcd (m * k) n = gcd m n :=
by rw [Nat.mul_comm m k, H.gcd_mul_left_cancel m]
theorem coprime.gcd_mul_left_cancel_right {k m : ℕ} (n : ℕ) (H : coprime k m) :
gcd m (k * n) = gcd m n :=
by rw [gcd_comm m n, gcd_comm m (k * n), H.gcd_mul_left_cancel n]
theorem coprime.gcd_mul_right_cancel_right {k m : ℕ} (n : ℕ) (H : coprime k m) :
gcd m (n * k) = gcd m n :=
by rw [Nat.mul_comm n k, H.gcd_mul_left_cancel_right n]
theorem coprime_div_gcd_div_gcd {m n : ℕ} (H : 0 < gcd m n) :
coprime (m / gcd m n) (n / gcd m n) :=
by rw [coprime_iff_gcd_eq_one, gcd_div (gcd_dvd_left m n) (gcd_dvd_right m n), Nat.div_self H]
theorem not_coprime_of_dvd_of_dvd {m n d : ℕ} (dgt1 : 1 < d) (Hm : d ∣ m) (Hn : d ∣ n) :
¬ coprime m n :=
λ co => by have hd : ¬ d ≤ 1 := Nat.not_le_of_gt dgt1
have := (Nat.le_of_dvd Nat.zero_lt_one $ by rw [←co.gcd_eq_one]; exact dvd_gcd Hm Hn)
exact hd this
theorem exists_coprime {m n : ℕ} (H : 0 < gcd m n) :
∃ m' n', coprime m' n' ∧ m = m' * gcd m n ∧ n = n' * gcd m n :=
⟨_, _, coprime_div_gcd_div_gcd H,
(Nat.div_mul_cancel (gcd_dvd_left m n)).symm,
(Nat.div_mul_cancel (gcd_dvd_right m n)).symm⟩
theorem exists_coprime' {m n : ℕ} (H : 0 < gcd m n) :
∃ g m' n', 0 < g ∧ coprime m' n' ∧ m = m' * g ∧ n = n' * g :=
let ⟨m', n', h⟩ := exists_coprime H
⟨_, m', n', H, h⟩
theorem coprime.mul {m n k : ℕ} (H1 : coprime m k) (H2 : coprime n k) : coprime (m * n) k :=
(H1.gcd_mul_left_cancel n).trans H2
theorem coprime.mul_right {k m n : ℕ} (H1 : coprime k m) (H2 : coprime k n) : coprime k (m * n) :=
(H1.symm.mul H2.symm).symm
theorem coprime.coprime_dvd_left {m k n : ℕ} (H1 : m ∣ k) (H2 : coprime k n) : coprime m n :=
by apply eq_one_of_dvd_one
have h1 : coprime k n = (gcd k n = 1) := rfl
rw [h1] at H2
have := @Nat.gcd_dvd_gcd_of_dvd_left m k n H1
rwa [←H2]
theorem coprime.coprime_dvd_right {m k n : ℕ} (H1 : n ∣ m) (H2 : coprime k m) : coprime k n :=
(H2.symm.coprime_dvd_left H1).symm
theorem coprime.coprime_mul_left {k m n : ℕ} (H : coprime (k * m) n) : coprime m n :=
H.coprime_dvd_left (Nat.dvd_mul_left _ _)
theorem coprime.coprime_mul_right {k m n : ℕ} (H : coprime (m * k) n) : coprime m n :=
H.coprime_dvd_left (Nat.dvd_mul_right _ _)
theorem coprime.coprime_mul_left_right {k m n : ℕ} (H : coprime m (k * n)) : coprime m n :=
H.coprime_dvd_right (Nat.dvd_mul_left _ _)
theorem coprime.coprime_mul_right_right {k m n : ℕ} (H : coprime m (n * k)) : coprime m n :=
H.coprime_dvd_right (Nat.dvd_mul_right _ _)
theorem coprime.coprime_div_left {m n a : ℕ} (cmn : coprime m n) (dvd : a ∣ m) :
coprime (m / a) n :=
match eq_zero_or_pos a with
| Or.inl h0 => by rw [h0] at dvd
rw [Nat.eq_zero_of_zero_dvd dvd]
rw [Nat.eq_zero_of_zero_dvd dvd] at cmn
simp
assumption
| Or.inr hpos =>
match dvd with
| ⟨k, hk⟩ => by rw [hk, Nat.mul_div_cancel_left _ hpos]
rw [hk] at cmn
exact coprime.coprime_mul_left cmn
theorem coprime.coprime_div_right {m n a : ℕ} (cmn : coprime m n) (dvd : a ∣ n) :
coprime m (n / a) :=
(coprime.coprime_div_left cmn.symm dvd).symm
lemma coprime_mul_iff_left {k m n : ℕ} : coprime (m * n) k ↔ coprime m k ∧ coprime n k :=
⟨λ h => ⟨coprime.coprime_mul_right h, coprime.coprime_mul_left h⟩,
λ ⟨h, _⟩ => by rwa [coprime_iff_gcd_eq_one, coprime.gcd_mul_left_cancel n h]⟩
lemma coprime_mul_iff_right {k m n : ℕ} : coprime k (m * n) ↔ coprime k m ∧ coprime k n :=
by rw [@coprime_comm (m*n) k, @coprime_comm m k, @coprime_comm n k, coprime_mul_iff_left]
lemma coprime.gcd_left (k : ℕ) {m n : ℕ} (hmn : coprime m n) : coprime (gcd k m) n :=
hmn.coprime_dvd_left $ gcd_dvd_right k m
lemma coprime.gcd_right (k : ℕ) {m n : ℕ} (hmn : coprime m n) : coprime m (gcd k n) :=
hmn.coprime_dvd_right $ gcd_dvd_right k n
lemma coprime.gcd_both (k l : ℕ) {m n : ℕ} (hmn : coprime m n) : coprime (gcd k m) (gcd l n) :=
(hmn.gcd_left k).gcd_right l
lemma coprime.mul_dvd_of_dvd_of_dvd {a n m : ℕ} (hmn : coprime m n)
(hm : m ∣ a) (hn : n ∣ a) : m * n ∣ a :=
let ⟨k, hk⟩ := hm
hk.symm ▸ Nat.mul_dvd_mul_left _ (hmn.symm.dvd_of_dvd_mul_left (hk ▸ hn))
theorem coprime_one_left : ∀ n, coprime 1 n := gcd_one_left
theorem coprime_one_right : ∀ n, coprime n 1 := gcd_one_right
theorem coprime.pow_left {m k : ℕ} (n : ℕ) (H1 : coprime m k) : coprime (m ^ n) k :=
by induction n with
| zero => exact coprime_one_left _
| succ n ih => have hm := H1.mul ih
have : m ^ succ n = m * m ^ n := by rw [Nat.pow_succ, Nat.mul_comm]
rwa [this]
theorem coprime.pow_right {m k : ℕ} (n : ℕ) (H1 : coprime k m) : coprime k (m ^ n) :=
(H1.symm.pow_left n).symm
theorem coprime.pow {k l : ℕ} (m n : ℕ) (H1 : coprime k l) : coprime (k ^ m) (l ^ n) :=
(H1.pow_left _).pow_right _
theorem coprime.eq_one_of_dvd {k m : ℕ} (H : coprime k m) (d : k ∣ m) : k = 1 :=
by rw [← H.gcd_eq_one, gcd_eq_left d]
@[simp] theorem coprime_zero_left (n : ℕ) : coprime 0 n ↔ n = 1 :=
by simp [coprime]
@[simp] theorem coprime_zero_right (n : ℕ) : coprime n 0 ↔ n = 1 :=
by simp [coprime]
@[simp] theorem coprime_one_left_iff (n : ℕ) : coprime 1 n ↔ true :=
by simp [coprime]
@[simp] theorem coprime_one_right_iff (n : ℕ) : coprime n 1 ↔ true :=
by simp [coprime]
@[simp] theorem coprime_self (n : ℕ) : coprime n n ↔ n = 1 :=
by simp [coprime]
/-- Represent a divisor of `m * n` as a product of a divisor of `m` and a divisor of `n`. -/
def prod_dvd_and_dvd_of_dvd_prod {m n k : ℕ} (H : k ∣ m * n) :
{ d : {m' // m' ∣ m} × {n' // n' ∣ n} // k = d.1.val * d.2.val } :=
by cases h0 : gcd k m with
| zero => have : k = 0 := eq_zero_of_gcd_eq_zero_left h0
subst this
have : m = 0 := eq_zero_of_gcd_eq_zero_right h0
subst this
exact ⟨⟨⟨0, Nat.dvd_refl 0⟩, ⟨n, Nat.dvd_refl n⟩⟩, (Nat.zero_mul n).symm⟩
| succ p => have hpos : 0 < gcd k m := h0.symm ▸ Nat.zero_lt_succ _;
clear h0
have hd : gcd k m * (k / gcd k m) = k := (Nat.mul_div_cancel' (gcd_dvd_left k m))
have hn : (k / gcd k m) ∣ n := by apply Nat.dvd_of_mul_dvd_mul_left hpos
rw [hd, ← gcd_mul_right]
exact Nat.dvd_gcd (Nat.dvd_mul_right _ _) H
exact ⟨⟨⟨gcd k m, gcd_dvd_right k m⟩, ⟨k / gcd k m, hn⟩⟩, hd.symm⟩
theorem gcd_mul_dvd_mul_gcd (k m n : ℕ) : gcd k (m * n) ∣ gcd k m * gcd k n :=
match (prod_dvd_and_dvd_of_dvd_prod $ gcd_dvd_right k (m * n)) with
| ⟨⟨⟨m', hm'⟩, ⟨n', hn'⟩⟩, h⟩ =>
by have h' : gcd k (m * n) = m' * n' := h
rw [h']
have hm'n' : m' * n' ∣ k := h ▸ gcd_dvd_left _ _
exact Nat.mul_dvd_mul
(by have hm'k : m' ∣ k := Nat.dvd_trans (Nat.dvd_mul_right m' n') hm'n'
exact dvd_gcd hm'k hm')
(by have hn'k : n' ∣ k := Nat.dvd_trans (Nat.dvd_mul_left n' m') hm'n'
exact dvd_gcd hn'k hn')
theorem coprime.gcd_mul (k : ℕ) {m n : ℕ} (h : coprime m n) : gcd k (m * n) = gcd k m * gcd k n :=
dvd_antisymm
(gcd_mul_dvd_mul_gcd k m n)
((h.gcd_both k k).mul_dvd_of_dvd_of_dvd
(gcd_dvd_gcd_mul_right_right _ _ _)
(gcd_dvd_gcd_mul_left_right _ _ _))
-- TODO: pow_dvd_pow_iff
lemma gcd_mul_gcd_of_coprime_of_mul_eq_mul {a b c d : ℕ} (cop : c.coprime d) (h : a * b = c * d) :
a.gcd c * b.gcd c = c :=
dvd_antisymm
(by apply Nat.coprime.dvd_of_dvd_mul_right (Nat.coprime.mul (cop.gcd_left _) (cop.gcd_left _))
rw [← h]
apply Nat.mul_dvd_mul (gcd_dvd _ _).1 (gcd_dvd _ _).1)
(by rw [gcd_comm a _, gcd_comm b _]
have h1 : c ∣ gcd c (a * b) :=
by rw [h, gcd_mul_right_right d c]
exact Nat.dvd_refl _
have h2 : gcd c (a * b) ∣ gcd c a * gcd c b :=
by apply gcd_mul_dvd_mul_gcd
exact Nat.dvd_trans h1 h2)
|
c43e5c3be23a02e2b9bf195c860434592bce3d59 | 957a80ea22c5abb4f4670b250d55534d9db99108 | /tests/lean/nested_match.lean | fe951a969d1f103c3536ced9d5f157676a48de7a | [
"Apache-2.0"
] | permissive | GaloisInc/lean | aa1e64d604051e602fcf4610061314b9a37ab8cd | f1ec117a24459b59c6ff9e56a1d09d9e9e60a6c0 | refs/heads/master | 1,592,202,909,807 | 1,504,624,387,000 | 1,504,624,387,000 | 75,319,626 | 2 | 1 | Apache-2.0 | 1,539,290,164,000 | 1,480,616,104,000 | C++ | UTF-8 | Lean | false | false | 415 | lean | namespace ex1
def f : ℕ → ℕ
| n :=
(match n with
| 0 := 0
| (m+1) := f m
end) + 1
def g : ℕ → ℕ
| n :=
(match n, rfl : ∀ m, m = n → ℕ with
| 0, h := 0
| (m+1), h :=
have m < n, begin rw [←h], apply nat.lt_succ_self end,
g m
end) + 1
end ex1
namespace ex2
mutual def f, g
with f : ℕ → ℕ
| n := g n + 1
with g : ℕ → ℕ
| 0 := 0
| (n+1) := f n
end ex2
|
efcae6975f1a70b571531c90dc0e7a114b7cbd3f | 63abd62053d479eae5abf4951554e1064a4c45b4 | /src/tactic/monotonicity/lemmas.lean | af69a7e7573e4ed2f9f9f93b29997a6893add9ca | [
"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 | 2,212 | lean | /-
Copyright (c) 2019 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Simon Hudon
-/
import tactic.monotonicity.basic
import data.set.lattice
import order.bounds
variables {α : Type*}
@[mono]
lemma mul_mono_nonneg {x y z : α} [ordered_semiring α]
(h' : 0 ≤ z)
(h : x ≤ y)
: x * z ≤ y * z :=
by apply mul_le_mul_of_nonneg_right; assumption
lemma lt_of_mul_lt_mul_neg_right {a b c : α} [linear_ordered_ring α]
(h : a * c < b * c) (hc : c ≤ 0) : b < a :=
have nhc : -c ≥ 0, from neg_nonneg_of_nonpos hc,
have h2 : -(b * c) < -(a * c), from neg_lt_neg h,
have h3 : b * (-c) < a * (-c), from calc
b * (-c) = - (b * c) : by rewrite neg_mul_eq_mul_neg
... < - (a * c) : h2
... = a * (-c) : by rewrite neg_mul_eq_mul_neg,
lt_of_mul_lt_mul_right h3 nhc
@[mono]
lemma mul_mono_nonpos {x y z : α} [linear_ordered_ring α]
(h' : z ≤ 0) (h : y ≤ x) : x * z ≤ y * z :=
begin
classical,
by_contradiction h'',
revert h,
apply not_le_of_lt,
apply lt_of_mul_lt_mul_neg_right _ h',
apply lt_of_not_ge h''
end
@[mono]
lemma nat.sub_mono_left_strict {x y z : ℕ}
(h' : z ≤ x)
(h : x < y)
: x - z < y - z :=
begin
have : z ≤ y,
{ transitivity, assumption, apply le_of_lt h, },
apply @nat.lt_of_add_lt_add_left z,
rw [nat.add_sub_of_le,nat.add_sub_of_le];
solve_by_elim
end
@[mono]
lemma nat.sub_mono_right_strict {x y z : ℕ}
(h' : x ≤ z)
(h : y < x)
: z - x < z - y :=
begin
have h'' : y ≤ z,
{ transitivity, apply le_of_lt h, assumption },
apply @nat.lt_of_add_lt_add_right _ x,
rw [nat.sub_add_cancel h'],
apply @lt_of_le_of_lt _ _ _ (z - y + y),
rw [nat.sub_add_cancel h''],
apply nat.add_lt_add_left h
end
open set
attribute [mono] monotone_inter monotone_union
sUnion_mono bUnion_mono sInter_subset_sInter bInter_mono
image_subset preimage_mono prod_mono monotone_prod seq_mono
attribute [mono] upper_bounds_mono_set lower_bounds_mono_set
upper_bounds_mono_mem lower_bounds_mono_mem
upper_bounds_mono lower_bounds_mono
bdd_above.mono bdd_below.mono
|
a7966f1a4d566d98a733ccca5b59ccf405f1a750 | 35677d2df3f081738fa6b08138e03ee36bc33cad | /src/data/set/intervals/unordered_interval.lean | 2afbdc0b413db0459f040aa62588d6d7b521165a | [
"Apache-2.0"
] | permissive | gebner/mathlib | eab0150cc4f79ec45d2016a8c21750244a2e7ff0 | cc6a6edc397c55118df62831e23bfbd6e6c6b4ab | refs/heads/master | 1,625,574,853,976 | 1,586,712,827,000 | 1,586,712,827,000 | 99,101,412 | 1 | 0 | Apache-2.0 | 1,586,716,389,000 | 1,501,667,958,000 | Lean | UTF-8 | Lean | false | false | 5,116 | lean | /-
Copyright (c) 2020 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou
-/
import data.set.intervals.basic order.bounds
/-!
# Intervals without endpoints ordering
In any decidable linear order `α`, we define the set of elements lying between two elements `a` and
`b` as `Icc (min a b) (max a b)`.
`Icc a b` requires the assumption `a ≤ b` to be meaningful, which is sometimes inconvenient. The
interval as defined in this file is always the set of things lying between `a` and `b`, regardless
of the relative order of `a` and `b`.
For real numbers, `Icc (min a b) (max a b)` is the same as `segment a b`.
## Notation
We use the localized notation `[a, b]` for `interval a b`. One can open the locale `interval` to
make the notation available.
-/
universe u
namespace set
section decidable_linear_order
variables {α : Type u} [decidable_linear_order α] {a a₁ a₂ b b₁ b₂ x : α}
/-- `interval a b` is the set of elements lying between `a` and `b`, with `a` and `b` included. -/
def interval (a b : α) := Icc (min a b) (max a b)
localized "notation `[`a `, ` b `]` := interval a b" in interval
@[simp] lemma interval_of_le (h : a ≤ b) : [a, b] = Icc a b :=
by rw [interval, min_eq_left h, max_eq_right h]
@[simp] lemma interval_of_ge (h : b ≤ a) : [a, b] = Icc b a :=
by { rw [interval, min_eq_right h, max_eq_left h] }
lemma interval_swap (a b : α) : [a, b] = [b, a] :=
or.elim (le_total a b) (by simp {contextual := tt}) (by simp {contextual := tt})
lemma interval_of_lt (h : a < b) : [a, b] = Icc a b :=
interval_of_le (le_of_lt h)
lemma interval_of_gt (h : b < a) : [a, b] = Icc b a :=
interval_of_ge (le_of_lt h)
lemma interval_of_not_le (h : ¬ a ≤ b) : [a, b] = Icc b a :=
interval_of_gt (lt_of_not_ge h)
lemma interval_of_not_ge (h : ¬ b ≤ a) : [a, b] = Icc a b :=
interval_of_lt (lt_of_not_ge h)
@[simp] lemma interval_self : [a, a] = {a} :=
set.ext $ by simp [le_antisymm_iff, and_comm]
@[simp] lemma nonempty_interval : set.nonempty [a, b] :=
by { simp only [interval, min_le_iff, le_max_iff, nonempty_Icc], left, left, refl }
@[simp] lemma left_mem_interval : a ∈ [a, b] :=
by { rw [interval, mem_Icc], exact ⟨min_le_left _ _, le_max_left _ _⟩ }
@[simp] lemma right_mem_interval : b ∈ [a, b] :=
by { rw interval_swap, exact left_mem_interval }
lemma Icc_subset_interval : Icc a b ⊆ [a, b] :=
by { assume x h, rwa interval_of_le, exact le_trans h.1 h.2 }
lemma Icc_subset_interval' : Icc b a ⊆ [a, b] :=
by { rw interval_swap, apply Icc_subset_interval }
lemma mem_interval_of_le (ha : a ≤ x) (hb : x ≤ b) : x ∈ [a, b] :=
Icc_subset_interval ⟨ha, hb⟩
lemma mem_interval_of_ge (hb : b ≤ x) (ha : x ≤ a) : x ∈ [a, b] :=
Icc_subset_interval' ⟨hb, ha⟩
lemma interval_subset_interval (h₁ : a₁ ∈ [a₂, b₂]) (h₂ : b₁ ∈ [a₂, b₂]) : [a₁, b₁] ⊆ [a₂, b₂] :=
Icc_subset_Icc (le_min h₁.1 h₂.1) (max_le h₁.2 h₂.2)
lemma interval_subset_interval_iff_mem : [a₁, b₁] ⊆ [a₂, b₂] ↔ a₁ ∈ [a₂, b₂] ∧ b₁ ∈ [a₂, b₂] :=
iff.intro (λh, ⟨h left_mem_interval, h right_mem_interval⟩) (λ h, interval_subset_interval h.1 h.2)
lemma interval_subset_interval_iff_le :
[a₁, b₁] ⊆ [a₂, b₂] ↔ min a₂ b₂ ≤ min a₁ b₁ ∧ max a₁ b₁ ≤ max a₂ b₂ :=
by { rw [interval, interval, Icc_subset_Icc_iff], exact min_le_max }
lemma interval_subset_interval_right (h : x ∈ [a, b]) : [x, b] ⊆ [a, b] :=
interval_subset_interval h right_mem_interval
lemma interval_subset_interval_left (h : x ∈ [a, b]) : [a, x] ⊆ [a, b] :=
interval_subset_interval left_mem_interval h
lemma bdd_below_bdd_above_iff_subset_interval (s : set α) :
bdd_below s ∧ bdd_above s ↔ ∃ a b, s ⊆ [a, b] :=
begin
rw [bdd_below_bdd_above_iff_subset_Icc],
split,
{ rintro ⟨a, b, h⟩, exact ⟨a, b, λ x hx, Icc_subset_interval (h hx)⟩ },
{ rintro ⟨a, b, h⟩, exact ⟨min a b, max a b, h⟩ }
end
end decidable_linear_order
open_locale interval
section ordered_add_comm_group
variables {α : Type u} [decidable_linear_ordered_add_comm_group α] {a b x y : α}
/-- If `[x, y]` is a subinterval of `[a, b]`, then the distance between `x` and `y`
is less than or equal to that of `a` and `b` -/
lemma abs_sub_le_of_subinterval (h : [x, y] ⊆ [a, b]) : abs (y - x) ≤ abs (b - a) :=
begin
rw [← max_sub_min_eq_abs, ← max_sub_min_eq_abs],
rw [interval_subset_interval_iff_le] at h,
exact sub_le_sub h.2 h.1,
end
/-- If `x ∈ [a, b]`, then the distance between `a` and `x` is less than or equal to
that of `a` and `b` -/
lemma abs_sub_left_of_mem_interval (h : x ∈ [a, b]) : abs (x - a) ≤ abs (b - a) :=
abs_sub_le_of_subinterval (interval_subset_interval_left h)
/-- If `x ∈ [a, b]`, then the distance between `x` and `b` is less than or equal to
that of `a` and `b` -/
lemma abs_sub_right_of_mem_interval (h : x ∈ [a, b]) : abs (b - x) ≤ abs (b - a) :=
abs_sub_le_of_subinterval (interval_subset_interval_right h)
end ordered_add_comm_group
end set
|
28b2b4fde3dd1812c1997e8ed06a3ddcf14973cf | d436468d80b739ba7e06843c4d0d2070e43448e5 | /src/analysis/complex/polynomial.lean | ae450b7853d6200e5077ac66ad8d0a93d287cb8b | [
"Apache-2.0"
] | permissive | roro47/mathlib | 761fdc002aef92f77818f3fef06bf6ec6fc1a28e | 80aa7d52537571a2ca62a3fdf71c9533a09422cf | refs/heads/master | 1,599,656,410,625 | 1,573,649,488,000 | 1,573,649,488,000 | 221,452,951 | 0 | 0 | Apache-2.0 | 1,573,647,693,000 | 1,573,647,692,000 | null | UTF-8 | Lean | false | false | 6,020 | lean | /-
Copyright (c) 2019 Chris Hughes All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import data.polynomial topology.algebra.polynomial analysis.complex.exponential
open complex polynomial metric filter is_absolute_value set lattice
namespace complex
lemma exists_forall_abs_polynomial_eval_le (p : polynomial ℂ) :
∃ x, ∀ y, (p.eval x).abs ≤ (p.eval y).abs :=
if hp0 : 0 < degree p
then let ⟨r, hr0, hr⟩ := polynomial.tendsto_infinity complex.abs hp0 ((p.eval 0).abs) in
let ⟨x, hx₁, hx₂⟩ := exists_forall_le_of_compact_of_continuous (λ y, (p.eval y).abs)
(continuous_abs.comp p.continuous_eval)
(closed_ball 0 r) (proper_space.compact_ball _ _)
(set.ne_empty_iff_exists_mem.2 ⟨0, by simp [le_of_lt hr0]⟩) in
⟨x, λ y, if hy : y.abs ≤ r then hx₂ y $ by simpa [complex.dist_eq] using hy
else le_trans (hx₂ _ (by simp [le_of_lt hr0])) (le_of_lt (hr y (lt_of_not_ge hy)))⟩
else ⟨p.coeff 0, by rw [eq_C_of_degree_le_zero (le_of_not_gt hp0)]; simp⟩
/- The following proof uses the method given at
https://ncatlab.org/nlab/show/fundamental+theorem+of+algebra#classical_fta_via_advanced_calculus -/
/-- The fundamental theorem of algebra. Every non constant complex polynomial
has a root -/
lemma exists_root {f : polynomial ℂ} (hf : 0 < degree f) : ∃ z : ℂ, is_root f z :=
let ⟨z₀, hz₀⟩ := exists_forall_abs_polynomial_eval_le f in
exists.intro z₀ $ by_contradiction $ λ hf0,
have hfX : f - C (f.eval z₀) ≠ 0,
from mt sub_eq_zero.1 (λ h, not_le_of_gt hf (h.symm ▸ degree_C_le)),
let n := root_multiplicity z₀ (f - C (f.eval z₀)) in
let g := (f - C (f.eval z₀)) /ₘ ((X - C z₀) ^ n) in
have hg0 : g.eval z₀ ≠ 0, from eval_div_by_monic_pow_root_multiplicity_ne_zero _ hfX,
have hg : g * (X - C z₀) ^ n = f - C (f.eval z₀),
from div_by_monic_mul_pow_root_multiplicity_eq _ _,
have hn0 : 0 < n, from nat.pos_of_ne_zero $ λ hn0, by simpa [g, hn0] using hg0,
let ⟨δ', hδ'₁, hδ'₂⟩ := continuous_iff.1 (polynomial.continuous_eval g) z₀
((g.eval z₀).abs) (complex.abs_pos.2 hg0) in
let δ := min (min (δ' / 2) 1) (((f.eval z₀).abs / (g.eval z₀).abs) / 2) in
have hf0' : 0 < (f.eval z₀).abs, from complex.abs_pos.2 hf0,
have hfg0 : 0 < abs (eval z₀ f) * (abs (eval z₀ g))⁻¹, from div_pos hf0' (complex.abs_pos.2 hg0),
have hδ0 : 0 < δ, from lt_min (lt_min (half_pos hδ'₁) (by norm_num)) (half_pos hfg0),
have hδ : ∀ z : ℂ, abs (z - z₀) = δ → abs (g.eval z - g.eval z₀) < (g.eval z₀).abs,
from λ z hz, hδ'₂ z (by rw [complex.dist_eq, hz];
exact lt_of_le_of_lt (le_trans (min_le_left _ _) (min_le_left _ _))
(half_lt_self hδ'₁)),
have hδ1 : δ ≤ 1, from le_trans (min_le_left _ _) (min_le_right _ _),
let F : polynomial ℂ := C (f.eval z₀) + C (g.eval z₀) * (X - C z₀) ^ n in
let z' := (-f.eval z₀ * (g.eval z₀).abs * δ ^ n /
((f.eval z₀).abs * g.eval z₀)) ^ (n⁻¹ : ℂ) + z₀ in
have hF₁ : F.eval z' = f.eval z₀ - f.eval z₀ * (g.eval z₀).abs * δ ^ n / (f.eval z₀).abs,
by simp only [F, cpow_nat_inv_pow _ hn0, div_eq_mul_inv, eval_pow, mul_assoc, mul_comm (g.eval z₀),
mul_left_comm (g.eval z₀), mul_left_comm (g.eval z₀)⁻¹, mul_inv', inv_mul_cancel hg0,
eval_C, eval_add, eval_neg, sub_eq_add_neg, eval_mul, eval_X, add_neg_cancel_right,
neg_mul_eq_neg_mul_symm, mul_one, div_eq_mul_inv];
simp only [mul_comm, mul_left_comm, mul_assoc],
have hδs : (g.eval z₀).abs * δ ^ n / (f.eval z₀).abs < 1,
by rw [div_eq_mul_inv, mul_right_comm, mul_comm, ← inv_inv' (complex.abs _ * _), mul_inv',
inv_inv', ← div_eq_mul_inv, div_lt_iff hfg0, one_mul];
calc δ ^ n ≤ δ ^ 1 : pow_le_pow_of_le_one (le_of_lt hδ0) hδ1 hn0
... = δ : pow_one _
... ≤ ((f.eval z₀).abs / (g.eval z₀).abs) / 2 : min_le_right _ _
... < _ : half_lt_self hfg0,
have hF₂ : (F.eval z').abs = (f.eval z₀).abs - (g.eval z₀).abs * δ ^ n,
from calc (F.eval z').abs = (f.eval z₀ - f.eval z₀ * (g.eval z₀).abs
* δ ^ n / (f.eval z₀).abs).abs : congr_arg abs hF₁
... = abs (f.eval z₀) * complex.abs (1 - (g.eval z₀).abs * δ ^ n /
(f.eval z₀).abs : ℝ) : by rw [← complex.abs_mul];
exact congr_arg complex.abs
(by simp [mul_add, add_mul, mul_assoc, div_eq_mul_inv])
... = _ : by rw [complex.abs_of_nonneg (sub_nonneg.2 (le_of_lt hδs)),
mul_sub, mul_div_cancel' _ (ne.symm (ne_of_lt hf0')), mul_one],
have hef0 : abs (eval z₀ g) * (eval z₀ f).abs ≠ 0,
from mul_ne_zero (mt complex.abs_eq_zero.1 hg0) (mt complex.abs_eq_zero.1 hf0),
have hz'z₀ : abs (z' - z₀) = δ,
by simp [z', mul_assoc, mul_left_comm _ (_ ^ n), mul_comm _ (_ ^ n),
mul_comm (eval z₀ f).abs, _root_.mul_div_cancel _ hef0, of_real_mul,
neg_mul_eq_neg_mul_symm, neg_div, is_absolute_value.abv_pow complex.abs,
complex.abs_of_nonneg (le_of_lt hδ0), real.pow_nat_rpow_nat_inv (le_of_lt hδ0) hn0],
have hF₃ : (f.eval z' - F.eval z').abs < (g.eval z₀).abs * δ ^ n,
from calc (f.eval z' - F.eval z').abs
= (g.eval z' - g.eval z₀).abs * (z' - z₀).abs ^ n :
by rw [← eq_sub_iff_add_eq.1 hg, ← is_absolute_value.abv_pow complex.abs,
← complex.abs_mul, sub_mul];
simp [F, eval_pow, eval_add, eval_mul, eval_sub, eval_C, eval_X, eval_neg, add_sub_cancel]
... = (g.eval z' - g.eval z₀).abs * δ ^ n : by rw hz'z₀
... < _ : (mul_lt_mul_right (pow_pos hδ0 _)).2 (hδ _ hz'z₀),
lt_irrefl (f.eval z₀).abs $
calc (f.eval z₀).abs ≤ (f.eval z').abs : hz₀ _
... = (F.eval z' + (f.eval z' - F.eval z')).abs : by simp
... ≤ (F.eval z').abs + (f.eval z' - F.eval z').abs : complex.abs_add _ _
... < (f.eval z₀).abs - (g.eval z₀).abs * δ ^ n + (g.eval z₀).abs * δ ^ n :
add_lt_add_of_le_of_lt (by rw hF₂) hF₃
... = (f.eval z₀).abs : sub_add_cancel _ _
end complex
|
53e3cf18dc1fd50de45937dfdde8e7936f04779d | a9d0fb7b0e4f802bd3857b803e6c5c23d87fef91 | /library/init/meta/default.lean | 170483c4657bafb4da0a8aa28240321bc0de7210 | [
"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 | 796 | 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
-/
prelude
import init.meta.name init.meta.options init.meta.format init.meta.rb_map
import init.meta.level init.meta.expr init.meta.environment init.meta.attribute
import init.meta.tactic init.meta.contradiction_tactic init.meta.constructor_tactic
import init.meta.injection_tactic init.meta.relation_tactics init.meta.fun_info
import init.meta.congr_lemma init.meta.match_tactic init.meta.ac_tactics
import init.meta.backward init.meta.rewrite_tactic init.meta.unfold_tactic
import init.meta.mk_dec_eq_instance init.meta.mk_inhabited_instance
import init.meta.simp_tactic init.meta.defeq_simp_tactic init.meta.set_get_option_tactics
|
f05521624e508a013967ad08f37ca560e5f144ef | 947fa6c38e48771ae886239b4edce6db6e18d0fb | /src/analysis/special_functions/exp.lean | 16febaeed988ddb3b3f1163f18203358adf1504e | [
"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 | 15,137 | lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
-/
import analysis.complex.basic
import data.complex.exponential
import analysis.asymptotics.theta
/-!
# Complex and real exponential
In this file we prove continuity of `complex.exp` and `real.exp`. We also prove a few facts about
limits of `real.exp` at infinity.
## Tags
exp
-/
noncomputable theory
open finset filter metric asymptotics set function
open_locale classical topological_space
namespace complex
variables {z y x : ℝ}
lemma exp_bound_sq (x z : ℂ) (hz : ∥z∥ ≤ 1) :
∥exp (x + z) - exp x - z • exp x∥ ≤ ∥exp x∥ * ∥z∥ ^ 2 :=
calc ∥exp (x + z) - exp x - z * exp x∥
= ∥exp x * (exp z - 1 - z)∥ : by { congr, rw [exp_add], ring }
... = ∥exp x∥ * ∥exp z - 1 - z∥ : norm_mul _ _
... ≤ ∥exp x∥ * ∥z∥^2 : mul_le_mul_of_nonneg_left (abs_exp_sub_one_sub_id_le hz) (norm_nonneg _)
lemma locally_lipschitz_exp {r : ℝ} (hr_nonneg : 0 ≤ r) (hr_le : r ≤ 1) (x y : ℂ)
(hyx : ∥y - x∥ < r) :
∥exp y - exp x∥ ≤ (1 + r) * ∥exp x∥ * ∥y - x∥ :=
begin
have hy_eq : y = x + (y - x), by abel,
have hyx_sq_le : ∥y - x∥ ^ 2 ≤ r * ∥y - x∥,
{ rw pow_two,
exact mul_le_mul hyx.le le_rfl (norm_nonneg _) hr_nonneg, },
have h_sq : ∀ z, ∥z∥ ≤ 1 → ∥exp (x + z) - exp x∥ ≤ ∥z∥ * ∥exp x∥ + ∥exp x∥ * ∥z∥ ^ 2,
{ intros z hz,
have : ∥exp (x + z) - exp x - z • exp x∥ ≤ ∥exp x∥ * ∥z∥ ^ 2, from exp_bound_sq x z hz,
rw [← sub_le_iff_le_add', ← norm_smul z],
exact (norm_sub_norm_le _ _).trans this, },
calc ∥exp y - exp x∥ = ∥exp (x + (y - x)) - exp x∥ : by nth_rewrite 0 hy_eq
... ≤ ∥y - x∥ * ∥exp x∥ + ∥exp x∥ * ∥y - x∥ ^ 2 : h_sq (y - x) (hyx.le.trans hr_le)
... ≤ ∥y - x∥ * ∥exp x∥ + ∥exp x∥ * (r * ∥y - x∥) :
add_le_add_left (mul_le_mul le_rfl hyx_sq_le (sq_nonneg _) (norm_nonneg _)) _
... = (1 + r) * ∥exp x∥ * ∥y - x∥ : by ring,
end
@[continuity] lemma continuous_exp : continuous exp :=
continuous_iff_continuous_at.mpr $
λ x, continuous_at_of_locally_lipschitz zero_lt_one (2 * ∥exp x∥)
(locally_lipschitz_exp zero_le_one le_rfl x)
lemma continuous_on_exp {s : set ℂ} : continuous_on exp s :=
continuous_exp.continuous_on
end complex
section complex_continuous_exp_comp
variable {α : Type*}
open complex
lemma filter.tendsto.cexp {l : filter α} {f : α → ℂ} {z : ℂ} (hf : tendsto f l (𝓝 z)) :
tendsto (λ x, exp (f x)) l (𝓝 (exp z)) :=
(continuous_exp.tendsto _).comp hf
variables [topological_space α] {f : α → ℂ} {s : set α} {x : α}
lemma continuous_within_at.cexp (h : continuous_within_at f s x) :
continuous_within_at (λ y, exp (f y)) s x :=
h.cexp
lemma continuous_at.cexp (h : continuous_at f x) : continuous_at (λ y, exp (f y)) x :=
h.cexp
lemma continuous_on.cexp (h : continuous_on f s) : continuous_on (λ y, exp (f y)) s :=
λ x hx, (h x hx).cexp
lemma continuous.cexp (h : continuous f) : continuous (λ y, exp (f y)) :=
continuous_iff_continuous_at.2 $ λ x, h.continuous_at.cexp
end complex_continuous_exp_comp
namespace real
@[continuity] lemma continuous_exp : continuous exp :=
complex.continuous_re.comp complex.continuous_of_real.cexp
lemma continuous_on_exp {s : set ℝ} : continuous_on exp s :=
continuous_exp.continuous_on
end real
section real_continuous_exp_comp
variable {α : Type*}
open real
lemma filter.tendsto.exp {l : filter α} {f : α → ℝ} {z : ℝ} (hf : tendsto f l (𝓝 z)) :
tendsto (λ x, exp (f x)) l (𝓝 (exp z)) :=
(continuous_exp.tendsto _).comp hf
variables [topological_space α] {f : α → ℝ} {s : set α} {x : α}
lemma continuous_within_at.exp (h : continuous_within_at f s x) :
continuous_within_at (λ y, exp (f y)) s x :=
h.exp
lemma continuous_at.exp (h : continuous_at f x) : continuous_at (λ y, exp (f y)) x :=
h.exp
lemma continuous_on.exp (h : continuous_on f s) : continuous_on (λ y, exp (f y)) s :=
λ x hx, (h x hx).exp
lemma continuous.exp (h : continuous f) : continuous (λ y, exp (f y)) :=
continuous_iff_continuous_at.2 $ λ x, h.continuous_at.exp
end real_continuous_exp_comp
namespace real
variables {α : Type*} {x y z : ℝ} {l : filter α}
lemma exp_half (x : ℝ) : exp (x / 2) = sqrt (exp x) :=
by rw [eq_comm, sqrt_eq_iff_sq_eq, sq, ← exp_add, add_halves]; exact (exp_pos _).le
/-- The real exponential function tends to `+∞` at `+∞`. -/
lemma tendsto_exp_at_top : tendsto exp at_top at_top :=
begin
have A : tendsto (λx:ℝ, x + 1) at_top at_top :=
tendsto_at_top_add_const_right at_top 1 tendsto_id,
have B : ∀ᶠ x in at_top, x + 1 ≤ exp x :=
eventually_at_top.2 ⟨0, λx hx, add_one_le_exp x⟩,
exact tendsto_at_top_mono' at_top B A
end
/-- The real exponential function tends to `0` at `-∞` or, equivalently, `exp(-x)` tends to `0`
at `+∞` -/
lemma tendsto_exp_neg_at_top_nhds_0 : tendsto (λx, exp (-x)) at_top (𝓝 0) :=
(tendsto_inv_at_top_zero.comp tendsto_exp_at_top).congr (λx, (exp_neg x).symm)
/-- The real exponential function tends to `1` at `0`. -/
lemma tendsto_exp_nhds_0_nhds_1 : tendsto exp (𝓝 0) (𝓝 1) :=
by { convert continuous_exp.tendsto 0, simp }
lemma tendsto_exp_at_bot : tendsto exp at_bot (𝓝 0) :=
(tendsto_exp_neg_at_top_nhds_0.comp tendsto_neg_at_bot_at_top).congr $
λ x, congr_arg exp $ neg_neg x
lemma tendsto_exp_at_bot_nhds_within : tendsto exp at_bot (𝓝[>] 0) :=
tendsto_inf.2 ⟨tendsto_exp_at_bot, tendsto_principal.2 $ eventually_of_forall exp_pos⟩
@[simp] lemma is_bounded_under_ge_exp_comp (l : filter α) (f : α → ℝ) :
is_bounded_under (≥) l (λ x, exp (f x)) :=
is_bounded_under_of ⟨0, λ x, (exp_pos _).le⟩
@[simp] lemma is_bounded_under_le_exp_comp {f : α → ℝ} :
is_bounded_under (≤) l (λ x, exp (f x)) ↔ is_bounded_under (≤) l f :=
exp_monotone.is_bounded_under_le_comp tendsto_exp_at_top
/-- The function `exp(x)/x^n` tends to `+∞` at `+∞`, for any natural number `n` -/
lemma tendsto_exp_div_pow_at_top (n : ℕ) : tendsto (λx, exp x / x^n) at_top at_top :=
begin
refine (at_top_basis_Ioi.tendsto_iff (at_top_basis' 1)).2 (λ C hC₁, _),
have hC₀ : 0 < C, from zero_lt_one.trans_le hC₁,
have : 0 < (exp 1 * C)⁻¹ := inv_pos.2 (mul_pos (exp_pos _) hC₀),
obtain ⟨N, hN⟩ : ∃ N, ∀ k ≥ N, (↑k ^ n : ℝ) / exp 1 ^ k < (exp 1 * C)⁻¹ :=
eventually_at_top.1 ((tendsto_pow_const_div_const_pow_of_one_lt n
(one_lt_exp_iff.2 zero_lt_one)).eventually (gt_mem_nhds this)),
simp only [← exp_nat_mul, mul_one, div_lt_iff, exp_pos, ← div_eq_inv_mul] at hN,
refine ⟨N, trivial, λ x hx, _⟩, rw set.mem_Ioi at hx,
have hx₀ : 0 < x, from N.cast_nonneg.trans_lt hx,
rw [set.mem_Ici, le_div_iff (pow_pos hx₀ _), ← le_div_iff' hC₀],
calc x ^ n ≤ ⌈x⌉₊ ^ n : pow_le_pow_of_le_left hx₀.le (nat.le_ceil _) _
... ≤ exp ⌈x⌉₊ / (exp 1 * C) : (hN _ (nat.lt_ceil.2 hx).le).le
... ≤ exp (x + 1) / (exp 1 * C) : div_le_div_of_le (mul_pos (exp_pos _) hC₀).le
(exp_le_exp.2 $ (nat.ceil_lt_add_one hx₀.le).le)
... = exp x / C : by rw [add_comm, exp_add, mul_div_mul_left _ _ (exp_pos _).ne']
end
/-- The function `x^n * exp(-x)` tends to `0` at `+∞`, for any natural number `n`. -/
lemma tendsto_pow_mul_exp_neg_at_top_nhds_0 (n : ℕ) : tendsto (λx, x^n * exp (-x)) at_top (𝓝 0) :=
(tendsto_inv_at_top_zero.comp (tendsto_exp_div_pow_at_top n)).congr $ λx,
by rw [comp_app, inv_eq_one_div, div_div_eq_mul_div, one_mul, div_eq_mul_inv, exp_neg]
/-- The function `(b * exp x + c) / (x ^ n)` tends to `+∞` at `+∞`, for any natural number
`n` and any real numbers `b` and `c` such that `b` is positive. -/
lemma tendsto_mul_exp_add_div_pow_at_top (b c : ℝ) (n : ℕ) (hb : 0 < b) :
tendsto (λ x, (b * exp x + c) / x ^ n) at_top at_top :=
begin
rcases eq_or_ne n 0 with rfl | hn,
{ simp only [pow_zero, div_one],
exact (tendsto_exp_at_top.const_mul_at_top hb).at_top_add tendsto_const_nhds },
simp only [add_div, mul_div_assoc],
exact ((tendsto_exp_div_pow_at_top n).const_mul_at_top hb).at_top_add
(tendsto_const_nhds.div_at_top (tendsto_pow_at_top hn))
end
/-- The function `(x ^ n) / (b * exp x + c)` tends to `0` at `+∞`, for any natural number
`n` and any real numbers `b` and `c` such that `b` is nonzero. -/
lemma tendsto_div_pow_mul_exp_add_at_top (b c : ℝ) (n : ℕ) (hb : 0 ≠ b) :
tendsto (λ x, x ^ n / (b * exp x + c)) at_top (𝓝 0) :=
begin
have H : ∀ d e, 0 < d → tendsto (λ (x:ℝ), x^n / (d * (exp x) + e)) at_top (𝓝 0),
{ intros b' c' h,
convert (tendsto_mul_exp_add_div_pow_at_top b' c' n h).inv_tendsto_at_top ,
ext x,
simpa only [pi.inv_apply] using (inv_div _ _).symm },
cases lt_or_gt_of_ne hb,
{ exact H b c h },
{ convert (H (-b) (-c) (neg_pos.mpr h)).neg,
{ ext x,
field_simp,
rw [← neg_add (b * exp x) c, neg_div_neg_eq] },
{ exact neg_zero.symm } },
end
/-- `real.exp` as an order isomorphism between `ℝ` and `(0, +∞)`. -/
def exp_order_iso : ℝ ≃o Ioi (0 : ℝ) :=
strict_mono.order_iso_of_surjective _ (exp_strict_mono.cod_restrict exp_pos) $
(continuous_subtype_mk _ continuous_exp).surjective
(by simp only [tendsto_Ioi_at_top, subtype.coe_mk, tendsto_exp_at_top])
(by simp [tendsto_exp_at_bot_nhds_within])
@[simp] lemma coe_exp_order_iso_apply (x : ℝ) : (exp_order_iso x : ℝ) = exp x := rfl
@[simp] lemma coe_comp_exp_order_iso : coe ∘ exp_order_iso = exp := rfl
@[simp] lemma range_exp : range exp = Ioi 0 :=
by rw [← coe_comp_exp_order_iso, range_comp, exp_order_iso.range_eq, image_univ, subtype.range_coe]
@[simp] lemma map_exp_at_top : map exp at_top = at_top :=
by rw [← coe_comp_exp_order_iso, ← filter.map_map, order_iso.map_at_top, map_coe_Ioi_at_top]
@[simp] lemma comap_exp_at_top : comap exp at_top = at_top :=
by rw [← map_exp_at_top, comap_map exp_injective, map_exp_at_top]
@[simp] lemma tendsto_exp_comp_at_top {f : α → ℝ} :
tendsto (λ x, exp (f x)) l at_top ↔ tendsto f l at_top :=
by rw [← tendsto_comap_iff, comap_exp_at_top]
lemma tendsto_comp_exp_at_top {f : ℝ → α} :
tendsto (λ x, f (exp x)) at_top l ↔ tendsto f at_top l :=
by rw [← tendsto_map'_iff, map_exp_at_top]
@[simp] lemma map_exp_at_bot : map exp at_bot = 𝓝[>] 0 :=
by rw [← coe_comp_exp_order_iso, ← filter.map_map, exp_order_iso.map_at_bot, ← map_coe_Ioi_at_bot]
@[simp] lemma comap_exp_nhds_within_Ioi_zero : comap exp (𝓝[>] 0) = at_bot :=
by rw [← map_exp_at_bot, comap_map exp_injective]
lemma tendsto_comp_exp_at_bot {f : ℝ → α} :
tendsto (λ x, f (exp x)) at_bot l ↔ tendsto f (𝓝[>] 0) l :=
by rw [← map_exp_at_bot, tendsto_map'_iff]
@[simp] lemma comap_exp_nhds_zero : comap exp (𝓝 0) = at_bot :=
(comap_nhds_within_range exp 0).symm.trans $ by simp
@[simp] lemma tendsto_exp_comp_nhds_zero {f : α → ℝ} :
tendsto (λ x, exp (f x)) l (𝓝 0) ↔ tendsto f l at_bot :=
by rw [← tendsto_comap_iff, comap_exp_nhds_zero]
lemma is_o_pow_exp_at_top {n : ℕ} : (λ x, x^n) =o[at_top] real.exp :=
by simpa [is_o_iff_tendsto (λ x hx, ((exp_pos x).ne' hx).elim)]
using tendsto_div_pow_mul_exp_add_at_top 1 0 n zero_ne_one
@[simp] lemma is_O_exp_comp_exp_comp {f g : α → ℝ} :
(λ x, exp (f x)) =O[l] (λ x, exp (g x)) ↔ is_bounded_under (≤) l (f - g) :=
iff.trans (is_O_iff_is_bounded_under_le_div $ eventually_of_forall $ λ x, exp_ne_zero _) $
by simp only [norm_eq_abs, abs_exp, ← exp_sub, is_bounded_under_le_exp_comp, pi.sub_def]
@[simp] lemma is_Theta_exp_comp_exp_comp {f g : α → ℝ} :
(λ x, exp (f x)) =Θ[l] (λ x, exp (g x)) ↔ is_bounded_under (≤) l (λ x, |f x - g x|) :=
by simp only [is_bounded_under_le_abs, ← is_bounded_under_le_neg, neg_sub, is_Theta,
is_O_exp_comp_exp_comp, pi.sub_def]
@[simp] lemma is_o_exp_comp_exp_comp {f g : α → ℝ} :
(λ x, exp (f x)) =o[l] (λ x, exp (g x)) ↔ tendsto (λ x, g x - f x) l at_top :=
by simp only [is_o_iff_tendsto, exp_ne_zero, ← exp_sub, ← tendsto_neg_at_top_iff, false_implies_iff,
implies_true_iff, tendsto_exp_comp_nhds_zero, neg_sub]
@[simp] lemma is_o_one_exp_comp {f : α → ℝ} :
(λ x, 1 : α → ℝ) =o[l] (λ x, exp (f x)) ↔ tendsto f l at_top :=
by simp only [← exp_zero, is_o_exp_comp_exp_comp, sub_zero]
/-- `real.exp (f x)` is bounded away from zero along a filter if and only if this filter is bounded
from below under `f`. -/
@[simp] lemma is_O_one_exp_comp {f : α → ℝ} :
(λ x, 1 : α → ℝ) =O[l] (λ x, exp (f x)) ↔ is_bounded_under (≥) l f :=
by simp only [← exp_zero, is_O_exp_comp_exp_comp, pi.sub_def, zero_sub, is_bounded_under_le_neg]
/-- `real.exp (f x)` is bounded away from zero along a filter if and only if this filter is bounded
from below under `f`. -/
lemma is_O_exp_comp_one {f : α → ℝ} :
(λ x, exp (f x)) =O[l] (λ x, 1 : α → ℝ) ↔ is_bounded_under (≤) l f :=
by simp only [is_O_one_iff, norm_eq_abs, abs_exp, is_bounded_under_le_exp_comp]
/-- `real.exp (f x)` is bounded away from zero and infinity along a filter `l` if and only if
`|f x|` is bounded from above along this filter. -/
@[simp] lemma is_Theta_exp_comp_one {f : α → ℝ} :
(λ x, exp (f x)) =Θ[l] (λ x, 1 : α → ℝ) ↔ is_bounded_under (≤) l (λ x, |f x|) :=
by simp only [← exp_zero, is_Theta_exp_comp_exp_comp, sub_zero]
end real
namespace complex
lemma comap_exp_comap_abs_at_top : comap exp (comap abs at_top) = comap re at_top :=
calc comap exp (comap abs at_top) = comap re (comap real.exp at_top) :
by simp only [comap_comap, (∘), abs_exp]
... = comap re at_top : by rw [real.comap_exp_at_top]
lemma comap_exp_nhds_zero : comap exp (𝓝 0) = comap re at_bot :=
calc comap exp (𝓝 0) = comap re (comap real.exp (𝓝 0)) :
by simp only [comap_comap, ← comap_abs_nhds_zero, (∘), abs_exp]
... = comap re at_bot : by rw [real.comap_exp_nhds_zero]
lemma comap_exp_nhds_within_zero : comap exp (𝓝[≠] 0) = comap re at_bot :=
have exp ⁻¹' {0}ᶜ = univ, from eq_univ_of_forall exp_ne_zero,
by simp [nhds_within, comap_exp_nhds_zero, this]
lemma tendsto_exp_nhds_zero_iff {α : Type*} {l : filter α} {f : α → ℂ} :
tendsto (λ x, exp (f x)) l (𝓝 0) ↔ tendsto (λ x, re (f x)) l at_bot :=
by rw [← tendsto_comap_iff, comap_exp_nhds_zero, tendsto_comap_iff]
/-- `complex.abs (complex.exp z) → ∞` as `complex.re z → ∞`. TODO: use `bornology.cobounded`. -/
lemma tendsto_exp_comap_re_at_top : tendsto exp (comap re at_top) (comap abs at_top) :=
comap_exp_comap_abs_at_top ▸ tendsto_comap
/-- `complex.exp z → 0` as `complex.re z → -∞`.-/
lemma tendsto_exp_comap_re_at_bot : tendsto exp (comap re at_bot) (𝓝 0) :=
comap_exp_nhds_zero ▸ tendsto_comap
lemma tendsto_exp_comap_re_at_bot_nhds_within : tendsto exp (comap re at_bot) (𝓝[≠] 0) :=
comap_exp_nhds_within_zero ▸ tendsto_comap
end complex
|
251d1a784ca79fe7bced38d10f4d55a0b5840084 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/geometry/manifold/cont_mdiff_mfderiv.lean | 89abe55046496ddb3206a8e702f9273ea14ba691 | [
"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 | 33,650 | lean | /-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Floris van Doorn
-/
import geometry.manifold.mfderiv
import geometry.manifold.cont_mdiff_map
/-!
### Interactions between differentiability, smoothness and manifold derivatives
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
We give the relation between `mdifferentiable`, `cont_mdiff`, `mfderiv`, `tangent_map`
and related notions.
## Main statements
* `cont_mdiff_on.cont_mdiff_on_tangent_map_within` states that the bundled derivative
of a `Cⁿ` function in a domain is `Cᵐ` when `m + 1 ≤ n`.
* `cont_mdiff.cont_mdiff_tangent_map` states that the bundled derivative
of a `Cⁿ` function is `Cᵐ` when `m + 1 ≤ n`.
-/
open set function filter charted_space smooth_manifold_with_corners bundle
open_locale topology manifold bundle
/-! ### Definition of smooth functions between manifolds -/
variables {𝕜 : Type*} [nontrivially_normed_field 𝕜]
-- declare a smooth manifold `M` over the pair `(E, H)`.
{E : Type*} [normed_add_comm_group E] [normed_space 𝕜 E]
{H : Type*} [topological_space H] {I : model_with_corners 𝕜 E H}
{M : Type*} [topological_space M] [charted_space H M] [Is : smooth_manifold_with_corners I M]
-- declare a smooth manifold `M'` over the pair `(E', H')`.
{E' : Type*} [normed_add_comm_group E'] [normed_space 𝕜 E']
{H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}
{M' : Type*} [topological_space M'] [charted_space H' M'] [I's : smooth_manifold_with_corners I' M']
-- declare a smooth manifold `N` over the pair `(F, G)`.
{F : Type*} [normed_add_comm_group F] [normed_space 𝕜 F]
{G : Type*} [topological_space G] {J : model_with_corners 𝕜 F G}
{N : Type*} [topological_space N] [charted_space G N] [Js : smooth_manifold_with_corners J N]
-- declare a smooth manifold `N'` over the pair `(F', G')`.
{F' : Type*} [normed_add_comm_group F'] [normed_space 𝕜 F']
{G' : Type*} [topological_space G'] {J' : model_with_corners 𝕜 F' G'}
{N' : Type*} [topological_space N'] [charted_space G' N'] [J's : smooth_manifold_with_corners J' N']
-- declare some additional normed spaces, used for fibers of vector bundles
{F₁ : Type*} [normed_add_comm_group F₁] [normed_space 𝕜 F₁]
{F₂ : Type*} [normed_add_comm_group F₂] [normed_space 𝕜 F₂]
-- declare functions, sets, points and smoothness indices
{f f₁ : M → M'} {s s₁ t : set M} {x : M} {m n : ℕ∞}
/-! ### Deducing differentiability from smoothness -/
lemma cont_mdiff_within_at.mdifferentiable_within_at
(hf : cont_mdiff_within_at I I' n f s x) (hn : 1 ≤ n) :
mdifferentiable_within_at I I' f s x :=
begin
suffices h : mdifferentiable_within_at I I' f (s ∩ (f ⁻¹' (ext_chart_at I' (f x)).source)) x,
{ rwa mdifferentiable_within_at_inter' at h,
apply (hf.1).preimage_mem_nhds_within,
exact ext_chart_at_source_mem_nhds I' (f x) },
rw mdifferentiable_within_at_iff,
exact ⟨hf.1.mono (inter_subset_left _ _),
(hf.2.differentiable_within_at hn).mono (by mfld_set_tac)⟩,
end
lemma cont_mdiff_at.mdifferentiable_at (hf : cont_mdiff_at I I' n f x) (hn : 1 ≤ n) :
mdifferentiable_at I I' f x :=
mdifferentiable_within_at_univ.1 $ cont_mdiff_within_at.mdifferentiable_within_at hf hn
lemma cont_mdiff_on.mdifferentiable_on (hf : cont_mdiff_on I I' n f s) (hn : 1 ≤ n) :
mdifferentiable_on I I' f s :=
λ x hx, (hf x hx).mdifferentiable_within_at hn
lemma cont_mdiff.mdifferentiable (hf : cont_mdiff I I' n f) (hn : 1 ≤ n) :
mdifferentiable I I' f :=
λ x, (hf x).mdifferentiable_at hn
lemma smooth_within_at.mdifferentiable_within_at
(hf : smooth_within_at I I' f s x) : mdifferentiable_within_at I I' f s x :=
hf.mdifferentiable_within_at le_top
lemma smooth_at.mdifferentiable_at (hf : smooth_at I I' f x) : mdifferentiable_at I I' f x :=
hf.mdifferentiable_at le_top
lemma smooth_on.mdifferentiable_on (hf : smooth_on I I' f s) : mdifferentiable_on I I' f s :=
hf.mdifferentiable_on le_top
lemma smooth.mdifferentiable (hf : smooth I I' f) : mdifferentiable I I' f :=
cont_mdiff.mdifferentiable hf le_top
lemma smooth.mdifferentiable_at (hf : smooth I I' f) : mdifferentiable_at I I' f x :=
hf.mdifferentiable x
lemma smooth.mdifferentiable_within_at (hf : smooth I I' f) :
mdifferentiable_within_at I I' f s x :=
hf.mdifferentiable_at.mdifferentiable_within_at
/-! ### The derivative of a smooth function is smooth -/
section mfderiv
include Is I's Js
/-- The function that sends `x` to the `y`-derivative of `f(x,y)` at `g(x)` is `C^m` at `x₀`,
where the derivative is taken as a continuous linear map.
We have to assume that `f` is `C^n` at `(x₀, g(x₀))` for `n ≥ m + 1` and `g` is `C^m` at `x₀`.
We have to insert a coordinate change from `x₀` to `x` to make the derivative sensible.
This result is used to show that maps into the 1-jet bundle and cotangent bundle are smooth.
`cont_mdiff_at.mfderiv_id` and `cont_mdiff_at.mfderiv_const` are special cases of this.
This result should be generalized to a `cont_mdiff_within_at` for `mfderiv_within`.
If we do that, we can deduce `cont_mdiff_on.cont_mdiff_on_tangent_map_within` from this.
-/
theorem cont_mdiff_at.mfderiv {x₀ : N} (f : N → M → M') (g : N → M)
(hf : cont_mdiff_at (J.prod I) I' n (function.uncurry f) (x₀, g x₀))
(hg : cont_mdiff_at J I m g x₀) (hmn : m + 1 ≤ n) :
cont_mdiff_at J 𝓘(𝕜, E →L[𝕜] E') m
(in_tangent_coordinates I I' g (λ x, f x (g x)) (λ x, mfderiv I I' (f x) (g x)) x₀) x₀ :=
begin
have h4f : continuous_at (λ x, f x (g x)) x₀,
{ apply continuous_at.comp (by apply hf.continuous_at) (continuous_at_id.prod hg.continuous_at) },
have h4f := h4f.preimage_mem_nhds (ext_chart_at_source_mem_nhds I' (f x₀ (g x₀))),
have h3f := cont_mdiff_at_iff_cont_mdiff_at_nhds.mp (hf.of_le $ (self_le_add_left 1 m).trans hmn),
have h2f : ∀ᶠ x₂ in 𝓝 x₀, cont_mdiff_at I I' 1 (f x₂) (g x₂),
{ refine ((continuous_at_id.prod hg.continuous_at).tendsto.eventually h3f).mono (λ x hx, _),
exact hx.comp (g x) (cont_mdiff_at_const.prod_mk cont_mdiff_at_id) },
have h2g := hg.continuous_at.preimage_mem_nhds (ext_chart_at_source_mem_nhds I (g x₀)),
have : cont_diff_within_at 𝕜 m (λ x, fderiv_within 𝕜
(ext_chart_at I' (f x₀ (g x₀)) ∘ f ((ext_chart_at J x₀).symm x) ∘ (ext_chart_at I (g x₀)).symm)
(range I) (ext_chart_at I (g x₀) (g ((ext_chart_at J x₀).symm x))))
(range J) (ext_chart_at J x₀ x₀),
{ rw [cont_mdiff_at_iff] at hf hg,
simp_rw [function.comp, uncurry, ext_chart_at_prod, local_equiv.prod_coe_symm,
model_with_corners.range_prod] at hf ⊢,
refine cont_diff_within_at.fderiv_within _ hg.2 I.unique_diff hmn (mem_range_self _) _,
{ simp_rw [ext_chart_at_to_inv], exact hf.2 },
{ rw [← image_subset_iff],
rintros _ ⟨x, hx, rfl⟩,
exact mem_range_self _ } },
have : cont_mdiff_at J 𝓘(𝕜, E →L[𝕜] E') m
(λ x, fderiv_within 𝕜 (ext_chart_at I' (f x₀ (g x₀)) ∘ f x ∘ (ext_chart_at I (g x₀)).symm)
(range I) (ext_chart_at I (g x₀) (g x))) x₀,
{ simp_rw [cont_mdiff_at_iff_source_of_mem_source (mem_chart_source G x₀),
cont_mdiff_within_at_iff_cont_diff_within_at, function.comp],
exact this },
have : cont_mdiff_at J 𝓘(𝕜, E →L[𝕜] E') m
(λ x, fderiv_within 𝕜 (ext_chart_at I' (f x₀ (g x₀)) ∘ (ext_chart_at I' (f x (g x))).symm ∘
written_in_ext_chart_at I I' (g x) (f x) ∘ ext_chart_at I (g x) ∘
(ext_chart_at I (g x₀)).symm) (range I) (ext_chart_at I (g x₀) (g x))) x₀,
{ refine this.congr_of_eventually_eq _,
filter_upwards [h2g, h2f],
intros x₂ hx₂ h2x₂,
have : ∀ x ∈ (ext_chart_at I (g x₀)).symm ⁻¹' (ext_chart_at I (g x₂)).source ∩
(ext_chart_at I (g x₀)).symm ⁻¹' (f x₂ ⁻¹' (ext_chart_at I' (f x₂ (g x₂))).source),
(ext_chart_at I' (f x₀ (g x₀)) ∘ (ext_chart_at I' (f x₂ (g x₂))).symm ∘
written_in_ext_chart_at I I' (g x₂) (f x₂) ∘ ext_chart_at I (g x₂) ∘
(ext_chart_at I (g x₀)).symm) x =
ext_chart_at I' (f x₀ (g x₀)) (f x₂ ((ext_chart_at I (g x₀)).symm x)),
{ rintro x ⟨hx, h2x⟩,
simp_rw [written_in_ext_chart_at, function.comp_apply],
rw [(ext_chart_at I (g x₂)).left_inv hx, (ext_chart_at I' (f x₂ (g x₂))).left_inv h2x] },
refine filter.eventually_eq.fderiv_within_eq_nhds _,
refine eventually_of_mem (inter_mem _ _) this,
{ exact ext_chart_at_preimage_mem_nhds' _ _ hx₂ (ext_chart_at_source_mem_nhds I (g x₂)) },
refine ext_chart_at_preimage_mem_nhds' _ _ hx₂ _,
exact (h2x₂.continuous_at).preimage_mem_nhds (ext_chart_at_source_mem_nhds _ _) },
/- The conclusion is equal to the following, when unfolding coord_change of
`tangent_bundle_core` -/
have : cont_mdiff_at J 𝓘(𝕜, E →L[𝕜] E') m
(λ x, (fderiv_within 𝕜 (ext_chart_at I' (f x₀ (g x₀)) ∘ (ext_chart_at I' (f x (g x))).symm)
(range I') (ext_chart_at I' (f x (g x)) (f x (g x)))).comp
((mfderiv I I' (f x) (g x)).comp (fderiv_within 𝕜 (ext_chart_at I (g x) ∘
(ext_chart_at I (g x₀)).symm) (range I) (ext_chart_at I (g x₀) (g x))))) x₀,
{ refine this.congr_of_eventually_eq _,
filter_upwards [h2g, h2f, h4f],
intros x₂ hx₂ h2x₂ h3x₂,
symmetry,
rw [(h2x₂.mdifferentiable_at le_rfl).mfderiv],
have hI := (cont_diff_within_at_ext_coord_change I (g x₂) (g x₀) $
local_equiv.mem_symm_trans_source _ hx₂ $ mem_ext_chart_source I (g x₂))
.differentiable_within_at le_top,
have hI' := (cont_diff_within_at_ext_coord_change I' (f x₀ (g x₀)) (f x₂ (g x₂)) $
local_equiv.mem_symm_trans_source _
(mem_ext_chart_source I' (f x₂ (g x₂))) h3x₂).differentiable_within_at le_top,
have h3f := (h2x₂.mdifferentiable_at le_rfl).2,
refine fderiv_within.comp₃ _ hI' h3f hI _ _ _ _ (I.unique_diff _ $ mem_range_self _),
{ exact λ x _, mem_range_self _ },
{ exact λ x _, mem_range_self _ },
{ simp_rw [written_in_ext_chart_at, function.comp_apply,
(ext_chart_at I (g x₂)).left_inv (mem_ext_chart_source I (g x₂))] },
{ simp_rw [function.comp_apply, (ext_chart_at I (g x₀)).left_inv hx₂] } },
refine this.congr_of_eventually_eq _,
filter_upwards [h2g, h4f] with x hx h2x,
rw [in_tangent_coordinates_eq],
{ refl },
{ rwa [ext_chart_at_source] at hx },
{ rwa [ext_chart_at_source] at h2x },
end
omit Js
/-- The derivative `D_yf(y)` is `C^m` at `x₀`, where the derivative is taken as a continuous
linear map. We have to assume that `f` is `C^n` at `x₀` for some `n ≥ m + 1`.
We have to insert a coordinate change from `x₀` to `x` to make the derivative sensible.
This is a special case of `cont_mdiff_at.mfderiv` where `f` does not contain any parameters and
`g = id`.
-/
lemma cont_mdiff_at.mfderiv_const {x₀ : M} {f : M → M'}
(hf : cont_mdiff_at I I' n f x₀) (hmn : m + 1 ≤ n) :
cont_mdiff_at I 𝓘(𝕜, E →L[𝕜] E') m (in_tangent_coordinates I I' id f (mfderiv I I' f) x₀) x₀ :=
begin
have : cont_mdiff_at (I.prod I) I' n (λ x : M × M, f x.2) (x₀, x₀) :=
cont_mdiff_at.comp (x₀, x₀) hf cont_mdiff_at_snd,
exact this.mfderiv (λ x, f) id cont_mdiff_at_id hmn,
end
include Js
/-- The function that sends `x` to the `y`-derivative of `f(x,y)` at `g(x)` applied to `g₂(x)` is
`C^n` at `x₀`, where the derivative is taken as a continuous linear map.
We have to assume that `f` is `C^(n+1)` at `(x₀, g(x₀))` and `g` is `C^n` at `x₀`.
We have to insert a coordinate change from `x₀` to `g₁(x)` to make the derivative sensible.
This is similar to `cont_mdiff_at.mfderiv`, but where the continuous linear map is applied to a
(variable) vector.
-/
lemma cont_mdiff_at.mfderiv_apply {x₀ : N'} (f : N → M → M') (g : N → M) (g₁ : N' → N)
(g₂ : N' → E)
(hf : cont_mdiff_at (J.prod I) I' n (function.uncurry f) (g₁ x₀, g (g₁ x₀)))
(hg : cont_mdiff_at J I m g (g₁ x₀))
(hg₁ : cont_mdiff_at J' J m g₁ x₀)
(hg₂ : cont_mdiff_at J' 𝓘(𝕜, E) m g₂ x₀) (hmn : m + 1 ≤ n) :
cont_mdiff_at J' 𝓘(𝕜, E') m
(λ x, in_tangent_coordinates I I' g (λ x, f x (g x)) (λ x, mfderiv I I' (f x) (g x))
(g₁ x₀) (g₁ x) (g₂ x))
x₀ :=
((hf.mfderiv f g hg hmn).comp_of_eq hg₁ rfl).clm_apply hg₂
end mfderiv
/-! ### The tangent map of a smooth function is smooth -/
section tangent_map
/-- If a function is `C^n` with `1 ≤ n` on a domain with unique derivatives, then its bundled
derivative is continuous. In this auxiliary lemma, we prove this fact when the source and target
space are model spaces in models with corners. The general fact is proved in
`cont_mdiff_on.continuous_on_tangent_map_within`-/
lemma cont_mdiff_on.continuous_on_tangent_map_within_aux
{f : H → H'} {s : set H}
(hf : cont_mdiff_on I I' n f s) (hn : 1 ≤ n) (hs : unique_mdiff_on I s) :
continuous_on (tangent_map_within I I' f s) (π E (tangent_space I) ⁻¹' s) :=
begin
suffices h : continuous_on (λ (p : H × E), (f p.fst,
(fderiv_within 𝕜 (written_in_ext_chart_at I I' p.fst f) (I.symm ⁻¹' s ∩ range I)
((ext_chart_at I p.fst) p.fst) : E →L[𝕜] E') p.snd)) (prod.fst ⁻¹' s),
{ have A := (tangent_bundle_model_space_homeomorph H I).continuous,
rw continuous_iff_continuous_on_univ at A,
have B := ((tangent_bundle_model_space_homeomorph H' I').symm.continuous.comp_continuous_on h)
.comp' A,
have : (univ ∩ ⇑(tangent_bundle_model_space_homeomorph H I) ⁻¹' (prod.fst ⁻¹' s)) =
π E (tangent_space I) ⁻¹' s,
by { ext ⟨x, v⟩, simp only with mfld_simps },
rw this at B,
apply B.congr,
rintros ⟨x, v⟩ hx,
dsimp [tangent_map_within],
ext, { refl },
simp only with mfld_simps,
apply congr_fun,
apply congr_arg,
rw mdifferentiable_within_at.mfderiv_within (hf.mdifferentiable_on hn x hx),
refl },
suffices h : continuous_on (λ (p : H × E), (fderiv_within 𝕜 (I' ∘ f ∘ I.symm)
(I.symm ⁻¹' s ∩ range I) (I p.fst) : E →L[𝕜] E') p.snd) (prod.fst ⁻¹' s),
{ dsimp [written_in_ext_chart_at, ext_chart_at],
apply continuous_on.prod
(continuous_on.comp hf.continuous_on continuous_fst.continuous_on (subset.refl _)),
apply h.congr,
assume p hp,
refl },
suffices h : continuous_on (fderiv_within 𝕜 (I' ∘ f ∘ I.symm)
(I.symm ⁻¹' s ∩ range I)) (I '' s),
{ have C := continuous_on.comp h I.continuous_to_fun.continuous_on (subset.refl _),
have A : continuous (λq : (E →L[𝕜] E') × E, q.1 q.2) :=
is_bounded_bilinear_map_apply.continuous,
have B : continuous_on (λp : H × E,
(fderiv_within 𝕜 (I' ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I)
(I p.1), p.2)) (prod.fst ⁻¹' s),
{ apply continuous_on.prod _ continuous_snd.continuous_on,
refine (continuous_on.comp C continuous_fst.continuous_on _ : _),
exact preimage_mono (subset_preimage_image _ _) },
exact A.comp_continuous_on B },
rw cont_mdiff_on_iff at hf,
let x : H := I.symm (0 : E),
let y : H' := I'.symm (0 : E'),
have A := hf.2 x y,
simp only [I.image_eq, inter_comm] with mfld_simps at A ⊢,
apply A.continuous_on_fderiv_within _ hn,
convert hs.unique_diff_on_target_inter x using 1,
simp only [inter_comm] with mfld_simps
end
/-- If a function is `C^n` on a domain with unique derivatives, then its bundled derivative is
`C^m` when `m+1 ≤ n`. In this auxiliary lemma, we prove this fact when the source and target space
are model spaces in models with corners. The general fact is proved in
`cont_mdiff_on.cont_mdiff_on_tangent_map_within` -/
lemma cont_mdiff_on.cont_mdiff_on_tangent_map_within_aux
{f : H → H'} {s : set H}
(hf : cont_mdiff_on I I' n f s) (hmn : m + 1 ≤ n) (hs : unique_mdiff_on I s) :
cont_mdiff_on I.tangent I'.tangent m (tangent_map_within I I' f s)
(π E (tangent_space I) ⁻¹' s) :=
begin
have m_le_n : m ≤ n,
{ apply le_trans _ hmn,
have : m + 0 ≤ m + 1 := add_le_add_left (zero_le _) _,
simpa only [add_zero] using this },
have one_le_n : 1 ≤ n,
{ apply le_trans _ hmn,
change 0 + 1 ≤ m + 1,
exact add_le_add_right (zero_le _) _ },
have U': unique_diff_on 𝕜 (range I ∩ I.symm ⁻¹' s),
{ assume y hy,
simpa only [unique_mdiff_on, unique_mdiff_within_at, hy.1, inter_comm] with mfld_simps
using hs (I.symm y) hy.2 },
rw cont_mdiff_on_iff,
refine ⟨hf.continuous_on_tangent_map_within_aux one_le_n hs, λp q, _⟩,
have A : range I ×ˢ univ ∩
((total_space.to_prod H E).symm ∘ λ (p : E × E), ((I.symm) p.fst, p.snd)) ⁻¹'
(π E (tangent_space I) ⁻¹' s)
= (range I ∩ I.symm ⁻¹' s) ×ˢ univ,
by { ext ⟨x, v⟩, simp only with mfld_simps, },
suffices h : cont_diff_on 𝕜 m (((λ (p : H' × E'), (I' p.fst, p.snd)) ∘
(total_space.to_prod H' E')) ∘ tangent_map_within I I' f s ∘
((total_space.to_prod H E).symm) ∘ λ (p : E × E), (I.symm p.fst, p.snd))
((range ⇑I ∩ ⇑(I.symm) ⁻¹' s) ×ˢ univ),
by simpa [A] using h,
change cont_diff_on 𝕜 m (λ (p : E × E),
((I' (f (I.symm p.fst)), ((mfderiv_within I I' f s (I.symm p.fst)) : E → E') p.snd) : E' × E'))
((range I ∩ I.symm ⁻¹' s) ×ˢ univ),
-- check that all bits in this formula are `C^n`
have hf' := cont_mdiff_on_iff.1 hf,
have A : cont_diff_on 𝕜 m (I' ∘ f ∘ I.symm) (range I ∩ I.symm ⁻¹' s) :=
by simpa only with mfld_simps using (hf'.2 (I.symm 0) (I'.symm 0)).of_le m_le_n,
have B : cont_diff_on 𝕜 m ((I' ∘ f ∘ I.symm) ∘ prod.fst)
((range I ∩ I.symm ⁻¹' s) ×ˢ univ) :=
A.comp (cont_diff_fst.cont_diff_on) (prod_subset_preimage_fst _ _),
suffices C : cont_diff_on 𝕜 m (λ (p : E × E),
((fderiv_within 𝕜 (I' ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I) p.1 : _) p.2))
((range I ∩ I.symm ⁻¹' s) ×ˢ univ),
{ apply cont_diff_on.prod B _,
apply C.congr (λp hp, _),
simp only with mfld_simps at hp,
simp only [mfderiv_within, hf.mdifferentiable_on one_le_n _ hp.2, hp.1, if_pos]
with mfld_simps },
have D : cont_diff_on 𝕜 m (λ x,
(fderiv_within 𝕜 (I' ∘ f ∘ I.symm) (I.symm ⁻¹' s ∩ range I) x))
(range I ∩ I.symm ⁻¹' s),
{ have : cont_diff_on 𝕜 n (I' ∘ f ∘ I.symm) (range I ∩ I.symm ⁻¹' s) :=
by simpa only with mfld_simps using (hf'.2 (I.symm 0) (I'.symm 0)),
simpa only [inter_comm] using this.fderiv_within U' hmn },
have := D.comp (cont_diff_fst.cont_diff_on) (prod_subset_preimage_fst _ _),
have := cont_diff_on.prod this (cont_diff_snd.cont_diff_on),
exact is_bounded_bilinear_map_apply.cont_diff.comp_cont_diff_on this,
end
include Is I's
/-- If a function is `C^n` on a domain with unique derivatives, then its bundled derivative
is `C^m` when `m+1 ≤ n`. -/
theorem cont_mdiff_on.cont_mdiff_on_tangent_map_within
(hf : cont_mdiff_on I I' n f s) (hmn : m + 1 ≤ n) (hs : unique_mdiff_on I s) :
cont_mdiff_on I.tangent I'.tangent m (tangent_map_within I I' f s)
(π E (tangent_space I) ⁻¹' s) :=
begin
/- The strategy of the proof is to avoid unfolding the definitions, and reduce by functoriality
to the case of functions on the model spaces, where we have already proved the result.
Let `l` and `r` be the charts to the left and to the right, so that we have
```
l^{-1} f r
H --------> M ---> M' ---> H'
```
Then the tangent map `T(r ∘ f ∘ l)` is smooth by a previous result. Consider the composition
```
Tl T(r ∘ f ∘ l^{-1}) Tr^{-1}
TM -----> TH -------------------> TH' ---------> TM'
```
where `Tr^{-1}` and `Tl` are the tangent maps of `r^{-1}` and `l`. Writing `Tl` and `Tr^{-1}` as
composition of charts (called `Dl` and `il` for `l` and `Dr` and `ir` in the proof below), it
follows that they are smooth. The composition of all these maps is `Tf`, and is therefore smooth
as a composition of smooth maps.
-/
have m_le_n : m ≤ n,
{ apply le_trans _ hmn,
have : m + 0 ≤ m + 1 := add_le_add_left (zero_le _) _,
simpa only [add_zero] },
have one_le_n : 1 ≤ n,
{ apply le_trans _ hmn,
change 0 + 1 ≤ m + 1,
exact add_le_add_right (zero_le _) _ },
/- First step: local reduction on the space, to a set `s'` which is contained in chart domains. -/
refine cont_mdiff_on_of_locally_cont_mdiff_on (λp hp, _),
have hf' := cont_mdiff_on_iff.1 hf,
simp only with mfld_simps at hp,
let l := chart_at H p.proj,
set Dl := chart_at (model_prod H E) p with hDl,
let r := chart_at H' (f p.proj),
let Dr := chart_at (model_prod H' E') (tangent_map_within I I' f s p),
let il := chart_at (model_prod H E) (tangent_map I I l p),
let ir := chart_at (model_prod H' E') (tangent_map I I' (r ∘ f) p),
let s' := f ⁻¹' r.source ∩ s ∩ l.source,
let s'_lift := π E (tangent_space I) ⁻¹' s',
let s'l := l.target ∩ l.symm ⁻¹' s',
let s'l_lift := π E (tangent_space I) ⁻¹' s'l,
rcases continuous_on_iff'.1 hf'.1 r.source r.open_source with ⟨o, o_open, ho⟩,
suffices h : cont_mdiff_on I.tangent I'.tangent m (tangent_map_within I I' f s) s'_lift,
{ refine ⟨π E (tangent_space I) ⁻¹' (o ∩ l.source), _, _, _⟩,
show is_open (π E (tangent_space I) ⁻¹' (o ∩ l.source)), from
(is_open.inter o_open l.open_source).preimage (continuous_proj E _) ,
show p ∈ π E (tangent_space I) ⁻¹' (o ∩ l.source),
{ simp,
have : p.proj ∈ f ⁻¹' r.source ∩ s, by simp [hp],
rw ho at this,
exact this.1 },
{ have : π E (tangent_space I) ⁻¹' s ∩ π E (tangent_space I) ⁻¹' (o ∩ l.source) = s'_lift,
{ dsimp only [s'_lift, s'], rw [ho], mfld_set_tac },
rw this,
exact h } },
/- Second step: check that all functions are smooth, and use the chain rule to write the bundled
derivative as a composition of a function between model spaces and of charts.
Convention: statements about the differentiability of `a ∘ b ∘ c` are named `diff_abc`. Statements
about differentiability in the bundle have a `_lift` suffix. -/
have U' : unique_mdiff_on I s',
{ apply unique_mdiff_on.inter _ l.open_source,
rw [ho, inter_comm],
exact hs.inter o_open },
have U'l : unique_mdiff_on I s'l :=
U'.unique_mdiff_on_preimage (mdifferentiable_chart _ _),
have diff_f : cont_mdiff_on I I' n f s' :=
hf.mono (by mfld_set_tac),
have diff_r : cont_mdiff_on I' I' n r r.source :=
cont_mdiff_on_chart,
have diff_rf : cont_mdiff_on I I' n (r ∘ f) s',
{ apply cont_mdiff_on.comp diff_r diff_f (λx hx, _),
simp only [s'] with mfld_simps at hx, simp only [hx] with mfld_simps },
have diff_l : cont_mdiff_on I I n l.symm s'l,
{ have A : cont_mdiff_on I I n l.symm l.target :=
cont_mdiff_on_chart_symm,
exact A.mono (by mfld_set_tac) },
have diff_rfl : cont_mdiff_on I I' n (r ∘ f ∘ l.symm) s'l,
{ apply cont_mdiff_on.comp diff_rf diff_l,
mfld_set_tac },
have diff_rfl_lift : cont_mdiff_on I.tangent I'.tangent m
(tangent_map_within I I' (r ∘ f ∘ l.symm) s'l) s'l_lift :=
diff_rfl.cont_mdiff_on_tangent_map_within_aux hmn U'l,
have diff_irrfl_lift : cont_mdiff_on I.tangent I'.tangent m
(ir ∘ (tangent_map_within I I' (r ∘ f ∘ l.symm) s'l)) s'l_lift,
{ have A : cont_mdiff_on I'.tangent I'.tangent m ir ir.source := cont_mdiff_on_chart,
exact cont_mdiff_on.comp A diff_rfl_lift (λp hp, by simp only [ir] with mfld_simps) },
have diff_Drirrfl_lift : cont_mdiff_on I.tangent I'.tangent m
(Dr.symm ∘ (ir ∘ (tangent_map_within I I' (r ∘ f ∘ l.symm) s'l))) s'l_lift,
{ have A : cont_mdiff_on I'.tangent I'.tangent m Dr.symm Dr.target :=
cont_mdiff_on_chart_symm,
apply cont_mdiff_on.comp A diff_irrfl_lift (λp hp, _),
simp only [s'l_lift] with mfld_simps at hp,
simp only [ir, hp] with mfld_simps },
-- conclusion of this step: the composition of all the maps above is smooth
have diff_DrirrflilDl : cont_mdiff_on I.tangent I'.tangent m
(Dr.symm ∘ (ir ∘ (tangent_map_within I I' (r ∘ f ∘ l.symm) s'l)) ∘
(il.symm ∘ Dl)) s'_lift,
{ have A : cont_mdiff_on I.tangent I.tangent m Dl Dl.source := cont_mdiff_on_chart,
have A' : cont_mdiff_on I.tangent I.tangent m Dl s'_lift,
{ apply A.mono (λp hp, _),
simp only [s'_lift] with mfld_simps at hp,
simp only [Dl, hp] with mfld_simps },
have B : cont_mdiff_on I.tangent I.tangent m il.symm il.target :=
cont_mdiff_on_chart_symm,
have C : cont_mdiff_on I.tangent I.tangent m (il.symm ∘ Dl) s'_lift :=
cont_mdiff_on.comp B A' (λp hp, by simp only [il] with mfld_simps),
apply cont_mdiff_on.comp diff_Drirrfl_lift C (λp hp, _),
simp only [s'_lift] with mfld_simps at hp,
simp only [il, s'l_lift, hp, total_space.proj] with mfld_simps },
/- Third step: check that the composition of all the maps indeed coincides with the derivative we
are looking for -/
have eq_comp : ∀q ∈ s'_lift, tangent_map_within I I' f s q =
(Dr.symm ∘ ir ∘ (tangent_map_within I I' (r ∘ f ∘ l.symm) s'l) ∘
(il.symm ∘ Dl)) q,
{ assume q hq,
simp only [s'_lift] with mfld_simps at hq,
have U'q : unique_mdiff_within_at I s' q.1,
by { apply U', simp only [hq, s'] with mfld_simps },
have U'lq : unique_mdiff_within_at I s'l (Dl q).1,
by { apply U'l, simp only [hq, s'l] with mfld_simps },
have A : tangent_map_within I I' ((r ∘ f) ∘ l.symm) s'l (il.symm (Dl q)) =
tangent_map_within I I' (r ∘ f) s' (tangent_map_within I I l.symm s'l (il.symm (Dl q))),
{ refine tangent_map_within_comp_at (il.symm (Dl q)) _ _ (λp hp, _) U'lq,
{ apply diff_rf.mdifferentiable_on one_le_n,
simp only [hq] with mfld_simps },
{ apply diff_l.mdifferentiable_on one_le_n,
simp only [s'l, hq] with mfld_simps },
{ simp only with mfld_simps at hp, simp only [hp] with mfld_simps } },
have B : tangent_map_within I I l.symm s'l (il.symm (Dl q)) = q,
{ have : tangent_map_within I I l.symm s'l (il.symm (Dl q))
= tangent_map I I l.symm (il.symm (Dl q)),
{ refine tangent_map_within_eq_tangent_map U'lq _,
refine mdifferentiable_at_atlas_symm _ (chart_mem_atlas _ _) _,
simp only [hq] with mfld_simps },
rw [this, tangent_map_chart_symm, hDl],
{ simp only [hq] with mfld_simps,
have : q ∈ (chart_at (model_prod H E) p).source, { simp only [hq] with mfld_simps },
exact (chart_at (model_prod H E) p).left_inv this },
{ simp only [hq] with mfld_simps } },
have C : tangent_map_within I I' (r ∘ f) s' q
= tangent_map_within I' I' r r.source (tangent_map_within I I' f s' q),
{ refine tangent_map_within_comp_at q _ _ (λr hr, _) U'q,
{ apply diff_r.mdifferentiable_on one_le_n,
simp only [hq] with mfld_simps },
{ apply diff_f.mdifferentiable_on one_le_n,
simp only [hq] with mfld_simps },
{ simp only [s'] with mfld_simps at hr,
simp only [hr] with mfld_simps } },
have D : Dr.symm (ir (tangent_map_within I' I' r r.source (tangent_map_within I I' f s' q)))
= tangent_map_within I I' f s' q,
{ have A : tangent_map_within I' I' r r.source (tangent_map_within I I' f s' q) =
tangent_map I' I' r (tangent_map_within I I' f s' q),
{ apply tangent_map_within_eq_tangent_map,
{ apply is_open.unique_mdiff_within_at _ r.open_source, simp [hq] },
{ refine mdifferentiable_at_atlas _ (chart_mem_atlas _ _) _,
simp only [hq] with mfld_simps } },
have : f p.proj = (tangent_map_within I I' f s p).1 := rfl,
rw [A],
dsimp [r, Dr],
rw [this, tangent_map_chart],
{ simp only [hq] with mfld_simps,
have : tangent_map_within I I' f s' q ∈
(chart_at (model_prod H' E') (tangent_map_within I I' f s p)).source,
by { simp only [hq] with mfld_simps },
exact (chart_at (model_prod H' E') (tangent_map_within I I' f s p)).left_inv this },
{ simp only [hq] with mfld_simps } },
have E : tangent_map_within I I' f s' q = tangent_map_within I I' f s q,
{ refine tangent_map_within_subset (by mfld_set_tac) U'q _,
apply hf.mdifferentiable_on one_le_n,
simp only [hq] with mfld_simps },
simp only [(∘), A, B, C, D, E.symm] },
exact diff_DrirrflilDl.congr eq_comp,
end
/-- If a function is `C^n` on a domain with unique derivatives, with `1 ≤ n`, then its bundled
derivative is continuous there. -/
theorem cont_mdiff_on.continuous_on_tangent_map_within
(hf : cont_mdiff_on I I' n f s) (hmn : 1 ≤ n) (hs : unique_mdiff_on I s) :
continuous_on (tangent_map_within I I' f s) (π E (tangent_space I) ⁻¹' s) :=
begin
have : cont_mdiff_on I.tangent I'.tangent 0 (tangent_map_within I I' f s)
(π E (tangent_space I) ⁻¹' s) :=
hf.cont_mdiff_on_tangent_map_within hmn hs,
exact this.continuous_on
end
/-- If a function is `C^n`, then its bundled derivative is `C^m` when `m+1 ≤ n`. -/
theorem cont_mdiff.cont_mdiff_tangent_map
(hf : cont_mdiff I I' n f) (hmn : m + 1 ≤ n) :
cont_mdiff I.tangent I'.tangent m (tangent_map I I' f) :=
begin
rw ← cont_mdiff_on_univ at hf ⊢,
convert hf.cont_mdiff_on_tangent_map_within hmn unique_mdiff_on_univ,
rw tangent_map_within_univ
end
/-- If a function is `C^n`, with `1 ≤ n`, then its bundled derivative is continuous. -/
theorem cont_mdiff.continuous_tangent_map
(hf : cont_mdiff I I' n f) (hmn : 1 ≤ n) :
continuous (tangent_map I I' f) :=
begin
rw ← cont_mdiff_on_univ at hf,
rw continuous_iff_continuous_on_univ,
convert hf.continuous_on_tangent_map_within hmn unique_mdiff_on_univ,
rw tangent_map_within_univ
end
end tangent_map
namespace tangent_bundle
include Is
variables (I M)
open bundle
/-- The derivative of the zero section of the tangent bundle maps `⟨x, v⟩` to `⟨⟨x, 0⟩, ⟨v, 0⟩⟩`.
Note that, as currently framed, this is a statement in coordinates, thus reliant on the choice
of the coordinate system we use on the tangent bundle.
However, the result itself is coordinate-dependent only to the extent that the coordinates
determine a splitting of the tangent bundle. Moreover, there is a canonical splitting at each
point of the zero section (since there is a canonical horizontal space there, the tangent space
to the zero section, in addition to the canonical vertical space which is the kernel of the
derivative of the projection), and this canonical splitting is also the one that comes from the
coordinates on the tangent bundle in our definitions. So this statement is not as crazy as it
may seem.
TODO define splittings of vector bundles; state this result invariantly. -/
lemma tangent_map_tangent_bundle_pure (p : tangent_bundle I M) :
tangent_map I I.tangent (zero_section E (tangent_space I)) p = ⟨⟨p.proj, 0⟩, ⟨p.2, 0⟩⟩ :=
begin
rcases p with ⟨x, v⟩,
have N : I.symm ⁻¹' (chart_at H x).target ∈ 𝓝 (I ((chart_at H x) x)),
{ apply is_open.mem_nhds,
apply (local_homeomorph.open_target _).preimage I.continuous_inv_fun,
simp only with mfld_simps },
have A : mdifferentiable_at I I.tangent (λ x, @total_space.mk M E (tangent_space I) x 0) x,
{ have : smooth I (I.prod 𝓘(𝕜, E)) (zero_section E (tangent_space I : M → Type*)) :=
bundle.smooth_zero_section 𝕜 (tangent_space I : M → Type*),
exact this.mdifferentiable_at },
have B : fderiv_within 𝕜 (λ (x' : E), (x', (0 : E))) (set.range ⇑I) (I ((chart_at H x) x)) v
= (v, 0),
{ rw [fderiv_within_eq_fderiv, differentiable_at.fderiv_prod],
{ simp },
{ exact differentiable_at_id' },
{ exact differentiable_at_const _ },
{ exact model_with_corners.unique_diff_at_image I },
{ exact differentiable_at_id'.prod (differentiable_at_const _) } },
simp only [bundle.zero_section, tangent_map, mfderiv, A, if_pos, chart_at,
fiber_bundle.charted_space_chart_at, tangent_bundle.trivialization_at_apply,
tangent_bundle_core, function.comp, continuous_linear_map.map_zero] with mfld_simps,
rw [← fderiv_within_inter N] at B,
rw [← fderiv_within_inter N, ← B],
congr' 1,
refine fderiv_within_congr (λ y hy, _) _,
{ simp only with mfld_simps at hy,
simp only [hy, prod.mk.inj_iff] with mfld_simps },
{ simp only [prod.mk.inj_iff] with mfld_simps },
end
end tangent_bundle
namespace cont_mdiff_map
-- These helpers for dot notation have been moved here from `geometry.manifold.cont_mdiff_map`
-- to avoid needing to import `geometry.manifold.cont_mdiff_mfderiv` there.
-- (However as a consequence we import `geometry.manifold.cont_mdiff_map` here now.)
-- They could be moved to another file (perhaps a new file) if desired.
open_locale manifold
protected lemma mdifferentiable' (f : C^n⟮I, M; I', M'⟯) (hn : 1 ≤ n) :
mdifferentiable I I' f :=
f.cont_mdiff.mdifferentiable hn
protected lemma mdifferentiable (f : C^∞⟮I, M; I', M'⟯) :
mdifferentiable I I' f :=
f.cont_mdiff.mdifferentiable le_top
protected lemma mdifferentiable_at (f : C^∞⟮I, M; I', M'⟯) {x} :
mdifferentiable_at I I' f x :=
f.mdifferentiable x
end cont_mdiff_map
|
894776d6c000b6052c8f4f860bea0e10260118ba | 94e33a31faa76775069b071adea97e86e218a8ee | /src/data/complex/is_R_or_C.lean | 98b22ac51b55f9a4eb78a1b61a2771fb24805eb9 | [
"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 | 36,844 | 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
-/
import data.real.sqrt
import field_theory.tower
import analysis.normed_space.finite_dimension
import analysis.normed_space.star.basic
/-!
# `is_R_or_C`: a typeclass for ℝ or ℂ
This file defines the typeclass `is_R_or_C` intended to have only two instances:
ℝ and ℂ. It is meant for definitions and theorems which hold for both the real and the complex case,
and in particular when the real case follows directly from the complex case by setting `re` to `id`,
`im` to zero and so on. Its API follows closely that of ℂ.
Applications include defining inner products and Hilbert spaces for both the real and
complex case. One typically produces the definitions and proof for an arbitrary field of this
typeclass, which basically amounts to doing the complex case, and the two cases then fall out
immediately from the two instances of the class.
The instance for `ℝ` is registered in this file.
The instance for `ℂ` is declared in `analysis.complex.basic`.
## Implementation notes
The coercion from reals into an `is_R_or_C` field is done by registering `algebra_map ℝ K` as
a `has_coe_t`. For this to work, we must proceed carefully to avoid problems involving circular
coercions in the case `K=ℝ`; in particular, we cannot use the plain `has_coe` and must set
priorities carefully. This problem was already solved for `ℕ`, and we copy the solution detailed
in `data/nat/cast`. See also Note [coercion into rings] for more details.
In addition, several lemmas need to be set at priority 900 to make sure that they do not override
their counterparts in `complex.lean` (which causes linter errors).
-/
open_locale big_operators
section
local notation `𝓚` := algebra_map ℝ _
open_locale complex_conjugate
/--
This typeclass captures properties shared by ℝ and ℂ, with an API that closely matches that of ℂ.
-/
class is_R_or_C (K : Type*)
extends nondiscrete_normed_field K, star_ring K, normed_algebra ℝ K, complete_space K :=
(re : K →+ ℝ)
(im : K →+ ℝ)
(I : K) -- Meant to be set to 0 for K=ℝ
(I_re_ax : re I = 0)
(I_mul_I_ax : I = 0 ∨ I * I = -1)
(re_add_im_ax : ∀ (z : K), 𝓚 (re z) + 𝓚 (im z) * I = z)
(of_real_re_ax : ∀ r : ℝ, re (𝓚 r) = r)
(of_real_im_ax : ∀ r : ℝ, im (𝓚 r) = 0)
(mul_re_ax : ∀ z w : K, re (z * w) = re z * re w - im z * im w)
(mul_im_ax : ∀ z w : K, im (z * w) = re z * im w + im z * re w)
(conj_re_ax : ∀ z : K, re (conj z) = re z)
(conj_im_ax : ∀ z : K, im (conj z) = -(im z))
(conj_I_ax : conj I = -I)
(norm_sq_eq_def_ax : ∀ (z : K), ∥z∥^2 = (re z) * (re z) + (im z) * (im z))
(mul_im_I_ax : ∀ (z : K), (im z) * im I = im z)
(inv_def_ax : ∀ (z : K), z⁻¹ = conj z * 𝓚 ((∥z∥^2)⁻¹))
(div_I_ax : ∀ (z : K), z / I = -(z * I))
end
mk_simp_attribute is_R_or_C_simps "Simp attribute for lemmas about `is_R_or_C`"
variables {K : Type*} [is_R_or_C K]
namespace is_R_or_C
open_locale complex_conjugate
/- The priority must be set at 900 to ensure that coercions are tried in the right order.
See Note [coercion into rings], or `data/nat/cast.lean` for more details. -/
@[priority 900] noncomputable instance algebra_map_coe : has_coe_t ℝ K := ⟨algebra_map ℝ K⟩
lemma of_real_alg (x : ℝ) : (x : K) = x • (1 : K) :=
algebra.algebra_map_eq_smul_one x
lemma algebra_map_eq_of_real : ⇑(algebra_map ℝ K) = coe := rfl
@[simp, is_R_or_C_simps] lemma re_add_im (z : K) : ((re z) : K) + (im z) * I = z :=
is_R_or_C.re_add_im_ax z
@[simp, norm_cast, is_R_or_C_simps] lemma of_real_re : ∀ r : ℝ, re (r : K) = r :=
is_R_or_C.of_real_re_ax
@[simp, norm_cast, is_R_or_C_simps] lemma of_real_im : ∀ r : ℝ, im (r : K) = 0 :=
is_R_or_C.of_real_im_ax
@[simp, is_R_or_C_simps] lemma mul_re : ∀ z w : K, re (z * w) = re z * re w - im z * im w :=
is_R_or_C.mul_re_ax
@[simp, is_R_or_C_simps] lemma mul_im : ∀ z w : K, im (z * w) = re z * im w + im z * re w :=
is_R_or_C.mul_im_ax
theorem inv_def (z : K) : z⁻¹ = conj z * ((∥z∥^2)⁻¹:ℝ) :=
is_R_or_C.inv_def_ax z
theorem ext_iff : ∀ {z w : K}, z = w ↔ re z = re w ∧ im z = im w :=
λ z w, { mp := by { rintro rfl, cc },
mpr := by { rintro ⟨h₁,h₂⟩, rw [←re_add_im z, ←re_add_im w, h₁, h₂] } }
theorem ext : ∀ {z w : K}, re z = re w → im z = im w → z = w :=
by { simp_rw ext_iff, cc }
@[simp, norm_cast, is_R_or_C_simps, priority 900] lemma of_real_zero : ((0 : ℝ) : K) = 0 :=
by rw [of_real_alg, zero_smul]
@[simp, is_R_or_C_simps] lemma zero_re' : re (0 : K) = (0 : ℝ) := re.map_zero
@[simp, norm_cast, is_R_or_C_simps, priority 900] lemma of_real_one : ((1 : ℝ) : K) = 1 :=
by rw [of_real_alg, one_smul]
@[simp, is_R_or_C_simps] lemma one_re : re (1 : K) = 1 := by rw [←of_real_one, of_real_re]
@[simp, is_R_or_C_simps] lemma one_im : im (1 : K) = 0 := by rw [←of_real_one, of_real_im]
@[simp, norm_cast, priority 900] theorem of_real_inj {z w : ℝ} : (z : K) = (w : K) ↔ z = w :=
{ mp := λ h, by { convert congr_arg re h; simp only [of_real_re] },
mpr := λ h, by rw h }
@[simp, is_R_or_C_simps] lemma bit0_re (z : K) : re (bit0 z) = bit0 (re z) :=
by simp only [bit0, map_add]
@[simp, is_R_or_C_simps] lemma bit1_re (z : K) : re (bit1 z) = bit1 (re z) :=
by simp only [bit1, add_monoid_hom.map_add, bit0_re, add_right_inj, one_re]
@[simp, is_R_or_C_simps] lemma bit0_im (z : K) : im (bit0 z) = bit0 (im z) :=
by simp only [bit0, map_add]
@[simp, is_R_or_C_simps] lemma bit1_im (z : K) : im (bit1 z) = bit0 (im z) :=
by simp only [bit1, add_right_eq_self, add_monoid_hom.map_add, bit0_im, one_im]
@[simp, is_R_or_C_simps, priority 900]
theorem of_real_eq_zero {z : ℝ} : (z : K) = 0 ↔ z = 0 :=
by rw [←of_real_zero]; exact of_real_inj
@[simp, is_R_or_C_simps, norm_cast, priority 900]
lemma of_real_add ⦃r s : ℝ⦄ : ((r + s : ℝ) : K) = r + s :=
by { apply (@is_R_or_C.ext_iff K _ ((r + s : ℝ) : K) (r + s)).mpr, simp }
@[simp, is_R_or_C_simps, norm_cast, priority 900]
lemma of_real_bit0 (r : ℝ) : ((bit0 r : ℝ) : K) = bit0 (r : K) :=
ext_iff.2 $ by simp [bit0]
@[simp, is_R_or_C_simps, norm_cast, priority 900]
lemma of_real_bit1 (r : ℝ) : ((bit1 r : ℝ) : K) = bit1 (r : K) :=
ext_iff.2 $ by simp [bit1]
/- Note: This can be proven by `norm_num` once K is proven to be of characteristic zero below. -/
lemma two_ne_zero : (2 : K) ≠ 0 :=
begin
intro h, rw [(show (2 : K) = ((2 : ℝ) : K), by norm_num), ←of_real_zero, of_real_inj] at h,
linarith,
end
@[simp, norm_cast, is_R_or_C_simps, priority 900]
lemma of_real_neg (r : ℝ) : ((-r : ℝ) : K) = -r := ext_iff.2 $ by simp
@[simp, norm_cast, is_R_or_C_simps, priority 900]
lemma of_real_mul (r s : ℝ) : ((r * s : ℝ) : K) = r * s := ext_iff.2 $ by simp with is_R_or_C_simps
@[simp, norm_cast, is_R_or_C_simps]
lemma of_real_smul (r x : ℝ) : r • (x : K) = (r : K) * (x : K) :=
begin
simp_rw [← smul_eq_mul, of_real_alg r],
simp only [algebra.id.smul_eq_mul, one_mul, algebra.smul_mul_assoc],
end
@[is_R_or_C_simps] lemma of_real_mul_re (r : ℝ) (z : K) : re (↑r * z) = r * re z :=
by simp only [mul_re, of_real_im, zero_mul, of_real_re, sub_zero]
@[is_R_or_C_simps] lemma of_real_mul_im (r : ℝ) (z : K) : im (↑r * z) = r * (im z) :=
by simp only [add_zero, of_real_im, zero_mul, of_real_re, mul_im]
@[is_R_or_C_simps] lemma smul_re : ∀ (r : ℝ) (z : K), re (r • z) = r * (re z) :=
λ r z, by { rw algebra.smul_def, apply of_real_mul_re }
@[is_R_or_C_simps] lemma smul_im : ∀ (r : ℝ) (z : K), im (r • z) = r * (im z) :=
λ r z, by { rw algebra.smul_def, apply of_real_mul_im }
/-! ### The imaginary unit, `I` -/
/-- The imaginary unit. -/
@[simp, is_R_or_C_simps] lemma I_re : re (I : K) = 0 := I_re_ax
@[simp, is_R_or_C_simps] lemma I_im (z : K) : im z * im (I : K) = im z := mul_im_I_ax z
@[simp, is_R_or_C_simps] lemma I_im' (z : K) : im (I : K) * im z = im z :=
by rw [mul_comm, I_im _]
@[simp, is_R_or_C_simps] lemma I_mul_re (z : K) : re (I * z) = - im z :=
by simp only [I_re, zero_sub, I_im', zero_mul, mul_re]
lemma I_mul_I : (I : K) = 0 ∨ (I : K) * I = -1 := I_mul_I_ax
@[simp, is_R_or_C_simps] lemma conj_re (z : K) : re (conj z) = re z := is_R_or_C.conj_re_ax z
@[simp, is_R_or_C_simps] lemma conj_im (z : K) : im (conj z) = -(im z) := is_R_or_C.conj_im_ax z
@[simp, is_R_or_C_simps] lemma conj_I : conj (I : K) = -I := is_R_or_C.conj_I_ax
@[simp, is_R_or_C_simps] lemma conj_of_real (r : ℝ) : conj (r : K) = (r : K) :=
by { rw ext_iff, simp only [of_real_im, conj_im, eq_self_iff_true, conj_re, and_self, neg_zero] }
@[simp, is_R_or_C_simps] lemma conj_bit0 (z : K) : conj (bit0 z) = bit0 (conj z) :=
by simp only [bit0, ring_hom.map_add, eq_self_iff_true]
@[simp, is_R_or_C_simps] lemma conj_bit1 (z : K) : conj (bit1 z) = bit1 (conj z) :=
by simp only [bit0, ext_iff, bit1_re, conj_im, eq_self_iff_true, conj_re, neg_add_rev,
and_self, bit1_im]
@[simp, is_R_or_C_simps] lemma conj_neg_I : conj (-I) = (I : K) :=
by simp only [conj_I, ring_hom.map_neg, eq_self_iff_true, neg_neg]
lemma conj_eq_re_sub_im (z : K) : conj z = re z - (im z) * I :=
by { rw ext_iff, simp only [add_zero, I_re, of_real_im, I_im, zero_sub, zero_mul, conj_im,
of_real_re, eq_self_iff_true, sub_zero, conj_re, mul_im, neg_inj,
and_self, mul_re, mul_zero, map_sub], }
@[is_R_or_C_simps] lemma conj_smul (r : ℝ) (z : K) : conj (r • z) = r • conj z :=
begin
simp_rw conj_eq_re_sub_im,
simp only [smul_re, smul_im, of_real_mul],
rw smul_sub,
simp_rw of_real_alg,
simp only [one_mul, algebra.smul_mul_assoc],
end
lemma eq_conj_iff_real {z : K} : conj z = z ↔ ∃ r : ℝ, z = (r : K) :=
begin
split,
{ intro h,
suffices : im z = 0,
{ use (re z),
rw ← add_zero (coe _),
convert (re_add_im z).symm, simp [this] },
contrapose! h,
rw ← re_add_im z,
simp only [conj_of_real, ring_hom.map_add, ring_hom.map_mul, conj_I_ax],
rw [add_left_cancel_iff, ext_iff],
simpa [neg_eq_iff_add_eq_zero, add_self_eq_zero] },
{ rintros ⟨r, rfl⟩, apply conj_of_real }
end
@[simp] lemma star_def : (has_star.star : K → K) = conj := rfl
variables (K)
/-- Conjugation as a ring equivalence. This is used to convert the inner product into a
sesquilinear product. -/
abbreviation conj_to_ring_equiv : K ≃+* Kᵐᵒᵖ := star_ring_equiv
variables {K}
lemma eq_conj_iff_re {z : K} : conj z = z ↔ ((re z) : K) = z :=
eq_conj_iff_real.trans ⟨by rintro ⟨r, rfl⟩; simp, λ h, ⟨_, h.symm⟩⟩
/-- The norm squared function. -/
def norm_sq : K →*₀ ℝ :=
{ to_fun := λ z, re z * re z + im z * im z,
map_zero' := by simp only [add_zero, mul_zero, map_zero],
map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero],
map_mul' := λ z w, by { simp only [mul_im, mul_re], ring } }
lemma norm_sq_eq_def {z : K} : ∥z∥^2 = (re z) * (re z) + (im z) * (im z) := norm_sq_eq_def_ax z
lemma norm_sq_eq_def' (z : K) : norm_sq z = ∥z∥^2 := by { rw norm_sq_eq_def, refl }
@[simp, is_R_or_C_simps] lemma norm_sq_of_real (r : ℝ) : ∥(r : K)∥^2 = r * r :=
by simp only [norm_sq_eq_def, add_zero, mul_zero] with is_R_or_C_simps
@[is_R_or_C_simps] lemma norm_sq_zero : norm_sq (0 : K) = 0 := norm_sq.map_zero
@[is_R_or_C_simps] lemma norm_sq_one : norm_sq (1 : K) = 1 := norm_sq.map_one
lemma norm_sq_nonneg (z : K) : 0 ≤ norm_sq z :=
add_nonneg (mul_self_nonneg _) (mul_self_nonneg _)
@[simp, is_R_or_C_simps] lemma norm_sq_eq_zero {z : K} : norm_sq z = 0 ↔ z = 0 :=
by { rw [norm_sq_eq_def'], simp [sq] }
@[simp, is_R_or_C_simps] lemma norm_sq_pos {z : K} : 0 < norm_sq z ↔ z ≠ 0 :=
by rw [lt_iff_le_and_ne, ne, eq_comm]; simp [norm_sq_nonneg]
@[simp, is_R_or_C_simps] lemma norm_sq_neg (z : K) : norm_sq (-z) = norm_sq z :=
by simp only [norm_sq_eq_def', norm_neg]
@[simp, is_R_or_C_simps] lemma norm_sq_conj (z : K) : norm_sq (conj z) = norm_sq z :=
by simp only [norm_sq, neg_mul, monoid_with_zero_hom.coe_mk,
mul_neg, neg_neg] with is_R_or_C_simps
@[simp, is_R_or_C_simps] lemma norm_sq_mul (z w : K) : norm_sq (z * w) = norm_sq z * norm_sq w :=
norm_sq.map_mul z w
lemma norm_sq_add (z w : K) :
norm_sq (z + w) = norm_sq z + norm_sq w + 2 * (re (z * conj w)) :=
by { simp only [norm_sq, map_add, monoid_with_zero_hom.coe_mk, mul_neg,
sub_neg_eq_add] with is_R_or_C_simps, ring }
lemma re_sq_le_norm_sq (z : K) : re z * re z ≤ norm_sq z :=
le_add_of_nonneg_right (mul_self_nonneg _)
lemma im_sq_le_norm_sq (z : K) : im z * im z ≤ norm_sq z :=
le_add_of_nonneg_left (mul_self_nonneg _)
theorem mul_conj (z : K) : z * conj z = ((norm_sq z) : K) :=
by simp only [map_add, add_zero, ext_iff, monoid_with_zero_hom.coe_mk,
add_left_inj, mul_eq_mul_left_iff, zero_mul, add_comm, true_or, eq_self_iff_true,
mul_neg, add_right_neg, zero_add, norm_sq, mul_comm, and_self,
neg_neg, mul_zero, sub_eq_neg_add, neg_zero] with is_R_or_C_simps
theorem add_conj (z : K) : z + conj z = 2 * (re z) :=
by simp only [ext_iff, two_mul, map_add, add_zero, of_real_im, conj_im, of_real_re,
eq_self_iff_true, add_right_neg, conj_re, and_self]
/-- The pseudo-coercion `of_real` as a `ring_hom`. -/
noncomputable def of_real_hom : ℝ →+* K := algebra_map ℝ K
/-- The coercion from reals as a `ring_hom`. -/
noncomputable def coe_hom : ℝ →+* K := ⟨coe, of_real_one, of_real_mul, of_real_zero, of_real_add⟩
@[simp, norm_cast, is_R_or_C_simps, priority 900] lemma of_real_sub (r s : ℝ) :
((r - s : ℝ) : K) = r - s :=
ext_iff.2 $ by simp only [of_real_im, of_real_re, eq_self_iff_true, sub_zero, and_self, map_sub]
@[simp, norm_cast, is_R_or_C_simps, priority 900] lemma of_real_pow (r : ℝ) (n : ℕ) :
((r ^ n : ℝ) : K) = r ^ n :=
begin
induction n,
{ simp only [of_real_one, pow_zero]},
{ simp only [*, of_real_mul, pow_succ]}
end
theorem sub_conj (z : K) : z - conj z = (2 * im z) * I :=
by simp only [ext_iff, two_mul, sub_eq_add_neg, add_mul, map_add, add_zero, add_left_inj, zero_mul,
map_add_neg, eq_self_iff_true, add_right_neg, and_self, neg_neg, mul_zero, neg_zero]
with is_R_or_C_simps
lemma norm_sq_sub (z w : K) : norm_sq (z - w) = norm_sq z + norm_sq w - 2 * re (z * conj w) :=
by simp only [norm_sq_add, sub_eq_add_neg, ring_equiv.map_neg, mul_neg,
norm_sq_neg, map_neg]
lemma sqrt_norm_sq_eq_norm {z : K} : real.sqrt (norm_sq z) = ∥z∥ :=
begin
have h₂ : ∥z∥ = real.sqrt (∥z∥^2) := (real.sqrt_sq (norm_nonneg z)).symm,
rw [h₂],
exact congr_arg real.sqrt (norm_sq_eq_def' z)
end
/-! ### Inversion -/
@[simp, is_R_or_C_simps] lemma inv_re (z : K) : re (z⁻¹) = re z / norm_sq z :=
by simp only [inv_def, norm_sq_eq_def, norm_sq, division_def,
monoid_with_zero_hom.coe_mk, sub_zero, mul_zero] with is_R_or_C_simps
@[simp, is_R_or_C_simps] lemma inv_im (z : K) : im (z⁻¹) = im (-z) / norm_sq z :=
by simp only [inv_def, norm_sq_eq_def, norm_sq, division_def, of_real_im,
monoid_with_zero_hom.coe_mk, of_real_re, zero_add, map_neg, mul_zero]
with is_R_or_C_simps
@[simp, norm_cast, is_R_or_C_simps, priority 900]
lemma of_real_inv (r : ℝ) : ((r⁻¹ : ℝ) : K) = r⁻¹ :=
begin
rw ext_iff,
by_cases r = 0,
{ simp only [h, of_real_zero, inv_zero, and_self, map_zero]},
{ simp only with is_R_or_C_simps,
field_simp [h, norm_sq] }
end
protected lemma inv_zero : (0⁻¹ : K) = 0 :=
by rw [← of_real_zero, ← of_real_inv, inv_zero]
protected theorem mul_inv_cancel {z : K} (h : z ≠ 0) : z * z⁻¹ = 1 :=
by rw [inv_def, ←mul_assoc, mul_conj, ←of_real_mul, ←norm_sq_eq_def',
mul_inv_cancel (mt norm_sq_eq_zero.1 h), of_real_one]
lemma div_re (z w : K) : re (z / w) = re z * re w / norm_sq w + im z * im w / norm_sq w :=
by simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, neg_mul,
mul_neg, neg_neg, map_neg] with is_R_or_C_simps
lemma div_im (z w : K) : im (z / w) = im z * re w / norm_sq w - re z * im w / norm_sq w :=
by simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm, neg_mul,
mul_neg, map_neg] with is_R_or_C_simps
@[simp, is_R_or_C_simps]
lemma conj_inv (x : K) : conj (x⁻¹) = (conj x)⁻¹ := star_inv' _
@[simp, norm_cast, is_R_or_C_simps, priority 900] lemma of_real_div (r s : ℝ) :
((r / s : ℝ) : K) = r / s :=
(@is_R_or_C.coe_hom K _).map_div r s
lemma div_re_of_real {z : K} {r : ℝ} : re (z / r) = re z / r :=
begin
by_cases h : r = 0,
{ simp only [h, of_real_zero, div_zero, zero_re']},
{ change r ≠ 0 at h,
rw [div_eq_mul_inv, ←of_real_inv, div_eq_mul_inv],
simp only [one_div, of_real_im, of_real_re, sub_zero, mul_re, mul_zero]}
end
@[simp, norm_cast, is_R_or_C_simps, priority 900] lemma of_real_zpow (r : ℝ) (n : ℤ) :
((r ^ n : ℝ) : K) = r ^ n :=
(@is_R_or_C.coe_hom K _).map_zpow r n
lemma I_mul_I_of_nonzero : (I : K) ≠ 0 → (I : K) * I = -1 :=
by { have := I_mul_I_ax, tauto }
@[simp, is_R_or_C_simps] lemma div_I (z : K) : z / I = -(z * I) :=
begin
by_cases h : (I : K) = 0,
{ simp [h] },
{ field_simp [mul_assoc, I_mul_I_of_nonzero h] }
end
@[simp, is_R_or_C_simps] lemma inv_I : (I : K)⁻¹ = -I :=
by field_simp
@[simp, is_R_or_C_simps] lemma norm_sq_inv (z : K) : norm_sq z⁻¹ = (norm_sq z)⁻¹ :=
(@norm_sq K _).map_inv z
@[simp, is_R_or_C_simps] lemma norm_sq_div (z w : K) : norm_sq (z / w) = norm_sq z / norm_sq w :=
(@norm_sq K _).map_div z w
@[is_R_or_C_simps] lemma norm_conj {z : K} : ∥conj z∥ = ∥z∥ :=
by simp only [←sqrt_norm_sq_eq_norm, norm_sq_conj]
@[priority 100] instance : cstar_ring K :=
{ norm_star_mul_self := λ x, (norm_mul _ _).trans $ congr_arg (* ∥x∥) norm_conj }
/-! ### Cast lemmas -/
@[simp, is_R_or_C_simps, norm_cast, priority 900] theorem of_real_nat_cast (n : ℕ) :
((n : ℝ) : K) = n :=
show (algebra_map ℝ K) n = n, from map_nat_cast of_real_hom n
--of_real_hom.map_nat_cast n
--@[simp, norm_cast, priority 900] theorem of_real_nat_cast (n : ℕ) : ((n : ℝ) : K) = n :=
@[simp, is_R_or_C_simps, norm_cast] lemma nat_cast_re (n : ℕ) : re (n : K) = n :=
by rw [← of_real_nat_cast, of_real_re]
@[simp, is_R_or_C_simps, norm_cast] lemma nat_cast_im (n : ℕ) : im (n : K) = 0 :=
by rw [← of_real_nat_cast, of_real_im]
@[simp, is_R_or_C_simps, norm_cast, priority 900] theorem of_real_int_cast (n : ℤ) :
((n : ℝ) : K) = n :=
of_real_hom.map_int_cast n
@[simp, is_R_or_C_simps, norm_cast] lemma int_cast_re (n : ℤ) : re (n : K) = n :=
by rw [← of_real_int_cast, of_real_re]
@[simp, is_R_or_C_simps, norm_cast] lemma int_cast_im (n : ℤ) : im (n : K) = 0 :=
by rw [← of_real_int_cast, of_real_im]
@[simp, is_R_or_C_simps, norm_cast, priority 900] theorem of_real_rat_cast (n : ℚ) :
((n : ℝ) : K) = n :=
map_rat_cast (@is_R_or_C.of_real_hom K _) n
@[simp, is_R_or_C_simps, norm_cast] lemma rat_cast_re (q : ℚ) : re (q : K) = q :=
by rw [← of_real_rat_cast, of_real_re]
@[simp, is_R_or_C_simps, norm_cast] lemma rat_cast_im (q : ℚ) : im (q : K) = 0 :=
by rw [← of_real_rat_cast, of_real_im]
/-! ### Characteristic zero -/
/-- ℝ and ℂ are both of characteristic zero. -/
@[priority 100] -- see Note [lower instance priority]
instance char_zero_R_or_C : char_zero K :=
char_zero_of_inj_zero $ λ n h,
by rwa [← of_real_nat_cast, of_real_eq_zero, nat.cast_eq_zero] at h
theorem re_eq_add_conj (z : K) : ↑(re z) = (z + conj z) / 2 :=
by rw [add_conj, mul_div_cancel_left ((re z):K) two_ne_zero']
theorem im_eq_conj_sub (z : K) : ↑(im z) = I * (conj z - z) / 2 :=
begin
rw [← neg_inj, ← of_real_neg, ← I_mul_re, re_eq_add_conj],
simp only [mul_add, sub_eq_add_neg, neg_div', neg_mul, conj_I,
mul_neg, neg_add_rev, neg_neg, ring_hom.map_mul]
end
/-! ### Absolute value -/
/-- The complex absolute value function, defined as the square root of the norm squared. -/
@[pp_nodot] noncomputable def abs (z : K) : ℝ := (norm_sq z).sqrt
local notation `abs'` := has_abs.abs
local notation `absK` := @abs K _
@[simp, norm_cast] lemma abs_of_real (r : ℝ) : absK r = abs' r :=
by simp only [abs, norm_sq, real.sqrt_mul_self_eq_abs, add_zero, of_real_im,
monoid_with_zero_hom.coe_mk, of_real_re, mul_zero]
lemma norm_eq_abs (z : K) : ∥z∥ = absK z :=
by simp only [abs, norm_sq_eq_def', norm_nonneg, real.sqrt_sq]
@[is_R_or_C_simps, norm_cast]
lemma norm_of_real (z : ℝ) : ∥(z : K)∥ = ∥z∥ :=
by { rw [is_R_or_C.norm_eq_abs, is_R_or_C.abs_of_real, real.norm_eq_abs] }
lemma abs_of_nonneg {r : ℝ} (h : 0 ≤ r) : absK r = r :=
(abs_of_real _).trans (abs_of_nonneg h)
lemma norm_of_nonneg {r : ℝ} (r_nn : 0 ≤ r) : ∥(r : K)∥ = r :=
by { rw norm_of_real, exact abs_eq_self.mpr r_nn, }
lemma abs_of_nat (n : ℕ) : absK n = n :=
by { rw [← of_real_nat_cast], exact abs_of_nonneg (nat.cast_nonneg n) }
lemma mul_self_abs (z : K) : abs z * abs z = norm_sq z :=
real.mul_self_sqrt (norm_sq_nonneg _)
@[simp, is_R_or_C_simps] lemma abs_zero : absK 0 = 0 := by simp only [abs, real.sqrt_zero, map_zero]
@[simp, is_R_or_C_simps] lemma abs_one : absK 1 = 1 := by simp only [abs, map_one, real.sqrt_one]
@[simp, is_R_or_C_simps] lemma abs_two : absK 2 = 2 :=
calc absK 2 = absK (2 : ℝ) : by rw [of_real_bit0, of_real_one]
... = (2 : ℝ) : abs_of_nonneg (by norm_num)
lemma abs_nonneg (z : K) : 0 ≤ absK z :=
real.sqrt_nonneg _
@[simp, is_R_or_C_simps] lemma abs_eq_zero {z : K} : absK z = 0 ↔ z = 0 :=
(real.sqrt_eq_zero $ norm_sq_nonneg _).trans norm_sq_eq_zero
lemma abs_ne_zero {z : K} : abs z ≠ 0 ↔ z ≠ 0 :=
not_congr abs_eq_zero
@[simp, is_R_or_C_simps] lemma abs_conj (z : K) : abs (conj z) = abs z :=
by simp only [abs, norm_sq_conj]
@[simp, is_R_or_C_simps] lemma abs_mul (z w : K) : abs (z * w) = abs z * abs w :=
by rw [abs, norm_sq_mul, real.sqrt_mul (norm_sq_nonneg _)]; refl
lemma abs_re_le_abs (z : K) : abs' (re z) ≤ abs z :=
by rw [mul_self_le_mul_self_iff (_root_.abs_nonneg (re z)) (abs_nonneg _),
abs_mul_abs_self, mul_self_abs];
apply re_sq_le_norm_sq
lemma abs_im_le_abs (z : K) : abs' (im z) ≤ abs z :=
by rw [mul_self_le_mul_self_iff (_root_.abs_nonneg (im z)) (abs_nonneg _),
abs_mul_abs_self, mul_self_abs];
apply im_sq_le_norm_sq
lemma norm_re_le_norm (z : K) : ∥re z∥ ≤ ∥z∥ :=
by { rw [is_R_or_C.norm_eq_abs, real.norm_eq_abs], exact is_R_or_C.abs_re_le_abs _, }
lemma norm_im_le_norm (z : K) : ∥im z∥ ≤ ∥z∥ :=
by { rw [is_R_or_C.norm_eq_abs, real.norm_eq_abs], exact is_R_or_C.abs_im_le_abs _, }
lemma re_le_abs (z : K) : re z ≤ abs z :=
(abs_le.1 (abs_re_le_abs _)).2
lemma im_le_abs (z : K) : im z ≤ abs z :=
(abs_le.1 (abs_im_le_abs _)).2
lemma im_eq_zero_of_le {a : K} (h : abs a ≤ re a) : im a = 0 :=
begin
rw ← zero_eq_mul_self,
have : re a * re a = re a * re a + im a * im a,
{ convert is_R_or_C.mul_self_abs a;
linarith [re_le_abs a] },
linarith
end
lemma re_eq_self_of_le {a : K} (h : abs a ≤ re a) : (re a : K) = a :=
by { rw ← re_add_im a, simp only [im_eq_zero_of_le h, add_zero, zero_mul] with is_R_or_C_simps }
lemma abs_add (z w : K) : abs (z + w) ≤ abs z + abs w :=
(mul_self_le_mul_self_iff (abs_nonneg _)
(add_nonneg (abs_nonneg _) (abs_nonneg _))).2 $
begin
rw [mul_self_abs, add_mul_self_eq, mul_self_abs, mul_self_abs,
add_right_comm, norm_sq_add, add_le_add_iff_left,
mul_assoc, mul_le_mul_left (@zero_lt_two ℝ _ _)],
simpa [-mul_re] with is_R_or_C_simps using re_le_abs (z * conj w)
end
instance : is_absolute_value absK :=
{ abv_nonneg := abs_nonneg,
abv_eq_zero := λ _, abs_eq_zero,
abv_add := abs_add,
abv_mul := abs_mul }
open is_absolute_value
@[simp, is_R_or_C_simps] lemma abs_abs (z : K) : abs' (abs z) = abs z :=
_root_.abs_of_nonneg (abs_nonneg _)
@[simp, is_R_or_C_simps] lemma abs_pos {z : K} : 0 < abs z ↔ z ≠ 0 := abv_pos abs
@[simp, is_R_or_C_simps] lemma abs_neg : ∀ z : K, abs (-z) = abs z := abv_neg abs
lemma abs_sub : ∀ z w : K, abs (z - w) = abs (w - z) := abv_sub abs
lemma abs_sub_le : ∀ a b c : K, abs (a - c) ≤ abs (a - b) + abs (b - c) := abv_sub_le abs
@[simp, is_R_or_C_simps] theorem abs_inv : ∀ z : K, abs z⁻¹ = (abs z)⁻¹ := abv_inv abs
@[simp, is_R_or_C_simps] theorem abs_div : ∀ z w : K, abs (z / w) = abs z / abs w := abv_div abs
lemma abs_abs_sub_le_abs_sub : ∀ z w : K, abs' (abs z - abs w) ≤ abs (z - w) :=
abs_abv_sub_le_abv_sub abs
lemma abs_re_div_abs_le_one (z : K) : abs' (re z / abs z) ≤ 1 :=
begin
by_cases hz : z = 0,
{ simp [hz, zero_le_one] },
{ simp_rw [_root_.abs_div, abs_abs, div_le_iff (abs_pos.2 hz), one_mul, abs_re_le_abs] }
end
lemma abs_im_div_abs_le_one (z : K) : abs' (im z / abs z) ≤ 1 :=
begin
by_cases hz : z = 0,
{ simp [hz, zero_le_one] },
{ simp_rw [_root_.abs_div, abs_abs, div_le_iff (abs_pos.2 hz), one_mul, abs_im_le_abs] }
end
@[simp, is_R_or_C_simps, norm_cast] lemma abs_cast_nat (n : ℕ) : abs (n : K) = n :=
by rw [← of_real_nat_cast, abs_of_nonneg (nat.cast_nonneg n)]
lemma norm_sq_eq_abs (x : K) : norm_sq x = abs x ^ 2 :=
by rw [abs, sq, real.mul_self_sqrt (norm_sq_nonneg _)]
lemma re_eq_abs_of_mul_conj (x : K) : re (x * (conj x)) = abs (x * (conj x)) :=
by rw [mul_conj, of_real_re, abs_of_real, norm_sq_eq_abs, sq, _root_.abs_mul, abs_abs]
lemma abs_sq_re_add_conj (x : K) : (abs (x + conj x))^2 = (re (x + conj x))^2 :=
by simp only [sq, ←norm_sq_eq_abs, norm_sq, map_add, add_zero, monoid_with_zero_hom.coe_mk,
add_right_neg, mul_zero] with is_R_or_C_simps
lemma abs_sq_re_add_conj' (x : K) : (abs (conj x + x))^2 = (re (conj x + x))^2 :=
by simp only [sq, ←norm_sq_eq_abs, norm_sq, map_add, add_zero, monoid_with_zero_hom.coe_mk,
add_left_neg, mul_zero] with is_R_or_C_simps
lemma conj_mul_eq_norm_sq_left (x : K) : conj x * x = ((norm_sq x) : K) :=
begin
rw ext_iff,
refine ⟨by simp only [norm_sq, neg_mul, monoid_with_zero_hom.coe_mk,
sub_neg_eq_add, map_add, sub_zero, mul_zero] with is_R_or_C_simps, _⟩,
simp only [mul_comm, mul_neg, add_left_neg] with is_R_or_C_simps
end
/-! ### Cauchy sequences -/
theorem is_cau_seq_re (f : cau_seq K abs) : is_cau_seq abs' (λ n, re (f n)) :=
λ ε ε0, (f.cauchy ε0).imp $ λ i H j ij,
lt_of_le_of_lt (by simpa using abs_re_le_abs (f j - f i)) (H _ ij)
theorem is_cau_seq_im (f : cau_seq K abs) : is_cau_seq abs' (λ n, im (f n)) :=
λ ε ε0, (f.cauchy ε0).imp $ λ i H j ij,
lt_of_le_of_lt (by simpa using abs_im_le_abs (f j - f i)) (H _ ij)
/-- The real part of a K Cauchy sequence, as a real Cauchy sequence. -/
noncomputable def cau_seq_re (f : cau_seq K abs) : cau_seq ℝ abs' :=
⟨_, is_cau_seq_re f⟩
/-- The imaginary part of a K Cauchy sequence, as a real Cauchy sequence. -/
noncomputable def cau_seq_im (f : cau_seq K abs) : cau_seq ℝ abs' :=
⟨_, is_cau_seq_im f⟩
lemma is_cau_seq_abs {f : ℕ → K} (hf : is_cau_seq abs f) :
is_cau_seq abs' (abs ∘ f) :=
λ ε ε0, let ⟨i, hi⟩ := hf ε ε0 in
⟨i, λ j hj, lt_of_le_of_lt (abs_abs_sub_le_abs_sub _ _) (hi j hj)⟩
@[simp, is_R_or_C_simps, norm_cast, priority 900]
lemma of_real_prod {α : Type*} (s : finset α) (f : α → ℝ) :
((∏ i in s, f i : ℝ) : K) = ∏ i in s, (f i : K) :=
ring_hom.map_prod _ _ _
@[simp, is_R_or_C_simps, norm_cast, priority 900]
lemma of_real_sum {α : Type*} (s : finset α) (f : α → ℝ) :
((∑ i in s, f i : ℝ) : K) = ∑ i in s, (f i : K) :=
ring_hom.map_sum _ _ _
@[simp, is_R_or_C_simps, norm_cast] lemma of_real_finsupp_sum
{α M : Type*} [has_zero M] (f : α →₀ M) (g : α → M → ℝ) :
((f.sum (λ a b, g a b) : ℝ) : K) = f.sum (λ a b, ((g a b) : K)) :=
ring_hom.map_finsupp_sum _ f g
@[simp, is_R_or_C_simps, norm_cast] lemma of_real_finsupp_prod
{α M : Type*} [has_zero M] (f : α →₀ M) (g : α → M → ℝ) :
((f.prod (λ a b, g a b) : ℝ) : K) = f.prod (λ a b, ((g a b) : K)) :=
ring_hom.map_finsupp_prod _ f g
end is_R_or_C
namespace polynomial
open_locale polynomial
lemma of_real_eval (p : ℝ[X]) (x : ℝ) : (p.eval x : K) = aeval ↑x p :=
(@aeval_algebra_map_apply ℝ K _ _ _ x p).symm
end polynomial
namespace finite_dimensional
open_locale classical
open is_R_or_C
/-- This instance generates a type-class problem with a metavariable `?m` that should satisfy
`is_R_or_C ?m`. Since this can only be satisfied by `ℝ` or `ℂ`, this does not cause problems. -/
library_note "is_R_or_C instance"
/-- An `is_R_or_C` field is finite-dimensional over `ℝ`, since it is spanned by `{1, I}`. -/
@[nolint dangerous_instance] instance is_R_or_C_to_real : finite_dimensional ℝ K :=
⟨⟨{1, I},
begin
rw eq_top_iff,
intros a _,
rw [finset.coe_insert, finset.coe_singleton, submodule.mem_span_insert],
refine ⟨re a, (im a) • I, _, _⟩,
{ rw submodule.mem_span_singleton,
use im a },
simp [re_add_im a, algebra.smul_def, algebra_map_eq_of_real]
end⟩⟩
variables (K) (E : Type*) [normed_group E] [normed_space K E]
/-- A finite dimensional vector space Over an `is_R_or_C` is a proper metric space.
This is not an instance because it would cause a search for `finite_dimensional ?x E` before
`is_R_or_C ?x`. -/
lemma proper_is_R_or_C [finite_dimensional K E] : proper_space E :=
begin
letI : normed_space ℝ E := restrict_scalars.normed_space ℝ K E,
letI : finite_dimensional ℝ E := finite_dimensional.trans ℝ K E,
apply_instance
end
variable {E}
instance is_R_or_C.proper_space_submodule (S : submodule K E) [finite_dimensional K ↥S] :
proper_space S :=
proper_is_R_or_C K S
end finite_dimensional
section instances
noncomputable instance real.is_R_or_C : is_R_or_C ℝ :=
{ re := add_monoid_hom.id ℝ,
im := 0,
I := 0,
I_re_ax := by simp only [add_monoid_hom.map_zero],
I_mul_I_ax := or.intro_left _ rfl,
re_add_im_ax := λ z, by simp only [add_zero, mul_zero, algebra.id.map_eq_id, ring_hom.id_apply,
add_monoid_hom.id_apply],
of_real_re_ax := λ r, by simp only [add_monoid_hom.id_apply, algebra.id.map_eq_self],
of_real_im_ax := λ r, by simp only [add_monoid_hom.zero_apply],
mul_re_ax := λ z w,
by simp only [sub_zero, mul_zero, add_monoid_hom.zero_apply, add_monoid_hom.id_apply],
mul_im_ax := λ z w, by simp only [add_zero, zero_mul, mul_zero, add_monoid_hom.zero_apply],
conj_re_ax := λ z, by simp only [star_ring_end_apply, star_id_of_comm],
conj_im_ax := λ z, by simp only [neg_zero, add_monoid_hom.zero_apply],
conj_I_ax := by simp only [ring_hom.map_zero, neg_zero],
norm_sq_eq_def_ax := λ z, by simp only [sq, real.norm_eq_abs, ←abs_mul, abs_mul_self z, add_zero,
mul_zero, add_monoid_hom.zero_apply, add_monoid_hom.id_apply],
mul_im_I_ax := λ z, by simp only [mul_zero, add_monoid_hom.zero_apply],
inv_def_ax := λ z, by simp only [star_ring_end_apply, star, sq, real.norm_eq_abs,
abs_mul_abs_self, ←div_eq_mul_inv, algebra.id.map_eq_id, id.def, ring_hom.id_apply,
div_self_mul_self'],
div_I_ax := λ z, by simp only [div_zero, mul_zero, neg_zero],
.. real.nondiscrete_normed_field, .. real.metric_space }
end instances
namespace is_R_or_C
open_locale complex_conjugate
section cleanup_lemmas
local notation `reR` := @is_R_or_C.re ℝ _
local notation `imR` := @is_R_or_C.im ℝ _
local notation `IR` := @is_R_or_C.I ℝ _
local notation `absR` := @is_R_or_C.abs ℝ _
local notation `norm_sqR` := @is_R_or_C.norm_sq ℝ _
@[simp, is_R_or_C_simps] lemma re_to_real {x : ℝ} : reR x = x := rfl
@[simp, is_R_or_C_simps] lemma im_to_real {x : ℝ} : imR x = 0 := rfl
@[simp, is_R_or_C_simps] lemma conj_to_real {x : ℝ} : conj x = x := rfl
@[simp, is_R_or_C_simps] lemma I_to_real : IR = 0 := rfl
@[simp, is_R_or_C_simps] lemma norm_sq_to_real {x : ℝ} : norm_sq x = x*x :=
by simp [is_R_or_C.norm_sq]
@[simp, is_R_or_C_simps] lemma abs_to_real {x : ℝ} : absR x = has_abs.abs x :=
by simp [is_R_or_C.abs, abs, real.sqrt_mul_self_eq_abs]
@[simp] lemma coe_real_eq_id : @coe ℝ ℝ _ = id := rfl
end cleanup_lemmas
section linear_maps
/-- The real part in a `is_R_or_C` field, as a linear map. -/
def re_lm : K →ₗ[ℝ] ℝ :=
{ map_smul' := smul_re, .. re }
@[simp, is_R_or_C_simps] lemma re_lm_coe : (re_lm : K → ℝ) = re := rfl
/-- The real part in a `is_R_or_C` field, as a continuous linear map. -/
noncomputable def re_clm : K →L[ℝ] ℝ :=
linear_map.mk_continuous re_lm 1 $ by
{ simp only [norm_eq_abs, re_lm_coe, one_mul, abs_to_real], exact abs_re_le_abs, }
@[simp, is_R_or_C_simps] lemma re_clm_norm : ∥(re_clm : K →L[ℝ] ℝ)∥ = 1 :=
begin
apply le_antisymm (linear_map.mk_continuous_norm_le _ zero_le_one _),
convert continuous_linear_map.ratio_le_op_norm _ (1 : K),
{ simp },
{ apply_instance }
end
@[simp, is_R_or_C_simps, norm_cast] lemma re_clm_coe : ((re_clm : K →L[ℝ] ℝ) :
K →ₗ[ℝ] ℝ) = re_lm := rfl
@[simp, is_R_or_C_simps] lemma re_clm_apply : ((re_clm : K →L[ℝ] ℝ) : K → ℝ) = re := rfl
@[continuity] lemma continuous_re : continuous (re : K → ℝ) := re_clm.continuous
/-- The imaginary part in a `is_R_or_C` field, as a linear map. -/
def im_lm : K →ₗ[ℝ] ℝ :=
{ map_smul' := smul_im, .. im }
@[simp, is_R_or_C_simps] lemma im_lm_coe : (im_lm : K → ℝ) = im := rfl
/-- The imaginary part in a `is_R_or_C` field, as a continuous linear map. -/
noncomputable def im_clm : K →L[ℝ] ℝ :=
linear_map.mk_continuous im_lm 1 $ by
{ simp only [norm_eq_abs, re_lm_coe, one_mul, abs_to_real], exact abs_im_le_abs, }
@[simp, is_R_or_C_simps, norm_cast] lemma im_clm_coe : ((im_clm : K →L[ℝ] ℝ) :
K →ₗ[ℝ] ℝ) = im_lm := rfl
@[simp, is_R_or_C_simps] lemma im_clm_apply : ((im_clm : K →L[ℝ] ℝ) : K → ℝ) = im := rfl
@[continuity] lemma continuous_im : continuous (im : K → ℝ) := im_clm.continuous
/-- Conjugate as an `ℝ`-algebra equivalence -/
def conj_ae : K ≃ₐ[ℝ] K :=
{ inv_fun := conj,
left_inv := conj_conj,
right_inv := conj_conj,
commutes' := conj_of_real,
.. conj }
@[simp, is_R_or_C_simps] lemma conj_ae_coe : (conj_ae : K → K) = conj := rfl
/-- Conjugate as a linear isometry -/
noncomputable def conj_lie : K ≃ₗᵢ[ℝ] K :=
⟨conj_ae.to_linear_equiv, λ z, by simp [norm_eq_abs] with is_R_or_C_simps⟩
@[simp, is_R_or_C_simps] lemma conj_lie_apply : (conj_lie : K → K) = conj := rfl
/-- Conjugate as a continuous linear equivalence -/
noncomputable def conj_cle : K ≃L[ℝ] K := @conj_lie K _
@[simp, is_R_or_C_simps] lemma conj_cle_coe :
(@conj_cle K _).to_linear_equiv = conj_ae.to_linear_equiv := rfl
@[simp, is_R_or_C_simps] lemma conj_cle_apply : (conj_cle : K → K) = conj := rfl
@[simp, is_R_or_C_simps] lemma conj_cle_norm : ∥(@conj_cle K _ : K →L[ℝ] K)∥ = 1 :=
(@conj_lie K _).to_linear_isometry.norm_to_continuous_linear_map
@[priority 100]
instance : has_continuous_star K := ⟨conj_lie.continuous⟩
@[continuity] lemma continuous_conj : continuous (conj : K → K) := continuous_star
/-- The `ℝ → K` coercion, as a linear map -/
noncomputable def of_real_am : ℝ →ₐ[ℝ] K := algebra.of_id ℝ K
@[simp, is_R_or_C_simps] lemma of_real_am_coe : (of_real_am : ℝ → K) = coe := rfl
/-- The ℝ → K coercion, as a linear isometry -/
noncomputable def of_real_li : ℝ →ₗᵢ[ℝ] K :=
{ to_linear_map := of_real_am.to_linear_map, norm_map' := by simp [norm_eq_abs] }
@[simp, is_R_or_C_simps] lemma of_real_li_apply : (of_real_li : ℝ → K) = coe := rfl
/-- The `ℝ → K` coercion, as a continuous linear map -/
noncomputable def of_real_clm : ℝ →L[ℝ] K := of_real_li.to_continuous_linear_map
@[simp, is_R_or_C_simps] lemma of_real_clm_coe :
((@of_real_clm K _) : ℝ →ₗ[ℝ] K) = of_real_am.to_linear_map := rfl
@[simp, is_R_or_C_simps] lemma of_real_clm_apply : (of_real_clm : ℝ → K) = coe := rfl
@[simp, is_R_or_C_simps] lemma of_real_clm_norm : ∥(of_real_clm : ℝ →L[ℝ] K)∥ = 1 :=
linear_isometry.norm_to_continuous_linear_map of_real_li
@[continuity] lemma continuous_of_real : continuous (coe : ℝ → K) := of_real_li.continuous
@[continuity] lemma continuous_abs : continuous (@is_R_or_C.abs K _) :=
by simp only [show @is_R_or_C.abs K _ = has_norm.norm, by { ext, exact (norm_eq_abs _).symm },
continuous_norm]
@[continuity] lemma continuous_norm_sq : continuous (@is_R_or_C.norm_sq K _) :=
begin
have : (@is_R_or_C.norm_sq K _ : K → ℝ) = λ x, (is_R_or_C.abs x) ^ 2,
{ ext,
exact norm_sq_eq_abs _ },
simp only [this, continuous_abs.pow 2],
end
end linear_maps
end is_R_or_C
|
6b458c4dca9f606fccb87832d85d27c3ea8a4316 | b2fe74b11b57d362c13326bc5651244f111fa6f4 | /src/data/list/chain.lean | 5f9f170b0599b74525fe7c5fcca4fe0ad2812523 | [
"Apache-2.0"
] | permissive | midfield/mathlib | c4db5fa898b5ac8f2f80ae0d00c95eb6f745f4c7 | 775edc615ecec631d65b6180dbcc7bc26c3abc26 | refs/heads/master | 1,675,330,551,921 | 1,608,304,514,000 | 1,608,304,514,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 11,197 | lean | /-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kenny Lau, Yury Kudryashov
-/
import data.list.pairwise
import logic.relation
universes u v
open nat
variables {α : Type u} {β : Type v}
namespace list
/- chain relation (conjunction of R a b ∧ R b c ∧ R c d ...) -/
mk_iff_of_inductive_prop list.chain list.chain_iff
variable {R : α → α → Prop}
theorem rel_of_chain_cons {a b : α} {l : list α}
(p : chain R a (b::l)) : R a b :=
(chain_cons.1 p).1
theorem chain_of_chain_cons {a b : α} {l : list α}
(p : chain R a (b::l)) : chain R b l :=
(chain_cons.1 p).2
theorem chain.imp' {S : α → α → Prop}
(HRS : ∀ ⦃a b⦄, R a b → S a b) {a b : α} (Hab : ∀ ⦃c⦄, R a c → S b c)
{l : list α} (p : chain R a l) : chain S b l :=
by induction p with _ a c l r p IH generalizing b; constructor;
[exact Hab r, exact IH (@HRS _)]
theorem chain.imp {S : α → α → Prop}
(H : ∀ a b, R a b → S a b) {a : α} {l : list α} (p : chain R a l) : chain S a l :=
p.imp' H (H a)
theorem chain.iff {S : α → α → Prop}
(H : ∀ a b, R a b ↔ S a b) {a : α} {l : list α} : chain R a l ↔ chain S a l :=
⟨chain.imp (λ a b, (H a b).1), chain.imp (λ a b, (H a b).2)⟩
theorem chain.iff_mem {a : α} {l : list α} :
chain R a l ↔ chain (λ x y, x ∈ a :: l ∧ y ∈ l ∧ R x y) a l :=
⟨λ p, by induction p with _ a b l r p IH; constructor;
[exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩,
exact IH.imp (λ a b ⟨am, bm, h⟩,
⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩)],
chain.imp (λ a b h, h.2.2)⟩
theorem chain_singleton {a b : α} : chain R a [b] ↔ R a b :=
by simp only [chain_cons, chain.nil, and_true]
theorem chain_split {a b : α} {l₁ l₂ : list α} : chain R a (l₁++b::l₂) ↔
chain R a (l₁++[b]) ∧ chain R b l₂ :=
by induction l₁ with x l₁ IH generalizing a;
simp only [*, nil_append, cons_append, chain.nil, chain_cons, and_true, and_assoc]
theorem chain_map (f : β → α) {b : β} {l : list β} :
chain R (f b) (map f l) ↔ chain (λ a b : β, R (f a) (f b)) b l :=
by induction l generalizing b; simp only [map, chain.nil, chain_cons, *]
theorem chain_of_chain_map {S : β → β → Prop} (f : α → β)
(H : ∀ a b : α, S (f a) (f b) → R a b) {a : α} {l : list α}
(p : chain S (f a) (map f l)) : chain R a l :=
((chain_map f).1 p).imp H
theorem chain_map_of_chain {S : β → β → Prop} (f : α → β)
(H : ∀ a b : α, R a b → S (f a) (f b)) {a : α} {l : list α}
(p : chain R a l) : chain S (f a) (map f l) :=
(chain_map f).2 $ p.imp H
theorem chain_of_pairwise {a : α} {l : list α} (p : pairwise R (a::l)) : chain R a l :=
begin
cases pairwise_cons.1 p with r p', clear p,
induction p' with b l r' p IH generalizing a, {exact chain.nil},
simp only [chain_cons, forall_mem_cons] at r,
exact chain_cons.2 ⟨r.1, IH r'⟩
end
theorem chain_iff_pairwise (tr : transitive R) {a : α} {l : list α} :
chain R a l ↔ pairwise R (a::l) :=
⟨λ c, begin
induction c with b b c l r p IH, {exact pairwise_singleton _ _},
apply IH.cons _, simp only [mem_cons_iff, forall_eq_or_imp, r, true_and],
show ∀ x ∈ l, R b x, from λ x m, (tr r (rel_of_pairwise_cons IH m)),
end, chain_of_pairwise⟩
theorem chain_iff_nth_le {R} : ∀ {a : α} {l : list α},
chain R a l ↔ (∀ h : 0 < length l, R a (nth_le l 0 h)) ∧ (∀ i (h : i < length l - 1),
R (nth_le l i (lt_of_lt_pred h)) (nth_le l (i+1) (lt_pred_iff.mp h)))
| a [] := by simp
| a (b :: t) :=
begin
rw [chain_cons, chain_iff_nth_le],
split,
{ rintros ⟨R, ⟨h0, h⟩⟩,
split,
{ intro w, exact R, },
{ intros i w,
cases i,
{ apply h0, },
{ convert h i _ using 1,
simp only [succ_eq_add_one, add_succ_sub_one, add_zero, length, add_lt_add_iff_right] at w,
exact lt_pred_iff.mpr w, } } },
{ rintros ⟨h0, h⟩, split,
{ apply h0, simp, },
{ split,
{ apply h 0, },
{ intros i w, convert h (i+1) _,
exact lt_pred_iff.mp w, } } },
end
theorem chain'.imp {S : α → α → Prop}
(H : ∀ a b, R a b → S a b) {l : list α} (p : chain' R l) : chain' S l :=
by cases l; [trivial, exact p.imp H]
theorem chain'.iff {S : α → α → Prop}
(H : ∀ a b, R a b ↔ S a b) {l : list α} : chain' R l ↔ chain' S l :=
⟨chain'.imp (λ a b, (H a b).1), chain'.imp (λ a b, (H a b).2)⟩
theorem chain'.iff_mem : ∀ {l : list α}, chain' R l ↔ chain' (λ x y, x ∈ l ∧ y ∈ l ∧ R x y) l
| [] := iff.rfl
| (x::l) :=
⟨λ h, (chain.iff_mem.1 h).imp $ λ a b ⟨h₁, h₂, h₃⟩, ⟨h₁, or.inr h₂, h₃⟩,
chain'.imp $ λ a b h, h.2.2⟩
@[simp] theorem chain'_nil : chain' R [] := trivial
@[simp] theorem chain'_singleton (a : α) : chain' R [a] := chain.nil
theorem chain'_split {a : α} : ∀ {l₁ l₂ : list α}, chain' R (l₁++a::l₂) ↔
chain' R (l₁++[a]) ∧ chain' R (a::l₂)
| [] l₂ := (and_iff_right (chain'_singleton a)).symm
| (b::l₁) l₂ := chain_split
theorem chain'_map (f : β → α) {l : list β} :
chain' R (map f l) ↔ chain' (λ a b : β, R (f a) (f b)) l :=
by cases l; [refl, exact chain_map _]
theorem chain'_of_chain'_map {S : β → β → Prop} (f : α → β)
(H : ∀ a b : α, S (f a) (f b) → R a b) {l : list α}
(p : chain' S (map f l)) : chain' R l :=
((chain'_map f).1 p).imp H
theorem chain'_map_of_chain' {S : β → β → Prop} (f : α → β)
(H : ∀ a b : α, R a b → S (f a) (f b)) {l : list α}
(p : chain' R l) : chain' S (map f l) :=
(chain'_map f).2 $ p.imp H
theorem pairwise.chain' : ∀ {l : list α}, pairwise R l → chain' R l
| [] _ := trivial
| (a::l) h := chain_of_pairwise h
theorem chain'_iff_pairwise (tr : transitive R) : ∀ {l : list α},
chain' R l ↔ pairwise R l
| [] := (iff_true_intro pairwise.nil).symm
| (a::l) := chain_iff_pairwise tr
@[simp] theorem chain'_cons {x y l} : chain' R (x :: y :: l) ↔ R x y ∧ chain' R (y :: l) :=
chain_cons
theorem chain'.cons {x y l} (h₁ : R x y) (h₂ : chain' R (y :: l)) :
chain' R (x :: y :: l) :=
chain'_cons.2 ⟨h₁, h₂⟩
theorem chain'.tail : ∀ {l} (h : chain' R l), chain' R l.tail
| [] _ := trivial
| [x] _ := trivial
| (x :: y :: l) h := (chain'_cons.mp h).right
theorem chain'.rel_head {x y l} (h : chain' R (x :: y :: l)) : R x y :=
rel_of_chain_cons h
theorem chain'.rel_head' {x l} (h : chain' R (x :: l)) ⦃y⦄ (hy : y ∈ head' l) : R x y :=
by { rw ← cons_head'_tail hy at h, exact h.rel_head }
theorem chain'.cons' {x} :
∀ {l : list α}, chain' R l → (∀ y ∈ l.head', R x y) → chain' R (x :: l)
| [] _ _ := chain'_singleton x
| (a :: l) hl H := hl.cons $ H _ rfl
theorem chain'_cons' {x l} : chain' R (x :: l) ↔ (∀ y ∈ head' l, R x y) ∧ chain' R l :=
⟨λ h, ⟨h.rel_head', h.tail⟩, λ ⟨h₁, h₂⟩, h₂.cons' h₁⟩
theorem chain'.append : ∀ {l₁ l₂ : list α} (h₁ : chain' R l₁) (h₂ : chain' R l₂)
(h : ∀ (x ∈ l₁.last') (y ∈ l₂.head'), R x y),
chain' R (l₁ ++ l₂)
| [] l₂ h₁ h₂ h := h₂
| [a] l₂ h₁ h₂ h := h₂.cons' $ h _ rfl
| (a::b::l) l₂ h₁ h₂ h :=
begin
simp only [last'] at h,
have : chain' R (b::l) := h₁.tail,
exact (this.append h₂ h).cons h₁.rel_head
end
theorem chain'_pair {x y} : chain' R [x, y] ↔ R x y :=
by simp only [chain'_singleton, chain'_cons, and_true]
theorem chain'.imp_head {x y} (h : ∀ {z}, R x z → R y z) {l} (hl : chain' R (x :: l)) :
chain' R (y :: l) :=
hl.tail.cons' $ λ z hz, h $ hl.rel_head' hz
theorem chain'_reverse : ∀ {l}, chain' R (reverse l) ↔ chain' (flip R) l
| [] := iff.rfl
| [a] := by simp only [chain'_singleton, reverse_singleton]
| (a :: b :: l) := by rw [chain'_cons, reverse_cons, reverse_cons, append_assoc, cons_append,
nil_append, chain'_split, ← reverse_cons, @chain'_reverse (b :: l), and_comm, chain'_pair, flip]
theorem chain'_iff_nth_le {R} : ∀ {l : list α},
chain' R l ↔ ∀ i (h : i < length l - 1),
R (nth_le l i (lt_of_lt_pred h)) (nth_le l (i+1) (lt_pred_iff.mp h))
| [] := by simp
| (a :: nil) := by simp
| (a :: b :: t) :=
begin
rw [chain'_cons, chain'_iff_nth_le],
split,
{ rintros ⟨R, h⟩ i w,
cases i,
{ exact R, },
{ convert h i _ using 1,
simp only [succ_eq_add_one, add_succ_sub_one, add_zero, length, add_lt_add_iff_right] at w,
simpa using w, },
},
{ rintros h, split,
{ apply h 0, simp, },
{ intros i w, convert h (i+1) _,
simp only [add_zero, length, add_succ_sub_one] at w,
simpa using w, }
},
end
/-- If `l₁ l₂` and `l₃` are lists and `l₁ ++ l₂` and `l₂ ++ l₃` both satisfy
`chain' R`, then so does `l₁ ++ l₂ ++ l₃` provided `l₂ ≠ []` -/
lemma chain'.append_overlap : ∀ {l₁ l₂ l₃ : list α}
(h₁ : chain' R (l₁ ++ l₂)) (h₂ : chain' R (l₂ ++ l₃)) (hn : l₂ ≠ []),
chain' R (l₁ ++ l₂ ++ l₃)
| [] l₂ l₃ h₁ h₂ hn := h₂
| l₁ [] l₃ h₁ h₂ hn := (hn rfl).elim
| [a] (b::l₂) l₃ h₁ h₂ hn := by { simp at *, tauto }
| (a::b::l₁) (c::l₂) l₃ h₁ h₂ hn := begin
simp only [cons_append, chain'_cons] at h₁ h₂ ⊢,
simp only [← cons_append] at h₁ h₂ ⊢,
exact ⟨h₁.1, chain'.append_overlap h₁.2 h₂ (cons_ne_nil _ _)⟩
end
/--
If `a` and `b` are related by the reflexive transitive closure of `r`,
then there is a `r`-chain starting from `a` and ending on `b`.
-/
lemma exists_chain_of_relation_refl_trans_gen {r : α → α → Prop} {a b : α} (h : relation.refl_trans_gen r a b) :
∃ l, chain r a l ∧ last (a :: l) (cons_ne_nil _ _) = b :=
begin
apply relation.refl_trans_gen.head_induction_on h,
{ exact ⟨[], chain.nil, rfl⟩ },
{ intros c d e t ih,
obtain ⟨l, hl₁, hl₂⟩ := ih,
refine ⟨d :: l, chain.cons e hl₁, _⟩,
rwa last_cons_cons }
end
/--
Given a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then
the predicate is true everywhere in the chain and at `a`.
That is, we can propagate the predicate up the chain.
-/
lemma chain.induction {r : α → α → Prop} (p : α → Prop) {a b : α}
(l : list α) (h : chain r a l)
(hb : last (a :: l) (cons_ne_nil _ _) = b)
(carries : ∀ ⦃x y : α⦄, r x y → p y → p x) (final : p b) : ∀ i ∈ a :: l, p i :=
begin
induction l generalizing a,
{ cases hb,
simp [final] },
{ rw chain_cons at h,
rintro _ (rfl | _),
apply carries h.1 (l_ih h.2 hb _ (or.inl rfl)),
apply l_ih h.2 hb _ H }
end
/--
Given a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then
the predicate is true at `a`.
That is, we can propagate the predicate all the way up the chain.
-/
lemma chain.induction_head {r : α → α → Prop} (p : α → Prop) {a b : α}
(l : list α) (h : chain r a l)
(hb : last (a :: l) (cons_ne_nil _ _) = b)
(carries : ∀ ⦃x y : α⦄, r x y → p y → p x) (final : p b) : p a :=
(chain.induction p l h hb carries final) _ (mem_cons_self _ _)
end list
|
c1e3663a205da377e5180fc5b1e1d1ce2bbae8ea | 5ae26df177f810c5006841e9c73dc56e01b978d7 | /src/topology/instances/complex.lean | b55e2f817cc3329c634dd1ca7868045d1f975081 | [
"Apache-2.0"
] | permissive | ChrisHughes24/mathlib | 98322577c460bc6b1fe5c21f42ce33ad1c3e5558 | a2a867e827c2a6702beb9efc2b9282bd801d5f9a | refs/heads/master | 1,583,848,251,477 | 1,565,164,247,000 | 1,565,164,247,000 | 129,409,993 | 0 | 1 | Apache-2.0 | 1,565,164,817,000 | 1,523,628,059,000 | Lean | UTF-8 | Lean | false | false | 6,008 | lean | /-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
Topology of the complex numbers.
-/
import data.complex.basic topology.metric_space.basic topology.instances.real
noncomputable theory
open filter metric
namespace complex
-- TODO(Mario): these proofs are all copied from analysis/real. Generalize
-- to normed fields
instance : metric_space ℂ :=
{ dist := λx y, (x - y).abs,
dist_self := by simp [abs_zero],
eq_of_dist_eq_zero := by simp [add_neg_eq_zero],
dist_comm := assume x y, complex.abs_sub _ _,
dist_triangle := assume x y z, complex.abs_sub_le _ _ _ }
theorem dist_eq (x y : ℂ) : dist x y = (x - y).abs := rfl
theorem uniform_continuous_add : uniform_continuous (λp : ℂ × ℂ, p.1 + p.2) :=
metric.uniform_continuous_iff.2 $ λ ε ε0,
let ⟨δ, δ0, Hδ⟩ := rat_add_continuous_lemma abs ε0 in
⟨δ, δ0, λ a b h, let ⟨h₁, h₂⟩ := max_lt_iff.1 h in Hδ h₁ h₂⟩
theorem uniform_continuous_neg : uniform_continuous (@has_neg.neg ℂ _) :=
metric.uniform_continuous_iff.2 $ λ ε ε0, ⟨_, ε0, λ a b h,
by rw dist_comm at h; simpa [dist_eq] using h⟩
instance : uniform_add_group ℂ :=
uniform_add_group.mk' uniform_continuous_add uniform_continuous_neg
instance : topological_add_group ℂ := by apply_instance
lemma uniform_continuous_inv (s : set ℂ) {r : ℝ} (r0 : 0 < r) (H : ∀ x ∈ s, r ≤ abs x) :
uniform_continuous (λp:s, p.1⁻¹) :=
metric.uniform_continuous_iff.2 $ λ ε ε0,
let ⟨δ, δ0, Hδ⟩ := rat_inv_continuous_lemma abs ε0 r0 in
⟨δ, δ0, λ a b h, Hδ (H _ a.2) (H _ b.2) h⟩
lemma uniform_continuous_abs : uniform_continuous (abs : ℂ → ℝ) :=
metric.uniform_continuous_iff.2 $ λ ε ε0,
⟨ε, ε0, λ a b, lt_of_le_of_lt (abs_abs_sub_le_abs_sub _ _)⟩
lemma continuous_abs : continuous (abs : ℂ → ℝ) :=
uniform_continuous_abs.continuous
lemma tendsto_inv {r : ℂ} (r0 : r ≠ 0) : tendsto (λq, q⁻¹) (nhds r) (nhds r⁻¹) :=
by rw ← abs_pos at r0; exact
tendsto_of_uniform_continuous_subtype
(uniform_continuous_inv {x | abs r / 2 < abs x} (half_pos r0) (λ x h, le_of_lt h))
(mem_nhds_sets (continuous_abs _ $ is_open_lt' (abs r / 2)) (half_lt_self r0))
lemma continuous_inv' : continuous (λa:{r:ℂ // r ≠ 0}, a.val⁻¹) :=
continuous_iff_continuous_at.mpr $ assume ⟨r, hr⟩,
tendsto.comp (tendsto_inv hr) (continuous_iff_continuous_at.mp continuous_subtype_val _)
lemma continuous_inv {α} [topological_space α] {f : α → ℂ} (h : ∀a, f a ≠ 0) (hf : continuous f) :
continuous (λa, (f a)⁻¹) :=
show continuous ((has_inv.inv ∘ @subtype.val ℂ (λr, r ≠ 0)) ∘ λa, ⟨f a, h a⟩),
from continuous_inv'.comp (continuous_subtype_mk _ hf)
lemma uniform_continuous_mul_const {x : ℂ} : uniform_continuous ((*) x) :=
metric.uniform_continuous_iff.2 $ λ ε ε0, begin
cases no_top (abs x) with y xy,
have y0 := lt_of_le_of_lt (abs_nonneg _) xy,
refine ⟨_, div_pos ε0 y0, λ a b h, _⟩,
rw [dist_eq, ← mul_sub, abs_mul, ← mul_div_cancel' ε (ne_of_gt y0)],
exact mul_lt_mul' (le_of_lt xy) h (abs_nonneg _) y0
end
lemma uniform_continuous_mul (s : set (ℂ × ℂ))
{r₁ r₂ : ℝ} (H : ∀ x ∈ s, abs (x : ℂ × ℂ).1 < r₁ ∧ abs x.2 < r₂) :
uniform_continuous (λp:s, p.1.1 * p.1.2) :=
metric.uniform_continuous_iff.2 $ λ ε ε0,
let ⟨δ, δ0, Hδ⟩ := rat_mul_continuous_lemma abs ε0 in
⟨δ, δ0, λ a b h,
let ⟨h₁, h₂⟩ := max_lt_iff.1 h in Hδ (H _ a.2).1 (H _ b.2).2 h₁ h₂⟩
protected lemma continuous_mul : continuous (λp : ℂ × ℂ, p.1 * p.2) :=
continuous_iff_continuous_at.2 $ λ ⟨a₁, a₂⟩,
tendsto_of_uniform_continuous_subtype
(uniform_continuous_mul
({x | abs x < abs a₁ + 1}.prod {x | abs x < abs a₂ + 1})
(λ x, id))
(mem_nhds_sets
(is_open_prod
(continuous_abs _ $ is_open_gt' (abs a₁ + 1))
(continuous_abs _ $ is_open_gt' (abs a₂ + 1)))
⟨lt_add_one (abs a₁), lt_add_one (abs a₂)⟩)
local attribute [semireducible] real.le
lemma uniform_continuous_re : uniform_continuous re :=
metric.uniform_continuous_iff.2 (λ ε ε0, ⟨ε, ε0, λ _ _, lt_of_le_of_lt (abs_re_le_abs _)⟩)
lemma continuous_re : continuous re := uniform_continuous_re.continuous
lemma uniform_continuous_im : uniform_continuous im :=
metric.uniform_continuous_iff.2 (λ ε ε0, ⟨ε, ε0, λ _ _, lt_of_le_of_lt (abs_im_le_abs _)⟩)
lemma continuous_im : continuous im := uniform_continuous_im.continuous
lemma uniform_continuous_of_real : uniform_continuous of_real :=
metric.uniform_continuous_iff.2 (λ ε ε0, ⟨ε, ε0, λ _ _,
by rw [real.dist_eq, complex.dist_eq, of_real_eq_coe, of_real_eq_coe, ← of_real_sub, abs_of_real];
exact id⟩)
lemma continuous_of_real : continuous of_real := uniform_continuous_of_real.continuous
instance : topological_ring ℂ :=
{ continuous_mul := complex.continuous_mul, ..complex.topological_add_group }
instance : topological_semiring ℂ := by apply_instance
def real_prod_homeo : homeomorph ℂ (ℝ × ℝ) :=
{ to_equiv := real_prod_equiv,
continuous_to_fun := continuous.prod_mk continuous_re continuous_im,
continuous_inv_fun := show continuous (λ p : ℝ × ℝ, complex.mk p.1 p.2),
by simp only [mk_eq_add_mul_I]; exact
continuous_add
(continuous_of_real.comp continuous_fst)
(continuous_mul (continuous_of_real.comp continuous_snd) continuous_const) }
instance : proper_space ℂ :=
⟨λx r, begin
refine real_prod_homeo.symm.compact_preimage.1
(compact_of_is_closed_subset
(compact_prod _ _ (proper_space.compact_ball x.re r) (proper_space.compact_ball x.im r))
(continuous_iff_is_closed.1 real_prod_homeo.symm.continuous _ is_closed_ball) _),
exact λ p h, ⟨
le_trans (abs_re_le_abs (⟨p.1, p.2⟩ - x)) h,
le_trans (abs_im_le_abs (⟨p.1, p.2⟩ - x)) h⟩
end⟩
end complex
|
ba2bca84fa25a966abf5884782da7be3bca319e7 | d7189ea2ef694124821b033e533f18905b5e87ef | /galois/sum.lean | cb773c8c8e9a9f839bd5047212698412341346d5 | [
"Apache-2.0"
] | permissive | digama0/lean-protocol-support | eaa7e6f8b8e0d5bbfff1f7f52bfb79a3b11b0f59 | cabfa3abedbdd6fdca6e2da6fbbf91a13ed48dda | refs/heads/master | 1,625,421,450,627 | 1,506,035,462,000 | 1,506,035,462,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,495 | lean | def sum.left {a b} : a ⊕ b → option a
| (sum.inl a) := option.some a
| (sum.inr b) := option.none
def sum.right {a b} : a ⊕ b → option b
| (sum.inl a) := option.none
| (sum.inr b) := option.some b
def sum.fmap {c a b} : (a → b) → c ⊕ a → c ⊕ b
| f (sum.inl e) := sum.inl e
| f (sum.inr v) := sum.inr (f v)
def sum.bind {c a b} : c ⊕ a → (a → c ⊕ b) → c ⊕ b
| (sum.inl e) f := sum.inl e
| (sum.inr a) f := f a
instance sum_is_monad {e} : monad (sum e) :=
{ pure := @sum.inr e
, bind := @sum.bind e
, id_map := λα x,
begin
-- Split on x having form(inl y) or (inr y)
cases x,
-- Simplify each goal after exposing definitions
all_goals { simp [monad.map._default, sum.bind, function.comp], },
end
, pure_bind := λα β x f, by simp [sum.bind]
, bind_assoc :=
begin
intros α β γ x f g,
cases x,
all_goals { simp [sum.bind] },
end
}
namespace sum
universe variable u
variables {α β e γ : Type u}
@[simp]
theorem map_inl (f : α → β) (x : e) : f <$> (@sum.inl e α x) = sum.inl x := rfl
@[simp]
theorem map_inr (f : α → β) (x : α) : f <$> (@sum.inr e α x) = sum.inr (f x) := rfl
@[simp]
theorem inl_bind (x : e) (h : α → sum e β) : (@sum.inl e α x) >>= h = sum.inl x := rfl
@[simp]
theorem inr_bind (x : α) (f : α → e ⊕ β) : (sum.inr x >>= f) = f x := rfl
def orelse : e ⊕ β → α ⊕ β → α ⊕ β
| (sum.inl _) y := y
| (sum.inr x) _ := sum.inr x
end sum
|
f3d2613c6e5f4e255982ae12f1431dd8812df28c | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/tactic/slim_check.lean | 4f113362deb405f666b3210425c24ceb745ea490 | [] | 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 | 3,753 | lean | /-
Copyright (c) 2020 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Simon Hudon
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.testing.slim_check.testable
import Mathlib.testing.slim_check.functions
import Mathlib.data.list.sort
import Mathlib.PostPort
namespace Mathlib
/-!
## Finding counterexamples automatically using `slim_check`
A proposition can be tested by writing it out as:
```lean
example (xs : list ℕ) (w : ∃ x ∈ xs, x < 3) : ∀ y ∈ xs, y < 5 := by slim_check
-- ===================
-- ===================
-- Found problems!
-- Found problems!
-- xs := [0, 5]
-- xs := [0, 5]
-- x := 0
-- x := 0
-- y := 5
-- y := 5
-- -------------------
-- -------------------
example (x : ℕ) (h : 2 ∣ x) : x < 100 := by slim_check
-- ===================
-- ===================
-- Found problems!
-- Found problems!
-- x := 258
-- x := 258
-- -------------------
-- -------------------
example (α : Type) (xs ys : list α) : xs ++ ys = ys ++ xs := by slim_check
-- ===================
-- ===================
-- Found problems!
-- Found problems!
-- α := ℤ
-- α := ℤ
-- xs := [-4]
-- xs := [-4]
-- ys := [1]
-- ys := [1]
-- -------------------
-- -------------------
example : ∀ x ∈ [1,2,3], x < 4 := by slim_check
-- Success
-- Success
```
In the first example, `slim_check` is called on the following goal:
```lean
xs : list ℕ,
h : ∃ (x : ℕ) (H : x ∈ xs), x < 3
⊢ ∀ (y : ℕ), y ∈ xs → y < 5
```
The local constants are reverted and an instance is found for
`testable (∀ (xs : list ℕ), (∃ x ∈ xs, x < 3) → (∀ y ∈ xs, y < 5))`.
The `testable` instance is supported by instances of `sampleable (list ℕ)`,
`decidable (x < 3)` and `decidable (y < 5)`. `slim_check` builds a
`testable` instance step by step with:
```
- testable (∀ (xs : list ℕ), (∃ x ∈ xs, x < 3) → (∀ y ∈ xs, y < 5))
-: sampleable (list xs)
- testable ((∃ x ∈ xs, x < 3) → (∀ y ∈ xs, y < 5))
- testable (∀ x ∈ xs, x < 3 → (∀ y ∈ xs, y < 5))
- testable (x < 3 → (∀ y ∈ xs, y < 5))
-: decidable (x < 3)
- testable (∀ y ∈ xs, y < 5)
-: decidable (y < 5)
```
`sampleable (list ℕ)` lets us create random data of type `list ℕ` in a way that
helps find small counter-examples. Next, the test of the proposition
hinges on `x < 3` and `y < 5` to both be decidable. The
implication between the two could be tested as a whole but it would be
less informative. Indeed, if we generate lists that only contain numbers
greater than `3`, the implication will always trivially hold but we should
conclude that we haven't found meaningful examples. Instead, when `x < 3`
does not hold, we reject the example (i.e. we do not count it toward
the 100 required positive examples) and we start over. Therefore, when
`slim_check` prints `Success`, it means that a hundred suitable lists
were found and successfully tested.
If no counter-examples are found, `slim_check` behaves like `admit`.
`slim_check` can also be invoked using `#eval`:
```lean
#eval slim_check.testable.check (∀ (α : Type) (xs ys : list α), xs ++ ys = ys ++ xs)
-- ===================
-- ===================
-- Found problems!
-- Found problems!
-- α := ℤ
-- α := ℤ
-- xs := [-4]
-- xs := [-4]
-- ys := [1]
-- ys := [1]
-- -------------------
-- -------------------
```
For more information on writing your own `sampleable` and `testable`
instances, see `testing.slim_check.testable`.
-/
namespace tactic.interactive
/-- Tree structure representing a `testable` instance. -/
|
b37f895ed1c2fc41b952f4a46e53ff1261fb1021 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/run/cases_crash1.lean | 544c864ffc8f3b12288c326d02813a0f05b8db79 | [
"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 | 362 | lean | open tactic
axiom Sorry : ∀ A : Type, A
inductive Enum : Type | ea | eb | ec | ed
attribute [instance]
noncomputable definition Enum_dec_eq : decidable_eq Enum :=
by do a ← intro `a, cases a,
b ← intro `b, cases b,
right >> reflexivity,
try (do left, h ← intro `H, cases h),
repeat $ intros >> mk_const `Sorry >>= apply >> skip
|
ba1c7e1d066090277fe55cf7317745f0b45f12f7 | e0f9ba56b7fedc16ef8697f6caeef5898b435143 | /src/ring_theory/integral_domain.lean | 1790c47f1d53487c257e44231299ff78a51885b7 | [
"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 | 5,250 | lean | /-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Chris Hughes
-/
import data.fintype.card
import data.polynomial
import group_theory.order_of_element
import algebra.geom_sum
/-!
# Integral domains
-/
section
open finset polynomial
variables {R : Type*} [integral_domain R] (S : set (units R)) [is_subgroup S] [fintype S]
lemma card_nth_roots_subgroup_units [decidable_eq R] {n : ℕ} (hn : 0 < n) (a : S) :
(univ.filter (λ b : S, b ^ n = a)).card ≤ (nth_roots n ((a : units R) : R)).card :=
card_le_card_of_inj_on (λ a, ((a : units R) : R))
(by simp [mem_nth_roots hn, (units.coe_pow _ _).symm, -units.coe_pow, units.ext_iff.symm, subtype.coe_ext])
(by simp [units.ext_iff.symm, subtype.coe_ext.symm])
instance subgroup_units_cyclic : is_cyclic S :=
by haveI := classical.dec_eq R; exact
is_cyclic_of_card_pow_eq_one_le
(λ n hn, le_trans (card_nth_roots_subgroup_units S hn 1) (card_nth_roots _ _))
end
section
variables {G : Type*} {R : Type*} [group G] [integral_domain R]
open_locale big_operators nat
open finset
lemma card_fiber_eq_of_mem_range [fintype G]
{H : Type*} [group H] [decidable_eq H] (f : G →* H) {x y : H}
(hx : x ∈ set.range f) (hy : y ∈ set.range f) :
(univ.filter $ λ g, f g = x).card = (univ.filter $ λ g, f g = y).card :=
begin
rcases hx with ⟨x, rfl⟩,
rcases hy with ⟨y, rfl⟩,
refine card_congr (λ g _, g * x⁻¹ * y) _ _ (λ g hg, ⟨g * y⁻¹ * x, _⟩),
{ simp only [mem_filter, one_mul, monoid_hom.map_mul, mem_univ, mul_right_inv,
eq_self_iff_true, monoid_hom.map_mul_inv, and_self, forall_true_iff] {contextual := tt} },
{ simp only [mul_left_inj, imp_self, forall_2_true_iff], },
{ simp only [true_and, mem_filter, mem_univ] at hg,
simp only [hg, mem_filter, one_mul, monoid_hom.map_mul, mem_univ, mul_right_inv,
eq_self_iff_true, exists_prop_of_true, monoid_hom.map_mul_inv, and_self,
mul_inv_cancel_right, inv_mul_cancel_right], }
end
variables {G} [fintype G]
/-- In an integral domain, a sum indexed by a nontrivial homomorphism from a finite group is zero. -/
lemma sum_hom_units_eq_zero (f : G →* R) (hf : f ≠ 1) : ∑ g : G, f g = 0 :=
begin
classical,
obtain ⟨x, hx⟩ : ∃ x : set.range f.to_hom_units, ∀ y : set.range f.to_hom_units, y ∈ powers x,
from is_cyclic.exists_monoid_generator (set.range (f.to_hom_units)),
have hx1 : x ≠ 1,
{ rintro rfl,
apply hf,
ext g,
rw [monoid_hom.one_apply],
cases hx ⟨f.to_hom_units g, g, rfl⟩ with n hn,
rwa [subtype.coe_ext, units.ext_iff, subtype.coe_mk, monoid_hom.coe_to_hom_units,
is_submonoid.coe_pow, units.coe_pow, is_submonoid.coe_one, units.coe_one,
_root_.one_pow, eq_comm] at hn, },
replace hx1 : (x : R) - 1 ≠ 0,
from λ h, hx1 (subtype.eq (units.ext (sub_eq_zero.1 h))),
let c := (univ.filter (λ g, f.to_hom_units g = 1)).card,
calc ∑ g : G, f g
= ∑ g : G, f.to_hom_units g : rfl
... = ∑ u : units R in univ.image f.to_hom_units, (univ.filter (λ g, f.to_hom_units g = u)).card • u :
sum_comp (coe : units R → R) f.to_hom_units
... = ∑ u : units R in univ.image f.to_hom_units, c • u :
sum_congr rfl (λ u hu, congr_arg2 _ _ rfl) -- remaining goal 1, proven below
... = ∑ b : set.range f.to_hom_units, c • ↑b : finset.sum_subtype
(by simp only [mem_image, set.mem_range, forall_const, iff_self, mem_univ, exists_prop_of_true]) _
... = c • ∑ b : set.range f.to_hom_units, (b : R) : smul_sum.symm
... = c • 0 : congr_arg2 _ rfl _ -- remaining goal 2, proven below
... = 0 : smul_zero _,
{ -- remaining goal 1
show (univ.filter (λ (g : G), f.to_hom_units g = u)).card = c,
apply card_fiber_eq_of_mem_range f.to_hom_units,
{ simpa only [mem_image, mem_univ, exists_prop_of_true, set.mem_range] using hu, },
{ exact ⟨1, f.to_hom_units.map_one⟩ } },
-- remaining goal 2
show ∑ b : set.range f.to_hom_units, (b : R) = 0,
calc ∑ b : set.range f.to_hom_units, (b : R)
= ∑ n in range (order_of x), x ^ n :
eq.symm $ sum_bij (λ n _, x ^ n)
(by simp only [mem_univ, forall_true_iff])
(by simp only [is_submonoid.coe_pow, eq_self_iff_true, units.coe_pow, coe_coe, forall_true_iff])
(λ m n hm hn, pow_injective_of_lt_order_of _
(by simpa only [mem_range] using hm)
(by simpa only [mem_range] using hn))
(λ b hb, let ⟨n, hn⟩ := hx b in ⟨n % order_of x, mem_range.2 (nat.mod_lt _ (order_of_pos _)),
by rw [← pow_eq_mod_order_of, hn]⟩)
... = 0 : _,
rw [← domain.mul_left_inj hx1, zero_mul, ← geom_series, geom_sum_mul, coe_coe],
norm_cast,
rw [pow_order_of_eq_one, is_submonoid.coe_one, units.coe_one, sub_self],
end
/-- In an integral domain, a sum indexed by a homomorphism from a finite group is zero,
unless the homomorphism is trivial, in which case the sum is equal to the cardinality of the group. -/
lemma sum_hom_units (f : G →* R) [decidable (f = 1)] :
∑ g : G, f g = if f = 1 then fintype.card G else 0 :=
begin
split_ifs with h h,
{ simp [h, card_univ] },
{ exact sum_hom_units_eq_zero f h }
end
end
|
a060e45b52a36901b92bcac77c58adac37f069d2 | e00ea76a720126cf9f6d732ad6216b5b824d20a7 | /src/tactic/interactive.lean | b9e3508914416e328539fc27b6dceacd211b5e34 | [
"Apache-2.0"
] | permissive | vaibhavkarve/mathlib | a574aaf68c0a431a47fa82ce0637f0f769826bfe | 17f8340912468f49bdc30acdb9a9fa02eeb0473a | refs/heads/master | 1,621,263,802,637 | 1,585,399,588,000 | 1,585,399,588,000 | 250,833,447 | 0 | 0 | Apache-2.0 | 1,585,410,341,000 | 1,585,410,341,000 | null | UTF-8 | Lean | false | false | 41,805 | lean |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Simon Hudon, Sebastien Gouezel, Scott Morrison
-/
import tactic.lint
open lean
open lean.parser
local postfix `?`:9001 := optional
local postfix *:9001 := many
namespace tactic
namespace interactive
open interactive interactive.types expr
/-- Similar to `constructor`, but does not reorder goals. -/
meta def fconstructor : tactic unit := concat_tags tactic.fconstructor
add_tactic_doc
{ name := "fconstructor",
category := doc_category.tactic,
decl_names := [`tactic.interactive.fconstructor],
tags := ["logic", "goal management"] }
/-- `try_for n { tac }` executes `tac` for `n` ticks, otherwise uses `sorry` to close the goal.
Never fails. Useful for debugging. -/
meta def try_for (max : parse parser.pexpr) (tac : itactic) : tactic unit :=
do max ← i_to_expr_strict max >>= tactic.eval_expr nat,
λ s, match _root_.try_for max (tac s) with
| some r := r
| none := (tactic.trace "try_for timeout, using sorry" >> admit) s
end
/-- Multiple `subst`. `substs x y z` is the same as `subst x, subst y, subst z`. -/
meta def substs (l : parse ident*) : tactic unit :=
l.mmap' (λ h, get_local h >>= tactic.subst) >> try (tactic.reflexivity reducible)
add_tactic_doc
{ name := "substs",
category := doc_category.tactic,
decl_names := [`tactic.interactive.substs],
tags := ["rewrite"] }
/-- Unfold coercion-related definitions -/
meta def unfold_coes (loc : parse location) : tactic unit :=
unfold [
``coe, ``coe_t, ``has_coe_t.coe, ``coe_b,``has_coe.coe,
``lift, ``has_lift.lift, ``lift_t, ``has_lift_t.lift,
``coe_fn, ``has_coe_to_fun.coe, ``coe_sort, ``has_coe_to_sort.coe] loc
add_tactic_doc
{ name := "unfold_coes",
category := doc_category.tactic,
decl_names := [`tactic.interactive.unfold_coes],
tags := ["simplification"] }
/-- Unfold auxiliary definitions associated with the current declaration. -/
meta def unfold_aux : tactic unit :=
do tgt ← target,
name ← decl_name,
let to_unfold := (tgt.list_names_with_prefix name),
guard (¬ to_unfold.empty),
-- should we be using simp_lemmas.mk_default?
simp_lemmas.mk.dsimplify to_unfold.to_list tgt >>= tactic.change
/-- For debugging only. This tactic checks the current state for any
missing dropped goals and restores them. Useful when there are no
goals to solve but "result contains meta-variables". -/
meta def recover : tactic unit :=
metavariables >>= tactic.set_goals
/-- Like `try { tac }`, but in the case of failure it continues
from the failure state instead of reverting to the original state. -/
meta def continue (tac : itactic) : tactic unit :=
λ s, result.cases_on (tac s)
(λ a, result.success ())
(λ e ref, result.success ())
/--
`swap n` will move the `n`th goal to the front.
`swap` defaults to `swap 2`, and so interchanges the first and second goals.
-/
meta def swap (n := 2) : tactic unit :=
do gs ← get_goals,
match gs.nth (n-1) with
| (some g) := set_goals (g :: gs.remove_nth (n-1))
| _ := skip
end
add_tactic_doc
{ name := "swap",
category := doc_category.tactic,
decl_names := [`tactic.interactive.swap],
tags := ["goal management"] }
/-- `rotate` moves the first goal to the back. `rotate n` will do this `n` times. -/
meta def rotate (n := 1) : tactic unit := tactic.rotate n
add_tactic_doc
{ name := "rotate",
category := doc_category.tactic,
decl_names := [`tactic.interactive.rotate],
tags := ["goal management"] }
/-- Clear all hypotheses starting with `_`, like `_match` and `_let_match`. -/
meta def clear_ : tactic unit := tactic.repeat $ do
l ← local_context,
l.reverse.mfirst $ λ h, do
name.mk_string s p ← return $ local_pp_name h,
guard (s.front = '_'),
cl ← infer_type h >>= is_class, guard (¬ cl),
tactic.clear h
add_tactic_doc
{ name := "clear_",
category := doc_category.tactic,
decl_names := [`tactic.interactive.clear_],
tags := ["context management"] }
meta def apply_iff_congr_core : tactic unit :=
applyc ``iff_of_eq
meta def congr_core' : tactic unit :=
do tgt ← target,
apply_eq_congr_core tgt
<|> apply_heq_congr_core
<|> apply_iff_congr_core
<|> fail "congr tactic failed"
/--
Same as the `congr` tactic, but takes an optional argument which gives
the depth of recursive applications. This is useful when `congr`
is too aggressive in breaking down the goal. For example, given
`⊢ f (g (x + y)) = f (g (y + x))`, `congr'` produces the goals `⊢ x = y`
and `⊢ y = x`, while `congr' 2` produces the intended `⊢ x + y = y + x`.
If, at any point, a subgoal matches a hypothesis then the subgoal will be closed. -/
meta def congr' : parse (with_desc "n" small_nat)? → tactic unit
| (some 0) := failed
| o := focus1 (assumption <|> (congr_core' >>
all_goals (reflexivity <|> `[apply proof_irrel_heq] <|>
`[apply proof_irrel] <|> try (congr' (nat.pred <$> o)))))
add_tactic_doc
{ name := "congr'",
category := doc_category.tactic,
decl_names := [`tactic.interactive.congr', `tactic.interactive.congr],
tags := ["congruence"],
inherit_description_from := `tactic.interactive.congr' }
/--
Acts like `have`, but removes a hypothesis with the same name as
this one. For example if the state is `h : p ⊢ goal` and `f : p → q`,
then after `replace h := f h` the goal will be `h : q ⊢ goal`,
where `have h := f h` would result in the state `h : p, h : q ⊢ goal`.
This can be used to simulate the `specialize` and `apply at` tactics
of Coq. -/
meta def replace (h : parse ident?) (q₁ : parse (tk ":" *> texpr)?)
(q₂ : parse $ (tk ":=" *> texpr)?) : tactic unit :=
do let h := h.get_or_else `this,
old ← try_core (get_local h),
«have» h q₁ q₂,
match old, q₂ with
| none, _ := skip
| some o, some _ := tactic.clear o
| some o, none := swap >> tactic.clear o >> swap
end
add_tactic_doc
{ name := "replace",
category := doc_category.tactic,
decl_names := [`tactic.interactive.replace],
tags := ["context management"] }
/-- Make every proposition in the context decidable. -/
meta def classical := tactic.classical
add_tactic_doc
{ name := "classical",
category := doc_category.tactic,
decl_names := [`tactic.interactive.classical],
tags := ["classical logic", "type class"] }
private meta def generalize_arg_p_aux : pexpr → parser (pexpr × name)
| (app (app (macro _ [const `eq _ ]) h) (local_const x _ _ _)) := pure (h, x)
| _ := fail "parse error"
private meta def generalize_arg_p : parser (pexpr × name) :=
with_desc "expr = id" $ parser.pexpr 0 >>= generalize_arg_p_aux
@[nolint def_lemma]
lemma {u} generalize_a_aux {α : Sort u}
(h : ∀ x : Sort u, (α → x) → x) : α := h α id
/--
Like `generalize` but also considers assumptions
specified by the user. The user can also specify to
omit the goal.
-/
meta def generalize_hyp (h : parse ident?) (_ : parse $ tk ":")
(p : parse generalize_arg_p)
(l : parse location) :
tactic unit :=
do h' ← get_unused_name `h,
x' ← get_unused_name `x,
g ← if ¬ l.include_goal then
do refine ``(generalize_a_aux _),
some <$> (prod.mk <$> tactic.intro x' <*> tactic.intro h')
else pure none,
n ← l.get_locals >>= tactic.revert_lst,
generalize h () p,
intron n,
match g with
| some (x',h') :=
do tactic.apply h',
tactic.clear h',
tactic.clear x'
| none := return ()
end
add_tactic_doc
{ name := "generalize_hyp",
category := doc_category.tactic,
decl_names := [`tactic.interactive.generalize_hyp],
tags := ["context management"] }
/--
The `exact e` and `refine e` tactics require a term `e` whose type is
definitionally equal to the goal. `convert e` is similar to `refine
e`, but the type of `e` is not required to exactly match the
goal. Instead, new goals are created for differences between the type
of `e` and the goal. For example, in the proof state
```lean
n : ℕ,
e : prime (2 * n + 1)
⊢ prime (n + n + 1)
```
the tactic `convert e` will change the goal to
```lean
⊢ n + n = 2 * n
```
In this example, the new goal can be solved using `ring`.
The syntax `convert ← e` will reverse the direction of the new goals
(producing `⊢ 2 * n = n + n` in this example).
Internally, `convert e` works by creating a new goal asserting that
the goal equals the type of `e`, then simplifying it using
`congr'`. The syntax `convert e using n` can be used to control the
depth of matching (like `congr' n`). In the example, `convert e using
1` would produce a new goal `⊢ n + n + 1 = 2 * n + 1`.
-/
meta def convert (sym : parse (with_desc "←" (tk "<-")?)) (r : parse texpr)
(n : parse (tk "using" *> small_nat)?) : tactic unit :=
do v ← mk_mvar,
if sym.is_some
then refine ``(eq.mp %%v %%r)
else refine ``(eq.mpr %%v %%r),
gs ← get_goals,
set_goals [v],
try (congr' n),
gs' ← get_goals,
set_goals $ gs' ++ gs
add_tactic_doc
{ name := "convert",
category := doc_category.tactic,
decl_names := [`tactic.interactive.convert],
tags := ["congruence"] }
meta def compact_decl_aux : list name → binder_info → expr → list expr →
tactic (list (list name × binder_info × expr))
| ns bi t [] := pure [(ns.reverse, bi, t)]
| ns bi t (v'@(local_const n pp bi' t') :: xs) :=
do t' ← get_local pp >>= infer_type,
if bi = bi' ∧ t = t'
then compact_decl_aux (pp :: ns) bi t xs
else do vs ← compact_decl_aux [pp] bi' t' xs,
pure $ (ns.reverse, bi, t) :: vs
| ns bi t (_ :: xs) := compact_decl_aux ns bi t xs
/-- go from (x₀ : t₀) (x₁ : t₀) (x₂ : t₀) to (x₀ x₁ x₂ : t₀) -/
meta def compact_decl : list expr → tactic (list (list name × binder_info × expr))
| [] := pure []
| (v@(local_const n pp bi t) :: xs) :=
do t ← infer_type v,
compact_decl_aux [pp] bi t xs
| (_ :: xs) := compact_decl xs
meta def clean_ids : list name :=
[``id, ``id_rhs, ``id_delta, ``hidden]
/--
Remove identity functions from a term. These are normally
automatically generated with terms like `show t, from p` or
`(p : t)` which translate to some variant on `@id t p` in
order to retain the type. -/
meta def clean (q : parse texpr) : tactic unit :=
do tgt : expr ← target,
e ← i_to_expr_strict ``(%%q : %%tgt),
tactic.exact $ e.replace (λ e n,
match e with
| (app (app (const n _) _) e') :=
if n ∈ clean_ids then some e' else none
| (app (lam _ _ _ (var 0)) e') := some e'
| _ := none
end)
meta def source_fields (missing : list name) (e : pexpr) : tactic (list (name × pexpr)) :=
do e ← to_expr e,
t ← infer_type e,
let struct_n : name := t.get_app_fn.const_name,
fields ← expanded_field_list struct_n,
let exp_fields := fields.filter (λ x, x.2 ∈ missing),
exp_fields.mmap $ λ ⟨p,n⟩,
(prod.mk n ∘ to_pexpr) <$> mk_mapp (n.update_prefix p) [none,some e]
meta def collect_struct' : pexpr → state_t (list $ expr×structure_instance_info) tactic pexpr | e :=
do some str ← pure (e.get_structure_instance_info)
| e.traverse collect_struct',
v ← monad_lift mk_mvar,
modify (list.cons (v,str)),
pure $ to_pexpr v
meta def collect_struct (e : pexpr) : tactic $ pexpr × list (expr×structure_instance_info) :=
prod.map id list.reverse <$> (collect_struct' e).run []
meta def refine_one (str : structure_instance_info) :
tactic $ list (expr×structure_instance_info) :=
do tgt ← target,
let struct_n : name := tgt.get_app_fn.const_name,
exp_fields ← expanded_field_list struct_n,
let missing_f := exp_fields.filter (λ f, (f.2 : name) ∉ str.field_names),
(src_field_names,src_field_vals) ← (@list.unzip name _ ∘ list.join) <$>
str.sources.mmap (source_fields $ missing_f.map prod.snd),
let provided := exp_fields.filter (λ f, (f.2 : name) ∈ str.field_names),
let missing_f' := missing_f.filter (λ x, x.2 ∉ src_field_names),
vs ← mk_mvar_list missing_f'.length,
(field_values,new_goals) ← list.unzip <$> (str.field_values.mmap collect_struct : tactic _),
e' ← to_expr $ pexpr.mk_structure_instance
{ struct := some struct_n
, field_names := str.field_names ++ missing_f'.map prod.snd ++ src_field_names
, field_values := field_values ++ vs.map to_pexpr ++ src_field_vals },
tactic.exact e',
gs ← with_enable_tags (
mzip_with (λ (n : name × name) v, do
set_goals [v],
try (interactive.unfold (provided.map $ λ ⟨s,f⟩, f.update_prefix s) (loc.ns [none])),
apply_auto_param
<|> apply_opt_param
<|> (set_main_tag [`_field,n.2,n.1]),
get_goals)
missing_f' vs),
set_goals gs.join,
return new_goals.join
meta def refine_recursively : expr × structure_instance_info → tactic (list expr) | (e,str) :=
do set_goals [e],
rs ← refine_one str,
gs ← get_goals,
gs' ← rs.mmap refine_recursively,
return $ gs'.join ++ gs
/--
`refine_struct { .. }` acts like `refine` but works only with structure instance
literals. It creates a goal for each missing field and tags it with the name of the
field so that `have_field` can be used to generically refer to the field currently
being refined.
As an example, we can use `refine_struct` to automate the construction semigroup
instances:
```lean
refine_struct ( { .. } : semigroup α ),
-- case semigroup, mul
-- α : Type u,
-- ⊢ α → α → α
-- case semigroup, mul_assoc
-- α : Type u,
-- ⊢ ∀ (a b c : α), a * b * c = a * (b * c)
```
`have_field`, used after `refine_struct _`, poses `field` as a local constant
with the type of the field of the current goal:
```lean
refine_struct ({ .. } : semigroup α),
{ have_field, ... },
{ have_field, ... },
```
behaves like
```lean
refine_struct ({ .. } : semigroup α),
{ have field := @semigroup.mul, ... },
{ have field := @semigroup.mul_assoc, ... },
```
-/
meta def refine_struct : parse texpr → tactic unit | e :=
do (x,xs) ← collect_struct e,
refine x,
gs ← get_goals,
xs' ← xs.mmap refine_recursively,
set_goals (xs'.join ++ gs)
/--
`guard_hyp h := t` fails if the hypothesis `h` does not have type `t`.
We use this tactic for writing tests.
Fixes `guard_hyp` by instantiating meta variables
-/
meta def guard_hyp' (n : parse ident) (p : parse $ tk ":=" *> texpr) : tactic unit :=
do h ← get_local n >>= infer_type >>= instantiate_mvars, guard_expr_eq h p
/--
`guard_expr_strict t := e` fails if the expr `t` is not equal to `e`. By contrast
to `guard_expr`, this tests strict (syntactic) equality.
We use this tactic for writing tests.
-/
meta def guard_expr_strict (t : expr) (p : parse $ tk ":=" *> texpr) : tactic unit :=
do e ← to_expr p, guard (t = e)
/--
`guard_target_strict t` fails if the target of the main goal is not syntactically `t`.
We use this tactic for writing tests.
-/
meta def guard_target_strict (p : parse texpr) : tactic unit :=
do t ← target, guard_expr_strict t p
/--
`guard_hyp_strict h := t` fails if the hypothesis `h` does not have type syntactically equal
to `t`.
We use this tactic for writing tests.
-/
meta def guard_hyp_strict (n : parse ident) (p : parse $ tk ":=" *> texpr) : tactic unit :=
do h ← get_local n >>= infer_type >>= instantiate_mvars, guard_expr_strict h p
meta def guard_hyp_nums (n : ℕ) : tactic unit :=
do k ← local_context,
guard (n = k.length) <|> fail format!"{k.length} hypotheses found"
meta def guard_tags (tags : parse ident*) : tactic unit :=
do (t : list name) ← get_main_tag,
guard (t = tags)
/-- `success_if_fail_with_msg { tac } msg` succeeds if the interactive tactic `tac` fails with
error message `msg` (for test writing purposes). -/
meta def success_if_fail_with_msg (tac : tactic.interactive.itactic) :=
tactic.success_if_fail_with_msg tac
meta def get_current_field : tactic name :=
do [_,field,str] ← get_main_tag,
expr.const_name <$> resolve_name (field.update_prefix str)
meta def field (n : parse ident) (tac : itactic) : tactic unit :=
do gs ← get_goals,
ts ← gs.mmap get_tag,
([g],gs') ← pure $ (list.zip gs ts).partition (λ x, x.snd.nth 1 = some n),
set_goals [g.1],
tac, done,
set_goals $ gs'.map prod.fst
/--
`have_field`, used after `refine_struct _` poses `field` as a local constant
with the type of the field of the current goal:
```lean
refine_struct ({ .. } : semigroup α),
{ have_field, ... },
{ have_field, ... },
```
behaves like
```lean
refine_struct ({ .. } : semigroup α),
{ have field := @semigroup.mul, ... },
{ have field := @semigroup.mul_assoc, ... },
```
-/
meta def have_field : tactic unit :=
propagate_tags $
get_current_field
>>= mk_const
>>= note `field none
>> return ()
/-- `apply_field` functions as `have_field, apply field, clear field` -/
meta def apply_field : tactic unit :=
propagate_tags $
get_current_field >>= applyc
add_tactic_doc
{ name := "refine_struct",
category := doc_category.tactic,
decl_names := [`tactic.interactive.refine_struct, `tactic.interactive.apply_field,
`tactic.interactive.have_field],
tags := ["structures"],
inherit_description_from := `tactic.interactive.refine_struct }
/--
`apply_rules hs n` applies the list of lemmas `hs` and `assumption` on the
first goal and the resulting subgoals, iteratively, at most `n` times.
`n` is optional, equal to 50 by default.
`hs` can contain user attributes: in this case all theorems with this
attribute are added to the list of rules.
For instance:
```lean
@[user_attribute]
meta def mono_rules : user_attribute :=
{ name := `mono_rules,
descr := "lemmas usable to prove monotonicity" }
attribute [mono_rules] add_le_add mul_le_mul_of_nonneg_right
lemma my_test {a b c d e : real} (h1 : a ≤ b) (h2 : c ≤ d) (h3 : 0 ≤ e) :
a + c * e + a + c + 0 ≤ b + d * e + b + d + e :=
-- any of the following lines solve the goal:
add_le_add (add_le_add (add_le_add (add_le_add h1 (mul_le_mul_of_nonneg_right h2 h3)) h1 ) h2) h3
by apply_rules [add_le_add, mul_le_mul_of_nonneg_right]
by apply_rules [mono_rules]
by apply_rules mono_rules
```
-/
meta def apply_rules (hs : parse pexpr_list_or_texpr) (n : nat := 50) : tactic unit :=
tactic.apply_rules hs n
add_tactic_doc
{ name := "apply_rules",
category := doc_category.tactic,
decl_names := [`tactic.interactive.apply_rules],
tags := ["lemma application"] }
meta def return_cast (f : option expr) (t : option (expr × expr))
(es : list (expr × expr × expr))
(e x x' eq_h : expr) :
tactic (option (expr × expr) × list (expr × expr × expr)) :=
(do guard (¬ e.has_var),
unify x x',
u ← mk_meta_univ,
f ← f <|> mk_mapp ``_root_.id [(expr.sort u : expr)],
t' ← infer_type e,
some (f',t) ← pure t | return (some (f,t'), (e,x',eq_h) :: es),
infer_type e >>= is_def_eq t,
unify f f',
return (some (f,t), (e,x',eq_h) :: es)) <|>
return (t, es)
meta def list_cast_of_aux (x : expr) (t : option (expr × expr))
(es : list (expr × expr × expr)) :
expr → tactic (option (expr × expr) × list (expr × expr × expr))
| e@`(cast %%eq_h %%x') := return_cast none t es e x x' eq_h
| e@`(eq.mp %%eq_h %%x') := return_cast none t es e x x' eq_h
| e@`(eq.mpr %%eq_h %%x') := mk_eq_symm eq_h >>= return_cast none t es e x x'
| e@`(@eq.subst %%α %%p %%a %%b %%eq_h %%x') := return_cast p t es e x x' eq_h
| e@`(@eq.substr %%α %%p %%a %%b %%eq_h %%x') := mk_eq_symm eq_h >>= return_cast p t es e x x'
| e@`(@eq.rec %%α %%a %%f %%x' _ %%eq_h) := return_cast f t es e x x' eq_h
| e@`(@eq.rec_on %%α %%a %%f %%b %%eq_h %%x') := return_cast f t es e x x' eq_h
| e := return (t,es)
meta def list_cast_of (x tgt : expr) : tactic (list (expr × expr × expr)) :=
(list.reverse ∘ prod.snd) <$> tgt.mfold (none, []) (λ e i es, list_cast_of_aux x es.1 es.2 e)
private meta def h_generalize_arg_p_aux : pexpr → parser (pexpr × name)
| (app (app (macro _ [const `heq _ ]) h) (local_const x _ _ _)) := pure (h, x)
| _ := fail "parse error"
private meta def h_generalize_arg_p : parser (pexpr × name) :=
with_desc "expr == id" $ parser.pexpr 0 >>= h_generalize_arg_p_aux
/--
`h_generalize Hx : e == x` matches on `cast _ e` in the goal and replaces it with
`x`. It also adds `Hx : e == x` as an assumption. If `cast _ e` appears multiple
times (not necessarily with the same proof), they are all replaced by `x`. `cast`
`eq.mp`, `eq.mpr`, `eq.subst`, `eq.substr`, `eq.rec` and `eq.rec_on` are all treated
as casts.
- `h_generalize Hx : e == x with h` adds hypothesis `α = β` with `e : α, x : β`;
- `h_generalize Hx : e == x with _` chooses automatically chooses the name of
assumption `α = β`;
- `h_generalize! Hx : e == x` reverts `Hx`;
- when `Hx` is omitted, assumption `Hx : e == x` is not added.
-/
meta def h_generalize (rev : parse (tk "!")?)
(h : parse ident_?)
(_ : parse (tk ":"))
(arg : parse h_generalize_arg_p)
(eqs_h : parse ( (tk "with" >> pure <$> ident_) <|> pure [])) :
tactic unit :=
do let (e,n) := arg,
let h' := if h = `_ then none else h,
h' ← (h' : tactic name) <|> get_unused_name ("h" ++ n.to_string : string),
e ← to_expr e,
tgt ← target,
((e,x,eq_h)::es) ← list_cast_of e tgt | fail "no cast found",
interactive.generalize h' () (to_pexpr e, n),
asm ← get_local h',
v ← get_local n,
hs ← es.mmap (λ ⟨e,_⟩, mk_app `eq [e,v]),
(eqs_h.zip [e]).mmap' (λ ⟨h,e⟩, do
h ← if h ≠ `_ then pure h else get_unused_name `h,
() <$ note h none eq_h ),
hs.mmap' (λ h,
do h' ← assert `h h,
tactic.exact asm,
try (rewrite_target h'),
tactic.clear h' ),
when h.is_some (do
(to_expr ``(heq_of_eq_rec_left %%eq_h %%asm)
<|> to_expr ``(heq_of_eq_mp %%eq_h %%asm))
>>= note h' none >> pure ()),
tactic.clear asm,
when rev.is_some (interactive.revert [n])
add_tactic_doc
{ name := "h_generalize",
category := doc_category.tactic,
decl_names := [`tactic.interactive.h_generalize],
tags := ["context management"] }
/-- `choose a b h using hyp` takes an hypothesis `hyp` of the form
`∀ (x : X) (y : Y), ∃ (a : A) (b : B), P x y a b` for some `P : X → Y → A → B → Prop` and outputs
into context a function `a : X → Y → A`, `b : X → Y → B` and a proposition `h` stating
`∀ (x : X) (y : Y), P x y (a x y) (b x y)`. It presumably also works with dependent versions.
Example:
```lean
example (h : ∀n m : ℕ, ∃i j, m = n + i ∨ m + j = n) : true :=
begin
choose i j h using h,
guard_hyp i := ℕ → ℕ → ℕ,
guard_hyp j := ℕ → ℕ → ℕ,
guard_hyp h := ∀ (n m : ℕ), m = n + i n m ∨ m + j n m = n,
trivial
end
```
-/
meta def choose (first : parse ident) (names : parse ident*) (tgt : parse (tk "using" *> texpr)?) :
tactic unit := do
tgt ← match tgt with
| none := get_local `this
| some e := tactic.i_to_expr_strict e
end,
tactic.choose tgt (first :: names),
try (interactive.simp none tt [simp_arg_type.expr ``(exists_prop)] [] (loc.ns $ some <$> names)),
try (tactic.clear tgt)
add_tactic_doc
{ name := "choose",
category := doc_category.tactic,
decl_names := [`tactic.interactive.choose],
tags := ["classical logic"] }
/--
The goal of `field_simp` is to reduce an expression in a field to an expression of the form `n / d`
where neither `n` nor `d` contains any division symbol, just using the simplifier (with a carefully
crafted simpset named `field_simps`) to reduce the number of division symbols whenever possible by
iterating the following steps:
- write an inverse as a division
- in any product, move the division to the right
- if there are several divisions in a product, group them together at the end and write them as a
single division
- reduce a sum to a common denominator
If the goal is an equality, this simpset will also clear the denominators, so that the proof
can normally be concluded by an application of `ring` or `ring_exp`.
`field_simp [hx, hy]` is a short form for `simp [-one_div_eq_inv, hx, hy] with field_simps`
Note that this naive algorithm will not try to detect common factors in denominators to reduce the
complexity of the resulting expression. Instead, it relies on the ability of `ring` to handle
complicated expressions in the next step.
As always with the simplifier, reduction steps will only be applied if the preconditions of the
lemmas can be checked. This means that proofs that denominators are nonzero should be included. The
fact that a product is nonzero when all factors are, and that a power of a nonzero number is
nonzero, are included in the simpset, but more complicated assertions (especially dealing with sums)
should be given explicitly. If your expression is not completely reduced by the simplifier
invocation, check the denominators of the resulting expression and provide proofs that they are
nonzero to enable further progress.
The invocation of `field_simp` removes the lemma `one_div_eq_inv` (which is marked as a simp lemma
in core) from the simpset, as this lemma works against the algorithm explained above.
For example,
```lean
example (a b c d x y : ℂ) (hx : x ≠ 0) (hy : y ≠ 0) :
a + b / x + c / x^2 + d / x^3 = a + x⁻¹ * (y * b / y + (d / x + c) / x) :=
begin
field_simp [hx, hy],
ring
end
```
-/
meta def field_simp (no_dflt : parse only_flag) (hs : parse simp_arg_list)
(attr_names : parse with_ident_list)
(locat : parse location) (cfg : simp_config_ext := {}) : tactic unit :=
let attr_names := `field_simps :: attr_names,
hs := simp_arg_type.except `one_div_eq_inv :: hs in
propagate_tags (simp_core cfg.to_simp_config cfg.discharger no_dflt hs attr_names locat)
add_tactic_doc
{ name := "field_simp",
category := doc_category.tactic,
decl_names := [`tactic.interactive.field_simp],
tags := ["simplification", "arithmetic"] }
meta def guard_expr_eq' (t : expr) (p : parse $ tk ":=" *> texpr) : tactic unit :=
do e ← to_expr p, is_def_eq t e
/--
`guard_target t` fails if the target of the main goal is not `t`.
We use this tactic for writing tests.
-/
meta def guard_target' (p : parse texpr) : tactic unit :=
do t ← target, guard_expr_eq' t p
add_tactic_doc
{ name := "guard_target'",
category := doc_category.tactic,
decl_names := [`tactic.interactive.guard_target'],
tags := ["testing"] }
/--
a weaker version of `trivial` that tries to solve the goal by reflexivity or by reducing it to true,
unfolding only `reducible` constants. -/
meta def triv : tactic unit :=
tactic.triv' <|> tactic.reflexivity reducible <|> tactic.contradiction <|> fail "triv tactic failed"
add_tactic_doc
{ name := "triv",
category := doc_category.tactic,
decl_names := [`tactic.interactive.triv],
tags := ["finishing"] }
/--
Similar to `existsi`. `use x` will instantiate the first term of an `∃` or `Σ` goal with `x`.
It will then try to close the new goal using `triv`, or try to simplify it by applying `exists_prop`.
Unlike `existsi`, `x` is elaborated with respect to the expected type.
`use` will alternatively take a list of terms `[x0, ..., xn]`.
`use` will work with constructors of arbitrary inductive types.
Examples:
```lean
example (α : Type) : ∃ S : set α, S = S :=
by use ∅
example : ∃ x : ℤ, x = x :=
by use 42
example : ∃ n > 0, n = n :=
begin
use 1,
-- goal is now 1 > 0 ∧ 1 = 1, whereas it would be ∃ (H : 1 > 0), 1 = 1 after existsi 1.
exact ⟨zero_lt_one, rfl⟩,
end
example : ∃ a b c : ℤ, a + b + c = 6 :=
by use [1, 2, 3]
example : ∃ p : ℤ × ℤ, p.1 = 1 :=
by use ⟨1, 42⟩
example : Σ x y : ℤ, (ℤ × ℤ) × ℤ :=
by use [1, 2, 3, 4, 5]
inductive foo
| mk : ℕ → bool × ℕ → ℕ → foo
example : foo :=
by use [100, tt, 4, 3]
```
-/
meta def use (l : parse pexpr_list_or_texpr) : tactic unit :=
focus1 $
tactic.use l;
try (triv <|> (do
`(Exists %%p) ← target,
to_expr ``(exists_prop.mpr) >>= tactic.apply >> skip))
add_tactic_doc
{ name := "use",
category := doc_category.tactic,
decl_names := [`tactic.interactive.use, `tactic.interactive.existsi],
tags := ["logic"],
inherit_description_from := `tactic.interactive.use }
/--
`clear_aux_decl` clears every `aux_decl` in the local context for the current goal.
This includes the induction hypothesis when using the equation compiler and
`_let_match` and `_fun_match`.
It is useful when using a tactic such as `finish`, `simp *` or `subst` that may use these
auxiliary declarations, and produce an error saying the recursion is not well founded.
```lean
example (n m : ℕ) (h₁ : n = m) (h₂ : ∃ a : ℕ, a = n ∧ a = m) : 2 * m = 2 * n :=
let ⟨a, ha⟩ := h₂ in
begin
clear_aux_decl, -- subst will fail without this line
subst h₁
end
example (x y : ℕ) (h₁ : ∃ n : ℕ, n * 1 = 2) (h₂ : 1 + 1 = 2 → x * 1 = y) : x = y :=
let ⟨n, hn⟩ := h₁ in
begin
clear_aux_decl, -- finish produces an error without this line
finish
end
```
-/
meta def clear_aux_decl : tactic unit := tactic.clear_aux_decl
add_tactic_doc
{ name := "clear_aux_decl",
category := doc_category.tactic,
decl_names := [`tactic.interactive.clear_aux_decl, `tactic.clear_aux_decl],
tags := ["context management"],
inherit_description_from := `tactic.interactive.clear_aux_decl }
meta def loc.get_local_pp_names : loc → tactic (list name)
| loc.wildcard := list.map expr.local_pp_name <$> local_context
| (loc.ns l) := return l.reduce_option
meta def loc.get_local_uniq_names (l : loc) : tactic (list name) :=
list.map expr.local_uniq_name <$> l.get_locals
/--
The logic of `change x with y at l` fails when there are dependencies.
`change'` mimics the behavior of `change`, except in the case of `change x with y at l`.
In this case, it will correctly replace occurences of `x` with `y` at all possible hypotheses
in `l`. As long as `x` and `y` are defeq, it should never fail.
-/
meta def change' (q : parse texpr) : parse (tk "with" *> texpr)? → parse location → tactic unit
| none (loc.ns [none]) := do e ← i_to_expr q, change_core e none
| none (loc.ns [some h]) := do eq ← i_to_expr q, eh ← get_local h, change_core eq (some eh)
| none _ := fail "change-at does not support multiple locations"
| (some w) l :=
do l' ← loc.get_local_pp_names l,
l'.mmap' (λ e, try (change_with_at q w e)),
when l.include_goal $ change q w (loc.ns [none])
add_tactic_doc
{ name := "change'",
category := doc_category.tactic,
decl_names := [`tactic.interactive.change', `tactic.interactive.change],
tags := ["renaming"],
inherit_description_from := `tactic.interactive.change' }
meta def convert_to_core (r : pexpr) : tactic unit :=
do tgt ← target,
h ← to_expr ``(_ : %%tgt = %%r),
rewrite_target h,
swap
/--
`convert_to g using n` attempts to change the current goal to `g`, but unlike `change`,
it will generate equality proof obligations using `congr' n` to resolve discrepancies.
`convert_to g` defaults to using `congr' 1`.
`ac_change` is `convert_to` followed by `ac_refl`. It is useful for rearranging/reassociating
e.g. sums:
```lean
example (a b c d e f g N : ℕ) : (a + b) + (c + d) + (e + f) + g ≤ N :=
begin
ac_change a + d + e + f + c + g + b ≤ _,
-- ⊢ a + d + e + f + c + g + b ≤ N
end
```
-/
meta def convert_to (r : parse texpr) (n : parse (tk "using" *> small_nat)?) : tactic unit :=
match n with
| none := convert_to_core r >> `[congr' 1]
| (some 0) := convert_to_core r
| (some o) := convert_to_core r >> congr' o
end
/-- `ac_change g using n` is `convert_to g using n; try {ac_refl}`. -/
meta def ac_change (r : parse texpr) (n : parse (tk "using" *> small_nat)?) : tactic unit :=
convert_to r n; try ac_refl
add_tactic_doc
{ name := "convert_to",
category := doc_category.tactic,
decl_names := [`tactic.interactive.convert_to, `tactic.interactive.ac_change],
tags := ["congruence"],
inherit_description_from := `tactic.interactive.convert_to }
private meta def opt_dir_with : parser (option (bool × name)) :=
(do tk "with",
arrow ← (tk "<-")?,
h ← ident,
return (arrow.is_some, h)) <|> return none
/--
`set a := t with h` is a variant of `let a := t`. It adds the hypothesis `h : a = t` to
the local context and replaces `t` with `a` everywhere it can.
`set a := t with ←h` will add `h : t = a` instead.
`set! a := t with h` does not do any replacing.
```lean
example (x : ℕ) (h : x = 3) : x + x + x = 9 :=
begin
set y := x with ←h_xy,
/-
x : ℕ,
y : ℕ := x,
h_xy : x = y,
h : y = 3
⊢ y + y + y = 9
-/
end
```
-/
meta def set (h_simp : parse (tk "!")?) (a : parse ident) (tp : parse ((tk ":") >> texpr)?)
(_ : parse (tk ":=")) (pv : parse texpr)
(rev_name : parse opt_dir_with) :=
do let vt := match tp with | some t := t | none := pexpr.mk_placeholder end,
let pv := ``(%%pv : %%vt),
v ← to_expr pv,
tp ← infer_type v,
definev a tp v,
when h_simp.is_none $ change' pv (some (expr.const a [])) loc.wildcard,
match rev_name with
| some (flip, id) :=
do nv ← get_local a,
pf ← to_expr (cond flip ``(%%pv = %%nv) ``(%%nv = %%pv)) >>= assert id,
reflexivity
| none := skip
end
add_tactic_doc
{ name := "set",
category := doc_category.tactic,
decl_names := [`tactic.interactive.set],
tags := ["context management"] }
/--
`clear_except h₀ h₁` deletes all the assumptions it can except for `h₀` and `h₁`.
-/
meta def clear_except (xs : parse ident *) : tactic unit :=
do n ← xs.mmap (try_core ∘ get_local) >>= revert_lst ∘ list.filter_map id,
ls ← local_context,
ls.reverse.mmap' $ try ∘ tactic.clear,
intron n
add_tactic_doc
{ name := "clear_except",
category := doc_category.tactic,
decl_names := [`tactic.interactive.clear_except],
tags := ["context management"] }
meta def format_names (ns : list name) : format :=
format.join $ list.intersperse " " (ns.map to_fmt)
private meta def indent_bindents (l r : string) : option (list name) → expr → tactic format
| none e :=
do e ← pp e,
pformat!"{l}{format.nest l.length e}{r}"
| (some ns) e :=
do e ← pp e,
let ns := format_names ns,
let margin := l.length + ns.to_string.length + " : ".length,
pformat!"{l}{ns} : {format.nest margin e}{r}"
private meta def format_binders : list name × binder_info × expr → tactic format
| (ns, binder_info.default, t) := indent_bindents "(" ")" ns t
| (ns, binder_info.implicit, t) := indent_bindents "{" "}" ns t
| (ns, binder_info.strict_implicit, t) := indent_bindents "⦃" "⦄" ns t
| ([n], binder_info.inst_implicit, t) :=
if "_".is_prefix_of n.to_string
then indent_bindents "[" "]" none t
else indent_bindents "[" "]" [n] t
| (ns, binder_info.inst_implicit, t) := indent_bindents "[" "]" ns t
| (ns, binder_info.aux_decl, t) := indent_bindents "(" ")" ns t
private meta def partition_vars' (s : name_set) : list expr → list expr → list expr → tactic (list expr × list expr)
| [] as bs := pure (as.reverse, bs.reverse)
| (x :: xs) as bs :=
do t ← infer_type x,
if t.has_local_in s then partition_vars' xs as (x :: bs)
else partition_vars' xs (x :: as) bs
private meta def partition_vars : tactic (list expr × list expr) :=
do ls ← local_context,
partition_vars' (name_set.of_list $ ls.map expr.local_uniq_name) ls [] []
/--
Format the current goal as a stand-alone example. Useful for testing tactic.
* `extract_goal`: formats the statement as an `example` declaration
* `extract_goal my_decl`: formats the statement as a `lemma` or `def` declaration
called `my_decl`
* `extract_goal with i j k:` only use local constants `i`, `j`, `k` in the declaration
Examples:
```lean
example (i j k : ℕ) (h₀ : i ≤ j) (h₁ : j ≤ k) : i ≤ k :=
begin
extract_goal,
-- prints:
-- example {i j k : ℕ} (h₀ : i ≤ j) (h₁ : j ≤ k) : i ≤ k :=
-- begin
-- end
extract_goal my_lemma
-- lemma my_lemma {i j k : ℕ} (h₀ : i ≤ j) (h₁ : j ≤ k) : i ≤ k :=
-- begin
-- end
end
example {i j k x y z w p q r m n : ℕ} (h₀ : i ≤ j) (h₁ : j ≤ k) (h₁ : k ≤ p) (h₁ : p ≤ q) : i ≤ k :=
begin
extract_goal my_lemma,
-- prints:
-- lemma my_lemma {i j k x y z w p q r m n : ℕ} (h₀ : i ≤ j) (h₁ : j ≤ k)
-- (h₁ : k ≤ p) (h₁ : p ≤ q) : i ≤ k :=
-- begin
-- end
extract_goal my_lemma with i j k
-- prints:
-- lemma my_lemma {i j k : ℕ} : i ≤ k :=
-- begin
-- end
end
```
-/
meta def extract_goal (print_use : parse $ tt <$ tk "!" <|> pure ff)
(n : parse ident?) (vs : parse with_ident_list)
: tactic unit :=
do tgt ← target,
((cxt₀,cxt₁),_) ← solve_aux tgt $
when (¬ vs.empty) (clear_except vs) >>
partition_vars,
tgt ← target,
is_prop ← is_prop tgt,
let title := match n, is_prop with
| none, _ := to_fmt "example"
| (some n), tt := format!"lemma {n}"
| (some n), ff := format!"def {n}"
end,
cxt₀ ← compact_decl cxt₀ >>= list.mmap format_binders,
cxt₁ ← compact_decl cxt₁ >>= list.mmap format_binders,
stmt ← pformat!"{tgt} :=",
let fmt :=
format.group $ format.nest 2 $
title ++ cxt₀.foldl (λ acc x, acc ++ format.group (format.line ++ x)) "" ++
format.line ++ format.intercalate format.line cxt₁ ++ " :" ++
format.line ++ stmt,
trace $ fmt.to_string $ options.mk.set_nat `pp.width 80,
trace!"begin\n admit\nend\n"
add_tactic_doc
{ name := "extract_goal",
category := doc_category.tactic,
decl_names := [`tactic.interactive.extract_goal],
tags := ["goal management"] }
/--
`inhabit α` tries to derive a `nonempty α` instance and then upgrades this
to an `inhabited α` instance.
If the target is a `Prop`, this is done constructively;
otherwise, it uses `classical.choice`.
```lean
example (α) [nonempty α] : ∃ a : α, true :=
begin
inhabit α,
existsi default α,
trivial
end
```
-/
meta def inhabit (t : parse parser.pexpr) (inst_name : parse ident?) : tactic unit :=
do ty ← i_to_expr t,
nm ← get_unused_name `inst,
mcond (target >>= is_prop)
(do mk_mapp `nonempty.elim_to_inhabited [ty, none] >>= tactic.apply <|>
fail "could not infer nonempty instance",
introI $ inst_name.get_or_else nm)
(do mk_mapp `classical.inhabited_of_nonempty' [ty, none] >>= note nm none <|>
fail "could not infer nonempty instance",
resetI)
add_tactic_doc
{ name := "inhabit",
category := doc_category.tactic,
decl_names := [`tactic.interactive.inhabit],
tags := ["context management", "type class"] }
/-- `revert_deps n₁ n₂ ...` reverts all the hypotheses that depend on one of `n₁, n₂, ...`
It does not revert `n₁, n₂, ...` themselves (unless they depend on another `nᵢ`). -/
meta def revert_deps (ns : parse ident*) : tactic unit :=
propagate_tags $ ns.reverse.mmap' $ λ n, get_local n >>= tactic.revert_deps
add_tactic_doc
{ name := "revert_deps",
category := doc_category.tactic,
decl_names := [`tactic.interactive.revert_deps],
tags := ["context management", "goal management"] }
/-- `revert_after n` reverts all the hypotheses after `n`. -/
meta def revert_after (n : parse ident) : tactic unit :=
propagate_tags $ get_local n >>= tactic.revert_after >> skip
add_tactic_doc
{ name := "revert_after",
category := doc_category.tactic,
decl_names := [`tactic.interactive.revert_after],
tags := ["context management", "goal management"] }
/-- `clear_value n₁ n₂ ...` clears the bodies of the local definitions `n₁, n₂ ...`, changing them
into regular hypotheses. A hypothesis `n : α := t` is changed to `n : α`. -/
meta def clear_value (ns : parse ident*) : tactic unit :=
propagate_tags $ ns.reverse.mmap' $ λ n, get_local n >>= tactic.clear_value
add_tactic_doc
{ name := "clear_value",
category := doc_category.tactic,
decl_names := [`tactic.interactive.clear_value],
tags := ["context management"] }
/--
`generalize' : e = x` replaces all occurrences of `e` in the target with a new hypothesis `x` of
the same type.
`generalize' h : e = x` in addition registers the hypothesis `h : e = x`.
`generalize'` is similar to `generalize`. The difference is that `generalize' : e = x` also
succeeds when `e` does not occur in the goal. It is similar to `set`, but the resulting hypothesis
`x` is not a local definition.
-/
meta def generalize' (h : parse ident?) (_ : parse $ tk ":") (p : parse generalize_arg_p) : tactic unit :=
propagate_tags $
do let (p, x) := p,
e ← i_to_expr p,
some h ← pure h | tactic.generalize' e x >> skip,
tgt ← target,
-- if generalizing fails, fall back to not replacing anything
tgt' ← do {
⟨tgt', _⟩ ← solve_aux tgt (tactic.generalize' e x >> target),
to_expr ``(Π x, %%e = x → %%(tgt'.binding_body.lift_vars 0 1))
} <|> to_expr ``(Π x, %%e = x → %%tgt),
t ← assert h tgt',
swap,
exact ``(%%t %%e rfl),
intro x,
intro h
add_tactic_doc
{ name := "generalize'",
category := doc_category.tactic,
decl_names := [`tactic.interactive.generalize'],
tags := ["context management"] }
end interactive
end tactic
|
ae6542e7a40e5d8b5a7ce871c451defac2f7bbfc | 367134ba5a65885e863bdc4507601606690974c1 | /src/set_theory/game.lean | 33f822ce6f1d849d0a84e07c978af9b273475c51 | [
"Apache-2.0"
] | permissive | kodyvajjha/mathlib | 9bead00e90f68269a313f45f5561766cfd8d5cad | b98af5dd79e13a38d84438b850a2e8858ec21284 | refs/heads/master | 1,624,350,366,310 | 1,615,563,062,000 | 1,615,563,062,000 | 162,666,963 | 0 | 0 | Apache-2.0 | 1,545,367,651,000 | 1,545,367,651,000 | null | UTF-8 | Lean | false | false | 5,400 | lean | /-
Copyright (c) 2019 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Reid Barton, Mario Carneiro, Isabel Longbottom, Scott Morrison
-/
import set_theory.pgame
/-!
# Combinatorial games.
In this file we define the quotient of pre-games by the equivalence relation `p ≈ q ↔ p ≤ q ∧ q ≤
p`, and construct an instance `add_comm_group game`, as well as an instance `partial_order game`
(although note carefully the warning that the `<` field in this instance is not the usual relation
on combinatorial games).
-/
universes u
local infix ` ≈ ` := pgame.equiv
instance pgame.setoid : setoid pgame :=
⟨λ x y, x ≈ y,
λ x, pgame.equiv_refl _,
λ x y, pgame.equiv_symm,
λ x y z, pgame.equiv_trans⟩
/-- The type of combinatorial games. In ZFC, a combinatorial game is constructed from
two sets of combinatorial games that have been constructed at an earlier
stage. To do this in type theory, we say that a combinatorial pre-game is built
inductively from two families of combinatorial games indexed over any type
in Type u. The resulting type `pgame.{u}` lives in `Type (u+1)`,
reflecting that it is a proper class in ZFC.
A combinatorial game is then constructed by quotienting by the equivalence
`x ≈ y ↔ x ≤ y ∧ y ≤ x`. -/
def game := quotient pgame.setoid
open pgame
namespace game
/-- The relation `x ≤ y` on games. -/
def le : game → game → Prop :=
quotient.lift₂ (λ x y, x ≤ y) (λ x₁ y₁ x₂ y₂ hx hy, propext (le_congr hx hy))
instance : has_le game :=
{ le := le }
@[refl] theorem le_refl : ∀ x : game, x ≤ x :=
by { rintro ⟨x⟩, apply pgame.le_refl }
@[trans] theorem le_trans : ∀ x y z : game, x ≤ y → y ≤ z → x ≤ z :=
by { rintro ⟨x⟩ ⟨y⟩ ⟨z⟩, apply pgame.le_trans }
theorem le_antisymm : ∀ x y : game, x ≤ y → y ≤ x → x = y :=
by { rintro ⟨x⟩ ⟨y⟩ h₁ h₂, apply quot.sound, exact ⟨h₁, h₂⟩ }
/-- The relation `x < y` on games. -/
-- We don't yet make this into an instance, because it will conflict with the (incorrect) notion
-- of `<` provided by `partial_order` later.
def lt : game → game → Prop :=
quotient.lift₂ (λ x y, x < y) (λ x₁ y₁ x₂ y₂ hx hy, propext (lt_congr hx hy))
theorem not_le : ∀ {x y : game}, ¬ (x ≤ y) ↔ (lt y x) :=
by { rintro ⟨x⟩ ⟨y⟩, exact not_le }
instance : has_zero game := ⟨⟦0⟧⟩
instance : inhabited game := ⟨0⟩
instance : has_one game := ⟨⟦1⟧⟩
/-- The negation of `{L | R}` is `{-R | -L}`. -/
def neg : game → game :=
quot.lift (λ x, ⟦-x⟧) (λ x y h, quot.sound (@neg_congr x y h))
instance : has_neg game :=
{ neg := neg }
/-- The sum of `x = {xL | xR}` and `y = {yL | yR}` is `{xL + y, x + yL | xR + y, x + yR}`. -/
def add : game → game → game :=
quotient.lift₂ (λ x y : pgame, ⟦x + y⟧) (λ x₁ y₁ x₂ y₂ hx hy, quot.sound (pgame.add_congr hx hy))
instance : has_add game := ⟨add⟩
theorem add_assoc : ∀ (x y z : game), (x + y) + z = x + (y + z) :=
begin
rintros ⟨x⟩ ⟨y⟩ ⟨z⟩,
apply quot.sound,
exact add_assoc_equiv
end
instance : add_semigroup game.{u} :=
{ add_assoc := add_assoc,
..game.has_add }
theorem add_zero : ∀ (x : game), x + 0 = x :=
begin
rintro ⟨x⟩,
apply quot.sound,
apply add_zero_equiv
end
theorem zero_add : ∀ (x : game), 0 + x = x :=
begin
rintro ⟨x⟩,
apply quot.sound,
apply zero_add_equiv
end
instance : add_monoid game :=
{ add_zero := add_zero,
zero_add := zero_add,
..game.has_zero,
..game.add_semigroup }
theorem add_left_neg : ∀ (x : game), (-x) + x = 0 :=
begin
rintro ⟨x⟩,
apply quot.sound,
apply add_left_neg_equiv
end
instance : add_group game :=
{ add_left_neg := add_left_neg,
..game.has_neg,
..game.add_monoid }
theorem add_comm : ∀ (x y : game), x + y = y + x :=
begin
rintros ⟨x⟩ ⟨y⟩,
apply quot.sound,
exact add_comm_equiv
end
instance : add_comm_semigroup game :=
{ add_comm := add_comm,
..game.add_semigroup }
instance : add_comm_group game :=
{ ..game.add_comm_semigroup,
..game.add_group }
theorem add_le_add_left : ∀ (a b : game), a ≤ b → ∀ (c : game), c + a ≤ c + b :=
begin rintro ⟨a⟩ ⟨b⟩ h ⟨c⟩, apply pgame.add_le_add_left h, end
-- While it is very tempting to define a `partial_order` on games, and prove
-- that games form an `ordered_add_comm_group`, it is a bit dangerous.
-- The relations `≤` and `<` on games do not satisfy
-- `lt_iff_le_not_le : ∀ a b : α, a < b ↔ (a ≤ b ∧ ¬ b ≤ a)`
-- (Consider `a = 0`, `b = star`.)
-- (`lt_iff_le_not_le` is satisfied by surreal numbers, however.)
-- Thus we can not use `<` when defining a `partial_order`.
-- Because of this issue, we define the `partial_order` and `ordered_add_comm_group` instances,
-- but do not actually mark them as instances, for safety.
/-- The `<` operation provided by this partial order is not the usual `<` on games! -/
def game_partial_order : partial_order game :=
{ le_refl := le_refl,
le_trans := le_trans,
le_antisymm := le_antisymm,
..game.has_le }
/-- The `<` operation provided by this `ordered_add_comm_group` is not the usual `<` on games! -/
def ordered_add_comm_group_game : ordered_add_comm_group game :=
{ add_le_add_left := add_le_add_left,
..game.add_comm_group,
..game_partial_order }
end game
|
00653243bf7e89b391dcda019b6bf48234486c3f | bbecf0f1968d1fba4124103e4f6b55251d08e9c4 | /src/data/polynomial/cancel_leads.lean | e21c1ea1b923bc684e502c660933fe12db9dd52d | [
"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 | 2,947 | lean | /-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import data.polynomial.degree.definitions
/-!
# Cancel the leading terms of two polynomials
## Definition
* `cancel_leads p q`: the polynomial formed by multiplying `p` and `q` by monomials so that they
have the same leading term, and then subtracting.
## Main Results
The degree of `cancel_leads` is less than that of the larger of the two polynomials being cancelled.
Thus it is useful for induction or minimal-degree arguments.
-/
namespace polynomial
noncomputable theory
variables {R : Type*}
section comm_ring
variables [comm_ring R] (p q : polynomial R)
/-- `cancel_leads p q` is formed by multiplying `p` and `q` by monomials so that they
have the same leading term, and then subtracting. -/
def cancel_leads : polynomial R :=
C p.leading_coeff * X ^ (p.nat_degree - q.nat_degree) * q -
C q.leading_coeff * X ^ (q.nat_degree - p.nat_degree) * p
variables {p q}
@[simp] lemma neg_cancel_leads : - p.cancel_leads q = q.cancel_leads p := neg_sub _ _
lemma dvd_cancel_leads_of_dvd_of_dvd {r : polynomial R} (pq : p ∣ q) (pr : p ∣ r) :
p ∣ q.cancel_leads r :=
dvd_sub (pr.trans (dvd.intro_left _ rfl)) (pq.trans (dvd.intro_left _ rfl))
end comm_ring
lemma nat_degree_cancel_leads_lt_of_nat_degree_le_nat_degree [comm_ring R] [integral_domain R]
{p q : polynomial R} (h : p.nat_degree ≤ q.nat_degree) (hq : 0 < q.nat_degree) :
(p.cancel_leads q).nat_degree < q.nat_degree :=
begin
by_cases hp : p = 0,
{ convert hq,
simp [hp, cancel_leads], },
rw [cancel_leads, sub_eq_add_neg, nat.sub_eq_zero_of_le h, pow_zero, mul_one],
by_cases h0 :
C p.leading_coeff * q + -(C q.leading_coeff * X ^ (q.nat_degree - p.nat_degree) * p) = 0,
{ convert hq,
simp only [h0, nat_degree_zero], },
have hq0 : ¬ q = 0,
{ contrapose! hq,
simp [hq] },
apply lt_of_le_of_ne,
{ rw [← with_bot.coe_le_coe, ← degree_eq_nat_degree h0, ← degree_eq_nat_degree hq0],
apply le_trans (degree_add_le _ _),
rw ← leading_coeff_eq_zero at hp hq0,
simp only [max_le_iff, degree_C hp, degree_C hq0, le_refl q.degree, true_and, nat.cast_with_bot,
nsmul_one, degree_neg, degree_mul, zero_add, degree_X, degree_pow],
rw leading_coeff_eq_zero at hp hq0,
rw [degree_eq_nat_degree hp, degree_eq_nat_degree hq0, ← with_bot.coe_add, with_bot.coe_le_coe,
nat.sub_add_cancel h], },
{ contrapose! h0,
rw [← leading_coeff_eq_zero, leading_coeff, h0, mul_assoc, mul_comm _ p,
← nat.sub_add_cancel h, add_comm _ p.nat_degree],
simp only [coeff_mul_X_pow, coeff_neg, coeff_C_mul, nat.add_sub_cancel_left, coeff_add],
rw [add_comm p.nat_degree, nat.sub_add_cancel h, ← leading_coeff, ← leading_coeff,
mul_comm _ q.leading_coeff, ← sub_eq_add_neg, ← mul_sub, sub_self, mul_zero] }
end
end polynomial
|
abb32cfbc75d1136a83cd04785a48f3e216ae8ee | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/run/395a.lean | af0d530f2c7f7639c1e4cedbd63ada17df0adfb0 | [
"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 | 431 | lean | lemma test (h : true) : true → true :=
λ h, trivial
lemma test' (h : 0 = 0) : true → true :=
λ h, trivial
meta def mk_test : tactic unit :=
do
e ← tactic.to_expr ``(test trivial),
tactic.to_expr ``(%%e trivial) >>= tactic.exact
meta def mk_test' : tactic unit :=
do
e ← tactic.to_expr ``(test' rfl),
tactic.to_expr ``(%%e trivial) >>= tactic.exact
lemma a : true :=
by mk_test
lemma a' : true :=
by mk_test'
|
23ef99ede57f0e5889abc46cb33d367865f6d9da | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/Lean3Lib/init/cc_lemmas.lean | a6ba2c574f8d8068aa4475f25288b65d2887b532 | [] | 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,210 | lean | /-
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.propext
import Mathlib.Lean3Lib.init.classical
universes u
namespace Mathlib
/- Lemmas use by the congruence closure module -/
theorem iff_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a ↔ b) = b :=
Eq.symm h ▸ propext (true_iff b)
theorem iff_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a ↔ b) = a :=
Eq.symm h ▸ propext (iff_true a)
theorem iff_eq_true_of_eq {a : Prop} {b : Prop} (h : a = b) : (a ↔ b) = True :=
h ▸ propext (iff_self a)
theorem and_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a ∧ b) = b :=
Eq.symm h ▸ propext (true_and b)
theorem and_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a ∧ b) = a :=
Eq.symm h ▸ propext (and_true a)
theorem and_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a ∧ b) = False :=
Eq.symm h ▸ propext (false_and b)
theorem and_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a ∧ b) = False :=
Eq.symm h ▸ propext (and_false a)
theorem and_eq_of_eq {a : Prop} {b : Prop} (h : a = b) : (a ∧ b) = a :=
h ▸ propext (and_self a)
theorem or_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a ∨ b) = True :=
Eq.symm h ▸ propext (true_or b)
theorem or_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a ∨ b) = True :=
Eq.symm h ▸ propext (or_true a)
theorem or_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a ∨ b) = b :=
Eq.symm h ▸ propext (false_or b)
theorem or_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a ∨ b) = a :=
Eq.symm h ▸ propext (or_false a)
theorem or_eq_of_eq {a : Prop} {b : Prop} (h : a = b) : (a ∨ b) = a :=
h ▸ propext (or_self a)
theorem imp_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a → b) = b :=
Eq.symm h ▸ propext { mp := fun (h : True → b) => h trivial, mpr := fun (h₁ : b) (h₂ : True) => h₁ }
theorem imp_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a → b) = True :=
Eq.symm h ▸ propext { mp := fun (h : a → True) => trivial, mpr := fun (h₁ : True) (h₂ : a) => h₁ }
theorem imp_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a → b) = True :=
Eq.symm h ▸ propext { mp := fun (h : False → b) => trivial, mpr := fun (h₁ : True) (h₂ : False) => false.elim h₂ }
theorem imp_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a → b) = (¬a) :=
Eq.symm h ▸ propext { mp := fun (h : a → False) => h, mpr := fun (hna : ¬a) (ha : a) => hna ha }
/- Remark: the congruence closure module will only use the following lemma is
cc_config.em is tt. -/
theorem not_imp_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (¬a → b) = a := sorry
theorem imp_eq_true_of_eq {a : Prop} {b : Prop} (h : a = b) : (a → b) = True :=
h ▸ propext { mp := fun (h : a → a) => trivial, mpr := fun (h : True) (ha : a) => ha }
theorem not_eq_of_eq_true {a : Prop} (h : a = True) : (¬a) = False :=
Eq.symm h ▸ propext not_true_iff
theorem not_eq_of_eq_false {a : Prop} (h : a = False) : (¬a) = True :=
Eq.symm h ▸ propext not_false_iff
theorem false_of_a_eq_not_a {a : Prop} (h : a = (¬a)) : False :=
(fun (this : ¬a) => absurd (eq.mpr h this) this) fun (ha : a) => absurd ha (eq.mp h ha)
theorem if_eq_of_eq_true {c : Prop} [d : Decidable c] {α : Sort u} (t : α) (e : α) (h : c = True) : ite c t e = t :=
if_pos (of_eq_true h)
theorem if_eq_of_eq_false {c : Prop} [d : Decidable c] {α : Sort u} (t : α) (e : α) (h : c = False) : ite c t e = e :=
if_neg (not_of_eq_false h)
theorem if_eq_of_eq (c : Prop) [d : Decidable c] {α : Sort u} {t : α} {e : α} (h : t = e) : ite c t e = t := sorry
theorem eq_true_of_and_eq_true_left {a : Prop} {b : Prop} (h : (a ∧ b) = True) : a = True :=
eq_true_intro (and.left (of_eq_true h))
theorem eq_true_of_and_eq_true_right {a : Prop} {b : Prop} (h : (a ∧ b) = True) : b = True :=
eq_true_intro (and.right (of_eq_true h))
theorem eq_false_of_or_eq_false_left {a : Prop} {b : Prop} (h : (a ∨ b) = False) : a = False :=
eq_false_intro fun (ha : a) => false.elim (eq.mp h (Or.inl ha))
theorem eq_false_of_or_eq_false_right {a : Prop} {b : Prop} (h : (a ∨ b) = False) : b = False :=
eq_false_intro fun (hb : b) => false.elim (eq.mp h (Or.inr hb))
theorem eq_false_of_not_eq_true {a : Prop} (h : (¬a) = True) : a = False :=
eq_false_intro fun (ha : a) => absurd ha (eq.mpr h trivial)
/- Remark: the congruence closure module will only use the following lemma is
cc_config.em is tt. -/
theorem eq_true_of_not_eq_false {a : Prop} (h : (¬a) = False) : a = True :=
eq_true_intro (classical.by_contradiction fun (hna : ¬a) => eq.mp h hna)
theorem ne_of_eq_of_ne {α : Sort u} {a : α} {b : α} {c : α} (h₁ : a = b) (h₂ : b ≠ c) : a ≠ c :=
Eq.symm h₁ ▸ h₂
theorem ne_of_ne_of_eq {α : Sort u} {a : α} {b : α} {c : α} (h₁ : a ≠ b) (h₂ : b = c) : a ≠ c :=
h₂ ▸ h₁
|
42cca942305aafdf2e7fe0813b9b81d7ccf09841 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/tactic/linarith/datatypes_auto.lean | a51ebd86f8bd58fed55091c06b3a03c670913267 | [] | 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 | 6,776 | lean | /-
Copyright (c) 2020 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.meta.rb_map
import Mathlib.tactic.ring
import Mathlib.tactic.linarith.lemmas
import Mathlib.PostPort
universes l
namespace Mathlib
/-!
# Datatypes for `linarith`
Some of the data structures here are used in multiple parts of the tactic.
We split them into their own file.
This file also contains a few convenient auxiliary functions.
-/
namespace linarith
/-- A shorthand for tracing when the `trace.linarith` option is set to true. -/
/--
A shorthand for tracing the types of a list of proof terms
when the `trace.linarith` option is set to true.
-/
/-! ### Linear expressions -/
/--
A linear expression is a list of pairs of variable indices and coefficients,
representing the sum of the products of each coefficient with its corresponding variable.
Some functions on `linexp` assume that `n : ℕ` occurs at most once as the first element of a pair,
and that the list is sorted in decreasing order of the first argument.
This is not enforced by the type but the operations here preserve it.
-/
def linexp := List (ℕ × ℤ)
namespace linexp
/--
Add two `linexp`s together componentwise.
Preserves sorting and uniqueness of the first argument.
-/
/-- `l.scale c` scales the values in `l` by `c` without modifying the order or keys. -/
def scale (c : ℤ) (l : linexp) : linexp :=
ite (c = 0) [] (ite (c = 1) l (list.map (fun (_x : ℕ × ℤ) => sorry) l))
/--
`l.get n` returns the value in `l` associated with key `n`, if it exists, and `none` otherwise.
This function assumes that `l` is sorted in decreasing order of the first argument,
that is, it will return `none` as soon as it finds a key smaller than `n`.
-/
def get (n : ℕ) : linexp → Option ℤ := sorry
/--
`l.contains n` is true iff `n` is the first element of a pair in `l`.
-/
def contains (n : ℕ) : linexp → Bool := option.is_some ∘ get n
/--
`l.zfind n` returns the value associated with key `n` if there is one, and 0 otherwise.
-/
def zfind (n : ℕ) (l : linexp) : ℤ := sorry
/-- `l.vars` returns the list of variables that occur in `l`. -/
def vars (l : linexp) : List ℕ := list.map prod.fst l
/--
Defines a lex ordering on `linexp`. This function is performance critical.
-/
def cmp : linexp → linexp → ordering := sorry
end linexp
/-! ### Inequalities -/
/-- The three-element type `ineq` is used to represent the strength of a comparison between terms. -/
inductive ineq where
| eq : ineq
| le : ineq
| lt : ineq
namespace ineq
/--
`max R1 R2` computes the strength of the sum of two inequalities. If `t1 R1 0` and `t2 R2 0`,
then `t1 + t2 (max R1 R2) 0`.
-/
def max : ineq → ineq → ineq := sorry
/-- `ineq` is ordered `eq < le < lt`. -/
def cmp : ineq → ineq → ordering := sorry
/-- Prints an `ineq` as the corresponding infix symbol. -/
def to_string : ineq → string := sorry
/-- Finds the name of a multiplicative lemma corresponding to an inequality strength. -/
protected instance has_to_string : has_to_string ineq := has_to_string.mk to_string
end ineq
/-! ### Comparisons with 0 -/
/--
The main datatype for FM elimination.
Variables are represented by natural numbers, each of which has an integer coefficient.
Index 0 is reserved for constants, i.e. `coeffs.find 0` is the coefficient of 1.
The represented term is `coeffs.sum (λ ⟨k, v⟩, v * Var[k])`.
str determines the strength of the comparison -- is it < 0, ≤ 0, or = 0?
-/
structure comp where
str : ineq
coeffs : linexp
/-- `c.vars` returns the list of variables that appear in the linear expression contained in `c`. -/
def comp.vars : comp → List ℕ := linexp.vars ∘ comp.coeffs
/-- `comp.coeff_of c a` projects the coefficient of variable `a` out of `c`. -/
def comp.coeff_of (c : comp) (a : ℕ) : ℤ := linexp.zfind a (comp.coeffs c)
/-- `comp.scale c n` scales the coefficients of `c` by `n`. -/
def comp.scale (c : comp) (n : ℕ) : comp := comp.mk (comp.str c) (linexp.scale (↑n) (comp.coeffs c))
/--
`comp.add c1 c2` adds the expressions represented by `c1` and `c2`.
The coefficient of variable `a` in `c1.add c2`
is the sum of the coefficients of `a` in `c1` and `c2`.
-/
/-- `comp` has a lex order. First the `ineq`s are compared, then the `coeff`s. -/
/--
A `comp` represents a contradiction if its expression has no coefficients and its strength is <,
that is, it represents the fact `0 < 0`.
-/
/-! ### Parsing into linear form -/
/-! ### Control -/
/--
A preprocessor transforms a proof of a proposition into a proof of a different propositon.
The return type is `list expr`, since some preprocessing steps may create multiple new hypotheses,
and some may remove a hypothesis from the list.
A "no-op" preprocessor should return its input as a singleton list.
-/
/--
Some preprocessors need to examine the full list of hypotheses instead of working item by item.
As with `preprocessor`, the input to a `global_preprocessor` is replaced by, not added to, its output.
-/
/--
Some preprocessors perform branching case splits. A `branch` is used to track one of these case
splits. The first component, an `expr`, is the goal corresponding to this branch of the split,
given as a metavariable. The `list expr` component is the list of hypotheses for `linarith`
in this branch. Every `expr` in this list should be type correct in the context of the associated goal.
-/
/--
Some preprocessors perform branching case splits.
A `global_branching_preprocessor` produces a list of branches to run.
Each branch is independent, so hypotheses that appear in multiple branches should be duplicated.
The preprocessor is responsible for making sure that each branch contains the correct goal
metavariable.
-/
/--
A `preprocessor` lifts to a `global_preprocessor` by folding it over the input list.
-/
/--
A `global_preprocessor` lifts to a `global_branching_preprocessor` by producing only one branch.
-/
/--
`process pp l` runs `pp.transform` on `l` and returns the result,
tracing the result if `trace.linarith` is on.
-/
/--
A `certificate_oracle` is a function `produce_certificate : list comp → ℕ → tactic (rb_map ℕ ℕ)`.
`produce_certificate hyps max_var` tries to derive a contradiction from the comparisons in `hyps`
by eliminating all variables ≤ `max_var`.
If successful, it returns a map `coeff : ℕ → ℕ` as a certificate.
This map represents that we can find a contradiction by taking the sum `∑ (coeff i) * hyps[i]`.
The default `certificate_oracle` used by `linarith` is `linarith.fourier_motzkin.produce_certificate`
-/
/-- A configuration object for `linarith`. -/
end Mathlib |
97dde8d8e9f76fafd48903be2b8c6aa523f814d9 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/ring_theory/polynomial_algebra.lean | 323fb6f7d9f6f52930eeee14fb181cfaa95aee2a | [
"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 | 10,459 | 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 ring_theory.matrix_algebra
import data.polynomial.algebra_map
import data.matrix.basis
import data.matrix.dmatrix
/-!
# Algebra isomorphism between matrices of polynomials and polynomials of matrices
Given `[comm_ring R] [ring A] [algebra R A]`
we show `A[X] ≃ₐ[R] (A ⊗[R] R[X])`.
Combining this with the isomorphism `matrix n n A ≃ₐ[R] (A ⊗[R] matrix n n R)` proved earlier
in `ring_theory.matrix_algebra`, we obtain the algebra isomorphism
```
def mat_poly_equiv :
matrix n n R[X] ≃ₐ[R] (matrix n n R)[X]
```
which is characterized by
```
coeff (mat_poly_equiv m) k i j = coeff (m i j) k
```
We will use this algebra isomorphism to prove the Cayley-Hamilton theorem.
-/
universes u v w
open_locale polynomial tensor_product
open polynomial
open tensor_product
open algebra.tensor_product (alg_hom_of_linear_map_tensor_product include_left)
noncomputable theory
variables (R A : Type*)
variables [comm_semiring R]
variables [semiring A] [algebra R A]
namespace poly_equiv_tensor
/--
(Implementation detail).
The function underlying `A ⊗[R] R[X] →ₐ[R] A[X]`,
as a bilinear function of two arguments.
-/
@[simps apply_apply]
def to_fun_bilinear : A →ₗ[A] R[X] →ₗ[R] A[X] :=
linear_map.to_span_singleton A _ (aeval (polynomial.X : A[X])).to_linear_map
lemma to_fun_bilinear_apply_eq_sum (a : A) (p : R[X]) :
to_fun_bilinear R A a p = p.sum (λ n r, monomial n (a * algebra_map R A r)) :=
begin
dsimp [to_fun_bilinear_apply_apply, aeval_def, eval₂_eq_sum, polynomial.sum],
rw finset.smul_sum,
congr' with i : 1,
rw [← algebra.smul_def, ←C_mul', mul_smul_comm, C_mul_X_pow_eq_monomial, ←algebra.commutes,
← algebra.smul_def, smul_monomial],
end
/--
(Implementation detail).
The function underlying `A ⊗[R] R[X] →ₐ[R] A[X]`,
as a linear map.
-/
def to_fun_linear : A ⊗[R] R[X] →ₗ[R] A[X] :=
tensor_product.lift (to_fun_bilinear R A)
@[simp]
lemma to_fun_linear_tmul_apply (a : A) (p : R[X]) :
to_fun_linear R A (a ⊗ₜ[R] p) = to_fun_bilinear R A a p := lift.tmul _ _
-- We apparently need to provide the decidable instance here
-- in order to successfully rewrite by this lemma.
lemma to_fun_linear_mul_tmul_mul_aux_1
(p : R[X]) (k : ℕ) (h : decidable (¬p.coeff k = 0)) (a : A) :
ite (¬coeff p k = 0) (a * (algebra_map R A) (coeff p k)) 0 = a * (algebra_map R A) (coeff p k) :=
by { classical, split_ifs; simp *, }
lemma to_fun_linear_mul_tmul_mul_aux_2 (k : ℕ) (a₁ a₂ : A) (p₁ p₂ : R[X]) :
a₁ * a₂ * (algebra_map R A) ((p₁ * p₂).coeff k) =
(finset.nat.antidiagonal k).sum
(λ x, a₁ * (algebra_map R A) (coeff p₁ x.1) * (a₂ * (algebra_map R A) (coeff p₂ x.2))) :=
begin
simp_rw [mul_assoc, algebra.commutes, ←finset.mul_sum, mul_assoc, ←finset.mul_sum],
congr,
simp_rw [algebra.commutes (coeff p₂ _), coeff_mul, ring_hom.map_sum, ring_hom.map_mul],
end
lemma to_fun_linear_mul_tmul_mul (a₁ a₂ : A) (p₁ p₂ : R[X]) :
(to_fun_linear R A) ((a₁ * a₂) ⊗ₜ[R] (p₁ * p₂)) =
(to_fun_linear R A) (a₁ ⊗ₜ[R] p₁) * (to_fun_linear R A) (a₂ ⊗ₜ[R] p₂) :=
begin
classical,
simp only [to_fun_linear_tmul_apply, to_fun_bilinear_apply_eq_sum],
ext k,
simp_rw [coeff_sum, coeff_monomial, sum_def, finset.sum_ite_eq', mem_support_iff, ne.def],
conv_rhs { rw [coeff_mul] },
simp_rw [finset_sum_coeff, coeff_monomial,
finset.sum_ite_eq', mem_support_iff, ne.def,
mul_ite, mul_zero, ite_mul, zero_mul],
simp_rw [ite_mul_zero_left (¬coeff p₁ _ = 0) (a₁ * (algebra_map R A) (coeff p₁ _))],
simp_rw [ite_mul_zero_right (¬coeff p₂ _ = 0) _ (_ * _)],
simp_rw [to_fun_linear_mul_tmul_mul_aux_1, to_fun_linear_mul_tmul_mul_aux_2],
end
lemma to_fun_linear_algebra_map_tmul_one (r : R) :
(to_fun_linear R A) ((algebra_map R A) r ⊗ₜ[R] 1) = (algebra_map R A[X]) r :=
by rw [to_fun_linear_tmul_apply, to_fun_bilinear_apply_apply, polynomial.aeval_one,
algebra_map_smul, algebra.algebra_map_eq_smul_one]
/--
(Implementation detail).
The algebra homomorphism `A ⊗[R] R[X] →ₐ[R] A[X]`.
-/
def to_fun_alg_hom : A ⊗[R] R[X] →ₐ[R] A[X] :=
alg_hom_of_linear_map_tensor_product
(to_fun_linear R A)
(to_fun_linear_mul_tmul_mul R A)
(to_fun_linear_algebra_map_tmul_one R A)
@[simp] lemma to_fun_alg_hom_apply_tmul (a : A) (p : R[X]) :
to_fun_alg_hom R A (a ⊗ₜ[R] p) = p.sum (λ n r, monomial n (a * (algebra_map R A) r)) :=
begin
dsimp [to_fun_alg_hom],
rw [to_fun_linear_tmul_apply, to_fun_bilinear_apply_eq_sum],
end
/--
(Implementation detail.)
The bare function `A[X] → A ⊗[R] R[X]`.
(We don't need to show that it's an algebra map, thankfully --- just that it's an inverse.)
-/
def inv_fun (p : A[X]) : A ⊗[R] R[X] :=
p.eval₂
(include_left : A →ₐ[R] A ⊗[R] R[X])
((1 : A) ⊗ₜ[R] (X : R[X]))
@[simp]
lemma inv_fun_add {p q} : inv_fun R A (p + q) = inv_fun R A p + inv_fun R A q :=
by simp only [inv_fun, eval₂_add]
lemma inv_fun_monomial (n : ℕ) (a : A) :
inv_fun R A (monomial n a) = include_left a * ((1 : A) ⊗ₜ[R] (X : R[X])) ^ n :=
eval₂_monomial _ _
lemma left_inv (x : A ⊗ R[X]) :
inv_fun R A ((to_fun_alg_hom R A) x) = x :=
begin
apply tensor_product.induction_on x,
{ simp [inv_fun], },
{ intros a p, dsimp only [inv_fun],
rw [to_fun_alg_hom_apply_tmul, eval₂_sum],
simp_rw [eval₂_monomial, alg_hom.coe_to_ring_hom, algebra.tensor_product.tmul_pow, one_pow,
algebra.tensor_product.include_left_apply, algebra.tensor_product.tmul_mul_tmul,
mul_one, one_mul, ←algebra.commutes, ←algebra.smul_def, smul_tmul, sum_def, ←tmul_sum],
conv_rhs { rw [←sum_C_mul_X_pow_eq p], },
simp only [algebra.smul_def],
refl, },
{ intros p q hp hq,
simp only [alg_hom.map_add, inv_fun_add, hp, hq], },
end
lemma right_inv (x : A[X]) :
(to_fun_alg_hom R A) (inv_fun R A x) = x :=
begin
apply polynomial.induction_on' x,
{ intros p q hp hq, simp only [inv_fun_add, alg_hom.map_add, hp, hq], },
{ intros n a,
rw [inv_fun_monomial, algebra.tensor_product.include_left_apply,
algebra.tensor_product.tmul_pow, one_pow, algebra.tensor_product.tmul_mul_tmul,
mul_one, one_mul, to_fun_alg_hom_apply_tmul, X_pow_eq_monomial, sum_monomial_index];
simp, }
end
/--
(Implementation detail)
The equivalence, ignoring the algebra structure, `(A ⊗[R] R[X]) ≃ A[X]`.
-/
def equiv : (A ⊗[R] R[X]) ≃ A[X] :=
{ to_fun := to_fun_alg_hom R A,
inv_fun := inv_fun R A,
left_inv := left_inv R A,
right_inv := right_inv R A, }
end poly_equiv_tensor
open poly_equiv_tensor
/--
The `R`-algebra isomorphism `A[X] ≃ₐ[R] (A ⊗[R] R[X])`.
-/
def poly_equiv_tensor : A[X] ≃ₐ[R] (A ⊗[R] R[X]) :=
alg_equiv.symm
{ ..(poly_equiv_tensor.to_fun_alg_hom R A), ..(poly_equiv_tensor.equiv R A) }
@[simp]
lemma poly_equiv_tensor_apply (p : A[X]) :
poly_equiv_tensor R A p =
p.eval₂ (include_left : A →ₐ[R] A ⊗[R] R[X]) ((1 : A) ⊗ₜ[R] (X : R[X])) :=
rfl
@[simp]
lemma poly_equiv_tensor_symm_apply_tmul (a : A) (p : R[X]) :
(poly_equiv_tensor R A).symm (a ⊗ₜ p) = p.sum (λ n r, monomial n (a * algebra_map R A r)) :=
to_fun_alg_hom_apply_tmul _ _ _ _
open dmatrix matrix
open_locale big_operators
variables {R}
variables {n : Type w} [decidable_eq n] [fintype n]
/--
The algebra isomorphism stating "matrices of polynomials are the same as polynomials of matrices".
(You probably shouldn't attempt to use this underlying definition ---
it's an algebra equivalence, and characterised extensionally by the lemma
`mat_poly_equiv_coeff_apply` below.)
-/
noncomputable def mat_poly_equiv :
matrix n n R[X] ≃ₐ[R] (matrix n n R)[X] :=
(((matrix_equiv_tensor R R[X] n)).trans
(algebra.tensor_product.comm R _ _)).trans
(poly_equiv_tensor R (matrix n n R)).symm
open finset
lemma mat_poly_equiv_coeff_apply_aux_1 (i j : n) (k : ℕ) (x : R) :
mat_poly_equiv (std_basis_matrix i j $ monomial k x) =
monomial k (std_basis_matrix i j x) :=
begin
simp only [mat_poly_equiv, alg_equiv.trans_apply,
matrix_equiv_tensor_apply_std_basis],
apply (poly_equiv_tensor R (matrix n n R)).injective,
simp only [alg_equiv.apply_symm_apply],
convert algebra.tensor_product.comm_tmul _ _ _ _ _,
simp only [poly_equiv_tensor_apply],
convert eval₂_monomial _ _,
simp only [algebra.tensor_product.tmul_mul_tmul, one_pow, one_mul, matrix.mul_one,
algebra.tensor_product.tmul_pow, algebra.tensor_product.include_left_apply, mul_eq_mul],
rw [← smul_X_eq_monomial, ← tensor_product.smul_tmul],
congr' with i' j'; simp
end
lemma mat_poly_equiv_coeff_apply_aux_2
(i j : n) (p : R[X]) (k : ℕ) :
coeff (mat_poly_equiv (std_basis_matrix i j p)) k =
std_basis_matrix i j (coeff p k) :=
begin
apply polynomial.induction_on' p,
{ intros p q hp hq, ext,
simp [hp, hq, coeff_add, add_apply, std_basis_matrix_add], },
{ intros k x,
simp only [mat_poly_equiv_coeff_apply_aux_1, coeff_monomial],
split_ifs; { funext, simp, }, }
end
@[simp] lemma mat_poly_equiv_coeff_apply
(m : matrix n n R[X]) (k : ℕ) (i j : n) :
coeff (mat_poly_equiv m) k i j = coeff (m i j) k :=
begin
apply matrix.induction_on' m,
{ simp, },
{ intros p q hp hq, simp [hp, hq], },
{ intros i' j' x,
erw mat_poly_equiv_coeff_apply_aux_2,
dsimp [std_basis_matrix],
split_ifs,
{ rcases h with ⟨rfl, rfl⟩, simp [std_basis_matrix], },
{ simp [std_basis_matrix, h], }, },
end
@[simp] lemma mat_poly_equiv_symm_apply_coeff
(p : (matrix n n R)[X]) (i j : n) (k : ℕ) :
coeff (mat_poly_equiv.symm p i j) k = coeff p k i j :=
begin
have t : p = mat_poly_equiv
(mat_poly_equiv.symm p) := by simp,
conv_rhs { rw t, },
simp only [mat_poly_equiv_coeff_apply],
end
lemma mat_poly_equiv_smul_one (p : R[X]) :
mat_poly_equiv (p • 1) = p.map (algebra_map R (matrix n n R)) :=
begin
ext m i j,
simp only [coeff_map, one_apply, algebra_map_matrix_apply, mul_boole,
pi.smul_apply, mat_poly_equiv_coeff_apply],
split_ifs; simp,
end
lemma support_subset_support_mat_poly_equiv
(m : matrix n n R[X]) (i j : n) :
support (m i j) ⊆ support (mat_poly_equiv m) :=
begin
assume k,
contrapose,
simp only [not_mem_support_iff],
assume hk,
rw [← mat_poly_equiv_coeff_apply, hk],
refl
end
|
f7950b3ee0b7be46e5dab244c2ea719e8bea908b | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/Lean3Lib/init/meta/match_tactic_auto.lean | aa3e41d5ea238b073fbdba9cc42d4de4e55fd092 | [] | 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,222 | 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
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.meta.interactive_base
import Mathlib.Lean3Lib.init.function
namespace Mathlib
namespace tactic
/-- A pattern is an expression `target` containing temporary metavariables.
A pattern also contains a list of `outputs` which also depend on these temporary metavariables.
When we run `match p e`, the system will match `p.target` with `e` and assign
the temporary metavariables. It then returns the outputs with the assigned variables.
## Fields
- `target` Term to match. Contains temporary metavariables.
- `uoutput` List of universes that are returned on a successful match.
- `moutput` List of expressions that are returned on a successful match.
- `nuvars` Number of (temporary) universe metavariables in this pattern.
- `nmvars` Number of (temporary) metavariables in this pattern.
## Example
The pattern for `list.cons h t` returning `h` and `t` would be
```
{ target := `(@list.cons ?x_0 ?x_1 ?x_2),
uoutput := [],
moutput := [?x_1,?x_2],
nuvars := 0,
nmvars := 3
}
```
-/
end Mathlib |
d0931b27d3347ff1c2e5e9d5ee2bbcfb7411f47b | 4d2583807a5ac6caaffd3d7a5f646d61ca85d532 | /src/topology/sequences.lean | 1109f75deb634ccd1816a525758b0b9e95959c73 | [
"Apache-2.0"
] | permissive | AntoineChambert-Loir/mathlib | 64aabb896129885f12296a799818061bc90da1ff | 07be904260ab6e36a5769680b6012f03a4727134 | refs/heads/master | 1,693,187,631,771 | 1,636,719,886,000 | 1,636,719,886,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 18,387 | lean | /-
Copyright (c) 2018 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Patrick Massot
-/
import topology.subset_properties
import topology.metric_space.basic
/-!
# Sequences in topological spaces
In this file we define sequences in topological spaces and show how they are related to
filters and the topology. In particular, we
* define the sequential closure of a set and prove that it's contained in the closure,
* define a type class "sequential_space" in which closure and sequential closure agree,
* define sequential continuity and show that it coincides with continuity in sequential spaces,
* provide an instance that shows that every first-countable (and in particular metric) space is
a sequential space.
* define sequential compactness, prove that compactness implies sequential compactness in first
countable spaces, and prove they are equivalent for uniform spaces having a countable uniformity
basis (in particular metric spaces).
-/
open set filter
open_locale topological_space
variables {α : Type*} {β : Type*}
local notation f ` ⟶ ` limit := tendsto f at_top (𝓝 limit)
/-! ### Sequential closures, sequential continuity, and sequential spaces. -/
section topological_space
variables [topological_space α] [topological_space β]
/-- A sequence converges in the sence of topological spaces iff the associated statement for filter
holds. -/
lemma topological_space.seq_tendsto_iff {x : ℕ → α} {limit : α} :
tendsto x at_top (𝓝 limit) ↔
∀ U : set α, limit ∈ U → is_open U → ∃ N, ∀ n ≥ N, (x n) ∈ U :=
(at_top_basis.tendsto_iff (nhds_basis_opens limit)).trans $
by simp only [and_imp, exists_prop, true_and, set.mem_Ici, ge_iff_le, id]
/-- The sequential closure of a subset M ⊆ α of a topological space α is
the set of all p ∈ α which arise as limit of sequences in M. -/
def sequential_closure (M : set α) : set α :=
{p | ∃ x : ℕ → α, (∀ n : ℕ, x n ∈ M) ∧ (x ⟶ p)}
lemma subset_sequential_closure (M : set α) : M ⊆ sequential_closure M :=
assume p (_ : p ∈ M), show p ∈ sequential_closure M, from
⟨λ n, p, assume n, ‹p ∈ M›, tendsto_const_nhds⟩
/-- A set `s` is sequentially closed if for any converging sequence `x n` of elements of `s`,
the limit belongs to `s` as well. -/
def is_seq_closed (s : set α) : Prop := s = sequential_closure s
/-- A convenience lemma for showing that a set is sequentially closed. -/
lemma is_seq_closed_of_def {A : set α}
(h : ∀(x : ℕ → α) (p : α), (∀ n : ℕ, x n ∈ A) → (x ⟶ p) → p ∈ A) : is_seq_closed A :=
show A = sequential_closure A, from subset.antisymm
(subset_sequential_closure A)
(show ∀ p, p ∈ sequential_closure A → p ∈ A, from
(assume p ⟨x, _, _⟩, show p ∈ A, from h x p ‹∀ n : ℕ, ((x n) ∈ A)› ‹(x ⟶ p)›))
/-- The sequential closure of a set is contained in the closure of that set.
The converse is not true. -/
lemma sequential_closure_subset_closure (M : set α) : sequential_closure M ⊆ closure M :=
assume p ⟨x, xM, xp⟩,
mem_closure_of_tendsto xp (univ_mem' xM)
/-- A set is sequentially closed if it is closed. -/
lemma is_seq_closed_of_is_closed (M : set α) (_ : is_closed M) : is_seq_closed M :=
suffices sequential_closure M ⊆ M, from
set.eq_of_subset_of_subset (subset_sequential_closure M) this,
calc sequential_closure M ⊆ closure M : sequential_closure_subset_closure M
... = M : is_closed.closure_eq ‹is_closed M›
/-- The limit of a convergent sequence in a sequentially closed set is in that set.-/
lemma mem_of_is_seq_closed {A : set α} (_ : is_seq_closed A) {x : ℕ → α}
(_ : ∀ n, x n ∈ A) {limit : α} (_ : (x ⟶ limit)) : limit ∈ A :=
have limit ∈ sequential_closure A, from
show ∃ x : ℕ → α, (∀ n : ℕ, x n ∈ A) ∧ (x ⟶ limit), from ⟨x, ‹∀ n, x n ∈ A›, ‹(x ⟶ limit)›⟩,
eq.subst (eq.symm ‹is_seq_closed A›) ‹limit ∈ sequential_closure A›
/-- The limit of a convergent sequence in a closed set is in that set.-/
lemma mem_of_is_closed_sequential {A : set α} (_ : is_closed A) {x : ℕ → α}
(_ : ∀ n, x n ∈ A) {limit : α} (_ : x ⟶ limit) : limit ∈ A :=
mem_of_is_seq_closed (is_seq_closed_of_is_closed A ‹is_closed A›) ‹∀ n, x n ∈ A› ‹(x ⟶ limit)›
/-- A sequential space is a space in which 'sequences are enough to probe the topology'. This can be
formalised by demanding that the sequential closure and the closure coincide. The following
statements show that other topological properties can be deduced from sequences in sequential
spaces. -/
class sequential_space (α : Type*) [topological_space α] : Prop :=
(sequential_closure_eq_closure : ∀ M : set α, sequential_closure M = closure M)
/-- In a sequential space, a set is closed iff it's sequentially closed. -/
lemma is_seq_closed_iff_is_closed [sequential_space α] {M : set α} :
is_seq_closed M ↔ is_closed M :=
iff.intro
(assume _, closure_eq_iff_is_closed.mp (eq.symm
(calc M = sequential_closure M : by assumption
... = closure M : sequential_space.sequential_closure_eq_closure M)))
(is_seq_closed_of_is_closed M)
/-- In a sequential space, a point belongs to the closure of a set iff it is a limit of a sequence
taking values in this set. -/
lemma mem_closure_iff_seq_limit [sequential_space α] {s : set α} {a : α} :
a ∈ closure s ↔ ∃ x : ℕ → α, (∀ n : ℕ, x n ∈ s) ∧ (x ⟶ a) :=
by { rw ← sequential_space.sequential_closure_eq_closure, exact iff.rfl }
/-- A function between topological spaces is sequentially continuous if it commutes with limit of
convergent sequences. -/
def sequentially_continuous (f : α → β) : Prop :=
∀ (x : ℕ → α), ∀ {limit : α}, (x ⟶ limit) → (f∘x ⟶ f limit)
/- A continuous function is sequentially continuous. -/
lemma continuous.to_sequentially_continuous {f : α → β} (_ : continuous f) :
sequentially_continuous f :=
assume x limit (_ : x ⟶ limit),
have tendsto f (𝓝 limit) (𝓝 (f limit)), from continuous.tendsto ‹continuous f› limit,
show (f ∘ x) ⟶ (f limit), from tendsto.comp this ‹(x ⟶ limit)›
/-- In a sequential space, continuity and sequential continuity coincide. -/
lemma continuous_iff_sequentially_continuous {f : α → β} [sequential_space α] :
continuous f ↔ sequentially_continuous f :=
iff.intro
(assume _, ‹continuous f›.to_sequentially_continuous)
(assume : sequentially_continuous f, show continuous f, from
suffices h : ∀ {A : set β}, is_closed A → is_seq_closed (f ⁻¹' A), from
continuous_iff_is_closed.mpr (assume A _, is_seq_closed_iff_is_closed.mp $ h ‹is_closed A›),
assume A (_ : is_closed A),
is_seq_closed_of_def $
assume (x : ℕ → α) p (_ : ∀ n, f (x n) ∈ A) (_ : x ⟶ p),
have (f ∘ x) ⟶ (f p), from ‹sequentially_continuous f› x ‹(x ⟶ p)›,
show f p ∈ A, from
mem_of_is_closed_sequential ‹is_closed A› ‹∀ n, f (x n) ∈ A› ‹(f∘x ⟶ f p)›)
end topological_space
namespace topological_space
namespace first_countable_topology
variables [topological_space α] [first_countable_topology α]
/-- Every first-countable space is sequential. -/
@[priority 100] -- see Note [lower instance priority]
instance : sequential_space α :=
⟨show ∀ M, sequential_closure M = closure M, from assume M,
suffices closure M ⊆ sequential_closure M,
from set.subset.antisymm (sequential_closure_subset_closure M) this,
-- For every p ∈ closure M, we need to construct a sequence x in M that converges to p:
assume (p : α) (hp : p ∈ closure M),
-- Since we are in a first-countable space, the neighborhood filter around `p` has a decreasing
-- basis `U` indexed by `ℕ`.
let ⟨U, hU⟩ := (𝓝 p).exists_antitone_basis in
-- Since `p ∈ closure M`, there is an element in each `M ∩ U i`
have hp : ∀ (i : ℕ), ∃ (y : α), y ∈ M ∧ y ∈ U i,
by simpa using (mem_closure_iff_nhds_basis hU.1).mp hp,
begin
-- The axiom of (countable) choice builds our sequence from the later fact
choose u hu using hp,
rw forall_and_distrib at hu,
-- It clearly takes values in `M`
use [u, hu.1],
-- and converges to `p` because the basis is decreasing.
apply hU.tendsto hu.2,
end⟩
end first_countable_topology
end topological_space
section seq_compact
open topological_space topological_space.first_countable_topology
variables [topological_space α]
/-- A set `s` is sequentially compact if every sequence taking values in `s` has a
converging subsequence. -/
def is_seq_compact (s : set α) :=
∀ ⦃u : ℕ → α⦄, (∀ n, u n ∈ s) →
∃ (x ∈ s) (φ : ℕ → ℕ), strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 x)
/-- A space `α` is sequentially compact if every sequence in `α` has a
converging subsequence. -/
class seq_compact_space (α : Type*) [topological_space α] : Prop :=
(seq_compact_univ : is_seq_compact (univ : set α))
lemma is_seq_compact.subseq_of_frequently_in {s : set α} (hs : is_seq_compact s) {u : ℕ → α}
(hu : ∃ᶠ n in at_top, u n ∈ s) :
∃ (x ∈ s) (φ : ℕ → ℕ), strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 x) :=
let ⟨ψ, hψ, huψ⟩ := extraction_of_frequently_at_top hu, ⟨x, x_in, φ, hφ, h⟩ := hs huψ in
⟨x, x_in, ψ ∘ φ, hψ.comp hφ, h⟩
lemma seq_compact_space.tendsto_subseq [seq_compact_space α] (u : ℕ → α) :
∃ x (φ : ℕ → ℕ), strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 x) :=
let ⟨x, _, φ, mono, h⟩ := seq_compact_space.seq_compact_univ (by simp : ∀ n, u n ∈ univ) in
⟨x, φ, mono, h⟩
section first_countable_topology
variables [first_countable_topology α]
open topological_space.first_countable_topology
lemma is_compact.is_seq_compact {s : set α} (hs : is_compact s) : is_seq_compact s :=
λ u u_in,
let ⟨x, x_in, hx⟩ := @hs (map u at_top) _
(le_principal_iff.mpr (univ_mem' u_in : _)) in ⟨x, x_in, tendsto_subseq hx⟩
lemma is_compact.tendsto_subseq' {s : set α} {u : ℕ → α} (hs : is_compact s)
(hu : ∃ᶠ n in at_top, u n ∈ s) :
∃ (x ∈ s) (φ : ℕ → ℕ), strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 x) :=
hs.is_seq_compact.subseq_of_frequently_in hu
lemma is_compact.tendsto_subseq {s : set α} {u : ℕ → α} (hs : is_compact s) (hu : ∀ n, u n ∈ s) :
∃ (x ∈ s) (φ : ℕ → ℕ), strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 x) :=
hs.is_seq_compact hu
@[priority 100] -- see Note [lower instance priority]
instance first_countable_topology.seq_compact_of_compact [compact_space α] : seq_compact_space α :=
⟨compact_univ.is_seq_compact⟩
lemma compact_space.tendsto_subseq [compact_space α] (u : ℕ → α) :
∃ x (φ : ℕ → ℕ), strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 x) :=
seq_compact_space.tendsto_subseq u
end first_countable_topology
end seq_compact
section uniform_space_seq_compact
open_locale uniformity
open uniform_space prod
variables [uniform_space β] {s : set β}
lemma lebesgue_number_lemma_seq {ι : Type*} [is_countably_generated (𝓤 β)] {c : ι → set β}
(hs : is_seq_compact s) (hc₁ : ∀ i, is_open (c i)) (hc₂ : s ⊆ ⋃ i, c i)
:
∃ V ∈ 𝓤 β, symmetric_rel V ∧ ∀ x ∈ s, ∃ i, ball x V ⊆ c i :=
begin
classical,
obtain ⟨V, hV, Vsymm⟩ :
∃ V : ℕ → set (β × β), (𝓤 β).has_antitone_basis (λ _, true) V ∧ ∀ n, swap ⁻¹' V n = V n,
from uniform_space.has_seq_basis β,
suffices : ∃ n, ∀ x ∈ s, ∃ i, ball x (V n) ⊆ c i,
{ cases this with n hn,
exact ⟨V n, hV.to_has_basis.mem_of_mem trivial, Vsymm n, hn⟩ },
by_contradiction H,
obtain ⟨x, x_in, hx⟩ : ∃ x : ℕ → β, (∀ n, x n ∈ s) ∧ ∀ n i, ¬ ball (x n) (V n) ⊆ c i,
{ push_neg at H,
choose x hx using H,
exact ⟨x, forall_and_distrib.mp hx⟩ }, clear H,
obtain ⟨x₀, x₀_in, φ, φ_mono, hlim⟩ : ∃ (x₀ ∈ s) (φ : ℕ → ℕ), strict_mono φ ∧ (x ∘ φ ⟶ x₀),
from hs x_in, clear hs,
obtain ⟨i₀, x₀_in⟩ : ∃ i₀, x₀ ∈ c i₀,
{ rcases hc₂ x₀_in with ⟨_, ⟨i₀, rfl⟩, x₀_in_c⟩,
exact ⟨i₀, x₀_in_c⟩ }, clear hc₂,
obtain ⟨n₀, hn₀⟩ : ∃ n₀, ball x₀ (V n₀) ⊆ c i₀,
{ rcases (nhds_basis_uniformity hV.to_has_basis).mem_iff.mp
(is_open_iff_mem_nhds.mp (hc₁ i₀) _ x₀_in) with ⟨n₀, _, h⟩,
use n₀,
rwa ← ball_eq_of_symmetry (Vsymm n₀) at h }, clear hc₁,
obtain ⟨W, W_in, hWW⟩ : ∃ W ∈ 𝓤 β, W ○ W ⊆ V n₀,
from comp_mem_uniformity_sets (hV.to_has_basis.mem_of_mem trivial),
obtain ⟨N, x_φ_N_in, hVNW⟩ : ∃ N, x (φ N) ∈ ball x₀ W ∧ V (φ N) ⊆ W,
{ obtain ⟨N₁, h₁⟩ : ∃ N₁, ∀ n ≥ N₁, x (φ n) ∈ ball x₀ W,
from tendsto_at_top'.mp hlim _ (mem_nhds_left x₀ W_in),
obtain ⟨N₂, h₂⟩ : ∃ N₂, V (φ N₂) ⊆ W,
{ rcases hV.to_has_basis.mem_iff.mp W_in with ⟨N, _, hN⟩,
use N,
exact subset.trans (hV.decreasing trivial trivial $ φ_mono.id_le _) hN },
have : φ N₂ ≤ φ (max N₁ N₂),
from φ_mono.le_iff_le.mpr (le_max_right _ _),
exact ⟨max N₁ N₂, h₁ _ (le_max_left _ _), trans (hV.decreasing trivial trivial this) h₂⟩ },
suffices : ball (x (φ N)) (V (φ N)) ⊆ c i₀,
from hx (φ N) i₀ this,
calc
ball (x $ φ N) (V $ φ N) ⊆ ball (x $ φ N) W : preimage_mono hVNW
... ⊆ ball x₀ (V n₀) : ball_subset_of_comp_subset x_φ_N_in hWW
... ⊆ c i₀ : hn₀,
end
lemma is_seq_compact.totally_bounded (h : is_seq_compact s) : totally_bounded s :=
begin
classical,
apply totally_bounded_of_forall_symm,
unfold is_seq_compact at h,
contrapose! h,
rcases h with ⟨V, V_in, V_symm, h⟩,
simp_rw [not_subset] at h,
have : ∀ (t : set β), finite t → ∃ a, a ∈ s ∧ a ∉ ⋃ y ∈ t, ball y V,
{ intros t ht,
obtain ⟨a, a_in, H⟩ : ∃ a ∈ s, ∀ (x : β), x ∈ t → (x, a) ∉ V,
by simpa [ht] using h t,
use [a, a_in],
intro H',
obtain ⟨x, x_in, hx⟩ := mem_bUnion_iff.mp H',
exact H x x_in hx },
cases seq_of_forall_finite_exists this with u hu, clear h this,
simp [forall_and_distrib] at hu,
cases hu with u_in hu,
use [u, u_in], clear u_in,
intros x x_in φ,
intros hφ huφ,
obtain ⟨N, hN⟩ : ∃ N, ∀ p q, p ≥ N → q ≥ N → (u (φ p), u (φ q)) ∈ V,
from huφ.cauchy_seq.mem_entourage V_in,
specialize hN N (N+1) (le_refl N) (nat.le_succ N),
specialize hu (φ $ N+1) (φ N) (hφ $ lt_add_one N),
exact hu hN,
end
protected lemma is_seq_compact.is_compact [is_countably_generated $ 𝓤 β] (hs : is_seq_compact s) :
is_compact s :=
begin
classical,
rw is_compact_iff_finite_subcover,
intros ι U Uop s_sub,
rcases lebesgue_number_lemma_seq hs Uop s_sub with ⟨V, V_in, Vsymm, H⟩,
rcases totally_bounded_iff_subset.mp hs.totally_bounded V V_in with ⟨t,t_sub, tfin, ht⟩,
have : ∀ x : t, ∃ (i : ι), ball x.val V ⊆ U i,
{ rintros ⟨x, x_in⟩,
exact H x (t_sub x_in) },
choose i hi using this,
haveI : fintype t := tfin.fintype,
use finset.image i finset.univ,
transitivity ⋃ y ∈ t, ball y V,
{ intros x x_in,
specialize ht x_in,
rw mem_bUnion_iff at *,
simp_rw ball_eq_of_symmetry Vsymm,
exact ht },
{ apply bUnion_subset_bUnion,
intros x x_in,
exact ⟨i ⟨x, x_in⟩, finset.mem_image_of_mem _ (finset.mem_univ _), hi ⟨x, x_in⟩⟩ },
end
/-- A version of Bolzano-Weistrass: in a uniform space with countably generated uniformity filter
(e.g., in a metric space), a set is compact if and only if it is sequentially compact. -/
protected lemma uniform_space.compact_iff_seq_compact [is_countably_generated $ 𝓤 β] :
is_compact s ↔ is_seq_compact s :=
⟨λ H, H.is_seq_compact, λ H, H.is_compact⟩
lemma uniform_space.compact_space_iff_seq_compact_space [is_countably_generated $ 𝓤 β] :
compact_space β ↔ seq_compact_space β :=
have key : is_compact (univ : set β) ↔ is_seq_compact univ := uniform_space.compact_iff_seq_compact,
⟨λ ⟨h⟩, ⟨key.mp h⟩, λ ⟨h⟩, ⟨key.mpr h⟩⟩
end uniform_space_seq_compact
section metric_seq_compact
variables [metric_space β] {s : set β}
open metric
/-- A version of Bolzano-Weistrass: in a proper metric space (eg. $ℝ^n$),
every bounded sequence has a converging subsequence. This version assumes only
that the sequence is frequently in some bounded set. -/
lemma tendsto_subseq_of_frequently_bounded [proper_space β] (hs : bounded s)
{u : ℕ → β} (hu : ∃ᶠ n in at_top, u n ∈ s) :
∃ b ∈ closure s, ∃ φ : ℕ → ℕ, strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 b) :=
begin
have hcs : is_compact (closure s) :=
compact_iff_closed_bounded.mpr ⟨is_closed_closure, bounded_closure_of_bounded hs⟩,
replace hcs : is_seq_compact (closure s),
from uniform_space.compact_iff_seq_compact.mp hcs,
have hu' : ∃ᶠ n in at_top, u n ∈ closure s,
{ apply frequently.mono hu,
intro n,
apply subset_closure },
exact hcs.subseq_of_frequently_in hu',
end
/-- A version of Bolzano-Weistrass: in a proper metric space (eg. $ℝ^n$),
every bounded sequence has a converging subsequence. -/
lemma tendsto_subseq_of_bounded [proper_space β] (hs : bounded s)
{u : ℕ → β} (hu : ∀ n, u n ∈ s) :
∃ b ∈ closure s, ∃ φ : ℕ → ℕ, strict_mono φ ∧ tendsto (u ∘ φ) at_top (𝓝 b) :=
tendsto_subseq_of_frequently_bounded hs $ frequently_of_forall hu
lemma seq_compact.lebesgue_number_lemma_of_metric
{ι : Type*} {c : ι → set β} (hs : is_seq_compact s)
(hc₁ : ∀ i, is_open (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
∃ δ > 0, ∀ x ∈ s, ∃ i, ball x δ ⊆ c i :=
begin
rcases lebesgue_number_lemma_seq hs hc₁ hc₂ with ⟨V, V_in, _, hV⟩,
rcases uniformity_basis_dist.mem_iff.mp V_in with ⟨δ, δ_pos, h⟩,
use [δ, δ_pos],
intros x x_in,
rcases hV x x_in with ⟨i, hi⟩,
use i,
have := ball_mono h x,
rw ball_eq_ball' at this,
exact subset.trans this hi,
end
end metric_seq_compact
|
f950c559d7e7062427c2256ddbad49f577c3e2ee | a9d0fb7b0e4f802bd3857b803e6c5c23d87fef91 | /tests/lean/run/match_convoy2.lean | a3670a53eada278457361cd28ae80d4674bbbfea | [
"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 | 302 | lean |
inductive vec (A : Type) : nat → Type
| nil {} : vec nat.zero
| cons : ∀ {n}, A → vec n → vec (nat.succ n)
open vec
definition boo (n : nat) (v : vec bool n) : vec bool n :=
match n, v : ∀ (n : _), vec bool n → _ with
| 0, nil := nil
| n+1, cons a v := cons (bool.bnot a) v
end
|
a974796ccd45093e97722a7cce1e940729f60e10 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/topology/continuous_function/t0_sierpinski.lean | 6c3b386264580334e99a832ef092ede7fc0eb9e2 | [
"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 | 2,326 | lean | /-
Copyright (c) 2022 Ivan Sadofschi Costa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ivan Sadofschi Costa
-/
import topology.order
import topology.sets.opens
import topology.continuous_function.basic
/-!
# Any T0 space embeds in a product of copies of the Sierpinski space.
We consider `Prop` with the Sierpinski topology. If `X` is a topological space, there is a
continuous map `product_of_mem_opens` from `X` to `opens X → Prop` which is the product of the maps
`X → Prop` given by `x ↦ x ∈ u`.
The map `product_of_mem_opens` is always inducing. Whenever `X` is T0, `product_of_mem_opens` is
also injective and therefore an embedding.
-/
noncomputable theory
namespace topological_space
lemma eq_induced_by_maps_to_sierpinski (X : Type*) [t : topological_space X] :
t = ⨅ (u : opens X), sierpinski_space.induced (∈ u) :=
begin
apply le_antisymm,
{ rw [le_infi_iff],
exact λ u, continuous.le_induced (is_open_iff_continuous_mem.mp u.2) },
{ intros u h,
rw ← generate_from_Union_is_open,
apply is_open_generate_from_of_mem,
simp only [set.mem_Union, set.mem_set_of_eq, is_open_induced_iff'],
exact ⟨⟨u, h⟩, {true}, is_open_singleton_true, by simp [set.preimage]⟩ },
end
variables (X : Type*) [topological_space X]
/--
The continuous map from `X` to the product of copies of the Sierpinski space, (one copy for each
open subset `u` of `X`). The `u` coordinate of `product_of_mem_opens x` is given by `x ∈ u`.
-/
def product_of_mem_opens : continuous_map X (opens X → Prop) :=
{ to_fun := λ x u, x ∈ u,
continuous_to_fun := continuous_pi_iff.2 (λ u, continuous_Prop.2 u.property) }
lemma product_of_mem_opens_inducing : inducing (product_of_mem_opens X) :=
begin
convert inducing_infi_to_pi (λ (u : opens X) (x : X), x ∈ u),
apply eq_induced_by_maps_to_sierpinski,
end
lemma product_of_mem_opens_injective [t0_space X] : function.injective (product_of_mem_opens X) :=
begin
intros x1 x2 h,
apply inseparable.eq,
rw [←inducing.inseparable_iff (product_of_mem_opens_inducing X), h],
end
theorem product_of_mem_opens_embedding [t0_space X] : embedding (product_of_mem_opens X) :=
embedding.mk (product_of_mem_opens_inducing X) (product_of_mem_opens_injective X)
end topological_space
|
452f2e353a2d4360fdeb1bffbcfe51c9e99275b8 | 7cef822f3b952965621309e88eadf618da0c8ae9 | /src/tactic/transport.lean | cf6500cb51aab27127a4cb7b98084e287ffe9f06 | [
"Apache-2.0"
] | permissive | rmitta/mathlib | 8d90aee30b4db2b013e01f62c33f297d7e64a43d | 883d974b608845bad30ae19e27e33c285200bf84 | refs/heads/master | 1,585,776,832,544 | 1,576,874,096,000 | 1,576,874,096,000 | 153,663,165 | 0 | 2 | Apache-2.0 | 1,544,806,490,000 | 1,539,884,365,000 | Lean | UTF-8 | Lean | false | false | 1,081 | lean | import meta.expr meta.rb_map
namespace tactic
private meta def transport_with_prefix_fun_aux (f : name → option name) (pre tgt_pre : name)
(attrs : list name) :
name → command :=
λ src,
do
let tgt := src.map_prefix (λ n, if n = pre then some tgt_pre else none),
(get_decl tgt >> skip) <|>
do
decl ← get_decl src,
(decl.type.list_names_with_prefix pre).mfold () (λ n _, transport_with_prefix_fun_aux n),
(decl.value.list_names_with_prefix pre).mfold () (λ n _, transport_with_prefix_fun_aux n),
add_decl (decl.update_with_fun (name.map_prefix f) tgt),
attrs.mmap' (λ n, copy_attribute n src tt tgt)
meta def transport_with_prefix_fun (f : name → option name) (src tgt : name) (attrs : list name) :
command :=
do transport_with_prefix_fun_aux f src tgt attrs src,
ls ← get_eqn_lemmas_for tt src,
ls.mmap' $ transport_with_prefix_fun_aux f src tgt attrs
meta def transport_with_prefix_dict (dict : name_map name) (src tgt : name) (attrs : list name) :
command :=
transport_with_prefix_fun dict.find src tgt attrs
end tactic
|
bb83761969dc647f755b75a7af1c81efd7e4beae | 952248371e69ccae722eb20bfe6815d8641554a8 | /test/normalizer.lean | 1b294120f1d3d3aff9efcee43bb68f85838f7000 | [] | no_license | robertylewis/lean_polya | 5fd079031bf7114449d58d68ccd8c3bed9bcbc97 | 1da14d60a55ad6cd8af8017b1b64990fccb66ab7 | refs/heads/master | 1,647,212,226,179 | 1,558,108,354,000 | 1,558,108,354,000 | 89,933,264 | 1 | 2 | null | 1,560,964,118,000 | 1,493,650,551,000 | Lean | UTF-8 | Lean | false | false | 290 | lean | import normalizer
open polya
constants a b c u v w z y x: ℚ
private meta def test_on (e : expr) := (do
t ← expr.to_term e,
st ← term.canonize t,
tactic.trace st
)
run_cmd test_on `(1*a + 3*(b + c) + 5*b)
run_cmd test_on `((1*u + (2* (1* v ^ 2 + 23*1) ^ 3) + 1*z) ^ 3)
|
cee1ac0f7935be0234f8bb9477a344b0a36d8d60 | ac2987d8c7832fb4a87edb6bee26141facbb6fa0 | /Mathlib/Tactic/SudoSetOption.lean | a420e3791b4b5198d6ca1da49077cf02e733bcc8 | [
"Apache-2.0"
] | permissive | AurelienSaue/mathlib4 | 52204b9bd9d207c922fe0cf3397166728bb6c2e2 | 84271fe0875bafdaa88ac41f1b5a7c18151bd0d5 | refs/heads/master | 1,689,156,096,545 | 1,629,378,840,000 | 1,629,378,840,000 | 389,648,603 | 0 | 0 | Apache-2.0 | 1,627,307,284,000 | 1,627,307,284,000 | null | UTF-8 | Lean | false | false | 1,655 | lean | /-
Copyright (c) 2021 Gabriel Ebner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner
-/
import Lean
open Lean Elab
private def setOption [Monad m] [MonadError m]
(name val : Syntax) (opts : Options) : m Options := do
let val ← match val with
| Syntax.ident _ _ `true _ => DataValue.ofBool true
| Syntax.ident _ _ `false _ => DataValue.ofBool false
| _ => match val.isNatLit? with
| some num => DataValue.ofNat num
| none => match val.isStrLit? with
| some str => DataValue.ofString str
| none =>
throwError "unsupported option value {val}"
opts.insert name.getId val
/-
The command `sudo set_option name val` is similar to `set_option name val`,
but it also allows to set undeclared options.
-/
open Elab.Command in
elab "sudo" "set_option" n:ident val:term : command => do
let options ← setOption n val (← getOptions)
modify fun s => { s with maxRecDepth := maxRecDepth.get options }
modifyScope fun scope => { scope with opts := options }
/-
The command `sudo set_option name val in term` is similar to `set_option name val in term`,
but it also allows to set undeclared options.
-/
open Elab.Term in
elab "sudo" "set_option" n:ident val:term "in" body:term : term <= expectedType => do
let options ← setOption n val (← getOptions)
withTheReader Core.Context (fun ctx =>
{ ctx with maxRecDepth := maxRecDepth.get options, options := options }) do
elabTerm body expectedType
/-
sudo set_option trace.Elab.resuming true in #check 4
#check sudo set_option trace.Elab.resuming true in by exact 4
-/
|
6e1d3d185912b74f67a07d3827e411d11c072e10 | 82b86ba2ae0d5aed0f01f49c46db5afec0eb2bd7 | /src/Std/Data/HashSet.lean | b8482cd1a39f32ec2a939f0a558c2e063373bc1c | [
"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 | 6,060 | lean | /-
Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
-/
namespace Std
universes u v w
def HashSetBucket (α : Type u) :=
{ b : Array (List α) // b.size > 0 }
def HashSetBucket.update {α : Type u} (data : HashSetBucket α) (i : USize) (d : List α) (h : i.toNat < data.val.size) : HashSetBucket α :=
⟨ data.val.uset i d h,
by rw [Array.szFSetEq]; exact data.property ⟩
structure HashSetImp (α : Type u) :=
(size : Nat)
(buckets : HashSetBucket α)
def mkHashSetImp {α : Type u} (nbuckets := 8) : HashSetImp α :=
let n := if nbuckets = 0 then 8 else nbuckets
{ size := 0,
buckets :=
⟨ mkArray n [],
by rw [Array.sizeMkArrayEq]; cases nbuckets; decide!; apply Nat.zeroLtSucc ⟩ }
namespace HashSetImp
variables {α : Type u}
def mkIdx {n : Nat} (h : n > 0) (u : USize) : { u : USize // u.toNat < n } :=
⟨u %ₙ n, USize.modnLt _ h⟩
@[inline] def reinsertAux (hashFn : α → USize) (data : HashSetBucket α) (a : α) : HashSetBucket α :=
let ⟨i, h⟩ := mkIdx data.property (hashFn a)
data.update i (a :: data.val.uget i h) h
@[inline] def foldBucketsM {δ : Type w} {m : Type w → Type w} [Monad m] (data : HashSetBucket α) (d : δ) (f : δ → α → m δ) : m δ :=
data.val.foldlM (init := d) fun d as => as.foldlM f d
@[inline] def foldBuckets {δ : Type w} (data : HashSetBucket α) (d : δ) (f : δ → α → δ) : δ :=
Id.run $ foldBucketsM data d f
@[inline] def foldM {δ : Type w} {m : Type w → Type w} [Monad m] (f : δ → α → m δ) (d : δ) (h : HashSetImp α) : m δ :=
foldBucketsM h.buckets d f
@[inline] def fold {δ : Type w} (f : δ → α → δ) (d : δ) (m : HashSetImp α) : δ :=
foldBuckets m.buckets d f
def find? [BEq α] [Hashable α] (m : HashSetImp α) (a : α) : Option α :=
match m with
| ⟨_, buckets⟩ =>
let ⟨i, h⟩ := mkIdx buckets.property (hash a)
(buckets.val.uget i h).find? (fun a' => a == a')
def contains [BEq α] [Hashable α] (m : HashSetImp α) (a : α) : Bool :=
match m with
| ⟨_, buckets⟩ =>
let ⟨i, h⟩ := mkIdx buckets.property (hash a)
(buckets.val.uget i h).contains a
-- TODO: remove `partial` by using well-founded recursion
partial def moveEntries [Hashable α] (i : Nat) (source : Array (List α)) (target : HashSetBucket α) : HashSetBucket α :=
if h : i < source.size then
let idx : Fin source.size := ⟨i, h⟩
let es : List α := source.get idx
-- We remove `es` from `source` to make sure we can reuse its memory cells when performing es.foldl
let source := source.set idx []
let target := es.foldl (reinsertAux hash) target
moveEntries (i+1) source target
else target
def expand [Hashable α] (size : Nat) (buckets : HashSetBucket α) : HashSetImp α :=
let nbuckets := buckets.val.size * 2
have nbuckets > 0 from Nat.mulPos buckets.property (decide! : 2 > 0)
let new_buckets : HashSetBucket α := ⟨mkArray nbuckets [], by rw [Array.sizeMkArrayEq]; assumption⟩
{ size := size,
buckets := moveEntries 0 buckets.val new_buckets }
def insert [BEq α] [Hashable α] (m : HashSetImp α) (a : α) : HashSetImp α :=
match m with
| ⟨size, buckets⟩ =>
let ⟨i, h⟩ := mkIdx buckets.property (hash a)
let bkt := buckets.val.uget i h
if bkt.contains a
then ⟨size, buckets.update i (bkt.replace a a) h⟩
else
let size' := size + 1
let buckets' := buckets.update i (a :: bkt) h
if size' ≤ buckets.val.size
then { size := size', buckets := buckets' }
else expand size' buckets'
def erase [BEq α] [Hashable α] (m : HashSetImp α) (a : α) : HashSetImp α :=
match m with
| ⟨ size, buckets ⟩ =>
let ⟨i, h⟩ := mkIdx buckets.property (hash a)
let bkt := buckets.val.uget i h
if bkt.contains a then ⟨size - 1, buckets.update i (bkt.erase a) h⟩
else m
inductive WellFormed [BEq α] [Hashable α] : HashSetImp α → Prop
| mkWff : ∀ n, WellFormed (mkHashSetImp n)
| insertWff : ∀ m a, WellFormed m → WellFormed (insert m a)
| eraseWff : ∀ m a, WellFormed m → WellFormed (erase m a)
end HashSetImp
def HashSet (α : Type u) [BEq α] [Hashable α] :=
{ m : HashSetImp α // m.WellFormed }
open HashSetImp
def mkHashSet {α : Type u} [BEq α] [Hashable α] (nbuckets := 8) : HashSet α :=
⟨ mkHashSetImp nbuckets, WellFormed.mkWff nbuckets ⟩
namespace HashSet
variables {α : Type u} [BEq α] [Hashable α]
instance : Inhabited (HashSet α) := ⟨mkHashSet⟩
instance : EmptyCollection (HashSet α) := ⟨mkHashSet⟩
@[inline] def insert (m : HashSet α) (a : α) : HashSet α :=
match m with
| ⟨ m, hw ⟩ => ⟨ m.insert a, WellFormed.insertWff m a hw ⟩
@[inline] def erase (m : HashSet α) (a : α) : HashSet α :=
match m with
| ⟨ m, hw ⟩ => ⟨ m.erase a, WellFormed.eraseWff m a hw ⟩
@[inline] def find? (m : HashSet α) (a : α) : Option α :=
match m with
| ⟨ m, _ ⟩ => m.find? a
@[inline] def contains (m : HashSet α) (a : α) : Bool :=
match m with
| ⟨ m, _ ⟩ => m.contains a
@[inline] def foldM {δ : Type w} {m : Type w → Type w} [Monad m] (f : δ → α → m δ) (init : δ) (h : HashSet α) : m δ :=
match h with
| ⟨ h, _ ⟩ => h.foldM f init
@[inline] def fold {δ : Type w} (f : δ → α → δ) (init : δ) (m : HashSet α) : δ :=
match m with
| ⟨ m, _ ⟩ => m.fold f init
@[inline] def size (m : HashSet α) : Nat :=
match m with
| ⟨ {size := sz, ..}, _ ⟩ => sz
@[inline] def isEmpty (m : HashSet α) : Bool :=
m.size = 0
@[inline] def empty : HashSet α :=
mkHashSet
def toList (m : HashSet α) : List α :=
m.fold (init := []) fun r a => a::r
def toArray (m : HashSet α) : Array α :=
m.fold (init := #[]) fun r a => r.push a
def numBuckets (m : HashSet α) : Nat :=
m.val.buckets.val.size
end HashSet
end Std
|
426464680fc63491bb83d32ff0b2cb802ebc75cf | 3d2a7f1582fe5bae4d0bdc2fe86e997521239a65 | /misc/bs2.lean | 8edbdc3ac3f70a7f0405a7afd4ab445d0be5a01d | [] | no_license | own-pt/common-sense-lean | e4fa643ae010459de3d1bf673be7cbc7062563c9 | f672210aecb4172f5bae265e43e6867397e13b1c | refs/heads/master | 1,622,065,660,261 | 1,589,487,533,000 | 1,589,487,533,000 | 254,167,782 | 3 | 2 | null | 1,589,487,535,000 | 1,586,370,214,000 | Lean | UTF-8 | Lean | false | false | 10,441 | lean | /-
The problem is originally presented in:
A. Pease, G. Sutcliffe, N. Siegel, and S. Trac, “Large Theory
Reasoning with SUMO at CASC,” pp. 1–8, Jul. 2009.
Here we present the natural deduction proof in Lean.
-/
import bs_test
-- some initial tests
lemma VertebrateAnimal : ∀ (x : U), ins x Vertebrate → ins x Animal :=
begin
intros a h,
have h1, from a15 Vertebrate Animal a,
apply h1,
exact (and.intro a71402 a72771),
exact (and.intro a71382 h)
end
lemma subclass_TransitiveRelation : ins subclass_m TransitiveRelation :=
begin
--specialize a15 PartialOrderingRelation TransitiveRelation subclass_m,
apply a15,
exact ⟨ a72180, a71844 ⟩,
exact ⟨ a67818, a13 ⟩,
end
lemma VertebrateOrganism : ∀ (x : U), ins x Vertebrate → ins x Organism :=
begin
intros a h,
have h1, from a15 Animal Organism a,
apply h1,
exact and.intro a72771 a71371,
have h0 : ∀ x, ins x Vertebrate → ins x Animal, apply VertebrateAnimal; assumption,
have h2, from h0 a h,
exact and.intro a71369 h2,
end
lemma VertebrateOrganism' : ∀ (x : U), ins x Vertebrate → ins x Organism :=
begin
intros a h,
have h₁ : ins subclass_m TransitiveRelation,
--specialize a15 PartialOrderingRelation TransitiveRelation subclass_m,
apply a15,
exact ⟨a72180, a71844⟩,
exact ⟨a67818, a13⟩,
have h₂ : subclass Vertebrate Organism,
apply a67809 _ Animal _,
exact ⟨a71402, ⟨a72771, a71371⟩⟩,
exact h₁,
exact ⟨a71382, a71369⟩,
apply a15 Vertebrate _ _,
exact ⟨a71402, a71371⟩,
exact ⟨h₂, h⟩
end
lemma VertebrateEntity : ∀ (x : U), ins x Vertebrate → ins x Entity :=
begin
intros a h,
have h1, apply subclass_TransitiveRelation; assumption,
have h2 : subclass Vertebrate Organism,
apply a67809 _ Animal _,
exact ⟨a71402, ⟨ a72771, a71371 ⟩⟩,
exact h1,
exact ⟨a71382, a71369⟩,
have h3 : subclass Vertebrate Agent,
apply a67809 _ Organism _,
exact ⟨a71402, ⟨ a71371, a71872 ⟩⟩,
exact h1,
exact ⟨h2, a71340⟩,
have h4 : subclass Vertebrate Object,
apply a67809 _ Agent _,
exact ⟨a71402, ⟨ a71872, a71669 ⟩⟩,
exact h1,
exact ⟨h3, a67315⟩,
have h5 : subclass Vertebrate Physical,
apply a67809 _ Object _,
exact ⟨a71402, ⟨ a71669, a69763 ⟩⟩,
exact h1,
exact ⟨h4, a67177⟩,
have h6 : subclass Vertebrate Entity,
apply a67809 _ Physical _,
exact ⟨a71402, ⟨ a69763, a67331 ⟩⟩,
exact h1,
exact ⟨ h5, a67174 ⟩,
apply a15 Vertebrate _ _,
exact ⟨a71402, a67331⟩,
exact ⟨h6, h⟩
end
-- start proofs
lemma listLemma (hne : nonempty U) : ∀ x y z : U,
ins x Entity ∧ ins y Entity ∧ ins z Entity →
inList x (ListFn2 y z) → x = y ∨ x = z :=
begin
intros x y z h h1,
rw (a72767 y z ⟨h.right.left, h.right.right⟩) at h1,
have h2 : x = y ∨ inList x (ConsFn z NullList_m),
rw ←(a72770 (ConsFn z NullList_m) x y),
exact h1,
simp *,
apply novo1 z NullList_m,
apply a15 Abstract Entity NullList_m,
--simp *,
--apply a15 Relation Abstract NullList_m;
-- simp *,
-- apply a15 List Relation NullList_m;
-- simp *,
-- assumption,
exact ⟨a68771, a67331⟩,
have h3, from a15 _ _ _ ⟨a67958, a68763⟩ ⟨a67954, a67959⟩,
exact ⟨a67332, a15 _ _ _ ⟨a68763, a68771⟩ ⟨a67450, h3⟩⟩,
exact a67959,
cases h2,
exact or.inl h2,
have h3 : x = z ∨ inList x NullList_m,
rw ←(a72770 NullList_m x z),
exact h2,
exact ⟨h.1, ⟨h.2.2, a67959⟩⟩,
cases h3,
exact or.inr h3,
apply false.elim,
exact ((a72769 x) h.left) h3
end
lemma lX (hne : nonempty U) : ∀ x c c1 c2,
(ins c SetOrClass ∧ ins c1 SetOrClass ∧ ins c2 SetOrClass) →
(ins c Class ∧ ins c1 Class ∧ ins c2 Class ∧ ins x Entity) →
(partition3 c c1 c2 ∧ ins x c ∧ ¬ ins x c1) → ins x c2 :=
begin
intros a c c1 c2 h1 h2 h3,
have a67131', from a67131 c c1 c2,
have a67115', from a67115 c1 c2 c a,
have h₃, from a67131' ⟨ h2.1, ⟨h2.2.1, h2.2.2.1 ⟩⟩,
have h4, from iff.elim_left h₃ h3.1,
cases h4 with h4a h4b,
cases a67115' with b h5,
have h7, from h5.right,
have h8, from h2.right.right.right,
specialize h7 h8,
have h9 : subclass SetOrClass Entity,
apply (a67809 _ Abstract _),
exact ⟨a67448, ⟨a68771, a67331⟩⟩,
apply subclass_TransitiveRelation; assumption,
exact ⟨a67446, a67332⟩,
have h10 : ins c1 Entity,
apply (a15 SetOrClass _ _),
exact ⟨a67448, a67331⟩,
exact ⟨h9, h1.2.1⟩,
have h11 : ins c2 Entity,
apply (a15 SetOrClass _ _),
exact ⟨a67448, a67331⟩,
exact ⟨h9, h1.2.2⟩,
specialize h7 ⟨h1.1, ⟨h2.1, ⟨h2.2.1, ⟨h10, ⟨h2.2.2.1, h11⟩⟩⟩⟩⟩,
specialize h7 h4a,
specialize h7 h3.right.left,
have h12 : b = c1 ∨ b = c2,
apply listLemma,
repeat { assumption },
split,
apply a15 SetOrClass _ _,
exact ⟨a67448, a67331⟩,
exact ⟨h9, h5.left⟩,
exact ⟨h10, h11⟩,
exact h7.left,
cases h12,
rw h12 at h7,
apply false.elim,
exact h3.right.right h7.right,
rw ←h12,
exact h7.right
end
lemma subclass_animal_entity : subclass Animal Entity :=
begin
have h1, apply subclass_TransitiveRelation; assumption,
have h2 : subclass Animal Agent,
apply a67809 _ Organism _,
exact ⟨a72771, ⟨ a71371, a71872 ⟩⟩,
exact h1,
exact ⟨a71369, a71340⟩,
have h3 : subclass Animal Object,
apply a67809 _ Agent _,
exact ⟨a72771, ⟨ a71872, a71669 ⟩⟩,
exact h1,
exact ⟨h2, a67315⟩,
have h4 : subclass Animal Physical,
apply a67809 _ Object _,
exact ⟨a72771, ⟨ a71669, a69763 ⟩⟩,
exact h1,
exact ⟨h3, a67177⟩,
apply a67809 _ Physical _,
exact ⟨a72771, ⟨ a69763, a67331 ⟩⟩,
exact h1,
exact ⟨ h4, a67174 ⟩,
end
lemma subclass_vertebrate_entity : subclass Vertebrate Entity :=
begin
have h1, apply subclass_TransitiveRelation; assumption,
have h2 : subclass Vertebrate Organism,
apply a67809 _ Animal _,
exact ⟨a71402, ⟨ a72771, a71371 ⟩⟩,
exact h1,
exact ⟨a71382, a71369⟩,
have h3 : subclass Vertebrate Agent,
apply a67809 _ Organism _,
exact ⟨a71402, ⟨ a71371, a71872 ⟩⟩,
exact h1,
exact ⟨h2, a71340⟩,
have h4 : subclass Vertebrate Object,
apply a67809 _ Agent _,
exact ⟨a71402, ⟨ a71872, a71669 ⟩⟩,
exact h1,
exact ⟨h3, a67315⟩,
have h5 : subclass Vertebrate Physical,
apply a67809 _ Object _,
exact ⟨a71402, ⟨ a71669, a69763 ⟩⟩,
exact h1,
exact ⟨h4, a67177⟩,
apply a67809 _ Physical _,
exact ⟨a71402, ⟨ a69763, a67331 ⟩⟩,
exact h1,
exact ⟨ h5, a67174 ⟩,
end
lemma subclass_invertebrate_entity : subclass Invertebrate Entity :=
begin
have h1, apply subclass_TransitiveRelation; assumption,
have h2 : subclass Invertebrate Organism,
apply a67809 _ Animal _,
exact ⟨a72778, ⟨ a72771, a71371 ⟩⟩,
exact h1,
exact ⟨a71383, a71369⟩,
have h3 : subclass Invertebrate Agent,
apply a67809 _ Organism _,
exact ⟨a72778, ⟨ a71371, a71872 ⟩⟩,
exact h1,
exact ⟨h2, a71340⟩,
have h4 : subclass Invertebrate Object,
apply a67809 _ Agent _,
exact ⟨a72778, ⟨ a71872, a71669 ⟩⟩,
exact h1,
exact ⟨h3, a67315⟩,
have h5 : subclass Invertebrate Physical,
apply a67809 _ Object _,
exact ⟨a72778, ⟨ a71669, a69763 ⟩⟩,
exact h1,
exact ⟨h4, a67177⟩,
apply a67809 _ Physical _,
exact ⟨a72778, ⟨ a69763, a67331 ⟩⟩,
exact h1,
exact ⟨ h5, a67174 ⟩,
end
lemma ins_banana_entity : ins BananaSlug10 Entity :=
begin
have h1, apply subclass_TransitiveRelation; assumption,
have h2 : ins BananaSlug10 Organism,
--specialize a15 Animal Organism BananaSlug10,
apply a15,
exact and.intro a72771 a71371,
exact and.intro a71369 a72772,
have h3 : ins BananaSlug10 Agent,
--specialize a15 Organism Agent BananaSlug10,
apply a15,
exact and.intro a71371 a71872,
exact and.intro a71340 h2,
have h4 : ins BananaSlug10 Object,
--specialize a15 Agent Object BananaSlug10,
apply a15,
exact and.intro a71872 a71669,
exact and.intro a67315 h3,
have h5 : ins BananaSlug10 Physical,
--specialize a15 Object Physical BananaSlug10,
apply a15,
exact and.intro a71669 a69763,
exact and.intro a67177 h4,
--specialize a15 Physical Entity BananaSlug10,
apply a15,
exact and.intro a69763 a67331,
exact and.intro a67174 h5,
end
lemma ins_animal_class : ins Animal Class :=
begin
have h0 : subclass Animal Entity,
apply subclass_animal_entity; assumption,
have h1, from (a67173 Animal),
exact h1.2 h0,
end
--lemma l0' (hne : nonempty U) : ¬(ins BananaSlug10 Vertebrate) := by simp *
lemma l0 (hne : nonempty U) : ¬(ins BananaSlug10 Vertebrate) :=
begin
have a72773', from a72773 BananaSlug10,
exact a72773' (and.intro a72772 a72774)
end
theorem Banana_Invertebrate (hne: nonempty U) : ins BananaSlug10 Invertebrate :=
begin
have h1 : ¬ ins BananaSlug10 Vertebrate,
apply l0; assumption,
have h2 : ∀ x c c1 c2,
(ins c SetOrClass ∧ ins c1 SetOrClass ∧ ins c2 SetOrClass) →
(ins c Class ∧ ins c1 Class ∧ ins c2 Class ∧ ins x Entity) →
(partition3 c c1 c2 ∧ ins x c ∧ ¬ ins x c1) → ins x c2,
apply lX; assumption,
have h3, from h2 BananaSlug10 Animal Vertebrate Invertebrate,
apply h3,
exact ⟨ a72771, ⟨ a71402, a72778 ⟩⟩,
have h₁ : subclass Animal Entity,
apply subclass_animal_entity; assumption,
have h₂ : ins Animal Class,
rw a67173, exact h₁,
have h₃ : subclass Vertebrate Entity,
apply subclass_vertebrate_entity; assumption,
have h₄ : ins Vertebrate Class,
rw a67173, exact h₃,
have h₅ : subclass Invertebrate Entity,
apply subclass_invertebrate_entity; assumption,
have h₆ : ins Invertebrate Class,
rw a67173, exact h₅,
have h₇ : ins BananaSlug10 Entity,
apply ins_banana_entity; assumption,
exact and.intro h₂ (and.intro h₄ (and.intro h₆ h₇)),
exact and.intro a71370 (and.intro a72772 h1),
end
|
d7233c896600f4ab62866e09cd0bd98cbb0563b1 | 37a833c924892ee3ecb911484775a6d6ebb8984d | /src/category_theory/examples/graphs.lean | 2f651f01cea1e7cc1b027267a0f3709dd8b6da1a | [] | no_license | silky/lean-category-theory | 28126e80564a1f99e9c322d86b3f7d750da0afa1 | 0f029a2364975f56ac727d31d867a18c95c22fd8 | refs/heads/master | 1,589,555,811,646 | 1,554,673,665,000 | 1,554,673,665,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,272 | lean | -- Copyright (c) 2017 Scott Morrison. All rights reserved.
-- Released under Apache 2.0 license as described in the file LICENSE.
-- Authors: Scott Morrison
import category_theory.category
import category_theory.graphs
open category_theory
open category_theory.graphs
namespace category_theory.examples.graphs
universe u₁
def Graph := Σ α : Type (u₁+1), graph.{u₁+1 u₁} α
instance graph_from_Graph (G : Graph) : graph G.1 := G.2
structure Graph_hom (G H : Graph.{u₁}) : Type (u₁+1) :=
(map : @graph_hom G.1 G.2 H.1 H.2)
@[extensionality] lemma graph_homomorphisms_pointwise_equal
{G H : Graph.{u₁}}
{p q : Graph_hom G H}
(vertexWitness : ∀ X : G.1, p.map.onVertices X = q.map.onVertices X)
(edgeWitness : ∀ X Y : G.1, ∀ f : edges X Y, ⟬ p.map.onEdges f ⟭ = q.map.onEdges f ) : p = q :=
begin
induction p,
induction q,
tidy,
tactic.result -- Heisenbug?
end
instance CategoryOfGraphs : large_category Graph := {
hom := Graph_hom,
id := λ G, ⟨ {
onVertices := id,
onEdges := λ _ _ f, f
} ⟩,
comp := λ G H K f g, ⟨ {
onVertices := λ v, g.map.onVertices (f.map.onVertices v),
onEdges := λ v w e, g.map.onEdges (f.map.onEdges e)
} ⟩
}
end category_theory.examples.graphs |
d7aea61afdf2866486e4b419367b6ef9cd9bdd11 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/category_theory/idempotents/karoubi.lean | 40f9de580a7cc247feff7673db7435b8721ed2c4 | [
"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 | 8,853 | 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 category_theory.idempotents.basic
import category_theory.preadditive.additive_functor
import category_theory.equivalence
/-!
# The Karoubi envelope of a category
In this file, we define the Karoubi envelope `karoubi C` of a category `C`.
## Main constructions and definitions
- `karoubi C` is the Karoubi envelope of a category `C`: it is an idempotent
complete category. It is also preadditive when `C` is preadditive.
- `to_karoubi C : C ⥤ karoubi C` is a fully faithful functor, which is an equivalence
(`to_karoubi_is_equivalence`) when `C` is idempotent complete.
-/
noncomputable theory
open category_theory.category
open category_theory.preadditive
open category_theory.limits
open_locale big_operators
namespace category_theory
variables (C : Type*) [category C]
namespace idempotents
/-- In a preadditive category `C`, when an object `X` decomposes as `X ≅ P ⨿ Q`, one may
consider `P` as a direct factor of `X` and up to unique isomorphism, it is determined by the
obvious idempotent `X ⟶ P ⟶ X` which is the projection onto `P` with kernel `Q`. More generally,
one may define a formal direct factor of an object `X : C` : it consists of an idempotent
`p : X ⟶ X` which is thought as the "formal image" of `p`. The type `karoubi C` shall be the
type of the objects of the karoubi enveloppe of `C`. It makes sense for any category `C`. -/
@[nolint has_inhabited_instance]
structure karoubi := (X : C) (p : X ⟶ X) (idem : p ≫ p = p)
namespace karoubi
variables {C}
@[ext]
lemma ext {P Q : karoubi C} (h_X : P.X = Q.X)
(h_p : P.p ≫ eq_to_hom h_X = eq_to_hom h_X ≫ Q.p) : P = Q :=
begin
cases P,
cases Q,
dsimp at h_X h_p,
subst h_X,
simpa only [true_and, eq_self_iff_true, id_comp, eq_to_hom_refl,
heq_iff_eq, comp_id] using h_p,
end
/-- A morphism `P ⟶ Q` in the category `karoubi C` is a morphism in the underlying category
`C` which satisfies a relation, which in the preadditive case, expresses that it induces a
map between the corresponding "formal direct factors" and that it vanishes on the complement
formal direct factor. -/
@[ext]
structure hom (P Q : karoubi C) := (f : P.X ⟶ Q.X) (comm : f = P.p ≫ f ≫ Q.p)
instance [preadditive C] (P Q : karoubi C) : inhabited (hom P Q) :=
⟨⟨0, by rw [zero_comp, comp_zero]⟩⟩
@[simp]
lemma hom_ext {P Q : karoubi C} {f g : hom P Q} : f = g ↔ f.f = g.f :=
begin
split,
{ intro h, rw h, },
{ ext, }
end
@[simp, reassoc]
lemma p_comp {P Q : karoubi C} (f : hom P Q) : P.p ≫ f.f = f.f :=
by rw [f.comm, ← assoc, P.idem]
@[simp, reassoc]
lemma comp_p {P Q : karoubi C} (f : hom P Q) : f.f ≫ Q.p = f.f :=
by rw [f.comm, assoc, assoc, Q.idem]
lemma p_comm {P Q : karoubi C} (f : hom P Q) : P.p ≫ f.f = f.f ≫ Q.p :=
by rw [p_comp, comp_p]
lemma comp_proof {P Q R : karoubi C} (g : hom Q R) (f : hom P Q) :
f.f ≫ g.f = P.p ≫ (f.f ≫ g.f) ≫ R.p :=
by rw [assoc, comp_p, ← assoc, p_comp]
/-- The category structure on the karoubi envelope of a category. -/
instance : category (karoubi C) :=
{ hom := karoubi.hom,
id := λ P, ⟨P.p, by { repeat { rw P.idem, }, }⟩,
comp := λ P Q R f g, ⟨f.f ≫ g.f, karoubi.comp_proof g f⟩, }
@[simp]
lemma comp {P Q R : karoubi C} (f : P ⟶ Q) (g : Q ⟶ R) :
f ≫ g = ⟨f.f ≫ g.f, comp_proof g f⟩ := by refl
@[simp]
lemma id_eq {P : karoubi C} : 𝟙 P = ⟨P.p, by repeat { rw P.idem, }⟩ := by refl
/-- It is possible to coerce an object of `C` into an object of `karoubi C`.
See also the functor `to_karoubi`. -/
instance coe : has_coe_t C (karoubi C) := ⟨λ X, ⟨X, 𝟙 X, by rw comp_id⟩⟩
@[simp]
lemma coe_X (X : C) : (X : karoubi C).X = X := by refl
@[simp]
lemma coe_p (X : C) : (X : karoubi C).p = 𝟙 X := by refl
@[simp]
lemma eq_to_hom_f {P Q : karoubi C} (h : P = Q) :
karoubi.hom.f (eq_to_hom h) = P.p ≫ eq_to_hom (congr_arg karoubi.X h) :=
by { subst h, simp only [eq_to_hom_refl, karoubi.id_eq, comp_id], }
end karoubi
/-- The obvious fully faithful functor `to_karoubi` sends an object `X : C` to the obvious
formal direct factor of `X` given by `𝟙 X`. -/
@[simps]
def to_karoubi : C ⥤ karoubi C :=
{ obj := λ X, ⟨X, 𝟙 X, by rw comp_id⟩,
map := λ X Y f, ⟨f, by simp only [comp_id, id_comp]⟩ }
instance : full (to_karoubi C) :=
{ preimage := λ X Y f, f.f, }
instance : faithful (to_karoubi C) := { }
variables {C}
@[simps]
instance [preadditive C] {P Q : karoubi C} : add_comm_group (P ⟶ Q) :=
{ add := λ f g, ⟨f.f+g.f, begin
rw [add_comp, comp_add],
congr',
exacts [f.comm, g.comm],
end⟩,
zero := ⟨0, by simp only [comp_zero, zero_comp]⟩,
zero_add := λ f, by { ext, simp only [zero_add], },
add_zero := λ f, by { ext, simp only [add_zero], },
add_assoc := λ f g h', by simp only [add_assoc],
add_comm := λ f g, by { ext, apply_rules [add_comm], },
neg := λ f, ⟨-f.f, by simpa only [neg_comp, comp_neg, neg_inj] using f.comm⟩,
add_left_neg := λ f, by { ext, apply_rules [add_left_neg], }, }
namespace karoubi
lemma hom_eq_zero_iff [preadditive C] {P Q : karoubi C} {f : hom P Q} : f = 0 ↔ f.f = 0 := hom_ext
/-- The map sending `f : P ⟶ Q` to `f.f : P.X ⟶ Q.X` is additive. -/
@[simps]
def inclusion_hom [preadditive C] (P Q : karoubi C) : add_monoid_hom (P ⟶ Q) (P.X ⟶ Q.X) :=
{ to_fun := λ f, f.f,
map_zero' := rfl,
map_add' := λ f g, rfl }
@[simp]
lemma sum_hom [preadditive C] {P Q : karoubi C} {α : Type*} (s : finset α) (f : α → (P ⟶ Q)) :
(∑ x in s, f x).f = ∑ x in s, (f x).f :=
add_monoid_hom.map_sum (inclusion_hom P Q) f s
end karoubi
/-- The category `karoubi C` is preadditive if `C` is. -/
instance [preadditive C] : preadditive (karoubi C) :=
{ hom_group := λ P Q, by apply_instance,
add_comp' := λ P Q R f g h,
by { ext, simp only [add_comp, quiver.hom.add_comm_group_add_f, karoubi.comp], },
comp_add' := λ P Q R f g h,
by { ext, simp only [comp_add, quiver.hom.add_comm_group_add_f, karoubi.comp], }, }
instance [preadditive C] : functor.additive (to_karoubi C) := { }
open karoubi
variables (C)
instance : is_idempotent_complete (karoubi C) :=
begin
refine ⟨_⟩,
intros P p hp,
have hp' := hom_ext.mp hp,
simp only [comp] at hp',
use ⟨P.X, p.f, hp'⟩,
use ⟨p.f, by rw [comp_p p, hp']⟩,
use ⟨p.f, by rw [hp', p_comp p]⟩,
split; simpa only [hom_ext] using hp',
end
instance [is_idempotent_complete C] : ess_surj (to_karoubi C) := ⟨λ P, begin
have h : is_idempotent_complete C := infer_instance,
rcases is_idempotent_complete.idempotents_split P.X P.p P.idem
with ⟨Y,i,e,⟨h₁,h₂⟩⟩,
use Y,
exact nonempty.intro
{ hom := ⟨i, by erw [id_comp, ← h₂, ← assoc, h₁, id_comp]⟩,
inv := ⟨e, by erw [comp_id, ← h₂, assoc, h₁, comp_id]⟩, },
end⟩
/-- If `C` is idempotent complete, the functor `to_karoubi : C ⥤ karoubi C` is an equivalence. -/
def to_karoubi_is_equivalence [is_idempotent_complete C] :
is_equivalence (to_karoubi C) :=
equivalence.of_fully_faithfully_ess_surj (to_karoubi C)
namespace karoubi
variables {C}
/-- The split mono which appears in the factorisation `decomp_id P`. -/
@[simps]
def decomp_id_i (P : karoubi C) : P ⟶ P.X := ⟨P.p, by erw [coe_p, comp_id, P.idem]⟩
/-- The split epi which appears in the factorisation `decomp_id P`. -/
@[simps]
def decomp_id_p (P : karoubi C) : (P.X : karoubi C) ⟶ P :=
⟨P.p, by erw [coe_p, id_comp, P.idem]⟩
/-- The formal direct factor of `P.X` given by the idempotent `P.p` in the category `C`
is actually a direct factor in the category `karoubi C`. -/
lemma decomp_id (P : karoubi C) :
𝟙 P = (decomp_id_i P) ≫ (decomp_id_p P) :=
by { ext, simp only [comp, id_eq, P.idem, decomp_id_i, decomp_id_p], }
lemma decomp_p (P : karoubi C) :
(to_karoubi C).map P.p = (decomp_id_p P) ≫ (decomp_id_i P) :=
by { ext, simp only [comp, decomp_id_p_f, decomp_id_i_f, P.idem, to_karoubi_map_f], }
lemma decomp_id_i_to_karoubi (X : C) : decomp_id_i ((to_karoubi C).obj X) = 𝟙 _ :=
by { ext, refl, }
lemma decomp_id_p_to_karoubi (X : C) : decomp_id_p ((to_karoubi C).obj X) = 𝟙 _ :=
by { ext, refl, }
lemma decomp_id_i_naturality {P Q : karoubi C} (f : P ⟶ Q) : f ≫ decomp_id_i _ =
decomp_id_i _ ≫ ⟨f.f, by erw [comp_id, id_comp]⟩ :=
by { ext, simp only [comp, decomp_id_i_f, karoubi.comp_p, karoubi.p_comp], }
lemma decomp_id_p_naturality {P Q : karoubi C} (f : P ⟶ Q) : decomp_id_p P ≫ f =
(⟨f.f, by erw [comp_id, id_comp]⟩ : (P.X : karoubi C) ⟶ Q.X) ≫ decomp_id_p Q :=
by { ext, simp only [comp, decomp_id_p_f, karoubi.comp_p, karoubi.p_comp], }
end karoubi
end idempotents
end category_theory
|
5a8dc3133efe140d5898f8c9b4698082e803d245 | 69d4931b605e11ca61881fc4f66db50a0a875e39 | /src/linear_algebra/affine_space/finite_dimensional.lean | dd3c7c0ccc254cb5d72dd63253ba35af1179aeb5 | [
"Apache-2.0"
] | permissive | abentkamp/mathlib | d9a75d291ec09f4637b0f30cc3880ffb07549ee5 | 5360e476391508e092b5a1e5210bd0ed22dc0755 | refs/heads/master | 1,682,382,954,948 | 1,622,106,077,000 | 1,622,106,077,000 | 149,285,665 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 16,088 | lean | /-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import linear_algebra.affine_space.independent
import linear_algebra.finite_dimensional
/-!
# Finite-dimensional subspaces of affine spaces.
This file provides a few results relating to finite-dimensional
subspaces of affine spaces.
## Main definitions
* `collinear` defines collinear sets of points as those that span a
subspace of dimension at most 1.
-/
noncomputable theory
open_locale big_operators classical affine
section affine_space'
variables (k : Type*) {V : Type*} {P : Type*} [field k] [add_comm_group V] [module k V]
[affine_space V P]
variables {ι : Type*}
include V
open affine_subspace finite_dimensional module
/-- The `vector_span` of a finite set is finite-dimensional. -/
lemma finite_dimensional_vector_span_of_finite {s : set P} (h : set.finite s) :
finite_dimensional k (vector_span k s) :=
span_of_finite k $ h.vsub h
/-- The `vector_span` of a family indexed by a `fintype` is
finite-dimensional. -/
instance finite_dimensional_vector_span_of_fintype [fintype ι] (p : ι → P) :
finite_dimensional k (vector_span k (set.range p)) :=
finite_dimensional_vector_span_of_finite k (set.finite_range _)
/-- The `vector_span` of a subset of a family indexed by a `fintype`
is finite-dimensional. -/
instance finite_dimensional_vector_span_image_of_fintype [fintype ι] (p : ι → P)
(s : set ι) : finite_dimensional k (vector_span k (p '' s)) :=
finite_dimensional_vector_span_of_finite k ((set.finite.of_fintype _).image _)
/-- The direction of the affine span of a finite set is
finite-dimensional. -/
lemma finite_dimensional_direction_affine_span_of_finite {s : set P} (h : set.finite s) :
finite_dimensional k (affine_span k s).direction :=
(direction_affine_span k s).symm ▸ finite_dimensional_vector_span_of_finite k h
/-- The direction of the affine span of a family indexed by a
`fintype` is finite-dimensional. -/
instance finite_dimensional_direction_affine_span_of_fintype [fintype ι] (p : ι → P) :
finite_dimensional k (affine_span k (set.range p)).direction :=
finite_dimensional_direction_affine_span_of_finite k (set.finite_range _)
/-- The direction of the affine span of a subset of a family indexed
by a `fintype` is finite-dimensional. -/
instance finite_dimensional_direction_affine_span_image_of_fintype [fintype ι] (p : ι → P)
(s : set ι) : finite_dimensional k (affine_span k (p '' s)).direction :=
finite_dimensional_direction_affine_span_of_finite k ((set.finite.of_fintype _).image _)
variables {k}
/-- The `vector_span` of a finite subset of an affinely independent
family has dimension one less than its cardinality. -/
lemma finrank_vector_span_image_finset_of_affine_independent {p : ι → P}
(hi : affine_independent k p) {s : finset ι} {n : ℕ} (hc : finset.card s = n + 1) :
finrank k (vector_span k (p '' ↑s)) = n :=
begin
have hi' := affine_independent_of_subset_affine_independent
(affine_independent_set_of_affine_independent hi) (set.image_subset_range p ↑s),
have hc' : fintype.card (p '' ↑s) = n + 1,
{ rwa [set.card_image_of_injective ↑s (injective_of_affine_independent hi), fintype.card_coe] },
have hn : (p '' ↑s).nonempty,
{ simp [hc, ←finset.card_pos] },
rcases hn with ⟨p₁, hp₁⟩,
rw affine_independent_set_iff_linear_independent_vsub k hp₁ at hi',
have hfr : (p '' ↑s \ {p₁}).finite := ((set.finite_mem_finset _).image _).subset
(set.diff_subset _ _),
haveI := hfr.fintype,
have hf : set.finite ((λ (p : P), p -ᵥ p₁) '' (p '' ↑s \ {p₁})) := hfr.image _,
haveI := hf.fintype,
have hc : hf.to_finset.card = n,
{ rw [hf.card_to_finset,
set.card_image_of_injective (p '' ↑s \ {p₁}) (vsub_left_injective _)],
have hd : insert p₁ (p '' ↑s \ {p₁}) = p '' ↑s,
{ rw [set.insert_diff_singleton, set.insert_eq_of_mem hp₁] },
have hc'' : fintype.card ↥(insert p₁ (p '' ↑s \ {p₁})) = n + 1,
{ convert hc' },
rw set.card_insert (p '' ↑s \ {p₁}) (λ h, ((set.mem_diff p₁).2 h).2 rfl) at hc'',
simpa using hc'' },
rw [vector_span_eq_span_vsub_set_right_ne k hp₁, finrank_span_set_eq_card _ hi', ←hc],
congr
end
/-- The `vector_span` of a finite affinely independent family has
dimension one less than its cardinality. -/
lemma finrank_vector_span_of_affine_independent [fintype ι] {p : ι → P}
(hi : affine_independent k p) {n : ℕ} (hc : fintype.card ι = n + 1) :
finrank k (vector_span k (set.range p)) = n :=
begin
rw ←finset.card_univ at hc,
rw [←set.image_univ, ←finset.coe_univ],
exact finrank_vector_span_image_finset_of_affine_independent hi hc
end
/-- If the `vector_span` of a finite subset of an affinely independent
family lies in a submodule with dimension one less than its
cardinality, it equals that submodule. -/
lemma vector_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_finrank_add_one
{p : ι → P} (hi : affine_independent k p) {s : finset ι} {sm : submodule k V}
[finite_dimensional k sm] (hle : vector_span k (p '' ↑s) ≤ sm)
(hc : finset.card s = finrank k sm + 1) : vector_span k (p '' ↑s) = sm :=
eq_of_le_of_finrank_eq hle $ finrank_vector_span_image_finset_of_affine_independent hi hc
/-- If the `vector_span` of a finite affinely independent
family lies in a submodule with dimension one less than its
cardinality, it equals that submodule. -/
lemma vector_span_eq_of_le_of_affine_independent_of_card_eq_finrank_add_one [fintype ι]
{p : ι → P} (hi : affine_independent k p) {sm : submodule k V} [finite_dimensional k sm]
(hle : vector_span k (set.range p) ≤ sm) (hc : fintype.card ι = finrank k sm + 1) :
vector_span k (set.range p) = sm :=
eq_of_le_of_finrank_eq hle $ finrank_vector_span_of_affine_independent hi hc
/-- If the `affine_span` of a finite subset of an affinely independent
family lies in an affine subspace whose direction has dimension one
less than its cardinality, it equals that subspace. -/
lemma affine_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_finrank_add_one
{p : ι → P} (hi : affine_independent k p) {s : finset ι} {sp : affine_subspace k P}
[finite_dimensional k sp.direction] (hle : affine_span k (p '' ↑s) ≤ sp)
(hc : finset.card s = finrank k sp.direction + 1) : affine_span k (p '' ↑s) = sp :=
begin
have hn : (p '' ↑s).nonempty, { simp [hc, ←finset.card_pos] },
refine eq_of_direction_eq_of_nonempty_of_le _ ((affine_span_nonempty k _).2 hn) hle,
have hd := direction_le hle,
rw direction_affine_span at ⊢ hd,
exact vector_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_finrank_add_one hi hd hc
end
/-- If the `affine_span` of a finite affinely independent family lies
in an affine subspace whose direction has dimension one less than its
cardinality, it equals that subspace. -/
lemma affine_span_eq_of_le_of_affine_independent_of_card_eq_finrank_add_one [fintype ι]
{p : ι → P} (hi : affine_independent k p) {sp : affine_subspace k P}
[finite_dimensional k sp.direction] (hle : affine_span k (set.range p) ≤ sp)
(hc : fintype.card ι = finrank k sp.direction + 1) : affine_span k (set.range p) = sp :=
begin
rw ←finset.card_univ at hc,
rw [←set.image_univ, ←finset.coe_univ] at ⊢ hle,
exact affine_span_image_finset_eq_of_le_of_affine_independent_of_card_eq_finrank_add_one hi hle hc
end
/-- The `vector_span` of a finite affinely independent family whose
cardinality is one more than that of the finite-dimensional space is
`⊤`. -/
lemma vector_span_eq_top_of_affine_independent_of_card_eq_finrank_add_one [finite_dimensional k V]
[fintype ι] {p : ι → P} (hi : affine_independent k p) (hc : fintype.card ι = finrank k V + 1) :
vector_span k (set.range p) = ⊤ :=
eq_top_of_finrank_eq $ finrank_vector_span_of_affine_independent hi hc
/-- The `affine_span` of a finite affinely independent family whose
cardinality is one more than that of the finite-dimensional space is
`⊤`. -/
lemma affine_span_eq_top_of_affine_independent_of_card_eq_finrank_add_one [finite_dimensional k V]
[fintype ι] {p : ι → P} (hi : affine_independent k p) (hc : fintype.card ι = finrank k V + 1) :
affine_span k (set.range p) = ⊤ :=
begin
rw [←finrank_top, ←direction_top k V P] at hc,
exact affine_span_eq_of_le_of_affine_independent_of_card_eq_finrank_add_one hi le_top hc
end
variables (k)
/-- The `vector_span` of `n + 1` points in an indexed family has
dimension at most `n`. -/
lemma finrank_vector_span_image_finset_le (p : ι → P) (s : finset ι) {n : ℕ}
(hc : finset.card s = n + 1) : finrank k (vector_span k (p '' ↑s)) ≤ n :=
begin
have hn : (p '' ↑s).nonempty,
{ simp [hc, ←finset.card_pos] },
rcases hn with ⟨p₁, hp₁⟩,
rw [vector_span_eq_span_vsub_set_right_ne k hp₁],
have hfp₁ : (p '' ↑s \ {p₁}).finite :=
((finset.finite_to_set _).image _).subset (set.diff_subset _ _),
haveI := hfp₁.fintype,
have hf : ((λ p, p -ᵥ p₁) '' (p '' ↑s \ {p₁})).finite := hfp₁.image _,
haveI := hf.fintype,
convert le_trans (finrank_span_le_card ((λ p, p -ᵥ p₁) '' (p '' ↑s \ {p₁}))) _,
have hm : p₁ ∉ p '' ↑s \ {p₁}, by simp,
haveI := set.fintype_insert' (p '' ↑s \ {p₁}) hm,
rw [set.to_finset_card, set.card_image_of_injective (p '' ↑s \ {p₁}) (vsub_left_injective p₁),
←add_le_add_iff_right 1, ←set.card_fintype_insert' _ hm],
have h : fintype.card (↑(s.image p) : set P) ≤ n + 1,
{ rw [fintype.card_coe, ←hc],
exact finset.card_image_le },
convert h,
simp [hp₁]
end
/-- The `vector_span` of an indexed family of `n + 1` points has
dimension at most `n`. -/
lemma finrank_vector_span_range_le [fintype ι] (p : ι → P) {n : ℕ}
(hc : fintype.card ι = n + 1) : finrank k (vector_span k (set.range p)) ≤ n :=
begin
rw [←set.image_univ, ←finset.coe_univ],
rw ←finset.card_univ at hc,
exact finrank_vector_span_image_finset_le _ _ _ hc
end
/-- `n + 1` points are affinely independent if and only if their
`vector_span` has dimension `n`. -/
lemma affine_independent_iff_finrank_vector_span_eq [fintype ι] (p : ι → P) {n : ℕ}
(hc : fintype.card ι = n + 1) :
affine_independent k p ↔ finrank k (vector_span k (set.range p)) = n :=
begin
have hn : nonempty ι, by simp [←fintype.card_pos_iff, hc],
cases hn with i₁,
rw [affine_independent_iff_linear_independent_vsub _ _ i₁,
linear_independent_iff_card_eq_finrank_span, eq_comm,
vector_span_range_eq_span_range_vsub_right_ne k p i₁],
congr',
rw ←finset.card_univ at hc,
rw fintype.subtype_card,
simp [finset.filter_ne', finset.card_erase_of_mem, hc]
end
/-- `n + 1` points are affinely independent if and only if their
`vector_span` has dimension at least `n`. -/
lemma affine_independent_iff_le_finrank_vector_span [fintype ι] (p : ι → P) {n : ℕ}
(hc : fintype.card ι = n + 1) :
affine_independent k p ↔ n ≤ finrank k (vector_span k (set.range p)) :=
begin
rw affine_independent_iff_finrank_vector_span_eq k p hc,
split,
{ rintro rfl,
refl },
{ exact λ hle, le_antisymm (finrank_vector_span_range_le k p hc) hle }
end
/-- `n + 2` points are affinely independent if and only if their
`vector_span` does not have dimension at most `n`. -/
lemma affine_independent_iff_not_finrank_vector_span_le [fintype ι] (p : ι → P) {n : ℕ}
(hc : fintype.card ι = n + 2) :
affine_independent k p ↔ ¬ finrank k (vector_span k (set.range p)) ≤ n :=
by rw [affine_independent_iff_le_finrank_vector_span k p hc, ←nat.lt_iff_add_one_le, lt_iff_not_ge]
/-- `n + 2` points have a `vector_span` with dimension at most `n` if
and only if they are not affinely independent. -/
lemma finrank_vector_span_le_iff_not_affine_independent [fintype ι] (p : ι → P) {n : ℕ}
(hc : fintype.card ι = n + 2) :
finrank k (vector_span k (set.range p)) ≤ n ↔ ¬ affine_independent k p :=
(not_iff_comm.1 (affine_independent_iff_not_finrank_vector_span_le k p hc).symm).symm
/-- A set of points is collinear if their `vector_span` has dimension
at most `1`. -/
def collinear (s : set P) : Prop := module.rank k (vector_span k s) ≤ 1
/-- The definition of `collinear`. -/
lemma collinear_iff_dim_le_one (s : set P) : collinear k s ↔ module.rank k (vector_span k s) ≤ 1 :=
iff.rfl
/-- A set of points, whose `vector_span` is finite-dimensional, is
collinear if and only if their `vector_span` has dimension at most
`1`. -/
lemma collinear_iff_finrank_le_one (s : set P) [finite_dimensional k (vector_span k s)] :
collinear k s ↔ finrank k (vector_span k s) ≤ 1 :=
begin
have h := collinear_iff_dim_le_one k s,
rw ←finrank_eq_dim at h,
exact_mod_cast h
end
variables (P)
/-- The empty set is collinear. -/
lemma collinear_empty : collinear k (∅ : set P) :=
begin
rw [collinear_iff_dim_le_one, vector_span_empty],
simp
end
variables {P}
/-- A single point is collinear. -/
lemma collinear_singleton (p : P) : collinear k ({p} : set P) :=
begin
rw [collinear_iff_dim_le_one, vector_span_singleton],
simp
end
/-- Given a point `p₀` in a set of points, that set is collinear if and
only if the points can all be expressed as multiples of the same
vector, added to `p₀`. -/
lemma collinear_iff_of_mem {s : set P} {p₀ : P} (h : p₀ ∈ s) :
collinear k s ↔ ∃ v : V, ∀ p ∈ s, ∃ r : k, p = r • v +ᵥ p₀ :=
begin
simp_rw [collinear_iff_dim_le_one, dim_submodule_le_one_iff', submodule.le_span_singleton_iff],
split,
{ rintro ⟨v₀, hv⟩,
use v₀,
intros p hp,
obtain ⟨r, hr⟩ := hv (p -ᵥ p₀) (vsub_mem_vector_span k hp h),
use r,
rw eq_vadd_iff_vsub_eq,
exact hr.symm },
{ rintro ⟨v, hp₀v⟩,
use v,
intros w hw,
have hs : vector_span k s ≤ k ∙ v,
{ rw [vector_span_eq_span_vsub_set_right k h, submodule.span_le, set.subset_def],
intros x hx,
rw [set_like.mem_coe, submodule.mem_span_singleton],
rw set.mem_image at hx,
rcases hx with ⟨p, hp, rfl⟩,
rcases hp₀v p hp with ⟨r, rfl⟩,
use r,
simp },
have hw' := set_like.le_def.1 hs hw,
rwa submodule.mem_span_singleton at hw' }
end
/-- A set of points is collinear if and only if they can all be
expressed as multiples of the same vector, added to the same base
point. -/
lemma collinear_iff_exists_forall_eq_smul_vadd (s : set P) :
collinear k s ↔ ∃ (p₀ : P) (v : V), ∀ p ∈ s, ∃ r : k, p = r • v +ᵥ p₀ :=
begin
rcases set.eq_empty_or_nonempty s with rfl | ⟨⟨p₁, hp₁⟩⟩,
{ simp [collinear_empty] },
{ rw collinear_iff_of_mem k hp₁,
split,
{ exact λ h, ⟨p₁, h⟩ },
{ rintros ⟨p, v, hv⟩,
use v,
intros p₂ hp₂,
rcases hv p₂ hp₂ with ⟨r, rfl⟩,
rcases hv p₁ hp₁ with ⟨r₁, rfl⟩,
use r - r₁,
simp [vadd_vadd, ←add_smul] } }
end
/-- Two points are collinear. -/
lemma collinear_insert_singleton (p₁ p₂ : P) : collinear k ({p₁, p₂} : set P) :=
begin
rw collinear_iff_exists_forall_eq_smul_vadd,
use [p₁, p₂ -ᵥ p₁],
intros p hp,
rw [set.mem_insert_iff, set.mem_singleton_iff] at hp,
cases hp,
{ use 0,
simp [hp] },
{ use 1,
simp [hp] }
end
/-- Three points are affinely independent if and only if they are not
collinear. -/
lemma affine_independent_iff_not_collinear (p : fin 3 → P) :
affine_independent k p ↔ ¬ collinear k (set.range p) :=
by rw [collinear_iff_finrank_le_one,
affine_independent_iff_not_finrank_vector_span_le k p (fintype.card_fin 3)]
/-- Three points are collinear if and only if they are not affinely
independent. -/
lemma collinear_iff_not_affine_independent (p : fin 3 → P) :
collinear k (set.range p) ↔ ¬ affine_independent k p :=
by rw [collinear_iff_finrank_le_one,
finrank_vector_span_le_iff_not_affine_independent k p (fintype.card_fin 3)]
end affine_space'
|
897c8ac2fba72c50945f9f0d50945bd864e5e636 | 54d7e71c3616d331b2ec3845d31deb08f3ff1dea | /library/data/bitvec.lean | c1c19e2429266e6aaf2e72055e075652a9b447ca | [
"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 | 6,548 | lean | /-
Copyright (c) 2015 Joe Hendrix. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joe Hendrix, Sebastian Ullrich
Basic operations on bitvectors.
This is a work-in-progress, and contains additions to other theories.
-/
import data.vector
@[reducible] def bitvec (n : ℕ) := vector bool n
namespace bitvec
open nat
open vector
local infix `++ₜ`:65 := vector.append
-- Create a zero bitvector
@[reducible] protected def zero (n : ℕ) : bitvec n := repeat ff n
-- Create a bitvector with the constant one.
@[reducible] protected def one : Π (n : ℕ), bitvec n
| 0 := []
| (succ n) := repeat ff n ++ₜ [tt]
protected def cong {a b : ℕ} (h : a = b) : bitvec a → bitvec b
| ⟨x, p⟩ := ⟨x, h ▸ p⟩
-- bitvec specific version of vector.append
def append {m n} : bitvec m → bitvec n → bitvec (m + n) := vector.append
section shift
variable {n : ℕ}
def shl (x : bitvec n) (i : ℕ) : bitvec n :=
bitvec.cong (by simp) $
dropn i x ++ₜ repeat ff (min n i)
local attribute [ematch] nat.add_sub_assoc sub_le le_of_not_ge sub_eq_zero_of_le
def fill_shr (x : bitvec n) (i : ℕ) (fill : bool) : bitvec n :=
bitvec.cong (by async { begin [smt] by_cases (i ≤ n), eblast end }) $
repeat fill (min n i) ++ₜ taken (n-i) x
-- unsigned shift right
def ushr (x : bitvec n) (i : ℕ) : bitvec n :=
fill_shr x i ff
-- signed shift right
def sshr : Π {m : ℕ}, bitvec m → ℕ → bitvec m
| 0 _ _ := []
| (succ m) x i := head x :: fill_shr (tail x) i (head x)
end shift
section bitwise
variable {n : ℕ}
def not : bitvec n → bitvec n := map bnot
def and : bitvec n → bitvec n → bitvec n := map₂ band
def or : bitvec n → bitvec n → bitvec n := map₂ bor
def xor : bitvec n → bitvec n → bitvec n := map₂ bxor
end bitwise
section arith
variable {n : ℕ}
protected def xor3 (x y c : bool) := bxor (bxor x y) c
protected def carry (x y c : bool) :=
x && y || x && c || y && c
protected def neg (x : bitvec n) : bitvec n :=
let f := λ y c, (y || c, bxor y c) in
prod.snd (map_accumr f x ff)
-- Add with carry (no overflow)
def adc (x y : bitvec n) (c : bool) : bitvec (n+1) :=
let f := λ x y c, (bitvec.carry x y c, bitvec.xor3 x y c) in
let ⟨c, z⟩ := vector.map_accumr₂ f x y c in
c :: z
protected def add (x y : bitvec n) : bitvec n := tail (adc x y ff)
protected def borrow (x y b : bool) :=
bnot x && y || bnot x && b || y && b
-- Subtract with borrow
def sbb (x y : bitvec n) (b : bool) : bool × bitvec n :=
let f := λ x y c, (bitvec.borrow x y c, bitvec.xor3 x y c) in
vector.map_accumr₂ f x y b
protected def sub (x y : bitvec n) : bitvec n := prod.snd (sbb x y ff)
instance : has_zero (bitvec n) := ⟨bitvec.zero n⟩
instance : has_one (bitvec n) := ⟨bitvec.one n⟩
instance : has_add (bitvec n) := ⟨bitvec.add⟩
instance : has_sub (bitvec n) := ⟨bitvec.sub⟩
instance : has_neg (bitvec n) := ⟨bitvec.neg⟩
protected def mul (x y : bitvec n) : bitvec n :=
let f := λ r b, cond b (r + r + y) (r + r) in
(to_list x).foldl f 0
instance : has_mul (bitvec n) := ⟨bitvec.mul⟩
end arith
section comparison
variable {n : ℕ}
def uborrow (x y : bitvec n) : bool := prod.fst (sbb x y ff)
def ult (x y : bitvec n) : Prop := uborrow x y
def ugt (x y : bitvec n) : Prop := ult y x
def ule (x y : bitvec n) : Prop := ¬ (ult y x)
def uge (x y : bitvec n) : Prop := ule y x
def sborrow : Π {n : ℕ}, bitvec n → bitvec n → bool
| 0 _ _ := ff
| (succ n) x y :=
match (head x, head y) with
| (tt, ff) := tt
| (ff, tt) := ff
| _ := uborrow (tail x) (tail y)
end
def slt (x y : bitvec n) : Prop := sborrow x y
def sgt (x y : bitvec n) : Prop := slt y x
def sle (x y : bitvec n) : Prop := ¬ (slt y x)
def sge (x y : bitvec n) : Prop := sle y x
end comparison
section conversion
variable {α : Type}
protected def of_nat : Π (n : ℕ), nat → bitvec n
| 0 x := nil
| (succ n) x := of_nat n (x / 2) ++ₜ [to_bool (x % 2 = 1)]
protected def of_int : Π (n : ℕ), int → bitvec (succ n)
| n (int.of_nat m) := ff :: bitvec.of_nat n m
| n (int.neg_succ_of_nat m) := tt :: not (bitvec.of_nat n m)
def add_lsb (r : ℕ) (b : bool) := r + r + cond b 1 0
def bits_to_nat (v : list bool) : nat :=
v.foldl add_lsb 0
protected def to_nat {n : nat} (v : bitvec n) : nat :=
bits_to_nat (to_list v)
lemma bits_to_nat_to_list {n : ℕ} (x : bitvec n)
: bitvec.to_nat x = bits_to_nat (vector.to_list x) := rfl
theorem to_nat_append {m : ℕ} (xs : bitvec m) (b : bool)
: bitvec.to_nat (xs ++ₜ[b]) = bitvec.to_nat xs * 2 + bitvec.to_nat [b] :=
begin
cases xs with xs P,
simp [bits_to_nat_to_list], clear P,
unfold bits_to_nat list.foldl,
-- the next 4 lines generalize the accumulator of foldl
pose x := 0,
change _ = add_lsb x b + _,
generalize 0 y,
revert x, simp,
induction xs with x xs ; intro y,
{ simp, unfold list.foldl add_lsb, simp [nat.mul_succ] },
{ simp, unfold list.foldl, apply ih_1 }
end
theorem bits_to_nat_to_bool (n : ℕ)
: bitvec.to_nat [to_bool (n % 2 = 1)] = n % 2 :=
begin
simp [bits_to_nat_to_list],
unfold bits_to_nat add_lsb list.foldl cond,
simp [cond_to_bool_mod_two],
end
lemma of_nat_succ {k n : ℕ}
: bitvec.of_nat (succ k) n = bitvec.of_nat k (n / 2) ++ₜ[to_bool (n % 2 = 1)] :=
rfl
theorem to_nat_of_nat {k n : ℕ}
: bitvec.to_nat (bitvec.of_nat k n) = n % 2^k :=
begin
revert n,
induction k with k ; intro n,
{ unfold pow, simp [nat.mod_one], refl },
{ assert h : 0 < 2, { apply le_succ },
rw [ of_nat_succ
, to_nat_append
, ih_1
, bits_to_nat_to_bool
, mod_pow_succ h],
ac_refl, }
end
protected def to_int : Π {n : nat}, bitvec n → int
| 0 _ := 0
| (succ n) v :=
cond (head v)
(int.neg_succ_of_nat $ bitvec.to_nat $ not $ tail v)
(int.of_nat $ bitvec.to_nat $ tail v)
end conversion
private def to_string {n : nat} : bitvec n → string
| ⟨bs, p⟩ :=
"0b" ++ (bs.reverse.map (λ b, if b then #"1" else #"0"))
instance (n : nat) : has_to_string (bitvec n) :=
⟨to_string⟩
end bitvec
instance {n} {x y : bitvec n} : decidable (bitvec.ult x y) := bool.decidable_eq _ _
instance {n} {x y : bitvec n} : decidable (bitvec.ugt x y) := bool.decidable_eq _ _
|
f8e53c6faf90bf105fa42f310b05ae93d9749c5c | fa02ed5a3c9c0adee3c26887a16855e7841c668b | /test/lift.lean | b723c733c57650867c3086c25701c85ec9e2c26d | [
"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 | 3,485 | lean | import tactic.lift
import data.set.basic
import data.int.basic
/-! Some tests of the `lift` tactic. -/
example (n m k x z u : ℤ) (hn : 0 < n) (hk : 0 ≤ k + n) (hu : 0 ≤ u)
(h : k + n = 2 + x) (f : false) :
k + n = m + x :=
begin
lift n to ℕ using le_of_lt hn,
guard_target (k + ↑n = m + x), guard_hyp hn : (0 : ℤ) < ↑n,
lift m to ℕ,
guard_target (k + ↑n = ↑m + x), tactic.swap, guard_target (0 ≤ m), tactic.swap,
tactic.num_goals >>= λ n, guard (n = 2),
lift (k + n) to ℕ using hk with l hl,
guard_hyp l : ℕ, guard_hyp hl : ↑l = k + ↑n, guard_target (↑l = ↑m + x),
tactic.success_if_fail (tactic.get_local `hk),
lift x to ℕ with y hy,
guard_hyp y : ℕ, guard_hyp hy : ↑y = x, guard_target (↑l = ↑m + x),
lift z to ℕ with w,
guard_hyp w : ℕ, tactic.success_if_fail (tactic.get_local `z),
lift u to ℕ using hu with u rfl hu,
guard_hyp hu : (0 : ℤ) ≤ ↑u,
all_goals { exfalso, assumption },
end
-- test lift of functions
example (α : Type*) (f : α → ℤ) (hf : ∀ a, 0 ≤ f a) (hf' : ∀ a, f a < 1) (a : α) : 0 ≤ 2 * f a :=
begin
lift f to α → ℕ using hf,
guard_target ((0:ℤ) ≤ 2 * (λ i : α, (f i : ℤ)) a),
guard_hyp hf' : ∀ a, ((λ i : α, (f i:ℤ)) a) < 1,
exact int.coe_nat_nonneg _
end
instance can_lift_unit : can_lift unit unit :=
⟨id, λ x, true, λ x _, ⟨x, rfl⟩⟩
/- test whether new instances of `can_lift` are added as simp lemmas -/
run_cmd do l ← can_lift_attr.get_cache, guard (`can_lift_unit ∈ l)
/- test error messages -/
example (n : ℤ) (hn : 0 < n) : true :=
begin
success_if_fail_with_msg {lift n to ℕ using hn} "lift tactic failed.
invalid type ascription, term has type\n 0 < n\nbut is expected to have type\n 0 ≤ n",
success_if_fail_with_msg {lift (n : option ℤ) to ℕ}
"Failed to find a lift from option ℤ to ℕ. Provide an instance of\n can_lift (option ℤ) ℕ",
trivial
end
example (n : ℤ) : ℕ :=
begin
success_if_fail_with_msg {lift n to ℕ}
"lift tactic failed. Tactic is only applicable when the target is a proposition.",
exact 0
end
instance can_lift_subtype (R : Type*) (P : R → Prop) : can_lift R {x // P x} :=
{ coe := coe,
cond := λ x, P x,
prf := λ x hx, ⟨⟨x, hx⟩, rfl⟩ }
instance can_lift_set (R : Type*) (s : set R) : can_lift R s :=
{ coe := coe,
cond := λ x, x ∈ s,
prf := λ x hx, ⟨⟨x, hx⟩, rfl⟩ }
example {R : Type*} {P : R → Prop} (x : R) (hx : P x) : true :=
by { lift x to {x // P x} using hx with y, trivial }
/-! Test that `lift` elaborates `s` as a type, not as a set. -/
example {R : Type*} {s : set R} (x : R) (hx : x ∈ s) : true :=
by { lift x to s using hx with y, trivial }
example (n : ℤ) (hn : 0 ≤ n) : true :=
by { lift n to ℕ, trivial, exact hn }
example (n : ℤ) (hn : 0 ≤ n) : true :=
by { lift n to ℕ using hn, trivial }
example (n : ℤ) (hn : n ≥ 0) : true :=
by { lift n to ℕ using ge.le _, trivial, guard_target (n ≥ 0), exact hn }
example (n : ℤ) (hn : 0 ≤ 1 * n) : true :=
begin
lift n to ℕ using by { simpa [int.one_mul] using hn } with k,
-- the above braces are optional, but it would be bad style to remove them (see next example)
guard_hyp hn : 0 ≤ 1 * ((k : ℕ) : ℤ),
trivial
end
example (n : ℤ) (hn : 0 ≤ n ↔ true) : true :=
begin
lift n to ℕ using by { simp [hn] } with k, -- the braces are not optional here
trivial
end
|
7169f74dd0d12a9d79a2ce41222cbd776c77f75a | fa02ed5a3c9c0adee3c26887a16855e7841c668b | /src/ring_theory/polynomial/vieta.lean | 90a2d6188c9f8b89770b0301a6e0907e8970445b | [
"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,420 | lean | /-
Copyright (c) 2020 Hanting Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Hanting Zhang
-/
import ring_theory.polynomial.symmetric
/-!
# Vieta's Formula
The main result is `vieta.prod_X_add_C_eq_sum_esymm`, which shows that the product of linear terms
`λ + X i` is equal to a linear combination of the symmetric polynomials `esymm σ R j`.
## Implementation Notes:
We first take the viewpoint where the "roots" `X i` are variables. This means we work over
`polynomial (mv_polynomial σ R)`, which enables us to talk about linear combinations of
`esymm σ R j`. We then derive Vieta's formula in `polynomial R` by giving a
valuation from each `X i` to `r i`.
-/
universes u
open_locale big_operators
open finset polynomial fintype
namespace mv_polynomial
variables {R : Type u} [comm_semiring R]
variables (σ : Type u) [fintype σ]
/-- A sum version of Vieta's formula. Viewing `X i` as variables,
the product of linear terms `λ + X i` is equal to a linear combination of
the symmetric polynomials `esymm σ R j`. -/
lemma prod_X_add_C_eq_sum_esymm :
(∏ i : σ, (polynomial.C (X i) + polynomial.X) : polynomial (mv_polynomial σ R) )=
∑ j in range (card σ + 1),
(polynomial.C (esymm σ R j) * polynomial.X ^ (card σ - j)) :=
begin
classical,
rw [prod_add, sum_powerset],
refine sum_congr begin congr end (λ j hj, _),
rw [esymm, polynomial.C.map_sum, sum_mul],
refine sum_congr rfl (λ t ht, _),
have h : (univ \ t).card = card σ - j :=
by { rw card_sdiff (mem_powerset_len.mp ht).1, congr, exact (mem_powerset_len.mp ht).2 },
rw [(polynomial.C : mv_polynomial σ R →+* polynomial _).map_prod, prod_const, ← h],
congr,
end
/-- A fully expanded sum version of Vieta's formula, evaluated at the roots.
The product of linear terms `X + r i` is equal to `∑ j in range (n + 1), e_j * X ^ (n - j)`,
where `e_j` is the `j`th symmetric polynomial of the constant terms `r i`. -/
lemma prod_X_add_C_eval (r : σ → R) : ∏ i : σ, (polynomial.C (r i) + polynomial.X) =
∑ i in range (card σ + 1), (∑ t in powerset_len i (univ : finset σ),
∏ i in t, polynomial.C (r i)) * polynomial.X ^ (card σ - i) :=
begin
classical,
have h := @prod_X_add_C_eq_sum_esymm _ _ σ _,
apply_fun (polynomial.map (eval r)) at h,
rw [map_prod, map_sum] at h,
convert h,
simp only [eval_X, map_add, polynomial.map_C, polynomial.map_X, eq_self_iff_true],
funext,
simp only [function.funext_iff, esymm, polynomial.map_C, map_sum, polynomial.C.map_sum,
polynomial.map_C, map_pow, polynomial.map_X, map_mul],
congr,
funext,
simp only [eval_prod, eval_X, (polynomial.C : R →+* polynomial R).map_prod],
end
lemma esymm_to_sum (r : σ → R) (j : ℕ) : polynomial.C (eval r (esymm σ R j)) =
∑ t in powerset_len j (univ : finset σ), ∏ i in t, polynomial.C (r i) :=
by simp only [esymm, eval_sum, eval_prod, eval_X, polynomial.C.map_sum,
(polynomial.C : R →+* polynomial _).map_prod]
/-- Vieta's formula for the coefficients of the product of linear terms `X + r i`,
The `k`th coefficient is `∑ t in powerset_len (card σ - k) (univ : finset σ), ∏ i in t, r i`,
i.e. the symmetric polynomial `esymm σ R (card σ - k)` of the constant terms `r i`. -/
lemma prod_X_add_C_coeff (r : σ → R) (k : ℕ) (h : k ≤ card σ):
polynomial.coeff (∏ i : σ, (polynomial.C (r i) + polynomial.X)) k =
∑ t in powerset_len (card σ - k) (univ : finset σ), ∏ i in t, r i :=
begin
have hk : filter (λ (x : ℕ), k = card σ - x) (range (card σ + 1)) = {card σ - k} :=
begin
refine finset.ext (λ a, ⟨λ ha, _, λ ha, _ ⟩),
rw mem_singleton,
have hσ := (nat.sub_eq_iff_eq_add (mem_range_succ_iff.mp
(mem_filter.mp ha).1)).mp ((mem_filter.mp ha).2).symm,
symmetry,
rwa [(nat.sub_eq_iff_eq_add h), add_comm],
rw mem_filter,
have haσ : a ∈ range (card σ + 1) :=
by { rw mem_singleton.mp ha, exact mem_range_succ_iff.mpr (nat.sub_le_self _ k) },
refine ⟨haσ, eq.symm _⟩,
rw nat.sub_eq_iff_eq_add (mem_range_succ_iff.mp haσ),
have hσ := (nat.sub_eq_iff_eq_add h).mp (mem_singleton.mp ha).symm,
rwa add_comm,
end,
simp only [prod_X_add_C_eval, ← esymm_to_sum, finset_sum_coeff, coeff_C_mul_X, sum_ite, hk,
sum_singleton, esymm, eval_sum, eval_prod, eval_X, add_zero, sum_const_zero],
end
end mv_polynomial
|
ae0eab2de486c4daba992dbbf1d33320a3f105c3 | 82b86ba2ae0d5aed0f01f49c46db5afec0eb2bd7 | /tests/lean/run/def12.lean | d3d731eea820f4721a5ab04e185188529a6b6cc7 | [
"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 | 1,107 | lean |
def diag : Bool → Bool → Bool → Nat
| b, true, false => 1
| false, b, true => 2
| true, false, b => 3
| b1, b2, b3 => arbitrary Nat
theorem diag1 (a : Bool) : diag a true false = 1 :=
match a with
| true => rfl
| false => rfl
theorem diag2 (a : Bool) : diag false a true = 2 :=
by cases a; exact rfl; exact rfl
theorem diag3 (a : Bool) : diag true false a = 3 :=
by cases a; exact rfl; exact rfl
theorem diag4_1 : diag false false false = arbitrary Nat :=
rfl
theorem diag4_2 : diag true true true = arbitrary Nat :=
rfl
def f : Nat → Nat → Nat
| n, 0 => 0
| 0, n => 1
| n, m => arbitrary Nat
theorem f_zero_right : (a : Nat) → f a 0 = 0
| 0 => rfl
| a+1 => rfl
theorem f_zero_succ (a : Nat) : f 0 (a+1) = 1 :=
rfl
theorem f_succ_succ (a b : Nat) : f (a+1) (b+1) = arbitrary Nat :=
rfl
def app {α} : List α → List α → List α
| [], l => l
| h::t, l => h :: (app t l)
theorem app_nil {α} (l : List α) : app [] l = l :=
rfl
theorem app_cons {α} (h : α) (t l : List α) : app (h :: t) l = h :: (app t l) :=
rfl
theorem ex : app [1, 2] [3,4,5] = [1,2,3,4,5] :=
rfl
|
e99b9efb3b2bcdede0e768ff367756194b613727 | 64874bd1010548c7f5a6e3e8902efa63baaff785 | /tests/lean/hott/cases.hlean | bfad630b20597263698d232967aed33c23916435 | [
"Apache-2.0"
] | permissive | tjiaqi/lean | 4634d729795c164664d10d093f3545287c76628f | d0ce4cf62f4246b0600c07e074d86e51f2195e30 | refs/heads/master | 1,622,323,796,480 | 1,422,643,069,000 | 1,422,643,069,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 476 | hlean | open nat
inductive vec (A : Type) : nat → Type :=
nil {} : vec A zero,
cons : Π {n}, A → vec A n → vec A (succ n)
namespace vec
variables {A B C : Type}
variables {n m : nat}
notation a :: b := cons a b
protected definition destruct (v : vec A (succ n)) {P : Π {n : nat}, vec A (succ n) → Type}
(H : Π {n : nat} (h : A) (t : vec A n), P (h :: t)) : P v :=
begin
cases v with (n', h', t'),
apply (H h' t')
end
end vec
|
e892dbe49b33aa90b29ad711cf423c2226581668 | fa02ed5a3c9c0adee3c26887a16855e7841c668b | /src/data/pi.lean | a7bbe4b0801d254ad3c0fb734b753ad44ef2da1b | [
"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 | 3,858 | lean | /-
Copyright (c) 2020 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon, Patrick Massot, Eric Wieser
-/
import tactic.split_ifs
import tactic.simpa
import tactic.congr
import algebra.group.to_additive
/-!
# Instances and theorems on pi types
This file provides basic definitions and notation instances for Pi types.
Instances of more sophisticated classes are defined in `pi.lean` files elsewhere.
-/
universes u v₁ v₂ v₃
variable {I : Type u} -- The indexing type
-- The families of types already equipped with instances
variables {f : I → Type v₁} {g : I → Type v₂} {h : I → Type v₃}
variables (x y : Π i, f i) (i : I)
namespace pi
/-! `1`, `0`, `+`, `*`, `-`, `⁻¹`, and `/` are defined pointwise. -/
@[to_additive] instance has_one [∀ i, has_one $ f i] :
has_one (Π i : I, f i) :=
⟨λ _, 1⟩
@[simp, to_additive] lemma one_apply [∀ i, has_one $ f i] : (1 : Π i, f i) i = 1 := rfl
@[to_additive] lemma one_def [Π i, has_one $ f i] : (1 : Π i, f i) = λ i, 1 := rfl
@[to_additive]
instance has_mul [∀ i, has_mul $ f i] :
has_mul (Π i : I, f i) :=
⟨λ f g i, f i * g i⟩
@[simp, to_additive] lemma mul_apply [∀ i, has_mul $ f i] : (x * y) i = x i * y i := rfl
@[to_additive] lemma mul_def [Π i, has_mul $ f i] : x * y = λ i, x i * y i := rfl
@[to_additive] instance has_inv [∀ i, has_inv $ f i] :
has_inv (Π i : I, f i) :=
⟨λ f i, (f i)⁻¹⟩
@[simp, to_additive] lemma inv_apply [∀ i, has_inv $ f i] : x⁻¹ i = (x i)⁻¹ := rfl
@[to_additive] instance has_div [Π i, has_div $ f i] :
has_div (Π i : I, f i) :=
⟨λ f g i, f i / g i⟩
@[simp, to_additive] lemma div_apply [Π i, has_div $ f i] : (x / y) i = x i / y i := rfl
@[to_additive] lemma div_def [Π i, has_div $ f i] : x / y = λ i, x i / y i := rfl
section
variables [decidable_eq I]
variables [Π i, has_zero (f i)] [Π i, has_zero (g i)] [Π i, has_zero (h i)]
/-- The function supported at `i`, with value `x` there. -/
def single (i : I) (x : f i) : Π i, f i :=
function.update 0 i x
@[simp] lemma single_eq_same (i : I) (x : f i) : single i x i = x :=
function.update_same i x _
@[simp] lemma single_eq_of_ne {i i' : I} (h : i' ≠ i) (x : f i) : single i x i' = 0 :=
function.update_noteq h x _
@[simp] lemma single_zero (i : I) : single i (0 : f i) = 0 :=
function.update_eq_self _ _
lemma apply_single (f' : Π i, f i → g i) (hf' : ∀ i, f' i 0 = 0) (i : I) (x : f i) (j : I):
f' j (single i x j) = single i (f' i x) j :=
by simpa only [pi.zero_apply, hf', single] using function.apply_update f' 0 i x j
lemma apply_single₂ (f' : Π i, f i → g i → h i) (hf' : ∀ i, f' i 0 0 = 0)
(i : I) (x : f i) (y : g i) (j : I):
f' j (single i x j) (single i y j) = single i (f' i x y) j :=
begin
by_cases h : j = i,
{ subst h, simp only [single_eq_same] },
{ simp only [single_eq_of_ne h, hf'] },
end
lemma single_op {g : I → Type*} [Π i, has_zero (g i)] (op : Π i, f i → g i) (h : ∀ i, op i 0 = 0)
(i : I) (x : f i) :
single i (op i x) = λ j, op j (single i x j) :=
eq.symm $ funext $ apply_single op h i x
lemma single_op₂ {g₁ g₂ : I → Type*} [Π i, has_zero (g₁ i)] [Π i, has_zero (g₂ i)]
(op : Π i, g₁ i → g₂ i → f i) (h : ∀ i, op i 0 0 = 0) (i : I) (x₁ : g₁ i) (x₂ : g₂ i) :
single i (op i x₁ x₂) = λ j, op j (single i x₁ j) (single i x₂ j) :=
eq.symm $ funext $ apply_single₂ op h i x₁ x₂
variables (f)
lemma single_injective (i : I) : function.injective (single i : f i → Π i, f i) :=
function.update_injective _ i
end
end pi
lemma subsingleton.pi_single_eq {α : Type*} [decidable_eq I] [subsingleton I] [has_zero α]
(i : I) (x : α) :
pi.single i x = λ _, x :=
funext $ λ j, by rw [subsingleton.elim j i, pi.single_eq_same]
|
eafa5d3bcded7696e2f8a53b654db7361ec9f0a3 | 0845ae2ca02071debcfd4ac24be871236c01784f | /tests/playground/termparsertest1.lean | 3604e79ef663a53c42bc36af56587a2a4624e088 | [
"Apache-2.0"
] | permissive | GaloisInc/lean4 | 74c267eb0e900bfaa23df8de86039483ecbd60b7 | 228ddd5fdcd98dd4e9c009f425284e86917938aa | refs/heads/master | 1,643,131,356,301 | 1,562,715,572,000 | 1,562,715,572,000 | 192,390,898 | 0 | 0 | null | 1,560,792,750,000 | 1,560,792,749,000 | null | UTF-8 | Lean | false | false | 1,929 | lean | import init.lean.parser.term
open Lean
open Lean.Parser
def testParser (input : String) : IO Unit :=
do
env ← mkEmptyEnvironment;
termPTables ← builtinTermParsingTable.get;
stx ← IO.ofExcept $ runParser env termPTables input "<input>" "expr";
IO.println stx
def test (is : List String) : IO Unit :=
is.mfor $ fun input => do
IO.println input;
testParser input
def testParserFailure (input : String) : IO Unit :=
do
env ← mkEmptyEnvironment;
termPTables ← builtinTermParsingTable.get;
match runParser env termPTables input "<input>" "expr" with
| Except.ok stx => throw (IO.userError ("unexpected success\n" ++ toString stx))
| Except.error msg => IO.println ("failed as expected, error: " ++ msg)
def testFailures (is : List String) : IO Unit :=
is.mfor $ fun input => do
IO.println input;
testParserFailure input
def main (xs : List String) : IO Unit :=
do
test [
"Prod.mk",
"x.{u, v+1}",
"x.{u}",
"x",
"x.{max u v}",
"x.{max u v, 0}",
"f 0 1",
"f.{u+1} \"foo\" x",
"(f x, 0, 1)",
"()",
"(f x)",
"(f x : Type)",
"h (f x) (g y)",
"if x then f x else g x",
"if h : x then f x h else g x h",
"have p x y from f x; g this",
"suffices h : p x y from f x; g this",
"show p x y from f x",
"fun x y => f y x",
"fun (x y : Nat) => f y x",
"fun (x, y) => f y x",
"fun z (x, y) => f y x",
"fun ⟨x, y⟩ ⟨z, w⟩ => f y x w z",
"fun (Prod.mk x y) => f y x",
"{ x := 10, y := 20 }",
"{ x := 10, y := 20, }",
"{ x // p x 10 }",
"{ x : Nat // p x 10 }",
"{ .. }",
"{ Prod . fst := 10, .. }",
"a[i]",
"f [10, 20]",
"g a[x+2]",
"g f.a.1.2.bla x.1.a",
"x+y*z < 10/3",
"id (α := Nat) 10",
"(x : a)",
"a -> b",
"{x : a} -> b",
"{a : Type} -> [HasToString a] -> (x : a) -> b",
"f ({x : a} -> b)",
"f (x : a) -> b",
"f ((x : a) -> b)",
"(f : (n : Nat) → Vector Nat n) -> Nat",
"∀ x y (z : Nat), x > y -> x > y - z",
"
match x with
| some x => true
| none => false"
];
testFailures [
"f {x : a} -> b",
"(x := 20)"
]
|
9791479a50f49d60ff55145068d53cdd8a366184 | a76f677b87d42a9470ba3a0a78cfddd3063118e6 | /src/order/angle.lean | a4da26b034228c962386dd3d6291f6c719c8150e | [] | no_license | Ja1941/hilberts-axioms | 50219c732ad5fa167408432e8c8baae259777a40 | 5b653a92e448b77da41c9893066b641bc4e6b316 | refs/heads/master | 1,693,238,884,856 | 1,635,702,120,000 | 1,635,702,120,000 | 385,546,384 | 9 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 30,123 | lean | /-
Copyright (c) 2021 Tianchen Zhao. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Tianchen Zhao
-/
import order.sidedness
/-!
# Ray and angle
This file defines rays and angles using `same_side_pt` and insidedness of an angle,
and then proves some important theorems such as the crossbar theorem.
## Main definitions
* `ray` is half of a line separated by its vertex.
* `ang` is the union of two `ray` sharing the same vertex.
* `inside_ang` defines how a point can be inside `ang`.
## References
* See [Geometry: Euclid and Beyond]
-/
open set
variable [B : incidence_order_geometry]
open incidence_geometry incidence_order_geometry
include B
/--A type with a vertex and inside defined as the set consising of the vertex and
all points on the same side with a point `a` to the vertex.
-/
structure ray := (vertex : pts) (inside : set pts)
(in_eq : ∃ a : pts, inside = {x : pts | same_side_pt vertex a x} ∪ {vertex})
/--A ray can be defined by explicitly stating the vertex `o` and `a`. -/
def two_pt_ray (o a : pts) : ray := ⟨o, {x : pts | same_side_pt o a x} ∪ {o}, ⟨a, rfl⟩⟩
notation a`-ᵣ`b := two_pt_ray a b
lemma two_pt_ray_vertex (o a : pts) : (o-ᵣa).vertex = o := rfl
lemma ray_unique {r₁ r₂ : ray} (hr₁r₂ : r₁.vertex = r₂.vertex) :
(∃ x : pts, x ≠ r₁.vertex ∧ x ∈ r₁.inside ∩ r₂.inside) → r₁ = r₂ :=
begin
rintros ⟨a, ha1, ha⟩,
suffices : r₁.inside = r₂.inside,
induction r₁ with v₁ I₁ hI₁, induction r₂ with v₂ I₂ hI₂ generalizing v₁ I₁ hI₁,
simp, exact ⟨hr₁r₂, this⟩,
cases r₁.in_eq with x h₁,
cases r₂.in_eq with y h₂,
replace h₁ : r₁.inside = {x : pts | same_side_pt r₁.vertex x a} ∪ {r₁.vertex},
rw h₁, ext p, simp,
have : same_side_pt r₁.vertex x p ↔ same_side_pt r₁.vertex p a,
rw h₁ at ha, simp at ha, split; intro h; cases ha.1 with ha ha,
exact absurd ha ha1, exact same_side_pt_trans (same_side_pt_symm h) ha,
exact absurd ha ha1, exact same_side_pt_trans ha (same_side_pt_symm h),
rw this,
rw [h₁, h₂], ext p, simp, rw hr₁r₂,
have : same_side_pt r₂.vertex p a ↔ same_side_pt r₂.vertex y p,
rw h₂ at ha, simp at ha, cases ha.2 with ha ha,
rw hr₁r₂ at ha1, exact absurd ha ha1,
split; intro h,
exact same_side_pt_trans ha (same_side_pt_symm h),
exact same_side_pt_trans (same_side_pt_symm h) ha,
rw this
end
lemma ray_eq_same_side_pt {r : ray} {a : pts}
(har : a ∈ r.inside) (hao : a ≠ r.vertex) : r = (r.vertex-ᵣa) :=
begin
suffices : r.inside = (r.vertex-ᵣa).inside,
induction r, unfold two_pt_ray, simp,
unfold two_pt_ray at this, simp at this, exact this,
cases r.in_eq with a' ha', rw ha',
rw ha' at har, simp at har, cases har with har har,
exact absurd har hao,
unfold two_pt_ray, ext, simp,
have : same_side_pt r.vertex a x ↔ same_side_pt r.vertex a' x,
split; intro h, exact same_side_pt_trans har h,
exact same_side_pt_trans (same_side_pt_symm har) h,
rw this
end
lemma ray_in_neq {o a b : pts} (hbo : b ≠ o) (h : b ∈ (o-ᵣa).inside) : same_side_pt o a b :=
by { cases h, exact h, exact absurd h hbo }
lemma two_pt_ray_eq_same_side_pt {o a b : pts} (hoab : same_side_pt o a b) :
(o-ᵣa) = (o-ᵣb) :=
begin
unfold two_pt_ray, simp only [true_and, eq_self_iff_true], ext, simp,
have : same_side_pt o a x ↔ same_side_pt o b x,
split; intro h, exact same_side_pt_trans (same_side_pt_symm hoab) h,
exact same_side_pt_trans hoab h,
rw this
end
lemma ray_singleton (a : pts) : (a-ᵣa).inside = {a} :=
begin
ext1, unfold two_pt_ray same_side_pt, simp,
intro hf, unfold two_pt_seg at hf, simp at hf, exfalso, exact hf
end
lemma ray_disjoint {s₁ s₂ : ray} (hvertex : s₁.vertex = s₂.vertex) :
s₁ ≠ s₂ → s₁.inside ∩ s₂.inside = {s₁.vertex} :=
begin
contrapose!, intro h,
refine ray_unique hvertex _,
by_contra hf, push_neg at hf,
apply h, apply subset.antisymm, intro y, contrapose!, exact hf y,
simp, cases s₁.in_eq, rw h_1, cases s₂.in_eq, rw h_2, rw hvertex, simp
end
lemma in_ray_col {o a b : pts} : b ∈ (o-ᵣa).inside → col o a b :=
begin
intro h,
cases h, exact h.2, simp at h, rw h,
by_cases hao : a = o,
rw hao, rcases one_pt_line o with ⟨l, hl, hol⟩,
exact ⟨l, hl, hol, hol, hol⟩,
exact ⟨(a-ₗo), line_in_lines hao,
pt_right_in_line a o, pt_left_in_line a o, pt_right_in_line a o⟩
end
lemma ray_reconstruct (r : ray) : ∃ a : pts, r = (r.vertex-ᵣa) :=
begin
cases r.in_eq with x hx, use x, unfold two_pt_ray,
induction r with v I hI, simp,
simp at hx, rw hx
end
lemma ray_singleton_iff_eq {o a p : pts} : (o-ᵣa).inside = {p} ↔ o = a ∧ o = p :=
begin
by_cases hoa : o = a,
rw [hoa, ray_singleton], simp,
split; intro h,
have : ∀ x ∈ (o-ᵣa).inside, x = p, rw h, simp, unfold two_pt_ray at this, simp at this,
rw this.2 a (same_side_pt_refl hoa), exact ⟨this.1, this.1⟩,
exact absurd h.1 hoa
end
lemma pt_left_in_ray (o a : pts) : o ∈ (o-ᵣa).inside :=
by {unfold two_pt_ray, simp}
lemma pt_right_in_ray (o a : pts) : a ∈ (o-ᵣa).inside :=
begin
by_cases hoa : o = a,
rw [hoa, ray_singleton], exact rfl,
unfold two_pt_ray, simp, right, exact same_side_pt_refl (hoa)
end
lemma seg_in_ray (o a : pts) : (o-ₛa).inside ⊆ (o-ᵣa).inside :=
begin
unfold two_pt_ray, unfold two_pt_seg,
intros x hx, simp at hx, simp,
rcases hx with hx | hx | hx,
rw hx, simp,
rw hx, by_cases hao : a = o, rw hao, left, refl,
right, split,
rw seg_singleton, exact ne.symm hao,
exact ⟨(a-ₗo), line_in_lines hao,
pt_right_in_line a o, pt_left_in_line a o, pt_left_in_line a o⟩,
right, unfold same_side_pt, unfold two_pt_seg, simp, split,
intro hf, rcases hf with hf | hf | hf,
rw hf at hx, exact (between_neq hx).2.1 rfl,
exact (between_neq hx).1 hf,
rw between_symm at hx, exact between_contra.2.1 ⟨hf, hx⟩,
rcases (between_col hx) with ⟨l, hl, hol, hxl, hal⟩,
exact ⟨l, hl, hol, hal, hxl⟩
end
lemma ray_in_line (o a : pts) : (o-ᵣa).inside ⊆ (o-ₗa) :=
begin
intros x hx, cases hx,
exact col_in12 hx.2 (same_side_pt_neq hx).1.symm,
simp at hx, rw hx, exact pt_left_in_line o a
end
lemma two_pt_ray_eq_same_side_pt_pt {o a b : pts} :
same_side_pt o a b ↔ (o-ᵣa) = (o-ᵣb) ∧ o ≠ a ∧ o ≠ b :=
begin
split, intro hoab, unfold two_pt_ray,
have : {x : pts | same_side_pt o a x} = {x : pts | same_side_pt o b x},
ext, simp, split; intro h,
exact same_side_pt_trans (same_side_pt_symm hoab) h,
exact same_side_pt_trans hoab h,
exact ⟨by {simp, simp at this, rw this},
(same_side_pt_neq hoab).1.symm, (same_side_pt_neq hoab).2.symm⟩,
rintros ⟨hoab, hoa, hob⟩,
cases two_pt_between hoa with x hoxa,
have hx : x ∈ (o-ᵣb).inside,
rw ←hoab, unfold two_pt_ray, simp,
right, exact same_side_pt_symm (between_same_side_pt.1 hoxa).1,
unfold two_pt_ray at hx, simp at hx,
cases hx with hx hx, exact absurd hx (between_neq hoxa).1.symm,
exact same_side_pt_trans (same_side_pt_symm (between_same_side_pt.1 hoxa).1)
(same_side_pt_symm hx)
end
lemma t_shape_ray {a b c : pts} (habc : noncol a b c) :
∀ {x : pts}, same_side_pt b c x → same_side_line (a-ₗb) c x :=
begin
intros x hbcx,
by_cases hcx : c = x,
rw ←hcx, exact same_side_line_refl (noncol_in12 habc),
rintros ⟨e, heab, hecx⟩,
have hab := (noncol_neq habc).1,
have hbe : b = e,
apply two_line_one_pt (line_in_lines hab) (line_in_lines hcx),
intro hf, apply noncol_in12 habc, rw hf, exact pt_left_in_line c x,
exact pt_right_in_line a b, exact col_in23 hbcx.2 hcx,
exact heab, exact (seg_in_line c x) hecx,
rw hbe at hbcx,
have hcex := seg_in_neq (same_side_pt_neq hbcx).1.symm (same_side_pt_neq hbcx).2.symm hecx,
rw [←not_diff_side_pt, ←between_diff_side_pt] at hbcx,
exact hbcx hcex,
exact hbcx.2,
exact (same_side_pt_neq hbcx).1, exact (same_side_pt_neq hbcx).2
end
lemma t_shape_seg {a b c : pts} (habc : noncol a b c) :
∀ x : pts, between b x c → same_side_line (a-ₗb) c x :=
λ x hbxc, t_shape_ray habc (same_side_pt_symm (between_same_side_pt.1 hbxc).1)
lemma between_diff_side_line {o a b c : pts} (hoab : noncol o a b) (hacb : between a c b) :
diff_side_line (o-ₗc) a b :=
begin
use c,
exact ⟨pt_right_in_line o c, by {left, exact hacb}⟩,
have hac := (between_neq hacb).1,
have hbc := (between_neq hacb).2.2.symm,
split,
exact noncol_in32 (col_noncol (col23 (between_col hacb)) (noncol123 hoab) hac),
exact noncol_in32 (col_noncol (col132 (between_col hacb)) (noncol13 hoab) hbc)
end
lemma between_same_side_line {o a b c : pts} (hoab : noncol o a b) (hacb : between a c b) :
same_side_line (o-ₗa) b c :=
begin
have hoa := (noncol_neq hoab).1,
have hbc := (between_neq hacb).2.2.symm,
have hab := (between_neq hacb).2.1,
have hac := (between_neq hacb).1,
rintros ⟨d, hd⟩,
have had : a = d,
apply two_line_one_pt (line_in_lines hoa) (line_in_lines hbc),
intro hf, apply noncol_in12 hoab, rw hf, exact pt_left_in_line b c,
exact pt_right_in_line o a,
exact col_in32 (between_col hacb) hbc,
exact hd.1, exact (seg_in_line b c) hd.2,
rw ←had at hd,
rw between_symm at hacb,
exact between_contra.2.1 ⟨hacb, seg_in_neq hab hac hd.2⟩
end
lemma ray_same_side_line {o a b c b' : pts} (hoa : o ≠ a) (h : same_side_line (o-ₗa) b c)
(hobb' : same_side_pt o b b') : same_side_line (o-ₗa) b' c :=
begin
have hob' := (same_side_pt_neq hobb').2.symm,
apply same_side_line_trans (line_in_lines hoa) _ h,
rw line_symm, apply t_shape_ray,
exact noncol132 (col_noncol hobb'.2 (noncol23 (same_side_line_noncol h hoa).1) hob'),
exact same_side_pt_symm hobb'
end
lemma ray_diff_side_line {o a b c a' : pts} (hob : o ≠ b) (h : diff_side_line (o-ₗb) a c)
(hoaa' : same_side_pt o a a') : diff_side_line (o-ₗb) a' c :=
begin
apply same_diff_side_line (line_in_lines hob) _ h,
rw line_symm, apply t_shape_ray,
{ have hoba := (diff_side_line_noncol h hob).1,
have hoa' := (same_side_pt_neq hoaa').2.symm,
exact noncol132 ((col_noncol hoaa'.2 (noncol23 hoba)) hoa') },
exact same_side_pt_symm hoaa'
end
lemma diff_same_side_line' {a o b c : pts} :
diff_side_line (o-ₗb) a c → same_side_line (o-ₗa) b c → same_side_line (o-ₗc) a b :=
begin
intros h₁ h₂,
have hoa := (diff_side_line_neq h₁).1.symm,
have hoc := (diff_side_line_neq' h₁).1.symm,
have hab := (diff_side_line_neq h₁).2,
have hob := (same_side_line_neq h₂).1.symm,
cases h₁.1 with b' hb',
have hb'a : b' ≠ a,
intro hf, rw hf at hb', exact h₁.2.1 hb'.1,
have hb'c : b' ≠ c,
intro hf, rw hf at hb', exact h₁.2.2 hb'.1,
have hb'o : b' ≠ o,
intro hf, rw hf at hb',
exact (same_side_line_noncol h₂ hoa).2 (col_in23' ((seg_in_line a c) hb'.2)),
have hab'c := seg_in_neq hb'a hb'c hb'.2,
apply same_side_line_symm, apply ray_same_side_line,
exact hoc,
{ apply same_side_line_symm, apply between_same_side_line,
exact noncol23 (same_side_line_noncol h₂ hoa).2,
rw between_symm at hab'c, exact hab'c },
have hobb' := col_in13' hb'.1,
apply same_side_line_pt,
exact hobb', exact line_in_lines hoa,
exact pt_left_in_line o a,
exact noncol_in13 (col_noncol (col23 hobb') (diff_side_line_noncol h₁ hob).1 hb'o.symm),
exact (same_side_line_notin h₂).1,
{ apply same_side_line_symm, apply same_side_line_trans (line_in_lines hoa) h₂,
exact t_shape_seg (same_side_line_noncol h₂ hoa).2 b' hab'c }
end
/--A type given by a vertex and its inside is the union of two rays with this vertex. -/
structure ang := (vertex : pts) (inside : set pts)
(in_eq : ∃ a b : pts, inside = (vertex-ᵣa).inside ∪ (vertex-ᵣb).inside)
noncomputable def pt1 (α : ang) :
{a : pts // ∃ b : pts, α.inside = (α.vertex-ᵣa).inside ∪ (α.vertex-ᵣb).inside} :=
by {choose a h using α.in_eq, exact ⟨a, h⟩}
noncomputable def pt2 (α : ang) :
{b : pts // α.inside = (α.vertex-ᵣ(pt1 α)).inside ∪ (α.vertex-ᵣb).inside} :=
by {choose b h using (pt1 α).2, exact ⟨b, h⟩}
lemma vertex_in_ang (α : ang) : α.vertex ∈ α.inside :=
by { rcases α.in_eq with ⟨a, b, h⟩, rw h, left, exact pt_left_in_ray _ _ }
/--Define an ang by giving its vertex and two other points on the two rays. -/
def three_pt_ang (a o b : pts) : ang := ⟨o, (o-ᵣa).inside∪(o-ᵣb).inside, ⟨a, b, rfl⟩⟩
notation `∠` := three_pt_ang
lemma ang_symm (a o b : pts) : ∠ a o b = ∠ b o a :=
by {unfold three_pt_ang, simp, rw union_comm}
lemma three_pt_ang_vertex (a o b : pts) : (∠ a o b).vertex = o :=
by unfold three_pt_ang
lemma pt_left_in_three_pt_ang (a o b : pts) : a ∈ (∠ a o b).inside :=
begin
unfold three_pt_ang two_pt_ray, simp, left,
by_cases a = o, left, exact h,
right, exact (same_side_pt_refl (ne.symm h))
end
lemma pt_right_in_three_pt_ang (a o b : pts) : b ∈ (∠ a o b).inside :=
by {rw ang_symm, exact pt_left_in_three_pt_ang b o a}
lemma ang_eq_same_side_pt (a : pts) {o b c : pts} (hobc : same_side_pt o b c) :
∠ a o b = ∠ a o c :=
by {unfold three_pt_ang, simp, rw two_pt_ray_eq_same_side_pt hobc}
/--An ang is proper if its two sides are noncollinear. -/
def ang_proper (α : ang) : Prop :=
∀ l ∈ lines, ¬α.inside ⊆ l
lemma ang_proper_iff_noncol {a o b : pts} :
ang_proper (∠ a o b) ↔ noncol a o b :=
begin
split; intro h,
{ rintros ⟨l, hl, hal, hol, hbl⟩,
apply h l hl,
unfold three_pt_ang, simp,
split,
{ intros x hx,
by_cases hoa : o = a,
rw [hoa, ray_singleton, mem_singleton_iff] at hx,
rw hx, exact hal,
rw two_pt_one_line hl (line_in_lines hoa) hoa hol hal
(pt_left_in_line o a) (pt_right_in_line o a),
exact (ray_in_line o a) hx },
{ intros x hx,
by_cases hob : o = b,
rw [hob, ray_singleton, mem_singleton_iff] at hx,
rw hx, exact hbl,
rw two_pt_one_line hl (line_in_lines hob) hob hol hbl
(pt_left_in_line o b) (pt_right_in_line o b),
exact (ray_in_line o b) hx } },
{ intros l hl hf,
unfold three_pt_ang at hf, simp at hf,
exact h ⟨l, hl, hf.1 (pt_right_in_ray o a), hf.1 (pt_left_in_ray o a),
hf.2 (pt_right_in_ray o b)⟩ }
end
private lemma three_pt_ang_eq_iff_prep {a o b a' b' : pts} (haob : ang_proper (∠ a o b)) :
(∠ a o b) = (∠ a' o b') → same_side_pt o a a' → same_side_pt o b b' :=
begin
intros he hoaa',
have ha'ob' : noncol a' o b',
rw he at haob, exact ang_proper_iff_noncol.1 haob,
rw ang_proper_iff_noncol at haob,
have hoa := (noncol_neq haob).1.symm,
have hob := (noncol_neq haob).2.2,
have hob' := (noncol_neq ha'ob').2.2,
by_cases hbb' : b = b',
rw ←hbb', exact same_side_pt_symm (same_side_pt_refl hob),
have hb' : b' ∈ (∠ a o b).inside,
rw he, unfold three_pt_ang, right, exact pt_right_in_ray o b',
cases hb' with hb' hb',
{ exfalso, apply noncol12 ha'ob',
exact col_trans hoaa'.2 ⟨(o-ₗa), line_in_lines hoa,
pt_left_in_line o a, pt_right_in_line o a, (ray_in_line o a) hb'⟩ hoa },
{ cases hb' with hb' hb',
exact hb', exact absurd hb' hob'.symm }
end
lemma three_pt_ang_eq_iff {a o b a' o' b' : pts}
(haob : noncol a o b) : (∠ a o b) = (∠ a' o' b') ↔ o = o'
∧ ((same_side_pt o a a' ∧ same_side_pt o b b') ∨ (same_side_pt o a b' ∧ same_side_pt o b a')) :=
begin
split,
{ intro he,
have hoo' : o = o',
unfold three_pt_ang at he, simp at he, exact he.1,
have ha'ob' : noncol a' o b',
rw [←ang_proper_iff_noncol, he, ←hoo'] at haob,
exact ang_proper_iff_noncol.1 haob,
have ha'o := (noncol_neq ha'ob').1,
split, exact hoo',
rw ←hoo' at he,
have ha' : a' ∈ (∠ a o b).inside,
rw he, unfold three_pt_ang, left, exact pt_right_in_ray o a',
cases ha' with ha' ha';
cases ha' with ha' ha',
left, exact ⟨ha', three_pt_ang_eq_iff_prep (ang_proper_iff_noncol.2 haob) he ha'⟩,
exact absurd ha' ha'o,
{ right, rw ang_symm at he,
exact ⟨three_pt_ang_eq_iff_prep (ang_proper_iff_noncol.2
(noncol13 haob)) he ha', ha'⟩ },
exact absurd ha' ha'o },
{ rintros ⟨hoo', h | h⟩,
rw [ang_eq_same_side_pt a h.2, ang_symm, ang_eq_same_side_pt b' h.1, ang_symm, hoo'],
rw [ang_eq_same_side_pt a h.2, ang_symm, ang_eq_same_side_pt a' h.1, hoo'] }
end
lemma ang_three_pt (α : ang) : ∃ a b : pts, α = ∠ a α.vertex b :=
begin
rcases α.in_eq with ⟨a, b, h⟩,
use [a, b], unfold three_pt_ang, induction α, simp, exact h
end
/--A point `p` is inside `∠ a o b` if `p` and `a` are on the same side to `o-ₗa` and
`p` and `b` are on the same side to line `o-ₗb`. -/
def inside_ang (p : pts) (α : ang) : Prop :=
(∃ a b : pts, α = ∠ a α.vertex b
∧ same_side_line (α.vertex-ₗa) b p ∧ same_side_line (α.vertex-ₗb) a p)
lemma inside_ang_proper {p : pts} {α : ang} :
inside_ang p α → ang_proper α :=
begin
rintros ⟨a, b, hα, hbp, hap⟩,
rw [hα, ang_proper_iff_noncol],
intro haob,
by_cases α.vertex = b,
rw h at hbp,
exact (same_side_line_notin hbp).1 (pt_left_in_line b a),
exact (same_side_line_notin hap).1 (col_in23 haob h)
end
lemma inside_three_pt_ang {p a o b : pts}:
inside_ang p (∠ a o b) ↔ same_side_line (o-ₗa) b p ∧ same_side_line (o-ₗb) a p :=
begin
split,
{ intro hp,
have haob := inside_ang_proper hp,
rcases hp with ⟨a', b', haoba'ob', hb'p, ha'p⟩,
rw three_pt_ang_vertex at haoba'ob' ha'p hb'p,
have ha'ob' : noncol a' o b',
rw [haoba'ob', ang_proper_iff_noncol] at haob, exact haob,
rw ang_proper_iff_noncol at haob,
have hoa := (noncol_neq haob).1.symm,
have hoa' := (noncol_neq ha'ob').1.symm,
have hob := (noncol_neq haob).2.2,
have hob' := (noncol_neq ha'ob').2.2,
cases ((three_pt_ang_eq_iff haob).1 haoba'ob').2,
split,
{ rw two_pt_one_line (line_in_lines hoa) (line_in_lines hoa') hoa
(pt_left_in_line o a) (pt_right_in_line o a) (pt_left_in_line o a') (col_in13 h.1.2 hoa'),
exact ray_same_side_line hoa' hb'p (same_side_pt_symm h.2) },
{ rw two_pt_one_line (line_in_lines hob) (line_in_lines hob') hob
(pt_left_in_line o b) (pt_right_in_line o b) (pt_left_in_line o b') (col_in13 h.2.2 hob'),
exact ray_same_side_line hob' ha'p (same_side_pt_symm h.1) },
split,
{ rw two_pt_one_line (line_in_lines hoa) (line_in_lines hob') hoa
(pt_left_in_line o a) (pt_right_in_line o a) (pt_left_in_line o b') (col_in13 h.1.2 hob'),
exact ray_same_side_line hob' ha'p (same_side_pt_symm h.2) },
{ rw two_pt_one_line (line_in_lines hob) (line_in_lines hoa') hob
(pt_left_in_line o b) (pt_right_in_line o b) (pt_left_in_line o a') (col_in13 h.2.2 hoa'),
exact ray_same_side_line hoa' hb'p (same_side_pt_symm h.1) } },
{ rintros ⟨hap, hbp⟩,
use [a, b],
rw three_pt_ang_vertex,
exact ⟨rfl, hap, hbp⟩ }
end
lemma inside_ang_proper' {p a o b : pts} : inside_ang p (∠ a o b)
→ ang_proper (∠ p o a) ∧ ang_proper (∠ p o b) :=
begin
intro hp,
have haob := ang_proper_iff_noncol.1 (inside_ang_proper hp),
have hoa := (noncol_neq haob).1.symm,
have hob := (noncol_neq haob).2.2,
rw inside_three_pt_ang at hp,
split; rw ang_proper_iff_noncol; intro h,
exact (same_side_line_notin hp.1).2 (col_in23 h hoa),
exact (same_side_line_notin hp.2).2 (col_in23 h hob)
end
lemma hypo_inside_ang {a b c d : pts} (habc : noncol a b c) (hadc : between a d c) :
inside_ang d (∠ a b c) :=
begin
have hab := (noncol_neq habc).1,
have hbc := (noncol_neq habc).2.2,
have had := (between_neq hadc).1,
have hdc := (between_neq hadc).2.2,
rw inside_three_pt_ang, split,
exact t_shape_seg (noncol12 habc) d hadc,
{ rw between_symm at hadc,
exact t_shape_seg (noncol123 habc) d hadc }
end
theorem crossbar {a b c d : pts}
(hd : inside_ang d (∠ b a c)) : (two_pt_ray a d).inside ♥ (b-ₛc).inside :=
begin
have hbac := inside_ang_proper hd, rw ang_proper_iff_noncol at hbac,
have hab := (noncol_neq hbac).1.symm,
have hac := (noncol_neq hbac).2.2,
rw inside_three_pt_ang at hd,
have had := (same_side_line_neq' hd.1).1.symm,
have hacd := ((same_side_line_noncol hd.2) hac).2,
have habd := ((same_side_line_noncol hd.1) hab).2,
cases between_extend hac.symm with e hcae,
have hce := (between_neq hcae).2.1,
have hae := (between_neq hcae).2.2,
have hceb := col_noncol (between_col hcae) (noncol13 hbac) hce,
have haed := col_noncol (col12 (between_col hcae)) hacd hae,
have haeb := col_noncol (col12 (between_col hcae)) (noncol123 hbac) hae,
have : ((a-ₗd) ♥ (c-ₛe).inside),
from ⟨a, pt_left_in_line a d, by {left, exact hcae}⟩,
cases (pasch hceb (line_in_lines had) (noncol_in13 hacd)
(noncol_in13 haed) (noncol_in13 habd) this).1,
{ cases h with x hx,
have hxa : x ≠ a,
intro hf, rw hf at hx, exact (noncol_in31 hbac) ((seg_in_line c b) hx.2),
have hxb : x ≠ b,
intro hf, rw hf at hx, exact (noncol_in13 habd) hx.1,
have hxc : x ≠ c,
intro hf, rw hf at hx, exact (noncol_in13 hacd) hx.1,
cases (line_separation (col_in12' hx.1) had.symm hxa).1,
rw seg_symm, exact ⟨x, by {left, exact h}, hx.2⟩,
{ have h₁ : diff_side_line (a-ₗc) d x,
apply diff_side_pt_line h (line_in_lines hac) (pt_left_in_line a c) (noncol_in12 hacd),
exact noncol_in13 (col_noncol (diff_side_pt_col h) (noncol23 hacd) hxa.symm),
have h₂ : same_side_line (a-ₗc) d x,
apply same_side_line_symm,
apply same_side_line_trans (line_in_lines hac) _ hd.2,
apply same_side_line_symm,
exact t_shape_seg (noncol123 hbac) x (seg_in_neq hxc hxb hx.2),
rw ←not_diff_side_line at h₂, exact absurd h₁ h₂,
exact noncol_in12 hacd, exact h₁.2.2 } },
{ cases h with x hx,
have hxa : x ≠ a,
intro hf, rw hf at hx, exact (noncol_in23 haeb) ((seg_in_line e b) hx.2),
have hxb : x ≠ b,
intro hf, rw hf at hx, exact (noncol_in13 habd) hx.1,
have hxe : x ≠ e,
intro hf, rw hf at hx, exact (noncol_in13 haed) hx.1,
cases (line_separation (col_in12' hx.1) had.symm hxa).1,
{ have h₁ : same_side_line (a-ₗb) c x,
apply same_side_line_trans (line_in_lines hab) hd.1,
rw line_symm,
exact t_shape_ray (noncol12 habd) h,
have h₂ : diff_side_line (a-ₗb) c x,
apply diff_same_side_line (line_in_lines hab),
{ apply diff_side_pt_line, exact (between_diff_side_pt.1 hcae),
exact line_in_lines hab, exact pt_left_in_line a b,
exact noncol_in21 hbac, exact noncol_in13 haeb },
{ apply t_shape_seg (noncol23 haeb),
rw seg_symm at hx, exact (seg_in_neq hxb hxe hx.2) },
rw ←not_same_side_line at h₂, exact absurd h₁ h₂,
exact noncol_in21 hbac, exact (same_side_line_notin h₁).2 },
{ have h₁ : diff_side_line (a-ₗc) d x,
apply diff_side_pt_line h (line_in_lines hac) (pt_left_in_line a c) (noncol_in12 hacd),
exact noncol_in13 (col_noncol (diff_side_pt_col h) (noncol23 hacd) hxa.symm),
have h₂ : same_side_line (a-ₗc) d x,
apply same_side_line_trans (line_in_lines hac) (same_side_line_symm hd.2),
rw two_pt_one_line (line_in_lines hac) (line_in_lines hae) hac (pt_left_in_line a c)
(pt_right_in_line a c) (pt_left_in_line a e) (col_in23 (between_col hcae) hae),
exact t_shape_seg haeb x (seg_in_neq hxe hxb hx.2),
rw ←not_diff_side_line at h₂, exact absurd h₁ h₂,
exact noncol_in12 hacd, exact h₁.2.2 } }
end
lemma ray_inside_ang {a o b p q : pts} :
inside_ang p (∠ a o b) → same_side_pt o p q → inside_ang q (∠ a o b) :=
begin
intros hp hopq,
have haob := ang_proper_iff_noncol.1 (inside_ang_proper hp),
rw inside_three_pt_ang at hp, rw inside_three_pt_ang,
have hoa := (noncol_neq haob).1.symm,
have hob := (noncol_neq haob).2.2,
split,
{ apply same_side_line_trans (line_in_lines hoa) hp.1,
rw line_symm, apply t_shape_ray,
exact noncol12 (same_side_line_noncol hp.1 hoa).2,
exact hopq },
{ apply same_side_line_trans (line_in_lines hob) hp.2,
rw line_symm, apply t_shape_ray,
exact noncol12 (same_side_line_noncol hp.2 hob).2,
exact hopq }
end
/--Two proper angs are supplementary if their shares one common ray and the other two
rays lie on the same line in opposite sides. -/
def supplementary (α β : ang) : Prop :=
(∃ a b c d : pts, α = ∠ b a c ∧ β = ∠ b a d ∧ between c a d)
∧ ang_proper α ∧ ang_proper β
lemma supplementary_symm {α β : ang} : supplementary α β ↔ supplementary β α :=
begin
split; rintros ⟨⟨a, b, c, d, hbac, hbad, hcad⟩, h₁, h₂⟩;
exact ⟨⟨a, b, d, c, hbad, hbac, by {rw between_symm, exact hcad}⟩, h₂, h₁⟩,
end
lemma three_pt_ang_supplementary {a b c d : pts} :
supplementary (∠b a c) (∠b a d) ↔ between c a d ∧ noncol b a c ∧ noncol b a d :=
begin
split,
{ rintros ⟨⟨a', b', c', d', hbac, hbad, hc'a'd'⟩, h₁, h₂⟩,
have h₁' : ang_proper (∠ b' a' c'),
rw ←hbac, exact h₁,
have h₂' : ang_proper (∠ b' a' d'),
rw ←hbad, exact h₂,
rw ang_proper_iff_noncol at h₁ h₁' h₂ h₂',
have haa' := ((three_pt_ang_eq_iff h₁).1 hbac).1,
rw ←haa' at hc'a'd',
cases ((three_pt_ang_eq_iff h₁).1 hbac).2 with H₁ H₁;
cases ((three_pt_ang_eq_iff h₂).1 hbad).2 with H₂ H₂,
{ have had'c := diff_same_side_pt (between_diff_side_pt.1 hc'a'd') (same_side_pt_symm H₁.2),
have hacd := diff_same_side_pt had'c (same_side_pt_symm H₂.2),
exact ⟨between_diff_side_pt.2 hacd, h₁, h₂⟩ },
{ have had'c := diff_same_side_pt (between_diff_side_pt.1 hc'a'd') (same_side_pt_symm H₁.2),
have hacb := diff_same_side_pt had'c (same_side_pt_symm H₂.1),
have hacb' := diff_same_side_pt (diff_side_pt_symm hacb) H₁.1,
have hacd := diff_same_side_pt (diff_side_pt_symm hacb') (same_side_pt_symm H₂.2),
exact ⟨between_diff_side_pt.2 hacd, h₁, h₂⟩ },
{ have had'b := diff_same_side_pt (between_diff_side_pt.1 hc'a'd') (same_side_pt_symm H₁.1),
have had'b' := diff_same_side_pt (diff_side_pt_symm had'b) H₂.1,
have hab'd := diff_same_side_pt had'b' (same_side_pt_symm H₂.2),
have hadc := diff_same_side_pt hab'd (same_side_pt_symm H₁.2),
exact ⟨between_diff_side_pt.2 (diff_side_pt_symm hadc), h₁, h₂⟩ },
{ have had'b := diff_same_side_pt (between_diff_side_pt.1 hc'a'd') (same_side_pt_symm H₁.1),
rw ←not_same_side_pt at had'b, exact absurd (same_side_pt_symm H₂.1) had'b,
exact diff_side_pt_col had'b, exact had'b.2.1, exact had'b.2.2 } },
rintros ⟨hcad, hbac, hbad⟩,
use [a, b, c, d],
exact ⟨rfl, rfl, hcad⟩,
rw [ang_proper_iff_noncol, ang_proper_iff_noncol], exact ⟨hbac, hbad⟩
end
lemma inside_ang_trans {a b c d e : pts} :
inside_ang d (∠ b a c) → inside_ang e (∠ b a d) → inside_ang e (∠ b a c) :=
begin
intros hd he,
have hbac := ang_proper_iff_noncol.1 (inside_ang_proper hd),
have hab := (noncol_neq hbac).1.symm,
have hac := (noncol_neq hbac).2.2,
have hbc := (noncol_neq hbac).2.1,
cases crossbar hd with d' hd',
rw inside_three_pt_ang at hd,
have hd'a : d' ≠ a,
intro hf, rw hf at hd', exact (noncol_in13 hbac) ((seg_in_line b c) hd'.2),
have hd'b : d' ≠ b,
intro hf, rw hf at hd',
exact (noncol_in13 (same_side_line_noncol hd.1 hab).2) ((ray_in_line a d) hd'.1),
have hd'c : d' ≠ c,
intro hf, rw hf at hd',
exact (noncol_in13 (same_side_line_noncol hd.2 hac).2) ((ray_in_line a d) hd'.1),
have hadd' := ray_in_neq hd'a hd'.1,
have hbd'c := seg_in_neq hd'b hd'c hd'.2,
rw ang_eq_same_side_pt b hadd' at he,
cases crossbar he with e' he',
have he'a : e' ≠ a,
intro hf, rw hf at he',
exact noncol_in13 (ang_proper_iff_noncol.1 (inside_ang_proper he))
((seg_in_line b d') he'.2),
have he'b : e' ≠ b,
intro hf, rw hf at he',
exact noncol_in21 (ang_proper_iff_noncol.1 (inside_ang_proper' he).1)
((ray_in_line a e) he'.1),
have he'd' : e' ≠ d',
intro hf, rw hf at he',
exact noncol_in21 (ang_proper_iff_noncol.1 (inside_ang_proper' he).2)
((ray_in_line a e) he'.1),
have haee' := ray_in_neq he'a he'.1,
have hbe'c := seg_in_neq he'b he'd' he'.2,
apply ray_inside_ang _ (same_side_pt_symm haee'),
apply hypo_inside_ang hbac,
rw between_symm at hbd'c hbe'c,
rw between_symm,
exact (between_trans' hbd'c hbe'c).2
end
lemma inside_ang_trans' {a o b c d : pts} (hboc : between b o c) :
inside_ang d (∠ a o b) → inside_ang a (∠ d o c) :=
begin
have hoc := (between_neq hboc).2.2,
intro hd,
have haob := ang_proper_iff_noncol.1 (inside_ang_proper hd),
have hao := (noncol_neq haob).1,
have hob := (noncol_neq haob).2.2,
rw inside_three_pt_ang at *,
split,
{ have hoad := (same_side_line_noncol hd.1 hao.symm).2,
have hobd := (same_side_line_noncol hd.2 hob).2,
have hocd := col_noncol (col12 (between_col hboc)) hobd hoc,
have hod := (noncol_neq hocd).2.1,
have h₁ : diff_side_line (o-ₗd) a b,
cases crossbar (inside_three_pt_ang.2 hd) with e he,
use e, exact ⟨(ray_in_line o d) he.1, he.2⟩,
exact ⟨noncol_in13 hoad, noncol_in13 hobd⟩,
have h₂ : diff_side_line (o-ₗd) b c,
have hdo := (same_side_line_neq' hd.1).1,
apply diff_side_pt_line (between_diff_side_pt.1 hboc)
(line_in_lines hdo.symm) (pt_left_in_line o d) (noncol_in13 hobd) (noncol_in13 hocd),
exact same_side_line_symm (diff_side_line_cancel (line_in_lines hod) h₁ h₂) },
{ rw two_pt_one_line (line_in_lines hoc) (line_in_lines hob) hob (pt_left_in_line o c)
(col_in23 (between_col hboc) hoc) (pt_left_in_line o b) (pt_right_in_line o b),
exact same_side_line_symm hd.2 }
end |
2273259e73fba664374ddce4ecbd0573e4acf8d2 | 57c233acf9386e610d99ed20ef139c5f97504ba3 | /src/category_theory/abelian/basic.lean | 1507c7ceae2d2212b6b2a177fc96086ef8736460 | [
"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 | 26,148 | lean | /-
Copyright (c) 2020 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import category_theory.limits.constructions.pullbacks
import category_theory.limits.shapes.biproducts
import category_theory.limits.shapes.images
import category_theory.limits.constructions.limits_of_products_and_equalizers
import category_theory.abelian.non_preadditive
/-!
# Abelian categories
This file contains the definition and basic properties of abelian categories.
There are many definitions of abelian category. Our definition is as follows:
A category is called abelian if it is preadditive,
has a finite products, kernels and cokernels,
and if every monomorphism and epimorphism is normal.
It should be noted that if we also assume coproducts, then preadditivity is
actually a consequence of the other properties, as we show in
`non_preadditive_abelian.lean`. However, this fact is of little practical
relevance, since essentially all interesting abelian categories come with a
preadditive structure. In this way, by requiring preadditivity, we allow the
user to pass in the preadditive structure the specific category they are
working with has natively.
## Main definitions
* `abelian` is the type class indicating that a category is abelian. It extends `preadditive`.
* `abelian.image f` is `kernel (cokernel.π f)`, and
* `abelian.coimage f` is `cokernel (kernel.ι f)`.
## Main results
* In an abelian category, mono + epi = iso.
* If `f : X ⟶ Y`, then the map `factor_thru_image f : X ⟶ image f` is an epimorphism, and the map
`factor_thru_coimage f : coimage f ⟶ Y` is a monomorphism.
* Factoring through the image and coimage is a strong epi-mono factorisation. This means that
* every abelian category has images. We instantiated this in such a way that `abelian.image f` is
definitionally equal to `limits.image f`, and
* there is a canonical isomorphism `coimage_iso_image : coimage f ≅ image f` such that
`coimage.π f ≫ (coimage_iso_image f).hom ≫ image.ι f = f`. The lemma stating this is called
`full_image_factorisation`.
* Every epimorphism is a cokernel of its kernel. Every monomorphism is a kernel of its cokernel.
* The pullback of an epimorphism is an epimorphism. The pushout of a monomorphism is a monomorphism.
(This is not to be confused with the fact that the pullback of a monomorphism is a monomorphism,
which is true in any category).
## Implementation notes
The typeclass `abelian` does not extend `non_preadditive_abelian`,
to avoid having to deal with comparing the two `has_zero_morphisms` instances
(one from `preadditive` in `abelian`, and the other a field of `non_preadditive_abelian`).
As a consequence, at the beginning of this file we trivially build
a `non_preadditive_abelian` instance from an `abelian` instance,
and use this to restate a number of theorems,
in each case just reusing the proof from `non_preadditive_abelian.lean`.
We don't show this yet, but abelian categories are finitely complete and finitely cocomplete.
However, the limits we can construct at this level of generality will most likely be less nice than
the ones that can be created in specific applications. For this reason, we adopt the following
convention:
* If the statement of a theorem involves limits, the existence of these limits should be made an
explicit typeclass parameter.
* If a limit only appears in a proof, but not in the statement of a theorem, the limit should not
be a typeclass parameter, but instead be created using `abelian.has_pullbacks` or a similar
definition.
## References
* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]
* [P. Aluffi, *Algebra: Chaper 0*][aluffi2016]
-/
noncomputable theory
open category_theory
open category_theory.preadditive
open category_theory.limits
universes v u
namespace category_theory
variables {C : Type u} [category.{v} C]
variables (C)
/--
A (preadditive) category `C` is called abelian if it has all finite products,
all kernels and cokernels, and if every monomorphism is the kernel of some morphism
and every epimorphism is the cokernel of some morphism.
(This definition implies the existence of zero objects:
finite products give a terminal object, and in a preadditive category
any terminal object is a zero object.)
-/
class abelian extends preadditive C :=
[has_finite_products : has_finite_products C]
[has_kernels : has_kernels C]
[has_cokernels : has_cokernels C]
(normal_mono : Π {X Y : C} (f : X ⟶ Y) [mono f], normal_mono f)
(normal_epi : Π {X Y : C} (f : X ⟶ Y) [epi f], normal_epi f)
attribute [instance, priority 100] abelian.has_finite_products
attribute [instance, priority 100] abelian.has_kernels abelian.has_cokernels
end category_theory
open category_theory
namespace category_theory.abelian
variables {C : Type u} [category.{v} C] [abelian C]
/-- An abelian category has finite biproducts. -/
@[priority 100]
instance has_finite_biproducts : has_finite_biproducts C :=
limits.has_finite_biproducts.of_has_finite_products
@[priority 100]
instance has_binary_biproducts : has_binary_biproducts C :=
limits.has_binary_biproducts_of_finite_biproducts _
@[priority 100]
instance has_zero_object : has_zero_object C :=
has_zero_object_of_has_initial_object
section to_non_preadditive_abelian
/-- Every abelian category is, in particular, `non_preadditive_abelian`. -/
def non_preadditive_abelian : non_preadditive_abelian C := { ..‹abelian C› }
end to_non_preadditive_abelian
section strong
local attribute [instance] abelian.normal_epi abelian.normal_mono
/-- In an abelian category, every epimorphism is strong. -/
lemma strong_epi_of_epi {P Q : C} (f : P ⟶ Q) [epi f] : strong_epi f := by apply_instance
/-- In an abelian category, every monomorphism is strong. -/
lemma strong_mono_of_mono {P Q : C} (f : P ⟶ Q) [mono f] : strong_mono f := by apply_instance
end strong
section mono_epi_iso
variables {X Y : C} (f : X ⟶ Y)
local attribute [instance] strong_epi_of_epi
/-- In an abelian category, a monomorphism which is also an epimorphism is an isomorphism. -/
lemma is_iso_of_mono_of_epi [mono f] [epi f] : is_iso f :=
is_iso_of_mono_of_strong_epi _
end mono_epi_iso
section factor
local attribute [instance] non_preadditive_abelian
variables {P Q : C} (f : P ⟶ Q)
section
lemma mono_of_zero_kernel (R : C)
(l : is_limit (kernel_fork.of_ι (0 : R ⟶ P) (show 0 ≫ f = 0, by simp))) : mono f :=
non_preadditive_abelian.mono_of_zero_kernel _ _ l
lemma mono_of_kernel_ι_eq_zero (h : kernel.ι f = 0) : mono f :=
mono_of_kernel_zero h
lemma epi_of_zero_cokernel (R : C)
(l : is_colimit (cokernel_cofork.of_π (0 : Q ⟶ R) (show f ≫ 0 = 0, by simp))) : epi f :=
non_preadditive_abelian.epi_of_zero_cokernel _ _ l
lemma epi_of_cokernel_π_eq_zero (h : cokernel.π f = 0) : epi f :=
begin
apply epi_of_zero_cokernel _ (cokernel f),
simp_rw ←h,
exact is_colimit.of_iso_colimit (colimit.is_colimit (parallel_pair f 0)) (iso_of_π _)
end
end
namespace images
/-- The kernel of the cokernel of `f` is called the image of `f`. -/
protected abbreviation image : C := kernel (cokernel.π f)
/-- The inclusion of the image into the codomain. -/
protected abbreviation image.ι : images.image f ⟶ Q :=
kernel.ι (cokernel.π f)
/-- There is a canonical epimorphism `p : P ⟶ image f` for every `f`. -/
protected abbreviation factor_thru_image : P ⟶ images.image f :=
kernel.lift (cokernel.π f) f $ cokernel.condition f
/-- `f` factors through its image via the canonical morphism `p`. -/
@[simp, reassoc] protected lemma image.fac :
images.factor_thru_image f ≫ image.ι f = f :=
kernel.lift_ι _ _ _
/-- The map `p : P ⟶ image f` is an epimorphism -/
instance : epi (images.factor_thru_image f) :=
show epi (non_preadditive_abelian.factor_thru_image f), by apply_instance
section
variables {f}
lemma image_ι_comp_eq_zero {R : C} {g : Q ⟶ R} (h : f ≫ g = 0) : images.image.ι f ≫ g = 0 :=
zero_of_epi_comp (images.factor_thru_image f) $ by simp [h]
end
instance mono_factor_thru_image [mono f] : mono (images.factor_thru_image f) :=
mono_of_mono_fac $ image.fac f
instance is_iso_factor_thru_image [mono f] : is_iso (images.factor_thru_image f) :=
is_iso_of_mono_of_epi _
/-- Factoring through the image is a strong epi-mono factorisation. -/
@[simps] def image_strong_epi_mono_factorisation : strong_epi_mono_factorisation f :=
{ I := images.image f,
m := image.ι f,
m_mono := by apply_instance,
e := images.factor_thru_image f,
e_strong_epi := strong_epi_of_epi _ }
end images
namespace coimages
/-- The cokernel of the kernel of `f` is called the coimage of `f`. -/
protected abbreviation coimage : C := cokernel (kernel.ι f)
/-- The projection onto the coimage. -/
protected abbreviation coimage.π : P ⟶ coimages.coimage f :=
cokernel.π (kernel.ι f)
/-- There is a canonical monomorphism `i : coimage f ⟶ Q`. -/
protected abbreviation factor_thru_coimage : coimages.coimage f ⟶ Q :=
cokernel.desc (kernel.ι f) f $ kernel.condition f
/-- `f` factors through its coimage via the canonical morphism `p`. -/
protected lemma coimage.fac : coimage.π f ≫ coimages.factor_thru_coimage f = f :=
cokernel.π_desc _ _ _
/-- The canonical morphism `i : coimage f ⟶ Q` is a monomorphism -/
instance : mono (coimages.factor_thru_coimage f) :=
show mono (non_preadditive_abelian.factor_thru_coimage f), by apply_instance
section
variables {f}
lemma comp_coimage_π_eq_zero {R : C} {g : Q ⟶ R} (h : f ≫ g = 0) : f ≫ coimages.coimage.π g = 0 :=
zero_of_comp_mono (coimages.factor_thru_coimage g) $ by simp [h]
end
instance epi_factor_thru_coimage [epi f] : epi (coimages.factor_thru_coimage f) :=
epi_of_epi_fac $ coimage.fac f
instance is_iso_factor_thru_coimage [epi f] : is_iso (coimages.factor_thru_coimage f) :=
is_iso_of_mono_of_epi _
/-- Factoring through the coimage is a strong epi-mono factorisation. -/
@[simps] def coimage_strong_epi_mono_factorisation : strong_epi_mono_factorisation f :=
{ I := coimages.coimage f,
m := coimages.factor_thru_coimage f,
m_mono := by apply_instance,
e := coimage.π f,
e_strong_epi := strong_epi_of_epi _ }
end coimages
end factor
section has_strong_epi_mono_factorisations
/-- An abelian category has strong epi-mono factorisations. -/
@[priority 100] instance : has_strong_epi_mono_factorisations C :=
has_strong_epi_mono_factorisations.mk $ λ X Y f, images.image_strong_epi_mono_factorisation f
/- In particular, this means that it has well-behaved images. -/
example : has_images C := by apply_instance
example : has_image_maps C := by apply_instance
end has_strong_epi_mono_factorisations
section images
variables {X Y : C} (f : X ⟶ Y)
/-- There is a canonical isomorphism between the coimage and the image of a morphism. -/
abbreviation coimage_iso_image : coimages.coimage f ≅ images.image f :=
is_image.iso_ext (coimages.coimage_strong_epi_mono_factorisation f).to_mono_is_image
(images.image_strong_epi_mono_factorisation f).to_mono_is_image
/-- There is a canonical isomorphism between the abelian image and the categorical image of a
morphism. -/
abbreviation image_iso_image : images.image f ≅ image f :=
is_image.iso_ext (images.image_strong_epi_mono_factorisation f).to_mono_is_image (image.is_image f)
/-- There is a canonical isomorphism between the abelian coimage and the categorical image of a
morphism. -/
abbreviation coimage_iso_image' : coimages.coimage f ≅ image f :=
is_image.iso_ext (coimages.coimage_strong_epi_mono_factorisation f).to_mono_is_image
(image.is_image f)
lemma full_image_factorisation : coimages.coimage.π f ≫ (coimage_iso_image f).hom ≫
images.image.ι f = f :=
by rw [limits.is_image.iso_ext_hom,
←images.image_strong_epi_mono_factorisation_to_mono_factorisation_m, is_image.lift_fac,
coimages.coimage_strong_epi_mono_factorisation_to_mono_factorisation_m, coimages.coimage.fac]
end images
section cokernel_of_kernel
variables {X Y : C} {f : X ⟶ Y}
local attribute [instance] non_preadditive_abelian
/-- In an abelian category, an epi is the cokernel of its kernel. More precisely:
If `f` is an epimorphism and `s` is some limit kernel cone on `f`, then `f` is a cokernel
of `fork.ι s`. -/
def epi_is_cokernel_of_kernel [epi f] (s : fork f 0) (h : is_limit s) :
is_colimit (cokernel_cofork.of_π f (kernel_fork.condition s)) :=
non_preadditive_abelian.epi_is_cokernel_of_kernel s h
/-- In an abelian category, a mono is the kernel of its cokernel. More precisely:
If `f` is a monomorphism and `s` is some colimit cokernel cocone on `f`, then `f` is a kernel
of `cofork.π s`. -/
def mono_is_kernel_of_cokernel [mono f] (s : cofork f 0) (h : is_colimit s) :
is_limit (kernel_fork.of_ι f (cokernel_cofork.condition s)) :=
non_preadditive_abelian.mono_is_kernel_of_cokernel s h
end cokernel_of_kernel
section
@[priority 100]
instance has_equalizers : has_equalizers C :=
preadditive.has_equalizers_of_has_kernels
/-- Any abelian category has pullbacks -/
@[priority 100]
instance has_pullbacks : has_pullbacks C :=
has_pullbacks_of_has_binary_products_of_has_equalizers C
end
section
@[priority 100]
instance has_coequalizers : has_coequalizers C :=
preadditive.has_coequalizers_of_has_cokernels
/-- Any abelian category has pushouts -/
@[priority 100]
instance has_pushouts : has_pushouts C :=
has_pushouts_of_has_binary_coproducts_of_has_coequalizers C
@[priority 100]
instance has_finite_limits : has_finite_limits C :=
limits.finite_limits_from_equalizers_and_finite_products
@[priority 100]
instance has_finite_colimits : has_finite_colimits C :=
limits.finite_colimits_from_coequalizers_and_finite_coproducts
end
namespace pullback_to_biproduct_is_kernel
variables [limits.has_pullbacks C] {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)
/-! This section contains a slightly technical result about pullbacks and biproducts.
We will need it in the proof that the pullback of an epimorphism is an epimorpism. -/
/-- The canonical map `pullback f g ⟶ X ⊞ Y` -/
abbreviation pullback_to_biproduct : pullback f g ⟶ X ⊞ Y :=
biprod.lift pullback.fst pullback.snd
/-- The canonical map `pullback f g ⟶ X ⊞ Y` induces a kernel cone on the map
`biproduct X Y ⟶ Z` induced by `f` and `g`. A slightly more intuitive way to think of
this may be that it induces an equalizer fork on the maps induced by `(f, 0)` and
`(0, g)`. -/
abbreviation pullback_to_biproduct_fork : kernel_fork (biprod.desc f (-g)) :=
kernel_fork.of_ι (pullback_to_biproduct f g) $
by rw [biprod.lift_desc, comp_neg, pullback.condition, add_right_neg]
/-- The canonical map `pullback f g ⟶ X ⊞ Y` is a kernel of the map induced by
`(f, -g)`. -/
def is_limit_pullback_to_biproduct : is_limit (pullback_to_biproduct_fork f g) :=
fork.is_limit.mk _
(λ s, pullback.lift (fork.ι s ≫ biprod.fst) (fork.ι s ≫ biprod.snd) $
sub_eq_zero.1 $ by rw [category.assoc, category.assoc, ←comp_sub, sub_eq_add_neg, ←comp_neg,
←biprod.desc_eq, kernel_fork.condition s])
(λ s,
begin
ext; rw [fork.ι_of_ι, category.assoc],
{ rw [biprod.lift_fst, pullback.lift_fst] },
{ rw [biprod.lift_snd, pullback.lift_snd] }
end)
(λ s m h, by ext; simp [fork.ι_eq_app_zero, ←h walking_parallel_pair.zero])
end pullback_to_biproduct_is_kernel
namespace biproduct_to_pushout_is_cokernel
variables [limits.has_pushouts C] {W X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z)
/-- The canonical map `Y ⊞ Z ⟶ pushout f g` -/
abbreviation biproduct_to_pushout : Y ⊞ Z ⟶ pushout f g :=
biprod.desc pushout.inl pushout.inr
/-- The canonical map `Y ⊞ Z ⟶ pushout f g` induces a cokernel cofork on the map
`X ⟶ Y ⊞ Z` induced by `f` and `-g`. -/
abbreviation biproduct_to_pushout_cofork : cokernel_cofork (biprod.lift f (-g)) :=
cokernel_cofork.of_π (biproduct_to_pushout f g) $
by rw [biprod.lift_desc, neg_comp, pushout.condition, add_right_neg]
/-- The cofork induced by the canonical map `Y ⊞ Z ⟶ pushout f g` is in fact a colimit cokernel
cofork. -/
def is_colimit_biproduct_to_pushout : is_colimit (biproduct_to_pushout_cofork f g) :=
cofork.is_colimit.mk _
(λ s, pushout.desc (biprod.inl ≫ cofork.π s) (biprod.inr ≫ cofork.π s) $
sub_eq_zero.1 $ by rw [←category.assoc, ←category.assoc, ←sub_comp, sub_eq_add_neg, ←neg_comp,
←biprod.lift_eq, cofork.condition s, zero_comp])
(λ s, by ext; simp)
(λ s m h, by ext; simp [cofork.π_eq_app_one, ←h walking_parallel_pair.one] )
end biproduct_to_pushout_is_cokernel
section epi_pullback
variables [limits.has_pullbacks C] {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)
/-- In an abelian category, the pullback of an epimorphism is an epimorphism.
Proof from [aluffi2016, IX.2.3], cf. [borceux-vol2, 1.7.6] -/
instance epi_pullback_of_epi_f [epi f] : epi (pullback.snd : pullback f g ⟶ Y) :=
-- It will suffice to consider some morphism e : Y ⟶ R such that
-- pullback.snd ≫ e = 0 and show that e = 0.
epi_of_cancel_zero _ $ λ R e h,
begin
-- Consider the morphism u := (0, e) : X ⊞ Y⟶ R.
let u := biprod.desc (0 : X ⟶ R) e,
-- The composite pullback f g ⟶ X ⊞ Y ⟶ R is zero by assumption.
have hu : pullback_to_biproduct_is_kernel.pullback_to_biproduct f g ≫ u = 0 := by simpa,
-- pullback_to_biproduct f g is a kernel of (f, -g), so (f, -g) is a
-- cokernel of pullback_to_biproduct f g
have := epi_is_cokernel_of_kernel _
(pullback_to_biproduct_is_kernel.is_limit_pullback_to_biproduct f g),
-- We use this fact to obtain a factorization of u through (f, -g) via some d : Z ⟶ R.
obtain ⟨d, hd⟩ := cokernel_cofork.is_colimit.desc' this u hu,
change Z ⟶ R at d,
change biprod.desc f (-g) ≫ d = u at hd,
-- But then f ≫ d = 0:
have : f ≫ d = 0, calc
f ≫ d = (biprod.inl ≫ biprod.desc f (-g)) ≫ d : by rw biprod.inl_desc
... = biprod.inl ≫ u : by rw [category.assoc, hd]
... = 0 : biprod.inl_desc _ _,
-- But f is an epimorphism, so d = 0...
have : d = 0 := (cancel_epi f).1 (by simpa),
-- ...or, in other words, e = 0.
calc
e = biprod.inr ≫ u : by rw biprod.inr_desc
... = biprod.inr ≫ biprod.desc f (-g) ≫ d : by rw ←hd
... = biprod.inr ≫ biprod.desc f (-g) ≫ 0 : by rw this
... = (biprod.inr ≫ biprod.desc f (-g)) ≫ 0 : by rw ←category.assoc
... = 0 : has_zero_morphisms.comp_zero _ _
end
/-- In an abelian category, the pullback of an epimorphism is an epimorphism. -/
instance epi_pullback_of_epi_g [epi g] : epi (pullback.fst : pullback f g ⟶ X) :=
-- It will suffice to consider some morphism e : X ⟶ R such that
-- pullback.fst ≫ e = 0 and show that e = 0.
epi_of_cancel_zero _ $ λ R e h,
begin
-- Consider the morphism u := (e, 0) : X ⊞ Y ⟶ R.
let u := biprod.desc e (0 : Y ⟶ R),
-- The composite pullback f g ⟶ X ⊞ Y ⟶ R is zero by assumption.
have hu : pullback_to_biproduct_is_kernel.pullback_to_biproduct f g ≫ u = 0 := by simpa,
-- pullback_to_biproduct f g is a kernel of (f, -g), so (f, -g) is a
-- cokernel of pullback_to_biproduct f g
have := epi_is_cokernel_of_kernel _
(pullback_to_biproduct_is_kernel.is_limit_pullback_to_biproduct f g),
-- We use this fact to obtain a factorization of u through (f, -g) via some d : Z ⟶ R.
obtain ⟨d, hd⟩ := cokernel_cofork.is_colimit.desc' this u hu,
change Z ⟶ R at d,
change biprod.desc f (-g) ≫ d = u at hd,
-- But then (-g) ≫ d = 0:
have : (-g) ≫ d = 0, calc
(-g) ≫ d = (biprod.inr ≫ biprod.desc f (-g)) ≫ d : by rw biprod.inr_desc
... = biprod.inr ≫ u : by rw [category.assoc, hd]
... = 0 : biprod.inr_desc _ _,
-- But g is an epimorphism, thus so is -g, so d = 0...
have : d = 0 := (cancel_epi (-g)).1 (by simpa),
-- ...or, in other words, e = 0.
calc
e = biprod.inl ≫ u : by rw biprod.inl_desc
... = biprod.inl ≫ biprod.desc f (-g) ≫ d : by rw ←hd
... = biprod.inl ≫ biprod.desc f (-g) ≫ 0 : by rw this
... = (biprod.inl ≫ biprod.desc f (-g)) ≫ 0 : by rw ←category.assoc
... = 0 : has_zero_morphisms.comp_zero _ _
end
lemma epi_snd_of_is_limit [epi f] {s : pullback_cone f g} (hs : is_limit s) : epi s.snd :=
begin
convert epi_of_epi_fac (is_limit.cone_point_unique_up_to_iso_hom_comp (limit.is_limit _) hs _),
{ refl },
{ exact abelian.epi_pullback_of_epi_f _ _ }
end
lemma epi_fst_of_is_limit [epi g] {s : pullback_cone f g} (hs : is_limit s) : epi s.fst :=
begin
convert epi_of_epi_fac (is_limit.cone_point_unique_up_to_iso_hom_comp (limit.is_limit _) hs _),
{ refl },
{ exact abelian.epi_pullback_of_epi_g _ _ }
end
/-- Suppose `f` and `g` are two morphisms with a common codomain and suppose we have written `g` as
an epimorphism followed by a monomorphism. If `f` factors through the mono part of this
factorization, then any pullback of `g` along `f` is an epimorphism. -/
lemma epi_fst_of_factor_thru_epi_mono_factorization
(g₁ : Y ⟶ W) [epi g₁] (g₂ : W ⟶ Z) [mono g₂] (hg : g₁ ≫ g₂ = g) (f' : X ⟶ W) (hf : f' ≫ g₂ = f)
(t : pullback_cone f g) (ht : is_limit t) : epi t.fst :=
by apply epi_fst_of_is_limit _ _ (pullback_cone.is_limit_of_factors f g g₂ f' g₁ hf hg t ht)
end epi_pullback
section mono_pushout
variables [limits.has_pushouts C] {W X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z)
instance mono_pushout_of_mono_f [mono f] : mono (pushout.inr : Z ⟶ pushout f g) :=
mono_of_cancel_zero _ $ λ R e h,
begin
let u := biprod.lift (0 : R ⟶ Y) e,
have hu : u ≫ biproduct_to_pushout_is_cokernel.biproduct_to_pushout f g = 0 := by simpa,
have := mono_is_kernel_of_cokernel _
(biproduct_to_pushout_is_cokernel.is_colimit_biproduct_to_pushout f g),
obtain ⟨d, hd⟩ := kernel_fork.is_limit.lift' this u hu,
change R ⟶ X at d,
change d ≫ biprod.lift f (-g) = u at hd,
have : d ≫ f = 0, calc
d ≫ f = d ≫ biprod.lift f (-g) ≫ biprod.fst : by rw biprod.lift_fst
... = u ≫ biprod.fst : by rw [←category.assoc, hd]
... = 0 : biprod.lift_fst _ _,
have : d = 0 := (cancel_mono f).1 (by simpa),
calc
e = u ≫ biprod.snd : by rw biprod.lift_snd
... = (d ≫ biprod.lift f (-g)) ≫ biprod.snd : by rw ←hd
... = (0 ≫ biprod.lift f (-g)) ≫ biprod.snd : by rw this
... = 0 ≫ biprod.lift f (-g) ≫ biprod.snd : by rw category.assoc
... = 0 : zero_comp
end
instance mono_pushout_of_mono_g [mono g] : mono (pushout.inl : Y ⟶ pushout f g) :=
mono_of_cancel_zero _ $ λ R e h,
begin
let u := biprod.lift e (0 : R ⟶ Z),
have hu : u ≫ biproduct_to_pushout_is_cokernel.biproduct_to_pushout f g = 0 := by simpa,
have := mono_is_kernel_of_cokernel _
(biproduct_to_pushout_is_cokernel.is_colimit_biproduct_to_pushout f g),
obtain ⟨d, hd⟩ := kernel_fork.is_limit.lift' this u hu,
change R ⟶ X at d,
change d ≫ biprod.lift f (-g) = u at hd,
have : d ≫ (-g) = 0, calc
d ≫ (-g) = d ≫ biprod.lift f (-g) ≫ biprod.snd : by rw biprod.lift_snd
... = u ≫ biprod.snd : by rw [←category.assoc, hd]
... = 0 : biprod.lift_snd _ _,
have : d = 0 := (cancel_mono (-g)).1 (by simpa),
calc
e = u ≫ biprod.fst : by rw biprod.lift_fst
... = (d ≫ biprod.lift f (-g)) ≫ biprod.fst : by rw ←hd
... = (0 ≫ biprod.lift f (-g)) ≫ biprod.fst : by rw this
... = 0 ≫ biprod.lift f (-g) ≫ biprod.fst : by rw category.assoc
... = 0 : zero_comp
end
lemma mono_inr_of_is_colimit [mono f] {s : pushout_cocone f g} (hs : is_colimit s) : mono s.inr :=
begin
convert mono_of_mono_fac
(is_colimit.comp_cocone_point_unique_up_to_iso_hom hs (colimit.is_colimit _) _),
{ refl },
{ exact abelian.mono_pushout_of_mono_f _ _ }
end
lemma mono_inl_of_is_colimit [mono g] {s : pushout_cocone f g} (hs : is_colimit s) : mono s.inl :=
begin
convert mono_of_mono_fac
(is_colimit.comp_cocone_point_unique_up_to_iso_hom hs (colimit.is_colimit _) _),
{ refl },
{ exact abelian.mono_pushout_of_mono_g _ _ }
end
/-- Suppose `f` and `g` are two morphisms with a common domain and suppose we have written `g` as
an epimorphism followed by a monomorphism. If `f` factors through the epi part of this
factorization, then any pushout of `g` along `f` is a monomorphism. -/
lemma mono_inl_of_factor_thru_epi_mono_factorization (f : X ⟶ Y) (g : X ⟶ Z)
(g₁ : X ⟶ W) [epi g₁] (g₂ : W ⟶ Z) [mono g₂] (hg : g₁ ≫ g₂ = g) (f' : W ⟶ Y) (hf : g₁ ≫ f' = f)
(t : pushout_cocone f g) (ht : is_colimit t) : mono t.inl :=
by apply mono_inl_of_is_colimit _ _ (pushout_cocone.is_colimit_of_factors _ _ _ _ _ hf hg t ht)
end mono_pushout
end category_theory.abelian
namespace category_theory.non_preadditive_abelian
variables (C : Type u) [category.{v} C] [non_preadditive_abelian C]
/-- Every non_preadditive_abelian category can be promoted to an abelian category. -/
def abelian : abelian C :=
{ has_finite_products := by apply_instance,
/- We need the `convert`s here because the instances we have are slightly different from the
instances we need: `has_kernels` depends on an instance of `has_zero_morphisms`. In the
case of `non_preadditive_abelian`, this instance is an explicit argument. However, in the case
of `abelian`, the `has_zero_morphisms` instance is derived from `preadditive`. So we need to
transform an instance of "has kernels with non_preadditive_abelian.has_zero_morphisms" to an
instance of "has kernels with non_preadditive_abelian.preadditive.has_zero_morphisms". Luckily,
we have a `subsingleton` instance for `has_zero_morphisms`, so `convert` can immediately close
the goal it creates for the two instances of `has_zero_morphisms`, and the proof is complete. -/
has_kernels := by convert (by apply_instance : limits.has_kernels C),
has_cokernels := by convert (by apply_instance : limits.has_cokernels C),
normal_mono := by { introsI, convert normal_mono f },
normal_epi := by { introsI, convert normal_epi f },
..non_preadditive_abelian.preadditive }
end category_theory.non_preadditive_abelian
|
beb0671c9d6dfc10e19e0480b20347caee7ea05a | 46ee5dc7248ccc9ee615639c0c003c05f58975cd | /src/tableau-examples.lean | 68f9cd998babdd076a53a5a5c0353cdf02f7b040 | [
"Apache-2.0"
] | permissive | m4lvin/tablean | e61d593b4dde6512245192c577edeb36c48f63c0 | 836202612fc2bfacb5545696412e7d27f7704141 | refs/heads/main | 1,685,613,112,076 | 1,676,755,678,000 | 1,676,755,678,000 | 454,064,275 | 8 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 4,586 | lean | -- TABLEAU-EXAMPLES
import syntax
import tableau
lemma noBot : provable (~ ⊥) :=
begin
apply provable.byTableau,
apply closedTableau.loc,
swap 2,
{
apply localTableau.byLocalRule (localRule.neg (finset.mem_singleton.mpr (refl (~~⊥)))),
intros β inB,
rw finset.sdiff_self at inB,
rw finset.empty_union at inB,
rw finset.mem_singleton at inB,
rw inB,
apply (localTableau.byLocalRule (localRule.bot (finset.mem_singleton.mpr (refl ⊥)))),
intros Y YinEmpty,
cases YinEmpty,
},
{ -- show that endNodesOf is empty
intros Y,
intro YisEndNode,
unfold endNodesOf at *,
simp at *,
exfalso,
rcases YisEndNode with ⟨a,h,hyp⟩,
subst h,
simp at *,
cases hyp,
},
end
def emptyTableau : Π (β : finset formula), β ∈ ∅ → localTableau β :=
begin
intros beta b_in_empty,
exact absurd b_in_empty (finset.not_mem_empty beta),
end
-- an example:
lemma noContradiction : provable (~ (p ⋏ ~p)) :=
begin
apply provable.byTableau,
apply closedTableau.loc,
swap 2,
{
apply localTableau.byLocalRule,
-- neg:
apply localRule.neg,
simp,
intros β β_prop,
simp at β_prop,
subst β_prop,
-- con:
apply localTableau.byLocalRule,
apply localRule.con,
simp,
split,
refl,
refl,
intros β2 β2_prop,
simp at β2_prop,
subst β2_prop,
-- closed:
apply localTableau.byLocalRule (@localRule.not _ p _) emptyTableau,
exact dec_trivial,
},
{ -- show that endNodesOf is empty
intros Y,
intro YisEndNode,
simp at *,
exfalso,
rcases YisEndNode with ⟨a,h,hyp⟩,
subst h,
simp at *,
rcases hyp with ⟨Y,Ydef,YinEndNodes⟩,
subst Ydef,
finish,
},
end
-- preparing example 2
def subTabForEx2 : closedTableau {r, ~□p, □(p ⋏ q)} :=
begin
apply @closedTableau.atm {r, ~□p, □(p ⋏ q)} p (by {simp,}),
-- show that this set is simple:
{ unfold simple, simp at *, tauto, },
apply closedTableau.loc,
rotate,
-- con:
apply localTableau.byLocalRule (@localRule.con {p⋏q, ~p} p q (by {simp, })),
intros child childDef,
rw finset.mem_singleton at childDef,
-- not:
apply localTableau.byLocalRule (@localRule.not _ p _) emptyTableau,
{ subst childDef, exact dec_trivial, },
{ -- show that endNodesOf is empty
intros Y,
intro YisEndNode,
simp at *,
exfalso,
assumption,
},
end
-- Example 2
example : closedTableau { r ⋏ ~□p, r ↣ □(p ⋏ q) } :=
begin
apply closedTableau.loc,
rotate,
{ -- con
apply localTableau.byLocalRule,
apply localRule.con,
simp only [impl, finset.mem_insert, finset.mem_singleton, or_false],
split,
refl,
refl,
intros branch branch_def,
rw finset.mem_singleton at branch_def,
rw finset.union_insert at branch_def,
-- nCo
apply localTableau.byLocalRule,
apply @localRule.nCo _ r (~□(p ⋏ q)),
{ rw branch_def, simp, },
intros b b_in,
simp only [finset.mem_insert, finset.mem_singleton] at b_in,
refine if h1 : b = branch \ {~(r⋏~□(p⋏q))} ∪ {~r} then _ else _,
{ -- right branch
-- not:
apply localTableau.byLocalRule (@localRule.not _ r _) emptyTableau,
finish,
},
{ --left branch
have h2 : b = branch \ {~(r⋏~□(p⋏q))} ∪ {~~□(p⋏q)}, { tauto, },
-- neg:
apply localTableau.byLocalRule (@localRule.neg _ (□(p ⋏ q)) _),
rotate, {rw h2, simp,},
intros child childDef,
-- ending local tableau with a simple node:
apply localTableau.sim,
rw finset.mem_singleton at childDef,
rw childDef,
unfold simple, simp at *, split, unfold simpleForm,
intros f f_notDef1 f_in_branch,
cases b_in,
tauto,
rw b_in at f_in_branch,
simp at f_in_branch,
cases f_in_branch,
tauto,
rw branch_def at f_in_branch,
cases f_in_branch with l r, simp at r,
cases r,
{ subst r, unfold r, },
cases r,
{ subst r, unfold simpleForm, },
{ exfalso, tauto, },
},
},
{ -- tableau for the simple end nodes:
rw conEndNodes,
rw nCoEndNodes,
intros Y Yin,
simp at *,
split_ifs at *,
{ -- not-R branch
exfalso, -- show that there are no endnodes!
simp at Yin,
exact Yin,
},
{ -- notnotbranch
dedup,
have Yis : Y = {r, ~□p, □(p ⋏ q)}, {
simp at Yin,
subst Yin,
ext1,
split ; { intro hyp, finish },
},
subst Yis,
exact subTabForEx2,
},
},
end
|
e551d1014358a369b19003ea6e64d0e493388e9b | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/category_theory/adjunction/mates_auto.lean | 6d2aa68015c798e3c81c67e0de2d223f896e7a73 | [] | 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 | 12,215 | lean | /-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Bhavik Mehta
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.category_theory.adjunction.basic
import Mathlib.category_theory.conj
import Mathlib.category_theory.yoneda
import Mathlib.PostPort
universes u₁ u₂ u₃ u₄ v₁ v₂ v₃ v₄
namespace Mathlib
/-!
# Mate of natural transformations
This file establishes the bijection between the 2-cells
L₁ R₁
C --→ D C ←-- D
G ↓ ↗ ↓ H G ↓ ↘ ↓ H
E --→ F E ←-- F
L₂ R₂
where `L₁ ⊣ R₁` and `L₂ ⊣ R₂`, and shows that in the special case where `G,H` are identity then the
bijection preserves and reflects isomorphisms (i.e. we have bijections `(L₂ ⟶ L₁) ≃ (R₁ ⟶ R₂)`, and
if either side is an iso then the other side is as well).
On its own, this bijection is not particularly useful but it includes a number of interesting cases
as specializations.
For instance, this generalises the fact that adjunctions are unique (since if `L₁ ≅ L₂` then we
deduce `R₁ ≅ R₂`).
Another example arises from considering the square representing that a functor `H` preserves
products, in particular the morphism `HA ⨯ H- ⟶ H(A ⨯ -)`. Then provided `(A ⨯ -)` and `HA ⨯ -` have
left adjoints (for instance if the relevant categories are cartesian closed), the transferred
natural transformation is the exponential comparison morphism: `H(A ^ -) ⟶ HA ^ H-`.
Furthermore if `H` has a left adjoint `L`, this morphism is an isomorphism iff its mate
`L(HA ⨯ -) ⟶ A ⨯ L-` is an isomorphism, see
https://ncatlab.org/nlab/show/Frobenius+reciprocity#InCategoryTheory.
This also relates to Grothendieck's yoga of six operations, though this is not spelled out in
mathlib: https://ncatlab.org/nlab/show/six+operations.
-/
namespace category_theory
/--
Suppose we have a square of functors (where the top and bottom are adjunctions `L₁ ⊣ R₁` and
`L₂ ⊣ R₂` respectively).
C ↔ D
G ↓ ↓ H
E ↔ F
Then we have a bijection between natural transformations `G ⋙ L₂ ⟶ L₁ ⋙ H` and
`R₁ ⋙ G ⟶ H ⋙ R₂`.
This can be seen as a bijection of the 2-cells:
L₁ R₁
C --→ D C ←-- D
G ↓ ↗ ↓ H G ↓ ↘ ↓ H
E --→ F E ←-- F
L₂ R₂
Note that if one of the transformations is an iso, it does not imply the other is an iso.
-/
def transfer_nat_trans {C : Type u₁} {D : Type u₂} [category C] [category D] {E : Type u₃}
{F : Type u₄} [category E] [category F] {G : C ⥤ E} {H : D ⥤ F} {L₁ : C ⥤ D} {R₁ : D ⥤ C}
{L₂ : E ⥤ F} {R₂ : F ⥤ E} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) :
(G ⋙ L₂ ⟶ L₁ ⋙ H) ≃ (R₁ ⋙ G ⟶ H ⋙ R₂) :=
equiv.mk
(fun (h : G ⋙ L₂ ⟶ L₁ ⋙ H) =>
nat_trans.mk
fun (X : D) =>
nat_trans.app (adjunction.unit adj₂) (functor.obj G (functor.obj R₁ X)) ≫
functor.map R₂
(nat_trans.app h (functor.obj R₁ X) ≫
functor.map H (nat_trans.app (adjunction.counit adj₁) X)))
(fun (h : R₁ ⋙ G ⟶ H ⋙ R₂) =>
nat_trans.mk
fun (X : C) =>
functor.map L₂
(functor.map G (nat_trans.app (adjunction.unit adj₁) X) ≫
nat_trans.app h (functor.obj L₁ X)) ≫
nat_trans.app (adjunction.counit adj₂) (functor.obj H (functor.obj L₁ X)))
sorry sorry
theorem transfer_nat_trans_counit {C : Type u₁} {D : Type u₂} [category C] [category D]
{E : Type u₃} {F : Type u₄} [category E] [category F] {G : C ⥤ E} {H : D ⥤ F} {L₁ : C ⥤ D}
{R₁ : D ⥤ C} {L₂ : E ⥤ F} {R₂ : F ⥤ E} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (f : G ⋙ L₂ ⟶ L₁ ⋙ H)
(Y : D) :
functor.map L₂ (nat_trans.app (coe_fn (transfer_nat_trans adj₁ adj₂) f) Y) ≫
nat_trans.app (adjunction.counit adj₂) (functor.obj H Y) =
nat_trans.app f (functor.obj R₁ Y) ≫
functor.map H (nat_trans.app (adjunction.counit adj₁) Y) :=
sorry
theorem unit_transfer_nat_trans {C : Type u₁} {D : Type u₂} [category C] [category D] {E : Type u₃}
{F : Type u₄} [category E] [category F] {G : C ⥤ E} {H : D ⥤ F} {L₁ : C ⥤ D} {R₁ : D ⥤ C}
{L₂ : E ⥤ F} {R₂ : F ⥤ E} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) (f : G ⋙ L₂ ⟶ L₁ ⋙ H) (X : C) :
functor.map G (nat_trans.app (adjunction.unit adj₁) X) ≫
nat_trans.app (coe_fn (transfer_nat_trans adj₁ adj₂) f) (functor.obj L₁ X) =
nat_trans.app (adjunction.unit adj₂) (functor.obj G (functor.obj 𝟭 X)) ≫
functor.map R₂ (nat_trans.app f (functor.obj 𝟭 X)) :=
sorry
/--
Given two adjunctions `L₁ ⊣ R₁` and `L₂ ⊣ R₂` both between categories `C`, `D`, there is a
bijection between natural transformations `L₂ ⟶ L₁` and natural transformations `R₁ ⟶ R₂`.
This is defined as a special case of `transfer_nat_trans`, where the two "vertical" functors are
identity.
TODO: Generalise to when the two vertical functors are equivalences rather than being exactly `𝟭`.
Furthermore, this bijection preserves (and reflects) isomorphisms, i.e. a transformation is an iso
iff its image under the bijection is an iso, see eg `category_theory.transfer_nat_trans_self_iso`.
This is in contrast to the general case `transfer_nat_trans` which does not in general have this
property.
-/
def transfer_nat_trans_self {C : Type u₁} {D : Type u₂} [category C] [category D] {L₁ : C ⥤ D}
{L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂) :
(L₂ ⟶ L₁) ≃ (R₁ ⟶ R₂) :=
equiv.trans
(equiv.trans (equiv.symm (iso.hom_congr (functor.left_unitor L₂) (functor.right_unitor L₁)))
(transfer_nat_trans adj₁ adj₂))
(iso.hom_congr (functor.right_unitor R₁) (functor.left_unitor R₂))
theorem transfer_nat_trans_self_counit {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
(f : L₂ ⟶ L₁) (X : D) :
functor.map L₂ (nat_trans.app (coe_fn (transfer_nat_trans_self adj₁ adj₂) f) X) ≫
nat_trans.app (adjunction.counit adj₂) X =
nat_trans.app f (functor.obj R₁ X) ≫ nat_trans.app (adjunction.counit adj₁) X :=
sorry
theorem unit_transfer_nat_trans_self {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
(f : L₂ ⟶ L₁) (X : C) :
nat_trans.app (adjunction.unit adj₁) X ≫
nat_trans.app (coe_fn (transfer_nat_trans_self adj₁ adj₂) f) (functor.obj L₁ X) =
nat_trans.app (adjunction.unit adj₂) X ≫ functor.map R₂ (nat_trans.app f X) :=
sorry
@[simp] theorem transfer_nat_trans_self_id {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {R₁ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) : coe_fn (transfer_nat_trans_self adj₁ adj₁) 𝟙 = 𝟙 :=
sorry
@[simp] theorem transfer_nat_trans_self_symm_id {C : Type u₁} {D : Type u₂} [category C]
[category D] {L₁ : C ⥤ D} {R₁ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) :
coe_fn (equiv.symm (transfer_nat_trans_self adj₁ adj₁)) 𝟙 = 𝟙 :=
sorry
theorem transfer_nat_trans_self_comp {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {L₃ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} {R₃ : D ⥤ C} (adj₁ : L₁ ⊣ R₁)
(adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃) (f : L₂ ⟶ L₁) (g : L₃ ⟶ L₂) :
coe_fn (transfer_nat_trans_self adj₁ adj₂) f ≫ coe_fn (transfer_nat_trans_self adj₂ adj₃) g =
coe_fn (transfer_nat_trans_self adj₁ adj₃) (g ≫ f) :=
sorry
theorem transfer_nat_trans_self_symm_comp {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {L₃ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} {R₃ : D ⥤ C} (adj₁ : L₁ ⊣ R₁)
(adj₂ : L₂ ⊣ R₂) (adj₃ : L₃ ⊣ R₃) (f : R₂ ⟶ R₁) (g : R₃ ⟶ R₂) :
coe_fn (equiv.symm (transfer_nat_trans_self adj₂ adj₁)) f ≫
coe_fn (equiv.symm (transfer_nat_trans_self adj₃ adj₂)) g =
coe_fn (equiv.symm (transfer_nat_trans_self adj₃ adj₁)) (g ≫ f) :=
sorry
theorem transfer_nat_trans_self_comm {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
{f : L₂ ⟶ L₁} {g : L₁ ⟶ L₂} (gf : g ≫ f = 𝟙) :
coe_fn (transfer_nat_trans_self adj₁ adj₂) f ≫ coe_fn (transfer_nat_trans_self adj₂ adj₁) g =
𝟙 :=
sorry
theorem transfer_nat_trans_self_symm_comm {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
{f : R₁ ⟶ R₂} {g : R₂ ⟶ R₁} (gf : g ≫ f = 𝟙) :
coe_fn (equiv.symm (transfer_nat_trans_self adj₁ adj₂)) f ≫
coe_fn (equiv.symm (transfer_nat_trans_self adj₂ adj₁)) g =
𝟙 :=
sorry
/--
If `f` is an isomorphism, then the transferred natural transformation is an isomorphism.
The converse is given in `transfer_nat_trans_self_of_iso`.
-/
protected instance transfer_nat_trans_self_iso {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
(f : L₂ ⟶ L₁) [is_iso f] : is_iso (coe_fn (transfer_nat_trans_self adj₁ adj₂) f) :=
is_iso.mk (coe_fn (transfer_nat_trans_self adj₂ adj₁) (inv f))
/--
If `f` is an isomorphism, then the un-transferred natural transformation is an isomorphism.
The converse is given in `transfer_nat_trans_self_symm_of_iso`.
-/
protected instance transfer_nat_trans_self_symm_iso {C : Type u₁} {D : Type u₂} [category C]
[category D] {L₁ : C ⥤ D} {L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁)
(adj₂ : L₂ ⊣ R₂) (f : R₁ ⟶ R₂) [is_iso f] :
is_iso (coe_fn (equiv.symm (transfer_nat_trans_self adj₁ adj₂)) f) :=
is_iso.mk (coe_fn (equiv.symm (transfer_nat_trans_self adj₂ adj₁)) (inv f))
/--
If `f` is a natural transformation whose transferred natural transformation is an isomorphism,
then `f` is an isomorphism.
The converse is given in `transfer_nat_trans_self_iso`.
-/
def transfer_nat_trans_self_of_iso {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
(f : L₂ ⟶ L₁) [is_iso (coe_fn (transfer_nat_trans_self adj₁ adj₂) f)] : is_iso f :=
eq.mpr sorry
(eq.mp sorry
(category_theory.transfer_nat_trans_self_symm_iso adj₁ adj₂
(coe_fn (transfer_nat_trans_self adj₁ adj₂) f)))
/--
If `f` is a natural transformation whose un-transferred natural transformation is an isomorphism,
then `f` is an isomorphism.
The converse is given in `transfer_nat_trans_self_symm_iso`.
-/
def transfer_nat_trans_self_symm_of_iso {C : Type u₁} {D : Type u₂} [category C] [category D]
{L₁ : C ⥤ D} {L₂ : C ⥤ D} {R₁ : D ⥤ C} {R₂ : D ⥤ C} (adj₁ : L₁ ⊣ R₁) (adj₂ : L₂ ⊣ R₂)
(f : R₁ ⟶ R₂) [is_iso (coe_fn (equiv.symm (transfer_nat_trans_self adj₁ adj₂)) f)] : is_iso f :=
eq.mpr sorry
(eq.mp sorry
(category_theory.transfer_nat_trans_self_iso adj₁ adj₂
(coe_fn (equiv.symm (transfer_nat_trans_self adj₁ adj₂)) f)))
end Mathlib |
a640b293baf1a662bffbbd2df166e42f63047a96 | 367134ba5a65885e863bdc4507601606690974c1 | /src/data/fp/basic.lean | 613875501a11a2923864e60191ed55fdb0ba6c4e | [
"Apache-2.0"
] | permissive | kodyvajjha/mathlib | 9bead00e90f68269a313f45f5561766cfd8d5cad | b98af5dd79e13a38d84438b850a2e8858ec21284 | refs/heads/master | 1,624,350,366,310 | 1,615,563,062,000 | 1,615,563,062,000 | 162,666,963 | 0 | 0 | Apache-2.0 | 1,545,367,651,000 | 1,545,367,651,000 | null | UTF-8 | Lean | false | false | 6,367 | lean | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import data.rat
import data.semiquot
/-!
# Implementation of floating-point numbers (experimental).
-/
def int.shift2 (a b : ℕ) : ℤ → ℕ × ℕ
| (int.of_nat e) := (a.shiftl e, b)
| -[1+ e] := (a, b.shiftl e.succ)
namespace fp
@[derive inhabited]
inductive rmode
| NE -- round to nearest even
class float_cfg :=
(prec emax : ℕ)
(prec_pos : 0 < prec)
(prec_max : prec ≤ emax)
variable [C : float_cfg]
include C
def prec := C.prec
def emax := C.emax
def emin : ℤ := 1 - C.emax
def valid_finite (e : ℤ) (m : ℕ) : Prop :=
emin ≤ e + prec - 1 ∧ e + prec - 1 ≤ emax ∧ e = max (e + m.size - prec) emin
instance dec_valid_finite (e m) : decidable (valid_finite e m) :=
by unfold valid_finite; apply_instance
inductive float
| inf : bool → float
| nan : float
| finite : bool → Π e m, valid_finite e m → float
def float.is_finite : float → bool
| (float.finite s e m f) := tt
| _ := ff
def to_rat : Π (f : float), f.is_finite → ℚ
| (float.finite s e m f) _ :=
let (n, d) := int.shift2 m 1 e,
r := rat.mk_nat n d in
if s then -r else r
theorem float.zero.valid : valid_finite emin 0 :=
⟨begin
rw add_sub_assoc,
apply le_add_of_nonneg_right,
apply sub_nonneg_of_le,
apply int.coe_nat_le_coe_nat_of_le,
exact C.prec_pos
end,
suffices prec ≤ 2 * emax,
begin
rw ← int.coe_nat_le at this,
rw ← sub_nonneg at *,
simp only [emin, emax] at *,
ring,
assumption
end, le_trans C.prec_max (nat.le_mul_of_pos_left dec_trivial),
by rw max_eq_right; simp [sub_eq_add_neg]⟩
def float.zero (s : bool) : float :=
float.finite s emin 0 float.zero.valid
instance : inhabited float := ⟨float.zero tt⟩
protected def float.sign' : float → semiquot bool
| (float.inf s) := pure s
| float.nan := ⊤
| (float.finite s e m f) := pure s
protected def float.sign : float → bool
| (float.inf s) := s
| float.nan := ff
| (float.finite s e m f) := s
protected def float.is_zero : float → bool
| (float.finite s e 0 f) := tt
| _ := ff
protected def float.neg : float → float
| (float.inf s) := float.inf (bnot s)
| float.nan := float.nan
| (float.finite s e m f) := float.finite (bnot s) e m f
def div_nat_lt_two_pow (n d : ℕ) : ℤ → bool
| (int.of_nat e) := n < d.shiftl e
| -[1+ e] := n.shiftl e.succ < d
-- TODO(Mario): Prove these and drop 'meta'
meta def of_pos_rat_dn (n : ℕ+) (d : ℕ+) : float × bool :=
begin
let e₁ : ℤ := n.1.size - d.1.size - prec,
cases h₁ : int.shift2 d.1 n.1 (e₁ + prec) with d₁ n₁,
let e₂ := if n₁ < d₁ then e₁ - 1 else e₁,
let e₃ := max e₂ emin,
cases h₂ : int.shift2 d.1 n.1 (e₃ + prec) with d₂ n₂,
let r := rat.mk_nat n₂ d₂,
let m := r.floor,
refine (float.finite ff e₃ (int.to_nat m) _, r.denom = 1),
{ exact undefined }
end
meta def next_up_pos (e m) (v : valid_finite e m) : float :=
let m' := m.succ in
if ss : m'.size = m.size then
float.finite ff e m' (by unfold valid_finite at *; rw ss; exact v)
else if h : e = emax then
float.inf ff
else
float.finite ff e.succ (nat.div2 m') undefined
meta def next_dn_pos (e m) (v : valid_finite e m) : float :=
match m with
| 0 := next_up_pos _ _ float.zero.valid
| nat.succ m' :=
if ss : m'.size = m.size then
float.finite ff e m' (by unfold valid_finite at *; rw ss; exact v)
else if h : e = emin then
float.finite ff emin m' undefined
else
float.finite ff e.pred (bit1 m') undefined
end
meta def next_up : float → float
| (float.finite ff e m f) := next_up_pos e m f
| (float.finite tt e m f) := float.neg $ next_dn_pos e m f
| f := f
meta def next_dn : float → float
| (float.finite ff e m f) := next_dn_pos e m f
| (float.finite tt e m f) := float.neg $ next_up_pos e m f
| f := f
meta def of_rat_up : ℚ → float
| ⟨0, _, _, _⟩ := float.zero ff
| ⟨nat.succ n, d, h, _⟩ :=
let (f, exact) := of_pos_rat_dn n.succ_pnat ⟨d, h⟩ in
if exact then f else next_up f
| ⟨-[1+n], d, h, _⟩ := float.neg (of_pos_rat_dn n.succ_pnat ⟨d, h⟩).1
meta def of_rat_dn (r : ℚ) : float :=
float.neg $ of_rat_up (-r)
meta def of_rat : rmode → ℚ → float
| rmode.NE r :=
let low := of_rat_dn r, high := of_rat_up r in
if hf : high.is_finite then
if r = to_rat _ hf then high else
if lf : low.is_finite then
if r - to_rat _ lf > to_rat _ hf - r then high else
if r - to_rat _ lf < to_rat _ hf - r then low else
match low, lf with float.finite s e m f, _ :=
if 2 ∣ m then low else high
end
else float.inf tt
else float.inf ff
namespace float
instance : has_neg float := ⟨float.neg⟩
meta def add (mode : rmode) : float → float → float
| nan _ := nan
| _ nan := nan
| (inf tt) (inf ff) := nan
| (inf ff) (inf tt) := nan
| (inf s₁) _ := inf s₁
| _ (inf s₂) := inf s₂
| (finite s₁ e₁ m₁ v₁) (finite s₂ e₂ m₂ v₂) :=
let f₁ := finite s₁ e₁ m₁ v₁, f₂ := finite s₂ e₂ m₂ v₂ in
of_rat mode (to_rat f₁ rfl + to_rat f₂ rfl)
meta instance : has_add float := ⟨float.add rmode.NE⟩
meta def sub (mode : rmode) (f1 f2 : float) : float :=
add mode f1 (-f2)
meta instance : has_sub float := ⟨float.sub rmode.NE⟩
meta def mul (mode : rmode) : float → float → float
| nan _ := nan
| _ nan := nan
| (inf s₁) f₂ := if f₂.is_zero then nan else inf (bxor s₁ f₂.sign)
| f₁ (inf s₂) := if f₁.is_zero then nan else inf (bxor f₁.sign s₂)
| (finite s₁ e₁ m₁ v₁) (finite s₂ e₂ m₂ v₂) :=
let f₁ := finite s₁ e₁ m₁ v₁, f₂ := finite s₂ e₂ m₂ v₂ in
of_rat mode (to_rat f₁ rfl * to_rat f₂ rfl)
meta def div (mode : rmode) : float → float → float
| nan _ := nan
| _ nan := nan
| (inf s₁) (inf s₂) := nan
| (inf s₁) f₂ := inf (bxor s₁ f₂.sign)
| f₁ (inf s₂) := zero (bxor f₁.sign s₂)
| (finite s₁ e₁ m₁ v₁) (finite s₂ e₂ m₂ v₂) :=
let f₁ := finite s₁ e₁ m₁ v₁, f₂ := finite s₂ e₂ m₂ v₂ in
if f₂.is_zero then inf (bxor s₁ s₂) else
of_rat mode (to_rat f₁ rfl / to_rat f₂ rfl)
end float
end fp
|
96fd8018a97352a38b4508a60e4ac4f4d0d571b0 | b328e8ebb2ba923140e5137c83f09fa59516b793 | /src/Lean/Meta/Tactic/Cases.lean | 0044e02f93f166a7b04e886a794f48a54d79f4a0 | [
"Apache-2.0"
] | permissive | DrMaxis/lean4 | a781bcc095511687c56ab060e816fd948553e162 | 5a02c4facc0658aad627cfdcc3db203eac0cb544 | refs/heads/master | 1,677,051,517,055 | 1,611,876,226,000 | 1,611,876,226,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 14,617 | 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 (List Name)) (useUnusedNames : Bool) (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 useUnusedNames
pure $ toCasesSubgoals s ctors majorFVarId us params
def cases (mvarId : MVarId) (majorFVarId : FVarId) (givenNames : Array (List Name) := #[]) (useUnusedNames := false) : 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 useUnusedNames 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 useUnusedNames ctx
let s₂ ← elimAuxIndices s₁ s₂
unifyCasesEqs s₁.numEqs s₂
end Cases
def cases (mvarId : MVarId) (majorFVarId : FVarId) (givenNames : Array (List Name) := #[]) (useUnusedNames := false) : MetaM (Array CasesSubgoal) :=
Cases.cases mvarId majorFVarId givenNames useUnusedNames
builtin_initialize registerTraceClass `Meta.Tactic.cases
end Lean.Meta
|
bb40d36338afd7afe68c0a9ef59dc92983f0f369 | 03bd658c402412f41d3026d1040ee8ca8c0fc579 | /src/MITM.lean | 6b92b0d4ba0359fea7f6744d39dd2dd5190c4d9a | [] | no_license | ImperialCollegeLondon/dots_and_boxes | c205f6dbad8af9625f56715e4d1bed96b0ac1022 | f7bd0b1603674a657170c5395adb717c4f670220 | refs/heads/master | 1,663,752,058,476 | 1,591,438,614,000 | 1,591,438,614,000 | 139,707,103 | 2 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 25,498 | lean | import game.modify.basic game.value
open game
open list
/-- the values of two games, that differ in exactly one component by at most d
d, differ by at most d-/
theorem MITM (G1 G2 : game 2) (d : ℤ) (p : game.modify G1 G2 d):
abs(G1.value - G2.value) ≤ d :=
begin
revert G1,
revert G2,
-- induction on size of G2 (using our recursor)
apply @game.rec_on_size2 (λ G2, ∀ G1, modify G1 G2 d →
abs (game.value G1 - game.value G2) ≤ d),
{ -- base case : G2 = zero 2
intros G1 p,
have hx : G1.size2 = (zero 2).size2 := eq_size_of_modify p, -- see game.modify.basic
rw size2_zero at hx, -- (zero 2).size2 = 0
have hy := eq_zero_of_size2_zero _ hx, -- hy is G1 = zero 2 (true by hx)
rw hy,
show 0 ≤ d, -- as by defintions of abs abd value, abs (value (zero 2) - value (zero 2)) = 0
exact abs_le_nonneg p.hl.bound,}, -- see misc_lemmas
{ -- inductive step : G2 has size n + 1
/- in the following we switched the names of G1 and G2, so now G1 is
initially assumed to have size n + 1-/
intros n H G1 h1 G2 p, -- H is the inductive hypothesis and h1 says G1.size2 = n + 1
have h2 := eq_size_of_modify p, -- h2 is size2 G2 = size2 G1 (see game.modify.basic)
rw h1 at h2, -- so now h2 is size2 G2 = n + 1, the parallel hypothesis to h1
/- now that we have h1 and h2, we can use our simplified value definition
(other arguments inferred)-/
rw game.value_def _ _ h2,
rw game.value_def _ _ h1,
apply list.min_change, -- se list.min.basic
/- necessary hypothesis for list.min : the lengths of the lists are the same
(whivh ia true because the sizes of the games are the same) -/
{ rw length_bind, dsimp,
rw [length_of_fn, length_of_fn],
rw length_bind, dsimp,
rw [length_of_fn, length_of_fn],
show G2.size = G1.size,
rw size_eq_size2,
rw size_eq_size2,
rw [h1, h2]},
/- because list.min takes as an argument, that the list we take the minimum
of is non-empty, these hypotheses for list.min_change are inferred from those
and need not be proved again-/
-- now we just need to prove hdist (see list.min.basic)
/- intuitively, we know this is true because G1 and G2 are modified games-/
intros i hiL hiM,
rw length_bind at hiL hiM,
dsimp at hiL hiM, /-because hiM and hiL are needed by nth_le, simplifying creates
new hypotheses -/
rw [length_of_fn, length_of_fn] at hiL_1 hiM_1,
rw sum_list2 at hiL_1,
rw sum_list2 at hiM_1,
/- now hiL_1 is : i < length (G2.f 0) + length (G2.f 1),
and hiM_1 is the similare statement for G1 -/
simp only [list.bind_fin2],
/- we just simplified a bit. Now as we viewed the lists of components
as the lists of chains and loops as bound together with list.bind we
need to consider two cases. Either the component considered is a chain
( ie. i < length (G2.f 0)) or it is a loop. That is important,
because we will case by case consider where G1 and G2 are modified-/
by_cases hi2 : i < length (G2.f 0),
{ -- hi2 : i < length (G2.f 0)
/- as the games are modified their chain and loop lists have the same lengths,
hence :-/
have lengthf0 : length (G2.f 0) = length (G1.f 0),
{apply eq_list_lengths_of_modify p},
have hi1 : i < length (G1.f 0),
{rw ←lengthf0, exact hi2},
/- so we can use this to show the elements we are comparing for hdist are both
chains and we can get rid of the appension of the list of values in case
we opened a loop-/
rw nth_le_append _ _,
swap,
{ rw length_of_fn,
exact hi2,
},
rw nth_le_append _ _,
swap,
{ rw length_of_fn,
exact hi1,
},
-- simplifying (see list.lemmas.simple)
rw nth_le_of_fn' _ _ hi2,
rw nth_le_of_fn' _ _ hi1,
/- now the goal is just
abs(nth_le (G2.f 0) (⟨i, hi2⟩.val) _ - (2 * ↑(0.val) + 2) +
abs (2 * ↑(0.val) + 2 - value (remove G2 0 ⟨i, hi2⟩)) -
(nth_le (G1.f 0) (⟨i, hi1⟩.val) _ - (2 * ↑(0.val) + 2) +
abs (2 * ↑(0.val) + 2 - value (remove G1 0 ⟨i, hi1⟩)))) ≤ d
Now we dive into the case by case consideration, of whether a chain
or a loop has been modified-/
by_cases hj : p.j = 0,
{ -- hj is p.j = 0 (ie. a chain has been modified)
set pl := p.hl with hpl,
set pn := pl.n with pln,
/- now either i stands for exacty the modified chain p.n (= pn)
or not-/
by_cases hni : pn = i,
{ -- hni : pn = i (i stands for the modified chain)
/- in that case removing component i makes the games exactly
the same, giving the following-/
have hG1G2 : game.remove G1 0 ⟨i, hi1⟩ = game.remove G2 0 ⟨i, hi2⟩,
{ apply game.ext, -- see game.basic
intros a ha,
cases a with a,
{ -- a = 0
unfold game.remove,
dsimp,
-- the if-condition in game.remove evaluates to true as ⟨0, ha⟩ = 0
rw dif_pos, swap, refl,
rw dif_pos, swap, refl,
rw ←hni,
rw pln,
convert pl.heq.symm; rw hj, -- this is then true by field heq of p.hl and hj
},
{ -- nat.succ a (a = 1, as a < 2 as it is a value of some object of type fin 2)
cases a with a,
swap,
{-- nat.succ (nat.succ a), which contradicts ha
cases ha,
cases ha_a,
cases ha_a_a}, -- do cases until Lean trivially sees the contradiction
-- a = 1
unfold game.remove,
dsimp,
-- the if-condition in game.remove is false, as we do not have ⟨1, ha⟩ = 0
rw dif_neg, swap, exact dec_trivial,
rw dif_neg, swap, exact dec_trivial,
/- so we just need to prove G1.f ⟨1, ha⟩ = G2.f ⟨1, ha⟩
as we are modifying a chain, this is true by field hj of p-/
convert (p.hj 1 _).symm using 1,
rw hj,
exact dec_trivial,
}
},
rw hG1G2,
/- with the resulting games after playing in component i being the same,
we just have to show the ith components differ by at most d.
That is basically what p.hl.bound says-/
convert pl.bound using 1,
apply congr_arg,
dsimp,
simp only [pln.symm, hni, hj],
ring
},
{ -- hni : ¬ (pn = i) (i does not stand for the modified chain)
/- in this case nth_le (G2.f 0) i _ = nth_le (G1.f 0) i _
and we can use the inductive hypothesis -/
have nth_le_eq : nth_le (G2.f 0) i hi2 = nth_le (G1.f 0) i hi1,
{apply list.modify_same _ i hi2 hi1 _, -- see list.modify.basic
-- an integer d
{exact d},
-- modify (G2.f 0) (G1.f 0) d
{simp only [hj] at pl,
exact pl},
/-(eq.mp _ pl).n ≠ i (basically just pl.n ≠ i, but we have a duplicate naming issue
for hypotheses which basically say the same (because of the simp only at pl, which
created a new pl, as the old one in that exact form was needed elsewhere))-/
convert hni,
rw eq_comm,
exact hj,
rw eq_comm,
exact hj,
-- prove eq.mp _ pl == pl, ie just the duplicate naming issue
-- one-line proof lean constructed by searchin through the library
exact cast_heq
((λ (A A_1 : list ℤ) (e_1 : A = A_1) (B B_1 : list ℤ) (e_2 : B = B_1) (d d_1 : ℤ) (e_3 : d = d_1),
congr (congr (congr_arg list.modify e_1) e_2) e_3)
(G2.f (p.j))
(G2.f 0)
((λ (c c_1 : game 2) (e_1 : c = c_1) (a a_1 : fin 2) (e_2 : a = a_1), congr (congr_arg f e_1) e_2) G2 G2
(eq.refl G2)
(p.j)
0
hj)
(G1.f (p.j))
(G1.f 0)
((λ (c c_1 : game 2) (e_1 : c = c_1) (a a_1 : fin 2) (e_2 : a = a_1), congr (congr_arg f e_1) e_2) G1 G1
(eq.refl G1)
(p.j)
0
hj)
d
d
(eq.refl d))
pl},--up to here by library_search
rw nth_le_eq,
/- so it suffices to prove the absolute value terms differ by at most d-/
suffices : abs
(abs (2 - game.value (game.remove G2 0 ⟨i, hi2⟩)) -
abs (2 - game.value (game.remove G1 0 ⟨i, hi1⟩))) ≤ d,
{ -- proof that this actually implies the result
convert this using 2,
rw [(show ((0 : fin 2).val : ℤ) = 0, by norm_cast), mul_zero, zero_add],
ring,
},
apply le_trans (abs_abs_sub_abs_le _ _), -- see misc_lemmas
/- now by using game.remove_of_modify we can prove the games with chain i
removed are also modified versions of each other, and then as they have sizen,
the inductive hypothesis and some term cancelling solve the goal-/
-- need the following as argument for game.remove_of_modify
have ho : 0 ≠ p.j ∨ (0 = p.j ∧ ((⟨i, hi2⟩ : fin (length (G2.f 0))).val) ≠ p.hl.n),
{right, -- the right side of the ∨ is true
split,
exact hj.symm, -- 0 = p.j
rw eq_comm at hni,
exact hni,}, /-((⟨i, hi2⟩ : fin (length (G2.f 0))).val) ≠ p.hl.n
which is what hni says-/
have hmod := (game.remove_of_modify_symm p 0 ⟨i, hi2⟩ ⟨i, hi1⟩ (by refl) ho), -- the reduced games are modified
have Hind := (H (game.remove G2 0 ⟨i, hi2⟩) _ (game.remove G1 0 ⟨i, hi1⟩) hmod), -- result of inductive hypothesis
swap,
-- proving size2 (remove G2 0 ⟨i, hi2⟩) = n (necessary hypothesis for H)
{rw game.size2_remove, -- size2 (remove G2 0 ⟨i, hi2⟩) = size2 G2 - 1
rw h2,
exact nat.add_sub_cancel n 1,
},
convert Hind using 2, -- goal is basically Hind (subject to terms cancelling)
ring, -- using that (ℤ,*,+) is a ring (commutativity and associativity, etc.)
},
},
/- This concludes the case where a chain has been modified. If a loop has been
modified, the chains are all exactly the same. So just as before,
nth_le (G2.f 0) i hi2 = nth_le (G1.f 0) i hi1 and we can use the inductive
hypothesis-/
{ -- hj is ¬ (p.j = 0) (ie. a loop has been modified)
have G1G2_1 : G2.f 0 = G1.f 0,
{rw eq_comm at hj,
exact p.hj 0 hj},
simp only [G1G2_1], -- simp only because of nth_le
{ have ho : 0 ≠ p.j ∨ (0 = p.j ∧ ((⟨i, hi2⟩ : fin (length (G2.f 0))).val) ≠ p.hl.n),
{left, -- the left side of ∨ is true
rw eq_comm at hj,
exact hj,},
have hmod := (game.remove_of_modify_symm p 0 ⟨i, hi2⟩ ⟨i, hi1⟩ (by refl) ho),
have Hind := (H (game.remove G2 0 ⟨i, hi2⟩) _ (game.remove G1 0 ⟨i, hi1⟩) hmod),
swap,
{rw game.size2_remove,
rw h2,
exact nat.add_sub_cancel n 1,
},
suffices : abs
(abs (2 - game.value (game.remove G2 0 ⟨i, hi2⟩)) -
abs (2 - game.value (game.remove G1 0 ⟨i, hi1⟩))) ≤ d,
{ convert this using 2,
rw [(show ((0 : fin 2).val : ℤ) = 0, by norm_cast), mul_zero, zero_add],
ring,
},
apply le_trans (abs_abs_sub_abs_le _ _),
convert Hind using 2,
ring,
},
},
},
/-This concludes the proof in the case that i represented a chain, now we consider
i to represent a loop -/
{ -- hi2 : ¬ (i < length (G2.f 0)) (we are considering a loop)
push_neg at hi2, -- hi2 is length (G2.f 0) ≤ i
/- similar to the other case, we can get rid of the lists of values
in case we opened a chain, which the other values are appended to in
the goal, by adjusting the index (subtracting the length of the first list)-/
rw nth_le_append_right _ _,
swap,
{ rw length_of_fn,
exact hi2,
},
rw nth_le_append_right _ _,
swap,
{ rw length_of_fn,
convert hi2 using 1,
symmetry,
apply eq_list_lengths_of_modify p,
},
-- through hiL_1, hi2 and the fact the games are modied, we have the following hypotheses
have hi_new2 : i - length (G2.f 0) < length (G2.f 1),
{ rwa [nat.sub_lt_right_iff_lt_add hi2, add_comm],},
have h1length : length (G2.f 1) = length (G1.f 1),
{apply eq_list_lengths_of_modify p},
have hi_new1 : i - length (G2.f 0) < length (G1.f 1),
{rw ←h1length,
exact hi_new2},
have hi_new1' : i - length (G1.f 0) < length (G1.f 1),
{convert hi_new1 using 2,
symmetry,
apply eq_list_lengths_of_modify p},
have h0length : length (G2.f 0) = length (G1.f 0),
{apply eq_list_lengths_of_modify p},
/- hi_new1, hi_new1' and h_new2 are what we will need instead of hi1 and
hi2 in this case, as the index has been shifted, when we got rid of the
pre-appended list -/
simp only [length_of_fn],
-- simplifying (see list.lemmas.simple)
rw nth_le_of_fn' _ _ hi_new2,
rw nth_le_of_fn' _ _ hi_new1',
/- now the goal is just
abs (nth_le (G2.f 1) (⟨i - length (G2.f 0), hi_new2⟩.val) _ - (2 * ↑(1.val) + 2) +
abs (2 * ↑(1.val) + 2 - value (remove G2 1 ⟨i - length (G2.f 0), hi_new2⟩)) -
(nth_le (G1.f 1) (⟨i - length (G1.f 0), hi_new1'⟩.val) _ - (2 * ↑(1.val) + 2) +
abs (2 * ↑(1.val) + 2 - value (remove G1 1 ⟨i - length (G1.f 0), hi_new1'⟩)))) ≤ d
Now, again, we dive into the case by case consideration, of whether a chain
or a loop has been modified-/
by_cases hj : p.j = 1,
{ -- hj is p.j = 1 (ie. a loop has been modified)
set pl := p.hl with hpl,
set pn := pl.n with pln,
/- now either i stands for exacty the modified loop p.n (= pn)
or not (i was the index in (chains ++ loops), so the index
is this time i - length (G2.f 0)-/
by_cases hni : pn = i - length (G2.f 0),
{ -- hni : pn = i - length (G2.f 0) (i stands for the modified loop)
/- in that case removing component i makes the games exactly
the same, giving the following-/
have hG1G2 : game.remove G1 1 ⟨i - length (G1.f 0), hi_new1'⟩ =
game.remove G2 1 ⟨i - length (G2.f 0), hi_new2⟩,
{ apply game.ext, -- see game.basic
intros a ha,
cases a with a,
{ -- a = 0
unfold game.remove,
dsimp,
/- the if-condition in game.remove evaluates to false as we do
not have ⟨0, ha⟩ = 1 -/
rw dif_neg, swap, exact dec_trivial,
rw dif_neg, swap, exact dec_trivial,
/- so we just need to prove G1.f ⟨0, ha⟩ = G2.f ⟨0, ha⟩
as we are modifying a chain, this is true by field hj of p-/
convert (p.hj 0 _).symm using 1,
rw hj,
exact dec_trivial,
},
{ -- nat.succ a (a = 1, as a < 2 as it is a value of some object of type fin 2)
cases a with a,
swap,
{ -- nat.succ (nat.succ a) , contradicts ha
cases ha,
cases ha_a,
cases ha_a_a}, -- do cases until Lean trivially sees the contradiction
unfold game.remove,
dsimp,
-- the if-condition in game.remove evaluates to true as ⟨1, ha⟩ = 1
rw dif_pos, swap, refl,
rw dif_pos, swap, refl,
rw ← eq_list_lengths_of_modify p 0,
rw ←hni,
rw pln,
convert pl.heq.symm; rw ← hj, -- this is then true by field heq of p.hl and hj
}
},
rw hG1G2,
/- with the resulting games after playing in component i being the same,
we just have to show the ith components differ by at most d.
That is basically what p.hl.bound says-/
convert pl.bound using 1,
apply congr_arg,
dsimp,
simp only [pln.symm, hni, hj],
simp only [eq_list_lengths_of_modify p 0],
ring,
},
{ -- hni : ¬ (pn = i) (i does not stand for the modified chain)
/- in this case nth_le (G2.f 1) (i - length (G2.f 0)) _ =
(G1.f 1) (i - length (G2.f 0)) _ ,
and we can use the inductive hypothesis -/
have nth_le_eq : nth_le (G2.f 1) (i - length (G2.f 0)) hi_new2
= nth_le (G1.f 1) (i - length (G2.f 0)) hi_new1,
{apply list.modify_same _ (i - length (G2.f 0)) hi_new2 hi_new1 _, -- see list.modify.basic
-- an integer d
{exact d},
-- modify (G2.f 1) (G1.f 1) d
{simp only [hj] at pl,
exact pl},
/-(eq.mp _ pl).n ≠ i - length (G2.f 0) (basically just pl.n ≠ i - length (G2.f 0),
but we have a duplicate naming issue for hypotheses which basically says the same
(because of the simp only at pl, which created a new pl, as the old one in that exact
form was needed elsewhere)-/
convert hni,
rw eq_comm,
exact hj,
rw eq_comm,
exact hj,
-- prove eq.mp _ pl == pl, ie just the duplicate naming issue
-- one-line proof lean constructed by searchin through the library
exact cast_heq
((λ (A A_1 : list ℤ) (e_1 : A = A_1) (B B_1 : list ℤ) (e_2 : B = B_1) (d d_1 : ℤ) (e_3 : d = d_1),
congr (congr (congr_arg list.modify e_1) e_2) e_3)
(G2.f (p.j))
(G2.f 1)
((λ (c c_1 : game 2) (e_1 : c = c_1) (a a_1 : fin 2) (e_2 : a = a_1), congr (congr_arg f e_1) e_2) G2 G2
(eq.refl G2)
(p.j)
1
hj)
(G1.f (p.j))
(G1.f 1)
((λ (c c_1 : game 2) (e_1 : c = c_1) (a a_1 : fin 2) (e_2 : a = a_1), congr (congr_arg f e_1) e_2) G1 G1
(eq.refl G1)
(p.j)
1
hj)
d
d
(eq.refl d))
pl},--up to here by library_search
rw nth_le_eq,
/- so it suffices to prove the absolute value terms differ by at most d-/
suffices : abs (
abs (4 - game.value (game.remove G2 1 ⟨i - length (G2.f 0), hi_new2⟩))
- abs (4 - game.value (game.remove G1 1 ⟨i - length (G1.f 0), hi_new1'⟩))
) ≤ d,
{ -- proof that this actually implies the result
convert this using 2,
rw (show (((1 : fin 2).val) : ℤ) = 1, by norm_cast),
simp only [h0length],
ring,
},
refine le_trans (abs_abs_sub_abs_le _ _) _, -- see misc_lemmas (le_trans is transitivity of ≤ )
/- now by using game.remove_of_modify we can prove the games with loop (i - length (G2.f 0))
removed are also modified versions of each other, and then as they have size n,
the inductive hypothesis and some term cancelling solve the goal-/
-- need the following as argument for game.remove_of_modify
have ho : 1 ≠ p.j ∨ (1 = p.j ∧ ((⟨i - length (G2.f 0), hi_new2⟩: fin (length (G2.f 1))).val) ≠ p.hl.n),
{right, -- the right side of the ∨ is true
split,
exact hj.symm, -- 1 = p.j
rw eq_comm at hni,
exact hni,}, /-((⟨i - length (G2.f 0), hi_new2⟩: fin (length (G2.f 1))).val) ≠ p.hl.n
which is what hni says-/
have hmod := (game.remove_of_modify_symm p 1 ⟨i - length (G2.f 0), hi_new2⟩ ⟨i - length (G1.f 0), hi_new1'⟩ _ ho), -- the reduced games are modified
swap,
{simp only [h0length],}, /- proving ⟨i - length (G2.f 0), hi_new2⟩.val = ⟨i - length (G1.f 0), hi_new1'⟩.val
(necessary hypothesis for game.remove_of_modify_symm)-/
have Hind := (H (game.remove G2 1 ⟨i - length (G2.f 0), hi_new2⟩) _ (game.remove G1 1 ⟨i - length (G1.f 0), hi_new1'⟩) hmod), -- result of inductive hypothesis
{ -- goal is basically Hind (subject to terms cancelling)
convert Hind using 2,
ring, -- using that (ℤ,*,+) is a ring (commutativity and associativity, etc.)
},
{ -- proving size2 (remove G2 1 ⟨i - length (G2.f 0), hi_new2⟩) = n (necessary hypothesis for H)
rw game.size2_remove, -- size2 (remove G2 1 ⟨i - length (G2.f 0), hi_new2⟩) = size2 G2 - 1
rw h2,
exact nat.add_sub_cancel n 1,
},
},
},
/- This concludes the case where a loop has been modified. If a chain has been
modified, the loops are all exactly the same. So just as before,
nth_le (G2.f 1) (i - length (G2.f 0)) hi_new2 = nth_le (G1.f 1) (i - length (G2.f 0)) hi_new1
and we can use the inductive hypothesis-/
{ -- hj is ¬ (p.j = 1) (ie. a chain has been modified)
have G1G2_1 : G2.f 1 = G1.f 1,
{rw eq_comm at hj,
exact p.hj 1 hj},
simp only [G1G2_1], --simp only because of nth_le
suffices : abs (
abs (4 - game.value (game.remove G2 1 ⟨i - length (G2.f 0), hi_new2⟩))
- abs (4 - game.value (game.remove G1 1 ⟨i - length (G1.f 0), hi_new1'⟩))
) ≤ d,
{ convert this using 2,
rw (show (((1 : fin 2).val) : ℤ) = 1, by norm_cast),
simp only [h0length],
ring,
},
refine le_trans (abs_abs_sub_abs_le _ _) _,
have ho : 1 ≠ p.j ∨ (1 = p.j ∧ ((⟨i - length (G2.f 0), hi_new2⟩: fin (length (G2.f 1))).val) ≠ p.hl.n),
{left, -- the left side of the ∨ is true
rw eq_comm at hj,
exact hj,},
have hmod := (game.remove_of_modify_symm p 1 ⟨i - length (G2.f 0), hi_new2⟩ ⟨i - length (G1.f 0), hi_new1'⟩ _ ho),
have Hind := (H (game.remove G2 1 ⟨i - length (G2.f 0), hi_new2⟩) _ (game.remove G1 1 ⟨i - length (G1.f 0), hi_new1'⟩) hmod),
{ convert Hind using 2,
ring,
},
{rw game.size2_remove,
rw h2,
exact nat.add_sub_cancel n 1,
},
{simp only [h0length],},
},
},
},
end |
6df4df55db8295b02ceea7dde006cc6a938e0795 | 4fa161becb8ce7378a709f5992a594764699e268 | /src/category_theory/limits/shapes/images.lean | d7dde43ae577c22a915e8d6f1fe684bece61da00 | [
"Apache-2.0"
] | permissive | laughinggas/mathlib | e4aa4565ae34e46e834434284cb26bd9d67bc373 | 86dcd5cda7a5017c8b3c8876c89a510a19d49aad | refs/heads/master | 1,669,496,232,688 | 1,592,831,995,000 | 1,592,831,995,000 | 274,155,979 | 0 | 0 | Apache-2.0 | 1,592,835,190,000 | 1,592,835,189,000 | null | UTF-8 | Lean | false | false | 19,098 | lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Markus Himmel
-/
import category_theory.limits.shapes.equalizers
import category_theory.limits.shapes.strong_epi
/-!
# Categorical images
We define the categorical image of `f` as a factorisation `f = e ≫ m` through a monomorphism `m`,
so that `m` factors through the `m'` in any other such factorisation.
## Main definitions
* A `mono_factorisation` is a factorisation `f = e ≫ m`, where `m` is a monomorphism
* `is_image F` means that a given mono factorisation `F` has the universal property of the image.
* `has_image f` means that we have chosen an image for the morphism `f : X ⟶ Y`.
* In this case, `image f` is the image object, `image.ι f : image f ⟶ Y` is the monomorphism `m`
of the factorisation and `factor_thru_image f : X ⟶ image f` is the morphism `e`.
* `has_images C` means that every morphism in `C` has an image.
* Let `f : X ⟶ Y` and `g : P ⟶ Q` be morphisms in `C`, which we will represent as objects of the
arrow category `arrow C`. Then `sq : f ⟶ g` is a commutative square in `C`. If `f` and `g` have
images, then `has_image_map sq` represents the fact that there is a morphism
`i : image f ⟶ image g` making the diagram
X ----→ image f ----→ Y
| | |
| | |
↓ ↓ ↓
P ----→ image g ----→ Q
commute, where the top row is the image factorisation of `f`, the bottom row is the image
factorisation of `g`, and the outer rectangle is the commutative square `sq`.
* If a category `has_images`, then `has_image_maps` means that every commutative square admits an
image map.
* If a category `has_images`, then `has_strong_epi_images` means that the morphism to the image is
always a strong epimorphism.
## Main statements
* When `C` has equalizers, the morphism `e` appearing in an image factorisation is an epimorphism.
* When `C` has strong epi images, then these images admit image maps.
## Future work
* TODO: coimages, and abelian categories.
* TODO: connect this with existing working in the group theory and ring theory libraries.
-/
universes v u
open category_theory
open category_theory.limits.walking_parallel_pair
namespace category_theory.limits
variables {C : Type u} [category.{v} C]
variables {X Y : C} (f : X ⟶ Y)
/-- A factorisation of a morphism `f = e ≫ m`, with `m` monic. -/
structure mono_factorisation (f : X ⟶ Y) :=
(I : C)
(m : I ⟶ Y)
[m_mono : mono.{v} m]
(e : X ⟶ I)
(fac' : e ≫ m = f . obviously)
restate_axiom mono_factorisation.fac'
attribute [simp, reassoc] mono_factorisation.fac
attribute [instance] mono_factorisation.m_mono
attribute [instance] mono_factorisation.m_mono
namespace mono_factorisation
/-- The obvious factorisation of a monomorphism through itself. -/
def self [mono f] : mono_factorisation f :=
{ I := X,
m := f,
e := 𝟙 X }
-- I'm not sure we really need this, but the linter says that an inhabited instance ought to exist...
instance [mono f] : inhabited (mono_factorisation f) := ⟨self f⟩
/-- The morphism `m` in a factorisation `f = e ≫ m` through a monomorphism is uniquely determined. -/
@[ext]
lemma ext
{F F' : mono_factorisation f} (hI : F.I = F'.I) (hm : F.m = (eq_to_hom hI) ≫ F'.m) : F = F' :=
begin
cases F, cases F',
cases hI,
simp at hm,
dsimp at F_fac' F'_fac',
congr,
{ assumption },
{ resetI, apply (cancel_mono F_m).1,
rw [F_fac', hm, F'_fac'], }
end
end mono_factorisation
variable {f}
/-- Data exhibiting that a given factorisation through a mono is initial. -/
structure is_image (F : mono_factorisation f) :=
(lift : Π (F' : mono_factorisation f), F.I ⟶ F'.I)
(lift_fac' : Π (F' : mono_factorisation f), lift F' ≫ F'.m = F.m . obviously)
restate_axiom is_image.lift_fac'
attribute [simp, reassoc] is_image.lift_fac
@[simp, reassoc] lemma is_image.fac_lift {F : mono_factorisation f} (hF : is_image F)
(F' : mono_factorisation f) : F.e ≫ hF.lift F' = F'.e :=
(cancel_mono F'.m).1 $ by simp
variable (f)
namespace is_image
/-- The trivial factorisation of a monomorphism satisfies the universal property. -/
@[simps]
def self [mono f] : is_image (mono_factorisation.self f) :=
{ lift := λ F', F'.e }
instance [mono f] : inhabited (is_image (mono_factorisation.self f)) :=
⟨self f⟩
variable {f}
/-- Two factorisations through monomorphisms satisfying the universal property
must factor through isomorphic objects. -/
-- TODO this is another good candidate for a future `unique_up_to_canonical_iso`.
@[simps]
def iso_ext {F F' : mono_factorisation f} (hF : is_image F) (hF' : is_image F') : F.I ≅ F'.I :=
{ hom := hF.lift F',
inv := hF'.lift F,
hom_inv_id' := (cancel_mono F.m).1 (by simp),
inv_hom_id' := (cancel_mono F'.m).1 (by simp) }
end is_image
/-- Data exhibiting that a morphism `f` has an image. -/
class has_image (f : X ⟶ Y) :=
(F : mono_factorisation f)
(is_image : is_image F)
section
variable [has_image f]
/-- The chosen factorisation of `f` through a monomorphism. -/
def image.mono_factorisation : mono_factorisation f := has_image.F
/-- The witness of the universal property for the chosen factorisation of `f` through a monomorphism. -/
def image.is_image : is_image (image.mono_factorisation f) := has_image.is_image
/-- The categorical image of a morphism. -/
def image : C := (image.mono_factorisation f).I
/-- The inclusion of the image of a morphism into the target. -/
def image.ι : image f ⟶ Y := (image.mono_factorisation f).m
@[simp] lemma image.as_ι : (image.mono_factorisation f).m = image.ι f := rfl
instance : mono (image.ι f) := (image.mono_factorisation f).m_mono
/-- The map from the source to the image of a morphism. -/
def factor_thru_image : X ⟶ image f := (image.mono_factorisation f).e
/-- Rewrite in terms of the `factor_thru_image` interface. -/
@[simp]
lemma as_factor_thru_image : (image.mono_factorisation f).e = factor_thru_image f := rfl
@[simp, reassoc]
lemma image.fac : factor_thru_image f ≫ image.ι f = f := (image.mono_factorisation f).fac'
variable {f}
/-- Any other factorisation of the morphism `f` through a monomorphism receives a map from the image. -/
def image.lift (F' : mono_factorisation f) : image f ⟶ F'.I := (image.is_image f).lift F'
@[simp, reassoc]
lemma image.lift_fac (F' : mono_factorisation f) : image.lift F' ≫ F'.m = image.ι f :=
(image.is_image f).lift_fac' F'
@[simp, reassoc]
lemma image.fac_lift (F' : mono_factorisation f) : factor_thru_image f ≫ image.lift F' = F'.e :=
(image.is_image f).fac_lift F'
-- TODO we could put a category structure on `mono_factorisation f`,
-- with the morphisms being `g : I ⟶ I'` commuting with the `m`s
-- (they then automatically commute with the `e`s)
-- and show that an `image_of f` gives an initial object there
-- (uniqueness of the lift comes for free).
instance lift_mono (F' : mono_factorisation f) : mono.{v} (image.lift F') :=
begin
split, intros Z a b w,
have w' : a ≫ image.ι f = b ≫ image.ι f :=
calc a ≫ image.ι f = a ≫ (image.lift F' ≫ F'.m) : by simp
... = (a ≫ image.lift F') ≫ F'.m : by rw [category.assoc]
... = (b ≫ image.lift F') ≫ F'.m : by rw w
... = b ≫ (image.lift F' ≫ F'.m) : by rw [←category.assoc]
... = b ≫ image.ι f : by simp,
exact (cancel_mono (image.ι f)).1 w',
end
lemma has_image.uniq
(F' : mono_factorisation f) (l : image f ⟶ F'.I) (w : l ≫ F'.m = image.ι f) :
l = image.lift F' :=
(cancel_mono F'.m).1 (by simp [w])
end
section
variables (C)
/-- `has_images` represents a choice of image for every morphism -/
class has_images :=
(has_image : Π {X Y : C} (f : X ⟶ Y), has_image.{v} f)
attribute [instance, priority 100] has_images.has_image
end
section
variables (f) [has_image f]
/-- The image of a monomorphism is isomorphic to the source. -/
def image_mono_iso_source [mono f] : image f ≅ X :=
is_image.iso_ext (image.is_image f) (is_image.self f)
@[simp, reassoc]
lemma image_mono_iso_source_inv_ι [mono f] : (image_mono_iso_source f).inv ≫ image.ι f = f :=
by simp [image_mono_iso_source]
@[simp, reassoc]
lemma image_mono_iso_source_hom_self [mono f] : (image_mono_iso_source f).hom ≫ f = image.ι f :=
begin
conv { to_lhs, congr, skip, rw ←image_mono_iso_source_inv_ι f, },
rw [←category.assoc, iso.hom_inv_id, category.id_comp],
end
-- This is the proof from https://en.wikipedia.org/wiki/Image_(category_theory), which is taken from:
-- Mitchell, Barry (1965), Theory of categories, MR 0202787, p.12, Proposition 10.1
instance [Π {Z : C} (g h : image f ⟶ Z), has_limit.{v} (parallel_pair g h)] :
epi (factor_thru_image f) :=
⟨λ Z g h w,
begin
let q := equalizer.ι g h,
let e' := equalizer.lift _ w,
let F' : mono_factorisation f :=
{ I := equalizer g h,
m := q ≫ image.ι f,
m_mono := by apply mono_comp,
e := e' },
let v := image.lift F',
have t₀ : v ≫ q ≫ image.ι f = image.ι f := image.lift_fac F',
have t : v ≫ q = 𝟙 (image f) := (cancel_mono_id (image.ι f)).1 (by { convert t₀ using 1, rw category.assoc }),
-- The proof from wikipedia next proves `q ≫ v = 𝟙 _`,
-- and concludes that `equalizer g h ≅ image f`,
-- but this isn't necessary.
calc g = 𝟙 (image f) ≫ g : by rw [category.id_comp]
... = v ≫ q ≫ g : by rw [←t, category.assoc]
... = v ≫ q ≫ h : by rw [equalizer.condition g h]
... = 𝟙 (image f) ≫ h : by rw [←category.assoc, t]
... = h : by rw [category.id_comp]
end⟩
lemma epi_of_epi_image {X Y : C} (f : X ⟶ Y) [has_image f]
[epi (image.ι f)] [epi (factor_thru_image f)] : epi f :=
by { rw [←image.fac f], apply epi_comp, }
end
section
variables {f} {f' : X ⟶ Y} [has_image f] [has_image f']
/-- An equation between morphisms gives a comparison map between the images (which momentarily we prove is an iso). -/
def image.eq_to_hom (h : f = f') : image f ⟶ image f' :=
image.lift.{v}
{ I := image f',
m := image.ι f',
e := factor_thru_image f', }.
instance (h : f = f') : is_iso (image.eq_to_hom h) :=
{ inv := image.eq_to_hom h.symm,
hom_inv_id' := (cancel_mono (image.ι f)).1 (by simp [image.eq_to_hom]),
inv_hom_id' := (cancel_mono (image.ι f')).1 (by simp [image.eq_to_hom]), }
/-- An equation between morphisms gives an isomorphism between the images. -/
def image.eq_to_iso (h : f = f') : image f ≅ image f' := as_iso (image.eq_to_hom h)
end
section
variables {Z : C} (g : Y ⟶ Z)
/-- The comparison map `image (f ≫ g) ⟶ image g`. -/
def image.pre_comp [has_image g] [has_image (f ≫ g)] : image (f ≫ g) ⟶ image g :=
image.lift.{v}
{ I := image g,
m := image.ι g,
e := f ≫ factor_thru_image g }
/--
The two step comparison map
`image (f ≫ (g ≫ h)) ⟶ image (g ≫ h) ⟶ image h`
agrees with the one step comparison map
`image (f ≫ (g ≫ h)) ≅ image ((f ≫ g) ≫ h) ⟶ image h`.
-/
lemma image.pre_comp_comp {W : C} (h : Z ⟶ W)
[has_image (g ≫ h)] [has_image (f ≫ g ≫ h)]
[has_image h] [has_image ((f ≫ g) ≫ h)] :
image.pre_comp f (g ≫ h) ≫ image.pre_comp g h = image.eq_to_hom (category.assoc f g h).symm ≫ (image.pre_comp (f ≫ g) h) :=
begin
apply (cancel_mono (image.ι h)).1,
simp [image.pre_comp, image.eq_to_hom],
end
-- Note that in general we don't have the other comparison map you might expect
-- `image f ⟶ image (f ≫ g)`.
end
end category_theory.limits
namespace category_theory.limits
variables {C : Type u} [category.{v} C]
section
instance {X Y : C} (f : X ⟶ Y) [has_image f] : has_image (arrow.mk f).hom :=
show has_image f, by apply_instance
end
section has_image_map
/-- An image map is a morphism `image f → image g` fitting into a commutative square and satisfying
the obvious commutativity conditions. -/
class has_image_map {f g : arrow C} [has_image f.hom] [has_image g.hom] (sq : f ⟶ g) :=
(map : image f.hom ⟶ image g.hom)
(map_ι' : map ≫ image.ι g.hom = image.ι f.hom ≫ sq.right . obviously)
restate_axiom has_image_map.map_ι'
attribute [simp, reassoc] has_image_map.map_ι
@[simp, reassoc]
lemma has_image_map.factor_map {f g : arrow C} [has_image f.hom] [has_image g.hom] (sq : f ⟶ g)
[has_image_map sq] :
factor_thru_image f.hom ≫ has_image_map.map sq = sq.left ≫ factor_thru_image g.hom :=
(cancel_mono (image.ι g.hom)).1 $ by simp [arrow.w]
variables {f g : arrow C} [has_image f.hom] [has_image g.hom] (sq : f ⟶ g)
section
local attribute [ext] has_image_map
instance : subsingleton (has_image_map sq) :=
subsingleton.intro $ λ a b, has_image_map.ext a b $ (cancel_mono (image.ι g.hom)).1 $
by simp only [has_image_map.map_ι]
end
variable [has_image_map sq]
/-- The map on images induced by a commutative square. -/
abbreviation image.map : image f.hom ⟶ image g.hom := has_image_map.map sq
lemma image.factor_map :
factor_thru_image f.hom ≫ image.map sq = sq.left ≫ factor_thru_image g.hom :=
by simp
lemma image.map_ι : image.map sq ≫ image.ι g.hom = image.ι f.hom ≫ sq.right :=
by simp
lemma image.map_hom_mk'_ι {X Y P Q : C} {k : X ⟶ Y} [has_image k] {l : P ⟶ Q} [has_image l]
{m : X ⟶ P} {n : Y ⟶ Q} (w : m ≫ l = k ≫ n) [has_image_map (arrow.hom_mk' w)] :
image.map (arrow.hom_mk' w) ≫ image.ι l = image.ι k ≫ n :=
image.map_ι _
section
variables {h : arrow C} [has_image h.hom] (sq' : g ⟶ h)
variables [has_image_map sq']
/-- Image maps for composable commutative squares induce an image map in the composite square. -/
def has_image_map_comp : has_image_map (sq ≫ sq') :=
{ map := image.map sq ≫ image.map sq' }
@[simp]
lemma image.map_comp [has_image_map (sq ≫ sq')] :
image.map (sq ≫ sq') = image.map sq ≫ image.map sq' :=
show (has_image_map.map (sq ≫ sq')) = (has_image_map_comp sq sq').map, by congr
end
section
variables (f)
/-- The identity `image f ⟶ image f` fits into the commutative square represented by the identity
morphism `𝟙 f` in the arrow category. -/
def has_image_map_id : has_image_map (𝟙 f) :=
{ map := 𝟙 (image f.hom) }
@[simp]
lemma image.map_id [has_image_map (𝟙 f)] : image.map (𝟙 f) = 𝟙 (image f.hom) :=
show (image.map (𝟙 f)) = (has_image_map_id f).map, by congr
end
end has_image_map
section
variables (C) [has_images.{v} C]
/-- If a category `has_image_maps`, then all commutative squares induce morphisms on images. -/
class has_image_maps :=
(has_image_map : Π {f g : arrow C} (st : f ⟶ g), has_image_map st)
attribute [instance, priority 100] has_image_maps.has_image_map
end
section has_image_maps
variables [has_images.{v} C] [has_image_maps.{v} C]
/-- The functor from the arrow category of `C` to `C` itself that maps a morphism to its image
and a commutative square to the induced morphism on images. -/
@[simps]
def im : arrow C ⥤ C :=
{ obj := λ f, image f.hom,
map := λ _ _ st, image.map st }
end has_image_maps
section strong_epi_mono_factorisation
/-- A strong epi-mono factorisation is a decomposition `f = e ≫ m` with `e` a strong epimorphism
and `m` a monomorphism. -/
structure strong_epi_mono_factorisation {X Y : C} (f : X ⟶ Y) extends mono_factorisation.{v} f :=
[e_strong_epi : strong_epi e]
attribute [instance] strong_epi_mono_factorisation.e_strong_epi
/-- Satisfying the inhabited linter -/
instance strong_epi_mono_factorisation_inhabited {X Y : C} (f : X ⟶ Y) [strong_epi f] :
inhabited (strong_epi_mono_factorisation f) :=
⟨⟨⟨Y, 𝟙 Y, f, by simp⟩⟩⟩
/-- A mono factorisation coming from a strong epi-mono factorisation always has the universal
property of the image. -/
def strong_epi_mono_factorisation.to_mono_is_image {X Y : C} {f : X ⟶ Y}
(F : strong_epi_mono_factorisation f) : is_image F.to_mono_factorisation :=
{ lift := λ G, arrow.lift $ arrow.hom_mk' $
show G.e ≫ G.m = F.e ≫ F.m, by rw [F.to_mono_factorisation.fac, G.fac] }
variable (C)
/-- A category has strong epi-mono factorisations if every morphism admits a strong epi-mono
factorisation. -/
class has_strong_epi_mono_factorisations :=
(has_fac : Π {X Y : C} (f : X ⟶ Y), strong_epi_mono_factorisation.{v} f)
@[priority 100]
instance has_images_of_has_strong_epi_mono_factorisations
[has_strong_epi_mono_factorisations.{v} C] : has_images.{v} C :=
{ has_image := λ X Y f,
let F' := has_strong_epi_mono_factorisations.has_fac f in
{ F := F'.to_mono_factorisation,
is_image := F'.to_mono_is_image } }
end strong_epi_mono_factorisation
section has_strong_epi_images
variables (C) [has_images.{v} C]
/-- A category has strong epi images if it has all images and `factor_thru_image f` is a strong
epimorphism for all `f`. -/
class has_strong_epi_images :=
(strong_factor_thru_image : Π {X Y : C} (f : X ⟶ Y), strong_epi.{v} (factor_thru_image f))
attribute [instance] has_strong_epi_images.strong_factor_thru_image
end has_strong_epi_images
section has_strong_epi_images
/-- If we constructed our images from strong epi-mono factorisations, then these images are
strong epi images. -/
@[priority 100]
instance has_strong_epi_images_of_has_strong_epi_mono_factorisations
[has_strong_epi_mono_factorisations.{v} C] : has_strong_epi_images.{v} C :=
{ strong_factor_thru_image := λ X Y f,
(has_strong_epi_mono_factorisations.has_fac f).e_strong_epi }
end has_strong_epi_images
section has_strong_epi_images
variables [has_images.{v} C]
/-- A category with strong epi images has image maps. The construction is taken from Borceux,
Handbook of Categorical Algebra 1, Proposition 4.4.5. -/
@[priority 100]
instance has_image_maps_of_has_strong_epi_images [has_strong_epi_images.{v} C] :
has_image_maps.{v} C :=
{ has_image_map := λ f g st,
let I := image (image.ι f.hom ≫ st.right) in
let I' := image (st.left ≫ factor_thru_image g.hom) in
let upper : strong_epi_mono_factorisation (f.hom ≫ st.right) :=
{ I := I,
e := factor_thru_image f.hom ≫ factor_thru_image (image.ι f.hom ≫ st.right),
m := image.ι (image.ι f.hom ≫ st.right),
e_strong_epi := strong_epi_comp _ _,
m_mono := by apply_instance } in
let lower : strong_epi_mono_factorisation (f.hom ≫ st.right) :=
{ I := I',
e := factor_thru_image (st.left ≫ factor_thru_image g.hom),
m := image.ι (st.left ≫ factor_thru_image g.hom) ≫ image.ι g.hom,
fac' := by simp [arrow.w],
e_strong_epi := by apply_instance,
m_mono := mono_comp _ _ } in
let s : I ⟶ I' := is_image.lift upper.to_mono_is_image lower.to_mono_factorisation in
{ map := factor_thru_image (image.ι f.hom ≫ st.right) ≫ s ≫
image.ι (st.left ≫ factor_thru_image g.hom),
map_ι' := by rw [category.assoc, category.assoc,
is_image.lift_fac upper.to_mono_is_image lower.to_mono_factorisation, image.fac] } }
end has_strong_epi_images
end category_theory.limits
|
10d334a47eb7986a69eabaa335009838e6595ca0 | ae1e94c332e17c7dc7051ce976d5a9eebe7ab8a5 | /stage0/src/Lean/Compiler/IR/ResetReuse.lean | eeb998f4e486a7acdcd3b73a314514e1934a6cbc | [
"Apache-2.0"
] | permissive | dupuisf/lean4 | d082d13b01243e1de29ae680eefb476961221eef | 6a39c65bd28eb0e28c3870188f348c8914502718 | refs/heads/master | 1,676,948,755,391 | 1,610,665,114,000 | 1,610,665,114,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 6,198 | 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.IR.Basic
import Lean.Compiler.IR.LiveVars
import Lean.Compiler.IR.Format
namespace Lean.IR.ResetReuse
/- Remark: the insertResetReuse transformation is applied before we have
inserted `inc/dec` instructions, and perfomed lower level optimizations
that introduce the instructions `release` and `set`. -/
/- Remark: the functions `S`, `D` and `R` defined here implement the
corresponding functions in the paper "Counting Immutable Beans"
Here are the main differences:
- We use the State monad to manage the generation of fresh variable names.
- Support for join points, and `uset` and `sset` instructions for unboxed data.
- `D` uses the auxiliary function `Dmain`.
- `Dmain` returns a pair `(b, found)` to avoid quadratic behavior when checking
the last occurrence of the variable `x`.
- Because we have join points in the actual implementation, a variable may be live even if it
does not occur in a function body. See example at `livevars.lean`.
-/
private def mayReuse (c₁ c₂ : CtorInfo) : Bool :=
c₁.size == c₂.size && c₁.usize == c₂.usize && c₁.ssize == c₂.ssize &&
/- The following condition is a heuristic.
We don't want to reuse cells from different types even when they are compatible
because it produces counterintuitive behavior. -/
c₁.name.getPrefix == c₂.name.getPrefix
private partial def S (w : VarId) (c : CtorInfo) : FnBody → FnBody
| FnBody.vdecl x t v@(Expr.ctor c' ys) b =>
if mayReuse c c' then
let updtCidx := c.cidx != c'.cidx
FnBody.vdecl x t (Expr.reuse w c' updtCidx ys) b
else
FnBody.vdecl x t v (S w c b)
| FnBody.jdecl j ys v b =>
let v' := S w c v
if v == v' then FnBody.jdecl j ys v (S w c b)
else FnBody.jdecl j ys v' b
| FnBody.case tid x xType alts => FnBody.case tid x xType $ alts.map $ fun alt => alt.modifyBody (S w c)
| b =>
if b.isTerminal then b
else let
(instr, b) := b.split
instr.setBody (S w c b)
/- We use `Context` to track join points in scope. -/
abbrev M := ReaderT LocalContext (StateT Index Id)
private def mkFresh : M VarId := do
let idx ← getModify (fun n => n + 1)
pure { idx := idx }
private def tryS (x : VarId) (c : CtorInfo) (b : FnBody) : M FnBody := do
let w ← mkFresh
let b' := S w c b
if b == b' then pure b
else pure $ FnBody.vdecl w IRType.object (Expr.reset c.size x) b'
private def Dfinalize (x : VarId) (c : CtorInfo) : FnBody × Bool → M FnBody
| (b, true) => pure b
| (b, false) => tryS x c b
private def argsContainsVar (ys : Array Arg) (x : VarId) : Bool :=
ys.any fun arg => match arg with
| Arg.var y => x == y
| _ => false
private def isCtorUsing (b : FnBody) (x : VarId) : Bool :=
match b with
| (FnBody.vdecl _ _ (Expr.ctor _ ys) _) => argsContainsVar ys x
| _ => false
/- Given `Dmain b`, the resulting pair `(new_b, flag)` contains the new body `new_b`,
and `flag == true` if `x` is live in `b`.
Note that, in the function `D` defined in the paper, for each `let x := e; F`,
`D` checks whether `x` is live in `F` or not. This is great for clarity but it
is expensive: `O(n^2)` where `n` is the size of the function body. -/
private partial def Dmain (x : VarId) (c : CtorInfo) : FnBody → M (FnBody × Bool)
| e@(FnBody.case tid y yType alts) => do
let ctx ← read
if e.hasLiveVar ctx x then do
/- If `x` is live in `e`, we recursively process each branch. -/
let alts ← alts.mapM fun alt => alt.mmodifyBody fun b => Dmain x c b >>= Dfinalize x c
pure (FnBody.case tid y yType alts, true)
else pure (e, false)
| FnBody.jdecl j ys v b => do
let (b, found) ← withReader (fun ctx => ctx.addJP j ys v) (Dmain x c b)
let (v, _ /- found' -/) ← Dmain x c v
/- If `found' == true`, then `Dmain b` must also have returned `(b, true)` since
we assume the IR does not have dead join points. So, if `x` is live in `j` (i.e., `v`),
then it must also live in `b` since `j` is reachable from `b` with a `jmp`.
On the other hand, `x` may be live in `b` but dead in `j` (i.e., `v`). -/
pure (FnBody.jdecl j ys v b, found)
| e => do
let ctx ← read
if e.isTerminal then
pure (e, e.hasLiveVar ctx x)
else do
let (instr, b) := e.split
if isCtorUsing instr x then
/- If the scrutinee `x` (the one that is providing memory) is being
stored in a constructor, then reuse will probably not be able to reuse memory at runtime.
It may work only if the new cell is consumed, but we ignore this case. -/
pure (e, true)
else
let (b, found) ← Dmain x c b
/- Remark: it is fine to use `hasFreeVar` instead of `hasLiveVar`
since `instr` is not a `FnBody.jmp` (it is not a terminal) nor it is a `FnBody.jdecl`. -/
if found || !instr.hasFreeVar x then
pure (instr.setBody b, found)
else
let b ← tryS x c b
pure (instr.setBody b, true)
private def D (x : VarId) (c : CtorInfo) (b : FnBody) : M FnBody :=
Dmain x c b >>= Dfinalize x c
partial def R : FnBody → M FnBody
| FnBody.case tid x xType alts => do
let alts ← alts.mapM fun alt => do
let alt ← alt.mmodifyBody R
match alt with
| Alt.ctor c b =>
if c.isScalar then pure alt
else Alt.ctor c <$> D x c b
| _ => pure alt
pure $ FnBody.case tid x xType alts
| FnBody.jdecl j ys v b => do
let v ← R v
let b ← withReader (fun ctx => ctx.addJP j ys v) (R b)
pure $ FnBody.jdecl j ys v b
| e => do
if e.isTerminal then pure e
else do
let (instr, b) := e.split
let b ← R b
pure (instr.setBody b)
end ResetReuse
open ResetReuse
def Decl.insertResetReuse : Decl → Decl
| d@(Decl.fdecl f xs t b) =>
let nextIndex := d.maxIndex + 1
let b := (R b {}).run' nextIndex
Decl.fdecl f xs t b
| other => other
end Lean.IR
|
f9358ffbe5584942d8ee853958fc348d6c9c3468 | 57c233acf9386e610d99ed20ef139c5f97504ba3 | /src/data/finset/option.lean | 9463ca34bc409470d16f7fbc982928ad767fc2a6 | [
"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 | 4,379 | lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Mario Carneiro, Sean Leather
-/
import data.finset.card
import order.hom.basic
/-!
# Finite sets in `option α`
In this file we define
* `option.to_finset`: construct an empty or singleton `finset α` from an `option α`;
* `finset.insert_none`: given `s : finset α`, lift it to a finset on `option α` using `option.some`
and then insert `option.none`;
* `finset.erase_none`: given `s : finset (option α)`, returns `t : finset α` such that
`x ∈ t ↔ some x ∈ s`.
Then we prove some basic lemmas about these definitions.
## Tags
finset, option
-/
variables {α β : Type*}
open function
namespace option
/-- Construct an empty or singleton finset from an `option` -/
def to_finset (o : option α) : finset α := o.elim ∅ singleton
@[simp] theorem to_finset_none : none.to_finset = (∅ : finset α) := rfl
@[simp] theorem to_finset_some {a : α} : (some a).to_finset = {a} := rfl
@[simp] theorem mem_to_finset {a : α} {o : option α} : a ∈ o.to_finset ↔ a ∈ o :=
by cases o; simp [eq_comm]
theorem card_to_finset (o : option α) : o.to_finset.card = o.elim 0 1 :=
by cases o; refl
end option
namespace finset
/-- Given a finset on `α`, lift it to being a finset on `option α`
using `option.some` and then insert `option.none`. -/
def insert_none : finset α ↪o finset (option α) :=
order_embedding.of_map_le_iff (λ s, cons none (s.map embedding.some) $ by simp) $ λ s t,
cons_subset_cons.trans map_subset_map
/-⟨none ::ₘ s.1.map some, multiset.nodup_cons.2
⟨by simp, multiset.nodup_map (λ a b, option.some.inj) s.2⟩⟩-/
@[simp] theorem mem_insert_none {s : finset α} : ∀ {o : option α},
o ∈ s.insert_none ↔ ∀ a ∈ o, a ∈ s
| none := iff_of_true (multiset.mem_cons_self _ _) (λ a h, by cases h)
| (some a) := multiset.mem_cons.trans $ by simp; refl
theorem some_mem_insert_none {s : finset α} {a : α} :
some a ∈ s.insert_none ↔ a ∈ s := by simp
@[simp] theorem card_insert_none (s : finset α) : s.insert_none.card = s.card + 1 :=
by simp [insert_none]
/-- Given `s : finset (option α)`, `s.erase_none : finset α` is the set of `x : α` such that
`some x ∈ s`. -/
def erase_none : finset (option α) →o finset α :=
(finset.map_embedding (equiv.option_is_some_equiv α).to_embedding).to_order_hom.comp
⟨finset.subtype _, subtype_mono⟩
@[simp] lemma mem_erase_none {s : finset (option α)} {x : α} :
x ∈ s.erase_none ↔ some x ∈ s :=
by simp [erase_none]
lemma erase_none_eq_bUnion [decidable_eq α] (s : finset (option α)) :
s.erase_none = s.bUnion option.to_finset :=
by { ext, simp }
@[simp] lemma erase_none_map_some (s : finset α) : (s.map embedding.some).erase_none = s :=
by { ext, simp }
@[simp] lemma erase_none_image_some [decidable_eq (option α)] (s : finset α) :
(s.image some).erase_none = s :=
by simpa only [map_eq_image] using erase_none_map_some s
@[simp] lemma coe_erase_none (s : finset (option α)) :
(s.erase_none : set α) = some ⁻¹' s :=
set.ext $ λ x, mem_erase_none
@[simp] lemma erase_none_union [decidable_eq (option α)] [decidable_eq α]
(s t : finset (option α)) :
(s ∪ t).erase_none = s.erase_none ∪ t.erase_none :=
by { ext, simp }
@[simp] lemma erase_none_inter [decidable_eq (option α)] [decidable_eq α]
(s t : finset (option α)) :
(s ∩ t).erase_none = s.erase_none ∩ t.erase_none :=
by { ext, simp }
@[simp] lemma erase_none_empty : (∅ : finset (option α)).erase_none = ∅ := by { ext, simp }
@[simp] lemma erase_none_none : ({none} : finset (option α)).erase_none = ∅ := by { ext, simp }
@[simp] lemma image_some_erase_none [decidable_eq (option α)] (s : finset (option α)) :
s.erase_none.image some = s.erase none :=
by ext (_|x); simp
@[simp] lemma map_some_erase_none [decidable_eq (option α)] (s : finset (option α)) :
s.erase_none.map embedding.some = s.erase none :=
by rw [map_eq_image, embedding.some_apply, image_some_erase_none]
@[simp] lemma insert_none_erase_none [decidable_eq (option α)] (s : finset (option α)) :
insert_none (erase_none s) = insert none s :=
by ext (_|x); simp
@[simp] lemma erase_none_insert_none (s : finset α) : erase_none (insert_none s) = s :=
by { ext, simp }
end finset
|
b164c73f43f23bb7c5d8960a40e67e110aa8fc84 | ea11767c9c6a467c4b7710ec6f371c95cfc023fd | /src/monoidal_categories/enriched/default.lean | 1a24adfdfefb68524a056750c35a100a645d443c | [] | no_license | RitaAhmadi/lean-monoidal-categories | 68a23f513e902038e44681336b87f659bbc281e0 | 81f43e1e0d623a96695aa8938951d7422d6d7ba6 | refs/heads/master | 1,651,458,686,519 | 1,529,824,613,000 | 1,529,824,613,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,145 | lean | import ..monoidal_category
import categories.types
open categories
open categories.monoidal_category
universes u₁ v₁
class enriched_category (C : Type u₁) extends category.{u₁ v₁} C :=
(V : Type (v₁+1))
[𝒱 : monoidal_category V]
(F : V ↝ (Type v₁)) -- needs to be a monoidal functor
(enriched_hom : C → C → V)
(enriched_identity : Π X : C, (monoidal_category.tensor_unit V) ⟶ (enriched_hom X X))
(enriched_composition : Π X Y Z : C, (enriched_hom X Y) ⊗ (enriched_hom Y Z) ⟶ (enriched_hom X Z))
(underlying_type_of_enriched_hom : Π X Y : C, F +> (enriched_hom X Y) = (X ⟶ Y))
(underlying_function_of_enriched_identity : Π X : C, sorry)
(underlying_function_of_enriched_composition : Π X Y Z : C, sorry)
class enriched_category' (C : Type u₁) (V : Type v₁) [𝒱 : monoidal_category V] :=
(Hom : C → C → V)
(identity : Π X : C, (monoidal_category.tensor_unit V) ⟶ (Hom X X))
(compose : Π {X Y Z : C}, (Hom X Y) ⊗ (Hom Y Z) ⟶ Hom X Z)
(left_identity : ∀ {X Y : C}, sorry)
(right_identity : ∀ {X Y : C}, sorry)
(associativity : ∀ {W X Y Z : C}, sorry)
|
9f05f29c711601810e2b96c5906ac3e0f133a6ad | 83c8119e3298c0bfc53fc195c41a6afb63d01513 | /tests/lean/run/local_attribute.lean | cf36cce450b9fb85a1d17583eb0d1d9613ff9629 | [
"Apache-2.0"
] | permissive | anfelor/lean | 584b91c4e87a6d95f7630c2a93fb082a87319ed0 | 31cfc2b6bf7d674f3d0f73848b842c9c9869c9f1 | refs/heads/master | 1,610,067,141,310 | 1,585,992,232,000 | 1,585,992,232,000 | 251,683,543 | 0 | 0 | Apache-2.0 | 1,585,676,570,000 | 1,585,676,569,000 | null | UTF-8 | Lean | false | false | 238 | lean |
local attribute [instance, priority 0] classical.prop_decidable
open tactic
run_cmd do
(p,_) ← has_attribute `instance ``nat.monoid,
guard p,
(p,_) ← has_attribute `instance ``classical.prop_decidable,
guard (¬ p),
skip
|
03971d805c5aaf50d2da11c59f95fed0405eeee0 | 9e47285bdd500b89455fd905c20aabcd3af1a5cf | /ak_compat.lean | 0c74a00f0056a3c4db7cbca14ba74a52c1db3126 | [] | no_license | akreuzer/feteke-lean | d4ec120e3e7dab9d36681499b239f0e57eb18349 | d030101b3ab2aa4155c2aa1a84021e833da3a497 | refs/heads/master | 1,610,987,214,936 | 1,490,906,196,000 | 1,490,906,196,000 | 86,744,981 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,763 | lean | import theories.analysis.real_limit
import standard
namespace ak_compat
open classical nat real analysis
/- These are definition from an old version of lean2.
We reintroduce them here to fix a regression.
-/
noncomputable definition converges_to_seq (X : ℕ → ℝ) (y : ℝ) : Prop :=
∀ ⦃ε : ℝ⦄, ε > 0 → ∃ ⦃N : ℕ⦄, ∀ ⦃n : ℕ⦄, n ≥ N → abs (X n - y) < ε
noncomputable definition converges_seq (X : ℕ → ℝ): Prop :=
∃ y : ℝ , converges_to_seq X y
noncomputable definition limit_seq (X : ℕ → ℝ) (H : ak_compat.converges_seq X) : ℝ := some H
proposition converges_to_limit_seq (X : ℕ → ℝ) (H : ak_compat.converges_seq X) :
converges_to_seq X (limit_seq X H) := epsilon_spec H
proposition converges_to_seq_unique {X : ℕ → ℝ} {y₁ y₂ : ℝ} (H₁ : converges_to_seq X y₁) (H₂ : converges_to_seq X y₂) : y₁ = y₂ :=
eq_of_forall_dist_le
(take ε, suppose ε > 0,
have e2pos : ε / 2 > 0, from div_pos_of_pos_of_pos `ε > 0` two_pos,
obtain N₁ (HN₁ : ∀ {n}, n ≥ N₁ → dist (X n) y₁ < ε / 2), from H₁ e2pos,
obtain N₂ (HN₂ : ∀ {n}, n ≥ N₂ → dist (X n) y₂ < ε / 2), from H₂ e2pos,
let N := max N₁ N₂ in
have dN₁ : dist (X N) y₁ < ε / 2, from HN₁ !le_max_left,
have dN₂ : dist (X N) y₂ < ε / 2, from HN₂ !le_max_right,
have dist y₁ y₂ < ε, from calc
dist y₁ y₂ ≤ dist y₁ (X N) + dist (X N) y₂ : dist_triangle
... = dist (X N) y₁ + dist (X N) y₂ : dist_comm
... < ε / 2 + ε / 2 : add_lt_add dN₁ dN₂
... = ε : add_halves,
show dist y₁ y₂ ≤ ε, from le_of_lt this)
end ak_compat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.