text
stringlengths 0
3.34M
|
---|
lemma bilinear_times: fixes c::"'a::real_algebra" shows "bilinear (\<lambda>x y::'a. x*y)" |
[STATEMENT]
lemma hom_delta: "hom_ab (delta_a x br) = delta_b x (hom_ab br)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. hom_ab (delta_a x br) = delta_b x (hom_ab br)
[PROOF STEP]
by(cases br) (auto simp add: Let_def) |
State Before: R : Type u_2
inst✝² : CommRing R
S : Submonoid R
P : Type u_1
inst✝¹ : CommRing P
inst✝ : Algebra R P
loc : IsLocalization S P
⊢ ↑1 = 1 State After: no goals Tactic: rw [coe_one_eq_coeSubmodule_top, coeSubmodule_top] |
[STATEMENT]
lemma switch_triangle:"(v=c>u) \<and> (v=d>w) \<longrightarrow> (u=d>w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. v = c > u \<and> v = d > w \<longrightarrow> u = d > w
[PROOF STEP]
using switch_def
[PROOF STATE]
proof (prove)
using this:
?v = ?c > ?w \<equiv> ext ?v = ext ?w \<and> lan ?v = lan ?w \<and> own ?w = ?c \<and> more ?v = more ?w
goal (1 subgoal):
1. v = c > u \<and> v = d > w \<longrightarrow> u = d > w
[PROOF STEP]
by auto |
[STATEMENT]
lemma fags_mem:"fags_cond f z i a \<Longrightarrow> (n\<Odot>a\<^bsub>f,i,z\<^esub>) \<in> fags_carr f z i a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fags_cond f z i a \<Longrightarrow> n\<Odot>a\<^bsub>f,i,z\<^esub> \<in> fags_carr f z i a
[PROOF STEP]
apply (simp add:fags_carr_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fags_cond f z i a \<Longrightarrow> \<exists>na. n\<Odot>a\<^bsub>f,i,z\<^esub> = na\<Odot>a\<^bsub>f,i,z\<^esub>
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done |
[STATEMENT]
lemma action_exhaust2: "actn = WB \<or> actn = WO \<or> actn = L \<or> actn = R \<or> actn = Nop"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. actn = WB \<or> actn = WO \<or> actn = L \<or> actn = R \<or> actn = Nop
[PROOF STEP]
by (rule Turing.action.exhaust) auto |
Require Import VST.floyd.proofauto.
Require Import onepile.
Require Import spec_stdlib.
Require Import PileModel.
Record OnePileAPD := {
onepile: option (list Z) -> globals -> mpred
}.
Local Open Scope assert.
Section OnepileASI.
Variable M: MallocFreeAPD.
Variable ONEPILE:OnePileAPD.
Definition Onepile_init_spec :=
DECLARE _Onepile_init
WITH gv: globals
PRE [ ]
PROP() PARAMS () GLOBALS (gv) SEP(onepile ONEPILE None gv; mem_mgr M gv)
POST[ tvoid ]
PROP() LOCAL() SEP(onepile ONEPILE (Some nil) gv; mem_mgr M gv).
Definition Onepile_add_spec :=
DECLARE _Onepile_add
WITH n: Z, sigma: list Z, gv: globals
PRE [ tint ]
PROP(0 <= n <= Int.max_signed)
PARAMS (Vint (Int.repr n)) GLOBALS (gv)
SEP(onepile ONEPILE (Some sigma) gv; mem_mgr M gv)
POST[ tvoid ]
PROP() LOCAL()
SEP(onepile ONEPILE (Some (n::sigma)) gv; mem_mgr M gv).
Definition Onepile_count_spec :=
DECLARE _Onepile_count
WITH sigma: list Z, gv: globals
PRE [ ]
PROP(0 <= sumlist sigma <= Int.max_signed)
PARAMS () GLOBALS (gv)
SEP(onepile ONEPILE (Some sigma) gv)
POST[ tint ]
PROP()
LOCAL(temp ret_temp (Vint (Int.repr (sumlist sigma))))
SEP(onepile ONEPILE (Some sigma) gv).
Definition OnepileASI:funspecs := [ Onepile_init_spec; Onepile_add_spec; Onepile_count_spec].
End OnepileASI. |
Formal statement is: lemma small_big_trans': "f \<in> l F (g) \<Longrightarrow> g \<in> L F (h) \<Longrightarrow> f \<in> L F (h)" Informal statement is: If $f$ is small with respect to $g$ and $g$ is big with respect to $h$, then $f$ is big with respect to $h$. |
Formal statement is: lemma compact_components: fixes s :: "'a::heine_borel set" shows "\<lbrakk>compact s; c \<in> components s\<rbrakk> \<Longrightarrow> compact c" Informal statement is: If $s$ is a compact set and $c$ is a component of $s$, then $c$ is compact. |
Formal statement is: lemma complex_eq_iff: "x = y \<longleftrightarrow> Re x = Re y \<and> Im x = Im y" Informal statement is: Two complex numbers are equal if and only if their real and imaginary parts are equal. |
#ifndef OPENMC_TALLIES_FILTER_ENERGY_H
#define OPENMC_TALLIES_FILTER_ENERGY_H
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
//==============================================================================
//! Bins the incident neutron energy.
//==============================================================================
class EnergyFilter : public Filter {
public:
//----------------------------------------------------------------------------
// Constructors, destructors
~EnergyFilter() = default;
//----------------------------------------------------------------------------
// Methods
std::string type() const override { return "energy"; }
void from_xml(pugi::xml_node node) override;
void get_all_bins(const Particle& p, TallyEstimator estimator,
FilterMatch& match) const override;
void to_statepoint(hid_t filter_group) const override;
std::string text_label(int bin) const override;
//----------------------------------------------------------------------------
// Accessors
const vector<double>& bins() const { return bins_; }
void set_bins(gsl::span<const double> bins);
bool matches_transport_groups() const { return matches_transport_groups_; }
protected:
//----------------------------------------------------------------------------
// Data members
vector<double> bins_;
//! True if transport group number can be used directly to get bin number
bool matches_transport_groups_ {false};
};
//==============================================================================
//! Bins the outgoing neutron energy.
//!
//! Only scattering events use the get_all_bins functionality. Nu-fission
//! tallies manually iterate over the filter bins.
//==============================================================================
class EnergyoutFilter : public EnergyFilter {
public:
//----------------------------------------------------------------------------
// Methods
std::string type() const override { return "energyout"; }
void get_all_bins(const Particle& p, TallyEstimator estimator,
FilterMatch& match) const override;
std::string text_label(int bin) const override;
};
} // namespace openmc
#endif // OPENMC_TALLIES_FILTER_ENERGY_H
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Monoidal where
open import Level
open import Categories.Category
open import Categories.Bifunctor using (Bifunctor)
open import Categories.NaturalIsomorphism
open import Categories.NaturalTransformation using (_∘₁_) renaming (_≡_ to _≡ⁿ_)
open import Categories.Monoidal.Helpers
record Monoidal {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where
private module C = Category C
open C hiding (id; identityˡ; identityʳ; assoc)
field
⊗ : Bifunctor C C C
id : Obj
open MonoidalHelperFunctors C ⊗ id
field
identityˡ : NaturalIsomorphism id⊗x x
identityʳ : NaturalIsomorphism x⊗id x
assoc : NaturalIsomorphism [x⊗y]⊗z x⊗[y⊗z]
open Coherence identityˡ identityʳ assoc
field
.triangle : TriangleLeftSide ≡ⁿ (TriangleRightSide ∘₁ TriangleTopSide)
.pentagon : (PentagonNESide ∘₁ PentagonNWSide) ≡ⁿ (PentagonSESide ∘₁ (PentagonSSide ∘₁ PentagonSWSide)) |
/-
Copyright (c) 2021 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import category_theory.preadditive.basic
/-!
# Preadditive structure on functor categories
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
If `C` and `D` are categories and `D` is preadditive,
then `C ⥤ D` is also preadditive.
-/
open_locale big_operators
namespace category_theory
open category_theory.limits preadditive
variables {C D : Type*} [category C] [category D] [preadditive D]
instance functor_category_preadditive : preadditive (C ⥤ D) :=
{ hom_group := λ F G,
{ add := λ α β,
{ app := λ X, α.app X + β.app X,
naturality' := by { intros, rw [comp_add, add_comp, α.naturality, β.naturality] } },
zero := { app := λ X, 0, naturality' := by { intros, rw [zero_comp, comp_zero] } },
neg := λ α,
{ app := λ X, -α.app X,
naturality' := by { intros, rw [comp_neg, neg_comp, α.naturality] } },
sub := λ α β,
{ app := λ X, α.app X - β.app X,
naturality' := by { intros, rw [comp_sub, sub_comp, α.naturality, β.naturality] } },
add_assoc := by { intros, ext, apply add_assoc },
zero_add := by { intros, ext, apply zero_add },
add_zero := by { intros, ext, apply add_zero },
sub_eq_add_neg := by { intros, ext, apply sub_eq_add_neg },
add_left_neg := by { intros, ext, apply add_left_neg },
add_comm := by { intros, ext, apply add_comm } },
add_comp' := by { intros, ext, apply add_comp },
comp_add' := by { intros, ext, apply comp_add } }
namespace nat_trans
variables {F G : C ⥤ D}
/-- Application of a natural transformation at a fixed object,
as group homomorphism -/
@[simps] def app_hom (X : C) : (F ⟶ G) →+ (F.obj X ⟶ G.obj X) :=
{ to_fun := λ α, α.app X,
map_zero' := rfl,
map_add' := λ _ _, rfl }
@[simp] lemma app_zero (X : C) : (0 : F ⟶ G).app X = 0 := rfl
@[simp]
@[simp] lemma app_sub (X : C) (α β : F ⟶ G) : (α - β).app X = α.app X - β.app X := rfl
@[simp] lemma app_neg (X : C) (α : F ⟶ G) : (-α).app X = -α.app X := rfl
@[simp] lemma app_nsmul (X : C) (α : F ⟶ G) (n : ℕ) : (n • α).app X = n • α.app X :=
(app_hom X).map_nsmul α n
@[simp] lemma app_zsmul (X : C) (α : F ⟶ G) (n : ℤ) : (n • α).app X = n • α.app X :=
(app_hom X : (F ⟶ G) →+ (F.obj X ⟶ G.obj X)).map_zsmul α n
@[simp] lemma app_sum {ι : Type*} (s : finset ι) (X : C) (α : ι → (F ⟶ G)) :
(∑ i in s, α i).app X = ∑ i in s, ((α i).app X) :=
by { rw [← app_hom_apply, add_monoid_hom.map_sum], refl }
end nat_trans
end category_theory
|
source("init.r")
api <- DefaultApi$new()
all.users.id <- api$read_users()$content$id
department.people.count <- list()
for (i in all.users.id) {
u <- api$read_user(i)$content
dept <- u$department
if (!(dept %in% names(department.people.count))) {
department.people.count[[ dept ]] <- 0
}
department.people.count[[ dept ]] <- department.people.count[[ dept ]] + 1
}
barplot(unlist(department.people.count), main="Employee count per department")
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.AbGroup.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Transport
open import Cubical.Foundations.SIP
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.CommMonoid
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.DirProd
open import Cubical.Displayed.Base
open import Cubical.Displayed.Auto
open import Cubical.Displayed.Record
open import Cubical.Displayed.Universe
open Iso
private
variable
ℓ ℓ' : Level
record IsAbGroup {G : Type ℓ}
(0g : G) (_+_ : G → G → G) (-_ : G → G) : Type ℓ where
constructor isabgroup
field
isGroup : IsGroup 0g _+_ -_
comm : (x y : G) → x + y ≡ y + x
open IsGroup isGroup public
record AbGroupStr (A : Type ℓ) : Type (ℓ-suc ℓ) where
constructor abgroupstr
field
0g : A
_+_ : A → A → A
-_ : A → A
isAbGroup : IsAbGroup 0g _+_ -_
infix 8 -_
infixr 7 _+_
open IsAbGroup isAbGroup public
AbGroup : ∀ ℓ → Type (ℓ-suc ℓ)
AbGroup ℓ = TypeWithStr ℓ AbGroupStr
makeIsAbGroup : {G : Type ℓ} {0g : G} {_+_ : G → G → G} { -_ : G → G}
(is-setG : isSet G)
(assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)
(rid : (x : G) → x + 0g ≡ x)
(rinv : (x : G) → x + (- x) ≡ 0g)
(comm : (x y : G) → x + y ≡ y + x)
→ IsAbGroup 0g _+_ -_
makeIsAbGroup is-setG assoc rid rinv comm =
isabgroup (makeIsGroup is-setG assoc rid (λ x → comm _ _ ∙ rid x) rinv (λ x → comm _ _ ∙ rinv x)) comm
makeAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (-_ : G → G)
(is-setG : isSet G)
(assoc : (x y z : G) → x + (y + z) ≡ (x + y) + z)
(rid : (x : G) → x + 0g ≡ x)
(rinv : (x : G) → x + (- x) ≡ 0g)
(comm : (x y : G) → x + y ≡ y + x)
→ AbGroup ℓ
makeAbGroup 0g _+_ -_ is-setG assoc rid rinv comm =
_ , abgroupstr 0g _+_ -_ (makeIsAbGroup is-setG assoc rid rinv comm)
open GroupStr
open AbGroupStr
open IsAbGroup
AbGroupStr→GroupStr : {G : Type ℓ} → AbGroupStr G → GroupStr G
AbGroupStr→GroupStr A .1g = A .0g
AbGroupStr→GroupStr A ._·_ = A ._+_
AbGroupStr→GroupStr A .inv = A .-_
AbGroupStr→GroupStr A .isGroup = A .isAbGroup .isGroup
AbGroup→Group : AbGroup ℓ → Group ℓ
fst (AbGroup→Group A) = fst A
snd (AbGroup→Group A) = AbGroupStr→GroupStr (snd A)
Group→AbGroup : (G : Group ℓ) → ((x y : fst G) → _·_ (snd G) x y ≡ _·_ (snd G) y x) → AbGroup ℓ
fst (Group→AbGroup G comm) = fst G
AbGroupStr.0g (snd (Group→AbGroup G comm)) = 1g (snd G)
AbGroupStr._+_ (snd (Group→AbGroup G comm)) = _·_ (snd G)
AbGroupStr.- snd (Group→AbGroup G comm) = inv (snd G)
IsAbGroup.isGroup (AbGroupStr.isAbGroup (snd (Group→AbGroup G comm))) = isGroup (snd G)
IsAbGroup.comm (AbGroupStr.isAbGroup (snd (Group→AbGroup G comm))) = comm
AbGroup→CommMonoid : AbGroup ℓ → CommMonoid ℓ
AbGroup→CommMonoid (_ , abgroupstr _ _ _ G) =
_ , commmonoidstr _ _ (iscommmonoid (IsAbGroup.isMonoid G) (IsAbGroup.comm G))
isSetAbGroup : (A : AbGroup ℓ) → isSet ⟨ A ⟩
isSetAbGroup A = isSetGroup (AbGroup→Group A)
AbGroupHom : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ')
AbGroupHom G H = GroupHom (AbGroup→Group G) (AbGroup→Group H)
AbGroupIso : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ')
AbGroupIso G H = GroupIso (AbGroup→Group G) (AbGroup→Group H)
IsAbGroupEquiv : {A : Type ℓ} {B : Type ℓ'}
(G : AbGroupStr A) (e : A ≃ B) (H : AbGroupStr B) → Type (ℓ-max ℓ ℓ')
IsAbGroupEquiv G e H = IsGroupHom (AbGroupStr→GroupStr G) (e .fst) (AbGroupStr→GroupStr H)
AbGroupEquiv : (G : AbGroup ℓ) (H : AbGroup ℓ') → Type (ℓ-max ℓ ℓ')
AbGroupEquiv G H = Σ[ e ∈ (G .fst ≃ H .fst) ] IsAbGroupEquiv (G .snd) e (H .snd)
isPropIsAbGroup : {G : Type ℓ} (0g : G) (_+_ : G → G → G) (- : G → G)
→ isProp (IsAbGroup 0g _+_ -)
isPropIsAbGroup 0g _+_ -_ (isabgroup GG GC) (isabgroup HG HC) =
λ i → isabgroup (isPropIsGroup _ _ _ GG HG i) (isPropComm GC HC i)
where
isSetG : isSet _
isSetG = GG .IsGroup.isMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set
isPropComm : isProp ((x y : _) → x + y ≡ y + x)
isPropComm = isPropΠ2 λ _ _ → isSetG _ _
𝒮ᴰ-AbGroup : DUARel (𝒮-Univ ℓ) AbGroupStr ℓ
𝒮ᴰ-AbGroup =
𝒮ᴰ-Record (𝒮-Univ _) IsAbGroupEquiv
(fields:
data[ _+_ ∣ autoDUARel _ _ ∣ pres· ]
data[ 0g ∣ autoDUARel _ _ ∣ pres1 ]
data[ -_ ∣ autoDUARel _ _ ∣ presinv ]
prop[ isAbGroup ∣ (λ _ _ → isPropIsAbGroup _ _ _) ])
where
open AbGroupStr
open IsGroupHom
-- Extract the characterization of equality of groups
AbGroupPath : (G H : AbGroup ℓ) → (AbGroupEquiv G H) ≃ (G ≡ H)
AbGroupPath = ∫ 𝒮ᴰ-AbGroup .UARel.ua
-- TODO: Induced structure results are temporarily inconvenient while we transition between algebra
-- representations
module _ (G : AbGroup ℓ) {A : Type ℓ} (m : A → A → A)
(e : ⟨ G ⟩ ≃ A)
(p· : ∀ x y → e .fst (G .snd ._+_ x y) ≡ m (e .fst x) (e .fst y))
where
private
module G = AbGroupStr (G .snd)
FamilyΣ : Σ[ B ∈ Type ℓ ] (B → B → B) → Type ℓ
FamilyΣ (B , n) =
Σ[ e ∈ B ]
Σ[ i ∈ (B → B) ]
IsAbGroup e n i
inducedΣ : FamilyΣ (A , m)
inducedΣ =
subst FamilyΣ
(UARel.≅→≡ (autoUARel (Σ[ B ∈ Type ℓ ] (B → B → B))) (e , p·))
(G.0g , G.-_ , G.isAbGroup)
InducedAbGroup : AbGroup ℓ
InducedAbGroup .fst = A
InducedAbGroup .snd ._+_ = m
InducedAbGroup .snd .0g = inducedΣ .fst
InducedAbGroup .snd .-_ = inducedΣ .snd .fst
InducedAbGroup .snd .isAbGroup = inducedΣ .snd .snd
InducedAbGroupPath : G ≡ InducedAbGroup
InducedAbGroupPath = AbGroupPath _ _ .fst (e , makeIsGroupHom p·)
open IsMonoid
open IsSemigroup
open IsGroup
dirProdAb : AbGroup ℓ → AbGroup ℓ' → AbGroup (ℓ-max ℓ ℓ')
dirProdAb A B =
Group→AbGroup (DirProd (AbGroup→Group A) (AbGroup→Group B))
λ p q → ΣPathP (comm (isAbGroup (snd A)) _ _
, comm (isAbGroup (snd B)) _ _)
trivialAbGroup : ∀ {ℓ} → AbGroup ℓ
fst trivialAbGroup = Unit*
0g (snd trivialAbGroup) = tt*
_+_ (snd trivialAbGroup) _ _ = tt*
(- snd trivialAbGroup) _ = tt*
is-set (isSemigroup (isMonoid (isGroup (isAbGroup (snd trivialAbGroup))))) =
isProp→isSet isPropUnit*
assoc (isSemigroup (isMonoid (isGroup (isAbGroup (snd trivialAbGroup))))) _ _ _ = refl
identity (isMonoid (isGroup (isAbGroup (snd trivialAbGroup)))) _ = refl , refl
inverse (isGroup (isAbGroup (snd trivialAbGroup))) _ = refl , refl
comm (isAbGroup (snd trivialAbGroup)) _ _ = refl
-- useful lemma
move4 : ∀ {ℓ} {A : Type ℓ} (x y z w : A) (_+_ : A → A → A)
→ ((x y z : A) → x + (y + z) ≡ (x + y) + z)
→ ((x y : A) → x + y ≡ y + x)
→ (x + y) + (z + w) ≡ ((x + z) + (y + w))
move4 x y z w _+_ assoc comm =
sym (assoc x y (z + w))
∙∙ cong (x +_) (assoc y z w ∙∙ cong (_+ w) (comm y z) ∙∙ sym (assoc z y w))
∙∙ assoc x z (y + w)
---- The type of homomorphisms A → B is an AbGroup if B is -----
module _ {ℓ ℓ' : Level} (AGr : Group ℓ) (BGr : AbGroup ℓ') where
private
strA = snd AGr
strB = snd BGr
_* = AbGroup→Group
A = fst AGr
B = fst BGr
open IsGroupHom
open AbGroupStr strB
renaming (_+_ to _+B_ ; -_ to -B_ ; 0g to 0B
; rid to ridB ; lid to lidB
; assoc to assocB ; comm to commB
; invr to invrB ; invl to invlB)
open GroupStr strA
renaming (_·_ to _∙A_ ; inv to -A_
; 1g to 1A ; rid to ridA)
trivGroupHom : GroupHom AGr (BGr *)
fst trivGroupHom x = 0B
snd trivGroupHom = makeIsGroupHom λ _ _ → sym (ridB 0B)
compHom : GroupHom AGr (BGr *) → GroupHom AGr (BGr *) → GroupHom AGr (BGr *)
fst (compHom f g) x = fst f x +B fst g x
snd (compHom f g) =
makeIsGroupHom λ x y
→ cong₂ _+B_ (pres· (snd f) x y) (pres· (snd g) x y)
∙ move4 (fst f x) (fst f y) (fst g x) (fst g y)
_+B_ assocB commB
invHom : GroupHom AGr (BGr *) → GroupHom AGr (BGr *)
fst (invHom (f , p)) x = -B f x
snd (invHom (f , p)) =
makeIsGroupHom
λ x y → cong -B_ (pres· p x y)
∙∙ GroupTheory.invDistr (BGr *) (f x) (f y)
∙∙ commB _ _
open AbGroupStr
open IsAbGroup
open IsGroup
open IsMonoid
open IsSemigroup
HomGroup : AbGroup (ℓ-max ℓ ℓ')
fst HomGroup = GroupHom AGr (BGr *)
0g (snd HomGroup) = trivGroupHom
AbGroupStr._+_ (snd HomGroup) = compHom
AbGroupStr.- snd HomGroup = invHom
is-set (isSemigroup (isMonoid (isGroup (isAbGroup (snd HomGroup))))) =
isSetGroupHom
assoc (isSemigroup (isMonoid (isGroup (isAbGroup (snd HomGroup))))) (f , p) (g , q) (h , r) =
Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(funExt λ x → assocB _ _ _)
fst (identity (isMonoid (isGroup (isAbGroup (snd HomGroup)))) (f , p)) =
Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ y → ridB _)
snd (identity (isMonoid (isGroup (isAbGroup (snd HomGroup)))) (f , p)) =
Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → lidB _)
fst (inverse (isGroup (isAbGroup (snd HomGroup))) (f , p)) =
Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → invrB (f x))
snd (inverse (isGroup (isAbGroup (snd HomGroup))) (f , p)) =
Σ≡Prop (λ _ → isPropIsGroupHom _ _) (funExt λ x → invlB (f x))
comm (isAbGroup (snd HomGroup)) (f , p) (g , q) =
Σ≡Prop (λ _ → isPropIsGroupHom _ _)
(funExt λ x → commB _ _)
|
module Replica.App
import public Control.App
import public Control.App.Console
import public Replica.App.FileSystem
import public Replica.App.Info
import public Replica.App.Log
import public Replica.App.Replica
import public Replica.App.Run
import public Replica.App.System
|
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import category_theory.category.Pointed
/-!
# The category of bipointed types
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This defines `Bipointed`, the category of bipointed types.
## TODO
Monoidal structure
-/
open category_theory
universes u
variables {α β : Type*}
/-- The category of bipointed types. -/
structure Bipointed : Type.{u + 1} :=
(X : Type.{u})
(to_prod : X × X)
namespace Bipointed
instance : has_coe_to_sort Bipointed Type* := ⟨X⟩
attribute [protected] Bipointed.X
/-- Turns a bipointing into a bipointed type. -/
def of {X : Type*} (to_prod : X × X) : Bipointed := ⟨X, to_prod⟩
@[simp] lemma coe_of {X : Type*} (to_prod : X × X) : ↥(of to_prod) = X := rfl
alias of ← _root_.prod.Bipointed
instance : inhabited Bipointed := ⟨of ((), ())⟩
/-- Morphisms in `Bipointed`. -/
@[ext] protected structure hom (X Y : Bipointed.{u}) : Type u :=
(to_fun : X → Y)
(map_fst : to_fun X.to_prod.1 = Y.to_prod.1)
(map_snd : to_fun X.to_prod.2 = Y.to_prod.2)
namespace hom
/-- The identity morphism of `X : Bipointed`. -/
@[simps] def id (X : Bipointed) : hom X X := ⟨id, rfl, rfl⟩
instance (X : Bipointed) : inhabited (hom X X) := ⟨id X⟩
/-- Composition of morphisms of `Bipointed`. -/
@[simps] def comp {X Y Z : Bipointed.{u}} (f : hom X Y) (g : hom Y Z) : hom X Z :=
⟨g.to_fun ∘ f.to_fun, by rw [function.comp_apply, f.map_fst, g.map_fst],
by rw [function.comp_apply, f.map_snd, g.map_snd]⟩
end hom
instance large_category : large_category Bipointed :=
{ hom := hom,
id := hom.id,
comp := @hom.comp,
id_comp' := λ _ _ _, hom.ext _ _ rfl,
comp_id' := λ _ _ _, hom.ext _ _ rfl,
assoc' := λ _ _ _ _ _ _ _, hom.ext _ _ rfl }
instance concrete_category : concrete_category Bipointed :=
{ forget := { obj := Bipointed.X, map := @hom.to_fun },
forget_faithful := ⟨@hom.ext⟩ }
/-- Swaps the pointed elements of a bipointed type. `prod.swap` as a functor. -/
@[simps] def swap : Bipointed ⥤ Bipointed :=
{ obj := λ X, ⟨X, X.to_prod.swap⟩, map := λ X Y f, ⟨f.to_fun, f.map_snd, f.map_fst⟩ }
/-- The equivalence between `Bipointed` and itself induced by `prod.swap` both ways. -/
@[simps] def swap_equiv : Bipointed ≌ Bipointed :=
equivalence.mk swap swap
(nat_iso.of_components (λ X, { hom := ⟨id, rfl, rfl⟩, inv := ⟨id, rfl, rfl⟩ }) $ λ X Y f, rfl)
(nat_iso.of_components (λ X, { hom := ⟨id, rfl, rfl⟩, inv := ⟨id, rfl, rfl⟩ }) $ λ X Y f, rfl)
@[simp] lemma swap_equiv_symm : swap_equiv.symm = swap_equiv := rfl
end Bipointed
/-- The forgetful functor from `Bipointed` to `Pointed` which forgets about the second point. -/
def Bipointed_to_Pointed_fst : Bipointed ⥤ Pointed :=
{ obj := λ X, ⟨X, X.to_prod.1⟩, map := λ X Y f, ⟨f.to_fun, f.map_fst⟩ }
/-- The forgetful functor from `Bipointed` to `Pointed` which forgets about the first point. -/
def Bipointed_to_Pointed_snd : Bipointed ⥤ Pointed :=
{ obj := λ X, ⟨X, X.to_prod.2⟩, map := λ X Y f, ⟨f.to_fun, f.map_snd⟩ }
@[simp] lemma Bipointed_to_Pointed_fst_comp_forget :
Bipointed_to_Pointed_fst ⋙ forget Pointed = forget Bipointed := rfl
@[simp] lemma Bipointed_to_Pointed_snd_comp_forget :
Bipointed_to_Pointed_snd ⋙ forget Pointed = forget Bipointed := rfl
@[simp] lemma swap_comp_Bipointed_to_Pointed_fst :
Bipointed.swap ⋙ Bipointed_to_Pointed_fst = Bipointed_to_Pointed_snd := rfl
@[simp] lemma swap_comp_Bipointed_to_Pointed_snd :
Bipointed.swap ⋙ Bipointed_to_Pointed_snd = Bipointed_to_Pointed_fst := rfl
/-- The functor from `Pointed` to `Bipointed` which bipoints the point. -/
def Pointed_to_Bipointed : Pointed.{u} ⥤ Bipointed :=
{ obj := λ X, ⟨X, X.point, X.point⟩, map := λ X Y f, ⟨f.to_fun, f.map_point, f.map_point⟩ }
/-- The functor from `Pointed` to `Bipointed` which adds a second point. -/
def Pointed_to_Bipointed_fst : Pointed.{u} ⥤ Bipointed :=
{ obj := λ X, ⟨option X, X.point, none⟩,
map := λ X Y f, ⟨option.map f.to_fun, congr_arg _ f.map_point, rfl⟩,
map_id' := λ X, Bipointed.hom.ext _ _ option.map_id,
map_comp' := λ X Y Z f g, Bipointed.hom.ext _ _ (option.map_comp_map _ _).symm }
/-- The functor from `Pointed` to `Bipointed` which adds a first point. -/
def Pointed_to_Bipointed_snd : Pointed.{u} ⥤ Bipointed :=
{ obj := λ X, ⟨option X, none, X.point⟩,
map := λ X Y f, ⟨option.map f.to_fun, rfl, congr_arg _ f.map_point⟩,
map_id' := λ X, Bipointed.hom.ext _ _ option.map_id,
map_comp' := λ X Y Z f g, Bipointed.hom.ext _ _ (option.map_comp_map _ _).symm }
@[simp] lemma Pointed_to_Bipointed_fst_comp_swap :
Pointed_to_Bipointed_fst ⋙ Bipointed.swap = Pointed_to_Bipointed_snd := rfl
@[simp] lemma Pointed_to_Bipointed_snd_comp_swap :
Pointed_to_Bipointed_snd ⋙ Bipointed.swap = Pointed_to_Bipointed_fst := rfl
/-- `Bipointed_to_Pointed_fst` is inverse to `Pointed_to_Bipointed`. -/
@[simps] def Pointed_to_Bipointed_comp_Bipointed_to_Pointed_fst :
Pointed_to_Bipointed ⋙ Bipointed_to_Pointed_fst ≅ 𝟭 _ :=
nat_iso.of_components (λ X, { hom := ⟨id, rfl⟩, inv := ⟨id, rfl⟩ }) $ λ X Y f, rfl
/-- `Bipointed_to_Pointed_snd` is inverse to `Pointed_to_Bipointed`. -/
@[simps] def Pointed_to_Bipointed_comp_Bipointed_to_Pointed_snd :
Pointed_to_Bipointed ⋙ Bipointed_to_Pointed_snd ≅ 𝟭 _ :=
nat_iso.of_components (λ X, { hom := ⟨id, rfl⟩, inv := ⟨id, rfl⟩ }) $ λ X Y f, rfl
/-- The free/forgetful adjunction between `Pointed_to_Bipointed_fst` and `Bipointed_to_Pointed_fst`.
-/
def Pointed_to_Bipointed_fst_Bipointed_to_Pointed_fst_adjunction :
Pointed_to_Bipointed_fst ⊣ Bipointed_to_Pointed_fst :=
adjunction.mk_of_hom_equiv
{ hom_equiv := λ X Y, { to_fun := λ f, ⟨f.to_fun ∘ option.some, f.map_fst⟩,
inv_fun := λ f, ⟨λ o, o.elim Y.to_prod.2 f.to_fun, f.map_point, rfl⟩,
left_inv := λ f, by { ext, cases x, exact f.map_snd.symm, refl },
right_inv := λ f, Pointed.hom.ext _ _ rfl },
hom_equiv_naturality_left_symm' := λ X' X Y f g, by { ext, cases x; refl } }
/-- The free/forgetful adjunction between `Pointed_to_Bipointed_snd` and `Bipointed_to_Pointed_snd`.
-/
def Pointed_to_Bipointed_snd_Bipointed_to_Pointed_snd_adjunction :
Pointed_to_Bipointed_snd ⊣ Bipointed_to_Pointed_snd :=
adjunction.mk_of_hom_equiv
{ hom_equiv := λ X Y, { to_fun := λ f, ⟨f.to_fun ∘ option.some, f.map_snd⟩,
inv_fun := λ f, ⟨λ o, o.elim Y.to_prod.1 f.to_fun, rfl, f.map_point⟩,
left_inv := λ f, by { ext, cases x, exact f.map_fst.symm, refl },
right_inv := λ f, Pointed.hom.ext _ _ rfl },
hom_equiv_naturality_left_symm' := λ X' X Y f g, by { ext, cases x; refl } }
|
[STATEMENT]
lemma less_multiset\<^sub>H\<^sub>O:
"M < N \<longleftrightarrow> M \<noteq> N \<and> (\<forall>y. count N y < count M y \<longrightarrow> (\<exists>x>y. count M x < count N x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (M < N) = (M \<noteq> N \<and> (\<forall>y. count N y < count M y \<longrightarrow> (\<exists>x>y. count M x < count N x)))
[PROOF STEP]
by (rule mult\<^sub>H\<^sub>O[folded multp_def less_multiset_def]) |
Formal statement is: lemma continuous_onI_mono: fixes f :: "'a::linorder_topology \<Rightarrow> 'b::{dense_order,linorder_topology}" assumes "open (f`A)" and mono: "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x \<le> y \<Longrightarrow> f x \<le> f y" shows "continuous_on A f" Informal statement is: If $f$ is a monotone function defined on a set $A$ and $f(A)$ is open, then $f$ is continuous on $A$. |
/-
Copyright (c) 2021 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov
-/
import measure_theory.function.l1_space
import analysis.normed_space.indicator_function
/-! # Functions integrable on a set and at a filter
We define `integrable_on f s μ := integrable f (μ.restrict s)` and prove theorems like
`integrable_on_union : integrable_on f (s ∪ t) μ ↔ integrable_on f s μ ∧ integrable_on f t μ`.
Next we define a predicate `integrable_at_filter (f : α → E) (l : filter α) (μ : measure α)`
saying that `f` is integrable at some set `s ∈ l` and prove that a measurable function is integrable
at `l` with respect to `μ` provided that `f` is bounded above at `l ⊓ μ.ae` and `μ` is finite
at `l`.
-/
noncomputable theory
open set filter topological_space measure_theory function
open_locale classical topological_space interval big_operators filter ennreal measure_theory
variables {α β E F : Type*} [measurable_space α]
section
variables [measurable_space β] {l l' : filter α} {f g : α → β} {μ ν : measure α}
/-- A function `f` is measurable at filter `l` w.r.t. a measure `μ` if it is ae-measurable
w.r.t. `μ.restrict s` for some `s ∈ l`. -/
def measurable_at_filter (f : α → β) (l : filter α) (μ : measure α . volume_tac) :=
∃ s ∈ l, ae_measurable f (μ.restrict s)
@[simp] lemma measurable_at_bot {f : α → β} : measurable_at_filter f ⊥ μ :=
⟨∅, mem_bot, by simp⟩
protected lemma measurable_at_filter.eventually (h : measurable_at_filter f l μ) :
∀ᶠ s in l.lift' powerset, ae_measurable f (μ.restrict s) :=
(eventually_lift'_powerset' $ λ s t, ae_measurable.mono_set).2 h
protected lemma measurable_at_filter.filter_mono (h : measurable_at_filter f l μ) (h' : l' ≤ l) :
measurable_at_filter f l' μ :=
let ⟨s, hsl, hs⟩ := h in ⟨s, h' hsl, hs⟩
protected lemma ae_measurable.measurable_at_filter (h : ae_measurable f μ) :
measurable_at_filter f l μ :=
⟨univ, univ_mem, by rwa measure.restrict_univ⟩
lemma ae_measurable.measurable_at_filter_of_mem {s} (h : ae_measurable f (μ.restrict s))
(hl : s ∈ l) : measurable_at_filter f l μ :=
⟨s, hl, h⟩
protected lemma measurable.measurable_at_filter (h : measurable f) :
measurable_at_filter f l μ :=
h.ae_measurable.measurable_at_filter
end
namespace measure_theory
section normed_group
lemma has_finite_integral_restrict_of_bounded [normed_group E] {f : α → E} {s : set α}
{μ : measure α} {C} (hs : μ s < ∞) (hf : ∀ᵐ x ∂(μ.restrict s), ∥f x∥ ≤ C) :
has_finite_integral f (μ.restrict s) :=
by haveI : is_finite_measure (μ.restrict s) := ⟨by rwa [measure.restrict_apply_univ]⟩;
exact has_finite_integral_of_bounded hf
variables [normed_group E] [measurable_space E] {f g : α → E} {s t : set α} {μ ν : measure α}
/-- A function is `integrable_on` a set `s` if it is almost everywhere measurable on `s` and if the
integral of its pointwise norm over `s` is less than infinity. -/
def integrable_on (f : α → E) (s : set α) (μ : measure α . volume_tac) : Prop :=
integrable f (μ.restrict s)
lemma integrable_on.integrable (h : integrable_on f s μ) :
integrable f (μ.restrict s) := h
@[simp] lemma integrable_on_empty : integrable_on f ∅ μ :=
by simp [integrable_on, integrable_zero_measure]
@[simp] lemma integrable_on_univ : integrable_on f univ μ ↔ integrable f μ :=
by rw [integrable_on, measure.restrict_univ]
lemma integrable_on_zero : integrable_on (λ _, (0:E)) s μ := integrable_zero _ _ _
@[simp] lemma integrable_on_const {C : E} : integrable_on (λ _, C) s μ ↔ C = 0 ∨ μ s < ∞ :=
integrable_const_iff.trans $ by rw [measure.restrict_apply_univ]
lemma integrable_on.mono (h : integrable_on f t ν) (hs : s ⊆ t) (hμ : μ ≤ ν) :
integrable_on f s μ :=
h.mono_measure $ measure.restrict_mono hs hμ
lemma integrable_on.mono_set (h : integrable_on f t μ) (hst : s ⊆ t) :
integrable_on f s μ :=
h.mono hst (le_refl _)
lemma integrable_on.mono_measure (h : integrable_on f s ν) (hμ : μ ≤ ν) :
integrable_on f s μ :=
h.mono (subset.refl _) hμ
lemma integrable_on.mono_set_ae (h : integrable_on f t μ) (hst : s ≤ᵐ[μ] t) :
integrable_on f s μ :=
h.integrable.mono_measure $ measure.restrict_mono_ae hst
lemma integrable_on.congr_set_ae (h : integrable_on f t μ) (hst : s =ᵐ[μ] t) :
integrable_on f s μ :=
h.mono_set_ae hst.le
lemma integrable.integrable_on (h : integrable f μ) : integrable_on f s μ :=
h.mono_measure $ measure.restrict_le_self
lemma integrable.integrable_on' (h : integrable f (μ.restrict s)) : integrable_on f s μ :=
h
lemma integrable_on.restrict (h : integrable_on f s μ) (hs : measurable_set s) :
integrable_on f s (μ.restrict t) :=
by { rw [integrable_on, measure.restrict_restrict hs], exact h.mono_set (inter_subset_left _ _) }
lemma integrable_on.left_of_union (h : integrable_on f (s ∪ t) μ) : integrable_on f s μ :=
h.mono_set $ subset_union_left _ _
lemma integrable_on.right_of_union (h : integrable_on f (s ∪ t) μ) : integrable_on f t μ :=
h.mono_set $ subset_union_right _ _
lemma integrable_on.union (hs : integrable_on f s μ) (ht : integrable_on f t μ) :
integrable_on f (s ∪ t) μ :=
(hs.add_measure ht).mono_measure $ measure.restrict_union_le _ _
@[simp] lemma integrable_on_union :
integrable_on f (s ∪ t) μ ↔ integrable_on f s μ ∧ integrable_on f t μ :=
⟨λ h, ⟨h.left_of_union, h.right_of_union⟩, λ h, h.1.union h.2⟩
@[simp] lemma integrable_on_singleton_iff {x : α} [measurable_singleton_class α]:
integrable_on f {x} μ ↔ f x = 0 ∨ μ {x} < ∞ :=
begin
have : f =ᵐ[μ.restrict {x}] (λ y, f x),
{ filter_upwards [ae_restrict_mem (measurable_set_singleton x)],
assume a ha,
simp only [mem_singleton_iff.1 ha] },
rw [integrable_on, integrable_congr this, integrable_const_iff],
simp,
end
@[simp] lemma integrable_on_finite_Union {s : set β} (hs : finite s)
{t : β → set α} : integrable_on f (⋃ i ∈ s, t i) μ ↔ ∀ i ∈ s, integrable_on f (t i) μ :=
begin
apply hs.induction_on,
{ simp },
{ intros a s ha hs hf, simp [hf, or_imp_distrib, forall_and_distrib] }
end
@[simp] lemma integrable_on_finset_Union {s : finset β} {t : β → set α} :
integrable_on f (⋃ i ∈ s, t i) μ ↔ ∀ i ∈ s, integrable_on f (t i) μ :=
integrable_on_finite_Union s.finite_to_set
@[simp] lemma integrable_on_fintype_Union [fintype β] {t : β → set α} :
integrable_on f (⋃ i, t i) μ ↔ ∀ i, integrable_on f (t i) μ :=
by simpa using @integrable_on_finset_Union _ _ _ _ _ _ f μ finset.univ t
lemma integrable_on.add_measure (hμ : integrable_on f s μ) (hν : integrable_on f s ν) :
integrable_on f s (μ + ν) :=
by { delta integrable_on, rw measure.restrict_add, exact hμ.integrable.add_measure hν }
@[simp] lemma integrable_on_add_measure :
integrable_on f s (μ + ν) ↔ integrable_on f s μ ∧ integrable_on f s ν :=
⟨λ h, ⟨h.mono_measure (measure.le_add_right (le_refl _)),
h.mono_measure (measure.le_add_left (le_refl _))⟩,
λ h, h.1.add_measure h.2⟩
lemma _root_.measurable_embedding.integrable_on_map_iff [measurable_space β] {e : α → β}
(he : measurable_embedding e) {f : β → E} {μ : measure α} {s : set β} :
integrable_on f s (measure.map e μ) ↔ integrable_on (f ∘ e) (e ⁻¹' s) μ :=
by simp only [integrable_on, he.restrict_map, he.integrable_map_iff]
lemma integrable_on_map_equiv [measurable_space β] (e : α ≃ᵐ β) {f : β → E} {μ : measure α}
{s : set β} :
integrable_on f s (measure.map e μ) ↔ integrable_on (f ∘ e) (e ⁻¹' s) μ :=
by simp only [integrable_on, e.restrict_map, integrable_map_equiv e]
lemma measure_preserving.integrable_on_comp_preimage [measurable_space β] {e : α → β} {ν}
(h₁ : measure_preserving e μ ν) (h₂ : measurable_embedding e) {f : β → E} {s : set β} :
integrable_on (f ∘ e) (e ⁻¹' s) μ ↔ integrable_on f s ν :=
(h₁.restrict_preimage_emb h₂ s).integrable_comp_emb h₂
lemma measure_preserving.integrable_on_image [measurable_space β] {e : α → β} {ν}
(h₁ : measure_preserving e μ ν) (h₂ : measurable_embedding e) {f : β → E} {s : set α} :
integrable_on f (e '' s) ν ↔ integrable_on (f ∘ e) s μ :=
((h₁.restrict_image_emb h₂ s).integrable_comp_emb h₂).symm
lemma integrable_indicator_iff (hs : measurable_set s) :
integrable (indicator s f) μ ↔ integrable_on f s μ :=
by simp [integrable_on, integrable, has_finite_integral, nnnorm_indicator_eq_indicator_nnnorm,
ennreal.coe_indicator, lintegral_indicator _ hs, ae_measurable_indicator_iff hs]
lemma integrable_on.indicator (h : integrable_on f s μ) (hs : measurable_set s) :
integrable (indicator s f) μ :=
(integrable_indicator_iff hs).2 h
lemma integrable.indicator (h : integrable f μ) (hs : measurable_set s) :
integrable (indicator s f) μ :=
h.integrable_on.indicator hs
lemma integrable_indicator_const_Lp {E} [normed_group E] [measurable_space E] [borel_space E]
[second_countable_topology E] {p : ℝ≥0∞} {s : set α} (hs : measurable_set s) (hμs : μ s ≠ ∞)
(c : E) :
integrable (indicator_const_Lp p hs hμs c) μ :=
begin
rw [integrable_congr indicator_const_Lp_coe_fn, integrable_indicator_iff hs, integrable_on,
integrable_const_iff, lt_top_iff_ne_top],
right,
simpa only [set.univ_inter, measurable_set.univ, measure.restrict_apply] using hμs,
end
lemma integrable_on_Lp_of_measure_ne_top {E} [normed_group E] [measurable_space E] [borel_space E]
[second_countable_topology E] {p : ℝ≥0∞} {s : set α} (f : Lp E p μ) (hp : 1 ≤ p) (hμs : μ s ≠ ∞) :
integrable_on f s μ :=
begin
refine mem_ℒp_one_iff_integrable.mp _,
have hμ_restrict_univ : (μ.restrict s) set.univ < ∞,
by simpa only [set.univ_inter, measurable_set.univ, measure.restrict_apply, lt_top_iff_ne_top],
haveI hμ_finite : is_finite_measure (μ.restrict s) := ⟨hμ_restrict_univ⟩,
exact ((Lp.mem_ℒp _).restrict s).mem_ℒp_of_exponent_le hp,
end
/-- We say that a function `f` is *integrable at filter* `l` if it is integrable on some
set `s ∈ l`. Equivalently, it is eventually integrable on `s` in `l.lift' powerset`. -/
def integrable_at_filter (f : α → E) (l : filter α) (μ : measure α . volume_tac) :=
∃ s ∈ l, integrable_on f s μ
variables {l l' : filter α}
protected lemma integrable_at_filter.eventually (h : integrable_at_filter f l μ) :
∀ᶠ s in l.lift' powerset, integrable_on f s μ :=
by { refine (eventually_lift'_powerset' $ λ s t hst ht, _).2 h, exact ht.mono_set hst }
lemma integrable_at_filter.filter_mono (hl : l ≤ l') (hl' : integrable_at_filter f l' μ) :
integrable_at_filter f l μ :=
let ⟨s, hs, hsf⟩ := hl' in ⟨s, hl hs, hsf⟩
lemma integrable_at_filter.inf_of_left (hl : integrable_at_filter f l μ) :
integrable_at_filter f (l ⊓ l') μ :=
hl.filter_mono inf_le_left
lemma integrable_at_filter.inf_of_right (hl : integrable_at_filter f l μ) :
integrable_at_filter f (l' ⊓ l) μ :=
hl.filter_mono inf_le_right
@[simp] lemma integrable_at_filter.inf_ae_iff {l : filter α} :
integrable_at_filter f (l ⊓ μ.ae) μ ↔ integrable_at_filter f l μ :=
begin
refine ⟨_, λ h, h.filter_mono inf_le_left⟩,
rintros ⟨s, ⟨t, ht, u, hu, rfl⟩, hf⟩,
refine ⟨t, ht, _⟩,
refine hf.integrable.mono_measure (λ v hv, _),
simp only [measure.restrict_apply hv],
refine measure_mono_ae (mem_of_superset hu $ λ x hx, _),
exact λ ⟨hv, ht⟩, ⟨hv, ⟨ht, hx⟩⟩
end
alias integrable_at_filter.inf_ae_iff ↔ measure_theory.integrable_at_filter.of_inf_ae _
/-- If `μ` is a measure finite at filter `l` and `f` is a function such that its norm is bounded
above at `l`, then `f` is integrable at `l`. -/
lemma measure.finite_at_filter.integrable_at_filter {l : filter α} [is_measurably_generated l]
(hfm : measurable_at_filter f l μ) (hμ : μ.finite_at_filter l)
(hf : l.is_bounded_under (≤) (norm ∘ f)) :
integrable_at_filter f l μ :=
begin
obtain ⟨C, hC⟩ : ∃ C, ∀ᶠ s in (l.lift' powerset), ∀ x ∈ s, ∥f x∥ ≤ C,
from hf.imp (λ C hC, eventually_lift'_powerset.2 ⟨_, hC, λ t, id⟩),
rcases (hfm.eventually.and (hμ.eventually.and hC)).exists_measurable_mem_of_lift'
with ⟨s, hsl, hsm, hfm, hμ, hC⟩,
refine ⟨s, hsl, ⟨hfm, has_finite_integral_restrict_of_bounded hμ _⟩⟩,
exact C,
rw [ae_restrict_eq hsm, eventually_inf_principal],
exact eventually_of_forall hC
end
lemma measure.finite_at_filter.integrable_at_filter_of_tendsto_ae
{l : filter α} [is_measurably_generated l] (hfm : measurable_at_filter f l μ)
(hμ : μ.finite_at_filter l) {b} (hf : tendsto f (l ⊓ μ.ae) (𝓝 b)) :
integrable_at_filter f l μ :=
(hμ.inf_of_left.integrable_at_filter (hfm.filter_mono inf_le_left)
hf.norm.is_bounded_under_le).of_inf_ae
alias measure.finite_at_filter.integrable_at_filter_of_tendsto_ae ←
filter.tendsto.integrable_at_filter_ae
lemma measure.finite_at_filter.integrable_at_filter_of_tendsto {l : filter α}
[is_measurably_generated l] (hfm : measurable_at_filter f l μ) (hμ : μ.finite_at_filter l)
{b} (hf : tendsto f l (𝓝 b)) :
integrable_at_filter f l μ :=
hμ.integrable_at_filter hfm hf.norm.is_bounded_under_le
alias measure.finite_at_filter.integrable_at_filter_of_tendsto ← filter.tendsto.integrable_at_filter
variables [borel_space E] [second_countable_topology E]
lemma integrable_add_of_disjoint {f g : α → E}
(h : disjoint (support f) (support g)) (hf : measurable f) (hg : measurable g) :
integrable (f + g) μ ↔ integrable f μ ∧ integrable g μ :=
begin
refine ⟨λ hfg, ⟨_, _⟩, λ h, h.1.add h.2⟩,
{ rw ← indicator_add_eq_left h, exact hfg.indicator (measurable_set_support hf) },
{ rw ← indicator_add_eq_right h, exact hfg.indicator (measurable_set_support hg) }
end
end normed_group
end measure_theory
open measure_theory
variables [measurable_space E] [normed_group E]
/-- If a function is integrable at `𝓝[s] x` for each point `x` of a compact set `s`, then it is
integrable on `s`. -/
lemma is_compact.integrable_on_of_nhds_within [topological_space α] {μ : measure α} {s : set α}
(hs : is_compact s) {f : α → E} (hf : ∀ x ∈ s, integrable_at_filter f (𝓝[s] x) μ) :
integrable_on f s μ :=
is_compact.induction_on hs integrable_on_empty (λ s t hst ht, ht.mono_set hst)
(λ s t hs ht, hs.union ht) hf
/-- A function which is continuous on a set `s` is almost everywhere measurable with respect to
`μ.restrict s`. -/
lemma continuous_on.ae_measurable [topological_space α] [opens_measurable_space α]
[measurable_space β] [topological_space β] [borel_space β]
{f : α → β} {s : set α} {μ : measure α} (hf : continuous_on f s) (hs : measurable_set s) :
ae_measurable f (μ.restrict s) :=
begin
nontriviality α, inhabit α,
have : piecewise s f (λ _, f (default α)) =ᵐ[μ.restrict s] f := piecewise_ae_eq_restrict hs,
refine ⟨piecewise s f (λ _, f (default α)), _, this.symm⟩,
apply measurable_of_is_open,
assume t ht,
obtain ⟨u, u_open, hu⟩ : ∃ (u : set α), is_open u ∧ f ⁻¹' t ∩ s = u ∩ s :=
_root_.continuous_on_iff'.1 hf t ht,
rw [piecewise_preimage, set.ite, hu],
exact (u_open.measurable_set.inter hs).union ((measurable_const ht.measurable_set).diff hs)
end
lemma continuous_on.integrable_at_nhds_within
[topological_space α] [opens_measurable_space α] [borel_space E]
{μ : measure α} [is_locally_finite_measure μ] {a : α} {t : set α} {f : α → E}
(hft : continuous_on f t) (ht : measurable_set t) (ha : a ∈ t) :
integrable_at_filter f (𝓝[t] a) μ :=
by haveI : (𝓝[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _;
exact (hft a ha).integrable_at_filter ⟨_, self_mem_nhds_within, hft.ae_measurable ht⟩
(μ.finite_at_nhds_within _ _)
/-- A function `f` continuous on a compact set `s` is integrable on this set with respect to any
locally finite measure. -/
lemma continuous_on.integrable_on_compact
[topological_space α] [opens_measurable_space α] [borel_space E]
[t2_space α] {μ : measure α} [is_locally_finite_measure μ]
{s : set α} (hs : is_compact s) {f : α → E} (hf : continuous_on f s) :
integrable_on f s μ :=
hs.integrable_on_of_nhds_within $ λ x hx, hf.integrable_at_nhds_within hs.measurable_set hx
lemma continuous_on.integrable_on_Icc [borel_space E]
[conditionally_complete_linear_order β] [topological_space β] [order_topology β]
[measurable_space β] [opens_measurable_space β] {μ : measure β} [is_locally_finite_measure μ]
{a b : β} {f : β → E} (hf : continuous_on f (Icc a b)) :
integrable_on f (Icc a b) μ :=
hf.integrable_on_compact is_compact_Icc
lemma continuous_on.integrable_on_interval [borel_space E]
[conditionally_complete_linear_order β] [topological_space β] [order_topology β]
[measurable_space β] [opens_measurable_space β] {μ : measure β} [is_locally_finite_measure μ]
{a b : β} {f : β → E} (hf : continuous_on f [a, b]) :
integrable_on f [a, b] μ :=
hf.integrable_on_compact is_compact_interval
/-- A continuous function `f` is integrable on any compact set with respect to any locally finite
measure. -/
lemma continuous.integrable_on_compact
[topological_space α] [opens_measurable_space α] [t2_space α]
[borel_space E] {μ : measure α} [is_locally_finite_measure μ] {s : set α}
(hs : is_compact s) {f : α → E} (hf : continuous f) :
integrable_on f s μ :=
hf.continuous_on.integrable_on_compact hs
lemma continuous.integrable_on_Icc [borel_space E]
[conditionally_complete_linear_order β] [topological_space β] [order_topology β]
[measurable_space β] [opens_measurable_space β] {μ : measure β} [is_locally_finite_measure μ]
{a b : β} {f : β → E} (hf : continuous f) :
integrable_on f (Icc a b) μ :=
hf.integrable_on_compact is_compact_Icc
lemma continuous.integrable_on_Ioc [borel_space E]
[conditionally_complete_linear_order β] [topological_space β] [order_topology β]
[measurable_space β] [opens_measurable_space β] {μ : measure β} [is_locally_finite_measure μ]
{a b : β} {f : β → E} (hf : continuous f) :
integrable_on f (Ioc a b) μ :=
hf.integrable_on_Icc.mono_set Ioc_subset_Icc_self
lemma continuous.integrable_on_interval [borel_space E]
[conditionally_complete_linear_order β] [topological_space β] [order_topology β]
[measurable_space β] [opens_measurable_space β] {μ : measure β} [is_locally_finite_measure μ]
{a b : β} {f : β → E} (hf : continuous f) :
integrable_on f [a, b] μ :=
hf.integrable_on_compact is_compact_interval
lemma continuous.integrable_on_interval_oc [borel_space E]
[conditionally_complete_linear_order β] [topological_space β] [order_topology β]
[measurable_space β] [opens_measurable_space β] {μ : measure β} [is_locally_finite_measure μ]
{a b : β} {f : β → E} (hf : continuous f) :
integrable_on f (Ι a b) μ :=
hf.integrable_on_Ioc
/-- A continuous function with compact closure of the support is integrable on the whole space. -/
lemma continuous.integrable_of_compact_closure_support
[topological_space α] [opens_measurable_space α] [t2_space α] [borel_space E]
{μ : measure α} [is_locally_finite_measure μ] {f : α → E} (hf : continuous f)
(hfc : is_compact (closure $ support f)) :
integrable f μ :=
begin
rw [← indicator_eq_self.2 (@subset_closure _ _ (support f)),
integrable_indicator_iff is_closed_closure.measurable_set],
{ exact hf.integrable_on_compact hfc },
{ apply_instance }
end
section
variables [topological_space α] [opens_measurable_space α]
{μ : measure α} {s t : set α} {f g : α → ℝ}
lemma measure_theory.integrable_on.mul_continuous_on_of_subset
(hf : integrable_on f s μ) (hg : continuous_on g t)
(hs : measurable_set s) (ht : is_compact t) (hst : s ⊆ t) :
integrable_on (λ x, f x * g x) s μ :=
begin
rcases is_compact.exists_bound_of_continuous_on ht hg with ⟨C, hC⟩,
rw [integrable_on, ← mem_ℒp_one_iff_integrable] at hf ⊢,
have : ∀ᵐ x ∂(μ.restrict s), ∥f x * g x∥ ≤ C * ∥f x∥,
{ filter_upwards [ae_restrict_mem hs],
assume x hx,
rw [real.norm_eq_abs, abs_mul, mul_comm, real.norm_eq_abs],
apply mul_le_mul_of_nonneg_right (hC x (hst hx)) (abs_nonneg _) },
exact mem_ℒp.of_le_mul hf (hf.ae_measurable.mul ((hg.mono hst).ae_measurable hs)) this,
end
lemma measure_theory.integrable_on.mul_continuous_on [t2_space α]
(hf : integrable_on f s μ) (hg : continuous_on g s) (hs : is_compact s) :
integrable_on (λ x, f x * g x) s μ :=
hf.mul_continuous_on_of_subset hg hs.measurable_set hs (subset.refl _)
lemma measure_theory.integrable_on.continuous_on_mul_of_subset
(hf : integrable_on f s μ) (hg : continuous_on g t)
(hs : measurable_set s) (ht : is_compact t) (hst : s ⊆ t) :
integrable_on (λ x, g x * f x) s μ :=
by simpa [mul_comm] using hf.mul_continuous_on_of_subset hg hs ht hst
lemma measure_theory.integrable_on.continuous_on_mul [t2_space α]
(hf : integrable_on f s μ) (hg : continuous_on g s) (hs : is_compact s) :
integrable_on (λ x, g x * f x) s μ :=
hf.continuous_on_mul_of_subset hg hs.measurable_set hs (subset.refl _)
end
section monotone
variables
[topological_space α] [borel_space α] [borel_space E]
[conditionally_complete_linear_order α] [conditionally_complete_linear_order E]
[order_topology α] [order_topology E] [second_countable_topology E]
{μ : measure α} [is_locally_finite_measure μ] {s : set α} (hs : is_compact s) {f : α → E}
include hs
lemma monotone_on.integrable_on_compact (hmono : monotone_on f s) :
integrable_on f s μ :=
begin
obtain rfl | h := s.eq_empty_or_nonempty,
{ exact integrable_on_empty },
have hbelow : bdd_below (f '' s) :=
⟨f (Inf s), λ x ⟨y, hy, hyx⟩, hyx ▸ hmono (hs.Inf_mem h) hy (cInf_le hs.bdd_below hy)⟩,
have habove : bdd_above (f '' s) :=
⟨f (Sup s), λ x ⟨y, hy, hyx⟩, hyx ▸ hmono hy (hs.Sup_mem h) (le_cSup hs.bdd_above hy)⟩,
have : metric.bounded (f '' s) := metric.bounded_of_bdd_above_of_bdd_below habove hbelow,
rcases bounded_iff_forall_norm_le.mp this with ⟨C, hC⟩,
exact integrable.mono' (continuous_const.integrable_on_compact hs)
(ae_measurable_restrict_of_monotone_on hs.measurable_set hmono)
((ae_restrict_iff' hs.measurable_set).mpr $ ae_of_all _ $
λ y hy, hC (f y) (mem_image_of_mem f hy)),
end
lemma antitone_on.integrable_on_compact (hanti : antitone_on f s) :
integrable_on f s μ :=
@monotone_on.integrable_on_compact α (order_dual E) _ _ ‹_› _ _ ‹_› _ _ _ _ ‹_› _ _ _ hs _ hanti
lemma monotone.integrable_on_compact (hmono : monotone f) :
integrable_on f s μ :=
monotone_on.integrable_on_compact hs (λ x y _ _ hxy, hmono hxy)
lemma antitone.integrable_on_compact (hanti : antitone f) :
integrable_on f s μ :=
@monotone.integrable_on_compact α (order_dual E) _ _ ‹_› _ _ ‹_› _ _ _ _ ‹_› _ _ _ hs _ hanti
end monotone
|
#' Work with databases in your CouchDB's.
#'
#' @name databases
#'
#' @details
#' There are the following functions for working with databases:
#' \itemize{
#' \item \code{\link{db_create}} - Create a database
#' \item \code{\link{db_delete}} - Delete a database
#' \item \code{\link{db_info}} - Get info for a database
#' \item \code{\link{db_list}} - List databases
#' \item \code{\link{db_replicate}} - Replicate a database from one couch to another
#' }
NULL
|
Formal statement is: lemma closed_subspace: fixes s :: "'a::euclidean_space set" assumes "subspace s" shows "closed s" Informal statement is: Any subspace of a Euclidean space is closed. |
[STATEMENT]
lemma equiv_congruent: "equiv UNIV (congruent_rel b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. equiv UNIV (congruent_rel b)
[PROOF STEP]
unfolding equiv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. refl (congruent_rel b) \<and> sym (congruent_rel b) \<and> trans (congruent_rel b)
[PROOF STEP]
using relf_congruent_rel sym_congruent_rel trans_congruent_rel
[PROOF STATE]
proof (prove)
using this:
refl (congruent_rel ?b)
sym (congruent_rel ?b)
trans (congruent_rel ?b)
goal (1 subgoal):
1. refl (congruent_rel b) \<and> sym (congruent_rel b) \<and> trans (congruent_rel b)
[PROOF STEP]
by auto |
import tactic
import order.filter.partial
import algebra.support
import kent_convergence_space.basic
import data.fin.tuple
noncomputable theory
open set filter classical kent_convergence_space convergence_space
open_locale classical filter
variables {α β : Type*}
/-!
### Definition
-/
@[ext] class limit_space (α : Type*) extends convergence_space α :=
(sup_converges : ∀ {f g x}, converges f x → converges g x → converges (f ⊔ g) x)
open limit_space
namespace limit_space
instance has_coe : has_coe (limit_space α) (convergence_space α) :=
{ coe := λ p, p.to_convergence_space }
@[simp, norm_cast] theorem coe_inj {p q : limit_space α} :
(↑p : convergence_space α)= ↑q ↔ p = q :=
by { rw limit_space.ext_iff, tauto }
lemma coe_injective : function.injective (coe : limit_space α → convergence_space α) :=
λ s t, coe_inj.1
end limit_space
@[simp] def sup_converges_ (p : limit_space α) {f g : filter α} {x : α}
(hf : converges_ ↑p f x) (hg : converges_ ↑p g x) : converges_ ↑p (f ⊔ g) x
:= @sup_converges _ p _ _ _ hf hg
instance limit_space.to_kent_convergence_space
[limit_space α] : kent_convergence_space α :=
{ converges := converges,
pure_converges := pure_converges,
le_converges := λ f g hle hconv, le_converges hle,
kent_converges := λ f x hconv, sup_converges hconv (pure_converges x) }
lemma Sup_converges [limit_space α] {fs : set (filter α)} (hfin : fs.finite)
{x : α} (hconv : ∀ f ∈ fs, converges f x) : converges (Sup fs) x :=
begin
refine set.finite.induction_on' hfin _ _,
{ simp, exact bot_converges x },
{ intros g gs hmem hsub hnmem hSup,
rw [set.insert_eq, Sup_union], simp,
have hg : converges g x := hconv g hmem,
exact sup_converges hg hSup}
end
lemma Sup_converges_ (p : limit_space α) {fs : set (filter α)} (hfin : fs.finite)
{x : α} (hconv : ∀ f ∈ fs, converges_ ↑p f x) : converges_ ↑p (Sup fs) x :=
@Sup_converges _ p fs hfin x hconv
/-!
### Ordering
-/
/-- The ordering is the one inherited from convergence spaces. -/
instance : has_le (limit_space α) := ⟨λ p q, ↑p ≤ (↑q : convergence_space α)⟩
instance : partial_order (limit_space α) :=
partial_order.lift coe limit_space.coe_injective
/-!
### Lattice of limit structures
-/
/-- Limit structures form a complete lattice. Infimums are formed like in convergence
spaces. Supremums are different: `h` converges to `x` with respect to `p ⊔ q` when there
exists filters `g, h` such that `g` converges to `x` with respect to `p`, `h` converges
to `x` with respect to `q` and `f ≤ g ⊔ h`. -/
instance : has_top (limit_space α) :=
{ top := { sup_converges := by tauto, ..convergence_space.has_top.top }}
instance : has_bot (limit_space α) :=
{ bot :=
{ sup_converges :=
begin
intros f g x hf hg,
calc f ⊔ g ≤ pure x ⊔ pure x : sup_le_sup hf hg
... = pure x : sup_idem,
end,
..convergence_space.has_bot.bot }}
instance : has_inf (limit_space α) :=
{ inf := λ p q, let super : convergence_space α := ↑p ⊓ ↑q in
{ converges := converges_ super,
pure_converges := pure_converges_ super,
le_converges := le_converges_ super,
sup_converges := λ f g x hf hg,
⟨sup_converges_ p hf.1 hg.1, sup_converges_ q hf.2 hg.2⟩ }}
instance : has_sup (limit_space α) :=
{ sup := λ p q,
{ converges := λ f x, ∃ g₁ g₂, f ≤ g₁ ⊔ g₂ ∧ converges_ ↑p g₁ x ∧ converges_ ↑q g₂ x,
pure_converges := λ x, by refine ⟨pure x, pure x, _, _, _⟩; simp,
le_converges :=
begin
rintros f g hle x ⟨g₁, g₂, hle', hg₁, hg₂⟩,
exact ⟨g₁, g₂, trans hle hle', hg₁, hg₂⟩
end,
sup_converges :=
begin
rintros f f' x ⟨g₁, g₂, hle, hg₁, hg₂⟩ ⟨g₁', g₂', hle', hg₁', hg₂'⟩,
refine ⟨g₁ ⊔ g₁', g₂ ⊔ g₂', _, sup_converges_ p hg₁ hg₁', sup_converges_ q hg₂ hg₂'⟩,
calc f ⊔ f' ≤ (g₁ ⊔ g₂) ⊔ (g₁' ⊔ g₂') : sup_le_sup hle hle'
... = (g₁ ⊔ g₁') ⊔ (g₂ ⊔ g₂') : sup_sup_sup_comm g₁ g₂ g₁' g₂'
end }}
instance : has_Inf (limit_space α) :=
{ Inf := λ ps, let super : convergence_space α := Inf (coe '' ps) in
{ converges := converges_ super,
pure_converges := pure_converges_ super,
le_converges := le_converges_ super,
sup_converges :=
begin
intros f g x hf hg p hp,
obtain ⟨q, hq, heq⟩ := mem_image_iff_bex.mp hp,
rw ← heq at *,
exact sup_converges_ q (hf hp) (hg hp)
end }}
instance : has_Sup (limit_space α) :=
{ Sup := λ ps, let super : convergence_space α := Sup (coe '' ps) in
{ converges := λ f x, ∃ gs : set (filter α), gs.nonempty ∧ gs.finite ∧
f ≤ Sup gs ∧ ∀ g, g ∈ gs → converges_ super g x,
pure_converges := λ x,
⟨{ pure x }, set.singleton_nonempty (pure x), set.finite_singleton (pure x), by simp, by simp⟩,
le_converges :=
begin
intros f f' hle x hconv,
obtain ⟨gs, hne, hfin, hle', hconv'⟩ := hconv,
exact ⟨gs, hne, hfin, le_trans hle hle', hconv'⟩
end,
sup_converges :=
begin
rintros f₁ f₂ x hf₁ hf₂,
obtain ⟨gs₁, hne₁, hfin₁, hle₁, hconv₁⟩ := hf₁,
obtain ⟨gs₂, hne₂, hfin₂, hle₂, hconv₂⟩ := hf₂,
refine ⟨gs₁ ∪ gs₂, set.nonempty.inl hne₁, set.finite_union.mpr ⟨hfin₁, hfin₂⟩, _, _⟩,
rw Sup_union,
exact sup_le_sup hle₁ hle₂,
intros g hmem, cases hmem,
{ exact hconv₁ g hmem },
{ exact hconv₂ g hmem }
end }}
instance : semilattice_inf (limit_space α) :=
by { refine function.injective.semilattice_inf coe limit_space.coe_injective _, tauto }
instance : semilattice_sup (limit_space α) :=
{ le_sup_left := λ p q f x hconv, ⟨f, pure x, le_sup_left, hconv, pure_converges_ ↑q x⟩,
le_sup_right := λ p q f x hconv, ⟨pure x, f, le_sup_right, pure_converges_ ↑p x, hconv⟩,
sup_le := λ p q r hp hq f x ⟨g₁, g₂, hle, hg₁, hg₂⟩,
le_converges_ r hle (sup_converges_ r (hp hg₁) (hq hg₂)),
..limit_space.partial_order,
..limit_space.has_sup }
lemma limit_space.coe_Inf (ps : set (limit_space α)) :
(↑(Inf ps) : convergence_space α) = Inf (coe '' ps) :=
by { ext, tauto }
instance : complete_semilattice_Inf (limit_space α) :=
{ Inf_le :=
begin
intros ps p hmem f x hconv,
rw limit_space.coe_Inf at hconv,
exact hconv (mem_image_of_mem coe hmem),
end,
le_Inf :=
begin
intros ps q hle,
change ↑q ≤ ↑(Inf ps),
rw limit_space.coe_Inf,
intros f x hconv p hp,
obtain ⟨r, hr, heq⟩ := mem_image_iff_bex.mp hp,
rw ← heq,
exact hle r hr hconv,
end,
..limit_space.partial_order,
..limit_space.has_Inf }
instance : complete_semilattice_Sup (limit_space α) :=
{ le_Sup :=
begin
intros ps p hp f x hconv,
refine ⟨{ f }, set.singleton_nonempty f, set.finite_singleton f, by simp, _⟩,
intros g hmem,
rw set.mem_singleton_iff.mp hmem,
exact or.inr ⟨p, mem_image_of_mem coe hp, hconv⟩,
end,
Sup_le :=
begin
rintros qs p hle f x ⟨gs, hne, hfin, hle', hconv⟩,
have hg : ∀ g ∈ gs, converges_ ↑p g x,
begin
intros g hmem,
let hconv' : g ≤ pure x ∨
∃ q : convergence_space α, q ∈ coe '' qs ∧ converges_ q g x := hconv g hmem,
exact hconv'.elim
(λ hg : g ≤ pure x, le_converges_ ↑p hg (pure_converges_ ↑p x))
(λ hexists : (∃ q : convergence_space α, q ∈ coe '' qs ∧ converges_ q g x),
begin
obtain ⟨q, hq, hg⟩ := hexists,
rw set.mem_image_iff_bex at hq,
obtain ⟨q', hq', heq⟩ := hq,
rw ← heq at hg,
exact (hle q' hq') hg,
end),
end,
have hSup : converges_ ↑p (Sup gs) x, from Sup_converges_ p hfin hg,
exact le_converges_ p hle' hSup,
end,
..limit_space.partial_order,
..limit_space.has_Sup }
instance : lattice (limit_space α) :=
{ ..limit_space.semilattice_sup,
..limit_space.semilattice_inf }
instance : complete_lattice (limit_space α) :=
{ bot_le := λ p f x hconv, le_converges_ p hconv (pure_converges_ p x),
le_top := by intros; tauto,
..limit_space.has_bot,
..limit_space.has_top,
..limit_space.lattice,
..limit_space.complete_semilattice_Inf,
..limit_space.complete_semilattice_Sup } |
Formal statement is: lemma closure_insert: fixes x :: "'a::t1_space" shows "closure (insert x s) = insert x (closure s)" Informal statement is: The closure of a set $S$ is the union of $S$ and the closure of $S$. |
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
! This file was ported from Lean 3 source module order.interval
! leanprover-community/mathlib commit 6623e6af705e97002a9054c1c05a980180276fc1
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Data.Set.Intervals.Basic
import Mathbin.Data.Set.Lattice
import Mathbin.Data.SetLike.Basic
/-!
# Order intervals
This file defines (nonempty) closed intervals in an order (see `set.Icc`). This is a prototype for
interval arithmetic.
## Main declarations
* `nonempty_interval`: Nonempty intervals. Pairs where the second element is greater than the first.
* `interval`: Intervals. Either `∅` or a nonempty interval.
-/
open Function OrderDual Set
variable {α β γ δ : Type _} {ι : Sort _} {κ : ι → Sort _}
/-- The nonempty closed intervals in an order.
We define intervals by the pair of endpoints `fst`, `snd`. To convert intervals to the set of
elements between these endpoints, use the coercion `nonempty_interval α → set α`. -/
@[ext]
structure NonemptyInterval (α : Type _) [LE α] extends α × α where
fst_le_snd : fst ≤ snd
#align nonempty_interval NonemptyInterval
namespace NonemptyInterval
section LE
variable [LE α] {s t : NonemptyInterval α}
theorem toProd_injective : Injective (toProd : NonemptyInterval α → α × α) := fun s t =>
(ext_iff _ _).2
#align nonempty_interval.to_prod_injective NonemptyInterval.toProd_injective
/-- The injection that induces the order on intervals. -/
def toDualProd : NonemptyInterval α → αᵒᵈ × α :=
toProd
#align nonempty_interval.to_dual_prod NonemptyInterval.toDualProd
@[simp]
theorem toDualProd_apply (s : NonemptyInterval α) : s.toDualProd = (toDual s.fst, s.snd) :=
Prod.mk.eta.symm
#align nonempty_interval.to_dual_prod_apply NonemptyInterval.toDualProd_apply
theorem toDualProd_injective : Injective (toDualProd : NonemptyInterval α → αᵒᵈ × α) :=
toProd_injective
#align nonempty_interval.to_dual_prod_injective NonemptyInterval.toDualProd_injective
instance [IsEmpty α] : IsEmpty (NonemptyInterval α) :=
⟨fun s => isEmptyElim s.fst⟩
instance [Subsingleton α] : Subsingleton (NonemptyInterval α) :=
toDualProd_injective.Subsingleton
instance : LE (NonemptyInterval α) :=
⟨fun s t => t.fst ≤ s.fst ∧ s.snd ≤ t.snd⟩
theorem le_def : s ≤ t ↔ t.fst ≤ s.fst ∧ s.snd ≤ t.snd :=
Iff.rfl
#align nonempty_interval.le_def NonemptyInterval.le_def
/-- `to_dual_prod` as an order embedding. -/
@[simps]
def toDualProdHom : NonemptyInterval α ↪o αᵒᵈ × α
where
toFun := toDualProd
inj' := toDualProd_injective
map_rel_iff' _ _ := Iff.rfl
#align nonempty_interval.to_dual_prod_hom NonemptyInterval.toDualProdHom
/-- Turn an interval into an interval in the dual order. -/
def dual : NonemptyInterval α ≃ NonemptyInterval αᵒᵈ
where
toFun s := ⟨s.toProd.symm, s.fst_le_snd⟩
invFun s := ⟨s.toProd.symm, s.fst_le_snd⟩
left_inv s := ext _ _ <| Prod.swap_swap _
right_inv s := ext _ _ <| Prod.swap_swap _
#align nonempty_interval.dual NonemptyInterval.dual
@[simp]
theorem fst_dual (s : NonemptyInterval α) : s.dual.fst = toDual s.snd :=
rfl
#align nonempty_interval.fst_dual NonemptyInterval.fst_dual
@[simp]
theorem snd_dual (s : NonemptyInterval α) : s.dual.snd = toDual s.fst :=
rfl
#align nonempty_interval.snd_dual NonemptyInterval.snd_dual
end LE
section Preorder
variable [Preorder α] [Preorder β] [Preorder γ] [Preorder δ] {s : NonemptyInterval α} {x : α × α}
{a : α}
instance : Preorder (NonemptyInterval α) :=
Preorder.lift toDualProd
instance : CoeTC (NonemptyInterval α) (Set α) :=
⟨fun s => Icc s.fst s.snd⟩
instance (priority := 100) : Membership α (NonemptyInterval α) :=
⟨fun a s => a ∈ (s : Set α)⟩
@[simp]
theorem mem_mk {hx : x.1 ≤ x.2} : a ∈ mk x hx ↔ x.1 ≤ a ∧ a ≤ x.2 :=
Iff.rfl
#align nonempty_interval.mem_mk NonemptyInterval.mem_mk
theorem mem_def : a ∈ s ↔ s.fst ≤ a ∧ a ≤ s.snd :=
Iff.rfl
#align nonempty_interval.mem_def NonemptyInterval.mem_def
@[simp]
theorem coe_nonempty (s : NonemptyInterval α) : (s : Set α).Nonempty :=
nonempty_Icc.2 s.fst_le_snd
#align nonempty_interval.coe_nonempty NonemptyInterval.coe_nonempty
/-- `{a}` as an interval. -/
@[simps]
def pure (a : α) : NonemptyInterval α :=
⟨⟨a, a⟩, le_rfl⟩
#align nonempty_interval.pure NonemptyInterval.pure
theorem mem_pure_self (a : α) : a ∈ pure a :=
⟨le_rfl, le_rfl⟩
#align nonempty_interval.mem_pure_self NonemptyInterval.mem_pure_self
theorem pure_injective : Injective (pure : α → NonemptyInterval α) := fun s t =>
congr_arg <| Prod.fst ∘ toProd
#align nonempty_interval.pure_injective NonemptyInterval.pure_injective
@[simp]
theorem dual_pure (a : α) : (pure a).dual = pure (toDual a) :=
rfl
#align nonempty_interval.dual_pure NonemptyInterval.dual_pure
instance [Inhabited α] : Inhabited (NonemptyInterval α) :=
⟨pure default⟩
instance : ∀ [Nonempty α], Nonempty (NonemptyInterval α) :=
Nonempty.map pure
instance [Nontrivial α] : Nontrivial (NonemptyInterval α) :=
pure_injective.Nontrivial
/-- Pushforward of nonempty intervals. -/
@[simps]
def map (f : α →o β) (a : NonemptyInterval α) : NonemptyInterval β :=
⟨a.toProd.map f f, f.mono a.fst_le_snd⟩
#align nonempty_interval.map NonemptyInterval.map
@[simp]
theorem map_pure (f : α →o β) (a : α) : (pure a).map f = pure (f a) :=
rfl
#align nonempty_interval.map_pure NonemptyInterval.map_pure
@[simp]
theorem map_map (g : β →o γ) (f : α →o β) (a : NonemptyInterval α) :
(a.map f).map g = a.map (g.comp f) :=
rfl
#align nonempty_interval.map_map NonemptyInterval.map_map
@[simp]
theorem dual_map (f : α →o β) (a : NonemptyInterval α) : (a.map f).dual = a.dual.map f.dual :=
rfl
#align nonempty_interval.dual_map NonemptyInterval.dual_map
/-- Binary pushforward of nonempty intervals. -/
@[simps]
def map₂ (f : α → β → γ) (h₀ : ∀ b, Monotone fun a => f a b) (h₁ : ∀ a, Monotone (f a)) :
NonemptyInterval α → NonemptyInterval β → NonemptyInterval γ := fun s t =>
⟨(f s.fst t.fst, f s.snd t.snd), (h₀ _ s.fst_le_snd).trans <| h₁ _ t.fst_le_snd⟩
#align nonempty_interval.map₂ NonemptyInterval.map₂
@[simp]
theorem map₂_pure (f : α → β → γ) (h₀ h₁) (a : α) (b : β) :
map₂ f h₀ h₁ (pure a) (pure b) = pure (f a b) :=
rfl
#align nonempty_interval.map₂_pure NonemptyInterval.map₂_pure
@[simp]
theorem dual_map₂ (f : α → β → γ) (h₀ h₁ s t) :
(map₂ f h₀ h₁ s t).dual =
map₂ (fun a b => toDual <| f (ofDual a) <| ofDual b) (fun _ => (h₀ _).dual)
(fun _ => (h₁ _).dual) s.dual t.dual :=
rfl
#align nonempty_interval.dual_map₂ NonemptyInterval.dual_map₂
variable [BoundedOrder α]
instance : OrderTop (NonemptyInterval α)
where
top := ⟨⟨⊥, ⊤⟩, bot_le⟩
le_top a := ⟨bot_le, le_top⟩
@[simp]
theorem dual_top : (⊤ : NonemptyInterval α).dual = ⊤ :=
rfl
#align nonempty_interval.dual_top NonemptyInterval.dual_top
end Preorder
section PartialOrder
variable [PartialOrder α] [PartialOrder β] {s t : NonemptyInterval α} {x : α × α} {a b : α}
instance : PartialOrder (NonemptyInterval α) :=
PartialOrder.lift _ toDualProd_injective
/-- Consider a nonempty interval `[a, b]` as the set `[a, b]`. -/
def coeHom : NonemptyInterval α ↪o Set α :=
OrderEmbedding.ofMapLEIff (fun s => Icc s.fst s.snd) fun s t => Icc_subset_Icc_iff s.fst_le_snd
#align nonempty_interval.coe_hom NonemptyInterval.coeHom
instance : SetLike (NonemptyInterval α) α
where
coe s := Icc s.fst s.snd
coe_injective' := coeHom.Injective
@[simp, norm_cast]
theorem coe_subset_coe : (s : Set α) ⊆ t ↔ s ≤ t :=
(@coeHom α _).le_iff_le
#align nonempty_interval.coe_subset_coe NonemptyInterval.coe_subset_coe
@[simp, norm_cast]
theorem coe_sSubset_coe : (s : Set α) ⊂ t ↔ s < t :=
(@coeHom α _).lt_iff_lt
#align nonempty_interval.coe_ssubset_coe NonemptyInterval.coe_sSubset_coe
@[simp]
theorem coe_coeHom : (coeHom : NonemptyInterval α → Set α) = coe :=
rfl
#align nonempty_interval.coe_coe_hom NonemptyInterval.coe_coeHom
@[simp, norm_cast]
theorem coe_pure (a : α) : (pure a : Set α) = {a} :=
Icc_self _
#align nonempty_interval.coe_pure NonemptyInterval.coe_pure
@[simp]
theorem mem_pure : b ∈ pure a ↔ b = a := by rw [← SetLike.mem_coe, coe_pure, mem_singleton_iff]
#align nonempty_interval.mem_pure NonemptyInterval.mem_pure
@[simp, norm_cast]
theorem coe_top [BoundedOrder α] : ((⊤ : NonemptyInterval α) : Set α) = univ :=
Icc_bot_top
#align nonempty_interval.coe_top NonemptyInterval.coe_top
@[simp, norm_cast]
theorem coe_dual (s : NonemptyInterval α) : (s.dual : Set αᵒᵈ) = ofDual ⁻¹' s :=
dual_Icc
#align nonempty_interval.coe_dual NonemptyInterval.coe_dual
theorem subset_coe_map (f : α →o β) (s : NonemptyInterval α) : f '' s ⊆ s.map f :=
image_subset_iff.2 fun a ha => ⟨f.mono ha.1, f.mono ha.2⟩
#align nonempty_interval.subset_coe_map NonemptyInterval.subset_coe_map
end PartialOrder
section Lattice
variable [Lattice α]
instance : Sup (NonemptyInterval α) :=
⟨fun s t => ⟨⟨s.fst ⊓ t.fst, s.snd ⊔ t.snd⟩, inf_le_left.trans <| s.fst_le_snd.trans le_sup_left⟩⟩
instance : SemilatticeSup (NonemptyInterval α) :=
toDualProd_injective.SemilatticeSup _ fun _ _ => rfl
@[simp]
theorem fst_sup (s t : NonemptyInterval α) : (s ⊔ t).fst = s.fst ⊓ t.fst :=
rfl
#align nonempty_interval.fst_sup NonemptyInterval.fst_sup
@[simp]
theorem snd_sup (s t : NonemptyInterval α) : (s ⊔ t).snd = s.snd ⊔ t.snd :=
rfl
#align nonempty_interval.snd_sup NonemptyInterval.snd_sup
end Lattice
end NonemptyInterval
/-- The closed intervals in an order.
We represent intervals either as `⊥` or a nonempty interval given by its endpoints `fst`, `snd`.
To convert intervals to the set of elements between these endpoints, use the coercion
`interval α → set α`. -/
def Interval (α : Type _) [LE α] :=
WithBot (NonemptyInterval α)deriving Inhabited, LE, OrderBot
#align interval Interval
namespace Interval
section LE
variable [LE α] {s t : Interval α}
instance : CoeTC (NonemptyInterval α) (Interval α) :=
WithBot.hasCoeT
instance canLift : CanLift (Interval α) (NonemptyInterval α) coe fun r => r ≠ ⊥ :=
WithBot.canLift
#align interval.can_lift Interval.canLift
theorem coe_injective : Injective (coe : NonemptyInterval α → Interval α) :=
WithBot.coe_injective
#align interval.coe_injective Interval.coe_injective
@[simp, norm_cast]
theorem coe_inj {s t : NonemptyInterval α} : (s : Interval α) = t ↔ s = t :=
WithBot.coe_inj
#align interval.coe_inj Interval.coe_inj
@[protected]
theorem forall {p : Interval α → Prop} : (∀ s, p s) ↔ p ⊥ ∧ ∀ s : NonemptyInterval α, p s :=
Option.forall
#align interval.forall Interval.forall
@[protected]
theorem exists {p : Interval α → Prop} : (∃ s, p s) ↔ p ⊥ ∨ ∃ s : NonemptyInterval α, p s :=
Option.exists
#align interval.exists Interval.exists
instance [IsEmpty α] : Unique (Interval α) :=
Option.unique
/-- Turn an interval into an interval in the dual order. -/
def dual : Interval α ≃ Interval αᵒᵈ :=
NonemptyInterval.dual.optionCongr
#align interval.dual Interval.dual
end LE
section Preorder
variable [Preorder α] [Preorder β] [Preorder γ]
instance : Preorder (Interval α) :=
WithBot.preorder
/-- `{a}` as an interval. -/
def pure (a : α) : Interval α :=
NonemptyInterval.pure a
#align interval.pure Interval.pure
theorem pure_injective : Injective (pure : α → Interval α) :=
coe_injective.comp NonemptyInterval.pure_injective
#align interval.pure_injective Interval.pure_injective
@[simp]
theorem dual_pure (a : α) : (pure a).dual = pure (toDual a) :=
rfl
#align interval.dual_pure Interval.dual_pure
@[simp]
theorem dual_bot : (⊥ : Interval α).dual = ⊥ :=
rfl
#align interval.dual_bot Interval.dual_bot
@[simp]
theorem pure_ne_bot {a : α} : pure a ≠ ⊥ :=
WithBot.coe_ne_bot
#align interval.pure_ne_bot Interval.pure_ne_bot
@[simp]
theorem bot_ne_pure {a : α} : ⊥ ≠ pure a :=
WithBot.bot_ne_coe
#align interval.bot_ne_pure Interval.bot_ne_pure
instance [Nonempty α] : Nontrivial (Interval α) :=
Option.nontrivial
/-- Pushforward of intervals. -/
def map (f : α →o β) : Interval α → Interval β :=
WithBot.map (NonemptyInterval.map f)
#align interval.map Interval.map
@[simp]
theorem map_pure (f : α →o β) (a : α) : (pure a).map f = pure (f a) :=
rfl
#align interval.map_pure Interval.map_pure
@[simp]
theorem map_map (g : β →o γ) (f : α →o β) (s : Interval α) : (s.map f).map g = s.map (g.comp f) :=
Option.map_map _ _ _
#align interval.map_map Interval.map_map
@[simp]
theorem dual_map (f : α →o β) (s : Interval α) : (s.map f).dual = s.dual.map f.dual :=
by
cases s
· rfl
· exact WithBot.map_comm rfl _
#align interval.dual_map Interval.dual_map
variable [BoundedOrder α]
instance : BoundedOrder (Interval α) :=
WithBot.boundedOrder
@[simp]
theorem dual_top : (⊤ : Interval α).dual = ⊤ :=
rfl
#align interval.dual_top Interval.dual_top
end Preorder
section PartialOrder
variable [PartialOrder α] [PartialOrder β] {s t : Interval α} {a b : α}
instance : PartialOrder (Interval α) :=
WithBot.partialOrder
/-- Consider a interval `[a, b]` as the set `[a, b]`. -/
def coeHom : Interval α ↪o Set α :=
OrderEmbedding.ofMapLEIff
(fun s =>
match s with
| ⊥ => ∅
| some s => s)
fun s t =>
match s, t with
| ⊥, t => iff_of_true bot_le bot_le
| some s, ⊥ =>
iff_of_false (fun h => s.coe_nonempty.ne_empty <| le_bot_iff.1 h) (WithBot.not_coe_le_bot _)
| some s, some t => (@NonemptyInterval.coeHom α _).le_iff_le.trans WithBot.some_le_some.symm
#align interval.coe_hom Interval.coeHom
instance : SetLike (Interval α) α where
coe := coeHom
coe_injective' := coeHom.Injective
@[simp, norm_cast]
theorem coe_subset_coe : (s : Set α) ⊆ t ↔ s ≤ t :=
(@coeHom α _).le_iff_le
#align interval.coe_subset_coe Interval.coe_subset_coe
@[simp, norm_cast]
theorem coe_sSubset_coe : (s : Set α) ⊂ t ↔ s < t :=
(@coeHom α _).lt_iff_lt
#align interval.coe_ssubset_coe Interval.coe_sSubset_coe
@[simp, norm_cast]
theorem coe_pure (a : α) : (pure a : Set α) = {a} :=
Icc_self _
#align interval.coe_pure Interval.coe_pure
@[simp, norm_cast]
theorem coe_coe (s : NonemptyInterval α) : ((s : Interval α) : Set α) = s :=
rfl
#align interval.coe_coe Interval.coe_coe
@[simp, norm_cast]
theorem coe_bot : ((⊥ : Interval α) : Set α) = ∅ :=
rfl
#align interval.coe_bot Interval.coe_bot
@[simp, norm_cast]
theorem coe_top [BoundedOrder α] : ((⊤ : Interval α) : Set α) = univ :=
Icc_bot_top
#align interval.coe_top Interval.coe_top
@[simp, norm_cast]
theorem coe_dual (s : Interval α) : (s.dual : Set αᵒᵈ) = ofDual ⁻¹' s :=
by
cases s
· rfl
exact s.coe_dual
#align interval.coe_dual Interval.coe_dual
theorem subset_coe_map (f : α →o β) : ∀ s : Interval α, f '' s ⊆ s.map f
| ⊥ => by simp
| (s : NonemptyInterval α) => s.subset_coe_map _
#align interval.subset_coe_map Interval.subset_coe_map
@[simp]
theorem mem_pure : b ∈ pure a ↔ b = a := by rw [← SetLike.mem_coe, coe_pure, mem_singleton_iff]
#align interval.mem_pure Interval.mem_pure
theorem mem_pure_self (a : α) : a ∈ pure a :=
mem_pure.2 rfl
#align interval.mem_pure_self Interval.mem_pure_self
end PartialOrder
section Lattice
variable [Lattice α]
instance : SemilatticeSup (Interval α) :=
WithBot.semilatticeSup
section Decidable
variable [@DecidableRel α (· ≤ ·)]
instance : Lattice (Interval α) :=
{
Interval.semilatticeSup with
inf := fun s t =>
match s, t with
| ⊥, t => ⊥
| s, ⊥ => ⊥
| some s, some t =>
if h : s.fst ≤ t.snd ∧ t.fst ≤ s.snd then
some
⟨⟨s.fst ⊔ t.fst, s.snd ⊓ t.snd⟩,
sup_le (le_inf s.fst_le_snd h.1) <| le_inf h.2 t.fst_le_snd⟩
else ⊥
inf_le_left := fun s t =>
match s, t with
| ⊥, ⊥ => bot_le
| ⊥, some t => bot_le
| some s, ⊥ => bot_le
| some s, some t => by
change dite _ _ _ ≤ _
split_ifs
· exact WithBot.some_le_some.2 ⟨le_sup_left, inf_le_left⟩
· exact bot_le
inf_le_right := fun s t =>
match s, t with
| ⊥, ⊥ => bot_le
| ⊥, some t => bot_le
| some s, ⊥ => bot_le
| some s, some t => by
change dite _ _ _ ≤ _
split_ifs
· exact WithBot.some_le_some.2 ⟨le_sup_right, inf_le_right⟩
· exact bot_le
le_inf := fun s t c =>
match s, t, c with
| ⊥, t, c => fun _ _ => bot_le
| some s, t, c => fun hb hc =>
by
lift t to NonemptyInterval α using ne_bot_of_le_ne_bot WithBot.coe_ne_bot hb
lift c to NonemptyInterval α using ne_bot_of_le_ne_bot WithBot.coe_ne_bot hc
change _ ≤ dite _ _ _
simp only [WithBot.some_eq_coe, WithBot.coe_le_coe] at hb hc⊢
rw [dif_pos, WithBot.coe_le_coe]
exact ⟨sup_le hb.1 hc.1, le_inf hb.2 hc.2⟩
exact ⟨hb.1.trans <| s.fst_le_snd.trans hc.2, hc.1.trans <| s.fst_le_snd.trans hb.2⟩ }
@[simp, norm_cast]
theorem coe_inf (s t : Interval α) : (↑(s ⊓ t) : Set α) = s ∩ t :=
by
cases s
· rw [WithBot.none_eq_bot, bot_inf_eq]
exact (empty_inter _).symm
cases t
· rw [WithBot.none_eq_bot, inf_bot_eq]
exact (inter_empty _).symm
refine' (_ : coe (dite _ _ _) = _).trans Icc_inter_Icc.symm
split_ifs
· rfl
·
exact
(Icc_eq_empty fun H =>
h
⟨le_sup_left.trans <| H.trans inf_le_right,
le_sup_right.trans <| H.trans inf_le_left⟩).symm
#align interval.coe_inf Interval.coe_inf
end Decidable
@[simp, norm_cast]
theorem disjoint_coe (s t : Interval α) : Disjoint (s : Set α) t ↔ Disjoint s t := by
classical
rw [disjoint_iff_inf_le, disjoint_iff_inf_le, le_eq_subset, ← coe_subset_coe, coe_inf]
rfl
#align interval.disjoint_coe Interval.disjoint_coe
end Lattice
end Interval
namespace NonemptyInterval
section Preorder
variable [Preorder α] {s : NonemptyInterval α} {a : α}
@[simp, norm_cast]
theorem coe_pure_interval (a : α) : (pure a : Interval α) = Interval.pure a :=
rfl
#align nonempty_interval.coe_pure_interval NonemptyInterval.coe_pure_interval
@[simp, norm_cast]
theorem coe_eq_pure : (s : Interval α) = Interval.pure a ↔ s = pure a := by
rw [← Interval.coe_inj, coe_pure_interval]
#align nonempty_interval.coe_eq_pure NonemptyInterval.coe_eq_pure
@[simp, norm_cast]
theorem coe_top_interval [BoundedOrder α] : ((⊤ : NonemptyInterval α) : Interval α) = ⊤ :=
rfl
#align nonempty_interval.coe_top_interval NonemptyInterval.coe_top_interval
end Preorder
@[simp, norm_cast]
theorem mem_coe_interval [PartialOrder α] {s : NonemptyInterval α} {x : α} :
x ∈ (s : Interval α) ↔ x ∈ s :=
Iff.rfl
#align nonempty_interval.mem_coe_interval NonemptyInterval.mem_coe_interval
@[simp, norm_cast]
theorem coe_sup_interval [Lattice α] (s t : NonemptyInterval α) : (↑(s ⊔ t) : Interval α) = s ⊔ t :=
rfl
#align nonempty_interval.coe_sup_interval NonemptyInterval.coe_sup_interval
end NonemptyInterval
namespace Interval
section CompleteLattice
variable [CompleteLattice α]
noncomputable instance [@DecidableRel α (· ≤ ·)] : CompleteLattice (Interval α) := by
classical exact
{ Interval.lattice,
Interval.boundedOrder with
supₛ := fun S =>
if h : S ⊆ {⊥} then ⊥
else
some
⟨⟨⨅ (s : NonemptyInterval α) (h : ↑s ∈ S), s.fst,
⨆ (s : NonemptyInterval α) (h : ↑s ∈ S), s.snd⟩,
by
obtain ⟨s, hs, ha⟩ := not_subset.1 h
lift s to NonemptyInterval α using ha
exact infᵢ₂_le_of_le s hs (le_supᵢ₂_of_le s hs s.fst_le_snd)⟩
le_sup := fun s s ha => by
split_ifs
· exact (h ha).le
cases s
· exact bot_le
· exact WithBot.some_le_some.2 ⟨infᵢ₂_le _ ha, le_supᵢ₂_of_le _ ha le_rfl⟩
sup_le := fun s s ha => by
split_ifs
· exact bot_le
obtain ⟨b, hs, hb⟩ := not_subset.1 h
lift s to NonemptyInterval α using ne_bot_of_le_ne_bot hb (ha _ hs)
exact
WithBot.coe_le_coe.2
⟨le_infᵢ₂ fun c hc => (WithBot.coe_le_coe.1 <| ha _ hc).1,
supᵢ₂_le fun c hc => (WithBot.coe_le_coe.1 <| ha _ hc).2⟩
infₛ := fun S =>
if h :
⊥ ∉ S ∧
∀ ⦃s : NonemptyInterval α⦄,
↑s ∈ S → ∀ ⦃t : NonemptyInterval α⦄, ↑t ∈ S → s.fst ≤ t.snd then
some
⟨⟨⨆ (s : NonemptyInterval α) (h : ↑s ∈ S), s.fst,
⨅ (s : NonemptyInterval α) (h : ↑s ∈ S), s.snd⟩,
supᵢ₂_le fun s hs => le_infᵢ₂ <| h.2 hs⟩
else ⊥
inf_le := fun s s ha => by
split_ifs
· lift s to NonemptyInterval α using ne_of_mem_of_not_mem ha h.1
exact WithBot.coe_le_coe.2 ⟨le_supᵢ₂ s ha, infᵢ₂_le s ha⟩
· exact bot_le
le_inf := fun S s ha => by
cases s
· exact bot_le
split_ifs
·
exact
WithBot.some_le_some.2
⟨supᵢ₂_le fun t hb => (WithBot.coe_le_coe.1 <| ha _ hb).1,
le_infᵢ₂ fun t hb => (WithBot.coe_le_coe.1 <| ha _ hb).2⟩
rw [not_and_or, Classical.not_not] at h
cases h
· exact ha _ h
cases
h fun t hb c hc =>
(WithBot.coe_le_coe.1 <| ha _ hb).1.trans <|
s.fst_le_snd.trans (WithBot.coe_le_coe.1 <| ha _ hc).2 }
@[simp, norm_cast]
theorem coe_infₛ [@DecidableRel α (· ≤ ·)] (S : Set (Interval α)) :
↑(infₛ S) = ⋂ s ∈ S, (s : Set α) :=
by
change coe (dite _ _ _) = _
split_ifs
· ext
simp [WithBot.some_eq_coe, Interval.forall, h.1, ← forall_and, ← NonemptyInterval.mem_def]
simp_rw [not_and_or, Classical.not_not] at h
cases h
· refine' (eq_empty_of_subset_empty _).symm
exact Inter₂_subset_of_subset _ h subset.rfl
· refine' (not_nonempty_iff_eq_empty.1 _).symm
rintro ⟨x, hx⟩
rw [mem_Inter₂] at hx
exact h fun s ha t hb => (hx _ ha).1.trans (hx _ hb).2
#align interval.coe_Inf Interval.coe_infₛ
@[simp, norm_cast]
theorem coe_infᵢ [@DecidableRel α (· ≤ ·)] (f : ι → Interval α) :
↑(⨅ i, f i) = ⋂ i, (f i : Set α) := by simp [infᵢ]
#align interval.coe_infi Interval.coe_infᵢ
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
@[simp, norm_cast]
theorem coe_infi₂ [@DecidableRel α (· ≤ ·)] (f : ∀ i, κ i → Interval α) :
↑(⨅ (i) (j), f i j) = ⋂ (i) (j), (f i j : Set α) := by simp_rw [coe_infi]
#align interval.coe_infi₂ Interval.coe_infi₂
end CompleteLattice
end Interval
|
/-
Copyright (c) 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.complex.determinant
import data.complex.is_R_or_C
/-!
# Normed space structure on `ℂ`.
This file gathers basic facts on complex numbers of an analytic nature.
## Main results
This file registers `ℂ` as a normed field, expresses basic properties of the norm, and gives
tools on the real vector space structure of `ℂ`. Notably, in the namespace `complex`,
it defines functions:
* `re_clm`
* `im_clm`
* `of_real_clm`
* `conj_cle`
They are bundled versions of the real part, the imaginary part, the embedding of `ℝ` in `ℂ`, and
the complex conjugate as continuous `ℝ`-linear maps. The last two are also bundled as linear
isometries in `of_real_li` and `conj_lie`.
We also register the fact that `ℂ` is an `is_R_or_C` field.
-/
noncomputable theory
namespace complex
open_locale complex_conjugate
instance : has_norm ℂ := ⟨abs⟩
instance : normed_group ℂ :=
normed_group.of_core ℂ
{ norm_eq_zero_iff := λ z, abs_eq_zero,
triangle := abs_add,
norm_neg := abs_neg }
instance : normed_field ℂ :=
{ norm := abs,
dist_eq := λ _ _, rfl,
norm_mul' := abs_mul,
.. complex.field }
instance : nondiscrete_normed_field ℂ :=
{ non_trivial := ⟨2, by simp [norm]; norm_num⟩ }
instance {R : Type*} [normed_field R] [normed_algebra R ℝ] : normed_algebra R ℂ :=
{ norm_algebra_map_eq := λ x, (abs_of_real $ algebra_map R ℝ x).trans (norm_algebra_map_eq ℝ x),
to_algebra := complex.algebra }
/-- The module structure from `module.complex_to_real` is a normed space. -/
@[priority 900] -- see Note [lower instance priority]
instance _root_.normed_space.complex_to_real {E : Type*} [normed_group E] [normed_space ℂ E] :
normed_space ℝ E :=
normed_space.restrict_scalars ℝ ℂ E
@[simp] lemma norm_eq_abs (z : ℂ) : ∥z∥ = abs z := rfl
lemma dist_eq (z w : ℂ) : dist z w = abs (z - w) := rfl
@[simp] lemma norm_real (r : ℝ) : ∥(r : ℂ)∥ = ∥r∥ := abs_of_real _
@[simp] lemma norm_rat (r : ℚ) : ∥(r : ℂ)∥ = |(r : ℝ)| :=
suffices ∥((r : ℝ) : ℂ)∥ = |r|, by simpa,
by rw [norm_real, real.norm_eq_abs]
@[simp] lemma norm_nat (n : ℕ) : ∥(n : ℂ)∥ = n := abs_of_nat _
@[simp] lemma norm_int {n : ℤ} : ∥(n : ℂ)∥ = |n| :=
suffices ∥((n : ℝ) : ℂ)∥ = |n|, by simpa,
by rw [norm_real, real.norm_eq_abs]
lemma norm_int_of_nonneg {n : ℤ} (hn : 0 ≤ n) : ∥(n : ℂ)∥ = n :=
by rw [norm_int, _root_.abs_of_nonneg]; exact int.cast_nonneg.2 hn
@[continuity] lemma continuous_abs : continuous abs := continuous_norm
@[continuity] lemma continuous_norm_sq : continuous norm_sq :=
by simpa [← norm_sq_eq_abs] using continuous_abs.pow 2
/-- The `abs` function on `ℂ` is proper. -/
lemma tendsto_abs_cocompact_at_top : filter.tendsto abs (filter.cocompact ℂ) filter.at_top :=
tendsto_norm_cocompact_at_top
/-- The `norm_sq` function on `ℂ` is proper. -/
lemma tendsto_norm_sq_cocompact_at_top :
filter.tendsto norm_sq (filter.cocompact ℂ) filter.at_top :=
by simpa [mul_self_abs] using
tendsto_abs_cocompact_at_top.at_top_mul_at_top tendsto_abs_cocompact_at_top
open continuous_linear_map
/-- Continuous linear map version of the real part function, from `ℂ` to `ℝ`. -/
def re_clm : ℂ →L[ℝ] ℝ := re_lm.mk_continuous 1 (λ x, by simp [real.norm_eq_abs, abs_re_le_abs])
@[continuity] lemma continuous_re : continuous re := re_clm.continuous
@[simp] lemma re_clm_coe : (coe (re_clm) : ℂ →ₗ[ℝ] ℝ) = re_lm := rfl
@[simp]
@[simp] lemma re_clm_norm : ∥re_clm∥ = 1 :=
le_antisymm (linear_map.mk_continuous_norm_le _ zero_le_one _) $
calc 1 = ∥re_clm 1∥ : by simp
... ≤ ∥re_clm∥ : unit_le_op_norm _ _ (by simp)
/-- Continuous linear map version of the real part function, from `ℂ` to `ℝ`. -/
def im_clm : ℂ →L[ℝ] ℝ := im_lm.mk_continuous 1 (λ x, by simp [real.norm_eq_abs, abs_im_le_abs])
@[continuity] lemma continuous_im : continuous im := im_clm.continuous
@[simp] lemma im_clm_coe : (coe (im_clm) : ℂ →ₗ[ℝ] ℝ) = im_lm := rfl
@[simp] lemma im_clm_apply (z : ℂ) : (im_clm : ℂ → ℝ) z = z.im := rfl
@[simp] lemma im_clm_norm : ∥im_clm∥ = 1 :=
le_antisymm (linear_map.mk_continuous_norm_le _ zero_le_one _) $
calc 1 = ∥im_clm I∥ : by simp
... ≤ ∥im_clm∥ : unit_le_op_norm _ _ (by simp)
lemma restrict_scalars_one_smul_right' {E : Type*} [normed_group E] [normed_space ℂ E] (x : E) :
continuous_linear_map.restrict_scalars ℝ ((1 : ℂ →L[ℂ] ℂ).smul_right x : ℂ →L[ℂ] E) =
re_clm.smul_right x + I • im_clm.smul_right x :=
by { ext ⟨a, b⟩, simp [mk_eq_add_mul_I, add_smul, mul_smul, smul_comm I] }
lemma restrict_scalars_one_smul_right (x : ℂ) :
continuous_linear_map.restrict_scalars ℝ ((1 : ℂ →L[ℂ] ℂ).smul_right x : ℂ →L[ℂ] ℂ) = x • 1 :=
by { ext1 z, dsimp, apply mul_comm }
/-- The complex-conjugation function from `ℂ` to itself is an isometric linear equivalence. -/
def conj_lie : ℂ ≃ₗᵢ[ℝ] ℂ := ⟨conj_ae.to_linear_equiv, abs_conj⟩
@[simp] lemma conj_lie_apply (z : ℂ) : conj_lie z = conj z := rfl
lemma isometry_conj : isometry (conj : ℂ → ℂ) := conj_lie.isometry
/-- The determinant of `conj_lie`, as a linear map. -/
@[simp] lemma det_conj_lie : (conj_lie.to_linear_equiv : ℂ →ₗ[ℝ] ℂ).det = -1 :=
det_conj_ae
/-- The determinant of `conj_lie`, as a linear equiv. -/
@[simp] lemma linear_equiv_det_conj_lie : conj_lie.to_linear_equiv.det = -1 :=
linear_equiv_det_conj_ae
@[continuity] lemma continuous_conj : continuous (conj : ℂ → ℂ) := conj_lie.continuous
/-- Continuous linear equiv version of the conj function, from `ℂ` to `ℂ`. -/
def conj_cle : ℂ ≃L[ℝ] ℂ := conj_lie
@[simp] lemma conj_cle_coe : conj_cle.to_linear_equiv = conj_ae.to_linear_equiv := rfl
@[simp] lemma conj_cle_apply (z : ℂ) : conj_cle z = conj z := rfl
@[simp] lemma conj_cle_norm : ∥(conj_cle : ℂ →L[ℝ] ℂ)∥ = 1 :=
conj_lie.to_linear_isometry.norm_to_continuous_linear_map
/-- Linear isometry version of the canonical embedding of `ℝ` in `ℂ`. -/
def of_real_li : ℝ →ₗᵢ[ℝ] ℂ := ⟨of_real_am.to_linear_map, norm_real⟩
lemma isometry_of_real : isometry (coe : ℝ → ℂ) := of_real_li.isometry
@[continuity] lemma continuous_of_real : continuous (coe : ℝ → ℂ) := of_real_li.continuous
/-- Continuous linear map version of the canonical embedding of `ℝ` in `ℂ`. -/
def of_real_clm : ℝ →L[ℝ] ℂ := of_real_li.to_continuous_linear_map
@[simp] lemma of_real_clm_coe : (of_real_clm : ℝ →ₗ[ℝ] ℂ) = of_real_am.to_linear_map := rfl
@[simp] lemma of_real_clm_apply (x : ℝ) : of_real_clm x = x := rfl
@[simp] lemma of_real_clm_norm : ∥of_real_clm∥ = 1 := of_real_li.norm_to_continuous_linear_map
noncomputable instance : is_R_or_C ℂ :=
{ re := ⟨complex.re, complex.zero_re, complex.add_re⟩,
im := ⟨complex.im, complex.zero_im, complex.add_im⟩,
I := complex.I,
I_re_ax := by simp only [add_monoid_hom.coe_mk, complex.I_re],
I_mul_I_ax := by simp only [complex.I_mul_I, eq_self_iff_true, or_true],
re_add_im_ax := λ z, by simp only [add_monoid_hom.coe_mk, complex.re_add_im,
complex.coe_algebra_map, complex.of_real_eq_coe],
of_real_re_ax := λ r, by simp only [add_monoid_hom.coe_mk, complex.of_real_re,
complex.coe_algebra_map, complex.of_real_eq_coe],
of_real_im_ax := λ r, by simp only [add_monoid_hom.coe_mk, complex.of_real_im,
complex.coe_algebra_map, complex.of_real_eq_coe],
mul_re_ax := λ z w, by simp only [complex.mul_re, add_monoid_hom.coe_mk],
mul_im_ax := λ z w, by simp only [add_monoid_hom.coe_mk, complex.mul_im],
conj_re_ax := λ z, rfl,
conj_im_ax := λ z, rfl,
conj_I_ax := by simp only [complex.conj_I, ring_hom.coe_mk],
norm_sq_eq_def_ax := λ z, by simp only [←complex.norm_sq_eq_abs, ←complex.norm_sq_apply,
add_monoid_hom.coe_mk, complex.norm_eq_abs],
mul_im_I_ax := λ z, by simp only [mul_one, add_monoid_hom.coe_mk, complex.I_im],
inv_def_ax := λ z, by simp only [complex.inv_def, complex.norm_sq_eq_abs, complex.coe_algebra_map,
complex.of_real_eq_coe, complex.norm_eq_abs],
div_I_ax := complex.div_I }
section
variables {α β γ : Type*}
[add_comm_monoid α] [topological_space α] [add_comm_monoid γ] [topological_space γ]
/-- The natural `add_equiv` from `ℂ` to `ℝ × ℝ`. -/
@[simps apply symm_apply_re symm_apply_im { simp_rhs := tt }]
def equiv_real_prod_add_hom : ℂ ≃+ ℝ × ℝ :=
{ map_add' := by simp, .. equiv_real_prod }
/-- The natural `linear_equiv` from `ℂ` to `ℝ × ℝ`. -/
@[simps apply symm_apply_re symm_apply_im { simp_rhs := tt }]
def equiv_real_prod_add_hom_lm : ℂ ≃ₗ[ℝ] ℝ × ℝ :=
{ map_smul' := by simp [equiv_real_prod_add_hom], .. equiv_real_prod_add_hom }
/-- The natural `continuous_linear_equiv` from `ℂ` to `ℝ × ℝ`. -/
@[simps apply symm_apply_re symm_apply_im { simp_rhs := tt }]
def equiv_real_prodₗ : ℂ ≃L[ℝ] ℝ × ℝ :=
equiv_real_prod_add_hom_lm.to_continuous_linear_equiv
end
lemma has_sum_iff {α} (f : α → ℂ) (c : ℂ) :
has_sum f c ↔ has_sum (λ x, (f x).re) c.re ∧ has_sum (λ x, (f x).im) c.im :=
begin
-- For some reason, `continuous_linear_map.has_sum` is orders of magnitude faster than
-- `has_sum.mapL` here:
refine ⟨λ h, ⟨re_clm.has_sum h, im_clm.has_sum h⟩, _⟩,
rintro ⟨h₁, h₂⟩,
convert (h₁.prod_mk h₂).mapL equiv_real_prodₗ.symm.to_continuous_linear_map,
{ ext x; refl },
{ cases c, refl }
end
end complex
namespace is_R_or_C
local notation `reC` := @is_R_or_C.re ℂ _
local notation `imC` := @is_R_or_C.im ℂ _
local notation `IC` := @is_R_or_C.I ℂ _
local notation `absC` := @is_R_or_C.abs ℂ _
local notation `norm_sqC` := @is_R_or_C.norm_sq ℂ _
@[simp] lemma re_to_complex {x : ℂ} : reC x = x.re := rfl
@[simp] lemma im_to_complex {x : ℂ} : imC x = x.im := rfl
@[simp] lemma I_to_complex : IC = complex.I := rfl
@[simp] lemma norm_sq_to_complex {x : ℂ} : norm_sqC x = complex.norm_sq x :=
by simp [is_R_or_C.norm_sq, complex.norm_sq]
@[simp] lemma abs_to_complex {x : ℂ} : absC x = complex.abs x :=
by simp [is_R_or_C.abs, complex.abs]
end is_R_or_C
|
State Before: 𝕜 : Type u_1
inst✝⁴ : NontriviallyNormedField 𝕜
F : Type u_2
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
E : Type ?u.3042
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
n : ℕ
f : 𝕜 → F
s : Set 𝕜
x : 𝕜
⊢ iteratedDerivWithin n f univ = iteratedDeriv n f State After: case h
𝕜 : Type u_1
inst✝⁴ : NontriviallyNormedField 𝕜
F : Type u_2
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
E : Type ?u.3042
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
n : ℕ
f : 𝕜 → F
s : Set 𝕜
x✝ x : 𝕜
⊢ iteratedDerivWithin n f univ x = iteratedDeriv n f x Tactic: ext x State Before: case h
𝕜 : Type u_1
inst✝⁴ : NontriviallyNormedField 𝕜
F : Type u_2
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
E : Type ?u.3042
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
n : ℕ
f : 𝕜 → F
s : Set 𝕜
x✝ x : 𝕜
⊢ iteratedDerivWithin n f univ x = iteratedDeriv n f x State After: no goals Tactic: rw [iteratedDerivWithin, iteratedDeriv, iteratedFDerivWithin_univ] |
import tactic --hide
variable X : Type --hide
/-
# Chapter 1 : Sets
## Level 7
-/
/-
In this level you continue working with sets, while learning some useful
Lean tactics, `by_contradiction` and `push_neg`.
You need to prove that the empty set is included in any set.
To do that, we'll follow the advice of P. Halmos in "Naive Set Theory".
That is, to prove something is true about the empty set, prove that it cannot be false.
-/
/- Hint : Empty set definition in mathlib:
theorem empty_def : (∅ : set α) = {x | false} := rfl
-/
-- begin hide
-- Is there a definition in Lean core that I'm missing?
-- end hide
/-
When starting this level, the goal is:
$$\forall (A : \textrm{set} \; X), \; \emptyset \subseteq A$$
To make progress, you'll need to instantiate a specific set $A$
with the well-known `intro` tactic.
Remember now the definition of set inclusion. The goal
$$ \emptyset \subseteq A$$
is the same as
$$ \forall x \in \emptyset, x \in A.$$
Thus, use `change ∀ x ∈ ∅, x ∈ A` on the line after `intro A`.
Time to switch to the meat of the proof. Type `by_contradiction hn` to introduce
the contradiction hypothesis `hn` and change the goal to `false`.
Next, it is helpful to further change this into the equivalent statement that there exists
a member of the empty set which does not belong to $A$.
This can be accomplished by
`push_neg at hn`. You sure can bring this home from here using `cases`.
-/
local attribute [instance] classical.prop_decidable --hide
/- Lemma
The empty set is included in any set $A$....
-/
theorem empty_set_subset : ∀ A : set X, ∅ ⊆ A :=
begin
intro A,
change ∀ x ∈ ∅, x ∈ A,
by_contradiction hn,
push_neg at hn,
cases hn with x h1,
cases h1 with hf ha,
exact hf, done
end
|
Address(Wisteria Way) is a residential Culdesacs culdesac that is past the western edge of the city limits of Davis.
Intersecting Streets
Patwin Road
|
function K = sdlfmvXsdrbfKernCompute(sdlfmvKern, sdrbfKern, t1, t2)
% SDLFMVXSDRBFKERNCOMPUTE Cross kernel between a SDLFMV and a SDRBF kernels.
% FORMAT
% DESC computes cross kernel terms between the velocity switching dynamical
% LFM and the switching dynamicl RBF.
% ARG sdlfmvKern : the kernel structure associated with the velocity of the
% first SDLFM kernel.
% ARG sdrbfKern : the kernel structure associated with the SDRBF kernel.
% ARG t : inputs for which kernel is to be computed.
% RETURN K : block of values from kernel matrix.
%
% FORMAT
% DESC computes cross kernel terms between the velocity switching dynamical
% LFM and the switching dynamicl RBF.
% ARG sdlfmvKern : the kernel structure associated with the velocity of the
% first SDLFM kernel.
% ARG sdrbfKern : the kernel structure associated with the SDRBF kernel.
% ARG t1 : row inputs for which kernel is to be computed.
% ARG t2 : column inputs for which kernel is to be computed.
% RETURN K : block of values from kernel matrix.
%
% SEEALSO : sdlfmvKernParamInit, sdlfmvKernCompute, sdlfmKernParamInit
%
% COPYRIGHT : Mauricio A. Alvarez, 2010
% KERN
if nargin < 4
t2 = t1;
end
K = sdlfmXsdrbfKernCompute(sdlfmvKern, sdrbfKern, t1, t2, 'Vel');
|
[GOAL]
C : Type u_1
inst✝² : Category.{?u.243, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ X.obj Δ ⟶ N s (SimplexCategory.len A.fst.unop)
[PROOFSTEP]
refine' (s.iso Δ).inv ≫ Sigma.desc fun B => _
[GOAL]
C : Type u_1
inst✝² : Category.{?u.243, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
⊢ summand s.N Δ B ⟶ N s (SimplexCategory.len A.fst.unop)
[PROOFSTEP]
by_cases B = A
[GOAL]
C : Type u_1
inst✝² : Category.{?u.243, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
⊢ summand s.N Δ B ⟶ N s (SimplexCategory.len A.fst.unop)
[PROOFSTEP]
by_cases B = A
[GOAL]
case pos
C : Type u_1
inst✝² : Category.{?u.243, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
h : B = A
⊢ summand s.N Δ B ⟶ N s (SimplexCategory.len A.fst.unop)
[PROOFSTEP]
exact eqToHom (by subst h; rfl)
[GOAL]
C : Type u_1
inst✝² : Category.{?u.243, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
h : B = A
⊢ summand s.N Δ B = N s (SimplexCategory.len A.fst.unop)
[PROOFSTEP]
subst h
[GOAL]
C : Type u_1
inst✝² : Category.{?u.243, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
B : IndexSet Δ
⊢ summand s.N Δ B = N s (SimplexCategory.len B.fst.unop)
[PROOFSTEP]
rfl
[GOAL]
case neg
C : Type u_1
inst✝² : Category.{?u.243, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
h : ¬B = A
⊢ summand s.N Δ B ⟶ N s (SimplexCategory.len A.fst.unop)
[PROOFSTEP]
exact 0
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ ιSummand s A ≫ πSummand s A = 𝟙 (N s (SimplexCategory.len A.fst.unop))
[PROOFSTEP]
dsimp only [ιSummand, iso_hom, πSummand, iso_inv, summand]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ ((ιCoprod s.N A ≫ map X s.ι Δ) ≫
inv (map X s.ι Δ) ≫
Sigma.desc fun B =>
if h : B = A then eqToHom (_ : summand s.N Δ B = N s (SimplexCategory.len A.fst.unop)) else 0) =
𝟙 (N s (SimplexCategory.len A.fst.unop))
[PROOFSTEP]
simp only [summand, assoc, IsIso.hom_inv_id_assoc]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ (ιCoprod s.N A ≫
Sigma.desc fun B =>
if h : B = A then eqToHom (_ : summand s.N Δ B = N s (SimplexCategory.len A.fst.unop)) else 0) =
𝟙 (N s (SimplexCategory.len A.fst.unop))
[PROOFSTEP]
erw [colimit.ι_desc, Cofan.mk_ι_app]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ (if h : { as := A }.as = A then eqToHom (_ : summand s.N Δ { as := A }.as = N s (SimplexCategory.len A.fst.unop))
else 0) =
𝟙 (N s (SimplexCategory.len A.fst.unop))
[PROOFSTEP]
dsimp
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ (if h : A = A then 𝟙 (N s (SimplexCategory.len A.fst.unop)) else 0) = 𝟙 (N s (SimplexCategory.len A.fst.unop))
[PROOFSTEP]
simp only [dite_eq_ite, ite_true]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
h : B ≠ A
⊢ ιSummand s A ≫ πSummand s B = 0
[PROOFSTEP]
dsimp only [ιSummand, iso_hom, πSummand, iso_inv, summand]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
h : B ≠ A
⊢ ((ιCoprod s.N A ≫ map X s.ι Δ) ≫
inv (map X s.ι Δ) ≫
Sigma.desc fun B_1 =>
if h : B_1 = B then eqToHom (_ : summand s.N Δ B_1 = N s (SimplexCategory.len B.fst.unop)) else 0) =
0
[PROOFSTEP]
simp only [summand, assoc, IsIso.hom_inv_id_assoc]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
h : B ≠ A
⊢ (ιCoprod s.N A ≫
Sigma.desc fun B_1 =>
if h : B_1 = B then eqToHom (_ : summand s.N Δ B_1 = N s (SimplexCategory.len B.fst.unop)) else 0) =
0
[PROOFSTEP]
erw [colimit.ι_desc, Cofan.mk_ι_app]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : HasZeroMorphisms C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
h : B ≠ A
⊢ (if h : { as := A }.as = B then eqToHom (_ : summand s.N Δ { as := A }.as = N s (SimplexCategory.len B.fst.unop))
else 0) =
0
[PROOFSTEP]
exact dif_neg h.symm
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Δ : SimplexCategoryᵒᵖ
⊢ 𝟙 (X.obj Δ) = ∑ A : IndexSet Δ, πSummand s A ≫ ιSummand s A
[PROOFSTEP]
apply s.hom_ext'
[GOAL]
case h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Δ : SimplexCategoryᵒᵖ
⊢ ∀ (A : IndexSet Δ), ιSummand s A ≫ 𝟙 (X.obj Δ) = ιSummand s A ≫ ∑ A : IndexSet Δ, πSummand s A ≫ ιSummand s A
[PROOFSTEP]
intro A
[GOAL]
case h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ ιSummand s A ≫ 𝟙 (X.obj Δ) = ιSummand s A ≫ ∑ A : IndexSet Δ, πSummand s A ≫ ιSummand s A
[PROOFSTEP]
rw [comp_id, comp_sum, Finset.sum_eq_single A, ι_πSummand_eq_id_assoc]
[GOAL]
case h.h₀
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ ∀ (b : IndexSet Δ), b ∈ Finset.univ → b ≠ A → ιSummand s A ≫ πSummand s b ≫ ιSummand s b = 0
[PROOFSTEP]
intro B _ h₂
[GOAL]
case h.h₀
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Δ : SimplexCategoryᵒᵖ
A B : IndexSet Δ
a✝ : B ∈ Finset.univ
h₂ : B ≠ A
⊢ ιSummand s A ≫ πSummand s B ≫ ιSummand s B = 0
[PROOFSTEP]
rw [s.ι_πSummand_eq_zero_assoc _ _ h₂, zero_comp]
[GOAL]
case h.h₁
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Δ : SimplexCategoryᵒᵖ
A : IndexSet Δ
⊢ ¬A ∈ Finset.univ → ιSummand s A ≫ πSummand s A ≫ ιSummand s A = 0
[PROOFSTEP]
simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
⊢ SimplicialObject.σ X i ≫ πSummand s (IndexSet.id (op [n + 1])) = 0
[PROOFSTEP]
apply s.hom_ext'
[GOAL]
case h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
⊢ ∀ (A : IndexSet (op [n])),
ιSummand s A ≫ SimplicialObject.σ X i ≫ πSummand s (IndexSet.id (op [n + 1])) = ιSummand s A ≫ 0
[PROOFSTEP]
intro A
[GOAL]
case h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
A : IndexSet (op [n])
⊢ ιSummand s A ≫ SimplicialObject.σ X i ≫ πSummand s (IndexSet.id (op [n + 1])) = ιSummand s A ≫ 0
[PROOFSTEP]
dsimp only [SimplicialObject.σ]
[GOAL]
case h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
A : IndexSet (op [n])
⊢ ιSummand s A ≫ X.map (SimplexCategory.σ i).op ≫ πSummand s (IndexSet.id (op [n + 1])) = ιSummand s A ≫ 0
[PROOFSTEP]
rw [comp_zero, s.ιSummand_epi_naturality_assoc A (SimplexCategory.σ i).op, ι_πSummand_eq_zero]
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
A : IndexSet (op [n])
⊢ IndexSet.id (op [n + 1]) ≠ IndexSet.epiComp A (SimplexCategory.σ i).op
[PROOFSTEP]
rw [ne_comm]
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
A : IndexSet (op [n])
⊢ IndexSet.epiComp A (SimplexCategory.σ i).op ≠ IndexSet.id (op [n + 1])
[PROOFSTEP]
change ¬(A.epiComp (SimplexCategory.σ i).op).EqId
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
A : IndexSet (op [n])
⊢ ¬IndexSet.EqId (IndexSet.epiComp A (SimplexCategory.σ i).op)
[PROOFSTEP]
rw [IndexSet.eqId_iff_len_eq]
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
A : IndexSet (op [n])
⊢ ¬SimplexCategory.len (IndexSet.epiComp A (SimplexCategory.σ i).op).fst.unop = SimplexCategory.len (op [n + 1]).unop
[PROOFSTEP]
have h := SimplexCategory.len_le_of_epi (inferInstance : Epi A.e)
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
A : IndexSet (op [n])
h : SimplexCategory.len A.fst.unop ≤ SimplexCategory.len (op [n]).unop
⊢ ¬SimplexCategory.len (IndexSet.epiComp A (SimplexCategory.σ i).op).fst.unop = SimplexCategory.len (op [n + 1]).unop
[PROOFSTEP]
dsimp at h ⊢
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
i : Fin (n + 1)
A : IndexSet (op [n])
h : SimplexCategory.len A.fst.unop ≤ n
⊢ ¬SimplexCategory.len A.fst.unop = n + 1
[PROOFSTEP]
linarith
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X✝ : SimplicialObject C
s✝ : Splitting X✝
inst✝ : Preadditive C
X : SimplicialObject C
s : Splitting X
n : ℕ
A : IndexSet (op [n])
hA : ¬IndexSet.EqId A
⊢ ιSummand s A ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
rw [SimplicialObject.Splitting.IndexSet.eqId_iff_mono] at hA
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X✝ : SimplicialObject C
s✝ : Splitting X✝
inst✝ : Preadditive C
X : SimplicialObject C
s : Splitting X
n : ℕ
A : IndexSet (op [n])
hA : ¬Mono (IndexSet.e A)
⊢ ιSummand s A ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
rw [SimplicialObject.Splitting.ιSummand_eq, assoc, degeneracy_comp_PInfty X n A.e hA, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
⊢ f ≫ HomologicalComplex.Hom.f PInfty n = 0 ↔ f ≫ πSummand s (IndexSet.id (op [n])) = 0
[PROOFSTEP]
constructor
[GOAL]
case mp
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
⊢ f ≫ HomologicalComplex.Hom.f PInfty n = 0 → f ≫ πSummand s (IndexSet.id (op [n])) = 0
[PROOFSTEP]
intro h
[GOAL]
case mp
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
h : f ≫ HomologicalComplex.Hom.f PInfty n = 0
⊢ f ≫ πSummand s (IndexSet.id (op [n])) = 0
[PROOFSTEP]
rcases n with _ | n
[GOAL]
case mp.zero
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
f : Z ⟶ X.obj (op [Nat.zero])
h : f ≫ HomologicalComplex.Hom.f PInfty Nat.zero = 0
⊢ f ≫ πSummand s (IndexSet.id (op [Nat.zero])) = 0
[PROOFSTEP]
dsimp at h
[GOAL]
case mp.zero
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
f : Z ⟶ X.obj (op [Nat.zero])
h : f ≫ 𝟙 (X.obj (op [0])) = 0
⊢ f ≫ πSummand s (IndexSet.id (op [Nat.zero])) = 0
[PROOFSTEP]
rw [comp_id] at h
[GOAL]
case mp.zero
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
f : Z ⟶ X.obj (op [Nat.zero])
h : f = 0
⊢ f ≫ πSummand s (IndexSet.id (op [Nat.zero])) = 0
[PROOFSTEP]
rw [h, zero_comp]
[GOAL]
case mp.succ
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [Nat.succ n])
h : f ≫ HomologicalComplex.Hom.f PInfty (Nat.succ n) = 0
⊢ f ≫ πSummand s (IndexSet.id (op [Nat.succ n])) = 0
[PROOFSTEP]
have h' := f ≫= PInfty_f_add_QInfty_f (n + 1)
[GOAL]
case mp.succ
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [Nat.succ n])
h : f ≫ HomologicalComplex.Hom.f PInfty (Nat.succ n) = 0
h' :
f ≫ (HomologicalComplex.Hom.f PInfty (n + 1) + HomologicalComplex.Hom.f QInfty (n + 1)) =
f ≫ 𝟙 (HomologicalComplex.X K[X] (n + 1))
⊢ f ≫ πSummand s (IndexSet.id (op [Nat.succ n])) = 0
[PROOFSTEP]
dsimp at h'
[GOAL]
case mp.succ
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [Nat.succ n])
h : f ≫ HomologicalComplex.Hom.f PInfty (Nat.succ n) = 0
h' :
f ≫ (HomologicalComplex.Hom.f PInfty (n + 1) + HomologicalComplex.Hom.f QInfty (n + 1)) = f ≫ 𝟙 (X.obj (op [n + 1]))
⊢ f ≫ πSummand s (IndexSet.id (op [Nat.succ n])) = 0
[PROOFSTEP]
rw [comp_id, comp_add, h, zero_add] at h'
[GOAL]
case mp.succ
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [Nat.succ n])
h : f ≫ HomologicalComplex.Hom.f PInfty (Nat.succ n) = 0
h' : f ≫ HomologicalComplex.Hom.f QInfty (n + 1) = f
⊢ f ≫ πSummand s (IndexSet.id (op [Nat.succ n])) = 0
[PROOFSTEP]
rw [← h', assoc, QInfty_f, decomposition_Q, Preadditive.sum_comp, Preadditive.comp_sum, Finset.sum_eq_zero]
[GOAL]
case mp.succ
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [Nat.succ n])
h : f ≫ HomologicalComplex.Hom.f PInfty (Nat.succ n) = 0
h' : f ≫ HomologicalComplex.Hom.f QInfty (n + 1) = f
⊢ ∀ (x : Fin (n + 1)),
x ∈ Finset.filter (fun i => ↑i < n + 1) Finset.univ →
f ≫
(HomologicalComplex.Hom.f (P ↑x) (n + 1) ≫
SimplicialObject.δ X (Fin.succ (↑Fin.revPerm x)) ≫ SimplicialObject.σ X (↑Fin.revPerm x)) ≫
πSummand s (IndexSet.id (op [Nat.succ n])) =
0
[PROOFSTEP]
intro i _
[GOAL]
case mp.succ
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [Nat.succ n])
h : f ≫ HomologicalComplex.Hom.f PInfty (Nat.succ n) = 0
h' : f ≫ HomologicalComplex.Hom.f QInfty (n + 1) = f
i : Fin (n + 1)
a✝ : i ∈ Finset.filter (fun i => ↑i < n + 1) Finset.univ
⊢ f ≫
(HomologicalComplex.Hom.f (P ↑i) (n + 1) ≫
SimplicialObject.δ X (Fin.succ (↑Fin.revPerm i)) ≫ SimplicialObject.σ X (↑Fin.revPerm i)) ≫
πSummand s (IndexSet.id (op [Nat.succ n])) =
0
[PROOFSTEP]
simp only [assoc, σ_comp_πSummand_id_eq_zero, comp_zero]
[GOAL]
case mpr
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
⊢ f ≫ πSummand s (IndexSet.id (op [n])) = 0 → f ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
intro h
[GOAL]
case mpr
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
h : f ≫ πSummand s (IndexSet.id (op [n])) = 0
⊢ f ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
rw [← comp_id f, assoc, s.decomposition_id, Preadditive.sum_comp, Preadditive.comp_sum, Fintype.sum_eq_zero]
[GOAL]
case mpr.h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
h : f ≫ πSummand s (IndexSet.id (op [n])) = 0
⊢ ∀ (a : IndexSet (op [n])), f ≫ (πSummand s a ≫ ιSummand s a) ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
intro A
[GOAL]
case mpr.h
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
h : f ≫ πSummand s (IndexSet.id (op [n])) = 0
A : IndexSet (op [n])
⊢ f ≫ (πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
by_cases hA : A.EqId
[GOAL]
case pos
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
h : f ≫ πSummand s (IndexSet.id (op [n])) = 0
A : IndexSet (op [n])
hA : IndexSet.EqId A
⊢ f ≫ (πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
dsimp at hA
[GOAL]
case pos
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
h : f ≫ πSummand s (IndexSet.id (op [n])) = 0
A : IndexSet (op [n])
hA : A = IndexSet.id (op [n])
⊢ f ≫ (πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
subst hA
[GOAL]
case pos
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
h : f ≫ πSummand s (IndexSet.id (op [n])) = 0
⊢ f ≫ (πSummand s (IndexSet.id (op [n])) ≫ ιSummand s (IndexSet.id (op [n]))) ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
rw [assoc, reassoc_of% h, zero_comp]
[GOAL]
case neg
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
Z : C
n : ℕ
f : Z ⟶ X.obj (op [n])
h : f ≫ πSummand s (IndexSet.id (op [n])) = 0
A : IndexSet (op [n])
hA : ¬IndexSet.EqId A
⊢ f ≫ (πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
simp only [assoc, s.ιSummand_comp_PInfty_eq_zero A hA, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ HomologicalComplex.Hom.f PInfty n ≫ πSummand s (IndexSet.id (op [n])) = πSummand s (IndexSet.id (op [n]))
[PROOFSTEP]
conv_rhs => rw [← id_comp (s.πSummand _)]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
| πSummand s (IndexSet.id (op [n]))
[PROOFSTEP]
rw [← id_comp (s.πSummand _)]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
| πSummand s (IndexSet.id (op [n]))
[PROOFSTEP]
rw [← id_comp (s.πSummand _)]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
| πSummand s (IndexSet.id (op [n]))
[PROOFSTEP]
rw [← id_comp (s.πSummand _)]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ HomologicalComplex.Hom.f PInfty n ≫ πSummand s (IndexSet.id (op [n])) =
𝟙 (X.obj (op [n])) ≫ πSummand s (IndexSet.id (op [n]))
[PROOFSTEP]
symm
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ 𝟙 (X.obj (op [n])) ≫ πSummand s (IndexSet.id (op [n])) =
HomologicalComplex.Hom.f PInfty n ≫ πSummand s (IndexSet.id (op [n]))
[PROOFSTEP]
rw [← sub_eq_zero, ← sub_comp, ← comp_PInfty_eq_zero_iff, sub_comp, id_comp, PInfty_f_idem, sub_self]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ πSummand s (IndexSet.id (op [n])) ≫ ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n =
HomologicalComplex.Hom.f PInfty n
[PROOFSTEP]
conv_rhs => rw [← id_comp (PInfty.f n)]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
| HomologicalComplex.Hom.f PInfty n
[PROOFSTEP]
rw [← id_comp (PInfty.f n)]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
| HomologicalComplex.Hom.f PInfty n
[PROOFSTEP]
rw [← id_comp (PInfty.f n)]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
| HomologicalComplex.Hom.f PInfty n
[PROOFSTEP]
rw [← id_comp (PInfty.f n)]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ πSummand s (IndexSet.id (op [n])) ≫ ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n =
𝟙 (HomologicalComplex.X K[X] n) ≫ HomologicalComplex.Hom.f PInfty n
[PROOFSTEP]
erw [s.decomposition_id, Preadditive.sum_comp]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ πSummand s (IndexSet.id (op [n])) ≫ ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n =
∑ j : IndexSet (op [n]), (πSummand s j ≫ ιSummand s j) ≫ HomologicalComplex.Hom.f PInfty n
[PROOFSTEP]
rw [Fintype.sum_eq_single (IndexSet.id (op [n])), assoc]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ ∀ (x : IndexSet (op [n])),
x ≠ IndexSet.id (op [n]) → (πSummand s x ≫ ιSummand s x) ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
rintro A (hA : ¬A.EqId)
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
A : IndexSet (op [n])
hA : ¬IndexSet.EqId A
⊢ (πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.Hom.f PInfty n = 0
[PROOFSTEP]
rw [assoc, s.ιSummand_comp_PInfty_eq_zero A hA, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
j k : ℕ
A : IndexSet (op [j])
hA : ¬IndexSet.EqId A
⊢ ιSummand s A ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) = 0
[PROOFSTEP]
rw [A.eqId_iff_mono] at hA
[GOAL]
C : Type u_1
inst✝² : Category.{u_2, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
j k : ℕ
A : IndexSet (op [j])
hA : ¬Mono (IndexSet.e A)
⊢ ιSummand s A ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) = 0
[PROOFSTEP]
rw [← assoc, ← s.comp_PInfty_eq_zero_iff, assoc, ← PInfty.comm j k, s.ιSummand_eq, assoc,
degeneracy_comp_PInfty_assoc X j A.e hA, zero_comp, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
hij : ¬ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ d s i j = 0
[PROOFSTEP]
simp only [d, K[X].shape i j hij, zero_comp, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
⊢ d s i j ≫ d s j k = 0
[PROOFSTEP]
simp only [d, assoc]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
⊢ ιSummand s (IndexSet.id (op [i])) ≫
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
have eq : K[X].d i j ≫ 𝟙 (X.obj (op [j])) ≫ K[X].d j k ≫ s.πSummand (IndexSet.id (op [k])) = 0 := by
erw [id_comp, HomologicalComplex.d_comp_d_assoc, zero_comp]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
⊢ HomologicalComplex.d K[X] i j ≫
𝟙 (X.obj (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
erw [id_comp, HomologicalComplex.d_comp_d_assoc, zero_comp]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
𝟙 (X.obj (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
⊢ ιSummand s (IndexSet.id (op [i])) ≫
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
rw [s.decomposition_id] at eq
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
(∑ A : IndexSet (op [j]), πSummand s A ≫ ιSummand s A) ≫
HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
⊢ ιSummand s (IndexSet.id (op [i])) ≫
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
classical
rw [Fintype.sum_eq_add_sum_compl (IndexSet.id (op [j])), add_comp, comp_add, assoc, Preadditive.sum_comp,
Preadditive.comp_sum, Finset.sum_eq_zero, add_zero] at eq
swap
· intro A hA
simp only [Finset.mem_compl, Finset.mem_singleton] at hA
simp only [assoc, ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ _ hA, comp_zero]
rw [eq, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
(∑ A : IndexSet (op [j]), πSummand s A ≫ ιSummand s A) ≫
HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
⊢ ιSummand s (IndexSet.id (op [i])) ≫
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
rw [Fintype.sum_eq_add_sum_compl (IndexSet.id (op [j])), add_comp, comp_add, assoc, Preadditive.sum_comp,
Preadditive.comp_sum, Finset.sum_eq_zero, add_zero] at eq
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
⊢ ιSummand s (IndexSet.id (op [i])) ≫
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) +
∑ j_1 in {IndexSet.id (op [j])}ᶜ,
HomologicalComplex.d K[X] i j ≫
(πSummand s j_1 ≫ ιSummand s j_1) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
⊢ ∀ (x : IndexSet (op [j])),
x ∈ {IndexSet.id (op [j])}ᶜ →
HomologicalComplex.d K[X] i j ≫
(πSummand s x ≫ ιSummand s x) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
swap
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) +
∑ j_1 in {IndexSet.id (op [j])}ᶜ,
HomologicalComplex.d K[X] i j ≫
(πSummand s j_1 ≫ ιSummand s j_1) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
⊢ ∀ (x : IndexSet (op [j])),
x ∈ {IndexSet.id (op [j])}ᶜ →
HomologicalComplex.d K[X] i j ≫
(πSummand s x ≫ ιSummand s x) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
intro A hA
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) +
∑ j_1 in {IndexSet.id (op [j])}ᶜ,
HomologicalComplex.d K[X] i j ≫
(πSummand s j_1 ≫ ιSummand s j_1) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
A : IndexSet (op [j])
hA : A ∈ {IndexSet.id (op [j])}ᶜ
⊢ HomologicalComplex.d K[X] i j ≫
(πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
simp only [Finset.mem_compl, Finset.mem_singleton] at hA
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) +
∑ j_1 in {IndexSet.id (op [j])}ᶜ,
HomologicalComplex.d K[X] i j ≫
(πSummand s j_1 ≫ ιSummand s j_1) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
A : IndexSet (op [j])
hA : ¬A = IndexSet.id (op [j])
⊢ HomologicalComplex.d K[X] i j ≫
(πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
simp only [assoc, ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ _ hA, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.276754, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j k : ℕ
x✝¹ : ComplexShape.Rel (ComplexShape.down ℕ) i j
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) j k
eq :
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
⊢ ιSummand s (IndexSet.id (op [i])) ≫
HomologicalComplex.d K[X] i j ≫
πSummand s (IndexSet.id (op [j])) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.d K[X] j k ≫ πSummand s (IndexSet.id (op [k])) =
0
[PROOFSTEP]
rw [eq, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ (fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) i ≫
HomologicalComplex.d (N₁.obj X).X i j =
HomologicalComplex.d ((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s)).X i j ≫
(fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) j
[PROOFSTEP]
dsimp
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ (ιSummand s (IndexSet.id (op [i])) ≫ HomologicalComplex.Hom.f PInfty i) ≫ HomologicalComplex.d K[X] i j =
(ιSummand s (IndexSet.id (op [i])) ≫ HomologicalComplex.d K[X] i j ≫ πSummand s (IndexSet.id (op [j]))) ≫
ιSummand s (IndexSet.id (op [j])) ≫ HomologicalComplex.Hom.f PInfty j
[PROOFSTEP]
rw [assoc, assoc, assoc, πSummand_comp_ιSummand_comp_PInfty_eq_PInfty, HomologicalComplex.Hom.comm]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
⊢ (HomologicalComplex.Hom.mk fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) =
((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s)).p ≫
(HomologicalComplex.Hom.mk fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) ≫
(N₁.obj X).p
[PROOFSTEP]
ext n
[GOAL]
case h
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ HomologicalComplex.Hom.f
(HomologicalComplex.Hom.mk fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) n =
HomologicalComplex.Hom.f
(((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s)).p ≫
(HomologicalComplex.Hom.mk fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) ≫
(N₁.obj X).p)
n
[PROOFSTEP]
dsimp
[GOAL]
case h
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n =
𝟙 (N s n) ≫
(ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) ≫ HomologicalComplex.Hom.f PInfty n
[PROOFSTEP]
rw [id_comp, assoc, PInfty_f_idem]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ (fun n => πSummand s (IndexSet.id (op [n]))) i ≫
HomologicalComplex.d ((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s)).X i j =
HomologicalComplex.d (N₁.obj X).X i j ≫ (fun n => πSummand s (IndexSet.id (op [n]))) j
[PROOFSTEP]
dsimp
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ πSummand s (IndexSet.id (op [i])) ≫
ιSummand s (IndexSet.id (op [i])) ≫ HomologicalComplex.d K[X] i j ≫ πSummand s (IndexSet.id (op [j])) =
HomologicalComplex.d K[X] i j ≫ πSummand s (IndexSet.id (op [j]))
[PROOFSTEP]
slice_rhs 1 1 => rw [← id_comp (K[X].d i j)]
[GOAL]
case a
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
| HomologicalComplex.d K[X] i j
case a
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
| πSummand s (IndexSet.id (op [j]))
[PROOFSTEP]
rw [← id_comp (K[X].d i j)]
[GOAL]
case a
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
| HomologicalComplex.d K[X] i j
case a
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
| πSummand s (IndexSet.id (op [j]))
[PROOFSTEP]
rw [← id_comp (K[X].d i j)]
[GOAL]
case a
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
| HomologicalComplex.d K[X] i j
case a
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
| πSummand s (IndexSet.id (op [j]))
[PROOFSTEP]
rw [← id_comp (K[X].d i j)]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ πSummand s (IndexSet.id (op [i])) ≫
ιSummand s (IndexSet.id (op [i])) ≫ HomologicalComplex.d K[X] i j ≫ πSummand s (IndexSet.id (op [j])) =
(𝟙 (HomologicalComplex.X K[X] i) ≫ HomologicalComplex.d K[X] i j) ≫ πSummand s (IndexSet.id (op [j]))
[PROOFSTEP]
erw [s.decomposition_id]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ πSummand s (IndexSet.id (op [i])) ≫
ιSummand s (IndexSet.id (op [i])) ≫ HomologicalComplex.d K[X] i j ≫ πSummand s (IndexSet.id (op [j])) =
((∑ A : IndexSet (op [i]), πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.d K[X] i j) ≫
πSummand s (IndexSet.id (op [j]))
[PROOFSTEP]
rw [sum_comp, sum_comp, Finset.sum_eq_single (IndexSet.id (op [i])), assoc, assoc]
[GOAL]
case h₀
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ ∀ (b : IndexSet (op [i])),
b ∈ Finset.univ →
b ≠ IndexSet.id (op [i]) →
((πSummand s b ≫ ιSummand s b) ≫ HomologicalComplex.d K[X] i j) ≫ πSummand s (IndexSet.id (op [j])) = 0
[PROOFSTEP]
intro A _ hA
[GOAL]
case h₀
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : IndexSet (op [i])
a✝ : A ∈ Finset.univ
hA : A ≠ IndexSet.id (op [i])
⊢ ((πSummand s A ≫ ιSummand s A) ≫ HomologicalComplex.d K[X] i j) ≫ πSummand s (IndexSet.id (op [j])) = 0
[PROOFSTEP]
simp only [assoc, s.ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ hA, comp_zero]
[GOAL]
case h₁
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ ¬IndexSet.id (op [i]) ∈ Finset.univ →
((πSummand s (IndexSet.id (op [i])) ≫ ιSummand s (IndexSet.id (op [i]))) ≫ HomologicalComplex.d K[X] i j) ≫
πSummand s (IndexSet.id (op [j])) =
0
[PROOFSTEP]
simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
⊢ (HomologicalComplex.Hom.mk fun n => πSummand s (IndexSet.id (op [n]))) =
(N₁.obj X).p ≫
(HomologicalComplex.Hom.mk fun n => πSummand s (IndexSet.id (op [n]))) ≫
((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s)).p
[PROOFSTEP]
ext n
[GOAL]
case h
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ HomologicalComplex.Hom.f (HomologicalComplex.Hom.mk fun n => πSummand s (IndexSet.id (op [n]))) n =
HomologicalComplex.Hom.f
((N₁.obj X).p ≫
(HomologicalComplex.Hom.mk fun n => πSummand s (IndexSet.id (op [n]))) ≫
((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s)).p)
n
[PROOFSTEP]
dsimp
[GOAL]
case h
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ πSummand s (IndexSet.id (op [n])) = HomologicalComplex.Hom.f PInfty n ≫ πSummand s (IndexSet.id (op [n])) ≫ 𝟙 (N s n)
[PROOFSTEP]
simp only [comp_id, PInfty_comp_πSummand_id]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
⊢ Karoubi.Hom.mk
(HomologicalComplex.Hom.mk fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) ≫
Karoubi.Hom.mk (HomologicalComplex.Hom.mk fun n => πSummand s (IndexSet.id (op [n]))) =
𝟙 ((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s))
[PROOFSTEP]
ext n
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ HomologicalComplex.Hom.f
(Karoubi.Hom.mk
(HomologicalComplex.Hom.mk fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) ≫
Karoubi.Hom.mk (HomologicalComplex.Hom.mk fun n => πSummand s (IndexSet.id (op [n])))).f
n =
HomologicalComplex.Hom.f (𝟙 ((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s))).f n
[PROOFSTEP]
simp only [assoc, PInfty_comp_πSummand_id, Karoubi.comp_f, HomologicalComplex.comp_f, ι_πSummand_eq_id]
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ 𝟙 (N s (SimplexCategory.len (IndexSet.id (op [n])).fst.unop)) =
HomologicalComplex.Hom.f (𝟙 ((toKaroubi (ChainComplex C ℕ)).obj (nondegComplex s))).f n
[PROOFSTEP]
rfl
[GOAL]
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
⊢ Karoubi.Hom.mk (HomologicalComplex.Hom.mk fun n => πSummand s (IndexSet.id (op [n]))) ≫
Karoubi.Hom.mk
(HomologicalComplex.Hom.mk fun n => ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) =
𝟙 (N₁.obj X)
[PROOFSTEP]
ext n
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{?u.336016, u_1} C
inst✝¹ : HasFiniteCoproducts C
X : SimplicialObject C
s : Splitting X
inst✝ : Preadditive C
n : ℕ
⊢ HomologicalComplex.Hom.f
(Karoubi.Hom.mk (HomologicalComplex.Hom.mk fun n => πSummand s (IndexSet.id (op [n]))) ≫
Karoubi.Hom.mk
(HomologicalComplex.Hom.mk fun n =>
ιSummand s (IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n)).f
n =
HomologicalComplex.Hom.f (𝟙 (N₁.obj X)).f n
[PROOFSTEP]
simp only [πSummand_comp_ιSummand_comp_PInfty_eq_PInfty, Karoubi.comp_f, HomologicalComplex.comp_f, N₁_obj_p,
Karoubi.id_eq]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ Hom.f Φ i ≫ HomologicalComplex.d ((fun S => Splitting.nondegComplex S.s) S₂) i j =
HomologicalComplex.d ((fun S => Splitting.nondegComplex S.s) S₁) i j ≫ Hom.f Φ j
[PROOFSTEP]
dsimp
[GOAL]
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ Hom.f Φ i ≫
Splitting.ιSummand S₂.s (Splitting.IndexSet.id (op [i])) ≫
HomologicalComplex.d K[S₂.X] i j ≫ Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
(Splitting.ιSummand S₁.s (Splitting.IndexSet.id (op [i])) ≫
HomologicalComplex.d K[S₁.X] i j ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j]))) ≫
Hom.f Φ j
[PROOFSTEP]
erw [← ιSummand_naturality_symm_assoc Φ (Splitting.IndexSet.id (op [i])),
((alternatingFaceMapComplex C).map Φ.F).comm_assoc i j]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ Splitting.ιSummand S₁.s (Splitting.IndexSet.id (op [i])) ≫
HomologicalComplex.d ((alternatingFaceMapComplex C).obj S₁.X) i j ≫
HomologicalComplex.Hom.f ((alternatingFaceMapComplex C).map Φ.F) j ≫
Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
(Splitting.ιSummand S₁.s (Splitting.IndexSet.id (op [i])) ≫
HomologicalComplex.d K[S₁.X] i j ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j]))) ≫
Hom.f Φ j
[PROOFSTEP]
simp only [assoc]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ Splitting.ιSummand S₁.s (Splitting.IndexSet.id (op [i])) ≫
HomologicalComplex.d ((alternatingFaceMapComplex C).obj S₁.X) i j ≫
HomologicalComplex.Hom.f ((alternatingFaceMapComplex C).map Φ.F) j ≫
Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s (Splitting.IndexSet.id (op [i])) ≫
HomologicalComplex.d K[S₁.X] i j ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
congr 2
[GOAL]
case e_a.e_a
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ HomologicalComplex.Hom.f ((alternatingFaceMapComplex C).map Φ.F) j ≫
Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
apply S₁.s.hom_ext'
[GOAL]
case e_a.e_a.h
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ ∀ (A : Splitting.IndexSet (op [j])),
Splitting.ιSummand S₁.s A ≫
HomologicalComplex.Hom.f ((alternatingFaceMapComplex C).map Φ.F) j ≫
Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
intro A
[GOAL]
case e_a.e_a.h
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
⊢ Splitting.ιSummand S₁.s A ≫
HomologicalComplex.Hom.f ((alternatingFaceMapComplex C).map Φ.F) j ≫
Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
dsimp [alternatingFaceMapComplex]
[GOAL]
case e_a.e_a.h
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
⊢ Splitting.ιSummand S₁.s A ≫ NatTrans.app Φ.F (op [j]) ≫ Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
erw [ιSummand_naturality_symm_assoc Φ A]
[GOAL]
case e_a.e_a.h
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
⊢ Hom.f Φ (SimplexCategory.len A.fst.unop) ≫
Splitting.ιSummand S₂.s A ≫ Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
by_cases A.EqId
[GOAL]
case e_a.e_a.h
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
⊢ Hom.f Φ (SimplexCategory.len A.fst.unop) ≫
Splitting.ιSummand S₂.s A ≫ Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
by_cases A.EqId
[GOAL]
case pos
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
h : Splitting.IndexSet.EqId A
⊢ Hom.f Φ (SimplexCategory.len A.fst.unop) ≫
Splitting.ιSummand S₂.s A ≫ Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
dsimp at h
[GOAL]
case pos
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
h : A = Splitting.IndexSet.id (op [j])
⊢ Hom.f Φ (SimplexCategory.len A.fst.unop) ≫
Splitting.ιSummand S₂.s A ≫ Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
subst h
[GOAL]
case pos
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ Hom.f Φ (SimplexCategory.len (Splitting.IndexSet.id (op [j])).fst.unop) ≫
Splitting.ιSummand S₂.s (Splitting.IndexSet.id (op [j])) ≫
Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫
Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
simp only [Splitting.ι_πSummand_eq_id, comp_id, Splitting.ι_πSummand_eq_id_assoc]
[GOAL]
case pos
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
⊢ Hom.f Φ (SimplexCategory.len (Splitting.IndexSet.id (op [j])).fst.unop) = Hom.f Φ j
[PROOFSTEP]
rfl
[GOAL]
case neg
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
h : ¬Splitting.IndexSet.EqId A
⊢ Hom.f Φ (SimplexCategory.len A.fst.unop) ≫
Splitting.ιSummand S₂.s A ≫ Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
have h' : Splitting.IndexSet.id (op [j]) ≠ A := by
rw [ne_comm]
exact h
[GOAL]
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
h : ¬Splitting.IndexSet.EqId A
⊢ Splitting.IndexSet.id (op [j]) ≠ A
[PROOFSTEP]
rw [ne_comm]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
h : ¬Splitting.IndexSet.EqId A
⊢ A ≠ Splitting.IndexSet.id (op [j])
[PROOFSTEP]
exact h
[GOAL]
case neg
C : Type u_1
inst✝² : Category.{?u.406470, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
S₁ S₂ : Split C
Φ : S₁ ⟶ S₂
i j : ℕ
x✝ : ComplexShape.Rel (ComplexShape.down ℕ) i j
A : Splitting.IndexSet (op [j])
h : ¬Splitting.IndexSet.EqId A
h' : Splitting.IndexSet.id (op [j]) ≠ A
⊢ Hom.f Φ (SimplexCategory.len A.fst.unop) ≫
Splitting.ιSummand S₂.s A ≫ Splitting.πSummand S₂.s (Splitting.IndexSet.id (op [j])) =
Splitting.ιSummand S₁.s A ≫ Splitting.πSummand S₁.s (Splitting.IndexSet.id (op [j])) ≫ Hom.f Φ j
[PROOFSTEP]
rw [S₁.s.ι_πSummand_eq_zero_assoc _ _ h', S₂.s.ι_πSummand_eq_zero _ _ h', zero_comp, comp_zero]
[GOAL]
C : Type u_1
inst✝² : Category.{?u.449707, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
X✝ Y✝ : Split C
Φ : X✝ ⟶ Y✝
⊢ (nondegComplexFunctor ⋙ toKaroubi (ChainComplex C ℕ)).map Φ ≫
((fun S => Splitting.toKaroubiNondegComplexIsoN₁ S.s) Y✝).hom =
((fun S => Splitting.toKaroubiNondegComplexIsoN₁ S.s) X✝).hom ≫ (forget C ⋙ N₁).map Φ
[PROOFSTEP]
ext n
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{?u.449707, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
X✝ Y✝ : Split C
Φ : X✝ ⟶ Y✝
n : ℕ
⊢ HomologicalComplex.Hom.f
((nondegComplexFunctor ⋙ toKaroubi (ChainComplex C ℕ)).map Φ ≫
((fun S => Splitting.toKaroubiNondegComplexIsoN₁ S.s) Y✝).hom).f
n =
HomologicalComplex.Hom.f (((fun S => Splitting.toKaroubiNondegComplexIsoN₁ S.s) X✝).hom ≫ (forget C ⋙ N₁).map Φ).f n
[PROOFSTEP]
dsimp
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{?u.449707, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
X✝ Y✝ : Split C
Φ : X✝ ⟶ Y✝
n : ℕ
⊢ Hom.f Φ n ≫ Splitting.ιSummand Y✝.s (Splitting.IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n =
(Splitting.ιSummand X✝.s (Splitting.IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n) ≫
HomologicalComplex.Hom.f PInfty n ≫ NatTrans.app Φ.F (op [n])
[PROOFSTEP]
simp only [Karoubi.comp_f, toKaroubi_map_f, HomologicalComplex.comp_f, nondegComplexFunctor_map_f,
Splitting.toKaroubiNondegComplexIsoN₁_hom_f_f, N₁_map_f, AlternatingFaceMapComplex.map_f, assoc, PInfty_f_idem_assoc]
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{?u.449707, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
X✝ Y✝ : Split C
Φ : X✝ ⟶ Y✝
n : ℕ
⊢ Hom.f Φ n ≫ Splitting.ιSummand Y✝.s (Splitting.IndexSet.id (op [n])) ≫ HomologicalComplex.Hom.f PInfty n =
Splitting.ιSummand X✝.s (Splitting.IndexSet.id (op [n])) ≫
HomologicalComplex.Hom.f PInfty n ≫ NatTrans.app Φ.F (op [n])
[PROOFSTEP]
erw [← Split.ιSummand_naturality_symm_assoc Φ (Splitting.IndexSet.id (op [n]))]
[GOAL]
case h.h
C : Type u_1
inst✝² : Category.{?u.449707, u_1} C
inst✝¹ : Preadditive C
inst✝ : HasFiniteCoproducts C
X✝ Y✝ : Split C
Φ : X✝ ⟶ Y✝
n : ℕ
⊢ Splitting.ιSummand X✝.s (Splitting.IndexSet.id (op [n])) ≫
NatTrans.app Φ.F (op [n]) ≫ HomologicalComplex.Hom.f PInfty n =
Splitting.ιSummand X✝.s (Splitting.IndexSet.id (op [n])) ≫
HomologicalComplex.Hom.f PInfty n ≫ NatTrans.app Φ.F (op [n])
[PROOFSTEP]
rw [PInfty_f_naturality]
|
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
% package for including graphics with figure-environment
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{float}
% colors for hyperlinks
% colored borders (false) colored text (true)
\hypersetup{colorlinks=true,citecolor=black,filecolor=black,linkcolor=black,urlcolor=black}
% package for bibliography
\usepackage[authoryear,round]{natbib}
% package for header
\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\ihead[]{Andreas Gerlach}
\ohead[]{\today}
\cfoot[]{\pagemark}
\setheadsepline[122mm]{0.3mm}
\begin{document}
\title{
\begin{figure}[!ht]
\flushleft
\includegraphics[width=0.7\textwidth]{logo.eps}
\end{figure}
\vspace{1cm}
\begin{figure}[!ht]
\includegraphics[width=\textwidth]{Connected_commuters_SSpage.png}
\end{figure}
\vspace{1cm}
\Huge The Easy Way \\
}
\vspace{1cm}
% if you are the only author, you might use the following
% \author{Name of student}
% Insert here your name and correct mail address
\author{\Large \href{mailto:[email protected]}{Andreas Gerlach}
\vspace{1cm}}
% name of the course and module
\date{
\large Module: Foundations and Principles II \\ Course: eEntrepreneurship \\
\vspace{0.8cm}
\large Lecturer: William Sen \\
\vspace{1cm}
\today
}
\maketitle
\setlength{\parindent}{0pt}
\newpage
\tableofcontents
\newpage
\listoffigures
\vspace{2cm}
\listoftables
\newpage
\section{Introduction} % (fold)
\label{sec:introduction}
\textit{The Easy Way} is a new online service that provides guidance and support for planning your trip via public transportation services. Beside being able to search for a connection between starting point and your destination for the expected date and time of the trip it will also give you realtime feedback on the day of travel related to delays or possible connections you might not be able to reach. In the latter case it will also give you instant alternatives that you could take for getting to your destination including the expected overall delay of arrival. If there is an intermediate stop on your track and you will have to wait a certain amount of time for your connection it shows you personalised offers that you can use for spending the time on the intermediate location. These offers can include bars, restaurants, shops, museums, historical buildings as well as other sightseeings. It can be combined with promotional offers from the respective owner of the location and includes the distance from the station and the time that you have left to spend there as well. For sure when accepting such an offer the service will also inform you via push notification when it’s time to leave to get the connection train or bus based on the current situation. \par \vspace{0.2cm}
If you travel a lot -- let’s say during your daily commute -- it might be interesting to see if other people you know might be nearby your travel route so that you can arrange an appointment -- for let’s say a dinner or so. Therefore \textit{The Easy Way} service can be connected to your social network profiles (e.g. Facebook, Twitter, Google+) so that it knows your relatives and can offer you possible matches. If you want to arrange a meeting at a specific location with one or more relatives you can do so right from within the service, that will on your behalf utilise the corresponding social network service API to send a post to your selected friends and followers.
\subsection{Vision}
\label{subsec:vision}
The vision behind \textit{The Easy Way} is: ''make commuting and travelling with public transportation services an enjoyable and straightforward experience".
\subsection{Key aspects}
\label{subsec:aspects}
The \textbf{key aspects} that the service wants to address are:
\begin{enumerate}
\item easily plan your trip with public transportation service in a sophisticated online or mobile application
\item get instantaneous feedback to your trip via push notifications on your smartphone that might include delays or connection you will not reach (based on current traffic situation)
\item rearrange your connection based on proposals of the application and check your expected overall delay of arrival
\item get promotional offers for points of interest on your track or intermediate stop locations
\item arrange an adhoc appointment with friends and followers
\end{enumerate}
\subsection{Key Questions}
\label{subsec:questions}
The following open issues have to be clarified upfront and can be likely solved with the information provided by the sources listed here:
\begin{table}[ht]
\begin{tabular}{|p{0.60\textwidth}|p{0.40\textwidth}|}
\hline
\textbf{Topic} & \textbf{Sources} \\
\hline
How to query and combine information from different public transportation services (e.g. Deutsche Bahn, BVG, …)? & http://www.bahn.de, http://www.bvg.de, … \\
\hline
Check conditions of cloud infrastructure provider (e.g. Amazon, Google, Microsoft).
& http://aws.amazon.com, https://cloud.google.com, ... \\
\hline
Check available online advertising providers and their conditions (e.g. Google AdSense, Google AdWords).
& https://www.google.com/ adsense, https://www.google.com/ adwords \\
\hline
Build up a database with points of interest and set up partnerships with their owners.
& https://www.google.de, http://www.berlin.de, http://www.koeln.de, … \\
\hline
Find first-movers to try out the service and use them to advertise it later .
& http://www.twitter.com, http://www.facebook.com, … \\
\hline
Find investors and business partners to build first version of the platform and it's mobile applications.
& http://www.kickstarter.com, http://www.indigogo.com, ... \\
\hline
\end{tabular}
\caption{Information Retrieval Sources}
\label{tab:inforetrieval}
\end{table}
\subsection{Revenue Streams}
\label{subsec:revenue}
The service is offered for free for end-users. They can register to it via the web site or by using one of the mobile applications. An important revenue stream for the service will be the monthly fee that business customers have to pay to participate on the platform and offer their products and services on it. Anonymous user information will be made available for analysing the success of those advertisings. Additionally the mobile applications will include mobile advertising as well as an in-app purchase option to get rid of them.
% section introduction (end)
\section{Objectives}
\label{sec:objectives}
The first 3 major objectives, that \textit{The Easy Way} will address, are as follows:
\begin{enumerate}
\item integrate at least 5 major cities w/ local transportation, sightseeings and other points of interest
\item get into the TOP 20 for travelling applications in the mobile application stores from Apple (AppStore), Google (Play Store) and Microsoft (Windows Store)
\item get a turnover of 10 000 EUR per month from advertising partners on the platform
\end{enumerate}
\section{Distribution and Sales Channels} % (fold)
\label{sec:channels}
\subsection{Offline Channels}
As our service relies on objects in the real-world -- like bars, restaurants, stations, time-tables, we will have to place links to our online service on those real-world objects. This will allow us to get in touch with people just arriving at or ''using" those real-world objects. We will focus on ease-of-use and the value-added service our product promise to them. This will likely get them interested to try out our service the next time.
\begin{itemize}
\item Place billboards on main stations saying ''Welcome to … Please scan the QR code to get information about points of interest and special offers!". If end user scans the QR code with his smartphone or tablet he will be routed to a mobile landing page that will include links to the native apps in the App Stores as well as provide registration and user profile maintenance functionality. This one will increase the penetration of the platform and the mobile applications (objective 2, 3).
\item Actively participate on important exhibitions -- e.g. ITB Berlin, to help build a network of partners who works or are attached to the platform (objective 1, 3).
\item Print flyers and distribute them through bars, restaurants, tourist info offices, travel agencies (objective 1, 2, 3).
\item Create postal cards with funny pictures and slogans that will be placed in bars or restaurants -- e.g. edgar freecards (objective 2, 3).
\item Write an article or prepare an interview to be published into a travel agent magazine -- e.g. customer magazine of Deutsche Bahn (objective 2, 3).
\item Provide funny accessories like t-shirts, notebook stickers, bags, … to the early adopters so that they can spread the message of your service (objective 2, 3).
\end{itemize}
\subsection{Online Channels}
As our service is a Web-based product we can make use of the full range of marketing and distribution channels that the Internet provides for us. In addition to that we can also provide our first-movers and customers with the possibility to promote our service to their friends and followers via the Social networks.
\begin{itemize}
\item Use social media to communicate the benefits of the service to a wider audience. This could affect end users and partners alike. Set up an own blog, Twitter, Facebook and Google+ channel, write about success stories and user experiences in case studies and track user feedback on each platform (objective 2, 3).
\item Promoting the smartphone apps on the respective stores by doing special pricing, participating on ''App of the week" or getting an official recommendation of the app store owner (objective 2).
\item Provide an user community feature on the web page to let users queue in bugs and feature requests for the application and service. Let the users vote for most important features, missing pointsofinterest, bars, restaurants, …. and inform them when you plan to integrate those (objective 1, 2).
\item Set up a bonus system that will give an existing partner a gratification for advertising a new member to the platform (objective 1, 3).
\item Use Google AdWords to place online advertising on search results that either deals with specific locations that are available on the service or when looking up travel routes in general (objective 1, 3).
\item Create an YouTube channel and host short video clips that explains the service and success stories (Simple Show style) for communicating the user stories visually (objective 1, 2, 3).
\end{itemize}
% section foundations (end)
\section{Customer Groups} % (fold)
\label{sec:segmentation}
At first we would focus on early adopters of the platform, which are likely jumping onto the service for its features and could be used to publish success stories on our site to address an even wider audience later. Those first early adopters would include:
\begin{enumerate}
\item Business Travellers
\item Daily Commuters
\item City Travellers
\item Business Owners
\end{enumerate}
\textbf{Business Travellers} are possibly interested in the platform as they are travelling around the country a lot, might have some spare time on stations or the airport, or are even staying at an unfamiliar destination location for some time. \par \vspace{0.2cm}
\textbf{Daily Commuters} travelling the same route twice every day: first from home to work, later in the opposite direction. Although they will know the route inside-out they will likely face traffic jam, will miss connection trains or buses and have to stay some time on an intermediate station of the route. Additionally they are likely participating in arranging appointments with relatives or friends based on their current time schedule and possible crossing points with them. \par \vspace{0.2cm}
\textbf{City Travellers} are hopping to a city for a short time-frame like a weekend or so as part of a vacation. They will either go to a city they have never been before or plan the trip to a known location to meet some friends. In both situations they might be interested in the platform to find interesting locations for their next city trip. \par \vspace{0.2cm}
\textbf{Business Owners} can use the platform to advertise special offers to these aforementioned groups of people to get them interested in visiting their store or shop. This would give them a targeted communication channel to reach them and their specific needs.
% section methodology (end)
\section{Lead Generation} % (fold)
\label{sec:lead}
A lead generation is a way to uniquely communicate with potential customers to get them interested in our products and services and address their specific needs, so that they will get attached to our business and are more likely to buy from us at the end.
\begin{figure}[!ht]
\center
\includegraphics[width=\textwidth]{From_Strangers_to_Promoters.png}
\caption{Lead Generation Process}
\label{fig:leadgen}
\end{figure}
As said, the lead generation process has to uniquely address the needs of our customers / customer groups. That also means we will have to set up different lead generation processes for our target groups mentioned above. \par \vspace{0.2cm}
Travellers and Commuters (B2C) can be addressed via a \textbf{landing page} that will provide them with the possibility to download the required mobile apps (via links to the corresponding AppStore) as well as \textbf{subscribe to our monthly newsletter}, that holds information about new locations attached to the platform, showing \textbf{user success stories} as well as offering special promotional coupon codes. Links to this landing page can be placed on our billboards at the stations, on our flyers at the restaurants and bars or on our free postal cards in form of a machine readable QR code, promoted via Social Networks like Facebook and Twitter as well as part of our advertising we place in a form of \textbf{CalltoAction messages} via Google AdWords. The latter ones could be displayed on travel planning sites on the Internet as well (e.g. www.bahn.de). Existing customers will be interviewed and the experience will be shared on our web site in textual format or as YouTube video story, offering a CalltoAction to join the platform. Those stories will also be announced via Social Media channels. All actions on the Social Media channels will be monitored and repeated after a certain amount of time. \par \vspace{0.2cm}
Business Owners (B2B) will be likely a little bit harder to convince to join the platform. We will present them with some \textbf{success stories and interviews} of early adopters (customers and business owners) as well as provide \textbf{successful case studies} of business owners that shows some figures about increase of number of customers, higher customer satisfaction and business turnover. Those can be accessed freely on our web site and we provide a CalltoAction to get an \textbf{introductory offer} for the first 30 days of joining the platform by filling out an email form. For business customers we would also offer to include their business success story in our monthly newsletter or post about it on our Social Media channels, which allows them to advertise their brand via our communication channels. This could also attract new customers to join the platform and have their business addressed as well. \par \vspace{0.2cm}
Having our lead generation process on the Internet will be the most cost-effective solution as we have nearly zero effort to put the landing page on our web servers and distribute the links to them via our Social Media channels. We will have to spend money continuously on the billboards (design, print and placement) and therefore will monitor the conversion rate of this channel regularly. We will also need some resources (money, personal) to prepare and make the interviews with potential and existing customers (B2B, B2C) and finalise them later so they can be placed online or in the newsletter as well. The same is true for setting up the monthly newsletter. We might use students in the beginning for those working packages to save some money. As the amount we have to spend to Google AdWords depends on the keywords we register for and the number of clicks we receive, it could also consume a lot of money (especially as the travel industry is an huge market with lot of businesses fighting for customer attention the amount we have to spend for the keywords would rather be high than low). We are therefore monitoring the conversion rate from that channel continuously as well. The introductory offer for the newcomers in the business sphere might effectively also cost us nearly nothing, we already invest in the IT infrastructure and software so that hosting some offers of the business for the first 30 days might (only) consume resources that are already in place.
% section results (end)
\end{document}
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import data.multiset.finset_ops
import data.multiset.fold
/-!
# Lattice operations on multisets
-/
namespace multiset
variables {α : Type*}
/-! ### sup -/
section sup
variables [semilattice_sup_bot α]
/-- Supremum of a multiset: `sup {a, b, c} = a ⊔ b ⊔ c` -/
def sup (s : multiset α) : α := s.fold (⊔) ⊥
@[simp] lemma sup_zero : (0 : multiset α).sup = ⊥ :=
fold_zero _ _
@[simp] lemma sup_cons (a : α) (s : multiset α) :
(a ::ₘ s).sup = a ⊔ s.sup :=
fold_cons_left _ _ _ _
@[simp] lemma sup_singleton {a : α} : (a ::ₘ 0).sup = a := by simp
@[simp] lemma sup_add (s₁ s₂ : multiset α) : (s₁ + s₂).sup = s₁.sup ⊔ s₂.sup :=
eq.trans (by simp [sup]) (fold_add _ _ _ _ _)
lemma sup_le {s : multiset α} {a : α} : s.sup ≤ a ↔ (∀b ∈ s, b ≤ a) :=
multiset.induction_on s (by simp)
(by simp [or_imp_distrib, forall_and_distrib] {contextual := tt})
lemma le_sup {s : multiset α} {a : α} (h : a ∈ s) : a ≤ s.sup :=
sup_le.1 (le_refl _) _ h
lemma sup_mono {s₁ s₂ : multiset α} (h : s₁ ⊆ s₂) : s₁.sup ≤ s₂.sup :=
sup_le.2 $ assume b hb, le_sup (h hb)
variables [decidable_eq α]
@[simp] lemma sup_erase_dup (s : multiset α) : (erase_dup s).sup = s.sup :=
fold_erase_dup_idem _ _ _
@[simp] lemma sup_ndunion (s₁ s₂ : multiset α) :
(ndunion s₁ s₂).sup = s₁.sup ⊔ s₂.sup :=
by rw [← sup_erase_dup, erase_dup_ext.2, sup_erase_dup, sup_add]; simp
@[simp] lemma sup_union (s₁ s₂ : multiset α) :
(s₁ ∪ s₂).sup = s₁.sup ⊔ s₂.sup :=
by rw [← sup_erase_dup, erase_dup_ext.2, sup_erase_dup, sup_add]; simp
@[simp] lemma sup_ndinsert (a : α) (s : multiset α) :
(ndinsert a s).sup = a ⊔ s.sup :=
by rw [← sup_erase_dup, erase_dup_ext.2, sup_erase_dup, sup_cons]; simp
lemma nodup_sup_iff {α : Type*} [decidable_eq α] {m : multiset (multiset α) } :
m.sup.nodup ↔ ∀ (a : multiset α), a ∈ m → a.nodup :=
begin
apply m.induction_on,
{ simp },
{ intros a s h,
simp [h] }
end
end sup
/-! ### inf -/
section inf
variables [semilattice_inf_top α]
/-- Infimum of a multiset: `inf {a, b, c} = a ⊓ b ⊓ c` -/
def inf (s : multiset α) : α := s.fold (⊓) ⊤
@[simp] lemma inf_zero : (0 : multiset α).inf = ⊤ :=
fold_zero _ _
@[simp]
@[simp] lemma inf_singleton {a : α} : (a ::ₘ 0).inf = a := by simp
@[simp] lemma inf_add (s₁ s₂ : multiset α) : (s₁ + s₂).inf = s₁.inf ⊓ s₂.inf :=
eq.trans (by simp [inf]) (fold_add _ _ _ _ _)
lemma le_inf {s : multiset α} {a : α} : a ≤ s.inf ↔ (∀b ∈ s, a ≤ b) :=
multiset.induction_on s (by simp)
(by simp [or_imp_distrib, forall_and_distrib] {contextual := tt})
lemma inf_le {s : multiset α} {a : α} (h : a ∈ s) : s.inf ≤ a :=
le_inf.1 (le_refl _) _ h
lemma inf_mono {s₁ s₂ : multiset α} (h : s₁ ⊆ s₂) : s₂.inf ≤ s₁.inf :=
le_inf.2 $ assume b hb, inf_le (h hb)
variables [decidable_eq α]
@[simp] lemma inf_erase_dup (s : multiset α) : (erase_dup s).inf = s.inf :=
fold_erase_dup_idem _ _ _
@[simp] lemma inf_ndunion (s₁ s₂ : multiset α) :
(ndunion s₁ s₂).inf = s₁.inf ⊓ s₂.inf :=
by rw [← inf_erase_dup, erase_dup_ext.2, inf_erase_dup, inf_add]; simp
@[simp] lemma inf_union (s₁ s₂ : multiset α) :
(s₁ ∪ s₂).inf = s₁.inf ⊓ s₂.inf :=
by rw [← inf_erase_dup, erase_dup_ext.2, inf_erase_dup, inf_add]; simp
@[simp] lemma inf_ndinsert (a : α) (s : multiset α) :
(ndinsert a s).inf = a ⊓ s.inf :=
by rw [← inf_erase_dup, erase_dup_ext.2, inf_erase_dup, inf_cons]; simp
end inf
end multiset
|
The French cruiser Sully was an armored cruiser of the Gloire class that was built for the French Navy in the early 1900s . She was named in honor of Maximilien de Béthune , Duke of Sully , trusted minister of King Henry IV . The ship struck a rock in Hạ Long Bay , French Indochina in 1905 , only eight months after she was completed , and was a total loss .
|
module TopoChains
using Functors
export FuncTopo, @functopo_str, @functopo
export TopoChain
include("code.jl")
include("topology.jl")
include("topochain.jl")
Functors.functor(s::TopoChain) = s.models, m -> TopoChain(s.topo, m...)
end
|
(*
Copyright (C) 2017 M.A.L. Marques
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
(* type: gga_exc *)
(* prefix:
gga_c_lyp_params *params;
assert(p->params != NULL);
params = (gga_c_lyp_params * )(p->params);
*)
lyp_Cf := 3/10 * (3*Pi^2)^(2/3):
lyp_omega := rr -> params_a_b*exp(-params_a_c*rr)/(1 + params_a_d*rr):
lyp_delta := rr -> (params_a_c + params_a_d/(1 + params_a_d*rr))*rr:
lyp_aux6 := 1/2^(8/3):
lyp_aux4 := lyp_aux6/4:
lyp_aux5 := lyp_aux4/(9*2):
lyp_t1 := (rr, z) ->
-(1 - z^2)/(1 + params_a_d*rr):
lyp_t2 := (rr, z, xt) ->
-xt^2*((1 - z^2)*(47 - 7*lyp_delta(rr))/(4*18) - 2/3):
lyp_t3 := (z) ->
-lyp_Cf/2*(1 - z^2)*(opz_pow_n(z,8/3) + opz_pow_n(-z,8/3)):
lyp_t4 := (rr, z, xs0, xs1) ->
lyp_aux4*(1 - z^2)*(5/2 - lyp_delta(rr)/18)*(xs0^2*opz_pow_n(z,8/3) + xs1^2*opz_pow_n(-z,8/3)):
lyp_t5 := (rr, z, xs0, xs1) ->
lyp_aux5*(1 - z^2)*(lyp_delta(rr) - 11)*(xs0^2*opz_pow_n(z,11/3) + xs1^2*opz_pow_n(-z,11/3)):
lyp_t6 := (z, xs0, xs1) ->
-lyp_aux6*(2/3*(xs0^2*opz_pow_n(z,8/3) + xs1^2*opz_pow_n(-z,8/3))
-opz_pow_n(z,2)*xs1^2*opz_pow_n(-z,8/3)/4 - opz_pow_n(-z,2)*xs0^2*opz_pow_n(z,8/3)/4):
f_lyp_rr := (rr, z, xt, xs0, xs1) -> params_a_a*(lyp_t1(rr, z) + lyp_omega(rr)*(
+ lyp_t2(rr, z, xt) + lyp_t3(z) + lyp_t4(rr, z, xs0, xs1)
+ lyp_t5(rr, z, xs0, xs1) + lyp_t6(z, xs0, xs1)
)):
(* rr = rs/RS_FACTOR is equal to n_total(rs)^(-1/3) *)
f_lyp := (rs, z, xt, xs0, xs1) -> f_lyp_rr(rs/RS_FACTOR, z, xt, xs0, xs1):
f := (rs, z, xt, xs0, xs1) -> f_lyp(rs, z, xt, xs0, xs1):
|
module Specifications.Semigroup
import public Common.Abbrev
%default total
%access public export
infixl 8 #
||| specification
isAssociative : Binop s -> Type
isAssociative (#) = (x,y,z : _) -> x # (y # z) = (x # y) # z
||| specification
isAbelian : Binop s -> Type
isAbelian (#) = (x,y : _) -> x # y = y # x
|
function W = randInitializeWeights(L_in, L_out)
%RANDINITIALIZEWEIGHTS Randomly initialize the weights of a layer with L_in
%incoming connections and L_out outgoing connections
% W = RANDINITIALIZEWEIGHTS(L_in, L_out) randomly initializes the weights
% of a layer with L_in incoming connections and L_out outgoing
% connections.
%
% Note that W should be set to a matrix of size(L_out, 1 + L_in) as
% the first row of W handles the "bias" terms
%
% You need to return the following variables correctly
W = zeros(L_out, 1 + L_in);
% ====================== YOUR CODE HERE ======================
% Instructions: Initialize W randomly so that we break the symmetry while
% training the neural network.
%
% Note: The first row of W corresponds to the parameters for the bias units
%
epsilon_init = 0.12;
W = rand(L out, 1 + L in) * 2 * epsilon init − epsilon init;
% =========================================================================
end
|
State Before: k : Type u_1
M : Type u_2
N : Type ?u.96377
inst✝³ : LinearOrderedField k
inst✝² : OrderedAddCommGroup M
inst✝¹ : Module k M
inst✝ : OrderedSMul k M
a b : M
c : k
h : c < 0
⊢ c⁻¹ • a < b ↔ c • b < a State After: no goals Tactic: rw [← smul_lt_smul_iff_of_neg h, smul_inv_smul₀ h.ne] |
(** * 6.822 Formal Reasoning About Programs, Spring 2022 - Pset 13 *)
(* Author:
* Samuel Gruetter ([email protected])
*)
Require Import Frap MessagesAndRefinement Pset13Sig.
Module Impl.
(* We suggest that you start by reading Chapter 21 in the FRAP book.
For this pset, you will need to understand everything in that chapter up to and
including Theorem 19.2 ("If p1 <| p2, then every trace generated by p1 is
also generated by p2").
Also study the code in MessagesAndRefinement.v, because this
pset depends on that code.
As always, if you ever get stuck, you can help yourself to the hints at
the bottom of Pset13Sig.v! *)
Arguments Nat.modulo: simpl never.
(* In this pset, we will define a small key-value store server.
To simplify, it only accepts GET requests: *)
Inductive request :=
| GET (client_id key : nat).
Definition get_key (req : request) : nat :=
match req with
| GET _ key => key
end.
(* There are two possible responses for a GET request: *)
Inductive response :=
| FOUND (client_id key value : nat)
| NOT_FOUND (client_id key : nat).
(* Given a key-value store (modeled as an fmap), a source channel, and an output channel,
here's how we handle one request: *)
Definition request_handler (store : fmap nat nat) (source output : channel) : proc :=
??source(req: request);
match req with
| GET client_id key =>
match store $? key with
| Some v => !!output(FOUND client_id key v); Done
| None => !!output(NOT_FOUND client_id key); Done
end
end.
(* Key-value stores might become very large, so that they don't fit on one single
server's disk. Therefore, we split the store into two shards:
One for all even keys, and one for all odd keys.
Here's a predicate asserting that a full_store is split correctly into an
even_store and an odd_store: *)
Definition split_store (full_store even_store odd_store : fmap nat nat) : Prop :=
(forall k, k mod 2 = 0 -> even_store $? k = full_store $? k) /\
(forall k, k mod 2 = 0 -> odd_store $? k = None) /\
(forall k, k mod 2 <> 0 -> even_store $? k = None) /\
(forall k, k mod 2 <> 0 -> odd_store $? k = full_store $? k).
(* The goal of this pset is to define a distributed key-value-store system
implementation that does not need to save the full store anywhere, and only
needs full_store to specify its correctness. *)
(* We use two intermediate channels forward_even and forward_odd, and add a
request_dispatcher to forward requests to these channels: *)
Definition request_dispatcher (input forward_even forward_odd : channel) : proc :=
??input(req: request);
if get_key req mod 2 ==n 0 then
!!forward_even(req); Done
else
!!forward_odd(req); Done.
(* Our balanced request handler creates two intermediate channels and then combines the
request dispatcher with two request handlers, one for even keys and one for odd keys: *)
Definition balanced_handler (even_store odd_store : fmap nat nat) (input output : channel) : proc :=
New[input; output](forward_even);
New[input; output; forward_even](forward_odd);
request_dispatcher input forward_even forward_odd
|| request_handler even_store forward_even output
|| request_handler odd_store forward_odd output.
(* Here's the correctness property that we want to hold for our balanced_handler:
Each I/O trace generated by balanced_handler should also be a trace generated
by one single request_handler which uses the full_store. *)
Definition correctness: Prop := forall full_store even_store odd_store input output,
split_store full_store even_store odd_store ->
input <> output ->
forall trace,
couldGenerate (balanced_handler even_store odd_store input output) trace ->
couldGenerate (request_handler full_store input output) trace.
(* We suggest that you start by testing your understanding by answering the
following questions.
They are graded as follows: If you complete all the Coq proofs, you will
get full score, no matter what you write in the answers to these questions.
On the other hand, if you can't finish the Coq proofs, you can get up to
40 points for answering these questions, plus points for partial Coq proofs.
Question 1) For each of the following processes, briefly describe what they do:
a) !!ch(v); k
b) ??ch(x: T); k
c) pr1 || pr2
d) Dup pr
e) Done
f) New[ch1; ch2; ch3](ch4); k
g) Block ch; k
Question 2) Is the "refines" relation symmetric?
That is, if "pr1 <| pr2", does that imply "pr2 <| pr1"?
Question 3) Which of "||" and ";" binds stronger?
In other words, does "pr1 || pr2 ; pr3" equal "pr1 || (pr2 ; pr3)" or
"(pr1 || pr2) ; pr3"?
Question 4) Draw a diagram of the balanced request handler and the channels it uses
Question 5) In order to prove refinements, we need to provide a simulation relation
R of type "proc -> proc -> Prop", and prove the three conditions defined by "simulates".
If we just pick "fun pr1 pr2 => True" for R, which of these three conditions can/cannot
be proven? And what if we pick "fun pr1 pr2 => False"?
Question 6) The specification (addN 2 input output) in MessagesAndRefinement.v performs
the following steps:
1) It starts as
(??input(n : nat); !!output(n + 2); Done)
where it reads an input n
2) and then becomes
(!!output(n + 2); Done)
where it outputs (n + 2)
3) and then becomes
Done
Write down the same kind of explanation of steps for the implementation (add2_once input output):
You should get steps numbered from 1) to 5).
Question 7) In order to prove that the specification (addN 2 input output) can
simulate the implementation (add2_once input output), we have to show that each
implementation state has a corresponding specification state. Do so by filling
out the following table:
Impl | Spec
state | state
------+------
1 |
2 |
3 |
4 |
5 |
Question 8) If you completed the above table, you've actually just created a paper
proof of add2_once_refines_addN. Now study the Coq proof add2_once_refines_addN,
and look at the three subgoals opened after the call to first_order.
Where do they come from, and what does each of them ask you to prove?
*)
(* Now you should be ready to start proving correctness!
NOTE: You MUST use refinement ("_ <| _") and "simulates" to earn full credit on this pset.
Hint: You should follow the same approach as add2_once_refines_addN and define a relation
similar to R_add2, with the following signature, where we use "fs", "es", and "os" as
abbreviations for full_store, even_store, and odd_store: *)
(* HINT 1-2 (see Pset13Sig.v) *)
Inductive R (fs es os : fmap nat nat) (input output : channel) : proc -> proc -> Prop :=
(* FILL IN HERE *)
.
Definition R_alias_for_grading := R.
(* One more hint: You can use the "lists" tactic to prove any "NoDup" goals/contradictions. *)
(* And another hint: Here's some tactic which you might find handy in your proofs.
Feel free to use and/or adapt it! *)
Ltac head e :=
match e with
| ?e _ => head e
| _ => e
end.
Ltac head_constructor e :=
let e := eval cbv beta delta in e in (* this is quite agressive... *)
let h := head e in
is_constructor h.
Ltac t_step :=
match goal with
| |- _ => solve [propositional]
| H : ?a = ?b |- _ => head_constructor a; head_constructor b; progress invert H
(* the previous case can loop because repeat invert can loop,
propositional earlier prunes the cases where this occurs in our proof *)
| H : R _ _ _ _ _ _ _ |- _ => invert H
| H:lstep ?c _ _ |- _ => head_constructor c; (apply invert_Recv in H; try subst) || invert H
| H:lstepSilent ?c _ |- _ => head_constructor c; invert H
| r : request |- _ => cases r
| H : True |- _ => clear H
| _ => progress (cbn [notUse Channel get_key] in *; simplify)
| |- _ /\ _ => split
| _ => solve [equality]
end.
Ltac t := repeat t_step.
(* HINT 3-5 (see Pset13Sig.v) *)
Theorem balanced_handler_correct : correctness.
Proof.
Admitted.
(* OPTIONAL exercise (ungraded, very short):
Another important property of refinment is that any subpart of a larger
program can be replaced with a refined version of it, yielding a refined
version of the larger program. You can try it out by wrapping our one-shot
server in Dup and using the "impl <| spec" fact you proved as a part of
the last theorem to show "Dup impl <| Dup spec". This should be trivial
once you have found the appropariate lemma from FRAP and factored out the
appropriate refinement claim from the last proof. *)
Lemma multicorrectness : forall full_store even_store odd_store input output,
split_store full_store even_store odd_store ->
input <> output ->
forall trace,
couldGenerate (Dup (balanced_handler even_store odd_store input output)) trace ->
couldGenerate (Dup (request_handler full_store input output)) trace.
Proof.
Admitted.
End Impl.
Module ImplCorrect : Pset13Sig.S := Impl.
|
theory Prog_Prove_2_5
imports Main
begin
datatype tree0 = Tip | Node "tree0" "tree0"
fun nodes :: "tree0 \<Rightarrow> nat" where
"nodes Tip = 1" |
"nodes (Node l r) = nodes r + nodes l"
fun explode :: "nat \<Rightarrow> tree0 \<Rightarrow> tree0" where
"explode 0 t = t" |
"explode (Suc n) t = explode n (Node t t)"
lemma "nodes (explode n t) = (2 ^ n) * nodes t "
apply(induction n arbitrary: t)
apply(auto)
done
datatype exp = Var | Const int | Add exp exp | Mult exp exp
fun eval :: "exp \<Rightarrow> int \<Rightarrow> int" where
"eval Var x = x" |
"eval (Const a) x = a" |
"eval (Add a b) x = (eval a x) + (eval b x)" |
"eval (Mult a b) x = (eval a x) * (eval b x)"
fun evalp :: "int list \<Rightarrow> int \<Rightarrow> int" where
"evalp [] y = 0" |
"evalp (x#xs) y = x + y * (evalp xs y)"
fun a_coeffs :: "int list \<Rightarrow> int list \<Rightarrow> int list" where
"a_coeffs Nil Nil = Nil" |
"a_coeffs Nil ys = ys" |
"a_coeffs xs Nil = xs" |
"a_coeffs (x#xs) (y#ys) = (x + y) # (a_coeffs xs ys)"
fun multi_dist_list:: "int \<Rightarrow> int list \<Rightarrow> int list" where
"multi_dist_list n Nil = Nil" |
"multi_dist_list n (x#xs) = (n*x)#(multi_dist_list n xs)"
fun m_coeffs :: "int list \<Rightarrow> int list \<Rightarrow> int list" where
"m_coeffs Nil ys = Nil" |
"m_coeffs (x#xs) ys = a_coeffs (multi_dist_list x ys) (0 # m_coeffs xs ys)"
fun coeffs :: "exp \<Rightarrow> int list" where
"coeffs Var = [0,1]" |
"coeffs (Const a) = [a]" |
"coeffs (Add a b) = a_coeffs (coeffs(a)) (coeffs(b))" |
"coeffs (Mult a b) = m_coeffs (coeffs(a)) (coeffs(b))"
lemma evalp_coeffs_to_eval_add[simp] :
"evalp (a_coeffs xs ys) x = evalp xs x + evalp ys x"
apply(induction xs rule: a_coeffs.induct)
apply(auto simp add: algebra_simps)
done
lemma evalp_m_d_l[simp]:" evalp (multi_dist_list a ys) x = a * evalp ys x"
apply(induction ys)
apply(auto simp add: algebra_simps)
done
lemma evalp_coeffs_to_eval_multi[simp]:
"evalp (m_coeffs xs ys) x = evalp xs x * evalp ys x"
apply(induction xs)
apply(auto simp add: algebra_simps)
done
lemma evalp_coeffs_eval: "evalp (coeffs e) x = eval e x"
apply(induction e arbitrary: x)
apply(auto)
done
|
/-
Copyright (c) 2020 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel, Jakob von Raumer
-/
import algebra.big_operators.basic
import algebra.hom.group
import algebra.module.basic
import category_theory.endomorphism
import category_theory.limits.shapes.kernels
/-!
# Preadditive categories
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
A preadditive category is a category in which `X ⟶ Y` is an abelian group in such a way that
composition of morphisms is linear in both variables.
This file contains a definition of preadditive category that directly encodes the definition given
above. The definition could also be phrased as follows: A preadditive category is a category
enriched over the category of Abelian groups. Once the general framework to state this in Lean is
available, the contents of this file should become obsolete.
## Main results
* Definition of preadditive categories and basic properties
* In a preadditive category, `f : Q ⟶ R` is mono if and only if `g ≫ f = 0 → g = 0` for all
composable `g`.
* A preadditive category with kernels has equalizers.
## Implementation notes
The simp normal form for negation and composition is to push negations as far as possible to
the outside. For example, `f ≫ (-g)` and `(-f) ≫ g` both become `-(f ≫ g)`, and `(-f) ≫ (-g)`
is simplified to `f ≫ g`.
## References
* [F. Borceux, *Handbook of Categorical Algebra 2*][borceux-vol2]
## Tags
additive, preadditive, Hom group, Ab-category, Ab-enriched
-/
universes v u
open category_theory.limits
open_locale big_operators
namespace category_theory
variables (C : Type u) [category.{v} C]
/-- A category is called preadditive if `P ⟶ Q` is an abelian group such that composition is
linear in both variables. -/
class preadditive :=
(hom_group : Π P Q : C, add_comm_group (P ⟶ Q) . tactic.apply_instance)
(add_comp' : ∀ (P Q R : C) (f f' : P ⟶ Q) (g : Q ⟶ R),
(f + f') ≫ g = f ≫ g + f' ≫ g . obviously)
(comp_add' : ∀ (P Q R : C) (f : P ⟶ Q) (g g' : Q ⟶ R),
f ≫ (g + g') = f ≫ g + f ≫ g' . obviously)
attribute [instance] preadditive.hom_group
restate_axiom preadditive.add_comp'
restate_axiom preadditive.comp_add'
attribute [simp,reassoc] preadditive.add_comp
attribute [reassoc] preadditive.comp_add -- (the linter doesn't like `simp` on this lemma)
attribute [simp] preadditive.comp_add
end category_theory
open category_theory
namespace category_theory
namespace preadditive
section preadditive
open add_monoid_hom
variables {C : Type u} [category.{v} C] [preadditive C]
section induced_category
universes u'
variables {C} {D : Type u'} (F : D → C)
instance induced_category : preadditive.{v} (induced_category C F) :=
{ hom_group := λ P Q, @preadditive.hom_group C _ _ (F P) (F Q),
add_comp' := λ P Q R f f' g, add_comp' _ _ _ _ _ _,
comp_add' := λ P Q R f g g', comp_add' _ _ _ _ _ _, }
end induced_category
instance full_subcategory (Z : C → Prop) : preadditive.{v} (full_subcategory Z) :=
{ hom_group := λ P Q, @preadditive.hom_group C _ _ P.obj Q.obj,
add_comp' := λ P Q R f f' g, add_comp' _ _ _ _ _ _,
comp_add' := λ P Q R f g g', comp_add' _ _ _ _ _ _, }
instance (X : C) : add_comm_group (End X) := by { dsimp [End], apply_instance, }
instance (X : C) : ring (End X) :=
{ left_distrib := λ f g h, preadditive.add_comp X X X g h f,
right_distrib := λ f g h, preadditive.comp_add X X X h f g,
..(infer_instance : add_comm_group (End X)),
..(infer_instance : monoid (End X)) }
/-- Composition by a fixed left argument as a group homomorphism -/
def left_comp {P Q : C} (R : C) (f : P ⟶ Q) : (Q ⟶ R) →+ (P ⟶ R) :=
mk' (λ g, f ≫ g) $ λ g g', by simp
/-- Composition by a fixed right argument as a group homomorphism -/
def right_comp (P : C) {Q R : C} (g : Q ⟶ R) : (P ⟶ Q) →+ (P ⟶ R) :=
mk' (λ f, f ≫ g) $ λ f f', by simp
variables {P Q R : C} (f f' : P ⟶ Q) (g g' : Q ⟶ R)
/-- Composition as a bilinear group homomorphism -/
def comp_hom : (P ⟶ Q) →+ (Q ⟶ R) →+ (P ⟶ R) :=
add_monoid_hom.mk' (λ f, left_comp _ f) $
λ f₁ f₂, add_monoid_hom.ext $ λ g, (right_comp _ g).map_add f₁ f₂
@[simp, reassoc] lemma sub_comp :
(f - f') ≫ g = f ≫ g - f' ≫ g :=
map_sub (right_comp P g) f f'
-- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma.
@[reassoc, simp] lemma comp_sub :
f ≫ (g - g') = f ≫ g - f ≫ g' :=
map_sub (left_comp R f) g g'
@[simp, reassoc] lemma neg_comp : (-f) ≫ g = -(f ≫ g) :=
map_neg (right_comp P g) f
/- The redundant simp lemma linter says that simp can prove the reassoc version of this lemma. -/
@[reassoc, simp] lemma comp_neg : f ≫ (-g) = -(f ≫ g) :=
map_neg (left_comp R f) g
@[reassoc] lemma neg_comp_neg : (-f) ≫ (-g) = f ≫ g :=
by simp
lemma nsmul_comp (n : ℕ) : (n • f) ≫ g = n • (f ≫ g) :=
map_nsmul (right_comp P g) n f
lemma comp_nsmul (n : ℕ) : f ≫ (n • g) = n • (f ≫ g) :=
map_nsmul (left_comp R f) n g
lemma zsmul_comp (n : ℤ) : (n • f) ≫ g = n • (f ≫ g) :=
map_zsmul (right_comp P g) n f
lemma comp_zsmul (n : ℤ) : f ≫ (n • g) = n • (f ≫ g) :=
map_zsmul (left_comp R f) n g
@[reassoc] lemma comp_sum {P Q R : C} {J : Type*} (s : finset J) (f : P ⟶ Q) (g : J → (Q ⟶ R)) :
f ≫ ∑ j in s, g j = ∑ j in s, f ≫ g j :=
map_sum (left_comp R f) _ _
@[reassoc] lemma sum_comp {P Q R : C} {J : Type*} (s : finset J) (f : J → (P ⟶ Q)) (g : Q ⟶ R) :
(∑ j in s, f j) ≫ g = ∑ j in s, f j ≫ g :=
map_sum (right_comp P g) _ _
instance {P Q : C} {f : P ⟶ Q} [epi f] : epi (-f) :=
⟨λ R g g' H, by rwa [neg_comp, neg_comp, ←comp_neg, ←comp_neg, cancel_epi, neg_inj] at H⟩
instance {P Q : C} {f : P ⟶ Q} [mono f] : mono (-f) :=
⟨λ R g g' H, by rwa [comp_neg, comp_neg, ←neg_comp, ←neg_comp, cancel_mono, neg_inj] at H⟩
@[priority 100]
instance preadditive_has_zero_morphisms : has_zero_morphisms C :=
{ has_zero := infer_instance,
comp_zero' := λ P Q f R, show left_comp R f 0 = 0, from map_zero _,
zero_comp' := λ P Q R f, show right_comp P f 0 = 0, from map_zero _ }
instance module_End_right {X Y : C} : module (End Y) (X ⟶ Y) :=
{ smul_add := λ r f g, add_comp _ _ _ _ _ _,
smul_zero := λ r, zero_comp,
add_smul := λ r s f, comp_add _ _ _ _ _ _,
zero_smul := λ r, comp_zero }
lemma mono_of_cancel_zero {Q R : C} (f : Q ⟶ R) (h : ∀ {P : C} (g : P ⟶ Q), g ≫ f = 0 → g = 0) :
mono f :=
⟨λ P g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (right_comp P f) g g').trans $ sub_eq_zero.2 hg⟩
lemma mono_iff_cancel_zero {Q R : C} (f : Q ⟶ R) :
mono f ↔ ∀ (P : C) (g : P ⟶ Q), g ≫ f = 0 → g = 0 :=
⟨λ m P g, by exactI zero_of_comp_mono _, mono_of_cancel_zero f⟩
lemma mono_of_kernel_zero {X Y : C} {f : X ⟶ Y} [has_limit (parallel_pair f 0)]
(w : kernel.ι f = 0) : mono f :=
mono_of_cancel_zero f (λ P g h, by rw [←kernel.lift_ι f g h, w, limits.comp_zero])
lemma epi_of_cancel_zero {P Q : C} (f : P ⟶ Q) (h : ∀ {R : C} (g : Q ⟶ R), f ≫ g = 0 → g = 0) :
epi f :=
⟨λ R g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (left_comp R f) g g').trans $ sub_eq_zero.2 hg⟩
lemma epi_iff_cancel_zero {P Q : C} (f : P ⟶ Q) :
epi f ↔ ∀ (R : C) (g : Q ⟶ R), f ≫ g = 0 → g = 0 :=
⟨λ e R g, by exactI zero_of_epi_comp _, epi_of_cancel_zero f⟩
namespace is_iso
@[simp] lemma comp_left_eq_zero [is_iso f] :
f ≫ g = 0 ↔ g = 0 :=
by rw [← is_iso.eq_inv_comp, limits.comp_zero]
@[simp] lemma comp_right_eq_zero [is_iso g] :
f ≫ g = 0 ↔ f = 0 :=
by rw [← is_iso.eq_comp_inv, limits.zero_comp]
end is_iso
open_locale zero_object
variables [has_zero_object C]
lemma mono_of_kernel_iso_zero {X Y : C} {f : X ⟶ Y} [has_limit (parallel_pair f 0)]
(w : kernel f ≅ 0) : mono f :=
mono_of_kernel_zero (zero_of_source_iso_zero _ w)
lemma epi_of_cokernel_iso_zero {X Y : C} {f : X ⟶ Y} [has_colimit (parallel_pair f 0)]
(w : cokernel f ≅ 0) : epi f :=
epi_of_cokernel_zero (zero_of_target_iso_zero _ w)
end preadditive
section equalizers
variables {C : Type u} [category.{v} C] [preadditive C]
section
variables {X Y : C} {f : X ⟶ Y} {g : X ⟶ Y}
/-- Map a kernel cone on the difference of two morphisms to the equalizer fork. -/
@[simps X]
def fork_of_kernel_fork (c : kernel_fork (f - g)) : fork f g :=
fork.of_ι c.ι $ by rw [← sub_eq_zero, ← comp_sub, c.condition]
@[simp] lemma fork_of_kernel_fork_ι (c : kernel_fork (f - g)) :
(fork_of_kernel_fork c).ι = c.ι := rfl
/-- Map any equalizer fork to a cone on the difference of the two morphisms. -/
def kernel_fork_of_fork (c : fork f g) : kernel_fork (f - g) :=
fork.of_ι c.ι $ by rw [comp_sub, comp_zero, sub_eq_zero, c.condition]
@[simp] lemma kernel_fork_of_fork_ι (c : fork f g) : (kernel_fork_of_fork c).ι = c.ι := rfl
@[simp] lemma kernel_fork_of_fork_of_ι {P : C} (ι : P ⟶ X) (w : ι ≫ f = ι ≫ g) :
(kernel_fork_of_fork (fork.of_ι ι w)) = kernel_fork.of_ι ι (by simp [w]) := rfl
/-- A kernel of `f - g` is an equalizer of `f` and `g`. -/
def is_limit_fork_of_kernel_fork {c : kernel_fork (f - g)} (i : is_limit c) :
is_limit (fork_of_kernel_fork c) :=
fork.is_limit.mk' _ $ λ s,
⟨i.lift (kernel_fork_of_fork s), i.fac _ _,
λ m h, by apply fork.is_limit.hom_ext i; tidy⟩
@[simp]
lemma is_limit_fork_of_kernel_fork_lift {c : kernel_fork (f - g)} (i : is_limit c) (s : fork f g) :
(is_limit_fork_of_kernel_fork i).lift s = i.lift (kernel_fork_of_fork s) := rfl
/-- An equalizer of `f` and `g` is a kernel of `f - g`. -/
def is_limit_kernel_fork_of_fork {c : fork f g} (i : is_limit c) :
is_limit (kernel_fork_of_fork c) :=
fork.is_limit.mk' _ $ λ s,
⟨i.lift (fork_of_kernel_fork s), i.fac _ _,
λ m h, by apply fork.is_limit.hom_ext i; tidy⟩
variables (f g)
/-- A preadditive category has an equalizer for `f` and `g` if it has a kernel for `f - g`. -/
lemma has_equalizer_of_has_kernel [has_kernel (f - g)] : has_equalizer f g :=
has_limit.mk { cone := fork_of_kernel_fork _,
is_limit := is_limit_fork_of_kernel_fork (equalizer_is_equalizer (f - g) 0) }
/-- A preadditive category has a kernel for `f - g` if it has an equalizer for `f` and `g`. -/
lemma has_kernel_of_has_equalizer [has_equalizer f g] : has_kernel (f - g) :=
has_limit.mk { cone := kernel_fork_of_fork (equalizer.fork f g),
is_limit := is_limit_kernel_fork_of_fork (limit.is_limit (parallel_pair f g)) }
variables {f g}
/-- Map a cokernel cocone on the difference of two morphisms to the coequalizer cofork. -/
@[simps X]
def cofork_of_cokernel_cofork (c : cokernel_cofork (f - g)) : cofork f g :=
cofork.of_π c.π $ by rw [← sub_eq_zero, ← sub_comp, c.condition]
@[simp] lemma cofork_of_cokernel_cofork_π (c : cokernel_cofork (f - g)) :
(cofork_of_cokernel_cofork c).π = c.π := rfl
/-- Map any coequalizer cofork to a cocone on the difference of the two morphisms. -/
def cokernel_cofork_of_cofork (c : cofork f g) : cokernel_cofork (f - g) :=
cofork.of_π c.π $ by rw [sub_comp, zero_comp, sub_eq_zero, c.condition]
@[simp] lemma cokernel_cofork_of_cofork_π (c : cofork f g) :
(cokernel_cofork_of_cofork c).π = c.π := rfl
@[simp] lemma cokernel_cofork_of_cofork_of_π {P : C} (π : Y ⟶ P) (w : f ≫ π = g ≫ π) :
(cokernel_cofork_of_cofork (cofork.of_π π w)) = cokernel_cofork.of_π π (by simp [w]) := rfl
/-- A cokernel of `f - g` is a coequalizer of `f` and `g`. -/
def is_colimit_cofork_of_cokernel_cofork {c : cokernel_cofork (f - g)} (i : is_colimit c) :
is_colimit (cofork_of_cokernel_cofork c) :=
cofork.is_colimit.mk' _ $ λ s,
⟨i.desc (cokernel_cofork_of_cofork s), i.fac _ _,
λ m h, by apply cofork.is_colimit.hom_ext i; tidy⟩
@[simp]
lemma is_colimit_cofork_of_cokernel_cofork_desc {c : cokernel_cofork (f - g)}
(i : is_colimit c) (s : cofork f g) :
(is_colimit_cofork_of_cokernel_cofork i).desc s = i.desc (cokernel_cofork_of_cofork s) := rfl
/-- A coequalizer of `f` and `g` is a cokernel of `f - g`. -/
def is_colimit_cokernel_cofork_of_cofork {c : cofork f g} (i : is_colimit c) :
is_colimit (cokernel_cofork_of_cofork c) :=
cofork.is_colimit.mk' _ $ λ s,
⟨i.desc (cofork_of_cokernel_cofork s), i.fac _ _,
λ m h, by apply cofork.is_colimit.hom_ext i; tidy⟩
variables (f g)
/-- A preadditive category has a coequalizer for `f` and `g` if it has a cokernel for `f - g`. -/
lemma has_coequalizer_of_has_cokernel [has_cokernel (f - g)] : has_coequalizer f g :=
has_colimit.mk { cocone := cofork_of_cokernel_cofork _,
is_colimit := is_colimit_cofork_of_cokernel_cofork (coequalizer_is_coequalizer (f - g) 0) }
/-- A preadditive category has a cokernel for `f - g` if it has a coequalizer for `f` and `g`. -/
lemma has_cokernel_of_has_coequalizer [has_coequalizer f g] : has_cokernel (f - g) :=
has_colimit.mk { cocone := cokernel_cofork_of_cofork (coequalizer.cofork f g),
is_colimit := is_colimit_cokernel_cofork_of_cofork (colimit.is_colimit (parallel_pair f g)) }
end
/-- If a preadditive category has all kernels, then it also has all equalizers. -/
lemma has_equalizers_of_has_kernels [has_kernels C] : has_equalizers C :=
@has_equalizers_of_has_limit_parallel_pair _ _ (λ _ _ f g, has_equalizer_of_has_kernel f g)
/-- If a preadditive category has all cokernels, then it also has all coequalizers. -/
lemma has_coequalizers_of_has_cokernels [has_cokernels C] : has_coequalizers C :=
@has_coequalizers_of_has_colimit_parallel_pair _ _ (λ _ _ f g, has_coequalizer_of_has_cokernel f g)
end equalizers
end preadditive
end category_theory
|
program part1
integer :: n, a, b
integer, dimension(12) :: bits
character(len = 12) :: s
n = 0
do i = 1, 12
bits(i) = 0
end do
do
read (5, 12, end=20) s
12 format(a12)
n = n+1
do i = 1, 12
if (s(i:i) == '1') then
bits(i) = bits(i) + 1
end if
end do
end do
20 a = 0
b = 0
do i = 1, 12
a = a * 2
b = b * 2
if (bits(i) > n/2) then
a = a + 1
else
b = b + 1
end if
end do
write(*, '(I0)') a * b
end program part1
|
import category_theory.limits.shapes.products
import for_mathlib.Profinite.compat_discrete_quotient
import topology.category.Profinite
import for_mathlib.quotient_map
import category_theory.limits.shapes.finite_limits
/-!
In this file we show that a finite disjoint union of profinite sets agrees with the coproduct.
*Note:* The existence of the coproduct is currently shown using some abstract nonsense.
-/
namespace Profinite
universe u
variables {α : Type u} [fintype α] (X : α → Profinite.{u})
def empty : Profinite.{u} := Profinite.of pempty
def empty.elim (X : Profinite.{u}) : empty ⟶ X := { to_fun := pempty.elim }
def sum (X Y : Profinite.{u}) : Profinite.{u} :=
Profinite.of $ X ⊕ Y
def sum.inl (X Y : Profinite.{u}) : X ⟶ sum X Y :=
{ to_fun := _root_.sum.inl }
def sum.inr (X Y : Profinite.{u}) : Y ⟶ sum X Y :=
{ to_fun := _root_.sum.inr }
def sum.desc {Z} (X Y : Profinite.{u}) (f : X ⟶ Z) (g : Y ⟶ Z) : sum X Y ⟶ Z :=
{ to_fun := λ x, _root_.sum.rec_on x f g,
continuous_to_fun := begin
simp only [continuous_sup_dom, continuous_coinduced_dom],
exact ⟨f.continuous, g.continuous⟩
end }
@[simp, reassoc]
lemma sum.inl_desc {Z} (X Y : Profinite.{u}) (f : X ⟶ Z) (g : Y ⟶ Z) :
sum.inl X Y ≫ sum.desc X Y f g = f := by { ext, refl }
@[simp, reassoc]
lemma sum.inr_desc {Z} (X Y : Profinite.{u}) (f : X ⟶ Z) (g : Y ⟶ Z) :
sum.inr X Y ≫ sum.desc X Y f g = g := by { ext, refl }
lemma sum.hom_ext {Z} (X Y : Profinite.{u}) (e₁ e₂ : sum X Y ⟶ Z)
(hl : sum.inl X Y ≫ e₁ = sum.inl X Y ≫ e₂) (hr : sum.inr X Y ≫ e₁ = sum.inr X Y ≫ e₂) :
e₁ = e₂ :=
begin
ext (u|u),
{ apply_fun (λ e, e u) at hl, exact hl },
{ apply_fun (λ e, e u) at hr, exact hr },
end
def sigma : Profinite.{u} :=
Profinite.of $ Σ a, X a
def sigma.ι (a : α) : X a ⟶ sigma X :=
{ to_fun := λ t, ⟨_,t⟩,
continuous_to_fun := begin
apply continuous_Sup_rng,
exact ⟨a,rfl⟩,
apply continuous_coinduced_rng,
end }
lemma sigma.ι_injective (a : α) : function.injective (sigma.ι X a) :=
by { dsimp [sigma.ι], exact sigma_mk_injective }
lemma sigma.ι_jointly_surjective (t : sigma X) : ∃ a (x : X a), sigma.ι X a x = t :=
by { rcases t with ⟨a,t⟩, exact ⟨a,t,rfl⟩ }
def sigma.desc {Y} (f : Π a, X a ⟶ Y) : sigma X ⟶ Y :=
{ to_fun := λ ⟨a,t⟩, f a t,
continuous_to_fun := begin
rw continuous_Sup_dom,
rintros _ ⟨a,rfl⟩,
resetI,
rw continuous_coinduced_dom,
exact (f a).continuous
end }
lemma sigma.desc_surjective {Y} (f : Π a, X a ⟶ Y) (surj : ∀ y, ∃ a (x : X a), f a x = y) :
function.surjective (sigma.desc X f) :=
begin
intros y,
obtain ⟨a,x,hx⟩ := surj y,
exact ⟨⟨a,x⟩,hx⟩,
end
@[simp, reassoc]
lemma sigma.ι_desc {Y} (a) (f : Π a, X a ⟶ Y) : sigma.ι X a ≫ sigma.desc X f = f a :=
by { ext, refl }
lemma sigma.hom_ext {Y} (f g : sigma X ⟶ Y) (w : ∀ a, sigma.ι X a ≫ f = sigma.ι X a ≫ g) :
f = g :=
begin
ext ⟨a,t⟩,
specialize w a,
apply_fun (λ e, e t) at w,
exact w,
end
open category_theory
def sigma_cofan : limits.cofan X :=
limits.cofan.mk (sigma X) (sigma.ι X)
def sigma_cofan_is_colimit : limits.is_colimit (sigma_cofan X) :=
{ desc := λ S, sigma.desc _ $ λ a, S.ι.app ⟨a⟩,
fac' := begin
rintros S ⟨j⟩,
ext t,
refl,
end,
uniq' := begin
intros S m h,
apply sigma.hom_ext,
intros a,
convert h ⟨a⟩,
simp,
end }
def pullback {X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B) : Profinite :=
{ to_CompHaus :=
{ to_Top := Top.of { a : X × Y | f a.1 = g a.2 },
is_compact := begin
erw ← is_compact_iff_compact_space,
apply is_closed.is_compact,
apply is_closed_eq,
all_goals { continuity },
end,
is_hausdorff := begin
change t2_space { a : X × Y | f a.1 = g a.2 },
apply_instance
end },
is_totally_disconnected := subtype.totally_disconnected_space }
def pullback.fst {X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B) :
pullback f g ⟶ X := { to_fun := λ a, a.1.1 }
def pullback.snd {X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B) :
pullback f g ⟶ Y := { to_fun := λ a, a.1.2 }
@[reassoc]
lemma pullback.condition {X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B) :
pullback.fst f g ≫ f = pullback.snd f g ≫ g := by { ext ⟨t,ht⟩, exact ht }
def pullback.lift {W X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B)
(e₁ : W ⟶ X) (e₂ : W ⟶ Y) (w : e₁ ≫ f = e₂ ≫ g) : W ⟶ pullback f g :=
{ to_fun := λ t, ⟨(e₁ t, e₂ t), by { apply_fun (λ ee, ee t) at w, exact w }⟩ }
@[simp, reassoc]
lemma pullback.lift_fst {W X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B)
(e₁ : W ⟶ X) (e₂ : W ⟶ Y) (w : e₁ ≫ f = e₂ ≫ g) :
pullback.lift f g e₁ e₂ w ≫ pullback.fst f g = e₁ := by { ext, refl }
@[simp, reassoc]
lemma pullback.lift_snd {W X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B)
(e₁ : W ⟶ X) (e₂ : W ⟶ Y) (w : e₁ ≫ f = e₂ ≫ g) :
pullback.lift f g e₁ e₂ w ≫ pullback.snd f g = e₂ := by { ext, refl }
lemma pullback.hom_ext {W X Y B : Profinite.{u}} (f : X ⟶ B) (g : Y ⟶ B) (e₁ e₂ : W ⟶ pullback f g)
(w₁ : e₁ ≫ pullback.fst f g = e₂ ≫ pullback.fst f g)
(w₂ : e₁ ≫ pullback.snd f g = e₂ ≫ pullback.snd f g) : e₁ = e₂ :=
begin
ext t,
{ apply_fun (λ e, e t) at w₁, exact w₁ },
{ apply_fun (λ e, e t) at w₂, exact w₂ },
end
def sigma_pullback_to_pullback_sigma {B} (f : Π a, X a ⟶ B) :
sigma (λ a : α × α, pullback (f a.1) (f a.2)) ⟶ pullback (sigma.desc X f) (sigma.desc X f) :=
sigma.desc _ $ λ a, pullback.lift _ _
(pullback.fst _ _ ≫ sigma.ι _ _) (pullback.snd _ _ ≫ sigma.ι _ _) begin
cases a, dsimp at *, ext1 x, cases x, assumption,
end
instance {B} (f : Π a, X a ⟶ B) : is_iso (sigma_pullback_to_pullback_sigma X f) :=
is_iso_of_bijective _
begin
split,
{ rintros ⟨⟨a,b⟩,⟨⟨x₁,x₂⟩,hx⟩⟩ ⟨⟨a',b'⟩,⟨⟨x'₁,x'₂⟩,hx'⟩⟩ h,
dsimp [sigma_pullback_to_pullback_sigma, sigma.desc, pullback.lift,
sigma.ι, pullback.fst, pullback.snd] at *,
tidy },
{ rintros ⟨⟨⟨a,x⟩,⟨b,y⟩⟩,h⟩,
refine ⟨⟨⟨a,b⟩,⟨⟨x,y⟩,h⟩⟩,rfl⟩ }
end
@[simp]
lemma sigma_pullback_to_pullback_sigma_fst {B} (f : Π a, X a ⟶ B) :
sigma_pullback_to_pullback_sigma X f ≫ pullback.fst _ _ =
sigma.desc _ (λ a, pullback.fst _ _ ≫ sigma.ι _ a.1) := by ext ⟨_,_⟩; refl
@[simp]
lemma sigma_pullback_to_pullback_sigma_snd {B} (f : Π a, X a ⟶ B) :
sigma_pullback_to_pullback_sigma X f ≫ pullback.snd _ _ =
sigma.desc _ (λ a, pullback.snd _ _ ≫ sigma.ι _ a.2) := by ext ⟨_,_⟩; refl
lemma sigma_iso_of_equiv_aux
{α β : Type u}
[fintype α]
[fintype β]
(e : α ≃ β)
(X : β → Profinite.{u})
(b : β)
(h : b = (e ((e.symm) b))) :
eq_to_hom (by rw h) ≫ sigma.ι _ _ = sigma.ι X b :=
begin
induction h,
simp,
end
def sigma_iso_of_equiv {α β : Type u} [fintype α] [fintype β] (e : α ≃ β)
(X : β → Profinite.{u}) :
sigma (X ∘ e) ≅ sigma X :=
{ hom := sigma.desc _ $ λ a, sigma.ι _ (e a),
inv := sigma.desc _ $ λ b, eq_to_hom (by simp) ≫ sigma.ι _ (e.symm b),
hom_inv_id' := begin
apply sigma.hom_ext,
intros a,
dsimp,
simp only [sigma.ι_desc_assoc, sigma.ι_desc, category.comp_id],
apply sigma_iso_of_equiv_aux,
simp,
end,
inv_hom_id' := begin
apply sigma.hom_ext,
intros b,
dsimp,
simp only [sigma.ι_desc_assoc, category.assoc, sigma.ι_desc, category.comp_id],
apply sigma_iso_of_equiv_aux,
simp,
end }
def sigma_iso_empty : sigma pempty.elim ≅ empty :=
{ hom := sigma.desc _ $ λ a, a.elim,
inv := empty.elim _,
hom_inv_id' := begin
apply sigma.hom_ext,
rintros ⟨⟩
end,
inv_hom_id' := begin
ext ⟨⟩
end }
-- fin_zero_elim is terrible!
def sigma_iso_empty' (X : (pempty : Type u) → Profinite.{u}) : sigma X ≅ (empty : Profinite.{u}) :=
{ hom := sigma.desc _ $ λ i, i.elim,
inv := empty.elim _,
hom_inv_id' := begin
apply sigma.hom_ext,
rintros ⟨⟩,
end,
inv_hom_id' := by { ext ⟨⟩ } }
def sigma_sum_iso {α β : Type u} [fintype α] [fintype β]
(X : α → Profinite.{u}) (Y : β → Profinite.{u}) :
sigma (λ (x : α ⊕ β), sum.rec_on x X Y) ≅ sum (sigma X) (sigma Y) :=
{ hom := sigma.desc _ $ λ x, sum.rec_on x
(λ a, by { dsimp, exact sigma.ι _ _ } ≫ Profinite.sum.inl _ _)
(λ b, by { dsimp, exact sigma.ι _ _ } ≫ Profinite.sum.inr _ _),
inv := sum.desc _ _
(sigma.desc _ $ λ a, begin
refine _ ≫ sigma.ι _ (_root_.sum.inl a),
exact 𝟙 _
end)
(sigma.desc _ $ λ b, begin
refine _ ≫ sigma.ι _ (_root_.sum.inr b),
exact 𝟙 _
end),
hom_inv_id' := begin
apply sigma.hom_ext,
rintros (a|b),
all_goals { dsimp, simp }
end,
inv_hom_id' := begin
apply sum.hom_ext,
all_goals
{ dsimp,
simp,
apply sigma.hom_ext,
intros,
simp },
end }
def sigma_sum_iso' {α β : Type u} [fintype α] [fintype β]
(X : α ⊕ β → Profinite.{u}) :
sigma X ≅ sum (sigma (X ∘ _root_.sum.inl)) (sigma (X ∘ _root_.sum.inr)) :=
{ hom := sigma.desc _ $ λ x, sum.rec_on x (λ a, begin
exact sigma.ι (X ∘ _root_.sum.inl) a,
end ≫ sum.inl _ _) (λ b, begin
exact sigma.ι (X ∘ _root_.sum.inr) b
end ≫ sum.inr _ _),
inv := sum.desc _ _ (sigma.desc _ $ λ a, sigma.ι _ _) (sigma.desc _ $ λ b, sigma.ι _ _),
hom_inv_id' := begin
apply sigma.hom_ext,
rintros (a|b),
all_goals { dsimp, simp },
end,
inv_hom_id' := begin
apply sum.hom_ext,
all_goals
{ dsimp,
simp,
apply sigma.hom_ext,
intros, simp }
end }
def sigma_punit_iso (X : (punit : Type u) → Profinite.{u}) :
X punit.star ≅ sigma X :=
{ hom := sigma.ι _ _,
inv := sigma.desc _ $ λ ⟨⟩, 𝟙 _ }
def sigma_walking_pair_iso (X : ulift.{u} limits.walking_pair → Profinite.{u}) :
sigma X ≅ (X ⟨limits.walking_pair.left⟩).sum (X ⟨limits.walking_pair.right⟩) :=
{ hom := sigma.desc _ $ λ a,
match a with
| ⟨a⟩ := limits.walking_pair.rec_on a (sum.inl _ _) (sum.inr _ _)
end,
inv := sum.desc _ _ (sigma.ι X (ulift.up _)) (sigma.ι X (ulift.up _)),
hom_inv_id' := begin
apply sigma.hom_ext,
rintros (⟨a⟩|⟨b⟩),
all_goals { dsimp, simp only [sigma.ι_desc_assoc, category.comp_id],
dsimp [sigma_walking_pair_iso._match_1],
simp only [sum.inl_desc, sum.inr_desc] },
end,
inv_hom_id' := begin
apply sum.hom_ext,
all_goals { dsimp, simpa only [sum.inl_desc_assoc, sigma.ι_desc, category.comp_id] },
end }
--TODO: Finish off the api for the explicit pullback
def equalizer {X Y : Profinite.{u}} (f g : X ⟶ Y) : Profinite :=
{ to_CompHaus :=
{ to_Top := Top.of { x | f x = g x },
is_compact := begin
erw ← is_compact_iff_compact_space,
apply is_closed.is_compact,
apply is_closed_eq,
exact f.continuous,
exact g.continuous
end,
is_hausdorff := begin
change t2_space { x | f x = g x },
apply_instance
end },
is_totally_disconnected := subtype.totally_disconnected_space }
def equalizer.ι {X Y : Profinite.{u}} (f g : X ⟶ Y) : equalizer f g ⟶ X := { to_fun := λ x, x.1 }
def equalizer.lift {W X Y : Profinite.{u}} (f g : X ⟶ Y) (e : W ⟶ X) (w : e ≫ f = e ≫ g) :
W ⟶ equalizer f g :=
{ to_fun := λ t, ⟨e t, by { apply_fun (λ ee, ee t) at w, exact w }⟩ }
@[simp, reassoc]
lemma equalizer.lift_ι {W X Y : Profinite.{u}} (f g : X ⟶ Y) (e : W ⟶ X)
(w : e ≫ f = e ≫ g) : equalizer.lift f g e w ≫ equalizer.ι f g = e := by { ext, refl }
lemma equalizer.hom_ext {W X Y : Profinite.{u}} (f g : X ⟶ Y) (e₁ e₂ : W ⟶ equalizer f g)
(w : e₁ ≫ equalizer.ι f g = e₂ ≫ equalizer.ι f g) : e₁ = e₂ :=
begin
ext t,
apply_fun (λ ee, ee t) at w,
exact w,
end
/-- Descend a morphism along a surjective morphism. -/
noncomputable
def descend {X B Y : Profinite} (π : X ⟶ B) (t : X ⟶ Y) (hπ : function.surjective π)
(w : pullback.fst π π ≫ t = pullback.snd π π ≫ t) : B ⟶ Y :=
{ to_fun := (λ i, quotient.lift_on' i t begin
rintros a b (h : π _ = π _),
apply_fun (λ e, e ⟨(a,b),h⟩) at w,
exact w,
end : quotient (setoid.ker π) → Y) ∘ (Profinite.quotient_map π hπ).homeomorph.symm,
continuous_to_fun := begin
apply continuous.comp,
{ apply continuous_quot_lift, exact t.continuous },
{ exact (quotient_map π hπ).homeomorph.symm.continuous }
end }
-- TODO: Define `foo_to_Top` analogues for the colimit-like constructions above.
noncomputable
def descend_to_Top {X B : Profinite} {Y : Top} (π : X ⟶ B) (t : Profinite.to_Top.obj X ⟶ Y)
(hπ : function.surjective π)
(w : Profinite.to_Top.map (pullback.fst π π) ≫ t =
Profinite.to_Top.map (pullback.snd π π) ≫ t) : Profinite.to_Top.obj B ⟶ Y :=
{ to_fun := (λ i, quotient.lift_on' i t begin
rintros a b (h : π _ = π _),
apply_fun (λ e, e ⟨(a,b),h⟩) at w,
exact w,
end : quotient (setoid.ker π) → Y) ∘ (Profinite.quotient_map π hπ).homeomorph.symm,
continuous_to_fun := begin
apply continuous.comp,
{ apply continuous_quot_lift, exact t.continuous },
{ exact (quotient_map π hπ).homeomorph.symm.continuous }
end }
@[simp]
lemma π_descend {X B Y : Profinite} (π : X ⟶ B) (t : X ⟶ Y) (hπ : function.surjective π)
(w : pullback.fst π π ≫ t = pullback.snd π π ≫ t) :
π ≫ descend π t hπ w = t :=
begin
ext i,
dsimp [descend, setoid.quotient_ker_equiv_of_surjective,
setoid.quotient_ker_equiv_of_right_inverse, quotient_map.homeomorph],
let c : pullback π π := ⟨(function.surj_inv hπ (π i), i), function.surj_inv_eq hπ (π i)⟩,
apply_fun (λ e, e c) at w,
exact w,
end
lemma π_descend_to_Top {X B : Profinite} {Y : Top} (π : X ⟶ B) (t : Profinite.to_Top.obj X ⟶ Y)
(hπ : function.surjective π)
(w : Profinite.to_Top.map (pullback.fst π π) ≫ t =
Profinite.to_Top.map (pullback.snd π π) ≫ t) :
Profinite.to_Top.map π ≫ descend_to_Top π t hπ w = t :=
begin
ext i,
dsimp [descend_to_Top, setoid.quotient_ker_equiv_of_surjective,
setoid.quotient_ker_equiv_of_right_inverse, quotient_map.homeomorph],
let c : pullback π π := ⟨(function.surj_inv hπ (π i), i), function.surj_inv_eq hπ (π i)⟩,
apply_fun (λ e, e c) at w,
exact w,
end
def product {α : Type} (X : α → Profinite.{u}) : Profinite :=
Profinite.of $ Π a, X a
def product.π {α : Type} (X : α → Profinite.{u}) (a : α) :
product X ⟶ X a := ⟨λ t, t a, continuous_apply _⟩
def product.lift {α : Type} {Y : Profinite.{u}} (X : α → Profinite.{u})
(f : Π a, Y ⟶ X a) : Y ⟶ product X :=
⟨λ y a, f a y, begin
apply continuous_pi,
intros i,
exact (f i).2,
end⟩
@[simp, reassoc]
lemma product.lift_π {α : Type} {Y : Profinite.{u}} (X : α → Profinite.{u})
(f : Π a, Y ⟶ X a) (a) : product.lift X f ≫ product.π X a = f _ := by { ext, refl }
lemma product.hom_ext {α : Type} {Y : Profinite.{u}} (X : α → Profinite.{u})
(f g : Y ⟶ product X) (h : ∀ a, f ≫ product.π X a = g ≫ product.π X a) : f = g :=
begin
ext y a,
specialize h a,
apply_fun (λ e, e y) at h,
exact h,
end
def punit : Profinite.{u} := Profinite.of punit
def punit.elim (X : Profinite.{u}) : X ⟶ punit :=
⟨λ x, punit.star, by tidy⟩
lemma punit.hom_ext (X : Profinite.{u}) (f g : X ⟶ punit) : f = g :=
by ext
def from_punit {X : Profinite.{u}} (x : X) : punit ⟶ X :=
⟨λ _, x, by tidy⟩
def pow (X : Profinite.{u}) (n : ℕ) : Profinite.{u} :=
Profinite.product (λ i : fin n, X)
def map_pow {X Y : Profinite.{u}} (f : X ⟶ Y) (n : ℕ) :
X.pow n ⟶ Y.pow n :=
Profinite.product.lift _ $ λ n, Profinite.product.π _ n ≫ f
end Profinite
|
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.Pointed.Base where
open import Cubical.Foundations.Prelude
Pointed : (ℓ : Level) → Type (ℓ-suc ℓ)
Pointed ℓ = Σ[ A ∈ Type ℓ ] A
typ : ∀ {ℓ} (A∙ : Pointed ℓ) → Type ℓ
typ = fst
pt : ∀ {ℓ} (A∙ : Pointed ℓ) → typ A∙
pt = snd
|
[STATEMENT]
lemma euler_genus_da: "H.euler_genus = G.euler_genus"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. H.euler_genus = G.euler_genus
[PROOF STEP]
unfolding G.euler_genus_def H.euler_genus_def G.euler_char_def H.euler_char_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (int (2 * card H.sccs) - int (card H.isolated_verts) - (int (card (verts H)) - int (card (arcs H) div 2) + int (card H.face_cycle_sets))) div 2 = (int (2 * card G.sccs) - int (card G.isolated_verts) - (int (card (verts G)) - int (card (arcs G) div 2) + int (card G.face_cycle_sets))) div 2
[PROOF STEP]
by (simp add: isolated_verts_da verts_H card_arcs_da card_face_cycle_sets_da card_sccs_da) |
/-
Copyright (c) 2022 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
import data.fintype.powerset
import data.fintype.prod
import data.fintype.sigma
import data.fintype.sum
import data.fintype.vector
/-!
# Finite types
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
In this file we prove some theorems about `finite` and provide some instances. This typeclass is a
`Prop`-valued counterpart of the typeclass `fintype`. See more details in the file where `finite` is
defined.
## Main definitions
* `fintype.finite`, `finite.of_fintype` creates a `finite` instance from a `fintype` instance. The
former lemma takes `fintype α` as an explicit argument while the latter takes it as an instance
argument.
* `fintype.of_finite` noncomputably creates a `fintype` instance from a `finite` instance.
## Implementation notes
There is an apparent duplication of many `fintype` instances in this module,
however they follow a pattern: if a `fintype` instance depends on `decidable`
instances or other `fintype` instances, then we need to "lower" the instance
to be a `finite` instance by removing the `decidable` instances and switching
the `fintype` instances to `finite` instances. These are precisely the ones
that cannot be inferred using `finite.of_fintype`. (However, when using
`open_locale classical` or the `classical` tactic the instances relying only
on `decidable` instances will give `finite` instances.) In the future we might
consider writing automation to create these "lowered" instances.
## Tags
finiteness, finite types
-/
noncomputable theory
open_locale classical
variables {α β γ : Type*}
namespace finite
@[priority 100] -- see Note [lower instance priority]
instance of_subsingleton {α : Sort*} [subsingleton α] : finite α :=
of_injective (function.const α ()) $ function.injective_of_subsingleton _
@[nolint instance_priority] -- Higher priority for `Prop`s
instance prop (p : Prop) : finite p := finite.of_subsingleton
instance [finite α] [finite β] : finite (α × β) :=
by { haveI := fintype.of_finite α, haveI := fintype.of_finite β, apply_instance }
instance {α β : Sort*} [finite α] [finite β] : finite (pprod α β) :=
of_equiv _ equiv.pprod_equiv_prod_plift.symm
lemma prod_right (α) [finite (α × β)] [nonempty α] : finite β :=
of_surjective (prod.snd : α × β → β) prod.snd_surjective
instance [finite α] [finite β] : finite (α ⊕ β) :=
by { haveI := fintype.of_finite α, haveI := fintype.of_finite β, apply_instance }
lemma sum_left (β) [finite (α ⊕ β)] : finite α :=
of_injective (sum.inl : α → α ⊕ β) sum.inl_injective
lemma sum_right (α) [finite (α ⊕ β)] : finite β :=
of_injective (sum.inr : β → α ⊕ β) sum.inr_injective
instance {β : α → Type*} [finite α] [Π a, finite (β a)] : finite (Σ a, β a) :=
by { letI := fintype.of_finite α, letI := λ a, fintype.of_finite (β a), apply_instance }
instance {ι : Sort*} {π : ι → Sort*} [finite ι] [Π i, finite (π i)] : finite (Σ' i, π i) :=
of_equiv _ (equiv.psigma_equiv_sigma_plift π).symm
instance [finite α] : finite (set α) := by { casesI nonempty_fintype α, apply_instance }
end finite
/-- This instance also provides `[finite s]` for `s : set α`. -/
instance subtype.finite {α : Sort*} [finite α] {p : α → Prop} : finite {x // p x} :=
finite.of_injective coe subtype.coe_injective
instance pi.finite {α : Sort*} {β : α → Sort*} [finite α] [∀ a, finite (β a)] : finite (Π a, β a) :=
begin
haveI := fintype.of_finite (plift α),
haveI := λ a, fintype.of_finite (plift (β a)),
exact finite.of_equiv (Π (a : plift α), plift (β (equiv.plift a)))
(equiv.Pi_congr equiv.plift (λ _, equiv.plift)),
end
instance vector.finite {α : Type*} [finite α] {n : ℕ} : finite (vector α n) :=
by { haveI := fintype.of_finite α, apply_instance }
instance quot.finite {α : Sort*} [finite α] (r : α → α → Prop) : finite (quot r) :=
finite.of_surjective _ (surjective_quot_mk r)
instance quotient.finite {α : Sort*} [finite α] (s : setoid α) : finite (quotient s) :=
quot.finite _
instance function.embedding.finite {α β : Sort*} [finite β] : finite (α ↪ β) :=
begin
casesI is_empty_or_nonempty (α ↪ β) with _ h,
{ apply_instance, },
{ refine h.elim (λ f, _),
haveI : finite α := finite.of_injective _ f.injective,
exact finite.of_injective _ fun_like.coe_injective },
end
instance equiv.finite_right {α β : Sort*} [finite β] : finite (α ≃ β) :=
finite.of_injective equiv.to_embedding $ λ e₁ e₂ h, equiv.ext $
by convert fun_like.congr_fun h
instance equiv.finite_left {α β : Sort*} [finite α] : finite (α ≃ β) :=
finite.of_equiv _ ⟨equiv.symm, equiv.symm, equiv.symm_symm, equiv.symm_symm⟩
instance [finite α] {n : ℕ} : finite (sym α n) :=
by { haveI := fintype.of_finite α, apply_instance }
|
module PlotUtils
using ColorSchemes
using Dates
using Reexport
using Printf
@reexport using Colors
import Base: getindex
import Random: MersenneTwister
export ColorGradient,
ColorPalette,
cgrad,
palette,
color_list,
cvec,
rgb_string,
rgba_string,
invisible,
get_color_palette,
isdark,
plot_color,
adapted_grid,
default_cgrad,
zscale
include("color_utils.jl")
include("colors.jl")
include("colorschemes.jl")
include("adapted_grid.jl")
include("intervals.jl")
export optimize_ticks, optimize_datetime_ticks
include("ticks.jl")
const _default_colorscheme = generate_colorscheme()
if Base.VERSION >= v"1.4.2"
include("precompile.jl")
_precompile_()
end
end # module
|
module CwF where
open import Setoid
open EqChain
infixr 30 _⇒_
infixl 50 _/_ _/ˢ_
infixr 45 _◄_
infixl 45 _▷_
Cxt : Set
Cxt = Setoid
_⇒_ : Cxt -> Cxt -> Set
Γ ⇒ Δ = El (Γ ==> Δ)
Type : Cxt -> Set
Type Γ = Fam Γ
_/_ : {Γ Δ : Cxt} -> Type Γ -> (Δ ⇒ Γ) -> Type Δ
A / σ = A ○ σ
lem-/id : {Γ : Cxt}{A : Type Γ} -> A / id == A
lem-/id = lem-○-id
Term : (Γ : Cxt) -> Type Γ -> Set
Term Γ A = El (Π Γ A)
_◄_ : {Γ : Cxt}{A B : Type Γ} -> B == A -> Term Γ A -> Term Γ B
B=A ◄ u = eqΠ refl B=A << u
_/ˢ_ : {Γ Δ : Cxt}{A : Type Γ} -> Term Γ A -> (σ : Δ ⇒ Γ) -> Term Δ (A / σ)
u /ˢ σ = u ∘ σ
_▷_ : (Γ : Cxt) -> Type Γ -> Cxt
Γ ▷ A = Σ Γ A
wk : {Γ : Cxt}(A : Type Γ) -> Γ ▷ A ⇒ Γ
wk A = ƛ fst \ x y x=y -> fst-eq x=y
vz : {Γ : Cxt}(A : Type Γ) -> Term (Γ ▷ A) (A / wk A)
vz A = ƛ snd \ x y x=y -> snd-eq x=y
ext : {Γ Δ : Cxt}(A : Type Γ)(σ : Δ ⇒ Γ)(u : Term Δ (A / σ)) -> Δ ⇒ Γ ▷ A
ext A σ u = ƛ (\x -> (σ # x , u # x))
\x y x=y -> eqInΣ refl (#-cong-R σ x=y) (#-cong-R u x=y)
lem-/-· : {Γ Δ Θ : Cxt}(A : Type Γ)(σ : Δ ⇒ Γ)(δ : Θ ⇒ Δ) ->
A / σ · δ == A / σ / δ
lem-/-· A σ δ = eqFam refl \x y x=y ->
!-cong-R A (sym (cast-id' _ (#-cong-R σ (#-cong-R δ (cast-id' _ (sym x=y))))))
lem-wk-∘-ext : {Γ Δ : Cxt}(A : Type Δ)(σ : Γ ⇒ Δ)(u : Term Γ (A / σ)) ->
wk A ∘ ext A σ u == σ
lem-wk-∘-ext A (ƛ σ pσ) u = eqInΠ refl pσ
lem-vz-/-ext : {Γ Δ : Cxt}(A : Type Δ)(σ : Γ ⇒ Δ)(u : Term Γ (A / σ)) ->
vz A /ˢ (ext A σ u) == u
lem-vz-/-ext A σ (ƛ u pu) = eqInΠ refl pu
-- (σ , u) ∘ δ == (σ ∘ δ , u / δ)
lem-ext-∘ : {Γ Δ Θ : Cxt}{A : Type Γ}(σ : Δ ⇒ Γ)(δ : Θ ⇒ Δ)(u : Term Δ (A / σ)) ->
ext A σ u · δ == ext A (σ · δ) (lem-/-· A σ δ ◄ u /ˢ δ)
lem-ext-∘ σ δ u = eqInΠ refl \x y x=y ->
eqInΣ refl
(cast-irr _ _ (#-cong-R σ (#-cong-R δ (cast-irr _ _ x=y))))
(cast-irr _ _ (#-cong-R u (#-cong-R δ (cast-irr _ _ x=y))))
<_> : {Γ : Cxt}{A : Type Γ} -> Term Γ A -> Γ ⇒ Γ ▷ A
< u > = ext _ id (lem-○-id ◄ u)
lift : {Γ Δ : Cxt}(A : Type Γ)(σ : Δ ⇒ Γ) -> Δ ▷ (A / σ) ⇒ Γ ▷ A
lift A σ = ƛ (\x -> σ # fst x , snd x)
\x y x=y -> eqInΣ refl (#-cong-R σ (fst-eq x=y)) (snd-eq x=y)
curryFam : {A : Setoid}{F : Fam A} -> Fam (Σ A F) -> (x : El A) -> Fam (F ! x)
curryFam G x = fam (\y -> G ! (x , y))
\z w z=w -> !-cong-R G (eqInΣ refl refl z=w)
Pi : {Γ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A)) -> Type Γ
Pi A B = fam (\x -> Π (A ! x) (curryFam B x))
\x y x=y ->
eqΠ (!-cong-R A (sym x=y))
(eqFam (!-cong-R A (sym x=y)) \z w z=w ->
!-cong-R B (eqInΣ refl x=y z=w)
)
lem-Pi-/ : {Γ Δ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A))(σ : Δ ⇒ Γ) ->
Pi A B / σ == Pi (A / σ) (B / lift A σ)
lem-Pi-/ A B σ = eqFam refl \x y x=y ->
eqΠ (Aσ-eq x=y)
(eqFam (Aσ-eq x=y) \z w z=w ->
!-cong-R B (eqInΣ refl (#-cong-R σ x=y) z=w)
)
where
Aσ-eq : forall {x y} -> x == y -> A ! σ # y == A ! σ # x
Aσ-eq x=y = !-cong-R A (#-cong-R σ (sym x=y))
lam : {Γ : Cxt}{A : Type Γ}{B : Type (Γ ▷ A)} -> Term (Γ ▷ A) B -> Term Γ (Pi A B)
lam {A = A} f =
ƛ (\γ -> ƛ (\x -> f # (γ , x)) (prf₁ γ)) prf₂
where
prf₁ : forall γ x y x=y -> _
prf₁ = \γ x y x=y -> #-cong-R f (eqInΣ refl refl x=y)
prf₂ = \x y x=y ->
eqInΠ (!-cong-R A (sym x=y)) \z w z=w ->
#-cong-R f (eqInΣ refl x=y z=w)
app : {Γ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A))
(v : Term Γ (Pi A B))(u : Term Γ A) -> Term Γ (B / < u >)
app A B v u = ƛ (\γ -> prf₁ γ << v # γ # (u # γ)) prf₂
where
lem : forall γ -> < u > # γ == (γ , u # γ)
lem γ = eqInΣ refl refl (#-cong (lem-○-id ◄ u) u (sym (cast-id _)) refl)
prf₁ : forall γ -> (B / < u >) ! γ == B ! (γ , u # γ)
prf₁ γ = !-cong-R B (lem γ)
prf₂ = \x y x=y -> cast-irr _ _ (#-cong (v # x) (v # y)
(#-cong-R v x=y)
(#-cong-R u x=y)
)
lem-β : {Γ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A))
(v : Term (Γ ▷ A) B)(u : Term Γ A) ->
app A B (lam v) u == v /ˢ < u >
lem-β A B v u = eqInΠ refl \x y x=y ->
sym (cast-id' _
(#-cong-R v
(eqInΣ refl (sym x=y)
(#-cong (lem-○-id ◄ u) u (sym (cast-id _)) (sym x=y)))
)
)
-- The stack blows when trying to prove η.
-- I'm not sure it does anymore, but I have no idea how to prove η,
-- I struggled just giving the type.
-- lem-η : {Γ : Cxt}(A : Type Γ)(B : Type (Γ ▷ A))
-- (v : Term Γ (Pi A B)) →
-- v == lam (app (A / wk A) (B / lift A (wk A)) (sym (lem-Pi-/ A B (wk A)) ◄ v /ˢ wk A) (vz A))
-- lem-η {Γ} A B (ƛ f pf) =
-- eqInΠ =S=-refl λ γ δ γ=δ →
-- proof f γ ≡ ƛ (_#_ (f γ)) (λ _ _ → #-cong-R (f γ)) by η (f γ)
-- ≡ _ by eqInΠ (!-cong-R A (sym γ=δ)) (λ x y x=y →
-- proof f γ # x
-- ≡ (_ << (_ << f (_ << δ))) # y by {!!}
-- qed)
-- qed
|
Formal statement is: lemma (in metric_space) totally_bounded_metric: "totally_bounded S \<longleftrightarrow> (\<forall>e>0. \<exists>k. finite k \<and> S \<subseteq> (\<Union>x\<in>k. {y. dist x y < e}))" Informal statement is: A metric space $X$ is totally bounded if and only if for every $\epsilon > 0$, there exists a finite set $K \subseteq X$ such that $X \subseteq \bigcup_{x \in K} B(x, \epsilon)$. |
Formal statement is: lemma restrict_count_space: "restrict_space (count_space B) A = count_space (A \<inter> B)" Informal statement is: The restriction of a countable space to a subset is a countable space. |
[STATEMENT]
lemma fine_rsum_const: "fine \<delta> (a,b) D \<Longrightarrow> rsum D (\<lambda>x. c) = (c * (b - a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fine \<delta> (a, b) D \<Longrightarrow> rsum D (\<lambda>x. c) = c * (b - a)
[PROOF STEP]
unfolding rsum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. fine \<delta> (a, b) D \<Longrightarrow> (\<Sum>(u, x, v)\<leftarrow>D. c * (v - u)) = c * (b - a)
[PROOF STEP]
by (induct set: fine, auto simp add: algebra_simps) |
Formal statement is: lemma frontier_cbox: fixes a b :: "'a::euclidean_space" shows "frontier (cbox a b) = cbox a b - box a b" Informal statement is: The frontier of a closed box is the boundary of the box. |
open import Data.Product using ( _×_ ; _,_ )
open import Data.Sum using ( _⊎_ )
open import Relation.Unary using ( _∈_ ; _∉_ )
open import Web.Semantic.DL.FOL using ( Formula ; true ; false ; _∧_ ; _∈₁_ ; _∈₁_⇒_ ; _∈₂_ ; _∈₂_⇒_ ; _∼_ ; _∼_⇒_ ; ∀₁ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox.Interp using ( Interp ; Δ ; _⊨_≈_ ; con ; rol )
open import Web.Semantic.Util using ( True ; False )
module Web.Semantic.DL.FOL.Model {Σ : Signature} where
_⊨f_ : (I : Interp Σ) → Formula Σ (Δ I) → Set
I ⊨f true = True
I ⊨f false = False
I ⊨f (F ∧ G) = (I ⊨f F) × (I ⊨f G)
I ⊨f (x ∈₁ c) = x ∈ (con I c)
I ⊨f (x ∈₁ c ⇒ F) = (x ∈ (con I c)) → (I ⊨f F)
I ⊨f ((x , y) ∈₂ r) = (x , y) ∈ (rol I r)
I ⊨f ((x , y) ∈₂ r ⇒ F) = ((x , y) ∈ (rol I r)) → (I ⊨f F)
I ⊨f (x ∼ y) = I ⊨ x ≈ y
I ⊨f (x ∼ y ⇒ F) = (I ⊨ x ≈ y) → (I ⊨f F)
I ⊨f ∀₁ F = ∀ x → (I ⊨f F x)
|
{-# OPTIONS --without-K --safe #-}
open import Level using (Level)
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_)
open import Data.Nat using (ℕ; suc; zero)
open import Data.Empty using (⊥)
open import Data.Vec using (Vec)
renaming ([] to []ⱽ; _∷_ to _∷ⱽ_)
module FLA.Data.Vec+.Base where
private
variable
ℓ : Level
A : Set ℓ
n : ℕ
-- TODO: Can this be replaced with something like the List⁺ definition so that
-- the proofs from Vec can be transferred? This definition is convenient because
-- the size is correct (it is not n - 1).
data Vec⁺ (A : Set ℓ) : ℕ → Set ℓ where
[_] : A → Vec⁺ A 1
_∷_ : ∀ {n} (x : A) (xs : Vec⁺ A n) → Vec⁺ A (suc n)
infixr 5 _∷_
-- Want to prove that is it not possible to construct an empty vector
emptyVecImpossible : Vec⁺ A 0 → ⊥
emptyVecImpossible = λ ()
Vec⁺→Vec : Vec⁺ A n → Vec A n
Vec⁺→Vec [ v ] = v ∷ⱽ []ⱽ
Vec⁺→Vec (v ∷ vs⁺) = v ∷ⱽ Vec⁺→Vec vs⁺
Vec⁺→n≢0 : Vec⁺ A n → n ≢ 0
Vec⁺→n≢0 {ℓ} {A} {suc n} v = suc≢0
where
suc≢0 : {n : ℕ} → suc n ≢ 0
suc≢0 {zero} ()
suc≢0 {suc n} = λ ()
-- Closer maybe but still buggered
-- Vec→Vec⁺ : ∀ {ℓ} → {A : Set ℓ} {n : ℕ} → (n ≢ 0) → Vec A n → Vec⁺ A n
-- Vec→Vec⁺ {ℓ} {A} {0} p []ⱽ = ⊥-elim (p refl)
-- Vec→Vec⁺ {ℓ} {A} {1} p (x ∷ⱽ []ⱽ) = [ x ]
-- Vec→Vec⁺ {ℓ} {A} {suc n} p (x ∷ⱽ xs) = x ∷ (Vec→Vec⁺ {!!} xs)
|
/-
Copyright (c) 2020 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import deprecated.group
/-!
# Unbundled semiring and ring homomorphisms (deprecated)
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file is deprecated, and is no longer imported by anything in mathlib other than other
deprecated files, and test files. You should not need to import it.
This file defines predicates for unbundled semiring and ring homomorphisms. Instead of using
this file, please use `ring_hom`, defined in `algebra.hom.ring`, with notation `→+*`, for
morphisms between semirings or rings. For example use `φ : A →+* B` to represent a
ring homomorphism.
## Main Definitions
`is_semiring_hom` (deprecated), `is_ring_hom` (deprecated)
## Tags
is_semiring_hom, is_ring_hom
-/
universes u v w
variable {α : Type u}
/-- Predicate for semiring homomorphisms (deprecated -- use the bundled `ring_hom` version). -/
structure is_semiring_hom {α : Type u} {β : Type v} [semiring α] [semiring β] (f : α → β) : Prop :=
(map_zero [] : f 0 = 0)
(map_one [] : f 1 = 1)
(map_add [] : ∀ {x y}, f (x + y) = f x + f y)
(map_mul [] : ∀ {x y}, f (x * y) = f x * f y)
namespace is_semiring_hom
variables {β : Type v} [semiring α] [semiring β]
variables {f : α → β} (hf : is_semiring_hom f) {x y : α}
/-- The identity map is a semiring homomorphism. -/
lemma id : is_semiring_hom (@id α) := by refine {..}; intros; refl
/-- The composition of two semiring homomorphisms is a semiring homomorphism. -/
lemma comp (hf : is_semiring_hom f) {γ} [semiring γ] {g : β → γ} (hg : is_semiring_hom g) :
is_semiring_hom (g ∘ f) :=
{ map_zero := by simpa [map_zero hf] using map_zero hg,
map_one := by simpa [map_one hf] using map_one hg,
map_add := λ x y, by simp [map_add hf, map_add hg],
map_mul := λ x y, by simp [map_mul hf, map_mul hg] }
/-- A semiring homomorphism is an additive monoid homomorphism. -/
lemma to_is_add_monoid_hom (hf : is_semiring_hom f) : is_add_monoid_hom f :=
{ ..‹is_semiring_hom f› }
/-- A semiring homomorphism is a monoid homomorphism. -/
lemma to_is_monoid_hom (hf : is_semiring_hom f) : is_monoid_hom f :=
{ ..‹is_semiring_hom f› }
end is_semiring_hom
/-- Predicate for ring homomorphisms (deprecated -- use the bundled `ring_hom` version). -/
structure is_ring_hom {α : Type u} {β : Type v} [ring α] [ring β] (f : α → β) : Prop :=
(map_one [] : f 1 = 1)
(map_mul [] : ∀ {x y}, f (x * y) = f x * f y)
(map_add [] : ∀ {x y}, f (x + y) = f x + f y)
namespace is_ring_hom
variables {β : Type v} [ring α] [ring β]
/-- A map of rings that is a semiring homomorphism is also a ring homomorphism. -/
lemma of_semiring {f : α → β} (H : is_semiring_hom f) : is_ring_hom f := {..H}
variables {f : α → β} (hf : is_ring_hom f) {x y : α}
/-- Ring homomorphisms map zero to zero. -/
lemma map_zero (hf : is_ring_hom f) : f 0 = 0 :=
calc f 0 = f (0 + 0) - f 0 : by rw [hf.map_add]; simp
... = 0 : by simp
/-- Ring homomorphisms preserve additive inverses. -/
lemma map_neg (hf : is_ring_hom f) : f (-x) = -f x :=
calc f (-x) = f (-x + x) - f x : by rw [hf.map_add]; simp
... = -f x : by simp [hf.map_zero]
/-- Ring homomorphisms preserve subtraction. -/
lemma map_sub (hf : is_ring_hom f) : f (x - y) = f x - f y :=
by simp [sub_eq_add_neg, hf.map_add, hf.map_neg]
/-- The identity map is a ring homomorphism. -/
lemma id : is_ring_hom (@id α) := by refine {..}; intros; refl
/-- The composition of two ring homomorphisms is a ring homomorphism. -/
-- see Note [no instance on morphisms]
lemma comp (hf : is_ring_hom f) {γ} [ring γ] {g : β → γ} (hg : is_ring_hom g) :
is_ring_hom (g ∘ f) :=
{ map_add := λ x y, by simp [map_add hf]; rw map_add hg; refl,
map_mul := λ x y, by simp [map_mul hf]; rw map_mul hg; refl,
map_one := by simp [map_one hf]; exact map_one hg }
/-- A ring homomorphism is also a semiring homomorphism. -/
lemma to_is_semiring_hom (hf : is_ring_hom f) : is_semiring_hom f :=
{ map_zero := map_zero hf, ..‹is_ring_hom f› }
lemma to_is_add_group_hom (hf : is_ring_hom f) : is_add_group_hom f :=
{ map_add := λ _ _, hf.map_add }
end is_ring_hom
variables {β : Type v} {γ : Type w} [rα : semiring α] [rβ : semiring β]
namespace ring_hom
section
include rα rβ
/-- Interpret `f : α → β` with `is_semiring_hom f` as a ring homomorphism. -/
def of {f : α → β} (hf : is_semiring_hom f) : α →+* β :=
{ to_fun := f,
.. monoid_hom.of hf.to_is_monoid_hom,
.. add_monoid_hom.of hf.to_is_add_monoid_hom }
@[simp] lemma coe_of {f : α → β} (hf : is_semiring_hom f) : ⇑(of hf) = f := rfl
lemma to_is_semiring_hom (f : α →+* β) : is_semiring_hom f :=
{ map_zero := f.map_zero,
map_one := f.map_one,
map_add := f.map_add,
map_mul := f.map_mul }
end
lemma to_is_ring_hom {α γ} [ring α] [ring γ] (g : α →+* γ) : is_ring_hom g :=
is_ring_hom.of_semiring g.to_is_semiring_hom
end ring_hom
|
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-/
import algebra.invertible
import linear_algebra.matrix.determinant
import linear_algebra.matrix.bilinear_form
import linear_algebra.matrix.symmetric
/-!
# Quadratic forms
This file defines quadratic forms over a `R`-module `M`.
A quadratic form on a ring `R` is a map `Q : M → R` such that:
* `quadratic_form.map_smul`: `Q (a • x) = a * a * Q x`
* `quadratic_form.polar_add_left`, `quadratic_form.polar_add_right`,
`quadratic_form.polar_smul_left`, `quadratic_form.polar_smul_right`:
the map `quadratic_form.polar Q := λ x y, Q (x + y) - Q x - Q y` is bilinear.
This notion generalizes to semirings using the approach in [izhakian2016][] which requires that
there be a (possibly non-unique) companion bilinear form `B` such that
`∀ x y, Q (x + y) = Q x + Q y + B x y`. Over a ring, this `B` is precisely `quadratic_form.polar Q`.
To build a `quadratic_form` from the `polar` axioms, use `quadratic_form.of_polar`.
Quadratic forms come with a scalar multiplication, `(a • Q) x = Q (a • x) = a * a * Q x`,
and composition with linear maps `f`, `Q.comp f x = Q (f x)`.
## Main definitions
* `quadratic_form.of_polar`: a more familiar constructor that works on rings
* `quadratic_form.associated`: associated bilinear form
* `quadratic_form.pos_def`: positive definite quadratic forms
* `quadratic_form.anisotropic`: anisotropic quadratic forms
* `quadratic_form.discr`: discriminant of a quadratic form
## Main statements
* `quadratic_form.associated_left_inverse`,
* `quadratic_form.associated_right_inverse`: in a commutative ring where 2 has
an inverse, there is a correspondence between quadratic forms and symmetric
bilinear forms
* `bilin_form.exists_orthogonal_basis`: There exists an orthogonal basis with
respect to any nondegenerate, symmetric bilinear form `B`.
## Notation
In this file, the variable `R` is used when a `ring` structure is sufficient and
`R₁` is used when specifically a `comm_ring` is required. This allows us to keep
`[module R M]` and `[module R₁ M]` assumptions in the variables without
confusion between `*` from `ring` and `*` from `comm_ring`.
The variable `S` is used when `R` itself has a `•` action.
## References
* https://en.wikipedia.org/wiki/Quadratic_form
* https://en.wikipedia.org/wiki/Discriminant#Quadratic_forms
## Tags
quadratic form, homogeneous polynomial, quadratic polynomial
-/
universes u v w
variables {S : Type*}
variables {R R₁: Type*} {M : Type*}
open_locale big_operators
section polar
variables [ring R] [comm_ring R₁] [add_comm_group M]
namespace quadratic_form
/-- Up to a factor 2, `Q.polar` is the associated bilinear form for a quadratic form `Q`.
Source of this name: https://en.wikipedia.org/wiki/Quadratic_form#Generalization
-/
def polar (f : M → R) (x y : M) :=
f (x + y) - f x - f y
lemma polar_add (f g : M → R) (x y : M) :
polar (f + g) x y = polar f x y + polar g x y :=
by { simp only [polar, pi.add_apply], abel }
lemma polar_neg (f : M → R) (x y : M) :
polar (-f) x y = - polar f x y :=
by { simp only [polar, pi.neg_apply, sub_eq_add_neg, neg_add] }
lemma polar_smul [monoid S] [distrib_mul_action S R] (f : M → R) (s : S) (x y : M) :
polar (s • f) x y = s • polar f x y :=
by { simp only [polar, pi.smul_apply, smul_sub] }
lemma polar_comm (f : M → R) (x y : M) : polar f x y = polar f y x :=
by rw [polar, polar, add_comm, sub_sub, sub_sub, add_comm (f x) (f y)]
/-- Auxiliary lemma to express bilinearity of `quadratic_form.polar` without subtraction. -/
lemma polar_add_left_iff {f : M → R} {x x' y : M} :
polar f (x + x') y = polar f x y + polar f x' y ↔
f (x + x' + y) + (f x + f x' + f y) = f (x + x') + f (x' + y) + f (y + x) :=
begin
simp only [←add_assoc],
simp only [polar, sub_eq_iff_eq_add, eq_sub_iff_add_eq, sub_add_eq_add_sub, add_sub],
simp only [add_right_comm _ (f y) _, add_right_comm _ (f x') (f x)],
rw [add_comm y x, add_right_comm _ _ (f (x + y)), add_comm _ (f (x + y)),
add_right_comm (f (x + y)), add_left_inj],
end
lemma polar_comp {F : Type*} [ring S] [add_monoid_hom_class F R S] (f : M → R) (g : F) (x y : M) :
polar (g ∘ f) x y = g (polar f x y) :=
by simp only [polar, pi.smul_apply, function.comp_apply, map_sub]
end quadratic_form
end polar
/-- A quadratic form over a module.
For a more familiar constructor when `R` is a ring, see `quadratic_form.of_polar`. -/
structure quadratic_form (R : Type u) (M : Type v) [semiring R] [add_comm_monoid M] [module R M] :=
(to_fun : M → R)
(to_fun_smul : ∀ (a : R) (x : M), to_fun (a • x) = a * a * to_fun x)
(exists_companion' : ∃ B : bilin_form R M, ∀ x y, to_fun (x + y) = to_fun x + to_fun y + B x y)
namespace quadratic_form
section fun_like
variables [semiring R] [add_comm_monoid M] [module R M]
variables {Q Q' : quadratic_form R M}
instance fun_like : fun_like (quadratic_form R M) M (λ _, R) :=
{ coe := to_fun,
coe_injective' := λ x y h, by cases x; cases y; congr' }
/-- Helper instance for when there's too many metavariables to apply
`fun_like.has_coe_to_fun` directly. -/
instance : has_coe_to_fun (quadratic_form R M) (λ _, M → R) := ⟨to_fun⟩
variables (Q)
/-- The `simp` normal form for a quadratic form is `coe_fn`, not `to_fun`. -/
@[simp] lemma to_fun_eq_coe : Q.to_fun = ⇑Q := rfl
-- this must come after the coe_to_fun definition
initialize_simps_projections quadratic_form (to_fun → apply)
variables {Q}
@[ext] lemma ext (H : ∀ (x : M), Q x = Q' x) : Q = Q' := fun_like.ext _ _ H
lemma congr_fun (h : Q = Q') (x : M) : Q x = Q' x := fun_like.congr_fun h _
lemma ext_iff : Q = Q' ↔ (∀ x, Q x = Q' x) := fun_like.ext_iff
/-- Copy of a `quadratic_form` with a new `to_fun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (Q : quadratic_form R M) (Q' : M → R) (h : Q' = ⇑Q) : quadratic_form R M :=
{ to_fun := Q',
to_fun_smul := h.symm ▸ Q.to_fun_smul,
exists_companion' := h.symm ▸ Q.exists_companion' }
@[simp]
lemma coe_copy (Q : quadratic_form R M) (Q' : M → R) (h : Q' = ⇑Q) : ⇑(Q.copy Q' h) = Q' := rfl
lemma copy_eq (Q : quadratic_form R M) (Q' : M → R) (h : Q' = ⇑Q) : Q.copy Q' h = Q :=
fun_like.ext' h
end fun_like
section semiring
variables [semiring R] [add_comm_monoid M] [module R M]
variables (Q : quadratic_form R M)
lemma map_smul (a : R) (x : M) : Q (a • x) = a * a * Q x := Q.to_fun_smul a x
lemma exists_companion : ∃ B : bilin_form R M, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
Q.exists_companion'
lemma map_add_add_add_map (x y z : M) :
Q (x + y + z) + (Q x + Q y + Q z) = Q (x + y) + Q (y + z) + Q (z + x) :=
begin
obtain ⟨B, h⟩ := Q.exists_companion,
rw [add_comm z x],
simp [h],
abel,
end
lemma map_add_self (x : M) : Q (x + x) = 4 * Q x :=
by { rw [←one_smul R x, ←add_smul, map_smul], norm_num }
@[simp] lemma map_zero : Q 0 = 0 :=
by rw [←@zero_smul R _ _ _ _ (0 : M), map_smul, zero_mul, zero_mul]
instance zero_hom_class : zero_hom_class (quadratic_form R M) M R :=
{ map_zero := map_zero,
..quadratic_form.fun_like }
lemma map_smul_of_tower [comm_semiring S] [algebra S R] [module S M] [is_scalar_tower S R M]
(a : S) (x : M) :
Q (a • x) = (a * a) • Q x :=
by rw [←is_scalar_tower.algebra_map_smul R a x, map_smul, ←ring_hom.map_mul, algebra.smul_def]
end semiring
section ring
variables [ring R] [comm_ring R₁] [add_comm_group M]
variables [module R M] (Q : quadratic_form R M)
@[simp] lemma map_neg (x : M) : Q (-x) = Q x :=
by rw [←@neg_one_smul R _ _ _ _ x, map_smul, neg_one_mul, neg_neg, one_mul]
lemma map_sub (x y : M) : Q (x - y) = Q (y - x) :=
by rw [←neg_sub, map_neg]
@[simp]
lemma polar_zero_left (y : M) : polar Q 0 y = 0 :=
by simp only [polar, zero_add, quadratic_form.map_zero, sub_zero, sub_self]
@[simp]
lemma polar_add_left (x x' y : M) :
polar Q (x + x') y = polar Q x y + polar Q x' y :=
polar_add_left_iff.mpr $ Q.map_add_add_add_map x x' y
@[simp]
lemma polar_smul_left (a : R) (x y : M) :
polar Q (a • x) y = a * polar Q x y :=
begin
obtain ⟨B, h⟩ := Q.exists_companion,
simp_rw [polar, h, Q.map_smul, bilin_form.smul_left, sub_sub, add_sub_cancel'],
end
@[simp]
lemma polar_neg_left (x y : M) :
polar Q (-x) y = -polar Q x y :=
by rw [←neg_one_smul R x, polar_smul_left, neg_one_mul]
@[simp]
lemma polar_sub_left (x x' y : M) :
polar Q (x - x') y = polar Q x y - polar Q x' y :=
by rw [sub_eq_add_neg, sub_eq_add_neg, polar_add_left, polar_neg_left]
@[simp]
lemma polar_zero_right (y : M) : polar Q y 0 = 0 :=
by simp only [add_zero, polar, quadratic_form.map_zero, sub_self]
@[simp]
lemma polar_add_right (x y y' : M) :
polar Q x (y + y') = polar Q x y + polar Q x y' :=
by rw [polar_comm Q x, polar_comm Q x, polar_comm Q x, polar_add_left]
@[simp]
lemma polar_smul_right (a : R) (x y : M) :
polar Q x (a • y) = a * polar Q x y :=
by rw [polar_comm Q x, polar_comm Q x, polar_smul_left]
@[simp]
lemma polar_neg_right (x y : M) :
polar Q x (-y) = -polar Q x y :=
by rw [←neg_one_smul R y, polar_smul_right, neg_one_mul]
@[simp]
lemma polar_sub_right (x y y' : M) :
polar Q x (y - y') = polar Q x y - polar Q x y' :=
by rw [sub_eq_add_neg, sub_eq_add_neg, polar_add_right, polar_neg_right]
@[simp]
lemma polar_self (x : M) : polar Q x x = 2 * Q x :=
begin
rw [polar, map_add_self, sub_sub, sub_eq_iff_eq_add, ←two_mul, ←two_mul, ←mul_assoc],
norm_num
end
/-- `quadratic_form.polar` as a bilinear form -/
@[simps]
def polar_bilin : bilin_form R M :=
{ bilin := polar Q,
bilin_add_left := polar_add_left Q,
bilin_smul_left := polar_smul_left Q,
bilin_add_right := λ x y z, by simp_rw [polar_comm _ x, polar_add_left Q],
bilin_smul_right := λ r x y, by simp_rw [polar_comm _ x, polar_smul_left Q] }
variables [comm_semiring S] [algebra S R] [module S M] [is_scalar_tower S R M]
@[simp]
lemma polar_smul_left_of_tower (a : S) (x y : M) :
polar Q (a • x) y = a • polar Q x y :=
by rw [←is_scalar_tower.algebra_map_smul R a x, polar_smul_left, algebra.smul_def]
@[simp]
lemma polar_smul_right_of_tower (a : S) (x y : M) :
polar Q x (a • y) = a • polar Q x y :=
by rw [←is_scalar_tower.algebra_map_smul R a y, polar_smul_right, algebra.smul_def]
/-- An alternative constructor to `quadratic_form.mk`, for rings where `polar` can be used. -/
@[simps]
def of_polar (to_fun : M → R) (to_fun_smul : ∀ (a : R) (x : M), to_fun (a • x) = a * a * to_fun x)
(polar_add_left : ∀ (x x' y : M), polar to_fun (x + x') y = polar to_fun x y + polar to_fun x' y)
(polar_smul_left : ∀ (a : R) (x y : M), polar to_fun (a • x) y = a • polar to_fun x y) :
quadratic_form R M :=
{ to_fun := to_fun,
to_fun_smul := to_fun_smul,
exists_companion' := ⟨
{ bilin := polar to_fun,
bilin_add_left := polar_add_left,
bilin_smul_left := polar_smul_left,
bilin_add_right := λ x y z, by simp_rw [polar_comm _ x, polar_add_left],
bilin_smul_right := λ r x y, by simp_rw [polar_comm _ x, polar_smul_left, smul_eq_mul] },
λ x y, by rw [bilin_form.coe_fn_mk, polar, sub_sub, add_sub_cancel'_right]⟩ }
/-- In a ring the companion bilinear form is unique and equal to `quadratic_form.polar`. -/
lemma some_exists_companion : Q.exists_companion.some = polar_bilin Q :=
bilin_form.ext $ λ x y,
by rw [polar_bilin_apply, polar, Q.exists_companion.some_spec, sub_sub, add_sub_cancel']
end ring
section semiring_operators
variables [semiring R] [add_comm_monoid M] [module R M]
section has_smul
variables [monoid S] [distrib_mul_action S R] [smul_comm_class S R R]
/-- `quadratic_form R M` inherits the scalar action from any algebra over `R`.
When `R` is commutative, this provides an `R`-action via `algebra.id`. -/
instance : has_smul S (quadratic_form R M) :=
⟨ λ a Q,
{ to_fun := a • Q,
to_fun_smul := λ b x, by rw [pi.smul_apply, map_smul, pi.smul_apply, mul_smul_comm],
exists_companion' := let ⟨B, h⟩ := Q.exists_companion in ⟨a • B,
by simp [h]⟩ } ⟩
@[simp] lemma coe_fn_smul (a : S) (Q : quadratic_form R M) : ⇑(a • Q) = a • Q := rfl
@[simp] lemma smul_apply (a : S) (Q : quadratic_form R M) (x : M) :
(a • Q) x = a • Q x := rfl
end has_smul
instance : has_zero (quadratic_form R M) :=
⟨ { to_fun := λ x, 0,
to_fun_smul := λ a x, by simp only [mul_zero],
exists_companion' := ⟨0, λ x y, by simp only [add_zero, bilin_form.zero_apply]⟩ } ⟩
@[simp] lemma coe_fn_zero : ⇑(0 : quadratic_form R M) = 0 := rfl
@[simp] lemma zero_apply (x : M) : (0 : quadratic_form R M) x = 0 := rfl
instance : inhabited (quadratic_form R M) := ⟨0⟩
instance : has_add (quadratic_form R M) :=
⟨ λ Q Q',
{ to_fun := Q + Q',
to_fun_smul := λ a x,
by simp only [pi.add_apply, map_smul, mul_add],
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion, ⟨B', h'⟩ := Q'.exists_companion in
⟨B + B', λ x y, by simp_rw [pi.add_apply, h, h', bilin_form.add_apply, add_add_add_comm] ⟩ } ⟩
@[simp] lemma coe_fn_add (Q Q' : quadratic_form R M) : ⇑(Q + Q') = Q + Q' := rfl
@[simp] lemma add_apply (Q Q' : quadratic_form R M) (x : M) : (Q + Q') x = Q x + Q' x := rfl
instance : add_comm_monoid (quadratic_form R M) :=
fun_like.coe_injective.add_comm_monoid _ coe_fn_zero coe_fn_add (λ _ _, coe_fn_smul _ _)
/-- `@coe_fn (quadratic_form R M)` as an `add_monoid_hom`.
This API mirrors `add_monoid_hom.coe_fn`. -/
@[simps apply]
def coe_fn_add_monoid_hom : quadratic_form R M →+ (M → R) :=
{ to_fun := coe_fn, map_zero' := coe_fn_zero, map_add' := coe_fn_add }
/-- Evaluation on a particular element of the module `M` is an additive map over quadratic forms. -/
@[simps apply]
def eval_add_monoid_hom (m : M) : quadratic_form R M →+ R :=
(pi.eval_add_monoid_hom _ m).comp coe_fn_add_monoid_hom
section sum
@[simp] lemma coe_fn_sum {ι : Type*} (Q : ι → quadratic_form R M) (s : finset ι) :
⇑(∑ i in s, Q i) = ∑ i in s, Q i :=
(coe_fn_add_monoid_hom : _ →+ (M → R)).map_sum Q s
@[simp] lemma sum_apply {ι : Type*} (Q : ι → quadratic_form R M) (s : finset ι) (x : M) :
(∑ i in s, Q i) x = ∑ i in s, Q i x :=
(eval_add_monoid_hom x : _ →+ R).map_sum Q s
end sum
instance [monoid S] [distrib_mul_action S R] [smul_comm_class S R R] :
distrib_mul_action S (quadratic_form R M) :=
{ mul_smul := λ a b Q, ext (λ x, by simp only [smul_apply, mul_smul]),
one_smul := λ Q, ext (λ x, by simp only [quadratic_form.smul_apply, one_smul]),
smul_add := λ a Q Q', by { ext, simp only [add_apply, smul_apply, smul_add] },
smul_zero := λ a, by { ext, simp only [zero_apply, smul_apply, smul_zero] }, }
instance [semiring S] [module S R] [smul_comm_class S R R] : module S (quadratic_form R M) :=
{ zero_smul := λ Q, by { ext, simp only [zero_apply, smul_apply, zero_smul] },
add_smul := λ a b Q, by { ext, simp only [add_apply, smul_apply, add_smul] } }
end semiring_operators
section ring_operators
variables [ring R] [add_comm_group M] [module R M]
instance : has_neg (quadratic_form R M) :=
⟨ λ Q,
{ to_fun := -Q,
to_fun_smul := λ a x,
by simp only [pi.neg_apply, map_smul, mul_neg],
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion in
⟨-B, λ x y, by simp_rw [pi.neg_apply, h, bilin_form.neg_apply, neg_add] ⟩ } ⟩
@[simp] lemma coe_fn_neg (Q : quadratic_form R M) : ⇑(-Q) = -Q := rfl
@[simp] lemma neg_apply (Q : quadratic_form R M) (x : M) : (-Q) x = -Q x := rfl
instance : has_sub (quadratic_form R M) :=
⟨ λ Q Q', (Q + -Q').copy (Q - Q') (sub_eq_add_neg _ _) ⟩
@[simp] lemma coe_fn_sub (Q Q' : quadratic_form R M) : ⇑(Q - Q') = Q - Q' := rfl
@[simp] lemma sub_apply (Q Q' : quadratic_form R M) (x : M) : (Q - Q') x = Q x - Q' x := rfl
instance : add_comm_group (quadratic_form R M) :=
fun_like.coe_injective.add_comm_group _
coe_fn_zero coe_fn_add coe_fn_neg coe_fn_sub (λ _ _, coe_fn_smul _ _) (λ _ _, coe_fn_smul _ _)
end ring_operators
section comp
variables [semiring R] [add_comm_monoid M] [module R M]
variables {N : Type v} [add_comm_monoid N] [module R N]
/-- Compose the quadratic form with a linear function. -/
def comp (Q : quadratic_form R N) (f : M →ₗ[R] N) :
quadratic_form R M :=
{ to_fun := λ x, Q (f x),
to_fun_smul := λ a x, by simp only [map_smul, f.map_smul],
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion in
⟨B.comp f f, λ x y, by simp_rw [f.map_add, h, bilin_form.comp_apply]⟩ }
@[simp] lemma comp_apply (Q : quadratic_form R N) (f : M →ₗ[R] N) (x : M) :
(Q.comp f) x = Q (f x) := rfl
/-- Compose a quadratic form with a linear function on the left. -/
@[simps {simp_rhs := tt}]
def _root_.linear_map.comp_quadratic_form {S : Type*}
[comm_semiring S] [algebra S R] [module S M] [is_scalar_tower S R M]
(f : R →ₗ[S] S) (Q : quadratic_form R M) :
quadratic_form S M :=
{ to_fun := λ x, f (Q x),
to_fun_smul := λ b x, by rw [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul],
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion in
⟨f.comp_bilin_form B, λ x y, by simp_rw [h, f.map_add, linear_map.comp_bilin_form_apply]⟩ }
end comp
section comm_ring
variables [comm_semiring R] [add_comm_monoid M] [module R M]
/-- The product of linear forms is a quadratic form. -/
def lin_mul_lin (f g : M →ₗ[R] R) : quadratic_form R M :=
{ to_fun := f * g,
to_fun_smul := λ a x,
by { simp only [smul_eq_mul, ring_hom.id_apply, pi.mul_apply, linear_map.map_smulₛₗ], ring },
exists_companion' := ⟨
bilin_form.lin_mul_lin f g + bilin_form.lin_mul_lin g f, λ x y, by { simp, ring }⟩ }
@[simp]
lemma lin_mul_lin_apply (f g : M →ₗ[R] R) (x) : lin_mul_lin f g x = f x * g x := rfl
@[simp]
lemma add_lin_mul_lin (f g h : M →ₗ[R] R) :
lin_mul_lin (f + g) h = lin_mul_lin f h + lin_mul_lin g h :=
ext (λ x, add_mul _ _ _)
@[simp]
lemma lin_mul_lin_add (f g h : M →ₗ[R] R) :
lin_mul_lin f (g + h) = lin_mul_lin f g + lin_mul_lin f h :=
ext (λ x, mul_add _ _ _)
variables {N : Type v} [add_comm_monoid N] [module R N]
@[simp]
lemma lin_mul_lin_comp (f g : M →ₗ[R] R) (h : N →ₗ[R] M) :
(lin_mul_lin f g).comp h = lin_mul_lin (f.comp h) (g.comp h) :=
rfl
variables {n : Type*}
/-- `sq` is the quadratic form mapping the vector `x : R₁` to `x * x` -/
@[simps]
def sq : quadratic_form R R :=
lin_mul_lin linear_map.id linear_map.id
/-- `proj i j` is the quadratic form mapping the vector `x : n → R₁` to `x i * x j` -/
def proj (i j : n) : quadratic_form R (n → R) :=
lin_mul_lin (@linear_map.proj _ _ _ (λ _, R) _ _ i) (@linear_map.proj _ _ _ (λ _, R) _ _ j)
@[simp]
lemma proj_apply (i j : n) (x : n → R) : proj i j x = x i * x j := rfl
end comm_ring
end quadratic_form
/-!
### Associated bilinear forms
Over a commutative ring with an inverse of 2, the theory of quadratic forms is
basically identical to that of symmetric bilinear forms. The map from quadratic
forms to bilinear forms giving this identification is called the `associated`
quadratic form.
-/
namespace bilin_form
open quadratic_form
section semiring
variables [semiring R] [add_comm_monoid M] [module R M]
variables {B : bilin_form R M}
/-- A bilinear form gives a quadratic form by applying the argument twice. -/
def to_quadratic_form (B : bilin_form R M) : quadratic_form R M :=
{ to_fun := λ x, B x x,
to_fun_smul := λ a x, by simp only [mul_assoc, smul_right, smul_left],
exists_companion' :=
⟨B + bilin_form.flip_hom ℕ B, λ x y, by { simp [add_add_add_comm, add_comm] }⟩ }
@[simp] lemma to_quadratic_form_apply (B : bilin_form R M) (x : M) :
B.to_quadratic_form x = B x x :=
rfl
section
variables (R M)
@[simp] lemma to_quadratic_form_zero : (0 : bilin_form R M).to_quadratic_form = 0 := rfl
end
@[simp] lemma to_quadratic_form_add (B₁ B₂ : bilin_form R M) :
(B₁ + B₂).to_quadratic_form = B₁.to_quadratic_form + B₂.to_quadratic_form := rfl
@[simp] lemma to_quadratic_form_smul [monoid S] [distrib_mul_action S R] [smul_comm_class S R R]
(a : S) (B : bilin_form R M) :
(a • B).to_quadratic_form = a • B.to_quadratic_form := rfl
section
variables (R M)
/-- `bilin_form.to_quadratic_form` as an additive homomorphism -/
@[simps] def to_quadratic_form_add_monoid_hom : bilin_form R M →+ quadratic_form R M :=
{ to_fun := to_quadratic_form,
map_zero' := to_quadratic_form_zero _ _,
map_add' := to_quadratic_form_add }
end
@[simp] lemma to_quadratic_form_list_sum (B : list (bilin_form R M)) :
B.sum.to_quadratic_form = (B.map to_quadratic_form).sum :=
map_list_sum (to_quadratic_form_add_monoid_hom R M) B
@[simp] lemma to_quadratic_form_multiset_sum (B : multiset (bilin_form R M)) :
B.sum.to_quadratic_form = (B.map to_quadratic_form).sum :=
map_multiset_sum (to_quadratic_form_add_monoid_hom R M) B
@[simp] lemma to_quadratic_form_sum {ι : Type*} (s : finset ι) (B : ι → bilin_form R M) :
(∑ i in s, B i).to_quadratic_form = ∑ i in s, (B i).to_quadratic_form :=
map_sum (to_quadratic_form_add_monoid_hom R M) B s
@[simp] lemma to_quadratic_form_eq_zero {B : bilin_form R M} :
B.to_quadratic_form = 0 ↔ B.is_alt :=
quadratic_form.ext_iff
end semiring
section ring
variables [ring R] [add_comm_group M] [module R M]
variables {B : bilin_form R M}
lemma polar_to_quadratic_form (x y : M) : polar (λ x, B x x) x y = B x y + B y x :=
by { simp only [add_assoc, add_sub_cancel', add_right, polar, add_left_inj, add_neg_cancel_left,
add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _] }
@[simp] lemma to_quadratic_form_neg (B : bilin_form R M) :
(-B).to_quadratic_form = -B.to_quadratic_form := rfl
@[simp] lemma to_quadratic_form_sub (B₁ B₂ : bilin_form R M) :
(B₁ - B₂).to_quadratic_form = B₁.to_quadratic_form - B₂.to_quadratic_form := rfl
end ring
end bilin_form
namespace quadratic_form
open bilin_form
section associated_hom
variables [ring R] [comm_ring R₁] [add_comm_group M] [module R M] [module R₁ M]
variables (S) [comm_semiring S] [algebra S R]
variables [invertible (2 : R)] {B₁ : bilin_form R M}
/-- `associated_hom` is the map that sends a quadratic form on a module `M` over `R` to its
associated symmetric bilinear form. As provided here, this has the structure of an `S`-linear map
where `S` is a commutative subring of `R`.
Over a commutative ring, use `associated`, which gives an `R`-linear map. Over a general ring with
no nontrivial distinguished commutative subring, use `associated'`, which gives an additive
homomorphism (or more precisely a `ℤ`-linear map.) -/
def associated_hom : quadratic_form R M →ₗ[S] bilin_form R M :=
{ to_fun := λ Q,
((•) : submonoid.center R → bilin_form R M → bilin_form R M)
(⟨⅟2, λ x, (commute.one_right x).bit0_right.inv_of_right⟩) Q.polar_bilin,
map_add' := λ Q Q', by { ext, simp only [bilin_form.add_apply, bilin_form.smul_apply, coe_fn_mk,
polar_bilin_apply, polar_add, coe_fn_add, smul_add] },
map_smul' := λ s Q, by { ext, simp only [ring_hom.id_apply, polar_smul, smul_comm s,
polar_bilin_apply, coe_fn_mk, coe_fn_smul, bilin_form.smul_apply] } }
variables (Q : quadratic_form R M) (S)
@[simp] lemma associated_apply (x y : M) :
associated_hom S Q x y = ⅟2 * (Q (x + y) - Q x - Q y) := rfl
lemma associated_is_symm : (associated_hom S Q).is_symm :=
λ x y, by simp only [associated_apply, add_comm, add_left_comm, sub_eq_add_neg]
@[simp] lemma associated_comp {N : Type v} [add_comm_group N] [module R N] (f : N →ₗ[R] M) :
associated_hom S (Q.comp f) = (associated_hom S Q).comp f f :=
by { ext, simp only [quadratic_form.comp_apply, bilin_form.comp_apply, associated_apply,
linear_map.map_add] }
lemma associated_to_quadratic_form (B : bilin_form R M) (x y : M) :
associated_hom S B.to_quadratic_form x y = ⅟2 * (B x y + B y x) :=
by simp only [associated_apply, ← polar_to_quadratic_form, polar, to_quadratic_form_apply]
lemma associated_left_inverse (h : B₁.is_symm) :
associated_hom S (B₁.to_quadratic_form) = B₁ :=
bilin_form.ext $ λ x y,
by rw [associated_to_quadratic_form, is_symm.eq h x y, ←two_mul, ←mul_assoc, inv_of_mul_self,
one_mul]
lemma to_quadratic_form_associated : (associated_hom S Q).to_quadratic_form = Q :=
quadratic_form.ext $ λ x,
calc (associated_hom S Q).to_quadratic_form x
= ⅟2 * (Q x + Q x) : by simp only [add_assoc, add_sub_cancel', one_mul,
to_quadratic_form_apply, add_mul, associated_apply, map_add_self, bit0]
... = Q x : by rw [← two_mul (Q x), ←mul_assoc, inv_of_mul_self, one_mul]
-- note: usually `right_inverse` lemmas are named the other way around, but this is consistent
-- with historical naming in this file.
lemma associated_right_inverse :
function.right_inverse (associated_hom S)
(bilin_form.to_quadratic_form : _ → quadratic_form R M) :=
λ Q, to_quadratic_form_associated S Q
lemma associated_eq_self_apply (x : M) : associated_hom S Q x x = Q x :=
begin
rw [associated_apply, map_add_self],
suffices : (⅟2) * (2 * Q x) = Q x,
{ convert this,
simp only [bit0, add_mul, one_mul],
abel },
simp only [← mul_assoc, one_mul, inv_of_mul_self],
end
/-- `associated'` is the `ℤ`-linear map that sends a quadratic form on a module `M` over `R` to its
associated symmetric bilinear form. -/
abbreviation associated' : quadratic_form R M →ₗ[ℤ] bilin_form R M :=
associated_hom ℤ
/-- Symmetric bilinear forms can be lifted to quadratic forms -/
instance can_lift :
can_lift (bilin_form R M) (quadratic_form R M) (associated_hom ℕ) bilin_form.is_symm :=
{ prf := λ B hB, ⟨B.to_quadratic_form, associated_left_inverse _ hB⟩ }
/-- There exists a non-null vector with respect to any quadratic form `Q` whose associated
bilinear form is non-zero, i.e. there exists `x` such that `Q x ≠ 0`. -/
lemma exists_quadratic_form_ne_zero {Q : quadratic_form R M} (hB₁ : Q.associated' ≠ 0) :
∃ x, Q x ≠ 0 :=
begin
rw ←not_forall,
intro h,
apply hB₁,
rw [(quadratic_form.ext h : Q = 0), linear_map.map_zero],
end
end associated_hom
section associated
variables [comm_ring R₁] [add_comm_group M] [module R₁ M]
variables [invertible (2 : R₁)]
-- Note: When possible, rather than writing lemmas about `associated`, write a lemma applying to
-- the more general `associated_hom` and place it in the previous section.
/-- `associated` is the linear map that sends a quadratic form over a commutative ring to its
associated symmetric bilinear form. -/
abbreviation associated : quadratic_form R₁ M →ₗ[R₁] bilin_form R₁ M :=
associated_hom R₁
@[simp] lemma associated_lin_mul_lin (f g : M →ₗ[R₁] R₁) :
(lin_mul_lin f g).associated =
⅟(2 : R₁) • (bilin_form.lin_mul_lin f g + bilin_form.lin_mul_lin g f) :=
by { ext, simp only [smul_add, algebra.id.smul_eq_mul, bilin_form.lin_mul_lin_apply,
quadratic_form.lin_mul_lin_apply, bilin_form.smul_apply, associated_apply, bilin_form.add_apply,
linear_map.map_add], ring }
end associated
section anisotropic
section semiring
variables [semiring R] [add_comm_monoid M] [module R M]
/-- An anisotropic quadratic form is zero only on zero vectors. -/
def anisotropic (Q : quadratic_form R M) : Prop := ∀ x, Q x = 0 → x = 0
lemma not_anisotropic_iff_exists (Q : quadratic_form R M) :
¬anisotropic Q ↔ ∃ x ≠ 0, Q x = 0 :=
by simp only [anisotropic, not_forall, exists_prop, and_comm]
lemma anisotropic.eq_zero_iff {Q : quadratic_form R M} (h : anisotropic Q) {x : M} :
Q x = 0 ↔ x = 0 :=
⟨h x, λ h, h.symm ▸ map_zero Q⟩
end semiring
section ring
variables [ring R] [add_comm_group M] [module R M]
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
lemma nondegenerate_of_anisotropic [invertible (2 : R)] (Q : quadratic_form R M)
(hB : Q.anisotropic) : Q.associated'.nondegenerate :=
begin
intros x hx,
refine hB _ _,
rw ← hx x,
exact (associated_eq_self_apply _ _ x).symm,
end
end ring
end anisotropic
section pos_def
variables {R₂ : Type u} [ordered_ring R₂] [add_comm_monoid M] [module R₂ M]
variables {Q₂ : quadratic_form R₂ M}
/-- A positive definite quadratic form is positive on nonzero vectors. -/
def pos_def (Q₂ : quadratic_form R₂ M) : Prop := ∀ x ≠ 0, 0 < Q₂ x
lemma pos_def.smul {R} [linear_ordered_comm_ring R] [module R M]
{Q : quadratic_form R M} (h : pos_def Q) {a : R} (a_pos : 0 < a) : pos_def (a • Q) :=
λ x hx, mul_pos a_pos (h x hx)
variables {n : Type*}
lemma pos_def.nonneg {Q : quadratic_form R₂ M} (hQ : pos_def Q) (x : M) :
0 ≤ Q x :=
(eq_or_ne x 0).elim (λ h, h.symm ▸ (map_zero Q).symm.le) (λ h, (hQ _ h).le)
lemma pos_def.anisotropic {Q : quadratic_form R₂ M} (hQ : Q.pos_def) : Q.anisotropic :=
λ x hQx, classical.by_contradiction $ λ hx, lt_irrefl (0 : R₂) $ begin
have := hQ _ hx,
rw hQx at this,
exact this,
end
lemma pos_def_of_nonneg {Q : quadratic_form R₂ M} (h : ∀ x, 0 ≤ Q x) (h0 : Q.anisotropic) :
pos_def Q :=
λ x hx, lt_of_le_of_ne (h x) (ne.symm $ λ hQx, hx $ h0 _ hQx)
lemma pos_def_iff_nonneg {Q : quadratic_form R₂ M} :
pos_def Q ↔ (∀ x, 0 ≤ Q x) ∧ Q.anisotropic :=
⟨λ h, ⟨h.nonneg, h.anisotropic⟩, λ ⟨n, a⟩, pos_def_of_nonneg n a⟩
lemma pos_def.add (Q Q' : quadratic_form R₂ M) (hQ : pos_def Q) (hQ' : pos_def Q') :
pos_def (Q + Q') :=
λ x hx, add_pos (hQ x hx) (hQ' x hx)
lemma lin_mul_lin_self_pos_def {R} [linear_ordered_comm_ring R] [module R M]
(f : M →ₗ[R] R) (hf : linear_map.ker f = ⊥) :
pos_def (lin_mul_lin f f) :=
λ x hx, mul_self_pos.2 (λ h, hx $ linear_map.ker_eq_bot'.mp hf _ h)
end pos_def
end quadratic_form
section
/-!
### Quadratic forms and matrices
Connect quadratic forms and matrices, in order to explicitly compute with them.
The convention is twos out, so there might be a factor 2⁻¹ in the entries of the
matrix.
The determinant of the matrix is the discriminant of the quadratic form.
-/
variables {n : Type w} [fintype n] [decidable_eq n]
variables [comm_ring R₁] [add_comm_monoid M] [module R₁ M]
/-- `M.to_quadratic_form` is the map `λ x, col x ⬝ M ⬝ row x` as a quadratic form. -/
def matrix.to_quadratic_form' (M : matrix n n R₁) :
quadratic_form R₁ (n → R₁) :=
M.to_bilin'.to_quadratic_form
variables [invertible (2 : R₁)]
/-- A matrix representation of the quadratic form. -/
def quadratic_form.to_matrix' (Q : quadratic_form R₁ (n → R₁)) : matrix n n R₁ :=
Q.associated.to_matrix'
open quadratic_form
lemma quadratic_form.to_matrix'_smul (a : R₁) (Q : quadratic_form R₁ (n → R₁)) :
(a • Q).to_matrix' = a • Q.to_matrix' :=
by simp only [to_matrix', linear_equiv.map_smul, linear_map.map_smul]
lemma quadratic_form.is_symm_to_matrix' (Q : quadratic_form R₁ (n → R₁)) :
Q.to_matrix'.is_symm :=
begin
ext i j,
rw [to_matrix', bilin_form.to_matrix'_apply, bilin_form.to_matrix'_apply, associated_is_symm]
end
end
namespace quadratic_form
variables {n : Type w} [fintype n]
variables [comm_ring R₁] [decidable_eq n] [invertible (2 : R₁)]
variables {m : Type w} [decidable_eq m] [fintype m]
open_locale matrix
@[simp]
lemma to_matrix'_comp (Q : quadratic_form R₁ (m → R₁)) (f : (n → R₁) →ₗ[R₁] (m → R₁)) :
(Q.comp f).to_matrix' = f.to_matrix'ᵀ ⬝ Q.to_matrix' ⬝ f.to_matrix' :=
by { ext, simp only [quadratic_form.associated_comp, bilin_form.to_matrix'_comp, to_matrix'] }
section discriminant
variables {Q : quadratic_form R₁ (n → R₁)}
/-- The discriminant of a quadratic form generalizes the discriminant of a quadratic polynomial. -/
def discr (Q : quadratic_form R₁ (n → R₁)) : R₁ := Q.to_matrix'.det
lemma discr_smul (a : R₁) : (a • Q).discr = a ^ fintype.card n * Q.discr :=
by simp only [discr, to_matrix'_smul, matrix.det_smul]
lemma discr_comp (f : (n → R₁) →ₗ[R₁] (n → R₁)) :
(Q.comp f).discr = f.to_matrix'.det * f.to_matrix'.det * Q.discr :=
by simp only [matrix.det_transpose, mul_left_comm, quadratic_form.to_matrix'_comp, mul_comm,
matrix.det_mul, discr]
end discriminant
end quadratic_form
namespace quadratic_form
end quadratic_form
namespace bilin_form
section semiring
variables [semiring R] [add_comm_monoid M] [module R M]
/-- A bilinear form is nondegenerate if the quadratic form it is associated with is anisotropic. -/
lemma nondegenerate_of_anisotropic
{B : bilin_form R M} (hB : B.to_quadratic_form.anisotropic) : B.nondegenerate :=
λ x hx, hB _ (hx x)
end semiring
variables [ring R] [add_comm_group M] [module R M]
/-- There exists a non-null vector with respect to any symmetric, nonzero bilinear form `B`
on a module `M` over a ring `R` with invertible `2`, i.e. there exists some
`x : M` such that `B x x ≠ 0`. -/
open finite_dimensional
variables {V : Type u} {K : Type v} [field K] [add_comm_group V] [module K V]
variable [finite_dimensional K V]
/-- Given a symmetric bilinear form `B` on some vector space `V` over a field `K`
in which `2` is invertible, there exists an orthogonal basis with respect to `B`. -/
lemma exists_orthogonal_basis [hK : invertible (2 : K)]
{B : bilin_form K V} (hB₂ : B.is_symm) :
∃ (v : basis (fin (finrank K V)) K V), B.is_Ortho v :=
begin
unfreezingI { induction hd : finrank K V with d ih generalizing V },
{ exact ⟨basis_of_finrank_zero hd, λ _ _ _, zero_left _⟩ },
haveI := finrank_pos_iff.1 (hd.symm ▸ nat.succ_pos d : 0 < finrank K V),
-- either the bilinear form is trivial or we can pick a non-null `x`
obtain rfl | hB₁ := eq_or_ne B 0,
{ let b := finite_dimensional.fin_basis K V,
rw hd at b,
refine ⟨b, λ i j hij, rfl⟩, },
obtain ⟨x, hx⟩ := exists_bilin_form_self_ne_zero hB₁ hB₂,
rw [← submodule.finrank_add_eq_of_is_compl (is_compl_span_singleton_orthogonal hx).symm,
finrank_span_singleton (ne_zero_of_not_is_ortho_self x hx)] at hd,
let B' := B.restrict (B.orthogonal $ K ∙ x),
obtain ⟨v', hv₁⟩ := ih (B.restrict_symm hB₂ _ : B'.is_symm) (nat.succ.inj hd),
-- concatenate `x` with the basis obtained by induction
let b := basis.mk_fin_cons x v'
(begin
rintros c y hy hc,
rw add_eq_zero_iff_neg_eq at hc,
rw [← hc, submodule.neg_mem_iff] at hy,
have := (is_compl_span_singleton_orthogonal hx).disjoint,
rw submodule.disjoint_def at this,
have := this (c • x) (submodule.smul_mem _ _ $ submodule.mem_span_singleton_self _) hy,
exact (smul_eq_zero.1 this).resolve_right (λ h, hx $ h.symm ▸ zero_left _),
end)
(begin
intro y,
refine ⟨-B x y/B x x, λ z hz, _⟩,
obtain ⟨c, rfl⟩ := submodule.mem_span_singleton.1 hz,
rw [is_ortho, smul_left, add_right, smul_right, div_mul_cancel _ hx, add_neg_self, mul_zero],
end),
refine ⟨b, _⟩,
{ rw basis.coe_mk_fin_cons,
intros j i,
refine fin.cases _ (λ i, _) i; refine fin.cases _ (λ j, _) j; intro hij;
simp only [function.on_fun, fin.cons_zero, fin.cons_succ, function.comp_apply],
{ exact (hij rfl).elim },
{ rw [is_ortho, hB₂],
exact (v' j).prop _ (submodule.mem_span_singleton_self x) },
{ exact (v' i).prop _ (submodule.mem_span_singleton_self x) },
{ exact hv₁ (ne_of_apply_ne _ hij), }, }
end
end bilin_form
namespace quadratic_form
open finset bilin_form
variables {M₁ : Type*} [semiring R] [comm_semiring R₁] [add_comm_monoid M] [add_comm_monoid M₁]
variables [module R M] [module R M₁]
variables {ι : Type*} [fintype ι] {v : basis ι R M}
/-- Given a quadratic form `Q` and a basis, `basis_repr` is the basis representation of `Q`. -/
noncomputable def basis_repr (Q : quadratic_form R M) (v : basis ι R M) :
quadratic_form R (ι → R) :=
Q.comp v.equiv_fun.symm
@[simp]
lemma basis_repr_apply (Q : quadratic_form R M) (w : ι → R) :
Q.basis_repr v w = Q (∑ i : ι, w i • v i) :=
by { rw ← v.equiv_fun_symm_apply, refl }
section
variables (R₁)
/-- The weighted sum of squares with respect to some weight as a quadratic form.
The weights are applied using `•`; typically this definition is used either with `S = R₁` or
`[algebra S R₁]`, although this is stated more generally. -/
def weighted_sum_squares [monoid S] [distrib_mul_action S R₁]
[smul_comm_class S R₁ R₁]
(w : ι → S) : quadratic_form R₁ (ι → R₁) :=
∑ i : ι, w i • proj i i
end
@[simp]
lemma weighted_sum_squares_apply [monoid S] [distrib_mul_action S R₁] [smul_comm_class S R₁ R₁]
(w : ι → S) (v : ι → R₁) :
weighted_sum_squares R₁ w v = ∑ i : ι, w i • (v i * v i) :=
quadratic_form.sum_apply _ _ _
/-- On an orthogonal basis, the basis representation of `Q` is just a sum of squares. -/
lemma basis_repr_eq_of_is_Ortho
{R₁ M} [comm_ring R₁] [add_comm_group M] [module R₁ M] [invertible (2 : R₁)]
(Q : quadratic_form R₁ M) (v : basis ι R₁ M) (hv₂ : (associated Q).is_Ortho v) :
Q.basis_repr v = weighted_sum_squares _ (λ i, Q (v i)) :=
begin
ext w,
rw [basis_repr_apply, ←@associated_eq_self_apply R₁, sum_left, weighted_sum_squares_apply],
refine sum_congr rfl (λ j hj, _),
rw [←@associated_eq_self_apply R₁, sum_right, sum_eq_single_of_mem j hj],
{ rw [smul_left, smul_right, smul_eq_mul], ring },
{ intros i _ hij,
rw [smul_left, smul_right,
show associated_hom R₁ Q (v j) (v i) = 0, from hv₂ hij.symm,
mul_zero, mul_zero] },
end
end quadratic_form
|
#' mstranslator
#'
#' @name mstranslator
#' @docType package
#' @import httr
#' @import XML
NULL
|
proposition separate_closed_compact: fixes s t :: "'a::heine_borel set" assumes "closed s" and "compact t" and "s \<inter> t = {}" shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" |
array[0]: 234, newp: 234
|
-- ------------------------------------------------------ [ GettingStarted.idr ]
-- Module : Exercises.GettingStarted
-- Description : Solutions to the Chapter 2 exercises in Edwin Brady's
-- book, "Type-Driven Development with Idris."
-- --------------------------------------------------------------------- [ EOH ]
module Exercises.GettingStarted
%access export
-- ----------------------------------------------------------- [ 2.5 Exercises ]
exercise1_1 : (String, String, String)
exercise1_1 = ("A", "B", "C")
exercise1_2 : List String
exercise1_2 = ["A", "B", "C"]
exercise1_3 : ((Char, String), Char)
exercise1_3 = (('A', "B"), 'C')
namespace Simple
||| Determine whether a string reads the same backwards as forwards.
||| @ str a string to analyze
palindrome : (str : String) -> Bool
palindrome str = str == reverse str
namespace CaseInsensitive
||| Determine, case insensitively, whether a string reads the same backwards
||| as forwards.
||| @ str a string to analyze
palindrome : (str : String) -> Bool
palindrome = Simple.palindrome . toLower
namespace LongerThanN
||| Return `True` iff `str` is longer than `len` characters and
||| case-insensitively reads the same backwards as forwards.
||| @ len the lower bound (exclusive) of string length
||| @ str a string to analyze
palindrome : (len : Nat) -> (str : String) -> Bool
palindrome n str = length str > n && CaseInsensitive.palindrome str
namespace LongerThan10
||| Return `True` iff `str` is longer than 10 characts and case-insensitively
||| reads the same backwards as forwards.
||| @ str a string to analyze
palindrome : (str : String) -> Bool
palindrome = LongerThanN.palindrome 10
||| Compute the number of words and number of characters in a string.
||| @ str a string to analyze
counts : (str : String) -> (Nat, Nat)
counts str =
let wordCount = length (words str)
charCount = length str
in (wordCount, charCount)
||| Return the largest ten values in a list.
||| @ list a list of values contstrained by `Ord`
topTen : Ord a => (list : List a) -> List a
topTen = take 10 . sortBy (flip compare)
-- NOTE: This is a bit like Clojure's cond->.
syntax "cond$" [x] [b] [f] = if b then x else f x
||| Count the number of strings in list that are over a given length.
||| @ len the lower bound (exclusive) of string length
overLength : (len : Nat) -> List String -> Nat
overLength len = foldr go 0
where
go : String -> Nat -> Nat
go str n = cond$ n (length str > len) S
-- --------------------------------------------------------------------- [ EOF ]
|
lemma Cauchy_higher_derivative_integral_circlepath: assumes contf: "continuous_on (cball z r) f" and holf: "f holomorphic_on ball z r" and w: "w \<in> ball z r" shows "(\<lambda>u. f u / (u - w)^(Suc k)) contour_integrable_on (circlepath z r)" (is "?thes1") and "(deriv ^^ k) f w = (fact k) / (2 * pi * \<i>) * contour_integral(circlepath z r) (\<lambda>u. f u/(u - w)^(Suc k))" (is "?thes2") |
State Before: k : Type u_1
M : Type u_2
N : Type ?u.36780
inst✝³ : OrderedRing k
inst✝² : OrderedAddCommGroup M
inst✝¹ : Module k M
inst✝ : OrderedSMul k M
a b : M
c : k
hc : c < 0
⊢ 0 < c • a ↔ a < 0 State After: k : Type u_1
M : Type u_2
N : Type ?u.36780
inst✝³ : OrderedRing k
inst✝² : OrderedAddCommGroup M
inst✝¹ : Module k M
inst✝ : OrderedSMul k M
a b : M
c : k
hc : c < 0
⊢ -c • a < 0 ↔ a < 0 Tactic: rw [← neg_neg c, neg_smul, neg_pos] State Before: k : Type u_1
M : Type u_2
N : Type ?u.36780
inst✝³ : OrderedRing k
inst✝² : OrderedAddCommGroup M
inst✝¹ : Module k M
inst✝ : OrderedSMul k M
a b : M
c : k
hc : c < 0
⊢ -c • a < 0 ↔ a < 0 State After: no goals Tactic: exact smul_neg_iff_of_pos (neg_pos_of_neg hc) |
State Before: 𝕜 : Type u_2
E : Type u_1
F : Type ?u.176423
G : Type ?u.176426
inst✝² : LinearOrderedField 𝕜
inst✝¹ : AddCommGroup E
inst✝ : Module 𝕜 E
s : Set E
hs : Convex 𝕜 s
x : E
⊢ IsLeast {t | s ⊆ ↑t} (toCone s hs) State After: 𝕜 : Type u_2
E : Type u_1
F : Type ?u.176423
G : Type ?u.176426
inst✝² : LinearOrderedField 𝕜
inst✝¹ : AddCommGroup E
inst✝ : Module 𝕜 E
s : Set E
hs : Convex 𝕜 s
x✝ : E
t : ConvexCone 𝕜 E
ht : t ∈ {t | s ⊆ ↑t}
x : E
hx : x ∈ toCone s hs
⊢ x ∈ t Tactic: refine' ⟨hs.subset_toCone, fun t ht x hx => _⟩ State Before: 𝕜 : Type u_2
E : Type u_1
F : Type ?u.176423
G : Type ?u.176426
inst✝² : LinearOrderedField 𝕜
inst✝¹ : AddCommGroup E
inst✝ : Module 𝕜 E
s : Set E
hs : Convex 𝕜 s
x✝ : E
t : ConvexCone 𝕜 E
ht : t ∈ {t | s ⊆ ↑t}
x : E
hx : x ∈ toCone s hs
⊢ x ∈ t State After: case intro.intro.intro.intro
𝕜 : Type u_2
E : Type u_1
F : Type ?u.176423
G : Type ?u.176426
inst✝² : LinearOrderedField 𝕜
inst✝¹ : AddCommGroup E
inst✝ : Module 𝕜 E
s : Set E
hs : Convex 𝕜 s
x : E
t : ConvexCone 𝕜 E
ht : t ∈ {t | s ⊆ ↑t}
c : 𝕜
hc : 0 < c
y : E
hy : y ∈ s
hx : c • y ∈ toCone s hs
⊢ c • y ∈ t Tactic: rcases hs.mem_toCone.1 hx with ⟨c, hc, y, hy, rfl⟩ State Before: case intro.intro.intro.intro
𝕜 : Type u_2
E : Type u_1
F : Type ?u.176423
G : Type ?u.176426
inst✝² : LinearOrderedField 𝕜
inst✝¹ : AddCommGroup E
inst✝ : Module 𝕜 E
s : Set E
hs : Convex 𝕜 s
x : E
t : ConvexCone 𝕜 E
ht : t ∈ {t | s ⊆ ↑t}
c : 𝕜
hc : 0 < c
y : E
hy : y ∈ s
hx : c • y ∈ toCone s hs
⊢ c • y ∈ t State After: no goals Tactic: exact t.smul_mem hc (ht hy) |
[STATEMENT]
lemma comp_arr_ide:
assumes "ide a" and "seq f a"
shows "f \<cdot> a = f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. f \<cdot> a = f
[PROOF STEP]
using assms ide_in_hom ide_def not_arr_null
[PROOF STATE]
proof (prove)
using this:
ide a
seq f a
ide ?a = \<guillemotleft>?a : ?a \<rightarrow> ?a\<guillemotright>
ide ?a \<equiv> ?a \<cdot> ?a \<noteq> null \<and> (\<forall>f. (f \<cdot> ?a \<noteq> null \<longrightarrow> f \<cdot> ?a = f) \<and> (?a \<cdot> f \<noteq> null \<longrightarrow> ?a \<cdot> f = f))
\<not> arr null
goal (1 subgoal):
1. f \<cdot> a = f
[PROOF STEP]
by metis |
= = History and etymology = =
|
Formal statement is: proposition no_isolated_singularity: fixes z::complex assumes f: "continuous_on S f" and holf: "f holomorphic_on (S - K)" and S: "open S" and K: "finite K" shows "f holomorphic_on S" Informal statement is: If $f$ is a continuous function on an open set $S$ and $f$ is holomorphic on $S - K$, where $K$ is a finite set, then $f$ is holomorphic on $S$. |
<a href="https://colab.research.google.com/github/yeyomuri/probabilidad/blob/main/distribucion_continua.ipynb" target="_parent"></a>
```python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import norm
```
#Distribucion normal teórica
\begin{align}
P(X) = \frac{1}{\sigma \sqrt{2\pi}^{\left[ -\frac{1}{2}\left(\frac{X - 𝜇}{\sigma}\right)^2\right]}}
\end{align}
```python
def gaussian(x, mu, sigma):
return 1/(sigma * np.sqrt(2*np.pi))*np.exp(-0.5 * pow((x-mu)/sigma, 2))
```
```python
#Lista de datos de entrada para la funcion gaussiana
x = np.arange(-4, 4, 0.1)
y = gaussian(x, 0.0, 1.0)
plt.plot(x, y)
```
#Usando scipy
```python
dist = norm(0, 1) #promedio, desviacion estandar
x = np.arange(-4, 4, 0.1)
y = [dist.pdf(value) for value in x]
plt.plot(x,y)
```
```python
dist = norm(0, 1)
x = np.arange(-4, 4, 0.1)
y = [dist.cdf(value) for value in x]
plt.plot(x, y)
```
#Distribución normal (gaussiana) a partir de los datos
Archivo [excel](https://seattlecentral.edu/qelp/sets/057/057.html)
```python
df = pd.read_excel('s057.xls')
arr = df['Normally Distributed Housefly Wing Lengths'].values[4:]
#frecuencia de los datos del array
values, dist = np.unique(arr, return_counts=True)
plt.bar(values, dist)
```
```python
#Estimacion parametrica de una distribucion
mu = arr.mean()
sigma = arr.std()
x = np.arange(30, 60, 0.1)
dist = norm(mu, sigma)
y = [dist.pdf(value) for value in x]
plt.plot(x,y)
values, dist = np.unique(arr, return_counts = True)
plt.bar(values, dist/len(arr))
```
|
lemma continuous_at_Sup_antimono: fixes f :: "'a::{linorder_topology,conditionally_complete_linorder} \<Rightarrow> 'b::{linorder_topology,conditionally_complete_linorder}" assumes "antimono f" and cont: "continuous (at_left (Sup S)) f" and S: "S \<noteq> {}" "bdd_above S" shows "f (Sup S) = (INF s\<in>S. f s)" |
lemma homotopic_with_linear: fixes f g :: "_ \<Rightarrow> 'b::real_normed_vector" assumes contf: "continuous_on S f" and contg:"continuous_on S g" and sub: "\<And>x. x \<in> S \<Longrightarrow> closed_segment (f x) (g x) \<subseteq> t" shows "homotopic_with_canon (\<lambda>z. True) S t f g" |
lemma closure_insert: fixes x :: "'a::t1_space" shows "closure (insert x s) = insert x (closure s)" |
/-
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro
-/
import algebra.order.group
import algebra.order.sub
import algebra.char_zero.defs
import algebra.hom.ring
import data.set.intervals.basic
/-!
# Ordered rings and semirings
This file develops the basics of ordered (semi)rings.
Each typeclass here comprises
* an algebraic class (`semiring`, `comm_semiring`, `ring`, `comm_ring`)
* an order class (`partial_order`, `linear_order`)
* assumptions on how both interact ((strict) monotonicity, canonicity)
For short,
* "`+` respects `≤`" means "monotonicity of addition"
* "`*` respects `<`" means "strict monotonicity of multiplication by a positive number".
## Typeclasses
* `ordered_semiring`: Semiring with a partial order such that `+` respects `≤` and `*` respects `<`.
* `ordered_comm_semiring`: Commutative semiring with a partial order such that `+` respects `≤` and
`*` respects `<`.
* `ordered_ring`: Ring with a partial order such that `+` respects `≤` and `*` respects `<`.
* `ordered_comm_ring`: Commutative ring with a partial order such that `+` respects `≤` and
`*` respects `<`.
* `linear_ordered_semiring`: Semiring with a linear order such that `+` respects `≤` and
`*` respects `<`.
* `linear_ordered_ring`: Ring with a linear order such that `+` respects `≤` and `*` respects `<`.
* `linear_ordered_comm_ring`: Commutative ring with a linear order such that `+` respects `≤` and
`*` respects `<`.
* `canonically_ordered_comm_semiring`: Commutative semiring with a partial order such that `+`
respects `≤`, `*` respects `<`, and `a ≤ b ↔ ∃ c, b = a + c`.
and some typeclasses to define ordered rings by specifying their nonegative elements:
* `nonneg_ring`: To define `ordered_ring`s.
* `linear_nonneg_ring`: To define `linear_ordered_ring`s.
## Hierarchy
The hardest part of proving order lemmas might be to figure out the correct generality and its
corresponding typeclass. Here's an attempt at demystifying it. For each typeclass, we list its
immediate predecessors and what conditions are added to each of them.
* `ordered_semiring`
- `ordered_cancel_add_comm_monoid` & multiplication & `*` respects `<`
- `semiring` & partial order structure & `+` respects `≤` & `*` respects `<`
* `ordered_comm_semiring`
- `ordered_semiring` & commutativity of multiplication
- `comm_semiring` & partial order structure & `+` respects `≤` & `*` respects `<`
* `ordered_ring`
- `ordered_semiring` & additive inverses
- `ordered_add_comm_group` & multiplication & `*` respects `<`
- `ring` & partial order structure & `+` respects `≤` & `*` respects `<`
* `ordered_comm_ring`
- `ordered_ring` & commutativity of multiplication
- `ordered_comm_semiring` & additive inverses
- `comm_ring` & partial order structure & `+` respects `≤` & `*` respects `<`
* `linear_ordered_semiring`
- `ordered_semiring` & totality of the order & nontriviality
- `linear_ordered_add_comm_monoid` & multiplication & nontriviality & `*` respects `<`
* `linear_ordered_ring`
- `ordered_ring` & totality of the order & nontriviality
- `linear_ordered_semiring` & additive inverses
- `linear_ordered_add_comm_group` & multiplication & `*` respects `<`
- `domain` & linear order structure
* `linear_ordered_comm_ring`
- `ordered_comm_ring` & totality of the order & nontriviality
- `linear_ordered_ring` & commutativity of multiplication
- `is_domain` & linear order structure
* `canonically_ordered_comm_semiring`
- `canonically_ordered_add_monoid` & multiplication & `*` respects `<` & no zero divisors
- `comm_semiring` & `a ≤ b ↔ ∃ c, b = a + c` & no zero divisors
## TODO
We're still missing some typeclasses, like
* `linear_ordered_comm_semiring`
* `canonically_ordered_semiring`
They have yet to come up in practice.
-/
set_option old_structure_cmd true
universe u
variable {α : Type u}
namespace order_dual
/-! Note that `order_dual` does not satisfy any of the ordered ring typeclasses due to the
`zero_le_one` field. -/
instance [h : distrib α] : distrib αᵒᵈ := h
instance [has_mul α] [h : has_distrib_neg α] : has_distrib_neg αᵒᵈ := h
instance [h : non_unital_non_assoc_semiring α] : non_unital_non_assoc_semiring αᵒᵈ := h
instance [h : non_unital_semiring α] : non_unital_semiring αᵒᵈ := h
instance [h : non_assoc_semiring α] : non_assoc_semiring αᵒᵈ := h
instance [h : semiring α] : semiring αᵒᵈ := h
instance [h : non_unital_comm_semiring α] : non_unital_comm_semiring αᵒᵈ := h
instance [h : comm_semiring α] : comm_semiring αᵒᵈ := h
instance [h : non_unital_non_assoc_ring α] : non_unital_non_assoc_ring αᵒᵈ := h
instance [h : non_unital_ring α] : non_unital_ring αᵒᵈ := h
instance [h : non_assoc_ring α] : non_assoc_ring αᵒᵈ := h
instance [h : ring α] : ring αᵒᵈ := h
instance [h : non_unital_comm_ring α] : non_unital_comm_ring αᵒᵈ := h
instance [h : comm_ring α] : comm_ring αᵒᵈ := h
end order_dual
lemma add_one_le_two_mul [has_le α] [semiring α] [covariant_class α α (+) (≤)]
{a : α} (a1 : 1 ≤ a) :
a + 1 ≤ 2 * a :=
calc a + 1 ≤ a + a : add_le_add_left a1 a
... = 2 * a : (two_mul _).symm
/-- An `ordered_semiring α` is a semiring `α` with a partial order such that
addition is monotone and multiplication by a positive number is strictly monotone. -/
@[protect_proj]
class ordered_semiring (α : Type u) extends semiring α, ordered_cancel_add_comm_monoid α :=
(zero_le_one : (0 : α) ≤ 1)
(mul_lt_mul_of_pos_left : ∀ a b c : α, a < b → 0 < c → c * a < c * b)
(mul_lt_mul_of_pos_right : ∀ a b c : α, a < b → 0 < c → a * c < b * c)
@[priority 100] instance ordered_semiring.zero_le_one_class [h : ordered_semiring α] :
zero_le_one_class α :=
{ ..h }
section ordered_semiring
variables [ordered_semiring α] {a b c d : α}
section nontrivial
variables [nontrivial α]
@[simp] lemma zero_lt_one : 0 < (1 : α) :=
lt_of_le_of_ne zero_le_one zero_ne_one
lemma zero_lt_two : 0 < (2:α) := add_pos zero_lt_one zero_lt_one
@[field_simps] lemma two_ne_zero : (2:α) ≠ 0 :=
zero_lt_two.ne'
lemma one_lt_two : 1 < (2:α) :=
calc (2:α) = 1+1 : one_add_one_eq_two
... > 1+0 : add_lt_add_left zero_lt_one _
... = 1 : add_zero 1
lemma zero_lt_three : 0 < (3:α) := add_pos zero_lt_two zero_lt_one
@[field_simps] lemma three_ne_zero : (3:α) ≠ 0 :=
zero_lt_three.ne'
lemma zero_lt_four : 0 < (4:α) := add_pos zero_lt_two zero_lt_two
@[field_simps] lemma four_ne_zero : (4:α) ≠ 0 :=
zero_lt_four.ne'
alias zero_lt_one ← one_pos
alias zero_lt_two ← two_pos
alias zero_lt_three ← three_pos
alias zero_lt_four ← four_pos
end nontrivial
lemma mul_lt_mul_of_pos_left (h₁ : a < b) (h₂ : 0 < c) : c * a < c * b :=
ordered_semiring.mul_lt_mul_of_pos_left a b c h₁ h₂
lemma mul_lt_mul_of_pos_right (h₁ : a < b) (h₂ : 0 < c) : a * c < b * c :=
ordered_semiring.mul_lt_mul_of_pos_right a b c h₁ h₂
lemma mul_lt_of_lt_one_left (hb : 0 < b) (ha : a < 1) : a * b < b :=
(mul_lt_mul_of_pos_right ha hb).trans_le (one_mul _).le
lemma mul_lt_of_lt_one_right (ha : 0 < a) (hb : b < 1) : a * b < a :=
(mul_lt_mul_of_pos_left hb ha).trans_le (mul_one _).le
-- See Note [decidable namespace]
protected lemma decidable.mul_le_mul_of_nonneg_left [@decidable_rel α (≤)]
(h₁ : a ≤ b) (h₂ : 0 ≤ c) : c * a ≤ c * b :=
begin
by_cases ba : b ≤ a, { simp [ba.antisymm h₁] },
by_cases c0 : c ≤ 0, { simp [c0.antisymm h₂] },
exact (mul_lt_mul_of_pos_left (h₁.lt_of_not_le ba) (h₂.lt_of_not_le c0)).le,
end
lemma mul_le_mul_of_nonneg_left : a ≤ b → 0 ≤ c → c * a ≤ c * b :=
by classical; exact decidable.mul_le_mul_of_nonneg_left
-- See Note [decidable namespace]
protected lemma decidable.mul_le_mul_of_nonneg_right [@decidable_rel α (≤)]
(h₁ : a ≤ b) (h₂ : 0 ≤ c) : a * c ≤ b * c :=
begin
by_cases ba : b ≤ a, { simp [ba.antisymm h₁] },
by_cases c0 : c ≤ 0, { simp [c0.antisymm h₂] },
exact (mul_lt_mul_of_pos_right (h₁.lt_of_not_le ba) (h₂.lt_of_not_le c0)).le,
end
lemma mul_le_mul_of_nonneg_right : a ≤ b → 0 ≤ c → a * c ≤ b * c :=
by classical; exact decidable.mul_le_mul_of_nonneg_right
-- TODO: there are four variations, depending on which variables we assume to be nonneg
-- See Note [decidable namespace]
protected lemma decidable.mul_le_mul [@decidable_rel α (≤)]
(hac : a ≤ c) (hbd : b ≤ d) (nn_b : 0 ≤ b) (nn_c : 0 ≤ c) : a * b ≤ c * d :=
calc
a * b ≤ c * b : decidable.mul_le_mul_of_nonneg_right hac nn_b
... ≤ c * d : decidable.mul_le_mul_of_nonneg_left hbd nn_c
lemma mul_le_mul : a ≤ c → b ≤ d → 0 ≤ b → 0 ≤ c → a * b ≤ c * d :=
by classical; exact decidable.mul_le_mul
-- See Note [decidable namespace]
protected lemma decidable.mul_nonneg_le_one_le {α : Type*} [ordered_semiring α]
[@decidable_rel α (≤)] {a b c : α}
(h₁ : 0 ≤ c) (h₂ : a ≤ c) (h₃ : 0 ≤ b) (h₄ : b ≤ 1) : a * b ≤ c :=
by simpa only [mul_one] using decidable.mul_le_mul h₂ h₄ h₃ h₁
lemma mul_nonneg_le_one_le {α : Type*} [ordered_semiring α] {a b c : α} :
0 ≤ c → a ≤ c → 0 ≤ b → b ≤ 1 → a * b ≤ c :=
by classical; exact decidable.mul_nonneg_le_one_le
-- See Note [decidable namespace]
protected lemma decidable.mul_nonneg [@decidable_rel α (≤)]
(ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a * b :=
have h : 0 * b ≤ a * b, from decidable.mul_le_mul_of_nonneg_right ha hb,
by rwa [zero_mul] at h
lemma mul_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a * b := by classical; exact decidable.mul_nonneg
@[simp] theorem pow_nonneg (H : 0 ≤ a) : ∀ (n : ℕ), 0 ≤ a ^ n
| 0 := by { rw pow_zero, exact zero_le_one}
| (n+1) := by { rw pow_succ, exact mul_nonneg H (pow_nonneg _) }
-- See Note [decidable namespace]
protected lemma decidable.mul_nonpos_of_nonneg_of_nonpos [@decidable_rel α (≤)]
(ha : 0 ≤ a) (hb : b ≤ 0) : a * b ≤ 0 :=
have h : a * b ≤ a * 0, from decidable.mul_le_mul_of_nonneg_left hb ha,
by rwa mul_zero at h
lemma mul_nonpos_of_nonneg_of_nonpos : 0 ≤ a → b ≤ 0 → a * b ≤ 0 :=
by classical; exact decidable.mul_nonpos_of_nonneg_of_nonpos
-- See Note [decidable namespace]
protected lemma decidable.mul_nonpos_of_nonpos_of_nonneg [@decidable_rel α (≤)]
(ha : a ≤ 0) (hb : 0 ≤ b) : a * b ≤ 0 :=
have h : a * b ≤ 0 * b, from decidable.mul_le_mul_of_nonneg_right ha hb,
by rwa zero_mul at h
lemma mul_nonpos_of_nonpos_of_nonneg : a ≤ 0 → 0 ≤ b → a * b ≤ 0 :=
by classical; exact decidable.mul_nonpos_of_nonpos_of_nonneg
-- See Note [decidable namespace]
protected lemma decidable.mul_lt_mul [@decidable_rel α (≤)]
(hac : a < c) (hbd : b ≤ d) (pos_b : 0 < b) (nn_c : 0 ≤ c) : a * b < c * d :=
calc
a * b < c * b : mul_lt_mul_of_pos_right hac pos_b
... ≤ c * d : decidable.mul_le_mul_of_nonneg_left hbd nn_c
lemma mul_lt_mul : a < c → b ≤ d → 0 < b → 0 ≤ c → a * b < c * d :=
by classical; exact decidable.mul_lt_mul
-- See Note [decidable namespace]
protected lemma decidable.mul_lt_mul' [@decidable_rel α (≤)]
(h1 : a ≤ c) (h2 : b < d) (h3 : 0 ≤ b) (h4 : 0 < c) : a * b < c * d :=
calc
a * b ≤ c * b : decidable.mul_le_mul_of_nonneg_right h1 h3
... < c * d : mul_lt_mul_of_pos_left h2 h4
lemma mul_lt_mul' : a ≤ c → b < d → 0 ≤ b → 0 < c → a * b < c * d :=
by classical; exact decidable.mul_lt_mul'
lemma mul_pos (ha : 0 < a) (hb : 0 < b) : 0 < a * b :=
have h : 0 * b < a * b, from mul_lt_mul_of_pos_right ha hb,
by rwa zero_mul at h
@[simp] theorem pow_pos (H : 0 < a) : ∀ (n : ℕ), 0 < a ^ n
| 0 := by { nontriviality, rw pow_zero, exact zero_lt_one }
| (n+1) := by { rw pow_succ, exact mul_pos H (pow_pos _) }
lemma mul_neg_of_pos_of_neg (ha : 0 < a) (hb : b < 0) : a * b < 0 :=
have h : a * b < a * 0, from mul_lt_mul_of_pos_left hb ha,
by rwa mul_zero at h
lemma mul_neg_of_neg_of_pos (ha : a < 0) (hb : 0 < b) : a * b < 0 :=
have h : a * b < 0 * b, from mul_lt_mul_of_pos_right ha hb,
by rwa zero_mul at h
-- See Note [decidable namespace]
protected lemma decidable.mul_self_lt_mul_self [@decidable_rel α (≤)]
(h1 : 0 ≤ a) (h2 : a < b) : a * a < b * b :=
decidable.mul_lt_mul' h2.le h2 h1 $ h1.trans_lt h2
lemma mul_self_lt_mul_self (h1 : 0 ≤ a) (h2 : a < b) : a * a < b * b :=
mul_lt_mul' h2.le h2 h1 $ h1.trans_lt h2
-- See Note [decidable namespace]
protected lemma decidable.strict_mono_on_mul_self [@decidable_rel α (≤)] :
strict_mono_on (λ x : α, x * x) (set.Ici 0) :=
λ x hx y hy hxy, decidable.mul_self_lt_mul_self hx hxy
lemma strict_mono_on_mul_self : strict_mono_on (λ x : α, x * x) (set.Ici 0) :=
λ x hx y hy hxy, mul_self_lt_mul_self hx hxy
-- See Note [decidable namespace]
protected lemma decidable.mul_self_le_mul_self [@decidable_rel α (≤)]
(h1 : 0 ≤ a) (h2 : a ≤ b) : a * a ≤ b * b :=
decidable.mul_le_mul h2 h2 h1 $ h1.trans h2
lemma mul_self_le_mul_self (h1 : 0 ≤ a) (h2 : a ≤ b) : a * a ≤ b * b :=
mul_le_mul h2 h2 h1 $ h1.trans h2
-- See Note [decidable namespace]
protected lemma decidable.mul_lt_mul'' [@decidable_rel α (≤)]
(h1 : a < c) (h2 : b < d) (h3 : 0 ≤ a) (h4 : 0 ≤ b) : a * b < c * d :=
h4.lt_or_eq_dec.elim
(λ b0, decidable.mul_lt_mul h1 h2.le b0 $ h3.trans h1.le)
(λ b0, by rw [← b0, mul_zero]; exact
mul_pos (h3.trans_lt h1) (h4.trans_lt h2))
lemma mul_lt_mul'' : a < c → b < d → 0 ≤ a → 0 ≤ b → a * b < c * d :=
by classical; exact decidable.mul_lt_mul''
-- See Note [decidable namespace]
protected lemma decidable.le_mul_of_one_le_right [@decidable_rel α (≤)]
(hb : 0 ≤ b) (h : 1 ≤ a) : b ≤ b * a :=
suffices b * 1 ≤ b * a, by rwa mul_one at this,
decidable.mul_le_mul_of_nonneg_left h hb
lemma le_mul_of_one_le_right : 0 ≤ b → 1 ≤ a → b ≤ b * a :=
by classical; exact decidable.le_mul_of_one_le_right
-- See Note [decidable namespace]
protected lemma decidable.le_mul_of_one_le_left [@decidable_rel α (≤)]
(hb : 0 ≤ b) (h : 1 ≤ a) : b ≤ a * b :=
suffices 1 * b ≤ a * b, by rwa one_mul at this,
decidable.mul_le_mul_of_nonneg_right h hb
lemma le_mul_of_one_le_left : 0 ≤ b → 1 ≤ a → b ≤ a * b :=
by classical; exact decidable.le_mul_of_one_le_left
-- See Note [decidable namespace]
protected lemma decidable.lt_mul_of_one_lt_right [@decidable_rel α (≤)]
(hb : 0 < b) (h : 1 < a) : b < b * a :=
suffices b * 1 < b * a, by rwa mul_one at this,
decidable.mul_lt_mul' le_rfl h zero_le_one hb
lemma lt_mul_of_one_lt_right : 0 < b → 1 < a → b < b * a :=
by classical; exact decidable.lt_mul_of_one_lt_right
-- See Note [decidable namespace]
protected lemma decidable.lt_mul_of_one_lt_left [@decidable_rel α (≤)]
(hb : 0 < b) (h : 1 < a) : b < a * b :=
suffices 1 * b < a * b, by rwa one_mul at this,
decidable.mul_lt_mul h le_rfl hb (zero_le_one.trans h.le)
lemma lt_mul_of_one_lt_left : 0 < b → 1 < a → b < a * b :=
by classical; exact decidable.lt_mul_of_one_lt_left
lemma lt_two_mul_self [nontrivial α] (ha : 0 < a) : a < 2 * a :=
lt_mul_of_one_lt_left ha one_lt_two
-- See Note [decidable namespace]
protected lemma decidable.add_le_mul_two_add [@decidable_rel α (≤)] {a b : α}
(a2 : 2 ≤ a) (b0 : 0 ≤ b) : a + (2 + b) ≤ a * (2 + b) :=
calc a + (2 + b) ≤ a + (a + a * b) :
add_le_add_left (add_le_add a2 (decidable.le_mul_of_one_le_left b0 (one_le_two.trans a2))) a
... ≤ a * (2 + b) : by rw [mul_add, mul_two, add_assoc]
lemma add_le_mul_two_add {a b : α} : 2 ≤ a → 0 ≤ b → a + (2 + b) ≤ a * (2 + b) :=
by classical; exact decidable.add_le_mul_two_add
-- See Note [decidable namespace]
protected lemma decidable.one_le_mul_of_one_le_of_one_le [@decidable_rel α (≤)]
{a b : α} (a1 : 1 ≤ a) (b1 : 1 ≤ b) : (1 : α) ≤ a * b :=
(mul_one (1 : α)).symm.le.trans (decidable.mul_le_mul a1 b1 zero_le_one (zero_le_one.trans a1))
lemma one_le_mul_of_one_le_of_one_le {a b : α} : 1 ≤ a → 1 ≤ b → (1 : α) ≤ a * b :=
by classical; exact decidable.one_le_mul_of_one_le_of_one_le
/-- Pullback an `ordered_semiring` under an injective map.
See note [reducible non-instances]. -/
@[reducible]
def function.injective.ordered_semiring {β : Type*}
[has_zero β] [has_one β] [has_add β] [has_mul β] [has_pow β ℕ]
[has_scalar ℕ β] [has_nat_cast β]
(f : β → α) (hf : function.injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(nsmul : ∀ x (n : ℕ), f (n • x) = n • f x) (npow : ∀ x (n : ℕ), f (x ^ n) = f x ^ n)
(nat_cast : ∀ n : ℕ, f n = n) :
ordered_semiring β :=
{ zero_le_one := show f 0 ≤ f 1, by simp only [zero, one, zero_le_one],
mul_lt_mul_of_pos_left := λ a b c ab c0, show f (c * a) < f (c * b),
begin
rw [mul, mul],
refine mul_lt_mul_of_pos_left ab _,
rwa ← zero,
end,
mul_lt_mul_of_pos_right := λ a b c ab c0, show f (a * c) < f (b * c),
begin
rw [mul, mul],
refine mul_lt_mul_of_pos_right ab _,
rwa ← zero,
end,
..hf.ordered_cancel_add_comm_monoid f zero add nsmul,
..hf.semiring f zero one add mul nsmul npow nat_cast }
section
variable [nontrivial α]
lemma bit1_pos (h : 0 ≤ a) : 0 < bit1 a :=
lt_add_of_le_of_pos (add_nonneg h h) zero_lt_one
lemma lt_add_one (a : α) : a < a + 1 :=
lt_add_of_le_of_pos le_rfl zero_lt_one
lemma lt_one_add (a : α) : a < 1 + a :=
by { rw [add_comm], apply lt_add_one }
end
lemma bit1_pos' (h : 0 < a) : 0 < bit1 a :=
begin
nontriviality,
exact bit1_pos h.le,
end
-- See Note [decidable namespace]
protected lemma decidable.one_lt_mul [@decidable_rel α (≤)]
(ha : 1 ≤ a) (hb : 1 < b) : 1 < a * b :=
begin
nontriviality,
exact (one_mul (1 : α)) ▸ decidable.mul_lt_mul' ha hb zero_le_one (zero_lt_one.trans_le ha)
end
lemma one_lt_mul : 1 ≤ a → 1 < b → 1 < a * b :=
by classical; exact decidable.one_lt_mul
-- See Note [decidable namespace]
protected lemma decidable.mul_le_one [@decidable_rel α (≤)]
(ha : a ≤ 1) (hb' : 0 ≤ b) (hb : b ≤ 1) : a * b ≤ 1 :=
one_mul (1 : α) ▸ decidable.mul_le_mul ha hb hb' zero_le_one
lemma mul_le_one : a ≤ 1 → 0 ≤ b → b ≤ 1 → a * b ≤ 1 :=
by classical; exact decidable.mul_le_one
-- See Note [decidable namespace]
protected lemma decidable.one_lt_mul_of_le_of_lt [@decidable_rel α (≤)]
(ha : 1 ≤ a) (hb : 1 < b) : 1 < a * b :=
begin
nontriviality,
calc 1 = 1 * 1 : by rw one_mul
... < a * b : decidable.mul_lt_mul' ha hb zero_le_one (zero_lt_one.trans_le ha)
end
lemma one_lt_mul_of_le_of_lt : 1 ≤ a → 1 < b → 1 < a * b :=
by classical; exact decidable.one_lt_mul_of_le_of_lt
-- See Note [decidable namespace]
protected lemma decidable.one_lt_mul_of_lt_of_le [@decidable_rel α (≤)]
(ha : 1 < a) (hb : 1 ≤ b) : 1 < a * b :=
begin
nontriviality,
calc 1 = 1 * 1 : by rw one_mul
... < a * b : decidable.mul_lt_mul ha hb zero_lt_one $ zero_le_one.trans ha.le
end
lemma one_lt_mul_of_lt_of_le : 1 < a → 1 ≤ b → 1 < a * b :=
by classical; exact decidable.one_lt_mul_of_lt_of_le
-- See Note [decidable namespace]
protected lemma decidable.mul_le_of_le_one_right [@decidable_rel α (≤)]
(ha : 0 ≤ a) (hb1 : b ≤ 1) : a * b ≤ a :=
calc a * b ≤ a * 1 : decidable.mul_le_mul_of_nonneg_left hb1 ha
... = a : mul_one a
lemma mul_le_of_le_one_right : 0 ≤ a → b ≤ 1 → a * b ≤ a :=
by classical; exact decidable.mul_le_of_le_one_right
-- See Note [decidable namespace]
protected lemma decidable.mul_le_of_le_one_left [@decidable_rel α (≤)]
(hb : 0 ≤ b) (ha1 : a ≤ 1) : a * b ≤ b :=
calc a * b ≤ 1 * b : decidable.mul_le_mul ha1 le_rfl hb zero_le_one
... = b : one_mul b
lemma mul_le_of_le_one_left : 0 ≤ b → a ≤ 1 → a * b ≤ b :=
by classical; exact decidable.mul_le_of_le_one_left
-- See Note [decidable namespace]
protected lemma decidable.mul_lt_one_of_nonneg_of_lt_one_left [@decidable_rel α (≤)]
(ha0 : 0 ≤ a) (ha : a < 1) (hb : b ≤ 1) : a * b < 1 :=
calc a * b ≤ a : decidable.mul_le_of_le_one_right ha0 hb
... < 1 : ha
lemma mul_lt_one_of_nonneg_of_lt_one_left : 0 ≤ a → a < 1 → b ≤ 1 → a * b < 1 :=
by classical; exact decidable.mul_lt_one_of_nonneg_of_lt_one_left
-- See Note [decidable namespace]
protected lemma decidable.mul_lt_one_of_nonneg_of_lt_one_right [@decidable_rel α (≤)]
(ha : a ≤ 1) (hb0 : 0 ≤ b) (hb : b < 1) : a * b < 1 :=
calc a * b ≤ b : decidable.mul_le_of_le_one_left hb0 ha
... < 1 : hb
lemma mul_lt_one_of_nonneg_of_lt_one_right : a ≤ 1 → 0 ≤ b → b < 1 → a * b < 1 :=
by classical; exact decidable.mul_lt_one_of_nonneg_of_lt_one_right
theorem nat.strict_mono_cast [nontrivial α] : strict_mono (coe : ℕ → α) :=
strict_mono_nat_of_lt_succ $ λ n, by rw [nat.cast_succ]; apply lt_add_one
/-- Note this is not an instance as `char_zero` implies `nontrivial`,
and this would risk forming a loop. -/
lemma ordered_semiring.to_char_zero [nontrivial α] : char_zero α :=
⟨nat.strict_mono_cast.injective⟩
section has_exists_add_of_le
variables [has_exists_add_of_le α]
/-- Binary **rearrangement inequality**. -/
lemma mul_add_mul_le_mul_add_mul (hab : a ≤ b) (hcd : c ≤ d) : a * d + b * c ≤ a * c + b * d :=
begin
obtain ⟨b, rfl⟩ := exists_add_of_le hab,
obtain ⟨d, rfl⟩ := exists_add_of_le hcd,
rw [mul_add, add_right_comm, mul_add, ←add_assoc],
exact add_le_add_left (mul_le_mul_of_nonneg_right hab $ (le_add_iff_nonneg_right _).1 hcd) _,
end
/-- Binary **rearrangement inequality**. -/
lemma mul_add_mul_le_mul_add_mul' (hba : b ≤ a) (hdc : d ≤ c) : a • d + b • c ≤ a • c + b • d :=
by { rw [add_comm (a • d), add_comm (a • c)], exact mul_add_mul_le_mul_add_mul hba hdc }
/-- Binary strict **rearrangement inequality**. -/
lemma mul_add_mul_lt_mul_add_mul (hab : a < b) (hcd : c < d) : a * d + b * c < a * c + b * d :=
begin
obtain ⟨b, rfl⟩ := exists_add_of_le hab.le,
obtain ⟨d, rfl⟩ := exists_add_of_le hcd.le,
rw [mul_add, add_right_comm, mul_add, ←add_assoc],
exact add_lt_add_left (mul_lt_mul_of_pos_right hab $ (lt_add_iff_pos_right _).1 hcd) _,
end
/-- Binary **rearrangement inequality**. -/
lemma mul_add_mul_lt_mul_add_mul' (hba : b < a) (hdc : d < c) : a • d + b • c < a • c + b • d :=
by { rw [add_comm (a • d), add_comm (a • c)], exact mul_add_mul_lt_mul_add_mul hba hdc }
end has_exists_add_of_le
end ordered_semiring
section ordered_comm_semiring
/-- An `ordered_comm_semiring α` is a commutative semiring `α` with a partial order such that
addition is monotone and multiplication by a positive number is strictly monotone. -/
@[protect_proj]
class ordered_comm_semiring (α : Type u) extends ordered_semiring α, comm_semiring α
/-- Pullback an `ordered_comm_semiring` under an injective map.
See note [reducible non-instances]. -/
@[reducible]
def function.injective.ordered_comm_semiring [ordered_comm_semiring α] {β : Type*}
[add_monoid_with_one β] [has_mul β] [has_pow β ℕ]
(f : β → α) (hf : function.injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(nsmul : ∀ x (n : ℕ), f (n • x) = n • f x) (npow : ∀ x (n : ℕ), f (x ^ n) = f x ^ n)
(nat_cast : ∀ n : ℕ, f n = n) :
ordered_comm_semiring β :=
{ ..hf.comm_semiring f zero one add mul nsmul npow nat_cast,
..hf.ordered_semiring f zero one add mul nsmul npow nat_cast }
end ordered_comm_semiring
/--
A `linear_ordered_semiring α` is a nontrivial semiring `α` with a linear order
such that addition is monotone and multiplication by a positive number is strictly monotone.
-/
-- It's not entirely clear we should assume `nontrivial` at this point;
-- it would be reasonable to explore changing this,
-- but be warned that the instances involving `domain` may cause
-- typeclass search loops.
@[protect_proj]
class linear_ordered_semiring (α : Type u)
extends ordered_semiring α, linear_ordered_add_comm_monoid α, nontrivial α
section linear_ordered_semiring
variables [linear_ordered_semiring α] {a b c d : α}
-- `norm_num` expects the lemma stating `0 < 1` to have a single typeclass argument
-- (see `norm_num.prove_pos_nat`).
-- Rather than working out how to relax that assumption,
-- we provide a synonym for `zero_lt_one` (which needs both `ordered_semiring α` and `nontrivial α`)
-- with only a `linear_ordered_semiring` typeclass argument.
lemma zero_lt_one' : 0 < (1 : α) := zero_lt_one
lemma lt_of_mul_lt_mul_left (h : c * a < c * b) (hc : 0 ≤ c) : a < b :=
by haveI := @linear_order.decidable_le α _; exact lt_of_not_ge
(assume h1 : b ≤ a,
have h2 : c * b ≤ c * a, from decidable.mul_le_mul_of_nonneg_left h1 hc,
h2.not_lt h)
lemma lt_of_mul_lt_mul_right (h : a * c < b * c) (hc : 0 ≤ c) : a < b :=
by haveI := @linear_order.decidable_le α _; exact lt_of_not_ge
(assume h1 : b ≤ a,
have h2 : b * c ≤ a * c, from decidable.mul_le_mul_of_nonneg_right h1 hc,
h2.not_lt h)
lemma le_of_mul_le_mul_left (h : c * a ≤ c * b) (hc : 0 < c) : a ≤ b :=
le_of_not_gt
(assume h1 : b < a,
have h2 : c * b < c * a, from mul_lt_mul_of_pos_left h1 hc,
h2.not_le h)
lemma le_of_mul_le_mul_right (h : a * c ≤ b * c) (hc : 0 < c) : a ≤ b :=
le_of_not_gt
(assume h1 : b < a,
have h2 : b * c < a * c, from mul_lt_mul_of_pos_right h1 hc,
h2.not_le h)
lemma pos_and_pos_or_neg_and_neg_of_mul_pos (hab : 0 < a * b) :
(0 < a ∧ 0 < b) ∨ (a < 0 ∧ b < 0) :=
begin
haveI := @linear_order.decidable_le α _,
rcases lt_trichotomy 0 a with (ha|rfl|ha),
{ refine or.inl ⟨ha, lt_imp_lt_of_le_imp_le (λ hb, _) hab⟩,
exact decidable.mul_nonpos_of_nonneg_of_nonpos ha.le hb },
{ rw [zero_mul] at hab, exact hab.false.elim },
{ refine or.inr ⟨ha, lt_imp_lt_of_le_imp_le (λ hb, _) hab⟩,
exact decidable.mul_nonpos_of_nonpos_of_nonneg ha.le hb }
end
lemma nonneg_and_nonneg_or_nonpos_and_nonpos_of_mul_nnonneg (hab : 0 ≤ a * b) :
(0 ≤ a ∧ 0 ≤ b) ∨ (a ≤ 0 ∧ b ≤ 0) :=
begin
haveI := @linear_order.decidable_le α _,
refine decidable.or_iff_not_and_not.2 _,
simp only [not_and, not_le], intros ab nab, apply not_lt_of_le hab _,
rcases lt_trichotomy 0 a with (ha|rfl|ha),
exacts [mul_neg_of_pos_of_neg ha (ab ha.le), ((ab le_rfl).asymm (nab le_rfl)).elim,
mul_neg_of_neg_of_pos ha (nab ha.le)]
end
lemma pos_of_mul_pos_left (h : 0 < a * b) (ha : 0 ≤ a) : 0 < b :=
((pos_and_pos_or_neg_and_neg_of_mul_pos h).resolve_right $ λ h, h.1.not_le ha).2
lemma pos_of_mul_pos_right (h : 0 < a * b) (hb : 0 ≤ b) : 0 < a :=
((pos_and_pos_or_neg_and_neg_of_mul_pos h).resolve_right $ λ h, h.2.not_le hb).1
lemma pos_iff_pos_of_mul_pos (hab : 0 < a * b) : 0 < a ↔ 0 < b :=
⟨pos_of_mul_pos_left hab ∘ le_of_lt, pos_of_mul_pos_right hab ∘ le_of_lt⟩
lemma neg_of_mul_pos_left (h : 0 < a * b) (ha : a ≤ 0) : b < 0 :=
((pos_and_pos_or_neg_and_neg_of_mul_pos h).resolve_left $ λ h, h.1.not_le ha).2
lemma neg_of_mul_pos_right (h : 0 < a * b) (ha : b ≤ 0) : a < 0 :=
((pos_and_pos_or_neg_and_neg_of_mul_pos h).resolve_left $ λ h, h.2.not_le ha).1
lemma neg_iff_neg_of_mul_pos (hab : 0 < a * b) : a < 0 ↔ b < 0 :=
⟨neg_of_mul_pos_left hab ∘ le_of_lt, neg_of_mul_pos_right hab ∘ le_of_lt⟩
lemma nonneg_of_mul_nonneg_left (h : 0 ≤ a * b) (h1 : 0 < a) : 0 ≤ b :=
le_of_not_gt (assume h2 : b < 0, (mul_neg_of_pos_of_neg h1 h2).not_le h)
lemma nonneg_of_mul_nonneg_right (h : 0 ≤ a * b) (h1 : 0 < b) : 0 ≤ a :=
le_of_not_gt (assume h2 : a < 0, (mul_neg_of_neg_of_pos h2 h1).not_le h)
lemma neg_of_mul_neg_left (h : a * b < 0) (h1 : 0 ≤ a) : b < 0 :=
by haveI := @linear_order.decidable_le α _; exact
lt_of_not_ge (assume h2 : b ≥ 0, (decidable.mul_nonneg h1 h2).not_lt h)
lemma neg_of_mul_neg_right (h : a * b < 0) (h1 : 0 ≤ b) : a < 0 :=
by haveI := @linear_order.decidable_le α _; exact
lt_of_not_ge (assume h2 : a ≥ 0, (decidable.mul_nonneg h2 h1).not_lt h)
lemma nonpos_of_mul_nonpos_left (h : a * b ≤ 0) (h1 : 0 < a) : b ≤ 0 :=
le_of_not_gt (assume h2 : b > 0, (mul_pos h1 h2).not_le h)
lemma nonpos_of_mul_nonpos_right (h : a * b ≤ 0) (h1 : 0 < b) : a ≤ 0 :=
le_of_not_gt (assume h2 : a > 0, (mul_pos h2 h1).not_le h)
@[simp] lemma mul_le_mul_left (h : 0 < c) : c * a ≤ c * b ↔ a ≤ b :=
by haveI := @linear_order.decidable_le α _; exact
⟨λ h', le_of_mul_le_mul_left h' h, λ h', decidable.mul_le_mul_of_nonneg_left h' h.le⟩
@[simp] lemma mul_le_mul_right (h : 0 < c) : a * c ≤ b * c ↔ a ≤ b :=
by haveI := @linear_order.decidable_le α _; exact
⟨λ h', le_of_mul_le_mul_right h' h, λ h', decidable.mul_le_mul_of_nonneg_right h' h.le⟩
@[simp] lemma mul_lt_mul_left (h : 0 < c) : c * a < c * b ↔ a < b :=
by haveI := @linear_order.decidable_le α _; exact
⟨lt_imp_lt_of_le_imp_le $ λ h', decidable.mul_le_mul_of_nonneg_left h' h.le,
λ h', mul_lt_mul_of_pos_left h' h⟩
@[simp] lemma mul_lt_mul_right (h : 0 < c) : a * c < b * c ↔ a < b :=
by haveI := @linear_order.decidable_le α _; exact
⟨lt_imp_lt_of_le_imp_le $ λ h', decidable.mul_le_mul_of_nonneg_right h' h.le,
λ h', mul_lt_mul_of_pos_right h' h⟩
@[simp] lemma zero_le_mul_left (h : 0 < c) : 0 ≤ c * b ↔ 0 ≤ b :=
by { convert mul_le_mul_left h, simp }
@[simp] lemma zero_le_mul_right (h : 0 < c) : 0 ≤ b * c ↔ 0 ≤ b :=
by { convert mul_le_mul_right h, simp }
@[simp] lemma zero_lt_mul_left (h : 0 < c) : 0 < c * b ↔ 0 < b :=
by { convert mul_lt_mul_left h, simp }
@[simp] lemma zero_lt_mul_right (h : 0 < c) : 0 < b * c ↔ 0 < b :=
by { convert mul_lt_mul_right h, simp }
lemma add_le_mul_of_left_le_right (a2 : 2 ≤ a) (ab : a ≤ b) : a + b ≤ a * b :=
have 0 < b, from
calc 0 < 2 : zero_lt_two
... ≤ a : a2
... ≤ b : ab,
calc a + b ≤ b + b : add_le_add_right ab b
... = 2 * b : (two_mul b).symm
... ≤ a * b : (mul_le_mul_right this).mpr a2
lemma add_le_mul_of_right_le_left (b2 : 2 ≤ b) (ba : b ≤ a) : a + b ≤ a * b :=
have 0 < a, from
calc 0 < 2 : zero_lt_two
... ≤ b : b2
... ≤ a : ba,
calc a + b ≤ a + a : add_le_add_left ba a
... = a * 2 : (mul_two a).symm
... ≤ a * b : (mul_le_mul_left this).mpr b2
lemma add_le_mul (a2 : 2 ≤ a) (b2 : 2 ≤ b) : a + b ≤ a * b :=
if hab : a ≤ b then add_le_mul_of_left_le_right a2 hab
else add_le_mul_of_right_le_left b2 (le_of_not_le hab)
lemma add_le_mul' (a2 : 2 ≤ a) (b2 : 2 ≤ b) : a + b ≤ b * a :=
(le_of_eq (add_comm _ _)).trans (add_le_mul b2 a2)
section
@[simp] lemma bit0_le_bit0 : bit0 a ≤ bit0 b ↔ a ≤ b :=
by rw [bit0, bit0, ← two_mul, ← two_mul, mul_le_mul_left (zero_lt_two : 0 < (2:α))]
@[simp] lemma bit0_lt_bit0 : bit0 a < bit0 b ↔ a < b :=
by rw [bit0, bit0, ← two_mul, ← two_mul, mul_lt_mul_left (zero_lt_two : 0 < (2:α))]
@[simp] lemma bit1_le_bit1 : bit1 a ≤ bit1 b ↔ a ≤ b :=
(add_le_add_iff_right 1).trans bit0_le_bit0
@[simp] lemma bit1_lt_bit1 : bit1 a < bit1 b ↔ a < b :=
(add_lt_add_iff_right 1).trans bit0_lt_bit0
@[simp] lemma one_le_bit1 : (1 : α) ≤ bit1 a ↔ 0 ≤ a :=
by rw [bit1, le_add_iff_nonneg_left, bit0, ← two_mul, zero_le_mul_left (zero_lt_two : 0 < (2:α))]
@[simp] lemma one_lt_bit1 : (1 : α) < bit1 a ↔ 0 < a :=
by rw [bit1, lt_add_iff_pos_left, bit0, ← two_mul, zero_lt_mul_left (zero_lt_two : 0 < (2:α))]
@[simp] lemma zero_le_bit0 : (0 : α) ≤ bit0 a ↔ 0 ≤ a :=
by rw [bit0, ← two_mul, zero_le_mul_left (zero_lt_two : 0 < (2:α))]
@[simp] lemma zero_lt_bit0 : (0 : α) < bit0 a ↔ 0 < a :=
by rw [bit0, ← two_mul, zero_lt_mul_left (zero_lt_two : 0 < (2:α))]
end
lemma le_mul_iff_one_le_left (hb : 0 < b) : b ≤ a * b ↔ 1 ≤ a :=
suffices 1 * b ≤ a * b ↔ 1 ≤ a, by rwa one_mul at this,
mul_le_mul_right hb
lemma lt_mul_iff_one_lt_left (hb : 0 < b) : b < a * b ↔ 1 < a :=
suffices 1 * b < a * b ↔ 1 < a, by rwa one_mul at this,
mul_lt_mul_right hb
lemma le_mul_iff_one_le_right (hb : 0 < b) : b ≤ b * a ↔ 1 ≤ a :=
suffices b * 1 ≤ b * a ↔ 1 ≤ a, by rwa mul_one at this,
mul_le_mul_left hb
lemma lt_mul_iff_one_lt_right (hb : 0 < b) : b < b * a ↔ 1 < a :=
suffices b * 1 < b * a ↔ 1 < a, by rwa mul_one at this,
mul_lt_mul_left hb
theorem mul_nonneg_iff_right_nonneg_of_pos (ha : 0 < a) : 0 ≤ a * b ↔ 0 ≤ b :=
by haveI := @linear_order.decidable_le α _; exact
⟨λ h, nonneg_of_mul_nonneg_left h ha, λ h, decidable.mul_nonneg ha.le h⟩
theorem mul_nonneg_iff_left_nonneg_of_pos (hb : 0 < b) : 0 ≤ a * b ↔ 0 ≤ a :=
by haveI := @linear_order.decidable_le α _; exact
⟨λ h, nonneg_of_mul_nonneg_right h hb, λ h, decidable.mul_nonneg h hb.le⟩
lemma mul_le_iff_le_one_left (hb : 0 < b) : a * b ≤ b ↔ a ≤ 1 :=
⟨ λ h, le_of_not_lt (mt (lt_mul_iff_one_lt_left hb).2 h.not_lt),
λ h, le_of_not_lt (mt (lt_mul_iff_one_lt_left hb).1 h.not_lt) ⟩
lemma mul_lt_iff_lt_one_left (hb : 0 < b) : a * b < b ↔ a < 1 :=
lt_iff_lt_of_le_iff_le $ le_mul_iff_one_le_left hb
lemma mul_le_iff_le_one_right (hb : 0 < b) : b * a ≤ b ↔ a ≤ 1 :=
⟨ λ h, le_of_not_lt (mt (lt_mul_iff_one_lt_right hb).2 h.not_lt),
λ h, le_of_not_lt (mt (lt_mul_iff_one_lt_right hb).1 h.not_lt) ⟩
lemma mul_lt_iff_lt_one_right (hb : 0 < b) : b * a < b ↔ a < 1 :=
lt_iff_lt_of_le_iff_le $ le_mul_iff_one_le_right hb
-- TODO: `left` and `right` for these two lemmas are backwards compared to `neg_of_mul_pos`
-- lemmas.
lemma nonpos_of_mul_nonneg_left (h : 0 ≤ a * b) (hb : b < 0) : a ≤ 0 :=
le_of_not_gt (λ ha, absurd h (mul_neg_of_pos_of_neg ha hb).not_le)
lemma nonpos_of_mul_nonneg_right (h : 0 ≤ a * b) (ha : a < 0) : b ≤ 0 :=
le_of_not_gt (λ hb, absurd h (mul_neg_of_neg_of_pos ha hb).not_le)
@[priority 100] -- see Note [lower instance priority]
instance linear_ordered_semiring.to_no_max_order {α : Type*} [linear_ordered_semiring α] :
no_max_order α :=
⟨assume a, ⟨a + 1, lt_add_of_pos_right _ zero_lt_one⟩⟩
/-- Pullback a `linear_ordered_semiring` under an injective map.
See note [reducible non-instances]. -/
@[reducible]
def function.injective.linear_ordered_semiring {β : Type*}
[has_zero β] [has_one β] [has_add β] [has_mul β] [has_pow β ℕ] [has_scalar ℕ β] [has_nat_cast β]
(f : β → α) (hf : function.injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(nsmul : ∀ x (n : ℕ), f (n • x) = n • f x) (npow : ∀ x (n : ℕ), f (x ^ n) = f x ^ n)
(nat_cast : ∀ n : ℕ, f n = n) :
linear_ordered_semiring β :=
{ .. linear_order.lift f hf,
.. pullback_nonzero f zero one,
.. hf.ordered_semiring f zero one add mul nsmul npow nat_cast }
@[simp] lemma units.inv_pos {u : αˣ} : (0 : α) < ↑u⁻¹ ↔ (0 : α) < u :=
have ∀ {u : αˣ}, (0 : α) < u → (0 : α) < ↑u⁻¹ := λ u h,
(zero_lt_mul_left h).mp $ u.mul_inv.symm ▸ zero_lt_one,
⟨this, this⟩
@[simp] lemma units.inv_neg {u : αˣ} : ↑u⁻¹ < (0 : α) ↔ ↑u < (0 : α) :=
have ∀ {u : αˣ}, ↑u < (0 : α) → ↑u⁻¹ < (0 : α) := λ u h,
neg_of_mul_pos_left (by exact (u.mul_inv.symm ▸ zero_lt_one)) h.le,
⟨this, this⟩
@[priority 100] -- see Note [lower instance priority]
instance linear_ordered_semiring.to_char_zero : char_zero α :=
ordered_semiring.to_char_zero
end linear_ordered_semiring
section mono
variables {β : Type*} [linear_ordered_semiring α] [preorder β] {f g : β → α} {a : α}
lemma monotone_mul_left_of_nonneg (ha : 0 ≤ a) : monotone (λ x, a*x) :=
by haveI := @linear_order.decidable_le α _; exact
assume b c b_le_c, decidable.mul_le_mul_of_nonneg_left b_le_c ha
lemma monotone_mul_right_of_nonneg (ha : 0 ≤ a) : monotone (λ x, x*a) :=
by haveI := @linear_order.decidable_le α _; exact
assume b c b_le_c, decidable.mul_le_mul_of_nonneg_right b_le_c ha
lemma monotone.mul_const (hf : monotone f) (ha : 0 ≤ a) :
monotone (λ x, (f x) * a) :=
(monotone_mul_right_of_nonneg ha).comp hf
lemma monotone.const_mul (hf : monotone f) (ha : 0 ≤ a) :
monotone (λ x, a * (f x)) :=
(monotone_mul_left_of_nonneg ha).comp hf
lemma monotone.mul (hf : monotone f) (hg : monotone g) (hf0 : ∀ x, 0 ≤ f x) (hg0 : ∀ x, 0 ≤ g x) :
monotone (λ x, f x * g x) :=
by haveI := @linear_order.decidable_le α _; exact
λ x y h, decidable.mul_le_mul (hf h) (hg h) (hg0 x) (hf0 y)
lemma strict_mono_mul_left_of_pos (ha : 0 < a) : strict_mono (λ x, a * x) :=
assume b c b_lt_c, (mul_lt_mul_left ha).2 b_lt_c
lemma strict_mono_mul_right_of_pos (ha : 0 < a) : strict_mono (λ x, x * a) :=
assume b c b_lt_c, (mul_lt_mul_right ha).2 b_lt_c
lemma strict_mono.mul_const (hf : strict_mono f) (ha : 0 < a) :
strict_mono (λ x, (f x) * a) :=
(strict_mono_mul_right_of_pos ha).comp hf
lemma strict_mono.const_mul (hf : strict_mono f) (ha : 0 < a) :
strict_mono (λ x, a * (f x)) :=
(strict_mono_mul_left_of_pos ha).comp hf
lemma strict_mono.mul_monotone (hf : strict_mono f) (hg : monotone g) (hf0 : ∀ x, 0 ≤ f x)
(hg0 : ∀ x, 0 < g x) :
strict_mono (λ x, f x * g x) :=
by haveI := @linear_order.decidable_le α _; exact
λ x y h, decidable.mul_lt_mul (hf h) (hg h.le) (hg0 x) (hf0 y)
lemma monotone.mul_strict_mono (hf : monotone f) (hg : strict_mono g) (hf0 : ∀ x, 0 < f x)
(hg0 : ∀ x, 0 ≤ g x) :
strict_mono (λ x, f x * g x) :=
by haveI := @linear_order.decidable_le α _; exact
λ x y h, decidable.mul_lt_mul' (hf h.le) (hg h) (hg0 x) (hf0 y)
lemma strict_mono.mul (hf : strict_mono f) (hg : strict_mono g) (hf0 : ∀ x, 0 ≤ f x)
(hg0 : ∀ x, 0 ≤ g x) :
strict_mono (λ x, f x * g x) :=
by haveI := @linear_order.decidable_le α _; exact
λ x y h, decidable.mul_lt_mul'' (hf h) (hg h) (hf0 x) (hg0 x)
end mono
section linear_ordered_semiring
variables [linear_ordered_semiring α] {a b c : α}
lemma mul_max_of_nonneg (b c : α) (ha : 0 ≤ a) : a * max b c = max (a * b) (a * c) :=
(monotone_mul_left_of_nonneg ha).map_max
lemma mul_min_of_nonneg (b c : α) (ha : 0 ≤ a) : a * min b c = min (a * b) (a * c) :=
(monotone_mul_left_of_nonneg ha).map_min
lemma max_mul_of_nonneg (a b : α) (hc : 0 ≤ c) : max a b * c = max (a * c) (b * c) :=
(monotone_mul_right_of_nonneg hc).map_max
lemma min_mul_of_nonneg (a b : α) (hc : 0 ≤ c) : min a b * c = min (a * c) (b * c) :=
(monotone_mul_right_of_nonneg hc).map_min
end linear_ordered_semiring
/-- An `ordered_ring α` is a ring `α` with a partial order such that
addition is monotone and multiplication by a positive number is strictly monotone. -/
@[protect_proj]
class ordered_ring (α : Type u) extends ring α, ordered_add_comm_group α :=
(zero_le_one : 0 ≤ (1 : α))
(mul_pos : ∀ a b : α, 0 < a → 0 < b → 0 < a * b)
section ordered_ring
variables [ordered_ring α] {a b c : α}
-- See Note [decidable namespace]
protected lemma decidable.ordered_ring.mul_nonneg [@decidable_rel α (≤)]
{a b : α} (h₁ : 0 ≤ a) (h₂ : 0 ≤ b) : 0 ≤ a * b :=
begin
by_cases ha : a ≤ 0, { simp [le_antisymm ha h₁] },
by_cases hb : b ≤ 0, { simp [le_antisymm hb h₂] },
exact (le_not_le_of_lt (ordered_ring.mul_pos a b (h₁.lt_of_not_le ha) (h₂.lt_of_not_le hb))).1,
end
lemma ordered_ring.mul_nonneg : 0 ≤ a → 0 ≤ b → 0 ≤ a * b :=
by classical; exact decidable.ordered_ring.mul_nonneg
-- See Note [decidable namespace]
protected lemma decidable.ordered_ring.mul_le_mul_of_nonneg_left
[@decidable_rel α (≤)] (h₁ : a ≤ b) (h₂ : 0 ≤ c) : c * a ≤ c * b :=
begin
rw [← sub_nonneg, ← mul_sub],
exact decidable.ordered_ring.mul_nonneg h₂ (sub_nonneg.2 h₁),
end
lemma ordered_ring.mul_le_mul_of_nonneg_left : a ≤ b → 0 ≤ c → c * a ≤ c * b :=
by classical; exact decidable.ordered_ring.mul_le_mul_of_nonneg_left
-- See Note [decidable namespace]
protected lemma decidable.ordered_ring.mul_le_mul_of_nonneg_right
[@decidable_rel α (≤)] (h₁ : a ≤ b) (h₂ : 0 ≤ c) : a * c ≤ b * c :=
begin
rw [← sub_nonneg, ← sub_mul],
exact decidable.ordered_ring.mul_nonneg (sub_nonneg.2 h₁) h₂,
end
lemma ordered_ring.mul_le_mul_of_nonneg_right : a ≤ b → 0 ≤ c → a * c ≤ b * c :=
by classical; exact decidable.ordered_ring.mul_le_mul_of_nonneg_right
lemma ordered_ring.mul_lt_mul_of_pos_left (h₁ : a < b) (h₂ : 0 < c) : c * a < c * b :=
begin
rw [← sub_pos, ← mul_sub],
exact ordered_ring.mul_pos _ _ h₂ (sub_pos.2 h₁),
end
lemma ordered_ring.mul_lt_mul_of_pos_right (h₁ : a < b) (h₂ : 0 < c) : a * c < b * c :=
begin
rw [← sub_pos, ← sub_mul],
exact ordered_ring.mul_pos _ _ (sub_pos.2 h₁) h₂,
end
@[priority 100] -- see Note [lower instance priority]
instance ordered_ring.to_ordered_semiring : ordered_semiring α :=
{ mul_zero := mul_zero,
zero_mul := zero_mul,
add_left_cancel := @add_left_cancel α _,
le_of_add_le_add_left := @le_of_add_le_add_left α _ _ _,
mul_lt_mul_of_pos_left := @ordered_ring.mul_lt_mul_of_pos_left α _,
mul_lt_mul_of_pos_right := @ordered_ring.mul_lt_mul_of_pos_right α _,
..‹ordered_ring α› }
-- See Note [decidable namespace]
protected lemma decidable.mul_le_mul_of_nonpos_left [@decidable_rel α (≤)]
{a b c : α} (h : b ≤ a) (hc : c ≤ 0) : c * a ≤ c * b :=
have -c ≥ 0, from neg_nonneg_of_nonpos hc,
have -c * b ≤ -c * a, from decidable.mul_le_mul_of_nonneg_left h this,
have -(c * b) ≤ -(c * a), by rwa [neg_mul, neg_mul] at this,
le_of_neg_le_neg this
lemma mul_le_mul_of_nonpos_left {a b c : α} : b ≤ a → c ≤ 0 → c * a ≤ c * b :=
by classical; exact decidable.mul_le_mul_of_nonpos_left
-- See Note [decidable namespace]
protected lemma decidable.mul_le_mul_of_nonpos_right [@decidable_rel α (≤)]
{a b c : α} (h : b ≤ a) (hc : c ≤ 0) : a * c ≤ b * c :=
have -c ≥ 0, from neg_nonneg_of_nonpos hc,
have b * -c ≤ a * -c, from decidable.mul_le_mul_of_nonneg_right h this,
have -(b * c) ≤ -(a * c), by rwa [mul_neg, mul_neg] at this,
le_of_neg_le_neg this
lemma mul_le_mul_of_nonpos_right {a b c : α} : b ≤ a → c ≤ 0 → a * c ≤ b * c :=
by classical; exact decidable.mul_le_mul_of_nonpos_right
-- See Note [decidable namespace]
protected lemma decidable.mul_nonneg_of_nonpos_of_nonpos [@decidable_rel α (≤)]
{a b : α} (ha : a ≤ 0) (hb : b ≤ 0) : 0 ≤ a * b :=
have 0 * b ≤ a * b, from decidable.mul_le_mul_of_nonpos_right ha hb,
by rwa zero_mul at this
lemma mul_nonneg_of_nonpos_of_nonpos {a b : α} : a ≤ 0 → b ≤ 0 → 0 ≤ a * b :=
by classical; exact decidable.mul_nonneg_of_nonpos_of_nonpos
lemma mul_lt_mul_of_neg_left {a b c : α} (h : b < a) (hc : c < 0) : c * a < c * b :=
have -c > 0, from neg_pos_of_neg hc,
have -c * b < -c * a, from mul_lt_mul_of_pos_left h this,
have -(c * b) < -(c * a), by rwa [neg_mul, neg_mul] at this,
lt_of_neg_lt_neg this
lemma mul_lt_mul_of_neg_right {a b c : α} (h : b < a) (hc : c < 0) : a * c < b * c :=
have -c > 0, from neg_pos_of_neg hc,
have b * -c < a * -c, from mul_lt_mul_of_pos_right h this,
have -(b * c) < -(a * c), by rwa [mul_neg, mul_neg] at this,
lt_of_neg_lt_neg this
lemma mul_pos_of_neg_of_neg {a b : α} (ha : a < 0) (hb : b < 0) : 0 < a * b :=
have 0 * b < a * b, from mul_lt_mul_of_neg_right ha hb,
by rwa zero_mul at this
/-- Pullback an `ordered_ring` under an injective map.
See note [reducible non-instances]. -/
@[reducible]
def function.injective.ordered_ring {β : Type*}
[has_zero β] [has_one β] [has_add β] [has_mul β] [has_neg β] [has_sub β]
[has_scalar ℕ β] [has_scalar ℤ β] [has_pow β ℕ] [has_nat_cast β] [has_int_cast β]
(f : β → α) (hf : function.injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(neg : ∀ x, f (- x) = - f x) (sub : ∀ x y, f (x - y) = f x - f y)
(nsmul : ∀ x (n : ℕ), f (n • x) = n • f x) (zsmul : ∀ x (n : ℤ), f (n • x) = n • f x)
(npow : ∀ x (n : ℕ), f (x ^ n) = f x ^ n)
(nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) :
ordered_ring β :=
{ mul_pos := λ a b a0 b0, show f 0 < f (a * b), by { rw [zero, mul], apply mul_pos; rwa ← zero },
..hf.ordered_semiring f zero one add mul nsmul npow nat_cast,
..hf.ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast }
lemma le_iff_exists_nonneg_add (a b : α) : a ≤ b ↔ ∃ c ≥ 0, b = a + c :=
⟨λ h, ⟨b - a, sub_nonneg.mpr h, by simp⟩,
λ ⟨c, hc, h⟩, by { rw [h, le_add_iff_nonneg_right], exact hc }⟩
end ordered_ring
section ordered_comm_ring
/-- An `ordered_comm_ring α` is a commutative ring `α` with a partial order such that
addition is monotone and multiplication by a positive number is strictly monotone. -/
@[protect_proj]
class ordered_comm_ring (α : Type u) extends ordered_ring α, comm_ring α
@[priority 100] -- See note [lower instance priority]
instance ordered_comm_ring.to_ordered_comm_semiring {α : Type u} [ordered_comm_ring α] :
ordered_comm_semiring α :=
{ .. (by apply_instance : ordered_semiring α),
.. ‹ordered_comm_ring α› }
/-- Pullback an `ordered_comm_ring` under an injective map.
See note [reducible non-instances]. -/
@[reducible]
def function.injective.ordered_comm_ring [ordered_comm_ring α] {β : Type*}
[has_zero β] [has_one β] [has_add β] [has_mul β] [has_neg β] [has_sub β]
[has_pow β ℕ] [has_scalar ℕ β] [has_scalar ℤ β] [has_nat_cast β] [has_int_cast β]
(f : β → α) (hf : function.injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(neg : ∀ x, f (- x) = - f x) (sub : ∀ x y, f (x - y) = f x - f y)
(nsmul : ∀ x (n : ℕ), f (n • x) = n • f x) (zsmul : ∀ x (n : ℤ), f (n • x) = n • f x)
(npow : ∀ x (n : ℕ), f (x ^ n) = f x ^ n)
(nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) :
ordered_comm_ring β :=
{ ..hf.ordered_ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast,
..hf.comm_ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast }
end ordered_comm_ring
/-- A `linear_ordered_ring α` is a ring `α` with a linear order such that
addition is monotone and multiplication by a positive number is strictly monotone. -/
@[protect_proj] class linear_ordered_ring (α : Type u)
extends ordered_ring α, linear_order α, nontrivial α
@[priority 100] -- see Note [lower instance priority]
instance linear_ordered_ring.to_linear_ordered_add_comm_group [s : linear_ordered_ring α] :
linear_ordered_add_comm_group α :=
{ .. s }
section linear_ordered_semiring
variables [linear_ordered_semiring α] {a b c : α}
local attribute [instance] linear_ordered_semiring.decidable_le
lemma le_of_mul_le_of_one_le {a b c : α} (h : a * c ≤ b) (hb : 0 ≤ b) (hc : 1 ≤ c) : a ≤ b :=
have h' : a * c ≤ b * c, from calc
a * c ≤ b : h
... = b * 1 : by rewrite mul_one
... ≤ b * c : decidable.mul_le_mul_of_nonneg_left hc hb,
le_of_mul_le_mul_right h' (zero_lt_one.trans_le hc)
lemma nonneg_le_nonneg_of_sq_le_sq {a b : α} (hb : 0 ≤ b) (h : a * a ≤ b * b) : a ≤ b :=
le_of_not_gt (λhab, (decidable.mul_self_lt_mul_self hb hab).not_le h)
lemma mul_self_le_mul_self_iff {a b : α} (h1 : 0 ≤ a) (h2 : 0 ≤ b) : a ≤ b ↔ a * a ≤ b * b :=
⟨decidable.mul_self_le_mul_self h1, nonneg_le_nonneg_of_sq_le_sq h2⟩
lemma mul_self_lt_mul_self_iff {a b : α} (h1 : 0 ≤ a) (h2 : 0 ≤ b) : a < b ↔ a * a < b * b :=
((@decidable.strict_mono_on_mul_self α _ _).lt_iff_lt h1 h2).symm
lemma mul_self_inj {a b : α} (h1 : 0 ≤ a) (h2 : 0 ≤ b) : a * a = b * b ↔ a = b :=
(@decidable.strict_mono_on_mul_self α _ _).inj_on.eq_iff h1 h2
end linear_ordered_semiring
section linear_ordered_ring
variables [linear_ordered_ring α] {a b c : α}
@[priority 100] -- see Note [lower instance priority]
instance linear_ordered_ring.to_linear_ordered_semiring : linear_ordered_semiring α :=
{ mul_zero := mul_zero,
zero_mul := zero_mul,
add_left_cancel := @add_left_cancel α _,
le_of_add_le_add_left := @le_of_add_le_add_left α _ _ _,
mul_lt_mul_of_pos_left := @mul_lt_mul_of_pos_left α _,
mul_lt_mul_of_pos_right := @mul_lt_mul_of_pos_right α _,
le_total := linear_ordered_ring.le_total,
..‹linear_ordered_ring α› }
@[priority 100] -- see Note [lower instance priority]
instance linear_ordered_ring.is_domain : is_domain α :=
{ eq_zero_or_eq_zero_of_mul_eq_zero :=
begin
intros a b hab,
refine decidable.or_iff_not_and_not.2 (λ h, _), revert hab,
cases lt_or_gt_of_ne h.1 with ha ha; cases lt_or_gt_of_ne h.2 with hb hb,
exacts [(mul_pos_of_neg_of_neg ha hb).ne.symm, (mul_neg_of_neg_of_pos ha hb).ne,
(mul_neg_of_pos_of_neg ha hb).ne, (mul_pos ha hb).ne.symm]
end,
.. ‹linear_ordered_ring α› }
@[simp] lemma abs_one : |(1 : α)| = 1 := abs_of_pos zero_lt_one
@[simp] lemma abs_two : |(2 : α)| = 2 := abs_of_pos zero_lt_two
lemma abs_mul (a b : α) : |a * b| = |a| * |b| :=
begin
haveI := @linear_order.decidable_le α _,
rw [abs_eq (decidable.mul_nonneg (abs_nonneg a) (abs_nonneg b))],
cases le_total a 0 with ha ha; cases le_total b 0 with hb hb;
simp only [abs_of_nonpos, abs_of_nonneg, true_or, or_true, eq_self_iff_true,
neg_mul, mul_neg, neg_neg, *]
end
/-- `abs` as a `monoid_with_zero_hom`. -/
def abs_hom : α →*₀ α := ⟨abs, abs_zero, abs_one, abs_mul⟩
@[simp] lemma abs_mul_abs_self (a : α) : |a| * |a| = a * a :=
abs_by_cases (λ x, x * x = a * a) rfl (neg_mul_neg a a)
@[simp] lemma abs_mul_self (a : α) : |a * a| = a * a :=
by rw [abs_mul, abs_mul_abs_self]
lemma mul_pos_iff : 0 < a * b ↔ 0 < a ∧ 0 < b ∨ a < 0 ∧ b < 0 :=
⟨pos_and_pos_or_neg_and_neg_of_mul_pos,
λ h, h.elim (and_imp.2 mul_pos) (and_imp.2 mul_pos_of_neg_of_neg)⟩
lemma mul_neg_iff : a * b < 0 ↔ 0 < a ∧ b < 0 ∨ a < 0 ∧ 0 < b :=
by rw [← neg_pos, neg_mul_eq_mul_neg, mul_pos_iff, neg_pos, neg_lt_zero]
lemma mul_nonneg_iff : 0 ≤ a * b ↔ 0 ≤ a ∧ 0 ≤ b ∨ a ≤ 0 ∧ b ≤ 0 :=
by haveI := @linear_order.decidable_le α _; exact
⟨nonneg_and_nonneg_or_nonpos_and_nonpos_of_mul_nnonneg,
λ h, h.elim (and_imp.2 decidable.mul_nonneg) (and_imp.2 decidable.mul_nonneg_of_nonpos_of_nonpos)⟩
/-- Out of three elements of a `linear_ordered_ring`, two must have the same sign. -/
lemma mul_nonneg_of_three (a b c : α) :
0 ≤ a * b ∨ 0 ≤ b * c ∨ 0 ≤ c * a :=
by iterate 3 { rw mul_nonneg_iff };
have := le_total 0 a; have := le_total 0 b; have := le_total 0 c; itauto
lemma mul_nonpos_iff : a * b ≤ 0 ↔ 0 ≤ a ∧ b ≤ 0 ∨ a ≤ 0 ∧ 0 ≤ b :=
by rw [← neg_nonneg, neg_mul_eq_mul_neg, mul_nonneg_iff, neg_nonneg, neg_nonpos]
lemma mul_self_nonneg (a : α) : 0 ≤ a * a :=
abs_mul_self a ▸ abs_nonneg _
@[simp] lemma neg_le_self_iff : -a ≤ a ↔ 0 ≤ a :=
by simp [neg_le_iff_add_nonneg, ← two_mul, mul_nonneg_iff, zero_le_one, (@zero_lt_two α _ _).not_le]
@[simp] lemma neg_lt_self_iff : -a < a ↔ 0 < a :=
by simp [neg_lt_iff_pos_add, ← two_mul, mul_pos_iff, zero_lt_one, (@zero_lt_two α _ _).not_lt]
@[simp] lemma le_neg_self_iff : a ≤ -a ↔ a ≤ 0 :=
calc a ≤ -a ↔ -(-a) ≤ -a : by rw neg_neg
... ↔ 0 ≤ -a : neg_le_self_iff
... ↔ a ≤ 0 : neg_nonneg
@[simp] lemma lt_neg_self_iff : a < -a ↔ a < 0 :=
calc a < -a ↔ -(-a) < -a : by rw neg_neg
... ↔ 0 < -a : neg_lt_self_iff
... ↔ a < 0 : neg_pos
@[simp] lemma abs_eq_self : |a| = a ↔ 0 ≤ a := by simp [abs_eq_max_neg]
@[simp] lemma abs_eq_neg_self : |a| = -a ↔ a ≤ 0 := by simp [abs_eq_max_neg]
/-- For an element `a` of a linear ordered ring, either `abs a = a` and `0 ≤ a`,
or `abs a = -a` and `a < 0`.
Use cases on this lemma to automate linarith in inequalities -/
lemma abs_cases (a : α) : (|a| = a ∧ 0 ≤ a) ∨ (|a| = -a ∧ a < 0) :=
begin
by_cases 0 ≤ a,
{ left,
exact ⟨abs_eq_self.mpr h, h⟩ },
{ right,
push_neg at h,
exact ⟨abs_eq_neg_self.mpr (le_of_lt h), h⟩ }
end
@[simp] lemma max_zero_add_max_neg_zero_eq_abs_self (a : α) :
max a 0 + max (-a) 0 = |a| :=
begin
symmetry,
rcases le_total 0 a with ha|ha;
simp [ha],
end
lemma gt_of_mul_lt_mul_neg_left (h : c * a < c * b) (hc : c ≤ 0) : b < a :=
have nhc : 0 ≤ -c, from neg_nonneg_of_nonpos hc,
have h2 : -(c * b) < -(c * a), from neg_lt_neg h,
have h3 : (-c) * b < (-c) * a, from calc
(-c) * b = - (c * b) : by rewrite neg_mul_eq_neg_mul
... < -(c * a) : h2
... = (-c) * a : by rewrite neg_mul_eq_neg_mul,
lt_of_mul_lt_mul_left h3 nhc
lemma neg_one_lt_zero : -1 < (0:α) := neg_lt_zero.2 zero_lt_one
@[simp] lemma mul_le_mul_left_of_neg {a b c : α} (h : c < 0) : c * a ≤ c * b ↔ b ≤ a :=
by haveI := @linear_order.decidable_le α _; exact
⟨le_imp_le_of_lt_imp_lt $ λ h', mul_lt_mul_of_neg_left h' h,
λ h', decidable.mul_le_mul_of_nonpos_left h' h.le⟩
@[simp] lemma mul_le_mul_right_of_neg {a b c : α} (h : c < 0) : a * c ≤ b * c ↔ b ≤ a :=
by haveI := @linear_order.decidable_le α _; exact
⟨le_imp_le_of_lt_imp_lt $ λ h', mul_lt_mul_of_neg_right h' h,
λ h', decidable.mul_le_mul_of_nonpos_right h' h.le⟩
@[simp] lemma mul_lt_mul_left_of_neg {a b c : α} (h : c < 0) : c * a < c * b ↔ b < a :=
lt_iff_lt_of_le_iff_le (mul_le_mul_left_of_neg h)
@[simp] lemma mul_lt_mul_right_of_neg {a b c : α} (h : c < 0) : a * c < b * c ↔ b < a :=
lt_iff_lt_of_le_iff_le (mul_le_mul_right_of_neg h)
lemma sub_one_lt (a : α) : a - 1 < a :=
sub_lt_iff_lt_add.2 (lt_add_one a)
@[simp] lemma mul_self_pos {a : α} : 0 < a * a ↔ a ≠ 0 :=
begin
split,
{ rintro h rfl, rw mul_zero at h, exact h.false },
{ intro h,
cases h.lt_or_lt with h h,
exacts [mul_pos_of_neg_of_neg h h, mul_pos h h] }
end
lemma mul_self_le_mul_self_of_le_of_neg_le {x y : α} (h₁ : x ≤ y) (h₂ : -x ≤ y) : x * x ≤ y * y :=
begin
haveI := @linear_order.decidable_le α _,
rw [← abs_mul_abs_self x],
exact decidable.mul_self_le_mul_self (abs_nonneg x) (abs_le.2 ⟨neg_le.2 h₂, h₁⟩)
end
lemma nonneg_of_mul_nonpos_left {a b : α} (h : a * b ≤ 0) (hb : b < 0) : 0 ≤ a :=
le_of_not_gt (λ ha, absurd h (mul_pos_of_neg_of_neg ha hb).not_le)
lemma nonneg_of_mul_nonpos_right {a b : α} (h : a * b ≤ 0) (ha : a < 0) : 0 ≤ b :=
le_of_not_gt (λ hb, absurd h (mul_pos_of_neg_of_neg ha hb).not_le)
lemma pos_of_mul_neg_left {a b : α} (h : a * b < 0) (hb : b ≤ 0) : 0 < a :=
by haveI := @linear_order.decidable_le α _; exact
lt_of_not_ge (λ ha, absurd h (decidable.mul_nonneg_of_nonpos_of_nonpos ha hb).not_lt)
lemma pos_of_mul_neg_right {a b : α} (h : a * b < 0) (ha : a ≤ 0) : 0 < b :=
by haveI := @linear_order.decidable_le α _; exact
lt_of_not_ge (λ hb, absurd h (decidable.mul_nonneg_of_nonpos_of_nonpos ha hb).not_lt)
lemma neg_iff_pos_of_mul_neg (hab : a * b < 0) : a < 0 ↔ 0 < b :=
⟨pos_of_mul_neg_right hab ∘ le_of_lt, neg_of_mul_neg_right hab ∘ le_of_lt⟩
lemma pos_iff_neg_of_mul_neg (hab : a * b < 0) : 0 < a ↔ b < 0 :=
⟨neg_of_mul_neg_left hab ∘ le_of_lt, pos_of_mul_neg_left hab ∘ le_of_lt⟩
/-- The sum of two squares is zero iff both elements are zero. -/
lemma mul_self_add_mul_self_eq_zero {x y : α} : x * x + y * y = 0 ↔ x = 0 ∧ y = 0 :=
by rw [add_eq_zero_iff', mul_self_eq_zero, mul_self_eq_zero]; apply mul_self_nonneg
lemma eq_zero_of_mul_self_add_mul_self_eq_zero (h : a * a + b * b = 0) : a = 0 :=
(mul_self_add_mul_self_eq_zero.mp h).left
lemma abs_eq_iff_mul_self_eq : |a| = |b| ↔ a * a = b * b :=
begin
rw [← abs_mul_abs_self, ← abs_mul_abs_self b],
exact (mul_self_inj (abs_nonneg a) (abs_nonneg b)).symm,
end
lemma abs_lt_iff_mul_self_lt : |a| < |b| ↔ a * a < b * b :=
begin
rw [← abs_mul_abs_self, ← abs_mul_abs_self b],
exact mul_self_lt_mul_self_iff (abs_nonneg a) (abs_nonneg b)
end
lemma abs_le_iff_mul_self_le : |a| ≤ |b| ↔ a * a ≤ b * b :=
begin
rw [← abs_mul_abs_self, ← abs_mul_abs_self b],
exact mul_self_le_mul_self_iff (abs_nonneg a) (abs_nonneg b)
end
lemma abs_le_one_iff_mul_self_le_one : |a| ≤ 1 ↔ a * a ≤ 1 :=
by simpa only [abs_one, one_mul] using @abs_le_iff_mul_self_le α _ a 1
/-- Pullback a `linear_ordered_ring` under an injective map.
See note [reducible non-instances]. -/
@[reducible]
def function.injective.linear_ordered_ring {β : Type*}
[has_zero β] [has_one β] [has_add β] [has_mul β] [has_neg β] [has_sub β]
[has_scalar ℕ β] [has_scalar ℤ β] [has_pow β ℕ] [has_nat_cast β] [has_int_cast β]
(f : β → α) (hf : function.injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(neg : ∀ x, f (-x) = -f x) (sub : ∀ x y, f (x - y) = f x - f y)
(nsmul : ∀ x (n : ℕ), f (n • x) = n • f x) (zsmul : ∀ x (n : ℤ), f (n • x) = n • f x)
(npow : ∀ x (n : ℕ), f (x ^ n) = f x ^ n)
(nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) :
linear_ordered_ring β :=
{ .. linear_order.lift f hf,
.. pullback_nonzero f zero one,
.. hf.ordered_ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast }
end linear_ordered_ring
/-- A `linear_ordered_comm_ring α` is a commutative ring `α` with a linear order
such that addition is monotone and multiplication by a positive number is strictly monotone. -/
@[protect_proj]
class linear_ordered_comm_ring (α : Type u) extends linear_ordered_ring α, comm_monoid α
@[priority 100] -- see Note [lower instance priority]
instance linear_ordered_comm_ring.to_ordered_comm_ring [d : linear_ordered_comm_ring α] :
ordered_comm_ring α :=
{ ..d }
@[priority 100] -- see Note [lower instance priority]
instance linear_ordered_comm_ring.to_linear_ordered_semiring [d : linear_ordered_comm_ring α] :
linear_ordered_semiring α :=
{ .. d, ..linear_ordered_ring.to_linear_ordered_semiring }
section linear_ordered_comm_ring
variables [linear_ordered_comm_ring α] {a b c d : α}
lemma max_mul_mul_le_max_mul_max (b c : α) (ha : 0 ≤ a) (hd: 0 ≤ d) :
max (a * b) (d * c) ≤ max a c * max d b :=
by haveI := @linear_order.decidable_le α _; exact
have ba : b * a ≤ max d b * max c a, from
decidable.mul_le_mul (le_max_right d b) (le_max_right c a) ha (le_trans hd (le_max_left d b)),
have cd : c * d ≤ max a c * max b d, from
decidable.mul_le_mul (le_max_right a c) (le_max_right b d) hd (le_trans ha (le_max_left a c)),
max_le
(by simpa [mul_comm, max_comm] using ba)
(by simpa [mul_comm, max_comm] using cd)
lemma abs_sub_sq (a b : α) : |a - b| * |a - b| = a * a + b * b - (1 + 1) * a * b :=
begin
rw abs_mul_abs_self,
simp only [mul_add, add_comm, add_left_comm, mul_comm, sub_eq_add_neg,
mul_one, mul_neg, neg_add_rev, neg_neg],
end
end linear_ordered_comm_ring
section
variables [ring α] [linear_order α] {a b : α}
@[simp] lemma abs_dvd (a b : α) : |a| ∣ b ↔ a ∣ b :=
by { cases abs_choice a with h h; simp only [h, neg_dvd] }
lemma abs_dvd_self (a : α) : |a| ∣ a :=
(abs_dvd a a).mpr (dvd_refl a)
@[simp] lemma dvd_abs (a b : α) : a ∣ |b| ↔ a ∣ b :=
by { cases abs_choice b with h h; simp only [h, dvd_neg] }
lemma self_dvd_abs (a : α) : a ∣ |a| :=
(dvd_abs a a).mpr (dvd_refl a)
lemma abs_dvd_abs (a b : α) : |a| ∣ |b| ↔ a ∣ b :=
(abs_dvd _ _).trans (dvd_abs _ _)
end
section linear_ordered_comm_ring
variables [linear_ordered_comm_ring α]
/-- Pullback a `linear_ordered_comm_ring` under an injective map.
See note [reducible non-instances]. -/
@[reducible]
def function.injective.linear_ordered_comm_ring {β : Type*}
[has_zero β] [has_one β] [has_add β] [has_mul β] [has_neg β] [has_sub β]
[has_pow β ℕ] [has_scalar ℕ β] [has_scalar ℤ β] [has_nat_cast β] [has_int_cast β]
(f : β → α) (hf : function.injective f) (zero : f 0 = 0) (one : f 1 = 1)
(add : ∀ x y, f (x + y) = f x + f y) (mul : ∀ x y, f (x * y) = f x * f y)
(neg : ∀ x, f (-x) = -f x) (sub : ∀ x y, f (x - y) = f x - f y)
(nsmul : ∀ x (n : ℕ), f (n • x) = n • f x) (zsmul : ∀ x (n : ℤ), f (n • x) = n • f x)
(npow : ∀ x (n : ℕ), f (x ^ n) = f x ^ n)
(nat_cast : ∀ n : ℕ, f n = n) (int_cast : ∀ n : ℤ, f n = n) :
linear_ordered_comm_ring β :=
{ .. linear_order.lift f hf,
.. pullback_nonzero f zero one,
.. hf.ordered_comm_ring f zero one add mul neg sub nsmul zsmul npow nat_cast int_cast }
end linear_ordered_comm_ring
namespace ring
/-- A positive cone in a ring consists of a positive cone in underlying `add_comm_group`,
which contains `1` and such that the positive elements are closed under multiplication. -/
@[nolint has_inhabited_instance]
structure positive_cone (α : Type*) [ring α] extends add_comm_group.positive_cone α :=
(one_nonneg : nonneg 1)
(mul_pos : ∀ (a b), pos a → pos b → pos (a * b))
/-- Forget that a positive cone in a ring respects the multiplicative structure. -/
add_decl_doc positive_cone.to_positive_cone
/-- A positive cone in a ring induces a linear order if `1` is a positive element. -/
@[nolint has_inhabited_instance]
structure total_positive_cone (α : Type*) [ring α]
extends positive_cone α, add_comm_group.total_positive_cone α :=
(one_pos : pos 1)
/-- Forget that a `total_positive_cone` in a ring is total. -/
add_decl_doc total_positive_cone.to_positive_cone
/-- Forget that a `total_positive_cone` in a ring respects the multiplicative structure. -/
add_decl_doc total_positive_cone.to_total_positive_cone
end ring
namespace ordered_ring
open ring
/-- Construct an `ordered_ring` by
designating a positive cone in an existing `ring`. -/
def mk_of_positive_cone {α : Type*} [ring α] (C : positive_cone α) :
ordered_ring α :=
{ zero_le_one := by { change C.nonneg (1 - 0), convert C.one_nonneg, simp, },
mul_pos := λ x y xp yp, begin
change C.pos (x*y - 0),
convert C.mul_pos x y (by { convert xp, simp, }) (by { convert yp, simp, }),
simp,
end,
..‹ring α›,
..ordered_add_comm_group.mk_of_positive_cone C.to_positive_cone }
end ordered_ring
namespace linear_ordered_ring
open ring
/-- Construct a `linear_ordered_ring` by
designating a positive cone in an existing `ring`. -/
def mk_of_positive_cone {α : Type*} [ring α] (C : total_positive_cone α) :
linear_ordered_ring α :=
{ exists_pair_ne := ⟨0, 1, begin
intro h,
have one_pos := C.one_pos,
rw [←h, C.pos_iff] at one_pos,
simpa using one_pos,
end⟩,
..ordered_ring.mk_of_positive_cone C.to_positive_cone,
..linear_ordered_add_comm_group.mk_of_positive_cone C.to_total_positive_cone, }
end linear_ordered_ring
/-- A canonically ordered commutative semiring is an ordered, commutative semiring
in which `a ≤ b` iff there exists `c` with `b = a + c`. This is satisfied by the
natural numbers, for example, but not the integers or other ordered groups. -/
@[protect_proj]
class canonically_ordered_comm_semiring (α : Type*) extends
canonically_ordered_add_monoid α, comm_semiring α :=
(eq_zero_or_eq_zero_of_mul_eq_zero : ∀ a b : α, a * b = 0 → a = 0 ∨ b = 0)
namespace canonically_ordered_comm_semiring
variables [canonically_ordered_comm_semiring α] {a b : α}
@[priority 100] -- see Note [lower instance priority]
instance to_no_zero_divisors : no_zero_divisors α :=
⟨canonically_ordered_comm_semiring.eq_zero_or_eq_zero_of_mul_eq_zero⟩
@[priority 100] -- see Note [lower instance priority]
instance to_covariant_mul_le : covariant_class α α (*) (≤) :=
begin
refine ⟨λ a b c h, _⟩,
rcases le_iff_exists_add.1 h with ⟨c, rfl⟩,
rw mul_add,
apply self_le_add_right
end
/-- A version of `zero_lt_one : 0 < 1` for a `canonically_ordered_comm_semiring`. -/
lemma zero_lt_one [nontrivial α] : (0:α) < 1 := (zero_le 1).lt_of_ne zero_ne_one
@[simp] lemma mul_pos : 0 < a * b ↔ (0 < a) ∧ (0 < b) :=
by simp only [pos_iff_ne_zero, ne.def, mul_eq_zero, not_or_distrib]
end canonically_ordered_comm_semiring
section sub
variables [canonically_ordered_comm_semiring α] {a b c : α}
variables [has_sub α] [has_ordered_sub α]
variables [is_total α (≤)]
namespace add_le_cancellable
protected lemma mul_tsub (h : add_le_cancellable (a * c)) :
a * (b - c) = a * b - a * c :=
begin
cases total_of (≤) b c with hbc hcb,
{ rw [tsub_eq_zero_iff_le.2 hbc, mul_zero, tsub_eq_zero_iff_le.2 (mul_le_mul_left' hbc a)] },
{ apply h.eq_tsub_of_add_eq, rw [← mul_add, tsub_add_cancel_of_le hcb] }
end
protected lemma tsub_mul (h : add_le_cancellable (b * c)) : (a - b) * c = a * c - b * c :=
by { simp only [mul_comm _ c] at *, exact h.mul_tsub }
end add_le_cancellable
variables [contravariant_class α α (+) (≤)]
lemma mul_tsub (a b c : α) : a * (b - c) = a * b - a * c :=
contravariant.add_le_cancellable.mul_tsub
lemma tsub_mul (a b c : α) : (a - b) * c = a * c - b * c :=
contravariant.add_le_cancellable.tsub_mul
end sub
/-! ### Structures involving `*` and `0` on `with_top` and `with_bot`
The main results of this section are `with_top.canonically_ordered_comm_semiring` and
`with_bot.comm_monoid_with_zero`.
-/
namespace with_top
instance [nonempty α] : nontrivial (with_top α) :=
option.nontrivial
instance [add_monoid_with_one α] : add_monoid_with_one (with_top α) :=
{ nat_cast := λ n, ((n : α) : with_top α),
nat_cast_zero := show (((0 : ℕ) : α) : with_top α) = 0, by simp,
nat_cast_succ :=
show ∀ n, (((n + 1 : ℕ) : α) : with_top α) = (((n : ℕ) : α) : with_top α) + 1,
by simp [with_top.coe_add],
.. with_top.add_monoid, .. with_top.has_one }
variable [decidable_eq α]
section has_mul
variables [has_zero α] [has_mul α]
instance : mul_zero_class (with_top α) :=
{ zero := 0,
mul := λm n, if m = 0 ∨ n = 0 then 0 else m.bind (λa, n.bind $ λb, ↑(a * b)),
zero_mul := assume a, if_pos $ or.inl rfl,
mul_zero := assume a, if_pos $ or.inr rfl }
lemma mul_def {a b : with_top α} :
a * b = if a = 0 ∨ b = 0 then 0 else a.bind (λa, b.bind $ λb, ↑(a * b)) := rfl
@[simp] lemma mul_top {a : with_top α} (h : a ≠ 0) : a * ⊤ = ⊤ :=
by cases a; simp [mul_def, h]; refl
@[simp] lemma top_mul {a : with_top α} (h : a ≠ 0) : ⊤ * a = ⊤ :=
by cases a; simp [mul_def, h]; refl
@[simp] lemma top_mul_top : (⊤ * ⊤ : with_top α) = ⊤ :=
top_mul top_ne_zero
end has_mul
section mul_zero_class
variables [mul_zero_class α]
@[norm_cast] lemma coe_mul {a b : α} : (↑(a * b) : with_top α) = a * b :=
decidable.by_cases (assume : a = 0, by simp [this]) $ assume ha,
decidable.by_cases (assume : b = 0, by simp [this]) $ assume hb,
by { simp [*, mul_def], refl }
lemma mul_coe {b : α} (hb : b ≠ 0) : ∀{a : with_top α}, a * b = a.bind (λa:α, ↑(a * b))
| none := show (if (⊤:with_top α) = 0 ∨ (b:with_top α) = 0 then 0 else ⊤ : with_top α) = ⊤,
by simp [hb]
| (some a) := show ↑a * ↑b = ↑(a * b), from coe_mul.symm
@[simp] lemma mul_eq_top_iff {a b : with_top α} : a * b = ⊤ ↔ (a ≠ 0 ∧ b = ⊤) ∨ (a = ⊤ ∧ b ≠ 0) :=
begin
cases a; cases b; simp only [none_eq_top, some_eq_coe],
{ simp [← coe_mul] },
{ suffices : ⊤ * (b : with_top α) = ⊤ ↔ b ≠ 0, by simpa,
by_cases hb : b = 0; simp [hb] },
{ suffices : (a : with_top α) * ⊤ = ⊤ ↔ a ≠ 0, by simpa,
by_cases ha : a = 0; simp [ha] },
{ simp [← coe_mul] }
end
lemma mul_lt_top [preorder α] {a b : with_top α} (ha : a ≠ ⊤) (hb : b ≠ ⊤) : a * b < ⊤ :=
begin
lift a to α using ha,
lift b to α using hb,
simp only [← coe_mul, coe_lt_top]
end
end mul_zero_class
/-- `nontrivial α` is needed here as otherwise we have `1 * ⊤ = ⊤` but also `= 0 * ⊤ = 0`. -/
instance [mul_zero_one_class α] [nontrivial α] : mul_zero_one_class (with_top α) :=
{ mul := (*),
one := 1,
zero := 0,
one_mul := λ a, match a with
| none := show ((1:α) : with_top α) * ⊤ = ⊤, by simp [-with_top.coe_one]
| (some a) := show ((1:α) : with_top α) * a = a, by simp [coe_mul.symm, -with_top.coe_one]
end,
mul_one := λ a, match a with
| none := show ⊤ * ((1:α) : with_top α) = ⊤, by simp [-with_top.coe_one]
| (some a) := show ↑a * ((1:α) : with_top α) = a, by simp [coe_mul.symm, -with_top.coe_one]
end,
.. with_top.mul_zero_class }
/-- A version of `with_top.map` for `monoid_with_zero_hom`s. -/
@[simps { fully_applied := ff }] protected def _root_.monoid_with_zero_hom.with_top_map
{R S : Type*} [mul_zero_one_class R] [decidable_eq R] [nontrivial R]
[mul_zero_one_class S] [decidable_eq S] [nontrivial S] (f : R →*₀ S) (hf : function.injective f) :
with_top R →*₀ with_top S :=
{ to_fun := with_top.map f,
map_mul' := λ x y,
begin
have : ∀ z, map f z = 0 ↔ z = 0,
from λ z, (option.map_injective hf).eq_iff' f.to_zero_hom.with_top_map.map_zero,
rcases eq_or_ne x 0 with rfl|hx, { simp },
rcases eq_or_ne y 0 with rfl|hy, { simp },
induction x using with_top.rec_top_coe, { simp [hy, this] },
induction y using with_top.rec_top_coe,
{ have : (f x : with_top S) ≠ 0, by simpa [hf.eq_iff' (map_zero f)] using hx,
simp [hx, this] },
simp [← coe_mul]
end,
.. f.to_zero_hom.with_top_map, .. f.to_monoid_hom.to_one_hom.with_top_map }
instance [mul_zero_class α] [no_zero_divisors α] : no_zero_divisors (with_top α) :=
⟨λ a b, by cases a; cases b; dsimp [mul_def]; split_ifs;
simp [*, none_eq_top, some_eq_coe, mul_eq_zero] at *⟩
instance [semigroup_with_zero α] [no_zero_divisors α] : semigroup_with_zero (with_top α) :=
{ mul := (*),
zero := 0,
mul_assoc := λ a b c, begin
cases a,
{ by_cases hb : b = 0; by_cases hc : c = 0;
simp [*, none_eq_top] },
cases b,
{ by_cases ha : a = 0; by_cases hc : c = 0;
simp [*, none_eq_top, some_eq_coe] },
cases c,
{ by_cases ha : a = 0; by_cases hb : b = 0;
simp [*, none_eq_top, some_eq_coe] },
simp [some_eq_coe, coe_mul.symm, mul_assoc]
end,
.. with_top.mul_zero_class }
instance [monoid_with_zero α] [no_zero_divisors α] [nontrivial α] : monoid_with_zero (with_top α) :=
{ .. with_top.mul_zero_one_class, .. with_top.semigroup_with_zero }
instance [comm_monoid_with_zero α] [no_zero_divisors α] [nontrivial α] :
comm_monoid_with_zero (with_top α) :=
{ mul := (*),
zero := 0,
mul_comm := λ a b, begin
by_cases ha : a = 0, { simp [ha] },
by_cases hb : b = 0, { simp [hb] },
simp [ha, hb, mul_def, option.bind_comm a b, mul_comm]
end,
.. with_top.monoid_with_zero }
variables [canonically_ordered_comm_semiring α]
private lemma distrib' (a b c : with_top α) : (a + b) * c = a * c + b * c :=
begin
cases c,
{ show (a + b) * ⊤ = a * ⊤ + b * ⊤,
by_cases ha : a = 0; simp [ha] },
{ show (a + b) * c = a * c + b * c,
by_cases hc : c = 0, { simp [hc] },
simp [mul_coe hc], cases a; cases b,
repeat { refl <|> exact congr_arg some (add_mul _ _ _) } }
end
/-- This instance requires `canonically_ordered_comm_semiring` as it is the smallest class
that derives from both `non_assoc_non_unital_semiring` and `canonically_ordered_add_monoid`, both
of which are required for distributivity. -/
instance [nontrivial α] : comm_semiring (with_top α) :=
{ right_distrib := distrib',
left_distrib := assume a b c, by rw [mul_comm, distrib', mul_comm b, mul_comm c]; refl,
.. with_top.add_monoid_with_one, .. with_top.add_comm_monoid, .. with_top.comm_monoid_with_zero }
instance [nontrivial α] : canonically_ordered_comm_semiring (with_top α) :=
{ .. with_top.comm_semiring,
.. with_top.canonically_ordered_add_monoid,
.. with_top.no_zero_divisors, }
/-- A version of `with_top.map` for `ring_hom`s. -/
@[simps { fully_applied := ff }] protected def _root_.ring_hom.with_top_map
{R S : Type*} [canonically_ordered_comm_semiring R] [decidable_eq R] [nontrivial R]
[canonically_ordered_comm_semiring S] [decidable_eq S] [nontrivial S]
(f : R →+* S) (hf : function.injective f) :
with_top R →+* with_top S :=
{ to_fun := with_top.map f,
.. f.to_monoid_with_zero_hom.with_top_map hf, .. f.to_add_monoid_hom.with_top_map }
end with_top
namespace with_bot
instance [nonempty α] : nontrivial (with_bot α) :=
option.nontrivial
instance [add_monoid_with_one α] : add_monoid_with_one (with_bot α) :=
{ nat_cast := λ n, ((n : α) : with_bot α),
nat_cast_zero := show (((0 : ℕ) : α) : with_bot α) = 0, by simp,
nat_cast_succ :=
show ∀ n, (((n + 1 : ℕ) : α) : with_bot α) = (((n : ℕ) : α) : with_bot α) + 1,
by simp [with_bot.coe_add],
.. with_bot.add_monoid, .. with_bot.has_one }
variable [decidable_eq α]
section has_mul
variables [has_zero α] [has_mul α]
instance : mul_zero_class (with_bot α) :=
with_top.mul_zero_class
lemma mul_def {a b : with_bot α} :
a * b = if a = 0 ∨ b = 0 then 0 else a.bind (λa, b.bind $ λb, ↑(a * b)) := rfl
@[simp] lemma mul_bot {a : with_bot α} (h : a ≠ 0) : a * ⊥ = ⊥ :=
with_top.mul_top h
@[simp] lemma bot_mul {a : with_bot α} (h : a ≠ 0) : ⊥ * a = ⊥ :=
with_top.top_mul h
@[simp] lemma bot_mul_bot : (⊥ * ⊥ : with_bot α) = ⊥ :=
with_top.top_mul_top
end has_mul
section mul_zero_class
variables [mul_zero_class α]
@[norm_cast] lemma coe_mul {a b : α} : (↑(a * b) : with_bot α) = a * b :=
decidable.by_cases (assume : a = 0, by simp [this]) $ assume ha,
decidable.by_cases (assume : b = 0, by simp [this]) $ assume hb,
by { simp [*, mul_def], refl }
lemma mul_coe {b : α} (hb : b ≠ 0) {a : with_bot α} : a * b = a.bind (λa:α, ↑(a * b)) :=
with_top.mul_coe hb
@[simp] lemma mul_eq_bot_iff {a b : with_bot α} : a * b = ⊥ ↔ (a ≠ 0 ∧ b = ⊥) ∨ (a = ⊥ ∧ b ≠ 0) :=
with_top.mul_eq_top_iff
lemma bot_lt_mul [preorder α] {a b : with_bot α} (ha : ⊥ < a) (hb : ⊥ < b) : ⊥ < a * b :=
begin
lift a to α using ne_bot_of_gt ha,
lift b to α using ne_bot_of_gt hb,
simp only [← coe_mul, bot_lt_coe],
end
end mul_zero_class
/-- `nontrivial α` is needed here as otherwise we have `1 * ⊥ = ⊥` but also `= 0 * ⊥ = 0`. -/
instance [mul_zero_one_class α] [nontrivial α] : mul_zero_one_class (with_bot α) :=
with_top.mul_zero_one_class
instance [mul_zero_class α] [no_zero_divisors α] : no_zero_divisors (with_bot α) :=
with_top.no_zero_divisors
instance [semigroup_with_zero α] [no_zero_divisors α] : semigroup_with_zero (with_bot α) :=
with_top.semigroup_with_zero
instance [monoid_with_zero α] [no_zero_divisors α] [nontrivial α] : monoid_with_zero (with_bot α) :=
with_top.monoid_with_zero
instance [comm_monoid_with_zero α] [no_zero_divisors α] [nontrivial α] :
comm_monoid_with_zero (with_bot α) :=
with_top.comm_monoid_with_zero
instance [canonically_ordered_comm_semiring α] [nontrivial α] : comm_semiring (with_bot α) :=
with_top.comm_semiring
end with_bot
|
-- {-# OPTIONS -v tc.lhs:100 #-}
module IrrelevantData where
data T (A : Set) : Set where
c : .A → T A
d : ∀ {A} → T A → A
d (c x) = x
-- needs to fail since x is irrelevant under c |
import data.real.basic
variables a b c : ℝ
#check mul_comm c
#check mul_assoc c b a
-- BEGIN
example (a b c : ℝ) : a * (b * c) = b * (c * a) :=
begin
rw mul_comm a,
sorry,
end
example (a b c : ℝ) : a * (b * c) = b * (a * c) :=
begin
rw mul_comm,
sorry,
end
-- END |
[STATEMENT]
lemma complete_c_K5: "K\<^bsub>5\<^esub> c_K5"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. K\<^bsub>5\<^esub> (with_proj c_K5)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. K\<^bsub>5\<^esub> (with_proj c_K5)
[PROOF STEP]
interpret K5: pair_graph c_K5
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. pair_graph c_K5
[PROOF STEP]
by eval
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. K\<^bsub>5\<^esub> (with_proj c_K5)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. K\<^bsub>5\<^esub> (with_proj c_K5)
[PROOF STEP]
unfolding complete_digraph_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. graph (with_proj c_K5) \<and> card (verts (with_proj c_K5)) = 5 \<and> arcs_ends (with_proj c_K5) = {(u, v). (u, v) \<in> verts (with_proj c_K5) \<times> verts (with_proj c_K5) \<and> u \<noteq> v}
[PROOF STEP]
by (auto simp: c_K5_simps)
[PROOF STATE]
proof (state)
this:
K\<^bsub>5\<^esub> (with_proj c_K5)
goal:
No subgoals!
[PROOF STEP]
qed |
[STATEMENT]
lemma sig_inv_setI: "keys (vectorize_poly r) \<subseteq> {0..<j} \<Longrightarrow> r \<in> sig_inv_set' j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. keys (vectorize_poly r) \<subseteq> {0..<j} \<Longrightarrow> r \<in> sig_inv_set' j
[PROOF STEP]
by (simp add: sig_inv_set'_def) |
lemma open_delete: fixes s :: "'a::t1_space set" shows "open s \<Longrightarrow> open (s - {x})" |
%% OMAS SYSTEM ENUMS (OMAS_systemType.m) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
classdef OMAS_systemType < uint8
enumeration
windows(0);
OSX(1);
linux(2);
end
end |
theory BExp imports AExp begin
subsection "Boolean Expressions"
datatype bexp = Bc bool | Not bexp | And bexp bexp | Less aexp aexp
fun bval :: "bexp \<Rightarrow> state \<Rightarrow> bool" where
"bval (Bc v) s = v" |
"bval (Not b) s = (\<not> bval b s)" |
"bval (And b\<^sub>1 b\<^sub>2) s = (bval b\<^sub>1 s \<and> bval b\<^sub>2 s)" |
"bval (Less a\<^sub>1 a\<^sub>2) s = (aval a\<^sub>1 s < aval a\<^sub>2 s)"
fun less :: "aexp \<Rightarrow> aexp \<Rightarrow> bexp" where
"less (N n\<^sub>1) (N n\<^sub>2) = Bc(n\<^sub>1 < n\<^sub>2)"|
"less n\<^sub>1 n\<^sub>2 = Less n\<^sub>1 n\<^sub>2"
fun "and" :: "bexp \<Rightarrow> bexp \<Rightarrow> bexp" where
"and (Bc True) b = b" |
"and b (Bc True) = b" |
"and (Bc False) b = Bc False" |
"and b (Bc False) = Bc False" |
"and n\<^sub>1 n\<^sub>2 = And n\<^sub>1 n\<^sub>2"
lemma bval_and[simp]: "bval (and b1 b2) s = (bval b1 s \<and> bval b2 s)"
apply(induction b1 b2 rule: and.induct)
apply auto
done
fun not :: "bexp \<Rightarrow> bexp" where
"not (Bc v) = Bc(\<not> v)" |
"not b = Not b"
lemma bval_not[simp]: "bval (not b) s = (\<not> bval b s)"
apply(induction )
apply auto
done
text \<open>Now the overall optimizer:\<close>
fun bsimp :: "bexp \<Rightarrow> bexp" where
"bsimp (Bc v) = Bc v" |
"bsimp (Not b) = not(bsimp b)" |
"bsimp (And b\<^sub>1 b\<^sub>2) = and (bsimp b\<^sub>1) (bsimp b\<^sub>2)" |
"bsimp (Less a\<^sub>1 a\<^sub>2) = less (asimp a\<^sub>1) (asimp a\<^sub>2)"
theorem "bval (bsimp b) s = bval b s"
apply(induction b)
apply auto
done
end
|
(**
Definition natural number objects (NNO's)
This is related to the initial algebra definition in FunctorAlgebras.v
Written by: Anders Mörtberg, 2018
*)
Require Import UniMath.MoreFoundations.All.
Require Import UniMath.CategoryTheory.Core.Categories.
Require Import UniMath.CategoryTheory.limits.terminal.
Local Open Scope cat.
Section nno.
Context {C : category} (TC : Terminal C).
Local Notation "1" := TC.
Definition isNNO (n : C) (z : C ⟦ 1, n ⟧) (s : C ⟦ n, n ⟧) : hProp.
Proof.
use tpair.
- exact (∏ (a : C) (q : C ⟦ 1, a ⟧) (f : C ⟦ a, a ⟧),
∃! u : C ⟦ n, a ⟧, (z · u = q) × (s · u = u · f)).
- abstract (repeat (apply impred_isaprop; intros); apply isapropiscontr).
Defined.
Definition NNO : UU :=
∑ (n : C) (z : C ⟦ 1, n ⟧) (s : C ⟦ n, n ⟧), isNNO n z s.
Definition NNObject (n : NNO) : C := pr1 n.
Coercion NNObject : NNO >-> ob.
Definition zeroNNO (n : NNO) : C ⟦1,n⟧ := pr1 (pr2 n).
Definition sucNNO (n : NNO) : C ⟦n,n⟧ := pr1 (pr2 (pr2 n)).
Lemma isNNO_NNO (n : NNO) : isNNO n (zeroNNO n) (sucNNO n).
Proof.
exact (pr2 (pr2 (pr2 n))).
Qed.
Definition make_NNO (n : C) (z : C ⟦ 1, n ⟧) (s : C ⟦ n, n ⟧)
(h : isNNO n z s) : NNO := (n,,z,,s,,h).
Definition hasNNO : hProp := ∥ NNO ∥.
End nno.
|
#' TreeImbalance.
#'
#' @name TreeImbalance
#' @docType package
NULL
|
import algebra.field
import data.polynomial
import data.mv_polynomial
import gtm106.weierstrass_equation.regular_function.basic
import gtm106.weierstrass_equation.regular_function.mv_polynomial
import tactic
noncomputable theory
namespace weierstrass_equation
namespace regular_function_ring'
def to_regular_function_ring.to_fun {K : Type*} [comm_ring K]
{E : weierstrass_equation K} (f : regular_function_ring' E) : regular_function_ring E
:= (polynomial.eval₂ (@regular_function_ring.C K _ E) regular_function_ring.x f.1)
+ (polynomial.eval₂ (@regular_function_ring.C K _ E) regular_function_ring.x f.2) * regular_function_ring.y
lemma to_regular_function_ring.map_one' {K : Type*} [comm_ring K]
{E : weierstrass_equation K} : @to_regular_function_ring.to_fun K _ E one = 1 :=
begin
simp [to_regular_function_ring.to_fun, one],
end
lemma to_regular_function_ring.map_mul' {K : Type*} [comm_ring K]
{E : weierstrass_equation K} (f g : regular_function_ring' E)
: (@to_regular_function_ring.to_fun K _ E (mul f g)) = (@to_regular_function_ring.to_fun K _ E f) * (@to_regular_function_ring.to_fun K _ E g) :=
begin
have h : (@regular_function_ring.x K _ E) ^ 3 + regular_function_ring.C E.a2 * regular_function_ring.x ^ 2 + regular_function_ring.C E.a4 * regular_function_ring.x + regular_function_ring.C E.a6 = 0 := by {
sorry,
},
-- simp [to_regular_function_ring.to_fun, mul],
sorry,
end
lemma to_regular_function_ring.map_zero' {K : Type*} [comm_ring K]
{E : weierstrass_equation K} : @to_regular_function_ring.to_fun K _ E zero = 0 :=
begin
simp [to_regular_function_ring.to_fun, zero],
end
lemma to_regular_function_ring.map_add' {K : Type*} [comm_ring K]
{E : weierstrass_equation K} (f g : regular_function_ring' E)
: (@to_regular_function_ring.to_fun K _ E (add f g)) = (@to_regular_function_ring.to_fun K _ E f) + (@to_regular_function_ring.to_fun K _ E g) :=
begin
unfold add to_regular_function_ring.to_fun,
dsimp only,
repeat { rw polynomial.eval₂_add },
ring,
end
def to_regular_function_ring {K : Type*} [comm_ring K]
{E : weierstrass_equation K} : ring_hom (regular_function_ring' E) (regular_function_ring E)
:= ⟨ to_regular_function_ring.to_fun, to_regular_function_ring.map_one', to_regular_function_ring.map_mul', to_regular_function_ring.map_zero', to_regular_function_ring.map_add' ⟩
end regular_function_ring'
end weierstrass_equation
|
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef INCLUDED_OLEHANDLER_HXX
#define INCLUDED_OLEHANDLER_HXX
#ifndef INCLUDED_WRITERFILTERDLLAPI_H
#include <WriterFilterDllApi.hxx>
#endif
#include <resourcemodel/LoggedResources.hxx>
#include <boost/shared_ptr.hpp>
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/drawing/XShape.hpp>
namespace com{ namespace sun{ namespace star{
namespace embed{
class XEmbeddedObject;
}
namespace graphic{
class XGraphic;
}
namespace io{
class XInputStream;
}
namespace text{
class XTextDocument;
}
namespace uno{
class XComponentContext;
}
}}}
namespace writerfilter {
namespace dmapper
{
//class PropertyMap;
/** Handler for OLE objects
*/
class WRITERFILTER_DLLPRIVATE OLEHandler : public LoggedProperties
{
::rtl::OUString m_sObjectType;
::rtl::OUString m_sProgId;
::rtl::OUString m_sShapeId;
::rtl::OUString m_sDrawAspect;
::rtl::OUString m_sObjectId;
::rtl::OUString m_sr_id;
sal_Int32 m_nDxaOrig;
sal_Int32 m_nDyaOrig;
sal_Int32 m_nWrapMode;
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > m_xShape;
::com::sun::star::awt::Size m_aShapeSize;
::com::sun::star::awt::Point m_aShapePosition;
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > m_xReplacement;
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xInputStream;
// Properties
virtual void lcl_attribute(Id Name, Value & val);
virtual void lcl_sprm(Sprm & sprm);
public:
OLEHandler();
virtual ~OLEHandler();
inline ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getShape( ) { return m_xShape; };
inline bool isOLEObject( ) { return m_xInputStream.is( ); };
::rtl::OUString copyOLEOStream( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextDocument > xTextDocument );
::com::sun::star::awt::Size getSize() const { return m_aShapeSize;}
::com::sun::star::awt::Point getPosition() const { return m_aShapePosition;}
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
getReplacement() const { return m_xReplacement; }
};
typedef boost::shared_ptr< OLEHandler > OLEHandlerPtr;
}}
#endif //
|
Formal statement is: lemma ball_eq_greaterThanLessThan: fixes a b::real shows "ball a b = {a - b <..< a + b}" Informal statement is: The ball of radius $b$ centered at $a$ is equal to the open interval $(a - b, a + b)$. |
[STATEMENT]
lemma (in ring) ideal_is_subalgebra:
assumes "K \<subseteq> carrier R" "ideal I R" shows "subalgebra K I R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. subalgebra K I R
[PROOF STEP]
using ideal.axioms(1)[OF assms(2)] ideal.I_l_closed[OF assms(2)] assms(1)
[PROOF STATE]
proof (prove)
using this:
additive_subgroup I R
\<lbrakk>?a \<in> I; ?x \<in> carrier R\<rbrakk> \<Longrightarrow> ?x \<otimes> ?a \<in> I
K \<subseteq> carrier R
goal (1 subgoal):
1. subalgebra K I R
[PROOF STEP]
unfolding subalgebra_def subalgebra_axioms_def additive_subgroup_def
[PROOF STATE]
proof (prove)
using this:
subgroup I (add_monoid R)
\<lbrakk>?a \<in> I; ?x \<in> carrier R\<rbrakk> \<Longrightarrow> ?x \<otimes> ?a \<in> I
K \<subseteq> carrier R
goal (1 subgoal):
1. subgroup I (add_monoid R) \<and> (\<forall>k v. k \<in> K \<longrightarrow> v \<in> I \<longrightarrow> k \<otimes> v \<in> I)
[PROOF STEP]
by auto |
State Before: α : Type u
β : Type v
γ : Type w
ι : Sort x
κ : ι → Sort ?u.39544
a a₁ a₂ : α
b b₁ b₂ : β
l : α → β
u : β → α
inst✝¹ : CompleteLattice α
inst✝ : CompleteLattice β
gi : GaloisInsertion l u
s : Set β
⊢ l (sSup (u '' s)) = sSup s State After: no goals Tactic: rw [sSup_image, gi.l_biSup_u, sSup_eq_iSup] |
Kyakat (Kyakat) is a populated place (class P - Populated Place) in ((BM07)), Burma (Asia) with the region font code of Asia/Pacific.
Its coordinates are 21°40'60" N and 95°13'0" E in DMS (Degrees Minutes Seconds) or 21.6833 and 95.2167 (in decimal degrees). Its UTM position is GJ29 and its Joint Operation Graphics reference is NF46-12. |
/-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import order.bounds.basic
/-!
# Intervals in Lattices
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
In this file, we provide instances of lattice structures on intervals within lattices.
Some of them depend on the order of the endpoints of the interval, and thus are not made
global instances. These are probably not all of the lattice instances that could be placed on these
intervals, but more can be added easily along the same lines when needed.
## Main definitions
In the following, `*` can represent either `c`, `o`, or `i`.
* `set.Ic*.order_bot`
* `set.Ii*.semillatice_inf`
* `set.I*c.order_top`
* `set.I*c.semillatice_inf`
* `set.I**.lattice`
* `set.Iic.bounded_order`, within an `order_bot`
* `set.Ici.bounded_order`, within an `order_top`
-/
variable {α : Type*}
namespace set
namespace Ico
instance [semilattice_inf α] {a b : α} : semilattice_inf (Ico a b) :=
subtype.semilattice_inf (λ x y hx hy, ⟨le_inf hx.1 hy.1, lt_of_le_of_lt inf_le_left hx.2⟩)
/-- `Ico a b` has a bottom element whenever `a < b`. -/
@[reducible] protected def order_bot [partial_order α] {a b : α} (h : a < b) :
order_bot (Ico a b) :=
(is_least_Ico h).order_bot
end Ico
namespace Iio
instance [semilattice_inf α] {a : α} : semilattice_inf (Iio a) :=
subtype.semilattice_inf (λ x y hx hy, lt_of_le_of_lt inf_le_left hx)
end Iio
namespace Ioc
instance [semilattice_sup α] {a b : α} : semilattice_sup (Ioc a b) :=
subtype.semilattice_sup (λ x y hx hy, ⟨lt_of_lt_of_le hx.1 le_sup_left, sup_le hx.2 hy.2⟩)
/-- `Ioc a b` has a top element whenever `a < b`. -/
@[reducible] protected def order_top [partial_order α] {a b : α} (h : a < b) :
order_top (Ioc a b) :=
(is_greatest_Ioc h).order_top
end Ioc
namespace Ioi
instance [semilattice_sup α] {a : α} : semilattice_sup (Ioi a) :=
subtype.semilattice_sup (λ x y hx hy, lt_of_lt_of_le hx le_sup_left)
end Ioi
namespace Iic
instance [semilattice_inf α] {a : α} : semilattice_inf (Iic a) :=
subtype.semilattice_inf (λ x y hx hy, le_trans inf_le_left hx)
instance [semilattice_sup α] {a : α} : semilattice_sup (Iic a) :=
subtype.semilattice_sup (λ x y hx hy, sup_le hx hy)
instance [lattice α] {a : α} : lattice (Iic a) :=
{ .. Iic.semilattice_inf,
.. Iic.semilattice_sup }
instance [preorder α] {a : α} : order_top (Iic a) :=
{ top := ⟨a, le_refl a⟩,
le_top := λ x, x.prop }
@[simp] lemma coe_top [preorder α] {a : α} : ↑(⊤ : Iic a) = a := rfl
instance [preorder α] [order_bot α] {a : α} : order_bot (Iic a) :=
{ bot := ⟨⊥, bot_le⟩,
bot_le := λ ⟨_,_⟩, subtype.mk_le_mk.2 bot_le }
@[simp] lemma coe_bot [preorder α] [order_bot α] {a : α} : ↑(⊥ : Iic a) = (⊥ : α) := rfl
instance [preorder α] [order_bot α] {a : α} : bounded_order (Iic a) :=
{ .. Iic.order_top,
.. Iic.order_bot }
end Iic
namespace Ici
instance [semilattice_inf α] {a : α}: semilattice_inf (Ici a) :=
subtype.semilattice_inf (λ x y hx hy, le_inf hx hy)
instance [semilattice_sup α] {a : α} : semilattice_sup (Ici a) :=
subtype.semilattice_sup (λ x y hx hy, le_trans hx le_sup_left)
instance [lattice α] {a : α} : lattice (Ici a) :=
{ .. Ici.semilattice_inf,
.. Ici.semilattice_sup }
instance [distrib_lattice α] {a : α} : distrib_lattice (Ici a) :=
{ le_sup_inf := λ a b c, le_sup_inf,
.. Ici.lattice }
instance [preorder α] {a : α} : order_bot (Ici a) :=
{ bot := ⟨a, le_refl a⟩,
bot_le := λ x, x.prop }
@[simp] lemma coe_bot [preorder α] {a : α} : ↑(⊥ : Ici a) = a := rfl
instance [preorder α] [order_top α] {a : α}: order_top (Ici a) :=
{ top := ⟨⊤, le_top⟩,
le_top := λ ⟨_,_⟩, subtype.mk_le_mk.2 le_top }
@[simp] lemma coe_top [preorder α] [order_top α] {a : α} : ↑(⊤ : Ici a) = (⊤ : α) := rfl
instance [preorder α] [order_top α] {a : α}: bounded_order (Ici a) :=
{ .. Ici.order_top,
.. Ici.order_bot }
end Ici
namespace Icc
instance [semilattice_inf α] {a b : α} : semilattice_inf (Icc a b) :=
subtype.semilattice_inf (λ x y hx hy, ⟨le_inf hx.1 hy.1, le_trans inf_le_left hx.2⟩)
instance [semilattice_sup α] {a b : α} : semilattice_sup (Icc a b) :=
subtype.semilattice_sup (λ x y hx hy, ⟨le_trans hx.1 le_sup_left, sup_le hx.2 hy.2⟩)
instance [lattice α] {a b : α} : lattice (Icc a b) :=
{ .. Icc.semilattice_inf,
.. Icc.semilattice_sup }
/-- `Icc a b` has a bottom element whenever `a ≤ b`. -/
@[reducible] protected def order_bot [preorder α] {a b : α} (h : a ≤ b) : order_bot (Icc a b) :=
(is_least_Icc h).order_bot
/-- `Icc a b` has a top element whenever `a ≤ b`. -/
@[reducible] protected def order_top [preorder α] {a b : α} (h : a ≤ b) : order_top (Icc a b) :=
(is_greatest_Icc h).order_top
/-- `Icc a b` is a `bounded_order` whenever `a ≤ b`. -/
@[reducible] protected def bounded_order [preorder α] {a b : α} (h : a ≤ b) :
bounded_order (Icc a b) :=
{ .. Icc.order_top h,
.. Icc.order_bot h }
end Icc
end set
|
(*
* Copyright 2016, NICTA
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(NICTA_GPL)
*)
theory FunBucket
imports
TypBucket
L4vBucket
begin
definition count :: "'a list \<Rightarrow> ('b::len) word"
where
"count xs \<equiv> of_nat (length xs) :: 'b word"
definition is_pow_of_2 :: "U32 \<Rightarrow> bool"
where
"is_pow_of_2 x \<equiv> \<exists>k. x = 1 << k \<and> k < 32"
declare fun_app_def [iff]
text {* slice: Return a slice of a list, frm and to are offset from the
beginning of the list *}
definition
slice :: "nat \<Rightarrow> nat \<Rightarrow> 'a list \<Rightarrow> 'a list"
where
"slice frm to xs \<equiv> drop frm $ take to xs"
lemma length_slice:
"length (slice f t xs) = min (length xs) t - f"
by (simp add: slice_def)
lemma slice_n_n:
"slice n n xs = []"
by (simp add: slice_def)
lemma slice_append: "slice f t (xs @ ys) = slice f t xs @ slice (f - min (length xs) t) (t - length xs) ys"
by (simp add: slice_def)
lemmas slice_simps = length_slice slice_n_n slice_append slice_def
lemma sub_mod_mask:
"\<lbrakk>k < 32 \<rbrakk> \<Longrightarrow> (x::32 word) - x mod 2^k = x && ~~ mask k"
apply (simp add: word_mod_2p_is_mask p2_gt_0 mask_out_sub_mask)
done
lemma alignUp_not_aligned_eq2:
" \<not> is_aligned a n \<Longrightarrow> WordSetup.alignUp a n = ((a >> n) + 1) << n"
apply (cases "n < size a")
apply (subst alignUp_not_aligned_eq, assumption)
apply (simp add: word_size)
apply (simp add: shiftr_div_2n_w shiftl_t2n)
apply (simp add: WordSetup.alignUp_def power_overflow
word_size complement_def shiftl_zero_size)
done
lemma alignUp_not_aligned_eq3:
"\<not> is_aligned a n \<Longrightarrow> WordSetup.alignUp a n = (a && ~~ mask n) + (1 << n)"
by (simp add: alignUp_not_aligned_eq2 word_shiftl_add_distrib and_not_mask)
lemma alignUp_def2:
"alignUp a sz = a + 2 ^ sz - 1 && ~~ mask sz"
unfolding alignUp_def[unfolded complement_def]
apply (subst word_log_esimps)
apply (simp add:mask_def[symmetric,unfolded shiftl_t2n,simplified])
done
lemma align32_alignUp:
"\<lbrakk>y = 1 << k; k < 32\<rbrakk> \<Longrightarrow> align32(x,y) = alignUp x k"
apply (clarsimp simp: align32_def)
apply (fold mask_def[simplified])
apply (subst mask_def, simp)
apply (subst add_diff_eq)
apply (subst alignUp_def2[symmetric])
by simp
lemma align32_eq:
"\<lbrakk>y=1<<k; k < 32\<rbrakk> \<Longrightarrow> align32(x,y) = (if y udvd x then x else x + y - (x mod y))"
apply (simp add: align32_alignUp)
apply safe
apply (simp add: udvd_iff_dvd)
apply (simp add: and_mask_dvd_nat)
apply (simp only: is_aligned_mask[symmetric])
apply (simp add: alignUp_idem)
apply (subst diff_add_eq[symmetric])
apply (subst sub_mod_mask, assumption)
apply (subst alignUp_not_aligned_eq3)
apply (clarsimp simp: is_aligned_def udvd_iff_dvd)
apply clarsimp
done
lemma align32_unchanged:
"\<lbrakk>is_pow_of_2 a; a udvd x\<rbrakk> \<Longrightarrow> align32 (x,a) = x"
by (clarsimp simp: is_pow_of_2_def align32_eq)
lemma alignUp_not_aligned_eq': "\<not> is_aligned x k
\<Longrightarrow> alignUp x k = x + (2 ^ k - (x && mask k))"
apply (subst alignUp_not_aligned_eq3, assumption)
apply (subst mask_out_sub_mask)
apply simp
done
lemma al_dvd_align32:
"\<lbrakk>is_pow_of_2 al; v < v + al\<rbrakk> \<Longrightarrow> al udvd align32 (v, al)"
by (clarsimp simp: is_pow_of_2_def align32_alignUp
udvd_iff_dvd is_aligned_def[symmetric])
lemma align32_le:
"\<lbrakk>is_pow_of_2 al; v < v + al\<rbrakk> \<Longrightarrow> v \<le> align32 (v, al)"
apply (case_tac "v=0", clarsimp simp: align32_alignUp)
apply (clarsimp simp: align32_alignUp is_pow_of_2_def)
apply (case_tac "is_aligned v k")
apply (rule alignUp_ge, simp)
apply (rule_tac x=v in alignUp_is_aligned_nz)
apply simp
apply simp
apply simp
apply simp
apply (simp add: alignUp_not_aligned_eq')
apply (drule word_less_sub_1)
apply (rule word_plus_mono_right2)
apply (subst(asm) field_simps[symmetric], assumption)
apply (rule word_le_minus_mono_right)
apply (clarsimp simp: lt1_neq0 is_aligned_mask)
apply (rule order_trans, rule word_and_le1)
apply (rule order_less_imp_le)
apply (simp add: mask_lt_2pn)
apply (simp add: word_1_le_power)
done
lemma align32_ge:
"\<lbrakk>is_pow_of_2 al; v < v + al\<rbrakk> \<Longrightarrow> align32 (v, al) \<ge> v"
by (auto simp:align32_le)
lemma alignUp_greater:
"\<lbrakk>(v::32 word) < 2^n; v \<noteq> 0\<rbrakk> \<Longrightarrow> alignUp v n = 2^n"
apply (subst alignUp_not_aligned_eq')
apply (clarsimp simp: aligned_small_is_0)
apply (simp add: less_mask_eq)
done
lemma mask_out_add_aligned:
assumes al: "is_aligned p n"
shows "p + (q && ~~ mask n) = (p + q) && ~~ mask n"
using mask_add_aligned [OF al]
by (simp add: mask_out_sub_mask)
lemma is_aligned_triv2:
"is_aligned (2^a) a"
apply (case_tac "word_bits\<le> a")
apply (simp add:is_aligned_triv)+
done
lemma alignUp_def3:
"alignUp a sz = 2^ sz + (a - 1 && ~~ mask sz)" (is "?lhs = ?rhs")
apply (simp add:alignUp_def2)
apply (subgoal_tac "2 ^ sz + a - 1 && ~~ mask sz = ?rhs")
apply (clarsimp simp:field_simps)
apply (subst mask_out_add_aligned)
apply (rule is_aligned_triv2)
apply (simp add:field_simps)
done
lemma mask_lower_twice:
"n \<le> m \<Longrightarrow> (x && ~~ mask n) && ~~ mask m = x && ~~ mask m"
apply (rule word_eqI)
apply (simp add: word_size word_ops_nth_size)
apply safe
apply simp
done
lemma alignUp_distance:
"(alignUp (q :: 'a :: len word) sz) - q \<le> mask sz"
apply (case_tac "len_of TYPE('a) \<le> sz")
apply (simp add:alignUp_def2 mask_def power_overflow)
apply (case_tac "is_aligned q sz")
apply (clarsimp simp:alignUp_def2 p_assoc_help)
apply (subst mask_out_add_aligned[symmetric],simp)+
apply (simp add:mask_lower_twice word_and_le2)
apply (simp add:and_not_mask)
apply (subst le_mask_iff[THEN iffD1])
apply (simp add:mask_def)
apply simp
apply (clarsimp simp:alignUp_def3)
apply (subgoal_tac "2 ^ sz - (q - (q - 1 && ~~ mask sz)) \<le> 2 ^ sz - 1")
apply (simp add:field_simps mask_def)
apply (rule word_sub_mono)
apply simp
apply (rule ccontr)
apply (clarsimp simp:not_le)
apply (drule eq_refl)
apply (drule order_trans[OF _ word_and_le2])
apply (subgoal_tac "q \<noteq> 0")
apply (drule minus_one_helper[rotated])
apply simp
apply simp
apply (fastforce)
apply (simp add: word_sub_le_iff)
apply (subgoal_tac "q - 1 && ~~ mask sz = (q - 1) - (q - 1 && mask sz)")
apply simp
apply (rule order_trans)
apply (rule word_add_le_mono2)
apply (rule word_and_le1)
apply (subst unat_plus_simple[THEN iffD1,symmetric])
apply (simp add:not_le mask_def)
apply (rule word_sub_1_le)
apply simp
apply (rule unat_lt2p)
apply (simp add:mask_def)
apply (simp add:mask_out_sub_mask)
apply (rule word_sub_1_le)
apply simp
done
lemma alignUp_nz:
"\<lbrakk>(v :: 32 word) \<noteq> 0; v < v + 2^k; k < 32\<rbrakk> \<Longrightarrow> alignUp v k \<noteq> 0"
apply (cut_tac v=v and al="2^k" in align32_le, simp add: is_pow_of_2_def)
apply (rule_tac x=k in exI, simp+)
apply (subst (asm) align32_alignUp[simplified], simp+)
apply auto
done
lemma aligned_neq_into_ineq:
fixes x :: "'a::len word"
assumes neq: "x \<noteq> y"
and alx: "is_aligned x sz"
and aly: "is_aligned y sz"
shows "x + 2 ^ sz - 1 < y \<or> y + 2 ^ sz - 1 < x"
proof -
note no_ov = aligned_neq_into_no_overlap [OF neq alx aly]
note x = eqset_imp_iff[OF no_ov, where x=x]
note y = eqset_imp_iff[OF no_ov, where x=y]
from x y show ?thesis
apply (simp add: is_aligned_no_overflow' alx aly)
apply (auto simp: field_simps)
done
qed
lemma align32_upper_bound:
"\<lbrakk>v \<le> bound; is_pow_of_2 al; al udvd bound; v < v + al\<rbrakk> \<Longrightarrow>
align32 (v, al) \<le> bound"
apply (case_tac "v=0")
apply (clarsimp simp: align32_alignUp is_pow_of_2_def alignUp_def2 mask_def)
apply (clarsimp simp: is_pow_of_2_def)
apply (subst (asm) udvd_iff_dvd)
apply simp
apply (fold is_aligned_def)
apply (subst align32_alignUp, simp+)
apply (case_tac "is_aligned v k")
apply (simp add: alignUp_idem)
apply (case_tac "al > v")
apply (subst alignUp_greater, simp+)
apply (drule_tac a=bound in is_aligned_less_sz)
apply clarsimp
apply (simp add: le_def[symmetric])
apply (simp add: le_def[symmetric])
apply (cut_tac p=v and n=k in is_aligned_alignUp)
apply (cut_tac q=v and sz=k in alignUp_distance)
apply (drule word_diff_ls'(3))
apply (drule word_less_sub_1)
apply (simp add: mask_def word_less_sub_1)
apply (subst diff_add_eq)
apply (simp add: add.commute)
apply (case_tac "v + 2^k \<le> bound")
apply (simp add: mask_def)
apply (cut_tac v=v and k=k in alignUp_nz, simp+)
apply (metis (erased, hide_lams) add.commute add_diff_eq
not_less order_trans word_le_less_eq word_less_1 word_sub_le)
apply (subst (asm) word_not_le)
apply (case_tac "bound = alignUp v k")
apply simp
apply (frule_tac x=bound and y="alignUp v k" and sz=k
in aligned_neq_into_ineq, assumption+)
apply (simp add: mask_def)
apply safe
apply (metis alignUp_le_greater_al word_bits_conv word_bits_def)
by (metis alignUp_le_greater_al word_bits_conv word_bits_def)
lemma align32_idempotence:
"is_pow_of_2 y \<Longrightarrow> x < x + y \<Longrightarrow>
align32 (align32 (x, y), y) = align32 (x, y)"
apply (frule (1) al_dvd_align32)
apply (erule (1) align32_unchanged)
done
end
|
import data.real.basic
variables a b c : ℝ
#check mul_comm b a
#check mul_assoc c b a
-- BEGIN
example (a b c : ℝ) : (c * b) * a = b * (a * c) :=
begin
rw mul_comm c b,
sorry,
end
example (a b c : ℝ) : a * (b * c) = b * (a * c) :=
begin
sorry,
end
-- END |
module AbstractMergers
import Flux: children, mapchildren
import Base: show
export AbstractMerger, inputname
"""
AbstractMerger
Abstract base type for mergers.
# Interface
Any subtype should support to combine a forward stream with other streams that
can be accessed through a state dictionary via their `Splitter` name.
"""
abstract type AbstractMerger end
end # module AbstractMergers
|
{-# OPTIONS --universe-polymorphism #-}
open import Categories.Category
module Categories.Object.Exponential {o ℓ e} (C : Category o ℓ e) where
open Category C
open import Level
open import Categories.Square
import Categories.Object.Product
open Categories.Object.Product C
hiding (repack; repack≡id; repack∘; repack-cancel; up-to-iso; transport-by-iso)
import Categories.Object.Product.Morphisms
open Categories.Object.Product.Morphisms C
import Categories.Morphisms as Morphisms
record Exponential (A B : Obj) : Set (o ⊔ ℓ ⊔ e) where
field
B^A : Obj
product : Product B^A A
module product = Product product
B^A×A : Obj
B^A×A = product.A×B
field
eval : B^A×A ⇒ B
λg : {X : Obj} → (X×A : Product X A) → (Product.A×B X×A ⇒ B) → (X ⇒ B^A)
.β
: {X : Obj} → (X×A : Product X A)
→ {g : Product.A×B X×A ⇒ B}
→ (eval ∘ [ X×A ⇒ product ]first (λg X×A g) ≡ g)
.λ-unique
: {X : Obj} → (X×A : Product X A)
→ {g : Product.A×B X×A ⇒ B}
→ {h : X ⇒ B^A}
→ (eval ∘ [ X×A ⇒ product ]first h ≡ g)
→ (h ≡ λg X×A g)
.η
: ∀ {X : Obj} (X×A : Product X A)
{f : X ⇒ B^A }
→ λg X×A (eval ∘ [ X×A ⇒ product ]first f) ≡ f
η X×A {f} = sym (λ-unique X×A refl)
where open Equiv
.λ-cong
: {X : Obj}(X×A : Product X A)
→ ∀{f g}
→ (f ≡ g)
→ (λg X×A f ≡ λg X×A g)
λ-cong X×A {f}{g} f≡g = λ-unique X×A (trans (β X×A) f≡g)
where
open Equiv
.subst : ∀ {C D}
→ (p₂ : Product C A)
→ (p₃ : Product D A)
→ {f : Product.A×B p₃ ⇒ B}{g : C ⇒ D}
→ λg p₃ f ∘ g
≡ λg p₂ (f ∘ [ p₂ ⇒ p₃ ]first g)
subst {C}{D} p₂ p₃ {f}{g} = λ-unique p₂ subst-commutes
where
open HomReasoning
open Equiv
subst-commutes =
let p₁ = product in
begin
eval ∘ [ p₂ ⇒ p₁ ]first (λg p₃ f ∘ g)
↑⟨ refl ⟩∘⟨ [ p₂ ⇒ p₃ ⇒ p₁ ]first∘first ⟩
eval
∘ [ p₃ ⇒ p₁ ]first (λg p₃ f)
∘ [ p₂ ⇒ p₃ ]first g
↑⟨ assoc ⟩
(eval ∘ [ p₃ ⇒ p₁ ]first (λg p₃ f))
∘ [ p₂ ⇒ p₃ ]first g
↓⟨ β p₃ ⟩∘⟨ refl ⟩
f ∘ [ p₂ ⇒ p₃ ]first g
∎
.η-id : λg product eval ≡ id
η-id =
begin
λg product eval
↑⟨ identityʳ ⟩
λg product eval ∘ id
↓⟨ subst _ _ ⟩
λg product (eval ∘ [ product ⇒ product ]first id)
↓⟨ η product ⟩
id
∎
where
open Equiv
open HomReasoning
open Morphisms C
-- some aliases to make proof signatures less ugly
[_]eval : ∀{A B}(e₁ : Exponential A B) → Exponential.B^A×A e₁ ⇒ B
[ e₁ ]eval = Exponential.eval e₁
[_]λ : ∀{A B}(e₁ : Exponential A B)
→ {X : Obj} → (X×A : Product X A) → (Product.A×B X×A ⇒ B) → (X ⇒ Exponential.B^A e₁)
[ e₁ ]λ = Exponential.λg e₁
.λ-distrib : ∀ {A B C D}
→ (e₁ : Exponential C B)
→ (e₂ : Exponential A B)
→ (p₃ : Product D C)
→ (p₄ : Product D A)
→ (p₅ : Product (Exponential.B^A e₂) C)
→ {f : C ⇒ A}{g : Product.A×B p₄ ⇒ B}
→ [ e₁ ]λ p₃ (g ∘ [ p₃ ⇒ p₄ ]second f)
≡ [ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]second f)
∘ [ e₂ ]λ p₄ g
λ-distrib {A}{B}{C}{D} e₁ e₂ p₃ p₄ p₅ {f}{g} =
begin
[ e₁ ]λ p₃ (g ∘ [ p₃ ⇒ p₄ ]second f)
↑⟨ e₁.λ-cong p₃ eval∘second∘first ⟩
[ e₁ ]λ p₃ (([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]second f) ∘ [ p₃ ⇒ p₅ ]first ([ e₂ ]λ p₄ g))
↑⟨ e₁.subst p₃ p₅ ⟩
[ e₁ ]λ p₅ ([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]second f)
∘ [ e₂ ]λ p₄ g
∎
where
open HomReasoning
open Equiv
module e₁ = Exponential e₁
module e₂ = Exponential e₂
eval∘second∘first =
let p₁ = e₁.product in
let p₂ = e₂.product in
begin
([ e₂ ]eval ∘ [ p₅ ⇒ Exponential.product e₂ ]second f) ∘ [ p₃ ⇒ p₅ ]first ([ e₂ ]λ p₄ g)
↓⟨ assoc ⟩
[ e₂ ]eval
∘ [ p₅ ⇒ p₂ ]second f
∘ [ p₃ ⇒ p₅ ]first ([ e₂ ]λ p₄ g)
↑⟨ refl ⟩∘⟨ [ p₄ ⇒ p₂ , p₃ ⇒ p₅ ]first↔second ⟩
[ e₂ ]eval
∘ [ p₄ ⇒ p₂ ]first ([ e₂ ]λ p₄ g)
∘ [ p₃ ⇒ p₄ ]second f
↑⟨ assoc ⟩
([ e₂ ]eval ∘ [ p₄ ⇒ p₂ ]first ([ e₂ ]λ p₄ g))
∘ [ p₃ ⇒ p₄ ]second f
↓⟨ e₂.β p₄ ⟩∘⟨ refl ⟩
g ∘ [ p₃ ⇒ p₄ ]second f
∎
repack : ∀{A B} (e₁ e₂ : Exponential A B) → Exponential.B^A e₁ ⇒ Exponential.B^A e₂
repack e₁ e₂ = e₂.λg e₁.product e₁.eval
where
module e₁ = Exponential e₁
module e₂ = Exponential e₂
.repack≡id : ∀{A B} (e : Exponential A B) → repack e e ≡ id
repack≡id e = Exponential.η-id e
.repack∘ : ∀{A B} (e₁ e₂ e₃ : Exponential A B) → repack e₂ e₃ ∘ repack e₁ e₂ ≡ repack e₁ e₃
repack∘ {A} {B} e₁ e₂ e₃ =
let p₁ = product e₁ in
let p₂ = product e₂ in
begin
[ e₃ ]λ p₂ [ e₂ ]eval
∘ [ e₂ ]λ p₁ [ e₁ ]eval
↓⟨ λ-cong e₃ p₂ (introʳ (second-id p₂)) ⟩∘⟨ refl ⟩
[ e₃ ]λ p₂ ([ e₂ ]eval ∘ [ p₂ ⇒ p₂ ]second id)
∘ [ e₂ ]λ p₁ [ e₁ ]eval
↑⟨ λ-distrib e₃ e₂ p₁ p₁ p₂ ⟩
[ e₃ ]λ p₁ ([ e₁ ]eval ∘ [ p₁ ⇒ p₁ ]second id)
↑⟨ λ-cong e₃ p₁ (introʳ (second-id p₁)) ⟩
[ e₃ ]λ p₁ [ e₁ ]eval
∎
where
open Equiv
open Exponential
open HomReasoning
open GlueSquares C
.repack-cancel : ∀{A B} (e₁ e₂ : Exponential A B) → repack e₁ e₂ ∘ repack e₂ e₁ ≡ id
repack-cancel e₁ e₂ = Equiv.trans (repack∘ e₂ e₁ e₂) (repack≡id e₂)
up-to-iso : ∀{A B} (e₁ e₂ : Exponential A B) → Exponential.B^A e₁ ≅ Exponential.B^A e₂
up-to-iso e₁ e₂ = record
{ f = repack e₁ e₂
; g = repack e₂ e₁
; iso = record
{ isoˡ = repack-cancel e₂ e₁
; isoʳ = repack-cancel e₁ e₂
}
}
transport-by-iso : ∀{A B} (e : Exponential A B) → ∀ {X} → Exponential.B^A e ≅ X → Exponential A B
transport-by-iso e {X} e≅X = record
{ B^A = X
; product = X×A
; eval = e.eval
; λg = λ Y×A y → f ∘ e.λg Y×A y
; β = λ Y×A → let open HomReasoning in let open GlueSquares C in let open Equiv in begin
e.eval ∘ [ Y×A ⇒ X×A ]first (f ∘ e.λg Y×A _)
↓⟨ ∘-resp-≡ʳ (e.product.⟨⟩-cong₂ (pullˡ (cancelLeft isoˡ)) (pullˡ identityˡ)) ⟩
e.eval ∘ [ Y×A ⇒ e.product ]first (e.λg Y×A _)
↓⟨ (e.β Y×A) ⟩
_
∎
; λ-unique = λ Y×A y → let open GlueSquares C in
switch-gfˡ e≅X
(e.λ-unique Y×A
(Equiv.trans
(∘-resp-≡ʳ
(e.product.⟨⟩-cong₂
assoc
(Equiv.sym (pullˡ identityˡ))))
y)) -- look ma i can write lisp in agda --xplat
}
where
module e = Exponential e
X×A = Mobile e.product e≅X idⁱ
open _≅_ e≅X
|
(* Title: ZF/Constructible/Formula.thy
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
*)
section \<open>First-Order Formulas and the Definition of the Class L\<close>
theory Formula imports ZF begin
subsection\<open>Internalized formulas of FOL\<close>
text\<open>De Bruijn representation.
Unbound variables get their denotations from an environment.\<close>
consts formula :: i
datatype
"formula" = Member ("x \<in> nat", "y \<in> nat")
| Equal ("x \<in> nat", "y \<in> nat")
| Nand ("p \<in> formula", "q \<in> formula")
| Forall ("p \<in> formula")
declare formula.intros [TC]
definition
Neg :: "i\<Rightarrow>i" where
"Neg(p) \<equiv> Nand(p,p)"
definition
And :: "[i,i]\<Rightarrow>i" where
"And(p,q) \<equiv> Neg(Nand(p,q))"
definition
Or :: "[i,i]\<Rightarrow>i" where
"Or(p,q) \<equiv> Nand(Neg(p),Neg(q))"
definition
Implies :: "[i,i]\<Rightarrow>i" where
"Implies(p,q) \<equiv> Nand(p,Neg(q))"
definition
Iff :: "[i,i]\<Rightarrow>i" where
"Iff(p,q) \<equiv> And(Implies(p,q), Implies(q,p))"
definition
Exists :: "i\<Rightarrow>i" where
"Exists(p) \<equiv> Neg(Forall(Neg(p)))"
lemma Neg_type [TC]: "p \<in> formula \<Longrightarrow> Neg(p) \<in> formula"
by (simp add: Neg_def)
lemma And_type [TC]: "\<lbrakk>p \<in> formula; q \<in> formula\<rbrakk> \<Longrightarrow> And(p,q) \<in> formula"
by (simp add: And_def)
lemma Or_type [TC]: "\<lbrakk>p \<in> formula; q \<in> formula\<rbrakk> \<Longrightarrow> Or(p,q) \<in> formula"
by (simp add: Or_def)
lemma Implies_type [TC]:
"\<lbrakk>p \<in> formula; q \<in> formula\<rbrakk> \<Longrightarrow> Implies(p,q) \<in> formula"
by (simp add: Implies_def)
lemma Iff_type [TC]:
"\<lbrakk>p \<in> formula; q \<in> formula\<rbrakk> \<Longrightarrow> Iff(p,q) \<in> formula"
by (simp add: Iff_def)
lemma Exists_type [TC]: "p \<in> formula \<Longrightarrow> Exists(p) \<in> formula"
by (simp add: Exists_def)
consts satisfies :: "[i,i]\<Rightarrow>i"
primrec (*explicit lambda is required because the environment varies*)
"satisfies(A,Member(x,y)) =
(\<lambda>env \<in> list(A). bool_of_o (nth(x,env) \<in> nth(y,env)))"
"satisfies(A,Equal(x,y)) =
(\<lambda>env \<in> list(A). bool_of_o (nth(x,env) = nth(y,env)))"
"satisfies(A,Nand(p,q)) =
(\<lambda>env \<in> list(A). not ((satisfies(A,p)`env) and (satisfies(A,q)`env)))"
"satisfies(A,Forall(p)) =
(\<lambda>env \<in> list(A). bool_of_o (\<forall>x\<in>A. satisfies(A,p) ` (Cons(x,env)) = 1))"
lemma satisfies_type: "p \<in> formula \<Longrightarrow> satisfies(A,p) \<in> list(A) -> bool"
by (induct set: formula) simp_all
abbreviation
sats :: "[i,i,i] \<Rightarrow> o" where
"sats(A,p,env) \<equiv> satisfies(A,p)`env = 1"
lemma sats_Member_iff [simp]:
"env \<in> list(A) \<Longrightarrow> sats(A, Member(x,y), env) \<longleftrightarrow> nth(x,env) \<in> nth(y,env)"
by simp
lemma sats_Equal_iff [simp]:
"env \<in> list(A) \<Longrightarrow> sats(A, Equal(x,y), env) \<longleftrightarrow> nth(x,env) = nth(y,env)"
by simp
lemma sats_Nand_iff [simp]:
"env \<in> list(A)
\<Longrightarrow> (sats(A, Nand(p,q), env)) \<longleftrightarrow> \<not> (sats(A,p,env) \<and> sats(A,q,env))"
by (simp add: Bool.and_def Bool.not_def cond_def)
lemma sats_Forall_iff [simp]:
"env \<in> list(A)
\<Longrightarrow> sats(A, Forall(p), env) \<longleftrightarrow> (\<forall>x\<in>A. sats(A, p, Cons(x,env)))"
by simp
declare satisfies.simps [simp del]
subsection\<open>Dividing line between primitive and derived connectives\<close>
lemma sats_Neg_iff [simp]:
"env \<in> list(A)
\<Longrightarrow> sats(A, Neg(p), env) \<longleftrightarrow> \<not> sats(A,p,env)"
by (simp add: Neg_def)
lemma sats_And_iff [simp]:
"env \<in> list(A)
\<Longrightarrow> (sats(A, And(p,q), env)) \<longleftrightarrow> sats(A,p,env) \<and> sats(A,q,env)"
by (simp add: And_def)
lemma sats_Or_iff [simp]:
"env \<in> list(A)
\<Longrightarrow> (sats(A, Or(p,q), env)) \<longleftrightarrow> sats(A,p,env) | sats(A,q,env)"
by (simp add: Or_def)
lemma sats_Implies_iff [simp]:
"env \<in> list(A)
\<Longrightarrow> (sats(A, Implies(p,q), env)) \<longleftrightarrow> (sats(A,p,env) \<longrightarrow> sats(A,q,env))"
by (simp add: Implies_def, blast)
lemma sats_Iff_iff [simp]:
"env \<in> list(A)
\<Longrightarrow> (sats(A, Iff(p,q), env)) \<longleftrightarrow> (sats(A,p,env) \<longleftrightarrow> sats(A,q,env))"
by (simp add: Iff_def, blast)
lemma sats_Exists_iff [simp]:
"env \<in> list(A)
\<Longrightarrow> sats(A, Exists(p), env) \<longleftrightarrow> (\<exists>x\<in>A. sats(A, p, Cons(x,env)))"
by (simp add: Exists_def)
subsubsection\<open>Derived rules to help build up formulas\<close>
lemma mem_iff_sats:
"\<lbrakk>nth(i,env) = x; nth(j,env) = y; env \<in> list(A)\<rbrakk>
\<Longrightarrow> (x\<in>y) \<longleftrightarrow> sats(A, Member(i,j), env)"
by (simp add: satisfies.simps)
lemma equal_iff_sats:
"\<lbrakk>nth(i,env) = x; nth(j,env) = y; env \<in> list(A)\<rbrakk>
\<Longrightarrow> (x=y) \<longleftrightarrow> sats(A, Equal(i,j), env)"
by (simp add: satisfies.simps)
lemma not_iff_sats:
"\<lbrakk>P \<longleftrightarrow> sats(A,p,env); env \<in> list(A)\<rbrakk>
\<Longrightarrow> (\<not>P) \<longleftrightarrow> sats(A, Neg(p), env)"
by simp
lemma conj_iff_sats:
"\<lbrakk>P \<longleftrightarrow> sats(A,p,env); Q \<longleftrightarrow> sats(A,q,env); env \<in> list(A)\<rbrakk>
\<Longrightarrow> (P \<and> Q) \<longleftrightarrow> sats(A, And(p,q), env)"
by (simp)
lemma disj_iff_sats:
"\<lbrakk>P \<longleftrightarrow> sats(A,p,env); Q \<longleftrightarrow> sats(A,q,env); env \<in> list(A)\<rbrakk>
\<Longrightarrow> (P | Q) \<longleftrightarrow> sats(A, Or(p,q), env)"
by (simp)
lemma iff_iff_sats:
"\<lbrakk>P \<longleftrightarrow> sats(A,p,env); Q \<longleftrightarrow> sats(A,q,env); env \<in> list(A)\<rbrakk>
\<Longrightarrow> (P \<longleftrightarrow> Q) \<longleftrightarrow> sats(A, Iff(p,q), env)"
by (simp)
lemma imp_iff_sats:
"\<lbrakk>P \<longleftrightarrow> sats(A,p,env); Q \<longleftrightarrow> sats(A,q,env); env \<in> list(A)\<rbrakk>
\<Longrightarrow> (P \<longrightarrow> Q) \<longleftrightarrow> sats(A, Implies(p,q), env)"
by (simp)
lemma ball_iff_sats:
"\<lbrakk>\<And>x. x\<in>A \<Longrightarrow> P(x) \<longleftrightarrow> sats(A, p, Cons(x, env)); env \<in> list(A)\<rbrakk>
\<Longrightarrow> (\<forall>x\<in>A. P(x)) \<longleftrightarrow> sats(A, Forall(p), env)"
by (simp)
lemma bex_iff_sats:
"\<lbrakk>\<And>x. x\<in>A \<Longrightarrow> P(x) \<longleftrightarrow> sats(A, p, Cons(x, env)); env \<in> list(A)\<rbrakk>
\<Longrightarrow> (\<exists>x\<in>A. P(x)) \<longleftrightarrow> sats(A, Exists(p), env)"
by (simp)
lemmas FOL_iff_sats =
mem_iff_sats equal_iff_sats not_iff_sats conj_iff_sats
disj_iff_sats imp_iff_sats iff_iff_sats imp_iff_sats ball_iff_sats
bex_iff_sats
subsection\<open>Arity of a Formula: Maximum Free de Bruijn Index\<close>
consts arity :: "i\<Rightarrow>i"
primrec
"arity(Member(x,y)) = succ(x) \<union> succ(y)"
"arity(Equal(x,y)) = succ(x) \<union> succ(y)"
"arity(Nand(p,q)) = arity(p) \<union> arity(q)"
"arity(Forall(p)) = Arith.pred(arity(p))"
lemma arity_type [TC]: "p \<in> formula \<Longrightarrow> arity(p) \<in> nat"
by (induct_tac p, simp_all)
lemma arity_Neg [simp]: "arity(Neg(p)) = arity(p)"
by (simp add: Neg_def)
lemma arity_And [simp]: "arity(And(p,q)) = arity(p) \<union> arity(q)"
by (simp add: And_def)
lemma arity_Or [simp]: "arity(Or(p,q)) = arity(p) \<union> arity(q)"
by (simp add: Or_def)
lemma arity_Implies [simp]: "arity(Implies(p,q)) = arity(p) \<union> arity(q)"
by (simp add: Implies_def)
lemma arity_Iff [simp]: "arity(Iff(p,q)) = arity(p) \<union> arity(q)"
by (simp add: Iff_def, blast)
lemma arity_Exists [simp]: "arity(Exists(p)) = Arith.pred(arity(p))"
by (simp add: Exists_def)
lemma arity_sats_iff [rule_format]:
"\<lbrakk>p \<in> formula; extra \<in> list(A)\<rbrakk>
\<Longrightarrow> \<forall>env \<in> list(A).
arity(p) \<le> length(env) \<longrightarrow>
sats(A, p, env @ extra) \<longleftrightarrow> sats(A, p, env)"
apply (induct_tac p)
apply (simp_all add: Arith.pred_def nth_append Un_least_lt_iff nat_imp_quasinat
split: split_nat_case, auto)
done
lemma arity_sats1_iff:
"\<lbrakk>arity(p) \<le> succ(length(env)); p \<in> formula; x \<in> A; env \<in> list(A);
extra \<in> list(A)\<rbrakk>
\<Longrightarrow> sats(A, p, Cons(x, env @ extra)) \<longleftrightarrow> sats(A, p, Cons(x, env))"
apply (insert arity_sats_iff [of p extra A "Cons(x,env)"])
apply simp
done
subsection\<open>Renaming Some de Bruijn Variables\<close>
definition
incr_var :: "[i,i]\<Rightarrow>i" where
"incr_var(x,nq) \<equiv> if x<nq then x else succ(x)"
lemma incr_var_lt: "x<nq \<Longrightarrow> incr_var(x,nq) = x"
by (simp add: incr_var_def)
lemma incr_var_le: "nq\<le>x \<Longrightarrow> incr_var(x,nq) = succ(x)"
apply (simp add: incr_var_def)
apply (blast dest: lt_trans1)
done
consts incr_bv :: "i\<Rightarrow>i"
primrec
"incr_bv(Member(x,y)) =
(\<lambda>nq \<in> nat. Member (incr_var(x,nq), incr_var(y,nq)))"
"incr_bv(Equal(x,y)) =
(\<lambda>nq \<in> nat. Equal (incr_var(x,nq), incr_var(y,nq)))"
"incr_bv(Nand(p,q)) =
(\<lambda>nq \<in> nat. Nand (incr_bv(p)`nq, incr_bv(q)`nq))"
"incr_bv(Forall(p)) =
(\<lambda>nq \<in> nat. Forall (incr_bv(p) ` succ(nq)))"
lemma [TC]: "x \<in> nat \<Longrightarrow> incr_var(x,nq) \<in> nat"
by (simp add: incr_var_def)
lemma incr_bv_type [TC]: "p \<in> formula \<Longrightarrow> incr_bv(p) \<in> nat -> formula"
by (induct_tac p, simp_all)
text\<open>Obviously, \<^term>\<open>DPow\<close> is closed under complements and finite
intersections and unions. Needs an inductive lemma to allow two lists of
parameters to be combined.\<close>
lemma sats_incr_bv_iff [rule_format]:
"\<lbrakk>p \<in> formula; env \<in> list(A); x \<in> A\<rbrakk>
\<Longrightarrow> \<forall>bvs \<in> list(A).
sats(A, incr_bv(p) ` length(bvs), bvs @ Cons(x,env)) \<longleftrightarrow>
sats(A, p, bvs@env)"
apply (induct_tac p)
apply (simp_all add: incr_var_def nth_append succ_lt_iff length_type)
apply (auto simp add: diff_succ not_lt_iff_le)
done
(*the following two lemmas prevent huge case splits in arity_incr_bv_lemma*)
lemma incr_var_lemma:
"\<lbrakk>x \<in> nat; y \<in> nat; nq \<le> x\<rbrakk>
\<Longrightarrow> succ(x) \<union> incr_var(y,nq) = succ(x \<union> y)"
apply (simp add: incr_var_def Ord_Un_if, auto)
apply (blast intro: leI)
apply (simp add: not_lt_iff_le)
apply (blast intro: le_anti_sym)
apply (blast dest: lt_trans2)
done
lemma incr_And_lemma:
"y < x \<Longrightarrow> y \<union> succ(x) = succ(x \<union> y)"
apply (simp add: Ord_Un_if lt_Ord lt_Ord2 succ_lt_iff)
apply (blast dest: lt_asym)
done
lemma arity_incr_bv_lemma [rule_format]:
"p \<in> formula
\<Longrightarrow> \<forall>n \<in> nat. arity (incr_bv(p) ` n) =
(if n < arity(p) then succ(arity(p)) else arity(p))"
apply (induct_tac p)
apply (simp_all add: imp_disj not_lt_iff_le Un_least_lt_iff lt_Un_iff le_Un_iff
succ_Un_distrib [symmetric] incr_var_lt incr_var_le
Un_commute incr_var_lemma Arith.pred_def nat_imp_quasinat
split: split_nat_case)
txt\<open>the Forall case reduces to linear arithmetic\<close>
prefer 2
apply clarify
apply (blast dest: lt_trans1)
txt\<open>left with the And case\<close>
apply safe
apply (blast intro: incr_And_lemma lt_trans1)
apply (subst incr_And_lemma)
apply (blast intro: lt_trans1)
apply (simp add: Un_commute)
done
subsection\<open>Renaming all but the First de Bruijn Variable\<close>
definition
incr_bv1 :: "i \<Rightarrow> i" where
"incr_bv1(p) \<equiv> incr_bv(p)`1"
lemma incr_bv1_type [TC]: "p \<in> formula \<Longrightarrow> incr_bv1(p) \<in> formula"
by (simp add: incr_bv1_def)
(*For renaming all but the bound variable at level 0*)
lemma sats_incr_bv1_iff:
"\<lbrakk>p \<in> formula; env \<in> list(A); x \<in> A; y \<in> A\<rbrakk>
\<Longrightarrow> sats(A, incr_bv1(p), Cons(x, Cons(y, env))) \<longleftrightarrow>
sats(A, p, Cons(x,env))"
apply (insert sats_incr_bv_iff [of p env A y "Cons(x,Nil)"])
apply (simp add: incr_bv1_def)
done
lemma formula_add_params1 [rule_format]:
"\<lbrakk>p \<in> formula; n \<in> nat; x \<in> A\<rbrakk>
\<Longrightarrow> \<forall>bvs \<in> list(A). \<forall>env \<in> list(A).
length(bvs) = n \<longrightarrow>
sats(A, iterates(incr_bv1, n, p), Cons(x, bvs@env)) \<longleftrightarrow>
sats(A, p, Cons(x,env))"
apply (induct_tac n, simp, clarify)
apply (erule list.cases)
apply (simp_all add: sats_incr_bv1_iff)
done
lemma arity_incr_bv1_eq:
"p \<in> formula
\<Longrightarrow> arity(incr_bv1(p)) =
(if 1 < arity(p) then succ(arity(p)) else arity(p))"
apply (insert arity_incr_bv_lemma [of p 1])
apply (simp add: incr_bv1_def)
done
lemma arity_iterates_incr_bv1_eq:
"\<lbrakk>p \<in> formula; n \<in> nat\<rbrakk>
\<Longrightarrow> arity(incr_bv1^n(p)) =
(if 1 < arity(p) then n #+ arity(p) else arity(p))"
apply (induct_tac n)
apply (simp_all add: arity_incr_bv1_eq)
apply (simp add: not_lt_iff_le)
apply (blast intro: le_trans add_le_self2 arity_type)
done
subsection\<open>Definable Powerset\<close>
text\<open>The definable powerset operation: Kunen's definition VI 1.1, page 165.\<close>
definition
DPow :: "i \<Rightarrow> i" where
"DPow(A) \<equiv> {X \<in> Pow(A).
\<exists>env \<in> list(A). \<exists>p \<in> formula.
arity(p) \<le> succ(length(env)) \<and>
X = {x\<in>A. sats(A, p, Cons(x,env))}}"
lemma DPowI:
"\<lbrakk>env \<in> list(A); p \<in> formula; arity(p) \<le> succ(length(env))\<rbrakk>
\<Longrightarrow> {x\<in>A. sats(A, p, Cons(x,env))} \<in> DPow(A)"
by (simp add: DPow_def, blast)
text\<open>With this rule we can specify \<^term>\<open>p\<close> later.\<close>
lemma DPowI2 [rule_format]:
"\<lbrakk>\<forall>x\<in>A. P(x) \<longleftrightarrow> sats(A, p, Cons(x,env));
env \<in> list(A); p \<in> formula; arity(p) \<le> succ(length(env))\<rbrakk>
\<Longrightarrow> {x\<in>A. P(x)} \<in> DPow(A)"
by (simp add: DPow_def, blast)
lemma DPowD:
"X \<in> DPow(A)
\<Longrightarrow> X \<subseteq> A \<and>
(\<exists>env \<in> list(A).
\<exists>p \<in> formula. arity(p) \<le> succ(length(env)) \<and>
X = {x\<in>A. sats(A, p, Cons(x,env))})"
by (simp add: DPow_def)
lemmas DPow_imp_subset = DPowD [THEN conjunct1]
(*Kunen's Lemma VI 1.2*)
lemma "\<lbrakk>p \<in> formula; env \<in> list(A); arity(p) \<le> succ(length(env))\<rbrakk>
\<Longrightarrow> {x\<in>A. sats(A, p, Cons(x,env))} \<in> DPow(A)"
by (blast intro: DPowI)
lemma DPow_subset_Pow: "DPow(A) \<subseteq> Pow(A)"
by (simp add: DPow_def, blast)
lemma empty_in_DPow: "0 \<in> DPow(A)"
apply (simp add: DPow_def)
apply (rule_tac x=Nil in bexI)
apply (rule_tac x="Neg(Equal(0,0))" in bexI)
apply (auto simp add: Un_least_lt_iff)
done
lemma Compl_in_DPow: "X \<in> DPow(A) \<Longrightarrow> (A-X) \<in> DPow(A)"
apply (simp add: DPow_def, clarify, auto)
apply (rule bexI)
apply (rule_tac x="Neg(p)" in bexI)
apply auto
done
lemma Int_in_DPow: "\<lbrakk>X \<in> DPow(A); Y \<in> DPow(A)\<rbrakk> \<Longrightarrow> X \<inter> Y \<in> DPow(A)"
apply (simp add: DPow_def, auto)
apply (rename_tac envp p envq q)
apply (rule_tac x="envp@envq" in bexI)
apply (rule_tac x="And(p, iterates(incr_bv1,length(envp),q))" in bexI)
apply typecheck
apply (rule conjI)
(*finally check the arity!*)
apply (simp add: arity_iterates_incr_bv1_eq Un_least_lt_iff)
apply (force intro: add_le_self le_trans)
apply (simp add: arity_sats1_iff formula_add_params1, blast)
done
lemma Un_in_DPow: "\<lbrakk>X \<in> DPow(A); Y \<in> DPow(A)\<rbrakk> \<Longrightarrow> X \<union> Y \<in> DPow(A)"
apply (subgoal_tac "X \<union> Y = A - ((A-X) \<inter> (A-Y))")
apply (simp add: Int_in_DPow Compl_in_DPow)
apply (simp add: DPow_def, blast)
done
lemma singleton_in_DPow: "a \<in> A \<Longrightarrow> {a} \<in> DPow(A)"
apply (simp add: DPow_def)
apply (rule_tac x="Cons(a,Nil)" in bexI)
apply (rule_tac x="Equal(0,1)" in bexI)
apply typecheck
apply (force simp add: succ_Un_distrib [symmetric])
done
lemma cons_in_DPow: "\<lbrakk>a \<in> A; X \<in> DPow(A)\<rbrakk> \<Longrightarrow> cons(a,X) \<in> DPow(A)"
apply (rule cons_eq [THEN subst])
apply (blast intro: singleton_in_DPow Un_in_DPow)
done
(*Part of Lemma 1.3*)
lemma Fin_into_DPow: "X \<in> Fin(A) \<Longrightarrow> X \<in> DPow(A)"
apply (erule Fin.induct)
apply (rule empty_in_DPow)
apply (blast intro: cons_in_DPow)
done
text\<open>\<^term>\<open>DPow\<close> is not monotonic. For example, let \<^term>\<open>A\<close> be some
non-constructible set of natural numbers, and let \<^term>\<open>B\<close> be \<^term>\<open>nat\<close>.
Then \<^term>\<open>A<=B\<close> and obviously \<^term>\<open>A \<in> DPow(A)\<close> but \<^term>\<open>A \<notin>
DPow(B)\<close>.\<close>
(*This may be true but the proof looks difficult, requiring relativization
lemma DPow_insert: "DPow (cons(a,A)) = DPow(A) \<union> {cons(a,X) . X \<in> DPow(A)}"
apply (rule equalityI, safe)
oops
*)
lemma Finite_Pow_subset_Pow: "Finite(A) \<Longrightarrow> Pow(A) \<subseteq> DPow(A)"
by (blast intro: Fin_into_DPow Finite_into_Fin Fin_subset)
lemma Finite_DPow_eq_Pow: "Finite(A) \<Longrightarrow> DPow(A) = Pow(A)"
apply (rule equalityI)
apply (rule DPow_subset_Pow)
apply (erule Finite_Pow_subset_Pow)
done
subsection\<open>Internalized Formulas for the Ordinals\<close>
text\<open>The \<open>sats\<close> theorems below differ from the usual form in that they
include an element of absoluteness. That is, they relate internalized
formulas to real concepts such as the subset relation, rather than to the
relativized concepts defined in theory \<open>Relative\<close>. This lets us prove
the theorem as \<open>Ords_in_DPow\<close> without first having to instantiate the
locale \<open>M_trivial\<close>. Note that the present theory does not even take
\<open>Relative\<close> as a parent.\<close>
subsubsection\<open>The subset relation\<close>
definition
subset_fm :: "[i,i]\<Rightarrow>i" where
"subset_fm(x,y) \<equiv> Forall(Implies(Member(0,succ(x)), Member(0,succ(y))))"
lemma subset_type [TC]: "\<lbrakk>x \<in> nat; y \<in> nat\<rbrakk> \<Longrightarrow> subset_fm(x,y) \<in> formula"
by (simp add: subset_fm_def)
lemma arity_subset_fm [simp]:
"\<lbrakk>x \<in> nat; y \<in> nat\<rbrakk> \<Longrightarrow> arity(subset_fm(x,y)) = succ(x) \<union> succ(y)"
by (simp add: subset_fm_def succ_Un_distrib [symmetric])
lemma sats_subset_fm [simp]:
"\<lbrakk>x < length(env); y \<in> nat; env \<in> list(A); Transset(A)\<rbrakk>
\<Longrightarrow> sats(A, subset_fm(x,y), env) \<longleftrightarrow> nth(x,env) \<subseteq> nth(y,env)"
apply (frule lt_length_in_nat, assumption)
apply (simp add: subset_fm_def Transset_def)
apply (blast intro: nth_type)
done
subsubsection\<open>Transitive sets\<close>
definition
transset_fm :: "i\<Rightarrow>i" where
"transset_fm(x) \<equiv> Forall(Implies(Member(0,succ(x)), subset_fm(0,succ(x))))"
lemma transset_type [TC]: "x \<in> nat \<Longrightarrow> transset_fm(x) \<in> formula"
by (simp add: transset_fm_def)
lemma arity_transset_fm [simp]:
"x \<in> nat \<Longrightarrow> arity(transset_fm(x)) = succ(x)"
by (simp add: transset_fm_def succ_Un_distrib [symmetric])
lemma sats_transset_fm [simp]:
"\<lbrakk>x < length(env); env \<in> list(A); Transset(A)\<rbrakk>
\<Longrightarrow> sats(A, transset_fm(x), env) \<longleftrightarrow> Transset(nth(x,env))"
apply (frule lt_nat_in_nat, erule length_type)
apply (simp add: transset_fm_def Transset_def)
apply (blast intro: nth_type)
done
subsubsection\<open>Ordinals\<close>
definition
ordinal_fm :: "i\<Rightarrow>i" where
"ordinal_fm(x) \<equiv>
And(transset_fm(x), Forall(Implies(Member(0,succ(x)), transset_fm(0))))"
lemma ordinal_type [TC]: "x \<in> nat \<Longrightarrow> ordinal_fm(x) \<in> formula"
by (simp add: ordinal_fm_def)
lemma arity_ordinal_fm [simp]:
"x \<in> nat \<Longrightarrow> arity(ordinal_fm(x)) = succ(x)"
by (simp add: ordinal_fm_def succ_Un_distrib [symmetric])
lemma sats_ordinal_fm:
"\<lbrakk>x < length(env); env \<in> list(A); Transset(A)\<rbrakk>
\<Longrightarrow> sats(A, ordinal_fm(x), env) \<longleftrightarrow> Ord(nth(x,env))"
apply (frule lt_nat_in_nat, erule length_type)
apply (simp add: ordinal_fm_def Ord_def Transset_def)
apply (blast intro: nth_type)
done
text\<open>The subset consisting of the ordinals is definable. Essential lemma for
\<open>Ord_in_Lset\<close>. This result is the objective of the present subsection.\<close>
theorem Ords_in_DPow: "Transset(A) \<Longrightarrow> {x \<in> A. Ord(x)} \<in> DPow(A)"
apply (simp add: DPow_def Collect_subset)
apply (rule_tac x=Nil in bexI)
apply (rule_tac x="ordinal_fm(0)" in bexI)
apply (simp_all add: sats_ordinal_fm)
done
subsection\<open>Constant Lset: Levels of the Constructible Universe\<close>
definition
Lset :: "i\<Rightarrow>i" where
"Lset(i) \<equiv> transrec(i, \<lambda>x f. \<Union>y\<in>x. DPow(f`y))"
definition
L :: "i\<Rightarrow>o" where \<comment> \<open>Kunen's definition VI 1.5, page 167\<close>
"L(x) \<equiv> \<exists>i. Ord(i) \<and> x \<in> Lset(i)"
text\<open>NOT SUITABLE FOR REWRITING -- RECURSIVE!\<close>
lemma Lset: "Lset(i) = (\<Union>j\<in>i. DPow(Lset(j)))"
by (subst Lset_def [THEN def_transrec], simp)
lemma LsetI: "\<lbrakk>y\<in>x; A \<in> DPow(Lset(y))\<rbrakk> \<Longrightarrow> A \<in> Lset(x)"
by (subst Lset, blast)
lemma LsetD: "A \<in> Lset(x) \<Longrightarrow> \<exists>y\<in>x. A \<in> DPow(Lset(y))"
apply (insert Lset [of x])
apply (blast intro: elim: equalityE)
done
subsubsection\<open>Transitivity\<close>
lemma elem_subset_in_DPow: "\<lbrakk>X \<in> A; X \<subseteq> A\<rbrakk> \<Longrightarrow> X \<in> DPow(A)"
apply (simp add: Transset_def DPow_def)
apply (rule_tac x="[X]" in bexI)
apply (rule_tac x="Member(0,1)" in bexI)
apply (auto simp add: Un_least_lt_iff)
done
lemma Transset_subset_DPow: "Transset(A) \<Longrightarrow> A \<subseteq> DPow(A)"
apply clarify
apply (simp add: Transset_def)
apply (blast intro: elem_subset_in_DPow)
done
lemma Transset_DPow: "Transset(A) \<Longrightarrow> Transset(DPow(A))"
apply (simp add: Transset_def)
apply (blast intro: elem_subset_in_DPow dest: DPowD)
done
text\<open>Kunen's VI 1.6 (a)\<close>
lemma Transset_Lset: "Transset(Lset(i))"
apply (rule_tac a=i in eps_induct)
apply (subst Lset)
apply (blast intro!: Transset_Union_family Transset_Un Transset_DPow)
done
lemma mem_Lset_imp_subset_Lset: "a \<in> Lset(i) \<Longrightarrow> a \<subseteq> Lset(i)"
apply (insert Transset_Lset)
apply (simp add: Transset_def)
done
subsubsection\<open>Monotonicity\<close>
text\<open>Kunen's VI 1.6 (b)\<close>
lemma Lset_mono [rule_format]:
"\<forall>j. i<=j \<longrightarrow> Lset(i) \<subseteq> Lset(j)"
proof (induct i rule: eps_induct, intro allI impI)
fix x j
assume "\<forall>y\<in>x. \<forall>j. y \<subseteq> j \<longrightarrow> Lset(y) \<subseteq> Lset(j)"
and "x \<subseteq> j"
thus "Lset(x) \<subseteq> Lset(j)"
by (force simp add: Lset [of x] Lset [of j])
qed
text\<open>This version lets us remove the premise \<^term>\<open>Ord(i)\<close> sometimes.\<close>
lemma Lset_mono_mem [rule_format]:
"\<forall>j. i \<in> j \<longrightarrow> Lset(i) \<subseteq> Lset(j)"
proof (induct i rule: eps_induct, intro allI impI)
fix x j
assume "\<forall>y\<in>x. \<forall>j. y \<in> j \<longrightarrow> Lset(y) \<subseteq> Lset(j)"
and "x \<in> j"
thus "Lset(x) \<subseteq> Lset(j)"
by (force simp add: Lset [of j]
intro!: bexI intro: elem_subset_in_DPow dest: LsetD DPowD)
qed
text\<open>Useful with Reflection to bump up the ordinal\<close>
lemma subset_Lset_ltD: "\<lbrakk>A \<subseteq> Lset(i); i < j\<rbrakk> \<Longrightarrow> A \<subseteq> Lset(j)"
by (blast dest: ltD [THEN Lset_mono_mem])
subsubsection\<open>0, successor and limit equations for Lset\<close>
lemma Lset_0 [simp]: "Lset(0) = 0"
by (subst Lset, blast)
lemma Lset_succ_subset1: "DPow(Lset(i)) \<subseteq> Lset(succ(i))"
by (subst Lset, rule succI1 [THEN RepFunI, THEN Union_upper])
lemma Lset_succ_subset2: "Lset(succ(i)) \<subseteq> DPow(Lset(i))"
apply (subst Lset, rule UN_least)
apply (erule succE)
apply blast
apply clarify
apply (rule elem_subset_in_DPow)
apply (subst Lset)
apply blast
apply (blast intro: dest: DPowD Lset_mono_mem)
done
lemma Lset_succ: "Lset(succ(i)) = DPow(Lset(i))"
by (intro equalityI Lset_succ_subset1 Lset_succ_subset2)
lemma Lset_Union [simp]: "Lset(\<Union>(X)) = (\<Union>y\<in>X. Lset(y))"
apply (subst Lset)
apply (rule equalityI)
txt\<open>first inclusion\<close>
apply (rule UN_least)
apply (erule UnionE)
apply (rule subset_trans)
apply (erule_tac [2] UN_upper, subst Lset, erule UN_upper)
txt\<open>opposite inclusion\<close>
apply (rule UN_least)
apply (subst Lset, blast)
done
subsubsection\<open>Lset applied to Limit ordinals\<close>
lemma Limit_Lset_eq:
"Limit(i) \<Longrightarrow> Lset(i) = (\<Union>y\<in>i. Lset(y))"
by (simp add: Lset_Union [symmetric] Limit_Union_eq)
lemma lt_LsetI: "\<lbrakk>a \<in> Lset(j); j<i\<rbrakk> \<Longrightarrow> a \<in> Lset(i)"
by (blast dest: Lset_mono [OF le_imp_subset [OF leI]])
lemma Limit_LsetE:
"\<lbrakk>a \<in> Lset(i); \<not>R \<Longrightarrow> Limit(i);
\<And>x. \<lbrakk>x<i; a \<in> Lset(x)\<rbrakk> \<Longrightarrow> R
\<rbrakk> \<Longrightarrow> R"
apply (rule classical)
apply (rule Limit_Lset_eq [THEN equalityD1, THEN subsetD, THEN UN_E])
prefer 2 apply assumption
apply blast
apply (blast intro: ltI Limit_is_Ord)
done
subsubsection\<open>Basic closure properties\<close>
lemma zero_in_Lset: "y \<in> x \<Longrightarrow> 0 \<in> Lset(x)"
by (subst Lset, blast intro: empty_in_DPow)
lemma notin_Lset: "x \<notin> Lset(x)"
apply (rule_tac a=x in eps_induct)
apply (subst Lset)
apply (blast dest: DPowD)
done
subsection\<open>Constructible Ordinals: Kunen's VI 1.9 (b)\<close>
lemma Ords_of_Lset_eq: "Ord(i) \<Longrightarrow> {x\<in>Lset(i). Ord(x)} = i"
apply (erule trans_induct3)
apply (simp_all add: Lset_succ Limit_Lset_eq Limit_Union_eq)
txt\<open>The successor case remains.\<close>
apply (rule equalityI)
txt\<open>First inclusion\<close>
apply clarify
apply (erule Ord_linear_lt, assumption)
apply (blast dest: DPow_imp_subset ltD notE [OF notin_Lset])
apply blast
apply (blast dest: ltD)
txt\<open>Opposite inclusion, \<^term>\<open>succ(x) \<subseteq> DPow(Lset(x)) \<inter> ON\<close>\<close>
apply auto
txt\<open>Key case:\<close>
apply (erule subst, rule Ords_in_DPow [OF Transset_Lset])
apply (blast intro: elem_subset_in_DPow dest: OrdmemD elim: equalityE)
apply (blast intro: Ord_in_Ord)
done
lemma Ord_subset_Lset: "Ord(i) \<Longrightarrow> i \<subseteq> Lset(i)"
by (subst Ords_of_Lset_eq [symmetric], assumption, fast)
lemma Ord_in_Lset: "Ord(i) \<Longrightarrow> i \<in> Lset(succ(i))"
apply (simp add: Lset_succ)
apply (subst Ords_of_Lset_eq [symmetric], assumption,
rule Ords_in_DPow [OF Transset_Lset])
done
lemma Ord_in_L: "Ord(i) \<Longrightarrow> L(i)"
by (simp add: L_def, blast intro: Ord_in_Lset)
subsubsection\<open>Unions\<close>
lemma Union_in_Lset:
"X \<in> Lset(i) \<Longrightarrow> \<Union>(X) \<in> Lset(succ(i))"
apply (insert Transset_Lset)
apply (rule LsetI [OF succI1])
apply (simp add: Transset_def DPow_def)
apply (intro conjI, blast)
txt\<open>Now to create the formula \<^term>\<open>\<exists>y. y \<in> X \<and> x \<in> y\<close>\<close>
apply (rule_tac x="Cons(X,Nil)" in bexI)
apply (rule_tac x="Exists(And(Member(0,2), Member(1,0)))" in bexI)
apply typecheck
apply (simp add: succ_Un_distrib [symmetric], blast)
done
theorem Union_in_L: "L(X) \<Longrightarrow> L(\<Union>(X))"
by (simp add: L_def, blast dest: Union_in_Lset)
subsubsection\<open>Finite sets and ordered pairs\<close>
lemma singleton_in_Lset: "a \<in> Lset(i) \<Longrightarrow> {a} \<in> Lset(succ(i))"
by (simp add: Lset_succ singleton_in_DPow)
lemma doubleton_in_Lset:
"\<lbrakk>a \<in> Lset(i); b \<in> Lset(i)\<rbrakk> \<Longrightarrow> {a,b} \<in> Lset(succ(i))"
by (simp add: Lset_succ empty_in_DPow cons_in_DPow)
lemma Pair_in_Lset:
"\<lbrakk>a \<in> Lset(i); b \<in> Lset(i); Ord(i)\<rbrakk> \<Longrightarrow> \<langle>a,b\<rangle> \<in> Lset(succ(succ(i)))"
unfolding Pair_def
apply (blast intro: doubleton_in_Lset)
done
lemmas Lset_UnI1 = Un_upper1 [THEN Lset_mono [THEN subsetD]]
lemmas Lset_UnI2 = Un_upper2 [THEN Lset_mono [THEN subsetD]]
text\<open>Hard work is finding a single \<^term>\<open>j \<in> i\<close> such that \<^term>\<open>{a,b} \<subseteq> Lset(j)\<close>\<close>
lemma doubleton_in_LLimit:
"\<lbrakk>a \<in> Lset(i); b \<in> Lset(i); Limit(i)\<rbrakk> \<Longrightarrow> {a,b} \<in> Lset(i)"
apply (erule Limit_LsetE, assumption)
apply (erule Limit_LsetE, assumption)
apply (blast intro: lt_LsetI [OF doubleton_in_Lset]
Lset_UnI1 Lset_UnI2 Limit_has_succ Un_least_lt)
done
theorem doubleton_in_L: "\<lbrakk>L(a); L(b)\<rbrakk> \<Longrightarrow> L({a, b})"
apply (simp add: L_def, clarify)
apply (drule Ord2_imp_greater_Limit, assumption)
apply (blast intro: lt_LsetI doubleton_in_LLimit Limit_is_Ord)
done
lemma Pair_in_LLimit:
"\<lbrakk>a \<in> Lset(i); b \<in> Lset(i); Limit(i)\<rbrakk> \<Longrightarrow> \<langle>a,b\<rangle> \<in> Lset(i)"
txt\<open>Infer that a, b occur at ordinals x,xa < i.\<close>
apply (erule Limit_LsetE, assumption)
apply (erule Limit_LsetE, assumption)
txt\<open>Infer that \<^term>\<open>succ(succ(x \<union> xa)) < i\<close>\<close>
apply (blast intro: lt_Ord lt_LsetI [OF Pair_in_Lset]
Lset_UnI1 Lset_UnI2 Limit_has_succ Un_least_lt)
done
text\<open>The rank function for the constructible universe\<close>
definition
lrank :: "i\<Rightarrow>i" where \<comment> \<open>Kunen's definition VI 1.7\<close>
"lrank(x) \<equiv> \<mu> i. x \<in> Lset(succ(i))"
lemma L_I: "\<lbrakk>x \<in> Lset(i); Ord(i)\<rbrakk> \<Longrightarrow> L(x)"
by (simp add: L_def, blast)
lemma L_D: "L(x) \<Longrightarrow> \<exists>i. Ord(i) \<and> x \<in> Lset(i)"
by (simp add: L_def)
lemma Ord_lrank [simp]: "Ord(lrank(a))"
by (simp add: lrank_def)
lemma Lset_lrank_lt [rule_format]: "Ord(i) \<Longrightarrow> x \<in> Lset(i) \<longrightarrow> lrank(x) < i"
apply (erule trans_induct3)
apply simp
apply (simp only: lrank_def)
apply (blast intro: Least_le)
apply (simp_all add: Limit_Lset_eq)
apply (blast intro: ltI Limit_is_Ord lt_trans)
done
text\<open>Kunen's VI 1.8. The proof is much harder than the text would
suggest. For a start, it needs the previous lemma, which is proved by
induction.\<close>
lemma Lset_iff_lrank_lt: "Ord(i) \<Longrightarrow> x \<in> Lset(i) \<longleftrightarrow> L(x) \<and> lrank(x) < i"
apply (simp add: L_def, auto)
apply (blast intro: Lset_lrank_lt)
unfolding lrank_def
apply (drule succI1 [THEN Lset_mono_mem, THEN subsetD])
apply (drule_tac P="\<lambda>i. x \<in> Lset(succ(i))" in LeastI, assumption)
apply (blast intro!: le_imp_subset Lset_mono [THEN subsetD])
done
lemma Lset_succ_lrank_iff [simp]: "x \<in> Lset(succ(lrank(x))) \<longleftrightarrow> L(x)"
by (simp add: Lset_iff_lrank_lt)
text\<open>Kunen's VI 1.9 (a)\<close>
lemma lrank_of_Ord: "Ord(i) \<Longrightarrow> lrank(i) = i"
unfolding lrank_def
apply (rule Least_equality)
apply (erule Ord_in_Lset)
apply assumption
apply (insert notin_Lset [of i])
apply (blast intro!: le_imp_subset Lset_mono [THEN subsetD])
done
text\<open>This is lrank(lrank(a)) = lrank(a)\<close>
declare Ord_lrank [THEN lrank_of_Ord, simp]
text\<open>Kunen's VI 1.10\<close>
lemma Lset_in_Lset_succ: "Lset(i) \<in> Lset(succ(i))"
apply (simp add: Lset_succ DPow_def)
apply (rule_tac x=Nil in bexI)
apply (rule_tac x="Equal(0,0)" in bexI)
apply auto
done
lemma lrank_Lset: "Ord(i) \<Longrightarrow> lrank(Lset(i)) = i"
unfolding lrank_def
apply (rule Least_equality)
apply (rule Lset_in_Lset_succ)
apply assumption
apply clarify
apply (subgoal_tac "Lset(succ(ia)) \<subseteq> Lset(i)")
apply (blast dest: mem_irrefl)
apply (blast intro!: le_imp_subset Lset_mono)
done
text\<open>Kunen's VI 1.11\<close>
lemma Lset_subset_Vset: "Ord(i) \<Longrightarrow> Lset(i) \<subseteq> Vset(i)"
apply (erule trans_induct)
apply (subst Lset)
apply (subst Vset)
apply (rule UN_mono [OF subset_refl])
apply (rule subset_trans [OF DPow_subset_Pow])
apply (rule Pow_mono, blast)
done
text\<open>Kunen's VI 1.12\<close>
lemma Lset_subset_Vset': "i \<in> nat \<Longrightarrow> Lset(i) = Vset(i)"
apply (erule nat_induct)
apply (simp add: Vfrom_0)
apply (simp add: Lset_succ Vset_succ Finite_Vset Finite_DPow_eq_Pow)
done
text\<open>Every set of constructible sets is included in some \<^term>\<open>Lset\<close>\<close>
lemma subset_Lset:
"(\<forall>x\<in>A. L(x)) \<Longrightarrow> \<exists>i. Ord(i) \<and> A \<subseteq> Lset(i)"
by (rule_tac x = "\<Union>x\<in>A. succ(lrank(x))" in exI, force)
lemma subset_LsetE:
"\<lbrakk>\<forall>x\<in>A. L(x);
\<And>i. \<lbrakk>Ord(i); A \<subseteq> Lset(i)\<rbrakk> \<Longrightarrow> P\<rbrakk>
\<Longrightarrow> P"
by (blast dest: subset_Lset)
subsubsection\<open>For L to satisfy the Powerset axiom\<close>
lemma LPow_env_typing:
"\<lbrakk>y \<in> Lset(i); Ord(i); y \<subseteq> X\<rbrakk>
\<Longrightarrow> \<exists>z \<in> Pow(X). y \<in> Lset(succ(lrank(z)))"
by (auto intro: L_I iff: Lset_succ_lrank_iff)
lemma LPow_in_Lset:
"\<lbrakk>X \<in> Lset(i); Ord(i)\<rbrakk> \<Longrightarrow> \<exists>j. Ord(j) \<and> {y \<in> Pow(X). L(y)} \<in> Lset(j)"
apply (rule_tac x="succ(\<Union>y \<in> Pow(X). succ(lrank(y)))" in exI)
apply simp
apply (rule LsetI [OF succI1])
apply (simp add: DPow_def)
apply (intro conjI, clarify)
apply (rule_tac a=x in UN_I, simp+)
txt\<open>Now to create the formula \<^term>\<open>y \<subseteq> X\<close>\<close>
apply (rule_tac x="Cons(X,Nil)" in bexI)
apply (rule_tac x="subset_fm(0,1)" in bexI)
apply typecheck
apply (rule conjI)
apply (simp add: succ_Un_distrib [symmetric])
apply (rule equality_iffI)
apply (simp add: Transset_UN [OF Transset_Lset] LPow_env_typing)
apply (auto intro: L_I iff: Lset_succ_lrank_iff)
done
theorem LPow_in_L: "L(X) \<Longrightarrow> L({y \<in> Pow(X). L(y)})"
by (blast intro: L_I dest: L_D LPow_in_Lset)
subsection\<open>Eliminating \<^term>\<open>arity\<close> from the Definition of \<^term>\<open>Lset\<close>\<close>
lemma nth_zero_eq_0: "n \<in> nat \<Longrightarrow> nth(n,[0]) = 0"
by (induct_tac n, auto)
lemma sats_app_0_iff [rule_format]:
"\<lbrakk>p \<in> formula; 0 \<in> A\<rbrakk>
\<Longrightarrow> \<forall>env \<in> list(A). sats(A,p, env@[0]) \<longleftrightarrow> sats(A,p,env)"
apply (induct_tac p)
apply (simp_all del: app_Cons add: app_Cons [symmetric]
add: nth_zero_eq_0 nth_append not_lt_iff_le nth_eq_0)
done
lemma sats_app_zeroes_iff:
"\<lbrakk>p \<in> formula; 0 \<in> A; env \<in> list(A); n \<in> nat\<rbrakk>
\<Longrightarrow> sats(A,p,env @ repeat(0,n)) \<longleftrightarrow> sats(A,p,env)"
apply (induct_tac n, simp)
apply (simp del: repeat.simps
add: repeat_succ_app sats_app_0_iff app_assoc [symmetric])
done
lemma exists_bigger_env:
"\<lbrakk>p \<in> formula; 0 \<in> A; env \<in> list(A)\<rbrakk>
\<Longrightarrow> \<exists>env' \<in> list(A). arity(p) \<le> succ(length(env')) \<and>
(\<forall>a\<in>A. sats(A,p,Cons(a,env')) \<longleftrightarrow> sats(A,p,Cons(a,env)))"
apply (rule_tac x="env @ repeat(0,arity(p))" in bexI)
apply (simp del: app_Cons add: app_Cons [symmetric]
add: length_repeat sats_app_zeroes_iff, typecheck)
done
text\<open>A simpler version of \<^term>\<open>DPow\<close>: no arity check!\<close>
definition
DPow' :: "i \<Rightarrow> i" where
"DPow'(A) \<equiv> {X \<in> Pow(A).
\<exists>env \<in> list(A). \<exists>p \<in> formula.
X = {x\<in>A. sats(A, p, Cons(x,env))}}"
lemma DPow_subset_DPow': "DPow(A) \<subseteq> DPow'(A)"
by (simp add: DPow_def DPow'_def, blast)
lemma DPow'_0: "DPow'(0) = {0}"
by (auto simp add: DPow'_def)
lemma DPow'_subset_DPow: "0 \<in> A \<Longrightarrow> DPow'(A) \<subseteq> DPow(A)"
apply (auto simp add: DPow'_def DPow_def)
apply (frule exists_bigger_env, assumption+, force)
done
lemma DPow_eq_DPow': "Transset(A) \<Longrightarrow> DPow(A) = DPow'(A)"
apply (drule Transset_0_disj)
apply (erule disjE)
apply (simp add: DPow'_0 Finite_DPow_eq_Pow)
apply (rule equalityI)
apply (rule DPow_subset_DPow')
apply (erule DPow'_subset_DPow)
done
text\<open>And thus we can relativize \<^term>\<open>Lset\<close> without bothering with
\<^term>\<open>arity\<close> and \<^term>\<open>length\<close>\<close>
lemma Lset_eq_transrec_DPow': "Lset(i) = transrec(i, \<lambda>x f. \<Union>y\<in>x. DPow'(f`y))"
apply (rule_tac a=i in eps_induct)
apply (subst Lset)
apply (subst transrec)
apply (simp only: DPow_eq_DPow' [OF Transset_Lset], simp)
done
text\<open>With this rule we can specify \<^term>\<open>p\<close> later and don't worry about
arities at all!\<close>
lemma DPow_LsetI [rule_format]:
"\<lbrakk>\<forall>x\<in>Lset(i). P(x) \<longleftrightarrow> sats(Lset(i), p, Cons(x,env));
env \<in> list(Lset(i)); p \<in> formula\<rbrakk>
\<Longrightarrow> {x\<in>Lset(i). P(x)} \<in> DPow(Lset(i))"
by (simp add: DPow_eq_DPow' [OF Transset_Lset] DPow'_def, blast)
end
|
State Before: R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p : R[X]
hp : 0 < natTrailingDegree p
⊢ nextCoeffUp p = coeff p (natTrailingDegree p + 1) State After: case hnc
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p : R[X]
hp : 0 < natTrailingDegree p
⊢ ¬natTrailingDegree p = 0 Tactic: rw [nextCoeffUp, if_neg] State Before: case hnc
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p : R[X]
hp : 0 < natTrailingDegree p
⊢ ¬natTrailingDegree p = 0 State After: case hnc
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p : R[X]
hp : natTrailingDegree p = 0
⊢ natTrailingDegree p ≤ 0 Tactic: contrapose! hp State Before: case hnc
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p : R[X]
hp : natTrailingDegree p = 0
⊢ natTrailingDegree p ≤ 0 State After: no goals Tactic: simpa |
[GOAL]
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
⊢ Subobject X ≃o (Subobject (op X))ᵒᵈ
[PROOFSTEP]
refine' OrderIso.ofHomInv (cokernelOrderHom X) (kernelOrderHom X) _ _
[GOAL]
case refine'_1
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
⊢ OrderHom.comp ↑(cokernelOrderHom X) ↑(kernelOrderHom X) = OrderHom.id
[PROOFSTEP]
change (cokernelOrderHom X).comp (kernelOrderHom X) = _
[GOAL]
case refine'_1
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
⊢ OrderHom.comp (cokernelOrderHom X) (kernelOrderHom X) = OrderHom.id
[PROOFSTEP]
refine' OrderHom.ext _ _ (funext (Subobject.ind _ _))
[GOAL]
case refine'_1
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
⊢ ∀ ⦃A : Cᵒᵖ⦄ (f : A ⟶ op X) [inst : Mono f],
↑(OrderHom.comp (cokernelOrderHom X) (kernelOrderHom X)) (Subobject.mk f) = ↑OrderHom.id (Subobject.mk f)
[PROOFSTEP]
intro A f hf
[GOAL]
case refine'_1
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ ↑(OrderHom.comp (cokernelOrderHom X) (kernelOrderHom X)) (Subobject.mk f) = ↑OrderHom.id (Subobject.mk f)
[PROOFSTEP]
dsimp only [OrderHom.comp_coe, Function.comp_apply, kernelOrderHom_coe, Subobject.lift_mk, cokernelOrderHom_coe,
OrderHom.id_coe, id.def]
[GOAL]
case refine'_1
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ Subobject.mk (cokernel.π (kernel.ι f.unop)).op = Subobject.mk f
[PROOFSTEP]
refine' Subobject.mk_eq_mk_of_comm _ _ ⟨_, _, Quiver.Hom.unop_inj _, Quiver.Hom.unop_inj _⟩ _
[GOAL]
case refine'_1.refine'_1
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ op (cokernel (kernel.ι f.unop)) ⟶ A
[PROOFSTEP]
exact (Abelian.epiDesc f.unop _ (cokernel.condition (kernel.ι f.unop))).op
[GOAL]
case refine'_1.refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ A ⟶ op (cokernel (kernel.ι f.unop))
[PROOFSTEP]
exact (cokernel.desc _ _ (kernel.condition f.unop)).op
[GOAL]
case refine'_1.refine'_3
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ ((epiDesc f.unop (cokernel.π (kernel.ι f.unop)) (_ : kernel.ι f.unop ≫ cokernel.π (kernel.ι f.unop) = 0)).op ≫
(cokernel.desc (kernel.ι f.unop) f.unop (_ : kernel.ι f.unop ≫ f.unop = 0)).op).unop =
(𝟙 (op (cokernel (kernel.ι f.unop)))).unop
[PROOFSTEP]
rw [← cancel_epi (cokernel.π (kernel.ι f.unop))]
[GOAL]
case refine'_1.refine'_3
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ cokernel.π (kernel.ι f.unop) ≫
((epiDesc f.unop (cokernel.π (kernel.ι f.unop)) (_ : kernel.ι f.unop ≫ cokernel.π (kernel.ι f.unop) = 0)).op ≫
(cokernel.desc (kernel.ι f.unop) f.unop (_ : kernel.ι f.unop ≫ f.unop = 0)).op).unop =
cokernel.π (kernel.ι f.unop) ≫ (𝟙 (op (cokernel (kernel.ι f.unop)))).unop
[PROOFSTEP]
simp only [unop_comp, Quiver.Hom.unop_op, unop_id_op, cokernel.π_desc_assoc, comp_epiDesc, Category.comp_id]
[GOAL]
case refine'_1.refine'_4
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ ((cokernel.desc (kernel.ι f.unop) f.unop (_ : kernel.ι f.unop ≫ f.unop = 0)).op ≫
(epiDesc f.unop (cokernel.π (kernel.ι f.unop))
(_ : kernel.ι f.unop ≫ cokernel.π (kernel.ι f.unop) = 0)).op).unop =
(𝟙 A).unop
[PROOFSTEP]
simp only [← cancel_epi f.unop, unop_comp, Quiver.Hom.unop_op, unop_id, comp_epiDesc_assoc, cokernel.π_desc,
Category.comp_id]
[GOAL]
case refine'_1.refine'_5
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ (Iso.mk (epiDesc f.unop (cokernel.π (kernel.ι f.unop)) (_ : kernel.ι f.unop ≫ cokernel.π (kernel.ι f.unop) = 0)).op
(cokernel.desc (kernel.ι f.unop) f.unop (_ : kernel.ι f.unop ≫ f.unop = 0)).op).hom ≫
f =
(cokernel.π (kernel.ι f.unop)).op
[PROOFSTEP]
exact Quiver.Hom.unop_inj (by simp only [unop_comp, Quiver.Hom.unop_op, comp_epiDesc])
[GOAL]
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
A : Cᵒᵖ
f : A ⟶ op X
hf : Mono f
⊢ ((Iso.mk (epiDesc f.unop (cokernel.π (kernel.ι f.unop)) (_ : kernel.ι f.unop ≫ cokernel.π (kernel.ι f.unop) = 0)).op
(cokernel.desc (kernel.ι f.unop) f.unop (_ : kernel.ι f.unop ≫ f.unop = 0)).op).hom ≫
f).unop =
(cokernel.π (kernel.ι f.unop)).op.unop
[PROOFSTEP]
simp only [unop_comp, Quiver.Hom.unop_op, comp_epiDesc]
[GOAL]
case refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
⊢ OrderHom.comp ↑(kernelOrderHom X) ↑(cokernelOrderHom X) = OrderHom.id
[PROOFSTEP]
change (kernelOrderHom X).comp (cokernelOrderHom X) = _
[GOAL]
case refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
⊢ OrderHom.comp (kernelOrderHom X) (cokernelOrderHom X) = OrderHom.id
[PROOFSTEP]
refine' OrderHom.ext _ _ (funext (Subobject.ind _ _))
[GOAL]
case refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X : C
⊢ ∀ ⦃A : C⦄ (f : A ⟶ X) [inst : Mono f],
↑(OrderHom.comp (kernelOrderHom X) (cokernelOrderHom X)) (Subobject.mk f) = ↑OrderHom.id (Subobject.mk f)
[PROOFSTEP]
intro A f hf
[GOAL]
case refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X A : C
f : A ⟶ X
hf : Mono f
⊢ ↑(OrderHom.comp (kernelOrderHom X) (cokernelOrderHom X)) (Subobject.mk f) = ↑OrderHom.id (Subobject.mk f)
[PROOFSTEP]
dsimp only [OrderHom.comp_coe, Function.comp_apply, cokernelOrderHom_coe, Subobject.lift_mk, kernelOrderHom_coe,
OrderHom.id_coe, id.def, unop_op, Quiver.Hom.unop_op]
[GOAL]
case refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X A : C
f : A ⟶ X
hf : Mono f
⊢ Subobject.mk (kernel.ι (cokernel.π f)) = Subobject.mk f
[PROOFSTEP]
refine' Subobject.mk_eq_mk_of_comm _ _ ⟨_, _, _, _⟩ _
[GOAL]
case refine'_2.refine'_1
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X A : C
f : A ⟶ X
hf : Mono f
⊢ kernel (cokernel.π f) ⟶ A
[PROOFSTEP]
exact Abelian.monoLift f _ (kernel.condition (cokernel.π f))
[GOAL]
case refine'_2.refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X A : C
f : A ⟶ X
hf : Mono f
⊢ A ⟶ kernel (cokernel.π f)
[PROOFSTEP]
exact kernel.lift _ _ (cokernel.condition f)
[GOAL]
case refine'_2.refine'_3
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X A : C
f : A ⟶ X
hf : Mono f
⊢ monoLift f (kernel.ι (cokernel.π f)) (_ : kernel.ι (cokernel.π f) ≫ cokernel.π f = 0) ≫
kernel.lift (cokernel.π f) f (_ : f ≫ cokernel.π f = 0) =
𝟙 (kernel (cokernel.π f))
[PROOFSTEP]
simp only [← cancel_mono (kernel.ι (cokernel.π f)), Category.assoc, image.fac, monoLift_comp, Category.id_comp]
[GOAL]
case refine'_2.refine'_4
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X A : C
f : A ⟶ X
hf : Mono f
⊢ kernel.lift (cokernel.π f) f (_ : f ≫ cokernel.π f = 0) ≫
monoLift f (kernel.ι (cokernel.π f)) (_ : kernel.ι (cokernel.π f) ≫ cokernel.π f = 0) =
𝟙 A
[PROOFSTEP]
simp only [← cancel_mono f, Category.assoc, monoLift_comp, image.fac, Category.id_comp]
[GOAL]
case refine'_2.refine'_5
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Abelian C
X A : C
f : A ⟶ X
hf : Mono f
⊢ (Iso.mk (monoLift f (kernel.ι (cokernel.π f)) (_ : kernel.ι (cokernel.π f) ≫ cokernel.π f = 0))
(kernel.lift (cokernel.π f) f (_ : f ≫ cokernel.π f = 0))).hom ≫
f =
kernel.ι (cokernel.π f)
[PROOFSTEP]
simp only [monoLift_comp]
|
#' fmlref
#'
#' @description
#' A reference implementation of the fmlr API. The implementation only uses base
#' R functions.
#'
#' @docType package
#' @name fmlref-package
#' @author Drew Schmidt
#' @keywords package
NULL
|
/-
Copyright (c) 2022 Antoine Labelle. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Labelle
-/
import category_theory.monoidal.braided
import category_theory.monoidal.linear
import category_theory.preadditive.additive_functor
import category_theory.linear.linear_functor
import category_theory.closed.monoidal
/-!
# Full monoidal subcategories
Given a monidal category `C` and a monoidal predicate on `C`, that is a function `P : C → Prop`
closed under `𝟙_` and `⊗`, we can put a monoidal structure on `{X : C // P X}` (the category
structure is defined in `category_theory.full_subcategory`).
When `C` is also braided/symmetric, the full monoidal subcategory also inherits the
braided/symmetric structure.
## TODO
* Add monoidal/braided versions of `category_theory.full_subcategory.lift`
-/
universes u v
namespace category_theory
namespace monoidal_category
open iso
variables {C : Type u} [category.{v} C] [monoidal_category C] (P : C → Prop)
/--
A property `C → Prop` is a monoidal predicate if it is closed under `𝟙_` and `⊗`.
-/
class monoidal_predicate : Prop :=
(prop_id' : P (𝟙_ C) . obviously)
(prop_tensor' : ∀ {X Y}, P X → P Y → P (X ⊗ Y) . obviously)
restate_axiom monoidal_predicate.prop_id'
restate_axiom monoidal_predicate.prop_tensor'
open monoidal_predicate
variables [monoidal_predicate P]
/--
When `P` is a monoidal predicate, the full subcategory for `P` inherits the monoidal structure of
`C`.
-/
instance full_monoidal_subcategory : monoidal_category (full_subcategory P) :=
{ tensor_obj := λ X Y, ⟨X.1 ⊗ Y.1, prop_tensor X.2 Y.2⟩,
tensor_hom := λ X₁ Y₁ X₂ Y₂ f g, by { change X₁.1 ⊗ X₂.1 ⟶ Y₁.1 ⊗ Y₂.1,
change X₁.1 ⟶ Y₁.1 at f, change X₂.1 ⟶ Y₂.1 at g, exact f ⊗ g },
tensor_unit := ⟨𝟙_ C, prop_id⟩,
associator := λ X Y Z,
⟨(α_ X.1 Y.1 Z.1).hom, (α_ X.1 Y.1 Z.1).inv,
hom_inv_id (α_ X.1 Y.1 Z.1), inv_hom_id (α_ X.1 Y.1 Z.1)⟩,
left_unitor := λ X, ⟨(λ_ X.1).hom, (λ_ X.1).inv, hom_inv_id (λ_ X.1), inv_hom_id (λ_ X.1)⟩,
right_unitor := λ X, ⟨(ρ_ X.1).hom, (ρ_ X.1).inv, hom_inv_id (ρ_ X.1), inv_hom_id (ρ_ X.1)⟩,
tensor_id' := λ X Y, tensor_id X.1 Y.1,
tensor_comp' := λ X₁ Y₁ Z₁ X₂ Y₂ Z₂ f₁ f₂ g₁ g₂, tensor_comp f₁ f₂ g₁ g₂,
associator_naturality' := λ X₁ X₂ X₃ Y₁ Y₂ Y₃ f₁ f₂ f₃, associator_naturality f₁ f₂ f₃,
left_unitor_naturality' := λ X Y f, left_unitor_naturality f,
right_unitor_naturality' := λ X Y f, right_unitor_naturality f,
pentagon' := λ W X Y Z, pentagon W.1 X.1 Y.1 Z.1,
triangle' := λ X Y, triangle X.1 Y.1 }
/--
The forgetful monoidal functor from a full monoidal subcategory into the original category
("forgetting" the condition).
-/
@[simps]
def full_monoidal_subcategory_inclusion : monoidal_functor (full_subcategory P) C :=
{ to_functor := full_subcategory_inclusion P,
ε := 𝟙 _,
μ := λ X Y, 𝟙 _ }
instance full_monoidal_subcategory.full :
full (full_monoidal_subcategory_inclusion P).to_functor := full_subcategory.full P
instance full_monoidal_subcategory.faithful :
faithful (full_monoidal_subcategory_inclusion P).to_functor := full_subcategory.faithful P
section
variables [preadditive C]
instance full_monoidal_subcategory_inclusion_additive :
(full_monoidal_subcategory_inclusion P).to_functor.additive :=
functor.full_subcategory_inclusion_additive _
instance [monoidal_preadditive C] : monoidal_preadditive (full_subcategory P) :=
monoidal_preadditive_of_faithful (full_monoidal_subcategory_inclusion P)
variables (R : Type*) [ring R] [linear R C]
instance full_monoidal_subcategory_inclusion_linear :
(full_monoidal_subcategory_inclusion P).to_functor.linear R :=
functor.full_subcategory_inclusion_linear R _
instance [monoidal_preadditive C] [monoidal_linear R C] : monoidal_linear R (full_subcategory P) :=
monoidal_linear_of_faithful R (full_monoidal_subcategory_inclusion P)
end
variables {P} {P' : C → Prop} [monoidal_predicate P']
/-- An implication of predicates `P → P'` induces a monoidal functor between full monoidal
subcategories. -/
@[simps]
def full_monoidal_subcategory.map (h : ∀ ⦃X⦄, P X → P' X) :
monoidal_functor (full_subcategory P) (full_subcategory P') :=
{ to_functor := full_subcategory.map h,
ε := 𝟙 _,
μ := λ X Y, 𝟙 _ }
instance full_monoidal_subcategory.map_full (h : ∀ ⦃X⦄, P X → P' X) :
full (full_monoidal_subcategory.map h).to_functor := { preimage := λ X Y f, f }
instance full_monoidal_subcategory.map_faithful (h : ∀ ⦃X⦄, P X → P' X) :
faithful (full_monoidal_subcategory.map h).to_functor := {}
section braided
variables (P) [braided_category C]
/--
The braided structure on a full subcategory inherited by the braided structure on `C`.
-/
instance full_braided_subcategory : braided_category (full_subcategory P) :=
braided_category_of_faithful (full_monoidal_subcategory_inclusion P)
(λ X Y, ⟨(β_ X.1 Y.1).hom, (β_ X.1 Y.1).inv, (β_ X.1 Y.1).hom_inv_id, (β_ X.1 Y.1).inv_hom_id⟩)
(λ X Y, by tidy)
/--
The forgetful braided functor from a full braided subcategory into the original category
("forgetting" the condition).
-/
@[simps]
def full_braided_subcategory_inclusion : braided_functor (full_subcategory P) C :=
{ to_monoidal_functor := full_monoidal_subcategory_inclusion P,
braided' := λ X Y, by { rw [is_iso.eq_inv_comp], tidy } }
instance full_braided_subcategory.full :
full (full_braided_subcategory_inclusion P).to_functor := full_monoidal_subcategory.full P
instance full_braided_subcategory.faithful :
faithful (full_braided_subcategory_inclusion P).to_functor := full_monoidal_subcategory.faithful P
variables {P}
/-- An implication of predicates `P → P'` induces a braided functor between full braided
subcategories. -/
@[simps]
def full_braided_subcategory.map (h : ∀ ⦃X⦄, P X → P' X) :
braided_functor (full_subcategory P) (full_subcategory P') :=
{ to_monoidal_functor := full_monoidal_subcategory.map h,
braided' := λ X Y, by { rw [is_iso.eq_inv_comp], tidy } }
instance full_braided_subcategory.map_full (h : ∀ ⦃X⦄, P X → P' X) :
full (full_braided_subcategory.map h).to_functor := full_monoidal_subcategory.map_full h
instance full_braided_subcategory.map_faithful (h : ∀ ⦃X⦄, P X → P' X) :
faithful (full_braided_subcategory.map h).to_functor := full_monoidal_subcategory.map_faithful h
end braided
section symmetric
variables (P) [symmetric_category C]
instance full_symmetric_subcategory : symmetric_category (full_subcategory P) :=
symmetric_category_of_faithful (full_braided_subcategory_inclusion P)
end symmetric
section closed
variables (P) [monoidal_closed C]
/--
A property `C → Prop` is a closed predicate if it is closed under taking internal homs
-/
class closed_predicate : Prop :=
(prop_ihom' : ∀ {X Y}, P X → P Y → P ((ihom X).obj Y) . obviously)
restate_axiom closed_predicate.prop_ihom'
open closed_predicate
variable [closed_predicate P]
instance full_monoidal_closed_subcategory : monoidal_closed (full_subcategory P) :=
{ closed' := λ X,
{ is_adj :=
{ right := full_subcategory.lift P (full_subcategory_inclusion P ⋙ (ihom X.1))
(λ Y, prop_ihom X.2 Y.2),
adj := adjunction.mk_of_unit_counit
{ unit := { app := λ Y, (ihom.coev X.1).app Y.1,
naturality' := λ Y Z f, ihom.coev_naturality X.1 f },
counit := { app := λ Y, (ihom.ev X.1).app Y.1,
naturality' := λ Y Z f, ihom.ev_naturality X.1 f },
left_triangle' := by { ext Y, simp, exact ihom.ev_coev X.1 Y.1 },
right_triangle' := by { ext Y, simp, exact ihom.coev_ev X.1 Y.1 } } } } }
@[simp] lemma full_monoidal_closed_subcategory_ihom_obj (X Y : full_subcategory P) :
((ihom X).obj Y).obj = (ihom (X.obj)).obj Y.obj := rfl
@[simp] lemma full_monoidal_closed_subcategory_ihom_map (X : full_subcategory P)
{Y Z : full_subcategory P}
(f : Y ⟶ Z) : (ihom X).map f = (ihom (X.obj)).map f := rfl
end closed
end monoidal_category
end category_theory
|
{-# OPTIONS --cubical --no-import-sorts #-}
module Cubical.Codata.Stream where
open import Cubical.Codata.Stream.Base public
open import Cubical.Codata.Stream.Properties public
|
lemma small_trans: "f \<in> l F (g) \<Longrightarrow> g \<in> l F (h) \<Longrightarrow> f \<in> l F (h)" |
Subsets and Splits